KickJava   Java API By Example, From Geeks To Geeks.

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


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.osgi.util.NLS;
15 import org.eclipse.swt.graphics.Image;
16
17 /**
18  * The message field is the field for the description of the marker.
19  *
20  * @since 3.1
21  *
22  */

23 public class FieldMessage extends AbstractField {
24
25     /**
26      * Create an instance of the receiver.
27      */

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

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

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

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

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

72     public String JavaDoc getValue(Object JavaDoc obj) {
73         if (obj == null) {
74             return MarkerMessages.FieldMessage_NullMessage;
75         }
76
77         if (obj instanceof MarkerNode) {
78             return ((MarkerNode) obj).getDescription();
79         }
80         return NLS.bind(MarkerMessages.FieldMessage_WrongType, obj.toString());
81     }
82
83     /*
84      * (non-Javadoc)
85      *
86      * @see org.eclipse.ui.views.markers.internal.IField#getImage(java.lang.Object)
87      */

88     public Image getImage(Object JavaDoc obj) {
89         return null;
90     }
91
92     /*
93      * (non-Javadoc)
94      *
95      * @see org.eclipse.ui.views.markers.internal.IField#compare(java.lang.Object,
96      * java.lang.Object)
97      */

98     public int compare(Object JavaDoc obj1, Object JavaDoc obj2) {
99         if (obj1 == null || obj2 == null || !(obj1 instanceof ConcreteMarker)
100                 || !(obj2 instanceof ConcreteMarker)) {
101             return 0;
102         }
103
104         ConcreteMarker marker1 = (ConcreteMarker) obj1;
105         ConcreteMarker marker2 = (ConcreteMarker) obj2;
106
107         return marker1.getDescriptionKey().compareTo(
108                 marker2.getDescriptionKey());
109     }
110
111     /*
112      * (non-Javadoc)
113      *
114      * @see org.eclipse.ui.views.markers.internal.IField#getDefaultDirection()
115      */

116     public int getDefaultDirection() {
117         return TableComparator.ASCENDING;
118     }
119
120     /*
121      * (non-Javadoc)
122      *
123      * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
124      */

125     public int getPreferredWidth() {
126         return 250;
127     }
128 }
129
Popular Tags