Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2017-08-03 11:31:09 +0000
committerJeremie Tatibouet2017-09-04 12:56:57 +0000
commit0d3569cafeb5f3ee411fd8b562068a02c090f869 (patch)
tree238c7c0e563b87111932a7191c8b0c80ab80ec09 /plugins
parent78b5b2fa1b20b0a2e1ebf6bb82cabe51b5c1188b (diff)
downloadorg.eclipse.papyrus-0d3569cafeb5f3ee411fd8b562068a02c090f869.tar.gz
org.eclipse.papyrus-0d3569cafeb5f3ee411fd8b562068a02c090f869.tar.xz
org.eclipse.papyrus-0d3569cafeb5f3ee411fd8b562068a02c090f869.zip
Bug 509015 - [StateMachineDiagram] lacks support for UML 2.5 notation of
redefinable elements with isLeaf=true Change-Id: I2a73f118552593ab7163134bc246808695b39fd5 Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPart.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPartTN.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/figures/StateFigure.java130
4 files changed, 156 insertions, 24 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
index 699b89949d7..e9812a58791 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
@@ -44,7 +44,7 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
protected boolean noBorder = false;
/** The Constant CHEVRON. */
- private static final String CHEVRON = String.valueOf("\u00AB") + String.valueOf("\u00BB");
+ protected static final String CHEVRON = String.valueOf("\u00AB") + String.valueOf("\u00BB");
/** The tagged label. */
protected PapyrusWrappingLabel taggedLabel;
@@ -84,7 +84,7 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
*/
protected PapyrusWrappingLabel stereotypesLabel;
- private int namePosition = PositionConstants.MIDDLE;
+ protected int namePosition = PositionConstants.MIDDLE;
/**
* Create a basic figure.
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPart.java
index bc070eeec1c..8f5b537e1ba 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPart.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014-2017 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,7 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ * Pauline DEVILLE (CEA LIST): Bug 509015 - [StateMachineDiagram] lacks support for UML 2.5 notation of redefinable elements with isLeaf=true
*/
package org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part;
@@ -76,20 +77,19 @@ public class CustomStateNameEditPart extends StateNameEditPart {
protected void refreshVisuals() {
super.refreshVisuals();
StateFigure stateFigure = ((StateEditPart) getParent()).getPrimaryShape();
-
+
View stateLabelView = (View) getModel();
- if(!(stateLabelView.getElement() instanceof State)) {
+ if (!(stateLabelView.getElement() instanceof State)) {
return;
}
-
+
State state = (State) stateLabelView.getElement();
-
+
View stateView = (View) stateLabelView.eContainer();
if (stateView == null) {
return;
}
View stateCompartmentView = CustomStateEditPart.getStateCompartmentView(stateView);
-
if (stateCompartmentView.getChildren().isEmpty()) {
stateFigure.getStateCompartmentFigure().setVisible(false);
} else {
@@ -104,6 +104,10 @@ public class CustomStateNameEditPart extends StateNameEditPart {
stateFigure.setIsSubmachineState(false);
}
+ // set <<final>> label
+ stateFigure.setIsLeafState(state.isLeaf());
+ stateFigure.restoreFinalLabel();
+
int width = stateFigure.getBounds().width;
// calculate height for labels via position of the rectangle figure after the labels. Layout managers such as the
// AutomaticCompartmentLayoutManager add extra space on top of the first label which would not be accounted for
@@ -116,8 +120,7 @@ public class CustomStateNameEditPart extends StateNameEditPart {
if (height < 0) {
height = 0;
}
- }
- else {
+ } else {
height = stateFigure.getNameLabel().getBounds().height;
}
@@ -144,9 +147,8 @@ public class CustomStateNameEditPart extends StateNameEditPart {
internalResizeRequest.setSizeDelta(new Dimension(dx, dy));
Rectangle rect = new Rectangle(x, y, stateWidth + dx, stateHeight + dy);
- CustomStateResizeCommand internalResizeCommand =
- new CustomStateResizeCommand(adaptableForState, getDiagramPreferencesHint(), getEditingDomain(), DiagramUIMessages.CreateCommand_Label,
- internalResizeRequest, rect, true);
+ CustomStateResizeCommand internalResizeCommand = new CustomStateResizeCommand(adaptableForState, getDiagramPreferencesHint(), getEditingDomain(), DiagramUIMessages.CreateCommand_Label,
+ internalResizeRequest, rect, true);
internalResizeCommand.setOptions(Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE));
try {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPartTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPartTN.java
index ae73059fb1b..6891f8f1ade 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPartTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomStateNameEditPartTN.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014-2017 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,7 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ * Pauline DEVILLE (CEA LIST): Bug 509015 - [StateMachineDiagram] lacks support for UML 2.5 notation of redefinable elements with isLeaf=true
*/
package org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part;
@@ -29,7 +30,6 @@ import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter;
import org.eclipse.papyrus.uml.diagram.statemachine.custom.commands.CustomStateResizeCommand;
import org.eclipse.papyrus.uml.diagram.statemachine.custom.figures.StateFigure;
import org.eclipse.papyrus.uml.diagram.statemachine.custom.helpers.Zone;
-import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateEditPartTN;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateNameEditPartTN;
import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
@@ -79,12 +79,12 @@ public class CustomStateNameEditPartTN extends StateNameEditPartTN {
View stateLabelView = (View) getModel();
StateFigure stateFigure = ((StateEditPartTN) getParent()).getPrimaryShape();
-
- if(!(stateLabelView.getElement() instanceof State)) {
+
+ if (!(stateLabelView.getElement() instanceof State)) {
return;
}
State state = (State) stateLabelView.getElement();
-
+
View stateView = (View) stateLabelView.eContainer();
if (stateView == null) {
return;
@@ -105,6 +105,10 @@ public class CustomStateNameEditPartTN extends StateNameEditPartTN {
stateFigure.setIsSubmachineState(false);
}
+ // set <<final>> label
+ stateFigure.setIsLeafState(state.isLeaf());
+ stateFigure.restoreFinalLabel();
+
int width = stateFigure.getBounds().width;
// calculate height for labels via position of the rectangle figure after the labels. Layout managers such as the
// AutomaticCompartmentLayoutManager add extra space on top of the first label which would not be accounted for
@@ -117,8 +121,7 @@ public class CustomStateNameEditPartTN extends StateNameEditPartTN {
if (height < 0) {
height = 0;
}
- }
- else {
+ } else {
height = stateFigure.getNameLabel().getBounds().height;
}
@@ -145,9 +148,8 @@ public class CustomStateNameEditPartTN extends StateNameEditPartTN {
internalResizeRequest.setSizeDelta(new Dimension(dx, dy));
Rectangle rect = new Rectangle(x, y, stateWidth + dx, stateHeight + dy);
- CustomStateResizeCommand internalResizeCommand =
- new CustomStateResizeCommand(adaptableForState, getDiagramPreferencesHint(), getEditingDomain(), DiagramUIMessages.CreateCommand_Label,
- internalResizeRequest, rect, true);
+ CustomStateResizeCommand internalResizeCommand = new CustomStateResizeCommand(adaptableForState, getDiagramPreferencesHint(), getEditingDomain(), DiagramUIMessages.CreateCommand_Label,
+ internalResizeRequest, rect, true);
internalResizeCommand.setOptions(Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE));
try {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/figures/StateFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/figures/StateFigure.java
index 07838b55d7d..6eaf56b04fb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/figures/StateFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/figures/StateFigure.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014-2017 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,13 +8,16 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Pauline DEVILLE (CEA LIST): Bug 509015 - [StateMachineDiagram] lacks support for UML 2.5 notation of redefinable elements with isLeaf=true
*/
package org.eclipse.papyrus.uml.diagram.statemachine.custom.figures;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
import org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure;
/**
@@ -26,6 +29,16 @@ public class StateFigure extends RoundedCompartmentFigure {
protected boolean isSubmachineState = false;
+ /**
+ * The isLeaf feature of the state
+ */
+ protected boolean isLeafState = false;
+
+ /** The final label. */
+ protected PapyrusWrappingLabel finalLabel;
+
+ private static final String FINAL_LABEL_VALUE = "final";
+
/** The State Compartment */
private final static String STATE_COMPARTMENT = "stateCompartment";
@@ -53,6 +66,7 @@ public class StateFigure extends RoundedCompartmentFigure {
*/
public StateFigure(String tagLabel) {
super(COMPARTMENT, tagLabel);
+ createFinalLabel();
}
public void setSubmachineStateName(String text) {
@@ -64,6 +78,14 @@ public class StateFigure extends RoundedCompartmentFigure {
}
/**
+ * @param isLeafState
+ * the isLeafState to set
+ */
+ public void setIsLeafState(boolean isLeafState) {
+ this.isLeafState = isLeafState;
+ }
+
+ /**
* Get the state compartment figure
*
* @return
@@ -72,4 +94,110 @@ public class StateFigure extends RoundedCompartmentFigure {
return getCompartment(STATE_COMPARTMENT);
}
+ /**
+ * Create the final label in the figure.
+ */
+ protected void createFinalLabel() {
+ finalLabel = new PapyrusWrappingLabel();
+ String textToDisplay = new StringBuffer(CHEVRON).insert(1, FINAL_LABEL_VALUE).toString();
+ finalLabel.setText(textToDisplay);
+ finalLabel.setOpaque(false);
+ finalLabel.setAlignment(namePosition);
+ finalLabel.setForegroundColor(getNameLabel().getForegroundColor());
+ finalLabel.setFont(getNameLabel().getFont());
+ if (isLeafState) {
+ getTagLabelContainer().add(finalLabel, getTagLabelConstraint(), getFinalLabelPosition());
+ }
+ }
+
+ public void restoreFinalLabel() {
+ if (isLeafState && finalLabel != null) {
+ finalLabel.setOpaque(false);
+ finalLabel.setAlignment(namePosition);
+ getFinalLabelContainer().add(finalLabel, getFinalLabelConstraint(), getFinalLabelPosition());
+ } else {
+ removeFinalLabel();
+ }
+ }
+
+ /**
+ * Create a label that contains the stereotype of the element.
+ */
+ protected void removeFinalLabel() {
+ if (finalLabel != null) {
+ if (getFinalLabelContainer().getChildren().contains(finalLabel)) {
+ getFinalLabelContainer().remove(finalLabel);
+ }
+ }
+ }
+
+ /**
+ * @return the position of the label
+ */
+ protected int getFinalLabelPosition() {
+ int position = 0;
+ if (getFinalLabelContainer().equals(getNameLabelContainer())) {
+ // located after name label
+ position = getNameLabelPosition();
+ if (this.nameLabel != null) {
+ position++;
+ }
+ } else if (getFinalLabelContainer().equals(getQualifiedNameLabelContainer())) {
+ // located after qualifed name label
+ position = getQualifiedNameLabelPosition();
+ if (this.qualifiedLabel != null) {
+ position++;
+ }
+ } else if (getFinalLabelContainer().equals(getStereotypePropertiesInBraceLabelContainer())) {
+ // located after stereotype properties in brace label
+ position = getStereotypePropertiesLabelPosition();
+ if (this.stereotypePropertiesInBraceContent != null) {
+ position++;
+ }
+ } else if (getFinalLabelContainer().equals(getStereotypeLabelContainer())) {
+ // located after stereotype label
+ position = getStereotypeLabelPosition();
+ if (this.stereotypesLabel != null) {
+ position++;
+ }
+ } else if (getFinalLabelContainer().equals(getIconLabelContainer())) {
+ // located after icon label
+ position = getIconLabelPosition();
+ if ((this.iconLabel != null) && (this.iconLabel.getIcon() != null)) {
+ position++;
+ }
+ }
+ return position;
+ }
+
+ /**
+ * Get the constraint for adding the final label.
+ *
+ * @return figure containing the final label
+ */
+ protected Object getFinalLabelConstraint() {
+ return getDefaultLabelsConstraint();
+ }
+
+ /**
+ * Get the container for the final label.
+ *
+ * @return figure containing the final label
+ */
+ protected IFigure getFinalLabelContainer() {
+ return getDefaultLabelsContainer();
+ }
+
+ /**
+ * Helper method to calculate the height of name
+ */
+ @Override
+ protected int getNameHeight() {
+ int nameHeight = super.getNameHeight();
+ if (finalLabel != null && getFinalLabelContainer().equals(getNameLabelContainer())) {
+ nameHeight += finalLabel.getPreferredSize().height;
+ }
+ return nameHeight;
+ }
+
}

Back to the top