Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java26
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java15
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java7
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend66
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/AbstractFSMProviderDispatcher.java11
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramProvider.xtend75
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramExtensions.xtend29
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java11
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java15
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/commands/UpdateCommand.java23
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java14
12 files changed, 244 insertions, 51 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF
index 150202ee5..d1e859f90 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF
@@ -5,7 +5,8 @@ Bundle-SymbolicName: org.eclipse.etrice.ui.behavior.fsm;singleton:=true
Bundle-Version: 1.1.0.qualifier
Bundle-Activator: org.eclipse.etrice.ui.behavior.fsm.Activator
Bundle-Vendor: eTrice
-Require-Bundle: org.eclipse.etrice.core.common.ui;bundle-version="1.1.0",
+Require-Bundle: org.eclipse.etrice.core.genmodel.fsm2;bundle-version="1.0.0",
+ org.eclipse.etrice.core.common.ui;bundle-version="1.1.0",
org.eclipse.etrice.ui.common.base;bundle-version="1.1.0",
org.eclipse.etrice.core.fsm;bundle-version="1.1.0",
org.eclipse.etrice.core.fsm.ui;bundle-version="1.1.0",
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java
index e2ca9158b..907066327 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/commands/PopulateDiagramCommand.java
@@ -16,42 +16,32 @@ import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
import org.eclipse.etrice.ui.behavior.fsm.support.ContextSwitcher;
-import org.eclipse.etrice.ui.behavior.fsm.support.util.DiagramEditingUtil;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
-import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.impl.UpdateContext;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.ui.services.GraphitiUi;
-import com.google.inject.Injector;
-
public class PopulateDiagramCommand extends RecordingCommand {
+ private String providerId;
private ModelComponent mc;
private Diagram diagram;
- private IFeatureProvider fp;
- private Injector injector;
- public PopulateDiagramCommand(String providerId, Diagram diag, ModelComponent mc, Injector injector, TransactionalEditingDomain domain) {
+ public PopulateDiagramCommand(String providerId, Diagram diag, ModelComponent mc, TransactionalEditingDomain domain) {
super(domain);
+ this.providerId = providerId;
this.diagram = diag;
this.mc = mc;
- this.injector = injector;
-
- IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, providerId); //$NON-NLS-1$
- fp = dtp.getFeatureProvider();
}
@Override
protected void doExecute() {
+ IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, providerId); //$NON-NLS-1$
- fp.link(diagram, mc);
-
- // we use a temporary structure to create the whole tree
- StateGraphContext tree = StateGraphContext.createContextTree(mc, injector);
- //System.out.println(tree);
-
- DiagramEditingUtil.getInstance().addStateGraph(tree, diagram, fp);
+ dtp.getFeatureProvider().link(diagram, mc);
+ UpdateContext ctx = new UpdateContext(diagram);
+ dtp.getFeatureProvider().getUpdateFeature(ctx).update(ctx);
ContextSwitcher.switchTop(diagram);
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java
index 73c0ee1e4..94cd2fdbb 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java
@@ -12,6 +12,8 @@
package org.eclipse.etrice.ui.behavior.fsm.editor;
+import org.eclipse.etrice.ui.behavior.fsm.provider.GenModelProvider;
+import org.eclipse.etrice.ui.behavior.fsm.provider.IInjectorProvider;
import org.eclipse.graphiti.dt.AbstractDiagramTypeProvider;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.platform.IDiagramContainer;
@@ -21,7 +23,17 @@ import org.eclipse.graphiti.platform.IDiagramContainer;
* functionality provided by {@link AbstractFSMEditor}. Diagram editor plugins
* that extend {@link AbstractFSMEditor} should also extend and use this class.
*/
-public abstract class AbstractFSMDiagramTypeProvider extends AbstractDiagramTypeProvider {
+public abstract class AbstractFSMDiagramTypeProvider extends AbstractDiagramTypeProvider implements IInjectorProvider {
+
+ protected GenModelProvider genModelProvider;
+
+ public AbstractFSMDiagramTypeProvider(){
+ genModelProvider = new GenModelProvider(this);
+ }
+
+ public GenModelProvider getGenModelProvider() {
+ return genModelProvider;
+ }
/* (non-Javadoc)
* @see org.eclipse.graphiti.dt.AbstractDiagramTypeProvider#resourceReloaded(org.eclipse.graphiti.mm.pictograms.Diagram)
@@ -35,4 +47,5 @@ public abstract class AbstractFSMDiagramTypeProvider extends AbstractDiagramType
((AbstractFSMEditor)dgContainer).attachDiagnosingModelObserver();
}
}
+
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java
index 1e268175f..153364e21 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMEditor.java
@@ -13,6 +13,7 @@
package org.eclipse.etrice.ui.behavior.fsm.editor;
import java.util.ArrayList;
+import java.util.EventObject;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -270,4 +271,10 @@ public abstract class AbstractFSMEditor extends DiagramEditorBase {
featureProvider.updateIfPossible(updateCtx);
diagramTypeProvider.getDiagramBehavior().refresh();
}
+
+ @Override
+ public void commandStackChanged(EventObject event) {
+ // TODO Auto-generated method stub
+ super.commandStackChanged(event);
+ }
}
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
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/AbstractFSMProviderDispatcher.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/AbstractFSMProviderDispatcher.java
index 1b231a161..e08126e73 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/AbstractFSMProviderDispatcher.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/AbstractFSMProviderDispatcher.java
@@ -24,6 +24,7 @@ import org.eclipse.etrice.core.fsm.fSM.TrPoint;
import org.eclipse.etrice.core.fsm.fSM.Transition;
import org.eclipse.etrice.core.fsm.fSM.util.FSMSwitch;
import org.eclipse.etrice.core.fsm.naming.FSMFragmentProvider;
+import org.eclipse.etrice.ui.behavior.fsm.editor.AbstractFSMDiagramTypeProvider;
import org.eclipse.etrice.ui.behavior.fsm.provider.IInjectorProvider;
import org.eclipse.etrice.ui.common.base.support.CantDeleteFeature;
import org.eclipse.etrice.ui.common.base.support.CantRemoveFeature;
@@ -78,7 +79,7 @@ import org.eclipse.graphiti.util.IColorConstant;
import com.google.inject.Injector;
-public abstract class AbstractFSMProviderDispatcher implements IInjectorProvider {
+public class AbstractFSMProviderDispatcher {
private class FeatureProviderSwitch extends FSMSwitch<IFeatureProvider> {
private ContainerShape parent = null;
@@ -235,9 +236,9 @@ public abstract class AbstractFSMProviderDispatcher implements IInjectorProvider
private IInjectorProvider injectorProvider;
- public DispatchingFeatureProvider(IDiagramTypeProvider dtp, IInjectorProvider injectorProvider) {
+ public DispatchingFeatureProvider(AbstractFSMDiagramTypeProvider dtp) {
super(dtp);
- this.injectorProvider = injectorProvider;
+ this.injectorProvider = dtp;
}
@Override
@@ -550,9 +551,9 @@ public abstract class AbstractFSMProviderDispatcher implements IInjectorProvider
private DispatchingToolBehaviorProvider dispatchingBP;
- public AbstractFSMProviderDispatcher(IDiagramTypeProvider dtp) {
+ public AbstractFSMProviderDispatcher(AbstractFSMDiagramTypeProvider dtp) {
// create those first before using them
- dispatchingFP = new DispatchingFeatureProvider(dtp, this);
+ dispatchingFP = new DispatchingFeatureProvider(dtp);
dispatchingBP = new DispatchingToolBehaviorProvider(dtp);
stateGraphSupport = new StateGraphSupport(dtp, dispatchingFP);
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)
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramExtensions.xtend b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramExtensions.xtend
new file mode 100644
index 000000000..4481b6fb3
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramExtensions.xtend
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.util
+
+import org.eclipse.graphiti.mm.pictograms.PictogramElement
+import org.eclipse.graphiti.services.Graphiti
+import org.eclipse.graphiti.features.context.IPictogramElementContext
+import org.eclipse.emf.ecore.EObject
+
+class DiagramExtensions {
+
+ def static <T extends PictogramElement> getCastedPe(IPictogramElementContext ctx){
+ ctx.pictogramElement as T
+ }
+
+ def static <T extends EObject> getCastedBo(PictogramElement pe) {
+ Graphiti.linkService.getBusinessObjectForLinkedPictogramElement(pe) as T
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
index 2d6c2d87e..1be4d3e83 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
@@ -20,13 +20,9 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.ui.behavior.editor.BehaviorEditor;
import org.eclipse.etrice.ui.behavior.fsm.commands.PopulateDiagramCommand;
-import org.eclipse.etrice.ui.behavior.fsm.support.DiagramUpdateFeature;
import org.eclipse.etrice.ui.common.base.commands.UpdateCommand;
import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
-import org.eclipse.graphiti.dt.IDiagramTypeProvider;
-import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.mm.pictograms.Diagram;
-import org.eclipse.graphiti.ui.services.GraphitiUi;
public class DiagramAccess extends DiagramAccessBase {
@@ -90,8 +86,9 @@ public class DiagramAccess extends DiagramAccessBase {
@Override
protected Command getInitialCommand(EObject rootObject, Diagram diagram, TransactionalEditingDomain editingDomain) {
if (rootObject instanceof ModelComponent) {
- return new PopulateDiagramCommand("org.eclipse.etrice.ui.behavior.diagramTypeProvider", diagram, (ModelComponent) rootObject, Activator.getDefault().getInjector(), editingDomain);
+ return new PopulateDiagramCommand(DiagramTypeProvider.PROVIDER_ID, diagram, (ModelComponent) rootObject, editingDomain);
}
+
return null;
}
@@ -100,9 +97,7 @@ public class DiagramAccess extends DiagramAccessBase {
*/
@Override
protected Command getUpdateCommand(Diagram diagram, TransactionalEditingDomain editingDomain) {
- IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, DiagramTypeProvider.PROVIDER_ID); //$NON-NLS-1$
- IFeatureProvider featureProvider = dtp.getFeatureProvider();
- UpdateCommand cmd = new UpdateCommand(diagram, editingDomain, new DiagramUpdateFeature(featureProvider));
+ UpdateCommand cmd = new UpdateCommand(DiagramTypeProvider.PROVIDER_ID, diagram, editingDomain);
if (cmd.updateNeeded())
return cmd;
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
index bd53b5b8c..d9c59ed30 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
@@ -12,11 +12,12 @@
package org.eclipse.etrice.ui.behavior;
-import org.eclipse.etrice.ui.behavior.fsm.support.AbstractFSMProviderDispatcher;
-import org.eclipse.etrice.ui.behavior.support.ProviderDispatcher;
import org.eclipse.etrice.ui.behavior.fsm.editor.AbstractFSMDiagramTypeProvider;
+import org.eclipse.etrice.ui.behavior.fsm.support.AbstractFSMProviderDispatcher;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
+import com.google.inject.Injector;
+
public class DiagramTypeProvider extends AbstractFSMDiagramTypeProvider {
public static final String PROVIDER_ID = "org.eclipse.etrice.ui.behavior.diagramTypeProvider";
@@ -28,7 +29,7 @@ public class DiagramTypeProvider extends AbstractFSMDiagramTypeProvider {
public DiagramTypeProvider() {
super();
- dispatcher = new ProviderDispatcher(this);
+ dispatcher = new AbstractFSMProviderDispatcher(this);
setFeatureProvider(dispatcher.getFeatureProvider());
}
@@ -36,8 +37,7 @@ public class DiagramTypeProvider extends AbstractFSMDiagramTypeProvider {
public IToolBehaviorProvider[] getAvailableToolBehaviorProviders() {
if (toolBehaviorProviders == null) {
toolBehaviorProviders =
- new IToolBehaviorProvider[] {
- dispatcher.getToolBehaviorProvider() };
+ new IToolBehaviorProvider[] { dispatcher.getToolBehaviorProvider() };
}
return toolBehaviorProviders;
}
@@ -65,4 +65,9 @@ public class DiagramTypeProvider extends AbstractFSMDiagramTypeProvider {
public boolean isAutoUpdateAtRuntime() {
return USE_AUTO_UPDATE;
}
+
+ @Override
+ public Injector getInjector() {
+ return Activator.getDefault().getInjector();
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/commands/UpdateCommand.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/commands/UpdateCommand.java
index c96378159..4e7837b3d 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/commands/UpdateCommand.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/commands/UpdateCommand.java
@@ -10,9 +10,10 @@ package org.eclipse.etrice.ui.common.base.commands;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.context.impl.UpdateContext;
-import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.ui.services.GraphitiUi;
/**
* @author Henrik Rentz-Reichert - initial contribution and API
@@ -20,26 +21,26 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
*/
public class UpdateCommand extends RecordingCommand {
- private Diagram diagram;
- private AbstractUpdateFeature feature;
+ private IDiagramTypeProvider dtp;
- public UpdateCommand(Diagram diag, TransactionalEditingDomain domain, AbstractUpdateFeature feature) {
- super(domain);
- this.feature = feature;
+ public UpdateCommand(String providerId, Diagram diagram, TransactionalEditingDomain editingDomain) {
+ super(editingDomain);
+
+ dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, providerId); //$NON-NLS-1$
}
public boolean updateNeeded() {
- UpdateContext context = new UpdateContext(diagram);
- return feature.updateNeeded(context).toBoolean();
+ UpdateContext ctx = new UpdateContext(dtp.getDiagram());
+ return dtp.getFeatureProvider().getUpdateFeature(ctx).updateNeeded(ctx).toBoolean();
}
/* (non-Javadoc)
* @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
*/
@Override
- protected void doExecute() {
- UpdateContext context = new UpdateContext(diagram);
- feature.update(context);
+ protected void doExecute() {
+ UpdateContext ctx = new UpdateContext(dtp.getDiagram());
+ dtp.getFeatureProvider().getUpdateFeature(ctx).update(ctx);
}
}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
index 42ef42770..ea44ea81b 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
@@ -64,8 +64,8 @@ public abstract class DiagramAccessBase {
super();
injectMembers();
}
-
- public Diagram getDiagram(EObject rootObject) {
+
+ public Diagram getDiagram(EObject rootObject){
Resource resource = rootObject.eResource();
if (resource==null)
return null;
@@ -74,6 +74,16 @@ public abstract class DiagramAccessBase {
ResourceSet rs = newResourceSet(uri);
+ return getDiagram(rootObject, rs);
+ }
+
+ public Diagram getDiagram(EObject rootObject, ResourceSet rs) {
+ Resource resource = rootObject.eResource();
+ if (resource==null)
+ return null;
+
+ URI uri = resource.getURI();
+
URI diagURI = null;
boolean exists = false;
if (uri.isPlatformResource()) {

Back to the top