Changeset 32779 in osm for applications/editors
- Timestamp:
- 2016-08-08T00:01:16+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/CommandLine
- Files:
-
- 1 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/CommandLine/.project
r32286 r32779 16 16 </arguments> 17 17 </buildCommand> 18 <buildCommand> 19 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 20 <arguments> 21 </arguments> 22 </buildCommand> 18 23 </buildSpec> 19 24 <natures> 20 25 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 21 27 </natures> 22 28 </projectDescription> -
applications/editors/josm/plugins/CommandLine/.settings/org.eclipse.jdt.ui.prefs
r25179 r32779 1 #Sat Jan 29 19:56:56 CET 20112 1 eclipse.preferences.version=1 3 2 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true … … 15 14 sp_cleanup.always_use_this_for_non_static_field_access=false 16 15 sp_cleanup.always_use_this_for_non_static_method_access=false 16 sp_cleanup.convert_functional_interfaces=false 17 17 sp_cleanup.convert_to_enhanced_for_loop=false 18 sp_cleanup.correct_indentation= true18 sp_cleanup.correct_indentation=false 19 19 sp_cleanup.format_source_code=false 20 20 sp_cleanup.format_source_code_changes_only=false 21 sp_cleanup.insert_inferred_type_arguments=false 21 22 sp_cleanup.make_local_variable_final=false 22 23 sp_cleanup.make_parameters_final=false … … 34 35 sp_cleanup.qualify_static_method_accesses_with_declaring_class=false 35 36 sp_cleanup.remove_private_constructors=true 37 sp_cleanup.remove_redundant_type_arguments=false 36 38 sp_cleanup.remove_trailing_whitespaces=true 37 39 sp_cleanup.remove_trailing_whitespaces_all=true … … 47 49 sp_cleanup.sort_members=false 48 50 sp_cleanup.sort_members_all=false 51 sp_cleanup.use_anonymous_class_creation=false 49 52 sp_cleanup.use_blocks=false 50 53 sp_cleanup.use_blocks_only_for_return_and_throw=false 54 sp_cleanup.use_lambda=false 51 55 sp_cleanup.use_parentheses_in_expressions=false 52 56 sp_cleanup.use_this_for_non_static_field_access=false … … 54 58 sp_cleanup.use_this_for_non_static_method_access=false 55 59 sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true 60 sp_cleanup.use_type_arguments=false -
applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java
r32416 r32779 1 /* 2 * AnyAction.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 26 20 public class AnyAction extends MapMode implements AWTEventListener { 27 21 private final CommandLine parentPlugin; 28 final privateCursor cursorNormal, cursorActive;22 private final Cursor cursorNormal, cursorActive; 29 23 private Cursor currentCursor; 30 24 private Point mousePos; … … 49 43 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 50 44 } catch (SecurityException ex) { 45 Main.warn(ex); 51 46 } 52 47 } … … 59 54 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 60 55 } catch (SecurityException ex) { 56 Main.warn(ex); 61 57 } 62 58 } … … 99 95 ds.addSelected(nearestPrimitive); 100 96 Main.map.mapView.repaint(); 101 } 102 else 97 } else 103 98 Main.info("Maximum instances!"); 104 99 } … … 124 119 if (!Main.isDisplayingMapView()) 125 120 return; 126 nearestPrimitive = Main.map.mapView.getNearestNodeOrWay(mousePos, OsmPrimitive .isUsablePredicate, false);121 nearestPrimitive = Main.map.mapView.getNearestNodeOrWay(mousePos, OsmPrimitive::isUsable, false); 127 122 if (nearestPrimitive != null) { 128 123 setCursor(cursorActive); 129 } 130 else { 124 } else { 131 125 setCursor(cursorNormal); 132 126 } … … 135 129 136 130 private void processMouseEvent(MouseEvent e) { 137 if (e != null) { mousePos = e.getPoint(); } 131 if (e != null) { 132 mousePos = e.getPoint(); 133 } 138 134 } 139 135 … … 154 150 currentCursor = c; 155 151 } catch (Exception e) { 152 Main.warn(e); 156 153 } 157 154 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Command.java
r30671 r32779 1 /* 2 * Command.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 19 13 20 14 public class Command { 21 public String name; 22 public String run; 23 public String icon; 24 public ArrayList<Parameter> parameters; 25 public ArrayList<Parameter> optParameters; 15 public String name; // Command name 16 public String run; // Executable file with arguments ("nya.exe {arg1} {arg2} ... {argn}") 17 public String icon; // Icon file name 18 public ArrayList<Parameter> parameters; // Required parameters list 19 public ArrayList<Parameter> optParameters; // Optional parameters list 26 20 public int currentParameterNum; 27 21 public boolean tracks; 28 22 public boolean asynchronous; 29 23 30 public Command 24 public Command() { 31 25 parameters = new ArrayList<>(); 32 26 optParameters = new ArrayList<>(); … … 45 39 return true; 46 40 } 47 } 48 else { 41 } else { 49 42 ArrayList<OsmPrimitive> multiValue = currentParameter.getValueList(); 50 43 if (obj instanceof Collection) { 51 if ( ((Collection<?>)obj).size() > currentParameter.maxInstances && currentParameter.maxInstances != 0)44 if (((Collection<?>) obj).size() > currentParameter.maxInstances && currentParameter.maxInstances != 0) 52 45 return false; 53 46 multiValue.clear(); 54 multiValue.addAll((Collection<OsmPrimitive>) obj);47 multiValue.addAll((Collection<OsmPrimitive>) obj); 55 48 return true; 56 } 57 else if (obj instanceof OsmPrimitive) { 49 } else if (obj instanceof OsmPrimitive) { 58 50 if (multiValue.size() < currentParameter.maxInstances || currentParameter.maxInstances == 0) { 59 51 if (isPair(obj, currentParameter)) { 60 multiValue.add((OsmPrimitive) obj);52 multiValue.add((OsmPrimitive) obj); 61 53 return true; 62 54 } else if (nextParameter() && multiValue.size() > 0) { 63 55 return loadObject(obj); 64 56 } 65 } 66 else if (nextParameter()) { 57 } else if (nextParameter()) { 67 58 return loadObject(obj); 68 59 } 69 } 70 else if (obj instanceof String) { 60 } else if (obj instanceof String) { 71 61 if (isPair(obj, currentParameter)) { 72 62 currentParameter.setValue(obj); … … 100 90 if (obj instanceof String) { 101 91 Pattern p = Pattern.compile("(-?\\d*\\.?\\d*,-?\\d*\\.?\\d*;?)*"); 102 Matcher m = p.matcher((String) obj);92 Matcher m = p.matcher((String) obj); 103 93 return m.matches(); 104 94 } … … 119 109 if (obj instanceof String) { 120 110 Pattern p = Pattern.compile("\\d*\\.?\\d*"); 121 Matcher m = p.matcher((String) obj);111 Matcher m = p.matcher((String) obj); 122 112 if (m.matches()) { 123 Float value = Float.parseFloat((String) obj);113 Float value = Float.parseFloat((String) obj); 124 114 if (parameter.minVal != 0 && value < parameter.minVal) 125 115 break; … … 133 123 if (obj instanceof String) { 134 124 Pattern p = Pattern.compile("\\d*"); 135 Matcher m = p.matcher((String) obj);125 Matcher m = p.matcher((String) obj); 136 126 if (m.matches()) { 137 Integer value = Integer.parseInt((String) obj);127 Integer value = Integer.parseInt((String) obj); 138 128 if (parameter.minVal != 0 && value < parameter.minVal) 139 129 break; … … 150 140 if (obj instanceof String) { 151 141 if (parameter.getRawValue() instanceof Relay) { 152 if ( ((Relay)(parameter.getRawValue())).isCorrectValue((String)obj))142 if (((Relay) (parameter.getRawValue())).isCorrectValue((String) obj)) 153 143 return true; 154 144 } … … 174 164 continue; 175 165 if (parameter.maxInstances == 1) { 176 depsObjects.addAll(getDepsObjects(depsObjects, (OsmPrimitive)parameter.getRawValue())); 177 } 178 else { 166 depsObjects.addAll(getDepsObjects(depsObjects, (OsmPrimitive) parameter.getRawValue())); 167 } else { 179 168 for (OsmPrimitive primitive : parameter.getValueList()) { 180 169 depsObjects.addAll(getDepsObjects(depsObjects, primitive)); … … 189 178 if (!currentObjects.contains(primitive)) { 190 179 if (primitive instanceof Way) { 191 depsObjects.addAll(((Way)primitive).getNodes()); 192 } 193 else if (primitive instanceof Relation) { 194 Collection<OsmPrimitive> relationMembers = ((Relation)primitive).getMemberPrimitives(); 180 depsObjects.addAll(((Way) primitive).getNodes()); 181 } else if (primitive instanceof Relation) { 182 Collection<OsmPrimitive> relationMembers = ((Relation) primitive).getMemberPrimitives(); 195 183 for (OsmPrimitive member : relationMembers) { 196 184 if (!currentObjects.contains(member)) { -
applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandAction.java
r30810 r32779 1 /* 2 * CommandAction.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 1 // License: GPL. For details, see LICENSE file. 7 2 package CommandLine; 8 3 -
applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java
r32683 r32779 1 /* 2 * CommandLine.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 1 // License: GPL. For details, see LICENSE file. 21 2 package CommandLine; 22 3 … … 121 102 break; 122 103 case SELECTION: 123 if (currentMapFrame.mapMode instanceof WayAction || currentMapFrame.mapMode instanceof NodeAction || currentMapFrame.mapMode instanceof RelationAction || currentMapFrame.mapMode instanceof AnyAction) { 104 if (currentMapFrame.mapMode instanceof WayAction 105 || currentMapFrame.mapMode instanceof NodeAction 106 || currentMapFrame.mapMode instanceof RelationAction 107 || currentMapFrame.mapMode instanceof AnyAction) { 124 108 Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getSelected(); 125 109 if (selected.size() > 0) 126 110 loadParameter(selected, true); 127 } 128 else { 111 } else { 129 112 loadParameter(commandText, currentCommand.parameters.get(currentCommand.currentParameterNum).maxInstances == 1); 130 113 } … … 134 117 } 135 118 e.consume(); 136 } 137 else if (code == KeyEvent.VK_UP) { 119 } else if (code == KeyEvent.VK_UP) { 138 120 textField.setText(prefix + history.getPrevItem()); 139 121 e.consume(); 140 } 141 else if (code == KeyEvent.VK_DOWN) { 122 } else if (code == KeyEvent.VK_DOWN) { 142 123 textField.setText(prefix + history.getNextItem()); 143 124 e.consume(); 144 } 145 else if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { 125 } else if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { 146 126 if (textField.getCaretPosition() <= prefix.length()) 147 127 e.consume(); 148 } 149 else if (code == KeyEvent.VK_HOME) { 128 } else if (code == KeyEvent.VK_HOME) { 150 129 setCaretPosition(prefix.length()); 151 130 e.consume(); 152 } 153 else if (code == KeyEvent.VK_ESCAPE) { 131 } else if (code == KeyEvent.VK_ESCAPE) { 154 132 if (textField.getText().length() == prefix.length() && mode == Mode.IDLE) 155 133 deactivate(); … … 157 135 endInput(); 158 136 e.consume(); 159 } 160 else if (code == KeyEvent.VK_DELETE || code == KeyEvent.VK_RIGHT || code == KeyEvent.VK_END) { 161 } 162 else { 163 e.consume(); 164 } 165 if (textField.getCaretPosition() < prefix.length() || (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0) ) 137 } else if (code == KeyEvent.VK_DELETE || code == KeyEvent.VK_RIGHT || code == KeyEvent.VK_END) { 138 } else { 139 e.consume(); 140 } 141 if (textField.getCaretPosition() < prefix.length() || 142 (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0)) 166 143 e.consume(); 167 144 } 168 145 if (e.getID() == KeyEvent.KEY_TYPED) 169 if (textField.getCaretPosition() < prefix.length() || (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0) ) 146 if (textField.getCaretPosition() < prefix.length() || 147 (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0)) 170 148 e.consume(); 171 149 super.processKeyEvent(e); … … 185 163 } 186 164 } 165 187 166 @Override 188 167 protected void processMouseEvent(MouseEvent e) { … … 221 200 currentCommand.resetLoading(); 222 201 parseSelection(ds.getSelected()); 223 if (!(Main.map.mapMode instanceof AnyAction || Main.map.mapMode instanceof DummyAction || Main.map.mapMode instanceof LengthAction || Main.map.mapMode instanceof NodeAction || Main.map.mapMode instanceof PointAction || Main.map.mapMode instanceof RelationAction || Main.map.mapMode instanceof WayAction)) { 202 if (!(Main.map.mapMode instanceof AnyAction 203 || Main.map.mapMode instanceof DummyAction 204 || Main.map.mapMode instanceof LengthAction 205 || Main.map.mapMode instanceof NodeAction 206 || Main.map.mapMode instanceof PointAction 207 || Main.map.mapMode instanceof RelationAction 208 || Main.map.mapMode instanceof WayAction)) { 224 209 previousMode = Main.map.mapMode; 225 210 } … … 287 272 } 288 273 ZipEntry entry = null; 289 while ( (entry = zis.getNextEntry()) != null) {274 while ((entry = zis.getNextEntry()) != null) { 290 275 if (!entry.isDirectory()) { 291 276 String name = entry.getName(); … … 313 298 for (int i = 0; i < commands.size(); i++) { 314 299 if (strict) { 315 if ( commands.get(i).name.equalsIgnoreCase(text)) {300 if (commands.get(i).name.equalsIgnoreCase(text)) { 316 301 return commands.get(i); 317 302 } 318 } else if ( commands.get(i).name.toLowerCase().startsWith( text.toLowerCase() ) && text.length() > 1) {303 } else if (commands.get(i).name.toLowerCase().startsWith(text.toLowerCase()) && text.length() > 1) { 319 304 return commands.get(i); 320 305 } … … 334 319 prefix = tr("Command") + commandSymbol; 335 320 textField.setText(prefix); 336 } 337 else if (targetMode == Mode.SELECTION) { 321 } else if (targetMode == Mode.SELECTION) { 338 322 mode = Mode.SELECTION; 339 323 Parameter currentParameter = currentCommand.parameters.get(currentCommand.currentParameterNum); 340 324 prefix = tr(currentParameter.description == null ? currentParameter.name : currentParameter.description); 341 325 if (currentParameter.getRawValue() instanceof Relay) 342 prefix = prefix + " (" + ((Relay) (currentParameter.getRawValue())).getOptionsString() + ")";326 prefix = prefix + " (" + ((Relay) (currentParameter.getRawValue())).getOptionsString() + ")"; 343 327 prefix += commandSymbol; 344 328 String value = currentParameter.getValue(); … … 376 360 if (imageryLayers.size() == 1) { 377 361 layer = imageryLayers.get(0); 378 } 379 else { 362 } else { 380 363 endInput(); 381 364 return; … … 383 366 } 384 367 } 385 ImageryInfo info = ((ImageryLayer) layer).getInfo();368 ImageryInfo info = ((ImageryLayer) layer).getInfo(); 386 369 String url = info.getUrl(); 387 370 String itype = info.getImageryType().getTypeString(); … … 396 379 if (imageryLayers.size() == 1) { 397 380 olayer = imageryLayers.get(0); 398 } 399 else { 381 } else { 400 382 endInput(); 401 383 return; … … 403 385 } 404 386 } 405 loadParameter((String.valueOf(((ImageryLayer) olayer).getDx()) + "," + String.valueOf(((ImageryLayer)olayer).getDy())), true);387 loadParameter((String.valueOf(((ImageryLayer) olayer).getDx()) + "," + String.valueOf(((ImageryLayer) olayer).getDy())), true); 406 388 action = new DummyAction(currentMapFrame, this); 407 389 break; … … 413 395 activate(); 414 396 textField.select(prefix.length(), textField.getText().length()); 415 } 416 else if (targetMode == Mode.PROCESSING) { 397 } else if (targetMode == Mode.PROCESSING) { 417 398 mode = Mode.PROCESSING; 418 399 prefix = tr("Processing..."); … … 507 488 508 489 // debug: print resulting cmdline 509 for (String s : builder.command()) 490 for (String s : builder.command()) { 510 491 debugstr.append(s + " "); 492 } 511 493 debugstr.append("\n"); 512 494 Main.info(debugstr.toString()); … … 540 522 } 541 523 } catch (IOException e) { 524 Main.warn(e); 542 525 } 543 526 } … … 639 622 } 640 623 } catch (Exception e) { 641 }642 finally {624 Main.warn(e); 625 } finally { 643 626 synchronized (syncObj) { 644 627 tp.running = false; … … 657 640 syncObj.wait(Main.pref.getInteger("commandline.timeout", 20000)); 658 641 } catch (InterruptedException e) { 642 Main.warn(e); 659 643 } 660 644 } … … 670 654 } 671 655 } catch (InterruptedException e) { 656 Main.warn(e); 672 657 } 673 658 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLineAction.java
r28581 r32779 1 /* 2 * CommandLineAction.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 17 11 18 12 public class CommandLineAction extends JosmAction { 19 13 private final CommandLine parentPlugin; 20 14 21 22 23 24 25 15 public CommandLineAction(CommandLine parentPlugin) { 16 super(tr("Command line"), "commandline", tr("Set input focus to the command line."), 17 Shortcut.registerShortcut("tool:commandline", tr("Tool: {0}", tr("Command line")), KeyEvent.VK_ENTER, Shortcut.DIRECT), true, "commandline", true); 18 this.parentPlugin = parentPlugin; 19 } 26 20 27 28 29 30 21 @Override 22 public void actionPerformed(ActionEvent e) { 23 parentPlugin.activate(); 24 } 31 25 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/DummyAction.java
r29769 r32779 1 /* 2 * DummyAction.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 18 12 19 13 public class DummyAction extends MapMode implements AWTEventListener { 20 private CommandLine parentPlugin;14 private final CommandLine parentPlugin; 21 15 22 16 public DummyAction(MapFrame mapFrame, CommandLine parentPlugin) { -
applications/editors/josm/plugins/CommandLine/src/CommandLine/GpxFilter.java
r30671 r32779 1 /* 2 * GpxFilter.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 40 34 currentSegment = new ArrayList<>(); 41 35 for (WayPoint wp : segment.getWayPoints()) { 42 if ( bbox.bounds(wp.getCoor())) {36 if (bbox.bounds(wp.getCoor())) { 43 37 currentSegment.add(wp); 44 38 } else { … … 54 48 } 55 49 } 56 this.data.tracks.add( new ImmutableGpxTrack( currentTrack, Collections.<String, Object>emptyMap()));50 this.data.tracks.add(new ImmutableGpxTrack(currentTrack, Collections.<String, Object>emptyMap())); 57 51 } 58 52 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/History.java
r30671 r32779 1 /* 2 * History.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 26 20 if (prevItem == null) { 27 21 historyList.addFirst(item); 28 } 29 else { 22 } else { 30 23 if (!prevItem.equalsIgnoreCase(item)) 31 24 historyList.addFirst(item); -
applications/editors/josm/plugins/CommandLine/src/CommandLine/LengthAction.java
r29595 r32779 1 /* 2 * LengthAction.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 39 33 public class LengthAction extends MapMode implements MapViewPaintable, AWTEventListener { 40 34 private final CommandLine parentPlugin; 41 final privateCursor cursorCrosshair;42 final privateCursor cursorJoinNode;35 private final Cursor cursorCrosshair; 36 private final Cursor cursorJoinNode; 43 37 private Cursor currentCursor; 44 38 private final Color selectedColor; … … 70 64 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 71 65 } catch (SecurityException ex) { 66 Main.warn(ex); 72 67 } 73 68 } … … 82 77 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 83 78 } catch (SecurityException ex) { 79 Main.warn(ex); 84 80 } 85 81 if (drawing) … … 161 157 requestFocusInMapView(); 162 158 drawingStart(e); 163 } 164 else 159 } else 165 160 drawing = false; 166 161 } … … 222 217 if (!Main.isDisplayingMapView()) 223 218 return; 224 nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive .isUsablePredicate);219 nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isUsable); 225 220 if (nearestNode != null) { 226 221 setCursor(cursorJoinNode); 227 } 228 else { 222 } else { 229 223 setCursor(cursorCrosshair); 230 224 } … … 248 242 currentCursor = c; 249 243 } catch (Exception e) { 244 Main.warn(e); 250 245 } 251 246 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Loader.java
r30677 r32779 1 /* 2 * Loader.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 28 22 private final ArrayList<Command> loadingCommands; 29 23 30 public Loader 24 public Loader(String dir) { 31 25 dirToScan = dir; 32 26 currentTag = ""; … … 90 84 } 91 85 } 92 } 93 else if (rawName.equals("parameter")) { 86 } else if (rawName.equals("parameter")) { 94 87 currentParameter = new Parameter(); 95 88 for (int i = 0; i < len; i++) { … … 98 91 if (Name.equals("required")) { 99 92 currentParameter.required = Value.equals("true") ? true : false; 100 } 101 else if (Name.equals("type")) { 93 } else if (Name.equals("type")) { 102 94 if (Value.equals("node")) currentParameter.type = Type.NODE; 103 95 else if (Value.equals("way")) currentParameter.type = Type.WAY; … … 112 104 else if (Value.equals("imageryurl")) currentParameter.type = Type.IMAGERYURL; 113 105 else if (Value.equals("imageryoffset")) currentParameter.type = Type.IMAGERYOFFSET; 114 } 115 else if (Name.equals("maxinstances")) { 106 } else if (Name.equals("maxinstances")) { 116 107 currentParameter.maxInstances = Integer.parseInt(Value); 117 } 118 else if (Name.equals("maxvalue")) { 108 } else if (Name.equals("maxvalue")) { 119 109 currentParameter.maxVal = Float.parseFloat(Value); 120 } 121 else if (Name.equals("minvalue")) { 110 } else if (Name.equals("minvalue")) { 122 111 currentParameter.minVal = Float.parseFloat(Value); 123 112 } … … 127 116 128 117 @Override 129 public void characters(char ch[], int start, int length) {118 public void characters(char[] ch, int start, int length) { 130 119 String text = (new String(ch, start, length)).trim(); 131 120 if (currentParameter != null) { 132 121 if (currentTag.equals("name")) { 133 122 currentParameter.name = text; 134 } 135 else if (currentTag.equals("description")) { 123 } else if (currentTag.equals("description")) { 136 124 currentParameter.description = text; 137 } 138 else if (currentTag.equals("value")) { 125 } else if (currentTag.equals("value")) { 139 126 if (currentParameter.type == Type.RELAY) { 140 127 if (!(currentParameter.getRawValue() instanceof Relay)) 141 128 currentParameter.setValue(new Relay()); 142 ((Relay)(currentParameter.getRawValue())).addValue(text); 143 } 144 else { 129 ((Relay) currentParameter.getRawValue()).addValue(text); 130 } else { 145 131 currentParameter.setValue(text); 146 132 } … … 154 140 loadingCommands.add(currentCommand); 155 141 currentCommand = null; 156 } 157 else if (rawName.equals("parameter")) { 158 if(currentParameter.required) 142 } else if (rawName.equals("parameter")) { 143 if (currentParameter.required) 159 144 currentCommand.parameters.add(currentParameter); 160 145 else 161 146 currentCommand.optParameters.add(currentParameter); 162 147 currentParameter = null; 163 } 164 else { 148 } else { 165 149 currentTag = ""; 166 150 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Mode.java
r25038 r32779 1 /* 2 * Mode.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 1 // License: GPL. For details, see LICENSE file. 22 2 package CommandLine; 23 3 -
applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java
r32416 r32779 1 /* 2 * NodeAction.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 27 21 public class NodeAction extends MapMode implements AWTEventListener { 28 22 private final CommandLine parentPlugin; 29 final privateCursor cursorNormal, cursorActive;23 private final Cursor cursorNormal, cursorActive; 30 24 private Cursor currentCursor; 31 25 private Point mousePos; … … 51 45 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 52 46 } catch (SecurityException ex) { 47 Main.warn(ex); 53 48 } 54 49 } … … 61 56 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 62 57 } catch (SecurityException ex) { 58 Main.warn(ex); 63 59 } 64 60 } … … 84 80 ds.clearSelection(nearestNode); 85 81 Main.map.mapView.repaint(); 86 } 87 else { 82 } else { 88 83 int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances; 89 84 switch (maxInstances) { … … 102 97 ds.addSelected(nearestNode); 103 98 Main.map.mapView.repaint(); 104 } 105 else 99 } else 106 100 parentPlugin.printHistory("Maximum instances is " + String.valueOf(maxInstances)); 107 101 } … … 127 121 if (!Main.isDisplayingMapView()) 128 122 return; 129 nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive .isUsablePredicate);123 nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isUsable); 130 124 if (nearestNode != null) { 131 125 setCursor(cursorActive); 132 } 133 else { 126 } else { 134 127 setCursor(cursorNormal); 135 128 } … … 138 131 139 132 private void processMouseEvent(MouseEvent e) { 140 if (e != null) { mousePos = e.getPoint(); } 133 if (e != null) { 134 mousePos = e.getPoint(); 135 } 141 136 } 142 137 … … 157 152 currentCursor = c; 158 153 } catch (Exception e) { 154 Main.warn(e); 159 155 } 160 156 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/OsmToCmd.java
r32416 r32779 1 /* 2 * OsmToCmd.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 1 // License: GPL. For details, see LICENSE file. 7 2 package CommandLine; 8 3 … … 57 52 private final HashMap<PrimitiveId, OsmPrimitive> externalIdMap; // Maps external ids to internal primitives 58 53 59 publicOsmToCmd(CommandLine parentPlugin, DataSet targetDataSet) {54 OsmToCmd(CommandLine parentPlugin, DataSet targetDataSet) { 60 55 this.parentPlugin = parentPlugin; 61 56 this.targetDataSet = targetDataSet; … … 70 65 parser.setProperty("http://xml.org/sax/properties/lexical-handler", handler); 71 66 parser.parse(inputSource, handler); 72 } catch (ParserConfigurationException e) {67 } catch (ParserConfigurationException e) { 73 68 throw new IllegalDataException(e.getMessage(), e); 74 69 } catch (SAXParseException e) { 75 70 throw new IllegalDataException(tr("Line {0} column {1}: ", e.getLineNumber(), e.getColumnNumber()) + e.getMessage(), e); 76 } catch (SAXException e) {71 } catch (SAXException e) { 77 72 throw new IllegalDataException(e.getMessage(), e); 78 } catch (Exception e) {73 } catch (Exception e) { 79 74 throw new IllegalDataException(e); 80 75 } … … 115 110 return; 116 111 } 117 if ( !(v.equals("0.6"))) {112 if (!(v.equals("0.6"))) { 118 113 throwException(tr("Unsupported version: {0}", v)); 119 114 return; … … 127 122 source.setCoor(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon"))); 128 123 readCommon(atts, source); 129 Node target = (Node) targetDataSet.getPrimitiveById( source.getUniqueId(), source.getType());130 131 if (target == null || !(source.isModified() || source.isDeleted()) 124 Node target = (Node) targetDataSet.getPrimitiveById(source.getUniqueId(), source.getType()); 125 126 if (target == null || !(source.isModified() || source.isDeleted())) 132 127 n.load(source); 133 128 else { … … 138 133 currentPrimitive = n; 139 134 externalIdMap.put(source.getPrimitiveId(), n); 140 } 141 else if (qName.equals("way")) { 135 } else if (qName.equals("way")) { 142 136 Way w = new Way(); 143 137 WayData source = new WayData(); 144 138 readCommon(atts, source); 145 Way target = (Way) targetDataSet.getPrimitiveById( source.getUniqueId(), source.getType());146 147 if (target == null || !(source.isModified() || source.isDeleted()) 139 Way target = (Way) targetDataSet.getPrimitiveById(source.getUniqueId(), source.getType()); 140 141 if (target == null || !(source.isModified() || source.isDeleted())) 148 142 w.load(source); 149 143 else { … … 155 149 currentWayNodes.clear(); 156 150 externalIdMap.put(source.getPrimitiveId(), w); 157 } 158 else if (qName.equals("nd")) { 151 } else if (qName.equals("nd")) { 159 152 if (atts.getValue("ref") == null) 160 153 throwException(tr("Missing mandatory attribute ''{0}'' on <nd> of way {1}.", "ref", currentPrimitive.getUniqueId())); 161 154 long id = getLong(atts, "ref"); 162 155 if (id == 0) 163 throwException(tr("Illegal value of attribute ''ref'' of element <nd>. Got {0}.", id) 164 Node node = (Node) externalIdMap.get(new SimplePrimitiveId(id, OsmPrimitiveType.NODE));156 throwException(tr("Illegal value of attribute ''ref'' of element <nd>. Got {0}.", id)); 157 Node node = (Node) externalIdMap.get(new SimplePrimitiveId(id, OsmPrimitiveType.NODE)); 165 158 if (node == null || node.isModified()) { 166 node = (Node) targetDataSet.getPrimitiveById( new SimplePrimitiveId(id, OsmPrimitiveType.NODE));159 node = (Node) targetDataSet.getPrimitiveById(new SimplePrimitiveId(id, OsmPrimitiveType.NODE)); 167 160 if (node == null) 168 161 throwException(tr("Missing definition of new object with id {0}.", id)); 169 162 } 170 163 currentWayNodes.add(node); 171 } 172 // ---- PARSING RELATIONS ---- 173 174 else if (qName.equals("relation")) { 164 } else if (qName.equals("relation")) { // ---- PARSING RELATIONS ---- 175 165 Relation r = new Relation(); 176 166 RelationData source = new RelationData(); 177 167 readCommon(atts, source); 178 Relation target = (Relation) targetDataSet.getPrimitiveById( source.getUniqueId(), source.getType());179 180 if (target == null || !(source.isModified() || source.isDeleted()) 168 Relation target = (Relation) targetDataSet.getPrimitiveById(source.getUniqueId(), source.getType()); 169 170 if (target == null || !(source.isModified() || source.isDeleted())) 181 171 r.load(source); 182 172 else { … … 188 178 currentRelationMembers.clear(); 189 179 externalIdMap.put(source.getPrimitiveId(), r); 190 } 191 else if (qName.equals("member")) { 180 } else if (qName.equals("member")) { 192 181 if (atts.getValue("ref") == null) 193 throwException(tr("Missing mandatory attribute ''{0}'' on <member> of relation {1}.", "ref", currentPrimitive.getUniqueId())); 182 throwException(tr("Missing mandatory attribute ''{0}'' on <member> of relation {1}.", 183 "ref", currentPrimitive.getUniqueId())); 194 184 long id = getLong(atts, "ref"); 195 185 if (id == 0) 196 throwException(tr("Illegal value of attribute ''ref'' of element <nd>. Got {0}.", id) 186 throwException(tr("Illegal value of attribute ''ref'' of element <nd>. Got {0}.", id)); 197 187 198 188 OsmPrimitiveType type = OsmPrimitiveType.NODE; 199 189 String value = atts.getValue("type"); 200 190 if (value == null) { 201 throwException(tr("Missing attribute ''type'' on member {0} in relation {1}.", Long.toString(id), Long.toString(currentPrimitive.getUniqueId()))); 191 throwException(tr("Missing attribute ''type'' on member {0} in relation {1}.", Long.toString(id), 192 Long.toString(currentPrimitive.getUniqueId()))); 202 193 } 203 194 try { 204 195 type = OsmPrimitiveType.fromApiTypeName(value); 205 } 206 catch(IllegalArgumentException e) {207 throwException(tr("Illegal value for attribute ''type'' on member {0} in relation {1}. Got {2}.",Long.toString(id), Long.toString(currentPrimitive.getUniqueId()), value));196 } catch (IllegalArgumentException e) { 197 throwException(tr("Illegal value for attribute ''type'' on member {0} in relation {1}. Got {2}.", 198 Long.toString(id), Long.toString(currentPrimitive.getUniqueId()), value)); 208 199 } 209 200 … … 218 209 RelationMember relationMember = new RelationMember(role, member); 219 210 currentRelationMembers.add(relationMember); 220 } 221 222 // ---- PARSING TAGS (applicable to all objects) ---- 223 224 else if (qName.equals("tag")) { 211 } else if (qName.equals("tag")) { // ---- PARSING TAGS (applicable to all objects) ---- 225 212 String key = atts.getValue("k"); 226 213 String value = atts.getValue("v"); … … 230 217 } 231 218 currentPrimitive.put(key.intern(), value.intern()); 232 } 233 else { 219 } else { 234 220 Main.warn(tr("Undefined element ''{0}'' found in input stream. Skipping.", qName)); 235 221 } 236 } 237 catch (Exception e) { 222 } catch (Exception e) { 238 223 throw new SAXParseException(e.getMessage(), locator, e); 239 224 } … … 244 229 if (qName.equals("node")) { 245 230 if (currentPrimitive.isDeleted()) { 246 cmds.add(new DeleteCommand( targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()) )); 247 } 248 else if (currentPrimitive.isModified()) { 249 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 250 } 251 else if (currentPrimitive.isNew()) { 231 cmds.add(new DeleteCommand(targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()))); 232 } else if (currentPrimitive.isModified()) { 233 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), 234 targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 235 } else if (currentPrimitive.isNew()) { 252 236 cmds.add(new AddCommand(currentPrimitive)); 253 237 } 254 } 255 else if (qName.equals("way")) { 256 ((Way)currentPrimitive).setNodes(currentWayNodes); 238 } else if (qName.equals("way")) { 239 ((Way) currentPrimitive).setNodes(currentWayNodes); 257 240 if (currentPrimitive.isDeleted()) { 258 cmds.add(new DeleteCommand( targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()) )); 259 } 260 else if (currentPrimitive.isModified()) { 261 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 262 } 263 else if (currentPrimitive.isNew()) { 241 cmds.add(new DeleteCommand(targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()))); 242 } else if (currentPrimitive.isModified()) { 243 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), 244 targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 245 } else if (currentPrimitive.isNew()) { 264 246 cmds.add(new AddCommand(currentPrimitive)); 265 247 } 266 } 267 else if (qName.equals("relation")) { 268 ((Relation)currentPrimitive).setMembers(currentRelationMembers); 248 } else if (qName.equals("relation")) { 249 ((Relation) currentPrimitive).setMembers(currentRelationMembers); 269 250 if (currentPrimitive.isDeleted()) { 270 cmds.add(new DeleteCommand( targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()) )); 271 } 272 else if (currentPrimitive.isModified()) { 273 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 274 } 275 else if (currentPrimitive.isNew()) { 251 cmds.add(new DeleteCommand(targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()))); 252 } else if (currentPrimitive.isModified()) { 253 cmds.add(new ChangeCommand(Main.getLayerManager().getEditLayer(), 254 targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive)); 255 } else if (currentPrimitive.isNew()) { 276 256 cmds.add(new AddCommand(currentPrimitive)); 277 257 } … … 315 295 String value = atts.getValue(name); 316 296 if (value == null) { 317 throwException(tr("Missing required attribute ''{0}''.", name));297 throwException(tr("Missing required attribute ''{0}''.", name)); 318 298 } 319 299 try { 320 300 return Long.parseLong(value); 321 } 322 catch(NumberFormatException e) { 323 throwException(tr("Illegal long value for attribute ''{0}''. Got ''{1}''.",name, value)); 301 } catch (NumberFormatException e) { 302 throwException(tr("Illegal long value for attribute ''{0}''. Got ''{1}''.", name, value)); 324 303 } 325 304 return 0; // should not happen … … 335 314 long id = Long.parseLong(uid); 336 315 return User.createOsmUser(id, name); 337 } 338 catch(NumberFormatException e) { 316 } catch (NumberFormatException e) { 339 317 throwException(tr("Illegal value for attribute ''uid''. Got ''{0}''.", uid)); 340 318 } … … 367 345 try { 368 346 version = Integer.parseInt(versionString); 369 } catch(NumberFormatException e) { 370 throwException(tr("Illegal value for attribute ''version'' on OSM primitive with ID {0}. Got {1}.", Long.toString(current.getUniqueId()), versionString)); 347 } catch (NumberFormatException e) { 348 throwException(tr("Illegal value for attribute ''version'' on OSM primitive with ID {0}. Got {1}.", 349 Long.toString(current.getUniqueId()), versionString)); 371 350 } 372 351 } … … 389 368 try { 390 369 current.setChangesetId(Integer.parseInt(v)); 391 } catch (NumberFormatException e) {370 } catch (NumberFormatException e) { 392 371 if (current.getUniqueId() <= 0) { 393 Main.warn(tr("Illegal value for attribute ''changeset'' on new object {1}. Got {0}. Resetting to 0.", v, current.getUniqueId())); 372 Main.warn(tr("Illegal value for attribute ''changeset'' on new object {1}. Got {0}. Resetting to 0.", 373 v, current.getUniqueId())); 394 374 current.setChangesetId(0); 395 375 } else { … … 397 377 } 398 378 } 399 if (current.getChangesetId() <= 0) {379 if (current.getChangesetId() <= 0) { 400 380 if (current.getUniqueId() <= 0) { 401 Main.warn(tr("Illegal value for attribute ''changeset'' on new object {1}. Got {0}. Resetting to 0.", v, current.getUniqueId())); 381 Main.warn(tr("Illegal value for attribute ''changeset'' on new object {1}. Got {0}. Resetting to 0.", 382 v, current.getUniqueId())); 402 383 current.setChangesetId(0); 403 384 } else { -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Parameter.java
r30671 r32779 1 /* 2 * Parameter.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 39 33 switch (type) { 40 34 case POINT: 41 out = (String) value;35 out = (String) value; 42 36 break; 43 37 case LENGTH: … … 51 45 break; 52 46 case RELAY: 53 out = String.valueOf(((Relay) value).getValue());47 out = String.valueOf(((Relay) value).getValue()); 54 48 break; 55 49 case NODE: … … 88 82 public void setValue(Object obj) { 89 83 if (type == Type.RELAY && obj instanceof String && value instanceof Relay) { 90 ((Relay)value).setValue((String)obj); 91 } 92 else 84 ((Relay) value).setValue((String) obj); 85 } else 93 86 value = obj; 94 87 } … … 98 91 if (isOsm()) { 99 92 if (maxInstances == 1) { 100 pObjects.add((OsmPrimitive)value); 101 } 102 else { 93 pObjects.add((OsmPrimitive) value); 94 } else { 103 95 return valueList; 104 96 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/PointAction.java
r32416 r32779 1 /* 2 * PointAction.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 32 26 public class PointAction extends MapMode implements AWTEventListener { 33 27 private final CommandLine parentPlugin; 34 final privateCursor cursorCrosshair;35 final privateCursor cursorJoinNode;28 private final Cursor cursorCrosshair; 29 private final Cursor cursorJoinNode; 36 30 private Cursor currentCursor; 37 31 private Point mousePos; … … 62 56 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 63 57 } catch (SecurityException ex) { 58 Main.warn(ex); 64 59 } 65 60 } … … 72 67 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 73 68 } catch (SecurityException ex) { 69 Main.warn(ex); 74 70 } 75 71 } … … 82 78 updateTextEdit(); 83 79 } 84 } 85 else { 80 } else { 86 81 LatLon coor; 87 82 if (nearestNode == null) … … 90 85 coor = nearestNode.getCoor(); 91 86 if (coor.isOutSideWorld()) { 92 JOptionPane.showMessageDialog(Main.parent, tr("Can not draw outside of the world."));87 JOptionPane.showMessageDialog(Main.parent, tr("Can not draw outside of the world.")); 93 88 return; 94 89 } … … 98 93 parentPlugin.loadParameter(point, true); 99 94 exitMode(); 100 } 101 else { 95 } else { 102 96 if (pointList.size() < maxInstances || maxInstances == 0) { 103 97 pointList.add(point); 104 98 updateTextEdit(); 105 } 106 else 99 } else 107 100 Main.info("Maximum instances!"); 108 101 } … … 136 129 if (!Main.isDisplayingMapView()) 137 130 return; 138 nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive .isUsablePredicate);131 nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isUsable); 139 132 if (nearestNode != null) { 140 133 setCursor(cursorJoinNode); 141 } 142 else { 134 } else { 143 135 setCursor(cursorCrosshair); 144 136 } … … 168 160 currentCursor = c; 169 161 } catch (Exception e) { 162 Main.warn(e); 170 163 } 171 164 } -
applications/editors/josm/plugins/CommandLine/src/CommandLine/RelationAction.java
r29769 r32779 1 /* 2 * RelationAction.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 18 12 19 13 public class RelationAction extends MapMode implements AWTEventListener { 20 privateCommandLine parentPlugin;14 private final CommandLine parentPlugin; 21 15 22 23 24 25 16 public RelationAction(MapFrame mapFrame, CommandLine parentPlugin) { 17 super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", null)); 18 this.parentPlugin = parentPlugin; 19 } 26 20 27 21 @Override 28 29 30 31 22 public void eventDispatched(AWTEvent arg0) { 23 if (!(arg0 instanceof KeyEvent)) 24 return; 25 KeyEvent ev = (KeyEvent) arg0; 32 26 if (ev.getKeyCode() == KeyEvent.VK_ESCAPE && ev.getID() == KeyEvent.KEY_PRESSED) { 33 27 ev.consume(); -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Relay.java
r30671 r32779 1 /* 2 * Relay.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 33 27 if (!(options.containsValue(value))) { 34 28 int i = 0; 35 for (; i < value.length() 29 for (; i < value.length(); i++) { 36 30 letter = value.substring(i, i + 1).toLowerCase(); 37 31 if (!options.containsKey(letter)) … … 41 35 letter = String.valueOf(System.currentTimeMillis()); 42 36 optionsString = optionsString + (optionsString.length() == 0 ? "" : ", ") + value; 43 } 44 else 37 } else 45 38 optionsString = optionsString + (optionsString.length() == 0 ? "" : ", ") + value.substring(0, i) + marker + value.substring(i); 46 39 options.put(letter, value); -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Type.java
r25052 r32779 1 /* 2 * Type.java 3 * 4 * Copyright 2010 Hind <foxhind@gmail.com> 5 * 6 * NODE - Node 7 * WAY - Way 8 * RELATION - Relation 9 * ANY - Any osm object (node, way or relation) 10 * POINT - Coordinates like as Lon,Lat 11 * LENGTH - Fractional number 12 * NATURAL - Natural number (1, 10, 9000) 13 * STRING - Text string 14 * TRIGGER - Yes/No 15 * RELAY - 16 * 17 */ 18 1 // License: GPL. For details, see LICENSE file. 19 2 package CommandLine; 20 3 -
applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java
r32416 r32779 1 /* 2 * WayAction.java 3 * 4 * Copyright 2011 Hind <foxhind@gmail.com> 5 * 6 */ 7 1 // License: GPL. For details, see LICENSE file. 8 2 package CommandLine; 9 3 … … 27 21 public class WayAction extends MapMode implements AWTEventListener { 28 22 private final CommandLine parentPlugin; 29 final privateCursor cursorNormal, cursorActive;23 private final Cursor cursorNormal, cursorActive; 30 24 private Cursor currentCursor; 31 25 private Point mousePos; … … 38 32 this.parentPlugin = parentPlugin; 39 33 /* 40 41 42 43 44 45 46 47 48 49 50 34 this.type = type; 35 switch (type) { 36 case POINT: 37 cursorNormal = ImageProvider.getCursor("crosshair", null); 38 cursorActive = ImageProvider.getCursor("crosshair", "joinnode"); 39 break; 40 case NODE: 41 cursorNormal = ImageProvider.getCursor("normal", "selection"); 42 cursorActive = ImageProvider.getCursor("normal", "joinnode"); 43 break; 44 case WAY: 51 45 */ 52 46 cursorNormal = ImageProvider.getCursor("normal", "selection"); 53 47 cursorActive = ImageProvider.getCursor("normal", "joinway"); 54 48 /* 55 56 57 58 59 60 49 break; 50 default: 51 cursorNormal = ImageProvider.getCursor("normal", "selection"); 52 cursorActive = ImageProvider.getCursor("normal", null); 53 break; 54 } 61 55 */ 62 56 currentCursor = cursorNormal; … … 72 66 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 73 67 } catch (SecurityException ex) { 68 Main.warn(ex); 74 69 } 75 70 } … … 82 77 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 83 78 } catch (SecurityException ex) { 79 Main.warn(ex); 84 80 } 85 81 } … … 122 118 ds.addSelected(nearestWay); 123 119 Main.map.mapView.repaint(); 124 } 125 else 120 } else 126 121 Main.info("Maximum instances!"); 127 122 } … … 147 142 if (!Main.isDisplayingMapView()) 148 143 return; 149 nearestWay = Main.map.mapView.getNearestWay(mousePos, OsmPrimitive .isUsablePredicate);144 nearestWay = Main.map.mapView.getNearestWay(mousePos, OsmPrimitive::isUsable); 150 145 if (nearestWay != null) { 151 146 setCursor(cursorActive); 152 } 153 else { 147 } else { 154 148 setCursor(cursorNormal); 155 149 } … … 158 152 159 153 private void processMouseEvent(MouseEvent e) { 160 if (e != null) { mousePos = e.getPoint(); } 154 if (e != null) { 155 mousePos = e.getPoint(); 156 } 161 157 } 162 158 … … 177 173 currentCursor = c; 178 174 } catch (Exception e) { 175 Main.warn(e); 179 176 } 180 177 }
Note:
See TracChangeset
for help on using the changeset viewer.