Author: tfmorris
Date: 2010-09-17 10:42:28-0700
New Revision: 18759
Modified:
trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java
Log:
Issue 6145: Fix up remaining Expression handling in this class
http://argouml.tigris.org/issues/show_bug.cgi?id=6145
Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java?view=diff&pathrev=18759&r1=18758&r2=18759
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java (original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java 2010-09-17 10:42:28-0700
@@ -11,7 +11,7 @@
* mvw
*****************************************************************************
*
- * Some portions of this file was previously release using the BSD License:
+ * Some portions of this file were previously released using the BSD License:
*/
// Copyright (c) 1996-2007 The Regents of the University of California. All
@@ -446,30 +446,42 @@
public void setRecurrence(Object handle, Object expr) {
- if (handle instanceof Action && expr instanceof IterationExpression) {
- ((Action) handle).setRecurrence((IterationExpression) expr);
- return;
+ Action action = (Action) handle;
+ IterationExpression oldExpr = action.getRecurrence();
+ IterationExpression newExpr = (IterationExpression) expr;
+ if (!equal(oldExpr, newExpr)) {
+ action.setRecurrence(newExpr);
+ if (oldExpr != null) {
+ Model.getUmlFactory().delete(oldExpr);
+ }
}
- throw new IllegalArgumentException("handle: " + handle + " or expr: "
- + expr);
}
+ private boolean equal(Expression expr1, Expression expr2) {
+ if (expr1 == null) {
+ if (expr2 == null) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return expr1.equals(expr2);
+ }
+ }
public void setScript(Object handle, Object expr) {
if (handle instanceof Action
&& (expr == null || expr instanceof ActionExpression)) {
Action a = (Action) handle;
- ActionExpression ae =a.getScript();
- if (ae == (ActionExpression) expr) {
+ ActionExpression oldae =a.getScript();
+ ActionExpression newae = (ActionExpression) expr;
+ if (equal(oldae,newae)) {
return;
}
- if (ae != null) {
+ a.setScript(newae);
+ if (oldae != null) {
/* Throw away the old actionExpression (see issue 6145): */
- a.setScript(null);
- modelImpl.getUmlFactory().delete(ae);
- }
- if (expr != null) {
- a.setScript((ActionExpression) expr);
+ modelImpl.getUmlFactory().delete(oldae);
}
return;
}
@@ -525,7 +537,15 @@
public void setTarget(Object handle, Object element) {
if (handle instanceof Action
&& element instanceof ObjectSetExpression) {
- ((Action) handle).setTarget((ObjectSetExpression) element);
+ Action action = (Action) handle;
+ ObjectSetExpression oldExpr = action.getTarget();
+ ObjectSetExpression newExpr = (ObjectSetExpression) element;
+ if (!equal(oldExpr, newExpr)) {
+ action.setTarget(newExpr);
+ if (oldExpr != null) {
+ Model.getUmlFactory().delete(oldExpr);
+ }
+ }
return;
}
if (handle instanceof Transition &&
@@ -557,6 +577,15 @@
public void setValue(Object handle, Object value) {
if (handle instanceof Argument) {
((Argument) handle).setValue((Expression) value);
+ Argument argument = (Argument) handle;
+ Expression oldExpr = argument.getValue();
+ Expression newExpr = (Expression) value;
+ if (!equal(oldExpr, newExpr)) {
+ argument.setValue(newExpr);
+ if (oldExpr != null) {
+ Model.getUmlFactory().delete(oldExpr);
+ }
+ }
return;
}
if (handle instanceof AttributeLink) {
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2661355
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.