01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.ide;
11:
12: import org.eclipse.core.resources.IMarker;
13: import org.eclipse.core.runtime.CoreException;
14:
15: /**
16: * Implementation of IMarkerImageProvider to provide the image
17: * path names for problem markers.
18: */
19: public class ProblemImageProvider implements IMarkerImageProvider {
20: /**
21: * TaskImageProvider constructor comment.
22: */
23: public ProblemImageProvider() {
24: super ();
25: }
26:
27: /**
28: * Returns the relative path for the image
29: * to be used for displaying an marker in the workbench.
30: * This path is relative to the plugin location
31: *
32: * Returns <code>null</code> if there is no appropriate image.
33: *
34: * @param marker The marker to get an image path for.
35: *
36: */
37: public String getImagePath(IMarker marker) {
38: String iconPath = "/icons/full/";//$NON-NLS-1$
39: if (isMarkerType(marker, IMarker.PROBLEM)) {
40: switch (marker.getAttribute(IMarker.SEVERITY,
41: IMarker.SEVERITY_WARNING)) {
42: case IMarker.SEVERITY_ERROR:
43: return iconPath + "obj16/error_tsk.gif";//$NON-NLS-1$
44: case IMarker.SEVERITY_WARNING:
45: return iconPath + "obj16/warn_tsk.gif";//$NON-NLS-1$
46: case IMarker.SEVERITY_INFO:
47: return iconPath + "obj16/info_tsk.gif";//$NON-NLS-1$
48: }
49: }
50: return null;
51: }
52:
53: /**
54: * Returns whether the given marker is of the given type (either directly or indirectly).
55: */
56: private boolean isMarkerType(IMarker marker, String type) {
57: try {
58: return marker.isSubtypeOf(type);
59: } catch (CoreException e) {
60: return false;
61: }
62: }
63: }
|