Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* $Id$
*
* Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
* Santa Clara, California 95054, U.S.A. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.jdesktop.swingx.action;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
/**
* The ActionManager manages sets of javax.swing.Actions for an
* application. There are convenience methods for getting and setting the state
* of the action.
* All of these elements have a unique id tag which is used by the ActionManager
* to reference the action. This id maps to the Action.ACTION_COMMAND_KEY
* on the Action.
*
* The ActionManager may be used to conveniently register callback methods
* on BoundActions.
*
* A typical use case of the ActionManager is:
*
*
* ActionManager manager = ActionManager.getInstance();
*
* // load Actions
* manager.addAction(action);
*
* // Change the state of the action:
* manager.setEnabled("new-action", newState);
*
*
* The ActionManager also supports Actions that can have a selected state
* associated with them. These Actions are typically represented by a
* JCheckBox or similar widget. For such actions the registered method is
* invoked with an additional parameter indicating the selected state of
* the widget. For example, for the callback handler:
*
*
* public class Handler {
* public void stateChanged(boolean newState);
* }
*
* The registration method would look similar:
*
* manager.registerCallback("select-action", new Handler(), "stateChanged");
*
*
* The stateChanged method would be invoked as the selected state of
* the widget changed. Additionally if you need to change the selected
* state of the Action use the ActionManager method setSelected.
*
* The ActionContainerFactory uses the managed Actions in a
* ActionManager to create user interface components. It uses the shared
* instance of ActionManager by default. For example, to create a JMenu based on an
* action-list id:
*
*
* @see ActionContainerFactory
* @see TargetableAction
* @see BoundAction
* @author Mark Davidson
* @author Neil Weber
*/
public class ActionManager extends ActionMap {
/**
* Shared instance of the singleton ActionManager.
*/
private static ActionManager INSTANCE;
/**
* Creates the action manager. Use this constuctor if the application should
* support many ActionManagers. Otherwise, using the getInstance method will
* return a singleton.
*/
public ActionManager() {
}
/**
* Return the instance of the ActionManger. If this has not been explicity
* set then it will be created.
*
* @return the ActionManager instance.
* @see #setInstance
*/
public static ActionManager getInstance() {
if (INSTANCE == null) {
INSTANCE = new ActionManager();
}
return INSTANCE;
}
/**
* Sets the ActionManager instance.
*/
public static void setInstance(ActionManager manager) {
INSTANCE = manager;
}
/**
* Returns the ids for all the managed actions.
*
* An action id is a unique idenitfier which can
* be used to retrieve the corrspondng Action from the ActionManager.
* This identifier can also
* be used to set the properties of the action through the action
* manager like setting the state of the enabled or selected flags.
*
* @return a set which represents all the action ids
*/
public Set