001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.views.markers.internal;
011:
012: import org.eclipse.osgi.util.NLS;
013: import org.eclipse.swt.graphics.Image;
014:
015: /**
016: * The message field is the field for the description of the marker.
017: *
018: * @since 3.1
019: *
020: */
021: public class FieldMessage extends AbstractField {
022:
023: /**
024: * Create an instance of the receiver.
025: */
026: public FieldMessage() {
027: }
028:
029: /*
030: * (non-Javadoc)
031: *
032: * @see org.eclipse.ui.views.markers.internal.IField#getDescription()
033: */
034: public String getDescription() {
035: return MarkerMessages.description_message;
036: }
037:
038: /*
039: * (non-Javadoc)
040: *
041: * @see org.eclipse.ui.views.markers.internal.IField#getDescriptionImage()
042: */
043: public Image getDescriptionImage() {
044: return null;
045: }
046:
047: /*
048: * (non-Javadoc)
049: *
050: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderText()
051: */
052: public String getColumnHeaderText() {
053: return MarkerMessages.description_message;
054: }
055:
056: /*
057: * (non-Javadoc)
058: *
059: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderImage()
060: */
061: public Image getColumnHeaderImage() {
062: return null;
063: }
064:
065: /*
066: * (non-Javadoc)
067: *
068: * @see org.eclipse.ui.views.markers.internal.IField#getValue(java.lang.Object)
069: */
070: public String getValue(Object obj) {
071: if (obj == null) {
072: return MarkerMessages.FieldMessage_NullMessage;
073: }
074:
075: if (obj instanceof MarkerNode) {
076: return ((MarkerNode) obj).getDescription();
077: }
078: return NLS.bind(MarkerMessages.FieldMessage_WrongType, obj
079: .toString());
080: }
081:
082: /*
083: * (non-Javadoc)
084: *
085: * @see org.eclipse.ui.views.markers.internal.IField#getImage(java.lang.Object)
086: */
087: public Image getImage(Object obj) {
088: return null;
089: }
090:
091: /*
092: * (non-Javadoc)
093: *
094: * @see org.eclipse.ui.views.markers.internal.IField#compare(java.lang.Object,
095: * java.lang.Object)
096: */
097: public int compare(Object obj1, Object obj2) {
098: if (obj1 == null || obj2 == null
099: || !(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: }
|