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: * Folder field. Designed to display and compare the names of the folders that contain
016: * IMarker objects.
017: */
018: public class FieldFolder extends AbstractField {
019:
020: /**
021: * Create a new instance of the receiver.
022: */
023: public FieldFolder() {
024: }
025:
026: /*
027: * (non-Javadoc)
028: * @see org.eclipse.ui.views.markers.internal.IField#getDescription()
029: */
030: public String getDescription() {
031: return MarkerMessages.description_folder;
032: }
033:
034: /*
035: * (non-Javadoc)
036: * @see org.eclipse.ui.views.markers.internal.IField#getDescriptionImage()
037: */
038: public Image getDescriptionImage() {
039: return null;
040: }
041:
042: /*
043: * (non-Javadoc)
044: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderText()
045: */
046: public String getColumnHeaderText() {
047: return MarkerMessages.description_folder;
048: }
049:
050: /*
051: * (non-Javadoc)
052: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderImage()
053: */
054: public Image getColumnHeaderImage() {
055: return null;
056: }
057:
058: /*
059: * (non-Javadoc)
060: * @see org.eclipse.ui.views.markers.internal.IField#getValue(java.lang.Object)
061: */
062: public String getValue(Object obj) {
063: if (obj == null || !(obj instanceof ConcreteMarker)) {
064: return Util.EMPTY_STRING;
065: }
066: ConcreteMarker marker = (ConcreteMarker) obj;
067: return marker.getFolder();
068: }
069:
070: /*
071: * (non-Javadoc)
072: * @see org.eclipse.ui.views.markers.internal.IField#getImage(java.lang.Object)
073: */
074: public Image getImage(Object obj) {
075: return null;
076: }
077:
078: /*
079: * (non-Javadoc)
080: * @see org.eclipse.ui.views.markers.internal.IField#compare(java.lang.Object, java.lang.Object)
081: */
082: public int compare(Object obj1, Object obj2) {
083: if (obj1 == null || obj2 == null
084: || !(obj1 instanceof ConcreteMarker)
085: || !(obj2 instanceof ConcreteMarker)) {
086: return 0;
087: }
088: ConcreteMarker marker1 = (ConcreteMarker) obj1;
089: ConcreteMarker marker2 = (ConcreteMarker) obj2;
090:
091: return marker1.getFolder().compareTo(marker2.getFolder());
092: }
093:
094: /* (non-Javadoc)
095: * @see org.eclipse.ui.views.markers.internal.IField#getDefaultDirection()
096: */
097: public int getDefaultDirection() {
098: return TableComparator.ASCENDING;
099: }
100:
101: /* (non-Javadoc)
102: * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
103: */
104: public int getPreferredWidth() {
105: return 150;
106: }
107:
108: }
|