carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/diagram/editpolicies/linkCommands.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) 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
 *    Alexander Shatalin (Borland) - initial API and implementation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    11
 *    Dmitry Stadnik (Borland) - creation logic was moved in commands
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    12
 */
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    13
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    14
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    15
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    16
«EXTENSION xpt::diagram::editpolicies::Utils»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    17
«EXTENSION xpt::GenModelUtils»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    18
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    19
«REM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    20
 * Start  		start of link creation. 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    21
 *				User click to this editpart and start dragging with link tool.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    22
 * Complete 	end of the command
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    23
 *				User points to this editpart as a link target and release mouse button.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    24
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    25
 * Outgoing 	the node is link source
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    26
 *				This element could be a source for this type of link.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    27
 * Incoming		the node is link destination
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    28
 *				This element could be a target for this type of link.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    29
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    30
 * Parameters:
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    31
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    32
 * 	diagram 	GenDiagram used to collect all defined links
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    33
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    34
 *	this		Instance of TypeModelFacet for the element link could be creates to/from.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    35
 *				This could be TypeModelFacet or TypeLinkModelFacet in case of links to links.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    36
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    37
«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    38
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    39
«DEFINE linkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    40
	«IF getAllPotentialLinks(diagram).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    41
		«EXPAND createLinkCommands(diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    42
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    43
	«IF getReroutableTypeLinks(diagram).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    44
		«EXPAND reorientTypeLinkCommands(diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    45
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    46
	«IF getReroutableRefLinks(diagram).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    47
		«EXPAND reorientRefLinkCommands(diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    48
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    49
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    50
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    51
«DEFINE createLinkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
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::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    54
protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    55
		org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    56
	org.eclipse.gef.commands.Command command = req.getTarget() == null ?
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    57
			getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    58
	return command != null ? command : super.getCreateRelationshipCommand(req);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    59
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    60
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    61
«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    62
protected org.eclipse.gef.commands.Command getStartCreateRelationshipCommand(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    63
		org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    64
	«EXPAND startLinkCommands(this) FOREACH getAllPotentialLinks(diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    65
	return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    66
}
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 xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    69
protected org.eclipse.gef.commands.Command getCompleteCreateRelationshipCommand(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    70
		org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    71
	«EXPAND completeLinkCommands(this) FOREACH getAllPotentialLinks(diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    72
	return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    73
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    74
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    75
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    76
«DEFINE startLinkCommands(gmfgen::TypeModelFacet typeModelFacet) FOR gmfgen::GenLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    77
if («getDiagram().getElementTypesQualifiedClassName()».«getUniqueIdentifier()» == req.getElementType()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    78
	«IF createStartLinkCommand(typeModelFacet)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    79
	return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    80
		«IF createStartIncomingLinkCommand(typeModelFacet)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    81
			req.getTarget(), req.getSource()
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    82
		«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    83
			req.getSource(), req.getTarget()
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    84
		«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    85
	));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    86
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    87
	return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    88
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    89
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    90
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    91
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    92
«DEFINE completeLinkCommands(gmfgen::TypeModelFacet typeModelFacet) FOR gmfgen::GenLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    93
if («getDiagram().getElementTypesQualifiedClassName()».«getUniqueIdentifier()» == req.getElementType()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    94
	«IF createCompleteLinkCommand(typeModelFacet)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    95
	return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    96
		«IF createCompleteOutgoingLinkCommand(typeModelFacet)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    97
			req.getTarget(), req.getSource()
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    98
		«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    99
			req.getSource(), req.getTarget()
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   100
		«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   101
	));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   102
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   103
	return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   104
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   105
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   106
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   107
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   108
«DEFINE reorientTypeLinkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   109
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   110
«EXPAND xpt::Common::generatedMemberComment(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   111
	"Returns command to reorient EClass based link. New link target or source\n" +
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   112
	"should be the domain model element associated with this node.\n"
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   113
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   114
protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   115
		org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   116
	switch (getVisualID(req)) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   117
	«EXPAND reorientLinkCommand FOREACH getReroutableTypeLinks(diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   118
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   119
	return super.getReorientRelationshipCommand(req);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   120
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   121
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   122
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   123
«DEFINE reorientRefLinkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   124
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   125
«EXPAND xpt::Common::generatedMemberComment(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   126
	"Returns command to reorient EReference based link. New link target or source\n" +
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   127
	"should be the domain model element associated with this node.\n"
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   128
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   129
protected org.eclipse.gef.commands.Command getReorientReferenceRelationshipCommand(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   130
		org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest req) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   131
	switch (getVisualID(req)) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   132
	«EXPAND reorientLinkCommand FOREACH getReroutableRefLinks(diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   133
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   134
	return super.getReorientReferenceRelationshipCommand(req);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   135
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   136
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   137
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   138
«DEFINE reorientLinkCommand FOR gmfgen::GenLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   139
«EXPAND xpt::Common::caseVisualID»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   140
	return getGEFWrapper(new «getReorientCommandQualifiedClassName()»(req));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   141
«ENDDEFINE»