Merge lp:~tapaal-contributor/tapaal/undo-up-down-sidepane-3.6-1870894 into lp:tapaal/3.6
- undo-up-down-sidepane-3.6-1870894
- Merge into 3.6
Proposed by
Jiri Srba
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Jiri Srba | ||||
Approved revision: | 1051 | ||||
Merged at revision: | 1052 | ||||
Proposed branch: | lp:~tapaal-contributor/tapaal/undo-up-down-sidepane-3.6-1870894 | ||||
Merge into: | lp:tapaal/3.6 | ||||
Diff against target: |
433 lines (+224/-40) 7 files modified
src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java (+38/-20) src/dk/aau/cs/gui/TemplateExplorer.java (+31/-10) src/dk/aau/cs/gui/undo/MoveElementDownCommand.java (+46/-0) src/dk/aau/cs/gui/undo/MoveElementUpCommand.java (+51/-0) src/pipe/gui/widgets/ConstantsPane.java (+26/-6) src/pipe/gui/widgets/QueryPane.java (+23/-4) src/pipe/gui/widgets/SidePane.java (+9/-0) |
||||
To merge this branch: | bzr merge lp:~tapaal-contributor/tapaal/undo-up-down-sidepane-3.6-1870894 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jiri Srba | Approve | ||
Review via email: mp+384060@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java' | |||
2 | --- src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java 2019-03-02 11:14:31 +0000 | |||
3 | +++ src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java 2020-05-16 08:49:46 +0000 | |||
4 | @@ -30,10 +30,12 @@ | |||
5 | 30 | import pipe.gui.CreateGui; | 30 | import pipe.gui.CreateGui; |
6 | 31 | import pipe.gui.undo.UndoManager; | 31 | import pipe.gui.undo.UndoManager; |
7 | 32 | import pipe.gui.widgets.EscapableDialog; | 32 | import pipe.gui.widgets.EscapableDialog; |
9 | 33 | 33 | import pipe.gui.widgets.SidePane; | |
10 | 34 | import dk.aau.cs.gui.components.NonsearchableJList; | 34 | import dk.aau.cs.gui.components.NonsearchableJList; |
11 | 35 | import dk.aau.cs.gui.undo.AddSharedPlaceCommand; | 35 | import dk.aau.cs.gui.undo.AddSharedPlaceCommand; |
12 | 36 | import dk.aau.cs.gui.undo.Command; | 36 | import dk.aau.cs.gui.undo.Command; |
13 | 37 | import dk.aau.cs.gui.undo.MoveElementDownCommand; | ||
14 | 38 | import dk.aau.cs.gui.undo.MoveElementUpCommand; | ||
15 | 37 | import dk.aau.cs.gui.undo.SortSharedPlacesCommand; | 39 | import dk.aau.cs.gui.undo.SortSharedPlacesCommand; |
16 | 38 | import dk.aau.cs.gui.undo.SortSharedTransitionsCommand; | 40 | import dk.aau.cs.gui.undo.SortSharedTransitionsCommand; |
17 | 39 | import dk.aau.cs.model.tapn.SharedPlace; | 41 | import dk.aau.cs.model.tapn.SharedPlace; |
18 | @@ -42,7 +44,7 @@ | |||
19 | 42 | import dk.aau.cs.util.Require; | 44 | import dk.aau.cs.util.Require; |
20 | 43 | import dk.aau.cs.util.RequireException; | 45 | import dk.aau.cs.util.RequireException; |
21 | 44 | 46 | ||
23 | 45 | public class SharedPlacesAndTransitionsPanel extends JPanel { | 47 | public class SharedPlacesAndTransitionsPanel extends JPanel implements SidePane{ |
24 | 46 | private static final String TRANSITION_IS_USED_MESSAGE = "<html>The shared transition is used in one or more components.<br/>TAPAAL will unshare all transitions under this name,<br/>but leave the transitions in the components.</html>"; | 48 | private static final String TRANSITION_IS_USED_MESSAGE = "<html>The shared transition is used in one or more components.<br/>TAPAAL will unshare all transitions under this name,<br/>but leave the transitions in the components.</html>"; |
25 | 47 | private static final String PLACE_IS_USED_MESSAGE = "<html>The shared place is used in one or more components.<br/>TAPAAL will unshare all places under this name,<br/>but leave the places in the components.</html>"; | 49 | private static final String PLACE_IS_USED_MESSAGE = "<html>The shared place is used in one or more components.<br/>TAPAAL will unshare all places under this name,<br/>but leave the places in the components.</html>"; |
26 | 48 | 50 | ||
27 | @@ -203,10 +205,9 @@ | |||
28 | 203 | int index = list.getSelectedIndex(); | 205 | int index = list.getSelectedIndex(); |
29 | 204 | 206 | ||
30 | 205 | if(index > 0) { | 207 | if(index > 0) { |
35 | 206 | if(isDisplayingTransitions()) | 208 | Command c = new MoveElementUpCommand(SharedPlacesAndTransitionsPanel.this, index, index-1); |
36 | 207 | sharedTransitionsListModel.swap(index, index-1); | 209 | undoManager.addNewEdit(c); |
37 | 208 | else | 210 | c.redo(); |
34 | 209 | sharedPlacesListModel.swap(index, index-1); | ||
38 | 210 | list.setSelectedIndex(index-1); | 211 | list.setSelectedIndex(index-1); |
39 | 211 | list.ensureIndexIsVisible(index-1); | 212 | list.ensureIndexIsVisible(index-1); |
40 | 212 | } | 213 | } |
41 | @@ -226,20 +227,11 @@ | |||
42 | 226 | public void actionPerformed(ActionEvent e) { | 227 | public void actionPerformed(ActionEvent e) { |
43 | 227 | int index = list.getSelectedIndex(); | 228 | int index = list.getSelectedIndex(); |
44 | 228 | 229 | ||
59 | 229 | if(isDisplayingTransitions()) { | 230 | Command c = new MoveElementDownCommand(SharedPlacesAndTransitionsPanel.this, index, index+1); |
60 | 230 | if(index < sharedTransitionsListModel.getSize() - 1) { | 231 | undoManager.addNewEdit(c); |
61 | 231 | sharedTransitionsListModel.swap(index, index+1); | 232 | c.redo(); |
62 | 232 | list.setSelectedIndex(index+1); | 233 | list.setSelectedIndex(index+1); |
63 | 233 | list.ensureIndexIsVisible(index+1); | 234 | list.ensureIndexIsVisible(index+1); |
50 | 234 | |||
51 | 235 | } | ||
52 | 236 | } else { | ||
53 | 237 | if(index < sharedPlacesListModel.getSize() - 1) { | ||
54 | 238 | sharedPlacesListModel.swap(index, index+1); | ||
55 | 239 | list.setSelectedIndex(index+1); | ||
56 | 240 | list.ensureIndexIsVisible(index+1); | ||
57 | 241 | } | ||
58 | 242 | } | ||
64 | 243 | } | 235 | } |
65 | 244 | }); | 236 | }); |
66 | 245 | 237 | ||
67 | @@ -626,4 +618,30 @@ | |||
68 | 626 | fireContentsChanged(this, 0, network.numberOfSharedTransitions()); | 618 | fireContentsChanged(this, 0, network.numberOfSharedTransitions()); |
69 | 627 | } | 619 | } |
70 | 628 | } | 620 | } |
71 | 621 | |||
72 | 622 | @Override | ||
73 | 623 | public void moveUp(int index) { | ||
74 | 624 | if(isDisplayingTransitions()) | ||
75 | 625 | sharedTransitionsListModel.swap(index, index-1); | ||
76 | 626 | else | ||
77 | 627 | sharedPlacesListModel.swap(index, index-1); | ||
78 | 628 | } | ||
79 | 629 | |||
80 | 630 | @Override | ||
81 | 631 | public void moveDown(int index) { | ||
82 | 632 | if(isDisplayingTransitions()) { | ||
83 | 633 | if(index < sharedTransitionsListModel.getSize() - 1) { | ||
84 | 634 | sharedTransitionsListModel.swap(index, index+1); | ||
85 | 635 | } | ||
86 | 636 | } else { | ||
87 | 637 | if(index < sharedPlacesListModel.getSize() - 1) { | ||
88 | 638 | sharedPlacesListModel.swap(index, index+1); | ||
89 | 639 | } | ||
90 | 640 | } | ||
91 | 641 | } | ||
92 | 642 | |||
93 | 643 | @Override | ||
94 | 644 | public JList getJList() { | ||
95 | 645 | return list; | ||
96 | 646 | } | ||
97 | 629 | } | 647 | } |
98 | 630 | 648 | ||
99 | === modified file 'src/dk/aau/cs/gui/TemplateExplorer.java' | |||
100 | --- src/dk/aau/cs/gui/TemplateExplorer.java 2019-01-24 20:01:38 +0000 | |||
101 | +++ src/dk/aau/cs/gui/TemplateExplorer.java 2020-05-16 08:49:46 +0000 | |||
102 | @@ -59,6 +59,8 @@ | |||
103 | 59 | import dk.aau.cs.TCTL.visitors.ContainsPlaceWithDisabledTemplateVisitor; | 59 | import dk.aau.cs.TCTL.visitors.ContainsPlaceWithDisabledTemplateVisitor; |
104 | 60 | import dk.aau.cs.gui.components.NonsearchableJList; | 60 | import dk.aau.cs.gui.components.NonsearchableJList; |
105 | 61 | import dk.aau.cs.gui.undo.Command; | 61 | import dk.aau.cs.gui.undo.Command; |
106 | 62 | import dk.aau.cs.gui.undo.MoveElementDownCommand; | ||
107 | 63 | import dk.aau.cs.gui.undo.MoveElementUpCommand; | ||
108 | 62 | import dk.aau.cs.gui.undo.SortTemplatesCommand; | 64 | import dk.aau.cs.gui.undo.SortTemplatesCommand; |
109 | 63 | import dk.aau.cs.model.tapn.Constant; | 65 | import dk.aau.cs.model.tapn.Constant; |
110 | 64 | import dk.aau.cs.model.tapn.SharedTransition; | 66 | import dk.aau.cs.model.tapn.SharedTransition; |
111 | @@ -68,8 +70,10 @@ | |||
112 | 68 | import dk.aau.cs.util.Require; | 70 | import dk.aau.cs.util.Require; |
113 | 69 | import dk.aau.cs.util.StringComparator; | 71 | import dk.aau.cs.util.StringComparator; |
114 | 70 | import dk.aau.cs.util.Tuple; | 72 | import dk.aau.cs.util.Tuple; |
117 | 71 | 73 | import pipe.gui.widgets.SidePane; | |
118 | 72 | public class TemplateExplorer extends JPanel { | 74 | |
119 | 75 | |||
120 | 76 | public class TemplateExplorer extends JPanel implements SidePane{ | ||
121 | 73 | private static final long serialVersionUID = -2334464984237161208L; | 77 | private static final long serialVersionUID = -2334464984237161208L; |
122 | 74 | 78 | ||
123 | 75 | // Template explorer panel items | 79 | // Template explorer panel items |
124 | @@ -252,10 +256,9 @@ | |||
125 | 252 | int index = templateList.getSelectedIndex(); | 256 | int index = templateList.getSelectedIndex(); |
126 | 253 | 257 | ||
127 | 254 | if(index > 0) { | 258 | if(index > 0) { |
132 | 255 | parent.swapTemplates(index, index-1); | 259 | Command c = new MoveElementUpCommand(TemplateExplorer.this, index, index-1); |
133 | 256 | Object o = listModel.getElementAt(index); | 260 | undoManager.addNewEdit(c); |
134 | 257 | listModel.setElementAt(listModel.getElementAt(index-1), index); | 261 | c.redo(); |
131 | 258 | listModel.setElementAt(o, index-1); | ||
135 | 259 | templateList.ensureIndexIsVisible(index+1); | 262 | templateList.ensureIndexIsVisible(index+1); |
136 | 260 | templateList.setSelectedIndex(index-1); | 263 | templateList.setSelectedIndex(index-1); |
137 | 261 | } | 264 | } |
138 | @@ -276,10 +279,9 @@ | |||
139 | 276 | int index = templateList.getSelectedIndex(); | 279 | int index = templateList.getSelectedIndex(); |
140 | 277 | 280 | ||
141 | 278 | if(index < parent.network().allTemplates().size() - 1) { | 281 | if(index < parent.network().allTemplates().size() - 1) { |
146 | 279 | parent.swapTemplates(index, index+1); | 282 | Command c = new MoveElementDownCommand(TemplateExplorer.this, index, index+1); |
147 | 280 | Object o = listModel.getElementAt(index); | 283 | undoManager.addNewEdit(c); |
148 | 281 | listModel.setElementAt(listModel.getElementAt(index+1), index); | 284 | c.redo(); |
145 | 282 | listModel.setElementAt(o, index+1); | ||
149 | 283 | templateList.ensureIndexIsVisible(index+1); | 285 | templateList.ensureIndexIsVisible(index+1); |
150 | 284 | templateList.setSelectedIndex(index+1); | 286 | templateList.setSelectedIndex(index+1); |
151 | 285 | } | 287 | } |
152 | @@ -1031,4 +1033,23 @@ | |||
153 | 1031 | } | 1033 | } |
154 | 1032 | 1034 | ||
155 | 1033 | } | 1035 | } |
156 | 1036 | @Override | ||
157 | 1037 | public void moveUp(int index) { | ||
158 | 1038 | parent.swapTemplates(index, index-1); | ||
159 | 1039 | Object o = listModel.getElementAt(index); | ||
160 | 1040 | listModel.setElementAt(listModel.getElementAt(index-1), index); | ||
161 | 1041 | listModel.setElementAt(o, index-1); | ||
162 | 1042 | } | ||
163 | 1043 | |||
164 | 1044 | @Override | ||
165 | 1045 | public void moveDown(int index) { | ||
166 | 1046 | parent.swapTemplates(index, index+1); | ||
167 | 1047 | Object o = listModel.getElementAt(index); | ||
168 | 1048 | listModel.setElementAt(listModel.getElementAt(index+1), index); | ||
169 | 1049 | listModel.setElementAt(o, index+1); | ||
170 | 1050 | } | ||
171 | 1051 | @Override | ||
172 | 1052 | public JList getJList(){ | ||
173 | 1053 | return templateList; | ||
174 | 1054 | } | ||
175 | 1034 | } | 1055 | } |
176 | 1035 | 1056 | ||
177 | === added file 'src/dk/aau/cs/gui/undo/MoveElementDownCommand.java' | |||
178 | --- src/dk/aau/cs/gui/undo/MoveElementDownCommand.java 1970-01-01 00:00:00 +0000 | |||
179 | +++ src/dk/aau/cs/gui/undo/MoveElementDownCommand.java 2020-05-16 08:49:46 +0000 | |||
180 | @@ -0,0 +1,46 @@ | |||
181 | 1 | package dk.aau.cs.gui.undo; | ||
182 | 2 | |||
183 | 3 | import pipe.dataLayer.Template; | ||
184 | 4 | import pipe.gui.widgets.SidePane; | ||
185 | 5 | |||
186 | 6 | import javax.swing.*; | ||
187 | 7 | |||
188 | 8 | public class MoveElementDownCommand extends Command{ | ||
189 | 9 | int oldIndex; | ||
190 | 10 | int newIndex; | ||
191 | 11 | SidePane sidePane; | ||
192 | 12 | JList<Template> templateList; | ||
193 | 13 | public MoveElementDownCommand(SidePane sidePane, int oldIndex, int newIndex){ | ||
194 | 14 | this.oldIndex = oldIndex; | ||
195 | 15 | this.newIndex = newIndex; | ||
196 | 16 | this.sidePane = sidePane; | ||
197 | 17 | } | ||
198 | 18 | |||
199 | 19 | @Override | ||
200 | 20 | public void redo() { | ||
201 | 21 | if(sidePane.getJList().getSelectedIndex() == oldIndex){ | ||
202 | 22 | sidePane.moveDown(oldIndex); | ||
203 | 23 | sidePane.getJList().setSelectedIndex(oldIndex+1); | ||
204 | 24 | }else if(sidePane.getJList().getSelectedIndex() == oldIndex+1){ | ||
205 | 25 | sidePane.moveDown(oldIndex); | ||
206 | 26 | sidePane.getJList().setSelectedIndex(newIndex-1); | ||
207 | 27 | } else{ | ||
208 | 28 | sidePane.moveDown(oldIndex); | ||
209 | 29 | } | ||
210 | 30 | sidePane.getJList().updateUI(); | ||
211 | 31 | } | ||
212 | 32 | |||
213 | 33 | @Override | ||
214 | 34 | public void undo() { | ||
215 | 35 | if(sidePane.getJList().getSelectedIndex() == newIndex){ | ||
216 | 36 | sidePane.moveUp(newIndex); | ||
217 | 37 | sidePane.getJList().setSelectedIndex(newIndex-1); | ||
218 | 38 | } else if(sidePane.getJList().getSelectedIndex() == newIndex-1){ | ||
219 | 39 | sidePane.moveUp(newIndex); | ||
220 | 40 | sidePane.getJList().setSelectedIndex(oldIndex+1); | ||
221 | 41 | }else{ | ||
222 | 42 | sidePane.moveUp(newIndex); | ||
223 | 43 | } | ||
224 | 44 | sidePane.getJList().updateUI(); | ||
225 | 45 | } | ||
226 | 46 | } | ||
227 | 0 | 47 | ||
228 | === added file 'src/dk/aau/cs/gui/undo/MoveElementUpCommand.java' | |||
229 | --- src/dk/aau/cs/gui/undo/MoveElementUpCommand.java 1970-01-01 00:00:00 +0000 | |||
230 | +++ src/dk/aau/cs/gui/undo/MoveElementUpCommand.java 2020-05-16 08:49:46 +0000 | |||
231 | @@ -0,0 +1,51 @@ | |||
232 | 1 | package dk.aau.cs.gui.undo; | ||
233 | 2 | |||
234 | 3 | import pipe.dataLayer.Template; | ||
235 | 4 | import pipe.gui.widgets.SidePane; | ||
236 | 5 | |||
237 | 6 | import javax.swing.*; | ||
238 | 7 | |||
239 | 8 | public class MoveElementUpCommand extends Command{ | ||
240 | 9 | int oldIndex; | ||
241 | 10 | int newIndex; | ||
242 | 11 | SidePane sidePane; | ||
243 | 12 | JList<Template> templateList; | ||
244 | 13 | public MoveElementUpCommand(SidePane sidePane, int oldIndex, int newIndex){ | ||
245 | 14 | this.oldIndex = oldIndex; | ||
246 | 15 | this.newIndex = newIndex; | ||
247 | 16 | this.sidePane = sidePane; | ||
248 | 17 | } | ||
249 | 18 | |||
250 | 19 | @Override | ||
251 | 20 | public void redo() { | ||
252 | 21 | if(sidePane.getJList().getSelectedIndex() == oldIndex){ | ||
253 | 22 | sidePane.moveUp(oldIndex); | ||
254 | 23 | sidePane.getJList().setSelectedIndex(oldIndex-1); | ||
255 | 24 | sidePane.getJList().ensureIndexIsVisible(oldIndex-1); | ||
256 | 25 | } else if(sidePane.getJList().getSelectedIndex() == oldIndex-1){ | ||
257 | 26 | sidePane.moveUp(oldIndex); | ||
258 | 27 | sidePane.getJList().setSelectedIndex(newIndex+1); | ||
259 | 28 | sidePane.getJList().ensureIndexIsVisible(newIndex+1); | ||
260 | 29 | }else{ | ||
261 | 30 | sidePane.moveUp(oldIndex); | ||
262 | 31 | } | ||
263 | 32 | sidePane.getJList().updateUI(); | ||
264 | 33 | |||
265 | 34 | } | ||
266 | 35 | |||
267 | 36 | @Override | ||
268 | 37 | public void undo() { | ||
269 | 38 | if(sidePane.getJList().getSelectedIndex() == newIndex){ | ||
270 | 39 | sidePane.moveDown(newIndex); | ||
271 | 40 | sidePane.getJList().setSelectedIndex(newIndex+1); | ||
272 | 41 | sidePane.getJList().ensureIndexIsVisible(newIndex+1); | ||
273 | 42 | }else if(sidePane.getJList().getSelectedIndex() == newIndex+1){ | ||
274 | 43 | sidePane.moveDown(newIndex); | ||
275 | 44 | sidePane.getJList().setSelectedIndex(oldIndex-1); | ||
276 | 45 | sidePane.getJList().ensureIndexIsVisible(oldIndex-1); | ||
277 | 46 | } else{ | ||
278 | 47 | sidePane.moveDown(newIndex); | ||
279 | 48 | } | ||
280 | 49 | sidePane.getJList().updateUI(); | ||
281 | 50 | } | ||
282 | 51 | } | ||
283 | 0 | 52 | ||
284 | === modified file 'src/pipe/gui/widgets/ConstantsPane.java' | |||
285 | --- src/pipe/gui/widgets/ConstantsPane.java 2020-01-12 12:27:45 +0000 | |||
286 | +++ src/pipe/gui/widgets/ConstantsPane.java 2020-05-16 08:49:46 +0000 | |||
287 | @@ -19,7 +19,6 @@ | |||
288 | 19 | import java.awt.event.MouseEvent; | 19 | import java.awt.event.MouseEvent; |
289 | 20 | import java.io.IOException; | 20 | import java.io.IOException; |
290 | 21 | 21 | ||
291 | 22 | |||
292 | 23 | import javax.swing.BorderFactory; | 22 | import javax.swing.BorderFactory; |
293 | 24 | import javax.swing.ImageIcon; | 23 | import javax.swing.ImageIcon; |
294 | 25 | import javax.swing.JButton; | 24 | import javax.swing.JButton; |
295 | @@ -39,13 +38,15 @@ | |||
296 | 39 | import pipe.gui.CreateGui; | 38 | import pipe.gui.CreateGui; |
297 | 40 | import dk.aau.cs.gui.TabContent; | 39 | import dk.aau.cs.gui.TabContent; |
298 | 41 | import dk.aau.cs.gui.undo.Command; | 40 | import dk.aau.cs.gui.undo.Command; |
299 | 41 | import dk.aau.cs.gui.undo.MoveElementDownCommand; | ||
300 | 42 | import dk.aau.cs.gui.undo.MoveElementUpCommand; | ||
301 | 42 | import dk.aau.cs.gui.undo.SortConstantsCommand; | 43 | import dk.aau.cs.gui.undo.SortConstantsCommand; |
302 | 43 | import dk.aau.cs.model.tapn.Constant; | 44 | import dk.aau.cs.model.tapn.Constant; |
303 | 44 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; | 45 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; |
304 | 45 | import dk.aau.cs.gui.components.ConstantsListModel; | 46 | import dk.aau.cs.gui.components.ConstantsListModel; |
305 | 46 | import dk.aau.cs.gui.components.NonsearchableJList; | 47 | import dk.aau.cs.gui.components.NonsearchableJList; |
306 | 47 | 48 | ||
308 | 48 | public class ConstantsPane extends JPanel { | 49 | public class ConstantsPane extends JPanel implements SidePane { |
309 | 49 | private static final long serialVersionUID = -7883351020889779067L; | 50 | private static final long serialVersionUID = -7883351020889779067L; |
310 | 50 | private JPanel constantsPanel; | 51 | private JPanel constantsPanel; |
311 | 51 | private JScrollPane constantsScroller; | 52 | private JScrollPane constantsScroller; |
312 | @@ -362,8 +363,9 @@ | |||
313 | 362 | int index = constantsList.getSelectedIndex(); | 363 | int index = constantsList.getSelectedIndex(); |
314 | 363 | 364 | ||
315 | 364 | if(index > 0) { | 365 | if(index > 0) { |
318 | 365 | parent.swapConstants(index, index-1); | 366 | Command c = new MoveElementUpCommand(ConstantsPane.this, index, index-1); |
319 | 366 | showConstants(); | 367 | CreateGui.getDrawingSurface().getUndoManager().addNewEdit(c); |
320 | 368 | c.redo(); | ||
321 | 367 | constantsList.setSelectedIndex(index-1); | 369 | constantsList.setSelectedIndex(index-1); |
322 | 368 | } | 370 | } |
323 | 369 | } | 371 | } |
324 | @@ -383,8 +385,9 @@ | |||
325 | 383 | int index = constantsList.getSelectedIndex(); | 385 | int index = constantsList.getSelectedIndex(); |
326 | 384 | 386 | ||
327 | 385 | if(index < parent.network().constants().size() - 1) { | 387 | if(index < parent.network().constants().size() - 1) { |
330 | 386 | parent.swapConstants(index, index+1); | 388 | Command c = new MoveElementDownCommand(ConstantsPane.this, index, index+1); |
331 | 387 | showConstants(); | 389 | CreateGui.getDrawingSurface().getUndoManager().addNewEdit(c); |
332 | 390 | c.redo(); | ||
333 | 388 | constantsList.setSelectedIndex(index+1); | 391 | constantsList.setSelectedIndex(index+1); |
334 | 389 | } | 392 | } |
335 | 390 | } | 393 | } |
336 | @@ -480,4 +483,21 @@ | |||
337 | 480 | constantsList.setSelectedIndex(0); | 483 | constantsList.setSelectedIndex(0); |
338 | 481 | 484 | ||
339 | 482 | } | 485 | } |
340 | 486 | |||
341 | 487 | @Override | ||
342 | 488 | public void moveUp(int index) { | ||
343 | 489 | parent.swapConstants(index, index-1); | ||
344 | 490 | showConstants(); | ||
345 | 491 | } | ||
346 | 492 | |||
347 | 493 | @Override | ||
348 | 494 | public void moveDown(int index) { | ||
349 | 495 | parent.swapConstants(index, index+1); | ||
350 | 496 | showConstants(); | ||
351 | 497 | } | ||
352 | 498 | |||
353 | 499 | @Override | ||
354 | 500 | public JList getJList() { | ||
355 | 501 | return constantsList; | ||
356 | 502 | } | ||
357 | 483 | } | 503 | } |
358 | 484 | 504 | ||
359 | === modified file 'src/pipe/gui/widgets/QueryPane.java' | |||
360 | --- src/pipe/gui/widgets/QueryPane.java 2019-01-24 20:03:51 +0000 | |||
361 | +++ src/pipe/gui/widgets/QueryPane.java 2020-05-16 08:49:46 +0000 | |||
362 | @@ -42,12 +42,14 @@ | |||
363 | 42 | import dk.aau.cs.gui.BatchProcessingDialog; | 42 | import dk.aau.cs.gui.BatchProcessingDialog; |
364 | 43 | import dk.aau.cs.gui.TabContent; | 43 | import dk.aau.cs.gui.TabContent; |
365 | 44 | import dk.aau.cs.gui.undo.Command; | 44 | import dk.aau.cs.gui.undo.Command; |
366 | 45 | import dk.aau.cs.gui.undo.MoveElementDownCommand; | ||
367 | 46 | import dk.aau.cs.gui.undo.MoveElementUpCommand; | ||
368 | 45 | import dk.aau.cs.gui.undo.SortQueriesCommand; | 47 | import dk.aau.cs.gui.undo.SortQueriesCommand; |
369 | 46 | import dk.aau.cs.gui.components.NonsearchableJList; | 48 | import dk.aau.cs.gui.components.NonsearchableJList; |
370 | 47 | import dk.aau.cs.translations.ReductionOption; | 49 | import dk.aau.cs.translations.ReductionOption; |
371 | 48 | import dk.aau.cs.util.Require; | 50 | import dk.aau.cs.util.Require; |
372 | 49 | 51 | ||
374 | 50 | public class QueryPane extends JPanel { | 52 | public class QueryPane extends JPanel implements SidePane { |
375 | 51 | private static final long serialVersionUID = 4062539545170994654L; | 53 | private static final long serialVersionUID = 4062539545170994654L; |
376 | 52 | private JPanel queryCollectionPanel; | 54 | private JPanel queryCollectionPanel; |
377 | 53 | private JPanel buttonsPanel; | 55 | private JPanel buttonsPanel; |
378 | @@ -216,7 +218,9 @@ | |||
379 | 216 | int index = queryList.getSelectedIndex(); | 218 | int index = queryList.getSelectedIndex(); |
380 | 217 | 219 | ||
381 | 218 | if(index > 0 && queryList.getSelectedIndices().length == 1) { | 220 | if(index > 0 && queryList.getSelectedIndices().length == 1) { |
383 | 219 | swapQueries(index, index-1); | 221 | Command c = new MoveElementUpCommand(QueryPane.this, index, index-1); |
384 | 222 | undoManager.addNewEdit(c); | ||
385 | 223 | c.redo(); | ||
386 | 220 | queryList.setSelectedIndex(index-1); | 224 | queryList.setSelectedIndex(index-1); |
387 | 221 | } | 225 | } |
388 | 222 | else | 226 | else |
389 | @@ -238,8 +242,10 @@ | |||
390 | 238 | int index = queryList.getSelectedIndex(); | 242 | int index = queryList.getSelectedIndex(); |
391 | 239 | 243 | ||
392 | 240 | if(index < listModel.size()-1 && queryList.getSelectedIndices().length == 1) { | 244 | if(index < listModel.size()-1 && queryList.getSelectedIndices().length == 1) { |
395 | 241 | swapQueries(index, index+1); | 245 | Command c = new MoveElementDownCommand(QueryPane.this, index, index+1); |
396 | 242 | queryList.setSelectedIndex(index+1); | 246 | undoManager.addNewEdit(c); |
397 | 247 | c.redo(); | ||
398 | 248 | queryList.setSelectedIndex(index+1); | ||
399 | 243 | } | 249 | } |
400 | 244 | else | 250 | else |
401 | 245 | moveDownButton.setEnabled(false); | 251 | moveDownButton.setEnabled(false); |
402 | @@ -527,4 +533,17 @@ | |||
403 | 527 | public void verifySelectedQuery() { | 533 | public void verifySelectedQuery() { |
404 | 528 | verifyQuery(); | 534 | verifyQuery(); |
405 | 529 | } | 535 | } |
406 | 536 | |||
407 | 537 | @Override | ||
408 | 538 | public void moveUp(int index){ | ||
409 | 539 | swapQueries(index, index-1); | ||
410 | 540 | } | ||
411 | 541 | @Override | ||
412 | 542 | public void moveDown(int index){ | ||
413 | 543 | swapQueries(index, index+1); | ||
414 | 544 | } | ||
415 | 545 | @Override | ||
416 | 546 | public JList getJList(){ | ||
417 | 547 | return queryList; | ||
418 | 548 | } | ||
419 | 530 | } | 549 | } |
420 | 531 | 550 | ||
421 | === added file 'src/pipe/gui/widgets/SidePane.java' | |||
422 | --- src/pipe/gui/widgets/SidePane.java 1970-01-01 00:00:00 +0000 | |||
423 | +++ src/pipe/gui/widgets/SidePane.java 2020-05-16 08:49:46 +0000 | |||
424 | @@ -0,0 +1,9 @@ | |||
425 | 1 | package pipe.gui.widgets; | ||
426 | 2 | |||
427 | 3 | import javax.swing.*; | ||
428 | 4 | |||
429 | 5 | public interface SidePane { | ||
430 | 6 | public void moveUp(int index); | ||
431 | 7 | public void moveDown(int index); | ||
432 | 8 | public JList getJList(); | ||
433 | 9 | } |
Next time propose the merge for 3.6 series and not for trunk.