svn commit: r16808 - trunk/src/argouml-app/src/org/argouml/uml/ui
Michiel van der Wulp <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mvw
Date: 2009-02-19 10:06:20-0800
New Revision: 16808
Modified:
trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionBodyField.java
trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionLanguageField.java
trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionModel2.java
Log:
Fix for issue 5648: Script field does not follow model changes.
Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionBodyField.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionBodyField.java?view=diff&pathrev=16808&r1=16807&r2=16808
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionBodyField.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionBodyField.java 2009-02-19 10:06:20-0800
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Copyright (c) 1996-2009 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -33,14 +33,15 @@
import org.apache.log4j.Logger;
import org.argouml.i18n.Translator;
import org.argouml.ui.LookAndFeelMgr;
+import org.argouml.ui.targetmanager.TargetListener;
+import org.argouml.ui.targetmanager.TargettableModelView;
/**
* This text field shows the body of a UML expression.
- *
*/
public class UMLExpressionBodyField extends JTextArea
implements DocumentListener, UMLUserInterfaceComponent,
- PropertyChangeListener {
+ PropertyChangeListener, TargettableModelView {
/**
* Logger.
@@ -125,4 +126,8 @@
public void insertUpdate(final DocumentEvent p1) {
model.setBody(getText());
}
+
+ public TargetListener getTargettableModel() {
+ return model;
+ }
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionLanguageField.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionLanguageField.java?view=diff&pathrev=16808&r1=16807&r2=16808
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionLanguageField.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionLanguageField.java 2009-02-19 10:06:20-0800
@@ -42,14 +42,15 @@
/**
* Creates a new field that selects the language for an expression.
*
- * @param m Expression model, should be shared between
+ * @param expressionModel Expression model, should be shared between
* Language and Body fields
- * @param n Only one of Language and Body fields should
+ * @param notify Only one of Language and Body fields should
* forward events to model
*/
- public UMLExpressionLanguageField(UMLExpressionModel2 m, boolean n) {
- model = m;
- notifyModel = n;
+ public UMLExpressionLanguageField(UMLExpressionModel2 expressionModel,
+ boolean notify) {
+ model = expressionModel;
+ notifyModel = notify;
getDocument().addDocumentListener(this);
setToolTipText(Translator.localize("label.language.tooltip"));
setFont(LookAndFeelMgr.getInstance().getStandardFont());
@@ -59,7 +60,9 @@
* @see org.argouml.uml.ui.UMLUserInterfaceComponent#targetChanged()
*/
public void targetChanged() {
- if (notifyModel) model.targetChanged();
+ if (notifyModel) {
+ model.targetChanged();
+ }
update();
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionModel2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionModel2.java?view=diff&pathrev=16808&r1=16807&r2=16808
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionModel2.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/UMLExpressionModel2.java 2009-02-19 10:06:20-0800
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2009 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -24,17 +24,32 @@
package org.argouml.uml.ui;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.SwingUtilities;
+
import org.argouml.model.Model;
+import org.argouml.ui.TabTarget;
+import org.argouml.ui.targetmanager.TargetEvent;
+import org.argouml.ui.targetmanager.TargetListener;
+import org.tigris.gef.presentation.Fig;
/**
+ * The model for an expression.
+ * An expression consists of a body and a language.
+ *
* @author mkl
*/
-public abstract class UMLExpressionModel2 {
+public abstract class UMLExpressionModel2
+ implements TargetListener, PropertyChangeListener {
private UMLUserInterfaceContainer container;
private String propertyName;
- private Object/*MExpression*/ expression;
+ private Object expression;
private boolean mustRefresh;
private static final String EMPTYSTRING = "";
+
+ private Object target = null;
/**
* The constructor.
@@ -169,4 +184,78 @@
return container;
}
+ /**
+ * TODO: The next text was copied - to adapt.
+ *
+ * Sets the target. If the old target is an UML Element, it also removes
+ * the model from the element listener list of the target. If the new target
+ * is an UML Element, the model is added as element listener to the
+ * new target. <p>
+ *
+ * This function is called when the user changes the target.
+ * Hence, this shall not result in any UML model changes.<p>
+ *
+ * This function looks a lot like the one in UMLComboBoxModel2.
+ * <p>
+ * As a possible future extension, we could allow listening to
+ * other model elements.
+ *
+ * @param theNewTarget the new target
+ */
+ public void setTarget(Object theNewTarget) {
+ theNewTarget = theNewTarget instanceof Fig
+ ? ((Fig) theNewTarget).getOwner() : theNewTarget;
+ if (Model.getFacade().isAUMLElement(target)) {
+ Model.getPump().removeModelEventListener(this, target,
+ propertyName);
+ // Allow listening to other elements:
+ // removeOtherModelEventListeners(listTarget);
+ }
+
+ if (Model.getFacade().isAUMLElement(theNewTarget)) {
+ target = theNewTarget;
+ Model.getPump().addModelEventListener(this, target,
+ propertyName);
+ // Allow listening to other elements:
+ // addOtherModelEventListeners(listTarget);
+
+ if (container instanceof TabTarget) {
+ ((TabTarget) container).refresh();
+ }
+ } else {
+ target = null;
+ }
+ }
+
+ public void propertyChange(PropertyChangeEvent e) {
+ if (target != null && target == e.getSource()) {
+ mustRefresh = true;
+ expression = null;
+ /* This works - we do get an event - and now
+ * refresh the UI: */
+ if (container instanceof TabTarget) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ ((TabTarget) container).refresh();
+ /* TODO: The above statement also refreshes when
+ * we are not shown (to be verified) - hence
+ * not entirely correct. */
+ }
+ });
+ }
+ }
+ }
+
+ public void targetAdded(TargetEvent e) {
+ setTarget(e.getNewTarget());
+ }
+
+ public void targetRemoved(TargetEvent e) {
+ setTarget(e.getNewTarget());
+ }
+
+ public void targetSet(TargetEvent e) {
+ setTarget(e.getNewTarget());
+ }
+
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1193215
To unsubscribe from this discussion, e-mail: [[email protected]].