diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies')
16 files changed, 1469 insertions, 1469 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractCustomLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractCustomLabelEditPolicy.java index 2bd68ccd3c2..31d5167668e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractCustomLabelEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractCustomLabelEditPolicy.java @@ -1,137 +1,137 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Nizar GUEDIDI (CEA LIST) - Update getUMLElement()
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.editpolicies.GraphicalEditPolicy;
-import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
-import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * Edit policy for specific Label
- */
-public abstract class AbstractCustomLabelEditPolicy extends GraphicalEditPolicy implements IPapyrusListener, NotificationListener {
-
- /** constant for this edit policy role */
- public final static String SPECIFIC_NAME_LABEL_POLICY = "SpecificNameLabelEditPolicy"; //$NON-NLS-1$
-
- /**
- * Creates a new Specific Name display edit policy
- */
- public AbstractCustomLabelEditPolicy() {
- super();
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void activate() {
- // retrieve the view and the element managed by the edit part
- View view = getView();
- if (view == null) {
- return;
- }
- Element element = getUMLElement();
- if (getUMLElement() != null) {
- // adds a listener on the view and the element controlled by the editpart
- getDiagramEventBroker().addNotificationListener(view, this);
- getDiagramEventBroker().addNotificationListener(element, this);
- addAdditionalListeners();
- refreshDisplay();
- }
- }
-
- /**
- * Adds more listeners upon activation
- */
- protected void addAdditionalListeners() {
- // default implementation does nothing
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void deactivate() {
- // retrieve the view and the element managed by the edit part
- View view = getView();
- if (view == null) {
- return;
- }
- Element element = getUMLElement();
- // remove notification on element and view
- getDiagramEventBroker().removeNotificationListener(view, this);
- if (element == null) {
- return;
- }
- getDiagramEventBroker().removeNotificationListener(element, this);
- removeAdditionalListeners();
- }
-
- /**
- * Remove the others listeners
- *
- */
- protected void removeAdditionalListeners() {
- // default implementation does nothing
- }
-
- /**
- * Gets the diagram event broker from the editing domain.
- *
- * @return the diagram event broker
- */
- protected DiagramEventBroker getDiagramEventBroker() {
- TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- if (theEditingDomain != null) {
- return DiagramEventBroker.getInstance(theEditingDomain);
- }
- return null;
- }
-
- /**
- * Returns the uml element controlled by the host edit part
- *
- * @return the uml element controlled by the host edit part
- */
- protected Element getUMLElement() {
- // be sure to have a UML element
- if (getView().getElement() instanceof Element) {
- return (Element) getView().getElement();
- }
- return null;
- }
-
- /**
- * Returns the view controlled by the host edit part
- *
- * @return the view controlled by the host edit part
- */
- protected View getView() {
- return (View) getHost().getModel();
- }
-
- /**
- * Refreshes the display for the element controlled by the edit part with this edit policies
- */
- public abstract void refreshDisplay();
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Nizar GUEDIDI (CEA LIST) - Update getUMLElement() + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.editpolicies.GraphicalEditPolicy; +import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; +import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener; +import org.eclipse.uml2.uml.Element; + +/** + * Edit policy for specific Label + */ +public abstract class AbstractCustomLabelEditPolicy extends GraphicalEditPolicy implements IPapyrusListener, NotificationListener { + + /** constant for this edit policy role */ + public final static String SPECIFIC_NAME_LABEL_POLICY = "SpecificNameLabelEditPolicy"; //$NON-NLS-1$ + + /** + * Creates a new Specific Name display edit policy + */ + public AbstractCustomLabelEditPolicy() { + super(); + } + + /** + * + * {@inheritDoc} + */ + @Override + public void activate() { + // retrieve the view and the element managed by the edit part + View view = getView(); + if (view == null) { + return; + } + Element element = getUMLElement(); + if (getUMLElement() != null) { + // adds a listener on the view and the element controlled by the editpart + getDiagramEventBroker().addNotificationListener(view, this); + getDiagramEventBroker().addNotificationListener(element, this); + addAdditionalListeners(); + refreshDisplay(); + } + } + + /** + * Adds more listeners upon activation + */ + protected void addAdditionalListeners() { + // default implementation does nothing + } + + /** + * + * {@inheritDoc} + */ + @Override + public void deactivate() { + // retrieve the view and the element managed by the edit part + View view = getView(); + if (view == null) { + return; + } + Element element = getUMLElement(); + // remove notification on element and view + getDiagramEventBroker().removeNotificationListener(view, this); + if (element == null) { + return; + } + getDiagramEventBroker().removeNotificationListener(element, this); + removeAdditionalListeners(); + } + + /** + * Remove the others listeners + * + */ + protected void removeAdditionalListeners() { + // default implementation does nothing + } + + /** + * Gets the diagram event broker from the editing domain. + * + * @return the diagram event broker + */ + protected DiagramEventBroker getDiagramEventBroker() { + TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + if (theEditingDomain != null) { + return DiagramEventBroker.getInstance(theEditingDomain); + } + return null; + } + + /** + * Returns the uml element controlled by the host edit part + * + * @return the uml element controlled by the host edit part + */ + protected Element getUMLElement() { + // be sure to have a UML element + if (getView().getElement() instanceof Element) { + return (Element) getView().getElement(); + } + return null; + } + + /** + * Returns the view controlled by the host edit part + * + * @return the view controlled by the host edit part + */ + protected View getView() { + return (View) getHost().getModel(); + } + + /** + * Refreshes the display for the element controlled by the edit part with this edit policies + */ + public abstract void refreshDisplay(); +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeEnumerationLiteralDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeEnumerationLiteralDisplayEditPolicy.java index 37f27734225..de28feee30f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeEnumerationLiteralDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeEnumerationLiteralDisplayEditPolicy.java @@ -1,54 +1,54 @@ -/*****************************************************************************
- * Copyright (c) 2015 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 472034
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.EnumerationLiteralLabelHelper;
-import org.eclipse.uml2.uml.EnumerationLiteral;
-
-/**
- * This Policy is to be used for Enumeration Literal Edit Part to manage the stereotype display
- *
- * @author Céline JANSSENS
- *
- */
-public class AppliedStereotypeEnumerationLiteralDisplayEditPolicy extends AbstractAppliedStereotypeDisplayEditPolicy {
- /**
- * {@inheritDoc}
- */
- @Override
- protected EnumerationLiteral getUMLElement() {
- EObject element = super.getUMLElement();
- EnumerationLiteral literal = null;
- if (element instanceof EnumerationLiteral) {
- literal = (EnumerationLiteral) element;
- }
- return literal;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- EnumerationLiteralLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-
-
-}
+/***************************************************************************** + * Copyright (c) 2015 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 472034 + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.helper.EnumerationLiteralLabelHelper; +import org.eclipse.uml2.uml.EnumerationLiteral; + +/** + * This Policy is to be used for Enumeration Literal Edit Part to manage the stereotype display + * + * @author Céline JANSSENS + * + */ +public class AppliedStereotypeEnumerationLiteralDisplayEditPolicy extends AbstractAppliedStereotypeDisplayEditPolicy { + /** + * {@inheritDoc} + */ + @Override + protected EnumerationLiteral getUMLElement() { + EObject element = super.getUMLElement(); + EnumerationLiteral literal = null; + if (element instanceof EnumerationLiteral) { + literal = (EnumerationLiteral) element; + } + return literal; + } + + + /** + * {@inheritDoc} + */ + @Override + public void refreshDisplay() { + // calls the helper for this edit Part + EnumerationLiteralLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeNestedLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeNestedLabelDisplayEditPolicy.java index 9776e6400a2..b3663079b1c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeNestedLabelDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeNestedLabelDisplayEditPolicy.java @@ -1,21 +1,21 @@ -package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.NestedStereotypeLabelHelper;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-
-/**
- *
- *
- */
-public class AppliedStereotypeNestedLabelDisplayEditPolicy extends AppliedStereotypeLabelDisplayEditPolicy {
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#refreshStereotypeDisplay()
- *
- */
- @Override
- protected void refreshStereotypeDisplay() {
- NestedStereotypeLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-}
+package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.NestedStereotypeLabelHelper; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; + +/** + * + * + */ +public class AppliedStereotypeNestedLabelDisplayEditPolicy extends AppliedStereotypeLabelDisplayEditPolicy { + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#refreshStereotypeDisplay() + * + */ + @Override + protected void refreshStereotypeDisplay() { + NestedStereotypeLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java index b4e3d919794..4fb8bdc5e32 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java @@ -1,51 +1,51 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- * Nizar GUEDIDI (CEA LIST) - Update getUMLElement()
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.OperationLabelHelper;
-import org.eclipse.uml2.uml.Operation;
-
-/**
- * Specific edit policy for label displaying stereotypes and their properties for edges representing
- * UML elements.
- */
-public class AppliedStereotypeOperationDisplayEditPolicy extends AbstractAppliedStereotypeDisplayEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Operation getUMLElement() {
- EObject element = super.getUMLElement();
- if (element instanceof Operation) {
- return (Operation) element;
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- OperationLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-
-
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Nizar GUEDIDI (CEA LIST) - Update getUMLElement() + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.helper.OperationLabelHelper; +import org.eclipse.uml2.uml.Operation; + +/** + * Specific edit policy for label displaying stereotypes and their properties for edges representing + * UML elements. + */ +public class AppliedStereotypeOperationDisplayEditPolicy extends AbstractAppliedStereotypeDisplayEditPolicy { + + /** + * {@inheritDoc} + */ + @Override + protected Operation getUMLElement() { + EObject element = super.getUMLElement(); + if (element instanceof Operation) { + return (Operation) element; + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public void refreshDisplay() { + // calls the helper for this edit Part + OperationLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypePropertyDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypePropertyDisplayEditPolicy.java index 2f77cad9491..bfc3ae49c1b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypePropertyDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypePropertyDisplayEditPolicy.java @@ -1,49 +1,49 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- * Nizar GUEDIDI (CEA LIST) - Update getUMLElement()
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * Specific edit policy for label displaying stereotypes and their properties for edges representing
- * UML elements.
- */
-public class AppliedStereotypePropertyDisplayEditPolicy extends AbstractAppliedStereotypeDisplayEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Property getUMLElement() {
- EObject element = super.getUMLElement();
- if (element instanceof Property) {
- return (Property) element;
- }
- return null;
- };
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- PropertyLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Nizar GUEDIDI (CEA LIST) - Update getUMLElement() + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper; +import org.eclipse.uml2.uml.Property; + +/** + * Specific edit policy for label displaying stereotypes and their properties for edges representing + * UML elements. + */ +public class AppliedStereotypePropertyDisplayEditPolicy extends AbstractAppliedStereotypeDisplayEditPolicy { + + /** + * {@inheritDoc} + */ + @Override + protected Property getUMLElement() { + EObject element = super.getUMLElement(); + if (element instanceof Property) { + return (Property) element; + } + return null; + }; + + /** + * {@inheritDoc} + */ + @Override + public void refreshDisplay() { + // calls the helper for this edit Part + PropertyLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ContainerHighlightEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ContainerHighlightEditPolicy.java index 6d128699f39..c62c2418861 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ContainerHighlightEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ContainerHighlightEditPolicy.java @@ -1,104 +1,104 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * This policy is used to change background of container when we move or connect an elent to them
- */
-public class ContainerHighlightEditPolicy extends org.eclipse.gef.editpolicies.GraphicalEditPolicy {
-
- /**
- * the color when the element is selected
- */
- private Color revertColor;
-
- /**
- *
- * {@inheritedDoc}
- */
- @Override
- public void eraseTargetFeedback(Request request) {
- if (revertColor != null) {
- setContainerBackground(revertColor);
- revertColor = null;
- }
- }
-
- /**
- *
- * @return the background color of the figure
- */
- private Color getContainerBackground() {
- return getContainerFigure().getBackgroundColor();
- }
-
- /**
- *
- * get the figure attach to the editpart
- *
- * @return
- */
- private IFigure getContainerFigure() {
- return ((GraphicalEditPart) getHost()).getFigure();
- }
-
- /**
- *
- * {@inheritedDoc}
- */
- @Override
- public EditPart getTargetEditPart(Request request) {
- return request.getType().equals(RequestConstants.REQ_SELECTION_HOVER) ? getHost() : null;
- }
-
- /**
- * set the color to the figure attached to the editpart
- *
- * @param c
- * the background color
- */
- private void setContainerBackground(Color c) {
- getContainerFigure().setBackgroundColor(c);
- }
-
- /**
- * change the color of the figure
- */
- protected void showHighlight() {
- if (revertColor == null) {
- revertColor = getContainerBackground();
- setContainerBackground(ColorConstants.lightBlue);
- }
- }
-
- /**
- *
- * {@inheritedDoc}
- */
- @Override
- public void showTargetFeedback(Request request) {
- if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_ADD) || request.getType().equals(RequestConstants.REQ_CLONE) || request.getType().equals(RequestConstants.REQ_CONNECTION_START)
- || request.getType().equals(RequestConstants.REQ_CONNECTION_END) || request.getType().equals(RequestConstants.REQ_CREATE)) {
- showHighlight();
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.swt.graphics.Color; + +/** + * This policy is used to change background of container when we move or connect an elent to them + */ +public class ContainerHighlightEditPolicy extends org.eclipse.gef.editpolicies.GraphicalEditPolicy { + + /** + * the color when the element is selected + */ + private Color revertColor; + + /** + * + * {@inheritedDoc} + */ + @Override + public void eraseTargetFeedback(Request request) { + if (revertColor != null) { + setContainerBackground(revertColor); + revertColor = null; + } + } + + /** + * + * @return the background color of the figure + */ + private Color getContainerBackground() { + return getContainerFigure().getBackgroundColor(); + } + + /** + * + * get the figure attach to the editpart + * + * @return + */ + private IFigure getContainerFigure() { + return ((GraphicalEditPart) getHost()).getFigure(); + } + + /** + * + * {@inheritedDoc} + */ + @Override + public EditPart getTargetEditPart(Request request) { + return request.getType().equals(RequestConstants.REQ_SELECTION_HOVER) ? getHost() : null; + } + + /** + * set the color to the figure attached to the editpart + * + * @param c + * the background color + */ + private void setContainerBackground(Color c) { + getContainerFigure().setBackgroundColor(c); + } + + /** + * change the color of the figure + */ + protected void showHighlight() { + if (revertColor == null) { + revertColor = getContainerBackground(); + setContainerBackground(ColorConstants.lightBlue); + } + } + + /** + * + * {@inheritedDoc} + */ + @Override + public void showTargetFeedback(Request request) { + if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_ADD) || request.getType().equals(RequestConstants.REQ_CLONE) || request.getType().equals(RequestConstants.REQ_CONNECTION_START) + || request.getType().equals(RequestConstants.REQ_CONNECTION_END) || request.getType().equals(RequestConstants.REQ_CREATE)) { + showHighlight(); + } + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomContainmentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomContainmentCreationEditPolicy.java index 67f00800db8..1a5c832db3e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomContainmentCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomContainmentCreationEditPolicy.java @@ -1,96 +1,96 @@ -/*****************************************************************************
- * Copyright (c) 2010 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:
- * Tatiana Fesenko (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-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.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GroupEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.ContainmentDragDropHelper;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPartTN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.NestedClassForClassEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry;
-
-/**
- * The Class CustomContainmentCreationEditPolicy.
- */
-public class CustomContainmentCreationEditPolicy extends DefaultCreationEditPolicy {
-
- private static List<String> ourCanHaveContainmentLinks = Arrays.asList(new String[] { NestedClassForClassEditPart.VISUAL_ID, ClassEditPartCN.VISUAL_ID, PackageEditPartCN.VISUAL_ID, ModelEditPartCN.VISUAL_ID, ModelEditPartTN.VISUAL_ID,
- ClassEditPart.VISUAL_ID, PackageEditPart.VISUAL_ID });
-
- /**
- * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getReparentCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
- *
- * @param request
- * @return
- */
- @Override
- protected Command getReparentCommand(ChangeBoundsRequest request) {
- Iterator<?> editParts = request.getEditParts().iterator();
- View container = (View) getHost().getAdapter(View.class);
- EObject context = container == null ? null : ViewUtil.resolveSemanticElement(container);
- CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label);
- while (editParts.hasNext()) {
- EditPart ep = (EditPart) editParts.next();
- if (ep instanceof LabelEditPart) {
- continue;
- }
- if (ep instanceof GroupEditPart) {
- cc.compose(getReparentGroupCommand((GroupEditPart) ep));
- }
- View view = (View) ep.getAdapter(View.class);
- if (view == null) {
- continue;
- }
- EObject semantic = ViewUtil.resolveSemanticElement(view);
- if (semantic == null) {
- cc.compose(getReparentViewCommand((IGraphicalEditPart) ep));
- } else if (context != null && hasContainmentLink(view)) {
- View hostView = (View) getHost().getModel();
- View movedView = (View) ep.getModel();
- Command customCommand = new ContainmentDragDropHelper(((IGraphicalEditPart) ep).getEditingDomain()).getDropWithContainmentCommand(hostView, movedView);
- if (customCommand != null) {
- return customCommand;
- }
- }
- if (semantic != null && context != null && shouldReparent(semantic, context)) {
- cc.compose(getReparentCommand((IGraphicalEditPart) ep));
- }
- }
- return cc.isEmpty() ? null : new ICommandProxy(cc.reduce());
- }
-
- private boolean hasContainmentLink(View movedView) {
- return ourCanHaveContainmentLinks.contains(UMLVisualIDRegistry.getVisualID(movedView));
- }
-}
+/***************************************************************************** + * Copyright (c) 2010 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: + * Tatiana Fesenko (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +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.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GroupEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; +import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.ContainmentDragDropHelper; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPartTN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.NestedClassForClassEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry; + +/** + * The Class CustomContainmentCreationEditPolicy. + */ +public class CustomContainmentCreationEditPolicy extends DefaultCreationEditPolicy { + + private static List<String> ourCanHaveContainmentLinks = Arrays.asList(new String[] { NestedClassForClassEditPart.VISUAL_ID, ClassEditPartCN.VISUAL_ID, PackageEditPartCN.VISUAL_ID, ModelEditPartCN.VISUAL_ID, ModelEditPartTN.VISUAL_ID, + ClassEditPart.VISUAL_ID, PackageEditPart.VISUAL_ID }); + + /** + * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getReparentCommand(org.eclipse.gef.requests.ChangeBoundsRequest) + * + * @param request + * @return + */ + @Override + protected Command getReparentCommand(ChangeBoundsRequest request) { + Iterator<?> editParts = request.getEditParts().iterator(); + View container = (View) getHost().getAdapter(View.class); + EObject context = container == null ? null : ViewUtil.resolveSemanticElement(container); + CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label); + while (editParts.hasNext()) { + EditPart ep = (EditPart) editParts.next(); + if (ep instanceof LabelEditPart) { + continue; + } + if (ep instanceof GroupEditPart) { + cc.compose(getReparentGroupCommand((GroupEditPart) ep)); + } + View view = (View) ep.getAdapter(View.class); + if (view == null) { + continue; + } + EObject semantic = ViewUtil.resolveSemanticElement(view); + if (semantic == null) { + cc.compose(getReparentViewCommand((IGraphicalEditPart) ep)); + } else if (context != null && hasContainmentLink(view)) { + View hostView = (View) getHost().getModel(); + View movedView = (View) ep.getModel(); + Command customCommand = new ContainmentDragDropHelper(((IGraphicalEditPart) ep).getEditingDomain()).getDropWithContainmentCommand(hostView, movedView); + if (customCommand != null) { + return customCommand; + } + } + if (semantic != null && context != null && shouldReparent(semantic, context)) { + cc.compose(getReparentCommand((IGraphicalEditPart) ep)); + } + } + return cc.isEmpty() ? null : new ICommandProxy(cc.reduce()); + } + + private boolean hasContainmentLink(View movedView) { + return ourCanHaveContainmentLinks.contains(UMLVisualIDRegistry.getVisualID(movedView)); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomGraphicalNodeEditPolicy.java index 9cef30af083..727b2fb737b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomGraphicalNodeEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomGraphicalNodeEditPolicy.java @@ -1,73 +1,73 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Bug 506314
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.Arrays;
-
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.AssociationClassHelper;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.MultiAssociationHelper;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.MultiDependencyHelper;
-import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
-
-/**
- * This class is used to launch command to create associationClass
- *
- * @author Patrick Tessier
- */
-public class CustomGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPolicy {
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public Command getCommand(Request request) {
- // we have to distinguish the case where this is an association class
- if (REQ_CONNECTION_END.equals(request.getType())) {
- if (request instanceof CreateConnectionViewAndElementRequest) {
- // default behavior
- Command c = getConnectionAndRelationshipCompleteCommand((CreateConnectionViewAndElementRequest) request);
- // case of associationClass
- CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
- CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter.getAdapter(CreateRelationshipRequest.class);
- IElementType elementType = createElementRequest.getElementType();
- if (UMLElementTypes.AssociationClass_Edge.equals(elementType)
- || (elementType!= null && Arrays.asList(elementType.getAllSuperTypes()).contains(UMLElementTypes.AssociationClass_Edge))) {
- AssociationClassHelper associationClassHelper = new AssociationClassHelper(getEditingDomain());
- return associationClassHelper.getAssociationClassElementCommand(((CreateConnectionViewAndElementRequest) request), c);
- } else if (UMLElementTypes.Dependency_BranchEdge.equals(elementType)) {
- MultiDependencyHelper multiDependencyHelper = new MultiDependencyHelper(getEditingDomain());
- return multiDependencyHelper.getCommand(((CreateConnectionViewAndElementRequest) request), c);
- } else if (UMLElementTypes.Association_BranchEdge.equals(elementType)) {
- MultiAssociationHelper multiAssociationHelper = new MultiAssociationHelper(getEditingDomain());
- return multiAssociationHelper.getCommand(((CreateConnectionViewAndElementRequest) request), c);
- } else {
- return c;
- }
-
- } else if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
- return getUnspecifiedConnectionCompleteCommand((CreateUnspecifiedTypeConnectionRequest) request);
- }
- }
- return super.getCommand(request);
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Bug 506314 + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.Arrays; + +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.AssociationClassHelper; +import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.MultiAssociationHelper; +import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.MultiDependencyHelper; +import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes; + +/** + * This class is used to launch command to create associationClass + * + * @author Patrick Tessier + */ +public class CustomGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPolicy { + + /** + * + * {@inheritDoc} + */ + @Override + public Command getCommand(Request request) { + // we have to distinguish the case where this is an association class + if (REQ_CONNECTION_END.equals(request.getType())) { + if (request instanceof CreateConnectionViewAndElementRequest) { + // default behavior + Command c = getConnectionAndRelationshipCompleteCommand((CreateConnectionViewAndElementRequest) request); + // case of associationClass + CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter(); + CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter.getAdapter(CreateRelationshipRequest.class); + IElementType elementType = createElementRequest.getElementType(); + if (UMLElementTypes.AssociationClass_Edge.equals(elementType) + || (elementType!= null && Arrays.asList(elementType.getAllSuperTypes()).contains(UMLElementTypes.AssociationClass_Edge))) { + AssociationClassHelper associationClassHelper = new AssociationClassHelper(getEditingDomain()); + return associationClassHelper.getAssociationClassElementCommand(((CreateConnectionViewAndElementRequest) request), c); + } else if (UMLElementTypes.Dependency_BranchEdge.equals(elementType)) { + MultiDependencyHelper multiDependencyHelper = new MultiDependencyHelper(getEditingDomain()); + return multiDependencyHelper.getCommand(((CreateConnectionViewAndElementRequest) request), c); + } else if (UMLElementTypes.Association_BranchEdge.equals(elementType)) { + MultiAssociationHelper multiAssociationHelper = new MultiAssociationHelper(getEditingDomain()); + return multiAssociationHelper.getCommand(((CreateConnectionViewAndElementRequest) request), c); + } else { + return c; + } + + } else if (request instanceof CreateUnspecifiedTypeConnectionRequest) { + return getUnspecifiedConnectionCompleteCommand((CreateUnspecifiedTypeConnectionRequest) request); + } + } + return super.getCommand(request); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomPackageReparentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomPackageReparentCreationEditPolicy.java index 515d7cdaa97..b05f58854cb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomPackageReparentCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/CustomPackageReparentCreationEditPolicy.java @@ -1,120 +1,120 @@ -/*****************************************************************************
- * Copyright (c) 2010 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-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.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GroupEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
-import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.edit.part.CModelEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPartCN;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy;
-import org.eclipse.uml2.uml.Element;
-
-public class CustomPackageReparentCreationEditPolicy extends PapyrusCreationEditPolicy {
-
- /**
- * return a command to reparent both the semantic and view elements.
- *
- * @param request
- * the request
- * @return command
- */
- @Override
- protected Command getReparentCommand(ChangeBoundsRequest request) {
- Iterator<?> editParts = request.getEditParts().iterator();
- View container = (View) getHost().getAdapter(View.class);
- EObject context = container == null ? null : ViewUtil.resolveSemanticElement(container);
- CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label);
-
- while (editParts.hasNext()) {
- EditPart ep = (EditPart) editParts.next();
- if (ep instanceof LabelEditPart) {
- continue;
- }
- if (ep instanceof GroupEditPart) {
- cc.compose(getReparentGroupCommand((GroupEditPart) ep));
- }
- if (ep instanceof PackageEditPart || ep instanceof CModelEditPart || ep instanceof PackageEditPartCN || ep instanceof ModelEditPartCN) {
- if (context != null) {
- cc.compose(getReparentCommand((IGraphicalEditPart) ep));
- }
- } else {
- // if ( context != null && shouldReparent(semantic, context)){
- ChangeBoundsRequest req = new ChangeBoundsRequest();
- req.setEditParts(ep);
- return super.getReparentCommand(req);
- // }
- }
- }
- return cc.isEmpty() ? null : new ICommandProxy(cc.reduce());
- }
-
- @Override
- protected ICommand getReparentCommand(IGraphicalEditPart gep) {
- // 1.******************************************** Variables initialization
- CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label);
- View container = (View) getHost().getModel();
- EObject context = ViewUtil.resolveSemanticElement(container);
- View view = (View) gep.getModel();
- EObject element = ViewUtil.resolveSemanticElement(view);
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- EditPart modelRootEditPart = null;
- EditPart rootEditPart = gep.getRoot();
- Iterator<?> rootEditPartIterator = rootEditPart.getChildren().iterator();
- while (rootEditPartIterator.hasNext()) {
- EditPart editPart = (EditPart) rootEditPartIterator.next();
- if (editPart instanceof ModelEditPart) {
- modelRootEditPart = editPart;
- }
- }
- org.eclipse.uml2.uml.Package modelElementRoot = (org.eclipse.uml2.uml.Package) ((View) modelRootEditPart.getModel()).getElement();
- // 2.********************************** Move the semantic element with his graphical view
- // Copied Code :semantic
- if (element != null) {
- Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(new MoveRequest(editingDomain, context, element)));
- // Added code
- // if the element is a Package and if it is contained by an other package which is not a Model, we return an UnexecutableCommand to execute a specific Drop command
- if (element instanceof org.eclipse.uml2.uml.Package && ((Element) element).getOwner() instanceof org.eclipse.uml2.uml.Package && !(((Element) element).getOwner().equals(modelElementRoot))) {
- return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
- }
- // Copied Code :semantic
- if (moveSemanticCmd == null) {
- return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
- }
- cc.compose(new CommandProxy(moveSemanticCmd));
- }
- // Copied Code :notation
- cc.compose(getReparentViewCommand(gep));
- return cc;
- }
-}
+/***************************************************************************** + * Copyright (c) 2010 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.Iterator; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.EditPart; +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.core.util.ViewUtil; +import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GroupEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; +import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; +import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.clazz.custom.edit.part.CModelEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPartCN; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy; +import org.eclipse.uml2.uml.Element; + +public class CustomPackageReparentCreationEditPolicy extends PapyrusCreationEditPolicy { + + /** + * return a command to reparent both the semantic and view elements. + * + * @param request + * the request + * @return command + */ + @Override + protected Command getReparentCommand(ChangeBoundsRequest request) { + Iterator<?> editParts = request.getEditParts().iterator(); + View container = (View) getHost().getAdapter(View.class); + EObject context = container == null ? null : ViewUtil.resolveSemanticElement(container); + CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label); + + while (editParts.hasNext()) { + EditPart ep = (EditPart) editParts.next(); + if (ep instanceof LabelEditPart) { + continue; + } + if (ep instanceof GroupEditPart) { + cc.compose(getReparentGroupCommand((GroupEditPart) ep)); + } + if (ep instanceof PackageEditPart || ep instanceof CModelEditPart || ep instanceof PackageEditPartCN || ep instanceof ModelEditPartCN) { + if (context != null) { + cc.compose(getReparentCommand((IGraphicalEditPart) ep)); + } + } else { + // if ( context != null && shouldReparent(semantic, context)){ + ChangeBoundsRequest req = new ChangeBoundsRequest(); + req.setEditParts(ep); + return super.getReparentCommand(req); + // } + } + } + return cc.isEmpty() ? null : new ICommandProxy(cc.reduce()); + } + + @Override + protected ICommand getReparentCommand(IGraphicalEditPart gep) { + // 1.******************************************** Variables initialization + CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label); + View container = (View) getHost().getModel(); + EObject context = ViewUtil.resolveSemanticElement(container); + View view = (View) gep.getModel(); + EObject element = ViewUtil.resolveSemanticElement(view); + TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + EditPart modelRootEditPart = null; + EditPart rootEditPart = gep.getRoot(); + Iterator<?> rootEditPartIterator = rootEditPart.getChildren().iterator(); + while (rootEditPartIterator.hasNext()) { + EditPart editPart = (EditPart) rootEditPartIterator.next(); + if (editPart instanceof ModelEditPart) { + modelRootEditPart = editPart; + } + } + org.eclipse.uml2.uml.Package modelElementRoot = (org.eclipse.uml2.uml.Package) ((View) modelRootEditPart.getModel()).getElement(); + // 2.********************************** Move the semantic element with his graphical view + // Copied Code :semantic + if (element != null) { + Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(new MoveRequest(editingDomain, context, element))); + // Added code + // if the element is a Package and if it is contained by an other package which is not a Model, we return an UnexecutableCommand to execute a specific Drop command + if (element instanceof org.eclipse.uml2.uml.Package && ((Element) element).getOwner() instanceof org.eclipse.uml2.uml.Package && !(((Element) element).getOwner().equals(modelElementRoot))) { + return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; + } + // Copied Code :semantic + if (moveSemanticCmd == null) { + return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; + } + cc.compose(new CommandProxy(moveSemanticCmd)); + } + // Copied Code :notation + cc.compose(getReparentViewCommand(gep)); + return cc; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/DeleteLinkedAssociationClassViewEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/DeleteLinkedAssociationClassViewEditPolicy.java index a89601e8d11..16b80c07236 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/DeleteLinkedAssociationClassViewEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/DeleteLinkedAssociationClassViewEditPolicy.java @@ -1,93 +1,93 @@ -package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ViewComponentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassLinkEditPart;
-
-public class DeleteLinkedAssociationClassViewEditPolicy extends ViewComponentEditPolicy {
-
- public static final String HIDE_ROLE = DeleteLinkedAssociationClassViewEditPolicy.class.getName() + ":HideRole";
-
- /**
- * Returns true when the request is a graphical delete
- *
- * @see org.eclipse.gef.EditPolicy#understandsRequest(Request)
- * @return true for a graphical delete request
- */
- @Override
- public boolean understandsRequest(Request req) {
- return RequestConstants.REQ_DELETE.equals(req.getType());
- }
-
- /**
- * Returns a command for graphical delete with linked AssociationClass node.
- *
- * @see org.eclipse.gef.EditPolicy#getCommand(Request)
- * @return the command or null
- */
- @Override
- public Command getCommand(Request request) {
- if (!RequestConstants.REQ_DELETE.equals(request.getType())) {
- return null;
- }
- if (false == request instanceof GroupRequest) {
- return null;
- }
- GraphicalEditPart host = (GraphicalEditPart) getHost();
- if (host instanceof AssociationClassLinkEditPart) {
- return getAssociationClassLinkHideCommand(host);
- } else if (host instanceof AssociationClassEditPart) {
- return getAssociationClassHideCommand(host);
- }
- return null;
- }
-
- private Command getAssociationClassLinkHideCommand(GraphicalEditPart host) {
- if (host.getSourceConnections() == null || host.getSourceConnections().isEmpty()) {
- return null;
- }
- EditPart dashedLink = (EditPart) host.getSourceConnections().get(0);
- if (false == dashedLink instanceof ConnectionEditPart) {
- return null;
- }
- EditPart source = ((ConnectionEditPart) dashedLink).getTarget();
- if (source == null) {
- return null;
- }
- return getHideCommand(source, dashedLink);
- }
-
- private Command getAssociationClassHideCommand(GraphicalEditPart host) {
- if (host.getTargetConnections() == null || host.getTargetConnections().isEmpty()) {
- return null;
- }
- EditPart dashedLink = (EditPart) host.getTargetConnections().get(0);
- if (false == dashedLink instanceof ConnectionEditPart) {
- return null;
- }
- EditPart source = ((ConnectionEditPart) dashedLink).getSource();
- if (source == null) {
- return null;
- }
- return getHideCommand(source, dashedLink);
- }
-
- private Command getHideCommand(EditPart source, EditPart dashedLink) {
- GroupRequest hideRequest = new GroupRequest(RequestConstants.REQ_DELETE);
- List<EditPart> parts = new ArrayList<EditPart>();
- parts.add(dashedLink);
- parts.add(source);
- hideRequest.setEditParts(parts);
- return getDeleteCommand(hideRequest);
- }
+package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.requests.GroupRequest; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ViewComponentEditPolicy; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassLinkEditPart; + +public class DeleteLinkedAssociationClassViewEditPolicy extends ViewComponentEditPolicy { + + public static final String HIDE_ROLE = DeleteLinkedAssociationClassViewEditPolicy.class.getName() + ":HideRole"; + + /** + * Returns true when the request is a graphical delete + * + * @see org.eclipse.gef.EditPolicy#understandsRequest(Request) + * @return true for a graphical delete request + */ + @Override + public boolean understandsRequest(Request req) { + return RequestConstants.REQ_DELETE.equals(req.getType()); + } + + /** + * Returns a command for graphical delete with linked AssociationClass node. + * + * @see org.eclipse.gef.EditPolicy#getCommand(Request) + * @return the command or null + */ + @Override + public Command getCommand(Request request) { + if (!RequestConstants.REQ_DELETE.equals(request.getType())) { + return null; + } + if (false == request instanceof GroupRequest) { + return null; + } + GraphicalEditPart host = (GraphicalEditPart) getHost(); + if (host instanceof AssociationClassLinkEditPart) { + return getAssociationClassLinkHideCommand(host); + } else if (host instanceof AssociationClassEditPart) { + return getAssociationClassHideCommand(host); + } + return null; + } + + private Command getAssociationClassLinkHideCommand(GraphicalEditPart host) { + if (host.getSourceConnections() == null || host.getSourceConnections().isEmpty()) { + return null; + } + EditPart dashedLink = (EditPart) host.getSourceConnections().get(0); + if (false == dashedLink instanceof ConnectionEditPart) { + return null; + } + EditPart source = ((ConnectionEditPart) dashedLink).getTarget(); + if (source == null) { + return null; + } + return getHideCommand(source, dashedLink); + } + + private Command getAssociationClassHideCommand(GraphicalEditPart host) { + if (host.getTargetConnections() == null || host.getTargetConnections().isEmpty()) { + return null; + } + EditPart dashedLink = (EditPart) host.getTargetConnections().get(0); + if (false == dashedLink instanceof ConnectionEditPart) { + return null; + } + EditPart source = ((ConnectionEditPart) dashedLink).getSource(); + if (source == null) { + return null; + } + return getHideCommand(source, dashedLink); + } + + private Command getHideCommand(EditPart source, EditPart dashedLink) { + GroupRequest hideRequest = new GroupRequest(RequestConstants.REQ_DELETE); + List<EditPart> parts = new ArrayList<EditPart>(); + parts.add(dashedLink); + parts.add(source); + hideRequest.setEditParts(parts); + return getDeleteCommand(hideRequest); + } }
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/GeneralizationSetLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/GeneralizationSetLabelDisplayEditPolicy.java index 416264b2e57..90eec3eb390 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/GeneralizationSetLabelDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/GeneralizationSetLabelDisplayEditPolicy.java @@ -1,200 +1,200 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.AbstractEditPolicy;
-import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
-import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.GeneralizationEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.GeneralizationSetEditPart;
-import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * this policy allows displaying generalizationSet without label if it references the same semantic
- * element. It allows placing correctly anchors in this case
- */
-public class GeneralizationSetLabelDisplayEditPolicy extends AbstractEditPolicy implements NotificationListener, IPapyrusListener {
-
- /** stores the host associated semantic element */
- protected EObject hostSemanticElement;
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void activate() {
- View view = (View) getHost().getModel();
- hostSemanticElement = view.getElement();
- getDiagramEventBroker().addNotificationListener(view, this);
- getDiagramEventBroker().addNotificationListener(hostSemanticElement, this);
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void deactivate() {
- View view = (View) getHost().getModel();
- getDiagramEventBroker().removeNotificationListener(view, this);
- getDiagramEventBroker().removeNotificationListener(hostSemanticElement, this);
- // removes the reference to the semantic element
- hostSemanticElement = null;
- }
-
- /**
- *
- * @param editPart
- * @return
- */
- public Collection<GeneralizationSetEditPart> getAllSameSemanticGeneralizationSet(GeneralizationEditPart editPart) {
- // look for all Generalization set connected to the source location that reference the same
- // generalizationSet
- List<GeneralizationSetEditPart> result = new ArrayList<GeneralizationSetEditPart>();
- List<Object> linkList = new ArrayList<Object>();
- for (Object object : editPart.getSourceConnections()) {
- linkList.add(object);
- }
- for (Object object : editPart.getTargetConnections()) {
- linkList.add(object);
- }
- // remove reconnected link
- linkList.remove(getHost());
- // get the link that refer the same model element
-
- Iterator<Object> iterator = linkList.iterator();
- while (iterator.hasNext()) {
- Object currentObject = iterator.next();
- if (currentObject instanceof GeneralizationSetEditPart) {
- if (((GeneralizationSetEditPart) getHost()).resolveSemanticElement().equals(((GeneralizationSetEditPart) currentObject).resolveSemanticElement())) {
- result.add((GeneralizationSetEditPart) currentObject);
- }
- }
- }
- return result;
- }
-
- /**
- * Gets the diagram event broker from the editing domain.
- *
- * @return the diagram event broker
- */
- private DiagramEventBroker getDiagramEventBroker() {
- TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- if (theEditingDomain != null) {
- return DiagramEventBroker.getInstance(theEditingDomain);
- }
- return null;
- }
-
- /**
- *
- * {@inheritedDoc}
- */
- @Override
- public void notifyChanged(Notification notification) {
- if (getHost().getViewer() instanceof DiagramGraphicalViewer) {
- if (getHost() instanceof GeneralizationSetEditPart) {
- String elementID = EMFCoreUtil.getProxyID(((GeneralizationSetEditPart) getHost()).resolveSemanticElement());
- List<EditPart> editpartList = new ArrayList<EditPart>();
- for (Object object : ((DiagramGraphicalViewer) (getHost().getViewer())).findEditPartsForElement(elementID, GeneralizationSetEditPart.class)) {
- editpartList.add((EditPart) object);
- }
-
- if (editpartList.size() > 1 && editpartList.indexOf(getHost()) > 0) {
- try {
- ((IGraphicalEditPart) getHost()).getEditingDomain().runExclusive(new Runnable() {
-
- @Override
- public void run() {
- Display.getCurrent().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- for (int i = 0; i < getHost().getChildren().size(); i++) {
- SetRequest setRequest = new SetRequest((View) ((EditPart) getHost().getChildren().get(i)).getModel(), NotationPackage.eINSTANCE.getView_Visible(), false);
- SetValueCommand setValueCommand = new SetValueCommand(setRequest);
- ((IGraphicalEditPart) getHost()).getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(setValueCommand));
- // refresh();
- }
- }
- });
- }
- });
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
- }
- }
- if (notification.getNotifier() instanceof RelativeBendpoints) {
- try {
- ((IGraphicalEditPart) getHost()).getEditingDomain().runExclusive(new Runnable() {
-
- @Override
- public void run() {
- Display.getCurrent().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- if (getAllSameSemanticGeneralizationSet(((GeneralizationEditPart) ((GeneralizationSetEditPart) getHost()).getTarget())).size() != 0) {
- ReconnectRequest reconnectRequest = new ReconnectRequest();
- reconnectRequest.setType(RequestConstants.REQ_RECONNECT_TARGET);
- reconnectRequest.setConnectionEditPart(((GeneralizationSetEditPart) getHost()));
- reconnectRequest.setTargetEditPart(((GeneralizationSetEditPart) getHost()).getTarget());
- Command command = ((GeneralizationSetEditPart) getHost()).getTarget().getCommand(reconnectRequest);
- ((GeneralizationSetEditPart) getHost()).getDiagramEditDomain().getDiagramCommandStack().execute(command);
- }
- if (getAllSameSemanticGeneralizationSet(((GeneralizationEditPart) ((GeneralizationSetEditPart) getHost()).getSource())).size() != 0) {
- ReconnectRequest reconnectRequest = new ReconnectRequest();
- reconnectRequest.setType(RequestConstants.REQ_RECONNECT_SOURCE);
- reconnectRequest.setConnectionEditPart(((GeneralizationSetEditPart) getHost()));
- reconnectRequest.setTargetEditPart(((GeneralizationSetEditPart) getHost()).getSource());
- Command command = ((GeneralizationSetEditPart) getHost()).getSource().getCommand(reconnectRequest);
- ((GeneralizationSetEditPart) getHost()).getDiagramEditDomain().getDiagramCommandStack().execute(command);
- }
- }
- });
- }
- });
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.AbstractEditPolicy; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; +import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer; +import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; +import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.RelativeBendpoints; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.GeneralizationEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.GeneralizationSetEditPart; +import org.eclipse.papyrus.uml.diagram.common.Activator; +import org.eclipse.swt.widgets.Display; + +/** + * this policy allows displaying generalizationSet without label if it references the same semantic + * element. It allows placing correctly anchors in this case + */ +public class GeneralizationSetLabelDisplayEditPolicy extends AbstractEditPolicy implements NotificationListener, IPapyrusListener { + + /** stores the host associated semantic element */ + protected EObject hostSemanticElement; + + /** + * + * {@inheritDoc} + */ + @Override + public void activate() { + View view = (View) getHost().getModel(); + hostSemanticElement = view.getElement(); + getDiagramEventBroker().addNotificationListener(view, this); + getDiagramEventBroker().addNotificationListener(hostSemanticElement, this); + } + + /** + * + * {@inheritDoc} + */ + @Override + public void deactivate() { + View view = (View) getHost().getModel(); + getDiagramEventBroker().removeNotificationListener(view, this); + getDiagramEventBroker().removeNotificationListener(hostSemanticElement, this); + // removes the reference to the semantic element + hostSemanticElement = null; + } + + /** + * + * @param editPart + * @return + */ + public Collection<GeneralizationSetEditPart> getAllSameSemanticGeneralizationSet(GeneralizationEditPart editPart) { + // look for all Generalization set connected to the source location that reference the same + // generalizationSet + List<GeneralizationSetEditPart> result = new ArrayList<GeneralizationSetEditPart>(); + List<Object> linkList = new ArrayList<Object>(); + for (Object object : editPart.getSourceConnections()) { + linkList.add(object); + } + for (Object object : editPart.getTargetConnections()) { + linkList.add(object); + } + // remove reconnected link + linkList.remove(getHost()); + // get the link that refer the same model element + + Iterator<Object> iterator = linkList.iterator(); + while (iterator.hasNext()) { + Object currentObject = iterator.next(); + if (currentObject instanceof GeneralizationSetEditPart) { + if (((GeneralizationSetEditPart) getHost()).resolveSemanticElement().equals(((GeneralizationSetEditPart) currentObject).resolveSemanticElement())) { + result.add((GeneralizationSetEditPart) currentObject); + } + } + } + return result; + } + + /** + * Gets the diagram event broker from the editing domain. + * + * @return the diagram event broker + */ + private DiagramEventBroker getDiagramEventBroker() { + TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + if (theEditingDomain != null) { + return DiagramEventBroker.getInstance(theEditingDomain); + } + return null; + } + + /** + * + * {@inheritedDoc} + */ + @Override + public void notifyChanged(Notification notification) { + if (getHost().getViewer() instanceof DiagramGraphicalViewer) { + if (getHost() instanceof GeneralizationSetEditPart) { + String elementID = EMFCoreUtil.getProxyID(((GeneralizationSetEditPart) getHost()).resolveSemanticElement()); + List<EditPart> editpartList = new ArrayList<EditPart>(); + for (Object object : ((DiagramGraphicalViewer) (getHost().getViewer())).findEditPartsForElement(elementID, GeneralizationSetEditPart.class)) { + editpartList.add((EditPart) object); + } + + if (editpartList.size() > 1 && editpartList.indexOf(getHost()) > 0) { + try { + ((IGraphicalEditPart) getHost()).getEditingDomain().runExclusive(new Runnable() { + + @Override + public void run() { + Display.getCurrent().asyncExec(new Runnable() { + + @Override + public void run() { + for (int i = 0; i < getHost().getChildren().size(); i++) { + SetRequest setRequest = new SetRequest((View) ((EditPart) getHost().getChildren().get(i)).getModel(), NotationPackage.eINSTANCE.getView_Visible(), false); + SetValueCommand setValueCommand = new SetValueCommand(setRequest); + ((IGraphicalEditPart) getHost()).getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(setValueCommand)); + // refresh(); + } + } + }); + } + }); + } catch (Exception e) { + Activator.log.error(e); + } + } + } + } + if (notification.getNotifier() instanceof RelativeBendpoints) { + try { + ((IGraphicalEditPart) getHost()).getEditingDomain().runExclusive(new Runnable() { + + @Override + public void run() { + Display.getCurrent().asyncExec(new Runnable() { + + @Override + public void run() { + if (getAllSameSemanticGeneralizationSet(((GeneralizationEditPart) ((GeneralizationSetEditPart) getHost()).getTarget())).size() != 0) { + ReconnectRequest reconnectRequest = new ReconnectRequest(); + reconnectRequest.setType(RequestConstants.REQ_RECONNECT_TARGET); + reconnectRequest.setConnectionEditPart(((GeneralizationSetEditPart) getHost())); + reconnectRequest.setTargetEditPart(((GeneralizationSetEditPart) getHost()).getTarget()); + Command command = ((GeneralizationSetEditPart) getHost()).getTarget().getCommand(reconnectRequest); + ((GeneralizationSetEditPart) getHost()).getDiagramEditDomain().getDiagramCommandStack().execute(command); + } + if (getAllSameSemanticGeneralizationSet(((GeneralizationEditPart) ((GeneralizationSetEditPart) getHost()).getSource())).size() != 0) { + ReconnectRequest reconnectRequest = new ReconnectRequest(); + reconnectRequest.setType(RequestConstants.REQ_RECONNECT_SOURCE); + reconnectRequest.setConnectionEditPart(((GeneralizationSetEditPart) getHost())); + reconnectRequest.setTargetEditPart(((GeneralizationSetEditPart) getHost()).getSource()); + Command command = ((GeneralizationSetEditPart) getHost()).getSource().getCommand(reconnectRequest); + ((GeneralizationSetEditPart) getHost()).getDiagramEditDomain().getDiagramCommandStack().execute(command); + } + } + }); + } + }); + } catch (Exception e) { + Activator.log.error(e); + } + } + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/InstanceSpecificationNameLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/InstanceSpecificationNameLabelEditPolicy.java index 92bdc68452d..969afd74270 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/InstanceSpecificationNameLabelEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/InstanceSpecificationNameLabelEditPolicy.java @@ -1,144 +1,144 @@ -/*****************************************************************************
- * Copyright (c) 2010 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Nizar GUEDIDI (CEA LIST) - Update getUMLElement()
- *
- */
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
-import org.eclipse.papyrus.uml.tools.utils.InstanceSpecificationUtil;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.InstanceSpecification;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * The Class InstanceSpecificationNameLabelEditPolicy.
- */
-public class InstanceSpecificationNameLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- protected final Map<String, String> masks = new HashMap<String, String>();
-
- public InstanceSpecificationNameLabelEditPolicy() {
- super();
- masks.put(ICustomAppearance.DISP_NAME, "Name");
- masks.put(ICustomAppearance.DISP_TYPE, "Type");
- }
-
- @Override
- protected void addAdditionalListeners() {
- super.addAdditionalListeners();
- Iterator<Classifier> iterator = getUMLElement().getClassifiers().iterator();
- while (iterator.hasNext()) {
- Classifier type = iterator.next();
- getDiagramEventBroker().addNotificationListener(type, this);
- }
- }
-
- @Override
- public void deactivate() {
- if (getUMLElement() != null) {
- Iterator<Classifier> iterator = getUMLElement().getClassifiers().iterator();
- while (iterator.hasNext()) {
- Classifier type = iterator.next();
- getDiagramEventBroker().removeNotificationListener(type, this);
- }
- }
- super.deactivate();
- }
-
- @Override
- public InstanceSpecification getUMLElement() {
- EObject element = super.getUMLElement();
- if (element instanceof InstanceSpecification) {
- return (InstanceSpecification) element;
- }
- return null;
- }
-
- /**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy#getMasks()
- *
- * @return
- */
- @Override
- public Map<String, String> getMasks() {
- return masks;
- }
-
- @Override
- protected Collection<String> getDefaultDisplayValue() {
- return ICustomAppearance.DEFAULT_UML_INSTANCESPECIFICATION;
- }
-
- @Override
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
- // change the label of the figure managed by the host edit part (managed by the parent edit
- // part in general...)
- // it must be changed only if:
- // - the annotation corresponding to the display of the stereotype changes
- // - the stereotype application list has changed
- Object object = notification.getNotifier();
-
- if (notification.getEventType() == Notification.ADD) {
- if (UMLPackage.eINSTANCE.getInstanceSpecification_Classifier().equals(notification.getFeature())) {
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- }
- }
- if (notification.getEventType() == Notification.REMOVE) {
- if (UMLPackage.eINSTANCE.getInstanceSpecification_Classifier().equals(notification.getFeature())) {
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- }
- }
- if (object == null) {
- return;
- }
- if (UMLPackage.eINSTANCE.getNamedElement_Name().equals(notification.getFeature())) {
- refreshDisplay();
- return;
- } else if (UMLPackage.eINSTANCE.getInstanceSpecification_Classifier().equals(notification.getFeature())) {
- refreshDisplay();
- return;
- }
- if (isMaskManagedAnnotation(object)) {
- refreshDisplay();
- return;
- }
- if (isRemovedMaskManagedLabelAnnotation(object, notification)) {
- refreshDisplay();
- return;
- }
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#refreshDisplay()
- *
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- if (getUMLElement() != null) {
- ((WrappingLabel) ((GraphicalEditPart) getHost()).getFigure()).setText(InstanceSpecificationUtil.getCustomLabel(getUMLElement(), getCurrentDisplayValue()));
- ((WrappingLabel) ((GraphicalEditPart) getHost()).getFigure()).setTextUnderline(true);
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2010 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Nizar GUEDIDI (CEA LIST) - Update getUMLElement() + * + */ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy; +import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; +import org.eclipse.papyrus.uml.tools.utils.InstanceSpecificationUtil; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.InstanceSpecification; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * The Class InstanceSpecificationNameLabelEditPolicy. + */ +public class InstanceSpecificationNameLabelEditPolicy extends AbstractMaskManagedEditPolicy { + + protected final Map<String, String> masks = new HashMap<String, String>(); + + public InstanceSpecificationNameLabelEditPolicy() { + super(); + masks.put(ICustomAppearance.DISP_NAME, "Name"); + masks.put(ICustomAppearance.DISP_TYPE, "Type"); + } + + @Override + protected void addAdditionalListeners() { + super.addAdditionalListeners(); + Iterator<Classifier> iterator = getUMLElement().getClassifiers().iterator(); + while (iterator.hasNext()) { + Classifier type = iterator.next(); + getDiagramEventBroker().addNotificationListener(type, this); + } + } + + @Override + public void deactivate() { + if (getUMLElement() != null) { + Iterator<Classifier> iterator = getUMLElement().getClassifiers().iterator(); + while (iterator.hasNext()) { + Classifier type = iterator.next(); + getDiagramEventBroker().removeNotificationListener(type, this); + } + } + super.deactivate(); + } + + @Override + public InstanceSpecification getUMLElement() { + EObject element = super.getUMLElement(); + if (element instanceof InstanceSpecification) { + return (InstanceSpecification) element; + } + return null; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy#getMasks() + * + * @return + */ + @Override + public Map<String, String> getMasks() { + return masks; + } + + @Override + protected Collection<String> getDefaultDisplayValue() { + return ICustomAppearance.DEFAULT_UML_INSTANCESPECIFICATION; + } + + @Override + public void notifyChanged(Notification notification) { + super.notifyChanged(notification); + // change the label of the figure managed by the host edit part (managed by the parent edit + // part in general...) + // it must be changed only if: + // - the annotation corresponding to the display of the stereotype changes + // - the stereotype application list has changed + Object object = notification.getNotifier(); + + if (notification.getEventType() == Notification.ADD) { + if (UMLPackage.eINSTANCE.getInstanceSpecification_Classifier().equals(notification.getFeature())) { + getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this); + } + } + if (notification.getEventType() == Notification.REMOVE) { + if (UMLPackage.eINSTANCE.getInstanceSpecification_Classifier().equals(notification.getFeature())) { + getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this); + } + } + if (object == null) { + return; + } + if (UMLPackage.eINSTANCE.getNamedElement_Name().equals(notification.getFeature())) { + refreshDisplay(); + return; + } else if (UMLPackage.eINSTANCE.getInstanceSpecification_Classifier().equals(notification.getFeature())) { + refreshDisplay(); + return; + } + if (isMaskManagedAnnotation(object)) { + refreshDisplay(); + return; + } + if (isRemovedMaskManagedLabelAnnotation(object, notification)) { + refreshDisplay(); + return; + } + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#refreshDisplay() + * + */ + @Override + public void refreshDisplay() { + // calls the helper for this edit Part + if (getUMLElement() != null) { + ((WrappingLabel) ((GraphicalEditPart) getHost()).getFigure()).setText(InstanceSpecificationUtil.getCustomLabel(getUMLElement(), getCurrentDisplayValue())); + ((WrappingLabel) ((GraphicalEditPart) getHost()).getFigure()).setTextUnderline(true); + } + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedClazzCompartmentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedClazzCompartmentCreationEditPolicy.java index a6de4178eff..8a9b7a26d9b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedClazzCompartmentCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedClazzCompartmentCreationEditPolicy.java @@ -1,107 +1,107 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Arthur Daussy (Atos) arthur.daussy@atos.net - Bug 249786: [General] drag'n'drop does not work for elements stored in nested classifier compartment
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
-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.EditCommandRequestWrapper;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.command.CreateUniqueViewCommand;
-import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
-
-/**
- * The Class ClazzCompartmentCreationEditPolicy overload the creation editpolicy in order to manage correctly the drop of a class into a class
- */
-public class NestedClazzCompartmentCreationEditPolicy extends DefaultCreationEditPolicy {
-
- /**
- *
- * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getReparentCommand(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)
- *
- * @param gep
- * @return
- */
- @Override
- protected ICommand getReparentCommand(IGraphicalEditPart gep) {
- CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label);
- View container = (View) getHost().getModel();
- EObject context = ViewUtil.resolveSemanticElement(container);
- View view = (View) gep.getModel();
- EObject element = ViewUtil.resolveSemanticElement(view);
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- // graphical Deletion
- Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
- cc.compose(new CommandProxy(gep.getCommand(deleteViewRequest)));
- // semantic reparent
- if (element != null) {
- Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(new MoveRequest(editingDomain, context, element)));
- if (moveSemanticCmd == null) {
- return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
- }
- cc.compose(new CommandProxy(moveSemanticCmd));
- }
- // drop of the object
- IAdaptable elementAdapter = new EObjectAdapter(element);
- String nodeVISUALID = UMLVisualIDRegistry.getNodeVisualID(((View) getHost().getModel()), element);
- // If none then the node can node be create
- if (nodeVISUALID == null || nodeVISUALID.isEmpty()) {
- cc.compose(UnexecutableCommand.INSTANCE);
- } else {
- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType) UMLElementTypes.getElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, true, ((GraphicalEditPart) getHost()).getDiagramPreferencesHint());
- CreateCommand createCommand = new CreateUniqueViewCommand(editingDomain, descriptor, ((View) (getHost().getModel())));
- cc.compose(createCommand);
- }
- return cc;
- }
-
- @Override
- protected Command getCreateCommand(CreateViewRequest request) {
- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- CompositeTransactionalCommand cc = new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label);
- Iterator<? extends org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor> descriptors = request.getViewDescriptors().iterator();
- while (descriptors.hasNext()) {
- CreateViewRequest.ViewDescriptor descriptor = descriptors.next();
- CreateCommand createCommand = new CreateUniqueViewCommand(editingDomain, descriptor, (View) (getHost().getModel()));
- createCommand.setLabel("custoCreateCommand");
- cc.compose(createCommand);
- }
- return new ICommandProxy(cc.reduce());
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Arthur Daussy (Atos) arthur.daussy@atos.net - Bug 249786: [General] drag'n'drop does not work for elements stored in nested classifier compartment + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.Iterator; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.requests.GroupRequest; +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; +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.EditCommandRequestWrapper; +import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.emf.type.core.IHintedType; +import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; +import org.eclipse.papyrus.uml.diagram.clazz.custom.command.CreateUniqueViewCommand; +import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry; +import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes; + +/** + * The Class ClazzCompartmentCreationEditPolicy overload the creation editpolicy in order to manage correctly the drop of a class into a class + */ +public class NestedClazzCompartmentCreationEditPolicy extends DefaultCreationEditPolicy { + + /** + * + * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getReparentCommand(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) + * + * @param gep + * @return + */ + @Override + protected ICommand getReparentCommand(IGraphicalEditPart gep) { + CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label); + View container = (View) getHost().getModel(); + EObject context = ViewUtil.resolveSemanticElement(container); + View view = (View) gep.getModel(); + EObject element = ViewUtil.resolveSemanticElement(view); + TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + // graphical Deletion + Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE); + cc.compose(new CommandProxy(gep.getCommand(deleteViewRequest))); + // semantic reparent + if (element != null) { + Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(new MoveRequest(editingDomain, context, element))); + if (moveSemanticCmd == null) { + return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; + } + cc.compose(new CommandProxy(moveSemanticCmd)); + } + // drop of the object + IAdaptable elementAdapter = new EObjectAdapter(element); + String nodeVISUALID = UMLVisualIDRegistry.getNodeVisualID(((View) getHost().getModel()), element); + // If none then the node can node be create + if (nodeVISUALID == null || nodeVISUALID.isEmpty()) { + cc.compose(UnexecutableCommand.INSTANCE); + } else { + ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType) UMLElementTypes.getElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, true, ((GraphicalEditPart) getHost()).getDiagramPreferencesHint()); + CreateCommand createCommand = new CreateUniqueViewCommand(editingDomain, descriptor, ((View) (getHost().getModel()))); + cc.compose(createCommand); + } + return cc; + } + + @Override + protected Command getCreateCommand(CreateViewRequest request) { + TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + CompositeTransactionalCommand cc = new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label); + Iterator<? extends org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor> descriptors = request.getViewDescriptors().iterator(); + while (descriptors.hasNext()) { + CreateViewRequest.ViewDescriptor descriptor = descriptors.next(); + CreateCommand createCommand = new CreateUniqueViewCommand(editingDomain, descriptor, (View) (getHost().getModel())); + createCommand.setLabel("custoCreateCommand"); + cc.compose(createCommand); + } + return new ICommandProxy(cc.reduce()); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedLabelMaskManagedEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedLabelMaskManagedEditPolicy.java index 2a8a3c14ba7..e57ec551b38 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedLabelMaskManagedEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/NestedLabelMaskManagedEditPolicy.java @@ -1,46 +1,46 @@ -package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.NestedStereotypeLabelHelper;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-
-/**
- *
- *
- */
-public class NestedLabelMaskManagedEditPolicy extends AbstractMaskManagedEditPolicy {
-
- /**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy#getMasks()
- *
- * @return
- */
- @Override
- public Map<String, String> getMasks() {
- return Collections.emptyMap();
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#refreshDisplay()
- *
- */
- @Override
- public void refreshDisplay() {
- NestedStereotypeLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#getDefaultDisplayValue()
- *
- * @return
- */
- @Override
- protected Collection<String> getDefaultDisplayValue() {
- return Collections.emptyList();
- }
-
-}
+package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.NestedStereotypeLabelHelper; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy; + +/** + * + * + */ +public class NestedLabelMaskManagedEditPolicy extends AbstractMaskManagedEditPolicy { + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy#getMasks() + * + * @return + */ + @Override + public Map<String, String> getMasks() { + return Collections.emptyMap(); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#refreshDisplay() + * + */ + @Override + public void refreshDisplay() { + NestedStereotypeLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#getDefaultDisplayValue() + * + * @return + */ + @Override + protected Collection<String> getDefaultDisplayValue() { + return Collections.emptyList(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/RemoveOrphanViewPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/RemoveOrphanViewPolicy.java index c845e5006e2..01cbcec0c59 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/RemoveOrphanViewPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/RemoveOrphanViewPolicy.java @@ -1,115 +1,115 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassNestedClassifierCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentNestedClassifierCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentNestedClassifierCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InstanceSpecificationSlotCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InstanceSpecificationSlotCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceNestedClassifierCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceNestedClassifierCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelPackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelPackageableElementCompartmentEditPartTN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackagePackageableElementCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackagePackageableElementCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeOperationCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeOperationCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.RedefinableTemplateSignatureTemplateParameterCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalAttributeCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalAttributeCompartmentEditPartCN;
-import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.TemplateSignatureTemplateParameterCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.OrphanViewPolicy;
-
-/**
- * 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 in clazzdiagram
- *
- */
-public class RemoveOrphanViewPolicy extends OrphanViewPolicy {
-
- public String[] notOrphanNode = {
- AssociationClassAttributeCompartmentEditPart.VISUAL_ID,
- AssociationClassNestedClassifierCompartmentEditPart.VISUAL_ID,
- AssociationClassOperationCompartmentEditPart.VISUAL_ID,
- ClassAttributeCompartmentEditPart.VISUAL_ID,
- ClassAttributeCompartmentEditPartCN.VISUAL_ID,
- ClassNestedClassifierCompartmentEditPart.VISUAL_ID,
- ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID,
- ClassOperationCompartmentEditPart.VISUAL_ID,
- ClassOperationCompartmentEditPartCN.VISUAL_ID,
- ComponentAttributeCompartmentEditPart.VISUAL_ID,
- ComponentAttributeCompartmentEditPartCN.VISUAL_ID,
- ComponentNestedClassifierCompartmentEditPart.VISUAL_ID,
- ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID,
- ComponentOperationCompartmentEditPart.VISUAL_ID,
- ComponentOperationCompartmentEditPartCN.VISUAL_ID,
- DataTypeAttributeCompartmentEditPart.VISUAL_ID,
- DataTypeAttributeCompartmentEditPartCN.VISUAL_ID,
- DataTypeOperationCompartmentEditPart.VISUAL_ID,
- DataTypeOperationCompartmentEditPartCN.VISUAL_ID,
- EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID,
- EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID,
- InstanceSpecificationSlotCompartmentEditPart.VISUAL_ID,
- InstanceSpecificationSlotCompartmentEditPartCN.VISUAL_ID,
- InterfaceAttributeCompartmentEditPart.VISUAL_ID,
- InterfaceAttributeCompartmentEditPartCN.VISUAL_ID,
- InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID,
- InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID,
- InterfaceOperationCompartmentEditPart.VISUAL_ID,
- InterfaceOperationCompartmentEditPartCN.VISUAL_ID,
- ModelPackageableElementCompartmentEditPartCN.VISUAL_ID,
- ModelPackageableElementCompartmentEditPartTN.VISUAL_ID,
- PackagePackageableElementCompartmentEditPart.VISUAL_ID,
- PackagePackageableElementCompartmentEditPartCN.VISUAL_ID,
- PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID,
- PrimitiveTypeAttributeCompartmentEditPartCN.VISUAL_ID,
- PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID,
- PrimitiveTypeOperationCompartmentEditPartCN.VISUAL_ID,
- RedefinableTemplateSignatureTemplateParameterCompartmentEditPart.VISUAL_ID,
- SignalAttributeCompartmentEditPart.VISUAL_ID,
- SignalAttributeCompartmentEditPartCN.VISUAL_ID,
- TemplateSignatureTemplateParameterCompartmentEditPart.VISUAL_ID,
- };
-
- public RemoveOrphanViewPolicy() {
- super();
- init(notOrphanNode);
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 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: + * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassAttributeCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassNestedClassifierCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationClassOperationCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassAttributeCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassAttributeCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentAttributeCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentAttributeCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentNestedClassifierCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentNestedClassifierCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentOperationCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentOperationCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeAttributeCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeAttributeCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeOperationCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DataTypeOperationCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationEnumerationLiteralCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationEnumerationLiteralCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InstanceSpecificationSlotCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InstanceSpecificationSlotCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceAttributeCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceAttributeCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceNestedClassifierCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceNestedClassifierCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceOperationCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.InterfaceOperationCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelPackageableElementCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ModelPackageableElementCompartmentEditPartTN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackagePackageableElementCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackagePackageableElementCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeAttributeCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeAttributeCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeOperationCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PrimitiveTypeOperationCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.RedefinableTemplateSignatureTemplateParameterCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalAttributeCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.SignalAttributeCompartmentEditPartCN; +import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.TemplateSignatureTemplateParameterCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.OrphanViewPolicy; + +/** + * 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 in clazzdiagram + * + */ +public class RemoveOrphanViewPolicy extends OrphanViewPolicy { + + public String[] notOrphanNode = { + AssociationClassAttributeCompartmentEditPart.VISUAL_ID, + AssociationClassNestedClassifierCompartmentEditPart.VISUAL_ID, + AssociationClassOperationCompartmentEditPart.VISUAL_ID, + ClassAttributeCompartmentEditPart.VISUAL_ID, + ClassAttributeCompartmentEditPartCN.VISUAL_ID, + ClassNestedClassifierCompartmentEditPart.VISUAL_ID, + ClassNestedClassifierCompartmentEditPartCN.VISUAL_ID, + ClassOperationCompartmentEditPart.VISUAL_ID, + ClassOperationCompartmentEditPartCN.VISUAL_ID, + ComponentAttributeCompartmentEditPart.VISUAL_ID, + ComponentAttributeCompartmentEditPartCN.VISUAL_ID, + ComponentNestedClassifierCompartmentEditPart.VISUAL_ID, + ComponentNestedClassifierCompartmentEditPartCN.VISUAL_ID, + ComponentOperationCompartmentEditPart.VISUAL_ID, + ComponentOperationCompartmentEditPartCN.VISUAL_ID, + DataTypeAttributeCompartmentEditPart.VISUAL_ID, + DataTypeAttributeCompartmentEditPartCN.VISUAL_ID, + DataTypeOperationCompartmentEditPart.VISUAL_ID, + DataTypeOperationCompartmentEditPartCN.VISUAL_ID, + EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID, + EnumerationEnumerationLiteralCompartmentEditPartCN.VISUAL_ID, + InstanceSpecificationSlotCompartmentEditPart.VISUAL_ID, + InstanceSpecificationSlotCompartmentEditPartCN.VISUAL_ID, + InterfaceAttributeCompartmentEditPart.VISUAL_ID, + InterfaceAttributeCompartmentEditPartCN.VISUAL_ID, + InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID, + InterfaceNestedClassifierCompartmentEditPartCN.VISUAL_ID, + InterfaceOperationCompartmentEditPart.VISUAL_ID, + InterfaceOperationCompartmentEditPartCN.VISUAL_ID, + ModelPackageableElementCompartmentEditPartCN.VISUAL_ID, + ModelPackageableElementCompartmentEditPartTN.VISUAL_ID, + PackagePackageableElementCompartmentEditPart.VISUAL_ID, + PackagePackageableElementCompartmentEditPartCN.VISUAL_ID, + PrimitiveTypeAttributeCompartmentEditPart.VISUAL_ID, + PrimitiveTypeAttributeCompartmentEditPartCN.VISUAL_ID, + PrimitiveTypeOperationCompartmentEditPart.VISUAL_ID, + PrimitiveTypeOperationCompartmentEditPartCN.VISUAL_ID, + RedefinableTemplateSignatureTemplateParameterCompartmentEditPart.VISUAL_ID, + SignalAttributeCompartmentEditPart.VISUAL_ID, + SignalAttributeCompartmentEditPartCN.VISUAL_ID, + TemplateSignatureTemplateParameterCompartmentEditPart.VISUAL_ID, + }; + + public RemoveOrphanViewPolicy() { + super(); + init(notOrphanNode); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ShowHideRelatedLinkEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ShowHideRelatedLinkEditPolicy.java index 1012c78ddc8..20f57605cdc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ShowHideRelatedLinkEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ShowHideRelatedLinkEditPolicy.java @@ -1,60 +1,60 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
-
-import org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure;
-import org.eclipse.papyrus.infra.gmfdiag.common.updater.DiagramUpdater;
-import org.eclipse.papyrus.uml.diagram.clazz.custom.edit.part.CustomUMLDiagramUpdater;
-import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractUMLShowHideRelatedLinkEditPolicy;
-
-/**
- * Show Hide link editpolicy for Class Diagram
- *
- *
- */
-public class ShowHideRelatedLinkEditPolicy extends AbstractUMLShowHideRelatedLinkEditPolicy {
-
- /**
- *
- * Constructor.
- *
- * @param host
- */
- public ShowHideRelatedLinkEditPolicy() {
- super();
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public DiagramUpdater getDiagramUpdater() {
- return CustomUMLDiagramUpdater.INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IDiagramInformationProviderEditPolicy#getDiagramStructure()
- *
- * @return
- */
-
- @Override
- public DiagramStructure getDiagramStructure() {
- return UMLVisualIDRegistry.TYPED_INSTANCE;
- }
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.clazz.custom.policies; + +import org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure; +import org.eclipse.papyrus.infra.gmfdiag.common.updater.DiagramUpdater; +import org.eclipse.papyrus.uml.diagram.clazz.custom.edit.part.CustomUMLDiagramUpdater; +import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractUMLShowHideRelatedLinkEditPolicy; + +/** + * Show Hide link editpolicy for Class Diagram + * + * + */ +public class ShowHideRelatedLinkEditPolicy extends AbstractUMLShowHideRelatedLinkEditPolicy { + + /** + * + * Constructor. + * + * @param host + */ + public ShowHideRelatedLinkEditPolicy() { + super(); + } + + + /** + * {@inheritDoc} + */ + @Override + public DiagramUpdater getDiagramUpdater() { + return CustomUMLDiagramUpdater.INSTANCE; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IDiagramInformationProviderEditPolicy#getDiagramStructure() + * + * @return + */ + + @Override + public DiagramStructure getDiagramStructure() { + return UMLVisualIDRegistry.TYPED_INSTANCE; + } +} |