KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > markers > internal > FieldCreationTime


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.views.markers.internal;
13
14 import org.eclipse.swt.graphics.Image;
15
16 /**
17  * Creation time field. Designed to display and compare creation times of IMarker objects.
18  */

19 public class FieldCreationTime extends AbstractField {
20
21     private String JavaDoc description;
22
23     private Image image;
24
25     /**
26      * The constructor
27      */

28     public FieldCreationTime() {
29         description = MarkerMessages.description_creationTime;
30     }
31
32     /*
33      * (non-Javadoc)
34      * @see org.eclipse.ui.views.markers.internal.IField#getDescription()
35      */

36     public String JavaDoc getDescription() {
37         return description;
38     }
39
40     /*
41      * (non-Javadoc)
42      * @see org.eclipse.ui.views.markers.internal.IField#getDescriptionImage()
43      */

44     public Image getDescriptionImage() {
45         return image;
46     }
47
48     /*
49      * (non-Javadoc)
50      * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderText()
51      */

52     public String JavaDoc getColumnHeaderText() {
53         return description;
54     }
55
56     /*
57      * (non-Javadoc)
58      * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderImage()
59      */

60     public Image getColumnHeaderImage() {
61         return image;
62     }
63
64     /*
65      * (non-Javadoc)
66      * @see org.eclipse.ui.views.markers.internal.IField#getValue(java.lang.Object)
67      */

68     public String JavaDoc getValue(Object JavaDoc obj) {
69         if (obj == null || !(obj instanceof ConcreteMarker)) {
70             return ""; //$NON-NLS-1$
71
}
72         ConcreteMarker marker = (ConcreteMarker) obj;
73         return String.valueOf(marker.getCreationTime());
74     }
75
76     /*
77      * (non-Javadoc)
78      * @see org.eclipse.ui.views.markers.internal.IField#getImage(java.lang.Object)
79      */

80     public Image getImage(Object JavaDoc obj) {
81         return null;
82     }
83
84     /*
85      * (non-Javadoc)
86      * @see org.eclipse.ui.views.markers.internal.IField#compare(java.lang.Object, java.lang.Object)
87      */

88     public int compare(Object JavaDoc obj1, Object JavaDoc 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     /* (non-Javadoc)
108      * @see org.eclipse.ui.views.markers.internal.IField#getDefaultDirection()
109      */

110     public int getDefaultDirection() {
111         return TableComparator.ASCENDING;
112     }
113     
114     /* (non-Javadoc)
115      * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
116      */

117     public int getPreferredWidth() {
118         return 0;
119     }
120 }
121
Popular Tags