001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/
004    package graphlab.plugins.commonplugin.actiongrouping;
005    
006    import graphlab.platform.core.AbstractAction;
007    import graphlab.platform.core.BlackBoard;
008    
009    /**
010     * this class is used whenever you have more than one action
011     * and you want them to be enabled and desabled alltogether,
012     * so they can be thinked as a single action.
013     *
014     * @author azin azadi
015     */
016    public abstract class ActionGrouper extends AbstractAction {
017    
018        public ActionGrouper(BlackBoard bb) {
019            super(bb);
020        }
021    
022        public abstract AbstractAction[] getActions();
023    
024        public void performAction(String eventName, Object value) {
025            enableActions();
026        }
027    
028        //enables all of the actions in the group
029        public void enableActions() {
030            for (AbstractAction _ : getActions())
031                _.enable();
032        }
033    
034        public void disable() {
035            super.disable();
036            disableActions();
037        }
038    
039        //disables all actions in group
040        public void disableActions() {
041            for (AbstractAction _ : getActions())
042                _.disable();
043        }
044    }