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    
005    package graphlab.plugins.algorithmanimator.extension;
006    
007    import graphlab.graph.ui.GTabbedGraphPane;
008    import graphlab.platform.core.BlackBoard;
009    import graphlab.plugins.algorithmanimator.core.AlgorithmAnimator;
010    import graphlab.ui.AbstractExtensionAction;
011    
012    
013    public class AlgorithmExtensionAction
014            extends AbstractExtensionAction<AlgorithmExtension> {
015    
016        public AlgorithmExtensionAction(BlackBoard bb, AlgorithmExtension sp) {
017            super(bb, sp);
018        }
019    
020        @Override
021        public String getParentMenuName() {
022            return "Algorithms";
023        }
024    
025        @Override
026        public void performExtension() {
027    
028            new Thread() {
029                public void run() {
030                    AlgorithmAnimator algorithmAnimator = new AlgorithmAnimator(blackboard);
031                    target.acceptEventDispatcher(algorithmAnimator);
032                    GTabbedGraphPane.showTimeNotificationMessage(target.getName() + " Algorithm started", blackboard, 2000, true);
033                    algorithmAnimator.createControlDialog(target.getName());
034                    target.doAlgorithm();
035                    GTabbedGraphPane.showTimeNotificationMessage(target.getName() + " Algorithm finished", blackboard, 3000, true);
036                }
037            }.start();
038        }
039    }