KickJava   Java API By Example, From Geeks To Geeks.

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


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.jface.resource.JFaceResources;
15 import org.eclipse.swt.graphics.Image;
16 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
17
18 /**
19  * FieldDone is the field for the done marker in tasks.
20  *
21  */

22 public class FieldDone extends AbstractField {
23
24     static final String JavaDoc DESCRIPTION_IMAGE_PATH = "obj16/header_complete.gif"; //$NON-NLS-1$
25

26     static final String JavaDoc COMPLETE_IMAGE_PATH = "obj16/complete_tsk.gif"; //$NON-NLS-1$
27

28     static final String JavaDoc INCOMPLETE_IMAGE_PATH = "obj16/incomplete_tsk.gif"; //$NON-NLS-1$
29

30     private String JavaDoc description = MarkerMessages.completion_description;
31
32
33     /**
34      * Create a new instance of the receiver
35      *
36      */

37     public FieldDone() {
38         
39     }
40
41     /*
42      * (non-Javadoc)
43      *
44      * @see org.eclipse.ui.views.markers.internal.IField#getDescription()
45      */

46     public String JavaDoc getDescription() {
47         return description;
48     }
49
50     /*
51      * (non-Javadoc)
52      *
53      * @see org.eclipse.ui.views.markers.internal.IField#getDescriptionImage()
54      */

55     public Image getDescriptionImage() {
56         return getImage(DESCRIPTION_IMAGE_PATH);
57     }
58     
59     /**
60      * Get the image at path.
61      * @param path
62      * @return Image
63      */

64     private Image getImage(String JavaDoc path){
65         return JFaceResources.getResources().createImageWithDefault(
66                 IDEWorkbenchPlugin
67                         .getIDEImageDescriptor(path));
68         
69     }
70
71     /*
72      * (non-Javadoc)
73      *
74      * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderText()
75      */

76     public String JavaDoc getColumnHeaderText() {
77         return ""; //$NON-NLS-1$
78
}
79
80     /*
81      * (non-Javadoc)
82      *
83      * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderImage()
84      */

85     public Image getColumnHeaderImage() {
86         return getImage(DESCRIPTION_IMAGE_PATH);
87     }
88
89     /*
90      * (non-Javadoc)
91      *
92      * @see org.eclipse.ui.views.markers.internal.IField#getValue(java.lang.Object)
93      */

94     public String JavaDoc getValue(Object JavaDoc obj) {
95         return ""; //$NON-NLS-1$
96
}
97
98     /*
99      * (non-Javadoc)
100      *
101      * @see org.eclipse.ui.views.markers.internal.IField#getImage(java.lang.Object)
102      */

103     public Image getImage(Object JavaDoc 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     /*
119      * (non-Javadoc)
120      *
121      * @see org.eclipse.ui.views.markers.internal.IField#compare(java.lang.Object,
122      * java.lang.Object)
123      */

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

139     public int getDefaultDirection() {
140         return TableComparator.ASCENDING;
141     }
142     
143     /* (non-Javadoc)
144      * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
145      */

146     public int getPreferredWidth() {
147         return 40;
148     }
149
150 }
151
Popular Tags