422
|
1 |
/*
|
|
2 |
* Copyright (c) 2006, 2007 Borland Software Corporation
|
|
3 |
*
|
|
4 |
* All rights reserved. This program and the accompanying materials
|
|
5 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
6 |
* which accompanies this distribution, and is available at
|
|
7 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
8 |
*
|
|
9 |
* Contributors:
|
|
10 |
* Dmitry Stadnik (Borland) - initial API and implementation
|
|
11 |
*/
|
|
12 |
|
|
13 |
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
|
|
14 |
|
|
15 |
«DEFINE GraphicalNodeEditPolicy FOR gmfgen::GenNode-»
|
|
16 |
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
|
|
17 |
package «getDiagram().editPoliciesPackageName»;
|
|
18 |
|
|
19 |
«EXPAND xpt::Common::generatedClassComment»
|
|
20 |
public class «graphicalNodeEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy {
|
|
21 |
|
|
22 |
«EXPAND xpt::Common::generatedClassComment»
|
|
23 |
protected org.eclipse.gef.commands.Command getConnectionCompleteCommand(
|
|
24 |
org.eclipse.gef.requests.CreateConnectionRequest request) {
|
|
25 |
org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getElementType(request);
|
|
26 |
«FOREACH reorientedIncomingLinks AS link-»
|
|
27 |
if («getDiagram().getElementTypesQualifiedClassName()».«link.getUniqueIdentifier()» == elementType) {
|
|
28 |
«IF link.outgoingCreationAllowed-»
|
|
29 |
if (request.getSourceEditPart() != getHost()) {
|
|
30 |
«ENDIF-»
|
|
31 |
return getConnectionWithReorientedViewCompleteCommand(request);
|
|
32 |
«IF link.outgoingCreationAllowed-»
|
|
33 |
}
|
|
34 |
«ENDIF-»
|
|
35 |
}
|
|
36 |
«ENDFOREACH-»
|
|
37 |
return super.getConnectionCompleteCommand(request);
|
|
38 |
}
|
|
39 |
|
|
40 |
«EXPAND xpt::Common::generatedClassComment»
|
|
41 |
protected org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(
|
|
42 |
org.eclipse.gef.requests.CreateConnectionRequest request) {
|
|
43 |
if (request instanceof org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest) {
|
|
44 |
org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter requestAdapter =
|
|
45 |
((org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest) request)
|
|
46 |
.getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
|
|
47 |
return (org.eclipse.gmf.runtime.emf.type.core.IElementType) requestAdapter.getAdapter(
|
|
48 |
org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
|
|
49 |
}
|
|
50 |
return null;
|
|
51 |
}
|
|
52 |
|
|
53 |
«EXPAND xpt::Common::generatedClassComment»
|
|
54 |
protected org.eclipse.gef.commands.Command getConnectionWithReorientedViewCompleteCommand(
|
|
55 |
org.eclipse.gef.requests.CreateConnectionRequest request) {
|
|
56 |
org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy c =
|
|
57 |
(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) super.getConnectionCompleteCommand(request);
|
|
58 |
org.eclipse.gmf.runtime.common.core.command.CompositeCommand cc =
|
|
59 |
(org.eclipse.gmf.runtime.common.core.command.CompositeCommand) c.getICommand();
|
|
60 |
org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain =
|
|
61 |
((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
|
|
62 |
«getDiagram().getReorientConnectionViewCommandQualifiedClassName()» rcvCommand =
|
|
63 |
new «getDiagram().getReorientConnectionViewCommandQualifiedClassName()»(editingDomain, null);
|
|
64 |
rcvCommand.setEdgeAdaptor(getViewAdapter());
|
|
65 |
cc.compose(rcvCommand);
|
|
66 |
return c;
|
|
67 |
}
|
|
68 |
«EXPAND additions-»
|
|
69 |
}
|
|
70 |
«ENDDEFINE»
|
|
71 |
|
|
72 |
«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
|