1 11 12 package org.eclipse.ui.views.markers.internal; 13 14 import org.eclipse.jface.resource.DeviceResourceException; 15 import org.eclipse.jface.resource.JFaceResources; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages; 18 19 24 public class FieldSeverityAndMessage extends FieldMessage { 25 26 private String description; 27 28 31 public FieldSeverityAndMessage() { 32 description = MarkerMessages.problemSeverity_description; 33 } 34 35 40 public String getDescription() { 41 return description; 42 } 43 44 49 public Image getImage(Object obj) { 50 if (obj == null || !(obj instanceof MarkerNode)) { 51 return null; 52 } 53 54 MarkerNode node = (MarkerNode) obj; 55 if (node.isConcrete()) { 56 if (node instanceof ProblemMarker) { 57 return Util.getImage(((ProblemMarker) obj).getSeverity()); 58 } 59 return null; 60 } 61 62 try { 63 return JFaceResources 64 .getResources() 65 .createImage( 66 IDEInternalWorkbenchImages 67 .getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY)); 68 } catch (DeviceResourceException e) { 69 return null; 70 } 71 } 72 73 79 public int compare(Object obj1, Object obj2) { 80 if (obj1 == null || obj2 == null || !(obj1 instanceof ProblemMarker) 81 || !(obj2 instanceof ProblemMarker)) { 82 return 0; 83 } 84 85 ProblemMarker marker1 = (ProblemMarker) obj1; 86 ProblemMarker marker2 = (ProblemMarker) obj2; 87 88 int severity1 = marker1.getSeverity(); 89 int severity2 = marker2.getSeverity(); 90 if(severity1 == severity2) 91 return marker1.getDescriptionKey().compareTo( 92 marker2.getDescriptionKey()); 93 return severity2 - severity1; 94 } 95 96 101 public Image getColumnHeaderImage() { 102 return getImage(FieldDone.DESCRIPTION_IMAGE_PATH); 103 } 104 105 106 } 107 | Popular Tags |