Changeset 25044 in osm
- Timestamp:
- 2011-01-13T21:45:45+01:00 (14 years ago)
- Location:
- applications/editors/josm
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/CommandLine/build.xml
r25037 r25044 3 3 4 4 <!-- enter the SVN commit message --> 5 <property name="commit.message" value="I nitial commit" />5 <property name="commit.message" value="Icons with menu and panel support" /> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 7 <property name="plugin.main.version" value="3751" /> -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Command.java
r25038 r25044 2 2 * Command.java 3 3 * 4 * Copyright 201 0Hind <foxhind@gmail.com>4 * Copyright 2011 Hind <foxhind@gmail.com> 5 5 * 6 6 */ … … 22 22 public String name; // Command name 23 23 public String run; // Executable file with arguments ("nya.exe {arg1} {arg2} ... {argn}") 24 public String icon; // Icon file name 24 25 public ArrayList<Parameter> parameters; // Required parameters list 25 26 public ArrayList<Parameter> optParameters; // Optional parameters list … … 27 28 public boolean tracks; 28 29 29 public Command () { parameters = new ArrayList<Parameter>(); optParameters = new ArrayList<Parameter>(); currentParameterNum = 0; tracks = false; } 30 public Command () { parameters = new ArrayList<Parameter>(); optParameters = new ArrayList<Parameter>(); currentParameterNum = 0; tracks = false; icon = ""; } 30 31 31 32 public boolean loadObject(Object obj) { -
applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java
r25038 r25044 2 2 * CommandLine.java 3 3 * 4 * Copyright 201 0Hind <foxhind@gmail.com>4 * Copyright 2011 Hind <foxhind@gmail.com> 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify … … 22 22 package CommandLine; 23 23 24 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 24 25 import static org.openstreetmap.josm.tools.I18n.tr; 26 import static org.openstreetmap.josm.tools.I18n.marktr; 25 27 26 28 import java.awt.BorderLayout; … … 43 45 import java.util.regex.*; 44 46 import javax.swing.JTextField; 47 import javax.swing.JMenu; 48 import javax.swing.JMenuItem; 45 49 46 50 import org.openstreetmap.josm.Main; … … 76 80 private Mode mode; 77 81 private ArrayList<Command> commands; 82 private JMenu commandMenu; 78 83 protected Command currentCommand; 79 84 protected String commandSymbol; 80 pr ivateHistory history;81 pr ivateMapFrame currentMapFrame;82 pr ivateMapMode previousMode;85 protected History history; 86 protected MapFrame currentMapFrame; 87 protected MapMode previousMode; 83 88 84 89 public CommandLine(PluginInformation info) { … … 104 109 Command command = findCommand(commandText, true); 105 110 if (command != null) { 106 currentCommand = command; 107 currentCommand.resetLoading(); 108 parseSelection(Main.main.getCurrentDataSet().getSelected()); 109 previousMode = Main.map.mapMode; 110 if (currentCommand.currentParameterNum < currentCommand.parameters.size()) 111 setMode(Mode.SELECTION); 112 else 113 runTool(); 111 startCommand(command); 114 112 } 115 113 else … … 193 191 }; 194 192 195 MainMenu.add(Main.main.menu.toolsMenu, new CommandLineAction(this)); 193 if ( Main.main.menu != null ) { 194 commandMenu = Main.main.menu.addMenu(marktr("Commands") , KeyEvent.VK_C, Main.main.menu.defaultMenuPos, ht("/Plugin/CommandLine")); 195 MainMenu.add(Main.main.menu.toolsMenu, new CommandLineAction(this)); 196 } 196 197 loadCommands(); 197 198 setMode(Mode.IDLE); 199 } 200 201 public void startCommand(String commandName) { 202 Command command = findCommand(commandName, true); 203 if (command != null) { 204 startCommand(command); 205 } 206 } 207 208 protected void startCommand(Command command) { 209 if (Main.map == null) 210 return; 211 DataSet ds = Main.main.getCurrentDataSet(); 212 if (ds == null) 213 return; 214 currentCommand = command; 215 currentCommand.resetLoading(); 216 parseSelection(ds.getSelected()); 217 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)) { 218 previousMode = Main.map.mapMode; 219 } 220 if (currentCommand.currentParameterNum < currentCommand.parameters.size()) 221 setMode(Mode.SELECTION); 222 else 223 runTool(); 198 224 } 199 225 … … 209 235 Loader loader = new Loader(getPluginDir()); 210 236 commands = loader.load(); // lol 237 238 for (Command command : commands) { 239 commandMenu.add(new CommandAction(command, this)); 240 } 211 241 } 212 242 … … 227 257 } 228 258 229 pr ivatevoid setMode(Mode targetMode) {259 protected void setMode(Mode targetMode) { 230 260 DataSet currentDataSet = Main.main.getCurrentDataSet(); 231 261 if (currentDataSet != null) { … … 295 325 public void endInput() { 296 326 setMode(Mode.IDLE); 297 //System.out.print(String.valueOf());298 327 Main.map.selectMapMode(previousMode); 299 328 Main.map.mapView.repaint(); -
applications/editors/josm/plugins/CommandLine/src/CommandLine/Loader.java
r25038 r25044 2 2 * Loader.java 3 3 * 4 * Copyright 201 0Hind <foxhind@gmail.com>4 * Copyright 2011 Hind <foxhind@gmail.com> 5 5 * 6 6 */ … … 79 79 else if (Name.equals("run")) 80 80 currentCommand.run = Value; 81 else if (Name.equals("tracks")) 81 else if (Name.equals("tracks")) { 82 82 if (Value.equals("bbox")) 83 83 currentCommand.tracks = true; 84 } 85 else if (Name.equals("icon")) { 86 currentCommand.icon = Value; 87 } 84 88 } 85 89 }
Note:
See TracChangeset
for help on using the changeset viewer.