~yrke/tapaal/ControllersAndPushdown

« back to all changes in this revision

Viewing changes to src/pipe/gui/GuiFrame.java

  • Committer: Kenneth Yrke Joergensen
  • Date: 2019-07-13 17:19:37 UTC
  • Revision ID: kenneth@yrke.dk-20190713171937-cx5f0t770lhk328p
Moved toggleAnimationMode to tab

Show diffs side-by-side

added added

removed removed

Lines of Context:
726
726
                                "M", true) {
727
727
                        @Override
728
728
                        public void actionPerformed(ActionEvent e) {
729
 
                                toggleAnimationMode();
 
729
                                currentTab.ifPresent(o->o.changeAnimationMode(isSelected()));
730
730
                        }
731
731
                });
732
732
                
1842
1842
 
1843
1843
                        // Enable all draw actions
1844
1844
                        startAction.setSelected(false);
1845
 
                        getCurrentTab().changeAnimationMode(false);
1846
1845
 
1847
1846
                        if (getCurrentTab().isInAnimationMode()) {
1848
1847
                                getCurrentTab().getAnimator().restoreModel();
1871
1870
 
1872
1871
                        setMode(ElementType.SELECT);
1873
1872
 
 
1873
                        getCurrentTab().switchToAnimationComponents(showEnabledTransitions);
1874
1874
                        getCurrentTab().getAnimator().setTabContent(getCurrentTab());
1875
 
                        getCurrentTab().switchToAnimationComponents(showEnabledTransitions);
 
1875
 
1876
1876
                        showComponents(showComponents);
1877
1877
 
1878
1878
                        startAction.setSelected(true);
1879
1879
                        if (!getCurrentTab().isInAnimationMode()) {
1880
 
                                getCurrentTab().changeAnimationMode(true);
1881
1880
                                getCurrentTab().drawingSurface().repaintAll();
1882
1881
                                getCurrentTab().getAnimator().reset(false);
1883
1882
                                getCurrentTab().getAnimator().storeModel();
2060
2059
        }
2061
2060
 
2062
2061
 
2063
 
        /**
2064
 
         * Starts/Stops Animation mode
2065
 
         */
2066
 
        private void toggleAnimationMode() {
2067
 
                try {
2068
 
 
2069
 
                        if (!getCurrentTab().isInAnimationMode()) {
2070
 
                                if (getCurrentTab().numberOfActiveTemplates() > 0) {
2071
 
                                        setGUIMode(GUIMode.animation);
2072
 
                                } else {
2073
 
                                        JOptionPane.showMessageDialog(GuiFrame.this,
2074
 
                                                        "You need at least one active template to enter simulation mode",
2075
 
                                                        "Simulation Mode Error", JOptionPane.ERROR_MESSAGE);
2076
 
                                }
2077
 
                        } else {
2078
 
                                setGUIMode(GUIMode.draw);
2079
 
                        }
2080
 
                } catch (Exception e) {
2081
 
                        Logger.log(e);
2082
 
                        JOptionPane.showMessageDialog(GuiFrame.this, e.toString(),
2083
 
                                        "Simulation Mode Error", JOptionPane.ERROR_MESSAGE);
2084
 
                        startAction.setSelected(false);
2085
 
                        getCurrentTab().changeAnimationMode(false);
2086
 
                        throw new RuntimeException(e);
2087
 
                }
2088
 
 
2089
 
        }
2090
 
 
2091
 
 
2092
2062
        public void showAbout() {
2093
2063
                StringBuilder buffer = new StringBuilder("About " + TAPAAL.getProgramName());
2094
2064
                buffer.append("\n\n");