Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCéline Janssens2015-03-06 09:58:05 +0000
committerCéline Janssens2015-03-06 09:58:05 +0000
commitb88c18edecf32538cdb17d6de206e7a925cd889f (patch)
treeaefcf009c2c73f8aa9da8debd2476034f23db765
parent6b9a563340e51bd83960562461ec1f388a4d8ba5 (diff)
downloadorg.eclipse.papyrus-b88c18edecf32538cdb17d6de206e7a925cd889f.tar.gz
org.eclipse.papyrus-b88c18edecf32538cdb17d6de206e7a925cd889f.tar.xz
org.eclipse.papyrus-b88c18edecf32538cdb17d6de206e7a925cd889f.zip
Bug 460356: [Stereotype Display] Objective 4c. Display properties into a
comment thanks to CSS. - Fix "null" text in front of Oparation and Label. https://bugs.eclipse.org/bugs/show_bug.cgi?id=460356 Change-Id: Ib9d333934484855bda811c49e5f52c481b093034 Change-Id: Ib9d333934484855bda811c49e5f52c481b093034 Signed-off-by: Céline Janssens <Celine.Janssens@all4tec.net>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java53
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java22
2 files changed, 44 insertions, 31 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
index f1cd20bb549..d66fcf17a39 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
@@ -70,16 +70,18 @@ public abstract class StereotypedElementLabelHelper {
*/
protected Map<String, List<String>> parseStereotypeProperties(GraphicalEditPart editPart, String stereotypesToDisplay, String stereotypesPropertiesToDisplay) {
Map<String, List<String>> propertiesMap = new HashMap<String, List<String>>();
- StringTokenizer stringTokenizer = new StringTokenizer(stereotypesPropertiesToDisplay, UMLVisualInformationPapyrusConstant.STEREOTYPE_PROPERTIES_LIST_SEPARATOR);
- while (stringTokenizer.hasMoreTokens()) {
- String propertyName = stringTokenizer.nextToken();
- // retrieve the name of the stereotype for this property
- String stereotypeName = propertyName.substring(0, propertyName.lastIndexOf(".")); // stereotypequalifiedName.propertyname
- if (!propertiesMap.containsKey(stereotypeName)) {
- List<String> propertiesForStereotype = new ArrayList<String>();
- propertiesMap.put(stereotypeName, propertiesForStereotype);
+ if (stereotypesPropertiesToDisplay != null) {
+ StringTokenizer stringTokenizer = new StringTokenizer(stereotypesPropertiesToDisplay, UMLVisualInformationPapyrusConstant.STEREOTYPE_PROPERTIES_LIST_SEPARATOR);
+ while (stringTokenizer.hasMoreTokens()) {
+ String propertyName = stringTokenizer.nextToken();
+ // retrieve the name of the stereotype for this property
+ String stereotypeName = propertyName.substring(0, propertyName.lastIndexOf(".")); // stereotypequalifiedName.propertyname
+ if (!propertiesMap.containsKey(stereotypeName)) {
+ List<String> propertiesForStereotype = new ArrayList<String>();
+ propertiesMap.put(stereotypeName, propertiesForStereotype);
+ }
+ propertiesMap.get(stereotypeName).add(propertyName.substring(propertyName.lastIndexOf(".") + 1, propertyName.length()));
}
- propertiesMap.get(stereotypeName).add(propertyName.substring(propertyName.lastIndexOf(".") + 1, propertyName.length()));
}
return propertiesMap;
}
@@ -126,7 +128,7 @@ public abstract class StereotypedElementLabelHelper {
* @return a string that displays stereotypes (using their simple name or
* their qualified name) and their properties
*/
- public String stereotypesAndPropertiesToDisplay(GraphicalEditPart editPart, String separator, String stereotypesToDisplay, String stereotypeWithQualifiedName, String stereotypesPropertiesToDisplay) {
+ public String stereotypesAndPropertiesToDisplay(GraphicalEditPart editPart, String separator, String stereotypesToDisplay, String stereotypesPropertiesToDisplay) {
// Get the preference from PreferenceStore. there should be an assert
final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
if (store == null) {
@@ -149,14 +151,7 @@ public abstract class StereotypedElementLabelHelper {
Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
if (stereotype != null) {
String name = currentStereotype;
- if ((stereotypeWithQualifiedName.indexOf(currentStereotype)) == -1) {
- // property value contains qualifiedName ==> extract name
- // from it
- StringTokenizer strToken = new StringTokenizer(currentStereotype, "::");
- while (strToken.hasMoreTokens()) {
- name = strToken.nextToken();
- }
- }
+
// AL Changes Feb. 07 - Beg
// Handling STEREOTYPE_NAME_APPEARANCE preference (from
// ProfileApplicationPreferencePage)
@@ -172,7 +167,7 @@ public abstract class StereotypedElementLabelHelper {
}
} else { // VisualInformationPapyrusConstants.P_STEREOTYPE_NAME_DISPLAY_UML_CONFORM))
// {
- name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
+
if (out.indexOf(name) == -1) {
out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator;
}
@@ -206,8 +201,26 @@ public abstract class StereotypedElementLabelHelper {
// retrieve all stereotypes to be displayed
// try to display stereotype properties
String stereotypesToDisplay = StereotypeDisplayHelper.getInstance().getStereotypeTextToDisplay(view);
+ String stereotypesPropertiesToDisplay = StereotypeDisplayHelper.getInstance().getStereotypePropertiesInBrace(view);
+
+
+ String display = "";
+ display += stereotypesAndPropertiesToDisplay(editPart, "\n", stereotypesToDisplay, stereotypesPropertiesToDisplay);
+
+
+ if (stereotypesToDisplay != null && !stereotypesToDisplay.equals("")) {
+ display += Activator.ST_LEFT + stereotypesToDisplay + Activator.ST_RIGHT + " ";
+ }
+ final String propSt = StereotypeUtil.getPropertiesValuesInBrace(stereotypesPropertiesToDisplay, getUMLElement(editPart));
+ if (propSt != null && !propSt.equals("")) {
+ if (stereotypesToDisplay != null && !stereotypesToDisplay.equals("")) {
+ // display += "\n";
+ }
+ display += "{" + propSt + "} ";
+ }
+
+ return display;
- return stereotypesToDisplay;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java
index a863e9bd5ef..7b2d8635386 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java
@@ -40,11 +40,13 @@ import org.eclipse.uml2.uml.util.UMLUtil;
* This Helper contains all the Methods required in the using of Stereotype Display thanks
* to the Notation View structure
*
- * @author Céline JANSSENS
+ * @author Celine JANSSENS
*
*/
public class StereotypeDisplayHelper {
+
+ private static final String EMPTY_STRING = ""; // $NON-NLS-1$
/**
* singleton instance
*/
@@ -62,7 +64,6 @@ public class StereotypeDisplayHelper {
return labelHelper;
}
- private static final String EMPTY_STRING = ""; // $NON-NLS-1$
/**
* Get the Full label to display into the header
@@ -72,16 +73,15 @@ public class StereotypeDisplayHelper {
* @return The label with Stereotype Name to display (i.e: "Blocks::Block, Allocation, SysML::Requirements::Requirement" )
*/
public String getStereotypeTextToDisplay(View model) {
- String textToDisplay = null;
- String finalText = null;
+ String textToDisplay = EMPTY_STRING;
+ String finalText = EMPTY_STRING;
Iterator<?> iter = model.getChildren().iterator();
- Object object;
- DecorationNode label;
+
// For all children, check if it's a StereotypeLabel and add the Name
while (iter.hasNext()) {
- object = iter.next();
+ Object object = iter.next();
if (object instanceof DecorationNode) {
- label = (DecorationNode) object;
+ DecorationNode label = (DecorationNode) object;
if (StereotypeDisplayUtils.STEREOTYPE_LABEL_TYPE.equals(label.getType())) {
if (label.isVisible()) {
@@ -112,7 +112,7 @@ public class StereotypeDisplayHelper {
* @return The entire string to be displayed in braces
*/
public String getStereotypePropertiesInBrace(View notationView) {
- String textToDisplay = null;
+ String textToDisplay = EMPTY_STRING;
Iterator<?> iter = notationView.getChildren().iterator();
Object object;
// For each Stereotype Compartment, retrieve the property text to be added in Braces
@@ -769,7 +769,7 @@ public class StereotypeDisplayHelper {
protected String addStereotypeCompartmentProperties(String textToDisplay, BasicCompartment compartment) {
- StringBuilder newTextToDisplay = new StringBuilder(textToDisplay == null ? "" : textToDisplay);
+ StringBuilder newTextToDisplay = new StringBuilder(textToDisplay);
StringBuilder propertiesText = new StringBuilder(EMPTY_STRING);
EList<?> properties = compartment.getChildren();
@@ -812,7 +812,7 @@ public class StereotypeDisplayHelper {
*/
protected StringBuilder addTextWithSeparator(final StringBuilder initialText, final String textToAdd, final String separator) {
- StringBuilder result = new StringBuilder(initialText == null ? "" : initialText);
+ StringBuilder result = new StringBuilder(initialText);
// if result and text to add is not empty, then add a separator
if ((!EMPTY_STRING.equals(textToAdd) && (textToAdd != null))) {

Back to the top