Merge lp:~tapaal-contributor/tapaal/undo-up-down-sidepane-3.6-1870894 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Rejected
Rejected by: Kenneth Yrke Jørgensen
Proposed branch: lp:~tapaal-contributor/tapaal/undo-up-down-sidepane-3.6-1870894
Merge into: lp:tapaal
Diff against target: 1033 lines (+554/-7) (has conflicts)
16 files modified
src/dk/aau/cs/gui/BatchProcessingDialog.java (+67/-0)
src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java (+56/-2)
src/dk/aau/cs/gui/TabContent.java (+8/-0)
src/dk/aau/cs/gui/TemplateExplorer.java (+41/-0)
src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java (+16/-0)
src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java (+6/-0)
src/dk/aau/cs/gui/undo/MoveElementDownCommand.java (+46/-0)
src/dk/aau/cs/gui/undo/MoveElementUpCommand.java (+51/-0)
src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java (+34/-0)
src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java (+35/-0)
src/net/tapaal/TAPAAL.java (+1/-1)
src/pipe/gui/undo/TranslatePetriNetObjectEdit.java (+24/-0)
src/pipe/gui/undo/UndoManager.java (+91/-0)
src/pipe/gui/widgets/ConstantsPane.java (+42/-1)
src/pipe/gui/widgets/QueryPane.java (+27/-3)
src/pipe/gui/widgets/SidePane.java (+9/-0)
Text conflict in src/dk/aau/cs/gui/BatchProcessingDialog.java
Text conflict in src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java
Text conflict in src/dk/aau/cs/gui/TabContent.java
Text conflict in src/dk/aau/cs/gui/TemplateExplorer.java
Text conflict in src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java
Text conflict in src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java
Text conflict in src/pipe/gui/undo/TranslatePetriNetObjectEdit.java
Text conflict in src/pipe/gui/undo/UndoManager.java
Text conflict in src/pipe/gui/widgets/ConstantsPane.java
Text conflict in src/pipe/gui/widgets/QueryPane.java
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/undo-up-down-sidepane-3.6-1870894
Reviewer Review Type Date Requested Status
Jiri Srba Pending
Review via email: mp+383882@code.launchpad.net

Commit message

Add undo/redo functionality when moving up and down with the arrows in the sidepanes.

To post a comment you must log in.

Unmerged revisions

1051. By Peter Taankvist <email address hidden>

Add undo functionality to up/down arrows in sidepane

1050. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/undo-redo-batchprocessing-3.6-1870904 fixing redo/undo in batch processing in the file selection dialog

1049. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/undo-redo-update-scrollbar-3.6-1875174 fixing unde/redo if a an object is placed outside of the drawing area

1048. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/fix-shared-places-exception-1871091 fixing exceptions in component copying and shared places

1047. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/fix-positionalInfo-detection-1870899 fixing positional info loading for PNML files

1046. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/shared-place-transition-rename-1871091 fixing problem with renaming of shared places

1045. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/pnml-disable-buttons-1868535 fixing enabled buttons when pnml file open fails

1044. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/open-on-windows-1868525 fixing .xml file open on windows

1043. By <email address hidden>

changed version number to 3.6.1 - this is the release version

1042. By <email address hidden>

changed year from 2019 to 2020

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/BatchProcessingDialog.java'
2--- src/dk/aau/cs/gui/BatchProcessingDialog.java 2020-05-03 09:49:19 +0000
3+++ src/dk/aau/cs/gui/BatchProcessingDialog.java 2020-05-13 15:53:33 +0000
4@@ -24,14 +24,25 @@
5 import javax.swing.table.TableModel;
6 import javax.swing.table.TableRowSorter;
7
8+<<<<<<< TREE
9 import dk.aau.cs.gui.undo.AddFileBatchProcessingCommand;
10 import dk.aau.cs.gui.undo.Command;
11 import dk.aau.cs.gui.undo.RemoveFileBatchProcessingCommand;
12+=======
13+import dk.aau.cs.gui.undo.Command;
14+import dk.aau.cs.verification.batchProcessing.Undo.AddFileCommand;
15+import dk.aau.cs.verification.batchProcessing.Undo.RemoveFileCommand;
16+>>>>>>> MERGE-SOURCE
17 import pipe.dataLayer.TAPNQuery;
18 import pipe.dataLayer.TAPNQuery.SearchOption;
19 import pipe.gui.CreateGui;
20+<<<<<<< TREE
21 import net.tapaal.swinghelpers.CustomJSpinner;
22 import pipe.gui.undo.UndoManager;
23+=======
24+import pipe.gui.undo.UndoManager;
25+import pipe.gui.widgets.CustomJSpinner;
26+>>>>>>> MERGE-SOURCE
27 import pipe.gui.widgets.EscapableDialog;
28 import pipe.gui.widgets.filebrowser.FileBrowser;
29 import pipe.gui.widgets.QueryPane;
30@@ -237,6 +248,7 @@
31 private static int memoryTimerCount = 0;
32 private static int memoryTimerMode = 0;
33 private static int peakMemory = -1;
34+ private UndoManager undoManager = new UndoManager(null,null,null);
35
36 private void startMemoryTimer(){
37 if(memoryTimer.isRunning()){
38@@ -465,25 +477,51 @@
39 FileBrowser browser = FileBrowser.constructor("Timed-Arc Petri Nets","tapn", "xml", lastPath);
40 File[] filesArray = browser.openFiles();
41 if (filesArray.length>0) {
42+<<<<<<< TREE
43 undoManager.newEdit();
44 for (File file : filesArray) {
45+=======
46+ undoManager.newEdit();
47+ for (File file : filesArray) {
48+>>>>>>> MERGE-SOURCE
49 lastPath = file.getParent();
50 if (!files.contains(file)) {
51+<<<<<<< TREE
52 Command c = new AddFileBatchProcessingCommand(listModel,file, files, this );
53 c.redo();
54 undoManager.addEdit(c);
55+=======
56+ Command c = new AddFileCommand(listModel,file,files,this);
57+ c.redo();
58+ undoManager.addEdit(c);
59+
60+>>>>>>> MERGE-SOURCE
61 }
62 }
63+<<<<<<< TREE
64+=======
65+ enableButtons();
66+>>>>>>> MERGE-SOURCE
67 }
68 }
69
70 private void removeSelectedFiles() {
71+<<<<<<< TREE
72 undoManager.newEdit();
73+=======
74+ undoManager.newEdit();
75+>>>>>>> MERGE-SOURCE
76 for (Object o : fileList.getSelectedValuesList()) {
77 File file = (File) o;
78+<<<<<<< TREE
79 Command c = new RemoveFileBatchProcessingCommand(listModel,file, files, this );
80 c.redo();
81 undoManager.addEdit(c);
82+=======
83+ Command c = new RemoveFileCommand(listModel, file,files,this);
84+ c.redo();
85+ undoManager.addEdit(c);
86+>>>>>>> MERGE-SOURCE
87 }
88 }
89
90@@ -1383,6 +1421,7 @@
91 }
92
93 private void clearFiles() {
94+<<<<<<< TREE
95 undoManager.newEdit();
96
97 for (Object o : listModel.toArray()) {
98@@ -1391,6 +1430,15 @@
99 c.redo();
100 undoManager.addEdit(c);
101 }
102+=======
103+ undoManager.newEdit();
104+ for (Object o : listModel.toArray()) {
105+ File file = (File)o;
106+ Command c = new RemoveFileCommand(listModel,file, files, this );
107+ c.redo();
108+ undoManager.addEdit(c);
109+ }
110+>>>>>>> MERGE-SOURCE
111 }
112
113 private void disableButtonsDuringProcessing() {
114@@ -1425,6 +1473,25 @@
115
116 enabledVerificationOptionButtons();
117 }
118+ private void makeShortcuts(){
119+ int shortcutkey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
120+ ActionMap am = splitpane.getActionMap();
121+ am.put("undo", new AbstractAction() {
122+ @Override
123+ public void actionPerformed(ActionEvent e) {
124+ undoManager.undo();
125+ }
126+ });
127+ am.put("redo", new AbstractAction() {
128+ @Override
129+ public void actionPerformed(ActionEvent e) {
130+ undoManager.redo();
131+ }
132+ });
133+ InputMap im = splitpane.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW);
134+ im.put(KeyStroke.getKeyStroke('Z', shortcutkey), "undo");
135+ im.put(KeyStroke.getKeyStroke('Y', shortcutkey), "redo");
136+ }
137
138 // Custom cell renderer for the Query Column of the result table display the
139 // property of the query
140
141=== modified file 'src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java'
142--- src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java 2020-04-18 12:27:02 +0000
143+++ src/dk/aau/cs/gui/SharedPlacesAndTransitionsPanel.java 2020-05-13 15:53:33 +0000
144@@ -27,9 +27,11 @@
145 import pipe.gui.CreateGui;
146 import pipe.gui.undo.UndoManager;
147 import pipe.gui.widgets.EscapableDialog;
148-
149+import pipe.gui.widgets.SidePane;
150 import dk.aau.cs.gui.components.NonsearchableJList;
151 import dk.aau.cs.gui.undo.Command;
152+import dk.aau.cs.gui.undo.MoveElementDownCommand;
153+import dk.aau.cs.gui.undo.MoveElementUpCommand;
154 import dk.aau.cs.gui.undo.SortSharedPlacesCommand;
155 import dk.aau.cs.gui.undo.SortSharedTransitionsCommand;
156 import dk.aau.cs.model.tapn.SharedPlace;
157@@ -37,7 +39,7 @@
158 import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
159 import dk.aau.cs.util.Require;
160
161-public class SharedPlacesAndTransitionsPanel extends JPanel {
162+public class SharedPlacesAndTransitionsPanel extends JPanel implements SidePane{
163 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>";
164 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>";
165
166@@ -192,6 +194,7 @@
167 moveUpButton = new JButton(new ImageIcon(Thread.currentThread().getContextClassLoader().getResource("resources/Images/Up.png")));
168 moveUpButton.setEnabled(false);
169 moveUpButton.setToolTipText(toolTipMoveUp);
170+<<<<<<< TREE
171 moveUpButton.addActionListener(e -> {
172 int index = list.getSelectedIndex();
173
174@@ -202,6 +205,19 @@
175 sharedPlacesListModel.swap(index, index-1);
176 list.setSelectedIndex(index-1);
177 list.ensureIndexIsVisible(index-1);
178+=======
179+ moveUpButton.addActionListener(new ActionListener() {
180+ public void actionPerformed(ActionEvent e) {
181+ int index = list.getSelectedIndex();
182+
183+ if(index > 0) {
184+ Command c = new MoveElementUpCommand(SharedPlacesAndTransitionsPanel.this, index, index-1);
185+ undoManager.addNewEdit(c);
186+ c.redo();
187+ list.setSelectedIndex(index-1);
188+ list.ensureIndexIsVisible(index-1);
189+ }
190+>>>>>>> MERGE-SOURCE
191 }
192 });
193
194@@ -214,6 +230,7 @@
195 moveDownButton = new JButton(new ImageIcon(Thread.currentThread().getContextClassLoader().getResource("resources/Images/Down.png")));
196 moveDownButton.setEnabled(false);
197 moveDownButton.setToolTipText(toolTipMoveDown);
198+<<<<<<< TREE
199 moveDownButton.addActionListener(e -> {
200 int index = list.getSelectedIndex();
201
202@@ -230,6 +247,17 @@
203 list.setSelectedIndex(index+1);
204 list.ensureIndexIsVisible(index+1);
205 }
206+=======
207+ moveDownButton.addActionListener(new ActionListener() {
208+ public void actionPerformed(ActionEvent e) {
209+ int index = list.getSelectedIndex();
210+
211+ Command c = new MoveElementDownCommand(SharedPlacesAndTransitionsPanel.this, index, index+1);
212+ undoManager.addNewEdit(c);
213+ c.redo();
214+ list.setSelectedIndex(index+1);
215+ list.ensureIndexIsVisible(index+1);
216+>>>>>>> MERGE-SOURCE
217 }
218 });
219
220@@ -606,4 +634,30 @@
221 fireContentsChanged(this, 0, network.numberOfSharedTransitions());
222 }
223 }
224+
225+ @Override
226+ public void moveUp(int index) {
227+ if(isDisplayingTransitions())
228+ sharedTransitionsListModel.swap(index, index-1);
229+ else
230+ sharedPlacesListModel.swap(index, index-1);
231+ }
232+
233+ @Override
234+ public void moveDown(int index) {
235+ if(isDisplayingTransitions()) {
236+ if(index < sharedTransitionsListModel.getSize() - 1) {
237+ sharedTransitionsListModel.swap(index, index+1);
238+ }
239+ } else {
240+ if(index < sharedPlacesListModel.getSize() - 1) {
241+ sharedPlacesListModel.swap(index, index+1);
242+ }
243+ }
244+ }
245+
246+ @Override
247+ public JList getJList() {
248+ return list;
249+ }
250 }
251
252=== modified file 'src/dk/aau/cs/gui/TabContent.java'
253--- src/dk/aau/cs/gui/TabContent.java 2020-04-30 12:51:14 +0000
254+++ src/dk/aau/cs/gui/TabContent.java 2020-05-13 15:53:33 +0000
255@@ -51,6 +51,7 @@
256 private TimedArcPetriNetNetwork tapnNetwork = new TimedArcPetriNetNetwork();
257 private HashMap<TimedArcPetriNet, DataLayer> guiModels = new HashMap<TimedArcPetriNet, DataLayer>();
258 private HashMap<TimedArcPetriNet, Zoomer> zoomLevels = new HashMap<TimedArcPetriNet, Zoomer>();
259+<<<<<<< TREE
260
261
262 private UndoManager undoManager = new UndoManager();
263@@ -182,6 +183,9 @@
264
265 private HashMap<TimedArcPetriNet, Boolean> hasPositionalInfos = new HashMap<TimedArcPetriNet, Boolean>();
266
267+=======
268+ private HashMap<TimedArcPetriNet, Boolean> hasPositionalInfos = new HashMap<TimedArcPetriNet, Boolean>();
269+>>>>>>> MERGE-SOURCE
270 private JScrollPane drawingSurfaceScroller;
271 private JScrollPane editorSplitPaneScroller;
272 private JScrollPane animatorSplitPaneScroller;
273@@ -229,7 +233,11 @@
274 for (TimedArcPetriNet net : tapnNetwork.allTemplates()) {
275 guiModels.put(net, new DataLayer());
276 zoomLevels.put(net, new Zoomer());
277+<<<<<<< TREE
278 hasPositionalInfos.put(net, Boolean.FALSE);
279+=======
280+ hasPositionalInfos.put(net, new Boolean(false));
281+>>>>>>> MERGE-SOURCE
282 }
283
284 drawingSurface = new DrawingSurfaceImpl(new DataLayer(), this, managerRef);
285
286=== modified file 'src/dk/aau/cs/gui/TemplateExplorer.java'
287--- src/dk/aau/cs/gui/TemplateExplorer.java 2020-04-18 15:50:17 +0000
288+++ src/dk/aau/cs/gui/TemplateExplorer.java 2020-05-13 15:53:33 +0000
289@@ -53,6 +53,8 @@
290 import dk.aau.cs.TCTL.visitors.ContainsPlaceWithDisabledTemplateVisitor;
291 import dk.aau.cs.gui.components.NonsearchableJList;
292 import dk.aau.cs.gui.undo.Command;
293+import dk.aau.cs.gui.undo.MoveElementDownCommand;
294+import dk.aau.cs.gui.undo.MoveElementUpCommand;
295 import dk.aau.cs.gui.undo.SortTemplatesCommand;
296 import dk.aau.cs.model.tapn.Constant;
297 import dk.aau.cs.model.tapn.SharedTransition;
298@@ -61,8 +63,16 @@
299 import dk.aau.cs.model.tapn.TimedTransition;
300 import dk.aau.cs.util.Require;
301 import dk.aau.cs.util.Tuple;
302+<<<<<<< TREE
303
304 public class TemplateExplorer extends JPanel {
305+=======
306+import pipe.gui.widgets.SidePane;
307+
308+
309+public class TemplateExplorer extends JPanel implements SidePane{
310+ private static final long serialVersionUID = -2334464984237161208L;
311+>>>>>>> MERGE-SOURCE
312
313 // Template explorer panel items
314 private JPanel templatePanel;
315@@ -244,10 +254,16 @@
316 int index = templateList.getSelectedIndex();
317
318 if(index > 0) {
319+<<<<<<< TREE
320 parent.swapTemplates(index, index-1);
321 Template o = listModel.getElementAt(index);
322 listModel.setElementAt(listModel.getElementAt(index-1), index);
323 listModel.setElementAt(o, index-1);
324+=======
325+ Command c = new MoveElementUpCommand(TemplateExplorer.this, index, index-1);
326+ undoManager.addNewEdit(c);
327+ c.redo();
328+>>>>>>> MERGE-SOURCE
329 templateList.ensureIndexIsVisible(index+1);
330 templateList.setSelectedIndex(index-1);
331 }
332@@ -268,10 +284,16 @@
333 int index = templateList.getSelectedIndex();
334
335 if(index < parent.network().allTemplates().size() - 1) {
336+<<<<<<< TREE
337 parent.swapTemplates(index, index+1);
338 Template o = listModel.getElementAt(index);
339 listModel.setElementAt(listModel.getElementAt(index+1), index);
340 listModel.setElementAt(o, index+1);
341+=======
342+ Command c = new MoveElementDownCommand(TemplateExplorer.this, index, index+1);
343+ undoManager.addNewEdit(c);
344+ c.redo();
345+>>>>>>> MERGE-SOURCE
346 templateList.ensureIndexIsVisible(index+1);
347 templateList.setSelectedIndex(index+1);
348 }
349@@ -1002,4 +1024,23 @@
350 }
351
352 }
353+ @Override
354+ public void moveUp(int index) {
355+ parent.swapTemplates(index, index-1);
356+ Object o = listModel.getElementAt(index);
357+ listModel.setElementAt(listModel.getElementAt(index-1), index);
358+ listModel.setElementAt(o, index-1);
359+ }
360+
361+ @Override
362+ public void moveDown(int index) {
363+ parent.swapTemplates(index, index+1);
364+ Object o = listModel.getElementAt(index);
365+ listModel.setElementAt(listModel.getElementAt(index+1), index);
366+ listModel.setElementAt(o, index+1);
367+ }
368+ @Override
369+ public JList getJList(){
370+ return templateList;
371+ }
372 }
373
374=== modified file 'src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java'
375--- src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java 2020-04-18 14:41:05 +0000
376+++ src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java 2020-05-13 15:53:33 +0000
377@@ -36,6 +36,7 @@
378 boolean first = true;
379 for(Template template : context.tabContent().allTemplates()) {
380 TimedPlaceComponent component = (TimedPlaceComponent)template.guiModel().getPlaceByName(place.getName());
381+<<<<<<< TREE
382
383 if (component != null) {
384 if (first) { //We make a new shared place with the first place
385@@ -50,6 +51,21 @@
386 commands.add(command);
387 }
388 }
389+=======
390+ //We make a new shared place with the first place
391+ if(component != null && i < 1) {
392+ command = new MakePlaceNewSharedCommand(template.model(), newSharedName, component.underlyingPlace(), component, context.tabContent(), true);
393+ command.redo();
394+ sharedPlace = (SharedPlace)component.underlyingPlace();
395+ commands.add(command);
396+ i++;
397+ //For the rest we make them shared with the recently made place
398+ } else if (component != null && i >= 1){
399+ command = new MakePlaceSharedCommand(context.activeModel(), sharedPlace, component.underlyingPlace(), component, context.tabContent(), true);
400+ command.redo();
401+ commands.add(command);
402+ }
403+>>>>>>> MERGE-SOURCE
404 }
405 }
406
407
408=== modified file 'src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java'
409--- src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java 2020-04-18 14:41:05 +0000
410+++ src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java 2020-05-13 15:53:33 +0000
411@@ -27,9 +27,15 @@
412
413 private final Hashtable<TAPNQuery, TAPNQuery> newQueryToOldQueryMapping;
414 private final List<TimedToken> oldTokens;
415+<<<<<<< TREE
416 private final TabContent currentTab;
417
418 public MakePlaceSharedCommand(TimedArcPetriNet tapn, SharedPlace sharedPlace, TimedPlace place, TimedPlaceComponent placeComponent, TabContent currentTab, boolean multishare){
419+=======
420+ private TabContent currentTab;
421+
422+ public MakePlaceSharedCommand(TimedArcPetriNet tapn, SharedPlace sharedPlace, TimedPlace place, TimedPlaceComponent placeComponent, TabContent currentTab, boolean multishare){
423+>>>>>>> MERGE-SOURCE
424 Require.that(tapn != null, "tapn cannot be null");
425 Require.that(sharedPlace != null, "sharedPlace cannot be null");
426 Require.that(place != null, "timedPlace cannot be null");
427
428=== added file 'src/dk/aau/cs/gui/undo/MoveElementDownCommand.java'
429--- src/dk/aau/cs/gui/undo/MoveElementDownCommand.java 1970-01-01 00:00:00 +0000
430+++ src/dk/aau/cs/gui/undo/MoveElementDownCommand.java 2020-05-13 15:53:33 +0000
431@@ -0,0 +1,46 @@
432+package dk.aau.cs.gui.undo;
433+
434+import pipe.dataLayer.Template;
435+import pipe.gui.widgets.SidePane;
436+
437+import javax.swing.*;
438+
439+public class MoveElementDownCommand extends Command{
440+ int oldIndex;
441+ int newIndex;
442+ SidePane sidePane;
443+ JList<Template> templateList;
444+ public MoveElementDownCommand(SidePane sidePane, int oldIndex, int newIndex){
445+ this.oldIndex = oldIndex;
446+ this.newIndex = newIndex;
447+ this.sidePane = sidePane;
448+ }
449+
450+ @Override
451+ public void redo() {
452+ if(sidePane.getJList().getSelectedIndex() == oldIndex){
453+ sidePane.moveDown(oldIndex);
454+ sidePane.getJList().setSelectedIndex(oldIndex+1);
455+ }else if(sidePane.getJList().getSelectedIndex() == oldIndex+1){
456+ sidePane.moveDown(oldIndex);
457+ sidePane.getJList().setSelectedIndex(newIndex-1);
458+ } else{
459+ sidePane.moveDown(oldIndex);
460+ }
461+ sidePane.getJList().updateUI();
462+ }
463+
464+ @Override
465+ public void undo() {
466+ if(sidePane.getJList().getSelectedIndex() == newIndex){
467+ sidePane.moveUp(newIndex);
468+ sidePane.getJList().setSelectedIndex(newIndex-1);
469+ } else if(sidePane.getJList().getSelectedIndex() == newIndex-1){
470+ sidePane.moveUp(newIndex);
471+ sidePane.getJList().setSelectedIndex(oldIndex+1);
472+ }else{
473+ sidePane.moveUp(newIndex);
474+ }
475+ sidePane.getJList().updateUI();
476+ }
477+}
478
479=== added file 'src/dk/aau/cs/gui/undo/MoveElementUpCommand.java'
480--- src/dk/aau/cs/gui/undo/MoveElementUpCommand.java 1970-01-01 00:00:00 +0000
481+++ src/dk/aau/cs/gui/undo/MoveElementUpCommand.java 2020-05-13 15:53:33 +0000
482@@ -0,0 +1,51 @@
483+package dk.aau.cs.gui.undo;
484+
485+import pipe.dataLayer.Template;
486+import pipe.gui.widgets.SidePane;
487+
488+import javax.swing.*;
489+
490+public class MoveElementUpCommand extends Command{
491+ int oldIndex;
492+ int newIndex;
493+ SidePane sidePane;
494+ JList<Template> templateList;
495+ public MoveElementUpCommand(SidePane sidePane, int oldIndex, int newIndex){
496+ this.oldIndex = oldIndex;
497+ this.newIndex = newIndex;
498+ this.sidePane = sidePane;
499+ }
500+
501+ @Override
502+ public void redo() {
503+ if(sidePane.getJList().getSelectedIndex() == oldIndex){
504+ sidePane.moveUp(oldIndex);
505+ sidePane.getJList().setSelectedIndex(oldIndex-1);
506+ sidePane.getJList().ensureIndexIsVisible(oldIndex-1);
507+ } else if(sidePane.getJList().getSelectedIndex() == oldIndex-1){
508+ sidePane.moveUp(oldIndex);
509+ sidePane.getJList().setSelectedIndex(newIndex+1);
510+ sidePane.getJList().ensureIndexIsVisible(newIndex+1);
511+ }else{
512+ sidePane.moveUp(oldIndex);
513+ }
514+ sidePane.getJList().updateUI();
515+
516+ }
517+
518+ @Override
519+ public void undo() {
520+ if(sidePane.getJList().getSelectedIndex() == newIndex){
521+ sidePane.moveDown(newIndex);
522+ sidePane.getJList().setSelectedIndex(newIndex+1);
523+ sidePane.getJList().ensureIndexIsVisible(newIndex+1);
524+ }else if(sidePane.getJList().getSelectedIndex() == newIndex+1){
525+ sidePane.moveDown(newIndex);
526+ sidePane.getJList().setSelectedIndex(oldIndex-1);
527+ sidePane.getJList().ensureIndexIsVisible(oldIndex-1);
528+ } else{
529+ sidePane.moveDown(newIndex);
530+ }
531+ sidePane.getJList().updateUI();
532+ }
533+}
534
535=== added directory 'src/dk/aau/cs/verification/batchProcessing/Undo'
536=== added file 'src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java'
537--- src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java 1970-01-01 00:00:00 +0000
538+++ src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java 2020-05-13 15:53:33 +0000
539@@ -0,0 +1,34 @@
540+package dk.aau.cs.verification.batchProcessing.Undo;
541+
542+import dk.aau.cs.gui.BatchProcessingDialog;
543+import dk.aau.cs.gui.undo.Command;
544+
545+import javax.swing.*;
546+import java.io.File;
547+import java.util.List;
548+
549+public class AddFileCommand extends Command {
550+ private DefaultListModel listModel;
551+ List<File> files;
552+ File file;
553+ private BatchProcessingDialog dialog;
554+ public AddFileCommand(DefaultListModel listModel, File file, List<File> files, BatchProcessingDialog dialog){
555+ this.listModel = listModel;
556+ this.file = file;
557+ this.files = files;
558+ this.dialog = dialog;
559+ }
560+ @Override
561+ public void redo() {
562+ files.add(file);
563+ listModel.addElement(file);
564+ dialog.enableButtons();
565+ }
566+
567+ @Override
568+ public void undo() {
569+ files.remove(file);
570+ listModel.removeElement(file);
571+ dialog.enableButtons();
572+ }
573+}
574
575=== added file 'src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java'
576--- src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java 1970-01-01 00:00:00 +0000
577+++ src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java 2020-05-13 15:53:33 +0000
578@@ -0,0 +1,35 @@
579+package dk.aau.cs.verification.batchProcessing.Undo;
580+
581+import dk.aau.cs.gui.BatchProcessingDialog;
582+import dk.aau.cs.gui.undo.Command;
583+
584+import javax.swing.*;
585+import java.io.File;
586+import java.util.List;
587+
588+public class RemoveFileCommand extends Command {
589+ private DefaultListModel listModel;
590+ List<File> files;
591+ File file;
592+ private BatchProcessingDialog dialog;
593+ public RemoveFileCommand(DefaultListModel listModel, File file, List<File> files, BatchProcessingDialog dialog){
594+ this.listModel = listModel;
595+ this.file = file;
596+ this.files = files;
597+ this.dialog = dialog;
598+ }
599+ @Override
600+ public void redo() {
601+ files.remove(file);
602+ listModel.removeElement(file);
603+ dialog.enableButtons();
604+ }
605+
606+ @Override
607+ public void undo() {
608+ files.add(file);
609+ listModel.addElement(file);
610+ dialog.enableButtons();
611+ }
612+}
613+
614
615=== modified file 'src/net/tapaal/TAPAAL.java'
616--- src/net/tapaal/TAPAAL.java 2020-04-18 16:13:35 +0000
617+++ src/net/tapaal/TAPAAL.java 2020-05-13 15:53:33 +0000
618@@ -39,7 +39,7 @@
619 public class TAPAAL {
620
621 public static final String TOOLNAME = "TAPAAL";
622- public static final String VERSION = "DEV";
623+ public static final String VERSION = "3.6.1";
624
625 public static String getProgramName(){
626 return "" + TAPAAL.TOOLNAME + " " + TAPAAL.VERSION;
627
628=== modified file 'src/pipe/gui/undo/TranslatePetriNetObjectEdit.java'
629--- src/pipe/gui/undo/TranslatePetriNetObjectEdit.java 2020-05-02 15:30:09 +0000
630+++ src/pipe/gui/undo/TranslatePetriNetObjectEdit.java 2020-05-13 15:53:33 +0000
631@@ -4,7 +4,11 @@
632
633 package pipe.gui.undo;
634
635+<<<<<<< TREE
636 import pipe.gui.canvas.DrawingSurfaceImpl;
637+=======
638+import pipe.gui.DrawingSurfaceImpl;
639+>>>>>>> MERGE-SOURCE
640 import pipe.gui.graphicElements.PetriNetObject;
641 import dk.aau.cs.gui.undo.Command;
642
643@@ -17,29 +21,49 @@
644 PetriNetObject pnObject;
645 Integer transX;
646 Integer transY;
647+<<<<<<< TREE
648 DrawingSurfaceImpl ds;
649+=======
650+ DrawingSurfaceImpl view;
651+>>>>>>> MERGE-SOURCE
652
653 /** Creates a new instance of */
654 public TranslatePetriNetObjectEdit(PetriNetObject _pnObject,
655+<<<<<<< TREE
656 Integer _transX, Integer _transY, DrawingSurfaceImpl drawingSurface) {
657+=======
658+ Integer _transX, Integer _transY, DrawingSurfaceImpl view) {
659+>>>>>>> MERGE-SOURCE
660 pnObject = _pnObject;
661 transX = _transX;
662 transY = _transY;
663+<<<<<<< TREE
664 ds = drawingSurface;
665+=======
666+ this.view = view;
667+>>>>>>> MERGE-SOURCE
668 }
669
670 /** */
671 @Override
672 public void undo() {
673 pnObject.translate(-transX, -transY);
674+<<<<<<< TREE
675 ds.updatePreferredSize();
676+=======
677+ view.updatePreferredSize();
678+>>>>>>> MERGE-SOURCE
679 }
680
681 /** */
682 @Override
683 public void redo() {
684 pnObject.translate(transX, transY);
685+<<<<<<< TREE
686 ds.updatePreferredSize();
687+=======
688+ view.updatePreferredSize();
689+>>>>>>> MERGE-SOURCE
690 }
691
692 @Override
693
694=== modified file 'src/pipe/gui/undo/UndoManager.java'
695--- src/pipe/gui/undo/UndoManager.java 2020-05-03 09:49:19 +0000
696+++ src/pipe/gui/undo/UndoManager.java 2020-05-13 15:53:33 +0000
697@@ -38,10 +38,21 @@
698 /**
699 * Creates a new instance of UndoManager
700 */
701+<<<<<<< TREE
702 public UndoManager() {
703
704 app.ifPresent(a -> a.setUndoActionEnabled(false));
705 app.ifPresent(a -> a.setRedoActionEnabled(false));
706+=======
707+ public UndoManager(DrawingSurfaceImpl _view, DataLayer _model, GuiFrame _app) {
708+ view = _view;
709+ guiModel = _model;
710+ app = _app;
711+ if(app != null) {
712+ app.setUndoActionEnabled(false);
713+ app.setRedoActionEnabled(false);
714+ }
715+>>>>>>> MERGE-SOURCE
716 for (int i = 0; i < UNDO_BUFFER_CAPACITY; i++) {
717 edits.add(null);
718 }
719@@ -50,7 +61,14 @@
720 public void redo() {
721
722 if (undoneEdits > 0) {
723+<<<<<<< TREE
724 checkArcBeingDrawn();
725+=======
726+ if(app != null && view != null) {
727+ checkArcBeingDrawn();
728+ checkMode();
729+ }
730+>>>>>>> MERGE-SOURCE
731
732 // The currentEdit to redo
733 for (Command command : edits.get(indexOfNextAdd)) {
734@@ -59,10 +77,21 @@
735 indexOfNextAdd = (indexOfNextAdd + 1) % UNDO_BUFFER_CAPACITY;
736 sizeOfBuffer++;
737 undoneEdits--;
738+<<<<<<< TREE
739 if (undoneEdits == 0) {
740 app.ifPresent(a -> a.setRedoActionEnabled(false));
741+=======
742+ if(app != null) {
743+ if (undoneEdits == 0) {
744+ app.setRedoActionEnabled(false);
745+ }
746+ app.setUndoActionEnabled(true);
747+>>>>>>> MERGE-SOURCE
748 }
749+<<<<<<< TREE
750 app.ifPresent(a -> a.setUndoActionEnabled(true));
751+=======
752+>>>>>>> MERGE-SOURCE
753 }
754 }
755
756@@ -79,7 +108,14 @@
757 public void undo() {
758
759 if (sizeOfBuffer > 0) {
760+<<<<<<< TREE
761 checkArcBeingDrawn();
762+=======
763+ if(app != null && view != null) {
764+ checkArcBeingDrawn();
765+ checkMode();
766+ }
767+>>>>>>> MERGE-SOURCE
768
769 if (--indexOfNextAdd < 0) {
770 indexOfNextAdd += UNDO_BUFFER_CAPACITY;
771@@ -92,11 +128,22 @@
772 for (int i = currentEdit.size() - 1; i >= 0; i--) {
773 currentEdit.get(i).undo();
774 }
775+<<<<<<< TREE
776
777 if (sizeOfBuffer == 0) {
778 app.ifPresent(a -> a.setUndoActionEnabled(false));
779+=======
780+ if(app != null) {
781+ if (sizeOfBuffer == 0) {
782+ app.setUndoActionEnabled(false);
783+ }
784+ app.setRedoActionEnabled(true);
785+>>>>>>> MERGE-SOURCE
786 }
787+<<<<<<< TREE
788 app.ifPresent(a -> a.setRedoActionEnabled(true));
789+=======
790+>>>>>>> MERGE-SOURCE
791 }
792 }
793
794@@ -116,11 +163,21 @@
795 }
796
797 undoneEdits = 0;
798+<<<<<<< TREE
799 app.ifPresent(a -> a.setUndoActionEnabled(true));
800 app.ifPresent(a -> a.setRedoActionEnabled(false));
801 if(CreateGui.getCurrentTab() != null) {
802 CreateGui.getCurrentTab().setNetChanged(true);
803 }
804+=======
805+ if(app != null) {
806+ app.setUndoActionEnabled(true);
807+ app.setRedoActionEnabled(false);
808+ }
809+ if(view != null){
810+ view.setNetChanged(true);
811+ }
812+>>>>>>> MERGE-SOURCE
813
814 ArrayList<Command> compoundEdit = new ArrayList<Command>();
815 edits.set(indexOfNextAdd, compoundEdit);
816@@ -143,6 +200,40 @@
817 addEdit(undoableEdit);
818 }
819
820+<<<<<<< TREE
821+=======
822+ private void deleteSelection(PetriNetObject pnObject) {
823+ if(pnObject instanceof PlaceTransitionObject){
824+ PlaceTransitionObject pto = (PlaceTransitionObject)pnObject;
825+
826+ for(Arc arc : pto.getPreset()){
827+ deleteObject(arc);
828+ }
829+
830+ for(Arc arc : pto.getPostset()){
831+ deleteObject(arc);
832+ }
833+ }
834+
835+ deleteObject(pnObject);
836+ }
837+
838+ public void deleteSelection(ArrayList<PetriNetObject> selection) {
839+ for (PetriNetObject pnObject : selection) {
840+ deleteSelection(pnObject);
841+ }
842+ }
843+
844+ public void translateSelection(ArrayList<PetriNetObject> objects,
845+ int transX, int transY) {
846+ newEdit(); // new "transaction""
847+ Iterator<PetriNetObject> iterator = objects.iterator();
848+ while (iterator.hasNext()) {
849+ addEdit(new TranslatePetriNetObjectEdit(iterator.next(), transX,
850+ transY, view));
851+ }
852+ }
853+>>>>>>> MERGE-SOURCE
854
855 private int currentIndex() {
856 int lastAdd = indexOfNextAdd - 1;
857
858=== modified file 'src/pipe/gui/widgets/ConstantsPane.java'
859--- src/pipe/gui/widgets/ConstantsPane.java 2020-04-18 12:27:02 +0000
860+++ src/pipe/gui/widgets/ConstantsPane.java 2020-05-13 15:53:33 +0000
861@@ -19,7 +19,6 @@
862 import java.awt.event.MouseEvent;
863 import java.io.IOException;
864
865-
866 import javax.swing.BorderFactory;
867 import javax.swing.ImageIcon;
868 import javax.swing.JButton;
869@@ -39,14 +38,21 @@
870 import pipe.gui.CreateGui;
871 import dk.aau.cs.gui.TabContent;
872 import dk.aau.cs.gui.undo.Command;
873+import dk.aau.cs.gui.undo.MoveElementDownCommand;
874+import dk.aau.cs.gui.undo.MoveElementUpCommand;
875 import dk.aau.cs.gui.undo.SortConstantsCommand;
876 import dk.aau.cs.model.tapn.Constant;
877 import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
878 import dk.aau.cs.gui.components.ConstantsListModel;
879 import dk.aau.cs.gui.components.NonsearchableJList;
880
881+<<<<<<< TREE
882 public class ConstantsPane extends JPanel {
883
884+=======
885+public class ConstantsPane extends JPanel implements SidePane {
886+ private static final long serialVersionUID = -7883351020889779067L;
887+>>>>>>> MERGE-SOURCE
888 private JPanel constantsPanel;
889 private JScrollPane constantsScroller;
890 private JPanel buttonsPanel;
891@@ -352,10 +358,19 @@
892 moveUpButton.addActionListener(e -> {
893 int index = constantsList.getSelectedIndex();
894
895+<<<<<<< TREE
896 if(index > 0) {
897 parent.swapConstants(index, index-1);
898 showConstants();
899 constantsList.setSelectedIndex(index-1);
900+=======
901+ if(index > 0) {
902+ Command c = new MoveElementUpCommand(ConstantsPane.this, index, index-1);
903+ CreateGui.getDrawingSurface().getUndoManager().addNewEdit(c);
904+ c.redo();
905+ constantsList.setSelectedIndex(index-1);
906+ }
907+>>>>>>> MERGE-SOURCE
908 }
909 });
910
911@@ -371,10 +386,19 @@
912 moveDownButton.addActionListener(e -> {
913 int index = constantsList.getSelectedIndex();
914
915+<<<<<<< TREE
916 if(index < parent.network().constants().size() - 1) {
917 parent.swapConstants(index, index+1);
918 showConstants();
919 constantsList.setSelectedIndex(index+1);
920+=======
921+ if(index < parent.network().constants().size() - 1) {
922+ Command c = new MoveElementDownCommand(ConstantsPane.this, index, index+1);
923+ CreateGui.getDrawingSurface().getUndoManager().addNewEdit(c);
924+ c.redo();
925+ constantsList.setSelectedIndex(index+1);
926+ }
927+>>>>>>> MERGE-SOURCE
928 }
929 });
930
931@@ -466,4 +490,21 @@
932 constantsList.setSelectedIndex(0);
933
934 }
935+
936+ @Override
937+ public void moveUp(int index) {
938+ parent.swapConstants(index, index-1);
939+ showConstants();
940+ }
941+
942+ @Override
943+ public void moveDown(int index) {
944+ parent.swapConstants(index, index+1);
945+ showConstants();
946+ }
947+
948+ @Override
949+ public JList getJList() {
950+ return constantsList;
951+ }
952 }
953
954=== modified file 'src/pipe/gui/widgets/QueryPane.java'
955--- src/pipe/gui/widgets/QueryPane.java 2020-04-18 16:08:44 +0000
956+++ src/pipe/gui/widgets/QueryPane.java 2020-05-13 15:53:33 +0000
957@@ -41,13 +41,20 @@
958 import dk.aau.cs.gui.BatchProcessingDialog;
959 import dk.aau.cs.gui.TabContent;
960 import dk.aau.cs.gui.undo.Command;
961+import dk.aau.cs.gui.undo.MoveElementDownCommand;
962+import dk.aau.cs.gui.undo.MoveElementUpCommand;
963 import dk.aau.cs.gui.undo.SortQueriesCommand;
964 import dk.aau.cs.gui.components.NonsearchableJList;
965 import dk.aau.cs.translations.ReductionOption;
966 import dk.aau.cs.util.Require;
967
968+<<<<<<< TREE
969 public class QueryPane extends JPanel {
970
971+=======
972+public class QueryPane extends JPanel implements SidePane {
973+ private static final long serialVersionUID = 4062539545170994654L;
974+>>>>>>> MERGE-SOURCE
975 private JPanel queryCollectionPanel;
976 private JPanel buttonsPanel;
977 private DefaultListModel listModel;
978@@ -213,7 +220,9 @@
979 int index = queryList.getSelectedIndex();
980
981 if(index > 0 && queryList.getSelectedIndices().length == 1) {
982- swapQueries(index, index-1);
983+ Command c = new MoveElementUpCommand(QueryPane.this, index, index-1);
984+ undoManager.addNewEdit(c);
985+ c.redo();
986 queryList.setSelectedIndex(index-1);
987 }
988 else
989@@ -235,8 +244,10 @@
990 int index = queryList.getSelectedIndex();
991
992 if(index < listModel.size()-1 && queryList.getSelectedIndices().length == 1) {
993- swapQueries(index, index+1);
994- queryList.setSelectedIndex(index+1);
995+ Command c = new MoveElementDownCommand(QueryPane.this, index, index+1);
996+ undoManager.addNewEdit(c);
997+ c.redo();
998+ queryList.setSelectedIndex(index+1);
999 }
1000 else
1001 moveDownButton.setEnabled(false);
1002@@ -513,4 +524,17 @@
1003 public void verifySelectedQuery() {
1004 verifyQuery();
1005 }
1006+
1007+ @Override
1008+ public void moveUp(int index){
1009+ swapQueries(index, index-1);
1010+ }
1011+ @Override
1012+ public void moveDown(int index){
1013+ swapQueries(index, index+1);
1014+ }
1015+ @Override
1016+ public JList getJList(){
1017+ return queryList;
1018+ }
1019 }
1020
1021=== added file 'src/pipe/gui/widgets/SidePane.java'
1022--- src/pipe/gui/widgets/SidePane.java 1970-01-01 00:00:00 +0000
1023+++ src/pipe/gui/widgets/SidePane.java 2020-05-13 15:53:33 +0000
1024@@ -0,0 +1,9 @@
1025+package pipe.gui.widgets;
1026+
1027+import javax.swing.*;
1028+
1029+public interface SidePane {
1030+ public void moveUp(int index);
1031+ public void moveDown(int index);
1032+ public JList getJList();
1033+}

Subscribers

People subscribed via source and target branches