1 11 12 package org.eclipse.jdt.internal.ui.search; 13 14 import org.eclipse.core.resources.IMarker; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.jdt.internal.ui.JavaPluginImages; 17 import org.eclipse.swt.graphics.Image; 18 19 23 class OccurrencesInFileLabelProvider extends JavaSearchResultLabelProvider { 24 25 public String getText(Object o) { 26 IMarker marker= getMarker(o); 27 try { 28 String text= (String )marker.getAttribute(IMarker.MESSAGE); 29 if (text != null) 30 return text.replace('\t', ' '); 31 } catch (CoreException ex) { 32 return ""; } 34 return super.getText(o); 35 } 36 37 public Image getImage(Object element) { 38 IMarker marker= getMarker(element); 39 if (isVariableAccess(marker)) { 40 if (isWriteAccess(marker)) 41 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_WRITEACCESS); 42 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_READACCESS); 43 } 44 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_OCCURRENCE); 45 } 46 47 private boolean isWriteAccess(IMarker marker) { 48 Boolean write= null; 49 boolean writeValue= false; 50 try { 51 write= (Boolean )marker.getAttribute(OccurrencesFinder.IS_WRITEACCESS); 52 writeValue= write != null && write.booleanValue(); 53 } catch (CoreException e) { 54 } 55 return writeValue; 56 } 57 58 private boolean isVariableAccess(IMarker marker) { 59 Boolean variable= null; 60 boolean variableValue= false; 61 try { 62 variable= (Boolean )marker.getAttribute(OccurrencesFinder.IS_VARIABLE); 63 variableValue= variable != null && variable.booleanValue(); 64 } catch (CoreException e) { 65 } 66 return variableValue; 67 } 68 } 69 | Popular Tags |