~tapaal-contributor/tapaal/unselect-objects-after-undo-1894108

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/gui/TabContent.java

  • Committer: srba.jiri at gmail
  • Date: 2020-08-19 12:02:28 UTC
  • mfrom: (1071.2.34 untimed-timed-gui)
  • Revision ID: srba.jiri@gmail.com-20200819120228-ktxdev3ou3kuj3l0
merged in lp:~tapaal-contributor/tapaal/untimed-timed-gui adding timed/untimed lens projection

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package dk.aau.cs.gui;
2
2
 
 
3
import java.awt.*;
 
4
import java.awt.event.ActionEvent;
 
5
import java.awt.event.MouseAdapter;
 
6
import java.awt.event.MouseEvent;
 
7
import java.awt.geom.Point2D;
 
8
import java.io.*;
 
9
import java.math.BigDecimal;
 
10
import java.util.*;
 
11
import java.util.List;
 
12
 
 
13
import javax.swing.*;
 
14
import javax.swing.border.BevelBorder;
3
15
import dk.aau.cs.debug.Logger;
4
16
import dk.aau.cs.gui.components.BugHandledJXMultisplitPane;
5
17
import dk.aau.cs.gui.components.StatisticsPanel;
27
39
import pipe.dataLayer.TAPNQuery;
28
40
import pipe.dataLayer.Template;
29
41
import pipe.gui.*;
 
42
import pipe.gui.action.GuiAction;
30
43
import pipe.gui.canvas.DrawingSurfaceImpl;
31
44
import pipe.gui.graphicElements.*;
32
45
import pipe.gui.graphicElements.tapn.*;
36
49
import pipe.gui.widgets.WorkflowDialog;
37
50
import pipe.gui.widgets.filebrowser.FileBrowser;
38
51
 
39
 
import javax.swing.*;
40
 
import javax.swing.border.BevelBorder;
41
 
import java.awt.*;
42
 
import java.awt.event.MouseAdapter;
43
 
import java.awt.event.MouseEvent;
44
52
import java.awt.event.MouseWheelEvent;
45
 
import java.awt.geom.Point2D;
46
 
import java.io.*;
47
 
import java.math.BigDecimal;
48
 
import java.util.List;
49
 
import java.util.*;
50
53
 
51
54
public class TabContent extends JSplitPane implements TabContentActions{
52
55
 
56
59
        this.guiFrameControllerActions.setReference(guiFrameControllerActions);
57
60
    }
58
61
 
59
 
    public static class TAPNLens {
 
62
    public static final class TAPNLens {
 
63
        public static final TAPNLens Default = new TAPNLens(true, true);
60
64
        public boolean isTimed() {
61
65
            return timed;
62
66
        }
68
72
        private final boolean timed;
69
73
        private final boolean game;
70
74
 
71
 
        TAPNLens(boolean timed, boolean game) {
 
75
        public TAPNLens(boolean timed, boolean game) {
72
76
            this.timed = timed;
73
77
            this.game = game;
74
78
        }
156
160
            Require.notNull(p, "Point can't be null");
157
161
 
158
162
            dk.aau.cs.model.tapn.LocalTimedPlace tp = new dk.aau.cs.model.tapn.LocalTimedPlace(drawingSurface.getNameGenerator().getNewPlaceName(guiModelToModel.get(c)));
159
 
            TimedPlaceComponent pnObject = new TimedPlaceComponent(p.x, p.y, tp);
 
163
            TimedPlaceComponent pnObject = new TimedPlaceComponent(p.x, p.y, tp, lens);
160
164
            guiModelToModel.get(c).add(tp);
161
165
            c.addPetriNetObject(pnObject);
162
166
 
167
171
        public Result<TimedTransitionComponent, ModelViolation> addNewTimedTransitions(DataLayer c, Point p) {
168
172
            dk.aau.cs.model.tapn.TimedTransition transition = new dk.aau.cs.model.tapn.TimedTransition(drawingSurface.getNameGenerator().getNewTransitionName(guiModelToModel.get(c)));
169
173
 
170
 
            TimedTransitionComponent pnObject = new TimedTransitionComponent(p.x, p.y, transition);
 
174
            TimedTransitionComponent pnObject = new TimedTransitionComponent(p.x, p.y, transition, lens);
171
175
 
172
176
            guiModelToModel.get(c).add(transition);
173
177
            c.addPetriNetObject(pnObject);
207
211
                TimeInterval.ZERO_INF
208
212
            );
209
213
 
210
 
            TimedInputArcComponent tiac = new TimedInputArcComponent(p, t, tia);
 
214
            TimedInputArcComponent tiac = new TimedInputArcComponent(p, t, tia, lens);
211
215
 
212
216
            if (path != null) {
213
217
                tiac.setArcPath(new ArcPath(tiac, path));
563
567
                }).start();
564
568
            }
565
569
 
566
 
                        TabContent tab = new TabContent(loadedModel.network(), loadedModel.templates(), loadedModel.queries(), loadedModel.isTimed(), loadedModel.isGame());
 
570
            TabContent tab = new TabContent(loadedModel.network(), loadedModel.templates(), loadedModel.queries(), loadedModel.getLens());
567
571
 
568
572
            tab.setInitialName(name);
569
573
 
784
788
            addGuiModel(template.model(), template.guiModel());
785
789
            zoomLevels.put(template.model(), template.zoomer());
786
790
            hasPositionalInfos.put(template.model(), template.getHasPositionalInfo());
 
791
            for(PetriNetObject o : template.guiModel().getPetriNetObjects()){
 
792
                o.setLens(this.lens);
 
793
            }
787
794
        }
788
795
 
789
796
        drawingSurface = new DrawingSurfaceImpl(new DataLayer(), this, managerRef);
831
838
    private TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, Iterable<TAPNQuery> tapnqueries) {
832
839
        this(network, templates, tapnqueries,  new TAPNLens(true, false));
833
840
    }
834
 
        private TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, Iterable<TAPNQuery> tapnqueries, TAPNLens lens) {
 
841
        public TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, Iterable<TAPNQuery> tapnqueries, TAPNLens lens) {
835
842
        this(network, templates, lens);
836
843
 
837
844
        setNetwork(network, templates);
1133
1140
                showEnabledTransitionsList(showEnabledTransitions);
1134
1141
                
1135
1142
                this.setLeftComponent(animatorSplitPaneScroller);
1136
 
 
1137
1143
        }
1138
1144
 
 
1145
        private void hideTimedInformation(){
 
1146
            if(!lens.isTimed()){
 
1147
            animControlerBox.setVisible(false);
 
1148
        }
 
1149
 
 
1150
    }
 
1151
 
1139
1152
        public void switchToEditorComponents() {
1140
1153
                
1141
1154
                //Remove dummy
1220
1233
        }
1221
1234
 
1222
1235
        private void createAnimationControlSidePanel() {
1223
 
                animControlerBox = new AnimationControlSidePanel(animator);
 
1236
                animControlerBox = new AnimationControlSidePanel(animator, lens);
1224
1237
        }
1225
1238
 
1226
1239
        public AnimationHistoryList getAnimationHistorySidePanel() {
1228
1241
        }
1229
1242
 
1230
1243
        private void createTransitionFireing() {
1231
 
                transitionFireing = new TransitionFireingComponent(CreateGui.getApp().isShowingDelayEnabledTransitions());
 
1244
                transitionFireing = new TransitionFireingComponent(CreateGui.getApp().isShowingDelayEnabledTransitions(), lens);
1232
1245
        }
1233
1246
 
1234
1247
        public TransitionFireingComponent getTransitionFireingComponent() {
1486
1499
        }
1487
1500
 
1488
1501
    private void createNewAndConvertUntimed() {
1489
 
            TabContent tab = duplicateTab(FeatureOption.TIME, false);
 
1502
            TabContent tab = duplicateTab(new TAPNLens(false, lens.isGame()), "-untimed");
1490
1503
        convertToUntimedTab(tab);
1491
1504
        guiFrameControllerActions.ifPresent(o -> o.openTab(tab));
1492
1505
    }
1493
1506
 
1494
1507
    private void createNewAndConvertNonGame() {
1495
 
        TabContent tab = duplicateTab(FeatureOption.GAME, false);
 
1508
        TabContent tab = duplicateTab(new TAPNLens(lens.isTimed(), false), "-nongame");
1496
1509
        TabTransformer.removeGameInformation(tab);
1497
1510
        guiFrameControllerActions.ifPresent(o -> o.openTab(tab));
1498
1511
    }
1512
1525
                    createNewAndConvertUntimed();
1513
1526
                }
1514
1527
            } else {
1515
 
                TabContent tab = duplicateTab(FeatureOption.TIME, isTime);
 
1528
                TabContent tab = duplicateTab(new TAPNLens(true, lens.isGame()), "-timed");
 
1529
                findAndRemoveAffectedQueries(tab);
1516
1530
                guiFrameControllerActions.ifPresent(o -> o.openTab(tab));
1517
1531
            }
1518
1532
            updateFeatureText();
1519
1533
        }
1520
1534
    }
1521
1535
 
 
1536
    private void findAndRemoveAffectedQueries(TabContent tab){
 
1537
        List<TAPNQuery> queriesToRemove = new ArrayList<TAPNQuery>();
 
1538
        for (TAPNQuery q : tab.queries()){
 
1539
            if(q.hasUntimedOnlyProperties()){
 
1540
                queriesToRemove.add(q);
 
1541
                tab.removeQuery(q);
 
1542
            }
 
1543
        }
 
1544
        String message = "The following queries will be removed in the conversion:";
 
1545
        for(TAPNQuery q : queriesToRemove){
 
1546
            message += "\n" + q.getName();
 
1547
        }
 
1548
        if(!queriesToRemove.isEmpty()){
 
1549
            JOptionPane.showMessageDialog(this,message,"Information", JOptionPane.INFORMATION_MESSAGE);
 
1550
        }
 
1551
    }
 
1552
 
1522
1553
    @Override
1523
1554
    public void changeGameFeature(boolean isGame) {
1524
1555
        if (isGame != lens.isGame()) {
1534
1565
                    createNewAndConvertNonGame();
1535
1566
                }
1536
1567
            } else {
1537
 
                TabContent tab = duplicateTab(FeatureOption.GAME, isGame);
 
1568
                TabContent tab = duplicateTab(new TAPNLens(lens.isTimed(), true), "-game");
1538
1569
                guiFrameControllerActions.ifPresent(o -> o.openTab(tab));
1539
1570
            }
1540
1571
            updateFeatureText();
1642
1673
                                drawingSurface().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1643
1674
 
1644
1675
                                animationmode = true; //XXX: Must be called after setGuiMode as guiMode uses last state,
 
1676
                app.ifPresent(o->o.setStatusBarText(textforAnimation));
 
1677
 
1645
1678
                        } else {
1646
1679
                                JOptionPane.showMessageDialog(CreateGui.getApp(),
1647
1680
                                                "You need at least one active template to enter simulation mode",
1669
1702
                        // Undo/Redo is enabled based on undo/redo manager
1670
1703
                        getUndoManager().setUndoRedoStatus();
1671
1704
                        animationmode = false;
 
1705
            app.ifPresent(o->o.setStatusBarText(textforDrawing));
1672
1706
                }
1673
1707
                animator.updateAnimationButtonsEnabled(); //Update stepBack/Forward
1674
1708
        }
1679
1713
        @Override
1680
1714
        public void setMode(Pipe.ElementType mode) {
1681
1715
 
1682
 
                app.ifPresent(o->o.updateMode(mode));
 
1716
        CreateGui.guiMode = mode;
 
1717
        changeStatusbarText(mode);
1683
1718
 
1684
1719
                //Disable selection and deselect current selection
1685
1720
                drawingSurface().getSelectionObject().clearSelection();
1686
1721
        editorMode = mode;
 
1722
        updateMode();
1687
1723
        switch (mode) {
1688
1724
            case ADDTOKEN:
1689
1725
                setManager(new AbstractDrawingSurfaceManager() {
1851
1887
                        app.ifPresent(o->o.setGUIMode(GuiFrame.GUIMode.draw));
1852
1888
                        app.ifPresent(o->setMode(Pipe.ElementType.SELECT));
1853
1889
                }
 
1890
                app.ifPresent(o->o.registerDrawingActions(getAvailableDrawActions()));
 
1891
        app.ifPresent(o->o.registerAnimationActions(getAvailableSimActions()));
 
1892
 
 
1893
        //TODO: this is a temporary implementation untill actions can be moved
 
1894
        app.ifPresent(o->o.registerViewActions(List.of()));
1854
1895
 
1855
1896
        }
1856
1897
 
1947
1988
                                        allTemplates(),
1948
1989
                                        queriesOverwrite,
1949
1990
                                        network().constants(),
1950
 
                    lens.timed,
1951
 
                                        lens.game
 
1991
                    lens
1952
1992
                        );
1953
1993
 
1954
1994
                        tapnWriter.savePNML(outFile);
2026
2066
                drawingSurface().updatePreferredSize();
2027
2067
        }
2028
2068
 
2029
 
        public TabContent duplicateTab(FeatureOption option, boolean isYes) {
2030
 
                NetWriter tapnWriter = new TimedArcPetriNetNetworkWriter(
2031
 
                                network(),
2032
 
                                allTemplates(),
2033
 
                                queries(),
2034
 
                                network().constants()
2035
 
                );
2036
 
 
2037
 
                option = isNetChanged(option, isYes) ? option : FeatureOption.TIME;
2038
 
 
2039
 
                try {
2040
 
                        ByteArrayOutputStream outputStream = tapnWriter.savePNML();
2041
 
                        String composedName = getTabTitle();
2042
 
                        composedName = composedName.replace(".tapn", "");
2043
 
 
2044
 
                        switch (option) {
2045
 
                case TIME:
2046
 
                    composedName += isYes ? "-timed" : "-untimed";
2047
 
                    break;
2048
 
                case GAME:
2049
 
                    composedName += isYes ? "-game" : "-noGame";
2050
 
                    break;
2051
 
            }
2052
 
 
2053
 
                        if (isNetChanged(option, isYes)) {
2054
 
                            return createNewTabFromInputStream(new ByteArrayInputStream(outputStream.toByteArray()), composedName, option, isYes);
2055
 
            } else {
2056
 
                return createNewTabFromInputStream(new ByteArrayInputStream(outputStream.toByteArray()), composedName);
2057
 
            }
2058
 
                } catch (Exception e1) {
2059
 
                        e1.printStackTrace();
2060
 
                        System.console().printf(e1.getMessage());
2061
 
                }
2062
 
                return null;
2063
 
        }
2064
 
 
2065
 
        private boolean isNetChanged(FeatureOption option, boolean isYes) {
2066
 
        switch (option) {
2067
 
            case TIME:
2068
 
                return lens.isTimed() != isYes;
2069
 
            case GAME:
2070
 
                return lens.isGame() != isYes;
2071
 
            default:
2072
 
                return false;
 
2069
        public TabContent duplicateTab(TAPNLens overwriteLens, String appendName) {
 
2070
        NetWriter tapnWriter = new TimedArcPetriNetNetworkWriter(
 
2071
            network(),
 
2072
            allTemplates(),
 
2073
            queries(),
 
2074
            network().constants(),
 
2075
            overwriteLens
 
2076
        );
 
2077
 
 
2078
        try {
 
2079
            ByteArrayOutputStream outputStream = tapnWriter.savePNML();
 
2080
            String composedName = getTabTitle();
 
2081
            composedName = composedName.replace(".tapn", "");
 
2082
            composedName += appendName;
 
2083
            return createNewTabFromInputStream(new ByteArrayInputStream(outputStream.toByteArray()), composedName);
 
2084
        } catch (Exception e1) {
 
2085
            Logger.log("Could not load model");
 
2086
            e1.printStackTrace();
2073
2087
        }
 
2088
        return null;
2074
2089
    }
2075
2090
 
2076
2091
        class CanvasPlaceDrawController extends AbstractDrawingSurfaceManager {
2651
2666
            );
2652
2667
        }
2653
2668
    }
 
2669
    public List<GuiAction> getAvailableDrawActions(){
 
2670
        if(lens.isTimed()){
 
2671
            return new ArrayList<>(Arrays.asList(selectAction, timedPlaceAction,transAction, timedArcAction, transportArcAction, inhibarcAction, tokenAction, deleteTokenAction));
 
2672
        } else{
 
2673
            return new ArrayList<>(Arrays.asList(selectAction, timedPlaceAction,transAction, timedArcAction, inhibarcAction, tokenAction, deleteTokenAction));
 
2674
        }
 
2675
    }
 
2676
 
 
2677
    public List<GuiAction> getAvailableSimActions(){
 
2678
        if(lens.isTimed()){
 
2679
            return new ArrayList<>(Arrays.asList(timeAction, delayFireAction));
 
2680
        } else{
 
2681
            delayFireAction.setName("Fire");
 
2682
            delayFireAction.setTooltip("Fire Selected Transition");
 
2683
            return new ArrayList<>(Arrays.asList(delayFireAction));
 
2684
        }
 
2685
    }
 
2686
 
 
2687
    private final GuiAction selectAction = new GuiAction("Select", "Select components (S)", "S", true) {
 
2688
        public void actionPerformed(ActionEvent e) {
 
2689
            setMode(Pipe.ElementType.SELECT);
 
2690
        }
 
2691
    };
 
2692
    private final GuiAction annotationAction = new GuiAction("Annotation", "Add an annotation (N)", "N", true) {
 
2693
        public void actionPerformed(ActionEvent e) {
 
2694
            setMode(Pipe.ElementType.ANNOTATION);
 
2695
        }
 
2696
    };
 
2697
    private final GuiAction inhibarcAction = new GuiAction("Inhibitor arc", "Add an inhibitor arc (I)", "I", true) {
 
2698
        public void actionPerformed(ActionEvent e) {
 
2699
            setMode(Pipe.ElementType.TAPNINHIBITOR_ARC);
 
2700
        }
 
2701
    };
 
2702
    private final GuiAction transAction = new GuiAction("Transition", "Add a transition (T)", "T", true) {
 
2703
        public void actionPerformed(ActionEvent e) {
 
2704
            setMode(Pipe.ElementType.TAPNTRANS);
 
2705
        }
 
2706
    };
 
2707
    private final GuiAction tokenAction = new GuiAction("Add token", "Add a token (+)", "typed +", true) {
 
2708
        public void actionPerformed(ActionEvent e) {
 
2709
            setMode(Pipe.ElementType.ADDTOKEN);
 
2710
        }
 
2711
    };
 
2712
 
 
2713
    private final GuiAction deleteTokenAction = new GuiAction("Delete token", "Delete a token (-)", "typed -", true) {
 
2714
        public void actionPerformed(ActionEvent e) {
 
2715
            setMode(Pipe.ElementType.DELTOKEN);
 
2716
        }
 
2717
    };
 
2718
    private final GuiAction timedPlaceAction = new GuiAction("Place", "Add a place (P)", "P", true) {
 
2719
        public void actionPerformed(ActionEvent e) {
 
2720
            setMode(Pipe.ElementType.TAPNPLACE);
 
2721
        }
 
2722
    };
 
2723
 
 
2724
    private final GuiAction timedArcAction = new GuiAction("Arc", "Add an arc (A)", "A", true) {
 
2725
        public void actionPerformed(ActionEvent e) {
 
2726
            setMode(Pipe.ElementType.TAPNARC);
 
2727
        }
 
2728
    };
 
2729
    private final GuiAction transportArcAction = new GuiAction("Transport arc", "Add a transport arc (R)", "R", true) {
 
2730
        public void actionPerformed(ActionEvent e) {
 
2731
            setMode(Pipe.ElementType.TRANSPORTARC);
 
2732
        }
 
2733
    };
 
2734
    private final GuiAction timeAction = new GuiAction("Delay one time unit", "Let time pass one time unit", "W") {
 
2735
        public void actionPerformed(ActionEvent e) {
 
2736
            timeDelay();
 
2737
        }
 
2738
    };
 
2739
    private final GuiAction delayFireAction = new GuiAction("Delay and fire", "Delay and fire selected transition", "F") {
 
2740
        public void actionPerformed(ActionEvent e) {
 
2741
            delayAndFire();
 
2742
        }
 
2743
    };
 
2744
 
 
2745
    public void updateMode() {
 
2746
        // deselect other actions
 
2747
        selectAction.setSelected(CreateGui.guiMode == Pipe.ElementType.SELECT);
 
2748
        transAction.setSelected(editorMode == Pipe.ElementType.TAPNTRANS);
 
2749
        timedPlaceAction.setSelected(editorMode == Pipe.ElementType.TAPNPLACE);
 
2750
        timedArcAction.setSelected(editorMode == Pipe.ElementType.TAPNARC);
 
2751
        transportArcAction.setSelected(editorMode == Pipe.ElementType.TRANSPORTARC);
 
2752
        inhibarcAction.setSelected(editorMode == Pipe.ElementType.TAPNINHIBITOR_ARC);
 
2753
        tokenAction.setSelected(editorMode == Pipe.ElementType.ADDTOKEN);
 
2754
        deleteTokenAction.setSelected(editorMode == Pipe.ElementType.DELTOKEN);
 
2755
        annotationAction.setSelected(editorMode == Pipe.ElementType.ANNOTATION);
 
2756
    }
 
2757
    @Override
 
2758
    public void updateEnabledActions(GuiFrame.GUIMode mode){
 
2759
        switch(mode){
 
2760
            case draw:
 
2761
                selectAction.setEnabled(true);
 
2762
                transAction.setEnabled(true);
 
2763
                timedPlaceAction.setEnabled(true);
 
2764
                timedArcAction.setEnabled(true);
 
2765
                transportArcAction.setEnabled(true);
 
2766
                inhibarcAction.setEnabled(true);
 
2767
                tokenAction.setEnabled(true);
 
2768
                deleteTokenAction.setEnabled(true);
 
2769
                annotationAction.setEnabled(true);
 
2770
                delayFireAction.setEnabled(false);
 
2771
                timeAction.setEnabled(false);
 
2772
                break;
 
2773
            case noNet:
 
2774
                selectAction.setEnabled(false);
 
2775
                transAction.setEnabled(false);
 
2776
                timedPlaceAction.setEnabled(false);
 
2777
                timedArcAction.setEnabled(false);
 
2778
                transportArcAction.setEnabled(false);
 
2779
                inhibarcAction.setEnabled(false);
 
2780
                tokenAction.setEnabled(false);
 
2781
                deleteTokenAction.setEnabled(false);
 
2782
                annotationAction.setEnabled(false);
 
2783
                delayFireAction.setEnabled(false);
 
2784
                timeAction.setEnabled(false);
 
2785
            case animation:
 
2786
                selectAction.setEnabled(false);
 
2787
                transAction.setEnabled(false);
 
2788
                timedPlaceAction.setEnabled(false);
 
2789
                timedArcAction.setEnabled(false);
 
2790
                transportArcAction.setEnabled(false);
 
2791
                inhibarcAction.setEnabled(false);
 
2792
                tokenAction.setEnabled(false);
 
2793
                deleteTokenAction.setEnabled(false);
 
2794
                annotationAction.setEnabled(false);
 
2795
                delayFireAction.setEnabled(true);
 
2796
                if(lens.isTimed())
 
2797
                    timeAction.setEnabled(true);
 
2798
                break;
 
2799
        }
 
2800
    }
 
2801
 
 
2802
 
 
2803
    public static final String textforDrawing = "Drawing Mode: Click on a button to start adding components to the Editor";
 
2804
    public static final String textforPlace = "Place Mode: Right click on a place to see menu options ";
 
2805
    public static final String textforTAPNPlace = "Place Mode: Right click on a place to see menu options ";
 
2806
    public static final String textforTrans = "Transition Mode: Right click on a transition to see menu options [Mouse wheel -> rotate]";
 
2807
    public static final String textforTimedTrans = "Timed Transition Mode: Right click on a transition to see menu options [Mouse wheel -> rotate]";
 
2808
    public static final String textforAddtoken = "Add Token Mode: Click on a place to add a token";
 
2809
    public static final String textforDeltoken = "Delete Token Mode: Click on a place to delete a token ";
 
2810
    public static final String textforAnimation = "Simulation Mode: Red transitions are enabled, click a transition to fire it";
 
2811
    public static final String textforArc = "Arc Mode: Right click on an arc to see menu options ";
 
2812
    public static final String textforTransportArc = "Transport Arc Mode: Right click on an arc to see menu options ";
 
2813
    public static final String textforInhibArc = "Inhibitor Mode: Right click on an arc to see menu options ";
 
2814
    public static final String textforMove = "Select Mode: Click/drag to select objects; drag to move them";
 
2815
    public static final String textforAnnotation = "Annotation Mode: Right click on an annotation to see menu options; double click to edit";
 
2816
    public static final String textforDrag = "Drag Mode";
 
2817
 
 
2818
    public void changeStatusbarText(Pipe.ElementType type) {
 
2819
        switch (type) {
 
2820
            case PLACE:
 
2821
                app.ifPresent(o13 -> o13.setStatusBarText(textforPlace));
 
2822
                break;
 
2823
 
 
2824
            case TAPNPLACE:
 
2825
                app.ifPresent(o12 -> o12.setStatusBarText(textforTAPNPlace));
 
2826
                break;
 
2827
 
 
2828
            case IMMTRANS:
 
2829
            case TAPNTRANS:
 
2830
                app.ifPresent(o11 -> o11.setStatusBarText(textforTrans));
 
2831
                break;
 
2832
 
 
2833
            case TIMEDTRANS:
 
2834
                app.ifPresent(o10 -> o10.setStatusBarText(textforTimedTrans));
 
2835
                break;
 
2836
 
 
2837
            case ARC:
 
2838
            case TAPNARC:
 
2839
                app.ifPresent(o9 -> o9.setStatusBarText(textforArc));
 
2840
                break;
 
2841
 
 
2842
            case TRANSPORTARC:
 
2843
                app.ifPresent(o8 -> o8.setStatusBarText(textforTransportArc));
 
2844
                break;
 
2845
 
 
2846
            case TAPNINHIBITOR_ARC:
 
2847
            case INHIBARC:
 
2848
                app.ifPresent(o7 -> o7.setStatusBarText(textforInhibArc));
 
2849
                break;
 
2850
 
 
2851
            case ADDTOKEN:
 
2852
                app.ifPresent(o6 -> o6.setStatusBarText(textforAddtoken));
 
2853
                break;
 
2854
 
 
2855
            case DELTOKEN:
 
2856
                app.ifPresent(o5 -> o5.setStatusBarText(textforDeltoken));
 
2857
                break;
 
2858
 
 
2859
            case SELECT:
 
2860
                app.ifPresent(o4 -> o4.setStatusBarText(textforMove));
 
2861
                break;
 
2862
 
 
2863
            case DRAW:
 
2864
                app.ifPresent(o3 -> o3.setStatusBarText(textforDrawing));
 
2865
                break;
 
2866
 
 
2867
            case ANNOTATION:
 
2868
                app.ifPresent(o2 -> o2.setStatusBarText(textforAnnotation));
 
2869
                break;
 
2870
 
 
2871
            case DRAG:
 
2872
                app.ifPresent(o1 -> o1.setStatusBarText(textforDrag));
 
2873
                break;
 
2874
 
 
2875
            default:
 
2876
                app.ifPresent(o->o.setStatusBarText("To-do (textfor" + type));
 
2877
                break;
 
2878
        }
 
2879
    }
 
2880
 
2654
2881
}