Changeset 32416 in osm
- Timestamp:
- 2016-06-27T09:06:28+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/CommandLine/src/CommandLine
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java
r30669 r32416 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.actions.mapmode.MapMode; 21 import org.openstreetmap.josm.data.osm.DataSet; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 23 import org.openstreetmap.josm.gui.MapFrame; … … 77 78 processMouseEvent(e); 78 79 if (nearestPrimitive != null) { 80 DataSet ds = Main.getLayerManager().getEditDataSet(); 79 81 if (isCtrlDown) { 80 Main.main.getCurrentDataSet().clearSelection(nearestPrimitive);82 ds.clearSelection(nearestPrimitive); 81 83 Main.map.mapView.repaint(); 82 } 83 else { 84 } else { 84 85 int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances; 85 86 switch (maxInstances) { 86 87 case 0: 87 Main.main.getCurrentDataSet().addSelected(nearestPrimitive);88 ds.addSelected(nearestPrimitive); 88 89 Main.map.mapView.repaint(); 89 90 break; 90 91 case 1: 91 Main.main.getCurrentDataSet().addSelected(nearestPrimitive);92 ds.addSelected(nearestPrimitive); 92 93 Main.map.mapView.repaint(); 93 94 parentPlugin.loadParameter(nearestPrimitive, true); … … 95 96 break; 96 97 default: 97 if ( Main.main.getCurrentDataSet().getSelected().size() < maxInstances) {98 Main.main.getCurrentDataSet().addSelected(nearestPrimitive);98 if (ds.getSelected().size() < maxInstances) { 99 ds.addSelected(nearestPrimitive); 99 100 Main.map.mapView.repaint(); 100 101 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java
r32329 r32416 121 121 case SELECTION: 122 122 if (currentMapFrame.mapMode instanceof WayAction || currentMapFrame.mapMode instanceof NodeAction || currentMapFrame.mapMode instanceof RelationAction || currentMapFrame.mapMode instanceof AnyAction) { 123 Collection<OsmPrimitive> selected = Main. main.getCurrentDataSet().getSelected();123 Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getSelected(); 124 124 if (selected.size() > 0) 125 125 loadParameter(selected, true); … … 214 214 if (Main.map == null) 215 215 return; 216 DataSet ds = Main. main.getCurrentDataSet();216 DataSet ds = Main.getLayerManager().getEditDataSet(); 217 217 if (ds == null) 218 218 return; … … 323 323 324 324 protected void setMode(Mode targetMode) { 325 DataSet currentDataSet = Main. main.getCurrentDataSet();325 DataSet currentDataSet = Main.getLayerManager().getEditDataSet(); 326 326 if (currentDataSet != null) { 327 327 currentDataSet.clearSelection(); … … 617 617 618 618 // Read stdout stream 619 final DataSet currentDataSet = Main. main.getCurrentDataSet();619 final DataSet currentDataSet = Main.getLayerManager().getEditDataSet(); 620 620 final CommandLine that = this; 621 621 Thread osmParseThread = new Thread(new Runnable() { -
applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java
r29769 r32416 1 1 /* 2 2 * NodeAction.java 3 * 3 * 4 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 5 * 6 6 */ 7 7 … … 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.actions.mapmode.MapMode; 21 import org.openstreetmap.josm.data.osm.DataSet; 21 22 import org.openstreetmap.josm.data.osm.Node; 22 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 25 26 26 27 public class NodeAction extends MapMode implements AWTEventListener { 27 privateCommandLine parentPlugin;28 private final CommandLine parentPlugin; 28 29 final private Cursor cursorNormal, cursorActive; 29 30 private Cursor currentCursor; … … 33 34 // private Type type; 34 35 35 36 37 38 39 36 public NodeAction(MapFrame mapFrame, CommandLine parentPlugin) { 37 super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", "selection")); 38 this.parentPlugin = parentPlugin; 39 cursorNormal = ImageProvider.getCursor("normal", "selection"); 40 cursorActive = ImageProvider.getCursor("normal", "joinnode"); 40 41 currentCursor = cursorNormal; 41 42 nearestNode = null; 42 43 } 43 44 44 45 45 @Override public void enterMode() { 46 super.enterMode(); 46 47 currentCursor = cursorNormal; 47 48 Main.map.mapView.addMouseListener(this); … … 51 52 } catch (SecurityException ex) { 52 53 } 53 54 } 54 55 55 56 57 56 @Override public void exitMode() { 57 super.exitMode(); 58 Main.map.mapView.removeMouseListener(this); 58 59 Main.map.mapView.removeMouseMotionListener(this); 59 60 try { … … 61 62 } catch (SecurityException ex) { 62 63 } 63 64 } 64 65 65 66 @Override … … 79 80 processMouseEvent(e); 80 81 if (nearestNode != null) { 81 if (isCtrlDown) { 82 Main.main.getCurrentDataSet().clearSelection(nearestNode); 83 Main.map.mapView.repaint(); 84 } 85 else { 86 int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances; 87 switch (maxInstances) { 88 case 0: 89 Main.main.getCurrentDataSet().addSelected(nearestNode); 90 Main.map.mapView.repaint(); 91 break; 92 case 1: 93 Main.main.getCurrentDataSet().addSelected(nearestNode); 94 Main.map.mapView.repaint(); 95 parentPlugin.loadParameter(nearestNode, true); 96 exitMode(); 97 break; 98 default: 99 if (Main.main.getCurrentDataSet().getSelected().size() < maxInstances) { 100 Main.main.getCurrentDataSet().addSelected(nearestNode); 101 Main.map.mapView.repaint(); 102 } 103 else 104 parentPlugin.printHistory("Maximum instances is " + String.valueOf(maxInstances)); 105 } 106 } 107 } 82 DataSet ds = Main.getLayerManager().getEditDataSet(); 83 if (isCtrlDown) { 84 ds.clearSelection(nearestNode); 85 Main.map.mapView.repaint(); 86 } 87 else { 88 int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances; 89 switch (maxInstances) { 90 case 0: 91 ds.addSelected(nearestNode); 92 Main.map.mapView.repaint(); 93 break; 94 case 1: 95 ds.addSelected(nearestNode); 96 Main.map.mapView.repaint(); 97 parentPlugin.loadParameter(nearestNode, true); 98 exitMode(); 99 break; 100 default: 101 if (ds.getSelected().size() < maxInstances) { 102 ds.addSelected(nearestNode); 103 Main.map.mapView.repaint(); 104 } 105 else 106 parentPlugin.printHistory("Maximum instances is " + String.valueOf(maxInstances)); 107 } 108 } 109 } 108 110 super.mousePressed(e); 109 111 } 110 112 111 112 113 @Override 114 public void eventDispatched(AWTEvent arg0) { 113 115 if (!(arg0 instanceof KeyEvent)) 114 116 return; 115 117 KeyEvent ev = (KeyEvent) arg0; 116 118 isCtrlDown = (ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0; … … 123 125 private void updCursor() { 124 126 if (mousePos != null) { 125 126 127 128 129 130 131 132 133 134 127 if (!Main.isDisplayingMapView()) 128 return; 129 nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive.isUsablePredicate); 130 if (nearestNode != null) { 131 setCursor(cursorActive); 132 } 133 else { 134 setCursor(cursorNormal); 135 } 136 } 135 137 } 136 138 137 138 139 139 private void processMouseEvent(MouseEvent e) { 140 if (e != null) { mousePos = e.getPoint(); } 141 } 140 142 141 143 private void setCursor(final Cursor c) { -
applications/editors/josm/plugins/CommandLine/src/CommandLine/OsmToCmd.java
r30671 r32416 247 247 } 248 248 else if (currentPrimitive.isModified()) { 249 cmds.add(new ChangeCommand(Main. main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));249 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 250 250 } 251 251 else if (currentPrimitive.isNew()) { … … 259 259 } 260 260 else if (currentPrimitive.isModified()) { 261 cmds.add(new ChangeCommand(Main. main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));261 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 262 262 } 263 263 else if (currentPrimitive.isNew()) { … … 271 271 } 272 272 else if (currentPrimitive.isModified()) { 273 cmds.add(new ChangeCommand(Main. main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));273 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 274 274 } 275 275 else if (currentPrimitive.isNew()) { -
applications/editors/josm/plugins/CommandLine/src/CommandLine/PointAction.java
r30671 r32416 52 52 @Override public void enterMode() { 53 53 super.enterMode(); 54 if (get CurrentDataSet() == null) {54 if (getLayerManager().getEditDataSet() == null) { 55 55 Main.map.selectSelectTool(false); 56 56 return; -
applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java
r30669 r32416 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.actions.mapmode.MapMode; 21 import org.openstreetmap.josm.data.osm.DataSet; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 23 import org.openstreetmap.josm.data.osm.Way; … … 100 101 processMouseEvent(e); 101 102 if (nearestWay != null) { 103 DataSet ds = Main.getLayerManager().getEditDataSet(); 102 104 if (isCtrlDown) { 103 Main.main.getCurrentDataSet().clearSelection(nearestWay);105 ds.clearSelection(nearestWay); 104 106 Main.map.mapView.repaint(); 105 } 106 else { 107 } else { 107 108 int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances; 108 109 switch (maxInstances) { 109 110 case 0: 110 Main.main.getCurrentDataSet().addSelected(nearestWay);111 ds.addSelected(nearestWay); 111 112 Main.map.mapView.repaint(); 112 113 break; 113 114 case 1: 114 Main.main.getCurrentDataSet().addSelected(nearestWay);115 ds.addSelected(nearestWay); 115 116 Main.map.mapView.repaint(); 116 117 parentPlugin.loadParameter(nearestWay, true); … … 118 119 break; 119 120 default: 120 if ( Main.main.getCurrentDataSet().getSelected().size() < maxInstances) {121 Main.main.getCurrentDataSet().addSelected(nearestWay);121 if (ds.getSelected().size() < maxInstances) { 122 ds.addSelected(nearestWay); 122 123 Main.map.mapView.repaint(); 123 124 }
Note:
See TracChangeset
for help on using the changeset viewer.