svn commit: r12719 - trunk/src_new/org/argouml/kernel/Project.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2007-05-30 10:56:29-0700
New Revision: 12719

Modified:
   trunk/src_new/org/argouml/kernel/Project.java

Log:
Now I finally know how a Vetoable Change Event works, I want to correct this old code written by me a long time ago.

This was complicated by the fact that there is a bug in GEF, which caused a nullpointerexception when deleting a Diagram that did not have any vetolistener set.

I adapted GEF, and leave some temporary code in place until a new GEF is released.

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=12719&p1=trunk/src_new/org/argouml/kernel/Project.java&p2=trunk/src_new/org/argouml/kernel/Project.java&r1=12718&r2=12719
==============================================================================
--- trunk/src_new/org/argouml/kernel/Project.java	(original)
+++ trunk/src_new/org/argouml/kernel/Project.java	2007-05-30 10:56:29-0700
@@ -25,6 +25,7 @@
 package org.argouml.kernel;
 
 import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.beans.PropertyVetoException;
 import java.beans.VetoableChangeListener;
 import java.beans.VetoableChangeSupport;
@@ -862,11 +863,30 @@
         // send indeterminate new value instead of making copy of vector
 	d.setProject(this);
         diagrams.add(d);
+        
+        // TODO: Remove this next line after GEF 0.12.4M4 
+        // is replaced by a newer one - it fixes a GEF bug 
+        // when removing a diagram:
         d.addVetoableChangeListener(new Vcl());
+
+        d.addPropertyChangeListener("name", new NamePCL());
         setSaveEnabled(true);
     }
 
     /**
+     * Listener to events from the Diagram class. <p>
+     *
+     * Purpose: changing the name of a diagram shall set the need save flag.
+     *
+     * @author Michiel
+     */
+    private class NamePCL implements PropertyChangeListener {
+        public void propertyChange(PropertyChangeEvent evt) {
+            setSaveEnabled(true);
+        }
+    }
+
+    /**
      * Removes a diagram from the list with diagrams.
      *
      * Removes (hopefully) the event listeners for this diagram.  Does
@@ -892,18 +912,14 @@
     }
 
     /**
-     * Listener to events from the Diagram class. <p>
+     * TODO: Remove this class after GEF 0.12.4M4 is replaced by a newer one
      *
-     * Purpose: changing the name of a diagram shall set the need save flag.
-     *
-     * @author [email protected]
+     * @author Michiel
      */
     private class Vcl implements VetoableChangeListener {
         public void vetoableChange(PropertyChangeEvent evt)
             throws PropertyVetoException {
-            if (evt.getPropertyName().equals("name")) {
-                setSaveEnabled(true);
-            }
+            //
         }
     }
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.