Merge lp:~tapaal-contributor/tapaal/undo-redo-not-available-when-drawing-arc-1848949 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 1025
Merged at revision: 1026
Proposed branch: lp:~tapaal-contributor/tapaal/undo-redo-not-available-when-drawing-arc-1848949
Merge into: lp:tapaal
Diff against target: 62 lines (+22/-6)
2 files modified
src/pipe/gui/GuiFrame.java (+18/-4)
src/pipe/gui/graphicElements/Arc.java (+4/-2)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/undo-redo-not-available-when-drawing-arc-1848949
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Peter Haahr Taankvist (community) Needs Resubmitting
Review via email: mp+374653@code.launchpad.net

Commit message

Pressing undo/redo when drawing an arc now removes the arc being drawn

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote :

Does not seem to fix the problem, I just draw place an started to draw an arc and pressed ctrl-Z and the place disappeared as well.

review: Needs Fixing
1023. By Peter Taankvist <email address hidden>

change ctrlmask to shortcutkeymask so it works on mac too

Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

It should work for mac too now. Used shortcutkeymask instead of ctrlmask in the action map so it should work with macs cmd button too

review: Needs Resubmitting
Revision history for this message
Jiri Srba (srba) wrote :

Now it does not compile anymore on mac:

src/pipe/gui/graphicElements/Arc.java:473: error: cannot find symbol
  iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()), "deleteArc");
                                                                            ^
  symbol: method getMenuShortcutKeyMaskEx()
  location: class Toolkit
src/pipe/gui/graphicElements/Arc.java:474: error: cannot find symbol
  iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()), "deleteArc");
                                                                            ^
  symbol: method getMenuShortcutKeyMaskEx()
  location: class Toolkit

review: Needs Fixing
1024. By Peter Taankvist <email address hidden>

Changed shortcutkeymaskex to shortcutkeymask as we use everywhere else

Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

changed .getMenuShortcutKeyMaskEx() to .getMenuShortcutKeyMask(). This is the function we use everywhere else as far as i can tell so hopefully this works on mac too.

review: Needs Resubmitting
Revision history for this message
Jiri Srba (srba) wrote :

Yes, it compiles and works nicely on mac as well, when I press ctrl-z then only the arc disappears.
However, if I press in the GUI on the back-arrow in the tool line (instead of ctrl-z), then also the place disappears, which is not the same behaviour as intended.

review: Needs Fixing
1025. By Peter Taankvist <email address hidden>

arc being drawn is deleted on undo/redo button press

Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

Arc being drawn is deleted on undo/redo button press.

review: Needs Resubmitting
Revision history for this message
Jiri Srba (srba) :
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/GuiFrame.java'
2--- src/pipe/gui/GuiFrame.java 2019-10-31 12:23:10 +0000
3+++ src/pipe/gui/GuiFrame.java 2019-11-01 10:31:26 +0000
4@@ -466,8 +466,15 @@
5 @Override
6 public void actionPerformed(ActionEvent e) {
7 if (CreateGui.getApp().isEditionAllowed()) {
8- appView.getUndoManager().undo();
9- CreateGui.getCurrentTab().network().buildConstraints();
10+ //If arc is being drawn delete it
11+ if(appView.createArc == null) {
12+ appView.getUndoManager().undo();
13+ CreateGui.getCurrentTab().network().buildConstraints();
14+ } else {
15+ appView.createArc.delete();
16+ appView.createArc = null;
17+ appView.repaint();
18+ }
19 }
20 }
21 });
22@@ -478,8 +485,15 @@
23 @Override
24 public void actionPerformed(ActionEvent e) {
25 if (CreateGui.getApp().isEditionAllowed()) {
26- appView.getUndoManager().redo();
27- CreateGui.getCurrentTab().network().buildConstraints();
28+ //If arc is being drawn delete it
29+ if(appView.createArc == null) {
30+ appView.getUndoManager().redo();
31+ CreateGui.getCurrentTab().network().buildConstraints();
32+ } else {
33+ appView.createArc.delete();
34+ appView.createArc = null;
35+ appView.repaint();
36+ }
37 }
38 }
39 });
40
41=== modified file 'src/pipe/gui/graphicElements/Arc.java'
42--- src/pipe/gui/graphicElements/Arc.java 2019-10-31 16:29:03 +0000
43+++ src/pipe/gui/graphicElements/Arc.java 2019-11-01 10:31:26 +0000
44@@ -2,6 +2,8 @@
45
46 import java.awt.*;
47 import java.awt.event.ActionEvent;
48+import java.awt.event.InputEvent;
49+import java.awt.event.KeyEvent;
50 import java.awt.geom.AffineTransform;
51 import java.awt.geom.Point2D;
52
53@@ -469,8 +471,8 @@
54 // Bind keyboard keys to action names.
55 iMap.put(KeyStroke.getKeyStroke("ESCAPE"), "deleteArc");
56 iMap.put(KeyStroke.getKeyStroke("DELETE"), "deleteArc");
57-
58- // Associate action names with actions.
59+ iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "deleteArc");
60+ iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "deleteArc");
61 aMap.put("deleteArc", new DeleteAction(this));
62 }
63

Subscribers

People subscribed via source and target branches