01: package newprocess.diagram.sheet;
02:
03: import org.eclipse.gef.EditPart;
04: import org.eclipse.gmf.runtime.notation.View;
05: import org.eclipse.jface.viewers.IStructuredSelection;
06: import org.eclipse.swt.graphics.Image;
07: import newprocess.diagram.navigator.New_processNavigatorGroup;
08:
09: import newprocess.diagram.part.New_processDiagramEditorPlugin;
10:
11: import org.eclipse.core.runtime.IAdaptable;
12:
13: import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
14:
15: import org.eclipse.jface.viewers.DecoratingLabelProvider;
16:
17: /**
18: * @generated
19: */
20: public class New_processSheetLabelProvider extends
21: DecoratingLabelProvider {
22:
23: /**
24: * @generated
25: */
26: public New_processSheetLabelProvider() {
27: super (new AdapterFactoryLabelProvider(
28: New_processDiagramEditorPlugin.getInstance()
29: .getItemProvidersAdapterFactory()), null);
30: }
31:
32: /**
33: * @generated
34: */
35: public String getText(Object element) {
36: Object selected = unwrap(element);
37: if (selected instanceof New_processNavigatorGroup) {
38: return ((New_processNavigatorGroup) selected)
39: .getGroupName();
40: }
41: return super .getText(selected);
42: }
43:
44: /**
45: * @generated
46: */
47: public Image getImage(Object element) {
48: return super .getImage(unwrap(element));
49: }
50:
51: /**
52: * @generated
53: */
54: private Object unwrap(Object element) {
55: if (element instanceof IStructuredSelection) {
56: return unwrap(((IStructuredSelection) element)
57: .getFirstElement());
58: }
59: if (element instanceof EditPart) {
60: return unwrapEditPart((EditPart) element);
61: }
62: if (element instanceof IAdaptable) {
63: View view = (View) ((IAdaptable) element)
64: .getAdapter(View.class);
65: if (view != null) {
66: return unwrapView(view);
67: }
68: }
69: return element;
70: }
71:
72: /**
73: * @generated
74: */
75: private Object unwrapEditPart(EditPart p) {
76: if (p.getModel() instanceof View) {
77: return unwrapView((View) p.getModel());
78: }
79: return p.getModel();
80: }
81:
82: /**
83: * @generated
84: */
85: private Object unwrapView(View view) {
86: return view.getElement() == null ? view : view.getElement();
87: }
88: }
|