svn commit: r16651 - trunk/src/argouml-app/src/org/argouml: kernel ui/explorer ui/targetmanager uml/diagram/ui
Tom Morris <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: tfmorris
Date: 2009-01-18 11:54:02-0800
New Revision: 16651
Modified:
trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java
trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerEventAdaptor.java
trunk/src/argouml-app/src/org/argouml/ui/targetmanager/TargetManager.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/TabDiagram.java
Log:
RESOLVED - issue 5597: Deleting diagram does not switch diagram
http://argouml.tigris.org/issues/show_bug.cgi?id=5597
Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java?view=diff&pathrev=16651&r1=16650&r2=16651
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectImpl.java 2009-01-18 11:54:02-0800
@@ -49,6 +49,7 @@
import org.argouml.model.Model;
import org.argouml.profile.Profile;
import org.argouml.profile.ProfileFacade;
+import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.CommentEdge;
import org.argouml.uml.ProjectMemberModel;
import org.argouml.uml.cognitive.ProjectMemberTodoList;
@@ -353,10 +354,12 @@
*/
protected void removeProjectMemberDiagram(ArgoDiagram d) {
if (activeDiagram == d) {
+ LOG.debug("Deleting active diagram " + d);
ArgoDiagram defaultDiagram = null;
if (diagrams.size() == 1) {
// We're deleting the last diagram so lets create a new one
// TODO: Once we go MDI we won't need this.
+ LOG.debug("Deleting last diagram - creating new default diag");
Object projectRoot = getRoot();
if (!Model.getUmlFactory().isRemoved(projectRoot)) {
defaultDiagram = DiagramFactory.getInstance()
@@ -367,11 +370,15 @@
// Make the topmost diagram (that is not the one being deleted)
// current.
defaultDiagram = diagrams.get(0);
+ LOG.debug("Candidate default diagram is " + defaultDiagram);
if (defaultDiagram == d) {
defaultDiagram = diagrams.get(1);
+ LOG.debug("Switching default diagram to " + defaultDiagram);
}
}
activeDiagram = defaultDiagram;
+ TargetManager.getInstance().setTarget(activeDiagram);
+ LOG.debug("New active diagram is " + defaultDiagram);
}
removeDiagram(d);
@@ -833,9 +840,8 @@
}
} else if (obj instanceof ArgoDiagram) {
removeProjectMemberDiagram((ArgoDiagram) obj);
- // TODO: Is the following still true? fix it there! - tfm
- // Need to manually delete diagrams from explorer because they
- // don't have a decent event system set up:
+ // Fire an event some anyone who cares about diagrams being
+ // removed can listen for it
ProjectManager.getManager()
.firePropertyChanged("remove", obj, null);
} else if (obj instanceof Fig) {
Modified: trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerEventAdaptor.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerEventAdaptor.java?view=diff&pathrev=16651&r1=16650&r2=16651
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerEventAdaptor.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerEventAdaptor.java 2009-01-18 11:54:02-0800
@@ -209,9 +209,7 @@
// notation events
treeModel.structureChanged();
} else if (pce.getSource() instanceof ProjectManager) {
- // TODO: Bob says - I think we don't need this any more
- // we no longer get "remove" from ProjectManager but instead
- // a DeleteInstanceEvent (trapped above)
+ // Handle remove for non-UML elements (e.g. diagrams)
if ("remove".equals(pce.getPropertyName())) {
treeModel.modelElementRemoved(pce.getOldValue());
}
Modified: trunk/src/argouml-app/src/org/argouml/ui/targetmanager/TargetManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/targetmanager/TargetManager.java?view=diff&pathrev=16651&r1=16650&r2=16651
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/targetmanager/TargetManager.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/targetmanager/TargetManager.java 2009-01-18 11:54:02-0800
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2002-2007 The Regents of the University of California. All
+// Copyright (c) 2002-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
@@ -808,7 +808,6 @@
+ listeners[i + 1]
+ " an error is thrown.",
e);
- e.printStackTrace();
}
}
}
@@ -897,6 +896,7 @@
*/
public void navigateForward() throws IllegalStateException {
historyManager.navigateForward();
+ LOG.debug("Navigate forward");
}
/**
@@ -908,6 +908,8 @@
*/
public void navigateBackward() throws IllegalStateException {
historyManager.navigateBackward();
+ LOG.debug("Navigate backward");
+
}
/**
@@ -953,13 +955,20 @@
private abstract class Remover implements PropertyChangeListener,
NotificationListener
{
+
+ protected Remover() {
+ // Listen for the removal of diagrams from project
+ ProjectManager.getManager().addPropertyChangeListener(this);
+ }
private void addListener(Object o) {
if (Model.getFacade().isAModelElement(o)) {
Model.getPump().addModelEventListener(this, o, "remove");
} else if (o instanceof Diagram) {
+ // Figs on a diagram without an owning model element
((Diagram) o).addPropertyChangeListener(this);
} else if (o instanceof NotificationEmitter) {
+ // CommentEdge - the owner of a FigEdgeNote
((NotificationEmitter) o).addNotificationListener(
this, null, o);
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/TabDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/TabDiagram.java?view=diff&pathrev=16651&r1=16650&r2=16651
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/TabDiagram.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/TabDiagram.java 2009-01-18 11:54:02-0800
@@ -413,8 +413,13 @@
public void propertyChange(PropertyChangeEvent arg0) {
if ("remove".equals(arg0.getPropertyName())) {
- ArgoDiagram diagram = DiagramUtils.getActiveDiagram();
- TargetManager.getInstance().setTarget(diagram);
+ LOG.debug("Got remove event for diagram = " + arg0.getSource()
+ + " old value = " + arg0.getOldValue());
+ // Although we register for notification of diagrams being
+ // deleted, we currently depend on the TargetManager to assign
+ // a new target when this happens
+ // When we implement MDI and have our own list of open diagrams
+ // we can ressurect the use of this
}
}
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1033186
To unsubscribe from this discussion, e-mail: [[email protected]].