Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend')
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend66
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend
new file mode 100644
index 000000000..0f0d874eb
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.behavior.fsm.provider
+
+import java.util.Map
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent
+import org.eclipse.etrice.core.genmodel.fsm.BasicFsmGenBuilder
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node
+import org.eclipse.etrice.ui.behavior.fsm.editor.AbstractFSMDiagramTypeProvider
+import org.eclipse.graphiti.dt.IDiagramTypeProvider
+import org.eclipse.graphiti.services.Graphiti
+
+class GenModelProvider {
+
+ val BasicFsmGenBuilder builder
+ val IDiagramTypeProvider fsmDiagramProvider
+ var Map<EObject, EObject> graphMap = newHashMap
+
+ var GraphContainer modelInstance = null
+
+ new(AbstractFSMDiagramTypeProvider fsmDiagramProvider) {
+ this.fsmDiagramProvider = fsmDiagramProvider
+ builder = new BasicFsmGenBuilder(fsmDiagramProvider.injector)
+ }
+
+ def updateModel() {
+ Graphiti.linkService.getBusinessObjectForLinkedPictogramElement(fsmDiagramProvider.diagram) => [
+ modelInstance = if(it instanceof ModelComponent) builder.createTransformedModel(it) else null
+ ]
+ if (modelInstance != null) {
+ graphMap = modelInstance.eAllContents.toMap [
+ switch (it) {
+ Graph: stateGraph
+ Node: stateGraphNode
+ Link: transition
+ }
+ ]
+ }
+ }
+
+ def getModel() {
+ if (modelInstance == null) {
+ updateModel()
+ }
+
+ return modelInstance;
+ }
+
+ def <T extends EObject> getCasted(EObject roomObj) {
+ return graphMap.get(roomObj) as T
+ }
+}

Back to the top