Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-06-13 11:04:56 -0400
committerHenrik Rentz-Reichert2012-06-13 11:04:56 -0400
commit3fa02ad3599b19246a358c92d866d1ef754ae51f (patch)
tree04921fc30f6c1330a9f5de080ad7ec7a56ebccd3 /plugins/org.eclipse.etrice.ui.structure
parent5112716c93ab686c7822293e596c9baff18aab0e (diff)
downloadorg.eclipse.etrice-3fa02ad3599b19246a358c92d866d1ef754ae51f.tar.gz
org.eclipse.etrice-3fa02ad3599b19246a358c92d866d1ef754ae51f.tar.xz
org.eclipse.etrice-3fa02ad3599b19246a358c92d866d1ef754ae51f.zip
[core.room, ui.structure, generator.*, genmodel] bug 382440: introduce compound protocols
https://bugs.eclipse.org/bugs/show_bug.cgi?id=382440
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.structure')
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java89
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SPPPropertyDialog.java2
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SubProtocolSelectionDialog.java213
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java158
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java2
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java10
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java4
8 files changed, 429 insertions, 53 deletions
diff --git a/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF
index 95b9495cf..093b40dd0 100644
--- a/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF
@@ -15,7 +15,9 @@ Require-Bundle: org.eclipse.etrice.core.room.ui;bundle-version="0.1.0",
org.eclipse.gef;bundle-version="3.6.1",
org.eclipse.emf.transaction;bundle-version="1.4.0",
org.eclipse.xtext.ui;bundle-version="2.1.1",
- org.eclipse.xtext.ui.shared;bundle-version="2.1.1"
+ org.eclipse.xtext.ui.shared;bundle-version="2.1.1",
+ org.eclipse.jface.databinding;bundle-version="1.5.0",
+ org.eclipse.core.databinding.beans;bundle-version="1.2.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.etrice.ui.structure,
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java
index 086d813f2..3c19fa37b 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java
@@ -16,6 +16,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.beans.PojoObservables;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
@@ -42,7 +44,9 @@ import org.eclipse.xtext.scoping.IScope;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerClass;
import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.CompoundProtocolClass;
import org.eclipse.etrice.core.room.ExternalPort;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RoomFactory;
@@ -50,6 +54,7 @@ import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.ui.common.dialogs.AbstractPropertyDialog;
import org.eclipse.etrice.ui.structure.Activator;
+import org.eclipse.jface.databinding.swt.SWTObservables;
public class PortPropertyDialog extends AbstractPropertyDialog {
@@ -75,6 +80,10 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
if (value==null)
return ValidationStatus.error("select a protocol");
+ if (value instanceof CompoundProtocolClass)
+ if (!relay)
+ return ValidationStatus.error("compound protocol only possible for relay port");
+
return Status.OK_STATUS;
}
}
@@ -108,7 +117,8 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
if (m==-1 && !multAnyAllowed)
return ValidationStatus.error("multiplicity * not allowed (actor used replicated)");
- if (port.getProtocol()!=null && port.getProtocol().getCommType()==CommunicationType.DATA_DRIVEN) {
+ if (port.getProtocol()!=null)
+ if (port.getProtocol() instanceof ProtocolClass && ((ProtocolClass)port.getProtocol()).getCommType()==CommunicationType.DATA_DRIVEN) {
if (m!=1)
return ValidationStatus.error("data driven ports can not be replicated");
}
@@ -116,6 +126,22 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
return Status.OK_STATUS;
}
}
+
+ class RelayValidator implements IValidator {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.databinding.validation.IValidator#validate(java.lang.Object)
+ */
+ @Override
+ public IStatus validate(Object value) {
+ if (!((Boolean)value).booleanValue())
+ if (port.getProtocol() instanceof CompoundProtocolClass)
+ return ValidationStatus.error("external end port must not have compound protocol");
+
+ return Status.OK_STATUS;
+ }
+
+ }
static class Multiplicity2StringConverter extends Converter {
@@ -159,6 +185,7 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
private boolean internal;
private Button relayCheck = null;
private boolean relay;
+ private boolean oldRelay;
public PortPropertyDialog(Shell shell, Port port, IScope scope, ActorContainerClass acc, boolean newPort, boolean refitem, boolean internal) {
super(shell, "Edit Port");
@@ -170,6 +197,7 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
this.internal = internal;
relay = isPortRelay();
+ oldRelay = relay;
}
private boolean isPortRelay() {
@@ -214,12 +242,12 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
while (it.hasNext()) {
IEObjectDescription desc = it.next();
EObject obj = desc.getEObjectOrProxy();
- if (obj instanceof ProtocolClass)
+ if (obj instanceof GeneralProtocolClass)
protocols.add(desc);
}
Text name = createText(body, "&Name:", port, RoomPackage.eINSTANCE.getInterfaceItem_Name(), nv);
- Combo protocol = createComboUsingDesc(body, "&Protocol:", port, ProtocolClass.class, RoomPackage.eINSTANCE.getInterfaceItem_Protocol(), protocols, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
+ Combo protocol = createComboUsingDesc(body, "&Protocol:", port, GeneralProtocolClass.class, RoomPackage.eINSTANCE.getPort_Protocol(), protocols, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
Button conj = createCheck(body, "&Conjugated:", port, RoomPackage.eINSTANCE.getPort_Conjugated());
if (!internal && !refitem && (acc instanceof ActorClass))
createRelayCheck(body, notReferenced, mform.getToolkit());
@@ -268,33 +296,42 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
relayCheck.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
relayCheck.setSelection(relay);
relayCheck.setEnabled(notReferenced.isOk());
+
+ RelayValidator validator = new RelayValidator();
+ UpdateValueStrategy t2m = new UpdateValueStrategy();
+ t2m.setAfterConvertValidator(validator);
+ t2m.setBeforeSetValidator(validator);
+ UpdateValueStrategy m2t = new UpdateValueStrategy();
+ m2t.setAfterConvertValidator(validator);
+ m2t.setBeforeSetValidator(validator);
+
+ getBindingContext().bindValue(SWTObservables.observeSelection(relayCheck), PojoObservables.observeValue(
+ this, "relay"), t2m, m2t);
- if (!notReferenced.isOk())
+ if (notReferenced.isOk())
+ createDecorator(relayCheck, "");
+ else
createInfoDecorator(relayCheck, notReferenced.getMsg());
}
@Override
protected void okPressed() {
- if (relayCheck!=null) {
- if (relay!=relayCheck.getSelection()) {
- relay = relayCheck.getSelection();
-
- // we know it's an ActorClass if we created the relayCheck in the first place
- ActorClass ac = (ActorClass) acc;
-
- if (relay) {
- for (ExternalPort xp : ac.getExtPorts()) {
- if (xp.getIfport()==port) {
- ac.getExtPorts().remove(xp);
- break;
- }
+ if (relay!=oldRelay) {
+ // we know it's an ActorClass (else the flag couldn't have changed)
+ ActorClass ac = (ActorClass) acc;
+
+ if (relay) {
+ for (ExternalPort xp : ac.getExtPorts()) {
+ if (xp.getIfport()==port) {
+ ac.getExtPorts().remove(xp);
+ break;
}
}
- else {
- ExternalPort xp = RoomFactory.eINSTANCE.createExternalPort();
- xp.setIfport(port);
- ac.getExtPorts().add(xp);
- }
+ }
+ else {
+ ExternalPort xp = RoomFactory.eINSTANCE.createExternalPort();
+ xp.setIfport(port);
+ ac.getExtPorts().add(xp);
}
}
@@ -305,4 +342,12 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
protected Image getImage() {
return Activator.getImage("icons/Structure.gif");
}
+
+ public boolean isRelay() {
+ return relay;
+ }
+
+ public void setRelay(boolean relay) {
+ this.relay = relay;
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SPPPropertyDialog.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SPPPropertyDialog.java
index e1e1bcaf1..a6a1f2b4e 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SPPPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SPPPropertyDialog.java
@@ -104,7 +104,7 @@ public class SPPPropertyDialog extends AbstractPropertyDialog {
}
Text name = createText(body, "Name:", spp, RoomPackage.eINSTANCE.getInterfaceItem_Name(), nv);
- Combo protocol = createComboUsingDesc(body, "Protocol:", spp, ProtocolClass.class, RoomPackage.eINSTANCE.getInterfaceItem_Protocol(), protocols, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
+ Combo protocol = createComboUsingDesc(body, "Protocol:", spp, ProtocolClass.class, RoomPackage.eINSTANCE.getSPPRef_Protocol(), protocols, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
if (!newSPP) {
// TODOHRR: check whether spp is used externally?
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SubProtocolSelectionDialog.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SubProtocolSelectionDialog.java
new file mode 100644
index 000000000..31567a72f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/SubProtocolSelectionDialog.java
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.structure.dialogs;
+
+import java.util.List;
+
+import org.eclipse.etrice.core.room.Binding;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.core.room.SubProtocol;
+import org.eclipse.etrice.core.room.util.CompoundProtocolHelpers;
+import org.eclipse.etrice.core.room.util.CompoundProtocolHelpers.Match;
+import org.eclipse.etrice.ui.structure.Activator;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.Form;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class SubProtocolSelectionDialog extends FormDialog {
+
+ private class MatchContentProvider implements IStructuredContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return matches.toArray();
+ }
+
+ }
+
+ private class MatchLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof Match) {
+ SubProtocol sub = (columnIndex==0)?
+ ((Match) element).getLeft() : ((Match) element).getRight();
+
+ if (sub==null)
+ return "-/"+((columnIndex==0)? src.getProtocol().getName() : dst.getProtocol().getName());
+ else
+ return sub.getName()+"/"+sub.getProtocol().getName();
+ }
+ return null;
+ }
+
+ }
+
+ private Port src;
+ private Port dst;
+ private TableViewer viewer;
+ private List<Match> matches;
+ private Match selected;
+
+ /**
+ * @param shell
+ */
+ public SubProtocolSelectionDialog(Shell shell, Port src, Port dst, Binding bind, StructureClass sc) {
+ super(shell);
+
+ this.src = src;
+ this.dst = dst;
+
+ matches = CompoundProtocolHelpers.getMatches(src, dst, sc, bind);
+
+ // find match to select
+ if (bind!=null) {
+ for (Match match : matches) {
+ if (match.getLeft()==bind.getEndpoint1().getSub() && match.getRight()==bind.getEndpoint2().getSub())
+ selected = match;
+ }
+ }
+ else
+ selected = matches.get(0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.FormDialog#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent(IManagedForm mform) {
+ super.createFormContent(mform);
+
+ Form form = mform.getForm().getForm();
+ form.setText("Connect SubProtocol(s)");
+ mform.getToolkit().decorateFormHeading(form);
+ form.setImage(Activator.getImage("icons/Structure.gif"));
+
+ Composite body = form.getBody();
+
+ Table matchTable = mform.getToolkit().createTable(body, SWT.NONE | SWT.SINGLE | SWT.FULL_SELECTION);
+ viewer = new TableViewer(matchTable);
+
+ TableColumn col0 = new TableColumn(viewer.getTable(), SWT.NONE);
+ col0.setText("Port "+src.getName());
+ TableColumn col1 = new TableColumn(viewer.getTable(), SWT.NONE);
+ col1.setText("Port "+dst.getName());
+ viewer.getTable().setHeaderVisible(true);
+
+ viewer.setContentProvider(new MatchContentProvider());
+ viewer.setLabelProvider(new MatchLabelProvider());
+
+ viewer.setInput(matches);
+
+ TableColumnLayout layout = new TableColumnLayout();
+ body.setLayout(layout);
+
+ layout.setColumnData(col0, new ColumnWeightData(50));
+ layout.setColumnData(col1, new ColumnWeightData(50));
+
+ viewer.setSelection(new StructuredSelection(selected));
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ Button ok = getButton(OK);
+ if (ok!=null) {
+ if (event.getSelection() instanceof IStructuredSelection) {
+ Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ ok.setEnabled(element instanceof Match);
+ }
+ else
+ ok.setEnabled(false);
+ }
+ }
+ });
+
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ ISelection selection = viewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ selected = (Match) ((IStructuredSelection) selection).getFirstElement();
+ }
+ super.okPressed();
+ }
+
+ public Match getSelected() {
+ return selected;
+ }
+}
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 d2db4c040..1b0ffb55b 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
@@ -12,11 +12,25 @@
package org.eclipse.etrice.ui.structure.support;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorContainerClass;
+import org.eclipse.etrice.core.room.ActorContainerRef;
+import org.eclipse.etrice.core.room.Binding;
+import org.eclipse.etrice.core.room.BindingEndPoint;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.LogicalSystem;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.RoomFactory;
+import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.validation.ValidationUtil;
import org.eclipse.etrice.ui.common.support.DeleteWithoutConfirmFeature;
import org.eclipse.etrice.ui.structure.ImageProvider;
+import org.eclipse.etrice.ui.structure.dialogs.SubProtocolSelectionDialog;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateConnectionFeature;
@@ -29,22 +43,28 @@ import org.eclipse.graphiti.features.IUpdateFeature;
import org.eclipse.graphiti.features.context.IAddConnectionContext;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.context.IDeleteContext;
+import org.eclipse.graphiti.features.context.IDoubleClickContext;
import org.eclipse.graphiti.features.context.IReconnectionContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.ReconnectionContext;
import org.eclipse.graphiti.features.context.impl.RemoveContext;
+import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
+import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
import org.eclipse.graphiti.features.impl.DefaultReconnectionFeature;
import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.features.impl.Reason;
+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
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.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
@@ -55,24 +75,16 @@ import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
-
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorContainerClass;
-import org.eclipse.etrice.core.room.ActorContainerRef;
-import org.eclipse.etrice.core.room.Binding;
-import org.eclipse.etrice.core.room.BindingEndPoint;
-import org.eclipse.etrice.core.room.LogicalSystem;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.RoomFactory;
-import org.eclipse.etrice.core.room.StructureClass;
-import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
public class BindingSupport {
public static final IColorConstant LINE_COLOR = new ColorConstant(0, 0, 0);
public static final IColorConstant INHERITED_COLOR = new ColorConstant(100, 100, 100);
- class FeatureProvider extends DefaultFeatureProvider {
+ static class FeatureProvider extends DefaultFeatureProvider {
private class CreateFeature extends AbstractCreateConnectionFeature {
@@ -110,7 +122,7 @@ public class BindingSupport {
ActorContainerRef tgtRef = SupportUtil.getRef(context.getTargetAnchor(), featureProvider);
- return ValidationUtil.isConnectable(src, srcRef, tgt, tgtRef, ac).isOk();
+ return ValidationUtil.isConnectable(src, srcRef, null, tgt, tgtRef, null, ac, null, false).isOk();
}
public boolean canStartConnection(ICreateConnectionContext context) {
@@ -144,8 +156,8 @@ public class BindingSupport {
IFeatureProvider featureProvider = getFeatureProvider();
Port src = SupportUtil.getPort(context.getSourceAnchor(), featureProvider);
Port dst = SupportUtil.getPort(context.getTargetAnchor(), featureProvider);
- StructureClass ac = SupportUtil.getParent(context, featureProvider);
- if (src!=null && dst!=null && ac!=null) {
+ StructureClass sc = SupportUtil.getParent(context, featureProvider);
+ if (src!=null && dst!=null && sc!=null) {
Binding bind = RoomFactory.eINSTANCE.createBinding();
BindingEndPoint ep1 = RoomFactory.eINSTANCE.createBindingEndPoint();
ActorContainerRef ar1 = SupportUtil.getRef(context.getSourceAnchor(), featureProvider);
@@ -157,7 +169,20 @@ public class BindingSupport {
ep2.setActorRef(ar2);
bind.setEndpoint1(ep1);
bind.setEndpoint2(ep2);
- ac.getBindings().add(bind);
+
+ GeneralProtocolClass srcGPC = src.getProtocol();
+ GeneralProtocolClass dstGPC = dst.getProtocol();
+ if (srcGPC instanceof GeneralProtocolClass || dstGPC instanceof GeneralProtocolClass) {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ SubProtocolSelectionDialog dlg = new SubProtocolSelectionDialog(shell, src, dst, null, sc);
+ if (dlg.open()!=Window.OK)
+ throw new OperationCanceledException();
+
+ ep1.setSub(dlg.getSelected().getLeft());
+ ep2.setSub(dlg.getSelected().getRight());
+ }
+
+ sc.getBindings().add(bind);
AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
addContext.setNewObject(bind);
@@ -271,7 +296,10 @@ public class BindingSupport {
ActorContainerRef tgtRef = SupportUtil.getRef(atgt, featureProvider);
- return ValidationUtil.isConnectable(src, srcRef, tgt, tgtRef, ac, bind).isOk();
+ return ValidationUtil.isConnectable(
+ src, srcRef, bind.getEndpoint1().getSub(),
+ tgt, tgtRef, bind.getEndpoint2().getSub(),
+ ac, bind, true).isOk();
}
@Override
@@ -281,10 +309,8 @@ public class BindingSupport {
IFeatureProvider featureProvider = getFeatureProvider();
Port src = SupportUtil.getPort(context.getConnection().getStart(), featureProvider);
Port dst = SupportUtil.getPort(context.getConnection().getEnd(), featureProvider);
- StructureClass ac = SupportUtil.getParent(getDiagram(), featureProvider);
- if (src!=null && dst!=null && ac!=null) {
- doneChanges = true;
-
+ StructureClass sc = SupportUtil.getParent(getDiagram(), featureProvider);
+ if (src!=null && dst!=null && sc!=null) {
Binding bind = (Binding) getBusinessObjectForPictogramElement(context.getConnection());
BindingEndPoint ep1 = RoomFactory.eINSTANCE.createBindingEndPoint();
ActorContainerRef ar1 = SupportUtil.getRef(context.getConnection().getStart(), featureProvider);
@@ -294,8 +320,23 @@ public class BindingSupport {
ActorContainerRef ar2 = SupportUtil.getRef(context.getConnection().getEnd(), featureProvider);
ep2.setPort(dst);
ep2.setActorRef(ar2);
+
+ GeneralProtocolClass srcGPC = src.getProtocol();
+ GeneralProtocolClass dstGPC = dst.getProtocol();
+ if (srcGPC instanceof GeneralProtocolClass || dstGPC instanceof GeneralProtocolClass) {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ SubProtocolSelectionDialog dlg = new SubProtocolSelectionDialog(shell, src, dst, bind, sc);
+ if (dlg.open()!=Window.OK)
+ return;
+
+ ep1.setSub(dlg.getSelected().getLeft());
+ ep2.setSub(dlg.getSelected().getRight());
+ }
+
bind.setEndpoint1(ep1);
bind.setEndpoint2(ep2);
+
+ doneChanges = true;
}
}
@@ -378,6 +419,55 @@ public class BindingSupport {
}
}
+ private static class PropertyFeature extends AbstractCustomFeature {
+
+ private boolean doneChanges;
+
+ public PropertyFeature(IFeatureProvider fp) {
+ super(fp);
+ }
+
+ @Override
+ public String getName() {
+ return "Edit Binding...";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Edit Binding Properties";
+ }
+
+ public boolean canExecute(ICustomContext context) {
+ return getBusinessObjectForPictogramElement(context.getPictogramElements()[0]) instanceof Binding;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.graphiti.features.custom.ICustomFeature#execute(org.eclipse.graphiti.features.context.ICustomContext)
+ */
+ @Override
+ public void execute(ICustomContext context) {
+ doneChanges = false;
+ Binding bind = (Binding) getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
+ StructureClass sc = (StructureClass) bind.eContainer();
+
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ SubProtocolSelectionDialog dlg = new SubProtocolSelectionDialog(
+ shell, bind.getEndpoint1().getPort(), bind.getEndpoint2().getPort(), bind, sc);
+ if (dlg.open()!=Window.OK)
+ return;
+
+ bind.getEndpoint1().setSub(dlg.getSelected().getLeft());
+ bind.getEndpoint2().setSub(dlg.getSelected().getRight());
+
+ doneChanges = true;
+ }
+
+ @Override
+ public boolean hasDoneChanges() {
+ return doneChanges;
+ }
+ }
+
private IFeatureProvider fp;
public FeatureProvider(IDiagramTypeProvider dtp, IFeatureProvider fp) {
@@ -419,9 +509,35 @@ public class BindingSupport {
public IDeleteFeature getDeleteFeature(IDeleteContext context) {
return new DeleteFeature(fp);
}
+
+ @Override
+ public ICustomFeature[] getCustomFeatures(ICustomContext context) {
+ return new ICustomFeature[] { new PropertyFeature(fp) };
+ }
}
class BehaviorProvider extends DefaultToolBehaviorProvider {
+
+ @Override
+ public String getToolTip(GraphicsAlgorithm ga) {
+ // if this is called we know there is a business object!=null
+ PictogramElement pe = ga.getPictogramElement();
+ if (pe instanceof ConnectionDecorator)
+ pe = (PictogramElement) pe.eContainer();
+
+ EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe);
+ if (bo instanceof Binding) {
+ Binding bind = (Binding) bo;
+ return RoomNameProvider.getDisplayName(bind);
+ }
+
+ return super.getToolTip(ga);
+ }
+
+ @Override
+ public ICustomFeature getDoubleClickFeature(IDoubleClickContext context) {
+ return new FeatureProvider.PropertyFeature(getDiagramTypeProvider().getFeatureProvider());
+ }
public BehaviorProvider(IDiagramTypeProvider dtp) {
super(dtp);
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java
index fa11ab4ee..85258bc56 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/InterfaceItemSupport.java
@@ -694,7 +694,7 @@ public class InterfaceItemSupport {
EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe);
if (bo instanceof InterfaceItem) {
String name = ((InterfaceItem) bo).getName();
- String protocol = ((InterfaceItem) bo).getProtocol().getName();
+ String protocol = RoomHelpers.getGeneralProtocol(((InterfaceItem) bo)).getName();
if (bo instanceof Port)
if (((Port) bo).isConjugated())
protocol = "conj "+protocol;
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
index d56390f7a..f8a0b5d44 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
@@ -32,7 +32,7 @@ import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.core.validation.ValidationUtil;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.ui.structure.DiagramTypeProvider;
import org.eclipse.etrice.ui.structure.ImageProvider;
import org.eclipse.etrice.ui.structure.dialogs.PortPropertyDialog;
@@ -125,7 +125,7 @@ public class PortSupport extends InterfaceItemSupport {
}
IScopeProvider scopeProvider = ((DiagramTypeProvider)getFeatureProvider().getDiagramTypeProvider()).getScopeProvider();
- IScope scope = scopeProvider.getScope(port, RoomPackage.eINSTANCE.getInterfaceItem_Protocol());
+ IScope scope = scopeProvider.getScope(port, RoomPackage.eINSTANCE.getPort_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
PortPropertyDialog dlg = new PortPropertyDialog(shell, port, scope, acc, true, false, internal);
if (dlg.open()!=Window.OK) {
@@ -212,7 +212,7 @@ public class PortSupport extends InterfaceItemSupport {
boolean refport = isRefItem(context.getPictogramElements()[0]);
IScopeProvider scopeProvider = ((DiagramTypeProvider)getFeatureProvider().getDiagramTypeProvider()).getScopeProvider();
- IScope scope = scopeProvider.getScope(port.eContainer().eContainer(), RoomPackage.eINSTANCE.getInterfaceItem_Protocol());
+ IScope scope = scopeProvider.getScope(port.eContainer().eContainer(), RoomPackage.eINSTANCE.getPort_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
PortPropertyDialog dlg = new PortPropertyDialog(shell, port, scope, acc, false, refport, internal);
if (dlg.open()!=Window.OK)
@@ -392,7 +392,7 @@ public class PortSupport extends InterfaceItemSupport {
ContainerShape containerShape,
GraphicsAlgorithm invisibleRectangle, Color darkColor, Color brightDolor) {
- boolean relay = ValidationUtil.isRelay(port);
+ boolean relay = RoomHelpers.isRelay(port);
int size = refport?ITEM_SIZE_SMALL:ITEM_SIZE;
int margin = refport?MARGIN_SMALL:MARGIN;
@@ -550,7 +550,7 @@ public class PortSupport extends InterfaceItemSupport {
String kind = "";
if (port.isConjugated())
kind += "C";
- if (ValidationUtil.isRelay(port))
+ if (RoomHelpers.isRelay(port))
kind += "R";
if (port.isReplicated())
kind += "M";
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
index 125687059..13c5ac35f 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/SPPSupport.java
@@ -105,7 +105,7 @@ public class SPPSupport extends InterfaceItemSupport {
acc.getIfSPPs().add(spp);
IScopeProvider scopeProvider = ((DiagramTypeProvider)getFeatureProvider().getDiagramTypeProvider()).getScopeProvider();
- IScope scope = scopeProvider.getScope(spp.eContainer().eContainer(), RoomPackage.eINSTANCE.getInterfaceItem_Protocol());
+ IScope scope = scopeProvider.getScope(spp.eContainer().eContainer(), RoomPackage.eINSTANCE.getSAPRef_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
SPPPropertyDialog dlg = new SPPPropertyDialog(shell, spp, scope, true, false);
if (dlg.open()!=Window.OK) {
@@ -176,7 +176,7 @@ public class SPPSupport extends InterfaceItemSupport {
boolean refport = isRefItem(context.getPictogramElements()[0]);
IScopeProvider scopeProvider = ((DiagramTypeProvider)getFeatureProvider().getDiagramTypeProvider()).getScopeProvider();
- IScope scope = scopeProvider.getScope(spp.eContainer().eContainer(), RoomPackage.eINSTANCE.getInterfaceItem_Protocol());
+ IScope scope = scopeProvider.getScope(spp.eContainer().eContainer(), RoomPackage.eINSTANCE.getSAPRef_Protocol());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
SPPPropertyDialog dlg = new SPPPropertyDialog(shell, spp, scope, false, refport);
if (dlg.open()!=Window.OK)

Back to the top