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.jface.resource.JFaceResources;
013: import org.eclipse.swt.graphics.Image;
014: import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
015:
016: /**
017: * FieldDone is the field for the done marker in tasks.
018: *
019: */
020: public class FieldDone extends AbstractField {
021:
022: static final String DESCRIPTION_IMAGE_PATH = "obj16/header_complete.gif"; //$NON-NLS-1$
023:
024: static final String COMPLETE_IMAGE_PATH = "obj16/complete_tsk.gif"; //$NON-NLS-1$
025:
026: static final String INCOMPLETE_IMAGE_PATH = "obj16/incomplete_tsk.gif"; //$NON-NLS-1$
027:
028: private String description = MarkerMessages.completion_description;
029:
030: /**
031: * Create a new instance of the receiver
032: *
033: */
034: public FieldDone() {
035:
036: }
037:
038: /*
039: * (non-Javadoc)
040: *
041: * @see org.eclipse.ui.views.markers.internal.IField#getDescription()
042: */
043: public String getDescription() {
044: return description;
045: }
046:
047: /*
048: * (non-Javadoc)
049: *
050: * @see org.eclipse.ui.views.markers.internal.IField#getDescriptionImage()
051: */
052: public Image getDescriptionImage() {
053: return getImage(DESCRIPTION_IMAGE_PATH);
054: }
055:
056: /**
057: * Get the image at path.
058: * @param path
059: * @return Image
060: */
061: private Image getImage(String path) {
062: return JFaceResources.getResources().createImageWithDefault(
063: IDEWorkbenchPlugin.getIDEImageDescriptor(path));
064:
065: }
066:
067: /*
068: * (non-Javadoc)
069: *
070: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderText()
071: */
072: public String getColumnHeaderText() {
073: return ""; //$NON-NLS-1$
074: }
075:
076: /*
077: * (non-Javadoc)
078: *
079: * @see org.eclipse.ui.views.markers.internal.IField#getColumnHeaderImage()
080: */
081: public Image getColumnHeaderImage() {
082: return getImage(DESCRIPTION_IMAGE_PATH);
083: }
084:
085: /*
086: * (non-Javadoc)
087: *
088: * @see org.eclipse.ui.views.markers.internal.IField#getValue(java.lang.Object)
089: */
090: public String getValue(Object obj) {
091: return ""; //$NON-NLS-1$
092: }
093:
094: /*
095: * (non-Javadoc)
096: *
097: * @see org.eclipse.ui.views.markers.internal.IField#getImage(java.lang.Object)
098: */
099: public Image getImage(Object obj) {
100: if (obj == null || !(obj instanceof TaskMarker)) {
101: return null;
102: }
103: TaskMarker marker = (TaskMarker) obj;
104: int done = marker.getDone();
105: if (done == -1) {
106: return null;
107: }
108: if (done == 1) {
109: return getImage(COMPLETE_IMAGE_PATH);
110: }
111: return getImage(INCOMPLETE_IMAGE_PATH);
112: }
113:
114: /*
115: * (non-Javadoc)
116: *
117: * @see org.eclipse.ui.views.markers.internal.IField#compare(java.lang.Object,
118: * java.lang.Object)
119: */
120: public int compare(Object obj1, Object obj2) {
121: if (obj1 == null || obj2 == null
122: || !(obj1 instanceof TaskMarker)
123: || !(obj2 instanceof TaskMarker)) {
124: return 0;
125: }
126: TaskMarker marker1 = (TaskMarker) obj1;
127: TaskMarker marker2 = (TaskMarker) obj2;
128: int value1 = marker1.getDone();
129: int value2 = marker2.getDone();
130: return value1 - value2;
131: }
132:
133: /* (non-Javadoc)
134: * @see org.eclipse.ui.views.markers.internal.IField#getDefaultDirection()
135: */
136: public int getDefaultDirection() {
137: return TableComparator.ASCENDING;
138: }
139:
140: /* (non-Javadoc)
141: * @see org.eclipse.ui.views.markers.internal.IField#getPreferredWidth()
142: */
143: public int getPreferredWidth() {
144: return 40;
145: }
146:
147: }
|