Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcmraidha2012-09-10 15:28:41 +0000
committercmraidha2012-09-10 15:28:41 +0000
commit756bf31205262c5a2ec5c2faa59df283b5556ee0 (patch)
tree25139d4acd2d3e124fdfc7cbffffb7d854a719bb
parentfb0cc901644cfb96db3feb6fce5e1b0dc5e2e6a8 (diff)
downloadorg.eclipse.papyrus-756bf31205262c5a2ec5c2faa59df283b5556ee0.tar.gz
org.eclipse.papyrus-756bf31205262c5a2ec5c2faa59df283b5556ee0.tar.xz
org.eclipse.papyrus-756bf31205262c5a2ec5c2faa59df283b5556ee0.zip
[Sequence Diagram] bug fixes: https://bugs.eclipse.org/bugs/show_bug.cgi?id=377501
https://bugs.eclipse.org/bugs/show_bug.cgi?id=383417
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java471
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java56
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/AnchorHelper.java195
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java20
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ConsiderIgnoreFragmentEditPart.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionEditPart.java115
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java74
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/preferences/MessagePreferencePage.java22
11 files changed, 714 insertions, 291 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
index 9a0d8e91a84..a2c39fc6107 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
@@ -31,10 +31,9 @@ import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities;
import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter;
import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.OrthogonalRouterUtilities;
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart.LifelineFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart.SlidableAnchorEx;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart.MessageAsync;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message4EditPart.MessageCreate;
/**
@@ -130,6 +129,13 @@ public class MessageRouter extends ObliqueRouter {
break;
}
}
+
+ protected boolean checkShapesIntersect(Connection conn, PointList newLine) {
+ if(conn.getTargetAnchor().getOwner() instanceof AnchorHelper.CombinedFragmentNodeFigure){
+ return false;
+ }
+ return super.checkShapesIntersect(conn, newLine);
+ }
protected void adjustCreateEndpoint(Connection conn, PointList newLine) {
if(conn instanceof MessageCreate){
@@ -198,8 +204,8 @@ public class MessageRouter extends ObliqueRouter {
protected boolean isOnRightHand(Connection conn, IFigure owner, Point middle) {
boolean right = true;
- if(conn.getTargetAnchor() instanceof SlidableAnchorEx){
- SlidableAnchorEx anchor = (SlidableAnchorEx) conn.getTargetAnchor();
+ if(conn.getTargetAnchor() instanceof AnchorHelper.SideAnchor){
+ AnchorHelper.SideAnchor anchor = ( AnchorHelper.SideAnchor) conn.getTargetAnchor();
right = anchor.isRight();
}else{
PointList list = conn.getPoints();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
index 5bfe6b386ed..b82ae91ea7e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
@@ -1,39 +1,55 @@
package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.OperationLabelHelper;
import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.sequence.preferences.MessagePreferencePage;
+import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
import org.eclipse.papyrus.uml.tools.utils.MultiplicityElementUtil;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
-import org.eclipse.papyrus.uml.tools.utils.OperationUtil;
+import org.eclipse.papyrus.uml.tools.utils.ParameterUtil;
import org.eclipse.papyrus.uml.tools.utils.PropertyUtil;
import org.eclipse.papyrus.uml.tools.utils.TypeUtil;
+import org.eclipse.papyrus.uml.tools.utils.TypedElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.ValueSpecification;
public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
@@ -41,6 +57,8 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
public static interface ICustomMessageLabel{
}
+
+ private DefaultValueListener defaultValueListener;
/**
* Refreshes the display of the edit part
@@ -106,7 +124,7 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
@Override
public void addAdditionalListeners() {
super.addAdditionalListeners();
-
+ this.defaultValueListener = new DefaultValueListener();
Message e = getUMLElement();
// check host semantic element is not null
if(e == null || e.getSignature() == null) {
@@ -119,24 +137,28 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
// adds a listener to the element itself, and to linked elements, like Type
for(Parameter parameter : operation.getOwnedParameters()) {
getDiagramEventBroker().addNotificationListener(parameter, this);
-
+ getDiagramEventBroker().addNotificationListener(parameter.getDefaultValue(), defaultValueListener);
+
// should also add this element as a listener of parameter type
- if(parameter.getType() != null) {
- getDiagramEventBroker().addNotificationListener(parameter.getType(), this);
- }
+ getDiagramEventBroker().addNotificationListener(parameter.getType(), this);
}
}else if(sig instanceof Signal){
Signal signal = (Signal)sig;
getDiagramEventBroker().addNotificationListener(signal, this);
for(Property property : signal.getOwnedAttributes()) {
getDiagramEventBroker().addNotificationListener(property, this);
+ getDiagramEventBroker().addNotificationListener(property.getDefaultValue(), defaultValueListener);
// should also add this element as a listener of parameter type
- if(property.getType() != null) {
- getDiagramEventBroker().addNotificationListener(property.getType(), this);
- }
+ getDiagramEventBroker().addNotificationListener(property.getType(), this);
}
}
+
+ EList<ValueSpecification> argments = e.getArguments();
+ for(ValueSpecification v : argments)
+ if(v instanceof EObject) {
+ getDiagramEventBroker().addNotificationListener((EObject)v, this);
+ }
}
@Override
@@ -153,35 +175,47 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
getDiagramEventBroker().removeNotificationListener(operation, this);
for(Parameter parameter : operation.getOwnedParameters()) {
getDiagramEventBroker().removeNotificationListener(parameter, this);
-
+ getDiagramEventBroker().removeNotificationListener(parameter.getDefaultValue(), defaultValueListener);
+
// remove parameter type listener
- if(parameter.getType() != null) {
- getDiagramEventBroker().removeNotificationListener(parameter.getType(), this);
- }
+ getDiagramEventBroker().removeNotificationListener(parameter.getType(), this);
}
}else if(sig instanceof Signal){
Signal signal = (Signal)sig;
getDiagramEventBroker().removeNotificationListener(signal, this);
for(Property property : signal.getOwnedAttributes()) {
getDiagramEventBroker().removeNotificationListener(property, this);
+ getDiagramEventBroker().removeNotificationListener(property.getDefaultValue(), defaultValueListener);
// remove parameter type listener
- if(property.getType() != null) {
- getDiagramEventBroker().removeNotificationListener(property.getType(), this);
- }
+ getDiagramEventBroker().removeNotificationListener(property.getType(), this);
}
}
+
+ EList<ValueSpecification> argments = e.getArguments();
+ for(ValueSpecification v : argments)
+ if(v instanceof EObject) {
+ getDiagramEventBroker().removeNotificationListener((EObject)v, this);
+ }
}
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
- Object object = notification.getNotifier();
+ final Object object = notification.getNotifier();
Message e = getUMLElement();
// check host semantic element is not null
if(e == null || e.getSignature() == null) {
return;
}
+ if(UMLPackage.Literals.MESSAGE__ARGUMENT.equals( notification.getFeature())){
+ parameterListChange(notification);
+ return;
+ }else if(e.getArguments().contains(object)){
+ refreshDisplay();
+ return;
+ }
+
NamedElement sig = e.getSignature();
if(sig instanceof Operation){
Operation operation = (Operation)sig;
@@ -199,25 +233,40 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
notifySignalChanged(signal, notification);
}else if(isProperty(object, signal)) {
notifyPropertyChanged(notification);
- } else if(isPropertyType(object, signal)) {
+ }else if(isPropertyType(object, signal)) {
notifyTypeChanged(notification);
+ }else if(object instanceof ValueSpecification){
+ Element own = ((ValueSpecification)object).getOwner();
+ if(isProperty(own, signal)){
+ refreshDisplay(); // may be default value
+ }
}
}
- if(isMaskManagedAnnotation(object)) {
+ if(isMaskManagedAnnotation(object) ){
+ refreshDisplay();
+ }else if(isRemovedMaskManagedLabelAnnotation(object, notification)) {
refreshDisplay();
}
+ }
+
+ class DefaultValueListener implements NotificationListener{
- if(isRemovedMaskManagedLabelAnnotation(object, notification)) {
+ public void notifyChanged(Notification notification) {
refreshDisplay();
}
}
-
private void notifyPropertyChanged(Notification notification) {
switch(notification.getFeatureID(Property.class)) {
+ case UMLPackage.PROPERTY__DEFAULT_VALUE: // set or unset default value
+ if(notification.getOldValue() instanceof EObject)
+ getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), defaultValueListener);
+ if(notification.getNewValue() instanceof EObject)
+ getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), defaultValueListener);
+ refreshDisplay();
+ break;
case UMLPackage.PROPERTY__NAME:
- case UMLPackage.PROPERTY__DEFAULT_VALUE:
case UMLPackage.PROPERTY__IS_ORDERED:
case UMLPackage.PROPERTY__LOWER:
case UMLPackage.PROPERTY__UPPER:
@@ -245,8 +294,14 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
*/
protected void notifyParameterChanged(Notification notification) {
switch(notification.getFeatureID(Parameter.class)) {
- case UMLPackage.PARAMETER__NAME:
case UMLPackage.PARAMETER__DEFAULT_VALUE:
+ if(notification.getOldValue() instanceof EObject)
+ getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), defaultValueListener);
+ if(notification.getNewValue() instanceof EObject)
+ getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), defaultValueListener);
+ refreshDisplay();
+ break;
+ case UMLPackage.PARAMETER__NAME:
case UMLPackage.PARAMETER__DIRECTION:
case UMLPackage.PARAMETER__IS_STREAM:
case UMLPackage.PARAMETER__IS_ORDERED:
@@ -448,6 +503,25 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
* singelton instance
*/
private static MessageLabelHelper labelHelper;
+
+ /** Map for masks */
+ protected final Map<Integer, String> masks = new HashMap<Integer, String>(11);
+
+ protected MessageLabelHelper() {
+ // initialize the map
+ masks.put(ICustomAppearence.DISP_VISIBILITY, "Visibility");
+ masks.put(ICustomAppearence.DISP_NAME, "Name");
+ masks.put(ICustomAppearence.DISP_PARAMETER_NAME, "Parameters Name");
+ masks.put(ICustomAppearence.DISP_PARAMETER_DIRECTION, "Parameters Direction");
+ masks.put(ICustomAppearence.DISP_PARAMETER_TYPE, "Parameters Type");
+ masks.put(ICustomAppearence.DISP_RT_TYPE, "Return Type");
+ masks.put(ICustomAppearence.DISP_PARAMETER_MULTIPLICITY, "Parameters Multiplicity");
+ masks.put(ICustomAppearence.DISP_PARAMETER_DEFAULT, "Parameters Default Value");
+ masks.put(ICustomAppearence.DISP_DERIVE, "Parameters Value");
+ masks.put(ICustomAppearence.DISP_PARAMETER_MODIFIERS, "Parameters Modifiers");
+ masks.put(ICustomAppearence.DISP_MOFIFIERS, "Modifiers");
+
+ }
/**
* Returns the singleton instance of this class
@@ -482,9 +556,9 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
NamedElement signature = e.getSignature();
if(signature instanceof Operation) {
- return OperationUtil.getCustomLabel((Operation)signature, displayValue);
+ return OperationUtil.getCustomLabel(e, (Operation)signature, displayValue);
}else if(signature instanceof Signal) {
- return SignalUtil.getCustomLabel((Signal)signature, displayValue);
+ return SignalUtil.getCustomLabel(e, (Signal)signature, displayValue);
} else if(signature != null) {
return signature.getName();
}
@@ -493,33 +567,113 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
}
public String getMaskLabel(int value) {
- return OperationLabelHelper.getInstance().getMaskLabel(value);
+ return masks.get(value);
}
public Collection<String> getMaskLabels() {
- return OperationLabelHelper.getInstance().getMaskLabels();
+ return masks.values();
}
public Map<Integer, String> getMasks() {
- return OperationLabelHelper.getInstance().getMasks();
+ return masks;
}
public Set<Integer> getMaskValues() {
- return OperationLabelHelper.getInstance().getMaskValues();
+ return masks.keySet();
}
}
static public class SignalUtil {
+ private static String getCustomPropertyLabel(Message e, Property property, int style) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+
+ buffer.append(" ");
+ if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
+ buffer.append(NamedElementUtil.getVisibilityAsSign(property));
+ }
+
+ // derived property
+ if((style & ICustomAppearence.DISP_DERIVE) != 0) {
+ if(property.isDerived()) {
+ buffer.append("/");
+ }
+ }
+ // name
+ if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0) {
+ buffer.append(" ");
+ buffer.append(property.getName());
+ }
+
+ if((style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0) {
+ // type
+ if(property.getType() != null) {
+ buffer.append(": " + property.getType().getName());
+ } else {
+ buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+ }
+
+ if((style & ICustomAppearence.DISP_MULTIPLICITY) != 0) {
+ // multiplicity -> do not display [1]
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
+ buffer.append(multiplicity);
+ }
+
+ if((style & ICustomAppearence.DISP_DERIVE) != 0) {
+ String value = getValue(e, property);
+ if(value != null){
+ if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0 || (style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0)
+ buffer.append(" = ");
+ buffer.append(value);
+ }
+ }else if((style & ICustomAppearence.DISP_PARAMETER_DEFAULT) != 0) {
+ // default value
+ if(property.getDefault() != null) {
+ if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0 || (style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0)
+ buffer.append(" = ");
+ buffer.append(property.getDefault());
+ }
+ }
+
+ if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
+ boolean multiLine = ((style & ICustomAppearence.DISP_MULTI_LINE) != 0);
+ // property modifiers
+ String modifiers = PropertyUtil.getModifiersAsString(property, multiLine);
+ if(!modifiers.equals("")) {
+ if(multiLine) {
+ buffer.append("\n");
+ }
+
+ if (!buffer.toString().endsWith(" ")){
+ buffer.append(" ");
+ }
+
+ buffer.append(modifiers);
+ }
+ }
+ return buffer.toString();
+ }
+
+ private static String getValue(Message e, Property property) {
+ EList<ValueSpecification> arguments = e.getArguments();
+ for(ValueSpecification v : arguments)
+ if(v.getName().equals(property.getName())){
+ return ValueSpecificationUtil.getSpecificationValue(v);
+ }
+ return null;
+ }
/**
* return the custom label of the signal, given UML2 specification and a custom style.
+ * @param e
*
* @param style
* the integer representing the style of the label
*
* @return the string corresponding to the label of the signal
*/
- public static String getCustomLabel(Signal signal, int style) {
+ public static String getCustomLabel(Message e, Signal signal, int style) {
StringBuffer buffer = new StringBuffer();
buffer.append(" "); // adds " " first for correct display considerations
@@ -537,7 +691,7 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
//
// parameters : '(' parameter-list ')'
buffer.append("(");
- buffer.append(getPropertiesAsString(signal, style));
+ buffer.append(getPropertiesAsString(e, signal, style));
buffer.append(")");
return buffer.toString();
@@ -548,12 +702,12 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
*
* @return a string containing all properties separated by commas
*/
- private static String getPropertiesAsString(Signal signal, int style) {
+ private static String getPropertiesAsString(Message e, Signal signal, int style) {
StringBuffer propertiesString = new StringBuffer();
boolean firstProperty = true;
for(Property property : signal.getOwnedAttributes()) {
// get the label for this property
- String propertyString = getCustomPropertyLabel(property, style);
+ String propertyString = getCustomPropertyLabel(e, property, style);
if(!propertyString.trim().equals("")) {
if(!firstProperty) {
propertiesString.append(", ");
@@ -564,68 +718,265 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
}
return propertiesString.toString();
}
-
- private static String getCustomPropertyLabel(Property property, int style) {
+ }
+
+ static class OperationUtil {
+ public static String getCustomLabel(Message e, Parameter parameter, int style) {
StringBuffer buffer = new StringBuffer();
// visibility
-
buffer.append(" ");
if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(property));
+ buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
}
- // derived property
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
- if(property.isDerived()) {
- buffer.append("/");
- }
+ // direction property
+ if((style & ICustomAppearence.DISP_PARAMETER_DIRECTION) != 0) {
+ buffer.append(" ");
+ buffer.append(parameter.getDirection().getLiteral());
}
+
// name
if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0) {
buffer.append(" ");
- buffer.append(property.getName());
+ buffer.append(parameter.getName());
}
if((style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0) {
// type
- if(property.getType() != null) {
- buffer.append(": " + property.getType().getName());
+ if(parameter.getType() != null) {
+ buffer.append(": " + parameter.getType().getName());
} else {
buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
}
}
- if((style & ICustomAppearence.DISP_MULTIPLICITY) != 0) {
+ if((style & ICustomAppearence.DISP_PARAMETER_MULTIPLICITY) != 0) {
// multiplicity -> do not display [1]
- String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
buffer.append(multiplicity);
}
-
- if((style & ICustomAppearence.DISP_PARAMETER_DEFAULT) != 0) {
- // default value
- if(property.getDefault() != null) {
- buffer.append(" = ");
- buffer.append(property.getDefault());
+
+ if((style & ICustomAppearence.DISP_DERIVE) != 0) {
+ String value = getValue(e, parameter);
+ if(value != null){
+ if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0 || (style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0)
+ buffer.append(" = ");
+ buffer.append(value);
+ }
+ }else if((style & ICustomAppearence.DISP_PARAMETER_DEFAULT) != 0) {
+ // default value
+ if(parameter.getDefault() != null) {
+ if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0 || (style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0)
+ buffer.append(" = ");
+ buffer.append(parameter.getDefault());
}
}
if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
boolean multiLine = ((style & ICustomAppearence.DISP_MULTI_LINE) != 0);
// property modifiers
- String modifiers = PropertyUtil.getModifiersAsString(property, multiLine);
+ String modifiers = ParameterUtil.getModifiersAsString(parameter, multiLine);
if(!modifiers.equals("")) {
if(multiLine) {
buffer.append("\n");
}
-
- if (!buffer.toString().endsWith(" ")){
- buffer.append(" ");
- }
-
buffer.append(modifiers);
}
}
return buffer.toString();
}
+
+ private static String getValue(Message e, Parameter parameter) {
+ EList<ValueSpecification> arguments = e.getArguments();
+ for(ValueSpecification v : arguments)
+ if(v.getName().equals(parameter.getName())){
+ return ValueSpecificationUtil.getSpecificationValue(v);
+ }
+ return null;
+ }
+
+ public static String getCustomLabel(Message e, Operation operation, int style) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(" "); // adds " " first for correct display considerations
+
+ // visibility
+ if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
+ buffer.append(NamedElementUtil.getVisibilityAsSign(operation));
+ }
+
+ // name
+ if((style & ICustomAppearence.DISP_NAME) != 0) {
+ buffer.append(" ");
+ buffer.append(operation.getName());
+ }
+
+ //
+ // parameters : '(' parameter-list ')'
+ buffer.append("(");
+ buffer.append(getParametersAsString(e, operation, style));
+ buffer.append(")");
+
+ // return type
+ if((style & ICustomAppearence.DISP_RT_TYPE) != 0) {
+ buffer.append(getReturnTypeAsString(operation, style));
+ }
+
+ // modifiers
+ if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
+ String modifiers = getModifiersAsString(operation);
+ if(!modifiers.equals("")) {
+ buffer.append("{");
+ buffer.append(modifiers);
+ buffer.append("}");
+ }
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Returns operation modifiers as string, separated with comma.
+ *
+ * @return a string containing the modifiers
+ */
+ private static String getModifiersAsString(Operation operation) {
+ StringBuffer buffer = new StringBuffer();
+ boolean needsComma = false;
+
+ // Return parameter modifiers
+ Parameter returnParameter = OperationUtil.getReturnParameter(operation);
+ if(returnParameter != null) {
+ // non unique parameter
+ if(!returnParameter.isUnique()) {
+ buffer.append("nonunique");
+ needsComma = true;
+ }
+
+ // return parameter has ordered values
+ if(returnParameter.isOrdered()) {
+ if(needsComma) {
+ buffer.append(", ");
+ }
+ buffer.append("ordered");
+ needsComma = true;
+ }
+ }
+
+ // is the operation a query ?
+ if(operation.isQuery()) {
+ if(needsComma) {
+ buffer.append(", ");
+ }
+ buffer.append("query");
+ needsComma = true;
+ }
+
+ // is the operation redefining another operation ?
+ Iterator<Operation> it = operation.getRedefinedOperations().iterator();
+ while(it.hasNext()) {
+ Operation currentOperation = it.next();
+ if(needsComma) {
+ buffer.append(", ");
+ }
+ buffer.append("redefines ");
+ buffer.append(currentOperation.getName());
+ needsComma = true;
+ }
+
+ // has the operation a constraint ?
+ Iterator<Constraint> it2 = operation.getOwnedRules().iterator();
+ while(it2.hasNext()) {
+ Constraint constraint = it2.next();
+ if(needsComma) {
+ buffer.append(", ");
+ }
+ if(constraint.getSpecification() != null) {
+ buffer.append(constraint.getSpecification().stringValue());
+ }
+ needsComma = true;
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Returns return parameter label as a string, string parametrized with a style mask.
+ *
+ * @param style
+ * the mask that indicates which element to display
+ * @return a string containing the return parameter type
+ */
+ private static String getReturnTypeAsString(Operation operation, int style) {
+ boolean displayType = ((style & ICustomAppearence.DISP_RT_TYPE) != 0);
+ boolean displayMultiplicity = ((style & ICustomAppearence.DISP_RT_MULTIPLICITY) != 0);
+ StringBuffer label = new StringBuffer("");
+
+ // Retrieve the return parameter (assume to be unique if defined)
+ Parameter returnParameter = getReturnParameter(operation);
+ // Create the string for the return type
+ if(returnParameter == null) {
+ // no-operation: label = ""
+
+ } else if(!displayType && !displayMultiplicity) {
+ // no-operation: label = ""
+
+ } else {
+ label.append(": ");
+ if(displayType) {
+ label.append(TypedElementUtil.getTypeAsString(returnParameter));
+ }
+
+ if(displayMultiplicity) {
+ label.append(MultiplicityElementUtil.getMultiplicityAsString(returnParameter));
+ }
+ }
+ return label.toString();
+ }
+
+ /**
+ * Gives the return parameter for this operation, or <code>null</code> if none exists.
+ *
+ * @return the return parameter of the operation or <code>null</code>
+ */
+ private static Parameter getReturnParameter(Operation operation) {
+ // Retrieve the return parameter (assume to be unique if defined)
+ Parameter returnParameter = null;
+
+ Iterator<Parameter> it = operation.getOwnedParameters().iterator();
+ while((returnParameter == null) && (it.hasNext())) {
+ Parameter parameter = it.next();
+ if(parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
+ returnParameter = parameter;
+ }
+ }
+ return returnParameter;
+ }
+
+ /**
+ * Returns operation parameters as a string, the label is customized using a bit mask
+ * @param e
+ *
+ * @return a string containing all parameters separated by commas
+ */
+ private static String getParametersAsString(Message e, Operation operation, int style) {
+ StringBuffer paramString = new StringBuffer();
+ Iterator<Parameter> paramIterator = operation.getOwnedParameters().iterator();
+ boolean firstParameter = true;
+ while(paramIterator.hasNext()) {
+ Parameter parameter = paramIterator.next();
+ // Do not include return parameters
+ if(!parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
+ // get the label for this parameter
+ String parameterString = getCustomLabel(e, parameter, style);
+ if (!parameterString.trim().equals("")) {
+ if (!firstParameter) {
+ paramString.append(", ");
+ }
+ paramString.append(parameterString);
+ firstParameter = false;
+ }
+ }
+ }
+ return paramString.toString();
+ }
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java
index 95c979a9f67..c0a156820f7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceGraphicalNodeEditPolicy.java
@@ -45,7 +45,9 @@ import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragment2EditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message3EditPart;
@@ -260,7 +262,7 @@ public class SequenceGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
if(replyHint.equals(desc.getSemanticHint()) && request.getSourceEditPart() instanceof IGraphicalEditPart) {
Rectangle srcBounds = SequenceUtil.getAbsoluteBounds((IGraphicalEditPart)request.getSourceEditPart());
int bottom = srcBounds.getBottom().y;
- if(bottom >= targetPoint.y) {
+ if(bottom >= targetPoint.y + MARGIN) {
return UnexecutableCommand.INSTANCE;
}
}
@@ -456,27 +458,41 @@ public class SequenceGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
|| REQ_RECONNECT_TARGET.equals(request.getType())){
EditPart host = getHost();
- if((host instanceof InteractionEditPart) && (request instanceof CreateConnectionRequest) ){
- if(REQ_CONNECTION_END.equals(request.getType()) && isCreateConnectionRequest(request,UMLElementTypes.Message_4008 )){
- return host;
- }
- if(REQ_CONNECTION_START.equals(request.getType()) && isCreateConnectionRequest(request,UMLElementTypes.Message_4009 )){
- return host;
- }
-
- InteractionEditPart interactionPart = (InteractionEditPart)host;
- CreateConnectionRequest req = (CreateConnectionRequest)request;
- IFigure figure = interactionPart.getFigure();
- Point location = req.getLocation().getCopy();
- figure.translateToRelative(location);
-
- // if mouse location is far from border, do not handle connection event
- Rectangle innerRetangle = figure.getBounds().getCopy().shrink(20, 20);
- if(innerRetangle.contains(location)){
+ if(request instanceof CreateConnectionRequest){
+ if(host instanceof InteractionEditPart){
+ if(REQ_CONNECTION_END.equals(request.getType()) && isCreateConnectionRequest(request,UMLElementTypes.Message_4008 )){
+ return host;
+ }
+ if(REQ_CONNECTION_START.equals(request.getType()) && isCreateConnectionRequest(request,UMLElementTypes.Message_4009 )){
+ return host;
+ }
+
+ InteractionEditPart interactionPart = (InteractionEditPart)host;
+ CreateConnectionRequest req = (CreateConnectionRequest)request;
+ IFigure figure = interactionPart.getFigure();
+ Point location = req.getLocation().getCopy();
+ figure.translateToRelative(location);
+
+ // if mouse location is far from border, do not handle connection event
+ Rectangle innerRetangle = figure.getBounds().getCopy().shrink(20, 20);
+ if(innerRetangle.contains(location)){
+ return null;
+ }
+ }else if(host instanceof InteractionOperandEditPart){
return null;
+ }else if(host instanceof CombinedFragmentEditPart){
+ CreateConnectionRequest req = (CreateConnectionRequest)request;
+ IFigure figure = ((GraphicalEditPart)host).getFigure();
+ Point location = req.getLocation().getCopy();
+ figure.translateToRelative(location);
+
+ // if mouse location is far from border, do not handle connection event
+ Rectangle innerRetangle = figure.getBounds().getCopy().shrink(10, 10);
+ if(innerRetangle.contains(location)){
+ return null;
+ }
}
- }
-
+ }
return host;
}
return null;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/AnchorHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/AnchorHelper.java
new file mode 100644
index 00000000000..a08b28ebedb
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/AnchorHelper.java
@@ -0,0 +1,195 @@
+package org.eclipse.papyrus.uml.diagram.sequence.edit.helpers;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.PrecisionRectangle;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.common.core.util.Log;
+import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin;
+import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.SlidableAnchor;
+import org.eclipse.gmf.runtime.notation.Anchor;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.IdentityAnchor;
+import org.eclipse.papyrus.uml.diagram.common.draw2d.anchors.FixedAnchor;
+
+
+public class AnchorHelper {
+
+ public static String getAnchorId(TransactionalEditingDomain domain, ConnectionEditPart connEditPart, final boolean isSource) {
+ final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection =
+ (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart)connEditPart;
+
+ String t = ""; //$NON-NLS-1$
+ try {
+ t = (String) domain.runExclusive(
+ new RunnableWithResult.Impl() {
+
+ public void run() {
+ Anchor a = null;
+ if(isSource)
+ a = ((Edge)connection.getModel()).getSourceAnchor();
+ else
+ a = ((Edge)connection.getModel()).getTargetAnchor();
+ if (a instanceof IdentityAnchor)
+ setResult(((IdentityAnchor) a).getId());
+ else
+ setResult(""); //$NON-NLS-1$
+ }
+ });
+ } catch (InterruptedException e) {
+ Log.error(DiagramUIPlugin.getInstance(),
+ DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
+ "getTargetConnectionAnchor", e); //$NON-NLS-1$
+ }
+ return t;
+ }
+
+
+ public static Point getRequestLocation(Request request){
+ if (request instanceof ReconnectRequest) {
+ if (((DropRequest) request).getLocation() != null) {
+ Point pt = ((DropRequest) request).getLocation().getCopy();
+ return pt;
+ }
+ }
+ else if (request instanceof DropRequest){
+ return ((DropRequest) request).getLocation();
+ }
+ return null;
+ }
+
+ public static class CombinedFragmentNodeFigure extends DefaultSizeNodeFigure{
+
+ public CombinedFragmentNodeFigure(int width, int height) {
+ super(width, height);
+ }
+
+ protected ConnectionAnchor createAnchor(PrecisionPoint p) {
+ if (p==null)
+ // If the old terminal for the connection anchor cannot be resolved (by SlidableAnchor) a null
+ // PrecisionPoint will passed in - this is handled here
+ return createDefaultAnchor();
+ return new AnchorHelper.IntersectionPointAnchor(this, p);
+ }
+ }
+
+ public static class IntersectionPointAnchor extends SlidableAnchor{
+
+ public IntersectionPointAnchor(IFigure fig, PrecisionPoint p) {
+ super(fig,p);
+ }
+
+ public IntersectionPointAnchor(IFigure fig) {
+ super(fig);
+ }
+
+ protected Point getLocation(Point ownReference, Point foreignReference) {
+ PointList intersections = getIntersectionPoints(ownReference, foreignReference);
+ if (intersections!=null && intersections.size()!=0) {
+ int size = intersections.size();
+ double dist = foreignReference.getDistance(ownReference);
+ for(int i = 0; i < size; i ++){
+ Point loc = intersections.getPoint(i);
+ if(isInOrder(foreignReference,ownReference,dist, loc)){
+ return loc;
+ }
+ }
+ return intersections.getFirstPoint();
+ }
+ return null;
+ }
+
+ private boolean isInOrder(Point start, Point end, double dist, Point loc) {
+ double total = loc.getDistance(start);
+ double dist2 = loc.getDistance(end);
+ if(total < dist || total < dist2)
+ return false;
+
+ if(Math.abs(total - dist - dist2) < 0.01)
+ return true;
+
+ return false;
+ }
+ }
+
+ public static class FixedAnchorEx extends FixedAnchor {
+
+ private int location;
+
+ public FixedAnchorEx(IFigure f, int location) {
+ super(f, location);
+ this.location = location;
+ }
+
+ public Point getLocation(Point reference) {
+ if(location == TOP)
+ return getBox().getTop();
+ else if(location == BOTTOM)
+ return getBox().getBottom();
+
+ return super.getLocation(reference);
+ }
+ }
+
+ public static class SideAnchor extends SlidableAnchor{
+
+ private boolean isRight;
+
+ public SideAnchor(NodeFigure nodeFigure, PrecisionPoint pt,
+ boolean isRight) {
+ super(nodeFigure, pt);
+ this.isRight = isRight;
+ }
+
+ public boolean isRight() {
+ return isRight;
+ }
+
+ public String getTerminal() {
+ String side = isRight? "R": "L";
+ return super.getTerminal() + "{" + side + "}";
+ }
+ }
+
+ public static class InnerPointAnchor extends SlidableAnchor{
+ private PrecisionPoint percent;
+ private IFigure figure;
+
+ public InnerPointAnchor(IFigure fig, PrecisionPoint percent) {
+ super(fig,percent);
+ this.figure = fig;
+ this.percent = percent;
+ }
+
+ public static InnerPointAnchor createAnchorAtLocation(IFigure fig, PrecisionPoint loc) {
+ PrecisionPoint p = loc.getPreciseCopy();
+ Rectangle b = fig.getBounds().getCopy();
+ fig.translateToAbsolute(b);
+
+ Dimension d = p.getDifference(b.getTopLeft());
+ PrecisionPoint per = new PrecisionPoint( d.preciseWidth()/ b.width , d.preciseHeight() / b.height);
+ return new InnerPointAnchor(fig, per);
+ }
+
+ protected Point getLocation(Point ownReference, Point foreignReference) {
+ PrecisionRectangle bounds = new PrecisionRectangle(figure.getBounds());
+ bounds.setPreciseWidth((bounds.width * percent.preciseX()));
+ bounds.setPreciseHeight((bounds.height * percent.preciseY()));
+ figure.translateToAbsolute(bounds);
+ return bounds.getBottomRight();
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java
index 1e739279331..9f35cd56053 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java
@@ -17,21 +17,11 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import org.eclipse.draw2d.BorderLayout;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.DelegatingLayout;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IClippingStrategy;
import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Locator;
import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.Shape;
-import org.eclipse.draw2d.StackLayout;
-import org.eclipse.draw2d.XYLayout;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
-import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
@@ -49,7 +39,6 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnecti
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
@@ -58,6 +47,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper;
import org.eclipse.papyrus.uml.diagram.common.draw2d.anchors.FixedAnchor;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ActionExecutionSpecificationItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationComponentEditPolicy;
@@ -1047,7 +1037,7 @@ AbstractExecutionSpecificationEditPart {
if(UMLElementTypes.Message_4003.equals(obj)) {
// Sync Message
if(!createRequest.getTargetEditPart().equals(createRequest.getSourceEditPart())) {
- return new FixedAnchor(getFigure(), FixedAnchor.TOP);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.TOP);
}
// otherwise, this is a recursive call, let destination free
}
@@ -1057,7 +1047,7 @@ AbstractExecutionSpecificationEditPart {
ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
if(connectionEditPart instanceof MessageEditPart) {
// Sync Message
- return new FixedAnchor(getFigure(), FixedAnchor.TOP);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.TOP);
}
}
@@ -1076,7 +1066,7 @@ AbstractExecutionSpecificationEditPart {
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) {
if(connEditPart instanceof MessageEditPart) {
// Sync Message
- return new FixedAnchor(getFigure(), FixedAnchor.TOP);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.TOP);
}
return super.getTargetConnectionAnchor(connEditPart);
}
@@ -1097,7 +1087,7 @@ AbstractExecutionSpecificationEditPart {
for(Object obj : relationshipTypes) {
if(UMLElementTypes.Message_4005.equals(obj)) {
// Reply Message
- return new FixedAnchor(getFigure(), FixedAnchor.BOTTOM);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.BOTTOM);
}
}
} else if(request instanceof ReconnectRequest) {
@@ -1105,7 +1095,7 @@ AbstractExecutionSpecificationEditPart {
ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
if(connectionEditPart instanceof Message3EditPart) {
// Reply Message
- return new FixedAnchor(getFigure(), FixedAnchor.BOTTOM);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.BOTTOM);
}
}
return super.getSourceConnectionAnchor(request);
@@ -1123,7 +1113,7 @@ AbstractExecutionSpecificationEditPart {
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) {
if(connEditPart instanceof Message3EditPart) {
// Reply Message
- return new FixedAnchor(getFigure(), FixedAnchor.BOTTOM);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.BOTTOM);
}
return super.getSourceConnectionAnchor(connEditPart);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java
index bce723a99a0..168caf49273 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java
@@ -21,11 +21,7 @@ import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.DelegatingLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.Shape;
-import org.eclipse.draw2d.StackLayout;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
@@ -38,13 +34,11 @@ import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
@@ -53,7 +47,7 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper;
import org.eclipse.papyrus.uml.diagram.common.draw2d.anchors.FixedAnchor;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart.FillParentLocator;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.BehaviorExecutionSpecificationItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationComponentEditPolicy;
@@ -1040,7 +1034,7 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe
if(UMLElementTypes.Message_4003.equals(obj)) {
// Sync Message
if(!createRequest.getTargetEditPart().equals(createRequest.getSourceEditPart())) {
- return new FixedAnchor(getFigure(), FixedAnchor.TOP);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.TOP);
}
// otherwise, this is a recursive call, let destination free
}
@@ -1050,7 +1044,7 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe
ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
if(connectionEditPart instanceof MessageEditPart) {
// Sync Message
- return new FixedAnchor(getFigure(), FixedAnchor.TOP);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.TOP);
}
}
@@ -1069,7 +1063,7 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) {
if(connEditPart instanceof MessageEditPart) {
// Sync Message
- return new FixedAnchor(getFigure(), FixedAnchor.TOP);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.TOP);
}
return super.getTargetConnectionAnchor(connEditPart);
}
@@ -1090,7 +1084,7 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe
for(Object obj : relationshipTypes) {
if(UMLElementTypes.Message_4005.equals(obj)) {
// Reply Message
- return new FixedAnchor(getFigure(), FixedAnchor.BOTTOM);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.BOTTOM);
}
}
} else if(request instanceof ReconnectRequest) {
@@ -1098,7 +1092,7 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe
ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
if(connectionEditPart instanceof Message3EditPart) {
// Reply Message
- return new FixedAnchor(getFigure(), FixedAnchor.BOTTOM);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.BOTTOM);
}
}
return super.getSourceConnectionAnchor(request);
@@ -1116,7 +1110,7 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) {
if(connEditPart instanceof Message3EditPart) {
// Reply Message
- return new FixedAnchor(getFigure(), FixedAnchor.BOTTOM);
+ return new AnchorHelper.FixedAnchorEx(getFigure(), FixedAnchor.BOTTOM);
}
return super.getSourceConnectionAnchor(connEditPart);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java
index 972ead53aa2..a0b42de2bda 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java
@@ -21,11 +21,13 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.StackLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
@@ -38,6 +40,7 @@ import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
@@ -61,8 +64,10 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
@@ -73,6 +78,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.SlidableAnchor;
import org.eclipse.gmf.runtime.gef.ui.internal.parts.TextCellEditorEx;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.FillStyle;
@@ -92,6 +98,7 @@ import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHel
import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CombinedFragmentItemComponentEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CombinedFragmentItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceGraphicalNodeEditPolicy;
@@ -103,6 +110,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
import org.eclipse.papyrus.uml.diagram.sequence.util.InteractionOperatorKindCompatibleMapping;
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineCoveredByUpdater;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
@@ -287,7 +295,7 @@ public class CombinedFragmentEditPart extends InteractionFragmentEditPart implem
IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.WIDTH);
String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT);
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight));
+ DefaultSizeNodeFigure result = new AnchorHelper.CombinedFragmentNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)) ;
return result;
}
@@ -1642,5 +1650,4 @@ public class CombinedFragmentEditPart extends InteractionFragmentEditPart implem
return null;
}
}
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ConsiderIgnoreFragmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ConsiderIgnoreFragmentEditPart.java
index c05889c07f9..ef41e739327 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ConsiderIgnoreFragmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ConsiderIgnoreFragmentEditPart.java
@@ -46,6 +46,7 @@ import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHel
import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CombinedFragmentItemComponentEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ConsiderIgnoreFragmentItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.figures.CombinedFragmentFigure;
@@ -164,7 +165,7 @@ public class ConsiderIgnoreFragmentEditPart extends CombinedFragmentEditPart {
IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.WIDTH);
String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT);
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight));
+ DefaultSizeNodeFigure result = new AnchorHelper.CombinedFragmentNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight));
return result;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionEditPart.java
index 45b719e98cd..b3f8af261e3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionEditPart.java
@@ -74,6 +74,7 @@ import org.eclipse.papyrus.uml.diagram.common.figure.node.InteractionRectangleFi
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl;
import org.eclipse.papyrus.uml.diagram.common.util.MessageDirection;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceGraphicalNodeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
@@ -273,64 +274,6 @@ public class InteractionEditPart extends ShapeNodeEditPart {
return getContentPane();
}
- static class SlidableAnchorEx extends SlidableAnchor{
- private PrecisionPoint percent;
- private IFigure figure;
-
- SlidableAnchorEx(IFigure fig, PrecisionPoint percent) {
- super(fig,percent);
- this.figure = fig;
- this.percent = percent;
- }
-
- static SlidableAnchorEx createAnchorAtLocation(IFigure fig, PrecisionPoint loc) {
- PrecisionPoint p = loc.getPreciseCopy();
- Rectangle b = fig.getBounds().getCopy();
- fig.translateToAbsolute(b);
-
- Dimension d = p.getDifference(b.getTopLeft());
- PrecisionPoint per = new PrecisionPoint( d.preciseWidth()/ b.width , d.preciseHeight() / b.height);
- return new SlidableAnchorEx(fig, per);
- }
-
- protected Point getLocation(Point ownReference, Point foreignReference) {
-// PointList intersections = getIntersectionPoints(ownReference, foreignReference);
-// if (intersections!=null && intersections.size()!=0) {
-// int size = intersections.size();
-// double dist = foreignReference.getDistance(ownReference);
-// for(int i = 0; i < size; i ++){
-// Point loc = intersections.getPoint(i);
-// if(isInOrder(foreignReference,ownReference,dist, loc)){
-// return loc;
-// }
-// }
-// return intersections.getFirstPoint();
-// }
-// return null;
- PrecisionRectangle bounds = new PrecisionRectangle(figure.getBounds());
- bounds.setPreciseWidth((bounds.width * percent.preciseX()));
- bounds.setPreciseHeight((bounds.height * percent.preciseY()));
- figure.translateToAbsolute(bounds);
- return bounds.getBottomRight();
- }
-
-// public String getTerminal() {
-// return super.getTerminal() ;
-// }
-//
-// private boolean isInOrder(Point start, Point end, double dist, Point loc) {
-// double total = loc.getDistance(start);
-// double dist2 = loc.getDistance(end);
-// if(total < dist || total < dist2)
-// return false;
-//
-// if(Math.abs(total - dist - dist2) < 0.01)
-// return true;
-//
-// return false;
-// }
- }
-
/**
* @generated
*/
@@ -341,13 +284,13 @@ public class InteractionEditPart extends ShapeNodeEditPart {
String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT);
DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)){
-// protected ConnectionAnchor createAnchor(PrecisionPoint p) {
-// if (p==null)
-// // If the old terminal for the connection anchor cannot be resolved (by SlidableAnchor) a null
-// // PrecisionPoint will passed in - this is handled here
-// return createDefaultAnchor();
-// return new SlidableAnchorEx(this, p);
-// }
+ protected ConnectionAnchor createAnchor(PrecisionPoint p) {
+ if (p==null)
+ // If the old terminal for the connection anchor cannot be resolved (by SlidableAnchor) a null
+ // PrecisionPoint will passed in - this is handled here
+ return createDefaultAnchor();
+ return new AnchorHelper.IntersectionPointAnchor(this, p);
+ }
};
return result;
@@ -1312,10 +1255,10 @@ public class InteractionEditPart extends ShapeNodeEditPart {
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) {
if(connEditPart instanceof Message7EditPart){
- String terminal = getAnchorId(connEditPart,true);
+ String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart,true);
if(terminal.length() > 0){
PrecisionPoint pt = SlidableAnchor.parseTerminalString(terminal);
- return new SlidableAnchorEx(getFigure(),pt);
+ return new AnchorHelper.InnerPointAnchor(getFigure(),pt);
}
}
@@ -1347,10 +1290,10 @@ public class InteractionEditPart extends ShapeNodeEditPart {
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) {
if(connEditPart instanceof Message6EditPart){
- String terminal = getAnchorId(connEditPart, false);
+ String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart, false);
if(terminal.length() > 0){
PrecisionPoint pt = SlidableAnchor.parseTerminalString(terminal);
- return new SlidableAnchorEx(getFigure(),pt);
+ return new AnchorHelper.InnerPointAnchor(getFigure(),pt);
}
}
@@ -1361,38 +1304,6 @@ public class InteractionEditPart extends ShapeNodeEditPart {
// }
return targetConnectionAnchor;
}
-
- private String getAnchorId(ConnectionEditPart connEditPart, final boolean isSource) {
- final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart)connEditPart;
-
- String t = ""; //$NON-NLS-1$
- try {
- t = (String) getEditingDomain().runExclusive(
- new RunnableWithResult.Impl() {
-
- public void run() {
- Anchor a = null;
- if(isSource)
- a = ((Edge)connection.getModel()).getSourceAnchor();
- else
- a = ((Edge)connection.getModel()).getTargetAnchor();
- if (a instanceof IdentityAnchor)
- setResult(((IdentityAnchor) a).getId());
- else
- setResult(""); //$NON-NLS-1$
- }
- });
- } catch (InterruptedException e) {
- Trace.catching(DiagramUIPlugin.getInstance(),
- DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(),
- "getTargetConnectionAnchor", e); //$NON-NLS-1$
- Log.error(DiagramUIPlugin.getInstance(),
- DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
- "getTargetConnectionAnchor", e); //$NON-NLS-1$
- }
- return t;
- }
/**
* Create Anchor
@@ -1444,7 +1355,7 @@ public class InteractionEditPart extends ShapeNodeEditPart {
*/
private ConnectionAnchor createAnchor(Point location) {
//return new SlidableAnchor(getFigure(), BaseSlidableAnchor.getAnchorRelativeLocation(location, getFigure().getBounds()));
- return SlidableAnchorEx.createAnchorAtLocation(getFigure(), new PrecisionPoint(location));
+ return AnchorHelper.InnerPointAnchor.createAnchorAtLocation(getFigure(), new PrecisionPoint(location));
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java
index 796c829c42e..78f5bec32b0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java
@@ -53,7 +53,6 @@ import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gef.requests.DropRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -104,6 +103,7 @@ import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabe
import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.RectangularShadowBorder;
import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomDiagramDragDropEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineAppliedStereotypeNodeLabelDisplayEditPolicy;
@@ -1898,7 +1898,7 @@ public class LifelineEditPart extends NamedElementEditPart {
}
if(connEditPart instanceof Message2EditPart){
- String terminal = getTargetAnchorId(connEditPart);
+ String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart, false);
if(terminal.length() > 0){
int start = terminal.indexOf("{") + 1;
PrecisionPoint pt = SlidableAnchor.parseTerminalString(terminal);
@@ -1913,40 +1913,12 @@ public class LifelineEditPart extends NamedElementEditPart {
if(list.getPoint(0).x > list.getPoint(1).x)
rightHand = false;
}
- return new SlidableAnchorEx(getNodeFigure(), pt, rightHand);
+ return new AnchorHelper.SideAnchor(getNodeFigure(), pt, rightHand);
}
}
return super.getTargetConnectionAnchor(connEditPart);
}
- private String getTargetAnchorId(ConnectionEditPart connEditPart) {
- final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection =
- (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart)connEditPart;
-
- String t = ""; //$NON-NLS-1$
- try {
- t = (String) getEditingDomain().runExclusive(
- new RunnableWithResult.Impl() {
-
- public void run() {
- Anchor a = ((Edge)connection.getModel()).getTargetAnchor();
- if (a instanceof IdentityAnchor)
- setResult(((IdentityAnchor) a).getId());
- else
- setResult(""); //$NON-NLS-1$
- }
- });
- } catch (InterruptedException e) {
- Trace.catching(DiagramUIPlugin.getInstance(),
- DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(),
- "getTargetConnectionAnchor", e); //$NON-NLS-1$
- Log.error(DiagramUIPlugin.getInstance(),
- DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
- "getTargetConnectionAnchor", e); //$NON-NLS-1$
- }
- return t;
- }
-
/**
* Create specific anchor to handle connection on top, on center and on bottom of the lifeline
*/
@@ -1970,13 +1942,13 @@ public class LifelineEditPart extends NamedElementEditPart {
ConnectionAnchor anchor = super.getTargetConnectionAnchor(request);
if(anchor instanceof SlidableAnchor) {
- return createSlidableAnchorEx(request, (SlidableAnchor)anchor);
+ return createSideAnchor(request, (SlidableAnchor)anchor);
}
return anchor;
}
- protected ConnectionAnchor createSlidableAnchorEx(Request request, SlidableAnchor sa) {
- Point loc = getRequestLocation(request);
+ protected ConnectionAnchor createSideAnchor(Request request, SlidableAnchor sa) {
+ Point loc = AnchorHelper.getRequestLocation(request);
if(loc == null)
return sa;
@@ -1987,21 +1959,9 @@ public class LifelineEditPart extends NamedElementEditPart {
boolean rightHand = true;
if(loc.x < bounds.getCenter().x)
rightHand = false;
- return new SlidableAnchorEx(getNodeFigure(), pt, rightHand);
+ return new AnchorHelper.SideAnchor(getNodeFigure(), pt, rightHand);
}
- private Point getRequestLocation(Request request){
- if (request instanceof ReconnectRequest) {
- if (((DropRequest) request).getLocation() != null) {
- Point pt = ((DropRequest) request).getLocation().getCopy();
- return pt;
- }
- }
- else if (request instanceof DropRequest){
- return ((DropRequest) request).getLocation();
- }
- return null;
- }
/**
* Create the dashLine figure
@@ -2206,26 +2166,6 @@ public class LifelineEditPart extends NamedElementEditPart {
return null;
}
- public static class SlidableAnchorEx extends SlidableAnchor{
-
- private boolean isRight;
-
- public SlidableAnchorEx(NodeFigure nodeFigure, PrecisionPoint pt,
- boolean isRight) {
- super(nodeFigure, pt);
- this.isRight = isRight;
- }
-
- public boolean isRight() {
- return isRight;
- }
-
- public String getTerminal() {
- String side = isRight? "R": "L";
- return super.getTerminal() + "{" + side + "}";
- }
- }
-
public static class PreserveAnchorsPositionCommandEx extends PreserveAnchorsPositionCommand{
public PreserveAnchorsPositionCommandEx(ShapeNodeEditPart shapeEP, Dimension sizeDelta, int preserveAxis) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/preferences/MessagePreferencePage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/preferences/MessagePreferencePage.java
index 4fd9155ffe1..4fc17049777 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/preferences/MessagePreferencePage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/preferences/MessagePreferencePage.java
@@ -63,7 +63,7 @@ public class MessagePreferencePage extends AbstractPapyrusLinkPreferencePage {
private int displayValue = getPreferenceStore().getInt(LABEL_DISPLAY_PREFERENCE);
/** buttons to select the display kind for the label of */
- private Button dispParamDir ,dispParamMod, dispParamName, dispVis, dispParamType, dispReturnType, dispParamMul, dispParamDef , dispName, dispMod ;
+ private Button dispParamDir ,dispParamMod, dispParamName, dispVis, dispParamType, dispReturnType, dispParamMul, dispParamDef , dispName, dispMod,dispParamVal;
/**
* Creates the group and check boxes to choose the kind of display
@@ -85,11 +85,12 @@ public class MessagePreferencePage extends AbstractPapyrusLinkPreferencePage {
dispReturnType = createCheckButton(group, "Return Type", ICustomAppearence.DISP_RT_TYPE);
dispParamMul = createCheckButton(group, "Parameters Multiplicity", ICustomAppearence.DISP_PARAMETER_MULTIPLICITY);
dispParamDef = createCheckButton(group, "Parameters Default Value", ICustomAppearence.DISP_PARAMETER_DEFAULT);
+ dispParamVal = createCheckButton(group, "Parameters Value", ICustomAppearence.DISP_DERIVE);
dispName = createCheckButton(group, "Name", ICustomAppearence.DISP_NAME);
dispMod = createCheckButton(group, "Modifiers", ICustomAppearence.DISP_MOFIFIERS);
}
- protected void refreshButtons() {
+ protected void refreshButtons(SelectionEvent e) {
dispParamDir.setSelection(isCheck(displayValue , ICustomAppearence.DISP_PARAMETER_DIRECTION));
dispParamMod.setSelection(isCheck(displayValue , ICustomAppearence.DISP_PARAMETER_MODIFIERS));
dispParamName.setSelection(isCheck(displayValue , ICustomAppearence.DISP_PARAMETER_NAME));
@@ -98,8 +99,19 @@ public class MessagePreferencePage extends AbstractPapyrusLinkPreferencePage {
dispReturnType.setSelection(isCheck(displayValue , ICustomAppearence.DISP_RT_TYPE));
dispParamMul.setSelection(isCheck(displayValue , ICustomAppearence.DISP_PARAMETER_MULTIPLICITY));
dispParamDef.setSelection(isCheck(displayValue , ICustomAppearence.DISP_PARAMETER_DEFAULT));
+ dispParamVal.setSelection(isCheck(displayValue , ICustomAppearence.DISP_DERIVE));
dispName.setSelection(isCheck(displayValue , ICustomAppearence.DISP_NAME));
dispMod.setSelection(isCheck(displayValue , ICustomAppearence.DISP_MOFIFIERS));
+ if(e != null && dispParamDef.getSelection() && dispParamVal.getSelection()){
+ // parameter default and value can only select one of them
+ if(e.widget == dispParamDef){
+ dispParamVal.setSelection(false);
+ displayValue = displayValue ^ ICustomAppearence.DISP_DERIVE;
+ }else if(e.widget == dispParamVal){
+ dispParamDef.setSelection(false);
+ displayValue = displayValue ^ ICustomAppearence.DISP_PARAMETER_DEFAULT;
+ }
+ }
}
protected void createPageContents(Composite parent) {
@@ -108,7 +120,7 @@ public class MessagePreferencePage extends AbstractPapyrusLinkPreferencePage {
// adds the label preferences checkboxes
createLabelPreferencesButtons(parent);
- refreshButtons();
+ refreshButtons(null);
}
/**
@@ -116,7 +128,7 @@ public class MessagePreferencePage extends AbstractPapyrusLinkPreferencePage {
*/
protected void loadDefaultPreferences() {
displayValue = getPreferenceStore().getInt(LABEL_DISPLAY_PREFERENCE);
- refreshButtons();
+ refreshButtons(null);
}
/**
@@ -202,7 +214,7 @@ public class MessagePreferencePage extends AbstractPapyrusLinkPreferencePage {
displayValue = displayValue ^ style;
// refresh buttons at the end
- refreshButtons();
+ refreshButtons(e);
}
}
}

Back to the top