Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d586c035fa2f359c88db1bb7d06b06db49cd46ce (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
import org.eclipse.gmf.internal.codegen.util.CodeGenerationUtils;

modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";

library Utils;

helper getMaxVisualID(navigator : genModel::GenNavigator) : Integer {
	return (if getMaxVisualIDNavigatorNode(navigator)->size() = 1 then getMaxVisualIDNavigatorNode(navigator)->first().oclAsType(genModel::GenCommonBase).visualID else 0 endif)
}

helper getMaxVisualIDNavigatorNode(navigator : genModel::GenNavigator) : Sequence(genModel::GenCommonBase) {
	return getNavigatorNodes(navigator)->select(navigatorNode | isMaximumVisualID(navigatorNode, getNavigatorNodes(navigator)))
}

helper isMaximumVisualID(commonBase : genModel::GenCommonBase, allNavigatorNodes : Sequence(genModel::GenCommonBase)) : Boolean {
	return allNavigatorNodes->select(navigatorNode | navigatorNode.visualID > commonBase.visualID)->isEmpty()
}

helper isStringFeature(feature : genModel_1::GenFeature) : Boolean {
	return feature.ecoreFeature.eType.name = 'EString'
}

helper getNavigatorContainerNodes(navigator : genModel::GenNavigator) : Sequence(genModel::GenCommonBase) {
	return getNavigatorNodes(navigator)->select(n | getChildReferencesFrom(navigator, n)->size() > 0)
}

helper getNavigatorContainedNodes(navigator : genModel::GenNavigator) : Sequence(genModel::GenCommonBase) {
	return getNavigatorNodes(navigator)->select(n | getChildReferencesTo(navigator, n)->size() > 0)
}

helper getNavigatorNodes(navigator : genModel::GenNavigator) : Sequence(genModel::GenCommonBase) {
	return let diagram = navigator.editorGen.diagram in (((Sequence { diagram })[genModel::GenContainerBase]->union(diagram.topLevelNodes->asSequence())->union(diagram.childNodes->asSequence()))[genModel::GenCommonBase]->union(diagram.links->asSequence())->union(diagram.compartments->asSequence()))[genModel::GenCommonBase]
}

helper getGroupNames(_references : Sequence(genModel::GenNavigatorChildReference)) : Set(String) {
	return _references->select(ref | ref.isInsideGroup())->collect(ref | ref.groupName)->asOrderedSet()
}

helper getNavigatorReference(groupName : String, childReferences : Sequence(genModel::GenNavigatorChildReference)) : genModel::GenNavigatorChildReference {
	return childReferences->select(r | r.groupName = groupName)->first()
}

helper getChildReferencesFrom(navigator : genModel::GenNavigator, parent : genModel::GenCommonBase) : Sequence(genModel::GenNavigatorChildReference) {
	return navigator.childReferences->select(r | parent.visualID = r.parent.visualID)->asSequence()
}

helper getChildReferencesTo(navigator : genModel::GenNavigator, child : genModel::GenCommonBase) : Sequence(genModel::GenNavigatorChildReference) {
	return navigator.childReferences->select(r | child.visualID = r.child.visualID)->asSequence()
}

helper getDiagramTopReference(navigator : genModel::GenNavigator) : genModel::GenNavigatorChildReference {
	return let diagramTopReferences = navigator.childReferences->select(cr | null = cr.parent)->select(cr | cr.child = navigator.editorGen.diagram) in (if diagramTopReferences->size() = 0 then null else diagramTopReferences->at(0 + 1) endif)
}


helper i18nKeyForGroup(groupName : String, contextElement : genModel::GenCommonBase) : String {
	return 'NavigatorGroupName.' + (if null <> contextElement then contextElement.getUniqueIdentifier() else 'File' endif) + '.' + validJavaIdentifier(groupName)
}

helper i18nKeyForOpenDiagramActionName() : String {
	return 'NavigatorActionProvider.OpenDiagramActionName'
}

Back to the top