|
What this is
Other links
The source code// $Id: ProjectManager.java,v 1.35 2004/09/18 17:13:23 mvw Exp $ // Copyright (c) 1996-2004 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.kernel; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Vector; import javax.swing.event.EventListenerList; import org.apache.log4j.Logger; import org.argouml.ui.ArgoDiagram; /** * This class manages the projects loaded in argouml. * * Classes in Argouml can ask this class for the current * project and set the current project. Since we only have one * project in ArgoUML at the moment, this class does not manage a list * of projects like one would expect. This could be a nice extension * for the future of argouml. As soon as the current project is * changed, a property changed event is fired. * * @since Nov 17, 2002 * @author jaap.branderhorst@xs4all.nl * @stereotype singleton */ public final class ProjectManager { /** * The name of the property that defines the current project. */ public static final String CURRENT_PROJECT_PROPERTY_NAME = "currentProject"; /** * The name of the property that defines the save state. */ public static final String SAVE_STATE_PROPERTY_NAME = "saveState"; /** logger */ private static final Logger LOG = Logger.getLogger(ProjectManager.class); /** * The singleton instance of this class */ private static ProjectManager instance; /** * The project that is visible in the projectbrowser */ private static Project currentProject; /** * Flag to indicate we are creating a new current project */ private boolean creatingCurrentProject; /** * The listener list */ private EventListenerList listenerList = new EventListenerList(); /** * The event to fire. * * TODO: Investigate! Is the purpose really to let the next call to * {@link #firePropertyChanged(String, Object, Object)} fire the old * event again if the previous invocation resulted in an exception? * If so, please document why. If not, fix it. */ private PropertyChangeEvent event; /** * The singleton accessor method of this class. * * @return The singleton. */ public static ProjectManager getManager() { if (instance == null) { instance = new ProjectManager(); } return instance; } /** * Constructor for ProjectManager. */ private ProjectManager() { super(); } /** * Adds a listener to the listener list. * * @param listener The listener to add. */ public void addPropertyChangeListener(PropertyChangeListener listener) { listenerList.add(PropertyChangeListener.class, listener); } /** * Removes a listener from the listener list. * * @param listener The listener to remove. */ public void removePropertyChangeListener(PropertyChangeListener listener) { listenerList.remove(PropertyChangeListener.class, listener); } /** * Fire an event to all members of the listener list. * * @param propertyName The name of the event. * @param oldValue The old value. * @param newValue The new value. */ private void firePropertyChanged(String propertyName, Object oldValue, Object newValue) { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == PropertyChangeListener.class) { // Lazily create the event: if (event == null) event = new PropertyChangeEvent( this, propertyName, oldValue, newValue); ((PropertyChangeListener) listeners[i + 1]).propertyChange( event); } } event = null; } /** * Sets the current project (the project that is viewable in the * projectbrowser). * This method fires a propertychanged event. |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.