KickJava   Java API By Example, From Geeks To Geeks.

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


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  * FieldResource is the field for the resource.
18  *
19  */

20 public class FieldResource extends AbstractField {
21
22     private String JavaDoc description;
23
24     private Image image;
25
26     /**
27      * Create a new instance of the receiver.
28      */

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

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

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

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

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

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

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

89     public int compare(Object JavaDoc obj1, Object JavaDoc obj2) {
90         if (obj1 == null || obj2 == null || !(obj1 instanceof ConcreteMarker)
91                 || !(obj2 instanceof ConcreteMarker)) {
92             return 0;
93         }
94
95         ConcreteMarker marker1 = (ConcreteMarker) obj1;
96         ConcreteMarker marker2 = (ConcreteMarker) obj2;
97
98         return marker1.getResourceName().compareTo(
99                 marker2.getResourceName());
100     }
101
102     /* (non-Javadoc)
103      * @see org.eclipse.ui.views.markers.internal.IField#getDefaultDirection()
104      */

105     public int getDefaultDirection() {
106         return TableComparator.ASCENDING;
107     }
108     
109     /* (non-Javadoc)
110      * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
111      */

112     public int getPreferredWidth() {
113         return 75;
114     }
115 }
116
Popular Tags