Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2008-12-29 07:41:38 -0500
committerashatalin2008-12-29 07:41:38 -0500
commitfc1dfb3b462e159eec1b6031bb41ab79c762474b (patch)
tree66acb7873f68640147106dcd919a5041ecbc918b /plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
parent7f3bb1960b122d5d9c4edae8dc1c330032c9cf60 (diff)
downloadorg.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.gz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.xz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.zip
QVTO-based xpand implementation was merged to HEAD
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto90
1 files changed, 90 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
new file mode 100644
index 000000000..cdb4a132c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
@@ -0,0 +1,90 @@
+import xpt.diagram.editpolicies.LinkUtils;
+import xpt.GenModelUtils;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Utils;
+
+helper hasChildrenOrCompartments(node : genModel::GenNode) : Boolean {
+ return not node.childNodes->isEmpty() or not node.compartments->isEmpty()
+}
+
+helper getContainerVariable(modelFacet : genModel::TypeLinkModelFacet) : String {
+ return (if null <> modelFacet.sourceMetaFeature then 'container' else 'source' endif)
+}
+
+helper getValidLinkConstraints(diagram : genModel::GenDiagram) : Sequence(genModel::GenLinkConstraints) {
+ return diagram.links->select(l | null <> l.creationConstraints and l.creationConstraints.isValid())->collect(l | l.creationConstraints)
+}
+
+helper getAllPotentialLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedLinks(linkEnd)->select(link | isCreationAllowed(link))
+}
+
+helper getReroutableTypeLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedReroutableLinks(linkEnd)->select(link | isTypeLink(link))
+}
+
+helper getReroutableRefLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedReroutableLinks(linkEnd)->select(link | isRefLink(link))
+}
+
+helper getAllRelatedLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) or canBeTarget(link, linkEnd))->asSequence()
+}
+
+helper getAllRelatedReroutableLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) and link.sourceReorientingAllowed or (canBeTarget(link, linkEnd) and link.targetReorientingAllowed))->asSequence()
+}
+
+helper isCreationAllowed(link : genModel::GenLink) : Boolean {
+ return null <> link.modelFacet and (link.outgoingCreationAllowed or link.incomingCreationAllowed)
+}
+
+helper createStartLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return createStartOutgoingLinkCommand(link, linkEnd) or createStartIncomingLinkCommand(link, linkEnd)
+}
+
+helper createStartOutgoingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isSelf(link, linkEnd) or (isOutgoing(link, linkEnd) and link.outgoingCreationAllowed)
+}
+
+helper createStartIncomingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isIncoming(link, linkEnd) and link.incomingCreationAllowed
+}
+
+helper createCompleteLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return createCompleteIncomingLinkCommand(link, linkEnd) or createCompleteOutgoingLinkCommand(link, linkEnd)
+}
+
+helper createCompleteIncomingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isSelf(link, linkEnd) or (isIncoming(link, linkEnd) and link.outgoingCreationAllowed)
+}
+
+helper createCompleteOutgoingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isOutgoing(link, linkEnd) and link.incomingCreationAllowed
+}
+
+helper checkSource(reversedRequest : Boolean, isCompleteCommand : Boolean) : Boolean {
+ return not reversedRequest or isCompleteCommand
+}
+
+helper checkTarget(reversedRequest : Boolean, isCompleteCommand : Boolean) : Boolean {
+ return reversedRequest or isCompleteCommand
+}
+
+helper isSelf(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeSource(link, linkEnd) and canBeTarget(link, linkEnd)
+}
+
+helper isOutgoing(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeSource(link, linkEnd) and not canBeTarget(link, linkEnd)
+}
+
+helper isIncoming(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeTarget(link, linkEnd) and not canBeSource(link, linkEnd)
+}
+
+helper i18nKeyForOpenCommandName() : String {
+ return 'CommandName.OpenDiagram'
+}

Back to the top