01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.internal.provisional.views.markers;
11:
12: import org.eclipse.core.resources.IMarker;
13: import org.eclipse.swt.graphics.Image;
14: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerField;
15: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerItem;
16: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerSupportConstants;
17:
18: /**
19: * MarkerPriorityField is the field for task priority.
20: * @since 3.4
21: *
22: */
23: public class MarkerPriorityField extends MarkerField {
24:
25: static final String HIGH_PRIORITY_IMAGE_PATH = "obj16/hprio_tsk.gif"; //$NON-NLS-1$
26:
27: static final String LOW_PRIORITY_IMAGE_PATH = "obj16/lprio_tsk.gif"; //$NON-NLS-1$
28:
29: /**
30: * Return a new priority field.
31: */
32: public MarkerPriorityField() {
33: super ();
34: }
35:
36: /* (non-Javadoc)
37: * @see org.eclipse.ui.internal.provisional.views.markers.MarkerField#getValue(org.eclipse.ui.internal.provisional.views.markers.MarkerItem)
38: */
39: public String getValue(MarkerItem item) {
40: return MarkerSupportConstants.EMPTY_STRING;
41: }
42:
43: /* (non-Javadoc)
44: * @see org.eclipse.ui.internal.provisional.views.markers.MarkerField#getColumnHeaderText()
45: */
46: public String getColumnHeaderText() {
47: return MarkerSupportConstants.EMPTY_STRING;
48: }
49:
50: /* (non-Javadoc)
51: * @see org.eclipse.ui.internal.provisional.views.markers.MarkerField#getColumnWeight()
52: */
53: public float getColumnWeight() {
54: return 0.25f;
55: }
56:
57: /* (non-Javadoc)
58: * @see org.eclipse.ui.internal.provisional.views.markers.MarkerField#getImage(org.eclipse.ui.internal.provisional.views.markers.MarkerItem)
59: */
60: public Image getImage(MarkerItem item) {
61: try {
62: int priority = item.getAttributeValue(IMarker.PRIORITY,
63: IMarker.PRIORITY_NORMAL);
64: if (priority == IMarker.PRIORITY_HIGH) {
65: return MarkerSupportInternalUtilities
66: .createImage(HIGH_PRIORITY_IMAGE_PATH);
67: }
68: if (priority == IMarker.PRIORITY_LOW) {
69: return MarkerSupportInternalUtilities
70: .createImage(LOW_PRIORITY_IMAGE_PATH);
71: }
72: } catch (NumberFormatException e) {
73: return null;
74: }
75: return null;
76: }
77:
78: }
|