Changeset 31646 in osm for applications
- Timestamp:
- 2015-10-19T13:28:54+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 9 edited
-
CommandLine/src/CommandLine/CommandLine.java (modified) (2 diffs)
-
cadastre-fr/src/cadastre_fr/CadastrePlugin.java (modified) (1 diff)
-
czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java (modified) (2 diffs)
-
imagery_offset_db/src/iodb/ImageryOffsetPlugin.java (modified) (2 diffs)
-
public_transport/src/public_transport/PublicTransportPlugin.java (modified) (2 diffs)
-
routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java (modified) (2 diffs)
-
sds/src/org/openstreetmap/hot/sds/SdsMenu.java (modified) (2 diffs)
-
trustosm/src/org/openstreetmap/josm/plugins/trustosm/TrustOSMplugin.java (modified) (2 diffs)
-
videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPlugin.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java
r30678 r31646 22 22 23 23 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 24 import static org.openstreetmap.josm.tools.I18n.marktr;25 24 import static org.openstreetmap.josm.tools.I18n.tr; 26 25 … … 76 75 77 76 public class CommandLine extends Plugin { 78 protected JTextField textField;79 protected JTextField historyField;80 private String prefix;81 private Mode mode;82 private ArrayList<Command> commands;83 private JMenu commandMenu;84 protected Command currentCommand;85 protected String commandSymbol;86 protected History history;87 protected MapFrame currentMapFrame;88 protected MapMode previousMode;89 90 static final String pluginDir = Main.pref.getPluginsDirectory().getAbsolutePath() + "/CommandLine/";91 92 @SuppressWarnings("serial")93 public CommandLine(PluginInformation info) {94 super(info);95 commandSymbol = ": ";96 history = new History(100);97 historyField = new DisableShortcutsOnFocusGainedTextField();98 textField = new DisableShortcutsOnFocusGainedTextField() {99 @Override100 protected void processKeyEvent(KeyEvent e) {101 if (e.getID() == KeyEvent.KEY_PRESSED) {102 int code = e.getKeyCode();103 if (code == KeyEvent.VK_ENTER) {104 String commandText = textField.getText().substring(prefix.length());105 switch (mode) {106 case IDLE:107 if (commandText.isEmpty()) {108 commandText = history.getLastItem();109 } else {110 history.addItem(commandText);111 }112 Command command = findCommand(commandText, true);113 if (command != null) {114 startCommand(command);115 } else {116 setMode(Mode.IDLE);117 }118 break;119 case SELECTION:120 if (currentMapFrame.mapMode instanceof WayAction || currentMapFrame.mapMode instanceof NodeAction || currentMapFrame.mapMode instanceof RelationAction || currentMapFrame.mapMode instanceof AnyAction) {121 Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected();122 if (selected.size() > 0)123 loadParameter(selected, true);124 }125 else {126 loadParameter(commandText, currentCommand.parameters.get(currentCommand.currentParameterNum).maxInstances == 1);127 }128 break;129 case ADJUSTMENT:130 break;131 }132 e.consume();133 }134 else if (code == KeyEvent.VK_UP) {135 textField.setText(prefix + history.getPrevItem());136 e.consume();137 }138 else if (code == KeyEvent.VK_DOWN) {139 textField.setText(prefix + history.getNextItem());140 e.consume();141 }142 else if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) {143 if (textField.getCaretPosition() <= prefix.length())144 e.consume();145 }146 else if (code == KeyEvent.VK_HOME) {147 setCaretPosition(prefix.length());148 e.consume();149 }150 else if (code == KeyEvent.VK_ESCAPE) {151 if (textField.getText().length() == prefix.length() && mode == Mode.IDLE)152 deactivate();153 else154 endInput();155 e.consume();156 }157 else if (code == KeyEvent.VK_DELETE || code == KeyEvent.VK_RIGHT || code == KeyEvent.VK_END) {158 }159 else {160 e.consume();161 }162 if (textField.getCaretPosition() < prefix.length() || (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0) )163 e.consume();164 }165 if (e.getID() == KeyEvent.KEY_TYPED)166 if (textField.getCaretPosition() < prefix.length() || (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0) )167 e.consume();168 super.processKeyEvent(e);169 if (textField.getText().length() < prefix.length()) { // Safe170 setMode(mode);171 }172 if (e.getID() == KeyEvent.KEY_TYPED) {173 if (e.getKeyChar() > 'A' && e.getKeyChar() < 'z') {174 Command command = findCommand(textField.getText().substring(prefix.length()), false);175 if (command != null) {176 int currentPos = textField.getSelectionStart() == 0 ? textField.getCaretPosition() : textField.getSelectionStart();177 textField.setText(prefix + command.name);178 textField.setCaretPosition(currentPos);179 textField.select(currentPos, prefix.length() + command.name.length());180 }181 }182 }183 }184 @Override185 protected void processMouseEvent(MouseEvent e) {186 super.processMouseEvent(e);187 if (e.getButton() == MouseEvent.BUTTON1 && e.getID() == MouseEvent.MOUSE_RELEASED) {188 if (textField.getSelectionStart() > 0 && textField.getSelectionStart() < prefix.length())189 textField.setSelectionStart(prefix.length());190 else if (textField.getCaretPosition() < prefix.length())191 textField.setCaretPosition(prefix.length());192 }193 }194 };195 196 if (Main.main.menu != null) {197 commandMenu = Main.main.menu.addMenu(marktr("Commands"), KeyEvent.VK_O, Main.main.menu.getDefaultMenuPos(), ht("/Plugin/CommandLine"));198 MainMenu.add(commandMenu, new CommandLineAction(this));199 }200 loadCommands();201 setMode(Mode.IDLE);202 }203 204 public void startCommand(String commandName) {205 Command command = findCommand(commandName, true);206 if (command != null) {207 startCommand(command);208 }209 }210 211 protected void startCommand(Command command) {212 if (Main.map == null)213 return;214 DataSet ds = Main.main.getCurrentDataSet();215 if (ds == null)216 return;217 currentCommand = command;218 currentCommand.resetLoading();219 parseSelection(ds.getSelected());220 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)) {221 previousMode = Main.map.mapMode;222 }223 if (currentCommand.currentParameterNum < currentCommand.parameters.size())224 setMode(Mode.SELECTION);225 else226 runTool();227 }228 229 @Override230 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {231 currentMapFrame = newFrame;232 if (oldFrame == null && newFrame != null) {233 JToolBar tb = new JToolBar();234 tb.setLayout(new BorderLayout());235 tb.setFloatable(false);236 tb.setOrientation(JToolBar.HORIZONTAL);237 tb.add(historyField, BorderLayout.NORTH);238 tb.add(textField, BorderLayout.SOUTH);239 currentMapFrame.add(tb, BorderLayout.NORTH);240 printHistory("Loaded CommandLine, version " + getPluginInformation().version);241 }242 }243 244 protected void printHistory(final String text) {245 SwingUtilities.invokeLater(new Runnable() {246 @Override247 public void run() {248 historyField.setText(text);249 }250 });251 }252 253 private void loadCommands() {254 commands = (new Loader(getPluginDir())).load();255 if (commands.isEmpty()) {256 if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(Main.parent,257 tr("No command has been found. Would you like to download and install default commands now?"),258 tr("No command found"), JOptionPane.YES_NO_CANCEL_OPTION)) {259 try {260 downloadAndInstallDefaultCommands();261 commands = (new Loader(getPluginDir())).load();262 JOptionPane.showMessageDialog(Main.parent, tr("Default commands have been successfully installed"),263 tr("Success"), JOptionPane.INFORMATION_MESSAGE);264 } catch (IOException e) {265 Main.warn(e);266 JOptionPane.showMessageDialog(Main.parent,267 tr("Failed to download and install default commands.\n\nError: {0}", e.getMessage()),268 tr("Warning"), JOptionPane.WARNING_MESSAGE);269 }270 }271 }272 for (Command command : commands) {273 commandMenu.add(new CommandAction(command, this));274 }275 }276 277 private void downloadAndInstallDefaultCommands() throws IOException {278 String url = Main.pref.get("commandline.default.commands.url",279 "https://github.com/Foxhind/JOSM-CommandLine-commands/archive/master.zip");280 try (ZipInputStream zis = new ZipInputStream(Utils.openURL(new URL(url)), StandardCharsets.UTF_8)) {281 File dir = new File(getPluginDir());282 if (!dir.exists()) {283 dir.mkdirs();284 }285 ZipEntry entry = null;286 while ( (entry = zis.getNextEntry()) != null ) {287 if (!entry.isDirectory()) {288 String name = entry.getName();289 if (name.contains("/")) {290 name = name.substring(name.lastIndexOf("/"));291 }292 File file = new File(dir + File.separator + name);293 Main.info("Installing command file: "+file);294 if (!file.createNewFile()) {295 throw new IOException("Could not create file: " + file.getAbsolutePath());296 }297 // Write file298 try (FileOutputStream fos = new FileOutputStream(file)) {299 Utils.copyStream(zis, fos);300 }301 // Set last modification date302 long time = entry.getTime();303 if (time > -1) {304 file.setLastModified(time);305 }306 }307 }308 }309 }310 311 private Command findCommand(String text, boolean strict) {312 for (int i = 0; i < commands.size(); i++) {313 if (strict) {314 if ( commands.get(i).name.equalsIgnoreCase(text) ) {315 return commands.get(i);316 }317 } else if ( commands.get(i).name.toLowerCase().startsWith( text.toLowerCase() ) && text.length() > 1 ) {318 return commands.get(i);319 }320 }321 return null;322 }323 324 protected void setMode(Mode targetMode) {325 DataSet currentDataSet = Main.main.getCurrentDataSet();326 if (currentDataSet != null) {327 currentDataSet.clearSelection();328 Main.map.mapView.repaint();329 }330 if (targetMode == Mode.IDLE) {331 mode = Mode.IDLE;332 currentCommand = null;333 prefix = tr("Command") + commandSymbol;334 textField.setText(prefix);335 }336 else if (targetMode == Mode.SELECTION) {337 mode = Mode.SELECTION;338 Parameter currentParameter = currentCommand.parameters.get(currentCommand.currentParameterNum);339 prefix = tr(currentParameter.description == null ? currentParameter.name : currentParameter.description);340 if (currentParameter.getRawValue() instanceof Relay)341 prefix = prefix + " (" + ((Relay)(currentParameter.getRawValue())).getOptionsString() + ")";342 prefix += commandSymbol;343 String value = currentParameter.getValue();344 textField.setText(prefix + value);345 Type currentType = currentParameter.type;346 MapMode action = null;347 switch (currentType) {348 case POINT:349 action = new PointAction(currentMapFrame, this);350 break;351 case WAY:352 action = new WayAction(currentMapFrame, this);353 break;354 case NODE:355 action = new NodeAction(currentMapFrame, this);356 break;357 case RELATION:358 action = new RelationAction(currentMapFrame, this);359 break;360 case ANY:361 action = new AnyAction(currentMapFrame, this);362 break;363 case LENGTH:364 action = new LengthAction(currentMapFrame, this);365 break;366 case USERNAME:367 loadParameter(Main.pref.get("osm-server.username", null), true);368 action = new DummyAction(currentMapFrame, this);369 break;370 case IMAGERYURL:371 Layer layer = Main.map.mapView.getActiveLayer();372 if (layer != null) {373 if (!(layer instanceof ImageryLayer)) {374 List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class);375 if (imageryLayers.size() == 1) {376 layer = imageryLayers.get(0);377 }378 else {379 endInput();380 return;381 }382 }383 }384 ImageryInfo info = ((ImageryLayer)layer).getInfo();385 String url = info.getUrl();386 String itype = info.getImageryType().getTypeString();387 loadParameter((url.equals("") ? itype : url), true);388 action = new DummyAction(currentMapFrame, this);389 break;390 case IMAGERYOFFSET:391 Layer olayer = Main.map.mapView.getActiveLayer();392 if (olayer != null) {393 if (!(olayer instanceof ImageryLayer)) {394 List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class);395 if (imageryLayers.size() == 1) {396 olayer = imageryLayers.get(0);397 }398 else {399 endInput();400 return;401 }402 }403 }404 loadParameter((String.valueOf(((ImageryLayer)olayer).getDx()) + "," + String.valueOf(((ImageryLayer)olayer).getDy())), true);405 action = new DummyAction(currentMapFrame, this);406 break;407 default:408 action = new DummyAction(currentMapFrame, this);409 break;410 }411 currentMapFrame.selectMapMode(action);412 activate();413 textField.select(prefix.length(), textField.getText().length());414 }415 else if (targetMode == Mode.PROCESSING) {416 mode = Mode.PROCESSING;417 prefix = tr("Processing...");418 textField.setText(prefix);419 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));420 }421 }422 423 public void activate() {424 textField.requestFocus();425 textField.setCaretPosition(textField.getText().length());426 }427 428 public void deactivate() {429 Main.map.mapView.requestFocus();430 }431 432 public void abortInput() {433 printHistory(tr("Aborted") + ".");434 endInput();435 }436 437 public void endInput() {438 setMode(Mode.IDLE);439 Main.map.selectMapMode(previousMode);440 Main.map.mapView.repaint();441 }442 443 public void loadParameter(Object obj, boolean next) {444 if (currentCommand.loadObject(obj)) {445 if (currentCommand.hasNextParameter()) {446 if (next) {447 Parameter currentParameter = currentCommand.parameters.get(currentCommand.currentParameterNum);448 String prefix = tr(currentParameter.description == null ? currentParameter.name : currentParameter.description);449 prefix += commandSymbol;450 String value = currentParameter.getValue();451 printHistory(prefix + value);452 currentCommand.nextParameter();453 setMode(Mode.SELECTION);454 }455 } else {456 runTool();457 }458 } else {459 Main.info("Invalid argument");460 endInput();461 }462 }463 464 private void parseSelection(Collection<OsmPrimitive> selection) {465 boolean ok = false;466 for (OsmPrimitive obj : selection) {467 ok = currentCommand.loadObject(obj);468 if (!ok)469 break;470 }471 if (ok) {472 currentCommand.nextParameter();473 } else {474 currentCommand.resetLoading();475 }476 }477 478 private class ToolProcess {479 public Process process;480 public volatile boolean running;481 }482 483 // Thanks to Upliner484 public void runTool() {485 setMode(Mode.PROCESSING);486 String commandToRun = currentCommand.run;487 final boolean tracks = currentCommand.tracks;488 final ArrayList<Parameter> parameters = currentCommand.parameters;489 490 for (Parameter parameter : currentCommand.parameters) {491 commandToRun = commandToRun.replace("{" + parameter.name + "}", parameter.getValue());492 }493 for (Parameter parameter : currentCommand.optParameters) {494 commandToRun = commandToRun.replace("{" + parameter.name + "}", parameter.getValue());495 }496 String[] listToRun = commandToRun.split(" ");497 498 // create the process499 final Object syncObj = new Object();500 501 ProcessBuilder builder;502 builder = new ProcessBuilder(listToRun);503 builder.directory(new File(getPluginDir()));504 505 final StringBuilder debugstr = new StringBuilder();506 507 // debug: print resulting cmdline508 for (String s : builder.command())509 debugstr.append(s + " ");510 debugstr.append("\n");511 Main.info(debugstr.toString());512 513 final ToolProcess tp = new ToolProcess();514 try {515 tp.process = builder.start();516 } catch (final IOException e) {517 synchronized (debugstr) {518 Main.error(519 tr("Error executing the script: ") +520 debugstr.toString() + e.getMessage() + "\n" + e.getStackTrace());521 }522 return;523 }524 tp.running = true;525 526 // redirect child process's stderr to JOSM stderr527 new Thread(new Runnable() {528 @Override529 public void run() {530 try {531 byte[] buffer = new byte[1024];532 InputStream errStream = tp.process.getErrorStream();533 int len;534 while ((len = errStream.read(buffer)) > 0) {535 synchronized (debugstr) {536 debugstr.append(new String(buffer, 0, len));537 }538 System.err.write(buffer, 0, len);539 }540 } catch (IOException e) {541 }542 }543 }).start();544 545 // Write stdin stream546 Thread osmWriteThread = new Thread(new Runnable() {547 @Override548 public void run() {549 BBox bbox = null;550 final OutputStream outputStream = tp.process.getOutputStream();551 PrintWriter printWriter = null;552 try {553 printWriter = new PrintWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));554 } catch (Exception e) {555 Main.error(e);556 }557 final OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(printWriter, true, null);558 Collection<OsmPrimitive> refObjects = currentCommand.getDepsObjects();559 Collection<OsmPrimitive> pObjects;560 osmWriter.header();561 Collection<OsmPrimitive> contents = new ArrayList<>();562 for (OsmPrimitive primitive : refObjects) {563 contents.add(primitive);564 if (bbox == null)565 bbox = new BBox(primitive.getBBox());566 else567 bbox.addPrimitive(primitive, 0.0);568 }569 osmWriter.writeNodes(new SubclassFilteredCollection<OsmPrimitive, Node>(contents, OsmPrimitive.nodePredicate));570 osmWriter.writeWays(new SubclassFilteredCollection<OsmPrimitive, Way>(contents, OsmPrimitive.wayPredicate));571 osmWriter.writeRelations(new SubclassFilteredCollection<OsmPrimitive, Relation>(contents, OsmPrimitive.relationPredicate));572 osmWriter.footer();573 osmWriter.flush();574 575 for (Parameter parameter : parameters) {576 if (!parameter.isOsm())577 continue;578 contents = new ArrayList<>();579 osmWriter.header();580 pObjects = parameter.getParameterObjects();581 for (OsmPrimitive primitive : pObjects) {582 contents.add(primitive);583 if (bbox == null)584 bbox = new BBox(primitive.getBBox());585 else586 bbox.addPrimitive(primitive, 0.0);587 }588 osmWriter.writeNodes(new SubclassFilteredCollection<OsmPrimitive, Node>(contents, OsmPrimitive.nodePredicate));589 osmWriter.writeWays(new SubclassFilteredCollection<OsmPrimitive, Way>(contents, OsmPrimitive.wayPredicate));590 osmWriter.writeRelations(new SubclassFilteredCollection<OsmPrimitive, Relation>(contents, OsmPrimitive.relationPredicate));591 osmWriter.footer();592 osmWriter.flush();593 }594 595 if (tracks) {596 try (GpxWriter gpxWriter = new GpxWriter(printWriter)) {597 GpxFilter gpxFilter = new GpxFilter();598 gpxFilter.initBboxFilter(bbox);599 List<GpxLayer> gpxLayers = Main.map.mapView.getLayersOfType(GpxLayer.class);600 for (GpxLayer gpxLayer : gpxLayers) {601 gpxFilter.addGpxData(gpxLayer.data);602 }603 gpxWriter.write(gpxFilter.getGpxData());604 } catch (IOException e) {605 Main.warn(e);606 }607 }608 Utils.close(osmWriter);609 synchronized (syncObj) {610 if (currentCommand.asynchronous) {611 tp.running = false;612 syncObj.notifyAll();613 }614 }615 }616 });617 618 // Read stdout stream619 final DataSet currentDataSet = Main.main.getCurrentDataSet();620 final CommandLine that = this;621 Thread osmParseThread = new Thread(new Runnable() {622 @Override623 public void run() {624 try {625 final OsmToCmd osmToCmd = new OsmToCmd(that, currentDataSet);626 String commandName = currentCommand.name;627 final InputStream inputStream = tp.process.getInputStream();628 osmToCmd.parseStream(inputStream);629 final List<org.openstreetmap.josm.command.Command> cmdlist = osmToCmd.getCommandList();630 if (!cmdlist.isEmpty()) {631 final SequenceCommand cmd = new SequenceCommand(commandName, cmdlist);632 SwingUtilities.invokeLater(new Runnable() {633 @Override634 public void run() {635 Main.main.undoRedo.add(cmd);636 }637 });638 }639 } catch (Exception e) {640 }641 finally {642 synchronized (syncObj) {643 tp.running = false;644 syncObj.notifyAll();645 }646 }647 }648 649 });650 651 osmParseThread.start();652 osmWriteThread.start();653 654 synchronized (syncObj) {655 try {656 syncObj.wait(Main.pref.getInteger("commandline.timeout", 20000));657 } catch (InterruptedException e) {658 }659 }660 if (tp.running) {661 new Thread(new PleaseWaitRunnable(currentCommand.name) {662 @Override663 protected void realRun() {664 try {665 progressMonitor.indeterminateSubTask(null);666 synchronized (syncObj) {667 if (tp.running)668 syncObj.wait();669 }670 } catch (InterruptedException e) {671 }672 }673 674 @Override675 protected void cancel() {676 synchronized (syncObj) {677 tp.running = false;678 tp.process.destroy();679 syncObj.notifyAll();680 endInput();681 }682 }683 684 @Override685 protected void finish() {686 }687 }).start();688 }689 endInput();690 }77 protected JTextField textField; 78 protected JTextField historyField; 79 private String prefix; 80 private Mode mode; 81 private ArrayList<Command> commands; 82 private JMenu commandMenu; 83 protected Command currentCommand; 84 protected String commandSymbol; 85 protected History history; 86 protected MapFrame currentMapFrame; 87 protected MapMode previousMode; 88 89 static final String pluginDir = Main.pref.getPluginsDirectory().getAbsolutePath() + "/CommandLine/"; 90 91 @SuppressWarnings("serial") 92 public CommandLine(PluginInformation info) { 93 super(info); 94 commandSymbol = ": "; 95 history = new History(100); 96 historyField = new DisableShortcutsOnFocusGainedTextField(); 97 textField = new DisableShortcutsOnFocusGainedTextField() { 98 @Override 99 protected void processKeyEvent(KeyEvent e) { 100 if (e.getID() == KeyEvent.KEY_PRESSED) { 101 int code = e.getKeyCode(); 102 if (code == KeyEvent.VK_ENTER) { 103 String commandText = textField.getText().substring(prefix.length()); 104 switch (mode) { 105 case IDLE: 106 if (commandText.isEmpty()) { 107 commandText = history.getLastItem(); 108 } else { 109 history.addItem(commandText); 110 } 111 Command command = findCommand(commandText, true); 112 if (command != null) { 113 startCommand(command); 114 } else { 115 setMode(Mode.IDLE); 116 } 117 break; 118 case SELECTION: 119 if (currentMapFrame.mapMode instanceof WayAction || currentMapFrame.mapMode instanceof NodeAction || currentMapFrame.mapMode instanceof RelationAction || currentMapFrame.mapMode instanceof AnyAction) { 120 Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected(); 121 if (selected.size() > 0) 122 loadParameter(selected, true); 123 } 124 else { 125 loadParameter(commandText, currentCommand.parameters.get(currentCommand.currentParameterNum).maxInstances == 1); 126 } 127 break; 128 case ADJUSTMENT: 129 break; 130 } 131 e.consume(); 132 } 133 else if (code == KeyEvent.VK_UP) { 134 textField.setText(prefix + history.getPrevItem()); 135 e.consume(); 136 } 137 else if (code == KeyEvent.VK_DOWN) { 138 textField.setText(prefix + history.getNextItem()); 139 e.consume(); 140 } 141 else if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { 142 if (textField.getCaretPosition() <= prefix.length()) 143 e.consume(); 144 } 145 else if (code == KeyEvent.VK_HOME) { 146 setCaretPosition(prefix.length()); 147 e.consume(); 148 } 149 else if (code == KeyEvent.VK_ESCAPE) { 150 if (textField.getText().length() == prefix.length() && mode == Mode.IDLE) 151 deactivate(); 152 else 153 endInput(); 154 e.consume(); 155 } 156 else if (code == KeyEvent.VK_DELETE || code == KeyEvent.VK_RIGHT || code == KeyEvent.VK_END) { 157 } 158 else { 159 e.consume(); 160 } 161 if (textField.getCaretPosition() < prefix.length() || (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0) ) 162 e.consume(); 163 } 164 if (e.getID() == KeyEvent.KEY_TYPED) 165 if (textField.getCaretPosition() < prefix.length() || (textField.getSelectionStart() < prefix.length() && textField.getSelectionStart() > 0) ) 166 e.consume(); 167 super.processKeyEvent(e); 168 if (textField.getText().length() < prefix.length()) { // Safe 169 setMode(mode); 170 } 171 if (e.getID() == KeyEvent.KEY_TYPED) { 172 if (e.getKeyChar() > 'A' && e.getKeyChar() < 'z') { 173 Command command = findCommand(textField.getText().substring(prefix.length()), false); 174 if (command != null) { 175 int currentPos = textField.getSelectionStart() == 0 ? textField.getCaretPosition() : textField.getSelectionStart(); 176 textField.setText(prefix + command.name); 177 textField.setCaretPosition(currentPos); 178 textField.select(currentPos, prefix.length() + command.name.length()); 179 } 180 } 181 } 182 } 183 @Override 184 protected void processMouseEvent(MouseEvent e) { 185 super.processMouseEvent(e); 186 if (e.getButton() == MouseEvent.BUTTON1 && e.getID() == MouseEvent.MOUSE_RELEASED) { 187 if (textField.getSelectionStart() > 0 && textField.getSelectionStart() < prefix.length()) 188 textField.setSelectionStart(prefix.length()); 189 else if (textField.getCaretPosition() < prefix.length()) 190 textField.setCaretPosition(prefix.length()); 191 } 192 } 193 }; 194 195 if (Main.main.menu != null) { 196 commandMenu = Main.main.menu.addMenu("Commands", tr("Commands"), KeyEvent.VK_O, Main.main.menu.getDefaultMenuPos(), ht("/Plugin/CommandLine")); 197 MainMenu.add(commandMenu, new CommandLineAction(this)); 198 } 199 loadCommands(); 200 setMode(Mode.IDLE); 201 } 202 203 public void startCommand(String commandName) { 204 Command command = findCommand(commandName, true); 205 if (command != null) { 206 startCommand(command); 207 } 208 } 209 210 protected void startCommand(Command command) { 211 if (Main.map == null) 212 return; 213 DataSet ds = Main.main.getCurrentDataSet(); 214 if (ds == null) 215 return; 216 currentCommand = command; 217 currentCommand.resetLoading(); 218 parseSelection(ds.getSelected()); 219 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)) { 220 previousMode = Main.map.mapMode; 221 } 222 if (currentCommand.currentParameterNum < currentCommand.parameters.size()) 223 setMode(Mode.SELECTION); 224 else 225 runTool(); 226 } 227 228 @Override 229 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 230 currentMapFrame = newFrame; 231 if (oldFrame == null && newFrame != null) { 232 JToolBar tb = new JToolBar(); 233 tb.setLayout(new BorderLayout()); 234 tb.setFloatable(false); 235 tb.setOrientation(JToolBar.HORIZONTAL); 236 tb.add(historyField, BorderLayout.NORTH); 237 tb.add(textField, BorderLayout.SOUTH); 238 currentMapFrame.add(tb, BorderLayout.NORTH); 239 printHistory("Loaded CommandLine, version " + getPluginInformation().version); 240 } 241 } 242 243 protected void printHistory(final String text) { 244 SwingUtilities.invokeLater(new Runnable() { 245 @Override 246 public void run() { 247 historyField.setText(text); 248 } 249 }); 250 } 251 252 private void loadCommands() { 253 commands = (new Loader(getPluginDir())).load(); 254 if (commands.isEmpty()) { 255 if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(Main.parent, 256 tr("No command has been found. Would you like to download and install default commands now?"), 257 tr("No command found"), JOptionPane.YES_NO_CANCEL_OPTION)) { 258 try { 259 downloadAndInstallDefaultCommands(); 260 commands = (new Loader(getPluginDir())).load(); 261 JOptionPane.showMessageDialog(Main.parent, tr("Default commands have been successfully installed"), 262 tr("Success"), JOptionPane.INFORMATION_MESSAGE); 263 } catch (IOException e) { 264 Main.warn(e); 265 JOptionPane.showMessageDialog(Main.parent, 266 tr("Failed to download and install default commands.\n\nError: {0}", e.getMessage()), 267 tr("Warning"), JOptionPane.WARNING_MESSAGE); 268 } 269 } 270 } 271 for (Command command : commands) { 272 commandMenu.add(new CommandAction(command, this)); 273 } 274 } 275 276 private void downloadAndInstallDefaultCommands() throws IOException { 277 String url = Main.pref.get("commandline.default.commands.url", 278 "https://github.com/Foxhind/JOSM-CommandLine-commands/archive/master.zip"); 279 try (ZipInputStream zis = new ZipInputStream(Utils.openURL(new URL(url)), StandardCharsets.UTF_8)) { 280 File dir = new File(getPluginDir()); 281 if (!dir.exists()) { 282 dir.mkdirs(); 283 } 284 ZipEntry entry = null; 285 while ( (entry = zis.getNextEntry()) != null ) { 286 if (!entry.isDirectory()) { 287 String name = entry.getName(); 288 if (name.contains("/")) { 289 name = name.substring(name.lastIndexOf("/")); 290 } 291 File file = new File(dir + File.separator + name); 292 Main.info("Installing command file: "+file); 293 if (!file.createNewFile()) { 294 throw new IOException("Could not create file: " + file.getAbsolutePath()); 295 } 296 // Write file 297 try (FileOutputStream fos = new FileOutputStream(file)) { 298 Utils.copyStream(zis, fos); 299 } 300 // Set last modification date 301 long time = entry.getTime(); 302 if (time > -1) { 303 file.setLastModified(time); 304 } 305 } 306 } 307 } 308 } 309 310 private Command findCommand(String text, boolean strict) { 311 for (int i = 0; i < commands.size(); i++) { 312 if (strict) { 313 if ( commands.get(i).name.equalsIgnoreCase(text) ) { 314 return commands.get(i); 315 } 316 } else if ( commands.get(i).name.toLowerCase().startsWith( text.toLowerCase() ) && text.length() > 1 ) { 317 return commands.get(i); 318 } 319 } 320 return null; 321 } 322 323 protected void setMode(Mode targetMode) { 324 DataSet currentDataSet = Main.main.getCurrentDataSet(); 325 if (currentDataSet != null) { 326 currentDataSet.clearSelection(); 327 Main.map.mapView.repaint(); 328 } 329 if (targetMode == Mode.IDLE) { 330 mode = Mode.IDLE; 331 currentCommand = null; 332 prefix = tr("Command") + commandSymbol; 333 textField.setText(prefix); 334 } 335 else if (targetMode == Mode.SELECTION) { 336 mode = Mode.SELECTION; 337 Parameter currentParameter = currentCommand.parameters.get(currentCommand.currentParameterNum); 338 prefix = tr(currentParameter.description == null ? currentParameter.name : currentParameter.description); 339 if (currentParameter.getRawValue() instanceof Relay) 340 prefix = prefix + " (" + ((Relay)(currentParameter.getRawValue())).getOptionsString() + ")"; 341 prefix += commandSymbol; 342 String value = currentParameter.getValue(); 343 textField.setText(prefix + value); 344 Type currentType = currentParameter.type; 345 MapMode action = null; 346 switch (currentType) { 347 case POINT: 348 action = new PointAction(currentMapFrame, this); 349 break; 350 case WAY: 351 action = new WayAction(currentMapFrame, this); 352 break; 353 case NODE: 354 action = new NodeAction(currentMapFrame, this); 355 break; 356 case RELATION: 357 action = new RelationAction(currentMapFrame, this); 358 break; 359 case ANY: 360 action = new AnyAction(currentMapFrame, this); 361 break; 362 case LENGTH: 363 action = new LengthAction(currentMapFrame, this); 364 break; 365 case USERNAME: 366 loadParameter(Main.pref.get("osm-server.username", null), true); 367 action = new DummyAction(currentMapFrame, this); 368 break; 369 case IMAGERYURL: 370 Layer layer = Main.map.mapView.getActiveLayer(); 371 if (layer != null) { 372 if (!(layer instanceof ImageryLayer)) { 373 List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class); 374 if (imageryLayers.size() == 1) { 375 layer = imageryLayers.get(0); 376 } 377 else { 378 endInput(); 379 return; 380 } 381 } 382 } 383 ImageryInfo info = ((ImageryLayer)layer).getInfo(); 384 String url = info.getUrl(); 385 String itype = info.getImageryType().getTypeString(); 386 loadParameter((url.equals("") ? itype : url), true); 387 action = new DummyAction(currentMapFrame, this); 388 break; 389 case IMAGERYOFFSET: 390 Layer olayer = Main.map.mapView.getActiveLayer(); 391 if (olayer != null) { 392 if (!(olayer instanceof ImageryLayer)) { 393 List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class); 394 if (imageryLayers.size() == 1) { 395 olayer = imageryLayers.get(0); 396 } 397 else { 398 endInput(); 399 return; 400 } 401 } 402 } 403 loadParameter((String.valueOf(((ImageryLayer)olayer).getDx()) + "," + String.valueOf(((ImageryLayer)olayer).getDy())), true); 404 action = new DummyAction(currentMapFrame, this); 405 break; 406 default: 407 action = new DummyAction(currentMapFrame, this); 408 break; 409 } 410 currentMapFrame.selectMapMode(action); 411 activate(); 412 textField.select(prefix.length(), textField.getText().length()); 413 } 414 else if (targetMode == Mode.PROCESSING) { 415 mode = Mode.PROCESSING; 416 prefix = tr("Processing..."); 417 textField.setText(prefix); 418 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 419 } 420 } 421 422 public void activate() { 423 textField.requestFocus(); 424 textField.setCaretPosition(textField.getText().length()); 425 } 426 427 public void deactivate() { 428 Main.map.mapView.requestFocus(); 429 } 430 431 public void abortInput() { 432 printHistory(tr("Aborted") + "."); 433 endInput(); 434 } 435 436 public void endInput() { 437 setMode(Mode.IDLE); 438 Main.map.selectMapMode(previousMode); 439 Main.map.mapView.repaint(); 440 } 441 442 public void loadParameter(Object obj, boolean next) { 443 if (currentCommand.loadObject(obj)) { 444 if (currentCommand.hasNextParameter()) { 445 if (next) { 446 Parameter currentParameter = currentCommand.parameters.get(currentCommand.currentParameterNum); 447 String prefix = tr(currentParameter.description == null ? currentParameter.name : currentParameter.description); 448 prefix += commandSymbol; 449 String value = currentParameter.getValue(); 450 printHistory(prefix + value); 451 currentCommand.nextParameter(); 452 setMode(Mode.SELECTION); 453 } 454 } else { 455 runTool(); 456 } 457 } else { 458 Main.info("Invalid argument"); 459 endInput(); 460 } 461 } 462 463 private void parseSelection(Collection<OsmPrimitive> selection) { 464 boolean ok = false; 465 for (OsmPrimitive obj : selection) { 466 ok = currentCommand.loadObject(obj); 467 if (!ok) 468 break; 469 } 470 if (ok) { 471 currentCommand.nextParameter(); 472 } else { 473 currentCommand.resetLoading(); 474 } 475 } 476 477 private class ToolProcess { 478 public Process process; 479 public volatile boolean running; 480 } 481 482 // Thanks to Upliner 483 public void runTool() { 484 setMode(Mode.PROCESSING); 485 String commandToRun = currentCommand.run; 486 final boolean tracks = currentCommand.tracks; 487 final ArrayList<Parameter> parameters = currentCommand.parameters; 488 489 for (Parameter parameter : currentCommand.parameters) { 490 commandToRun = commandToRun.replace("{" + parameter.name + "}", parameter.getValue()); 491 } 492 for (Parameter parameter : currentCommand.optParameters) { 493 commandToRun = commandToRun.replace("{" + parameter.name + "}", parameter.getValue()); 494 } 495 String[] listToRun = commandToRun.split(" "); 496 497 // create the process 498 final Object syncObj = new Object(); 499 500 ProcessBuilder builder; 501 builder = new ProcessBuilder(listToRun); 502 builder.directory(new File(getPluginDir())); 503 504 final StringBuilder debugstr = new StringBuilder(); 505 506 // debug: print resulting cmdline 507 for (String s : builder.command()) 508 debugstr.append(s + " "); 509 debugstr.append("\n"); 510 Main.info(debugstr.toString()); 511 512 final ToolProcess tp = new ToolProcess(); 513 try { 514 tp.process = builder.start(); 515 } catch (final IOException e) { 516 synchronized (debugstr) { 517 Main.error( 518 tr("Error executing the script: ") + 519 debugstr.toString() + e.getMessage() + "\n" + e.getStackTrace()); 520 } 521 return; 522 } 523 tp.running = true; 524 525 // redirect child process's stderr to JOSM stderr 526 new Thread(new Runnable() { 527 @Override 528 public void run() { 529 try { 530 byte[] buffer = new byte[1024]; 531 InputStream errStream = tp.process.getErrorStream(); 532 int len; 533 while ((len = errStream.read(buffer)) > 0) { 534 synchronized (debugstr) { 535 debugstr.append(new String(buffer, 0, len)); 536 } 537 System.err.write(buffer, 0, len); 538 } 539 } catch (IOException e) { 540 } 541 } 542 }).start(); 543 544 // Write stdin stream 545 Thread osmWriteThread = new Thread(new Runnable() { 546 @Override 547 public void run() { 548 BBox bbox = null; 549 final OutputStream outputStream = tp.process.getOutputStream(); 550 PrintWriter printWriter = null; 551 try { 552 printWriter = new PrintWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)); 553 } catch (Exception e) { 554 Main.error(e); 555 } 556 final OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(printWriter, true, null); 557 Collection<OsmPrimitive> refObjects = currentCommand.getDepsObjects(); 558 Collection<OsmPrimitive> pObjects; 559 osmWriter.header(); 560 Collection<OsmPrimitive> contents = new ArrayList<>(); 561 for (OsmPrimitive primitive : refObjects) { 562 contents.add(primitive); 563 if (bbox == null) 564 bbox = new BBox(primitive.getBBox()); 565 else 566 bbox.addPrimitive(primitive, 0.0); 567 } 568 osmWriter.writeNodes(new SubclassFilteredCollection<OsmPrimitive, Node>(contents, OsmPrimitive.nodePredicate)); 569 osmWriter.writeWays(new SubclassFilteredCollection<OsmPrimitive, Way>(contents, OsmPrimitive.wayPredicate)); 570 osmWriter.writeRelations(new SubclassFilteredCollection<OsmPrimitive, Relation>(contents, OsmPrimitive.relationPredicate)); 571 osmWriter.footer(); 572 osmWriter.flush(); 573 574 for (Parameter parameter : parameters) { 575 if (!parameter.isOsm()) 576 continue; 577 contents = new ArrayList<>(); 578 osmWriter.header(); 579 pObjects = parameter.getParameterObjects(); 580 for (OsmPrimitive primitive : pObjects) { 581 contents.add(primitive); 582 if (bbox == null) 583 bbox = new BBox(primitive.getBBox()); 584 else 585 bbox.addPrimitive(primitive, 0.0); 586 } 587 osmWriter.writeNodes(new SubclassFilteredCollection<OsmPrimitive, Node>(contents, OsmPrimitive.nodePredicate)); 588 osmWriter.writeWays(new SubclassFilteredCollection<OsmPrimitive, Way>(contents, OsmPrimitive.wayPredicate)); 589 osmWriter.writeRelations(new SubclassFilteredCollection<OsmPrimitive, Relation>(contents, OsmPrimitive.relationPredicate)); 590 osmWriter.footer(); 591 osmWriter.flush(); 592 } 593 594 if (tracks) { 595 try (GpxWriter gpxWriter = new GpxWriter(printWriter)) { 596 GpxFilter gpxFilter = new GpxFilter(); 597 gpxFilter.initBboxFilter(bbox); 598 List<GpxLayer> gpxLayers = Main.map.mapView.getLayersOfType(GpxLayer.class); 599 for (GpxLayer gpxLayer : gpxLayers) { 600 gpxFilter.addGpxData(gpxLayer.data); 601 } 602 gpxWriter.write(gpxFilter.getGpxData()); 603 } catch (IOException e) { 604 Main.warn(e); 605 } 606 } 607 Utils.close(osmWriter); 608 synchronized (syncObj) { 609 if (currentCommand.asynchronous) { 610 tp.running = false; 611 syncObj.notifyAll(); 612 } 613 } 614 } 615 }); 616 617 // Read stdout stream 618 final DataSet currentDataSet = Main.main.getCurrentDataSet(); 619 final CommandLine that = this; 620 Thread osmParseThread = new Thread(new Runnable() { 621 @Override 622 public void run() { 623 try { 624 final OsmToCmd osmToCmd = new OsmToCmd(that, currentDataSet); 625 String commandName = currentCommand.name; 626 final InputStream inputStream = tp.process.getInputStream(); 627 osmToCmd.parseStream(inputStream); 628 final List<org.openstreetmap.josm.command.Command> cmdlist = osmToCmd.getCommandList(); 629 if (!cmdlist.isEmpty()) { 630 final SequenceCommand cmd = new SequenceCommand(commandName, cmdlist); 631 SwingUtilities.invokeLater(new Runnable() { 632 @Override 633 public void run() { 634 Main.main.undoRedo.add(cmd); 635 } 636 }); 637 } 638 } catch (Exception e) { 639 } 640 finally { 641 synchronized (syncObj) { 642 tp.running = false; 643 syncObj.notifyAll(); 644 } 645 } 646 } 647 648 }); 649 650 osmParseThread.start(); 651 osmWriteThread.start(); 652 653 synchronized (syncObj) { 654 try { 655 syncObj.wait(Main.pref.getInteger("commandline.timeout", 20000)); 656 } catch (InterruptedException e) { 657 } 658 } 659 if (tp.running) { 660 new Thread(new PleaseWaitRunnable(currentCommand.name) { 661 @Override 662 protected void realRun() { 663 try { 664 progressMonitor.indeterminateSubTask(null); 665 synchronized (syncObj) { 666 if (tp.running) 667 syncObj.wait(); 668 } 669 } catch (InterruptedException e) { 670 } 671 } 672 673 @Override 674 protected void cancel() { 675 synchronized (syncObj) { 676 tp.running = false; 677 tp.process.destroy(); 678 syncObj.notifyAll(); 679 endInput(); 680 } 681 } 682 683 @Override 684 protected void finish() { 685 } 686 }).start(); 687 } 688 endInput(); 689 } 691 690 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
r30859 r31646 220 220 221 221 if (cadastreJMenu == null) { 222 cadastreJMenu = menu.addMenu( marktr("Cadastre"), KeyEvent.VK_C, menu.getDefaultMenuPos(), ht("/Plugin/CadastreFr"));222 cadastreJMenu = menu.addMenu("Cadastre", tr("Cadastre"), KeyEvent.VK_C, menu.getDefaultMenuPos(), ht("/Plugin/CadastreFr")); 223 223 JosmAction grab = new MenuActionGrab(); 224 224 JMenuItem menuGrab = new JMenuItem(grab); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java
r30737 r31646 2 2 3 3 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 import static org.openstreetmap.josm.tools.I18n. marktr;4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.awt.event.KeyEvent; … … 186 186 GuiHelper.runInEDTAndWait(new Runnable() { 187 187 @Override public void run() { 188 czechMenu = Main.main.menu.addMenu( marktr("Address"), KeyEvent.VK_Z, Main.main.menu.getDefaultMenuPos(), ht("/Plugin/CzechAddress"));188 czechMenu = Main.main.menu.addMenu("Address", tr("Address"), KeyEvent.VK_Z, Main.main.menu.getDefaultMenuPos(), ht("/Plugin/CzechAddress")); 189 189 menuItems.add(MainMenu.add(czechMenu, new PointManipulatorAction())); 190 190 menuItems.add(MainMenu.add(czechMenu, new GroupManipulatorAction())); -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetPlugin.java
r30738 r31646 1 1 package iodb; 2 2 3 import static org.openstreetmap.josm.tools.I18n. marktr;3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 5 import java.awt.event.KeyEvent; … … 41 41 int version = Version.getInstance().getVersion(); 42 42 JMenu offsetMenu = version < 5803 43 ? Main.main.menu.addMenu( marktr("Offset"), KeyEvent.VK_O, 6, "help")43 ? Main.main.menu.addMenu("Offset", tr("Offset"), KeyEvent.VK_O, 6, "help") 44 44 : Main.main.menu.imageryMenu; 45 45 offsetMenu.add(getAction); -
applications/editors/josm/plugins/public_transport/src/public_transport/PublicTransportPlugin.java
r29854 r31646 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n. marktr;3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 5 import java.awt.event.KeyEvent; … … 28 28 29 29 if (jMenu == null) 30 jMenu = menu.addMenu( marktr("Public Transport"), KeyEvent.VK_COMMA, menu.getDefaultMenuPos(), "help");30 jMenu = menu.addMenu("Public Transport", tr("Public Transport"), KeyEvent.VK_COMMA, menu.getDefaultMenuPos(), "help"); 31 31 else 32 32 jMenu.removeAll(); -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
r30361 r31646 29 29 30 30 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 31 import static org.openstreetmap.josm.tools.I18n.marktr;32 31 import static org.openstreetmap.josm.tools.I18n.tr; 33 32 … … 75 74 public RoutingMenu() { 76 75 MainMenu mm = Main.main.menu; 77 menu = mm.addMenu( marktr("Routing"), KeyEvent.VK_O, mm.getDefaultMenuPos(), ht("/Plugin/Routing"));76 menu = mm.addMenu("Routing", tr("Routing"), KeyEvent.VK_O, mm.getDefaultMenuPos(), ht("/Plugin/Routing")); 78 77 79 78 startMI = new JMenuItem(tr("Add routing layer")); -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsMenu.java
r30738 r31646 3 3 4 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 import static org.openstreetmap.josm.tools.I18n.marktr;6 5 import static org.openstreetmap.josm.tools.I18n.tr; 7 6 … … 39 38 public SdsMenu(final SeparateDataStorePlugin thePlugin) { 40 39 MainMenu mm = Main.main.menu; 41 menu = mm.addMenu( marktr("SDS"), KeyEvent.VK_S, mm.getDefaultMenuPos(), null);40 menu = mm.addMenu("SDS", tr("SDS"), KeyEvent.VK_S, mm.getDefaultMenuPos(), null); 42 41 saveItem = new JMenuItem(new SdsSaveAction()); 43 42 menu.add(saveItem); -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/TrustOSMplugin.java
r30745 r31646 2 2 3 3 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 import static org.openstreetmap.josm.tools.I18n. marktr;4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.awt.event.KeyEvent; … … 257 257 258 258 if (gpgJMenu == null) { 259 gpgJMenu = menu.addMenu( marktr("GPG"), KeyEvent.VK_B, menu.getDefaultMenuPos(), ht("/Plugin/TrustOSM"));259 gpgJMenu = menu.addMenu("GPG", tr("GPG"), KeyEvent.VK_B, menu.getDefaultMenuPos(), ht("/Plugin/TrustOSM")); 260 260 gpgJMenu.add(new JMenuItem(new ExportSigsAction())); 261 261 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPlugin.java
r30639 r31646 2 2 3 3 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 4 import static org.openstreetmap.josm.tools.I18n.tr; 6 5 … … 78 77 79 78 private void createMenusAndShortCuts() { 80 VMenu = Main.main.menu.addMenu( marktr("Video"), KeyEvent.VK_Q, Main.main.menu.getDefaultMenuPos(),ht("/Plugin/Videomapping"));79 VMenu = Main.main.menu.addMenu("Video", tr("Video"), KeyEvent.VK_Q, Main.main.menu.getDefaultMenuPos(),ht("/Plugin/Videomapping")); 81 80 VMenu.setEnabled(false); 82 81 VAdd= new JosmAction(tr("Import Video"),"videomapping",tr("Sync a video against this GPS track"),null,false) {
Note:
See TracChangeset
for help on using the changeset viewer.
