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