1 | /*
|
---|
2 | * DummyAction.java
|
---|
3 | *
|
---|
4 | * Copyright 2010 Hind <foxhind@gmail.com>
|
---|
5 | *
|
---|
6 | */
|
---|
7 |
|
---|
8 | package CommandLine;
|
---|
9 |
|
---|
10 | import java.awt.AWTEvent;
|
---|
11 | import java.awt.event.AWTEventListener;
|
---|
12 | import java.awt.event.KeyEvent;
|
---|
13 |
|
---|
14 | import org.openstreetmap.josm.Main;
|
---|
15 | import org.openstreetmap.josm.actions.mapmode.MapMode;
|
---|
16 | import org.openstreetmap.josm.gui.MapFrame;
|
---|
17 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
18 |
|
---|
19 | public class DummyAction extends MapMode implements AWTEventListener {
|
---|
20 | private CommandLine parentPlugin;
|
---|
21 |
|
---|
22 | public DummyAction(MapFrame mapFrame, CommandLine parentPlugin) {
|
---|
23 | super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", null));
|
---|
24 | this.parentPlugin = parentPlugin;
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public void eventDispatched(AWTEvent arg0) {
|
---|
29 | if (!(arg0 instanceof KeyEvent))
|
---|
30 | return;
|
---|
31 | KeyEvent ev = (KeyEvent) arg0;
|
---|
32 | if (ev.getKeyCode() == KeyEvent.VK_ESCAPE && ev.getID() == KeyEvent.KEY_PRESSED) {
|
---|
33 | ev.consume();
|
---|
34 | cancelDrawing();
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public void cancelDrawing() {
|
---|
39 | if (Main.map == null || Main.map.mapView == null)
|
---|
40 | return;
|
---|
41 | Main.map.statusLine.setHeading(-1);
|
---|
42 | Main.map.statusLine.setAngle(-1);
|
---|
43 | Main.map.mapView.repaint();
|
---|
44 | updateStatusLine();
|
---|
45 | parentPlugin.abortInput();
|
---|
46 | }
|
---|
47 | }
|
---|