Skip to content

Package: ExpandBarCategorizationElementRenderer$1

ExpandBarCategorizationElementRenderer$1

nameinstructionbranchcomplexitylinemethod
getColumnImage(Object, int)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getColumnText(Object, int)
M: 63 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
getImage(Object)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
{...}
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.swt.categorization.expandbar;
15:
16: import java.util.LinkedHashSet;
17: import java.util.Set;
18:
19: import javax.inject.Inject;
20:
21: import org.eclipse.core.databinding.observable.value.IObservableValue;
22: import org.eclipse.emf.common.notify.Adapter;
23: import org.eclipse.emf.common.notify.Notification;
24: import org.eclipse.emf.common.notify.impl.AdapterImpl;
25: import org.eclipse.emf.common.util.Diagnostic;
26: import org.eclipse.emf.common.util.EList;
27: import org.eclipse.emf.databinding.EMFDataBindingContext;
28: import org.eclipse.emf.databinding.edit.EMFEditObservables;
29: import org.eclipse.emfforms.spi.swt.core.ui.SWTValidationHelper;
30: import org.eclipse.emf.ecp.view.spi.categorization.model.VAbstractCategorization;
31: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizableElement;
32: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorization;
33: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationElement;
34: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategory;
35: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
36: import org.eclipse.emf.ecp.view.spi.model.VDiagnostic;
37: import org.eclipse.emf.ecp.view.spi.model.VElement;
38: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
39: import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
40: import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
41: import org.eclipse.emf.ecp.view.spi.swt.reporting.RenderingFailedReport;
42: import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
43: import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
44: import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
45: import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
46: import org.eclipse.emfforms.spi.common.report.AbstractReport;
47: import org.eclipse.emfforms.spi.common.report.ReportService;
48: import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
49: import org.eclipse.emfforms.spi.swt.core.EMFFormsNoRendererException;
50: import org.eclipse.emfforms.spi.swt.core.EMFFormsRendererFactory;
51: import org.eclipse.emfforms.spi.swt.core.SWTDataElementIdHelper;
52: import org.eclipse.emfforms.spi.swt.core.layout.GridDescriptionFactory;
53: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell;
54: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription;
55: import org.eclipse.jface.databinding.swt.ISWTObservableValue;
56: import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
57: import org.eclipse.jface.layout.GridDataFactory;
58: import org.eclipse.jface.layout.GridLayoutFactory;
59: import org.eclipse.jface.viewers.ISelectionChangedListener;
60: import org.eclipse.jface.viewers.IStructuredSelection;
61: import org.eclipse.jface.viewers.SelectionChangedEvent;
62: import org.eclipse.jface.viewers.StructuredSelection;
63: import org.eclipse.jface.viewers.TableViewer;
64: import org.eclipse.jface.viewers.Viewer;
65: import org.eclipse.jface.viewers.ViewerFilter;
66: import org.eclipse.rap.rwt.RWT;
67: import org.eclipse.swt.SWT;
68: import org.eclipse.swt.custom.SashForm;
69: import org.eclipse.swt.custom.ScrolledComposite;
70: import org.eclipse.swt.graphics.Image;
71: import org.eclipse.swt.graphics.Point;
72: import org.eclipse.swt.internal.widgets.MarkupValidator;
73: import org.eclipse.swt.layout.GridLayout;
74: import org.eclipse.swt.widgets.Composite;
75: import org.eclipse.swt.widgets.Control;
76: import org.eclipse.swt.widgets.ExpandBar;
77: import org.eclipse.swt.widgets.ExpandItem;
78: import org.eclipse.swt.widgets.Table;
79:
80: /**
81: * A VCategorizationElement renderer that renders the categories as expandbar items.
82: * This renderer does only work if there are only VCategorization items on the root and each VCategorization item
83: * contains only VCategory items.
84: *
85: * @author Eugen Neufeld
86: *
87: */
88: @SuppressWarnings("restriction")
89: public class ExpandBarCategorizationElementRenderer extends AbstractSWTRenderer<VCategorizationElement> {
90:
91:         private static final String VALIDATION_ERRORS = "validationErrors"; //$NON-NLS-1$
92:         private SWTGridDescription gridDescription;
93:         private final EMFFormsRendererFactory emfFormsRendererFactory;
94:         private ScrolledComposite editorComposite;
95:         private AdapterFactoryLabelProvider labelProvider;
96:         private ExpandBar expandBar;
97:
98:         private final EMFDataBindingContext dbc;
99:         private ComposedAdapterFactory adapterFactory;
100:         private AdapterFactoryContentProvider contentProvider;
101:
102:         /**
103:          * Default constructor.
104:          *
105:          * @param vElement the view model element to be rendered
106:          * @param viewContext the view context
107:          * @param reportService the {@link ReportService}
108:          * @param emfFormsRendererFactory The {@link EMFFormsRendererFactory}
109:          * @since 1.9
110:          */
111:         @Inject
112:         public ExpandBarCategorizationElementRenderer(VCategorizationElement vElement, ViewModelContext viewContext,
113:                 ReportService reportService, EMFFormsRendererFactory emfFormsRendererFactory) {
114:                 super(vElement, viewContext, reportService);
115:                 this.emfFormsRendererFactory = emfFormsRendererFactory;
116:                 dbc = new EMFDataBindingContext();
117:         }
118:
119:         /**
120:          * {@inheritDoc}
121:          *
122:          * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#getGridDescription(org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription)
123:          */
124:         @Override
125:         public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) {
126:                 if (this.gridDescription == null) {
127:                         this.gridDescription = GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 1, this);
128:                 }
129:                 return this.gridDescription;
130:         }
131:
132:         /**
133:          * {@inheritDoc}
134:          *
135:          * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#renderControl(org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell,
136:          * org.eclipse.swt.widgets.Composite)
137:          */
138:         @Override
139:         protected Control renderControl(SWTGridCell cell, Composite parent)
140:                 throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
141:                 adapterFactory = new ComposedAdapterFactory(
142:                         ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
143:                 final EList<VAbstractCategorization> categorizations = getVElement().getCategorizations();
144:
145:                 if (categorizations.size() == 1 && categorizations.get(0) instanceof VCategory) {
146:                         final VElement child = categorizations.get(0);
147:                         AbstractSWTRenderer<VElement> renderer;
148:                         try {
149:                                 renderer = getEMFFormsRendererFactory().getRendererInstance(child,
150:                                         getViewModelContext());
151:                         } catch (final EMFFormsNoRendererException ex) {
152:                                 getReportService().report(new AbstractReport(ex));
153:                                 return null;
154:                         }
155:                         final Control render = renderer.render(cell, parent);
156:                         renderer.finalizeRendering(parent);
157:                         SWTDataElementIdHelper.setElementIdDataWithSubId(render, getVElement(), "vcategory", getViewModelContext()); //$NON-NLS-1$
158:                         return render;
159:
160:                 }
161:
162:                 Composite expandBar;
163:                 final Object detailPane = getViewModelContext().getContextValue("detailPane"); //$NON-NLS-1$
164:                 if (detailPane != null && Composite.class.isInstance(detailPane)) {
165:                         expandBar = createExpandBarMaster(parent);
166:
167:                         editorComposite = createdEditorPane(Composite.class.cast(detailPane));
168:
169:                         Composite.class.cast(detailPane).layout();
170:
171:                         selectFirstEntry();
172:
173:                         return expandBar;
174:                 }
175:
176:                 final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
177:                 SWTDataElementIdHelper.setElementIdDataWithSubId(sashForm, getVElement(), "sash", getViewModelContext()); //$NON-NLS-1$
178:                 GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(sashForm);
179:
180:                 expandBar = createExpandBarMaster(sashForm);
181:
182:                 editorComposite = createdEditorPane(sashForm);
183:
184:                 sashForm.setWeights(new int[] { 1, 3 });
185:
186:                 selectFirstEntry();
187:
188:                 return sashForm;
189:         }
190:
191:         private void selectFirstEntry() {
192:                 if (expandBar.getItemCount() != 0) {
193:                         final TableViewer tableViewer = TableViewer.class
194:                                 .cast(expandBar.getItem(0).getData("tableViewer")); //$NON-NLS-1$
195:                         tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(0)));
196:                 }
197:         }
198:
199:         private Composite createExpandBarMaster(final Composite parent) {
200:
201:                 labelProvider = new AdapterFactoryLabelProvider(adapterFactory) {
202:
203:                         @Override
204:                         public Image getImage(Object object) {
205:                                 return null;
206:                         }
207:
208:                         @Override
209:                         public Image getColumnImage(Object object, int columnIndex) {
210:                                 return null;
211:                         }
212:
213:                         @Override
214:                         public String getColumnText(Object object, int columnIndex) {
215:                                 String result = super.getColumnText(object, columnIndex);
216:                                 final VDiagnostic diagnostic = VCategory.class.cast(object).getDiagnostic();
217:•                                if (diagnostic != null && diagnostic.getHighestSeverity() > 0) {
218:
219:                                         result += String.format(
220:                                                 " <span style='background-color:#%2$s;border-radius: 1em;color:#%3$s;height:1.25em;width:1.25em;display:inline-block;text-align:center'>%1$s</span>", //$NON-NLS-1$
221:                                                 diagnostic.getDiagnostics().size(), SWTValidationHelper.INSTANCE.getValidationColorHEX(
222:                                                         diagnostic.getHighestSeverity(), getVElement(), getViewModelContext()),
223:                                                 getFontColor());
224:                                 }
225:                                 return String.format("<span style='display:inline-block;margin-left:1.25em;'>%1$s</span>", result); //$NON-NLS-1$
226:                         }
227:
228:                 };
229:
230:                 final Composite expandBarComposite = new Composite(parent, SWT.BORDER);
231:                 SWTDataElementIdHelper.setElementIdDataWithSubId(expandBarComposite, getVElement(), "expandBarComposite", //$NON-NLS-1$
232:                         getViewModelContext());
233:                 expandBarComposite.setLayout(new GridLayout());
234:
235:                 expandBar = new ExpandBar(expandBarComposite, SWT.V_SCROLL);
236:                 SWTDataElementIdHelper.setElementIdDataWithSubId(expandBar, getVElement(), "expandBar", getViewModelContext()); //$NON-NLS-1$
237:                 expandBar.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
238:                 int destroyedItems = 0;
239:                 for (final VAbstractCategorization categorization : getVElement().getCategorizations()) {
240:
241:                         final ExpandItem item = createExpandItem(adapterFactory, categorization, destroyedItems);
242:                         item.setExpanded(true);
243:
244:                         categorization.eAdapters().add(new CategorizationVisibilityAdapter(categorization, item));
245:                         if (!categorization.isVisible()) {
246:                                 item.dispose();
247:                                 destroyedItems++;
248:                         }
249:                 }
250:
251:                 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
252:                         .hint(SWT.DEFAULT, 5000) // arbitrary high height that won't be reached
253:                         .applyTo(expandBar);
254:
255:                 return expandBarComposite;
256:         }
257:
258:         private ExpandItem createExpandItem(final ComposedAdapterFactory adapterFactory,
259:                 final VAbstractCategorization categorization, int destroyedItems) {
260:                 final ExpandItem item = new ExpandItem(expandBar, SWT.NONE,
261:                         getVElement().getCategorizations().indexOf(categorization) - destroyedItems);
262:                 SWTDataElementIdHelper.setElementIdDataWithSubId(item, categorization, "expandItem", getViewModelContext()); //$NON-NLS-1$
263:                 item.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
264:
265:                 final ISWTObservableValue target = WidgetProperties.text().observe(item);
266:                 final IObservableValue modelValue = EMFEditObservables.observeValue(
267:                         AdapterFactoryEditingDomain.getEditingDomainFor(categorization), categorization,
268:                         VViewPackage.eINSTANCE.getElement_Label());
269:                 dbc.bindValue(target, modelValue);
270:
271:                 item.setImage(labelProvider.getImage(categorization));
272:
273:                 final TableViewer tv = new TableViewer(expandBar, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
274:                 tv.getTable().setHeaderVisible(false);
275:                 tv.setLabelProvider(labelProvider);
276:                 tv.addFilter(new ViewerFilter() {
277:
278:                         @Override
279:                         public boolean select(Viewer viewer, Object parentElement, Object element) {
280:                                 return VCategory.class.isInstance(element) && VCategory.class.cast(element).isVisible();
281:                         }
282:                 });
283:
284:                 contentProvider = new AdapterFactoryContentProvider(adapterFactory);
285:                 tv.setContentProvider(contentProvider);
286:                 tv.setInput(VCategorization.class.cast(categorization));
287:                 tv.addSelectionChangedListener(new CustomTableSelectionAdapter());
288:                 tv.getTable().setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
289:                 tv.getTable().setData(MarkupValidator.MARKUP_VALIDATION_DISABLED, Boolean.TRUE);
290:                 item.setControl(tv.getControl());
291:                 SWTDataElementIdHelper.setElementIdDataWithSubId(tv.getControl(), categorization, "expandItemContent", //$NON-NLS-1$
292:                         getViewModelContext());
293:                 item.setHeight(computeHeight(item.getControl()));
294:                 if (categorization.getDiagnostic() != null && categorization.getDiagnostic().getHighestSeverity() > 0) {
295:                         item.setData(RWT.CUSTOM_VARIANT, getValidationKey(categorization));
296:                 }
297:                 item.setData("tableViewer", tv); //$NON-NLS-1$
298:                 return item;
299:         }
300:
301:         private String getValidationKey(final VAbstractCategorization categorization) {
302:                 switch (categorization.getDiagnostic().getHighestSeverity()) {
303:                 case Diagnostic.INFO:
304:                         return VALIDATION_ERRORS + "_info"; //$NON-NLS-1$
305:                 case Diagnostic.WARNING:
306:                         return VALIDATION_ERRORS + "_warning"; //$NON-NLS-1$
307:                 case Diagnostic.ERROR:
308:                         return VALIDATION_ERRORS + "_error"; //$NON-NLS-1$
309:                 case Diagnostic.CANCEL:
310:                         return VALIDATION_ERRORS + "_cancel"; //$NON-NLS-1$
311:                 default:
312:                         return VALIDATION_ERRORS;
313:                 }
314:         }
315:
316:         private String getFontColor() {
317:                 return "ffffff"; //$NON-NLS-1$
318:         }
319:
320:         private int computeHeight(Control control) {
321:                 return control.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + 1;
322:         }
323:
324:         private Composite createComposite(Composite parent) {
325:                 final Composite composite = new Composite(parent, SWT.NONE);
326:                 composite.setBackground(parent.getBackground());
327:
328:                 GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).margins(7, 7).applyTo(composite);
329:                 GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(composite);
330:                 return composite;
331:         }
332:
333:         /**
334:          * Created editor pane.
335:          *
336:          * @param composite the composite
337:          * @return the created editor composite
338:          */
339:         protected ScrolledComposite createdEditorPane(Composite composite) {
340:                 final ScrolledComposite editorComposite = createScrolledComposite(composite);
341:                 editorComposite.setExpandHorizontal(true);
342:                 editorComposite.setExpandVertical(true);
343:                 editorComposite.setShowFocusedControl(true);
344:                 SWTDataElementIdHelper.setElementIdDataWithSubId(editorComposite, getVElement(), "editorComposite", //$NON-NLS-1$
345:                         getViewModelContext());
346:
347:                 GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(editorComposite);
348:
349:                 return editorComposite;
350:         }
351:
352:         /**
353:          * Creates the scrolled composite.
354:          *
355:          * @param parent the parent
356:          * @return the scrolled composite
357:          */
358:         private ScrolledComposite createScrolledComposite(Composite parent) {
359:                 final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL
360:                         | SWT.BORDER);
361:                 scrolledComposite.setShowFocusedControl(true);
362:                 scrolledComposite.setExpandVertical(true);
363:                 scrolledComposite.setExpandHorizontal(true);
364:                 scrolledComposite.setBackground(parent.getBackground());
365:
366:                 return scrolledComposite;
367:         }
368:
369:         private EMFFormsRendererFactory getEMFFormsRendererFactory() {
370:                 return emfFormsRendererFactory;
371:         }
372:
373:         /**
374:          * Adapter to check for visibility changes on categorizations.
375:          *
376:          * @author Eugen Neufeld
377:          *
378:          */
379:         private final class CategorizationVisibilityAdapter extends AdapterImpl {
380:                 private final VAbstractCategorization categorization;
381:                 private ExpandItem catItem;
382:
383:                 private CategorizationVisibilityAdapter(VAbstractCategorization categorization, ExpandItem item) {
384:                         this.categorization = categorization;
385:                         catItem = item;
386:                 }
387:
388:                 /**
389:                  * {@inheritDoc}
390:                  *
391:                  * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
392:                  */
393:                 @Override
394:                 public void notifyChanged(Notification msg) {
395:                         super.notifyChanged(msg);
396:                         if (msg.getFeature() != VViewPackage.eINSTANCE.getElement_Visible()) {
397:                                 return;
398:                         }
399:                         if (!categorization.isVisible()) {
400:                                 if (catItem.getControl().isFocusControl()) {
401:                                         expandBar.forceFocus();
402:                                 }
403:                                 catItem.dispose();
404:                         } else {
405:                                 int index = Math.min(expandBar.getChildren().length,
406:                                         getVElement().getCategorizations().indexOf(categorization));
407:                                 catItem = createExpandItem(adapterFactory, categorization, index);
408:                         }
409:                 }
410:         }
411:
412:         /**
413:          * A custom adapter that resets the selection in the other table viewers and triggers the rendering of the selected
414:          * category.
415:          *
416:          * @author Eugen Neufeld
417:          *
418:          */
419:         private class CustomTableSelectionAdapter implements ISelectionChangedListener {
420:                 private Composite childComposite;
421:
422:                 /**
423:                  * {@inheritDoc}
424:                  *
425:                  * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
426:                  */
427:                 @Override
428:                 public void selectionChanged(SelectionChangedEvent event) {
429:                         for (int i = 0; i < expandBar.getItemCount(); i++) {
430:                                 final ExpandItem expandItem = expandBar.getItem(i);
431:                                 final Table table = (Table) expandItem.getControl();
432:                                 if (TableViewer.class.cast(event.getSource()).getTable() != table) {
433:                                         table.deselectAll();
434:                                 }
435:                         }
436:                         final Object selection = IStructuredSelection.class.cast(event.getSelection()).getFirstElement();
437:
438:                         if (childComposite != null) {
439:                                 childComposite.dispose();
440:                                 childComposite = null;
441:                         }
442:                         if (selection == null) {
443:                                 return;
444:                         }
445:                         childComposite = createComposite(editorComposite);
446:
447:                         childComposite.setBackground(editorComposite.getBackground());
448:                         editorComposite.setContent(childComposite);
449:
450:                         final VElement child = (VElement) selection;
451:                         try {
452:
453:                                 AbstractSWTRenderer<VElement> renderer;
454:                                 try {
455:                                         renderer = getEMFFormsRendererFactory().getRendererInstance(child, getViewModelContext());
456:                                 } catch (final EMFFormsNoRendererException ex) {
457:                                         getReportService().report(new AbstractReport(ex));
458:                                         return;
459:                                 }
460:                                 final Control render = renderer.render(
461:                                         renderer.getGridDescription(
462:                                                 GridDescriptionFactory.INSTANCE.createEmptyGridDescription()).getGrid().get(0),
463:                                         childComposite);
464:                                 renderer.finalizeRendering(childComposite);
465:                                 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
466:                                         .minSize(SWT.DEFAULT, 200)
467:                                         .applyTo(render);
468:                                 getVElement().setCurrentSelection((VCategorizableElement) child);
469:                         } catch (final NoRendererFoundException e) {
470:                                 getReportService().report(new RenderingFailedReport(e));
471:                         } catch (final NoPropertyDescriptorFoundExeption e) {
472:                                 getReportService().report(new RenderingFailedReport(e));
473:                         }
474:
475:                         childComposite.layout();
476:                         final Point point = childComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
477:                         editorComposite.setMinSize(point);
478:                 }
479:         }
480:
481:         /**
482:          * {@inheritDoc}
483:          *
484:          * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#applyValidation()
485:          */
486:         @Override
487:         protected void applyValidation() {
488:                 super.applyValidation();
489:                 labelProvider.fireLabelProviderChanged();
490:                 for (int i = 0; i < expandBar.getItemCount(); i++) {
491:                         final ExpandItem expandItem = expandBar.getItem(i);
492:                         final VAbstractCategorization categorization = getVElement().getCategorizations().get(i);
493:                         expandItem.setImage(labelProvider.getImage(categorization));
494:                         if (categorization.getDiagnostic() != null && categorization.getDiagnostic().getHighestSeverity() > 0) {
495:                                 expandItem.setData(RWT.CUSTOM_VARIANT,
496:                                         getValidationKey(categorization));
497:                         } else {
498:                                 expandItem.setData(RWT.CUSTOM_VARIANT, null);
499:                         }
500:                 }
501:         }
502:
503:         @Override
504:         protected void dispose() {
505:                 if (dbc != null) {
506:                         dbc.dispose();
507:                 }
508:                 if (adapterFactory != null) {
509:                         adapterFactory.dispose();
510:                 }
511:                 if (labelProvider != null) {
512:                         labelProvider.dispose();
513:                 }
514:                 if (contentProvider != null) {
515:                         contentProvider.dispose();
516:                 }
517:                 for (final VAbstractCategorization categorization : getVElement().getCategorizations()) {
518:                         final Set<Adapter> toRemove = new LinkedHashSet<Adapter>();
519:                         for (final Adapter adapter : categorization.eAdapters()) {
520:                                 if (CategorizationVisibilityAdapter.class.isInstance(adapter)) {
521:                                         toRemove.add(adapter);
522:                                 }
523:                         }
524:                         categorization.eAdapters().removeAll(toRemove);
525:                 }
526:                 super.dispose();
527:         }
528: }