Author: mvw
Date: 2011-05-02 23:06:53-0700
New Revision: 19320
Modified:
trunk/src/argouml-app/src/org/argouml/i18n/parsing.properties
trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationEndNameNotation.java
trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationNameNotation.java
trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationEndNameNotationUml.java
trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationNameNotationUml.java
Log:
Fix for issue 4252: Implement notation for "derived".
Modified: trunk/src/argouml-app/src/org/argouml/i18n/parsing.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/parsing.properties?view=diff&pathrev=19320&r1=19319&r2=19320
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/parsing.properties (original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/parsing.properties 2011-05-02 23:06:53-0700
@@ -66,9 +66,10 @@
["<<" stereo ">>"] [ "+" | "-" | "#" | "~" ] [name] ["("parameter-list")"] \
[":" return-type-expression] ["{" property "}"]
parsing.help.fig-actionstate = Enter the action expression.
-parsing.help.fig-association-name = Enter the name of the association.
+parsing.help.fig-association-name = Enter the name of the association according: \
+ ["/"] ["<<" stereo ">>"] [ "+" | "-" | "#" | "~" ] name
parsing.help.fig-association-end-name = Enter the association role name according: \
- ["<<" stereo ">>"] [ "+" | "-" | "#" | "~" ] name
+ ["/"] ["<<" stereo ">>"] [ "+" | "-" | "#" | "~" ] name
parsing.help.fig-association-role = Enter the association role name according: \
["/" name] [ ":" association ]
parsing.help.fig-association-source-multiplicity = Enter the multiplicity \
Modified: trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationEndNameNotation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationEndNameNotation.java?view=diff&pathrev=19320&r1=19319&r2=19320
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationEndNameNotation.java (original)
+++ trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationEndNameNotation.java 2011-05-02 23:06:53-0700
@@ -1,6 +1,6 @@
/* $Id$
*****************************************************************************
- * Copyright (c) 2009-2010 Contributors - see below
+ * Copyright (c) 2009-2011 Contributors - see below
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -71,7 +71,7 @@
public void initialiseListener(Object modelElement) {
addElementListener(
modelElement,
- new String[] {"name", "visibility", "stereotype"});
+ new String[] {"name", "visibility", "stereotype", "taggedValue"});
Collection stereotypes =
Model.getFacade().getStereotypes(modelElement);
Iterator iter = stereotypes.iterator();
@@ -81,6 +81,10 @@
o,
new String[] {"name", "remove"});
}
+ // We also show tagged values (the / for derived)
+ for (Object uml : Model.getFacade().getTaggedValuesCollection(modelElement)) {
+ addElementListener(uml);
+ }
}
@Override
@@ -88,7 +92,8 @@
PropertyChangeEvent pce) {
Object obj = pce.getSource();
if ((obj == modelElement)
- && "stereotype".equals(pce.getPropertyName())) {
+ && ("stereotype".equals(pce.getPropertyName())
+ || "taggedValue".equals(pce.getPropertyName()))) {
if (pce instanceof AddAssociationEvent
&& Model.getFacade().isAStereotype(pce.getNewValue())) {
// new stereotype
@@ -102,6 +107,14 @@
removeElementListener(
pce.getOldValue());
}
+ if (pce instanceof AddAssociationEvent
+ && Model.getFacade().isATaggedValue(pce.getNewValue())) {
+ addElementListener(pce.getNewValue());
+ }
+ if (pce instanceof RemoveAssociationEvent
+ && Model.getFacade().isATaggedValue(pce.getOldValue())) {
+ removeElementListener(pce.getOldValue());
+ }
}
}
Modified: trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationNameNotation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationNameNotation.java?view=diff&pathrev=19320&r1=19319&r2=19320
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationNameNotation.java (original)
+++ trunk/src/argouml-app/src/org/argouml/notation/providers/AssociationNameNotation.java 2011-05-02 23:06:53-0700
@@ -1,6 +1,6 @@
/* $Id$
*****************************************************************************
- * Copyright (c) 2009-2010 Contributors - see below
+ * Copyright (c) 2009-2011 Contributors - see below
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -68,7 +68,7 @@
public void initialiseListener(Object modelElement) {
/* Listen to the modelelement itself: */
addElementListener(modelElement,
- new String[] {"name", "visibility", "stereotype"});
+ new String[] {"name", "visibility", "stereotype", "taggedValue"});
Collection stereotypes =
Model.getFacade().getStereotypes(modelElement);
Iterator iter = stereotypes.iterator();
@@ -78,5 +78,9 @@
oneStereoType,
new String[] {"name", "remove"});
}
+ // We also show tagged values (the / for derived)
+ for (Object uml : Model.getFacade().getTaggedValuesCollection(modelElement)) {
+ addElementListener(uml);
+ }
}
}
Modified: trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationEndNameNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationEndNameNotationUml.java?view=diff&pathrev=19320&r1=19319&r2=19320
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationEndNameNotationUml.java (original)
+++ trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationEndNameNotationUml.java 2011-05-02 23:06:53-0700
@@ -1,13 +1,13 @@
/* $Id$
*****************************************************************************
- * Copyright (c) 2009-2010 Contributors - see below
+ * Copyright (c) 2009-2011 Contributors - see below
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * mvw
+ * Michiel van der Wulp
*****************************************************************************
*
* Some portions of this file was previously release using the BSD License:
@@ -45,6 +45,7 @@
import org.argouml.application.events.ArgoEventTypes;
import org.argouml.application.events.ArgoHelpEvent;
import org.argouml.i18n.Translator;
+import org.argouml.model.Facade;
import org.argouml.model.Model;
import org.argouml.notation.NotationSettings;
import org.argouml.notation.providers.AssociationEndNameNotation;
@@ -102,6 +103,14 @@
}
/**
+ * Parse a line of the form: <pre>
+ * [/] [visibility] name
+ * </pre><p>
+ *
+ * Stereotypes can be given between any element. It must be given
+ * in the form:
+ * <<stereotype1,stereotype2,stereotype3>>
+ *
* @param role The AssociationEnd <em>text</em> describes.
* @param text A String on the above format.
* @throws ParseException
@@ -115,7 +124,16 @@
String name = null;
StringBuilder stereotype = null;
String token;
+ boolean derived = false;
+ text = text.trim();
+ /* Handle Derived: */
+ if (text.length() > 0 && "/".indexOf(text.charAt(0)) >= 0) {
+ derived = true;
+ text = text.substring(1);
+ text = text.trim();
+ }
+
try {
st = new MyTokenizer(text, "<<,\u00AB,\u00BB,>>");
while (st.hasMoreTokens()) {
@@ -155,6 +173,8 @@
throw pre;
}
+ dealWithDerived(role, derived);
+
if (name != null) {
name = name.trim();
}
@@ -186,8 +206,22 @@
StereotypeUtility.dealWithStereotypes(role, stereotype, true);
}
+ private void dealWithDerived(Object umlObject, boolean derived) {
+ NotationUtilityUml.setDerived(umlObject, derived);
+ }
+
private String toString(Object modelElement, boolean showVisibility,
boolean useGuillemets) {
+ String derived = "";
+ Object tv = Model.getFacade().getTaggedValue(modelElement,
+ Facade.DERIVED_TAG);
+ if (tv != null) {
+ String tag = Model.getFacade().getValueOfTag(tv);
+ if ("true".equalsIgnoreCase(tag)) {
+ derived = "/";
+ }
+ }
+
String name = Model.getFacade().getName(modelElement);
if (name == null) {
name = "";
@@ -210,7 +244,7 @@
stereoString += " ";
}
- return stereoString + visibility + name;
+ return derived + stereoString + visibility + name;
}
@Override
Modified: trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationNameNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationNameNotationUml.java?view=diff&pathrev=19320&r1=19319&r2=19320
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationNameNotationUml.java (original)
+++ trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AssociationNameNotationUml.java 2011-05-02 23:06:53-0700
@@ -1,13 +1,13 @@
/* $Id$
*****************************************************************************
- * Copyright (c) 2009 Contributors - see below
+ * Copyright (c) 2009-2011 Contributors - see below
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * mvw
+ * Michiel van der Wulp
*****************************************************************************
*
* Some portions of this file was previously release using the BSD License:
@@ -44,6 +44,7 @@
import org.argouml.application.events.ArgoEventTypes;
import org.argouml.application.events.ArgoHelpEvent;
import org.argouml.i18n.Translator;
+import org.argouml.model.Facade;
import org.argouml.model.Model;
import org.argouml.notation.NotationSettings;
import org.argouml.notation.providers.AssociationNameNotation;
@@ -51,7 +52,7 @@
/**
* Handles the notation of the name of an association modelelement in UML,
* ie a string on the format:<pre>
- * [ << stereotype >>] [+|-|#|~] [name]
+ * [/] [ << stereotype >>] [+|-|#|~] [name]
* </pre>
*
* @author Michiel
@@ -80,7 +81,7 @@
*/
public void parse(Object modelElement, String text) {
try {
- NotationUtilityUml.parseModelElement(modelElement, text);
+ parseAssociationName(modelElement, text);
} catch (ParseException pe) {
String msg = "statusmsg.bar.error.parsing.association-name";
Object[] args = {
@@ -92,6 +93,22 @@
Translator.messageFormat(msg, args)));
}
}
+
+ protected void parseAssociationName(Object modelElement, String text)
+ throws ParseException {
+ boolean derived = false;
+
+ text = text.trim();
+ /* Handle Derived: */
+ if (text.length() > 0 && "/".indexOf(text.charAt(0)) >= 0) {
+ derived = true;
+ text = text.substring(1);
+ text = text.trim();
+ }
+ NotationUtilityUml.setDerived(modelElement, derived);
+
+ NotationUtilityUml.parseModelElement(modelElement, text);
+ }
/*
* @see org.argouml.notation.providers.NotationProvider#toString(java.lang.Object, java.util.Map)
@@ -111,9 +128,20 @@
if (showAssociationName == Boolean.FALSE) {
return "";
}
+
+ String derived = "";
+ Object tv = Model.getFacade().getTaggedValue(modelElement,
+ Facade.DERIVED_TAG);
+ if (tv != null) {
+ String tag = Model.getFacade().getValueOfTag(tv);
+ if ("true".equalsIgnoreCase(tag)) {
+ derived = "/";
+ }
+ }
String name = Model.getFacade().getName(modelElement);
StringBuffer sb = new StringBuffer("");
+ sb.append(derived);
if (fullyHandleStereotypes) {
sb.append(NotationUtilityUml.generateStereotype(modelElement,
useGuillemets));
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2728564
To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.