Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/AbstractShowHideRelatedLinkEditPolicy.java40
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/EdgeWithNoSemanticElementRepresentationImpl.java117
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/part/SysMLDiagramUpdater.java223
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractUMLShowHideRelatedLinkEditPolicy.java27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java67
7 files changed, 452 insertions, 33 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/AbstractShowHideRelatedLinkEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/AbstractShowHideRelatedLinkEditPolicy.java
index 78c0d515057..0923b8c1bb9 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/AbstractShowHideRelatedLinkEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/AbstractShowHideRelatedLinkEditPolicy.java
@@ -51,6 +51,8 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.gmf.runtime.notation.BasicCompartment;
import org.eclipse.gmf.runtime.notation.Connector;
import org.eclipse.gmf.runtime.notation.Diagram;
@@ -196,7 +198,7 @@ public abstract class AbstractShowHideRelatedLinkEditPolicy extends AbstractEdit
*
* @return linkdescriptors
*/
- protected Collection<? extends UpdaterLinkDescriptor> collectPartRelatedLinks(View view, Map<EObject, View> domain2NotationMap) {
+ protected Collection<? extends UpdaterLinkDescriptor> collectPartRelatedLinks(final View view, final Map<EObject, View> domain2NotationMap) {
Collection<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
DiagramUpdater diagramUpdater = getDiagramUpdater();
// We must prevent duplicate descriptors
@@ -232,6 +234,20 @@ public abstract class AbstractShowHideRelatedLinkEditPolicy extends AbstractEdit
* only ends
*/
protected Collection<UpdaterLinkDescriptor> removeInvalidLinkDescriptor(final Collection<UpdaterLinkDescriptor> descriptors) {
+ final Collection<UpdaterLinkDescriptor> toRemove = new ArrayList<UpdaterLinkDescriptor>();
+ final Collection<UpdaterLinkDescriptor> toAdd = new ArrayList<UpdaterLinkDescriptor>();
+ for(final UpdaterLinkDescriptor current : descriptors) {
+ if(current.getModelElement() == null) {
+ final IElementType elementType = (IElementType)current.getSemanticAdapter().getAdapter(IElementType.class);
+ final EdgeWithNoSemanticElementRepresentationImpl noSemantic = new EdgeWithNoSemanticElementRepresentationImpl(current.getSource(), current.getDestination(), ((IHintedType)elementType).getSemanticHint());
+ final UpdaterLinkDescriptor replacement = new UpdaterLinkDescriptor(current.getSource(), current.getDestination(), noSemantic, elementType, current.getVisualID());
+ toRemove.add(current);
+ toAdd.add(replacement);
+ }
+ }
+
+ descriptors.removeAll(toRemove);
+ descriptors.addAll(toAdd);
return descriptors;
}
@@ -424,7 +440,6 @@ public abstract class AbstractShowHideRelatedLinkEditPolicy extends AbstractEdit
}
}
}
- // compositeCommand.add(getRefreshHostCommand(domain));
return compositeCommand;
}
@@ -483,16 +498,22 @@ public abstract class AbstractShowHideRelatedLinkEditPolicy extends AbstractEdit
protected void mapModel(View view, Map<EObject, View> domain2NotationMap) {
if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
if((view instanceof Connector || view instanceof Shape) && !(view instanceof BasicCompartment)) {
- domain2NotationMap.put(view.getElement(), view);
+ EObject element = view.getElement();
+ if(element == null) {
+ final EObject source = ((Connector)view).getSource().getElement();
+ final EObject target = ((Connector)view).getTarget().getElement();
+ element = new EdgeWithNoSemanticElementRepresentationImpl(source, target, view.getType());
+ }
+ domain2NotationMap.put(element, view);
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")//$NON-NLS-1$
List<View> children = view.getChildren();
for(View child : children) {
mapModel(child, domain2NotationMap);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")//$NON-NLS-1$
List<View> sourceEdges = view.getSourceEdges();
for(View edge : sourceEdges) {
mapModel(edge, domain2NotationMap);
@@ -520,7 +541,11 @@ public abstract class AbstractShowHideRelatedLinkEditPolicy extends AbstractEdit
//we look for the link descriptor
UpdaterLinkDescriptor descriptor = getLinkDescriptor(linkToShow, linkDescriptors);
-
+ if(linkToShow instanceof EdgeWithNoSemanticElementRepresentationImpl) {
+ //we replace the specific link descriptor by a new one, with no model element (if not the view provider refuse to create the view
+ final IElementType elementType = (IElementType)descriptor.getSemanticAdapter().getAdapter(IElementType.class);
+ descriptor = new UpdaterLinkDescriptor(descriptor.getSource(), descriptor.getDestination(), elementType, descriptor.getVisualID());
+ }
if(descriptor != null) {
EditPart sourceEditPart = getEditPart(descriptor.getSource(), domain2NotationMap);
EditPart targetEditPart = getEditPart(descriptor.getDestination(), domain2NotationMap);
@@ -530,6 +555,9 @@ public abstract class AbstractShowHideRelatedLinkEditPolicy extends AbstractEdit
return null;
}
String semanticHint = getSemanticHint(linkToShow);
+ if(semanticHint == null) {
+ semanticHint = ((IHintedType)descriptor.getSemanticAdapter().getAdapter(IElementType.class)).getSemanticHint();
+ }
CreateConnectionViewRequest.ConnectionViewDescriptor viewDescriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(descriptor.getSemanticAdapter(), semanticHint, ViewUtil.APPEND, false, ((GraphicalEditPart)getHost()).getDiagramPreferencesHint());
CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(viewDescriptor);
ccr.setType(RequestConstants.REQ_CONNECTION_START);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/EdgeWithNoSemanticElementRepresentationImpl.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/EdgeWithNoSemanticElementRepresentationImpl.java
new file mode 100644
index 00000000000..5674a126936
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/EdgeWithNoSemanticElementRepresentationImpl.java
@@ -0,0 +1,117 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.editpolicies;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+/**
+ *
+ * @author vl222926
+ * An eobject class used to represent a link with no semantic element
+ */
+public class EdgeWithNoSemanticElementRepresentationImpl extends EObjectImpl {
+
+ /**
+ * the semantic hint for the represented element
+ */
+ private String semanticHint;
+
+ /**
+ * the source of the link
+ */
+ private final EObject source;
+
+ /**
+ * the target of the link
+ */
+ private final EObject target;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param source
+ * the source of the link
+ * @param target
+ * the target of the link
+ * @param semanticHint
+ * the semantic hint for the represented element
+ */
+ public EdgeWithNoSemanticElementRepresentationImpl(final EObject source, final EObject target, final String semanticHint) {
+ this.source = source;
+ this.target = target;
+ this.semanticHint = semanticHint;
+ }
+
+ /**
+ *
+ * @return
+ * the source of the represented link
+ */
+ public EObject getSource() {
+ return source;
+ }
+
+ /**
+ *
+ * @return
+ * the target of the represented link
+ */
+ public EObject getTarget() {
+ return target;
+ }
+
+ /**
+ *
+ * @return
+ * a view for this link
+ */
+ public String getSemanticHint() {
+ return semanticHint;
+ }
+
+ /**
+ * Calculate the hashcode in order to allows to have the same hashcode for 2 {@link EdgeWithNoSemanticElementRepresentationImpl} with the same
+ * field values.
+ *
+ * @see java.lang.Object#hashCode()
+ *
+ * @return
+ * the hashcode
+ */
+ @Override
+ public int hashCode() {
+ return this.target.hashCode() + 7 * this.source.hashCode() + 11 * this.semanticHint.hashCode();
+ }
+
+ /**
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ *
+ * @param obj
+ * an object
+ * @return
+ * <code>true</code> if this object is the same than the other one
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if(obj instanceof EdgeWithNoSemanticElementRepresentationImpl) {
+ final EdgeWithNoSemanticElementRepresentationImpl otherLink = (EdgeWithNoSemanticElementRepresentationImpl)obj;
+ return this.source == otherLink.getSource() && this.target == otherLink.getTarget() && this.semanticHint.equals(otherLink.getSemanticHint());
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/part/SysMLDiagramUpdater.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/part/SysMLDiagramUpdater.java
index d616c12169e..bfbab55c419 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/part/SysMLDiagramUpdater.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/part/SysMLDiagramUpdater.java
@@ -29,11 +29,22 @@ import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
import org.eclipse.gmf.tooling.runtime.update.UpdaterLinkDescriptor;
import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes;
import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.composite.part.UMLLinkDescriptor;
+import org.eclipse.papyrus.uml.diagram.composite.providers.UMLElementTypes;
import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Connector;
import org.eclipse.uml2.uml.ConnectorEnd;
+import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Property;
@@ -111,55 +122,197 @@ public class SysMLDiagramUpdater {
* @param view
* a view
* @return
- * the list of the outgoing links for this view
+ * the list of the incoming links for this view
*/
- public static List<UpdaterLinkDescriptor> getOutgoingLinks(final View view) {
+ public static List<UpdaterLinkDescriptor> getIncomingLinks(final View view) {
final String id = view.getType();//TODO : could be done by the SysMLVisualIdRegistry...
if(id.equals(UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID)) {
- return getPort_shape_uml_port_as_affixed_OutgoingLink(view);
+ return getPort_shape_uml_port_as_affixed_IncominkLink(view);
}
if(id.equals(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID)) {
- return getFlowPort_shape_sysml_flowport_as_affixed_OutgoingLink(view);
+ return getFlowPort_shape_sysml_flowport_as_affixed_IncominkLink(view);
}
if(id.equals(SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID)) {
- return getProperty_shape_sysml_blockproperty_as_composite_OutgoingLink(view);
+ return getProperty_shape_sysml_blockproperty_as_composite_IncomingLink(view);
}
if(id.equals(SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID)) {
- return getBlock_shape_sysml_block_as_composite_OutgoingLink(view);
+ return getBlock_shape_sysml_block_as_composite_IncomingLink(view);
+ }
+ if(id.equals(UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID)) {
+ return getDependency_link_uml_dependency_IncomingLink(view);
+ }
+ if(id.equals(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID)) {
+ return getConnector_link_uml_connector_IncomingLink(view);
+ }
+ if(id.equals(Integer.toString(CommentEditPart.VISUAL_ID))) {
+ return getComment_2109IncomingLinks(view);
+ }
+ if(id.equals(Integer.toString(CommentEditPartCN.VISUAL_ID))) {
+ return getComment_3097IncomingLinks(view);
+ }
+ if(id.equals(Integer.toString(ConstraintEditPart.VISUAL_ID))) {
+ return getConstraint_2114IncomingLinks(view);
+ }
+ if(id.equals(Integer.toString(ConstraintEditPartCN.VISUAL_ID))) {
+ return getConstraint_3120IncomingLinks(view);
}
return Collections.emptyList();
}
-
/**
*
* @param view
* a view
* @return
- * the list of the incoming links for this view
+ * the list of the outgoing links for this view
*/
- public static List<UpdaterLinkDescriptor> getIncomingLinks(final View view) {
+ public static List<UpdaterLinkDescriptor> getOutgoingLinks(final View view) {
final String id = view.getType();//TODO : could be done by the SysMLVisualIdRegistry...
if(id.equals(UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID)) {
- return getPort_shape_uml_port_as_affixed_IncominkLink(view);
+ return getPort_shape_uml_port_as_affixed_OutgoingLink(view);
}
if(id.equals(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID)) {
- return getFlowPort_shape_sysml_flowport_as_affixed_IncominkLink(view);
+ return getFlowPort_shape_sysml_flowport_as_affixed_OutgoingLink(view);
}
if(id.equals(SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID)) {
- return getProperty_shape_sysml_blockproperty_as_composite_IncomingLink(view);
+ return getProperty_shape_sysml_blockproperty_as_composite_OutgoingLink(view);
}
if(id.equals(SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID)) {
- return getBlock_shape_sysml_block_as_composite_IncomingLink(view);
+ return getBlock_shape_sysml_block_as_composite_OutgoingLink(view);
+ }
+ if(id.equals(UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID)) {
+ return getDependency_link_uml_dependency_OutgoingLink(view);
+ }
+ if(id.equals(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID)) {
+ return getConnector_link_uml_connector_OutgoingLink(view);
+ }
+ if(id.equals(Integer.toString(CommentEditPart.VISUAL_ID))) {
+ return getComment_2109OutgoingLinks(view);
+ }
+ if(id.equals(Integer.toString(CommentEditPartCN.VISUAL_ID))) {
+ return getComment_3097OutgoingLinks(view);
+ }
+ if(id.equals(Integer.toString(ConstraintEditPart.VISUAL_ID))) {
+ return getConstraint_2114OutgoingLinks(view);
+ }
+ if(id.equals(Integer.toString(ConstraintEditPartCN.VISUAL_ID))) {
+ return getConstraint_3120OutgoingLinks(view);
}
return Collections.emptyList();
}
+ private static List<UpdaterLinkDescriptor> getConnector_link_uml_connector_IncomingLink(View view) {
+ Connector modelElement = (Connector)view.getElement();
+ Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
+ result.addAll(getIncomingTypeModelFacetsLinks_Dependency_link_uml_dependency(modelElement, crossReferences));
+ return result;
+
+ }
+
+ private static List<UpdaterLinkDescriptor> getConnector_link_uml_connector_OutgoingLink(View view) {
+ Connector modelElement = (Connector)view.getElement();
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_link_uml_dependency(modelElement));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getDependency_link_uml_dependency_IncomingLink(View view) {
+ Dependency modelElement = (Dependency)view.getElement();
+ Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
+ result.addAll(getIncomingTypeModelFacetsLinks_Dependency_link_uml_dependency(modelElement, crossReferences));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getDependency_link_uml_dependency_OutgoingLink(View view) {
+ Dependency modelElement = (Dependency)view.getElement();
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_link_uml_dependency(modelElement));
+ return result;
+ }
+
+
+ private static List<UpdaterLinkDescriptor> getComment_3097IncomingLinks(View view) {
+ Comment modelElement = (Comment)view.getElement();
+ Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getComment_3097OutgoingLinks(View view) {
+ Comment modelElement = (Comment)view.getElement();
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getComment_2109IncomingLinks(View view) {
+ Comment modelElement = (Comment)view.getElement();
+ Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getComment_2109OutgoingLinks(View view) {
+ Comment modelElement = (Comment)view.getElement();
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getConstraint_2114IncomingLinks(View view) {
+ Constraint modelElement = (Constraint)view.getElement();
+ Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
+ result.addAll(getIncomingTypeModelFacetsLinks_Dependency_link_uml_dependency(modelElement, crossReferences));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getConstraint_2114OutgoingLinks(View view) {
+ Constraint modelElement = (Constraint)view.getElement();
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement));
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_link_uml_dependency(modelElement));
+ return result;
+ }
+
+ private static List<UpdaterLinkDescriptor> getConstraint_3120IncomingLinks(View view) {
+ Constraint modelElement = (Constraint)view.getElement();
+ Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
+ result.addAll(getIncomingTypeModelFacetsLinks_Dependency_link_uml_dependency(modelElement, crossReferences));
+ return result;
+ }
+
+
+ private static List<UpdaterLinkDescriptor> getConstraint_3120OutgoingLinks(View view) {
+ Constraint modelElement = (Constraint)view.getElement();
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getOutgoingTypeModelFacetLinks_Dependency_link_uml_dependency(modelElement));
+ result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement));
+ return result;
+ }
+
private static List<UpdaterLinkDescriptor> getBlock_shape_sysml_block_as_composite_IncomingLink(final View view) {
final Class modelElement = (Class)view.getElement();
final Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
final LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
result.addAll(getIncomingTypeModelFacetsLinks_Dependency_link_uml_dependency(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
return result;
}
@@ -181,6 +334,8 @@ public class SysMLDiagramUpdater {
final Property modelElement = (Property)view.getElement();
final Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
final LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(modelElement, crossReferences));
+ result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(modelElement, crossReferences));
result.addAll(getIncomingTypeModelFacetsLinks_Connector_link_uml_connector(modelElement, crossReferences));
result.addAll(getIncomingTypeModelFacetsLinks_Dependency_link_uml_dependency(modelElement, crossReferences));
return result;
@@ -202,6 +357,48 @@ public class SysMLDiagramUpdater {
return result;
}
+ private static Collection<? extends UpdaterLinkDescriptor> getIncomingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(final Element target, final Map<EObject, Collection<Setting>> crossReferences) {
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferences.get(target);
+ for(EStructuralFeature.Setting setting : settings) {
+ if(setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getComment_AnnotatedElement()) {
+ result.add(new UpdaterLinkDescriptor(setting.getEObject(), target, UMLElementTypes.CommentAnnotatedElement_4002, CommentAnnotatedElementEditPart.VISUAL_ID));
+ }
+ }
+ return result;
+ }
+
+
+ private static Collection<UpdaterLinkDescriptor> getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElement_4002(Comment source) {
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ for(Iterator<?> destinations = source.getAnnotatedElements().iterator(); destinations.hasNext();) {
+ Element destination = (Element)destinations.next();
+ result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.CommentAnnotatedElement_4002, CommentAnnotatedElementEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
+ private static Collection<UpdaterLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(Element target, Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
+ LinkedList<UpdaterLinkDescriptor> result = new LinkedList<UpdaterLinkDescriptor>();
+ Collection<EStructuralFeature.Setting> settings = crossReferences.get(target);
+ for(EStructuralFeature.Setting setting : settings) {
+ if(setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_ConstrainedElement()) {
+ result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.ConstraintConstrainedElement_4003, ConstraintConstrainedElementEditPart.VISUAL_ID));
+ }
+ }
+ return result;
+ }
+
+
+ private static Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElement_4003(Constraint source) {
+ LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>();
+ for(Iterator<?> destinations = source.getConstrainedElements().iterator(); destinations.hasNext();) {
+ Element destination = (Element)destinations.next();
+ result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.ConstraintConstrainedElement_4003, ConstraintConstrainedElementEditPart.VISUAL_ID));
+ }
+ return result;
+ }
+
private static List<UpdaterLinkDescriptor> getProperty_shape_sysml_blockproperty_as_composite_IncomingLink(final View view) {
return getProperty_IncomingLink(view);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractUMLShowHideRelatedLinkEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractUMLShowHideRelatedLinkEditPolicy.java
index 4ec070639de..1d95e904c3b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractUMLShowHideRelatedLinkEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractUMLShowHideRelatedLinkEditPolicy.java
@@ -40,6 +40,7 @@ import org.eclipse.gmf.tooling.runtime.update.UpdaterLinkDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.AbstractShowHideRelatedLinkEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.EdgeWithNoSemanticElementRepresentationImpl;
import org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper;
import org.eclipse.papyrus.uml.diagram.common.ui.dialogs.ShowHideRelatedLinkSelectionDialog;
import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
@@ -96,7 +97,12 @@ public abstract class AbstractUMLShowHideRelatedLinkEditPolicy extends AbstractS
final UpdaterLinkDescriptor current = iter.next();
final EObject link = current.getModelElement();
if(link instanceof Element) {
- linkMapping.put(link, createLinkEndMapper((Element)link));
+ linkMapping.put(link, createLinkEndMapper((Element)link, current));
+ } else if(link instanceof EdgeWithNoSemanticElementRepresentationImpl) {
+ final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl)link).getSource();
+ if(source instanceof Comment || source instanceof Constraint) {
+ linkMapping.put(link, createLinkEndMapper((Element)source, current));
+ }
}
}
@@ -121,18 +127,13 @@ public abstract class AbstractUMLShowHideRelatedLinkEditPolicy extends AbstractS
* only ends)
*/
protected Collection<UpdaterLinkDescriptor> removeInvalidLinkDescriptor(final Collection<UpdaterLinkDescriptor> descriptor) {
+ final Collection<UpdaterLinkDescriptor> firstResult = super.removeInvalidLinkDescriptor(descriptor);
final Collection<UpdaterLinkDescriptor> result = new ArrayList<UpdaterLinkDescriptor>();
- final Iterator<UpdaterLinkDescriptor> iter = descriptor.iterator();
+ final Iterator<UpdaterLinkDescriptor> iter = firstResult.iterator();
while(iter.hasNext()) {
final UpdaterLinkDescriptor current = iter.next();
final EObject modelElement = current.getModelElement();
- if(modelElement == null) {//TODO currently we exclude links for comments and constraints
- final EObject source = current.getSource();
- if(source instanceof Comment || source instanceof Constraint) {
- continue;
- }
- }
/*
* for example, for association between Class1 and class2, we get a link descriptor between class1 and class2 BUT another one between
* class1 and class1...
@@ -188,6 +189,8 @@ public abstract class AbstractUMLShowHideRelatedLinkEditPolicy extends AbstractS
return false;
} else if(link instanceof Connector) {
return false;
+ } else if(link instanceof Comment || link instanceof Constraint) {
+ return true;
}
return false;
}
@@ -202,11 +205,15 @@ public abstract class AbstractUMLShowHideRelatedLinkEditPolicy extends AbstractS
* @return
* a linkEndsMapper according to this element
*/
- public static final LinkEndsMapper createLinkEndMapper(final Element element) {
+ public static final LinkEndsMapper createLinkEndMapper(final Element element, final UpdaterLinkDescriptor descriptor) {
Collection<?> ends;
Collection<?> sources;
Collection<?> targets;
- if(isAnOrientedLink(element)) {
+ if(element instanceof Comment || element instanceof Constraint) {
+ ends = Collections.emptyList();
+ sources = Collections.singletonList(descriptor.getSource());
+ targets = Collections.singletonList(descriptor.getDestination());
+ } else if(isAnOrientedLink(element)) {
ends = Collections.emptyList();
sources = LinkMappingHelper.getSource(element);
targets = LinkMappingHelper.getTarget(element);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java
index f3ec844517d..5cc509c5325 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java
@@ -19,6 +19,12 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.diagram.common.messages.messages"; //$NON-NLS-1$
+ public static String ShowHideRelatedLinkSelectionDialog_Comment_;
+
+ public static String ShowHideRelatedLinkSelectionDialog_CommentLink;
+
+ public static String ShowHideRelatedLinkSelectionDialog_ConstraintLink;
+
public static String ShowHideRelatedLinkSelectionDialog_Targets;
public static String ShowHideRelatedLinkSelectionDialog_Sources;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties
index c18940bdaa3..ebf6c58d913 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties
@@ -7,7 +7,10 @@ CreateOrShowExistingLinkDialog_RestoreSelection=Restore Selection
CreateOrShowExistingLinkDialog_ShowOrCreate=Show or Create
CreateOrShowExistingLinkDialog_Sources=Sources
CreateOrShowExistingLinkDialog_Targets=Targets
-ShowHideRelatedLinkSelectionDialog_Targets=Targets;
+ShowHideRelatedLinkSelectionDialog_Comment_=Comment:
+ShowHideRelatedLinkSelectionDialog_CommentLink=Comment Link
+ShowHideRelatedLinkSelectionDialog_ConstraintLink=Constraint Link
+ShowHideRelatedLinkSelectionDialog_Targets=Targets
ShowHideRelatedLinkSelectionDialog_Sources=Sources
ShowHideRelatedLinkSelectionDialog_Ends=Ends
ShowHideRelatedLinkSelectionDialog_LinksToDisplay=Links To Display
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java
index a56031b9e8c..710d5d76f76 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java
@@ -24,6 +24,8 @@ import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -34,6 +36,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.EdgeWithNoSemanticElementRepresentationImpl;
import org.eclipse.papyrus.uml.diagram.common.dialogs.AbstractCheckedTreeColumnViewerSelectionDialog;
import org.eclipse.papyrus.uml.diagram.common.messages.Messages;
import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
@@ -43,6 +46,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Constraint;
/**
*
@@ -196,12 +201,29 @@ public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColum
final Object currentElement = event.getElement();
boolean isChecked = event.getChecked();
if(currentElement instanceof EditPart) {
+ //we update the selected element list
if(isChecked) {
selectedElements.addAll(availableLinks.get(currentElement));
} else {
selectedElements.removeAll(availableLinks.get(currentElement));
}
+
+ //in some case, the EditPart can be a link which appears as possible elements of an other selected edit part
+ final View view = (View)((EditPart)currentElement).getAdapter(View.class);
+ if(view instanceof Edge) {
+ final EObject element = view.getElement();
+ for(final Set<EObject> currentCol : availableLinks.values()) {
+ if(currentCol.contains(element)) {
+ if(isChecked) {
+ selectedElements.add(element);
+ } else {
+ selectedElements.remove(element);
+ }
+ }
+ }
+ }
} else {
+ //we update the selected element list
if(isChecked) {
selectedElements.add((EObject)currentElement);
} else {
@@ -283,6 +305,15 @@ public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColum
Collection<EObject> tmp = new ArrayList<EObject>(selectedElements);
tmp.retainAll(possibleLinks);
isChecked = tmp.size() > 0;
+
+
+ final View view = (View)((EditPart)element).getAdapter(View.class);
+ if(!isChecked && view instanceof Edge) {//the edge edit part could be selected as grayed because the link is already selected for an another edit part
+ final EObject eobject = view.getElement();
+ isChecked = selectedElements.contains(eobject);
+ }
+
+
} else if(element instanceof EObject) {
isChecked = selectedElements.contains(element);
}
@@ -310,7 +341,10 @@ public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColum
* {@inheritDoc}
*/
@Override
- public Image getImage(Object element) {
+ public Image getImage(final Object element) {
+ if(element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
+ return null;
+ }
if(element instanceof EObject) {
return labelProvider.getImage(element);
}
@@ -321,7 +355,16 @@ public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColum
* {@inheritDoc}
*/
@Override
- public String getText(Object element) {
+ public String getText(final Object element) {
+ if(element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
+ final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl)element).getSource();
+ if(source instanceof Comment) {
+ return Messages.ShowHideRelatedLinkSelectionDialog_CommentLink;
+ }
+ if(source instanceof Constraint) {
+ return Messages.ShowHideRelatedLinkSelectionDialog_ConstraintLink;
+ }
+ }
if(element instanceof EObject) {
return ((EObject)element).eClass().getName();
}
@@ -360,6 +403,12 @@ public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColum
*/
@Override
public Image getImage(Object element) {
+ if(element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
+ final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl)element).getSource();
+ if(source instanceof Comment || source instanceof Constraint) {
+ return labelProvider.getImage(source);
+ }
+ }
return labelProvider.getImage(element);
}
@@ -368,6 +417,14 @@ public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColum
*/
@Override
public String getText(Object element) {
+ if(element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
+ final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl)element).getSource();
+ if(source instanceof Comment) {
+ return Messages.ShowHideRelatedLinkSelectionDialog_CommentLink;
+ } else if(source instanceof Constraint) {
+ return Messages.ShowHideRelatedLinkSelectionDialog_ConstraintLink;
+ }
+ }
return labelProvider.getText(element);
}
@@ -528,7 +585,11 @@ public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColum
builder.append(START_LIST);
final Iterator<?> iter = ends.iterator();
while(iter.hasNext()) {
- builder.append(this.labelProvider.getText(iter.next()));
+ final Object current = iter.next();
+ if(current instanceof Comment) {
+ builder.append(Messages.ShowHideRelatedLinkSelectionDialog_Comment_);
+ }
+ builder.append(this.labelProvider.getText(current));
if(iter.hasNext()) {
builder.append(VALUE_SEPARATOR);
}

Back to the top