diff options
| author | Céline Janssens | 2015-08-28 15:59:53 +0000 |
|---|---|---|
| committer | Remi Schnekenburger | 2015-09-01 13:08:08 +0000 |
| commit | 4f272b0bc82686c312ad1ba5e9abe6996e313790 (patch) | |
| tree | 797ca39b65da876b5580f251f4f894f6149375be | |
| parent | 33b9811beddb6405e0c2a160f298cab29831a710 (diff) | |
| download | org.eclipse.papyrus-rt-4f272b0bc82686c312ad1ba5e9abe6996e313790.tar.gz org.eclipse.papyrus-rt-4f272b0bc82686c312ad1ba5e9abe6996e313790.tar.xz org.eclipse.papyrus-rt-4f272b0bc82686c312ad1ba5e9abe6996e313790.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
- change Class location (architecture)
- Fix approximative port location
- Add Message.properties to the build
- fix the typo for internal port drop strategy
- added custom label to property view for capsulepart:multiplicity
- change back the multiplicity editor for the release. should be set
back to custom UML-Rt management after release 0.7.0
Change-Id: Icd033b8562428079bec14c73839a3334b325681f
Signed-off-by: Céline Janssens <Celine.Janssens@all4tec.net>
26 files changed, 515 insertions, 204 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 e84cec412..cf847cd57 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 @@ -10,7 +10,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0", org.eclipse.uml2.uml;bundle-version="5.1.0", org.eclipse.papyrusrt.umlrt.profile;bundle-version="0.7.0", org.eclipse.papyrus.infra.tools;bundle-version="1.1.1", - org.eclipse.papyrus.uml.tools.utils;bundle-version="1.1.1", org.eclipse.papyrus.infra.core.log;bundle-version="1.1.1", org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.1", org.eclipse.papyrus.uml.service.types;bundle-version="1.1.1", @@ -25,9 +24,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0", 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.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" + org.eclipse.papyrus.uml.tools.utils 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/build.properties b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/build.properties index 24277f373..e91a4c87e 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/build.properties +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/build.properties @@ -4,4 +4,5 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ elementtypes/,\ - about.html + about.html,\ + messages.properties 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 d23695015..890b9c135 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/plugin.xml +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/plugin.xml @@ -33,13 +33,4 @@ 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/types/advice/ExternalBehaviorPortEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ExternalBehaviorPortEditHelperAdvice.java index 3eae51bc1..713277a6e 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ExternalBehaviorPortEditHelperAdvice.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ExternalBehaviorPortEditHelperAdvice.java @@ -1,3 +1,14 @@ +/***************************************************************************** + * 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.types.advice; import org.eclipse.core.commands.ExecutionException; @@ -9,6 +20,7 @@ import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTPort; import org.eclipse.uml2.uml.Port; import org.eclipse.uml2.uml.VisibilityKind; @@ -37,7 +49,7 @@ public class ExternalBehaviorPortEditHelperAdvice extends AbstractEditHelperAdvi @Override protected ICommand getAfterConfigureCommand(ConfigureRequest request) { final Port externalBehaviorPort = (Port) request.getElementToConfigure(); - // final String name = NamedElementUtil.getDefaultNameWithIncrementFromBase("port", externalBehaviorPort.eContainer().eContents()); + final String name = NamedElementUtil.getDefaultNameWithIncrementFromBase("port", externalBehaviorPort.eContainer().eContents()); return new ConfigureElementCommand(request) { @@ -45,7 +57,7 @@ public class ExternalBehaviorPortEditHelperAdvice extends AbstractEditHelperAdvi protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { // isService: true externalBehaviorPort.setIsService(true); - + // isBehavior: true externalBehaviorPort.setIsBehavior(true); @@ -60,7 +72,7 @@ public class ExternalBehaviorPortEditHelperAdvice extends AbstractEditHelperAdvi externalBehaviorPort.setVisibility(VisibilityKind.PUBLIC_LITERAL); // name - externalBehaviorPort.setName(null); + externalBehaviorPort.setName(name); return CommandResult.newOKCommandResult(externalBehaviorPort); } diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/InternalBehaviorPortEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/InternalBehaviorPortEditHelperAdvice.java index f9a639697..e97c50038 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/InternalBehaviorPortEditHelperAdvice.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/InternalBehaviorPortEditHelperAdvice.java @@ -1,3 +1,14 @@ +/***************************************************************************** + * 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: + * CEA LIST- Initial API and implementation + *****************************************************************************/ package org.eclipse.papyrusrt.umlrt.core.types.advice; import org.eclipse.core.commands.ExecutionException; @@ -15,7 +26,6 @@ import org.eclipse.uml2.uml.Port; import org.eclipse.uml2.uml.VisibilityKind; import org.eclipse.uml2.uml.util.UMLUtil; - /** * The helperadvice class used for UMLRealTime::Protocol. * @@ -24,16 +34,26 @@ import org.eclipse.uml2.uml.util.UMLUtil; */ public class InternalBehaviorPortEditHelperAdvice extends AbstractEditHelperAdvice { + /** + * Gets the before create relationship command. + * + * @param request + * the request + * @return the before create relationship command + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeCreateRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest) + */ @Override protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) { return super.getBeforeCreateRelationshipCommand(request); } /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) + * Gets the after configure command. * * @param request - * @return + * the request + * @return the after configure command + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) */ @Override protected ICommand getAfterConfigureCommand(ConfigureRequest request) { @@ -46,7 +66,7 @@ public class InternalBehaviorPortEditHelperAdvice extends AbstractEditHelperAdvi protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { // isService: false internalBehaviorPort.setIsService(false); - + // isBehavior: true internalBehaviorPort.setIsBehavior(true); diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ProtocolEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ProtocolEditHelperAdvice.java index 653366b8f..381b07eff 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ProtocolEditHelperAdvice.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ProtocolEditHelperAdvice.java @@ -98,7 +98,6 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { return false; } - // return super.approveRequest(createElementRequest); } } return super.approveRequest(request); @@ -151,7 +150,7 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { } else if (editCommandRequest instanceof DestroyElementRequest) { EObject eObject = ((DestroyElementRequest) editCommandRequest).getElementToDestroy(); - if(eObject instanceof Collaboration) { + if (eObject instanceof Collaboration) { if (ProtocolUtils.isProtocol(eObject)) { Package protocolContainerToDestroy = ProtocolUtils.getProtocolContainer((Collaboration) eObject); // if element to destroy is the protocol, the target of the request should be the protocol container instead of the protocol itself @@ -290,7 +289,7 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { } /** - * Creates an UML::InterfaceRealization relation between protocol and rtMessageSet with given name. + * Creates an UML::InterfaceRealization relation between protocol and rtMessageSet with given name. * * @param protocol * @param name @@ -328,7 +327,7 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { throw new ExecutionException("Element creation problem for " + elementType.getDisplayName() + "."); } - ((NamedElement)newElement).setName(name); + ((NamedElement) newElement).setName(name); if (relation == Relation.CHILD) { // if newElement is an owned element of protocol if (elementType == UMLElementTypes.INTERFACE_REALIZATION) { @@ -348,7 +347,7 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { return newElement; } - private void setRtMsgKind(Interface rtMessageSetInt, RTMessageKind kind){ + private void setRtMsgKind(Interface rtMessageSetInt, RTMessageKind kind) { RTMessageSet rtMessageSet = UMLUtil.getStereotypeApplication(rtMessageSetInt, RTMessageSet.class); rtMessageSet.setRtMsgKind(kind); } diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RelayPortEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RelayPortEditHelperAdvice.java index 7ccb304c7..bfb5499a3 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RelayPortEditHelperAdvice.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/RelayPortEditHelperAdvice.java @@ -1,3 +1,14 @@ +/***************************************************************************** + * 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.types.advice; import org.eclipse.core.commands.ExecutionException; @@ -46,7 +57,7 @@ public class RelayPortEditHelperAdvice extends AbstractEditHelperAdvice { protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { // isService: true relayPort.setIsService(true); - + // isBehavior: false relayPort.setIsBehavior(false); diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceAccessPointEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceAccessPointEditHelperAdvice.java index d77ab1436..5a4bd7764 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceAccessPointEditHelperAdvice.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceAccessPointEditHelperAdvice.java @@ -1,3 +1,14 @@ +/***************************************************************************** + * 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.types.advice; import org.eclipse.core.commands.ExecutionException; diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceProvisionPointEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceProvisionPointEditHelperAdvice.java index a75b1943a..3f4431954 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceProvisionPointEditHelperAdvice.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/ServiceProvisionPointEditHelperAdvice.java @@ -1,3 +1,14 @@ +/***************************************************************************** + * 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.types.advice; import org.eclipse.core.commands.ExecutionException; @@ -21,7 +32,6 @@ import org.eclipse.uml2.uml.Port; import org.eclipse.uml2.uml.VisibilityKind; import org.eclipse.uml2.uml.util.UMLUtil; - /** * The helperadvice class used for UMLRealTime::Protocol. * @@ -30,6 +40,12 @@ import org.eclipse.uml2.uml.util.UMLUtil; */ public class ServiceProvisionPointEditHelperAdvice extends AbstractEditHelperAdvice { + /** + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) + * + * @param request + * @return + */ @Override public boolean approveRequest(IEditCommandRequest request) { if (request instanceof CreateRelationshipRequest) { @@ -48,10 +64,12 @@ public class ServiceProvisionPointEditHelperAdvice extends AbstractEditHelperAdv } /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) + * Gets the after configure command. * * @param request - * @return + * the request + * @return the after configure command + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) */ @Override protected ICommand getAfterConfigureCommand(ConfigureRequest request) { diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/Constants.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/IRealTimeConstants.java index e6dfd79b8..6367e4456 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/Constants.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/utils/IRealTimeConstants.java @@ -15,14 +15,9 @@ package org.eclipse.papyrusrt.umlrt.core.utils; /** * This Class regroups all the Constants related to the Real Time context. */ -public final class Constants { - - /** - * Instantiates a new constants. - */ - private Constants() { - // Private constructor to avoid instantiation - } +public interface IRealTimeConstants { + + /** The Constant UML_RT_STEREOTYPE_QN. */ 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 7d5d377d8..c9a63c28c 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 @@ -50,21 +50,21 @@ public class RTPortUtils { }
public static Stereotype getStereotype(Port port) {
- return port.getAppliedStereotype(Constants.UML_RT_STEREOTYPE_QN);
+ return port.getAppliedStereotype(IRealTimeConstants.UML_RT_STEREOTYPE_QN);
}
public static boolean isWired(Port port) {
- return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), Constants.WIRED);
+ return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), IRealTimeConstants.WIRED);
}
public static boolean isPublish(Port port) {
- return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), Constants.PUBLISH);
+ return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), IRealTimeConstants.PUBLISH);
}
public static boolean isNotification(Port port) {
- return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), Constants.NOTIFICATION);
+ return getStereotype(port) == null ? false : (Boolean) port.getValue(getStereotype(port), IRealTimeConstants.NOTIFICATION);
}
public static boolean isBehavior(Port port) {
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/META-INF/MANIFEST.MF b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/META-INF/MANIFEST.MF index 37c2f4665..dad68cfaa 100644 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/META-INF/MANIFEST.MF +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/META-INF/MANIFEST.MF @@ -39,15 +39,16 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrusrt.umlrt.tooling.wizards;bundle-version="0.7.0", org.eclipse.papyrus.infra.gmfdiag.dnd, org.eclipse.papyrus.infra.services.edit;bundle-version="1.1.1", - org.eclipse.papyrusrt.umlrt.tooling.ui;bundle-version="0.7.0" + org.eclipse.papyrusrt.umlrt.tooling.ui;bundle-version="0.7.0", + org.eclipse.gmf.tooling.runtime;bundle-version="3.3.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy -Import-Package: org.eclipse.papyrusrt.umlrt.core.sync Export-Package: org.eclipse.papyrusrt.umlrt.tooling.diagram.common, org.eclipse.papyrusrt.umlrt.tooling.diagram.common.copy, org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop, org.eclipse.papyrusrt.umlrt.tooling.diagram.common.internal.sync, org.eclipse.papyrusrt.umlrt.tooling.diagram.common.internal.sync.statemachine, + org.eclipse.papyrusrt.umlrt.tooling.diagram.common.locator, org.eclipse.papyrusrt.umlrt.tooling.diagram.common.provider, org.eclipse.papyrusrt.umlrt.tooling.diagram.common.query, org.eclipse.papyrusrt.umlrt.tooling.diagram.common.service, 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 ab7152b16..903458b26 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 @@ -77,10 +77,19 @@ strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToSPPPortDropStrategy"> </strategy>--> <strategy - strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToInternalBehavoirPortDropStrategy"> + strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToInternalBehaviorPortDropStrategy"> </strategy> <!--<strategy strategy="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.drop.ProtocolToSAPPortDropStrategy"> </strategy>--> </extension> + <extension + point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders"> + <editpartProvider + class="org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editparts.providers.RTEditPartProvider"> + <Priority + name="Medium"> + </Priority> + </editpartProvider> + </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 index bdc2cd453..236b98d55 100644 --- 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 @@ -80,11 +80,12 @@ public abstract class AbstractProtocolToRTPortDropStrategy extends Transactional if (dropReq != null) { List<Classifier> handledDroppedObjects = getDroppedProtocol(dropReq); EObject targetElement = getTargetSemanticElement(targetEditPart); - if (canHandleRequest(handledDroppedObjects, targetElement)) { + if (canHandleRequest(handledDroppedObjects, targetElement) && canHandleDropPosition(dropReq.getLocation())) { // 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; @@ -140,6 +141,18 @@ public abstract class AbstractProtocolToRTPortDropStrategy extends Transactional } + + /** + * Can handle drop position. + * + * @param point + * the point + * @return true, if successful + */ + protected boolean canHandleDropPosition(Point point) { + return true; + } + /** * Gets the dropped protocol. * 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/ProtocolToInternalBehaviorPortDropStrategy.java index 6f19c3d14..b36522a93 100644 --- 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/ProtocolToInternalBehaviorPortDropStrategy.java @@ -15,18 +15,22 @@ 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.GraphicalEditPart; 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. + * Drop strategy to create a Internal Behavior Port when droping a protocol on a capsule. */ -public class ProtocolToInternalBehavoirPortDropStrategy extends AbstractProtocolToRTPortDropStrategy { +public class ProtocolToInternalBehaviorPortDropStrategy extends AbstractProtocolToRTPortDropStrategy { + + + protected GraphicalEditPart dropTarget; /** * Constructor. */ - public ProtocolToInternalBehavoirPortDropStrategy() { + public ProtocolToInternalBehaviorPortDropStrategy() { } /* @@ -36,7 +40,7 @@ public class ProtocolToInternalBehavoirPortDropStrategy extends AbstractProtocol */ @Override public String getLabel() { - return "Protocol drop to create Internal Behavoir Port"; + return "Protocol drop to create Internal Behavior Port"; } /* @@ -46,7 +50,7 @@ public class ProtocolToInternalBehavoirPortDropStrategy extends AbstractProtocol */ @Override public String getDescription() { - return "Protocol drop to create Internal Behavoir Port"; + return "Protocol drop to create Internal Behavior Port"; } /* @@ -56,7 +60,7 @@ public class ProtocolToInternalBehavoirPortDropStrategy extends AbstractProtocol */ @Override public String getID() { - return Activator.PLUGIN_ID + ".protocolToInternalBehavoirPortDrop";//$NON-NLS-1$ + return Activator.PLUGIN_ID + ".protocolToInternalBehaviorPortDrop";//$NON-NLS-1$ } /* @@ -67,12 +71,15 @@ public class ProtocolToInternalBehavoirPortDropStrategy extends AbstractProtocol @Override protected Command doGetCommand(Request request, EditPart targetEditPart) { // initDefaultStrategy(); - boolean canHandle = false; + if (targetEditPart instanceof GraphicalEditPart) { + dropTarget = (GraphicalEditPart) targetEditPart; - if ((targetEditPart instanceof CompartmentEditPart)) { - canHandle = true; - targetEditPart = targetEditPart.getParent(); + // In case of Compartment return the Parent'command (ClassComposite) + if ((targetEditPart instanceof CompartmentEditPart)) { + canHandle = true; + targetEditPart = targetEditPart.getParent(); + } } return canHandle ? super.doGetCommand(request, targetEditPart) : null; @@ -88,4 +95,6 @@ public class ProtocolToInternalBehavoirPortDropStrategy extends AbstractProtocol return RTPortKindEnum.INTERNAL; } + + } diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpart/RTClassCompositeEditPart.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editparts/RTClassCompositeEditPart.java index 2ed619cca..6abb012ce 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpart/RTClassCompositeEditPart.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editparts/RTClassCompositeEditPart.java @@ -9,7 +9,7 @@ * Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrusrt.umlrt.core.editpart;
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editparts;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
@@ -21,9 +21,9 @@ import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeCompar 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;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editpolicies.RTCustomDiagramDragDropEditPolicy;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editpolicies.RTSideAffixedNodesCreationEditPolicy;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.locator.RTPortPositionLocator;
/**
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/provider/RTEditPartProvider.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editparts/providers/RTEditPartProvider.java index a49966077..95ad8b7a0 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/provider/RTEditPartProvider.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editparts/providers/RTEditPartProvider.java @@ -9,19 +9,21 @@ * Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrusrt.umlrt.core.provider;
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editparts.providers;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.emf.ecore.EObject;
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;
+import org.eclipse.papyrusrt.umlrt.core.utils.CapsuleUtils;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editparts.RTClassCompositeEditPart;
+import org.eclipse.uml2.uml.Classifier;
/**
@@ -60,10 +62,10 @@ public class RTEditPartProvider extends AbstractEditPartProvider { @Override
public boolean provides(IOperation operation) {
- boolean provide;
+ boolean provide = false;
String currentDiagramType;
-
- if ((operation instanceof CreateGraphicEditPartOperation) && (RTPortUtils.isRTPort(((IEditPartOperation) operation).getView().getElement()))) {
+ EObject referenceElement = ((IEditPartOperation) operation).getView().getElement();
+ if ((operation instanceof CreateGraphicEditPartOperation) && (referenceElement instanceof Classifier) && (CapsuleUtils.isCapsule((Classifier) referenceElement))) {
currentDiagramType = ((IEditPartOperation) operation).getView().getDiagram().getType();
@@ -73,8 +75,7 @@ public class RTEditPartProvider extends AbstractEditPartProvider { provide = super.provides(operation);
}
- } else {
- provide = super.provides(operation);
+
}
return provide;
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTCustomDiagramDragDropEditPolicy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editpolicies/RTCustomDiagramDragDropEditPolicy.java index b0594d4fa..9ef62c00c 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTCustomDiagramDragDropEditPolicy.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editpolicies/RTCustomDiagramDragDropEditPolicy.java @@ -9,7 +9,7 @@ * Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrusrt.umlrt.core.editpolicies;
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editpolicies;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.Viewport;
@@ -27,7 +27,7 @@ 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.papyrusrt.umlrt.tooling.diagram.common.locator.RTPortPositionLocator;
import org.eclipse.uml2.uml.Behavior;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Element;
@@ -102,14 +102,14 @@ public class RTCustomDiagramDragDropEditPolicy extends CustomDiagramDragDropEdit PortPositionLocator locator = new RTPortPositionLocator(droppedElement, graphicalParentEditPart.getFigure(), PositionConstants.NONE);
Rectangle proposedBounds = new Rectangle(dropLocation, new Dimension(20, 20));
-
+ // proposedBounds = proposedBounds.getTranslated(parentLoc.getNegated());
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();
+ // Rectangle creationBounds = preferredBounds.getTranslated(parentLoc);
+ dropLocation = preferredBounds.getLocation();
EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTSideAffixedNodesCreationEditPolicy.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editpolicies/RTSideAffixedNodesCreationEditPolicy.java index 047103d93..c35a65203 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/editpolicies/RTSideAffixedNodesCreationEditPolicy.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/editpolicies/RTSideAffixedNodesCreationEditPolicy.java @@ -9,9 +9,13 @@ * Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrusrt.umlrt.core.editpolicies;
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.editpolicies;
+import java.util.Map;
+
+import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
@@ -19,8 +23,9 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescrip 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.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool;
import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
+import org.eclipse.papyrusrt.umlrt.tooling.diagram.common.locator.RTPortPositionLocator;
import org.eclipse.uml2.uml.Port;
/**
@@ -46,16 +51,35 @@ public class RTSideAffixedNodesCreationEditPolicy extends SideAffixedNodesCreati @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();
- }
+
+ if (descriptor.getElementAdapter() instanceof EObjectAdapter) {
+ element = ((EObjectAdapter) descriptor.getElementAdapter()).getRealObject();
}
return super.getSetBoundsCommand(request, descriptor);
+
+
+ }
+
+ /**
+ * @param absoluteLocation
+ * @return
+ */
+ protected Point getRelativeLocation(Point absoluteLocation) {
+ getHostFigure().translateToRelative(absoluteLocation);
+ return absoluteLocation.getCopy();
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ protected Point getParamLocation(CreateViewRequest request) {
+ Map<?, ?> params = request.getExtendedData();
+ Point realLocation = (Point) params.get(AspectUnspecifiedTypeCreationTool.INITIAL_MOUSE_LOCATION_FOR_CREATION);
+ return realLocation;
}
/**
@@ -67,10 +91,17 @@ public class RTSideAffixedNodesCreationEditPolicy extends SideAffixedNodesCreati protected PortPositionLocator getPositionLocator() {
PortPositionLocator locator = null;
if (RTPortUtils.isRTPort((Port) element)) {
- locator = new RTPortPositionLocator((Port) element, ((GraphicalEditPart) getHost()).getFigure(), PositionConstants.NONE);
+ locator = new RTPortPositionLocator((Port) element, getHostFigure(), PositionConstants.NONE);
}
return null != locator ? locator : super.getPositionLocator();
}
+ /**
+ * @return
+ */
+ protected IFigure getHostFigure() {
+ return ((GraphicalEditPart) getHost()).getFigure();
+ }
+
}
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/locator/RTPortPositionLocator.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/locator/RTPortPositionLocator.java index 0bafea95c..bbc5e26cd 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/locator/RTPortPositionLocator.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.diagram.common/src/org/eclipse/papyrusrt/umlrt/tooling/diagram/common/locator/RTPortPositionLocator.java @@ -9,7 +9,7 @@ * Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrusrt.umlrt.core.locator;
+package org.eclipse.papyrusrt.umlrt.tooling.diagram.common.locator;
import java.util.Iterator;
@@ -17,6 +17,8 @@ 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.papyrus.uml.diagram.composite.custom.locators.ExternalPortPositionLocator;
+import org.eclipse.papyrus.uml.diagram.composite.custom.locators.InternalPortPositionLocator;
import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
import org.eclipse.uml2.uml.Element;
@@ -37,6 +39,9 @@ public class RTPortPositionLocator extends PortPositionLocator { /** the figure. */
private IFigure figure;
+ private InternalPortPositionLocator internalLocator;
+ private ExternalPortPositionLocator externalLocator;
+
/**
* Instantiates a new RT port position locator.
*
@@ -99,25 +104,70 @@ public class RTPortPositionLocator extends PortPositionLocator { * @return the preferred internal location
*/
private Rectangle getPreferredInternalLocation(Rectangle proposedLocation) {
- Rectangle parentBounds = parentFigure.getBounds().getCopy();
- IFigure compartment = getCompositeCompartmentFigure(parentFigure);
- Rectangle prefferedLocation;
+ // Initialize port location with proposed location
+ // and resolve the bounds of it graphical parent
+ Rectangle realLocation = new Rectangle(proposedLocation);
+
+ // Retrieve the bound of the Compartment to avoid the Name Label area.
+ IFigure compartment = getCompositeCompartmentFigure(parentFigure);
+ Rectangle compartmentBounds;
if (null != compartment) {
- if (compartment.getBounds().contains(proposedLocation)) {
- prefferedLocation = proposedLocation.getCopy();
- } else {
- prefferedLocation = parentBounds.translate(30, 60).getCopy();
- prefferedLocation.setSize(proposedLocation.width, proposedLocation.height);
+ compartmentBounds = compartment.getBounds().getCopy();
+
+ // Calculate Max position around the graphical parent (1/2 size or the port around
+ // the graphical parent bounds.
+ // this is an intra rectangle
+ int xMin = compartmentBounds.x + borderItemOffset;
+ int xMax = compartmentBounds.x + compartmentBounds.width - borderItemOffset;
+ int yMin = compartmentBounds.y + borderItemOffset;
+ int yMax = compartmentBounds.y + compartmentBounds.height - borderItemOffset;
+
+ // Modify Port location if MAX X or Y are exceeded
+ if (realLocation.x < xMin) {
+ realLocation.x = xMin;
+ }
+
+ if (realLocation.x > xMax) {
+ realLocation.x = xMax;
+ }
+ if (realLocation.y < yMin) {
+ realLocation.y = yMin;
}
- } else {
- // Should not happened
- prefferedLocation = new Rectangle();
+ if (realLocation.y > yMax) {
+ realLocation.y = yMax;
+ }
}
- return prefferedLocation;
+
+ // Return constrained location
+ return realLocation;
+
+
+ // Rectangle parentBounds = parentFigure.getBounds().getCopy();
+ // IFigure compartment = getCompositeCompartmentFigure(parentFigure);
+ //
+ // Rectangle prefferedLocation;
+ // if (null != compartment) {
+ // Rectangle compartmentBounds = compartment.getBounds().getCopy();
+ // compartmentBounds = compartmentBounds.getTranslated(compartment.getBounds().getLocation().getCopy().getNegated());
+ // Rectangle reduceCompartment = compartmentBounds.expand(-10, -10);
+ // if (reduceCompartment.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;
}
/**
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt index 79fe20541..506755b13 100644 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<Composite +<Composite xmlns="http://www.eclipse.org/xwt/presentation" xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout" - xmlns:j="clr-namespace:java.lang" xmlns:x="http://www.eclipse.org/xwt" - xmlns:ppumlrt="clr-namespace:org.eclipse.papyrusrt.umlrt.tooling.ui.widgets" - xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets" + xmlns:x="http://www.eclipse.org/xwt" xmlns:ppumlrt="clr-namespace:org.eclipse.papyrusrt.umlrt.tooling.ui.widgets" xmlns:uml="clr-namespace:org.eclipse.papyrus.uml.properties.widgets" - xmlns="http://www.eclipse.org/xwt/presentation"> + xmlns:j="clr-namespace:java.lang" xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets"> <Composite.layout> <ppel:PropertiesLayout></ppel:PropertiesLayout> </Composite.layout> @@ -14,8 +12,8 @@ <ppel:PropertiesLayout></ppel:PropertiesLayout> </Composite.layout> <ppe:StringEditor input="{Binding}" property="UML:NamedElement:name"></ppe:StringEditor> - <ppumlrt:CapsulePartTypeEditor - customLabel="Capsule" input="{Binding}" property="UMLRealTimeExt:Property:type"></ppumlrt:CapsulePartTypeEditor> + <ppumlrt:CapsulePartTypeEditor property="UMLRealTimeExt:Property:type" + input="{Binding}" customLabel="Capsule"></ppumlrt:CapsulePartTypeEditor> </Composite> <Group text="Capsule Part Properties"> <Group.layout> @@ -23,7 +21,7 @@ </Group.layout> <ppe:EnumRadio input="{Binding}" property="UMLRealTime:CapsulePart:kind"></ppe:EnumRadio> <uml:MultiplicityDialog input="{Binding}" - property="UMLRealTimeExt:RTMultiplicity:RTmultiplicity"></uml:MultiplicityDialog> + property="Multiplicity:multiplicity" customLabel="Multiplicity"></uml:MultiplicityDialog> <ppe:EnumCombo input="{Binding}" property="UML:Property:aggregation" readOnly="true"></ppe:EnumCombo> </Group> 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 56f4324eb..6bd39da37 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 @@ -9,7 +9,6 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.papyrusrt.umlrt.profile;bundle-version="0.7.0", org.eclipse.papyrus.uml.extensionpoints;bundle-version="1.1.1", - org.eclipse.papyrus.uml.properties;bundle-version="1.1.1", org.eclipse.papyrus.infra.widgets;bundle-version="1.1.1", org.eclipse.core.databinding;bundle-version="1.5.0", org.eclipse.emf.databinding;bundle-version="1.3.0", @@ -27,9 +26,10 @@ Require-Bundle: org.eclipse.ui, 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.papyrusrt.umlrt.tooling.properties, + org.eclipse.papyrus.infra.gmfdiag.commands, org.eclipse.papyrus.uml.properties, - org.eclipse.papyrus.uml.diagram.common, - org.eclipse.papyrusrt.umlrt.tooling.properties + org.eclipse.papyrus.uml.diagram.common Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.papyrusrt.umlrt.tooling.ui, 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 01bfa993a..cfdebd5ab 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 @@ -24,7 +24,7 @@ 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.core.utils.CapsulePartKindEnum; -import org.eclipse.papyrusrt.umlrt.core.utils.Constants; +import org.eclipse.papyrusrt.umlrt.core.utils.IRealTimeConstants; import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.CapsulePart; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTPort; @@ -48,13 +48,13 @@ public class RTStereotypeModelElement extends StereotypeModelElement { if (stereoApplication instanceof RTPort) { - if (Constants.KIND.equals(propertyPath)) { + if (IRealTimeConstants.KIND.equals(propertyPath)) { editable = true; - } else if (Constants.NOTIFICATION.equals(propertyPath)) { + } else if (IRealTimeConstants.NOTIFICATION.equals(propertyPath)) { editable = true; // TODO: This method is not updated when values are changed (good value would be when portHelper.isBehavior(port);) - } else if (Constants.WIRED.equals(propertyPath)) { + } else if (IRealTimeConstants.WIRED.equals(propertyPath)) { editable = true; // TODO: This method is not updated when values are changed (good value would be when portHelper.isBehavior(port) || portHelper.isConnected(port);) - } else if (Constants.PUBLISH.equals(propertyPath)) { + } else if (IRealTimeConstants.PUBLISH.equals(propertyPath)) { editable = false; } } else if (stereoApplication instanceof CapsulePart) { @@ -72,7 +72,7 @@ public class RTStereotypeModelElement extends StereotypeModelElement { IObservable observe = null; // Case of Kind value in the Port RT Property View - if (Constants.KIND.equals(propertyPath)) { + if (IRealTimeConstants.KIND.equals(propertyPath)) { if (stereoApplication instanceof RTPort) { observe = new PortRTKindObservableValue(stereoApplication, (TransactionalEditingDomain) domain); @@ -100,7 +100,7 @@ public class RTStereotypeModelElement extends StereotypeModelElement { @Override public IStaticContentProvider getContentProvider(String propertyPath) { IStaticContentProvider provider = null; - if (Constants.KIND.equals(propertyPath) && stereoApplication instanceof RTPort) { + if (IRealTimeConstants.KIND.equals(propertyPath) && stereoApplication instanceof RTPort) { Map<Object, String> map = new LinkedHashMap<Object, String>(RTPortKindEnum.values().length); map.put(RTPortKindEnum.EXTERNAL, RTPortKindEnum.EXTERNAL.getLabel()); @@ -111,7 +111,7 @@ public class RTStereotypeModelElement extends StereotypeModelElement { provider = new StaticContentProvider(map.keySet().toArray()); - } else if (Constants.KIND.equals(propertyPath) && stereoApplication instanceof CapsulePart) { + } else if (IRealTimeConstants.KIND.equals(propertyPath) && stereoApplication instanceof CapsulePart) { Map<Object, String> map = new LinkedHashMap<Object, String>(CapsulePartKindEnum.values().length); map.put(CapsulePartKindEnum.FIXED, CapsulePartKindEnum.FIXED.getLabel()); 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 c314c3557..683693ec4 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 @@ -41,7 +41,7 @@ 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.core.utils.IRealTimeConstants; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.CapsulePart; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTMessageKind; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTMessageSet; @@ -102,7 +102,7 @@ public class UMLRTExtModelElement extends UMLModelElement { if (intf != null) { return getDelegationModelElement(intf).getContentProvider(ownedOp); } - if (propertyPath.contains(Constants.CAPSULE_PART_MULTIPLICITY)) { + if (propertyPath.contains(IRealTimeConstants.CAPSULE_PART_MULTIPLICITY)) { return new StaticContentProvider(new String[] { ONE, OPTIONAL }); @@ -165,7 +165,7 @@ public class UMLRTExtModelElement extends UMLModelElement { if (intf != null) { observable = getDelegationModelElement(intf).doGetObservable(ownedOp); - } else if (Constants.CAPSULE_PART_MULTIPLICITY.equals(propertyPath)) { + } else if (IRealTimeConstants.CAPSULE_PART_MULTIPLICITY.equals(propertyPath)) { observable = new CapsulePartExtendedObservableValue(source, domain); } else { observable = super.doGetObservable(propertyPath); @@ -236,13 +236,13 @@ public class UMLRTExtModelElement extends UMLModelElement { Port port = (Port) source; // Rules defined by the Client - if (Constants.SERVICE.equals(propertyPath)) { + if (IRealTimeConstants.SERVICE.equals(propertyPath)) { editable = true; // TODO: This method is called only when view opening (good value would be when portHelper.isBehavior(port) && !portHelper.isConnected(port);) - } else if (Constants.BEHAVIOR.equals(propertyPath)) { + } else if (IRealTimeConstants.BEHAVIOR.equals(propertyPath)) { editable = true; // TODO: This method is called only when view opening (good value would be when !(!portHelper.isWired(port) || (portHelper.isWired(port) && !portHelper.isService(port)));) - } else if (Constants.CONJUGATED.equals(propertyPath)) { + } else if (IRealTimeConstants.CONJUGATED.equals(propertyPath)) { editable = true; - } else if (Constants.PROTOCOL_TYPE.equals(propertyPath)) { + } else if (IRealTimeConstants.PROTOCOL_TYPE.equals(propertyPath)) { editable = true; } else { editable = super.isFeatureEditable(propertyPath); diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java index e5802023e..88c012662 100644 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java @@ -1,3 +1,14 @@ +/*****************************************************************************
+ * 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.tooling.ui.widgets;
import org.eclipse.core.databinding.observable.Diffs;
@@ -20,23 +31,40 @@ import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.util.UMLUtil;
+/**
+ * The Class CapsulePartKindObservableValue.
+ */
public class CapsulePartKindObservableValue extends PapyrusObservableValue implements IObserving {
+ /** The Constant LABEL_MULTIPLICITY. */
private static final String LABEL_MULTIPLICITY = "Set Multiplicity";
+
+ /** The Constant LABEL_AGGREGATION. */
private static final String LABEL_AGGREGATION = "Set Aggregation";
+
+ /** The capsule part element. */
private Property capsulePartElement;
- private EObject capsulePartStereotypeApplication;
+
+ /** The aggregation Enum value. */
private AggregationKind aggregation;
+
+ /** The multiplicity Element. */
private MultiplicityElement multiplicity;
+ /**
+ * Instantiates a new capsule part kind observable value.
+ *
+ * @param RTApplication
+ * the RT application
+ * @param domain
+ * the domain
+ */
public CapsulePartKindObservableValue(final EObject RTApplication, final TransactionalEditingDomain domain) {
super(UMLUtil.getBaseElement(RTApplication), UMLUtil.getBaseElement(RTApplication).eContainingFeature(), domain);
if (RTApplication instanceof CapsulePart) {
capsulePartElement = (Property) UMLUtil.getBaseElement(RTApplication);
- capsulePartStereotypeApplication = RTApplication;
-
capsulePartElement.eAdapters().add(getListener());
capsulePartElement.getUpperValue().eAdapters().add(getListener());
@@ -47,8 +75,9 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple }
+
/**
- *
+ * Sets the uml properties value.
*/
protected void setUMLPropertiesValue() {
if (capsulePartElement instanceof Property) {
@@ -57,6 +86,11 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple }
}
+ /**
+ * @see org.eclipse.emf.databinding.EObjectObservableValue#doGetValue()
+ *
+ * @return
+ */
@Override
protected Object doGetValue() {
CapsulePartKindEnum kind = null;
@@ -74,20 +108,37 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple }
}
+
return kind;
}
+ /**
+ * @see org.eclipse.emf.databinding.EObjectObservableValue#getObserved()
+ *
+ * @return
+ */
@Override
public Object getObserved() {
return capsulePartElement;
}
+ /**
+ * @see org.eclipse.emf.databinding.EObjectObservableValue#getValueType()
+ *
+ * @return
+ */
@Override
public Object getValueType() {
return CapsulePartKindEnum.class;
}
+ /**
+ * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue#getCommand(java.lang.Object)
+ *
+ * @param value
+ * @return
+ */
@Override
public Command getCommand(Object value) {
Command command = null;
@@ -113,6 +164,17 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple return command;
}
+ /**
+ * Gets the command for capsule part.
+ *
+ * @param aggregation
+ * the aggregation
+ * @param lower
+ * the lower
+ * @param upper
+ * the upper
+ * @return the command for capsule part
+ */
protected Command getCommandForCapsulePart(AggregationKind aggregation, int lower, int upper) {
CompoundCommand command = new CompoundCommand();
command.append(getSetAggregationCommand(aggregation));
@@ -121,6 +183,16 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple return command;
}
+
+ /**
+ * Gets the sets the multiplicity command.
+ *
+ * @param lower
+ * the lower
+ * @param upper
+ * the upper
+ * @return the sets the multiplicity command
+ */
protected Command getSetMultiplicityCommand(final int lower, final int upper) {
RecordingCommand multiplicityCommand = new RecordingCommand((TransactionalEditingDomain) domain) {
@Override
@@ -146,8 +218,8 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple /**
* Retrieve Listener to put on the Stereotype Application.
- *
- * @return
+ *
+ * @return the listener
*/
protected AdapterImpl getListener() {
return new AdapterImpl() {
@@ -185,6 +257,13 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple };
}
+ /**
+ * Gets the sets the aggregation command.
+ *
+ * @param wishedAggregation
+ * the wished aggregation
+ * @return the sets the aggregation command
+ */
protected Command getSetAggregationCommand(final AggregationKind wishedAggregation) {
RecordingCommand aggregationCommand = new RecordingCommand((TransactionalEditingDomain) domain) {
@Override
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 b6645a9b5..0cbc69a51 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 @@ -1,3 +1,14 @@ +/***************************************************************************** + * 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.tooling.ui.widgets; import org.eclipse.core.databinding.observable.Diffs; @@ -12,45 +23,67 @@ import org.eclipse.emf.common.notify.impl.AdapterImpl; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.transaction.RecordingCommand; import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; +import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; -import org.eclipse.papyrusrt.umlrt.core.utils.Constants; +import org.eclipse.papyrusrt.umlrt.core.utils.IRealTimeConstants; 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; import org.eclipse.uml2.uml.util.UMLUtil; +/** + * The Class PortRTKindObservableValue. + */ public class PortRTKindObservableValue extends PapyrusObservableValue implements IObserving { + /** The port. */ private Port port; - private Stereotype stereo; + + /** The stereotype application. */ private EObject stereotypeApplication; + /** The service. */ private boolean service; + + /** The wired. */ private boolean wired; + + /** The behavior. */ private boolean behavior; + + /** The publish. */ private boolean publish; + + /** The conjugated. */ private boolean conjugated; + + /** The notification. */ private boolean notification; /** - * * Constructor. * - * @param sourceElement + * @param RTPortApplication + * the RT port application + * @param domain + * the domain */ public PortRTKindObservableValue(final EObject RTPortApplication, final TransactionalEditingDomain domain) { super(UMLUtil.getBaseElement(RTPortApplication), UMLUtil.getBaseElement(RTPortApplication).eContainingFeature(), domain); port = (Port) UMLUtil.getBaseElement(RTPortApplication); if (UMLUtil.getBaseElement(RTPortApplication) instanceof Port) { port = (Port) UMLUtil.getBaseElement(RTPortApplication); - stereo = UMLUtil.getStereotype(RTPortApplication); + this.stereotypeApplication = RTPortApplication; stereotypeApplication.eAdapters().add(getListener()); port.eAdapters().add(getListener()); + setUMLPropertiesValue(); setUMLRTPropertiesValue(); } @@ -58,10 +91,10 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements /** * Retrieve Listener to put on the Stereotype Application. - * - * @return + * + * @return the listener */ - private AdapterImpl getListener() { + protected AdapterImpl getListener() { return new AdapterImpl() { @Override @@ -100,7 +133,7 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements /** - * + * Set the Properties relative to the RT profile. */ private void setUMLRTPropertiesValue() { wired = RTPortUtils.isWired(port); @@ -109,7 +142,7 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements } /** - * + * Set properties relative to UML. */ private void setUMLPropertiesValue() { service = RTPortUtils.isService(port); @@ -117,11 +150,21 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements conjugated = RTPortUtils.isConjugated(port); } + /** + * @see org.eclipse.emf.databinding.EObjectObservableValue#getValueType() + * + * @return + */ @Override public Object getValueType() { return RTPortKindEnum.class; } + /** + * @see org.eclipse.emf.databinding.EObjectObservableValue#getObserved() + * + * @return + */ @Override public Object getObserved() { return port; @@ -129,6 +172,11 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements + /** + * @see org.eclipse.emf.databinding.EObjectObservableValue#doGetValue() + * + * @return + */ @Override protected Object doGetValue() { RTPortKindEnum kind = RTPortKindEnum.RELAY; @@ -136,15 +184,15 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements setUMLPropertiesValue(); setUMLRTPropertiesValue(); - if (service && wired && behavior && !publish) { + if (service && wired && behavior) { kind = RTPortKindEnum.EXTERNAL; - } else if (service && behavior && publish && !wired) { + } else if (service && behavior && !wired) { kind = RTPortKindEnum.SPP; - } else if (wired && behavior && !service && !publish) { + } else if (wired && behavior && !service) { kind = RTPortKindEnum.INTERNAL; - } else if (service && wired && !behavior && !publish) { + } else if (service && wired && !behavior) { kind = RTPortKindEnum.RELAY; - } else if (behavior && !wired && !publish && !service) { + } else if (behavior && !wired && !service) { kind = RTPortKindEnum.SAP; } @@ -154,6 +202,12 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements + /** + * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue#getCommand(java.lang.Object) + * + * @param value + * @return + */ @Override public Command getCommand(Object value) { Command command = null; @@ -161,107 +215,118 @@ public class PortRTKindObservableValue extends PapyrusObservableValue implements // For Each Kind of Port, set the property accordingly switch ((RTPortKindEnum) value) { case EXTERNAL: - command = getCommandForRTPort(true, false, true, true); + command = getCommandForRTPort(true, true, true); break; case INTERNAL: - command = getCommandForRTPort(true, false, false, true); + command = getCommandForRTPort(true, false, true); break; case RELAY: - command = getCommandForRTPort(false, false, true, true); + command = getCommandForRTPort(false, true, true); break; case SAP: - command = getCommandForRTPort(true, false, false, false); + command = getCommandForRTPort(true, false, false); break; case SPP: - command = getCommandForRTPort(true, true, true, false); + command = getCommandForRTPort(true, true, false); break; default: // Relay Port by Default - command = getCommandForRTPort(false, false, true, true); + command = getCommandForRTPort(false, true, true); break; } } return command; } - private Command getCommandForRTPort(boolean behavior, boolean publish, boolean service, boolean wired) { + /** + * Get the Command to set the RT Port properties. + * + * @param behavior + * Value of isBehavior attribute + * @param service + * Value of isService attribute + * @param wired + * Value of isWired attribute + * @return the command for rt port + */ + protected Command getCommandForRTPort(boolean behavior, boolean service, boolean wired) { CompoundCommand command = new CompoundCommand(); command.append(getSetBehaviorCommand(behavior)); - command.append(getSetPublishCommand(publish)); command.append(getSetServiceCommand(service)); command.append(getSetWiredCommand(wired)); return command; } - private Command getSetPublishCommand(final boolean publish) { - RecordingCommand publishCommand = new RecordingCommand((TransactionalEditingDomain) domain) { - @Override - protected void doExecute() { - port.setValue(stereo, Constants.PUBLISH, publish); - } - - @Override - public boolean canExecute() { - return true; - } + /** + * Gets the Command to set the publish parameter. + * + * @param publish + * The publish value to be set + * @return The Command to set the isPublish parameter + */ + protected Command getSetPublishCommand(final boolean publish) { + IElementEditService serviceEdit = ElementEditServiceUtils.getCommandProvider(stereotypeApplication); - }; + SetRequest request = new SetRequest(stereotypeApplication, stereotypeApplication.eClass().getEStructuralFeature(IRealTimeConstants.PUBLISH), publish); + ICommand gmfCommand = serviceEdit.getEditCommand(request); + Command cmd = GMFtoEMFCommandWrapper.wrap(gmfCommand); - return publishCommand; + return cmd; } + /** + * Gets the Command to set the wired parameter. + * + * @param wired + * The wired value to be set + * @return The Command to set the isWired parameter + */ + protected Command getSetWiredCommand(final boolean wired) { + IElementEditService serviceEdit = ElementEditServiceUtils.getCommandProvider(stereotypeApplication); - private Command getSetWiredCommand(final boolean wired) { - RecordingCommand wiredCommand = new RecordingCommand((TransactionalEditingDomain) domain) { - @Override - protected void doExecute() { - port.setValue(stereo, Constants.WIRED, wired); - } - - @Override - public boolean canExecute() { - return true; - } - }; + SetRequest request = new SetRequest(stereotypeApplication, stereotypeApplication.eClass().getEStructuralFeature(IRealTimeConstants.WIRED), wired); + ICommand gmfCommand = serviceEdit.getEditCommand(request); + Command cmd = GMFtoEMFCommandWrapper.wrap(gmfCommand); - return wiredCommand; + return cmd; } - private Command getSetServiceCommand(final boolean service) { - RecordingCommand serviceCommand = new RecordingCommand((TransactionalEditingDomain) domain) { - @Override - protected void doExecute() { - port.setIsService(service); - } + /** + * Gets the Command to set the service parameter. + * + * @param service + * The service value to be set + * @return The Command to set the isService parameter + */ + protected Command getSetServiceCommand(final boolean service) { + Command cmd = null; + IElementEditService serviceEdit = ElementEditServiceUtils.getCommandProvider(port); - @Override - public boolean canExecute() { - return true; - } - }; + SetRequest request = new SetRequest(port, port.eClass().getEStructuralFeature(IRealTimeConstants.SERVICE), service); + ICommand gmfCommand = serviceEdit.getEditCommand(request); + cmd = GMFtoEMFCommandWrapper.wrap(gmfCommand); - return serviceCommand; + return cmd; } - private Command getSetBehaviorCommand(final boolean behavior) { - RecordingCommand behaviorCommand = new RecordingCommand((TransactionalEditingDomain) domain) { - @Override - protected void doExecute() { - port.setIsBehavior(behavior); - } + /** + * Gets the Command to set the behavior parameter. + * + * @param behavior + * The behavior value to be set + * @return The Command to set the isBehavior parameter + */ + protected Command getSetBehaviorCommand(final boolean behavior) { + Command cmd = null; + IElementEditService serviceEdit = ElementEditServiceUtils.getCommandProvider(port); - @Override - public boolean canExecute() { - return true; - } - }; + SetRequest request = new SetRequest(port, port.eClass().getEStructuralFeature(IRealTimeConstants.BEHAVIOR), behavior); + ICommand gmfCommand = serviceEdit.getEditCommand(request); + cmd = GMFtoEMFCommandWrapper.wrap(gmfCommand); - return behaviorCommand; + return cmd; } - - - } |
