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/support/BaseDiagramProvider.xtend')
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramProvider.xtend75
1 files changed, 75 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramProvider.xtend
new file mode 100644
index 000000000..961b5da9d
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramProvider.xtend
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.support
+
+import java.util.Map
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.util.EcoreUtil
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent
+import org.eclipse.etrice.ui.behavior.fsm.editor.AbstractFSMDiagramTypeProvider
+import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase
+import org.eclipse.graphiti.mm.pictograms.Diagram
+import org.eclipse.graphiti.mm.pictograms.PictogramElement
+import org.eclipse.graphiti.mm.pictograms.PictogramLink
+import org.eclipse.graphiti.services.Graphiti
+
+/**
+ * Provides the PictogramElements from the base class diagram. Replacement for DefaultPositionProvider.
+ */
+class BaseDiagramProvider {
+
+ val DiagramAccessBase diagramAccess
+
+ val Map<EObject, PictogramElement> graphElements = newHashMap
+ val Map<EObject, PictogramElement> stateElements = newHashMap
+
+ new(AbstractFSMDiagramTypeProvider diagramTypeProvider) {
+ diagramAccess = diagramTypeProvider.injector.getInstance(DiagramAccessBase)
+
+ val mc = Graphiti.linkService.getBusinessObjectForLinkedPictogramElement(diagramTypeProvider.diagram)
+ if (mc instanceof ModelComponent)
+ visitDiagramRec(mc.base)
+ }
+
+ def void visitDiagramRec(ModelComponent mc) {
+ if(mc == null) return;
+
+ val rs = mc.eResource.resourceSet
+ // temporary load base diagram into current resourceSet to link its business objects against current resources
+ val diagram = diagramAccess.getDiagram(mc, mc.eResource.resourceSet)
+ if (diagram != null) {
+ mapPositions(diagram)
+ rs.resources.remove(diagram)
+ }
+
+ // visitDiagramRec(mc.base)
+ }
+
+ def mapPositions(Diagram diagram) {
+ // create mapping from business object to pictogram elements
+ EcoreUtil.ExternalCrossReferencer.find(diagram).forEach [ crossRef, eFeatureSetting |
+ eFeatureSetting.forEach [
+ // println(crossRef + " -> " + EObject)
+ if (EObject instanceof PictogramLink) {
+ val pe = (EObject as PictogramLink).pictogramElement
+ graphElements.put(crossRef, pe)
+ }
+ ]
+ ]
+ }
+
+ def getBasePictogram(EObject roomObj) {
+ return graphElements.get(roomObj)
+ }
+
+}

Back to the top