diff options
author | atischenko | 2015-05-20 11:08:58 +0000 |
---|---|---|
committer | Camille Letavernier | 2015-05-21 08:37:40 +0000 |
commit | ea6e2cefb10cd1f3dc0b0663951aba78c6f0eb04 (patch) | |
tree | 9759337bd3b1996555f802797c2dc9fa36b33d98 /plugins/uml | |
parent | cd3207bf30ea8f45592f32b08df84d559ec6ad97 (diff) | |
download | org.eclipse.papyrus-ea6e2cefb10cd1f3dc0b0663951aba78c6f0eb04.tar.gz org.eclipse.papyrus-ea6e2cefb10cd1f3dc0b0663951aba78c6f0eb04.tar.xz org.eclipse.papyrus-ea6e2cefb10cd1f3dc0b0663951aba78c6f0eb04.zip |
Reincarnation of the gerrit #47576.
Commit 6b39cb25bb200356c94ed63ef1e432fc39939862 from gerrit #47576 was
not merged correctly.
Fix StructuredActivityNode tests:
-testFeatureLoopNodeInActivity
-testFeatureSequenceNodeInActivity
-testFeatureStructuredActivityNodeInActivity
-testFeatureExpansionRegionInActivity
-testFeatureConditionalNodeInActivity
- posible NPE fix for expansionRegion helper
Change-Id: I62449542cabf6cf4cc9d88f35e5560cee5232a16
Signed-off-by: atischenko <tischenko@montages.com>
Reviewed-on: https://git.eclipse.org/r/48254
Reviewed-by: Michael Golubev <golubev@montages.com>
Reviewed-by: Camille Letavernier <camille.letavernier@cea.fr>
Tested-by: Camille Letavernier <camille.letavernier@cea.fr>
Diffstat (limited to 'plugins/uml')
2 files changed, 104 insertions, 105 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java index 975fd2f1382..2449c3850d7 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java @@ -14,6 +14,7 @@ package org.eclipse.papyrus.uml.service.types.helper; import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest; import org.eclipse.papyrus.uml.service.types.command.NotContainmentMoveCommand; @@ -32,123 +33,121 @@ public class ActivityHelper extends ElementEditHelper { protected ICommand getMoveCommand(MoveRequest req) { return new NotContainmentMoveCommand(req); } - + @Override protected ICommand getCreateCommand(CreateElementRequest req) { -// CreateElementRequest request; -// boolean isActivityNode = isActivityNode(req.getElementType()); -// if (isActivityNode) { -// request = createActivityNodeRequest(req); -// } else { -// boolean isStructureNode = isStructuredNode(req.getElementType()); -// if (isStructureNode) { -// request = createStructuredNodeRequest(req); -// } else { -// request = req; -// } -// } - // return super.getCreateCommand(request); - return super.getCreateCommand(req); - } - - /** - * @param elementType - * @return - */ - private CreateElementRequest createActivityNodeRequest(CreateElementRequest baseReq) { - CreateElementRequest req = new CreateElementRequest(baseReq.getEditingDomain(), baseReq.getContainer(), baseReq.getElementType()); - req.addParameters(baseReq.getParameters()); - req.setContainmentFeature(UMLPackage.eINSTANCE.getActivity_OwnedNode()); - return req; + CreateElementRequest request; + IElementType elementType = req.getElementType(); + if (isStructuredNode(elementType)) { + request = createStructuredNodeRequest(req); + } + // else if (isActivityNode(elementType)) { + // request = createActivityNodeRequest(req); + // } + else { + request = req; + } + return super.getCreateCommand(request); } // /** // * @param elementType // * @return // */ + // private CreateElementRequest createActivityNodeRequest(CreateElementRequest baseReq) { + // CreateElementRequest req = new CreateElementRequest(baseReq.getEditingDomain(), baseReq.getContainer(), baseReq.getElementType()); + // req.addParameters(baseReq.getParameters()); + // req.setContainmentFeature(UMLPackage.eINSTANCE.getActivity_OwnedNode()); + // return req; + // } + // + // /** + // * @param elementType + // * @return + // */ // protected boolean isActivityNode(IElementType type) { // return type.getEClass() != null && UMLPackage.eINSTANCE.getActivityNode().isSuperTypeOf(type.getEClass()); // } // - // protected CreateElementRequest createStructuredNodeRequest(CreateElementRequest baseReq) { - // CreateElementRequest req = new CreateElementRequest(baseReq.getEditingDomain(), baseReq.getContainer(), baseReq.getElementType()); - // req.addParameters(baseReq.getParameters()); - // req.setContainmentFeature(UMLPackage.eINSTANCE.getActivity_StructuredNode()); - // return req; + protected CreateElementRequest createStructuredNodeRequest(CreateElementRequest baseReq) { + CreateElementRequest req = new CreateElementRequest(baseReq.getEditingDomain(), baseReq.getContainer(), baseReq.getElementType()); + req.addParameters(baseReq.getParameters()); + req.setContainmentFeature(UMLPackage.eINSTANCE.getActivity_StructuredNode()); + return req; + } + + protected boolean isStructuredNode(IElementType type) { + return type.getEClass() != null && UMLPackage.eINSTANCE.getStructuredActivityNode().isSuperTypeOf(type.getEClass()); + } + + // { + // getDefaultContainmentFeatures().put(UMLPackage.eINSTANCE.getCentralBufferNode(), UMLPackage.eINSTANCE.getActivity_OwnedNode()); + // } + // + // @Override + // protected ICommand getCreateCommand(CreateElementRequest req) { + // return super.getCreateCommand(req); + // // return new CreateActivityNode(req); + // } + // + // + // /** + // * this inner class is used to call specific command of UML + // * + // */ + // private class CreateActivityNode extends CreateElementCommand{ + // + // protected Command emfcmd=null; + // public CreateActivityNode(CreateElementRequest request) { + // super(request); + // } + // @Override + // protected EObject doDefaultElementCreation() { + // EObject result = null; + // EReference containment = getContainmentFeature(); + // EClass eClass = getElementType().getEClass(); + // + // if (containment != null) { + // EObject element = getElementToEdit(); + // if (element != null) { + // result = eClass.getEPackage().getEFactoryInstance().create(eClass); + // //Command cmd=new CreateChildCommand(getRequest().getEditingDomain(), element, UMLPackage.eINSTANCE.getActivity_OwnedNode(), UMLFactory.eINSTANCE.createOpaqueAction(), Collections.EMPTY_LIST); + // emfcmd= new CreateChildCommand(getRequest().getEditingDomain(),element, containment, result, Collections.EMPTY_LIST); + // emfcmd.canExecute(); + // emfcmd.execute(); + // if(!emfcmd.getResult().isEmpty()){ + // result=(EObject)emfcmd.getResult().toArray()[0]; // } + // } + // } + // + // IStatus status = (result != null) ? Status.OK_STATUS + // : new Status( + // Status.ERROR, + // EMFTypePlugin.getPluginId(), + // EMFTypeCoreMessages + // .bind( + // EMFTypeCoreMessages.createElementCommand_noElementCreated, + // getElementType().getDisplayName())); // - // protected boolean isStructuredNode(IElementType type) { - // return type.getEClass() != null && UMLPackage.eINSTANCE.getStructuredActivityNode().isSuperTypeOf(type.getEClass()); + // setDefaultElementCreationStatus(status); + // + // return result; + // } + // @Override + // protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + // emfcmd.undo(); + // return super.doUndo(monitor, info); // } - -// { -// getDefaultContainmentFeatures().put(UMLPackage.eINSTANCE.getCentralBufferNode(), UMLPackage.eINSTANCE.getActivity_OwnedNode()); -// } -// -// @Override -// protected ICommand getCreateCommand(CreateElementRequest req) { -// return super.getCreateCommand(req); -// // return new CreateActivityNode(req); -// } -// -// -// /** -// * this inner class is used to call specific command of UML -// * -// */ -// private class CreateActivityNode extends CreateElementCommand{ -// -// protected Command emfcmd=null; -// public CreateActivityNode(CreateElementRequest request) { -// super(request); -// } -// @Override -// protected EObject doDefaultElementCreation() { -// EObject result = null; -// EReference containment = getContainmentFeature(); -// EClass eClass = getElementType().getEClass(); -// -// if (containment != null) { -// EObject element = getElementToEdit(); -// if (element != null) { -// result = eClass.getEPackage().getEFactoryInstance().create(eClass); -// //Command cmd=new CreateChildCommand(getRequest().getEditingDomain(), element, UMLPackage.eINSTANCE.getActivity_OwnedNode(), UMLFactory.eINSTANCE.createOpaqueAction(), Collections.EMPTY_LIST); -// emfcmd= new CreateChildCommand(getRequest().getEditingDomain(),element, containment, result, Collections.EMPTY_LIST); -// emfcmd.canExecute(); -// emfcmd.execute(); -// if(!emfcmd.getResult().isEmpty()){ -// result=(EObject)emfcmd.getResult().toArray()[0]; -// } -// } -// } -// -// IStatus status = (result != null) ? Status.OK_STATUS -// : new Status( -// Status.ERROR, -// EMFTypePlugin.getPluginId(), -// EMFTypeCoreMessages -// .bind( -// EMFTypeCoreMessages.createElementCommand_noElementCreated, -// getElementType().getDisplayName())); -// -// setDefaultElementCreationStatus(status); -// -// return result; -// } -// @Override -// protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { -// emfcmd.undo(); -// return super.doUndo(monitor, info); -// } -// -// @Override -// protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { -// -// IStatus status= super.doRedo(monitor, info); -// emfcmd.redo(); -// return status; -// } -// } -// -// + // + // @Override + // protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + // + // IStatus status= super.doRedo(monitor, info); + // emfcmd.redo(); + // return status; + // } + // } + // + // } diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ExpansionRegionHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ExpansionRegionHelper.java index f5717d71d1a..e1f11122c34 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ExpansionRegionHelper.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ExpansionRegionHelper.java @@ -68,7 +68,7 @@ public class ExpansionRegionHelper extends StructuredActivityNodeHelper { * the {@link CreateElementRequest} new {@link IElementType} */ protected boolean isExpansionNodeType(IElementType type) { - return UMLPackage.eINSTANCE.getExpansionNode().equals(type.getEClass()); + return type != null && UMLPackage.eINSTANCE.getExpansionNode().equals(type.getEClass()); } @Override |