Author: mvw
Date: 2007-12-11 13:34:52-0800
New Revision: 13909
Added:
trunk/src_new/org/argouml/application/events/ArgoProfileEvent.java (contents, props changed)
trunk/src_new/org/argouml/application/events/ArgoProfileEventListener.java (contents, props changed)
Modified:
trunk/src_new/org/argouml/application/events/ArgoEventPump.java
trunk/src_new/org/argouml/application/events/ArgoEventTypes.java
trunk/src_new/org/argouml/kernel/ProfileConfiguration.java
trunk/src_new/org/argouml/ui/ProjectSettingsTabProfile.java
trunk/src_new/org/argouml/ui/explorer/ExplorerEventAdaptor.java
Log:
Removed last dependency of the org.argouml.kernel package on the (explorer) ui.
Added firing events when profiles are added or removed to/from the project.
The explorer now listens to these events to update the tree.
Modified: trunk/src_new/org/argouml/application/events/ArgoEventPump.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/application/events/ArgoEventPump.java?view=diff&rev=13909&p1=trunk/src_new/org/argouml/application/events/ArgoEventPump.java&p2=trunk/src_new/org/argouml/application/events/ArgoEventPump.java&r1=13908&r2=13909
==============================================================================
--- trunk/src_new/org/argouml/application/events/ArgoEventPump.java (original)
+++ trunk/src_new/org/argouml/application/events/ArgoEventPump.java 2007-12-11 13:34:52-0800
@@ -254,6 +254,31 @@
break;
}
}
+
+ /**
+ * Handle firing a profile event.
+ *
+ * @param event The event to be fired.
+ * @param listener The listener.
+ */
+ private void handleFireProfileEvent(
+ ArgoProfileEvent event,
+ ArgoProfileEventListener listener) {
+ switch (event.getEventType()) {
+ case ArgoEventTypes.PROFILE_ADDED:
+ listener.profileAdded(event);
+ break;
+
+ case ArgoEventTypes.PROFILE_REMOVED:
+ listener.profileRemoved(event);
+ break;
+
+ default:
+ LOG.error("Invalid event:" + event.getEventType());
+ break;
+ }
+ }
+
/**
* Handle firing a generator event.
*
@@ -333,6 +358,13 @@
(ArgoStatusEventListener) listener);
}
}
+ if (event.getEventType() >= ArgoEventTypes.ANY_PROFILE_EVENT
+ && event.getEventType() < ArgoEventTypes.LAST_PROFILE_EVENT) {
+ if (listener instanceof ArgoProfileEventListener) {
+ handleFireProfileEvent((ArgoProfileEvent) event,
+ (ArgoProfileEventListener) listener);
+ }
+ }
}
}
Modified: trunk/src_new/org/argouml/application/events/ArgoEventTypes.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/application/events/ArgoEventTypes.java?view=diff&rev=13909&p1=trunk/src_new/org/argouml/application/events/ArgoEventTypes.java&p2=trunk/src_new/org/argouml/application/events/ArgoEventTypes.java&r1=13908&r2=13909
==============================================================================
--- trunk/src_new/org/argouml/application/events/ArgoEventTypes.java (original)
+++ trunk/src_new/org/argouml/application/events/ArgoEventTypes.java 2007-12-11 13:34:52-0800
@@ -202,6 +202,26 @@
int LAST_DIAGRAM_APPEARANCE_EVENT = 1699;
/**
+ * Indicating any profile event.
+ */
+ int ANY_PROFILE_EVENT = 1700;
+
+ /**
+ * Indicating that a profile has been added.
+ */
+ int PROFILE_ADDED = 1701;
+
+ /**
+ * Indicating that a profile has been removed.
+ */
+ int PROFILE_REMOVED = 1702;
+
+ /**
+ * Last profile event.
+ */
+ int LAST_PROFILE_EVENT = 1799;
+
+ /**
* Id marker for the last Argo event.
*/
int ARGO_EVENT_END = 99999;
Added: trunk/src_new/org/argouml/application/events/ArgoProfileEvent.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/application/events/ArgoProfileEvent.java?view=auto&rev=13909
==============================================================================
--- (empty file)
+++ trunk/src_new/org/argouml/application/events/ArgoProfileEvent.java 2007-12-11 13:34:52-0800
@@ -0,0 +1,49 @@
+// $Id$
+// Copyright (c) 2007 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.application.events;
+
+/**
+ * ArgoProfileEvent is used to notify interested parties
+ * that the profile is changed.
+ *
+ * @author Michiel
+ */
+public class ArgoProfileEvent extends ArgoEvent {
+
+ /**
+ * @param eT reported by this event
+ * @param src object that caused the event
+ */
+ public ArgoProfileEvent(int eT, Object src) {
+ super(eT, src);
+ }
+
+ /**
+ * Indicates the start of the 100-digit range for profile events.
+ *
+ * @return the first id reserved for events.
+ */
+ public int getEventStartRange() { return ANY_PROFILE_EVENT; }
+}
Added: trunk/src_new/org/argouml/application/events/ArgoProfileEventListener.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/application/events/ArgoProfileEventListener.java?view=auto&rev=13909
==============================================================================
--- (empty file)
+++ trunk/src_new/org/argouml/application/events/ArgoProfileEventListener.java 2007-12-11 13:34:52-0800
@@ -0,0 +1,47 @@
+// $Id$
+// Copyright (c) 2007 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.application.events;
+
+import org.argouml.application.api.ArgoEventListener;
+
+/**
+ * An interface that all objects interested in ProfileEvent
+ * notifications shall implement.
+ *
+ * @author Michiel
+ */
+public interface ArgoProfileEventListener extends ArgoEventListener {
+ /**
+ * Invoked when a profile has been added.
+ * @param e <code>ArgoProfileEvent</code> describing the added notation.
+ */
+ public void profileAdded(ArgoProfileEvent e);
+
+ /**
+ * Invoked when a profile has been removed.
+ * @param e <code>ArgoProfileEvent</code> describing the removed notation.
+ */
+ public void profileRemoved(ArgoProfileEvent e);
+}
Modified: trunk/src_new/org/argouml/kernel/ProfileConfiguration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProfileConfiguration.java?view=diff&rev=13909&p1=trunk/src_new/org/argouml/kernel/ProfileConfiguration.java&p2=trunk/src_new/org/argouml/kernel/ProfileConfiguration.java&r1=13908&r2=13909
==============================================================================
--- trunk/src_new/org/argouml/kernel/ProfileConfiguration.java (original)
+++ trunk/src_new/org/argouml/kernel/ProfileConfiguration.java 2007-12-11 13:34:52-0800
@@ -25,14 +25,18 @@
package org.argouml.kernel;
import java.awt.Image;
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.ArrayList;
import org.apache.log4j.Logger;
+import org.argouml.application.events.ArgoEventPump;
+import org.argouml.application.events.ArgoEventTypes;
+import org.argouml.application.events.ArgoProfileEvent;
import org.argouml.configuration.Configuration;
import org.argouml.configuration.ConfigurationKey;
import org.argouml.model.Model;
@@ -42,7 +46,6 @@
import org.argouml.profile.Profile;
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileFacade;
-import org.argouml.ui.explorer.ExplorerEventAdaptor;
/**
* This class captures represents the unique access point for the
@@ -174,8 +177,9 @@
}
updateStrategies();
- // TODO: remove this dependency
- ExplorerEventAdaptor.getInstance().structureChanged();
+ ArgoEventPump.fireEvent(new ArgoProfileEvent(
+ ArgoEventTypes.PROFILE_ADDED, new PropertyChangeEvent(this,
+ "profile", null, p)));
}
}
@@ -219,9 +223,10 @@
removeProfile(profile);
}
- updateStrategies();
- // TODO: remove this dependency
- ExplorerEventAdaptor.getInstance().structureChanged();
+ updateStrategies();
+ ArgoEventPump.fireEvent(new ArgoProfileEvent(
+ ArgoEventTypes.PROFILE_REMOVED, new PropertyChangeEvent(this,
+ "profile", p, null)));
}
private FigNodeStrategy compositeFigNodeStrategy = new FigNodeStrategy() {
Modified: trunk/src_new/org/argouml/ui/ProjectSettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/ProjectSettingsTabProfile.java?view=diff&rev=13909&p1=trunk/src_new/org/argouml/ui/ProjectSettingsTabProfile.java&p2=trunk/src_new/org/argouml/ui/ProjectSettingsTabProfile.java&r1=13908&r2=13909
==============================================================================
--- trunk/src_new/org/argouml/ui/ProjectSettingsTabProfile.java (original)
+++ trunk/src_new/org/argouml/ui/ProjectSettingsTabProfile.java 2007-12-11 13:34:52-0800
@@ -50,15 +50,14 @@
import org.argouml.application.api.GUISettingsTabInterface;
import org.argouml.i18n.Translator;
+import org.argouml.kernel.ProfileConfiguration;
import org.argouml.kernel.ProjectManager;
import org.argouml.kernel.ProjectSettings;
-import org.argouml.ui.explorer.ExplorerEventAdaptor;
-import org.argouml.uml.diagram.ui.FigNodeModelElement;
import org.argouml.profile.Profile;
-import org.argouml.kernel.ProfileConfiguration;
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileFacade;
import org.argouml.profile.UserDefinedProfile;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
/**
* The Tab where new profiles can be added and the registered
@@ -447,8 +446,7 @@
pc.addProfile(profile);
}
}
-
- ExplorerEventAdaptor.getInstance().structureChanged();
+
}
}
Modified: trunk/src_new/org/argouml/ui/explorer/ExplorerEventAdaptor.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/ExplorerEventAdaptor.java?view=diff&rev=13909&p1=trunk/src_new/org/argouml/ui/explorer/ExplorerEventAdaptor.java&p2=trunk/src_new/org/argouml/ui/explorer/ExplorerEventAdaptor.java&r1=13908&r2=13909
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/ExplorerEventAdaptor.java (original)
+++ trunk/src_new/org/argouml/ui/explorer/ExplorerEventAdaptor.java 2007-12-11 13:34:52-0800
@@ -26,6 +26,10 @@
import java.beans.PropertyChangeListener;
+import org.argouml.application.events.ArgoEventPump;
+import org.argouml.application.events.ArgoEventTypes;
+import org.argouml.application.events.ArgoProfileEvent;
+import org.argouml.application.events.ArgoProfileEventListener;
import org.argouml.configuration.Configuration;
import org.argouml.kernel.ProjectManager;
import org.argouml.model.AddAssociationEvent;
@@ -85,6 +89,8 @@
// tailored to cut down on event traffic. - tfm 20060410
Model.getPump().addClassModelEventListener(this,
Model.getMetaTypes().getModelElement(), (String[]) null);
+ ArgoEventPump.addListener(
+ ArgoEventTypes.ANY_PROFILE_EVENT, new ProfileChangeListener());
}
/**
@@ -209,7 +215,24 @@
treeModel.modelElementRemoved(pce.getOldValue());
}
}
+ }
+
+ /**
+ * Listener for additions and removals of profiles.
+ * Since they generally have a major impact on the explorer tree,
+ * we simply update them completely.
+ *
+ * @author Michiel
+ */
+ class ProfileChangeListener implements ArgoProfileEventListener {
+ public void profileAdded(ArgoProfileEvent e) {
+ structureChanged();
+ }
+ public void profileRemoved(ArgoProfileEvent e) {
+ structureChanged();
+ }
+
}
}
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.