1 11 12 package org.eclipse.ui.views.markers.internal; 13 14 import org.eclipse.jface.resource.JFaceResources; 15 import org.eclipse.swt.graphics.Image; 16 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 17 18 22 public class FieldDone extends AbstractField { 23 24 static final String DESCRIPTION_IMAGE_PATH = "obj16/header_complete.gif"; 26 static final String COMPLETE_IMAGE_PATH = "obj16/complete_tsk.gif"; 28 static final String INCOMPLETE_IMAGE_PATH = "obj16/incomplete_tsk.gif"; 30 private String description = MarkerMessages.completion_description; 31 32 33 37 public FieldDone() { 38 39 } 40 41 46 public String getDescription() { 47 return description; 48 } 49 50 55 public Image getDescriptionImage() { 56 return getImage(DESCRIPTION_IMAGE_PATH); 57 } 58 59 64 private Image getImage(String path){ 65 return JFaceResources.getResources().createImageWithDefault( 66 IDEWorkbenchPlugin 67 .getIDEImageDescriptor(path)); 68 69 } 70 71 76 public String getColumnHeaderText() { 77 return ""; } 79 80 85 public Image getColumnHeaderImage() { 86 return getImage(DESCRIPTION_IMAGE_PATH); 87 } 88 89 94 public String getValue(Object obj) { 95 return ""; } 97 98 103 public Image getImage(Object obj) { 104 if (obj == null || !(obj instanceof TaskMarker)) { 105 return null; 106 } 107 TaskMarker marker = (TaskMarker) obj; 108 int done = marker.getDone(); 109 if (done == -1) { 110 return null; 111 } 112 if (done == 1) { 113 return getImage(COMPLETE_IMAGE_PATH); 114 } 115 return getImage(INCOMPLETE_IMAGE_PATH); 116 } 117 118 124 public int compare(Object obj1, Object obj2) { 125 if (obj1 == null || obj2 == null || !(obj1 instanceof TaskMarker) 126 || !(obj2 instanceof TaskMarker)) { 127 return 0; 128 } 129 TaskMarker marker1 = (TaskMarker) obj1; 130 TaskMarker marker2 = (TaskMarker) obj2; 131 int value1 = marker1.getDone(); 132 int value2 = marker2.getDone(); 133 return value1 - value2; 134 } 135 136 139 public int getDefaultDirection() { 140 return TableComparator.ASCENDING; 141 } 142 143 146 public int getPreferredWidth() { 147 return 40; 148 } 149 150 } 151 | Popular Tags |