258N/A/*
1472N/A * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
258N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
258N/A *
258N/A * This code is free software; you can redistribute it and/or modify it
258N/A * under the terms of the GNU General Public License version 2 only, as
258N/A * published by the Free Software Foundation.
258N/A *
258N/A * This code is distributed in the hope that it will be useful, but WITHOUT
258N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
258N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
258N/A * version 2 for more details (a copy is included in the LICENSE file that
258N/A * accompanied this code).
258N/A *
258N/A * You should have received a copy of the GNU General Public License version
258N/A * 2 along with this work; if not, write to the Free Software Foundation,
258N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
258N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
258N/A *
258N/A */
258N/A
258N/A
258N/Apackage com.sun.java.swing.action;
258N/A
258N/Aimport java.util.HashMap;
258N/Aimport javax.swing.Action;
258N/Aimport javax.swing.ImageIcon;
258N/A
258N/A// Referenced classes of package com.sun.java.swing.action:
258N/A// DelegateAction, StateChangeAction, ActionUtilities
258N/A
258N/Apublic abstract class ActionManager
258N/A{
258N/A
258N/A protected ActionManager()
258N/A {
258N/A actions = new HashMap();
258N/A addActions();
258N/A }
258N/A
258N/A public static ActionManager getInstance()
258N/A {
258N/A return manager;
258N/A }
258N/A
258N/A protected abstract void addActions();
258N/A
258N/A protected void addAction(String cmdname, Action action)
258N/A {
258N/A actions.put(cmdname, action);
258N/A }
258N/A
258N/A public Action getAction(String key)
258N/A {
258N/A return (Action)actions.get(key);
258N/A }
258N/A
258N/A public DelegateAction getDelegateAction(String name)
258N/A {
258N/A Action a = getAction(name);
258N/A if(a instanceof DelegateAction)
258N/A return (DelegateAction)a;
258N/A else
258N/A return null;
258N/A }
258N/A
258N/A public StateChangeAction getStateChangeAction(String name)
258N/A {
258N/A Action a = getAction(name);
258N/A if(a instanceof StateChangeAction)
258N/A return (StateChangeAction)a;
258N/A else
258N/A return null;
258N/A }
258N/A
258N/A public static ImageIcon getIcon(String name)
258N/A {
258N/A return utilities.getIcon(name);
258N/A }
258N/A
258N/A public void setActionEnabled(String name, boolean enabled)
258N/A {
258N/A Action action = getAction(name);
258N/A if(action != null)
258N/A action.setEnabled(enabled);
258N/A }
258N/A
258N/A private HashMap actions;
258N/A private static ActionUtilities utilities = new ActionUtilities();
258N/A protected static ActionManager manager;
258N/A
258N/A}