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.swt.graphics.Image;
013:
014: /**
015: * FieldId is the field for marker id.
016: *
017: */
018: public class FieldId implements IField {
019:
020: private String description;
021:
022: private Image image;
023:
024: /**
025: * Create a new instance of the receiver.
026: */
027: public FieldId() {
028: description = MarkerMessages.description_markerId;
029: }
030:
031: /*
032: * (non-Javadoc)
033: * @see org.eclipse.ui.views.markers.internal.IField#getDescription()
034: */
035: public String getDescription() {
036: return description;
037: }
038:
039: /*
040: * (non-Javadoc)
041: * @see org.eclipse.ui.views.markers.internal.IField#getDescriptionImage()
042: */
043: public Image getDescriptionImage() {
044: return image;
045: }
046:
047: /*
048: * (non-Javadoc)
049: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderText()
050: */
051: public String getColumnHeaderText() {
052: return description;
053: }
054:
055: /*
056: * (non-Javadoc)
057: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderImage()
058: */
059: public Image getColumnHeaderImage() {
060: return image;
061: }
062:
063: /*
064: * (non-Javadoc)
065: * @see org.eclipse.ui.views.markers.internal.IField#getValue(java.lang.Object)
066: */
067: public String getValue(Object obj) {
068: if (obj == null || !(obj instanceof ConcreteMarker)) {
069: return ""; //$NON-NLS-1$
070: }
071: ConcreteMarker marker = (ConcreteMarker) obj;
072: return "" + marker.getId(); //$NON-NLS-1$
073: }
074:
075: /*
076: * (non-Javadoc)
077: * @see org.eclipse.ui.views.markers.internal.IField#getImage(java.lang.Object)
078: */
079: public Image getImage(Object obj) {
080: return null;
081: }
082:
083: /*
084: * (non-Javadoc)
085: * @see org.eclipse.ui.views.markers.internal.IField#compare(java.lang.Object, java.lang.Object)
086: */
087: public int compare(Object obj1, Object obj2) {
088: if (obj1 == null || obj2 == null
089: || !(obj1 instanceof ConcreteMarker)
090: || !(obj2 instanceof ConcreteMarker)) {
091: return 0;
092: }
093:
094: ConcreteMarker marker1 = (ConcreteMarker) obj1;
095: ConcreteMarker marker2 = (ConcreteMarker) obj2;
096: return (int) (marker1.getId() - marker2.getId());
097: }
098:
099: /* (non-Javadoc)
100: * @see org.eclipse.ui.views.markers.internal.IField#getDefaultDirection()
101: */
102: public int getDefaultDirection() {
103: return TableComparator.ASCENDING;
104: }
105:
106: /* (non-Javadoc)
107: * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
108: */
109: public int getPreferredWidth() {
110: return 0;
111: }
112:
113: /* (non-Javadoc)
114: * @see org.eclipse.ui.views.markers.internal.IField#isShowing()
115: */
116: public boolean isShowing() {
117: // Never show id
118: return false;
119: }
120:
121: /* (non-Javadoc)
122: * @see org.eclipse.ui.views.markers.internal.IField#setShowing(boolean)
123: */
124: public void setShowing(boolean showing) {
125: // Ignore
126:
127: }
128: }
|