Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: cdb4a132ce381e43eb5affca80180da425e824ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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