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.undo.undo;
005    /*
006    author :roozbeh
007    */
008    
009    import graphlab.platform.core.AbstractAction;
010    import graphlab.platform.core.BlackBoard;
011    import graphlab.plugins.commonplugin.undo.UndoableActionOccuredData;
012    import graphlab.ui.UIUtils;
013    
014    public class RedoAction extends AbstractAction {
015    
016        public static final String EVENT_KEY = UIUtils.getUIEventKey("Redo Action");
017    
018    
019        public RedoAction(BlackBoard bb) {
020            super(bb);
021            listen4Event(EVENT_KEY);
022        }
023    
024        /**
025         * performs the redo operation for basic actions
026         */
027        public static void redo(UndoableActionOccuredData uaod) {
028            uaod.undoableAction.redo(uaod);
029    
030        }
031    
032        public void performAction(String eventName, Object value) {
033            redo(blackboard);
034        }
035    
036        /**
037         * redo the last undoabe operation done in the context of current blackboard
038         */
039        public static void redo(BlackBoard blackboard) {
040            UndoLogManager logManager = blackboard.getData(UndoLogManager.EVENT_KEY);
041            UndoableActionOccuredData uaod = logManager.getNextRedoData();
042            if (uaod != null)
043                redo(uaod);
044        }
045    }