Author: thn
Date: 2010-06-05 06:54:28-0700
New Revision: 18434
Modified:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ExpressionModel.java
Log:
UML2: enable property panel for Method bodies
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ExpressionModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ExpressionModel.java?view=diff&pathrev=18434&r1=18433&r2=18434
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ExpressionModel.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ExpressionModel.java 2010-06-05 06:54:28-0700
@@ -8,6 +8,7 @@
*
* Contributors:
* Bob Tarling
+ * Thomas Neustupny
*******************************************************************************
*/
@@ -49,7 +50,8 @@
import org.argouml.model.Model;
/**
- * The model for Expressions.
+ * The model for entities with body and language attributes (Expression in
+ * UML1, OpaqueExpression/OpaqueBehavior in UML2).
* The target is the UML element to which this Expression is attached.
*
* The ChangeEvent/ChangeListener handling is inspired by
@@ -57,7 +59,7 @@
* It listens to UML model changes not caused by us,
* which need to trigger an update of the UI rendering.
*
- * @author mkl, penyaskito, mvw
+ * @author mkl, penyaskito, mvw, thn
*/
class ExpressionModel implements PropertyChangeListener {
@@ -126,7 +128,14 @@
* @return the expression
*/
public Object getExpression() {
- return getterSetterManager.get(target, propertyName, type);
+ Object expression = null;
+ if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
+ expression = getterSetterManager.get(target, propertyName, type);
+ } else {
+ // in UML2, the target is already the "expression" (Opaque...)
+ expression = target;
+ }
+ return expression;
}
/**
@@ -147,7 +156,7 @@
* @return the language of the expression
*/
public String getLanguage() {
- Object expression = getExpression();
+ Object expression = getExpression();
if (expression == null) {
return EMPTYSTRING;
}
@@ -223,22 +232,28 @@
* @param body the body text of the expression
*/
private void setExpression(String lang, String body) {
-
- // Expressions are DataTypes, not independent model elements
- // be careful not to reuse them
- final Object currentExpression = getExpression();
- removeModelEventListener();
- if (currentExpression != null) {
- Model.getUmlFactory().delete(currentExpression);
- }
- final Object newExpression;
- if (lang.length() == 0 && body.length()==0) {
- newExpression = null;
+ if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
+ // Expressions are DataTypes, not independent model elements
+ // be careful not to reuse them
+ final Object currentExpression = getExpression();
+ removeModelEventListener();
+ if (currentExpression != null) {
+ Model.getUmlFactory().delete(currentExpression);
+ }
+ final Object newExpression;
+ if (lang.length() == 0 && body.length()==0) {
+ newExpression = null;
+ } else {
+ newExpression = newExpression(lang, body);
+ }
+ setExpression(newExpression);
+ addModelEventListener();
} else {
- newExpression = newExpression(lang, body);
+ // reuse Opaque..., just set it's attributes
+ Object expression = getExpression();
+ Model.getDataTypesHelper().setBody(expression, body);
+ Model.getDataTypesHelper().setLanguage(expression, lang);
}
- setExpression(newExpression);
- addModelEventListener();
}
/**
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2617268
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.