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
=== modified file 'src/pipe/gui/GuiFrame.java'
--- src/pipe/gui/GuiFrame.java 2019-10-31 12:23:10 +0000
+++ src/pipe/gui/GuiFrame.java 2019-11-01 10:31:26 +0000
@@ -466,8 +466,15 @@
466 @Override466 @Override
467 public void actionPerformed(ActionEvent e) {467 public void actionPerformed(ActionEvent e) {
468 if (CreateGui.getApp().isEditionAllowed()) {468 if (CreateGui.getApp().isEditionAllowed()) {
469 appView.getUndoManager().undo();469 //If arc is being drawn delete it
470 CreateGui.getCurrentTab().network().buildConstraints();470 if(appView.createArc == null) {
471 appView.getUndoManager().undo();
472 CreateGui.getCurrentTab().network().buildConstraints();
473 } else {
474 appView.createArc.delete();
475 appView.createArc = null;
476 appView.repaint();
477 }
471 }478 }
472 }479 }
473 });480 });
@@ -478,8 +485,15 @@
478 @Override485 @Override
479 public void actionPerformed(ActionEvent e) {486 public void actionPerformed(ActionEvent e) {
480 if (CreateGui.getApp().isEditionAllowed()) {487 if (CreateGui.getApp().isEditionAllowed()) {
481 appView.getUndoManager().redo();488 //If arc is being drawn delete it
482 CreateGui.getCurrentTab().network().buildConstraints();489 if(appView.createArc == null) {
490 appView.getUndoManager().redo();
491 CreateGui.getCurrentTab().network().buildConstraints();
492 } else {
493 appView.createArc.delete();
494 appView.createArc = null;
495 appView.repaint();
496 }
483 }497 }
484 }498 }
485 });499 });
486500
=== modified file 'src/pipe/gui/graphicElements/Arc.java'
--- src/pipe/gui/graphicElements/Arc.java 2019-10-31 16:29:03 +0000
+++ src/pipe/gui/graphicElements/Arc.java 2019-11-01 10:31:26 +0000
@@ -2,6 +2,8 @@
22
3import java.awt.*;3import java.awt.*;
4import java.awt.event.ActionEvent;4import java.awt.event.ActionEvent;
5import java.awt.event.InputEvent;
6import java.awt.event.KeyEvent;
5import java.awt.geom.AffineTransform;7import java.awt.geom.AffineTransform;
6import java.awt.geom.Point2D;8import java.awt.geom.Point2D;
79
@@ -469,8 +471,8 @@
469 // Bind keyboard keys to action names.471 // Bind keyboard keys to action names.
470 iMap.put(KeyStroke.getKeyStroke("ESCAPE"), "deleteArc");472 iMap.put(KeyStroke.getKeyStroke("ESCAPE"), "deleteArc");
471 iMap.put(KeyStroke.getKeyStroke("DELETE"), "deleteArc");473 iMap.put(KeyStroke.getKeyStroke("DELETE"), "deleteArc");
472474 iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "deleteArc");
473 // Associate action names with actions.475 iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "deleteArc");
474 aMap.put("deleteArc", new DeleteAction(this));476 aMap.put("deleteArc", new DeleteAction(this));
475 }477 }
476478

Subscribers

People subscribed via source and target branches