Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a2b9e6e0df4c45d3a2a7cb2b98472d4babe68488 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
«IMPORT "http://www.eclipse.org/gmf/2005/GenModel/2.0"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»

«DEFINE SheetLabelProvider FOR gmfgen::GenPropertySheet-»
«EXPAND xpt::Common::copyright FOR editorGen»
package «packageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «labelProviderClassName» extends org.eclipse.jface.viewers.DecoratingLabelProvider {
	«EXPAND xpt::Common::generatedMemberComment»
	public «labelProviderClassName»() {
		super(new org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider(«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory()), null);
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public String getText(Object element) {
		Object selected = unwrap(element); 
«IF null != editorGen.navigator && null != editorGen.application»
		if (selected instanceof «editorGen.navigator.getNavigatorGroupQualifiedClassName()») {
			return ((«editorGen.navigator.getNavigatorGroupQualifiedClassName()») selected).getGroupName();
		}
«ENDIF»
		return super.getText(selected);
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public org.eclipse.swt.graphics.Image getImage(Object element) {
		return super.getImage(unwrap(element));
	}

	«EXPAND unwrap-»
	«EXPAND unwrapView-»
	«EXPAND unwrapEditPart-»
}
«ENDDEFINE»

«DEFINE unwrap FOR gmfgen::GenPropertySheet-»
	«EXPAND xpt::Common::generatedMemberComment»
	private Object unwrap(Object element) {
		if (element instanceof org.eclipse.jface.viewers.IStructuredSelection) {
			return unwrap(((org.eclipse.jface.viewers.IStructuredSelection) element).getFirstElement());
		}
		if (element instanceof org.eclipse.gef.EditPart) {
			return unwrapEditPart((org.eclipse.gef.EditPart) element);
		}
		if (element instanceof org.eclipse.core.runtime.IAdaptable) {
			org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) ((org.eclipse.core.runtime.IAdaptable) element).getAdapter(org.eclipse.gmf.runtime.notation.View.class);
			if (view != null) {
				return unwrapView(view);
			}
		}
		return element;
	}
«ENDDEFINE»

«DEFINE unwrapView FOR gmfgen::GenPropertySheet-»
	«EXPAND xpt::Common::generatedMemberComment»
	private Object unwrapView(org.eclipse.gmf.runtime.notation.View view) {
		return view.getElement() == null ? view : view.getElement();
	}
«ENDDEFINE»

«DEFINE unwrapEditPart FOR gmfgen::GenPropertySheet-»
	«EXPAND xpt::Common::generatedMemberComment»
	private Object unwrapEditPart(org.eclipse.gef.EditPart p) {
		if (p.getModel() instanceof org.eclipse.gmf.runtime.notation.View) {
			return unwrapView((org.eclipse.gmf.runtime.notation.View) p.getModel());
		}
		return p.getModel();
	}
«ENDDEFINE»

Back to the top