Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-06-08 10:04:23 +0000
committerHenrik Rentz-Reichert2011-06-08 10:04:23 +0000
commit9c806c53db8952032a6413df75606916fcee0ff6 (patch)
tree7f970b17f913d080ccf3044007921fa31e934526 /plugins
parenta74a1a64059d318a5360f598bf97d230eae96ceb (diff)
downloadorg.eclipse.etrice-9c806c53db8952032a6413df75606916fcee0ff6.tar.gz
org.eclipse.etrice-9c806c53db8952032a6413df75606916fcee0ff6.tar.xz
org.eclipse.etrice-9c806c53db8952032a6413df75606916fcee0ff6.zip
[ui.common/structure] implemented auto update
A new AutoUpdateFeature has been introduced which is invoked for the Diagram. It recursively calls update features for all Connections and Shapes. The DiagramAccess also runs an UpdateCommand for existing diagrams.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java2
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/DiagramAccessBase.java56
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/ProviderDispatcher.java5
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java3
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/UpdateCommand.java47
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureEditor.java12
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/AutoUpdateFeature.java98
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java7
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java15
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SupportUtil.java22
13 files changed, 250 insertions, 42 deletions
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 f2f84a6c2..969fbac3d 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
@@ -63,4 +63,12 @@ public class DiagramAccess extends DiagramAccessBase {
TransactionalEditingDomain editingDomain) {
return new PopulateDiagramCommand(diagram, (ActorClass) ac, editingDomain);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.ui.common.DiagramAccessBase#getUpdateCommand(org.eclipse.graphiti.mm.pictograms.Diagram, org.eclipse.emf.transaction.TransactionalEditingDomain)
+ */
+ @Override
+ protected Command getUpdateCommand(Diagram diagram, TransactionalEditingDomain editingDomain) {
+ return null;
+ }
}
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 2d8617af1..68bb760ba 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
@@ -17,6 +17,8 @@ import org.eclipse.graphiti.tb.IToolBehaviorProvider;
public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
+ public static final String PROVIDER_ID = "org.eclipse.etrice.ui.structure.diagramTypeProvider";
+
private IToolBehaviorProvider[] toolBehaviorProviders;
private ProviderDispatcher dispatcher;
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/DiagramAccessBase.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/DiagramAccessBase.java
index 43b124161..ff50aa65e 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/DiagramAccessBase.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/DiagramAccessBase.java
@@ -59,9 +59,6 @@ public abstract class DiagramAccessBase {
URI uri = resource.getURI();
- // TODOHRR: put common diagram access code into ui.common
- // make abstract methods get fileEtension() and populateDiagram()
-
String modelName = ((RoomModel) sc.eContainer()).getName();
URI diagURI = null;
@@ -90,8 +87,11 @@ public abstract class DiagramAccessBase {
Resource diagRes = rs.getResource(diagURI, true);
if (diagRes.getContents().isEmpty())
return null;
- if (diagRes.getContents().get(0) instanceof Diagram)
- return (Diagram) diagRes.getContents().get(0);
+ if (diagRes.getContents().get(0) instanceof Diagram) {
+ Diagram diagram = (Diagram) diagRes.getContents().get(0);
+ updateDiagram(diagram);
+ return diagram;
+ }
}
else {
Resource diagRes = rs.createResource(diagURI);
@@ -99,7 +99,7 @@ public abstract class DiagramAccessBase {
Diagram diagram = Graphiti.getPeCreateService().createDiagram(getDiagramTypeId(), getDiagramName(sc), true);
diagRes.getContents().add(diagram);
- populatediagram(sc, diagram);
+ populateDiagram(sc, diagram);
try {
diagRes.save(Collections.EMPTY_MAP);
@@ -112,21 +112,8 @@ public abstract class DiagramAccessBase {
return null;
}
- private void populatediagram(StructureClass ac, Diagram diagram) {
- // CAUTION: if the IResourceSetProvider should be used it has to contain the diagram resource!
-// IProject project = null;
-// Resource resource = ac.eResource();
-// if (resource!=null) {
-// URI uri = resource.getURI();
-// if (uri.isPlatformResource()) {
-// uri = uri.trimSegments(1);
-// IFolder parentFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(uri.toPlatformString(true)));
-// project = parentFolder.getProject();
-// }
-// }
-//
-// IResourceSetProvider rsp = new XtextResourceSetProvider();
- ResourceSet rs = diagram.eResource().getResourceSet();//rsp.get(project);
+ private void populateDiagram(StructureClass ac, Diagram diagram) {
+ ResourceSet rs = diagram.eResource().getResourceSet();
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(rs);
if (editingDomain == null) {
// Not yet existing, create one
@@ -141,6 +128,31 @@ public abstract class DiagramAccessBase {
editingDomain.dispose();
}
+ /**
+ * @param diagram
+ */
+ private void updateDiagram(Diagram diagram) {
+ ResourceSet rs = diagram.eResource().getResourceSet();
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(rs);
+ if (editingDomain == null) {
+ // Not yet existing, create one
+ editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(rs);
+ }
+
+ Command updateCommand = getUpdateCommand(diagram, editingDomain);
+ if (updateCommand!=null) {
+ editingDomain.getCommandStack().execute(updateCommand);
+
+ try {
+ diagram.eResource().save(Collections.EMPTY_MAP);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ editingDomain.dispose();
+ }
+
public void openDiagramEditor(StructureClass sc) {
Diagram diagram = getDiagram(sc);
@@ -161,5 +173,5 @@ public abstract class DiagramAccessBase {
abstract protected String getEditorId();
abstract protected String getFileExtension();
abstract protected Command getInitialCommand(StructureClass ac, Diagram diagram, TransactionalEditingDomain editingDomain);
-
+ abstract protected Command getUpdateCommand(Diagram diagram, TransactionalEditingDomain editingDomain);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
index 0ed90adba..232edbc52 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.etrice.ui.common.DiagramAccessBase;
import org.eclipse.etrice.ui.structure.commands.PopulateDiagramCommand;
+import org.eclipse.etrice.ui.structure.commands.UpdateCommand;
import org.eclipse.etrice.ui.structure.editor.StructureEditor;
import org.eclipse.graphiti.mm.pictograms.Diagram;
@@ -43,4 +44,12 @@ public class DiagramAccess extends DiagramAccessBase {
protected Command getInitialCommand(StructureClass ac, Diagram diagram, TransactionalEditingDomain editingDomain) {
return new PopulateDiagramCommand(diagram, ac, editingDomain);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.ui.common.DiagramAccessBase#getUpdateCommand(org.eclipse.graphiti.mm.pictograms.Diagram, org.eclipse.emf.transaction.TransactionalEditingDomain)
+ */
+ @Override
+ protected Command getUpdateCommand(Diagram diagram, TransactionalEditingDomain editingDomain) {
+ return new UpdateCommand(diagram, editingDomain);
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java
index 79db96f25..ebdf9da9d 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java
@@ -27,7 +27,7 @@ import com.google.inject.Injector;
@SuppressWarnings("restriction")
public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
- private static final boolean AUTO_UPDATE = false;
+ private static final boolean USE_AUTO_UPDATE = true;
private IToolBehaviorProvider[] toolBehaviorProviders;
private ProviderDispatcher dispatcher;
@@ -64,7 +64,7 @@ public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
*/
@Override
public boolean isAutoUpdateAtStartup() {
- return AUTO_UPDATE;
+ return USE_AUTO_UPDATE;
}
/* (non-Javadoc)
@@ -72,7 +72,7 @@ public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
*/
@Override
public boolean isAutoUpdateAtReset() {
- return AUTO_UPDATE;
+ return USE_AUTO_UPDATE;
}
/* (non-Javadoc)
@@ -80,7 +80,7 @@ public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
*/
@Override
public boolean isAutoUpdateAtRuntime() {
- return AUTO_UPDATE;
+ return USE_AUTO_UPDATE;
}
public IScopeProvider getScopeProvider() {
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/ProviderDispatcher.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/ProviderDispatcher.java
index c0363163a..b65fc3bc5 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/ProviderDispatcher.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/ProviderDispatcher.java
@@ -17,6 +17,7 @@ import java.util.Arrays;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.naming.RoomFragmentProvider;
import org.eclipse.etrice.ui.structure.support.ActorContainerRefSupport;
+import org.eclipse.etrice.ui.structure.support.AutoUpdateFeature;
import org.eclipse.etrice.ui.structure.support.BindingSupport;
import org.eclipse.etrice.ui.structure.support.LayerConnectionSupport;
import org.eclipse.etrice.ui.structure.support.PortSupport;
@@ -48,6 +49,7 @@ import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
@@ -259,6 +261,9 @@ public class ProviderDispatcher {
@Override
public IUpdateFeature getUpdateFeature(IUpdateContext context) {
+ if (context.getPictogramElement() instanceof Diagram)
+ return new AutoUpdateFeature(this);
+
IFeatureProvider fp = featureSwitch.doSwitch(getBusinessObject(context));
if (fp!=null)
return fp.getUpdateFeature(context);
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java
index f0a0166e1..2a4a54dc6 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java
@@ -26,6 +26,7 @@ import org.eclipse.etrice.core.room.LayerConnection;
import org.eclipse.etrice.core.room.LogicalSystem;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.ui.behavior.DiagramTypeProvider;
import org.eclipse.etrice.ui.structure.support.StructureClassSupport;
import org.eclipse.etrice.ui.structure.support.SupportUtil;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
@@ -50,7 +51,7 @@ public class PopulateDiagramCommand extends RecordingCommand {
@Override
protected void doExecute() {
- IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, "org.eclipse.etrice.ui.structure.diagramTypeProvider"); //$NON-NLS-1$
+ IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, DiagramTypeProvider.PROVIDER_ID); //$NON-NLS-1$
IFeatureProvider featureProvider = dtp.getFeatureProvider();
AddContext addContext = new AddContext();
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/UpdateCommand.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/UpdateCommand.java
new file mode 100644
index 000000000..53fc3f257
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/UpdateCommand.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.structure.commands;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.etrice.ui.behavior.DiagramTypeProvider;
+import org.eclipse.etrice.ui.structure.support.AutoUpdateFeature;
+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;
+
+/**
+ * @author Henrik Rentz-Reichert - initial contribution and API
+ *
+ */
+public class UpdateCommand extends RecordingCommand {
+
+ private Diagram diagram;
+
+ public UpdateCommand(Diagram diag, TransactionalEditingDomain domain) {
+ super(domain);
+ this.diagram = diag;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ */
+ @Override
+ protected void doExecute() {
+ IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(diagram, DiagramTypeProvider.PROVIDER_ID); //$NON-NLS-1$
+ IFeatureProvider featureProvider = dtp.getFeatureProvider();
+
+ UpdateContext context = new UpdateContext(diagram);
+ AutoUpdateFeature feature = new AutoUpdateFeature(featureProvider);
+ feature.update(context);
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureEditor.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureEditor.java
index 7a5436f08..42c43a735 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureEditor.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureEditor.java
@@ -17,6 +17,7 @@ import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.ui.common.editor.RoomDiagramEditor;
import org.eclipse.etrice.ui.structure.Activator;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
@@ -46,4 +47,15 @@ public class StructureEditor extends RoomDiagramEditor {
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal#setInput(org.eclipse.ui.IEditorInput)
+ */
+ @SuppressWarnings("restriction")
+ @Override
+ protected void setInput(IEditorInput input) {
+ super.setInput(input);
+
+ doSave(null);
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/AutoUpdateFeature.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/AutoUpdateFeature.java
new file mode 100644
index 000000000..be50adc21
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/AutoUpdateFeature.java
@@ -0,0 +1,98 @@
+package org.eclipse.etrice.ui.structure.support;
+
+import java.util.ArrayList;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.IReason;
+import org.eclipse.graphiti.features.IUpdateFeature;
+import org.eclipse.graphiti.features.context.IUpdateContext;
+import org.eclipse.graphiti.features.context.impl.UpdateContext;
+import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
+import org.eclipse.graphiti.features.impl.Reason;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+
+/**
+ * @author Henrik Rentz-Reichert - initial contribution and API
+ *
+ */
+public class AutoUpdateFeature extends AbstractUpdateFeature {
+
+ public AutoUpdateFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public boolean canUpdate(IUpdateContext context) {
+ return true;
+ }
+
+ @Override
+ public IReason updateNeeded(IUpdateContext context) {
+ return Reason.createFalseReason();
+ }
+
+ @Override
+ public boolean update(IUpdateContext context) {
+ boolean doneChanges = updateConnections(getDiagram());
+
+ if (updateIfNeeded(getDiagram()))
+ doneChanges = true;
+
+ if (doneChanges)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * This just removes dangling connections (bindings and layer connections).
+ * New ones are added by the structure class support.
+ *
+ * @param diagram
+ * @return
+ */
+ private boolean updateConnections(Diagram diagram) {
+ boolean doneChanges = false;
+
+ ArrayList<Connection> connections = new ArrayList<Connection>(diagram.getConnections());
+ for (Connection conn : connections) {
+ UpdateContext context = new UpdateContext(conn);
+ IUpdateFeature updateFeature = getFeatureProvider().getUpdateFeature(context);
+ if (updateFeature.canUpdate(context))
+ if (updateFeature.updateNeeded(context).toBoolean())
+ if (updateFeature.update(context))
+ doneChanges = true;
+ }
+ return doneChanges;
+ }
+
+ /**
+ * @param diagram
+ * @return
+ */
+ private boolean updateIfNeeded(ContainerShape container) {
+ boolean doneChanges = false;
+
+ // first recursion because ref ports might be needed for bindings
+ // we need to make a copy since children might be removed
+ ArrayList<Shape> children = new ArrayList<Shape>(container.getChildren());
+ for (Shape child : children) {
+ if (child instanceof ContainerShape)
+ if (updateIfNeeded((ContainerShape) child))
+ doneChanges = true;
+ }
+
+ UpdateContext context = new UpdateContext(container);
+ IUpdateFeature updateFeature = getFeatureProvider().getUpdateFeature(context);
+ if (updateFeature.canUpdate(context))
+ if (updateFeature.updateNeeded(context).toBoolean())
+ if (updateFeature.update(context))
+ doneChanges = true;
+
+ return doneChanges;
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java
index fe0f3d7c7..ebbeaa932 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java
@@ -44,7 +44,6 @@ import org.eclipse.graphiti.features.impl.Reason;
import org.eclipse.graphiti.mm.algorithms.Polyline;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
-import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
@@ -332,10 +331,10 @@ public class BindingSupport {
@Override
public boolean update(IUpdateContext context) {
- ContainerShape containerShape = (ContainerShape)context.getPictogramElement();
- Object bo = getBusinessObjectForPictogramElement(containerShape);
+ PictogramElement pe = context.getPictogramElement();
+ Object bo = getBusinessObjectForPictogramElement(pe);
if (bo instanceof EObject && ((EObject)bo).eIsProxy()) {
- IRemoveContext rc = new RemoveContext(containerShape);
+ IRemoveContext rc = new RemoveContext(pe);
IFeatureProvider featureProvider = getFeatureProvider();
IRemoveFeature removeFeature = featureProvider.getRemoveFeature(rc);
if (removeFeature != null) {
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
index 59553576c..8dc95a778 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
@@ -312,8 +312,7 @@ public class StructureClassSupport {
}
StructureClass sc = (StructureClass) bo;
- HashMap<String, Anchor> ifitem2anchor = new HashMap<String, Anchor>();
- addMissingItems(sc, containerShape, ifitem2anchor, fp);
+ addMissingItems(sc, containerShape, fp);
return true;
}
@@ -559,8 +558,8 @@ public class StructureClassSupport {
// we don't have to recurse since the base class diagram already contains all inherited items
Diagram diag = (Diagram) acShape.eContainer();
ResourceSet rs = ac.eResource().getResourceSet();
- List<InterfaceItem> presentIfItems = SupportUtil.getInterfaceItems(acShape, fp);
- List<ActorContainerRef> presentRefs = SupportUtil.getRefs(acShape, fp);
+ List<InterfaceItem> presentIfItems = SupportUtil.getInterfaceItems(acShape, fp, ifitem2anchor);
+ List<ActorContainerRef> presentRefs = SupportUtil.getRefs(acShape, fp, ifitem2anchor);
List<Binding> presentBindings = SupportUtil.getBindings(diag, fp);
List<LayerConnection> presentConnections = SupportUtil.getConnections(diag, fp);
@@ -604,13 +603,15 @@ public class StructureClassSupport {
}
}
- public static void addMissingItems(StructureClass sc, ContainerShape acShape, Map<String,Anchor> ifitem2anchor, IFeatureProvider fp) {
+ public static void addMissingItems(StructureClass sc, ContainerShape acShape, IFeatureProvider fp) {
int width = acShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().get(0).getWidth();
+ HashMap<String, Anchor> ifitem2anchor = new HashMap<String, Anchor>();
+
// interface items
{
- List<InterfaceItem> present = SupportUtil.getInterfaceItems(acShape, fp);
+ List<InterfaceItem> present = SupportUtil.getInterfaceItems(acShape, fp, ifitem2anchor);
{
List<InterfaceItem> expected = RoomHelpers.getInterfaceItems(sc, false);
List<InterfaceItem> items = new ArrayList<InterfaceItem>();
@@ -633,7 +634,7 @@ public class StructureClassSupport {
// actor container references
{
- List<ActorContainerRef> present = SupportUtil.getRefs(acShape, fp);
+ List<ActorContainerRef> present = SupportUtil.getRefs(acShape, fp, ifitem2anchor);
List<ActorContainerRef> expected = RoomHelpers.getRefs(sc, false);
List<ActorContainerRef> items = new ArrayList<ActorContainerRef>();
for (ActorContainerRef item : expected) {
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SupportUtil.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SupportUtil.java
index 9bbb1c388..3d5d46860 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SupportUtil.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SupportUtil.java
@@ -149,7 +149,7 @@ public class SupportUtil {
String ep2 = getName(lc.getTo());
Anchor a1 = ifitem2anchor.get(ep1);
Anchor a2 = ifitem2anchor.get(ep2);
- assert(a1!=null && a2!=null): "ports for layer connection must be present";
+ assert(a1!=null && a2!=null): "spps for layer connection must be present";
AddConnectionContext context = new AddConnectionContext(a1, a2);
context.setNewObject(lc);
@@ -218,21 +218,35 @@ public class SupportUtil {
}
public static List<InterfaceItem> getInterfaceItems(ContainerShape shape, IFeatureProvider fp) {
+ return getInterfaceItems(shape, fp, null);
+ }
+
+ public static List<InterfaceItem> getInterfaceItems(ContainerShape shape, IFeatureProvider fp, Map<String, Anchor> ifitem2anchor) {
List<InterfaceItem> items = new ArrayList<InterfaceItem>();
for (Shape ch : shape.getChildren()) {
Object bo = fp.getBusinessObjectForPictogramElement(ch);
- if (bo instanceof InterfaceItem)
+ if (bo instanceof InterfaceItem) {
items.add((InterfaceItem)bo);
+ if (ifitem2anchor!=null)
+ ifitem2anchor.put(SEP+((InterfaceItem)bo).getName(), ch.getAnchors().get(0));
+ }
}
return items;
}
-
+
public static List<ActorContainerRef> getRefs(ContainerShape shape, IFeatureProvider fp) {
+ return getRefs(shape, fp, null);
+ }
+
+ public static List<ActorContainerRef> getRefs(ContainerShape shape, IFeatureProvider fp, Map<String, Anchor> ifitem2anchor) {
List<ActorContainerRef> refs = new ArrayList<ActorContainerRef>();
for (Shape ch : shape.getChildren()) {
Object bo = fp.getBusinessObjectForPictogramElement(ch);
- if (bo instanceof ActorContainerRef)
+ if (bo instanceof ActorContainerRef) {
refs.add((ActorContainerRef)bo);
+ if (ifitem2anchor!=null)
+ getAnchors((ActorContainerRef)bo, ch, ifitem2anchor);
+ }
}
return refs;
}

Back to the top