Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 11c9dddbc897ba819853c25b3c51c32bbb66eb35 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * Copyright (c) 2006,2007 Borland Software Corporation
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Alexander Shatalin (Borland) - initial API and implementation
 */

«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»

«DEFINE ShortcutsDecoratorProvider FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::copyright FOR editorGen-»
package «providersPackageName»;

	«EXPAND xpt::Common::generatedClassComment»
public class «shortcutsDecoratorProviderClassName» extends org.eclipse.gmf.runtime.common.core.service.AbstractProvider implements org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider {

	«EXPAND attributes-»
	
	«EXPAND provides-»
	
	«EXPAND createDecorators-»
	
	«EXPAND ShortcutsDecorator-»

	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE attributes FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
public static final String SHORTCUTS_DECORATOR_ID = "shortcuts"; «EXPAND xpt::Common::nonNLS»
«ENDDEFINE»

«DEFINE provides FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
public boolean provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation) {
	if (!(operation instanceof org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation)) {
		return false;
	}
	org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget decoratorTarget = ((org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation) operation).getDecoratorTarget();
	org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) decoratorTarget.getAdapter(org.eclipse.gmf.runtime.notation.View.class);
	return view != null && «EXPAND xpt::editor::VisualIDRegistry::modelID».equals(«EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall»(view));
}
«ENDDEFINE»

«DEFINE createDecorators FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
public void createDecorators(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget decoratorTarget) {
	org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) decoratorTarget.getAdapter(org.eclipse.gmf.runtime.notation.View.class);
	if (view != null) {
		org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «EXPAND xpt::Common::nonNLS»
		if (annotation != null) {
			decoratorTarget.installDecorator(SHORTCUTS_DECORATOR_ID, new ShortcutsDecorator(decoratorTarget));
		}
	}
}
«ENDDEFINE»

«DEFINE ShortcutsDecorator FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedClassComment»
protected class ShortcutsDecorator extends org.eclipse.gmf.runtime.diagram.ui.services.decorator.AbstractDecorator {

	«EXPAND SD_constructor-»
	
	«EXPAND SD_activate-»

	«EXPAND SD_refresh-»

	«EXPAND SD_additions-»
}
«ENDDEFINE»

«DEFINE SD_constructor FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
public ShortcutsDecorator(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget decoratorTarget) {
	super(decoratorTarget);
}
«ENDDEFINE»

«DEFINE SD_activate FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
public void activate() {
	refresh();
}
«ENDDEFINE»

«DEFINE SD_refresh FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
public void refresh() {
	removeDecoration();
	org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) getDecoratorTarget().getAdapter(org.eclipse.gef.EditPart.class);
	org.eclipse.swt.graphics.Image image = «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getBundledImage("icons/shortcut.gif"); «EXPAND xpt::Common::nonNLS»
	if (editPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart) {
		setDecoration(getDecoratorTarget().addShapeDecoration(image, org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget.Direction.SOUTH_WEST, 0, false));
	} else if (editPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) {
		setDecoration(getDecoratorTarget().addConnectionDecoration(image, 50, false));
	}
}
«ENDDEFINE»

«DEFINE SD_additions FOR gmfgen::GenDiagram-»
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram-»
«ENDDEFINE»

Back to the top