Changeset 34498 in osm for applications/editors/josm/plugins/CommandLine/src
- Timestamp:
- 2018-08-18T03:17:09+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/CommandLine/src/CommandLine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java
r34342 r34498 33 33 import javax.swing.SwingUtilities; 34 34 35 import org.openstreetmap.josm.Main;36 35 import org.openstreetmap.josm.actions.mapmode.MapMode; 37 36 import org.openstreetmap.josm.command.SequenceCommand; 37 import org.openstreetmap.josm.data.Preferences; 38 import org.openstreetmap.josm.data.UndoRedoHandler; 38 39 import org.openstreetmap.josm.data.imagery.ImageryInfo; 39 40 import org.openstreetmap.josm.data.osm.BBox; … … 57 58 import org.openstreetmap.josm.plugins.Plugin; 58 59 import org.openstreetmap.josm.plugins.PluginInformation; 60 import org.openstreetmap.josm.spi.preferences.Config; 59 61 import org.openstreetmap.josm.tools.HttpClient; 60 62 import org.openstreetmap.josm.tools.Logging; … … 75 77 protected MapMode previousMode; 76 78 77 static final String pluginDir = Main.pref.getPluginsDirectory().getAbsolutePath() + "/CommandLine/";79 static final String pluginDir = Preferences.main().getPluginsDirectory().getAbsolutePath() + "/CommandLine/"; 78 80 79 81 public CommandLine(PluginInformation info) { … … 148 150 commands = (new Loader(getPluginDirs().getUserDataDirectory(false))).load(); 149 151 if (commands.isEmpty()) { 150 if (!GraphicsEnvironment.isHeadless() && JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(Main .parent,152 if (!GraphicsEnvironment.isHeadless() && JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), 151 153 tr("No command has been found. Would you like to download and install default commands now?"), 152 154 tr("No command found"), JOptionPane.YES_NO_CANCEL_OPTION)) { … … 154 156 downloadAndInstallDefaultCommands(); 155 157 commands = (new Loader(getPluginDirs().getUserDataDirectory(false))).load(); 156 JOptionPane.showMessageDialog(Main .parent, tr("Default commands have been successfully installed"),158 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Default commands have been successfully installed"), 157 159 tr("Success"), JOptionPane.INFORMATION_MESSAGE); 158 160 } catch (IOException e) { 159 161 Logging.warn(e); 160 JOptionPane.showMessageDialog(Main .parent,162 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 161 163 tr("Failed to download and install default commands.\n\nError: {0}", e.getMessage()), 162 164 tr("Warning"), JOptionPane.WARNING_MESSAGE); … … 170 172 171 173 private void downloadAndInstallDefaultCommands() throws IOException { 172 String url = Main.pref.get("commandline.default.commands.url",174 String url = Config.getPref().get("commandline.default.commands.url", 173 175 "https://github.com/Foxhind/JOSM-CommandLine-commands/archive/master.zip"); 174 176 try (ZipInputStream zis = new ZipInputStream(HttpClient.create(new URL(url)).connect().getContent(), StandardCharsets.UTF_8)) { … … 256 258 break; 257 259 case USERNAME: 258 loadParameter( Main.pref.get("osm-server.username", null), true);260 loadParameter(Config.getPref().get("osm-server.username", null), true); 259 261 action = new DummyAction(this); 260 262 break; … … 613 615 if (!cmdlist.isEmpty()) { 614 616 final SequenceCommand cmd = new SequenceCommand(commandName, cmdlist); 615 SwingUtilities.invokeLater(() -> Main.main.undoRedo.add(cmd));617 SwingUtilities.invokeLater(() -> UndoRedoHandler.getInstance().add(cmd)); 616 618 } 617 619 } catch (Exception e) { … … 630 632 synchronized (syncObj) { 631 633 try { 632 syncObj.wait( Main.pref.getInt("commandline.timeout", 20000));634 syncObj.wait(Config.getPref().getInt("commandline.timeout", 20000)); 633 635 } catch (InterruptedException e) { 634 636 Logging.warn(e); -
applications/editors/josm/plugins/CommandLine/src/CommandLine/PointAction.java
r33984 r34498 16 16 import javax.swing.JOptionPane; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.actions.mapmode.MapMode; 20 19 import org.openstreetmap.josm.data.coor.LatLon; … … 87 86 coor = nearestNode.getCoor(); 88 87 if (coor.isOutSideWorld()) { 89 JOptionPane.showMessageDialog(Main .parent, tr("Can not draw outside of the world."));88 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Can not draw outside of the world.")); 90 89 return; 91 90 }
Note:
See TracChangeset
for help on using the changeset viewer.