001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.util;
019:
020: import java.util.List;
021: import java.util.Vector;
022: import java.util.logging.Logger;
023:
024: import javax.swing.Action;
025:
026: import de.finix.contelligent.client.gui.ContelligentAction;
027:
028: public class ActionGroup {
029:
030: private String name;
031:
032: private List<Action> actions;
033:
034: private boolean containsToolBarAction, containsMenuBarAction,
035: containsPopupAction;
036:
037: private ActionBundle lastActionBundle;
038:
039: private static Logger logger = Logger.getLogger(ActionGroup.class
040: .getName());
041:
042: private int mnemonic;
043:
044: public ActionGroup(String name, int mnemonic) {
045: this .name = name;
046: this .mnemonic = mnemonic;
047: init();
048: }
049:
050: private void init() {
051: actions = new Vector<Action>();
052: lastActionBundle = null;
053: containsToolBarAction = false;
054: containsMenuBarAction = false;
055: containsPopupAction = false;
056: }
057:
058: public void addAction(Action action, ActionBundle actionBundle) {
059: action.putValue(ContelligentAction.ACTION_BUNDLE, actionBundle);
060: lastActionBundle = actionBundle;
061:
062: if (action.getValue(ContelligentAction.BUTTON_TARGET) != null
063: && action.getValue(ContelligentAction.BUTTON_TARGET)
064: .equals(ContelligentAction.TOOLBAR)) {
065: containsToolBarAction = true;
066: }
067: if (action.getValue(ContelligentAction.MENU_TARGET) != null
068: && action.getValue(ContelligentAction.MENU_TARGET)
069: .equals(ContelligentAction.MENU)) {
070: containsMenuBarAction = true;
071: }
072: if (action.getValue(ContelligentAction.POPUP_TARGET) != null
073: && action.getValue(ContelligentAction.POPUP_TARGET)
074: .equals(ContelligentAction.POPUP_MENU)) {
075: containsPopupAction = true;
076: }
077: actions.add(action);
078: }
079:
080: public int getMnemonic() {
081: return mnemonic;
082: }
083:
084: public List<Action> getActions() {
085: return actions;
086: }
087:
088: public boolean containsToolBarAction() {
089: return containsToolBarAction;
090: }
091:
092: public boolean containsMenuBarAction() {
093: return containsMenuBarAction;
094: }
095:
096: public boolean containsPopupAction() {
097: return containsPopupAction;
098: }
099:
100: public String getName() {
101: return name;
102: }
103:
104: public boolean equals(Object o) {
105: return (o instanceof ActionGroup && ((ActionGroup) o).getName()
106: .equals(name));
107: }
108:
109: public int hashCode() {
110: return -1;
111: }
112:
113: }
|