Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 68076ac9bfea7af0c9a83d93ba5da8f09ff9bc0c (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
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * Copyright (c) 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:
 *    bblajer (Borland) - initial API and implementation
 */

«IMPORT "http://www.eclipse.org/gmf/2006/GenModel"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
«EXTENSION xpt::diagram::parts::Common»
«EXTENSION xpt::diagram::parts::LabelController»

«DEFINE performRequest FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
public void performRequest(org.eclipse.gef.Request req) {
	«EXPAND performOpen-»
	«EXPAND performDirectEdit-»
	super.performRequest(req);
}
«ENDDEFINE»

«DEFINE performOpen FOR gmfgen::GenCommonBase-»
if (org.eclipse.gef.RequestConstants.REQ_OPEN.equals(req.getType())) {
	org.eclipse.gef.commands.Command command = getCommand(req);
	if (command != null && command.canExecute()) {
		getViewer().getEditDomain().getCommandStack().execute(command);
	}
	return;
}
«ENDDEFINE»

«DEFINE performOpen FOR gmfgen::GenDiagram»«ENDDEFINE»

«DEFINE performDirectEdit FOR gmfgen::GenCommonBase»«ENDDEFINE»

«DEFINE performDirectEdit FOR gmfgen::GenLabel»
«IF !isReadOnly()-»
«EXPAND performLabelDirectEdit-»
«ENDIF-»
«ENDDEFINE»

«DEFINE performDirectEdit FOR gmfgen::GenChildLabelNode-»
«IF !isReadOnly()-»
«EXPAND performLabelDirectEdit-»
«ENDIF-»
«ENDDEFINE»

«DEFINE performLabelDirectEdit FOR gmfgen::GenCommonBase-»
if (org.eclipse.gef.RequestConstants.REQ_DIRECT_EDIT.equals(req.getType()) && understandsRequest(req)) {
	performDirectEdit();
	return;
}
«ENDDEFINE»

«DEFINE performDirectEdit FOR gmfgen::GenNode-»
«EXPAND performDelegatingDirectEdit-»
«ENDDEFINE»

«DEFINE performDirectEdit FOR gmfgen::GenLink-»
«EXPAND performDelegatingDirectEdit-»
«ENDDEFINE»

«DEFINE performDelegatingDirectEdit FOR gmfgen::GenCommonBase-»
«IF getPrimaryLabel() != null-»
if (org.eclipse.gef.RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
	org.eclipse.gef.EditPart labelToEdit;
	if (req instanceof org.eclipse.gef.requests.DirectEditRequest) {
		labelToEdit = getLabelEditPart((org.eclipse.gef.requests.DirectEditRequest) req);
	} else {
		labelToEdit = getPrimaryLabelEditPart();
	}
	if (labelToEdit != null) {
		labelToEdit.performRequest(req);
	}
}
«ENDIF-»
«ENDDEFINE»

«DEFINE getLabelEditPart FOR gmfgen::GenCommonBase-»
«IF getPrimaryLabel() != null-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gef.EditPart getLabelEditPart(org.eclipse.gef.requests.DirectEditRequest req) {
	org.eclipse.gef.EditPart result = getViewer().findObjectAt(req.getLocation());
	if (result != null) {
		if («EXPAND xpt::diagram::parts::Common::getViewCode».getChildren().contains(result.getModel())) {
			org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) result.getModel();
			int visualId = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(view);
			switch (visualId) {
			«EXPAND returnLabelEditPart FOREACH getAllLabels().select(e| !e.readOnly)-»
			}
		}
	}
	return getPrimaryLabelEditPart();
}
«ENDIF-»
«ENDDEFINE»

«DEFINE returnLabelEditPart FOR gmfgen::GenLabel-»
case «getEditPartQualifiedClassName()».VISUAL_ID:
	return result;
«ENDDEFINE»

«DEFINE getPrimaryLabelEditPart FOR gmfgen::GenCommonBase-»
«IF getPrimaryLabel() != null-»
«EXPAND xpt::Common::generatedMemberComment("Returns the label which should be direct-edited by default.")»
private org.eclipse.gef.EditPart getPrimaryLabelEditPart() {
	for(java.util.Iterator it = «EXPAND xpt::diagram::parts::Common::getViewCode».getChildren().iterator(); it.hasNext(); ) {
		org.eclipse.gmf.runtime.notation.View nextChild = (org.eclipse.gmf.runtime.notation.View)it.next();
		if («getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(nextChild) == «getPrimaryLabel().getEditPartQualifiedClassName()».VISUAL_ID) {
			return (org.eclipse.gef.EditPart) getViewer().getEditPartRegistry().get(nextChild);
		}
	}
	return null;
}
«ENDIF-»
«ENDDEFINE»

Back to the top