Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2016-09-26 04:48:41 -0400
committerBenoit Maggi2016-09-29 08:31:53 -0400
commit52b6db0337e4d0a91de8001283ae5622921dd2c0 (patch)
treea61d2d1029d6329a83c121768c33e6473bf47bc0 /plugins
parent139b053a5b429bbaf012f44a3ec6088698054fde (diff)
downloadorg.eclipse.papyrus-52b6db0337e4d0a91de8001283ae5622921dd2c0.tar.gz
org.eclipse.papyrus-52b6db0337e4d0a91de8001283ae5622921dd2c0.tar.xz
org.eclipse.papyrus-52b6db0337e4d0a91de8001283ae5622921dd2c0.zip
Bug 501701 - [Composite] Showing nested port on Full Port fails
- show/hide innerport - allow drop for inner port - port always at the top-left Change-Id: I57f4459cc1cb815bf8230db3d7a2bacce0d24d88 Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java58
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/ShowHideContentsAction.java384
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShowHideClassifierContentsEditPolicy.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/parts/ResizablePortEditPart.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/ShowHideCompositeContentsEditPolicy.java42
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/PortToTypesPortDropStrategy.java114
8 files changed, 256 insertions, 374 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java
index 901176f5ca0..9587b2c2cce 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/AbstractShowHideAction.java
@@ -13,20 +13,6 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.actions;
-/*****************************************************************************
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
import java.util.ArrayList;
import java.util.List;
@@ -615,48 +601,4 @@ public abstract class AbstractShowHideAction implements IActionDelegate, IWorkbe
return editorLabelProvider.getImage(element);
}
}
-
- // /**
- // *
- // * EditorLabelProvider for the {@link CheckedTreeSelectionDialog}
- // *
- // */
- // public class CustomEditorLabelProvider extends EditorLabelProvider {
- //
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // public Image getImage(Object element) {
- // if(element instanceof EditPartRepresentation) {
- // element = ((EditPartRepresentation)element).getSemanticElement();
- // }
- // return super.getImage(element);
- // }
- //
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // public String getText(Object element) {
- // if(element instanceof CompartmentEditPartRepresentation) {
- // return ((CompartmentEditPartRepresentation)element).getCompartmentName();
- // } else if(element instanceof EditPartRepresentation) {
- // EObject semanticElement = ((EditPartRepresentation)element).getSemanticElement();
- // if(isElementInherited((EditPartRepresentation)element)) {
- // StringBuffer buffer = new StringBuffer();
- // buffer.append(super.getText(semanticElement));
- // buffer.append(" ");
- // buffer.append("(from ");
- // buffer.append(super.getText(((EditPartRepresentation)element).getSemanticElement().eContainer()));
- // buffer.append(")");
- // return buffer.toString();
- // } else {
- // return super.getText(semanticElement);
- // }
- // }
- // return super.getText(element);
- // }
- // }
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/ShowHideContentsAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/ShowHideContentsAction.java
index b233640dca1..17446b142e3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/ShowHideContentsAction.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/actions/ShowHideContentsAction.java
@@ -9,7 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Benoit maggi (CEA LIST) benoit.maggi@cea.fr -#501701 Showing nested port on Port
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.actions;
@@ -55,6 +55,7 @@ import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Type;
/**
@@ -116,6 +117,14 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
if (element instanceof Classifier || element instanceof InstanceSpecification) {
this.representations.add(new RootEditPartRepresentation(current, element));
}
+ if (element instanceof Port ) {
+ Port port = (Port) element;
+ Type type = port.getType();
+ if (type instanceof Classifier || type instanceof InstanceSpecification) {
+ RootEditPartRepresentation e = new RootEditPartRepresentation(current, element);
+ this.representations.add(e);
+ }
+ }
}
// this.setEditorLabelProvider(new CustomEditorLabelProvider());
this.setContentProvider(new ContentProvider());
@@ -300,32 +309,6 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
return null;
}
- // /**
- // * Return the EditPart owning the Object or <code>null</code>
- // *
- // * @param obj
- // * @return the EditPart owning the Object or <code>null</code>
- // */
- // protected EditPart findEditPart(EditPartRepresentation obj) {
- // EditPart ep = null;
- // EditPart parentEditPart = obj.getParentRepresentation().getRepresentedEditPart();
- // for(Object child : parentEditPart.getChildren()) {
- // EditPart child = (EditPart)child;
- // }
- //
- // Iterator<EditPartRepresentation> it = representations.iterator();
- //
- // while(ep == null && it.hasNext()) {
- // List<EditPart> children = getChildrenEditPart(it.next().getRepresentedEditPart());
- // for(EditPart editPart : children) {
- // if(((View)editPart.getModel()).getElement() == obj) {
- // return editPart;
- // }
- // }
- // }
- // return null;
- // }
-
/**
* {@inheritDoc}
*/
@@ -485,52 +468,10 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
*/
@Override
public Object[] getChildren(Object parentElement) {
- // if(parentElement instanceof RootEditPartRepresentation) {
- // RootEditPartRepresentation parentRepresentation = (RootEditPartRepresentation)parentElement;
- // return parentRepresentation.getPossibleElement().toArray();
- // } else if(parentElement instanceof CompartmentEditPartRepresentation) {
- // CompartmentEditPartRepresentation compartmentRepresentation = (CompartmentEditPartRepresentation)parentElement;
- // return compartmentRepresentation.getPossibleElement().toArray();
- // }
if (parentElement instanceof EditPartRepresentation) {
return ((EditPartRepresentation) parentElement).getPossibleElement().toArray();
}
return new Object[0];
-
-
- // // in case of parent is the main edit part => returns all compartment
- // // if this is a compartment, returns all members that can be displayed
- // if(parentElement instanceof CompartmentEditPartRepresentation) {
- // CompartmentEditPartRepresentation compartmentRepresentation = (CompartmentEditPartRepresentation)parentElement;
- //
- // // case parent is a compartment edit part
- // EObject myClassifier = compartmentRepresentation.getUMLElement();
- // if(myClassifier instanceof Classifier) {
- // // returns all members that can be displayed in this compartment
- // List<NamedElement> members = new ArrayList<NamedElement>();
- // EList<NamedElement> localMembers = ((Classifier)myClassifier).getOwnedMembers();
- // for(NamedElement namedElement : localMembers) {
- // if(((EditPartRepresentation)parentElement).getPossibleElement().contains(namedElement)) {
- // members.add(namedElement);
- // }
- // }
- // Collections.sort(members, new CustomComparator(members));
- // return members.toArray();
- // }
- // } else if(parentElement instanceof EditPartRepresentation) {// case parent is the main edit part
- // EditPartRepresentation parentRepresentation = (EditPartRepresentation)parentElement;
- // Element element = parentRepresentation.getUMLElement();
- // if(element instanceof Classifier) {
- // List<CompartmentEditPartRepresentation> compartmentRepresentations = new ArrayList<CompartmentEditPartRepresentation>();
- // List<IResizableCompartmentEditPart> compartmentEditParts = CompartmentUtils.getAllCompartmentsEditPart(parentRepresentation.getRepresentedEditPart(), false);
- // for(IResizableCompartmentEditPart currentEditPart : compartmentEditParts) {
- // CompartmentEditPartRepresentation representation = new CompartmentEditPartRepresentation(currentEditPart, (Classifier)element);
- // compartmentRepresentations.add(representation);
- // }
- // return compartmentRepresentations.toArray();
- // }
- // }
- // return new Object[]{};
}
/**
@@ -543,22 +484,6 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
return editPartRepresentation.getParentRepresentation();
}
- // if(!(element instanceof EditPartRepresentation)) {
- // EditPartRepresentation rep = findEditPartRepresentation(element);
- // if(rep != null) {
- //
- // Classifier classifier = (Classifier)(rep).getUMLElement();
- // if(classifier.getOwnedMembers().contains(element)) {
- // return rep;
- // } else {
- // // for(ClassifierRepresentation classRep : ((CustomEditPartRepresentation)rep).getSuperClasses()) {
- // // if(classRep.ownsElement(element)) {
- // // return classRep;
- // // }
- // // }
- // }
- // }
- // }
return null;
}
@@ -599,18 +524,24 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
protected void initRepresentation() {
super.initRepresentation();
- List<IResizableCompartmentEditPart> compartmentEditParts = CompartmentUtils.getAllCompartmentsEditPart(getRepresentedEditPart(), false);
+ IGraphicalEditPart representedEditPart = getRepresentedEditPart();
+ List<IResizableCompartmentEditPart> compartmentEditParts = CompartmentUtils.getAllCompartmentsEditPart(representedEditPart, false);
for (IResizableCompartmentEditPart currentEditPart : compartmentEditParts) {
CompartmentEditPartRepresentation representation = new CompartmentEditPartRepresentation(currentEditPart, getSemanticElement(), this);
elementsToSelect.add(representation);
}
// check if the element has a affixed child edit policy => will be treated as a compartment
- EditPolicy policy = getRepresentedEditPart().getEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE);
+ EditPolicy policy = representedEditPart.getEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE);
if (policy != null) {
+ EditPartRepresentation representation;
// there can be some affixed children, create a pseudo compartment edit part representation
- AffixedChildrenEditPartRepresentation representation = new AffixedChildrenEditPartRepresentation(getSemanticElement(), this);
- elementsToSelect.add(representation);
+ if (getSemanticElement() instanceof Port){
+ representation = new PortAffixedChildrenEditPartRepresentation(getSemanticElement(), this);
+ }else {
+ representation = new AffixedChildrenEditPartRepresentation(getSemanticElement(), this);
+ }
+ elementsToSelect.add(representation);
}
}
}
@@ -634,19 +565,6 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
super(compartmentEditPart, element, parentRepresentation);
}
- // /**
- // * Returns the title of the compartment
- // *
- // * @return the title of the compartment
- // */
- // public String getCompartmentName() {
- // if(getRepresentedEditPart() instanceof IResizableCompartmentEditPart) {
- // return ((IResizableCompartmentEditPart)getRepresentedEditPart()).getCompartmentName();
- // }
- // // this is not a compartment, but the virtual placeholder for border items
- // return "Not a Compartment";
- // }
-
/**
* {@inheritDoc}
*/
@@ -750,11 +668,8 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
protected boolean canContain(Element element) {
TransactionalEditingDomain domain = getParentRepresentation().getRepresentedEditPart().getEditingDomain();
ViewDescriptor viewDescriptor = new ViewDescriptor(new EObjectAdapter(element), Node.class, null, ViewUtil.APPEND, false, getParentRepresentation().getRepresentedEditPart().getDiagramPreferencesHint());
-
CreateCommand cmd = new CreateCommand(domain, viewDescriptor, getParentRepresentation().getRepresentedEditPart().getNotationView());
return (cmd.canExecute());
-
- // return super.canContain(namedElement);
}
/**
@@ -808,11 +723,63 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
}
}
-
-
}
/**
+ * Specific edit part representation for edit part that can display InnerPort affixed children. It extends {@link AffixedChildrenEditPartRepresentation}
+ */
+ protected class PortAffixedChildrenEditPartRepresentation extends AffixedChildrenEditPartRepresentation {
+
+ /**
+ * Constructor.
+ *
+ * @param element
+ * @param parentRepresentation
+ */
+ public PortAffixedChildrenEditPartRepresentation(EObject element, EditPartRepresentation parentRepresentation) {
+ super(element, parentRepresentation);
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.actions.ShowHideContentsAction.CompartmentEditPartRepresentation#collectMembers()
+ *
+ * @return
+ */
+ @Override
+ protected List<Element> collectMembers() {
+ List<Element> res = new ArrayList<Element>();
+ EObject semanticElement = getSemanticElement();
+ if (semanticElement instanceof Port) {
+ Port port = (Port) semanticElement;
+ Type type = port.getType();
+ if (type != null){
+ EList<Element> allOwnedElements = type.allOwnedElements();
+ for (Element element : allOwnedElements) {
+ if (element instanceof Port) {
+ res.add(element);
+ }
+ }
+ return res;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean canContain(Element element) {
+ TransactionalEditingDomain domain = getParentRepresentation().getRepresentedEditPart().getEditingDomain();
+ ViewDescriptor viewDescriptor = new ViewDescriptor(new EObjectAdapter(element), Node.class, "Port_Shape", ViewUtil.APPEND, false, getParentRepresentation().getRepresentedEditPart().getDiagramPreferencesHint());
+ CreateCommand cmd = new CreateCommand(domain, viewDescriptor, getParentRepresentation().getRepresentedEditPart().getNotationView());
+ return (cmd.canExecute());
+ }
+
+ }
+
+ /**
* Class that manages an element that can not be displayed currently
*/
protected class OptionalEditPartRepresentation extends EditPartRepresentation {
@@ -840,207 +807,4 @@ public class ShowHideContentsAction extends AbstractShowHideAction implements IA
}
}
-
- // /**
- // * The custom EditPartRepresentation for this action
- // */
- // protected class CustomEditPartRepresentation extends EditPartRepresentation {
- //
- // /**
- // * this list contains the representation of all classifiers which are
- // * superclass of the classifier represented by EditPartRepresentaiton
- // */
- // protected List<ClassifierRepresentation> superClasses;
- //
- // /**
- // *
- // * Constructor.
- // *
- // * @param representedEditPart
- // * the edit part managing the classifier
- // * @param classifier
- // * the classifier for which display is customized
- // */
- // public CustomEditPartRepresentation(EditPart representedEditPart, Classifier classifier) {
- // super(representedEditPart, classifier);
- // }
- //
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // protected void initRepresentation() {
- // super.initRepresentation();
- // this.superClasses = new ArrayList<ShowHideContentsAction.ClassifierRepresentation>();
- // if(this.UMLElement instanceof Classifier) {
- // EList<Classifier> parents = ((Classifier)UMLElement).allParents();
- // for(Classifier classifier : parents) {
- // superClasses.add(new ClassifierRepresentation(classifier, this));
- // }
- //
- // /*
- // * build the list of the elements to select we suggest only the
- // * elements which can be displayed in the shown compartments
- // */
- // EList<NamedElement> members = ((Classifier)UMLElement).getMembers();
- // for(NamedElement namedElement : members) {
- // View compartment = getCompartmentForCreation(this.representedEditPart, namedElement);
- // if(compartment != null) {
- // this.elementsToSelect.add(namedElement);
- //
- // // build the initial selection
- // EList<?> childrenView = compartment.getVisibleChildren();
- // for(Object object : childrenView) {
- // if(object instanceof View) {
- // if(((View)object).getElement() == namedElement) {
- // this.initialSelection.add(namedElement);
- // break;
- // }
- // }
- // }
- // }
- // }
- // }
- // }
- //
- // /**
- // *
- // * @return a list containing the {@link ClassifierRepresentation} for
- // * each superclass of the {@link #representedEditPart}
- // */
- // public List<ClassifierRepresentation> getSuperClasses() {
- // return this.superClasses;
- // }
- //
- // }
-
- // /**
- // * Extends the edit part representation only for compartments edit part
- // */
- // protected class CompartmentEditPartRepresentation extends EditPartRepresentation {
- //
- // /**
- // * Constructor.
- // *
- // * @param compartmentEditPart
- // * the compartment edit part represented
- // * @param umlElement
- // * the uml element for which the compartment is displayed
- // */
- // public CompartmentEditPartRepresentation(IResizableCompartmentEditPart compartmentEditPart, Classifier umlElement) {
- // super(compartmentEditPart, umlElement);
- // }
- //
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // public IResizableCompartmentEditPart getRepresentedEditPart() {
- // return (IResizableCompartmentEditPart)super.getRepresentedEditPart();
- // }
- //
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // public Classifier getUMLElement() {
- // return (Classifier)super.getUMLElement();
- // }
- //
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // protected void initRepresentation() {
- // // call super first
- // super.initRepresentation();
- //
- // EList<NamedElement> members = getUMLElement().getMembers();
- // for(NamedElement namedElement : members) {
- // if(canContain(namedElement)) {
- // this.elementsToSelect.add(namedElement);
- // // build the initial selection
- // EList<?> childrenView = getRepresentedEditPart().getNotationView().getVisibleChildren();
- // for(Object object : childrenView) {
- // if(object instanceof View) {
- // if(((View)object).getElement() == namedElement) {
- // this.initialSelection.add(namedElement);
- // break;
- // }
- // }
- // }
- // }
- // }
- //
- // }
- //
- // /**
- // * REturns <code>true</code> if the associated compartment edit part can contain the given element
- // *
- // * @param namedElement
- // * the named element to show/hide
- // * @return <code>true</code> if the compartment can display the element
- // */
- // protected boolean canContain(NamedElement namedElement) {
- // TransactionalEditingDomain domain = getRepresentedEditPart().getEditingDomain();
- // ViewDescriptor viewDescriptor = new ViewDescriptor(new EObjectAdapter(namedElement), Node.class, null, ViewUtil.APPEND, false, getRepresentedEditPart().getDiagramPreferencesHint());
- //
- // CreateCommand cmd = new CreateCommand(domain, viewDescriptor, getRepresentedEditPart().getNotationView());
- // return (cmd.canExecute());
- // }
- // }
-
- // /**
- // *
- // * This class is used to do easily the difference between the nested
- // * classifiers and the superclass of the selected class in the Tree The
- // * superclass are represented with this class
- // */
- // protected class ClassifierRepresentation {
- //
- // /** the represented classifier */
- // protected Classifier representedClassifier;
- //
- // /** the CustomEditPartRepresentation owning this classifier */
- // protected EditPartRepresentation rep;
- //
- // /**
- // * Constructor.
- // *
- // * @param representedClassifier
- // * the represented classifier
- // * @param rep
- // * the representation containing this classifier
- // */
- // public ClassifierRepresentation(Classifier representedClassifier, CustomEditPartRepresentation rep) {
- // this.representedClassifier = representedClassifier;
- // this.rep = rep;
- // }
- //
- // public boolean ownsElement(Object element) {
- // if(representedClassifier.getOwnedMembers().contains(element)) {
- // return true;
- // }
- // return false;
- // }
- //
- // /**
- // * Getter for {@link #representedClassifier}
- // *
- // * @return {@link #representedClassifier}
- // */
- // public Classifier getRepresentedClassifier() {
- // return this.representedClassifier;
- // }
- //
- // /**
- // * Getter for {@link #rep}
- // *
- // * @return {@link #rep}
- // */
- // public EditPartRepresentation getEditPartRepresentation() {
- // return this.rep;
- // }
- //
- // }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShowHideClassifierContentsEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShowHideClassifierContentsEditPolicy.java
index 29cdda26b8e..1c3955c01ad 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShowHideClassifierContentsEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShowHideClassifierContentsEditPolicy.java
@@ -75,9 +75,22 @@ public class ShowHideClassifierContentsEditPolicy extends AbstractEditPolicy {
* @return The command to create the view
*/
protected Command getCreateViewCommand(View container, EObject semanticElement, Point location) {
+ return getCreateViewCommand(container, semanticElement, location, null);
+ }
+ /**
+ * Return the command to create the view
+ *
+ * @param container
+ * the container for the element
+ * @param semanticElement
+ * @param point where to create the view
+ * @param hint to create the view
+ * @return The command to create the view
+ */
+ protected Command getCreateViewCommand(View container, EObject semanticElement, Point location, String hint) {
// creation of the node
- ViewDescriptor viewDescriptor = new ViewDescriptor(new EObjectAdapter(semanticElement), Node.class, null, ViewUtil.APPEND, true, ((IGraphicalEditPart) this.getHost()).getDiagramPreferencesHint());
+ ViewDescriptor viewDescriptor = new ViewDescriptor(new EObjectAdapter(semanticElement), Node.class, hint, ViewUtil.APPEND, true, ((IGraphicalEditPart) this.getHost()).getDiagramPreferencesHint());
CompoundCommand compositeCmd = new CompoundCommand("Create View");//$NON-NLS-1$
CreateCommand cmd = new CreateCommand(getEditingDomain(), viewDescriptor, container);
if (cmd.canExecute()) {
@@ -92,8 +105,8 @@ public class ShowHideClassifierContentsEditPolicy extends AbstractEditPolicy {
}
return compositeCmd;
- }
-
+ }
+
/**
* Return the command to the EditPart
*
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/parts/ResizablePortEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/parts/ResizablePortEditPart.java
index 2ec20ea949f..4180177d6a9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/parts/ResizablePortEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/parts/ResizablePortEditPart.java
@@ -7,8 +7,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * CEA LIST - Initial API and implementation
- * Benoit maggi (CEA LIST) benoit.maggi@cea.fr - Allow InnerPort (Visual : Port in Port)
+ * CEA LIST - Initial API and implementation
+ * Benoit maggi (CEA LIST) benoit.maggi@cea.fr - Allow InnerPort (Visual : Port in Port)
+ * Benoit maggi (CEA LIST) benoit.maggi@cea.fr -#501701 Showing nested port on Port
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts;
@@ -25,7 +26,9 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.PortResizableEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
+import org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.ShowHideCompositeContentsEditPolicy;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.PortEditPart;
@@ -47,6 +50,7 @@ public class ResizablePortEditPart extends PortEditPart {
public ResizablePortEditPart(View view) {
super(view);
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy());
+ installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideCompositeContentsEditPolicy());
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/ShowHideCompositeContentsEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/ShowHideCompositeContentsEditPolicy.java
new file mode 100644
index 00000000000..fd7ddf04b0a
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/ShowHideCompositeContentsEditPolicy.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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:
+ * Benoit maggi (CEA LIST) benoit.maggi@cea.fr -#501701 Showing nested port on Port
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
+import org.eclipse.uml2.uml.Port;
+
+/**
+ * Diagram related ShowHideContentsEdit policy for Composite diagram
+ *
+ */
+public class ShowHideCompositeContentsEditPolicy extends ShowHideClassifierContentsEditPolicy {
+
+ /**
+ *
+ */
+ private static final String HINT_PORT_SHAPE = "Port_Shape";//$NON-NLS-1$
+
+ @Override
+ protected Command getCreateViewCommand(View container, EObject semanticElement, Point location) {
+ if (semanticElement instanceof Port) {
+ return getCreateViewCommand(container, semanticElement, location, HINT_PORT_SHAPE);
+ } else {
+ return super.getCreateViewCommand(container, semanticElement, location);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen
index df5aaadd816..5d12b0f6477 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen
@@ -11061,7 +11061,7 @@
iD="org.eclipse.papyrus.uml.diagram.composite"
name="Papyrus Composite Structure Diagram "
provider="Eclipse Modeling Project"
- version="2.0.0.qualifier">
+ version="3.0.0.qualifier">
<requiredPlugins>org.eclipse.draw2d</requiredPlugins>
<requiredPlugins>org.eclipse.gmf.runtime.draw2d.ui</requiredPlugins>
</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
index 9924e32201b..3797dabcf77 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/plugin.xml
@@ -27,5 +27,8 @@
<strategy
strategy="org.eclipse.papyrus.uml.diagram.dnd.strategy.transition.OperationAsTriggerToTransitionDropStrategy">
</strategy>
+ <strategy
+ strategy="org.eclipse.papyrus.uml.diagram.dnd.strategy.PortToTypesPortDropStrategy">
+ </strategy>
</extension>
</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/PortToTypesPortDropStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/PortToTypesPortDropStrategy.java
new file mode 100644
index 00000000000..82ce7b220d0
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd/src/org/eclipse/papyrus/uml/diagram/dnd/strategy/PortToTypesPortDropStrategy.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.dnd.strategy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.TransactionalDropStrategy;
+import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.ResizablePortEditPart;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * A DropStrategy to move a Port in a Port
+ */
+public class PortToTypesPortDropStrategy extends TransactionalDropStrategy {
+
+ @Override
+ public String getLabel() {
+ return "Parameter drag and drop inside Parameter Property";
+ }
+
+ @Override
+ public String getID() {
+ return "org.eclipse.papyrus.sysml14.diagram.parametric.dnd.ParameterDropStrategy"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getDescription() {
+ return "This strategy is is a specialization in order to be able to drop a Port inside Port.";
+ }
+
+
+ @Override
+ public Command doGetCommand(Request request, final EditPart targetEditPart) {
+ CompositeCommand cc = new CompositeCommand(getLabel());
+ if (targetEditPart instanceof ResizablePortEditPart) {
+ ResizablePortEditPart graphicalEditPart = (ResizablePortEditPart) targetEditPart;
+ List<EObject> sourceElements = getSourceEObjects(request);
+ if (sourceElements.size() == 0) {
+ return null;
+ }
+ final List<EObject> valuesToAdd = new ArrayList<EObject>(sourceElements.size());
+ Element target = (Element) graphicalEditPart.resolveSemanticElement();
+ if (target instanceof Port && ((Port) target).getType() != null) {
+ Port targetPort = (Port) target;
+ Type targetType = targetPort.getType();
+ for (EObject sourceElement : sourceElements) {
+ if ((sourceElement instanceof Port) && sourceElement.eContainer().equals(targetType)) {
+ addCommandDrop(graphicalEditPart, cc, valuesToAdd, sourceElement);
+ }
+ }
+ }
+ }
+ return cc.canExecute() ? new ICommandProxy(cc.reduce()) : null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getImage()
+ *
+ * @return
+ */
+ @Override
+ public Image getImage() {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getPriority()
+ *
+ * @return
+ * @deprecated
+ */
+ @Override
+ public int getPriority() {
+ return 0;
+ }
+
+
+ protected Command addCommandDrop(final ResizablePortEditPart targetEditPart, CompositeCommand cc, final List<EObject> valuesToAdd, EObject sourceElement) {
+
+ valuesToAdd.add(sourceElement);
+ Command cmd = new Command() {
+ @Override
+ public void execute() {
+ ViewService.createNode(targetEditPart.getNotationView(), valuesToAdd.get(0), "Port_Shape", targetEditPart.getDiagramPreferencesHint());
+ }
+
+ };
+ cc.add(new CommandProxy(cmd));
+ return cmd;
+ }
+}

Back to the top