diff options
author | Fanch BONNABESSE | 2017-12-12 14:15:46 +0000 |
---|---|---|
committer | Patrick Tessier | 2017-12-19 16:09:11 +0000 |
commit | cc9b6ff54abb6afaf23e1e8c5304f6fd0e035180 (patch) | |
tree | 8eddbbcfd992fba028bd119b3c1bca5439e4c5b7 | |
parent | db53bc665d69dcf519579e4615f540ee038bc8af (diff) | |
download | org.eclipse.papyrus-cc9b6ff54abb6afaf23e1e8c5304f6fd0e035180.tar.gz org.eclipse.papyrus-cc9b6ff54abb6afaf23e1e8c5304f6fd0e035180.tar.xz org.eclipse.papyrus-cc9b6ff54abb6afaf23e1e8c5304f6fd0e035180.zip |
Bug 528499: [SequenceDiagram] EditPolicy "RemoveOrphanViewPolicy" must
be disabled on Sequence Diagram
https://bugs.eclipse.org/bugs/show_bug.cgi?id=528499
Set RemoveOrphanViewPolicy" on deprecated and disabled it.
Change-Id: I1e423ae278a855ba93caf3082808cabedaccee79
Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
3 files changed, 327 insertions, 330 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart.java index ddde4ef1cd0..a92041edccc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart.java @@ -1,221 +1,217 @@ -/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.ScrollPane;
-import org.eclipse.draw2d.XYLayout;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.RemoveOrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.diagram.sequence.util.OperandBoundsComputeHelper;
-
-/**
- * @author Jin Liu (jin.liu@soyatec.com)
- */
-public class OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart extends CombinedFragmentCombinedFragmentCompartmentEditPart {
-
- /**
- * Children string for notification event type.
- */
- private static final String CHILDREN_TYPE = "children";
-
- /**
- * Constructor.
- *
- * @param view
- */
- public OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart(View view) {
- super(view);
- }
-
- /**
- * Not generated for delete borders add stretch children figures.
- *
- * @Override
- */
- @Override
- public IFigure createFigure() {
- ResizableCompartmentFigure result = (ResizableCompartmentFigure) super.createFigure();
- result.getScrollPane().setVerticalScrollBarVisibility(ScrollPane.NEVER);
- result.setTitleVisibility(false);
- result.setBorder(null);
- IFigure contentPane = result.getContentPane();
- if (contentPane != null) {
- contentPane.setBorder(null);
- // fix Scroll bars(https://bugs.eclipse.org/bugs/show_bug.cgi?id=364697)
- contentPane.setLayoutManager(new XYLayout());
- // LayoutManager layout = contentPane.getLayoutManager();
- // if(layout instanceof ConstrainedToolbarLayout) {
- // ConstrainedToolbarLayout constrainedToolbarLayout = (ConstrainedToolbarLayout)layout;
- // constrainedToolbarLayout.setStretchMajorAxis(true);
- // constrainedToolbarLayout.setStretchMinorAxis(true);
- // }
- }
- return result;
- }
-
- /**
- * Add RemoveOrphanView role
- *
- * @Override
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, createCreationEditPolicy());
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy());
- }
-
- private EditPolicy createCreationEditPolicy() {
- return new PapyrusCreationEditPolicy() {
-
- @Override
- protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) {
- // THIS WAS ALREADY DID IN getCreateCommand(), WHY AGAIN?
- // Command createCommand = super.getCreateElementAndViewCommand(request);
- // if (createCommand == null || !createCommand.canExecute()){
- // return createCommand;
- // }
- // ICommandProxy commandProxy = (ICommandProxy)createCommand;
- // CompositeCommand command = (CompositeCommand)commandProxy.getICommand();
- //
- // IHintedType type = (IHintedType)UMLElementTypes.InteractionOperand_Shape;
- // if(type.getSemanticHint().equals(request.getViewAndElementDescriptor().getSemanticHint())) {
- // //fix Scroll bars(https://bugs.eclipse.org/bugs/show_bug.cgi?id=364697), note that we use XYLayout
- // //to relocate both its bounds and combined fragment bounds when operand is added to combined fragment
- // OperandBoundsComputeHelper.addUpdateBoundsForIOCreationCommand(CombinedFragmentCombinedFragmentCompartmentEditPart.this, request.getViewAndElementDescriptor(), command);
- // }
- // return commandProxy;
- return super.getCreateElementAndViewCommand(request);
- }
-
- @Override
- protected Command getCreateCommand(CreateViewRequest request) {
- ICommandProxy commandProxy = (ICommandProxy) super.getCreateCommand(request);
- ICommand command = commandProxy.getICommand();
- CompositeCommand compositeCommand = null;
- if (command instanceof CompositeCommand) {
- compositeCommand = (CompositeCommand) command;
- } else {
- compositeCommand = new CompositeCommand(commandProxy.getLabel());
- compositeCommand.add(command);
- }
- for (ViewDescriptor viewDescriptor : request.getViewDescriptors()) {
- IHintedType type = (IHintedType) UMLElementTypes.InteractionOperand_Shape;
- if (type.getSemanticHint().equals(viewDescriptor.getSemanticHint())) {
- // fix Scroll bars(https://bugs.eclipse.org/bugs/show_bug.cgi?id=364697), note that we use XYLayout
- // to relocate both its bounds and combined fragment bounds when operand is added to combined fragment
- OperandBoundsComputeHelper.addUpdateBoundsForIOCreationCommand(OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart.this, viewDescriptor, compositeCommand);
- }
- }
- return new ICommandProxy(compositeCommand.reduce());
- }
- };
- }
-
- /**
- * Not generated for handle the first InteractionOperand case (no LineSeparator) {@inheritDoc}
- *
- */
- @Override
- protected EditPart createChild(Object model) {
- EditPart child = super.createChild(model);
- if (getChildren() == null || getChildren().isEmpty() && child instanceof OLDCustomInteractionOperandEditPart) {
- ((OLDCustomInteractionOperandEditPart) child).setFirstOperand(true);
- }
- return child;
- }
-
- /**
- * Handle the first InteractionOperand deletion case (change FirstOperand attribute)
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
- Object feature = event.getFeature();
- if (feature instanceof EStructuralFeature) {
- EStructuralFeature ref = (EStructuralFeature) feature;
- String typeName = ref.getName();
- if (CHILDREN_TYPE.equals(typeName)) {
- if (event.getEventType() == Notification.UNSET || event.getEventType() == Notification.REMOVE) {
- List<?> children = getChildren();
- if (children != null && children.size() > 1) {
- Object firstChild = children.get(0);
- if (firstChild instanceof OLDCustomInteractionOperandEditPart) {
- OLDCustomInteractionOperandEditPart firstOperandChild = (OLDCustomInteractionOperandEditPart) firstChild;
- Object firstChildModel = firstOperandChild.getModel();
- if (firstChildModel != null && firstChildModel.equals(event.getOldValue()) && children.get(1) instanceof OLDCustomInteractionOperandEditPart) {
- OLDCustomInteractionOperandEditPart secondOperandChild = (OLDCustomInteractionOperandEditPart) children.get(1);
- secondOperandChild.setFirstOperand(true);
- }
- }
- }
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- public boolean ignoreRequest(Request request) {
- if (request instanceof ChangeBoundsRequest && (request.getType().equals(org.eclipse.gef.RequestConstants.REQ_ADD) || request.getType().equals(RequestConstants.REQ_DROP))) {
- List parts = ((ChangeBoundsRequest) request).getEditParts();
- if (parts != null) {
- for (Object obj : parts) {
- if (obj instanceof CommentEditPart || obj instanceof ConstraintEditPart || obj instanceof TimeObservationEditPart) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- @Override
- public void showTargetFeedback(Request request) {
- if (ignoreRequest(request)) {
- return;
- }
- super.showTargetFeedback(request);
- }
-
- @Override
- public Command getCommand(Request request) {
- if (ignoreRequest(request)) {
- return null;
- }
- return super.getCommand(request);
- }
-}
+/***************************************************************************** + * Copyright (c) 2010 CEA + * + * + * 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: + * Soyatec - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.ScrollPane; +import org.eclipse.draw2d.XYLayout; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; +import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; +import org.eclipse.gmf.runtime.emf.type.core.IHintedType; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomDiagramDragDropEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; +import org.eclipse.papyrus.uml.diagram.sequence.util.OperandBoundsComputeHelper; + +/** + * @author Jin Liu (jin.liu@soyatec.com) + */ +public class OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart extends CombinedFragmentCombinedFragmentCompartmentEditPart { + + /** + * Children string for notification event type. + */ + private static final String CHILDREN_TYPE = "children"; + + /** + * Constructor. + * + * @param view + */ + public OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart(View view) { + super(view); + } + + /** + * Not generated for delete borders add stretch children figures. + * + * @Override + */ + @Override + public IFigure createFigure() { + ResizableCompartmentFigure result = (ResizableCompartmentFigure) super.createFigure(); + result.getScrollPane().setVerticalScrollBarVisibility(ScrollPane.NEVER); + result.setTitleVisibility(false); + result.setBorder(null); + IFigure contentPane = result.getContentPane(); + if (contentPane != null) { + contentPane.setBorder(null); + // fix Scroll bars(https://bugs.eclipse.org/bugs/show_bug.cgi?id=364697) + contentPane.setLayoutManager(new XYLayout()); + // LayoutManager layout = contentPane.getLayoutManager(); + // if(layout instanceof ConstrainedToolbarLayout) { + // ConstrainedToolbarLayout constrainedToolbarLayout = (ConstrainedToolbarLayout)layout; + // constrainedToolbarLayout.setStretchMajorAxis(true); + // constrainedToolbarLayout.setStretchMinorAxis(true); + // } + } + return result; + } + + /** + * {@inheritDoc} + */ + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.CREATION_ROLE, createCreationEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); + } + + private EditPolicy createCreationEditPolicy() { + return new PapyrusCreationEditPolicy() { + + @Override + protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) { + // THIS WAS ALREADY DID IN getCreateCommand(), WHY AGAIN? + // Command createCommand = super.getCreateElementAndViewCommand(request); + // if (createCommand == null || !createCommand.canExecute()){ + // return createCommand; + // } + // ICommandProxy commandProxy = (ICommandProxy)createCommand; + // CompositeCommand command = (CompositeCommand)commandProxy.getICommand(); + // + // IHintedType type = (IHintedType)UMLElementTypes.InteractionOperand_Shape; + // if(type.getSemanticHint().equals(request.getViewAndElementDescriptor().getSemanticHint())) { + // //fix Scroll bars(https://bugs.eclipse.org/bugs/show_bug.cgi?id=364697), note that we use XYLayout + // //to relocate both its bounds and combined fragment bounds when operand is added to combined fragment + // OperandBoundsComputeHelper.addUpdateBoundsForIOCreationCommand(CombinedFragmentCombinedFragmentCompartmentEditPart.this, request.getViewAndElementDescriptor(), command); + // } + // return commandProxy; + return super.getCreateElementAndViewCommand(request); + } + + @Override + protected Command getCreateCommand(CreateViewRequest request) { + ICommandProxy commandProxy = (ICommandProxy) super.getCreateCommand(request); + ICommand command = commandProxy.getICommand(); + CompositeCommand compositeCommand = null; + if (command instanceof CompositeCommand) { + compositeCommand = (CompositeCommand) command; + } else { + compositeCommand = new CompositeCommand(commandProxy.getLabel()); + compositeCommand.add(command); + } + for (ViewDescriptor viewDescriptor : request.getViewDescriptors()) { + IHintedType type = (IHintedType) UMLElementTypes.InteractionOperand_Shape; + if (type.getSemanticHint().equals(viewDescriptor.getSemanticHint())) { + // fix Scroll bars(https://bugs.eclipse.org/bugs/show_bug.cgi?id=364697), note that we use XYLayout + // to relocate both its bounds and combined fragment bounds when operand is added to combined fragment + OperandBoundsComputeHelper.addUpdateBoundsForIOCreationCommand(OLDCustomCombinedFragmentCombinedFragmentCompartmentEditPart.this, viewDescriptor, compositeCommand); + } + } + return new ICommandProxy(compositeCommand.reduce()); + } + }; + } + + /** + * Not generated for handle the first InteractionOperand case (no LineSeparator) {@inheritDoc} + * + */ + @Override + protected EditPart createChild(Object model) { + EditPart child = super.createChild(model); + if (getChildren() == null || getChildren().isEmpty() && child instanceof OLDCustomInteractionOperandEditPart) { + ((OLDCustomInteractionOperandEditPart) child).setFirstOperand(true); + } + return child; + } + + /** + * Handle the first InteractionOperand deletion case (change FirstOperand attribute) + */ + @Override + protected void handleNotificationEvent(Notification event) { + Object feature = event.getFeature(); + if (feature instanceof EStructuralFeature) { + EStructuralFeature ref = (EStructuralFeature) feature; + String typeName = ref.getName(); + if (CHILDREN_TYPE.equals(typeName)) { + if (event.getEventType() == Notification.UNSET || event.getEventType() == Notification.REMOVE) { + List<?> children = getChildren(); + if (children != null && children.size() > 1) { + Object firstChild = children.get(0); + if (firstChild instanceof OLDCustomInteractionOperandEditPart) { + OLDCustomInteractionOperandEditPart firstOperandChild = (OLDCustomInteractionOperandEditPart) firstChild; + Object firstChildModel = firstOperandChild.getModel(); + if (firstChildModel != null && firstChildModel.equals(event.getOldValue()) && children.get(1) instanceof OLDCustomInteractionOperandEditPart) { + OLDCustomInteractionOperandEditPart secondOperandChild = (OLDCustomInteractionOperandEditPart) children.get(1); + secondOperandChild.setFirstOperand(true); + } + } + } + } + } + } + super.handleNotificationEvent(event); + } + + public boolean ignoreRequest(Request request) { + if (request instanceof ChangeBoundsRequest && (request.getType().equals(org.eclipse.gef.RequestConstants.REQ_ADD) || request.getType().equals(RequestConstants.REQ_DROP))) { + List parts = ((ChangeBoundsRequest) request).getEditParts(); + if (parts != null) { + for (Object obj : parts) { + if (obj instanceof CommentEditPart || obj instanceof ConstraintEditPart || obj instanceof TimeObservationEditPart) { + return true; + } + } + } + } + return false; + } + + @Override + public void showTargetFeedback(Request request) { + if (ignoreRequest(request)) { + return; + } + super.showTargetFeedback(request); + } + + @Override + public Command getCommand(Request request) { + if (ignoreRequest(request)) { + return null; + } + return super.getCommand(request); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java index c81fdd2b842..30ce446bdf3 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/RemoveOrphanViewPolicy.java @@ -1,45 +1,48 @@ -/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
-
-import org.eclipse.gmf.runtime.notation.BasicCompartment;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.OrphanViewPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
-
-/**
- * this policy is used to suppress orphan node view in GMF view the policy to remove orphan
- * connection is more complex. It is dependent of the diagram. see remove OrphanConnectionView
- * policy
- *
- */
-public class RemoveOrphanViewPolicy extends OrphanViewPolicy {
-
- public String[] notOrphanNode = { LifelineNameEditPart.VISUAL_ID };
-
- public RemoveOrphanViewPolicy() {
- super();
- init(notOrphanNode);
- }
-
- @Override
- protected boolean isOrphaned(View view) {
- // Since added support of ShapeCompartment for NamedElement(See ShapeCompartmentEditPolicy.CreateShapeCompartmentViewCommand, the element is not set for ShapeCompartment),
- // There's a bug about removing orphaned views. Some ShapeCompartments unrelated to current context would be removed, this will block the undo/redo actions.
- if (view instanceof BasicCompartment) {
- return ((BasicCompartment) view).getElement() == null;
- }
- return super.isOrphaned(view);
- }
-}
+/***************************************************************************** + * Copyright (c) 2010, 2017 CEA LIST and Others. + * + * + * 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: + * Atos Origin - Initial API and implementation + * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 528499 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import org.eclipse.gmf.runtime.notation.BasicCompartment; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.OrphanViewPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart; + +/** + * this policy is used to suppress orphan node view in GMF view the policy to remove orphan + * connection is more complex. It is dependent of the diagram. see remove OrphanConnectionView + * policy. + * + * @deprecated since 5.0. Useless. Helper Advices remove views. + * + */ +public class RemoveOrphanViewPolicy extends OrphanViewPolicy { + + public String[] notOrphanNode = { LifelineNameEditPart.VISUAL_ID }; + + public RemoveOrphanViewPolicy() { + super(); + init(notOrphanNode); + } + + @Override + protected boolean isOrphaned(View view) { + // Since added support of ShapeCompartment for NamedElement(See ShapeCompartmentEditPolicy.CreateShapeCompartmentViewCommand, the element is not set for ShapeCompartment), + // There's a bug about removing orphaned views. Some ShapeCompartments unrelated to current context would be removed, this will block the undo/redo actions. + if (view instanceof BasicCompartment) { + return ((BasicCompartment) view).getElement() == null; + } + return super.isOrphaned(view); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/PackageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/PackageEditPart.java index 3fa8d66a3f8..f1a58f9b8ca 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/PackageEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/PackageEditPart.java @@ -1,64 +1,62 @@ -
-/**
- * Copyright (c) 2016 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.uml.diagram.sequence.edit.parts;
-
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusDiagramEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCompartmentSemanticEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.RemoveOrphanViewPolicy;
-
-/**
- * @generated
- */
-public class PackageEditPart extends PapyrusDiagramEditPart {
-
- /**
- * @generated
- */
- public final static String MODEL_ID = "PapyrusUMLSequenceDiagram"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final String VISUAL_ID = "Package_SequenceDiagram";
-
- /**
- * @generated
- */
- public PackageEditPart(View view) {
- super(view);
- }
-
- /**
- * @generated
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
-
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy());
- installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy());
-
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultCompartmentSemanticEditPolicy());
- // in Papyrus diagrams are not strongly synchronised
- // installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.sequence.edit.policies.PackageCanonicalEditPolicy());
-
- installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy());
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
- }
-}
+ +/** + * Copyright (c) 2016 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.uml.diagram.sequence.edit.parts; + +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusDiagramEditPart; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCompartmentSemanticEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomDiagramDragDropEditPolicy; + +/** + * @generated + */ +public class PackageEditPart extends PapyrusDiagramEditPart { + + /** + * @generated + */ + public final static String MODEL_ID = "PapyrusUMLSequenceDiagram"; //$NON-NLS-1$ + + /** + * @generated + */ + public static final String VISUAL_ID = "Package_SequenceDiagram"; + + /** + * @generated + */ + public PackageEditPart(View view) { + super(view); + } + + /** + * @generated + */ + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); + installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); + + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultCompartmentSemanticEditPolicy()); + // in Papyrus diagrams are not strongly synchronised + // installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.sequence.edit.policies.PackageCanonicalEditPolicy()); + + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); + // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE); + } +} |