Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCéline Janssens2015-08-10 09:38:05 +0000
committerGerrit Code Review @ Eclipse.org2015-08-27 16:46:23 +0000
commitc1ab9e2c3cc4a36e20c206705f3ef8962db2b813 (patch)
tree411058faf01cb82858f587fbdf324f3e81b7fa46
parentadfb94879da95a8ace7f273333cacd28565e9cb7 (diff)
downloadorg.eclipse.papyrus-rt-c1ab9e2c3cc4a36e20c206705f3ef8962db2b813.tar.gz
org.eclipse.papyrus-rt-c1ab9e2c3cc4a36e20c206705f3ef8962db2b813.tar.xz
org.eclipse.papyrus-rt-c1ab9e2c3cc4a36e20c206705f3ef8962db2b813.zip
Bug 473064 - [tooling] A port RT is automatically created when DnD on a
Capsule https://bugs.eclipse.org/bugs/show_bug.cgi?id=473064 -Adds drops strategies to drag and drop Strategy on a capsule and create an RT Port. - When An internal Behavior Port is Created it is located inside the ClassComposite (new RTPortPositionLocator) Change-Id: Ibeb7d30b5f1f2ce37a0fda1876012264b5ee1ebe Signed-off-by: Céline Janssens <Celine.Janssens@all4tec.net>
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/META-INF/MANIFEST.MF6
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/elementtypes/uml-rt.elementtypesconfigurations2
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/plugin.xml9
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpart/RTClassCompositeEditPart.java89
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTCustomDiagramDragDropEditPolicy.java147
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTSideAffixedNodesCreationEditPolicy.java75
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/locator/RTPortPositionLocator.java161
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/provider/RTEditPartProvider.java98
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RTPortEditHelperAdvice.java176
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/Constants.java (renamed from plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/util/Constants.java)2
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortKindEnum.java (renamed from plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindEnum.java)6
-rw-r--r--plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortUtils.java89
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/plugin.xml15
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/AbstractProtocolToRTPortDropStrategy.java189
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/CreateRTPortAndDisplayCommand.java319
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToExternalBehaviorPortDropStrategy.java91
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToInternalBehavoirPortDropStrategy.java91
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToRelayPortDropStrategy.java67
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSAPPortDropStrategy.java66
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSPPPortDropStrategy.java68
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/META-INF/MANIFEST.MF5
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java14
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java2
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/util/RTPortHelper.java63
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindObservableValue.java35
25 files changed, 1784 insertions, 101 deletions
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/META-INF/MANIFEST.MF b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/META-INF/MANIFEST.MF
index fdcfe70a1..e84cec412 100644
--- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/META-INF/MANIFEST.MF
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/META-INF/MANIFEST.MF
@@ -23,7 +23,11 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0",
org.eclipse.papyrus.infra.emf;bundle-version="1.1.1",
org.eclipse.papyrus.infra.elementtypesconfigurations;bundle-version="1.1.1",
org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypes;bundle-version="1.1.1",
- org.eclipse.papyrus.uml.tools.elementtypesconfigurations;bundle-version="1.1.1"
+ org.eclipse.papyrus.uml.tools.elementtypesconfigurations;bundle-version="1.1.1",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.1",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.1.1",
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="1.1.1",
+ org.eclipse.gmf.tooling.runtime;bundle-version="3.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrusrt.umlrt.core,
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/elementtypes/uml-rt.elementtypesconfigurations b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/elementtypes/uml-rt.elementtypesconfigurations
index df3e5fbb0..ddd1c5475 100644
--- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/elementtypes/uml-rt.elementtypesconfigurations
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/elementtypes/uml-rt.elementtypesconfigurations
@@ -157,7 +157,7 @@
inheritance="all"/>
<matcherConfiguration
xmi:id="_g1WZAxAZEeWc8PaHufXjyA"
- matcherClassName="org.eclipse.papyrusrt.umlrt.core.types.matcher.ExternalBehaviorPortMatcher"/>
+ matcherClassName="org.eclipse.papyrusrt.umlrt.core.types.matcher.InternalBehaviorPortMatcher"/>
</elementTypeConfigurations>
<elementTypeConfigurations
xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/plugin.xml b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/plugin.xml
index 890b9c135..d23695015 100644
--- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/plugin.xml
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/plugin.xml
@@ -33,4 +33,13 @@
path="elementtypes/uml-rt.elementtypesconfigurations">
</elementTypeSet>
</extension>
+ <extension
+ point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders">
+ <editpartProvider
+ class="org.eclipse.papyrusrt.umlrt.core.provider.RTEditPartProvider">
+ <Priority
+ name="Medium">
+ </Priority>
+ </editpartProvider>
+ </extension>
</plugin>
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpart/RTClassCompositeEditPart.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpart/RTClassCompositeEditPart.java
new file mode 100644
index 000000000..2ed619cca
--- /dev/null
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpart/RTClassCompositeEditPart.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.core.editpart;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeNameEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.PortEditPart;
+import org.eclipse.papyrusrt.umlrt.core.editpolicies.RTCustomDiagramDragDropEditPolicy;
+import org.eclipse.papyrusrt.umlrt.core.editpolicies.RTSideAffixedNodesCreationEditPolicy;
+import org.eclipse.papyrusrt.umlrt.core.locator.RTPortPositionLocator;
+
+
+/**
+ * The Class RTClassCompositeEditPart defines how an affixed Child node can be added in the Real Time Context.
+ * A port can be added inside the Bounds instead of exclusively on the boundaries;
+ */
+public class RTClassCompositeEditPart extends ClassCompositeEditPart {
+
+ /**
+ * Instantiates a new RT class composite edit part.
+ *
+ * @param view
+ * the view
+ */
+ public RTClassCompositeEditPart(View view) {
+ super(view);
+
+ }
+
+ /**
+ * Add the specific EditPolicies to DND and to Create an RT port
+ *
+ * @see org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart#createDefaultEditPolicies()
+ *
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new RTSideAffixedNodesCreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new RTCustomDiagramDragDropEditPolicy());
+ }
+
+ /**
+ * Redefine the way the Affixed Child note is added to the EditPart by specifying the Port Position Locator as {@link RTPortPositionLocator}.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart#addFixedChild(org.eclipse.gef.EditPart)
+ *
+ * @param childEditPart
+ * @return
+ */
+ @Override
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ClassCompositeNameEditPart) {
+ ((ClassCompositeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
+ return true;
+ }
+ if (childEditPart instanceof ClassCompositeCompartmentEditPart) {
+ IFigure pane = getPrimaryShape().getCompositeCompartmentFigure();
+ setupContentPane(pane); // FIXME each compartment should handle his content pane in his own way
+ pane.add(((ClassCompositeCompartmentEditPart) childEditPart).getFigure());
+ return true;
+ }
+ // Papyrus Gencode :Affixed Port locator
+ if (childEditPart instanceof PortEditPart) {
+ IBorderItemLocator locator = new RTPortPositionLocator(((PortEditPart) childEditPart).getUMLElement(), getMainFigure(), PositionConstants.NONE);
+ getBorderedFigure().getBorderItemContainer().add(((PortEditPart) childEditPart).getFigure(), locator);
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTCustomDiagramDragDropEditPolicy.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTCustomDiagramDragDropEditPolicy.java
new file mode 100644
index 000000000..b0594d4fa
--- /dev/null
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTCustomDiagramDragDropEditPolicy.java
@@ -0,0 +1,147 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.core.editpolicies;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.figures.ShapeCompartmentFigure;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
+import org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.CustomDiagramDragDropEditPolicy;
+import org.eclipse.papyrusrt.umlrt.core.Activator;
+import org.eclipse.papyrusrt.umlrt.core.locator.RTPortPositionLocator;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.ConnectableElement;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.EncapsulatedClassifier;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Type;
+
+
+/**
+ * The Class RTCustomDiagramDragDropEditPolicy. Installed on RTClassCompositeEditPart to manage the location of RTPort.
+ */
+public class RTCustomDiagramDragDropEditPolicy extends CustomDiagramDragDropEditPolicy {
+
+ /**
+ * PortPositionLocator is RTPortPositionLocator to allow port to be inside the figure when Internal.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.CustomDiagramDragDropEditPolicy#dropAffixedNode(org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest, org.eclipse.uml2.uml.Element, int)
+ *
+ */
+ @Override
+ protected Command dropAffixedNode(DropObjectsRequest dropRequest, Element droppedElement, int nodeVISUALID) {
+ // The dropped element must be a Port or Parameter
+ if (!((droppedElement instanceof Port))) {
+ Activator.log.error(new Exception("Incorrect parameter type (droppedElement should be a Port or Parameter)"));
+ return UnexecutableCommand.INSTANCE;
+ }
+
+
+ // Manage Element drop in compartment
+ Boolean isCompartmentTarget = false; // True if the target is a
+ // ShapeCompartmentEditPart
+ GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart) getHost();
+
+ // Default drop location
+ Point dropLocation = dropRequest.getLocation().getCopy();
+
+ // Detect if the drop target is a compartment
+ if (graphicalParentEditPart instanceof ShapeCompartmentEditPart) {
+ isCompartmentTarget = true;
+
+ // Replace compartment edit part by its parent EditPart
+ graphicalParentEditPart = (GraphicalEditPart) graphicalParentEditPart.getParent();
+
+ // Translate Port expected location according to the compartment
+ // location
+ Point targetLocation = graphicalParentEditPart.getContentPane().getBounds().getLocation();
+ ShapeCompartmentFigure compartmentFigure = (ShapeCompartmentFigure) getHostFigure();
+
+ // Retrieve ViewPort location = the area where compartment children
+ // are located
+ // Retrieve ViewPort view location = the relative location of the
+ // viewed compartment
+ // depending on the current scroll bar state
+ Viewport compartmentViewPort = compartmentFigure.getScrollPane().getViewport();
+ Point compartmentViewPortLocation = compartmentViewPort.getLocation();
+ Point compartmentViewPortViewLocation = compartmentViewPort.getViewLocation();
+
+ // Calculate the delta between the targeted element position for
+ // drop (the Composite figure)
+ // and the View location with eventual scroll bar.
+ Point delta = compartmentViewPortLocation.translate(targetLocation.negate());
+ delta = delta.translate(compartmentViewPortViewLocation.negate());
+
+ // Translate the requested drop location (relative to parent)
+ dropLocation = dropRequest.getLocation().getTranslated(delta);
+ }
+ // Manage Element drop in compartment
+
+ // Create proposed creation bounds and use the locator to find the
+ // expected position
+ Point parentLoc = graphicalParentEditPart.getFigure().getBounds().getLocation().getCopy();
+ PortPositionLocator locator = new RTPortPositionLocator(droppedElement, graphicalParentEditPart.getFigure(), PositionConstants.NONE);
+
+ Rectangle proposedBounds = new Rectangle(dropLocation, new Dimension(20, 20));
+
+ Rectangle preferredBounds = locator.getPreferredLocation(proposedBounds);
+
+ if (null != preferredBounds) {
+ // Convert the calculated preferred bounds as relative to parent
+ // location
+ Rectangle creationBounds = preferredBounds.getTranslated(parentLoc.getNegated());
+ dropLocation = creationBounds.getLocation();
+
+ EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
+
+ if ((graphicalParentObject instanceof EncapsulatedClassifier) && (((EncapsulatedClassifier) graphicalParentObject).getAllAttributes().contains(droppedElement))) {
+ // Drop Port on StructuredClassifier
+ if (isCompartmentTarget) {
+ return getDropAffixedNodeInCompartmentCommand(nodeVISUALID, dropLocation, droppedElement);
+ }
+ return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, dropLocation, droppedElement));
+
+ } else if (graphicalParentObject instanceof ConnectableElement) {
+ // Drop Port on Part
+ Type type = ((ConnectableElement) graphicalParentObject).getType();
+
+ if ((type != null) && (type instanceof EncapsulatedClassifier) && (((EncapsulatedClassifier) type).getAllAttributes().contains(droppedElement))) {
+ if (isCompartmentTarget) {
+ return getDropAffixedNodeInCompartmentCommand(nodeVISUALID, dropLocation, droppedElement);
+ }
+ return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, dropLocation, droppedElement));
+ }
+
+ } else if ((graphicalParentObject instanceof Behavior) && (((Behavior) graphicalParentObject).getOwnedParameters().contains(droppedElement))) {
+ // Drop Parameter on Behavior
+ if (isCompartmentTarget) {
+ return getDropAffixedNodeInCompartmentCommand(nodeVISUALID, dropLocation, droppedElement);
+ }
+ return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, dropLocation, droppedElement));
+ }
+ }
+
+ return UnexecutableCommand.INSTANCE;
+ }
+
+}
+
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTSideAffixedNodesCreationEditPolicy.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTSideAffixedNodesCreationEditPolicy.java
new file mode 100644
index 000000000..ff726bdf2
--- /dev/null
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTSideAffixedNodesCreationEditPolicy.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.core.editpolicies;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.SideAffixedNodesCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
+import org.eclipse.papyrusrt.umlrt.core.locator.RTPortPositionLocator;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
+import org.eclipse.uml2.uml.Port;
+
+/**
+ * This EditPolicy is installed on the RTClassCompositeEditPart to manage the location of RTPort that could be internal instead of on the border
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public class RTSideAffixedNodesCreationEditPolicy extends SideAffixedNodesCreationEditPolicy {
+
+ /**
+ * RTPort UML Element.
+ */
+ private Object element = null;
+
+ /**
+ * Set the Uml object and get the Super SetBoundsCommand
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.SideAffixedNodesCreationEditPolicy#getSetBoundsCommand(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest, org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor)
+ *
+ *
+ */
+ @Override
+ protected ICommand getSetBoundsCommand(CreateViewRequest request, ViewDescriptor descriptor) {
+
+ if (request.getViewDescriptors().size() == 1) {
+ ViewDescriptor vd = request.getViewDescriptors().get(0);
+ if (vd.getElementAdapter() instanceof EObjectAdapter) {
+ element = ((EObjectAdapter) vd.getElementAdapter()).getRealObject();
+ }
+ }
+
+ return super.getSetBoundsCommand(request, descriptor);
+
+
+ }
+
+ /**
+ * In case the element is an RTPort, set the locator accordingly.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.SideAffixedNodesCreationEditPolicy#getPositionLocator()
+ */
+ @Override
+ protected PortPositionLocator getPositionLocator() {
+ PortPositionLocator locator = null;
+ if (RTPortUtils.isRTPort((Port) element)) {
+ locator = new RTPortPositionLocator((Port) element, getHostFigure(), PositionConstants.NONE);
+ }
+
+ return null != locator ? locator : super.getPositionLocator();
+ }
+
+}
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/locator/RTPortPositionLocator.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/locator/RTPortPositionLocator.java
new file mode 100644
index 000000000..0bafea95c
--- /dev/null
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/locator/RTPortPositionLocator.java
@@ -0,0 +1,161 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.core.locator;
+
+import java.util.Iterator;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.SubCompartmentLayoutManager;
+import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Port;
+
+/**
+ * The Class RTPortPositionLocator is a specific Port Position Locator for the Real Time Context,
+ * to allow RTPort to be inside a ClassComposite.
+ */
+public class RTPortPositionLocator extends PortPositionLocator {
+
+ /** The view. */
+ private Object view;
+
+ /** The port. */
+ private Element port;
+
+ /** the figure. */
+ private IFigure figure;
+
+ /**
+ * Instantiates a new RT port position locator.
+ *
+ * @param droppedElement
+ * the dropped element
+ * @param parentFigure
+ * the parent figure
+ * @param preferredSide
+ * the preferred side
+ */
+ public RTPortPositionLocator(Element droppedElement, IFigure parentFigure, int preferredSide) {
+ super(parentFigure, preferredSide);
+ this.view = droppedElement.getModel();
+ this.port = droppedElement;
+ }
+
+ /**
+ * Calculates the preferred location according to the RTPort type.
+ * Only Internal and SAP Kind can be located internally.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator#getPreferredLocation(org.eclipse.draw2d.geometry.Rectangle)
+ */
+ @Override
+ public Rectangle getPreferredLocation(Rectangle proposedLocation) {
+
+ Rectangle newLocation = null;
+ if (port instanceof Port) {
+ RTPortKindEnum kind = RTPortUtils.getKind((Port) port);
+ if (null != kind) {
+ switch (kind) {
+
+ case EXTERNAL:
+ case RELAY:
+ case SPP:
+ newLocation = getPreferredBorderedLocation(proposedLocation);
+ break;
+ case INTERNAL:
+ case SAP:
+ newLocation = getPreferredInternalLocation(proposedLocation);
+ break;
+ default:
+ newLocation = getPreferredBorderedLocation(proposedLocation);
+ break;
+ }
+
+ } else {
+ newLocation = getPreferredBorderedLocation(proposedLocation);
+ }
+ }
+ return newLocation;
+ }
+
+ /**
+ * Gets the preferred internal location. As a Standard port is not internal,
+ * this method calculates the right position based on the Compartment bounds and the target Position.
+ *
+ *
+ * @param proposedLocation
+ * the proposed location
+ * @return the preferred internal location
+ */
+ private Rectangle getPreferredInternalLocation(Rectangle proposedLocation) {
+ Rectangle parentBounds = parentFigure.getBounds().getCopy();
+ IFigure compartment = getCompositeCompartmentFigure(parentFigure);
+
+ Rectangle prefferedLocation;
+ if (null != compartment) {
+ if (compartment.getBounds().contains(proposedLocation)) {
+ prefferedLocation = proposedLocation.getCopy();
+ } else {
+ prefferedLocation = parentBounds.translate(30, 60).getCopy();
+ prefferedLocation.setSize(proposedLocation.width, proposedLocation.height);
+
+ }
+
+ } else {
+ // Should not happened
+ prefferedLocation = new Rectangle();
+ }
+
+ return prefferedLocation;
+ }
+
+ /**
+ * Retrieve the Compartment of the Composite Class.
+ *
+ * @param parentFigure
+ * the parent figure
+ * @return the composite compartment figure
+ */
+ private IFigure getCompositeCompartmentFigure(IFigure parentFigure) {
+ IFigure composite = null;
+ Iterator childrenIterator = parentFigure.getChildren().iterator();
+ while (null == composite && childrenIterator.hasNext()) {
+ Object child = childrenIterator.next();
+ if (child instanceof IFigure) {
+ // The compartment figure should have the Compartment Layout Manager
+ if (((IFigure) child).getLayoutManager() instanceof SubCompartmentLayoutManager) {
+ composite = (IFigure) child;
+ }
+
+ if (null == composite) {
+ composite = getCompositeCompartmentFigure((IFigure) child);
+ }
+ }
+
+ }
+ return composite;
+ }
+
+ /**
+ * Gets the preferred bordered location.
+ *
+ * @param proposedLocation
+ * the proposed location
+ * @return the preferred bordered location
+ */
+ private Rectangle getPreferredBorderedLocation(Rectangle proposedLocation) {
+ return super.getPreferredLocation(proposedLocation);
+ }
+
+}
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/provider/RTEditPartProvider.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/provider/RTEditPartProvider.java
new file mode 100644
index 000000000..a49966077
--- /dev/null
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/provider/RTEditPartProvider.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.core.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart;
+import org.eclipse.papyrusrt.umlrt.core.editpart.RTClassCompositeEditPart;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
+
+
+/**
+ * The Class RTEditPartProvider provide the editParts for the Real Time specification.
+ * This is applied for the Composite Structure Diagram
+ */
+public class RTEditPartProvider extends AbstractEditPartProvider {
+
+ /** The provides only provides for this diagram type. */
+ protected String diagramType = org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart.MODEL_ID;
+
+ /** Map containing node view types supported by this provider. */
+ protected Map<String, Class<?>> nodeMap = new HashMap<String, Class<?>>();
+
+ /** Map containing edge view types supported by this provider. */
+ protected Map<String, Class<?>> edgeMap = new HashMap<String, Class<?>>();
+
+ /**
+ * Default constructor.
+ */
+ public RTEditPartProvider() {
+ super();
+
+ // Nodes
+ nodeMap.put(Integer.toString(ClassCompositeEditPart.VISUAL_ID), RTClassCompositeEditPart.class);
+ }
+
+ /**
+ * Provides.
+ *
+ * @param operation
+ * the operation
+ * @return true, if successful
+ * @see org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation)
+ */
+ @Override
+ public boolean provides(IOperation operation) {
+
+ boolean provide;
+ String currentDiagramType;
+
+ if ((operation instanceof CreateGraphicEditPartOperation) && (RTPortUtils.isRTPort(((IEditPartOperation) operation).getView().getElement()))) {
+
+ currentDiagramType = ((IEditPartOperation) operation).getView().getDiagram().getType();
+
+ if ((diagramType == null) || (!diagramType.equals(currentDiagramType))) {
+ provide = false;
+ } else {
+ provide = super.provides(operation);
+ }
+
+ } else {
+ provide = super.provides(operation);
+ }
+
+ return provide;
+
+ }
+
+ /**
+ * Gets the node edit part class.
+ *
+ * @param view
+ * the view
+ * @return the node edit part class
+ * @see org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider#getNodeEditPartClass(org.eclipse.gmf.runtime.notation.View)
+ */
+ @Override
+ protected Class getNodeEditPartClass(View view) {
+
+ return nodeMap.get(view.getType());
+ }
+
+}
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RTPortEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RTPortEditHelperAdvice.java
index 8e5603f45..45c4bf4a1 100644
--- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RTPortEditHelperAdvice.java
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RTPortEditHelperAdvice.java
@@ -13,6 +13,9 @@ package org.eclipse.papyrusrt.umlrt.core.types.advice;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
@@ -21,13 +24,18 @@ import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
import org.eclipse.papyrusrt.umlrt.core.types.ElementTypeUtils;
import org.eclipse.papyrusrt.umlrt.core.types.IUMLRTElementTypes;
import org.eclipse.papyrusrt.umlrt.core.utils.ProtocolUtils;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTPort;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.VisibilityKind;
+import org.eclipse.uml2.uml.util.UMLUtil;
/**
* Edit Helper Advice for {@link RTPort}
@@ -94,6 +102,9 @@ public class RTPortEditHelperAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getAfterSetCommand(SetRequest request) {
+ CompositeCommand cc = new CompositeCommand("Set RTPort");
+
+
EStructuralFeature feature = request.getFeature();
if (UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature)) {
// if element is unnamed, set a name according to the new Type name
@@ -103,11 +114,172 @@ public class RTPortEditHelperAdvice extends AbstractEditHelperAdvice {
String name = ((Type) newValue).getName();
if (name != null && !name.isEmpty()) {
String newName = Character.toLowerCase(name.charAt(0)) + name.substring(1);
- return new SetValueCommand(new SetRequest(request.getElementToEdit(), UMLPackage.eINSTANCE.getNamedElement_Name(), newName));
+ cc.add( new SetValueCommand(new SetRequest(request.getElementToEdit(), UMLPackage.eINSTANCE.getNamedElement_Name(), newName)));
}
}
}
- return super.getAfterSetCommand(request);
+
+ ICommand setKindCommand = getSetKindCommand(request);
+ if(null!=setKindCommand){
+ cc.add(setKindCommand);
+ }
+
+ return cc.isEmpty()?super.getAfterSetCommand(request):cc;
+ }
+
+
+ protected ICommand getSetKindCommand(SetRequest request) {
+ ICommand cmd = null;
+ final EObject object = request.getElementToEdit();
+ final Object kindParameter = request.getParameter(RTPortUtils.RTPORT_KIND_REQUEST_PARAMETER);
+ if (object instanceof Port && (null!=kindParameter) && kindParameter instanceof RTPortKindEnum) {
+ final Port rtPort = (Port) object;
+ RecordingCommand command = new RecordingCommand(TransactionUtil.getEditingDomain(object)) {
+ @Override
+ protected void doExecute() {
+
+ if(RTPortKindEnum.EXTERNAL.equals(kindParameter)){
+ setExternalPort(rtPort);
+ }
+ if(RTPortKindEnum.INTERNAL.equals(kindParameter)){
+ setInternalPort(rtPort);
+ }
+ if(RTPortKindEnum.RELAY.equals(kindParameter)){
+ setRelayPort(rtPort);
+ }
+ if(RTPortKindEnum.SAP.equals(kindParameter)){
+ setSAPPort(rtPort);
+ }
+ if(RTPortKindEnum.SPP.equals(kindParameter)){
+ setSPPPort(rtPort);
+ }
+
+ }
+ };
+ cmd = EMFtoGMFCommandWrapper.wrap(command);
+ }
+
+ return cmd;
+ }
+
+ /**
+ * Sets the RT port as a external Behavior Port.
+ *
+ * @param externalBehaviorPort
+ * the new RT port as a external Behavior Port
+ */
+ protected void setExternalPort(final Port externalBehaviorPort) {
+ // isService: true
+ externalBehaviorPort.setIsService(true);
+
+ // isBehavior: true
+ externalBehaviorPort.setIsBehavior(true);
+
+ // isWired: true
+ RTPort stereotype = UMLUtil.getStereotypeApplication(externalBehaviorPort, RTPort.class);
+ stereotype.setIsWired(true);
+
+ // isPublish: false
+ stereotype.setIsPublish(false);
+
+ // Visibility: public
+ externalBehaviorPort.setVisibility(VisibilityKind.PUBLIC_LITERAL);
+ }
+
+ /**
+ * Sets the RT port as internal Behavior Port.
+ *
+ * @param internalBehaviorPort
+ * the new RT port as internal Behavior Port
+ */
+ protected void setInternalPort(final Port internalBehaviorPort) {
+ // isService: false
+ internalBehaviorPort.setIsService(false);
+
+ // isBehavior: true
+ internalBehaviorPort.setIsBehavior(true);
+
+ // isWired: true
+ RTPort stereotype = UMLUtil.getStereotypeApplication(internalBehaviorPort, RTPort.class);
+ stereotype.setIsWired(true);
+
+ // isPublish: false
+ stereotype.setIsPublish(false);
+
+ // Visibility: protected
+ internalBehaviorPort.setVisibility(VisibilityKind.PROTECTED_LITERAL);
+ }
+
+ /**
+ * Sets the RT port as a relay port.
+ *
+ * @param relayPort
+ * the new RT port as a relay port
+ */
+ protected void setRelayPort(final Port relayPort) {
+ // isService: true
+ relayPort.setIsService(true);
+
+ // isBehavior: false
+ relayPort.setIsBehavior(false);
+
+ // isWired: true
+ RTPort stereotype = UMLUtil.getStereotypeApplication(relayPort, RTPort.class);
+ stereotype.setIsWired(true);
+
+ // isPublish: false
+ stereotype.setIsPublish(false);
+
+ // Visibility: public
+ relayPort.setVisibility(VisibilityKind.PUBLIC_LITERAL);
+ }
+
+ /**
+ * Sets the RT port properties as an service Access Point.
+ *
+ * @param serviceAccessPoint
+ * the new RT port as an service Access Point
+ */
+ protected void setSAPPort(final Port serviceAccessPoint) {
+ // isService: false
+ serviceAccessPoint.setIsService(false);
+
+ // isBehavior: true
+ serviceAccessPoint.setIsBehavior(true);
+
+ // isWired: false
+ RTPort stereotype = UMLUtil.getStereotypeApplication(serviceAccessPoint, RTPort.class);
+ stereotype.setIsWired(false);
+
+ // isPublish: false
+ stereotype.setIsPublish(false);
+
+ // Visibility: protected
+ serviceAccessPoint.setVisibility(VisibilityKind.PROTECTED_LITERAL);
+ }
+
+ /**
+ * Sets the RT port as service provision point.
+ *
+ * @param serviceProvisionPoint
+ * the new RT port as service provision point
+ */
+ protected void setSPPPort(final Port serviceProvisionPoint) {
+ // isService: true
+ serviceProvisionPoint.setIsService(true);
+
+ // isBehavior: true
+ serviceProvisionPoint.setIsBehavior(true);
+
+ // isWired: false
+ RTPort stereotype = UMLUtil.getStereotypeApplication(serviceProvisionPoint, RTPort.class);
+ stereotype.setIsWired(false);
+
+ // isPublish: true
+ stereotype.setIsPublish(true);
+
+ // Visibility: public
+ serviceProvisionPoint.setVisibility(VisibilityKind.PUBLIC_LITERAL);
}
}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/util/Constants.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/Constants.java
index 6fc003677..b0fa3daed 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/util/Constants.java
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/Constants.java
@@ -1,4 +1,4 @@
-package org.eclipse.papyrusrt.umlrt.tooling.ui.util;
+package org.eclipse.papyrusrt.umlrt.core.utils;
public final class Constants {
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindEnum.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortKindEnum.java
index 0d9fcc0df..0d6489a8d 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindEnum.java
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortKindEnum.java
@@ -1,6 +1,6 @@
-package org.eclipse.papyrusrt.umlrt.tooling.ui.widgets;
+package org.eclipse.papyrusrt.umlrt.core.utils;
-public enum PortRTKindEnum implements Comparable<PortRTKindEnum> {
+public enum RTPortKindEnum implements Comparable<RTPortKindEnum> {
/**
*
@@ -43,7 +43,7 @@ public enum PortRTKindEnum implements Comparable<PortRTKindEnum> {
- private PortRTKindEnum(int index, String label) {
+ private RTPortKindEnum(int index, String label) {
this.label = label;
this.index = index;
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortUtils.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortUtils.java
index 7b26816e4..7d5d377d8 100644
--- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortUtils.java
+++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/RTPortUtils.java
@@ -1,26 +1,109 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - add RTPORT_KIND_REQUEST_PARAMETER
+ *
+ *****************************************************************************/
package org.eclipse.papyrusrt.umlrt.core.utils;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Stereotype;
/**
- * Utility class on {@link Operation} that are RTMessage
+ * Utility class on {@link Operation} that are RTMessage.
*/
public class RTPortUtils {
+ /** The Constant RTPORT_KIND_REQUEST_PARAMETER. Used as key on creation request to define which kind of RTPort we want to create. */
+ public static final String RTPORT_KIND_REQUEST_PARAMETER = "RTPORT_KIND";
/**
+ * Checks if is a RT port.
+ *
* @param eObject
- * @return
+ * the e object
+ * @return true, if is a RT port
*/
public static boolean isRTPort(EObject eObject) {
if (eObject instanceof Port) {
// get Owner of the operation, and check if this is a messageSET
Port port = (Port) eObject;
- return true;//UMLUtil.getStereotype(stereotypeApplication);
+ if (null != getStereotype(port)) {
+ return true;// UMLUtil.getStereotype(stereotypeApplication);
+ }
+
}
return false;
}
+ public boolean isConnected(Port port) {
+ // TODO To Implements
+ return true;
+ }
+
+ public static Stereotype getStereotype(Port port) {
+ return port.getAppliedStereotype(Constants.UML_RT_STEREOTYPE_QN);
+ }
+
+
+ public static boolean isWired(Port port) {
+
+ return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), Constants.WIRED);
+ }
+
+ public static boolean isPublish(Port port) {
+ return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), Constants.PUBLISH);
+ }
+
+ public static boolean isNotification(Port port) {
+ return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), Constants.NOTIFICATION);
+ }
+
+ public static boolean isBehavior(Port port) {
+ return port.isBehavior();
+ }
+
+ public static boolean isService(Port port) {
+ return port.isService();
+ }
+
+ public static boolean isConjugated(Port port) {
+ return port.isConjugated();
+ }
+
+ /**
+ * Gets the kind of the RT Port.
+ *
+ * @param port
+ * the port
+ * @return the kind
+ */
+ public static RTPortKindEnum getKind(Port port) {
+ RTPortKindEnum kind = null;
+ if (null != getStereotype(port)) {
+ if (isService(port) && isWired(port) && isBehavior(port) && !isPublish(port)) {
+ kind = RTPortKindEnum.EXTERNAL;
+ } else if (isService(port) && isBehavior(port) && isPublish(port) && !isWired(port)) {
+ kind = RTPortKindEnum.SPP;
+ } else if (isWired(port) && isBehavior(port) && !isService(port) && !isPublish(port)) {
+ kind = RTPortKindEnum.INTERNAL;
+ } else if (isService(port) && isWired(port) && !isBehavior(port) && !isPublish(port)) {
+ kind = RTPortKindEnum.RELAY;
+ } else if (isBehavior(port) && !isWired(port) && !isPublish(port) && !isService(port)) {
+ kind = RTPortKindEnum.SAP;
+ }
+ }
+
+ return kind;
+ }
+
+
}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/plugin.xml b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/plugin.xml
index f9aa3bbea..ab7152b16 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/plugin.xml
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/plugin.xml
@@ -67,5 +67,20 @@
<strategy
strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.CapsuleToCapsulePartDropStrategy">
</strategy>
+ <!--<strategy
+ strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToRelayPortDropStrategy">
+ </strategy>-->
+ <strategy
+ strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToExternalBehaviorPortDropStrategy">
+ </strategy>
+ <!--<strategy
+ strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToSPPPortDropStrategy">
+ </strategy>-->
+ <strategy
+ strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToInternalBehavoirPortDropStrategy">
+ </strategy>
+ <!--<strategy
+ strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToSAPPortDropStrategy">
+ </strategy>-->
</extension>
</plugin>
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/AbstractProtocolToRTPortDropStrategy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/AbstractProtocolToRTPortDropStrategy.java
new file mode 100644
index 000000000..bdc2cd453
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/AbstractProtocolToRTPortDropStrategy.java
@@ -0,0 +1,189 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy;
+import org.eclipse.papyrusrt.umlrt.core.types.IUMLRTElementTypes;
+import org.eclipse.papyrusrt.umlrt.core.utils.CapsuleUtils;
+import org.eclipse.papyrusrt.umlrt.core.utils.ProtocolUtils;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Drop strategy to create a RTPort when droping a Protocol on a capsule.
+ */
+public abstract class AbstractProtocolToRTPortDropStrategy extends TransactionalDropStrategy {
+
+
+ private static final String EMPTY_STRING = "";// $NON-NLS-0$
+
+ /**
+ * Instantiates a new abstract protocol to rt port drop strategy.
+ */
+ public AbstractProtocolToRTPortDropStrategy() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getPriority()
+ */
+ @Override
+ public int getPriority() {
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy#doGetCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
+ */
+ @Override
+ protected Command doGetCommand(Request request, EditPart targetEditPart) {
+
+ Command command = null;
+ if ((request instanceof DropObjectsRequest)) {
+ DropObjectsRequest dropReq = getDropObjectsRequest(request);
+ if (dropReq != null) {
+ List<Classifier> handledDroppedObjects = getDroppedProtocol(dropReq);
+ EObject targetElement = getTargetSemanticElement(targetEditPart);
+ if (canHandleRequest(handledDroppedObjects, targetElement)) {
+ // dropping a protocol on a Capsule => creating a rt port
+ Point location = dropReq.getLocation();
+ CompoundCommand compoundCommand = new CompoundCommand();
+ for (EObject droppedObject : handledDroppedObjects) {
+ compoundCommand.add(getCreateAndDropObjectCommand(droppedObject, (Classifier) targetElement, location, targetEditPart));
+ location.performTranslate(20, 20);
+ command = compoundCommand;
+ }
+ }
+ }
+ }
+
+ return command;
+
+ }
+
+ /**
+ * Gets the creates the and drop object command.
+ *
+ * @param droppedObject
+ * the dropped object
+ * @param targetClassifier
+ * the target classifier
+ * @param location
+ * the location
+ * @param targetEditPart
+ * the target edit part
+ * @return the creates the and drop object command
+ */
+ protected Command getCreateAndDropObjectCommand(EObject droppedObject, Classifier targetClassifier, Point location, EditPart targetEditPart) {
+ // create RTport part
+ CreateRTPortAndDisplayCommand command = new CreateRTPortAndDisplayCommand(targetClassifier, IUMLRTElementTypes.RT_PORT_ID, UMLPackage.eINSTANCE.getNamespace_OwnedMember(), droppedObject, location, targetEditPart);
+ // set Name
+ command.setRTPortName(getName(droppedObject));
+ // Set kind
+ command.setRTPortKind(getRTPortKind());
+ return new ICommandProxy(command);
+ }
+
+
+ /**
+ * Gets the name of the dropped object.
+ *
+ * @param droppedObject
+ * the dropped object
+ * @return the name
+ */
+ protected String getName(EObject droppedObject) {
+ String name = EMPTY_STRING;
+ if (droppedObject instanceof NamedElement) {
+ String elementName = ((NamedElement) droppedObject).getName();
+ if (elementName.length() > 0) {
+ name = Character.toLowerCase(elementName.charAt(0)) + elementName.substring(1);
+ }
+ }
+ return name;
+
+ }
+
+ /**
+ * Gets the dropped protocol.
+ *
+ * @param req
+ * the req
+ * @return the dropped protocol
+ */
+ protected List<Classifier> getDroppedProtocol(Request req) {
+ List<EObject> droppedObjects = getSourceEObjects(req);
+ List<Classifier> result = new ArrayList<Classifier>();
+ if (droppedObjects != null) {
+ for (EObject droppedObject : droppedObjects) {
+ if (droppedObject instanceof Classifier) {
+ if (ProtocolUtils.isProtocol(droppedObject)) {
+ result.add((Classifier) droppedObject);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Can handle request.
+ *
+ * @param droppedObjects
+ * the dropped objects
+ * @param targetElement
+ * the target element
+ * @return true, if successful
+ */
+ protected boolean canHandleRequest(List<Classifier> droppedObjects, EObject targetElement) {
+ boolean result = false;
+ if (!droppedObjects.isEmpty()) {
+ result = (targetElement instanceof Classifier && CapsuleUtils.isCapsule((Classifier) targetElement) && droppedObjects.size() > 0);
+ }
+ return result;
+ }
+
+ /**
+ * Gets the kind of the RTPort. The Kind is a {@link RTPortKindEnum}.
+ *
+ * @return the kind of the RTPort.
+ */
+ abstract protected RTPortKindEnum getRTPortKind();
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/CreateRTPortAndDisplayCommand.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/CreateRTPortAndDisplayCommand.java
new file mode 100644
index 000000000..653ae55d8
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/CreateRTPortAndDisplayCommand.java
@@ -0,0 +1,319 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrusrt.umlrt.core.types.IUMLRTElementTypes;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.Activator;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Command to create a RTPort, and display it to the given location.
+ */
+// TODO: fix the location of the port
+public class CreateRTPortAndDisplayCommand extends AbstractCommand {
+
+ private static final String EMPTY_STRING = ""; // $NON-NLS-0$
+
+ /** The target classifier. */
+ protected Classifier targetClassifier;
+
+ /** The rt port id. */
+ protected String rtPortId;
+
+ /** The classifier reference. */
+ protected EReference classifierReference;
+
+ /** The dropped object. */
+ protected EObject droppedObject;
+
+ /** The location. */
+ protected Point location;
+
+ /** The target edit part. */
+ protected EditPart targetEditPart;
+
+ /** The name. */
+ private String name;
+
+ /** The kind. */
+ private RTPortKindEnum kind = RTPortKindEnum.RELAY;
+
+ /**
+ * Instantiates a new creates the rt port and display command.
+ *
+ * @param targetClassifier
+ * the target classifier
+ * @param rtPortId
+ * the rt port id
+ * @param classifier_Feature
+ * the classifier_ feature
+ * @param droppedObject
+ * the dropped object
+ * @param location
+ * the location
+ * @param targetEditPart
+ * the target edit part
+ */
+ public CreateRTPortAndDisplayCommand(Classifier targetClassifier, String rtPortId, EReference classifier_Feature, EObject droppedObject, Point location, EditPart targetEditPart) {
+ super(EMPTY_STRING);
+ this.targetClassifier = targetClassifier;
+ this.rtPortId = rtPortId;
+ this.classifierReference = classifier_Feature;
+ this.droppedObject = droppedObject;
+ this.location = new Point(location);
+ this.targetEditPart = targetEditPart;
+ }
+
+ /**
+ * Do execute with result.
+ *
+ * @param progressMonitor
+ * the progress monitor
+ * @param info
+ * the info
+ * @return the command result
+ * @throws ExecutionException
+ * the execution exception
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ TransactionalEditingDomain editingDomain = null;
+ try {
+ editingDomain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(targetClassifier);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ return CommandResult.newErrorCommandResult(e);
+ }
+ // Create the port
+ Port rtPort = createRTPort(editingDomain);
+
+ // Set the Name and the Kind of the Port
+ setRTPort(editingDomain, rtPort, name, kind);
+ // Bind the source protocol to the created RTPort as a Type
+ setProtocolAsType(editingDomain, rtPort, droppedObject);
+ // Drop the Port
+ dropRTPort(editingDomain, rtPort);
+
+ return CommandResult.newOKCommandResult(rtPort);
+ }
+
+
+
+ /**
+ * Sets the RTPort.
+ *
+ * @param editingDomain
+ * the editing domain
+ * @param rtPort
+ * the RTPort
+ */
+ protected void setRTPort(TransactionalEditingDomain editingDomain, Port rtPort, String rtPortName, RTPortKindEnum rtPortKind) {
+ // Set the name
+ SetRequest setRequest = new SetRequest(editingDomain, rtPort, UMLPackage.eINSTANCE.getNamedElement_Name(), rtPortName);
+
+ // Set the kind
+ setRequest.addParameters(Collections.singletonMap(RTPortUtils.RTPORT_KIND_REQUEST_PARAMETER, rtPortKind));
+
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_PORT_ID));
+ if (provider != null) {
+ ICommand setCommand = provider.getEditCommand(setRequest);
+
+ if (setCommand != null && setCommand.canExecute()) {
+ try {
+ setCommand.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Sets the protocol as type.
+ *
+ * @param editingDomain
+ * the editing domain
+ * @param rtPort
+ * the rt port
+ * @param type
+ * the type
+ */
+ protected void setProtocolAsType(TransactionalEditingDomain editingDomain, Port rtPort, EObject type) {
+ SetRequest setRequest = new SetRequest(editingDomain, rtPort, UMLPackage.eINSTANCE.getTypedElement_Type(), type);
+
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetClassifier);
+ if (provider != null) {
+ ICommand setCommand = provider.getEditCommand(setRequest);
+
+ if (setCommand != null && setCommand.canExecute()) {
+ try {
+ setCommand.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Drop RT Port.
+ *
+ * @param createdRTPort
+ * the created RTPort
+ */
+ protected void dropRTPort(TransactionalEditingDomain editingDomain, Port createdRTPort) {
+ CompoundCommand cc = new CompoundCommand();
+ DropObjectsRequest dropReq = new DropObjectsRequest();
+ dropReq.setObjects(Arrays.asList(createdRTPort));
+ dropReq.setLocation(location);
+ Command dropReqCommand = targetEditPart.getCommand(dropReq);
+ cc.add(dropReqCommand);
+
+ if (cc != null && cc.canExecute()) {
+ cc.execute();
+ }
+
+
+ }
+
+
+ /**
+ * Creates the rt port.
+ *
+ * @param editingDomain
+ * the editing domain
+ * @return the port
+ */
+ protected Port createRTPort(TransactionalEditingDomain editingDomain) {
+ Port createdPort = null;
+ CreateElementRequest createElementRequest = new CreateElementRequest(editingDomain, targetClassifier, ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_PORT_ID));
+
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetClassifier);
+ if (provider != null) {
+
+ ICommand createCommand = provider.getEditCommand(createElementRequest);
+
+ if (createCommand != null && createCommand.canExecute()) {
+ try {
+ createCommand.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ Activator.log.error(e);
+ return null;
+ }
+ CommandResult result = createCommand.getCommandResult();
+ createdPort = getCreatedObject(result);
+ return createdPort;
+ }
+
+ }
+
+ return createdPort;
+ }
+
+ /**
+ * Gets the created object.
+ *
+ * @param <T>
+ * the generic type
+ * @param commandResult
+ * the command result
+ * @return the created object
+ */
+ public static <T extends EObject> T getCreatedObject(CommandResult commandResult) {
+ Object objectResult = commandResult.getReturnValue();
+ if (objectResult instanceof List) {
+ // Result of the semantic + graphical creation command
+ List<?> listResult = (List<?>) objectResult;
+ for (Object elementResult : listResult) {
+ if (elementResult instanceof CreateElementRequestAdapter) {
+ CreateElementRequest request = (CreateElementRequest) ((CreateElementRequestAdapter) elementResult).getAdapter(CreateElementRequest.class);
+ if (request != null) {
+ EObject newElement = request.getNewElement();
+ if (newElement instanceof EObject) {
+ return (T) newElement;
+ }
+ }
+ }
+ }
+ } else if (commandResult.getReturnValue() instanceof EObject) {
+ // Result of the semantic creation command
+ return (T) commandResult.getReturnValue();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+
+ @Override
+ protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+
+ /**
+ * Sets the RT port name.
+ *
+ * @param name
+ * the new RT port name
+ */
+ public void setRTPortName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the RTPort kind.
+ *
+ * @param rtPortKindEnum
+ * the new RT port kind
+ */
+ public void setRTPortKind(RTPortKindEnum rtPortKindEnum) {
+ this.kind = rtPortKindEnum;
+ }
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToExternalBehaviorPortDropStrategy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToExternalBehaviorPortDropStrategy.java
new file mode 100644
index 000000000..21f93c786
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToExternalBehaviorPortDropStrategy.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.Activator;
+
+/**
+ * Drop strategy to create a Relay Port when droping a protocol on a capsule.
+ */
+public class ProtocolToExternalBehaviorPortDropStrategy extends AbstractProtocolToRTPortDropStrategy {
+
+ /**
+ * Constructor.
+ */
+ public ProtocolToExternalBehaviorPortDropStrategy() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ return "Protocol drop to create External Behavior Port";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return "Protocol drop to create External Behavior Port";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID()
+ */
+ @Override
+ public String getID() {
+ return Activator.PLUGIN_ID + ".protocolToExternalBehaviorPortDrop";//$NON-NLS-1$
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.AbstractProtocolToRTPortDropStrategy#doGetCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
+ */
+ @Override
+ protected Command doGetCommand(Request request, EditPart targetEditPart) {
+ boolean canHandle = false;
+
+ // can handle it if its on the Edit Part(the border)
+ if (!(targetEditPart instanceof DiagramEditPart) && !(targetEditPart instanceof CompartmentEditPart)) {
+ canHandle = true;
+ }
+
+ return canHandle ? super.doGetCommand(request, targetEditPart) : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.AbstractProtocolToRTPortDropStrategy#getRTPortKind()
+ */
+ @Override
+ protected RTPortKindEnum getRTPortKind() {
+ return RTPortKindEnum.EXTERNAL;
+ }
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToInternalBehavoirPortDropStrategy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToInternalBehavoirPortDropStrategy.java
new file mode 100644
index 000000000..6f19c3d14
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToInternalBehavoirPortDropStrategy.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.Activator;
+
+/**
+ * Drop strategy to create a Internal Behavoir Port when droping a protocol on a capsule.
+ */
+public class ProtocolToInternalBehavoirPortDropStrategy extends AbstractProtocolToRTPortDropStrategy {
+
+ /**
+ * Constructor.
+ */
+ public ProtocolToInternalBehavoirPortDropStrategy() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ return "Protocol drop to create Internal Behavoir Port";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return "Protocol drop to create Internal Behavoir Port";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getID()
+ */
+ @Override
+ public String getID() {
+ return Activator.PLUGIN_ID + ".protocolToInternalBehavoirPortDrop";//$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.AbstractProtocolToRTPortDropStrategy#doGetCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
+ */
+ @Override
+ protected Command doGetCommand(Request request, EditPart targetEditPart) {
+ // initDefaultStrategy();
+
+ boolean canHandle = false;
+
+ if ((targetEditPart instanceof CompartmentEditPart)) {
+ canHandle = true;
+ targetEditPart = targetEditPart.getParent();
+ }
+
+ return canHandle ? super.doGetCommand(request, targetEditPart) : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.AbstractProtocolToRTPortDropStrategy#getRTPortKind()
+ */
+ @Override
+ protected RTPortKindEnum getRTPortKind() {
+ return RTPortKindEnum.INTERNAL;
+ }
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToRelayPortDropStrategy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToRelayPortDropStrategy.java
new file mode 100644
index 000000000..c669477fe
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToRelayPortDropStrategy.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.Activator;
+
+/**
+ * Drop strategy to create a Relay Port when droping a protocol on a capsule
+ */
+public class ProtocolToRelayPortDropStrategy extends AbstractProtocolToRTPortDropStrategy {
+
+ /**
+ * Constructor.
+ */
+ public ProtocolToRelayPortDropStrategy() {
+ }
+
+ @Override
+ public String getLabel() {
+ return "Protocol drop to create Relay Port";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Protocol drop to create Relay Port";
+ }
+
+ @Override
+ public String getID() {
+ return Activator.PLUGIN_ID + ".protocolToRelayPortDrop";//$NON-NLS-1$
+ }
+
+
+ @Override
+ protected Command doGetCommand(Request request, EditPart targetEditPart) {
+ boolean canHandle = false;
+
+ // can handle it if its on the Edit Part(the border)
+ if (!(targetEditPart instanceof DiagramEditPart) && !(targetEditPart instanceof CompartmentEditPart)) {
+ canHandle = true;
+ }
+
+ return canHandle ? super.doGetCommand(request, targetEditPart) : null;
+ }
+
+ @Override
+ protected RTPortKindEnum getRTPortKind() {
+ return RTPortKindEnum.RELAY;
+ }
+
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSAPPortDropStrategy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSAPPortDropStrategy.java
new file mode 100644
index 000000000..e4e8a5e05
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSAPPortDropStrategy.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.Activator;
+
+/**
+ * Drop strategy to create a SAP Port when droping a protocol on a capsule
+ */
+public class ProtocolToSAPPortDropStrategy extends AbstractProtocolToRTPortDropStrategy {
+
+ /**
+ * Constructor.
+ */
+ public ProtocolToSAPPortDropStrategy() {
+ }
+
+ @Override
+ public String getLabel() {
+ return "Protocol drop to create SAP Port";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Protocol drop to create SAP Port";
+ }
+
+ @Override
+ public String getID() {
+ return Activator.PLUGIN_ID + ".protocolToSAPPortDrop";//$NON-NLS-1$
+ }
+
+ @Override
+ protected Command doGetCommand(Request request, EditPart targetEditPart) {
+ boolean canHandle = false;
+
+ if ((targetEditPart instanceof CompartmentEditPart)) {
+ canHandle = true;
+ targetEditPart = targetEditPart.getParent();
+ }
+
+ return canHandle ? super.doGetCommand(request, targetEditPart) : null;
+ }
+
+ @Override
+ protected RTPortKindEnum getRTPortKind() {
+ return RTPortKindEnum.SAP;
+ }
+
+
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSPPPortDropStrategy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSPPPortDropStrategy.java
new file mode 100644
index 000000000..87dda166f
--- /dev/null
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/drop/ProtocolToSPPPortDropStrategy.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *****************************************************************************/
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.Activator;
+
+/**
+ * Drop strategy to create a SPP Port when droping a protocol on a capsule
+ */
+public class ProtocolToSPPPortDropStrategy extends AbstractProtocolToRTPortDropStrategy {
+
+ /**
+ * Constructor.
+ */
+ public ProtocolToSPPPortDropStrategy() {
+ }
+
+ @Override
+ public String getLabel() {
+ return "Protocol drop to create SPP Port";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Protocol drop to create SPP Port";
+ }
+
+ @Override
+ public String getID() {
+ return Activator.PLUGIN_ID + ".protocolToSPPPortDrop";//$NON-NLS-1$
+ }
+
+
+ @Override
+ protected Command doGetCommand(Request request, EditPart targetEditPart) {
+ boolean canHandle = false;
+
+ // can handle it if its on the Edit Part(the border)
+ if (!(targetEditPart instanceof DiagramEditPart) && !(targetEditPart instanceof CompartmentEditPart)) {
+ canHandle = true;
+ }
+
+ return canHandle ? super.doGetCommand(request, targetEditPart) : null;
+ }
+
+ @Override
+ protected RTPortKindEnum getRTPortKind() {
+ return RTPortKindEnum.SPP;
+ }
+
+
+
+}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/META-INF/MANIFEST.MF b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/META-INF/MANIFEST.MF
index f6056257e..4e6f9e2f9 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/META-INF/MANIFEST.MF
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/META-INF/MANIFEST.MF
@@ -26,10 +26,11 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.core;bundle-version="1.1.1",
org.eclipse.papyrusrt.umlrt.core;bundle-version="0.7.0",
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.1.1",
- org.eclipse.papyrus.infra.elementtypesconfigurations
+ org.eclipse.papyrus.infra.elementtypesconfigurations,
+ org.eclipse.papyrus.uml.properties,
+ org.eclipse.papyrus.uml.diagram.common
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrusrt.umlrt.tooling.ui,
org.eclipse.papyrusrt.umlrt.tooling.ui.modelelement,
- org.eclipse.papyrusrt.umlrt.tooling.ui.util,
org.eclipse.papyrusrt.umlrt.tooling.ui.widgets
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java
index 0ad24f4de..d422cea59 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java
@@ -23,8 +23,8 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
import org.eclipse.papyrus.uml.properties.modelelement.StereotypeModelElement;
-import org.eclipse.papyrusrt.umlrt.tooling.ui.util.Constants;
-import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.PortRTKindEnum;
+import org.eclipse.papyrusrt.umlrt.core.utils.Constants;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.PortRTKindObservableValue;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Stereotype;
@@ -93,11 +93,11 @@ public class RTStereotypeModelElement extends StereotypeModelElement {
if (Constants.KIND.equals(propertyPath)) {
Map<Object, String> map = new HashMap<Object, String>();
- map.put(PortRTKindEnum.EXTERNAL, PortRTKindEnum.EXTERNAL.getLabel());
- map.put(PortRTKindEnum.INTERNAL, PortRTKindEnum.INTERNAL.getLabel());
- map.put(PortRTKindEnum.RELAY, PortRTKindEnum.RELAY.getLabel());
- map.put(PortRTKindEnum.SAP, PortRTKindEnum.SAP.getLabel());
- map.put(PortRTKindEnum.SPP, PortRTKindEnum.SPP.getLabel());
+ map.put(RTPortKindEnum.EXTERNAL, RTPortKindEnum.EXTERNAL.getLabel());
+ map.put(RTPortKindEnum.INTERNAL, RTPortKindEnum.INTERNAL.getLabel());
+ map.put(RTPortKindEnum.RELAY, RTPortKindEnum.RELAY.getLabel());
+ map.put(RTPortKindEnum.SAP, RTPortKindEnum.SAP.getLabel());
+ map.put(RTPortKindEnum.SPP, RTPortKindEnum.SPP.getLabel());
provider = new StaticContentProvider(map.keySet().toArray());
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java
index 4b71c7625..0623afd12 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java
@@ -37,9 +37,9 @@ import org.eclipse.papyrus.uml.properties.modelelement.UMLModelElement;
import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
+import org.eclipse.papyrusrt.umlrt.core.utils.Constants;
import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTMessageKind;
import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTMessageSet;
-import org.eclipse.papyrusrt.umlrt.tooling.ui.util.Constants;
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.CapsulePartTypeValueFactory;
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.RTPortTypeValueFactory;
import org.eclipse.uml2.uml.Collaboration;
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/util/RTPortHelper.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/util/RTPortHelper.java
deleted file mode 100644
index fb7f4501d..000000000
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/util/RTPortHelper.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.eclipse.papyrusrt.umlrt.tooling.ui.util;
-
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Stereotype;
-
-public class RTPortHelper {
- /**
- * singleton instance
- */
- private static RTPortHelper helper;
-
- /** Singleton constructor */
- private RTPortHelper() {
- }
-
- /**
- * Returns the singleton instance of this class
- *
- * @return the singleton instance.
- */
- public static RTPortHelper getInstance() {
- if (helper == null) {
- helper = new RTPortHelper();
- }
- return helper;
- }
-
- public boolean isConnected(Port port) {
- // TODO To Implements
- return true;
- }
-
- public Stereotype getStereotype(Port port) {
- return port.getAppliedStereotype(Constants.UML_RT_STEREOTYPE_QN);
- }
-
-
- public boolean isWired(Port port) {
- return (Boolean) port.getValue(getStereotype(port), Constants.WIRED);
- }
-
- public boolean isPublish(Port port) {
- return (Boolean) port.getValue(getStereotype(port), Constants.PUBLISH);
- }
-
- public boolean isNotification(Port port) {
- return (Boolean) port.getValue(getStereotype(port), Constants.NOTIFICATION);
- }
-
- public boolean isBehavior(Port port) {
- return port.isBehavior();
- }
-
- public boolean isService(Port port) {
- return port.isService();
- }
-
- public boolean isConjugated(Port port) {
- return port.isConjugated();
- }
-
-
-}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindObservableValue.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindObservableValue.java
index dc3a28062..558c5094e 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindObservableValue.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/PortRTKindObservableValue.java
@@ -15,8 +15,9 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
-import org.eclipse.papyrusrt.umlrt.tooling.ui.util.Constants;
-import org.eclipse.papyrusrt.umlrt.tooling.ui.util.RTPortHelper;
+import org.eclipse.papyrusrt.umlrt.core.utils.Constants;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
+import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Stereotype;
@@ -93,23 +94,23 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements
*
*/
private void setUMLRTPropertiesValue() {
- wired = RTPortHelper.getInstance().isWired(port);
- notification = RTPortHelper.getInstance().isNotification(port);
- publish = RTPortHelper.getInstance().isPublish(port);
+ wired = RTPortUtils.isWired(port);
+ notification = RTPortUtils.isNotification(port);
+ publish = RTPortUtils.isPublish(port);
}
/**
*
*/
private void setUMLPropertiesValue() {
- service = RTPortHelper.getInstance().isService(port);
- behavior = RTPortHelper.getInstance().isBehavior(port);
- conjugated = RTPortHelper.getInstance().isConjugated(port);
+ service = RTPortUtils.isService(port);
+ behavior = RTPortUtils.isBehavior(port);
+ conjugated = RTPortUtils.isConjugated(port);
}
@Override
public Object getValueType() {
- return PortRTKindEnum.class;
+ return RTPortKindEnum.class;
}
@Override
@@ -121,21 +122,21 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements
@Override
protected Object doGetValue() {
- PortRTKindEnum kind = PortRTKindEnum.RELAY;
+ RTPortKindEnum kind = RTPortKindEnum.RELAY;
setUMLPropertiesValue();
setUMLRTPropertiesValue();
if (service && wired && behavior && !publish) {
- kind = PortRTKindEnum.EXTERNAL;
+ kind = RTPortKindEnum.EXTERNAL;
} else if (service && behavior && publish && !wired) {
- kind = PortRTKindEnum.SPP;
+ kind = RTPortKindEnum.SPP;
} else if (wired && behavior && !service && !publish) {
- kind = PortRTKindEnum.INTERNAL;
+ kind = RTPortKindEnum.INTERNAL;
} else if (service && wired && !behavior && !publish) {
- kind = PortRTKindEnum.RELAY;
+ kind = RTPortKindEnum.RELAY;
} else if (behavior && !wired && !publish && !service) {
- kind = PortRTKindEnum.SAP;
+ kind = RTPortKindEnum.SAP;
}
return kind;
@@ -152,9 +153,9 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements
@Override
public Command getCommand(Object value) {
Command command = null;
- if (value instanceof PortRTKindEnum) {
+ if (value instanceof RTPortKindEnum) {
// For Each Kind of Port, set the property accordingly
- switch ((PortRTKindEnum) value) {
+ switch ((RTPortKindEnum) value) {
case EXTERNAL:
command = getCommandForRTPort(true, false, true, true);
break;

Back to the top