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: * FieldResource is the field for the resource.
016: *
017: */
018: public class FieldResource extends AbstractField {
019:
020: private String description;
021:
022: private Image image;
023:
024: /**
025: * Create a new instance of the receiver.
026: */
027: public FieldResource() {
028: description = MarkerMessages.description_resource;
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.getResourceName();
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:
097: return marker1.getResourceName().compareTo(
098: marker2.getResourceName());
099: }
100:
101: /* (non-Javadoc)
102: * @see org.eclipse.ui.views.markers.internal.IField#getDefaultDirection()
103: */
104: public int getDefaultDirection() {
105: return TableComparator.ASCENDING;
106: }
107:
108: /* (non-Javadoc)
109: * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
110: */
111: public int getPreferredWidth() {
112: return 75;
113: }
114: }
|