Merge lp:~tapaal-contributor/tapaal/fix-is-enabled-transition-query into lp:tapaal

Proposed by Lena Said on 2020-11-06
Status: Merged
Approved by: Jiri Srba on 2020-11-06
Approved revision: 1118
Merged at revision: 1113
Proposed branch: lp:~tapaal-contributor/tapaal/fix-is-enabled-transition-query
Merge into: lp:tapaal
Diff against target: 231 lines (+33/-30)
1 file modified
src/pipe/gui/widgets/QueryDialog.java (+33/-30)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/fix-is-enabled-transition-query
Reviewer Review Type Date Requested Status
Kenneth Yrke Jørgensen Approve on 2020-11-06
Jiri Srba 2020-11-06 Approve on 2020-11-06
Review via email: mp+393444@code.launchpad.net

Description of the change

When net is untimed, the predicate for transitions are now shown as "is enabled" instead of " = 0".
When net is game, it is not possible to select any transitions.

To post a comment you must log in.
Jiri Srba (srba) wrote :

Open untimed game and make a query; the text "is enabled" is prited next to predicate - it should only show if you select transition from the list.

review: Needs Fixing
1118. By Lena Said on 2020-11-06

Removed extra 'is enabled' when net is untimed and game

Jiri Srba (srba) wrote :

Tested and fixes the problem.

review: Approve
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/pipe/gui/widgets/QueryDialog.java'
2--- src/pipe/gui/widgets/QueryDialog.java 2020-10-30 21:14:42 +0000
3+++ src/pipe/gui/widgets/QueryDialog.java 2020-11-06 13:15:27 +0000
4@@ -127,7 +127,7 @@
5 private JPanel predicatePanel;
6 private JButton addPredicateButton;
7 private JComboBox templateBox;
8- private JComboBox<String> placesBox;
9+ private JComboBox<String> placeTransitionBox;
10 private JComboBox<String> relationalOperatorBox;
11 private JLabel transitionIsEnabledLabel;
12 private CustomJSpinner placeMarking;
13@@ -703,10 +703,10 @@
14 } else {
15 templateBox.setSelectedItem(tapnNetwork.getTAPNByName(transitionNode.getTemplate()));
16 }
17- placesBox.setSelectedItem(transitionNode.getTransition());
18+ placeTransitionBox.setSelectedItem(transitionNode.getTransition());
19 userChangedAtomicPropSelection = true;
20 }
21- if (!lens.isTimed()) {
22+ if (!lens.isTimed() && !lens.isGame()) {
23 setEnablednessOfOperatorAndMarkingBoxes();
24 }
25 }
26@@ -718,7 +718,7 @@
27 TCTLPlaceNode placeNode = (TCTLPlaceNode) node.getLeft();
28 TCTLConstNode placeMarkingNode = (TCTLConstNode) node.getRight();
29
30- placesBox.setSelectedItem(placeNode.getPlace());
31+ placeTransitionBox.setSelectedItem(placeNode.getPlace());
32 relationalOperatorBox.setSelectedItem(node.getOp());
33 placeMarking.setValue(placeMarkingNode.getConstant());
34 userChangedAtomicPropSelection = true;
35@@ -728,10 +728,10 @@
36 userChangedAtomicPropSelection = false;
37 if (node.getLeft() instanceof TCTLPlaceNode) {
38 TCTLPlaceNode placeNode = (TCTLPlaceNode) node.getLeft();
39- placesBox.setSelectedItem(placeNode.getPlace());
40+ placeTransitionBox.setSelectedItem(placeNode.getPlace());
41 } else {
42- if (placesBox.getItemCount() > 0) {
43- placesBox.setSelectedIndex(0);
44+ if (placeTransitionBox.getItemCount() > 0) {
45+ placeTransitionBox.setSelectedIndex(0);
46 }
47 }
48 relationalOperatorBox.setSelectedItem(node.getOp());
49@@ -756,7 +756,7 @@
50 }
51
52 private boolean transitionIsSelected() {
53- String itemName = (String) placesBox.getSelectedItem();
54+ String itemName = (String) placeTransitionBox.getSelectedItem();
55 if (itemName == null) return false;
56 boolean transitionSelected = false;
57 boolean sharedTransitionSelected = false;
58@@ -980,7 +980,7 @@
59 disjunctionButton.setEnabled(false);
60 negationButton.setEnabled(false);
61 templateBox.setEnabled(false);
62- placesBox.setEnabled(false);
63+ placeTransitionBox.setEnabled(false);
64 relationalOperatorBox.setEnabled(false);
65 placeMarking.setEnabled(false);
66 addPredicateButton.setEnabled(false);
67@@ -1005,7 +1005,7 @@
68 disjunctionButton.setEnabled(false);
69 negationButton.setEnabled(false);
70 templateBox.setEnabled(false);
71- placesBox.setEnabled(false);
72+ placeTransitionBox.setEnabled(false);
73 relationalOperatorBox.setEnabled(false);
74 placeMarking.setEnabled(false);
75 addPredicateButton.setEnabled(false);
76@@ -1028,7 +1028,7 @@
77 disjunctionButton.setEnabled(true);
78 negationButton.setEnabled(true);
79 templateBox.setEnabled(true);
80- placesBox.setEnabled(true);
81+ placeTransitionBox.setEnabled(true);
82 relationalOperatorBox.setEnabled(true);
83 placeMarking.setEnabled(true);
84 truePredicateButton.setEnabled(true);
85@@ -1051,7 +1051,7 @@
86 disjunctionButton.setEnabled(true);
87 negationButton.setEnabled(true);
88 templateBox.setEnabled(true);
89- placesBox.setEnabled(true);
90+ placeTransitionBox.setEnabled(true);
91 relationalOperatorBox.setEnabled(true);
92 placeMarking.setEnabled(true);
93 truePredicateButton.setEnabled(true);
94@@ -1076,7 +1076,7 @@
95 disjunctionButton.setEnabled(false);
96 negationButton.setEnabled(false);
97 templateBox.setEnabled(false);
98- placesBox.setEnabled(false);
99+ placeTransitionBox.setEnabled(false);
100 relationalOperatorBox.setEnabled(false);
101 placeMarking.setEnabled(false);
102 addPredicateButton.setEnabled(false);
103@@ -1086,7 +1086,7 @@
104 }
105
106 private void setEnablednessOfAddPredicateButton() {
107- if (placesBox.getSelectedItem() == null)
108+ if (placeTransitionBox.getSelectedItem() == null)
109 addPredicateButton.setEnabled(false);
110 else
111 addPredicateButton.setEnabled(true);
112@@ -1145,10 +1145,10 @@
113 TCTLAbstractStateProperty property;
114
115 if (!lens.isTimed() && transitionIsSelected()) {
116- property = new TCTLTransitionNode(template, (String) placesBox.getSelectedItem());
117+ property = new TCTLTransitionNode(template, (String) placeTransitionBox.getSelectedItem());
118 } else {
119 property = new TCTLAtomicPropositionNode(
120- new TCTLPlaceNode(template, (String) placesBox.getSelectedItem()),
121+ new TCTLPlaceNode(template, (String) placeTransitionBox.getSelectedItem()),
122 (String) relationalOperatorBox.getSelectedItem(),
123 new TCTLConstNode((Integer) placeMarking.getValue()));
124 }
125@@ -2002,10 +2002,10 @@
126 predicatePanel = new JPanel(new GridBagLayout());
127 predicatePanel.setBorder(BorderFactory.createTitledBorder("Predicates"));
128
129- placesBox = new JComboBox();
130+ placeTransitionBox = new JComboBox();
131 Dimension d = new Dimension(125, 27);
132- placesBox.setMaximumSize(d);
133- placesBox.setPreferredSize(d);
134+ placeTransitionBox.setMaximumSize(d);
135+ placeTransitionBox.setPreferredSize(d);
136
137 Vector<Object> items = new Vector<Object>(tapnNetwork.activeTemplates().size()+1);
138 items.addAll(tapnNetwork.activeTemplates());
139@@ -2025,7 +2025,7 @@
140 placeNames.add(place.name());
141 }
142 }
143- if (!lens.isTimed()) {
144+ if (!lens.isTimed() && !lens.isGame()) {
145 for (TimedTransition transition : tapn.transitions()) {
146 if (!transition.isShared()) {
147 placeNames.add(transition.name());
148@@ -2034,7 +2034,7 @@
149 }
150
151 placeNames.sort(String::compareToIgnoreCase);
152- placesBox.setModel(new DefaultComboBoxModel<>(placeNames));
153+ placeTransitionBox.setModel(new DefaultComboBoxModel<>(placeNames));
154
155 currentlySelected = tapn;
156 setEnablednessOfAddPredicateButton();
157@@ -2053,7 +2053,7 @@
158 }
159 }
160 placeNames.sort(String::compareToIgnoreCase);
161- placesBox.setModel(new DefaultComboBoxModel<>(placeNames));
162+ placeTransitionBox.setModel(new DefaultComboBoxModel<>(placeNames));
163
164 currentlySelected = SHARED;
165 setEnablednessOfAddPredicateButton();
166@@ -2061,7 +2061,7 @@
167 updateQueryOnAtomicPropositionChange();
168 }
169 }
170- if (!lens.isTimed()) setEnablednessOfOperatorAndMarkingBoxes();
171+ if (!lens.isTimed() && !lens.isGame()) setEnablednessOfOperatorAndMarkingBoxes();
172
173 }
174 });
175@@ -2085,7 +2085,7 @@
176 JPanel placeRow = new JPanel(new FlowLayout(FlowLayout.CENTER));
177 gbc.gridy = 1;
178 predicatePanel.add(placeRow, gbc);
179- placeRow.add(placesBox);
180+ placeRow.add(placeTransitionBox);
181
182 String[] relationalSymbols = { "=", "!=", "<=", "<", ">=", ">" };
183 relationalOperatorBox = new JComboBox(new DefaultComboBoxModel(relationalSymbols));
184@@ -2098,7 +2098,7 @@
185
186 transitionIsEnabledLabel = new JLabel(" is enabled");
187 transitionIsEnabledLabel.setPreferredSize(new Dimension(165, 27));
188- if (!lens.isTimed()) placeRow.add(transitionIsEnabledLabel);
189+ if (!lens.isTimed() && !lens.isGame()) placeRow.add(transitionIsEnabledLabel);
190
191 JPanel addPredicateRow = new JPanel(new FlowLayout(FlowLayout.CENTER));
192 gbc.gridy = 2;
193@@ -2144,7 +2144,7 @@
194 queryPanel.add(predicatePanel, gbc);
195
196 //Add tool tips for predicate panel
197- placesBox.setToolTipText(TOOL_TIP_PLACESBOX);
198+ placeTransitionBox.setToolTipText(TOOL_TIP_PLACESBOX);
199 templateBox.setToolTipText(TOOL_TIP_TEMPLATEBOX);
200 relationalOperatorBox.setToolTipText(TOOL_TIP_RELATIONALOPERATORBOX);
201 placeMarking.setToolTipText(TOOL_TIP_PLACEMARKING);
202@@ -2160,11 +2160,11 @@
203 String template = templateBox.getSelectedItem().toString();
204 if(template.equals(SHARED)) template = "";
205
206- if ((lens.isTimed() || lens.isGame()) && transitionIsSelected()) {
207- addPropertyToQuery(new TCTLTransitionNode(template, (String) placesBox.getSelectedItem()));
208+ if ((!lens.isTimed() && !lens.isGame()) && transitionIsSelected()) {
209+ addPropertyToQuery(new TCTLTransitionNode(template, (String) placeTransitionBox.getSelectedItem()));
210 } else {
211 TCTLAtomicPropositionNode property = new TCTLAtomicPropositionNode(
212- new TCTLPlaceNode(template, (String) placesBox.getSelectedItem()),
213+ new TCTLPlaceNode(template, (String) placeTransitionBox.getSelectedItem()),
214 (String) relationalOperatorBox.getSelectedItem(),
215 new TCTLConstNode((Integer) placeMarking.getValue()));
216 addPropertyToQuery(property);
217@@ -2193,10 +2193,13 @@
218 }
219 });
220
221- placesBox.addActionListener(e -> {
222+ placeTransitionBox.addActionListener(e -> {
223 if (userChangedAtomicPropSelection) {
224 updateQueryOnAtomicPropositionChange();
225 }
226+ if (!lens.isTimed() && !lens.isGame()) {
227+ setEnablednessOfOperatorAndMarkingBoxes();
228+ }
229 });
230
231 relationalOperatorBox.addActionListener(e -> {

Subscribers

People subscribed via source and target branches