1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 /***
19 * <p>Title: WSMO Studio</p>
20 * <p>Description: Semantic Web Service Editor</p>
21 * <p>Copyright: Copyright (c) 2004-2006</p>
22 * <p>Company: OntoText Lab. / SIRMA </p>
23 */
24
25
26 package org.wsmostudio.ui;
27
28 import org.eclipse.core.resources.*;
29 import org.eclipse.core.runtime.CoreException;
30 import org.eclipse.jface.resource.*;
31 import org.eclipse.jface.viewers.*;
32 import org.eclipse.swt.graphics.*;
33 import org.wsmostudio.runtime.WsmoImageRegistry;
34
35 public class ResourcesDecorator implements ILabelDecorator {
36
37 private boolean forceImageLoadPerformed = false;
38
39 public Image decorateImage(Image image, Object element) {
40 if (false == element instanceof IFile) {
41 return image;
42 }
43
44 IMarker[] markers = null;
45 try {
46 markers = ((IFile)element).findMarkers("org.wsmostudio.runtime.wsmlmarker", true, 1);
47 }
48 catch(CoreException coreEx) { }
49 if (markers == null
50 || markers.length == 0) {
51 return image;
52 }
53 boolean containsWarning = false;
54 for(int i = 0; i < markers.length; i++) {
55 if (markers[i].getAttribute(IMarker.SEVERITY, 0) == IMarker.SEVERITY_ERROR) {
56 return findImage(WsmoImageRegistry.RESOURCE_ERROR_ICON);
57 }
58 else if (markers[i].getAttribute(IMarker.SEVERITY, 0) == IMarker.SEVERITY_WARNING) {
59 containsWarning = true;
60 }
61 }
62 if (containsWarning == true) {
63 return findImage(WsmoImageRegistry.RESOURCE_WARNING_ICON);
64 }
65 return image;
66 }
67
68 public String decorateText(String text, Object element) {
69 return text;
70 }
71
72 public void addListener(ILabelProviderListener listener) {
73 }
74
75 public void dispose() {
76 }
77
78 public boolean isLabelProperty(Object element, String property) {
79 return false;
80 }
81
82 public void removeListener(ILabelProviderListener listener) {
83 }
84
85 private Image findImage(String imageID) {
86 Image image = JFaceResources.getImageRegistry().get(imageID);
87 if (image != null) {
88 return image;
89 }
90 if (false == forceImageLoadPerformed) {
91 WsmoImageRegistry.declareStudioImages();
92 forceImageLoadPerformed = true;
93 }
94 return JFaceResources.getImageRegistry().get(imageID);
95 }
96
97 }
98
99
100
101
102
103
104
105
106
107
108