Changeset 12792 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2017-09-08T22:02:38+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12790 r12792 34 34 import java.util.Locale; 35 35 import java.util.Map; 36 import java.util.Objects; 36 37 import java.util.Optional; 37 38 import java.util.Set; … … 61 62 import org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager; 62 63 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; 64 import org.openstreetmap.josm.CLIModule; 63 65 import org.openstreetmap.josm.Main; 64 66 import org.openstreetmap.josm.actions.DeleteAction; … … 85 87 import org.openstreetmap.josm.data.osm.UserInfo; 86 88 import org.openstreetmap.josm.data.osm.search.SearchMode; 89 import org.openstreetmap.josm.data.projection.ProjectionCLI; 87 90 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileSource; 88 91 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper; … … 163 166 * Command-line arguments used to run the application. 164 167 */ 165 private static final List<String> COMMAND_LINE_ARGS = new ArrayList<>();168 private static List<String> commandLineArgs; 166 169 167 170 /** … … 230 233 public void layerAdded(LayerAddEvent e) { 231 234 // Do nothing 235 } 236 }; 237 238 private static final List<CLIModule> cliModules = new ArrayList<>(); 239 240 /** 241 * Default JOSM command line interface. 242 * <p> 243 * Runs JOSM and performs some action, depending on the options and positional 244 * arguments. 245 */ 246 public static final CLIModule JOSM_CLI_MODULE = new CLIModule() { 247 @Override 248 public String getActionKeyword() { 249 return "runjosm"; 250 } 251 252 @Override 253 public void processArguments(String[] argArray) { 254 ProgramArguments args = null; 255 // construct argument table 256 try { 257 args = new ProgramArguments(argArray); 258 } catch (IllegalArgumentException e) { 259 System.err.println(e.getMessage()); 260 System.exit(1); 261 } 262 mainJOSM(args); 232 263 } 233 264 }; … … 256 287 } 257 288 }; 289 290 static { 291 registerCLIModue(JOSM_CLI_MODULE); 292 registerCLIModue(ProjectionCLI.INSTANCE); 293 } 294 295 /** 296 * Register a command line interface module. 297 * @param module the module 298 * @since 12792 299 */ 300 public static void registerCLIModue(CLIModule module) { 301 cliModules.add(module); 302 } 258 303 259 304 /** … … 488 533 */ 489 534 public static List<String> getCommandLineArgs() { 490 return Collections.unmodifiableList( COMMAND_LINE_ARGS);535 return Collections.unmodifiableList(commandLineArgs); 491 536 } 492 537 … … 766 811 public static void main(final String[] argArray) { 767 812 I18n.init(); 768 769 ProgramArguments args = null; 770 // construct argument table 771 try { 772 args = new ProgramArguments(argArray); 773 } catch (IllegalArgumentException e) { 774 System.err.println(e.getMessage()); 775 System.exit(1); 776 return; 777 } 813 commandLineArgs = Arrays.asList(Arrays.copyOf(argArray, argArray.length)); 814 815 if (argArray.length > 0) { 816 String moduleStr = argArray[0]; 817 for (CLIModule module : cliModules) { 818 if (Objects.equals(moduleStr, module.getActionKeyword())) { 819 String[] argArrayCdr = Arrays.copyOfRange(argArray, 1, argArray.length); 820 module.processArguments(argArrayCdr); 821 return; 822 } 823 } 824 } 825 // no module specified, use default (josm) 826 JOSM_CLI_MODULE.processArguments(argArray); 827 } 828 829 /** 830 * Main method to run the JOSM GUI. 831 * @param args program arguments 832 */ 833 public static void mainJOSM(ProgramArguments args) { 778 834 779 835 if (!GraphicsEnvironment.isHeadless()) { … … 821 877 return; 822 878 } 823 824 COMMAND_LINE_ARGS.addAll(Arrays.asList(argArray));825 879 826 880 boolean skipLoadingPlugins = args.hasOption(Option.SKIP_PLUGINS); -
trunk/src/org/openstreetmap/josm/gui/ProgramArguments.java
r12633 r12792 113 113 */ 114 114 private void buildCommandLineArgumentMap(String... args) { 115 LongOpt[] los = Stream.of(Option.values()).map(Option::toLongOpt).toArray( i -> new LongOpt[i]);115 LongOpt[] los = Stream.of(Option.values()).map(Option::toLongOpt).toArray(LongOpt[]::new); 116 116 117 117 Getopt g = new Getopt("JOSM", args, "hv", los); -
trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java
r12735 r12792 27 27 import org.openstreetmap.josm.data.coor.LatLon; 28 28 import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager; 29 import org.openstreetmap.josm.data.coor.conversion.LatLonParser; 29 30 import org.openstreetmap.josm.gui.ExtendedDialog; 30 31 import org.openstreetmap.josm.gui.util.WindowGeometry; … … 245 246 LatLon latLon; 246 247 try { 247 latLon = LatLon .parse(tfLatLon.getText());248 latLon = LatLonParser.parse(tfLatLon.getText()); 248 249 if (!LatLon.isValidLat(latLon.lat()) || !LatLon.isValidLon(latLon.lon())) { 249 250 latLon = null;
Note:
See TracChangeset
for help on using the changeset viewer.