Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/Utils.qvto')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/Utils.qvto63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/Utils.qvto
new file mode 100644
index 000000000..18631d24e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/Utils.qvto
@@ -0,0 +1,63 @@
+import xpt.navigator.NativeUtils;
+
+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) + '.' + asValidJavaIdentifier(groupName)
+}
+
+helper i18nKeyForOpenDiagramActionName() : String {
+ return 'NavigatorActionProvider.OpenDiagramActionName'
+}

Back to the top