Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java77
1 files changed, 41 insertions, 36 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java
index 6b2cc5d4150..5e5931cc0e4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java
@@ -19,7 +19,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure;
-import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
/**
* This edit policy is used to display only applied stereotypes and properties
@@ -50,7 +50,7 @@ public class AppliedStereotypeExternalNodeEditPolicy extends AppliedStereotypeLa
getDiagramEventBroker().addNotificationListener(parentView, this);
}
- refreshDisplay();
+
}
@@ -64,11 +64,26 @@ public class AppliedStereotypeExternalNodeEditPolicy extends AppliedStereotypeLa
}
/**
- * {@inheritDoc}
+ * Refresh the text of the stereotype
*/
@Override
- public void refreshDisplay() {
- refreshStereotypeDisplay();
+ protected void refreshStereotypeDisplay() {
+ IFigure figure;
+ if (getHost() instanceof IPapyrusEditPart) {
+ figure = ((IPapyrusEditPart) getHost()).getPrimaryShape();
+ } else {
+ figure = hostEditPart.getFigure();
+ }
+
+ if (figure instanceof IPapyrusUMLElementFigure) {// calculate text
+ // and icon to display
+ final String stereotypesToDisplay = stereotypesToDisplay();
+ ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay), null);
+
+ }
+
+
+
}
/**
@@ -83,48 +98,38 @@ public class AppliedStereotypeExternalNodeEditPolicy extends AppliedStereotypeLa
// retrieve all stereotypes to be displayed
if (parentView == null) {
- return "";
+ return EMPTY_STRING;
}
// try to display stereotype properties
- String stereotypesToDisplay = helper.getStereotypeTextToDisplay(parentView);
- return stereotypesToDisplay;
- }
+ final String stereotypesToDisplay = helper.getStereotypeTextToDisplay(parentView);
+ final String stereotypesPropertiesToDisplay = helper.getStereotypePropertiesInBrace(parentView);
+ String display = getStereotypeAndPropertiesTextToDisplay(stereotypesToDisplay, stereotypesPropertiesToDisplay);
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy#refreshStereotypeBraceStructure(org.eclipse.uml2.uml.Stereotype)
- *
- * @param stereotype
- * Stereotype related to the Brace to refresh
- */
- @Override
- public void refreshStereotypeBraceStructure(Stereotype stereotype) {
- // Nothing to Do
- }
-
+ return display;
+ }
/**
- * Refresh the text of the stereotype
+ * @param stereotypesToDisplay
+ * @param stereotypesPropertiesToDisplay
+ * @param display
+ * @return
*/
- @Override
- protected void refreshStereotypeDisplay() {
- IFigure figure;
- if (getHost() instanceof IPapyrusEditPart) {
- figure = ((IPapyrusEditPart) getHost()).getPrimaryShape();
- } else {
- figure = hostEditPart.getFigure();
+ private String getStereotypeAndPropertiesTextToDisplay(final String stereotypesToDisplay, final String stereotypesPropertiesToDisplay) {
+ StringBuilder display = new StringBuilder();
+ if (stereotypesToDisplay != null && !stereotypesToDisplay.isEmpty()) {
+ display.append(stereotypesToDisplay);
}
- if (figure instanceof IPapyrusUMLElementFigure) {// calculate text
- // and icon to display
- final String stereotypesToDisplay = stereotypesToDisplay();
- ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay), null);
-
+ if (stereotypesPropertiesToDisplay != null && !stereotypesPropertiesToDisplay.isEmpty()) {
+ if (display.length() > 0) {
+ display.append(StereotypeDisplayConstant.STEREOTYPE_PROPERTY_SEPARATOR);
+ }
+ display.append(StereotypeDisplayConstant.BRACE_LEFT + stereotypesPropertiesToDisplay + StereotypeDisplayConstant.BRACE_RIGHT);
}
-
-
-
+ return display.toString();
}
+
}

Back to the top