Author: mvw
Date: 2007-05-31 11:18:15-0700
New Revision: 12737
Modified:
trunk/src_new/org/argouml/kernel/Project.java
trunk/src_new/org/argouml/ui/targetmanager/TargetManager.java
trunk/src_new/org/argouml/uml/diagram/static_structure/ui/CommentEdge.java
Log:
Reduce the dependency from the Project (org.argouml.kernel) on the GUI (org.argouml.ui.targetmanager).
All CommentEdges now send a "remove" event when they are deleted, and the TargetManager listens to these to clear its history.
Modified: trunk/src_new/org/argouml/kernel/Project.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/Project.java?view=diff&rev=12737&p1=trunk/src_new/org/argouml/kernel/Project.java&p2=trunk/src_new/org/argouml/kernel/Project.java&r1=12736&r2=12737
==============================================================================
--- trunk/src_new/org/argouml/kernel/Project.java (original)
+++ trunk/src_new/org/argouml/kernel/Project.java 2007-05-31 11:18:15-0700
@@ -1114,13 +1114,10 @@
// are not deleted (crtl-Del) they are removed (Del)
LOG.error("Request to delete a Fig " + obj.getClass().getName());
} else if (obj instanceof CommentEdge) {
- TargetManager.getInstance().removeTarget(obj);
- TargetManager.getInstance().removeHistoryElement(obj);
CommentEdge ce = (CommentEdge) obj;
LOG.info("Removing the link from " + ce.getAnnotatedElement()
+ " to " + ce.getComment());
- Model.getCoreHelper().removeAnnotatedElement(
- ce.getComment(), ce.getAnnotatedElement());
+ ce.delete();
}
}
Modified: trunk/src_new/org/argouml/ui/targetmanager/TargetManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/targetmanager/TargetManager.java?view=diff&rev=12737&p1=trunk/src_new/org/argouml/ui/targetmanager/TargetManager.java&p2=trunk/src_new/org/argouml/ui/targetmanager/TargetManager.java&r1=12736&r2=12737
==============================================================================
--- trunk/src_new/org/argouml/ui/targetmanager/TargetManager.java (original)
+++ trunk/src_new/org/argouml/ui/targetmanager/TargetManager.java 2007-05-31 11:18:15-0700
@@ -34,12 +34,15 @@
import java.util.List;
import java.util.ListIterator;
+import javax.management.ListenerNotFoundException;
+import javax.management.Notification;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationListener;
import javax.swing.event.EventListenerList;
import org.apache.log4j.Logger;
import org.argouml.kernel.Project;
import org.argouml.kernel.ProjectManager;
-import org.argouml.model.DeleteInstanceEvent;
import org.argouml.model.Model;
import org.argouml.uml.diagram.ui.UMLDiagram;
import org.tigris.gef.base.Diagram;
@@ -938,13 +941,15 @@
}
/**
- * The listener to UML model changes.
- * Deleted model elements are removed
- * from the target list or from the history.
+ * The listener to removals of UML model elements,
+ * diagrams and CommentEdges.
+ * Deleted elements are removed
+ * from the target list and/or from the history.
*
* @author michiel
*/
- private abstract class Remover implements PropertyChangeListener
+ private abstract class Remover implements PropertyChangeListener,
+ NotificationListener
{
private void addListener(Object o) {
@@ -952,6 +957,9 @@
Model.getPump().addModelEventListener(this, o, "remove");
} else if (o instanceof UMLDiagram) {
((UMLDiagram) o).addPropertyChangeListener(this);
+ } else if (o instanceof NotificationEmitter) {
+ ((NotificationEmitter) o).addNotificationListener(
+ this, null, o);
}
}
@@ -960,6 +968,13 @@
Model.getPump().removeModelEventListener(this, o, "remove");
} else if (o instanceof UMLDiagram) {
((UMLDiagram) o).removePropertyChangeListener(this);
+ } else if (o instanceof NotificationEmitter) {
+ try {
+ ((NotificationEmitter) o).removeNotificationListener(this);
+ } catch (ListenerNotFoundException e) {
+ LOG.error("Notification Listener for "
+ + "CommentEdge not found", e);
+ }
}
}
@@ -978,6 +993,17 @@
remove(evt.getSource());
}
}
+
+ /*
+ * @see javax.management.NotificationListener#handleNotification(javax.management.Notification, java.lang.Object)
+ */
+ public void handleNotification(Notification notification,
+ Object handback) {
+ if ("remove".equals(notification.getType())) {
+ remove(notification.getSource());
+ }
+
+ }
protected abstract void remove(Object obj);
}
Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/CommentEdge.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/CommentEdge.java?view=diff&rev=12737&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/CommentEdge.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/CommentEdge.java&r1=12736&r2=12737
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/CommentEdge.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/CommentEdge.java 2007-05-31 11:18:15-0700
@@ -24,6 +24,9 @@
package org.argouml.uml.diagram.static_structure.ui;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+
import org.argouml.i18n.Translator;
import org.argouml.model.Model;
import org.argouml.model.UUIDManager;
@@ -39,7 +42,7 @@
* @since Jul 17, 2004
* @author [email protected]
*/
-public class CommentEdge {
+public class CommentEdge extends NotificationBroadcasterSupport {
private Object source;
private Object dest;
private Object uuid;
@@ -147,6 +150,7 @@
if (Model.getFacade().isAComment(dest))
Model.getCoreHelper().removeAnnotatedElement(dest, source);
}
+ this.sendNotification(new Notification("remove", this, 0));
}
/*
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.