1 11 12 package org.eclipse.ui.views.markers.internal; 13 14 import org.eclipse.core.resources.IMarker; 15 import org.eclipse.swt.graphics.Image; 16 17 public class FieldSeverity implements IField { 18 19 private static final String IMAGE_ERROR_PATH = "obj16/error_tsk.gif"; 21 private static final String IMAGE_WARNING_PATH = "obj16/warn_tsk.gif"; 23 private static final String IMAGE_INFO_PATH = "obj16/info_tsk.gif"; 25 private String description; 26 27 private Image image; 28 29 public FieldSeverity() { 30 description = Messages.getString("problemSeverity.description"); image = null; 32 } 33 34 38 public String getDescription() { 39 return description; 40 } 41 42 46 public Image getDescriptionImage() { 47 return image; 48 } 49 50 54 public String getColumnHeaderText() { 55 return ""; } 57 58 62 public Image getColumnHeaderImage() { 63 return null; 64 } 65 66 70 public String getValue(Object obj) { 71 return "" + ((ProblemMarker) obj).getSeverity(); } 73 74 78 public Image getImage(Object obj) { 79 if (obj == null || !(obj instanceof ProblemMarker)) { 80 return null; 81 } 82 83 int severity = ((ProblemMarker) obj).getSeverity(); 84 if (severity == IMarker.SEVERITY_ERROR) { 85 return ImageFactory.getImage(IMAGE_ERROR_PATH); 86 } 87 if (severity == IMarker.SEVERITY_WARNING) { 88 return ImageFactory.getImage(IMAGE_WARNING_PATH); 89 } 90 if (severity == IMarker.SEVERITY_INFO) { 91 return ImageFactory.getImage(IMAGE_INFO_PATH); 92 } 93 return null; 94 } 95 96 100 public int compare(Object obj1, Object obj2) { 101 if (obj1 == null || obj2 == null || !(obj1 instanceof ProblemMarker) 102 || !(obj2 instanceof ProblemMarker)) { 103 return 0; 104 } 105 106 int severity1 = ((ProblemMarker) obj1).getSeverity(); 107 int severity2 = ((ProblemMarker) obj2).getSeverity(); 108 return severity1 - severity2; 109 } 110 111 } 112 | Popular Tags |