1 11 12 package org.eclipse.ui.views.markers.internal; 13 14 import org.eclipse.swt.graphics.Image; 15 16 19 public class FieldCreationTime extends AbstractField { 20 21 private String description; 22 23 private Image image; 24 25 28 public FieldCreationTime() { 29 description = MarkerMessages.description_creationTime; 30 } 31 32 36 public String getDescription() { 37 return description; 38 } 39 40 44 public Image getDescriptionImage() { 45 return image; 46 } 47 48 52 public String getColumnHeaderText() { 53 return description; 54 } 55 56 60 public Image getColumnHeaderImage() { 61 return image; 62 } 63 64 68 public String getValue(Object obj) { 69 if (obj == null || !(obj instanceof ConcreteMarker)) { 70 return ""; } 72 ConcreteMarker marker = (ConcreteMarker) obj; 73 return String.valueOf(marker.getCreationTime()); 74 } 75 76 80 public Image getImage(Object obj) { 81 return null; 82 } 83 84 88 public int compare(Object obj1, Object obj2) { 89 if (obj1 == null || obj2 == null || !(obj1 instanceof ConcreteMarker) 90 || !(obj2 instanceof ConcreteMarker)) { 91 return 0; 92 } 93 94 ConcreteMarker marker1 = (ConcreteMarker) obj1; 95 ConcreteMarker marker2 = (ConcreteMarker) obj2; 96 97 long value = marker1.getCreationTime() - marker2.getCreationTime(); 98 if (value < 0) { 99 return -1; 100 } else if (value > 0) { 101 return 1; 102 } else { 103 return 0; 104 } 105 } 106 107 110 public int getDefaultDirection() { 111 return TableComparator.ASCENDING; 112 } 113 114 117 public int getPreferredWidth() { 118 return 0; 119 } 120 } 121 | Popular Tags |