diff options
Diffstat (limited to 'plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/templates/xpt/diagram/editpolicies/Utils.qvto')
-rw-r--r-- | plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/templates/xpt/diagram/editpolicies/Utils.qvto | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/templates/xpt/diagram/editpolicies/Utils.qvto b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/templates/xpt/diagram/editpolicies/Utils.qvto deleted file mode 100644 index c0862fe2f21..00000000000 --- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/templates/xpt/diagram/editpolicies/Utils.qvto +++ /dev/null @@ -1,118 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Alexander Shatalin (Borland) - initial API and implementation - * Michael Golubev (Borland) - [243151] explicit source/target for links - * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174 - *****************************************************************************/ -import xpt.diagram.editpolicies.LinkUtils; -import xpt.GenModelUtils; - -modeltype gmfgen uses "http://www.eclipse.org/papyrus/gmf/2020/GenModel"; - -library Utils; - -helper hasChildrenOrCompartments(node : gmfgen::GenNode) : Boolean { - return not node.childNodes->isEmpty() or not node.compartments->isEmpty() -} - -helper getContainerVariable(modelFacet : gmfgen::TypeLinkModelFacet) : String { - return (if null <> modelFacet.sourceMetaFeature then 'container' else 'source' endif) -} - -helper getValidLinkConstraints(diagram : gmfgen::GenDiagram) : Sequence(gmfgen::GenLinkConstraints) { - return diagram.links->select(l | null <> l.creationConstraints and l.creationConstraints.isValid())->collect(l | l.creationConstraints) -} - -helper getAllPotentialLinks(linkEnd : gmfgen::GenLinkEnd) : Sequence(gmfgen::GenLink) { - return getAllRelatedLinks(linkEnd)->select(link | isCreationAllowed(link)) -} - -helper getReroutableTypeLinks(linkEnd : gmfgen::GenLinkEnd) : Sequence(gmfgen::GenLink) { - return getAllRelatedReroutableLinks(linkEnd)->select(isTypeLink()) -} - -helper getReroutableRefLinks(linkEnd : gmfgen::GenLinkEnd) : Sequence(gmfgen::GenLink) { - return getAllRelatedReroutableLinks(linkEnd)->select(isRefLink()) -} - ---XXX[MG]: again, it would be better to use linkEnd.incomingLinks.union(linkEnd.outgoingLinks).toList() ---but it will change the ordering and produce meaningless diff in the generated code --- MODIFIERS: private cached -helper getAllRelatedLinks(linkEnd : gmfgen::GenLinkEnd) : Sequence(gmfgen::GenLink) { - return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) or canBeTarget(link, linkEnd))->asSequence() -} - --- MODIFIERS: private cached -helper getAllRelatedReroutableLinks(linkEnd : gmfgen::GenLinkEnd) : Sequence(gmfgen::GenLink) { - return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) and link.sourceReorientingAllowed or (canBeTarget(link, linkEnd) and link.targetReorientingAllowed))->asSequence() -} - --- MODIFIERS: private -helper isCreationAllowed(link : gmfgen::GenLink) : Boolean { - return null <> link.modelFacet and (link.outgoingCreationAllowed or link.incomingCreationAllowed) -} - -helper createStartLinkCommand(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return createStartOutgoingLinkCommand(link, linkEnd) or createStartIncomingLinkCommand(link, linkEnd) -} - -helper createStartOutgoingLinkCommand(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return isSelf(link, linkEnd) or (isOutgoing(link, linkEnd) and link.outgoingCreationAllowed) -} - -helper createStartIncomingLinkCommand(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return isIncoming(link, linkEnd) and link.incomingCreationAllowed -} - -helper createCompleteLinkCommand(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return createCompleteIncomingLinkCommand(link, linkEnd) or createCompleteOutgoingLinkCommand(link, linkEnd) -} - -helper createCompleteIncomingLinkCommand(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return isSelf(link, linkEnd) or (isIncoming(link, linkEnd) and link.outgoingCreationAllowed) -} - -helper createCompleteOutgoingLinkCommand(link : gmfgen::GenLink, linkEnd : gmfgen::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 -} - --- MODIFIERS: private -helper isSelf(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return canBeSource(link, linkEnd) and canBeTarget(link, linkEnd) -} - --- MODIFIERS: private -helper isOutgoing(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return canBeSource(link, linkEnd) and not canBeTarget(link, linkEnd) -} - --- MODIFIERS: private -helper isIncoming(link : gmfgen::GenLink, linkEnd : gmfgen::GenLinkEnd) : Boolean { - return canBeTarget(link, linkEnd) and not canBeSource(link, linkEnd) -} - -helper i18nKeyForOpenCommandName() : String { - return 'CommandName.OpenDiagram' -} --- if child's containment feature comes from the node, assume deletion of the parent would delete the child. -helper GenChildNode::isDirectlyOwned(genNode : GenNode) : Boolean { - if self.modelFacet.oclIsUndefined() or genNode.modelFacet.oclIsUndefined() then return false endif; -- can't assume anything - return self.modelFacet.containmentMetaFeature.genClass.isSuperTypeOf(genNode.modelFacet.metaClass) -} |