Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-03-07 03:06:16 -0500
committerNicolas FAUVERGUE2016-03-17 12:43:35 -0400
commit460af49c25343bb226972a680f65a7c5faac65cc (patch)
tree61b9746b33a9d375d6377e74af27c8dfe89dc722 /plugins/sysml
parente7b03a7a14a8d2100c42c274e7f7609a4d6809fc (diff)
downloadorg.eclipse.papyrus-460af49c25343bb226972a680f65a7c5faac65cc.tar.gz
org.eclipse.papyrus-460af49c25343bb226972a680f65a7c5faac65cc.tar.xz
org.eclipse.papyrus-460af49c25343bb226972a680f65a7c5faac65cc.zip
Bug 488557: [SysML 1.1][IBD] Drag n drop of a nested Part inside another
Part creates a bad view https://bugs.eclipse.org/bugs/show_bug.cgi?id=488557 Don't destroy the view when the object drop is an instance of block (property or object directly). Change-Id: Ia13fc591526227dbea8262152fe59dd2a605974f Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins/sysml')
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/helper/advice/DeleteViewDuringMoveHelperAdvice.java201
1 files changed, 100 insertions, 101 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/helper/advice/DeleteViewDuringMoveHelperAdvice.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/helper/advice/DeleteViewDuringMoveHelperAdvice.java
index f8a32972eb5..3963b3f7047 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/helper/advice/DeleteViewDuringMoveHelperAdvice.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/helper/advice/DeleteViewDuringMoveHelperAdvice.java
@@ -1,101 +1,100 @@
-/*****************************************************************************
- * Copyright (c) 2011 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.papyrus.sysml.diagram.internalblock.helper.advice;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.sysml.diagram.internalblock.provider.ElementTypes;
-import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.common.util.CrossReferencerUtil;
-
-/**
- * <pre>
- * Edit helper advice that delete views from diagram when an element is
- * moved in a new container (in the model explorer).
- *
- * Block is an exception as the IBD is attached to the Block itself, removing it
- * would result in an unusable IBD.
- * </pre>
- */
-public class DeleteViewDuringMoveHelperAdvice extends AbstractEditHelperAdvice {
-
- @Override
- protected ICommand getBeforeMoveCommand(MoveRequest request) {
-
- ICommand moveCommand = super.getBeforeMoveCommand(request);
-
- Set<View> viewsToDestroy = new HashSet<View>();
-
- @SuppressWarnings("unchecked")
- Iterator<EObject> it = request.getElementsToMove().keySet().iterator();
- while (it.hasNext()) {
- EObject eObject = it.next();
-
- // If current eObject is a Block do nothing.
- if (((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches(eObject)) {
- continue;
- }
-
- viewsToDestroy.addAll(getViewsToDestroy(eObject));
- }
-
- if (!viewsToDestroy.isEmpty()) {
- DestroyDependentsRequest ddr = new DestroyDependentsRequest(request.getEditingDomain(), request.getTargetContainer(), false);
- ddr.setClientContext(request.getClientContext());
- ddr.addParameters(request.getParameters());
- ICommand destroyViewsCommand = ddr.getDestroyDependentsCommand(viewsToDestroy);
- moveCommand = CompositeCommand.compose(moveCommand, destroyViewsCommand);
- }
-
- return moveCommand;
- }
-
- /**
- * This methods looks for inconsistent views to delete in case a semantic move done in the model explorer.
- *
- * @param movedObject
- * the moved {@link EObject}
- * @return the list of {@link View} to delete
- */
- protected Set<View> getViewsToDestroy(EObject movedObject) {
- Set<View> viewsToDestroy = new HashSet<View>();
-
- Iterator<View> viewIt = CrossReferencerUtil.getCrossReferencingViews(movedObject, ElementTypes.DIAGRAM_ID).iterator();
- while (viewIt.hasNext()) {
- View view = viewIt.next();
-
- String containerType = ViewUtil.getViewContainer(view) != null ? ViewUtil.getViewContainer(view).getType() : null;
-
- // Views are to be destroyed if they are not the diagram itself (containerType == null)
- // and not a view directly owned by the diagram (the current policy in Papyrus allows
- // to drop nearly anything in the diagram whatever the semantic container).
- if ((containerType != null) && !ElementTypes.DIAGRAM_ID.equals(containerType)) {
- viewsToDestroy.add(view);
- }
- }
-
- return viewsToDestroy;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2011 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.papyrus.sysml.diagram.internalblock.helper.advice;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.sysml.diagram.internalblock.provider.ElementTypes;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.common.util.CrossReferencerUtil;
+import org.eclipse.uml2.uml.Property;
+
+/**
+ * <pre>
+ * Edit helper advice that delete views from diagram when an element is
+ * moved in a new container (in the model explorer).
+ *
+ * Block is an exception as the IBD is attached to the Block itself, removing it
+ * would result in an unusable IBD.
+ * </pre>
+ */
+public class DeleteViewDuringMoveHelperAdvice extends AbstractEditHelperAdvice {
+
+ @Override
+ protected ICommand getBeforeMoveCommand(MoveRequest request) {
+
+ ICommand moveCommand = super.getBeforeMoveCommand(request);
+
+ Set<View> viewsToDestroy = new HashSet<View>();
+
+ @SuppressWarnings("unchecked")
+ Iterator<EObject> it = request.getElementsToMove().keySet().iterator();
+ while (it.hasNext()) {
+ EObject eObject = it.next();
+
+ // If current eObject is a Block do nothing.
+ if (!((eObject instanceof Property && ((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches(((Property) eObject).getType())))) {
+ viewsToDestroy.addAll(getViewsToDestroy(eObject));
+ }
+ }
+
+ if (!viewsToDestroy.isEmpty()) {
+ DestroyDependentsRequest ddr = new DestroyDependentsRequest(request.getEditingDomain(), request.getTargetContainer(), false);
+ ddr.setClientContext(request.getClientContext());
+ ddr.addParameters(request.getParameters());
+ ICommand destroyViewsCommand = ddr.getDestroyDependentsCommand(viewsToDestroy);
+ moveCommand = CompositeCommand.compose(moveCommand, destroyViewsCommand);
+ }
+
+ return moveCommand;
+ }
+
+ /**
+ * This methods looks for inconsistent views to delete in case a semantic move done in the model explorer.
+ *
+ * @param movedObject
+ * the moved {@link EObject}
+ * @return the list of {@link View} to delete
+ */
+ protected Set<View> getViewsToDestroy(EObject movedObject) {
+ Set<View> viewsToDestroy = new HashSet<View>();
+
+ Iterator<View> viewIt = CrossReferencerUtil.getCrossReferencingViews(movedObject, ElementTypes.DIAGRAM_ID).iterator();
+ while (viewIt.hasNext()) {
+ View view = viewIt.next();
+
+ String containerType = ViewUtil.getViewContainer(view) != null ? ViewUtil.getViewContainer(view).getType() : null;
+
+ // Views are to be destroyed if they are not the diagram itself (containerType == null)
+ // and not a view directly owned by the diagram (the current policy in Papyrus allows
+ // to drop nearly anything in the diagram whatever the semantic container).
+ if ((containerType != null) && !ElementTypes.DIAGRAM_ID.equals(containerType)) {
+ viewsToDestroy.add(view);
+ }
+ }
+
+ return viewsToDestroy;
+ }
+}

Back to the top