Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-08-16 07:01:50 -0400
committerHenrik Rentz-Reichert2012-08-16 07:01:50 -0400
commit1fd9b5893b70323f9a26d81d665c6d22842d412a (patch)
treed352cc91450cb9076d120f8f76de6a6a72712096 /plugins/org.eclipse.etrice.ui.structure
parent03274d9e3521613a28e570371ded89d1e117a846 (diff)
downloadorg.eclipse.etrice-1fd9b5893b70323f9a26d81d665c6d22842d412a.tar.gz
org.eclipse.etrice-1fd9b5893b70323f9a26d81d665c6d22842d412a.tar.xz
org.eclipse.etrice-1fd9b5893b70323f9a26d81d665c6d22842d412a.zip
[ui.structure] introduced feed back for binding creation
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.structure')
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/ProviderDispatcher.java22
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/BindingSupport.java74
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DecorationProvider.java51
3 files changed, 113 insertions, 34 deletions
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 3a0a5368c..ac8077676 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
@@ -16,9 +16,17 @@ import java.util.Arrays;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.naming.RoomFragmentProvider;
+import org.eclipse.etrice.core.room.ActorContainerRef;
+import org.eclipse.etrice.core.room.Binding;
+import org.eclipse.etrice.core.room.LayerConnection;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.core.room.util.RoomSwitch;
import org.eclipse.etrice.ui.common.support.AutoUpdateFeature;
import org.eclipse.etrice.ui.structure.support.ActorContainerRefSupport;
import org.eclipse.etrice.ui.structure.support.BindingSupport;
+import org.eclipse.etrice.ui.structure.support.DecorationProvider;
import org.eclipse.etrice.ui.structure.support.LayerConnectionSupport;
import org.eclipse.etrice.ui.structure.support.PortSupport;
import org.eclipse.etrice.ui.structure.support.SPPSupport;
@@ -54,20 +62,13 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IContextButtonPadData;
+import org.eclipse.graphiti.tb.IDecorator;
import org.eclipse.graphiti.tb.ISelectionInfo;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.graphiti.tb.SelectionInfoImpl;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.IColorConstant;
-import org.eclipse.etrice.core.room.ActorContainerRef;
-import org.eclipse.etrice.core.room.Binding;
-import org.eclipse.etrice.core.room.LayerConnection;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.StructureClass;
-import org.eclipse.etrice.core.room.util.RoomSwitch;
-
public class ProviderDispatcher {
private class FeatureProviderSwitch extends RoomSwitch<IFeatureProvider> {
@@ -334,6 +335,11 @@ public class ProviderDispatcher {
}
@Override
+ public IDecorator[] getDecorators(PictogramElement pe) {
+ return DecorationProvider.getDecorators(pe);
+ }
+
+ @Override
public GraphicsAlgorithm[] getClickArea(PictogramElement pe) {
IToolBehaviorProvider bp = getToolBehaviorProvider(pe);
if (bp==null)
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 9d00c9f81..15630c85c 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
@@ -16,18 +16,15 @@ 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.CompoundProtocolClass;
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;
@@ -66,8 +63,10 @@ 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.ContainerShape;
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.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeCreateService;
@@ -89,8 +88,6 @@ public class BindingSupport {
private class CreateFeature extends AbstractCreateConnectionFeature {
- private boolean justStarted = false;
-
public CreateFeature(IFeatureProvider fp) {
super(fp, "Binding", "create Binding");
}
@@ -107,11 +104,6 @@ public class BindingSupport {
Port tgt = SupportUtil.getPort(context.getTargetAnchor(), featureProvider);
ActorContainerRef srcRef = SupportUtil.getRef(context.getSourceAnchor(), featureProvider);
- if (justStarted) {
- justStarted = false;
- beginHighLightMatches(src, srcRef);
- }
-
if (src==null || tgt==null) {
return false;
}
@@ -143,8 +135,7 @@ public class BindingSupport {
canStart = false;
}
}
- if (canStart)
- justStarted = true;
+
return canStart;
}
@@ -193,26 +184,57 @@ public class BindingSupport {
return newConnection;
}
- private void beginHighLightMatches(Port port, ActorContainerRef ref) {
- if (port==null)
+ @Override
+ public void attachedToSource(ICreateConnectionContext context) {
+ Port src = SupportUtil.getPort(context.getSourceAnchor(), getFeatureProvider());
+ ActorContainerRef ref = SupportUtil.getRef(context.getSourceAnchor(), getFeatureProvider());
+ StructureClass sc = SupportUtil.getParent(context, getFeatureProvider());
+
+ beginHighLightMatches(sc, src, ref);
+ }
+
+ @Override
+ public void canceledAttaching(ICreateConnectionContext context) {
+ endHighLightMatches();
+ }
+
+ @Override
+ public void endConnecting() {
+ endHighLightMatches();
+ }
+
+ private void beginHighLightMatches(StructureClass sc, Port src, ActorContainerRef srcRef) {
+ if (src==null)
return;
- StructureClass acc = (ActorContainerClass) ((ref!=null)? ref.eContainer():port.eContainer());
- if (acc instanceof ActorClass) {
-
- }
- else if (acc instanceof SubSystemClass) {
-
- }
- else if (acc instanceof LogicalSystem) {
+ ContainerShape scContainer = (ContainerShape) getDiagram().getChildren().get(0);
+ for (Shape subShape : scContainer.getChildren()) {
+ Object bo = getBusinessObjectForPictogramElement(subShape);
+ if (bo instanceof Port) {
+ if (ValidationUtil.isConnectable(src, srcRef, null, (Port) bo, null, null, sc, null, false).isOk()) {
+ DecorationProvider.addAllowedPortShape(subShape);
+ getDiagramEditor().refreshRenderingDecorators(subShape);
+ }
+ }
+ else if (bo instanceof ActorContainerRef) {
+ ActorContainerRef tgtRef = (ActorContainerRef) bo;
+ for (Shape subSubShape : ((ContainerShape)subShape).getChildren()) {
+ bo = getBusinessObjectForPictogramElement(subSubShape);
+ if (bo instanceof Port) {
+ if (ValidationUtil.isConnectable(src, srcRef, null, (Port) bo, tgtRef, null, sc, null, false).isOk()) {
+ DecorationProvider.addAllowedPortShape(subSubShape);
+ getDiagramEditor().refreshRenderingDecorators(subSubShape);
+ }
+ }
+ }
+ }
}
- else {
- assert(false): "unknown kind of StructureClass";
- }
}
private void endHighLightMatches() {
+ DecorationProvider.clearAllowedPortShapes();
+ getDiagramEditor().refresh();
}
}
@@ -537,7 +559,7 @@ public class BindingSupport {
return super.getToolTip(ga);
}
-
+
@Override
public ICustomFeature getDoubleClickFeature(IDoubleClickContext context) {
return new FeatureProvider.PropertyFeature(getDiagramTypeProvider().getFeatureProvider());
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DecorationProvider.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DecorationProvider.java
new file mode 100644
index 000000000..1cb852c02
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DecorationProvider.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.support;
+
+import java.util.ArrayList;
+
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.tb.BorderDecorator;
+import org.eclipse.graphiti.tb.IDecorator;
+import org.eclipse.graphiti.util.IColorConstant;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class DecorationProvider {
+
+ private static ArrayList<Shape> allowedPortShapes = new ArrayList<Shape>();
+
+ public static void clearAllowedPortShapes() {
+ allowedPortShapes.clear();
+ }
+
+ public static void addAllowedPortShape(Shape portShape) {
+ allowedPortShapes.add(portShape);
+ }
+
+ public static IDecorator[] getDecorators(PictogramElement pe) {
+ if (allowedPortShapes.contains(pe)) {
+ BorderDecorator decorator = new BorderDecorator();
+ decorator.setBorderColor(IColorConstant.GREEN);
+ decorator.setBorderWidth(2);
+// ColorDecorator decorator = new ColorDecorator();
+// decorator.setForegroundColor(IColorConstant.GREEN);
+// decorator.setBackgroundColor(IColorConstant.GREEN);
+ return new IDecorator[] { decorator };
+ }
+ return new IDecorator[0];
+ }
+
+}

Back to the top