Package: VdmElementImageProvider

VdmElementImageProvider

nameinstructionbranchcomplexitylinemethod
VdmElementImageProvider()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
computeDescriptor(Object, int)
M: 281 C: 0
0%
M: 60 C: 0
0%
M: 31 C: 0
0%
M: 90 C: 0
0%
M: 1 C: 0
0%
computeVdmAdornmentFlags(Object)
M: 48 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getCUResourceImageDescriptor(IFile, int)
M: 14 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getClassDefinitionFlags(AClassClassDefinition)
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getExplicitFunctionDefinitionImage(AExplicitFunctionDefinition, int, int)
M: 70 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
getExplicitOperationDefinitionFlags(AExplicitOperationDefinition)
M: 36 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getExplicitOperationDefinitionImage(AExplicitOperationDefinition, int, int)
M: 70 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
getFieldImage(AFieldField, int, int)
M: 74 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 22 C: 0
0%
M: 1 C: 0
0%
getImageLabel(ImageDescriptor)
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getImageLabel(Object, int)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getImplicitFunctionDefinitionImage(AImplicitFunctionDefinition, int, int)
M: 74 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 21 C: 0
0%
M: 1 C: 0
0%
getImplicitOperationDefinitionImage(AImplicitOperationDefinition, int, int)
M: 74 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 21 C: 0
0%
M: 1 C: 0
0%
getInheritedDefinitionFlags(AInheritedDefinition)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getInheritedDefinitionImage(AInheritedDefinition, int, int)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getInstanceVariableDefinitionFlags(AInstanceVariableDefinition)
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getInstanceVariableDefinitionImage(AInstanceVariableDefinition, int, int)
M: 70 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
getLocalDefinitionFlags(ALocalDefinition)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getLocalDefinitionImage(ALocalDefinition, int, int)
M: 70 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
getNamedTraceDefinitionImage(ANamedTraceDefinition, int, int)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getPerSyncDefinitionImage(APerSyncDefinition, int, int)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getRegistry()
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getTypeDefinitionImage(ATypeDefinition, int, int)
M: 70 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
getValueDefinitionImage(AValueDefinition, int, int)
M: 74 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 21 C: 0
0%
M: 1 C: 0
0%
getWorkbenchImageDescriptor(IAdaptable, int)
M: 31 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 17 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
useSmallSize(int)
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.ui
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.ui.internal.viewsupport;
23:
24: import java.util.HashMap;
25: import java.util.List;
26: import java.util.Map;
27:
28: import org.eclipse.core.resources.IFile;
29: import org.eclipse.core.runtime.IAdaptable;
30: import org.eclipse.jface.resource.ImageDescriptor;
31: import org.eclipse.swt.graphics.Image;
32: import org.eclipse.swt.graphics.Point;
33: import org.eclipse.ui.model.IWorkbenchAdapter;
34: import org.overture.ast.definitions.AClassClassDefinition;
35: import org.overture.ast.definitions.AExplicitFunctionDefinition;
36: import org.overture.ast.definitions.AExplicitOperationDefinition;
37: import org.overture.ast.definitions.AImplicitFunctionDefinition;
38: import org.overture.ast.definitions.AImplicitOperationDefinition;
39: import org.overture.ast.definitions.AInheritedDefinition;
40: import org.overture.ast.definitions.AInstanceVariableDefinition;
41: import org.overture.ast.definitions.ALocalDefinition;
42: import org.overture.ast.definitions.ANamedTraceDefinition;
43: import org.overture.ast.definitions.APerSyncDefinition;
44: import org.overture.ast.definitions.ARenamedDefinition;
45: import org.overture.ast.definitions.ASystemClassDefinition;
46: import org.overture.ast.definitions.ATypeDefinition;
47: import org.overture.ast.definitions.AUntypedDefinition;
48: import org.overture.ast.definitions.AValueDefinition;
49: import org.overture.ast.definitions.PDefinition;
50: import org.overture.ast.definitions.SClassDefinition;
51: import org.overture.ast.modules.AFromModuleImports;
52: import org.overture.ast.modules.AModuleImports;
53: import org.overture.ast.modules.AModuleModules;
54: import org.overture.ast.modules.AOperationValueImport;
55: import org.overture.ast.types.AAccessSpecifierAccessSpecifier;
56: import org.overture.ast.types.AFieldField;
57: import org.overture.ide.ui.VdmPluginImages;
58: import org.overture.ide.ui.VdmUIPlugin;
59:
60: public class VdmElementImageProvider {
61:         /**
62:          * Flags for the JavaImageLabelProvider: Generate images with overlays.
63:          */
64:         public final static int OVERLAY_ICONS = 0x1;
65:
66:         /**
67:          * Generate small sized images.
68:          */
69:         public final static int SMALL_ICONS = 0x2;
70:
71:         /**
72:          * Use the 'light' style for rendering types.
73:          */
74:         public final static int LIGHT_TYPE_ICONS = 0x4;
75:
76:         public static final Point SMALL_SIZE = new Point(16, 16);
77:         public static final Point BIG_SIZE = new Point(22, 16);
78:
79:
80:
81:         private ImageDescriptorRegistry fRegistry;
82:
83:         public VdmElementImageProvider() {
84:                 fRegistry = null; // lazy initialization
85:         }
86:
87:         /**
88:          * Returns the icon for a given element. The icon depends on the element
89:          * type and element properties. If configured, overlay icons are constructed
90:          * for <code>ISourceReference</code>s.
91:          *
92:          * @param element
93:          * the element
94:          * @param flags
95:          * Flags as defined by the JavaImageLabelProvider
96:          * @return return the image or <code>null</code>
97:          */
98:         public Image getImageLabel(Object element, int flags) {
99:                 return getImageLabel(computeDescriptor(element, flags));
100:         }
101:
102:         private Image getImageLabel(ImageDescriptor descriptor) {
103:•                if (descriptor == null)
104:                         return null;
105:                 return getRegistry().get(descriptor);
106:         }
107:
108:         private ImageDescriptorRegistry getRegistry() {
109:•                if (fRegistry == null) {
110:                         fRegistry = VdmUIPlugin.getImageDescriptorRegistry();
111:                 }
112:                 return fRegistry;
113:         }
114:
115:         
116:         //TODO: this map should be deleted when the AST fix is made
117:         //so that definitions contain a reference to the module they belong
118:         static Map<String,AModuleModules> activeModule = new HashMap<String,AModuleModules>();
119:
120:         protected ImageDescriptor computeDescriptor(Object element, int flags) {
121:                 int adornmentFlags = 0;
122:
123:                 adornmentFlags = computeVdmAdornmentFlags(element);
124:
125:•                if (element instanceof ASystemClassDefinition) {
126: //                        activeModule = null;
127:                         return VdmPluginImages
128:                                         .getDescriptor(VdmPluginImages.IMG_OBJS_SYSTEM);
129:•                } else if (element instanceof AClassClassDefinition) {
130: //                        activeModule = null;
131:                         return VdmPluginImages
132:                                         .getDescriptor(VdmPluginImages.IMG_OBJS_CLASS);
133:•                } else if (element instanceof AModuleModules) {
134:                         activeModule.put(((AModuleModules)element).getName().getName(), ((AModuleModules)element));
135:                         return VdmPluginImages
136:                                         .getDescriptor(VdmPluginImages.IMG_OBJS_MODULE);
137:•                } else if (element instanceof ATypeDefinition) {
138:                         return getTypeDefinitionImage((ATypeDefinition) element,
139:                                         SMALL_ICONS, adornmentFlags);
140:•                } else if (element instanceof AInstanceVariableDefinition) {
141:                         return getInstanceVariableDefinitionImage(
142:                                         (AInstanceVariableDefinition) element, SMALL_ICONS,
143:                                         adornmentFlags);
144:•                } else if (element instanceof AExplicitOperationDefinition) {
145:                         return getExplicitOperationDefinitionImage(
146:                                         (AExplicitOperationDefinition) element, SMALL_ICONS,
147:                                         adornmentFlags);
148:•                } else if (element instanceof AExplicitFunctionDefinition) {
149:                         return getExplicitFunctionDefinitionImage(
150:                                         (AExplicitFunctionDefinition) element, SMALL_ICONS,
151:                                         adornmentFlags);
152:•                } else if(element instanceof AImplicitFunctionDefinition){
153:                         return getImplicitFunctionDefinitionImage(
154:                                         (AImplicitFunctionDefinition) element, SMALL_ICONS,
155:                                         adornmentFlags);
156:•                }else if(element instanceof AImplicitOperationDefinition){
157:                         return getImplicitOperationDefinitionImage(
158:                                         (AImplicitOperationDefinition) element, SMALL_ICONS,
159:                                         adornmentFlags);
160:•                }else if(element instanceof APerSyncDefinition){
161:                         return getPerSyncDefinitionImage(
162:                                         (APerSyncDefinition) element, SMALL_ICONS,
163:                                         adornmentFlags);
164:                 }
165:                 
166:                 
167:                 
168:                 
169:•                else if (element instanceof ALocalDefinition) {
170:                         return getLocalDefinitionImage((ALocalDefinition) element,
171:                                         SMALL_ICONS, adornmentFlags);
172:•                } else if (element instanceof AValueDefinition) {
173:                         return getValueDefinitionImage((AValueDefinition) element,
174:                                         SMALL_ICONS, adornmentFlags);
175:•                } else if (element instanceof ANamedTraceDefinition) {
176:                         return getNamedTraceDefinitionImage((ANamedTraceDefinition) element,
177:                                         SMALL_ICONS, adornmentFlags);
178:•                } else if (element instanceof AUntypedDefinition) {
179:                         List<PDefinition> definitions = null;
180:•                        if (((AUntypedDefinition) element).getClassDefinition() != null) {
181:                                 SClassDefinition classDef = ((AUntypedDefinition) element).getClassDefinition();
182:                                 definitions = classDef.getDefinitions();
183:                         } else {
184:•                                if (activeModule != null){
185:                                         AUntypedDefinition untypedDef = (AUntypedDefinition) element;
186:                                         
187:                                         definitions = activeModule.get(untypedDef.getName().getModule()).getDefs();
188:                                 }
189:                         }
190:•                        if (definitions != null) {
191:•                                for (PDefinition def : definitions) {
192:•                                        if (def instanceof AValueDefinition) {
193:•                                                for (int i = 0; i < ((AValueDefinition)def).getDefs().size(); i++) {
194:                                                         if (((AValueDefinition)def).getDefs().get(i).getLocation()
195:                                                                         .equals(
196:                                                                                         ((AUntypedDefinition) element)
197:•                                                                                                        .getLocation())) {
198:                                                                 return getValueDefinitionImage(
199:                                                                                 (AValueDefinition) def, SMALL_ICONS,
200:                                                                                 adornmentFlags);
201:                                                         }
202:                                                 }
203:                                         }
204:                                 }
205:                         }
206:                 }
207:
208:•                else if (element instanceof AModuleImports) {
209:                         return VdmPluginImages.DESC_OBJS_IMPCONT;
210:                 }
211:
212:•                else if (element instanceof AFromModuleImports) {
213:                         return VdmPluginImages.DESC_OBJS_IMPDECL;
214:                 }
215:                 
216:•                else if(element instanceof ImportsContainer){
217:                         return computeDescriptor(((ImportsContainer) element).getImports(), adornmentFlags);
218:                 }
219:                 
220:•                else if (element instanceof IFile) {
221:                         IFile file = (IFile) element;
222:                         // if (JavaCore.isJavaLikeFileName(file.getName())) {
223:                         // return getCUResourceImageDescriptor(file, flags); // image for a
224:                         // CU not on the build path
225:                         // }
226:                         return getWorkbenchImageDescriptor(file, flags);
227:•                } else if (element instanceof IAdaptable) {
228:                         return getWorkbenchImageDescriptor((IAdaptable) element, flags);
229:•                } else if (element instanceof AFieldField){
230:                         return getFieldImage((AFieldField) element,
231:                                         SMALL_ICONS, adornmentFlags);
232:•                } else if (element instanceof AInheritedDefinition){
233:                         return getInheritedDefinitionImage((AInheritedDefinition)element,SMALL_ICONS,adornmentFlags);
234:•                } else if (element instanceof ARenamedDefinition){
235:                         return VdmPluginImages.DESC_OBJS_IMPDECL;
236:•                } else if(element instanceof AOperationValueImport){
237:                         return VdmPluginImages.DESC_METHOD_DEFAULT;                                        
238:                 }
239:                 
240:                 
241:                 return null;
242:         }
243:
244:         
245:
246:         private ImageDescriptor getFieldImage(AFieldField element, int smallIcons,
247:                         int adornmentFlags) {
248:                 ImageDescriptor result = null;
249:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
250:•                if(as == null)
251:                         return result;
252:                 
253:•                Point size = useSmallSize(smallIcons) ? SMALL_SIZE : BIG_SIZE;
254:•                if (as.getAccess().toString().equals("private")) {
255:                         return new VdmElementImageDescriptor(VdmPluginImages
256:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PRIVATE),
257:                                         adornmentFlags, size);
258:•                } else if (as.getAccess().toString().equals("public")) {
259:                         return new VdmElementImageDescriptor(VdmPluginImages
260:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PUBLIC),
261:                                         adornmentFlags, size);
262:•                } else if (as.getAccess().toString().equals("protected")) {
263:                         return new VdmElementImageDescriptor(VdmPluginImages
264:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PROTECTED),
265:                                         adornmentFlags, size);
266:•                } else if (as.getAccess().toString().equals("default")) {
267:                         return new VdmElementImageDescriptor(VdmPluginImages
268:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_DEFAULT),
269:                                         adornmentFlags, size);
270:                 }
271:
272:                 return result;
273:                 
274:         }
275:
276:         private ImageDescriptor getInheritedDefinitionImage(
277:                         AInheritedDefinition element, int smallIcons, int adornmentFlags) {
278:•                Point size = useSmallSize(smallIcons) ? SMALL_SIZE : BIG_SIZE;
279:                 ImageDescriptor desc = computeDescriptor(element.getSuperdef(),adornmentFlags);
280:                 
281:                 
282:                 return new VdmElementImageDescriptor(desc, adornmentFlags, size);
283:         }
284:         
285:         private ImageDescriptor getImplicitOperationDefinitionImage(
286:                         AImplicitOperationDefinition element, int smallIcons,
287:                         int adornmentFlags) {
288:                 ImageDescriptor result = null;
289:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
290:•                Point size = useSmallSize(smallIcons) ? SMALL_SIZE : BIG_SIZE;
291:
292:                 // result =
293:                 // VdmPluginImages.getDescriptor(VdmPluginImages.IMG_METHOD_PRIVATE);
294:
295:                 adornmentFlags = adornmentFlags | VdmElementImageDescriptor.FINAL;
296:
297:•                if (as.getAccess().toString().equals("private")) {
298:                         return new VdmElementImageDescriptor(VdmPluginImages
299:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PRIVATE),
300:                                         adornmentFlags, size);
301:•                } else if (as.getAccess().toString().equals("public")) {
302:                         return new VdmElementImageDescriptor(VdmPluginImages
303:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PUBLIC),
304:                                         adornmentFlags, size);
305:•                } else if (as.getAccess().toString().equals("protected")) {
306:                         return new VdmElementImageDescriptor(VdmPluginImages
307:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PROTECTED),
308:                                         adornmentFlags, size);
309:•                } else if (as.getAccess().toString().equals("default")) {
310:                         return new VdmElementImageDescriptor(VdmPluginImages
311:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_DEFAULT),
312:                                         adornmentFlags, size);
313:                 }
314:
315:                 return result;
316:         }
317:
318:         private ImageDescriptor getImplicitFunctionDefinitionImage(
319:                         AImplicitFunctionDefinition element, int smallIcons,
320:                         int adornmentFlags) {
321:                 ImageDescriptor result = null;
322:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
323:•                Point size = useSmallSize(smallIcons) ? SMALL_SIZE : BIG_SIZE;
324:
325:                 // result =
326:                 // VdmPluginImages.getDescriptor(VdmPluginImages.IMG_METHOD_PRIVATE);
327:
328:                 adornmentFlags = adornmentFlags | VdmElementImageDescriptor.FINAL;
329:
330:•                if (as.getAccess().toString().equals("private")) {
331:                         return new VdmElementImageDescriptor(VdmPluginImages
332:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_PRIVATE),
333:                                         adornmentFlags, size);
334:•                } else if (as.getAccess().toString().equals("public")) {
335:                         return new VdmElementImageDescriptor(VdmPluginImages
336:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_PUBLIC),
337:                                         adornmentFlags, size);
338:•                } else if (as.getAccess().toString().equals("protected")) {
339:                         return new VdmElementImageDescriptor(VdmPluginImages
340:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_PROTECTED),
341:                                         adornmentFlags, size);
342:•                } else if (as.getAccess().toString().equals("default")) {
343:                         return new VdmElementImageDescriptor(VdmPluginImages
344:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_DEFAULT),
345:                                         adornmentFlags, size);
346:                 }
347:
348:                 return result;
349:         }
350:
351:         private ImageDescriptor getExplicitFunctionDefinitionImage(
352:                         AExplicitFunctionDefinition element, int renderFlags,
353:                         int adornmentFlags) {
354:                 ImageDescriptor result = null;
355:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
356:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
357:
358:                 // result =
359:                 // VdmPluginImages.getDescriptor(VdmPluginImages.IMG_METHOD_PRIVATE);
360:
361:                 //adornmentFlags = adornmentFlags | VdmElementImageDescriptor.FINAL;
362:
363:•                if (as.getAccess().toString().equals("private")) {
364:                         return new VdmElementImageDescriptor(VdmPluginImages
365:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_PRIVATE),
366:                                         adornmentFlags, size);
367:•                } else if (as.getAccess().toString().equals("public")) {
368:                         return new VdmElementImageDescriptor(VdmPluginImages
369:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_PUBLIC),
370:                                         adornmentFlags, size);
371:•                } else if (as.getAccess().toString().equals("protected")) {
372:                         return new VdmElementImageDescriptor(VdmPluginImages
373:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_PROTECTED),
374:                                         adornmentFlags, size);
375:•                } else if (as.getAccess().toString().equals("default")) {
376:                         return new VdmElementImageDescriptor(VdmPluginImages
377:                                         .getDescriptor(VdmPluginImages.IMG_FUNC_DEFAULT),
378:                                         adornmentFlags, size);
379:                 }
380:
381:                 return result;
382:         }
383:
384:         private ImageDescriptor getNamedTraceDefinitionImage(
385:                         ANamedTraceDefinition element, int renderFlags, int adornmentFlags) {
386:                 //ImageDescriptor result = null;
387:
388:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
389:
390:                 return new VdmElementImageDescriptor(VdmPluginImages
391:                                 .getDescriptor(VdmPluginImages.IMG_TRACE_DEFAULT),
392:                                 adornmentFlags, size);
393:         }
394:         
395:         private ImageDescriptor getPerSyncDefinitionImage(
396:                         APerSyncDefinition element, int renderFlags, int adornmentFlags) {
397:                 //ImageDescriptor result = null;
398:
399:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
400:
401:                 return new VdmElementImageDescriptor(VdmPluginImages
402:                                 .getDescriptor(VdmPluginImages.IMG_OBJS_LOCK),
403:                                 adornmentFlags, size);
404:         }
405:
406:         private ImageDescriptor getTypeDefinitionImage(ATypeDefinition element,
407:                         int renderFlags, int adornmentFlags) {
408:                 ImageDescriptor result = null;
409:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
410:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
411:
412:•                if (as.getAccess().toString().equals("private")) {
413:                         return new VdmElementImageDescriptor(VdmPluginImages
414:                                         .getDescriptor(VdmPluginImages.IMG_TYPE_PRIVATE),
415:                                         adornmentFlags, size);
416:•                } else if (as.getAccess().toString().equals("public")) {
417:                         return new VdmElementImageDescriptor(VdmPluginImages
418:                                         .getDescriptor(VdmPluginImages.IMG_TYPE_PUBLIC),
419:                                         adornmentFlags, size);
420:•                } else if (as.getAccess().toString().equals("protected")) {
421:                         return new VdmElementImageDescriptor(VdmPluginImages
422:                                         .getDescriptor(VdmPluginImages.IMG_TYPE_PROTECTED),
423:                                         adornmentFlags, size);
424:•                } else if (as.getAccess().toString().equals("default")) {
425:                         return new VdmElementImageDescriptor(VdmPluginImages
426:                                         .getDescriptor(VdmPluginImages.IMG_TYPE_DEFAULT),
427:                                         adornmentFlags, size);
428:                 }
429:
430:                 return result;
431:         }
432:
433:         private ImageDescriptor getValueDefinitionImage(AValueDefinition element,
434:                         int renderFlags, int adornmentFlags) {
435:                 ImageDescriptor result = null;
436:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
437:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
438:
439:                 adornmentFlags |= VdmElementImageDescriptor.FINAL;
440:                 
441:•                if (as.getAccess().toString().equals("private")) {
442:                         return new VdmElementImageDescriptor(VdmPluginImages
443:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PRIVATE),
444:                                         adornmentFlags, size);
445:•                } else if (as.getAccess().toString().equals("public")) {
446:                         return new VdmElementImageDescriptor(VdmPluginImages
447:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PUBLIC),
448:                                         adornmentFlags, size);
449:•                } else if (as.getAccess().toString().equals("protected")) {
450:                         return new VdmElementImageDescriptor(VdmPluginImages
451:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PROTECTED),
452:                                         adornmentFlags, size);
453:•                } else if (as.getAccess().toString().equals("default")) {
454:                         return new VdmElementImageDescriptor(VdmPluginImages
455:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_DEFAULT),
456:                                         adornmentFlags, size);
457:                 }
458:
459:                 return result;
460:         }
461:
462:         private ImageDescriptor getLocalDefinitionImage(ALocalDefinition element,
463:                         int renderFlags, int adornmentFlags) {
464:                 ImageDescriptor result = null;
465:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
466:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
467:
468:•                if (as.getAccess().toString().equals("private")) {
469:                         return new VdmElementImageDescriptor(VdmPluginImages
470:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PRIVATE),
471:                                         adornmentFlags, size);
472:•                } else if (as.getAccess().toString().equals("public")) {
473:                         return new VdmElementImageDescriptor(VdmPluginImages
474:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PUBLIC),
475:                                         adornmentFlags, size);
476:•                } else if (as.getAccess().toString().equals("protected")) {
477:                         return new VdmElementImageDescriptor(VdmPluginImages
478:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PROTECTED),
479:                                         adornmentFlags, size);
480:•                } else if (as.getAccess().toString().equals("default")) {
481:                         return new VdmElementImageDescriptor(VdmPluginImages
482:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_DEFAULT),
483:                                         adornmentFlags, size);
484:                 }
485:
486:                 return result;
487:         }
488:
489:         private ImageDescriptor getExplicitOperationDefinitionImage(
490:                         AExplicitOperationDefinition element, int renderFlags,
491:                         int adornmentFlags) {
492:                 ImageDescriptor result = null;
493:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
494:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
495:
496:                 // result =
497:                 // VdmPluginImages.getDescriptor(VdmPluginImages.IMG_METHOD_PRIVATE);
498:
499:•                if (as.getAccess().toString().equals("private")) {
500:                         return new VdmElementImageDescriptor(VdmPluginImages
501:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PRIVATE),
502:                                         adornmentFlags, size);
503:•                } else if (as.getAccess().toString().equals("public")) {
504:                         return new VdmElementImageDescriptor(VdmPluginImages
505:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PUBLIC),
506:                                         adornmentFlags, size);
507:•                } else if (as.getAccess().toString().equals("protected")) {
508:                         return new VdmElementImageDescriptor(VdmPluginImages
509:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_PROTECTED),
510:                                         adornmentFlags, size);
511:•                } else if (as.getAccess().toString().equals("default")) {
512:                         return new VdmElementImageDescriptor(VdmPluginImages
513:                                         .getDescriptor(VdmPluginImages.IMG_METHOD_DEFAULT),
514:                                         adornmentFlags, size);
515:                 }
516:
517:                 return result;
518:                 //                
519:
520:                 // return new
521:                 // VdmElementImageDescriptor(VdmPluginImages.getDescriptor(VdmPluginImages.IMG_METHOD_PROTECTED),
522:                 // 0,
523:                 // size);
524:         }
525:
526:         private ImageDescriptor getInstanceVariableDefinitionImage(
527:                         AInstanceVariableDefinition element, int renderFlags,
528:                         int adornmentFlags) {
529:                 ImageDescriptor result = null;
530:                 AAccessSpecifierAccessSpecifier as = element.getAccess();
531:•                Point size = useSmallSize(renderFlags) ? SMALL_SIZE : BIG_SIZE;
532:
533:•                if (as.getAccess().toString().equals("private")) {
534:                         return new VdmElementImageDescriptor(VdmPluginImages
535:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PRIVATE),
536:                                         adornmentFlags, size);
537:•                } else if (as.getAccess().toString().equals("public")) {
538:                         return new VdmElementImageDescriptor(VdmPluginImages
539:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PUBLIC),
540:                                         adornmentFlags, size);
541:•                } else if (as.getAccess().toString().equals("protected")) {
542:                         return new VdmElementImageDescriptor(VdmPluginImages
543:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_PROTECTED),
544:                                         adornmentFlags, size);
545:•                } else if (as.getAccess().toString().equals("default")) {
546:                         return new VdmElementImageDescriptor(VdmPluginImages
547:                                         .getDescriptor(VdmPluginImages.IMG_FIELD_DEFAULT),
548:                                         adornmentFlags, size);
549:                 }
550:
551:                 return result;
552:
553:         }
554:
555: //        private static boolean showOverlayIcons(int flags) {
556: //                return (flags & OVERLAY_ICONS) != 0;
557: //        }
558:
559:         protected static boolean useSmallSize(int flags) {
560:•                return (flags & SMALL_ICONS) != 0;
561:         }
562:
563: //        private static boolean useLightIcons(int flags) {
564: //                return (flags & LIGHT_TYPE_ICONS) != 0;
565: //        }
566:
567:         /**
568:          * Returns an image descriptor for a compilation unit not on the class path.
569:          * The descriptor includes overlays, if specified.
570:          *
571:          * @param file
572:          * the cu resource file
573:          * @param flags
574:          * the image flags
575:          * @return returns the image descriptor
576:          */
577:         public ImageDescriptor getCUResourceImageDescriptor(IFile file, int flags) {
578:•                Point size = useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
579:                 return new VdmElementImageDescriptor(
580:                                 VdmPluginImages.DESC_OBJS_CUNIT_RESOURCE, 0, size);
581:         }
582:
583:         /**
584:          * Returns an image descriptor for a IAdaptable. The descriptor includes
585:          * overlays, if specified (only error ticks apply). Returns
586:          * <code>null</code> if no image could be found.
587:          *
588:          * @param adaptable
589:          * the adaptable
590:          * @param flags
591:          * the image flags
592:          * @return returns the image descriptor
593:          */
594:         public ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable,
595:                         int flags) {
596:                 IWorkbenchAdapter wbAdapter = (IWorkbenchAdapter) adaptable
597:                                 .getAdapter(IWorkbenchAdapter.class);
598:•                if (wbAdapter == null) {
599:                         return null;
600:                 }
601:                 ImageDescriptor descriptor = wbAdapter.getImageDescriptor(adaptable);
602:•                if (descriptor == null) {
603:                         return null;
604:                 }
605:
606:•                Point size = useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
607:                 return new VdmElementImageDescriptor(descriptor, 0, size);
608:         }
609:
610:         public int computeVdmAdornmentFlags(Object element) {
611:                 int flags = 0;
612:
613:•                if (element instanceof AClassClassDefinition) {
614:                         flags = getClassDefinitionFlags((AClassClassDefinition) element);
615:•                } else if (element instanceof AInstanceVariableDefinition) {
616:                         flags = getInstanceVariableDefinitionFlags((AInstanceVariableDefinition) element);
617:•                } else if (element instanceof AExplicitOperationDefinition) {
618:                         flags = getExplicitOperationDefinitionFlags((AExplicitOperationDefinition) element);
619:
620:•                } else if (element instanceof ALocalDefinition) {
621:                         flags = getLocalDefinitionFlags((ALocalDefinition) element);
622:•                } else if (element instanceof AInheritedDefinition){
623:                         flags = getInheritedDefinitionFlags((AInheritedDefinition)element);
624:                 }
625:                 
626:                 
627:                 return flags;
628:         }
629:
630:         private int getInheritedDefinitionFlags(AInheritedDefinition element) {
631:                 int flags = 0;
632:                 flags |= VdmElementImageDescriptor.OVERRIDES;
633:                 
634:                 return flags;
635:         }
636:
637:         private int getLocalDefinitionFlags(ALocalDefinition element) {
638:                 int flags = 0;
639:
640:                 //flags |= VdmElementImageDescriptor.STATIC;
641:                 flags |= VdmElementImageDescriptor.FINAL;
642:
643:                 return flags;
644:         }
645:
646:         private int getInstanceVariableDefinitionFlags(
647:                         AInstanceVariableDefinition element) {
648:                 int flags = 0;
649:
650:•                if (element.getAccess().getStatic()!=null) {
651:                         flags |= VdmElementImageDescriptor.STATIC;
652:                 }
653:
654:                 return flags;
655:         }
656:
657:         private int getExplicitOperationDefinitionFlags(
658:                         AExplicitOperationDefinition element) {
659:
660:                 int flags = 0;
661:•                if (element.getIsConstructor()) {
662:                         flags |= VdmElementImageDescriptor.CONSTRUCTOR;
663:                 }
664:•                if (element.getAccess().getStatic()!=null) {
665:                         flags |= VdmElementImageDescriptor.STATIC;
666:                 }
667:•                if(element.getName().getName() != null){
668:                         String s = element.getName().getName();
669:•                        if(s.equals("thread")){
670:                                 flags |= VdmElementImageDescriptor.RUNNABLE;
671:                         }
672:                 }
673:                 
674:                 
675:
676:                 return flags;
677:         }
678:
679:         private int getClassDefinitionFlags(AClassClassDefinition element) {
680:                 int flags = 0;
681:
682:•                if (element.getIsAbstract()) {
683:                         flags |= VdmElementImageDescriptor.ABSTRACT;
684:                 }
685:                 return flags;
686:         }
687:         
688:         
689:
690:         public void dispose() {
691:         }
692:
693: }