Changeset 19103 in josm
- Timestamp:
- 2024-06-13T00:23:03+02:00 (5 months ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r18399 r19103 102 102 103 103 private final GpxTrackChangeListener proxy = e -> invalidate(); 104 private boolean modified, updating, initializing; 104 private boolean modified; 105 private boolean updating; 106 private boolean initializing; 105 107 private boolean suppressedInvalidate; 106 108 … … 109 111 * @see #getTracks() 110 112 */ 111 public final Collection<IGpxTrack> tracks = new ListeningCollection< IGpxTrack>(privateTracks, this::invalidate) {113 public final Collection<IGpxTrack> tracks = new ListeningCollection<>(privateTracks, this::invalidate) { 112 114 113 115 @Override … … 418 420 OptionalLong i1 = getTrackFirstWaypointMin(t1); 419 421 OptionalLong i2 = getTrackFirstWaypointMin(t2); 420 boolean i1absent = !i1.isPresent();421 boolean i2absent = !i2.isPresent();422 boolean i1absent = i1.isEmpty(); 423 boolean i2absent = i2.isEmpty(); 422 424 if (i1absent && i2absent) { 423 425 return 0; … … 537 539 HashMap<String, Object> attrs = new HashMap<>(trk.getAttributes()); 538 540 ensureUniqueName(attrs, counts, srcLayerName); 539 return new GpxTrack( Arrays.asList(seg), attrs);541 return new GpxTrack(Collections.singletonList(seg), attrs); 540 542 })) 541 543 .collect(Collectors.toCollection(ArrayList<GpxTrack>::new)); … … 548 550 * Split tracks into layers, the result is one layer for each track. 549 551 * If this layer currently has only one GpxTrack this is a no-operation. 550 * 552 * <p> 551 553 * The new GpxLayers are added to the LayerManager, the original GpxLayer 552 554 * is untouched as to preserve potential route or wpt parts. … … 1258 1260 */ 1259 1261 public static class XMLNamespace { 1260 private final String uri, prefix; 1262 private final String uri; 1263 private final String prefix; 1261 1264 private String location; 1262 1265 -
trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java
r18208 r19103 229 229 stream(prefix, key) 230 230 .collect(Collectors.toList()) //needs to be collected to avoid concurrent modification 231 .forEach( e -> super.remove(e));231 .forEach(super::remove); 232 232 } 233 233 … … 240 240 .filter(e -> Objects.equals(prefix, e.getPrefix())) 241 241 .collect(Collectors.toList()) //needs to be collected to avoid concurrent modification 242 .forEach( e -> super.remove(e));242 .forEach(super::remove); 243 243 } 244 244 -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r18989 r19103 80 80 */ 81 81 @Override 82 public finalString getTypeString() {82 public String getTypeString() { 83 83 return typeString; 84 84 } … … 143 143 */ 144 144 @Override 145 public finalString getCategoryString() {145 public String getCategoryString() { 146 146 return category; 147 147 } … … 152 152 */ 153 153 @Override 154 public finalString getDescription() {154 public String getDescription() { 155 155 return description; 156 156 } … … 163 163 */ 164 164 @Override 165 public finalImageIcon getIcon(ImageSizes size) {165 public ImageIcon getIcon(ImageSizes size) { 166 166 return iconCache 167 167 .computeIfAbsent(size, x -> Collections.synchronizedMap(new EnumMap<>(ImageryCategory.class))) -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
r17975 r19103 70 70 */ 71 71 public static ThreadPoolExecutor getNewThreadPoolExecutor(String nameFormat, int workers) { 72 return getNewThreadPoolExecutor(nameFormat, workers, HOST_LIMIT.get() .intValue());72 return getNewThreadPoolExecutor(nameFormat, workers, HOST_LIMIT.get()); 73 73 } 74 74 … … 97 97 */ 98 98 public static ThreadPoolExecutor getNewThreadPoolExecutor(String name) { 99 return getNewThreadPoolExecutor(name, THREAD_LIMIT.get() .intValue());99 return getNewThreadPoolExecutor(name, THREAD_LIMIT.get()); 100 100 } 101 101 -
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/MVTTile.java
r18478 r19103 56 56 for (ProtobufRecord protoBufRecord : protobufRecords) { 57 57 if (protoBufRecord.getField() == Layer.LAYER_FIELD) { 58 try (ProtobufParser tParser = new ProtobufParser(protoBufRecord.getBytes())) { 58 try (protoBufRecord; // Cleanup bytes 59 ProtobufParser tParser = new ProtobufParser(protoBufRecord.getBytes())) { 59 60 this.layers.add(new Layer(tParser.allRecords())); 60 61 } catch (IOException e) { 61 62 Logging.error(e); 62 } finally {63 // Cleanup bytes64 protoBufRecord.close();65 63 } 66 64 } -
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/Layers.java
r19080 r19103 59 59 } 60 60 61 private static final String DEFAULT_COLOR = "#000000"; 61 62 private static final char SEMI_COLON = ';'; 62 63 private static final Pattern CURLY_BRACES = Pattern.compile("(\\{(.*?)})"); … … 186 187 // line-blur, default 0 (px) 187 188 // line-color, default #000000, disabled by line-pattern 188 final String color = paintObject.getString("line-color", "#000000");189 final String color = paintObject.getString("line-color", DEFAULT_COLOR); 189 190 sb.append(StyleKeys.COLOR).append(':').append(color).append(SEMI_COLON); 190 191 // line-opacity, default 1 (0-1) … … 210 211 if (paintObject.containsKey("line-dasharray")) { 211 212 final JsonArray dashArray = paintObject.getJsonArray("line-dasharray"); 212 sb.append(StyleKeys.DASHES).append(':') ;213 sb.append(dashArray.stream().filter(JsonNumber.class::isInstance).map(JsonNumber.class::cast)214 .map(JsonNumber::toString).collect(Collectors.joining(",")));215 sb.append(SEMI_COLON);213 sb.append(StyleKeys.DASHES).append(':') 214 .append(dashArray.stream().filter(JsonNumber.class::isInstance).map(JsonNumber.class::cast) 215 .map(JsonNumber::toString).collect(Collectors.joining(","))) 216 .append(SEMI_COLON); 216 217 } 217 218 // line-gap-width … … 235 236 // circle-blur 236 237 // circle-color 237 .append("symbol-fill-color:").append(paintObject.getString("circle-color", "#000000")).append(SEMI_COLON);238 .append("symbol-fill-color:").append(paintObject.getString("circle-color", DEFAULT_COLOR)).append(SEMI_COLON); 238 239 // circle-opacity 239 240 final JsonNumber fillOpacity = paintObject.getJsonNumber("circle-opacity"); … … 246 247 // circle-sort-key 247 248 // circle-stroke-color 248 .append("symbol-stroke-color:").append(paintObject.getString("circle-stroke-color", "#000000")).append(SEMI_COLON);249 .append("symbol-stroke-color:").append(paintObject.getString("circle-stroke-color", DEFAULT_COLOR)).append(SEMI_COLON); 249 250 // circle-stroke-opacity 250 251 final JsonNumber strokeOpacity = paintObject.getJsonNumber("circle-stroke-opacity"); … … 277 278 } 278 279 Matcher matcher = CURLY_BRACES.matcher(layoutObject.getString("icon-image")); 279 StringBu ffer stringBuffer = new StringBuffer();280 StringBuilder stringBuffer = new StringBuilder(); 280 281 int previousMatch; 281 282 if (matcher.lookingAt()) { … … 299 300 stringBuffer.append('"'); 300 301 } 301 StringBu ffer tail = new StringBuffer();302 StringBuilder tail = new StringBuilder(); 302 303 matcher.appendTail(tail); 303 304 if (tail.length() > 0) { … … 375 376 .orElseGet(() -> fontMatches.stream().filter(font -> font.getFamily().equals(fontString)).findAny().orElse(null)))); 376 377 if (setFont != null) { 377 sb.append(StyleKeys.FONT_FAMILY).append(':').append('"').append(setFont.getFamily()).append('"').append(SEMI_COLON) ;378 sb.append(StyleKeys.FONT_WEIGHT).append(':').append(setFont.isBold() ? "bold" : "normal").append(SEMI_COLON);379 sb.append(StyleKeys.FONT_STYLE).append(':').append(setFont.isItalic() ? "italic" : "normal").append(SEMI_COLON);378 sb.append(StyleKeys.FONT_FAMILY).append(':').append('"').append(setFont.getFamily()).append('"').append(SEMI_COLON) 379 .append(StyleKeys.FONT_WEIGHT).append(':').append(setFont.isBold() ? "bold" : "normal").append(SEMI_COLON) 380 .append(StyleKeys.FONT_STYLE).append(':').append(setFont.isItalic() ? "italic" : "normal").append(SEMI_COLON); 380 381 break; 381 382 } … … 439 440 // fill-antialias 440 441 // fill-color 441 .append(StyleKeys.FILL_COLOR).append(':').append(paintObject.getString(StyleKeys.FILL_COLOR, "#000000")).append(SEMI_COLON);442 .append(StyleKeys.FILL_COLOR).append(':').append(paintObject.getString(StyleKeys.FILL_COLOR, DEFAULT_COLOR)).append(SEMI_COLON); 442 443 // fill-opacity 443 444 final JsonNumber opacity = paintObject.getJsonNumber(StyleKeys.FILL_OPACITY); … … 445 446 // fill-outline-color 446 447 .append(StyleKeys.COLOR).append(':').append(paintObject.getString("fill-outline-color", 447 paintObject.getString("fill-color", "#000000"))).append(SEMI_COLON);448 paintObject.getString("fill-color", DEFAULT_COLOR))).append(SEMI_COLON); 448 449 // fill-pattern 449 450 // fill-sort-key -
trunk/src/org/openstreetmap/josm/data/osm/OsmData.java
r17862 r19103 283 283 */ 284 284 default void clearHighlightedVirtualNodes() { 285 setHighlightedVirtualNodes(new ArrayList< WaySegment>());285 setHighlightedVirtualNodes(new ArrayList<>()); 286 286 } 287 287 … … 290 290 */ 291 291 default void clearHighlightedWaySegments() { 292 setHighlightedWaySegments(new ArrayList< WaySegment>());292 setHighlightedWaySegments(new ArrayList<>()); 293 293 } 294 294 … … 327 327 * Replies an unmodifiable collection of primitives currently selected 328 328 * in this dataset, except deleted ones. May be empty, but not null. 329 * 329 * <p> 330 330 * When iterating through the set it is ordered by the order in which the primitives were added to the selection. 331 331 * … … 339 339 * Replies an unmodifiable collection of primitives currently selected 340 340 * in this dataset, including deleted ones. May be empty, but not null. 341 * 341 * <p> 342 342 * When iterating through the set it is ordered by the order in which the primitives were added to the selection. 343 343 * -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r19050 r19103 397 397 398 398 /** 399 * Asks user to migrate to OpenWebStart400 * @param url download URL401 * @since 17679402 */403 public static void askMigrateWebStart(String url) {404 // CHECKSTYLE.OFF: LineLength405 StringBuilder content = new StringBuilder(tr("You are running an <b>Oracle</b> implementation of Java WebStart."))406 .append("<br><br>")407 .append(tr("It was for years the recommended way to use JOSM. Oracle removed WebStart from Java 11,<br>but the open source community reimplemented the Java Web Start technology as a new product: <b>OpenWebStart</b>"))408 .append("<br><br>")409 .append(tr("OpenWebStart is now considered mature enough by JOSM developers to ask everyone to move away from an Oracle implementation,<br>allowing you to benefit from a recent version of Java, and allowing JOSM developers to move forward by planning the Java {0} migration.", "11"))410 .append("<br><br>")411 .append(tr("Would you like to <b>download OpenWebStart now</b>? (Please do!)"));412 askUpdate(tr("Outdated Java WebStart version"), tr("Update to OpenWebStart"), "askUpdateWebStart", /* ICON */"presets/transport/rocket", content, url);413 // CHECKSTYLE.ON: LineLength414 }415 416 /**417 399 * Tells the user that a sanity check failed 418 400 * @param title The title of the message to show -
trunk/src/org/openstreetmap/josm/gui/MainInitialization.java
r19050 r19103 72 72 new InitializationTask(tr("Starting file watcher"), FileWatcher.getDefaultInstance()::start), 73 73 new InitializationTask(tr("Executing platform startup hook"), 74 () -> PlatformManager.getPlatform().startupHook(MainApplication::askUpdateJava, 75 MainApplication::askMigrateWebStart, MainApplication::sanityCheckFailed)), 74 () -> PlatformManager.getPlatform().startupHook(MainApplication::askUpdateJava, MainApplication::sanityCheckFailed)), 76 75 new InitializationTask(tr("Building main menu"), application::initializeMainWindow), 77 76 new InitializationTask(tr("Updating user interface"), () -> { -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r18287 r19103 79 79 /** 80 80 * used by {@link ChooseTrackVisibilityAction} to determine which tracks to show/hide 81 * 81 * <p> 82 82 * Call {@link #invalidate()} after each change! 83 * 83 * <p> 84 84 * TODO: Make it private, make it respond to track changes. 85 85 */ … … 146 146 if (data == null) 147 147 return null; 148 Color[] c = data.getTracks().stream().map( t -> t.getColor()).distinct().toArray(Color[]::new);148 Color[] c = data.getTracks().stream().map(IGpxTrack::getColor).distinct().toArray(Color[]::new); 149 149 return c.length == 1 ? c[0] : null; //only return if exactly one distinct color present 150 150 } … … 210 210 211 211 if (!data.getTracks().isEmpty()) { 212 String tdSep = "</td><td>"; 212 213 info.append("<table><thead align='center'><tr><td colspan='5'>") 213 214 .append(trn("{0} track, {1} track segments", "{0} tracks, {1} track segments", … … 215 216 data.getTrackSegsCount(), data.getTrackSegsCount())) 216 217 .append("</td></tr><tr align='center'><td>").append(tr("Name")) 217 .append( "</td><td>").append(tr("Description"))218 .append( "</td><td>").append(tr("Timespan"))219 .append( "</td><td>").append(tr("Length"))220 .append( "</td><td>").append(tr("Number of<br/>Segments"))221 .append( "</td><td>").append(tr("URL"))218 .append(tdSep).append(tr("Description")) 219 .append(tdSep).append(tr("Timespan")) 220 .append(tdSep).append(tr("Length")) 221 .append(tdSep).append(tr("Number of<br/>Segments")) 222 .append(tdSep).append(tr("URL")) 222 223 .append("</td></tr></thead>"); 223 224 224 225 for (IGpxTrack trk : data.getTracks()) { 225 info.append("<tr><td>") ;226 info.append(trk.getAttributes().getOrDefault(GpxConstants.GPX_NAME, ""));227 info.append("</td><td>");228 info.append(trk.getAttributes().getOrDefault(GpxConstants.GPX_DESC, ""));229 info.append("</td><td>");230 info.append(getTimespanForTrack(trk));231 info.append("</td><td>");232 info.append(SystemOfMeasurement.getSystemOfMeasurement().getDistText(trk.length()));233 info.append("</td><td>");234 info.append(trk.getSegments().size());235 info.append("</td><td>");226 info.append("<tr><td>") 227 .append(trk.getAttributes().getOrDefault(GpxConstants.GPX_NAME, "")) 228 .append(tdSep) 229 .append(trk.getAttributes().getOrDefault(GpxConstants.GPX_DESC, "")) 230 .append(tdSep) 231 .append(getTimespanForTrack(trk)) 232 .append(tdSep) 233 .append(SystemOfMeasurement.getSystemOfMeasurement().getDistText(trk.length())) 234 .append(tdSep) 235 .append(trk.getSegments().size()) 236 .append(tdSep); 236 237 if (trk.getAttributes().containsKey("url")) { 237 238 info.append(trk.get("url")); … … 287 288 if (isExpertMode && expert.stream().anyMatch(Action::isEnabled)) { 288 289 entries.add(SeparatorLayerAction.INSTANCE); 289 e xpert.stream().filter(Action::isEnabled).forEach(entries::add);290 entries.addAll(expert.stream().filter(Action::isEnabled).collect(Collectors.toList())); 290 291 } 291 292 … … 621 622 622 623 private void jumpToNext(List<IGpxTrackSegment> segments) { 623 if (segments.isEmpty()) { 624 return; 625 } else if (currentSegment == null) { 624 if (!segments.isEmpty() && currentSegment == null) { 626 625 currentSegment = segments.get(0); 627 626 MainApplication.getMap().mapView.zoomTo(currentSegment.getBounds()); 628 } else {627 } else if (!segments.isEmpty()) { 629 628 try { 630 629 int index = segments.indexOf(currentSegment); 631 630 currentSegment = segments.listIterator(index + 1).next(); 632 631 MainApplication.getMap().mapView.zoomTo(currentSegment.getBounds()); 633 } catch (IndexOutOfBoundsException | NoSuchElementException ignore) {634 Logging.trace( ignore);632 } catch (IndexOutOfBoundsException | NoSuchElementException exception) { 633 Logging.trace(exception); 635 634 } 636 635 } -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/TMSSettingsPanel.java
r15586 r19103 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.GridBagConstraints; 6 7 import java.awt.GridBagLayout; 7 8 … … 40 41 super(new GridBagLayout()); 41 42 minZoomLvl = new JSpinner(new SpinnerNumberModel( 42 Utils.clamp(TMSLayer.PROP_MIN_ZOOM_LVL.get() .intValue(), TMSLayer.MIN_ZOOM, TMSLayer.MAX_ZOOM),43 Utils.clamp(TMSLayer.PROP_MIN_ZOOM_LVL.get(), TMSLayer.MIN_ZOOM, TMSLayer.MAX_ZOOM), 43 44 TMSLayer.MIN_ZOOM, 44 45 TMSLayer.MAX_ZOOM, 1)); 45 46 maxZoomLvl = new JSpinner(new SpinnerNumberModel( 46 Utils.clamp(TMSLayer.PROP_MAX_ZOOM_LVL.get() .intValue(), TMSLayer.MIN_ZOOM, TMSLayer.MAX_ZOOM),47 Utils.clamp(TMSLayer.PROP_MAX_ZOOM_LVL.get(), TMSLayer.MIN_ZOOM, TMSLayer.MAX_ZOOM), 47 48 TMSLayer.MIN_ZOOM, 48 49 TMSLayer.MAX_ZOOM, 1)); … … 55 56 add(new JLabel(tr("Auto zoom by default: ")), GBC.std()); 56 57 add(GBC.glue(5, 0), GBC.std()); 57 add(autozoomActive, GBC.eol().fill(G BC.HORIZONTAL));58 add(autozoomActive, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 58 59 59 60 add(new JLabel(tr("Autoload tiles by default: ")), GBC.std()); 60 61 add(GBC.glue(5, 0), GBC.std()); 61 add(autoloadTiles, GBC.eol().fill(G BC.HORIZONTAL));62 add(autoloadTiles, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 62 63 63 64 add(new JLabel(tr("Min. zoom level: ")), GBC.std()); … … 71 72 add(new JLabel(tr("Add to slippymap chooser: ")), GBC.std()); 72 73 add(GBC.glue(5, 0), GBC.std()); 73 add(addToSlippyMapChosser, GBC.eol().fill(G BC.HORIZONTAL));74 add(addToSlippyMapChosser, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 74 75 75 76 add(new JLabel(tr("Maximum concurrent downloads: ")), GBC.std()); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java
r18871 r19103 107 107 } 108 108 109 /** 110 * A {@link LinkedHashSet} with the ability to get the "last" object. 111 * Note that this is unnecessary in Java 21 (see JEP 431). 112 * @param <E> The object type in the set 113 */ 109 114 static class HashSetWithLast<E> extends LinkedHashSet<E> { 110 115 private static final long serialVersionUID = 1L; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java
r18260 r19103 11 11 import java.awt.event.ComponentAdapter; 12 12 import java.awt.event.ComponentEvent; 13 import java.util. Arrays;13 import java.util.Collections; 14 14 import java.util.Comparator; 15 15 … … 104 104 addEntry(PresetListEntry.ENTRY_EMPTY); 105 105 106 usage.map.forEach((value, count) -> { 107 addEntry(new PresetListEntry(value, this)); 108 }); 106 usage.map.forEach((value, count) -> addEntry(new PresetListEntry(value, this))); 109 107 110 108 combobox = new JosmComboBox<>(dropDownModel); … … 125 123 126 124 autoCompModel = new AutoCompComboBoxModel<>(Comparator.<AutoCompletionItem>naturalOrder()); 127 getAllForKeys( Arrays.asList(key)).forEach(autoCompModel::addElement);125 getAllForKeys(Collections.singletonList(key)).forEach(autoCompModel::addElement); 128 126 getDisplayValues().forEach(s -> autoCompModel.addElement(new AutoCompletionItem(s, AutoCompletionPriority.IS_IN_STANDARD))); 129 127 … … 131 129 tf.setModel(autoCompModel); 132 130 133 if ( TaggingPresetItem.DISPLAY_KEYS_AS_HINT.get()) {131 if (Boolean.TRUE.equals(TaggingPresetItem.DISPLAY_KEYS_AS_HINT.get())) { 134 132 combobox.setHint(key); 135 133 } … … 218 216 if (sel instanceof String) { 219 217 // free edit. If the free edit corresponds to a known entry, use that entry. This is 220 // to avoid that we write a display_value to the tag's value, e g. if the user did an218 // to avoid that we write a display_value to the tag's value, e.g. if the user did an 221 219 // undo. 222 220 PresetListEntry selItem = dropDownModel.find((String) sel); -
trunk/src/org/openstreetmap/josm/gui/widgets/ChangesetIdTextField.java
r19080 r19103 79 79 id = 0; 80 80 try { 81 if (value.matches("http.*/changeset/ [0-9]+")) {81 if (value.matches("http.*/changeset/\\d+")) { 82 82 // full URL given, extract id 83 83 value = value.substring(value.lastIndexOf('/') + 1); -
trunk/src/org/openstreetmap/josm/gui/widgets/EditableList.java
r18211 r19103 34 34 * The list items 35 35 */ 36 public final JList<String> sourcesList = new JList<>(new DefaultListModel< String>());36 public final JList<String> sourcesList = new JList<>(new DefaultListModel<>()); 37 37 /** 38 38 * The add button -
trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBoxModel.java
r18173 r19103 31 31 */ 32 32 public void addAllStrings(List<String> strings) { 33 strings.forEach( s -> addElement(s));33 strings.forEach(this::addElement); 34 34 } 35 35 … … 41 41 public List<String> asStringList() { 42 42 List<String> list = new ArrayList<>(getSize()); 43 this.forEach( item -> list.add(item));43 this.forEach(list::add); 44 44 return list; 45 45 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBox.java
r18313 r19103 67 67 */ 68 68 public JosmComboBox() { 69 super(new JosmComboBoxModel< E>());69 super(new JosmComboBoxModel<>()); 70 70 init(); 71 71 } … … 85 85 * @deprecated use {@link #setPrototypeDisplayValue} instead. 86 86 */ 87 @Deprecated 87 @Deprecated(since = "18221", forRemoval = true) 88 88 public JosmComboBox(E prototypeDisplayValue) { 89 super(new JosmComboBoxModel< E>());89 super(new JosmComboBoxModel<>()); 90 90 setPrototypeDisplayValue(prototypeDisplayValue); 91 91 init(); … … 111 111 * @deprecated use {@link #setPrototypeDisplayValue} instead. 112 112 */ 113 @Deprecated 113 @Deprecated(since = "18221", forRemoval = true) 114 114 public JosmComboBox(JosmComboBoxModel<E> aModel, E prototypeDisplayValue) { 115 115 super(aModel); … … 126 126 */ 127 127 public JosmComboBox(E[] items) { 128 super(new JosmComboBoxModel< E>());128 super(new JosmComboBoxModel<>()); 129 129 init(); 130 130 for (E elem : items) { … … 206 206 /** 207 207 * Selects an item and/or sets text 208 * 208 * <p> 209 209 * Selects the item whose {@code toString()} equals {@code text}. If an item could not be found, 210 210 * selects nothing and sets the text anyway. … … 234 234 * Sets the hint to display when no text has been entered. 235 235 * 236 * @param hint the hint to set236 * @param newHint the hint to set 237 237 * @return the old hint 238 238 * @since 18221 239 239 */ 240 public String setHint(String hint) {241 String old = hint;242 this.hint = hint;240 public String setHint(String newHint) { 241 String old = this.hint; 242 this.hint = newHint; 243 243 JosmTextField tf = getEditorComponent(); 244 244 if (tf != null) 245 tf.setHint( hint);245 tf.setHint(newHint); 246 246 return old; 247 247 } … … 288 288 * <p> 289 289 * Set this to -1 to get the default behaviour back. 290 * 290 * <p> 291 291 * See also: #6157 292 292 * … … 310 310 public JList getList() { 311 311 Object popup = getUI().getAccessibleChild(this, 0); 312 if (popup != null && popupinstanceof javax.swing.plaf.basic.ComboPopup) {312 if (popup instanceof javax.swing.plaf.basic.ComboPopup) { 313 313 return ((javax.swing.plaf.basic.ComboPopup) popup).getList(); 314 314 } … … 421 421 int rowCount = Math.min(configMaximumRowCount, getItemCount()); 422 422 ListCellRenderer<? super E> r = jList.getCellRenderer(); // must take this from list, not combo: flatlaf bug 423 int i, h = 0; 423 int i; 424 int h = 0; 424 425 for (i = 0; i < rowCount; ++i) { 425 426 Component c = r.getListCellRendererComponent(jList, getModel().getElementAt(i), i, false, false); -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBoxModel.java
r18283 r19103 50 50 /** 51 51 * Returns the index of the specified element 52 * 52 * <p> 53 53 * Note: This is not part of the {@link javax.swing.ComboBoxModel} interface but is defined in 54 54 * {@link javax.swing.DefaultComboBoxModel}. … … 184 184 public void addAllElements(Collection<E> elems) { 185 185 int index0 = elements.size(); 186 elems.forEach( e -> doAddElement(e));186 elems.forEach(this::doAddElement); 187 187 int index1 = elements.size() - 1; 188 188 if (index0 <= index1) … … 269 269 270 270 /** A {@link Function} that builds an {@code <E>} from a {@code String}. */ 271 private Function<String, E> readE;271 private final Function<String, E> readE; 272 272 /** A {@code Function} that serializes {@code <E>} to a {@code String}. */ 273 private Function<E, String> writeE;273 private final Function<E, String> writeE; 274 274 275 275 /** -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java
r18871 r19103 77 77 * Create a MultiSplitLayout with a default model with a single 78 78 * Leaf node named "default". 79 * 79 * <p> 80 80 * #see setModel 81 81 */ … … 86 86 /** 87 87 * Create a MultiSplitLayout with the specified model. 88 * 88 * <p> 89 89 * #see setModel 90 90 * @param model model … … 127 127 128 128 private void firePCS(String propertyName, Object oldValue, Object newValue) { 129 if (!(oldValue != null && newValue != null &&oldValue.equals(newValue))) {129 if (!(oldValue != null && oldValue.equals(newValue))) { 130 130 pcs.firePropertyChange(propertyName, oldValue, newValue); 131 131 } … … 149 149 * property is a Leaf named "default". 150 150 * 151 * @param model the root of the tree of Split, Leaf, and Divider node151 * @param newModel the root of the tree of Split, Leaf, and Divider node 152 152 * @throws IllegalArgumentException if model is a Divider or null 153 153 * @see #getModel 154 154 */ 155 public void setModel(Node model) {156 if (( model == null) || (model instanceof Divider))155 public void setModel(Node newModel) { 156 if ((newModel == null) || (newModel instanceof Divider)) 157 157 throw new IllegalArgumentException("invalid model"); 158 Node oldModel = model;159 this.model = model;160 firePCS("model", oldModel, model);158 Node oldModel = this.model; 159 this.model = newModel; 160 firePCS("model", oldModel, newModel); 161 161 } 162 162 … … 270 270 return preferredComponentSize(root); 271 271 else if (root instanceof Divider) { 272 int dividerSize = getDividerSize();273 return new Dimension( dividerSize, dividerSize);272 int currentDividerSize = getDividerSize(); 273 return new Dimension(currentDividerSize, currentDividerSize); 274 274 } else { 275 275 Split split = (Split) root; … … 299 299 return (child != null) ? child.getMinimumSize() : new Dimension(0, 0); 300 300 } else if (root instanceof Divider) { 301 int dividerSize = getDividerSize();302 return new Dimension( dividerSize, dividerSize);301 int currentDividerSize = getDividerSize(); 302 return new Dimension(currentDividerSize, currentDividerSize); 303 303 } else { 304 304 Split split = (Split) root; … … 611 611 Iterator<Node> splitChildren = split.getChildren().iterator(); 612 612 Rectangle childBounds; 613 int dividerSize = getDividerSize();613 int currentDividerSize = getDividerSize(); 614 614 615 615 /* Layout the Split's child Nodes' along the X axis. The bounds … … 647 647 if (getFloatingDividers() && (dividerChild != null)) { 648 648 double dividerX = childBounds.getMaxX(); 649 Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, dividerSize);649 Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, currentDividerSize); 650 650 dividerChild.setBounds(dividerBounds); 651 651 } … … 680 680 if (getFloatingDividers() && (dividerChild != null)) { 681 681 double dividerY = childBounds.getMaxY(); 682 Rectangle dividerBounds = boundsWithYandHeight(bounds, dividerY, dividerSize);682 Rectangle dividerBounds = boundsWithYandHeight(bounds, dividerY, currentDividerSize); 683 683 dividerChild.setBounds(dividerBounds); 684 684 } … … 854 854 /** 855 855 * Returns the Split parent of this Node, or null. 856 * 856 * <p> 857 857 * This method isn't called getParent(), in order to avoid problems 858 858 * with recursive object creation when using XmlDecoder. … … 868 868 * Set the value of this Node's parent property. The default 869 869 * value of this property is null. 870 * 870 * <p> 871 871 * This method isn't called setParent(), in order to avoid problems 872 872 * with recursive object creation when using XmlEncoder. … … 936 936 937 937 private Node siblingAtOffset(int offset) { 938 Split parent = getParent();939 if ( parent == null)938 Split currentParent = getParent(); 939 if (currentParent == null) 940 940 return null; 941 List<Node> siblings = parent.getChildren();941 List<Node> siblings = currentParent.getChildren(); 942 942 int index = siblings.indexOf(this); 943 943 if (index == -1) … … 1050 1050 */ 1051 1051 public final Node lastWeightedChild() { 1052 List<Node> c hildren = getChildren();1052 List<Node> currentChildren = getChildren(); 1053 1053 Node weightedChild = null; 1054 for (Node child : c hildren) {1054 for (Node child : currentChildren) { 1055 1055 if (child.getWeight() > 0.0) { 1056 1056 weightedChild = child; … … 1063 1063 public String toString() { 1064 1064 int nChildren = getChildren().size(); 1065 StringBuilder sb = new StringBuilder("MultiSplitLayout.Split"); 1066 sb.append(isRowLayout() ? " ROW [" : " COLUMN [") 1067 .append(nChildren) 1068 .append((nChildren == 1) ? " child" : " children") 1069 .append("] ") 1070 .append(getBounds()); 1071 return sb.toString(); 1065 return "MultiSplitLayout.Split" + (isRowLayout() ? " ROW [" : " COLUMN [") + 1066 nChildren + 1067 ((nChildren == 1) ? " child" : " children") + 1068 "] " + 1069 getBounds(); 1072 1070 } 1073 1071 } -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r19080 r19103 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 31 32 */ 32 33 public class ChangesetQuery { 34 private static final String ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL = 35 marktr("Unexpected value for ''{0}'' in changeset query url, got {1}"); 36 private static final String DISPLAY_NAME = "display_name"; 33 37 34 38 /** … … 102 106 /** 103 107 * Restricts the query to changesets owned by the user with user name <code>username</code>. 104 * 108 * <p> 105 109 * Caveat: for historical reasons the username might not be unique! It is recommended to use 106 110 * {@link #forUser(int)} to restrict the query to a specific user. … … 226 230 throw new IllegalArgumentException(tr("Illegal latitude value for parameter ''{0}'', got {1}", "minLat", minLat)); 227 231 if (!LatLon.isValidLat(maxLat)) 228 throw new IllegalArgumentException(tr("Illegal l ongitude value for parameter ''{0}'', got {1}", "maxLat", maxLat));232 throw new IllegalArgumentException(tr("Illegal latitude value for parameter ''{0}'', got {1}", "maxLat", maxLat)); 229 233 230 234 return inBbox(new LatLon(minLon, minLat), new LatLon(maxLon, maxLat)); … … 356 360 sb.append('&'); 357 361 } 358 sb.append("time=").append(closedAfter) ;359 sb.append(',').append(createdBefore);362 sb.append("time=").append(closedAfter) 363 .append(',').append(createdBefore); 360 364 } else if (closedAfter != null) { 361 365 if (sb.length() > 0) { … … 369 373 sb.append('&'); 370 374 } 371 sb.append("open=").append( Boolean.toString(open));375 sb.append("open=").append(open); 372 376 } else if (closed != null) { 373 377 if (sb.length() > 0) { … … 433 437 protected int parseUid(String value) throws ChangesetQueryUrlException { 434 438 if (Utils.isStripEmpty(value)) 435 throw new ChangesetQueryUrlException( 436 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value)); 439 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, "uid", value)); 437 440 int id; 438 441 try { 439 442 id = Integer.parseInt(value); 440 443 if (id <= 0) 441 throw new ChangesetQueryUrlException( 442 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value)); 444 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, "uid", value)); 443 445 } catch (NumberFormatException e) { 444 throw new ChangesetQueryUrlException( 445 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value), e); 446 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, "uid", value), e); 446 447 } 447 448 return id; … … 450 451 protected boolean parseBoolean(String value, String parameter) throws ChangesetQueryUrlException { 451 452 if (Utils.isStripEmpty(value)) 452 throw new ChangesetQueryUrlException( 453 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value)); 453 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, parameter, value)); 454 454 switch (value) { 455 455 case "true": … … 458 458 return false; 459 459 default: 460 throw new ChangesetQueryUrlException( 461 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value)); 460 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, parameter, value)); 462 461 } 463 462 } … … 465 464 protected Instant parseDate(String value, String parameter) throws ChangesetQueryUrlException { 466 465 if (Utils.isStripEmpty(value)) 467 throw new ChangesetQueryUrlException( 468 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value)); 466 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, parameter, value)); 469 467 try { 470 468 return DateUtils.parseInstant(value); 471 469 } catch (UncheckedParseException e) { 472 throw new ChangesetQueryUrlException( 473 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value), e); 470 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, parameter, value), e); 474 471 } 475 472 } … … 478 475 String[] dates = value.split(",", -1); 479 476 if (dates.length == 0 || dates.length > 2) 480 throw new ChangesetQueryUrlException( 481 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "time", value)); 477 throw new ChangesetQueryUrlException(tr(ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL, "time", value)); 482 478 if (dates.length == 1) 483 479 return new Instant[]{parseDate(dates[0], "time")}; 484 else if (dates.length == 2) 485 return new Instant[]{parseDate(dates[0], "time"), parseDate(dates[1], "time")}; 486 return new Instant[]{}; 480 // This will always have length 2, due to the (dates.length == 0 || dates.length > 2) check above. 481 return new Instant[]{parseDate(dates[0], "time"), parseDate(dates[1], "time")}; 487 482 } 488 483 489 484 protected Collection<Long> parseLongs(String value) { 490 485 if (Utils.isEmpty(value)) { 491 return Collections. <Long>emptySet();486 return Collections.emptySet(); 492 487 } else { 493 488 return Stream.of(value.split(",", -1)).map(Long::valueOf).collect(Collectors.toSet()); … … 502 497 switch (k) { 503 498 case "uid": 504 if (queryParams.containsKey( "display_name"))499 if (queryParams.containsKey(DISPLAY_NAME)) 505 500 throw new ChangesetQueryUrlException( 506 501 tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''")); 507 502 csQuery.forUser(parseUid(queryParams.get("uid"))); 508 503 break; 509 case "display_name":504 case DISPLAY_NAME: 510 505 if (queryParams.containsKey("uid")) 511 506 throw new ChangesetQueryUrlException( 512 507 tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''")); 513 csQuery.forUser(queryParams.get( "display_name"));508 csQuery.forUser(queryParams.get(DISPLAY_NAME)); 514 509 break; 515 510 case "open": … … 566 561 /** 567 562 * Parses the changeset query given as URL query parameters and replies a {@link ChangesetQuery}. 568 * 569 * <code>query</code> is the query part of a API url for querying changesets,563 * <p> 564 * <code>query</code> is the query part of an API url for querying changesets, 570 565 * see <a href="http://wiki.openstreetmap.org/wiki/API_v0.6#Query:_GET_.2Fapi.2F0.6.2Fchangesets">OSM API</a>. 571 * 566 * <p> 572 567 * Example for a query string:<br> 573 568 * <pre> -
trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java
r15386 r19103 2 2 package org.openstreetmap.josm.io.session; 3 3 4 import java.io.IOException; 4 5 import java.io.OutputStream; 5 6 import java.io.OutputStreamWriter; 6 7 import java.io.PrintWriter; 8 import java.io.UncheckedIOException; 7 9 import java.io.Writer; 8 10 import java.nio.charset.StandardCharsets; … … 12 14 import org.openstreetmap.josm.io.OsmWriter; 13 15 import org.openstreetmap.josm.io.OsmWriterFactory; 16 import org.openstreetmap.josm.tools.JosmRuntimeException; 14 17 15 18 /** … … 40 43 public static void exportData(DataSet data, OutputStream out) { 41 44 Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8); 42 OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, data.getVersion());43 45 data.getReadLock().lock(); 44 try {46 try (OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, data.getVersion())) { 45 47 w.write(data); 46 48 w.flush(); 49 } catch (IOException e) { 50 // Catch needed since XmlWriter (parent of OsmWriter) has IOException in the method signature. 51 // It doesn't actually throw though. In other words, we should never hit this. 52 throw new UncheckedIOException(e); 47 53 } finally { 48 54 data.getReadLock().unlock(); -
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r18986 r19103 6 6 import java.awt.GraphicsEnvironment; 7 7 import java.awt.Toolkit; 8 import java.awt.event. KeyEvent;8 import java.awt.event.InputEvent; 9 9 import java.io.BufferedReader; 10 10 import java.io.File; … … 39 39 * Visitor to construct a PlatformHook from a given {@link Platform} object. 40 40 */ 41 PlatformVisitor<PlatformHook> CONSTRUCT_FROM_PLATFORM = new PlatformVisitor< PlatformHook>() {41 PlatformVisitor<PlatformHook> CONSTRUCT_FROM_PLATFORM = new PlatformVisitor<>() { 42 42 @Override 43 43 public PlatformHook visitUnixoid() { … … 65 65 * The preStartupHook will be called extremely early. It is 66 66 * guaranteed to be called before the GUI setup has started. 67 * 67 * <p> 68 68 * Reason: On OSX we need to inform the Swing libraries 69 69 * that we want to be integrated with the OS before we setup our GUI. … … 84 84 85 85 /** 86 * The startupHook will be called early, but after the GUI 87 * setup has started. 88 * 89 * Reason: On OSX we need to register some callbacks with the 90 * OS, so we'll receive events from the system menu. 91 * @param javaCallback Java expiration callback, providing GUI feedback 92 * @param webStartCallback WebStart migration callback, providing GUI feedback 93 * @since 18985 94 */ 95 default void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 96 SanityCheckCallback sanityCheckCallback) { 86 * The startupHook will be called early, but after the GUI 87 * setup has started. 88 * <p> 89 * Reason: On OSX we need to register some callbacks with the 90 * OS, so we'll receive events from the system menu. 91 * @param javaCallback Java expiration callback, providing GUI feedback 92 * @param sanityCheckCallback Sanity check callback, providing GUI feedback 93 * @since 18985 94 */ 95 default void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) { 97 96 startupSanityChecks(sanityCheckCallback); 98 97 } 99 98 100 99 /** 101 * The openURL hook will be used to open a nURL in the100 * The openURL hook will be used to open a URL in the 102 101 * default web browser. 103 102 * @param url The URL to open … … 111 110 * from the config, but before any shortcuts are read from 112 111 * it or registered from within the application. 113 * 112 * <p> 114 113 * Please note that you are not allowed to register any 115 114 * shortcuts from this hook, but only "systemCuts"! 116 * 115 * <p> 117 116 * BTW: SystemCuts should be named "system:<whatever>", 118 117 * and it'd be best if you'd recycle the names already used 119 * by the Windows and OSX hooks. Especially the lat er has118 * by the Windows and OSX hooks. Especially the latter has 120 119 * really many of them. 121 * 120 * <p> 122 121 * You should also register any and all shortcuts that the 123 * operati onsystem handles itself to block JOSM from trying122 * operating system handles itself to block JOSM from trying 124 123 * to use them---as that would just not work. Call setAutomatic 125 124 * on them to prevent the keyboard preferences from allowing the … … 260 259 default int getMenuShortcutKeyMaskEx() { 261 260 // To remove when switching to Java 10+, and use Toolkit.getMenuShortcutKeyMaskEx instead 262 return KeyEvent.CTRL_DOWN_MASK;261 return InputEvent.CTRL_DOWN_MASK; 263 262 } 264 263 … … 277 276 */ 278 277 void askUpdateJava(String updVersion, String url, String eolDate, boolean major); 279 }280 281 /**282 * Called when Oracle Java WebStart is detected at startup.283 * @since 17679284 */285 @FunctionalInterface286 interface WebStartMigrationCallback {287 /**288 * Asks user to migrate to OpenWebStart.289 * @param url download URL290 */291 void askMigrateWebStart(String url);292 278 } 293 279 … … 379 365 380 366 /** 381 * Checks if we run Oracle Web Start, proposes to user to migrate to OpenWebStart. 382 * @param callback WebStart migration callback 383 * @since 17679 384 */ 385 default void checkWebStartMigration(WebStartMigrationCallback callback) { 386 if (Utils.isRunningJavaWebStart()) { 387 callback.askMigrateWebStart(Config.getPref().get("openwebstart.download.url", "https://openwebstart.com/download/")); 388 } 389 } 390 367 * Check startup preconditions 368 * @param sanityCheckCallback The callback to inform the user about failed checks 369 */ 391 370 default void startupSanityChecks(SanityCheckCallback sanityCheckCallback) { 392 371 final String arch = System.getProperty("os.arch"); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r18985 r19103 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.Utils.getSystemProperty; … … 7 8 import java.awt.Desktop; 8 9 import java.awt.GraphicsEnvironment; 10 import java.awt.HeadlessException; 9 11 import java.awt.Image; 10 12 import java.awt.Window; 13 import java.awt.event.InputEvent; 11 14 import java.awt.event.KeyEvent; 12 15 import java.io.ByteArrayInputStream; 13 16 import java.io.File; 14 17 import java.io.IOException; 15 import java.lang.reflect.InvocationHandler; 16 import java.lang.reflect.InvocationTargetException; 17 import java.lang.reflect.Method; 18 import java.lang.reflect.Proxy; 18 import java.net.URISyntaxException; 19 19 import java.nio.charset.StandardCharsets; 20 20 import java.security.KeyStoreException; … … 24 24 import java.security.cert.X509Certificate; 25 25 import java.util.Arrays; 26 import java.util.List;27 26 import java.util.Objects; 28 27 import java.util.concurrent.ExecutionException; … … 39 38 * @since 1023 40 39 */ 41 public class PlatformHookOsx implements PlatformHook , InvocationHandler{40 public class PlatformHookOsx implements PlatformHook { 42 41 43 42 private String oSBuildNumber; … … 69 68 70 69 @Override 71 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 72 SanityCheckCallback sanityCheckCallback) { 70 public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) { 73 71 // Here we register callbacks for the menu entries in the system menu and file opening through double-click 74 72 // https://openjdk.java.net/jeps/272 75 73 // https://bugs.openjdk.java.net/browse/JDK-8048731 76 74 // https://cr.openjdk.java.net/~azvegint/jdk/9/8143227/10/jdk/ 77 // This method must be cleaned up after we switch to Java 978 75 try { 79 76 Class<?> eawtApplication = Class.forName("com.apple.eawt.Application"); 80 Class<?> quitHandler = findHandlerClass("QuitHandler"); 81 Class<?> aboutHandler = findHandlerClass("AboutHandler"); 82 Class<?> openFilesHandler = findHandlerClass("OpenFilesHandler"); 83 Class<?> preferencesHandler = findHandlerClass("PreferencesHandler"); 84 Object proxy = Proxy.newProxyInstance(PlatformHookOsx.class.getClassLoader(), new Class<?>[] { 85 quitHandler, aboutHandler, openFilesHandler, preferencesHandler}, this); 86 Object appli = eawtApplication.getConstructor((Class[]) null).newInstance((Object[]) null); 87 if (Utils.getJavaVersion() < 9) { 88 setHandlers(eawtApplication, quitHandler, aboutHandler, openFilesHandler, preferencesHandler, proxy, appli); 89 // this method has been deprecated, but without replacement. To remove with Java 9 migration 90 eawtApplication.getDeclaredMethod("setEnabledPreferencesMenu", boolean.class).invoke(appli, Boolean.TRUE); 91 } else if (!GraphicsEnvironment.isHeadless()) { 92 setHandlers(Desktop.class, quitHandler, aboutHandler, openFilesHandler, preferencesHandler, proxy, Desktop.getDesktop()); 77 Object appli = eawtApplication.getConstructor((Class<?>[]) null).newInstance((Object[]) null); 78 if (!GraphicsEnvironment.isHeadless()) { 79 setHandlers(); 93 80 } 94 81 // setup the dock icon. It is automatically set with application bundle and Web start but we need … … 107 94 warnSoonToBeUnsupportedJava(javaCallback); 108 95 checkExpiredJava(javaCallback); 109 checkWebStartMigration(webStartCallback); 110 PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback); 96 PlatformHook.super.startupHook(javaCallback, sanityCheckCallback); 111 97 } 112 98 … … 122 108 @Override 123 109 public int getMenuShortcutKeyMaskEx() { 124 return KeyEvent.META_DOWN_MASK;110 return InputEvent.META_DOWN_MASK; 125 111 } 126 112 127 113 /** 128 114 * Registers Apple handlers. 129 * @param appClass application class 130 * @param quitHandler quit handler class 131 * @param aboutHandler about handler class 132 * @param openFilesHandler open file handler class 133 * @param preferencesHandler preferences handler class 134 * @param proxy proxy 135 * @param appInstance application instance (instance of {@code appClass}) 136 * @throws IllegalAccessException in case of reflection error 137 * @throws InvocationTargetException in case of reflection error 138 * @throws NoSuchMethodException if any {@code set*Handler} method cannot be found 115 * 139 116 */ 140 protected void setHandlers(Class<?> appClass, Class<?> quitHandler, Class<?> aboutHandler, 141 Class<?> openFilesHandler, Class<?> preferencesHandler, Object proxy, Object appInstance) 142 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 143 appClass.getDeclaredMethod("setQuitHandler", quitHandler).invoke(appInstance, proxy); 144 appClass.getDeclaredMethod("setAboutHandler", aboutHandler).invoke(appInstance, proxy); 145 appClass.getDeclaredMethod("setOpenFileHandler", openFilesHandler).invoke(appInstance, proxy); 146 appClass.getDeclaredMethod("setPreferencesHandler", preferencesHandler).invoke(appInstance, proxy); 147 } 148 149 /** 150 * Find Apple handler class in {@code com.apple.eawt} or {@code java.awt.desktop} packages. 151 * @param className simple class name 152 * @return class 153 * @throws ClassNotFoundException if the handler class cannot be found 154 */ 155 protected Class<?> findHandlerClass(String className) throws ClassNotFoundException { 156 try { 157 // Java 8 handlers 158 return Class.forName("com.apple.eawt."+className); 159 } catch (ClassNotFoundException e) { 160 Logging.trace(e); 161 // Java 9 handlers 162 return Class.forName("java.awt.desktop."+className); 163 } 117 protected void setHandlers() { 118 Desktop.getDesktop().setQuitHandler((event, response) -> { 119 boolean closed = osCallback.handleQuitRequest(); 120 if (response != null) { 121 if (closed) { 122 response.performQuit(); 123 } else { 124 response.cancelQuit(); 125 } 126 } 127 }); 128 Desktop.getDesktop().setAboutHandler(event -> osCallback.handleAbout()); 129 Desktop.getDesktop().setOpenFileHandler(event -> { 130 if (event != null) { 131 osCallback.openFiles(event.getFiles()); 132 } 133 }); 134 Desktop.getDesktop().setPreferencesHandler(event -> osCallback.handlePreferences()); 164 135 } 165 136 … … 186 157 } 187 158 188 @SuppressWarnings("unchecked")189 @Override190 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {191 if (Logging.isDebugEnabled()) {192 Logging.debug("macOS handler: {0} - {1}", method.getName(), Arrays.toString(args));193 }194 switch (method.getName()) {195 case "openFiles":196 if (args[0] != null) {197 try {198 Object oFiles = args[0].getClass().getMethod("getFiles").invoke(args[0]);199 if (oFiles instanceof List) {200 osCallback.openFiles((List<File>) oFiles);201 }202 } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException ex) {203 Logging.warn("Failed to access open files event: " + ex);204 }205 }206 break;207 case "handleQuitRequestWith":208 boolean closed = osCallback.handleQuitRequest();209 if (args[1] != null) {210 try {211 args[1].getClass().getDeclaredMethod(closed ? "performQuit" : "cancelQuit").invoke(args[1]);212 } catch (IllegalAccessException e) {213 Logging.debug(e);214 // with Java 9, module java.desktop does not export com.apple.eawt, use new Desktop API instead215 Class.forName("java.awt.desktop.QuitResponse").getMethod(closed ? "performQuit" : "cancelQuit").invoke(args[1]);216 }217 }218 break;219 case "handleAbout":220 osCallback.handleAbout();221 break;222 case "handlePreferences":223 osCallback.handlePreferences();224 break;225 default:226 Logging.warn("macOS unsupported method: "+method.getName());227 }228 return null;229 }230 231 159 @Override 232 160 public void openUrl(String url) throws IOException { 233 Runtime.getRuntime().exec(new String[]{"open", url}); 234 } 235 236 @Override 161 try { 162 Desktop.getDesktop().browse(Utils.urlToURI(url)); 163 } catch (HeadlessException | URISyntaxException e) { 164 Logging.log(Logging.LEVEL_WARN, "Desktop class failed. Platform dependent fall back for open url in browser.", e); 165 Runtime.getRuntime().exec(new String[]{"open", url}); 166 } 167 } 168 169 @Override 170 @SuppressWarnings("squid:S103") // NOSONAR LineLength 237 171 public void initSystemShortcuts() { 172 final String reserved = marktr("reserved"); 238 173 // CHECKSTYLE.OFF: LineLength 239 auto(Shortcut.registerSystemShortcut("apple-reserved-01", tr( "reserved"), KeyEvent.VK_SPACE, KeyEvent.META_DOWN_MASK)); // Show or hide the Spotlight search field (when multiple languages are installed, may rotate through enabled script systems).240 auto(Shortcut.registerSystemShortcut("apple-reserved-02", tr( "reserved"), KeyEvent.VK_SPACE, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Apple reserved.241 auto(Shortcut.registerSystemShortcut("apple-reserved-03", tr( "reserved"), KeyEvent.VK_SPACE, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Show the Spotlight search results window (when multiple languages are installed, may rotate through keyboard layouts and input methods within a script).242 auto(Shortcut.registerSystemShortcut("apple-reserved-04", tr( "reserved"), KeyEvent.VK_SPACE, KeyEvent.META_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)); // | Apple reserved.243 auto(Shortcut.registerSystemShortcut("apple-reserved-05", tr( "reserved"), KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK)); // Navigate through controls in a reverse direction. See "Keyboard Focus and Navigation."244 auto(Shortcut.registerSystemShortcut("apple-reserved-06", tr( "reserved"), KeyEvent.VK_TAB, KeyEvent.META_DOWN_MASK)); // Move forward to the next most recently used application in a list of open applications.245 auto(Shortcut.registerSystemShortcut("apple-reserved-07", tr( "reserved"), KeyEvent.VK_TAB, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Move backward through a list of open applications (sorted by recent use).246 auto(Shortcut.registerSystemShortcut("apple-reserved-08", tr( "reserved"), KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK)); // Move focus to the next grouping of controls in a dialog or the next table (when Tab moves to the next cell). See Accessibility Overview.247 auto(Shortcut.registerSystemShortcut("apple-reserved-09", tr( "reserved"), KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Move focus to the previous grouping of controls. See Accessibility Overview.248 auto(Shortcut.registerSystemShortcut("apple-reserved-10", tr( "reserved"), KeyEvent.VK_ESCAPE, KeyEvent.META_DOWN_MASK)); // Open Front Row.249 auto(Shortcut.registerSystemShortcut("apple-reserved-11", tr( "reserved"), KeyEvent.VK_ESCAPE, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Open the Force Quit dialog.250 auto(Shortcut.registerSystemShortcut("apple-reserved-12", tr( "reserved"), KeyEvent.VK_F1, KeyEvent.CTRL_DOWN_MASK)); // Toggle full keyboard access on or off. See Accessibility Overview.251 auto(Shortcut.registerSystemShortcut("apple-reserved-13", tr( "reserved"), KeyEvent.VK_F2, KeyEvent.CTRL_DOWN_MASK)); // Move focus to the menu bar. See Accessibility Overview.252 auto(Shortcut.registerSystemShortcut("apple-reserved-14", tr( "reserved"), KeyEvent.VK_F3, KeyEvent.CTRL_DOWN_MASK)); // Move focus to the Dock. See Accessibility Overview.253 auto(Shortcut.registerSystemShortcut("apple-reserved-15", tr( "reserved"), KeyEvent.VK_F4, KeyEvent.CTRL_DOWN_MASK)); // Move focus to the active (or next) window. See Accessibility Overview.254 auto(Shortcut.registerSystemShortcut("apple-reserved-16", tr( "reserved"), KeyEvent.VK_F4, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Move focus to the previously active window. See Accessibility Overview.255 auto(Shortcut.registerSystemShortcut("apple-reserved-17", tr( "reserved"), KeyEvent.VK_F5, KeyEvent.CTRL_DOWN_MASK)); // Move focus to the toolbar. See Accessibility Overview.256 auto(Shortcut.registerSystemShortcut("apple-reserved-18", tr( "reserved"), KeyEvent.VK_F5, KeyEvent.META_DOWN_MASK)); // Turn VoiceOver on or off. See Accessibility Overview.257 auto(Shortcut.registerSystemShortcut("apple-reserved-19", tr( "reserved"), KeyEvent.VK_F6, KeyEvent.CTRL_DOWN_MASK)); // Move focus to the first (or next) panel. See Accessibility Overview.258 auto(Shortcut.registerSystemShortcut("apple-reserved-20", tr( "reserved"), KeyEvent.VK_F6, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Move focus to the previous panel. See Accessibility Overview.259 auto(Shortcut.registerSystemShortcut("apple-reserved-21", tr( "reserved"), KeyEvent.VK_F7, KeyEvent.CTRL_DOWN_MASK)); // Temporarily override the current keyboard access mode in windows and dialogs. See Accessibility Overview.174 auto(Shortcut.registerSystemShortcut("apple-reserved-01", tr(reserved), KeyEvent.VK_SPACE, InputEvent.META_DOWN_MASK)); // Show or hide the Spotlight search field (when multiple languages are installed, may rotate through enabled script systems). 175 auto(Shortcut.registerSystemShortcut("apple-reserved-02", tr(reserved), KeyEvent.VK_SPACE, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Apple reserved. 176 auto(Shortcut.registerSystemShortcut("apple-reserved-03", tr(reserved), KeyEvent.VK_SPACE, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Show the Spotlight search results window (when multiple languages are installed, may rotate through keyboard layouts and input methods within a script). 177 auto(Shortcut.registerSystemShortcut("apple-reserved-04", tr(reserved), KeyEvent.VK_SPACE, InputEvent.META_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)); // | Apple reserved. 178 auto(Shortcut.registerSystemShortcut("apple-reserved-05", tr(reserved), KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK)); // Navigate through controls in a reverse direction. See "Keyboard Focus and Navigation." 179 auto(Shortcut.registerSystemShortcut("apple-reserved-06", tr(reserved), KeyEvent.VK_TAB, InputEvent.META_DOWN_MASK)); // Move forward to the next most recently used application in a list of open applications. 180 auto(Shortcut.registerSystemShortcut("apple-reserved-07", tr(reserved), KeyEvent.VK_TAB, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Move backward through a list of open applications (sorted by recent use). 181 auto(Shortcut.registerSystemShortcut("apple-reserved-08", tr(reserved), KeyEvent.VK_TAB, InputEvent.CTRL_DOWN_MASK)); // Move focus to the next grouping of controls in a dialog or the next table (when Tab moves to the next cell). See Accessibility Overview. 182 auto(Shortcut.registerSystemShortcut("apple-reserved-09", tr(reserved), KeyEvent.VK_TAB, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Move focus to the previous grouping of controls. See Accessibility Overview. 183 auto(Shortcut.registerSystemShortcut("apple-reserved-10", tr(reserved), KeyEvent.VK_ESCAPE, InputEvent.META_DOWN_MASK)); // Open Front Row. 184 auto(Shortcut.registerSystemShortcut("apple-reserved-11", tr(reserved), KeyEvent.VK_ESCAPE, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Open the Force Quit dialog. 185 auto(Shortcut.registerSystemShortcut("apple-reserved-12", tr(reserved), KeyEvent.VK_F1, InputEvent.CTRL_DOWN_MASK)); // Toggle full keyboard access on or off. See Accessibility Overview. 186 auto(Shortcut.registerSystemShortcut("apple-reserved-13", tr(reserved), KeyEvent.VK_F2, InputEvent.CTRL_DOWN_MASK)); // Move focus to the menu bar. See Accessibility Overview. 187 auto(Shortcut.registerSystemShortcut("apple-reserved-14", tr(reserved), KeyEvent.VK_F3, InputEvent.CTRL_DOWN_MASK)); // Move focus to the Dock. See Accessibility Overview. 188 auto(Shortcut.registerSystemShortcut("apple-reserved-15", tr(reserved), KeyEvent.VK_F4, InputEvent.CTRL_DOWN_MASK)); // Move focus to the active (or next) window. See Accessibility Overview. 189 auto(Shortcut.registerSystemShortcut("apple-reserved-16", tr(reserved), KeyEvent.VK_F4, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Move focus to the previously active window. See Accessibility Overview. 190 auto(Shortcut.registerSystemShortcut("apple-reserved-17", tr(reserved), KeyEvent.VK_F5, InputEvent.CTRL_DOWN_MASK)); // Move focus to the toolbar. See Accessibility Overview. 191 auto(Shortcut.registerSystemShortcut("apple-reserved-18", tr(reserved), KeyEvent.VK_F5, InputEvent.META_DOWN_MASK)); // Turn VoiceOver on or off. See Accessibility Overview. 192 auto(Shortcut.registerSystemShortcut("apple-reserved-19", tr(reserved), KeyEvent.VK_F6, InputEvent.CTRL_DOWN_MASK)); // Move focus to the first (or next) panel. See Accessibility Overview. 193 auto(Shortcut.registerSystemShortcut("apple-reserved-20", tr(reserved), KeyEvent.VK_F6, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Move focus to the previous panel. See Accessibility Overview. 194 auto(Shortcut.registerSystemShortcut("apple-reserved-21", tr(reserved), KeyEvent.VK_F7, InputEvent.CTRL_DOWN_MASK)); // Temporarily override the current keyboard access mode in windows and dialogs. See Accessibility Overview. 260 195 //auto(Shortcut.registerSystemShortcut("apple-reserved-22", tr("reserved"), KeyEvent.VK_F9, 0)); // Tile or untile all open windows. 261 196 //auto(Shortcut.registerSystemShortcut("apple-reserved-23", tr("reserved"), KeyEvent.VK_F10, 0)); // Tile or untile all open windows in the currently active application. 262 197 //auto(Shortcut.registerSystemShortcut("apple-reserved-24", tr("reserved"), KeyEvent.VK_F11, 0)); // Hide or show all open windows. 263 198 //auto(Shortcut.registerSystemShortcut("apple-reserved-25", tr("reserved"), KeyEvent.VK_F12, 0)); // Hide or display Dashboard. 264 auto(Shortcut.registerSystemShortcut("apple-reserved-26", tr( "reserved"), KeyEvent.VK_DEAD_GRAVE, KeyEvent.META_DOWN_MASK)); // Activate the next open window in the frontmost application. See "Window Layering."265 auto(Shortcut.registerSystemShortcut("apple-reserved-27", tr( "reserved"), KeyEvent.VK_DEAD_GRAVE, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Activate the previous open window in the frontmost application. See "Window Layering."266 auto(Shortcut.registerSystemShortcut("apple-reserved-28", tr( "reserved"), KeyEvent.VK_DEAD_GRAVE, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Move focus to the window drawer.267 //auto(Shortcut.registerSystemShortcut("apple-reserved-29", tr( "reserved"), KeyEvent.VK_MINUS, KeyEvent.META_DOWN_MASK)); // Decrease the size of the selected item (equivalent to the Smaller command). See "The Format Menu."268 auto(Shortcut.registerSystemShortcut("apple-reserved-30", tr( "reserved"), KeyEvent.VK_MINUS, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Zoom out when screen zooming is on. See Accessibility Overview.269 270 //Shortcut.registerSystemShortcut("system:align-left", tr( "reserved"), KeyEvent.VK_OPEN_BRACKET, KeyEvent.META_DOWN_MASK); // Left-align a selection (equivalent to the Align Left command). See "The Format Menu."271 //Shortcut.registerSystemShortcut("system:align-right",tr( "reserved"), KeyEvent.VK_CLOSE_BRACKET, KeyEvent.META_DOWN_MASK); // Right-align a selection (equivalent to the Align Right command). See "The Format Menu."199 auto(Shortcut.registerSystemShortcut("apple-reserved-26", tr(reserved), KeyEvent.VK_DEAD_GRAVE, InputEvent.META_DOWN_MASK)); // Activate the next open window in the frontmost application. See "Window Layering." 200 auto(Shortcut.registerSystemShortcut("apple-reserved-27", tr(reserved), KeyEvent.VK_DEAD_GRAVE, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Activate the previous open window in the frontmost application. See "Window Layering." 201 auto(Shortcut.registerSystemShortcut("apple-reserved-28", tr(reserved), KeyEvent.VK_DEAD_GRAVE, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Move focus to the window drawer. 202 //auto(Shortcut.registerSystemShortcut("apple-reserved-29", tr(reserved), KeyEvent.VK_MINUS, KeyEvent.META_DOWN_MASK)); // Decrease the size of the selected item (equivalent to the Smaller command). See "The Format Menu." 203 auto(Shortcut.registerSystemShortcut("apple-reserved-30", tr(reserved), KeyEvent.VK_MINUS, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Zoom out when screen zooming is on. See Accessibility Overview. 204 205 //Shortcut.registerSystemShortcut("system:align-left", tr(reserved), KeyEvent.VK_OPEN_BRACKET, KeyEvent.META_DOWN_MASK); // Left-align a selection (equivalent to the Align Left command). See "The Format Menu." 206 //Shortcut.registerSystemShortcut("system:align-right",tr(reserved), KeyEvent.VK_CLOSE_BRACKET, KeyEvent.META_DOWN_MASK); // Right-align a selection (equivalent to the Align Right command). See "The Format Menu." 272 207 // I found no KeyEvent for | 273 //Shortcut.registerSystemCut("system:align-center", tr( "reserved"), '|', KeyEvent.META_DOWN_MASK); // Center-align a selection (equivalent to the Align Center command). See "The Format Menu."274 //Shortcut.registerSystemShortcut("system:spelling", tr( "reserved"), KeyEvent.VK_COLON, KeyEvent.META_DOWN_MASK); // Display the Spelling window (equivalent to the Spelling command). See "The Edit Menu."275 //Shortcut.registerSystemShortcut("system:spellcheck", tr( "reserved"), KeyEvent.VK_SEMICOLON, KeyEvent.META_DOWN_MASK); // Find misspelled words in the document (equivalent to the Check Spelling command). See "The Edit Menu."276 auto(Shortcut.registerSystemShortcut("system:preferences", tr( "reserved"), KeyEvent.VK_COMMA, KeyEvent.META_DOWN_MASK)); // Open the application's preferences window (equivalent to the Preferences command). See "The Application Menu."277 278 auto(Shortcut.registerSystemShortcut("apple-reserved-31", tr( "reserved"), KeyEvent.VK_COMMA, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Decrease screen contrast. See Accessibility Overview.279 auto(Shortcut.registerSystemShortcut("apple-reserved-32", tr( "reserved"), KeyEvent.VK_PERIOD, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Increase screen contrast. See Accessibility Overview.208 //Shortcut.registerSystemCut("system:align-center", tr(reserved), '|', KeyEvent.META_DOWN_MASK); // Center-align a selection (equivalent to the Align Center command). See "The Format Menu." 209 //Shortcut.registerSystemShortcut("system:spelling", tr(reserved), KeyEvent.VK_COLON, KeyEvent.META_DOWN_MASK); // Display the Spelling window (equivalent to the Spelling command). See "The Edit Menu." 210 //Shortcut.registerSystemShortcut("system:spellcheck", tr(reserved), KeyEvent.VK_SEMICOLON, KeyEvent.META_DOWN_MASK); // Find misspelled words in the document (equivalent to the Check Spelling command). See "The Edit Menu." 211 auto(Shortcut.registerSystemShortcut("system:preferences", tr(reserved), KeyEvent.VK_COMMA, InputEvent.META_DOWN_MASK)); // Open the application's preferences window (equivalent to the Preferences command). See "The Application Menu." 212 213 auto(Shortcut.registerSystemShortcut("apple-reserved-31", tr(reserved), KeyEvent.VK_COMMA, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Decrease screen contrast. See Accessibility Overview. 214 auto(Shortcut.registerSystemShortcut("apple-reserved-32", tr(reserved), KeyEvent.VK_PERIOD, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Increase screen contrast. See Accessibility Overview. 280 215 281 216 // I found no KeyEvent for ? 282 //auto(Shortcut.registerSystemCut("system:help", tr( "reserved"), '?', KeyEvent.META_DOWN_MASK)); // Open the application's help in Help Viewer. See "The Help Menu."283 284 auto(Shortcut.registerSystemShortcut("apple-reserved-33", tr( "reserved"), KeyEvent.VK_SLASH, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Turn font smoothing on or off.285 auto(Shortcut.registerSystemShortcut("apple-reserved-34", tr( "reserved"), KeyEvent.VK_EQUALS, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Increase the size of the selected item (equivalent to the Bigger command). See "The Format Menu."286 auto(Shortcut.registerSystemShortcut("apple-reserved-35", tr( "reserved"), KeyEvent.VK_EQUALS, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Zoom in when screen zooming is on. See Accessibility Overview.287 auto(Shortcut.registerSystemShortcut("apple-reserved-36", tr( "reserved"), KeyEvent.VK_3, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Capture the screen to a file.288 auto(Shortcut.registerSystemShortcut("apple-reserved-37", tr( "reserved"), KeyEvent.VK_3, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)); // Capture the screen to the Clipboard.289 auto(Shortcut.registerSystemShortcut("apple-reserved-38", tr( "reserved"), KeyEvent.VK_4, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Capture a selection to a file.290 auto(Shortcut.registerSystemShortcut("apple-reserved-39", tr( "reserved"), KeyEvent.VK_4, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)); // Capture a selection to the Clipboard.291 auto(Shortcut.registerSystemShortcut("apple-reserved-40", tr( "reserved"), KeyEvent.VK_8, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Turn screen zooming on or off. See Accessibility Overview.292 auto(Shortcut.registerSystemShortcut("apple-reserved-41", tr( "reserved"), KeyEvent.VK_8, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)); // Invert the screen colors. See Accessibility Overview.293 294 Shortcut.registerSystemShortcut("system:selectall", tr( "reserved"), KeyEvent.VK_A, KeyEvent.META_DOWN_MASK); // Highlight every item in a document or window, or all characters in a text field (equivalent to the Select All command). See "The Edit Menu."295 //Shortcut.registerSystemShortcut("system:bold", tr( "reserved"), KeyEvent.VK_B, KeyEvent.META_DOWN_MASK); // Boldface the selected text or toggle boldfaced text on and off (equivalent to the Bold command). See "The Edit Menu."296 Shortcut.registerSystemShortcut("system:copy", tr( "reserved"), KeyEvent.VK_C, KeyEvent.META_DOWN_MASK); // Duplicate the selected data and store on the Clipboard (equivalent to the Copy command). See "The Edit Menu."297 //Shortcut.registerSystemShortcut("system:colors", tr( "reserved"), KeyEvent.VK_C, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Display the Colors window (equivalent to the Show Colors command). See "The Format Menu."298 //Shortcut.registerSystemShortcut("system:copystyle", tr( "reserved"), KeyEvent.VK_C, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Copy the style of the selected text (equivalent to the Copy Style command). See "The Format Menu."299 //Shortcut.registerSystemShortcut("system:copyformat", tr( "reserved"), KeyEvent.VK_C, KeyEvent.META_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)); // Copy the formatting settings of the selected item and store on the Clipboard (equivalent to the Copy Ruler command). See "The Format Menu."300 301 auto(Shortcut.registerSystemShortcut("apple-reserved-42", tr( "reserved"), KeyEvent.VK_D, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Show or hide the Dock. See "The Dock."302 303 Shortcut.registerSystemShortcut("system:dictionarylookup", tr( "reserved"), KeyEvent.VK_D, KeyEvent.META_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK); // Display the definition of the selected word in the Dictionary application.304 //Shortcut.registerSystemShortcut("system:findselected", tr( "reserved"), KeyEvent.VK_E, KeyEvent.META_DOWN_MASK); // Use the selection for a find operation. See "Find Windows."305 Shortcut.registerSystemShortcut("system:find", tr( "reserved"), KeyEvent.VK_F, KeyEvent.META_DOWN_MASK); // Open a Find window (equivalent to the Find command). See "The Edit Menu."306 Shortcut.registerSystemShortcut("system:search", tr( "reserved"), KeyEvent.VK_F, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Jump to the search field control. See "Search Fields."307 //Shortcut.registerSystemShortcut("system:findnext", tr( "reserved"), KeyEvent.VK_G, KeyEvent.META_DOWN_MASK); // Find the next occurrence of the selection (equivalent to the Find Next command). See "The Edit Menu."308 //Shortcut.registerSystemShortcut("system:findprev", tr( "reserved"), KeyEvent.VK_G, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Find the previous occurrence of the selection (equivalent to the Find Previous command). See "The Edit Menu."309 auto(Shortcut.registerSystemShortcut("system:hide", tr( "reserved"), KeyEvent.VK_H, KeyEvent.META_DOWN_MASK)); // Hide the windows of the currently running application (equivalent to the Hide ApplicationName command). See "The Application Menu."310 auto(Shortcut.registerSystemShortcut("system:hideothers", tr( "reserved"), KeyEvent.VK_H, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Hide the windows of all other running applications (equivalent to the Hide Others command). See "The Application Menu."217 //auto(Shortcut.registerSystemCut("system:help", tr(reserved), '?', KeyEvent.META_DOWN_MASK)); // Open the application's help in Help Viewer. See "The Help Menu." 218 219 auto(Shortcut.registerSystemShortcut("apple-reserved-33", tr(reserved), KeyEvent.VK_SLASH, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Turn font smoothing on or off. 220 auto(Shortcut.registerSystemShortcut("apple-reserved-34", tr(reserved), KeyEvent.VK_EQUALS, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Increase the size of the selected item (equivalent to the Bigger command). See "The Format Menu." 221 auto(Shortcut.registerSystemShortcut("apple-reserved-35", tr(reserved), KeyEvent.VK_EQUALS, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Zoom in when screen zooming is on. See Accessibility Overview. 222 auto(Shortcut.registerSystemShortcut("apple-reserved-36", tr(reserved), KeyEvent.VK_3, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Capture the screen to a file. 223 auto(Shortcut.registerSystemShortcut("apple-reserved-37", tr(reserved), KeyEvent.VK_3, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)); // Capture the screen to the Clipboard. 224 auto(Shortcut.registerSystemShortcut("apple-reserved-38", tr(reserved), KeyEvent.VK_4, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Capture a selection to a file. 225 auto(Shortcut.registerSystemShortcut("apple-reserved-39", tr(reserved), KeyEvent.VK_4, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)); // Capture a selection to the Clipboard. 226 auto(Shortcut.registerSystemShortcut("apple-reserved-40", tr(reserved), KeyEvent.VK_8, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Turn screen zooming on or off. See Accessibility Overview. 227 auto(Shortcut.registerSystemShortcut("apple-reserved-41", tr(reserved), KeyEvent.VK_8, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)); // Invert the screen colors. See Accessibility Overview. 228 229 Shortcut.registerSystemShortcut("system:selectall", tr(reserved), KeyEvent.VK_A, InputEvent.META_DOWN_MASK); // Highlight every item in a document or window, or all characters in a text field (equivalent to the Select All command). See "The Edit Menu." 230 //Shortcut.registerSystemShortcut("system:bold", tr(reserved), KeyEvent.VK_B, KeyEvent.META_DOWN_MASK); // Boldface the selected text or toggle boldfaced text on and off (equivalent to the Bold command). See "The Edit Menu." 231 Shortcut.registerSystemShortcut("system:copy", tr(reserved), KeyEvent.VK_C, InputEvent.META_DOWN_MASK); // Duplicate the selected data and store on the Clipboard (equivalent to the Copy command). See "The Edit Menu." 232 //Shortcut.registerSystemShortcut("system:colors", tr(reserved), KeyEvent.VK_C, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Display the Colors window (equivalent to the Show Colors command). See "The Format Menu." 233 //Shortcut.registerSystemShortcut("system:copystyle", tr(reserved), KeyEvent.VK_C, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Copy the style of the selected text (equivalent to the Copy Style command). See "The Format Menu." 234 //Shortcut.registerSystemShortcut("system:copyformat", tr(reserved), KeyEvent.VK_C, KeyEvent.META_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)); // Copy the formatting settings of the selected item and store on the Clipboard (equivalent to the Copy Ruler command). See "The Format Menu." 235 236 auto(Shortcut.registerSystemShortcut("apple-reserved-42", tr(reserved), KeyEvent.VK_D, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Show or hide the Dock. See "The Dock." 237 238 Shortcut.registerSystemShortcut("system:dictionarylookup", tr(reserved), KeyEvent.VK_D, InputEvent.META_DOWN_MASK | InputEvent.CTRL_DOWN_MASK); // Display the definition of the selected word in the Dictionary application. 239 //Shortcut.registerSystemShortcut("system:findselected", tr(reserved), KeyEvent.VK_E, KeyEvent.META_DOWN_MASK); // Use the selection for a find operation. See "Find Windows." 240 Shortcut.registerSystemShortcut("system:find", tr(reserved), KeyEvent.VK_F, InputEvent.META_DOWN_MASK); // Open a Find window (equivalent to the Find command). See "The Edit Menu." 241 Shortcut.registerSystemShortcut("system:search", tr(reserved), KeyEvent.VK_F, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK); // Jump to the search field control. See "Search Fields." 242 //Shortcut.registerSystemShortcut("system:findnext", tr(reserved), KeyEvent.VK_G, KeyEvent.META_DOWN_MASK); // Find the next occurrence of the selection (equivalent to the Find Next command). See "The Edit Menu." 243 //Shortcut.registerSystemShortcut("system:findprev", tr(reserved), KeyEvent.VK_G, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Find the previous occurrence of the selection (equivalent to the Find Previous command). See "The Edit Menu." 244 auto(Shortcut.registerSystemShortcut("system:hide", tr(reserved), KeyEvent.VK_H, InputEvent.META_DOWN_MASK)); // Hide the windows of the currently running application (equivalent to the Hide ApplicationName command). See "The Application Menu." 245 auto(Shortcut.registerSystemShortcut("system:hideothers", tr(reserved), KeyEvent.VK_H, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Hide the windows of all other running applications (equivalent to the Hide Others command). See "The Application Menu." 311 246 // What about applications that have italic text AND info windows? 312 //Shortcut.registerSystemCut("system:italic", tr( "reserved"), KeyEvent.VK_I, KeyEvent.META_DOWN_MASK); // Italicize the selected text or toggle italic text on or off (equivalent to the Italic command). See "The Format Menu."313 //Shortcut.registerSystemShortcut("system:info", tr( "reserved"), KeyEvent.VK_I, KeyEvent.META_DOWN_MASK); // Display an Info window. See "Inspector Windows."314 //Shortcut.registerSystemShortcut("system:inspector", tr( "reserved"), KeyEvent.VK_I, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Display an inspector window. See "Inspector Windows."315 //Shortcut.registerSystemShortcut("system:toselection", tr( "reserved"), KeyEvent.VK_J, KeyEvent.META_DOWN_MASK); // Scroll to a selection.316 //Shortcut.registerSystemShortcut("system:minimize", tr( "reserved"), KeyEvent.VK_M, KeyEvent.META_DOWN_MASK); // Minimize the active window to the Dock (equivalent to the Minimize command). See "The Window Menu."317 //Shortcut.registerSystemShortcut("system:minimizeall", tr( "reserved"), KeyEvent.VK_M, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Minimize all windows of the active application to the Dock (equivalent to the Minimize All command). See "The Window Menu."318 Shortcut.registerSystemShortcut("system:new", tr( "reserved"), KeyEvent.VK_N, KeyEvent.META_DOWN_MASK); // Open a new document (equivalent to the New command). See "The File Menu."319 Shortcut.registerSystemShortcut("system:open", tr( "reserved"), KeyEvent.VK_O, KeyEvent.META_DOWN_MASK); // Display a dialog for choosing a document to open (equivalent to the Open command). See "The File Menu."320 Shortcut.registerSystemShortcut("system:print", tr( "reserved"), KeyEvent.VK_P, KeyEvent.META_DOWN_MASK); // Display the Print dialog (equivalent to the Print command). See "The File Menu."321 //Shortcut.registerSystemShortcut("system:printsetup", tr( "reserved"), KeyEvent.VK_P, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Display a dialog for specifying printing parameters (equivalent to the Page Setup command). See "The File Menu."322 auto(Shortcut.registerSystemShortcut("system:menuexit", tr( "reserved"), KeyEvent.VK_Q, KeyEvent.META_DOWN_MASK)); // Quit the application (equivalent to the Quit command). See "The Application Menu."323 324 auto(Shortcut.registerSystemShortcut("apple-reserved-43", tr( "reserved"), KeyEvent.VK_Q, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Log out the current user (equivalent to the Log Out command).325 auto(Shortcut.registerSystemShortcut("apple-reserved-44", tr( "reserved"), KeyEvent.VK_Q, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)); // Log out the current user without confirmation.326 327 Shortcut.registerSystemShortcut("system:save", tr( "reserved"), KeyEvent.VK_S, KeyEvent.META_DOWN_MASK); // Save the active document (equivalent to the Save command). See "The File Menu."328 Shortcut.registerSystemShortcut("system:saveas", tr( "reserved"), KeyEvent.VK_S, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Display the Save dialog (equivalent to the Save As command). See "The File Menu."329 //Shortcut.registerSystemShortcut("system:fonts", tr( "reserved"), KeyEvent.VK_T, KeyEvent.META_DOWN_MASK); // Display the Fonts window (equivalent to the Show Fonts command). See "The Format Menu."330 Shortcut.registerSystemShortcut("system:toggletoolbar", tr( "reserved"), KeyEvent.VK_T, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Show or hide a toolbar (equivalent to the Show/Hide Toolbar command). See "The View Menu" and "Toolbars."331 //Shortcut.registerSystemShortcut("system:underline", tr( "reserved"), KeyEvent.VK_U, KeyEvent.META_DOWN_MASK); // Underline the selected text or turn underlining on or off (equivalent to the Underline command). See "The Format Menu."332 Shortcut.registerSystemShortcut("system:paste", tr( "reserved"), KeyEvent.VK_V, KeyEvent.META_DOWN_MASK); // Insert the Clipboard contents at the insertion point (equivalent to the Paste command). See "The File Menu."333 //Shortcut.registerSystemShortcut("system:pastestyle", tr( "reserved"), KeyEvent.VK_V, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Apply the style of one object to the selected object (equivalent to the Paste Style command). See "The Format Menu."334 //Shortcut.registerSystemShortcut("system:pastemwithoutstyle", tr( "reserved"), KeyEvent.VK_V, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Apply the style of the surrounding text to the inserted object (equivalent to the Paste and Match Style command). See "The Edit Menu."335 //Shortcut.registerSystemShortcut("system:pasteformatting", tr( "reserved"), KeyEvent.VK_V, KeyEvent.META_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK); // Apply formatting settings to the selected object (equivalent to the Paste Ruler command). See "The Format Menu."336 //Shortcut.registerSystemShortcut("system:closewindow", tr( "reserved"), KeyEvent.VK_W, KeyEvent.META_DOWN_MASK); // Close the active window (equivalent to the Close command). See "The File Menu."337 Shortcut.registerSystemShortcut("system:closefile", tr( "reserved"), KeyEvent.VK_W, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Close a file and its associated windows (equivalent to the Close File command). See "The File Menu."338 Shortcut.registerSystemShortcut("system:closeallwindows", tr( "reserved"), KeyEvent.VK_W, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Close all windows in the application (equivalent to the Close All command). See "The File Menu."339 Shortcut.registerSystemShortcut("system:cut", tr( "reserved"), KeyEvent.VK_X, KeyEvent.META_DOWN_MASK); // Remove the selection and store on the Clipboard (equivalent to the Cut command). See "The Edit Menu."340 Shortcut.registerSystemShortcut("system:undo", tr( "reserved"), KeyEvent.VK_Z, KeyEvent.META_DOWN_MASK); // Reverse the effect of the user's previous operation (equivalent to the Undo command). See "The Edit Menu."341 Shortcut.registerSystemShortcut("system:redo", tr( "reserved"), KeyEvent.VK_Z, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Reverse the effect of the last Undo command (equivalent to the Redo command). See "The Edit Menu."342 343 auto(Shortcut.registerSystemShortcut("apple-reserved-45", tr( "reserved"), KeyEvent.VK_RIGHT, KeyEvent.META_DOWN_MASK)); // Change the keyboard layout to current layout of Roman script.344 //auto(Shortcut.registerSystemCut("apple-reserved-46", tr( "reserved"), KeyEvent.VK_RIGHT, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the next semantic unit, typically the end of the current line.345 //auto(Shortcut.registerSystemCut("apple-reserved-47", tr( "reserved"), KeyEvent.VK_RIGHT, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection one character to the right.346 //auto(Shortcut.registerSystemCut("apple-reserved-48", tr( "reserved"), KeyEvent.VK_RIGHT, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the end of the current word, then to the end of the next word.347 348 Shortcut.registerSystemShortcut("system:movefocusright", tr( "reserved"), KeyEvent.VK_RIGHT, KeyEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview.349 350 auto(Shortcut.registerSystemShortcut("apple-reserved-49", tr( "reserved"), KeyEvent.VK_LEFT, KeyEvent.META_DOWN_MASK)); // Change the keyboard layout to current layout of system script.351 //auto(Shortcut.registerSystemCut("apple-reserved-50", tr( "reserved"), KeyEvent.VK_LEFT, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the previous semantic unit, typically the beginning of the current line.352 //auto(Shortcut.registerSystemCut("apple-reserved-51", tr( "reserved"), KeyEvent.VK_LEFT, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection one character to the left.353 //auto(Shortcut.registerSystemCut("apple-reserved-52", tr( "reserved"), KeyEvent.VK_LEFT, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the beginning of the current word, then to the beginning of the previous word.354 355 Shortcut.registerSystemShortcut("system:movefocusleft", tr( "reserved"), KeyEvent.VK_LEFT, KeyEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview.356 357 //auto(Shortcut.registerSystemCut("apple-reserved-53", tr( "reserved"), KeyEvent.VK_UP, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection upward in the next semantic unit, typically the beginning of the document.358 //auto(Shortcut.registerSystemCut("apple-reserved-54", tr( "reserved"), KeyEvent.VK_UP, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the line above, to the nearest character boundary at the same horizontal location.359 //auto(Shortcut.registerSystemCut("apple-reserved-55", tr( "reserved"), KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the beginning of the current paragraph, then to the beginning of the next paragraph.360 361 Shortcut.registerSystemShortcut("system:movefocusup", tr( "reserved"), KeyEvent.VK_UP, KeyEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview.362 363 //auto(Shortcut.registerSystemCut("apple-reserved-56", tr( "reserved"), KeyEvent.VK_DOWN, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection downward in the next semantic unit, typically the end of the document.364 //auto(Shortcut.registerSystemCut("apple-reserved-57", tr( "reserved"), KeyEvent.VK_DOWN, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the line below, to the nearest character boundary at the same horizontal location.365 //auto(Shortcut.registerSystemCut("apple-reserved-58", tr( "reserved"), KeyEvent.VK_DOWN, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the end of the current paragraph, then to the end of the next paragraph (include the blank line between paragraphs in cut, copy, and paste operations).366 367 Shortcut.registerSystemShortcut("system:movefocusdown", tr( "reserved"), KeyEvent.VK_DOWN, KeyEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview.368 369 auto(Shortcut.registerSystemShortcut("system:about", tr( "reserved"), 0, -1)); // About370 371 //Shortcut.registerSystemShortcut("view:zoomin", tr( "reserved"), KeyEvent.VK_ADD, KeyEvent.META_DOWN_MASK); // Zoom in372 //Shortcut.registerSystemShortcut("view:zoomout", tr( "reserved"), KeyEvent.VK_SUBTRACT, KeyEvent.META_DOWN_MASK); // Zoom out247 //Shortcut.registerSystemCut("system:italic", tr(reserved), KeyEvent.VK_I, KeyEvent.META_DOWN_MASK); // Italicize the selected text or toggle italic text on or off (equivalent to the Italic command). See "The Format Menu." 248 //Shortcut.registerSystemShortcut("system:info", tr(reserved), KeyEvent.VK_I, KeyEvent.META_DOWN_MASK); // Display an Info window. See "Inspector Windows." 249 //Shortcut.registerSystemShortcut("system:inspector", tr(reserved), KeyEvent.VK_I, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Display an inspector window. See "Inspector Windows." 250 //Shortcut.registerSystemShortcut("system:toselection", tr(reserved), KeyEvent.VK_J, KeyEvent.META_DOWN_MASK); // Scroll to a selection. 251 //Shortcut.registerSystemShortcut("system:minimize", tr(reserved), KeyEvent.VK_M, KeyEvent.META_DOWN_MASK); // Minimize the active window to the Dock (equivalent to the Minimize command). See "The Window Menu." 252 //Shortcut.registerSystemShortcut("system:minimizeall", tr(reserved), KeyEvent.VK_M, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Minimize all windows of the active application to the Dock (equivalent to the Minimize All command). See "The Window Menu." 253 Shortcut.registerSystemShortcut("system:new", tr(reserved), KeyEvent.VK_N, InputEvent.META_DOWN_MASK); // Open a new document (equivalent to the New command). See "The File Menu." 254 Shortcut.registerSystemShortcut("system:open", tr(reserved), KeyEvent.VK_O, InputEvent.META_DOWN_MASK); // Display a dialog for choosing a document to open (equivalent to the Open command). See "The File Menu." 255 Shortcut.registerSystemShortcut("system:print", tr(reserved), KeyEvent.VK_P, InputEvent.META_DOWN_MASK); // Display the Print dialog (equivalent to the Print command). See "The File Menu." 256 //Shortcut.registerSystemShortcut("system:printsetup", tr(reserved), KeyEvent.VK_P, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK); // Display a dialog for specifying printing parameters (equivalent to the Page Setup command). See "The File Menu." 257 auto(Shortcut.registerSystemShortcut("system:menuexit", tr(reserved), KeyEvent.VK_Q, InputEvent.META_DOWN_MASK)); // Quit the application (equivalent to the Quit command). See "The Application Menu." 258 259 auto(Shortcut.registerSystemShortcut("apple-reserved-43", tr(reserved), KeyEvent.VK_Q, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); // Log out the current user (equivalent to the Log Out command). 260 auto(Shortcut.registerSystemShortcut("apple-reserved-44", tr(reserved), KeyEvent.VK_Q, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK)); // Log out the current user without confirmation. 261 262 Shortcut.registerSystemShortcut("system:save", tr(reserved), KeyEvent.VK_S, InputEvent.META_DOWN_MASK); // Save the active document (equivalent to the Save command). See "The File Menu." 263 Shortcut.registerSystemShortcut("system:saveas", tr(reserved), KeyEvent.VK_S, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK); // Display the Save dialog (equivalent to the Save As command). See "The File Menu." 264 //Shortcut.registerSystemShortcut("system:fonts", tr(reserved), KeyEvent.VK_T, KeyEvent.META_DOWN_MASK); // Display the Fonts window (equivalent to the Show Fonts command). See "The Format Menu." 265 Shortcut.registerSystemShortcut("system:toggletoolbar", tr(reserved), KeyEvent.VK_T, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK); // Show or hide a toolbar (equivalent to the Show/Hide Toolbar command). See "The View Menu" and "Toolbars." 266 //Shortcut.registerSystemShortcut("system:underline", tr(reserved), KeyEvent.VK_U, KeyEvent.META_DOWN_MASK); // Underline the selected text or turn underlining on or off (equivalent to the Underline command). See "The Format Menu." 267 Shortcut.registerSystemShortcut("system:paste", tr(reserved), KeyEvent.VK_V, InputEvent.META_DOWN_MASK); // Insert the Clipboard contents at the insertion point (equivalent to the Paste command). See "The File Menu." 268 //Shortcut.registerSystemShortcut("system:pastestyle", tr(reserved), KeyEvent.VK_V, KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Apply the style of one object to the selected object (equivalent to the Paste Style command). See "The Format Menu." 269 //Shortcut.registerSystemShortcut("system:pastemwithoutstyle", tr(reserved), KeyEvent.VK_V, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK); // Apply the style of the surrounding text to the inserted object (equivalent to the Paste and Match Style command). See "The Edit Menu." 270 //Shortcut.registerSystemShortcut("system:pasteformatting", tr(reserved), KeyEvent.VK_V, KeyEvent.META_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK); // Apply formatting settings to the selected object (equivalent to the Paste Ruler command). See "The Format Menu." 271 //Shortcut.registerSystemShortcut("system:closewindow", tr(reserved), KeyEvent.VK_W, KeyEvent.META_DOWN_MASK); // Close the active window (equivalent to the Close command). See "The File Menu." 272 Shortcut.registerSystemShortcut("system:closefile", tr(reserved), KeyEvent.VK_W, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK); // Close a file and its associated windows (equivalent to the Close File command). See "The File Menu." 273 Shortcut.registerSystemShortcut("system:closeallwindows", tr(reserved), KeyEvent.VK_W, InputEvent.META_DOWN_MASK | InputEvent.ALT_DOWN_MASK); // Close all windows in the application (equivalent to the Close All command). See "The File Menu." 274 Shortcut.registerSystemShortcut("system:cut", tr(reserved), KeyEvent.VK_X, InputEvent.META_DOWN_MASK); // Remove the selection and store on the Clipboard (equivalent to the Cut command). See "The Edit Menu." 275 Shortcut.registerSystemShortcut("system:undo", tr(reserved), KeyEvent.VK_Z, InputEvent.META_DOWN_MASK); // Reverse the effect of the user's previous operation (equivalent to the Undo command). See "The Edit Menu." 276 Shortcut.registerSystemShortcut("system:redo", tr(reserved), KeyEvent.VK_Z, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK); // Reverse the effect of the last Undo command (equivalent to the Redo command). See "The Edit Menu." 277 278 auto(Shortcut.registerSystemShortcut("apple-reserved-45", tr(reserved), KeyEvent.VK_RIGHT, InputEvent.META_DOWN_MASK)); // Change the keyboard layout to current layout of Roman script. 279 //auto(Shortcut.registerSystemCut("apple-reserved-46", tr(reserved), KeyEvent.VK_RIGHT, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the next semantic unit, typically the end of the current line. 280 //auto(Shortcut.registerSystemCut("apple-reserved-47", tr(reserved), KeyEvent.VK_RIGHT, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection one character to the right. 281 //auto(Shortcut.registerSystemCut("apple-reserved-48", tr(reserved), KeyEvent.VK_RIGHT, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the end of the current word, then to the end of the next word. 282 283 Shortcut.registerSystemShortcut("system:movefocusright", tr(reserved), KeyEvent.VK_RIGHT, InputEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview. 284 285 auto(Shortcut.registerSystemShortcut("apple-reserved-49", tr(reserved), KeyEvent.VK_LEFT, InputEvent.META_DOWN_MASK)); // Change the keyboard layout to current layout of system script. 286 //auto(Shortcut.registerSystemCut("apple-reserved-50", tr(reserved), KeyEvent.VK_LEFT, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the previous semantic unit, typically the beginning of the current line. 287 //auto(Shortcut.registerSystemCut("apple-reserved-51", tr(reserved), KeyEvent.VK_LEFT, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection one character to the left. 288 //auto(Shortcut.registerSystemCut("apple-reserved-52", tr(reserved), KeyEvent.VK_LEFT, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the beginning of the current word, then to the beginning of the previous word. 289 290 Shortcut.registerSystemShortcut("system:movefocusleft", tr(reserved), KeyEvent.VK_LEFT, InputEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview. 291 292 //auto(Shortcut.registerSystemCut("apple-reserved-53", tr(reserved), KeyEvent.VK_UP, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection upward in the next semantic unit, typically the beginning of the document. 293 //auto(Shortcut.registerSystemCut("apple-reserved-54", tr(reserved), KeyEvent.VK_UP, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the line above, to the nearest character boundary at the same horizontal location. 294 //auto(Shortcut.registerSystemCut("apple-reserved-55", tr(reserved), KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the beginning of the current paragraph, then to the beginning of the next paragraph. 295 296 Shortcut.registerSystemShortcut("system:movefocusup", tr(reserved), KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview. 297 298 //auto(Shortcut.registerSystemCut("apple-reserved-56", tr(reserved), KeyEvent.VK_DOWN, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection downward in the next semantic unit, typically the end of the document. 299 //auto(Shortcut.registerSystemCut("apple-reserved-57", tr(reserved), KeyEvent.VK_DOWN, KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the line below, to the nearest character boundary at the same horizontal location. 300 //auto(Shortcut.registerSystemCut("apple-reserved-58", tr(reserved), KeyEvent.VK_DOWN, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)); // Extend selection to the end of the current paragraph, then to the end of the next paragraph (include the blank line between paragraphs in cut, copy, and paste operations). 301 302 Shortcut.registerSystemShortcut("system:movefocusdown", tr(reserved), KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK); // Move focus to another value or cell within a view, such as a table. See Accessibility Overview. 303 304 auto(Shortcut.registerSystemShortcut("system:about", tr(reserved), 0, -1)); // About 305 306 //Shortcut.registerSystemShortcut("view:zoomin", tr(reserved), KeyEvent.VK_ADD, KeyEvent.META_DOWN_MASK); // Zoom in 307 //Shortcut.registerSystemShortcut("view:zoomout", tr(reserved), KeyEvent.VK_SUBTRACT, KeyEvent.META_DOWN_MASK); // Zoom out 373 308 // CHECKSTYLE.ON: LineLength 374 309 } … … 380 315 } 381 316 317 private static String getHome() { 318 return getSystemProperty("user.home"); 319 } 320 382 321 @Override 383 322 public String getDefaultStyle() { … … 399 338 StringBuilder sb = new StringBuilder(); 400 339 try { 401 sb.append(exec("sw_vers", "-productName")) 340 String swVers = "sw_vers"; 341 sb.append(exec(swVers, "-productName")) 402 342 .append(' ') 403 .append(exec( "sw_vers", "-productVersion"))343 .append(exec(swVers, "-productVersion")) 404 344 .append(" (") 405 .append(exec( "sw_vers", "-buildVersion"))345 .append(exec(swVers, "-buildVersion")) 406 346 .append(')'); 407 347 } catch (IOException e) { … … 421 361 @Override 422 362 public File getDefaultCacheDirectory() { 423 return new File(get SystemProperty("user.home")+"/Library/Caches",363 return new File(getHome() + "/Library/Caches", 424 364 Preferences.getJOSMDirectoryBaseName()); 425 365 } … … 427 367 @Override 428 368 public File getDefaultPrefDirectory() { 429 return new File(get SystemProperty("user.home")+"/Library/Preferences",369 return new File(getHome() + "/Library/Preferences", 430 370 Preferences.getJOSMDirectoryBaseName()); 431 371 } … … 433 373 @Override 434 374 public File getDefaultUserDataDirectory() { 435 return new File(get SystemProperty("user.home")+"/Library",375 return new File(getHome() + "/Library", 436 376 Preferences.getJOSMDirectoryBaseName()); 437 377 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r18985 r19103 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.Utils.getSystemEnv; … … 7 8 8 9 import java.awt.Desktop; 10 import java.awt.event.InputEvent; 9 11 import java.awt.event.KeyEvent; 10 12 import java.io.BufferedReader; … … 29 31 import java.util.Set; 30 32 import java.util.concurrent.ExecutionException; 33 import java.util.regex.Matcher; 34 import java.util.regex.Pattern; 31 35 32 36 import org.openstreetmap.josm.data.Preferences; … … 51 55 // See #12022, #16666 - Disable GNOME ATK Java wrapper as it causes a lot of serious trouble 52 56 if (isDebianOrUbuntu()) { 53 if (Utils.getJavaVersion() >= 9) { 54 // TODO: find a way to disable ATK wrapper on Java >= 9 55 // We should probably be able to do that by embedding a no-op AccessibilityProvider in our jar 56 // so that it is loaded by ServiceLoader without error 57 // But this require to compile at least one class with Java 9 58 } else { 59 // Java 8 does a simple Class.newInstance() from system classloader 60 Utils.updateSystemProperty("javax.accessibility.assistive_technologies", "java.lang.Object"); 61 } 62 } 63 } 64 65 @Override 66 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 67 SanityCheckCallback sanityCheckCallback) { 68 checkWebStartMigration(webStartCallback); 69 PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback); 57 // TODO: find a way to disable ATK wrapper on Java >= 9 58 // We should probably be able to do that by embedding a no-op AccessibilityProvider in our jar 59 // so that it is loaded by ServiceLoader without error 60 // But this require to compile at least one class with Java 9 61 } 62 } 63 64 @Override 65 public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) { 66 PlatformHook.super.startupHook(javaCallback, sanityCheckCallback); 70 67 } 71 68 … … 91 88 92 89 @Override 90 @SuppressWarnings("squid:S103") // NOSONAR LineLength 93 91 public void initSystemShortcuts() { 92 final String reserved = marktr("reserved"); 94 93 // CHECKSTYLE.OFF: LineLength 95 94 // TODO: Insert system shortcuts here. See Windows and especially OSX to see how to. 96 95 for (int i = KeyEvent.VK_F1; i <= KeyEvent.VK_F12; ++i) { 97 Shortcut.registerSystemShortcut("screen:to ogle"+i, tr("reserved"), i, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)96 Shortcut.registerSystemShortcut("screen:toggle"+i, tr(reserved), i, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK) 98 97 .setAutomatic(); 99 98 } 100 Shortcut.registerSystemShortcut("system:reset", tr( "reserved"), KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)99 Shortcut.registerSystemShortcut("system:reset", tr(reserved), KeyEvent.VK_DELETE, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK) 101 100 .setAutomatic(); 102 Shortcut.registerSystemShortcut("system:resetX", tr( "reserved"), KeyEvent.VK_BACK_SPACE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)101 Shortcut.registerSystemShortcut("system:resetX", tr(reserved), KeyEvent.VK_BACK_SPACE, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK) 103 102 .setAutomatic(); 104 103 // CHECKSTYLE.ON: LineLength … … 175 174 /** 176 175 * Get the Java package name including detailed version. 177 * 176 * <p> 178 177 * Some Java bugs are specific to a certain security update, so in addition 179 178 * to the Java version, we also need the exact package version. … … 183 182 public String getJavaPackageDetails() { 184 183 String home = getSystemProperty("java.home"); 185 if (home.contains("java-8-openjdk") || home.contains("java-1.8.0-openjdk")) { 186 return getPackageDetails("openjdk-8-jre", "java-1_8_0-openjdk", "java-1.8.0-openjdk"); 187 } else if (home.contains("java-9-openjdk") || home.contains("java-1.9.0-openjdk")) { 188 return getPackageDetails("openjdk-9-jre", "java-1_9_0-openjdk", "java-1.9.0-openjdk", "java-9-openjdk"); 189 } else if (home.contains("java-10-openjdk")) { 190 return getPackageDetails("openjdk-10-jre", "java-10-openjdk"); 191 } else if (home.contains("java-11-openjdk")) { 192 return getPackageDetails("openjdk-11-jre", "java-11-openjdk"); 193 } else if (home.contains("java-17-openjdk")) { 194 return getPackageDetails("openjdk-17-jre", "java-17-openjdk"); 184 if (home == null) { 185 return null; 186 } 187 Matcher matcher = Pattern.compile("java-(\\d+)-openjdk").matcher(home); 188 if (matcher.find()) { 189 String version = matcher.group(1); 190 return getPackageDetails("openjdk-" + version + "-jre", "java-" + version + "-openjdk"); 195 191 } else if (home.contains("java-openjdk")) { 196 192 return getPackageDetails("java-openjdk"); … … 205 201 /** 206 202 * Get the Web Start package name including detailed version. 207 * 203 * <p> 208 204 * OpenJDK packages are shipped with icedtea-web package, 209 205 * but its version generally does not match main java package version. 210 * 206 * <p> 211 207 * Simply return {@code null} if there's no separate package for Java WebStart. 212 208 * … … 222 218 /** 223 219 * Get the Gnome ATK wrapper package name including detailed version. 224 * 220 * <p> 225 221 * Debian and Ubuntu derivatives come with a pre-enabled accessibility software 226 222 * completely buggy that makes Swing crash in a lot of different ways. 227 * 223 * <p> 228 224 * Simply return {@code null} if it's not found. 229 225 * -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r19041 r19103 26 26 import static java.awt.event.KeyEvent.VK_Y; 27 27 import static java.awt.event.KeyEvent.VK_Z; 28 import static org.openstreetmap.josm.tools.I18n.marktr; 28 29 import static org.openstreetmap.josm.tools.I18n.tr; 29 30 import static org.openstreetmap.josm.tools.Utils.getSystemEnv; … … 93 94 /** 94 95 * Simple data class to hold information about a font. 95 * 96 * <p> 96 97 * Used for fontconfig.properties files. 97 98 */ … … 154 155 155 156 @Override 156 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 157 SanityCheckCallback sanityCheckCallback) { 157 public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) { 158 158 warnSoonToBeUnsupportedJava(javaCallback); 159 159 checkExpiredJava(javaCallback); 160 checkWebStartMigration(webStartCallback); 161 PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback); 160 PlatformHook.super.startupHook(javaCallback, sanityCheckCallback); 162 161 } 163 162 … … 181 180 182 181 @Override 182 @SuppressWarnings("squid:S103") // NOSONAR LineLength 183 183 public void initSystemShortcuts() { 184 final String reserved = marktr("reserved"); 184 185 // CHECKSTYLE.OFF: LineLength 185 //Shortcut.registerSystemCut("system:menuexit", tr( "reserved"), VK_Q, CTRL_DOWN_MASK);186 Shortcut.registerSystemShortcut("system:duplicate", tr( "reserved"), VK_D, CTRL_DOWN_MASK); // not really system, but to avoid odd results186 //Shortcut.registerSystemCut("system:menuexit", tr(reserved), VK_Q, CTRL_DOWN_MASK); 187 Shortcut.registerSystemShortcut("system:duplicate", tr(reserved), VK_D, CTRL_DOWN_MASK); // not really system, but to avoid odd results 187 188 188 189 // Windows 7 shortcuts: http://windows.microsoft.com/en-US/windows7/Keyboard-shortcuts … … 191 192 192 193 // Don't know why Ctrl-Alt-Del isn't even listed on official Microsoft support page 193 Shortcut.registerSystemShortcut("system:reset", tr( "reserved"), VK_DELETE, CTRL_DOWN_MASK | ALT_DOWN_MASK).setAutomatic();194 Shortcut.registerSystemShortcut("system:reset", tr(reserved), VK_DELETE, CTRL_DOWN_MASK | ALT_DOWN_MASK).setAutomatic(); 194 195 195 196 // Ease of Access keyboard shortcuts 196 Shortcut.registerSystemShortcut("microsoft-reserved-01", tr( "reserved"), VK_PRINTSCREEN, ALT_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Turn High Contrast on or off197 Shortcut.registerSystemShortcut("microsoft-reserved-02", tr( "reserved"), VK_NUM_LOCK, ALT_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Turn Mouse Keys on or off198 //Shortcut.registerSystemCut("microsoft-reserved-03", tr( "reserved"), VK_U, );// Open the Ease of Access Center (TODO: Windows-U, how to handle it in Java ?)197 Shortcut.registerSystemShortcut("microsoft-reserved-01", tr(reserved), VK_PRINTSCREEN, ALT_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Turn High Contrast on or off 198 Shortcut.registerSystemShortcut("microsoft-reserved-02", tr(reserved), VK_NUM_LOCK, ALT_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Turn Mouse Keys on or off 199 //Shortcut.registerSystemCut("microsoft-reserved-03", tr(reserved), VK_U, );// Open the Ease of Access Center (TODO: Windows-U, how to handle it in Java ?) 199 200 200 201 // General keyboard shortcuts 201 //Shortcut.registerSystemShortcut("system:help", tr( "reserved"), VK_F1, 0); // Display Help202 Shortcut.registerSystemShortcut("system:copy", tr( "reserved"), VK_C, CTRL_DOWN_MASK); // Copy the selected item203 Shortcut.registerSystemShortcut("system:cut", tr( "reserved"), VK_X, CTRL_DOWN_MASK); // Cut the selected item204 Shortcut.registerSystemShortcut("system:paste", tr( "reserved"), VK_V, CTRL_DOWN_MASK); // Paste the selected item205 Shortcut.registerSystemShortcut("system:undo", tr( "reserved"), VK_Z, CTRL_DOWN_MASK); // Undo an action206 Shortcut.registerSystemShortcut("system:redo", tr( "reserved"), VK_Y, CTRL_DOWN_MASK); // Redo an action207 //Shortcut.registerSystemCut("microsoft-reserved-10", tr( "reserved"), VK_DELETE, 0); // Delete the selected item and move it to the Recycle Bin208 //Shortcut.registerSystemCut("microsoft-reserved-11", tr( "reserved"), VK_DELETE, SHIFT_DOWN_MASK); // Delete the selected item without moving it to the Recycle Bin first209 //Shortcut.registerSystemCut("system:rename", tr( "reserved"), VK_F2, 0); // Rename the selected item210 Shortcut.registerSystemShortcut("system:movefocusright", tr( "reserved"), VK_RIGHT, CTRL_DOWN_MASK); // Move the cursor to the beginning of the next word211 Shortcut.registerSystemShortcut("system:movefocusleft", tr( "reserved"), VK_LEFT, CTRL_DOWN_MASK); // Move the cursor to the beginning of the previous word212 Shortcut.registerSystemShortcut("system:movefocusdown", tr( "reserved"), VK_DOWN, CTRL_DOWN_MASK); // Move the cursor to the beginning of the next paragraph213 Shortcut.registerSystemShortcut("system:movefocusup", tr( "reserved"), VK_UP, CTRL_DOWN_MASK); // Move the cursor to the beginning of the previous paragraph214 //Shortcut.registerSystemCut("microsoft-reserved-17", tr( "reserved"), VK_RIGHT, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text215 //Shortcut.registerSystemCut("microsoft-reserved-18", tr( "reserved"), VK_LEFT, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text216 //Shortcut.registerSystemCut("microsoft-reserved-19", tr( "reserved"), VK_DOWN, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text217 //Shortcut.registerSystemCut("microsoft-reserved-20", tr( "reserved"), VK_UP, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text218 //Shortcut.registerSystemCut("microsoft-reserved-21", tr( "reserved"), VK_RIGHT, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document219 //Shortcut.registerSystemCut("microsoft-reserved-22", tr( "reserved"), VK_LEFT, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document220 //Shortcut.registerSystemCut("microsoft-reserved-23", tr( "reserved"), VK_DOWN, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document221 //Shortcut.registerSystemCut("microsoft-reserved-24", tr( "reserved"), VK_UP, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document222 //Shortcut.registerSystemCut("microsoft-reserved-25", tr( "reserved"), VK_RIGHT+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?)223 //Shortcut.registerSystemCut("microsoft-reserved-26", tr( "reserved"), VK_LEFT+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?)224 //Shortcut.registerSystemCut("microsoft-reserved-27", tr( "reserved"), VK_DOWN+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?)225 //Shortcut.registerSystemCut("microsoft-reserved-28", tr( "reserved"), VK_UP+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?)226 Shortcut.registerSystemShortcut("system:selectall", tr( "reserved"), VK_A, CTRL_DOWN_MASK); // Select all items in a document or window227 //Shortcut.registerSystemCut("system:search", tr( "reserved"), VK_F3, 0); // Search for a file or folder228 Shortcut.registerSystemShortcut("microsoft-reserved-31", tr( "reserved"), VK_ENTER, ALT_DOWN_MASK).setAutomatic(); // Display properties for the selected item229 Shortcut.registerSystemShortcut("system:exit", tr( "reserved"), VK_F4, ALT_DOWN_MASK).setAutomatic(); // Close the active item, or exit the active program230 Shortcut.registerSystemShortcut("microsoft-reserved-33", tr( "reserved"), VK_SPACE, ALT_DOWN_MASK).setAutomatic(); // Open the shortcut menu for the active window231 //Shortcut.registerSystemCut("microsoft-reserved-34", tr( "reserved"), VK_F4, CTRL_DOWN_MASK); // Close the active document (in programs that allow you to have multiple documents open simultaneously)232 Shortcut.registerSystemShortcut("microsoft-reserved-35", tr( "reserved"), VK_TAB, ALT_DOWN_MASK).setAutomatic(); // Switch between open items233 Shortcut.registerSystemShortcut("microsoft-reserved-36", tr( "reserved"), VK_TAB, CTRL_DOWN_MASK | ALT_DOWN_MASK).setAutomatic(); // Use the arrow keys to switch between open items234 //Shortcut.registerSystemCut("microsoft-reserved-37", tr( "reserved"), VK_TAB, ); // Cycle through programs on the taskbar by using Aero Flip 3-D (TODO: Windows-Tab, how to handle it in Java ?)235 //Shortcut.registerSystemCut("microsoft-reserved-38", tr( "reserved"), VK_TAB, CTRL_DOWN_MASK | ); // Use the arrow keys to cycle through programs on the taskbar by using Aero Flip 3-D (TODO: Ctrl-Windows-Tab, how to handle it in Java ?)236 Shortcut.registerSystemShortcut("microsoft-reserved-39", tr( "reserved"), VK_ESCAPE, ALT_DOWN_MASK).setAutomatic(); // Cycle through items in the order in which they were opened237 //Shortcut.registerSystemCut("microsoft-reserved-40", tr( "reserved"), VK_F6, 0); // Cycle through screen elements in a window or on the desktop238 //Shortcut.registerSystemCut("microsoft-reserved-41", tr( "reserved"), VK_F4, 0); // Display the address bar list in Windows Explorer239 Shortcut.registerSystemShortcut("microsoft-reserved-42", tr( "reserved"), VK_F10, SHIFT_DOWN_MASK); // Display the shortcut menu for the selected item240 Shortcut.registerSystemShortcut("microsoft-reserved-43", tr( "reserved"), VK_ESCAPE, CTRL_DOWN_MASK).setAutomatic(); // Open the Start menu241 //Shortcut.registerSystemShortcut("microsoft-reserved-44", tr( "reserved"), VK_F10, 0); // Activate the menu bar in the active program242 //Shortcut.registerSystemCut("microsoft-reserved-45", tr( "reserved"), VK_RIGHT, 0); // Open the next menu to the right, or open a submenu243 //Shortcut.registerSystemCut("microsoft-reserved-46", tr( "reserved"), VK_LEFT, 0); // Open the next menu to the left, or close a submenu244 //Shortcut.registerSystemCut("microsoft-reserved-47", tr( "reserved"), VK_F5, 0); // Refresh the active window245 //Shortcut.registerSystemCut("microsoft-reserved-48", tr( "reserved"), VK_UP, ALT_DOWN_MASK); // View the folder one level up in Windows Explorer246 //Shortcut.registerSystemCut("microsoft-reserved-49", tr( "reserved"), VK_ESCAPE, 0); // Cancel the current task247 Shortcut.registerSystemShortcut("microsoft-reserved-50", tr( "reserved"), VK_ESCAPE, CTRL_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Open Task Manager248 Shortcut.registerSystemShortcut("microsoft-reserved-51", tr( "reserved"), VK_SHIFT, ALT_DOWN_MASK).setAutomatic(); // Switch the input language when multiple input languages are enabled249 Shortcut.registerSystemShortcut("microsoft-reserved-52", tr( "reserved"), VK_SHIFT, CTRL_DOWN_MASK).setAutomatic(); // Switch the keyboard layout when multiple keyboard layouts are enabled250 //Shortcut.registerSystemCut("microsoft-reserved-53", tr( "reserved"), ); // Change the reading direction of text in right-to-left reading languages (TODO: unclear)202 //Shortcut.registerSystemShortcut("system:help", tr(reserved), VK_F1, 0); // Display Help 203 Shortcut.registerSystemShortcut("system:copy", tr(reserved), VK_C, CTRL_DOWN_MASK); // Copy the selected item 204 Shortcut.registerSystemShortcut("system:cut", tr(reserved), VK_X, CTRL_DOWN_MASK); // Cut the selected item 205 Shortcut.registerSystemShortcut("system:paste", tr(reserved), VK_V, CTRL_DOWN_MASK); // Paste the selected item 206 Shortcut.registerSystemShortcut("system:undo", tr(reserved), VK_Z, CTRL_DOWN_MASK); // Undo an action 207 Shortcut.registerSystemShortcut("system:redo", tr(reserved), VK_Y, CTRL_DOWN_MASK); // Redo an action 208 //Shortcut.registerSystemCut("microsoft-reserved-10", tr(reserved), VK_DELETE, 0); // Delete the selected item and move it to the Recycle Bin 209 //Shortcut.registerSystemCut("microsoft-reserved-11", tr(reserved), VK_DELETE, SHIFT_DOWN_MASK); // Delete the selected item without moving it to the Recycle Bin first 210 //Shortcut.registerSystemCut("system:rename", tr(reserved), VK_F2, 0); // Rename the selected item 211 Shortcut.registerSystemShortcut("system:movefocusright", tr(reserved), VK_RIGHT, CTRL_DOWN_MASK); // Move the cursor to the beginning of the next word 212 Shortcut.registerSystemShortcut("system:movefocusleft", tr(reserved), VK_LEFT, CTRL_DOWN_MASK); // Move the cursor to the beginning of the previous word 213 Shortcut.registerSystemShortcut("system:movefocusdown", tr(reserved), VK_DOWN, CTRL_DOWN_MASK); // Move the cursor to the beginning of the next paragraph 214 Shortcut.registerSystemShortcut("system:movefocusup", tr(reserved), VK_UP, CTRL_DOWN_MASK); // Move the cursor to the beginning of the previous paragraph 215 //Shortcut.registerSystemCut("microsoft-reserved-17", tr(reserved), VK_RIGHT, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text 216 //Shortcut.registerSystemCut("microsoft-reserved-18", tr(reserved), VK_LEFT, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text 217 //Shortcut.registerSystemCut("microsoft-reserved-19", tr(reserved), VK_DOWN, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text 218 //Shortcut.registerSystemCut("microsoft-reserved-20", tr(reserved), VK_UP, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text 219 //Shortcut.registerSystemCut("microsoft-reserved-21", tr(reserved), VK_RIGHT, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document 220 //Shortcut.registerSystemCut("microsoft-reserved-22", tr(reserved), VK_LEFT, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document 221 //Shortcut.registerSystemCut("microsoft-reserved-23", tr(reserved), VK_DOWN, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document 222 //Shortcut.registerSystemCut("microsoft-reserved-24", tr(reserved), VK_UP, SHIFT_DOWN_MASK); // Select more than one item in a window or on the desktop, or select text within a document 223 //Shortcut.registerSystemCut("microsoft-reserved-25", tr(reserved), VK_RIGHT+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?) 224 //Shortcut.registerSystemCut("microsoft-reserved-26", tr(reserved), VK_LEFT+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?) 225 //Shortcut.registerSystemCut("microsoft-reserved-27", tr(reserved), VK_DOWN+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?) 226 //Shortcut.registerSystemCut("microsoft-reserved-28", tr(reserved), VK_UP+, CTRL_DOWN_MASK); // Select multiple individual items in a window or on the desktop (TODO: ctrl+arrow+spacebar, how to handle it in Java ?) 227 Shortcut.registerSystemShortcut("system:selectall", tr(reserved), VK_A, CTRL_DOWN_MASK); // Select all items in a document or window 228 //Shortcut.registerSystemCut("system:search", tr(reserved), VK_F3, 0); // Search for a file or folder 229 Shortcut.registerSystemShortcut("microsoft-reserved-31", tr(reserved), VK_ENTER, ALT_DOWN_MASK).setAutomatic(); // Display properties for the selected item 230 Shortcut.registerSystemShortcut("system:exit", tr(reserved), VK_F4, ALT_DOWN_MASK).setAutomatic(); // Close the active item, or exit the active program 231 Shortcut.registerSystemShortcut("microsoft-reserved-33", tr(reserved), VK_SPACE, ALT_DOWN_MASK).setAutomatic(); // Open the shortcut menu for the active window 232 //Shortcut.registerSystemCut("microsoft-reserved-34", tr(reserved), VK_F4, CTRL_DOWN_MASK); // Close the active document (in programs that allow you to have multiple documents open simultaneously) 233 Shortcut.registerSystemShortcut("microsoft-reserved-35", tr(reserved), VK_TAB, ALT_DOWN_MASK).setAutomatic(); // Switch between open items 234 Shortcut.registerSystemShortcut("microsoft-reserved-36", tr(reserved), VK_TAB, CTRL_DOWN_MASK | ALT_DOWN_MASK).setAutomatic(); // Use the arrow keys to switch between open items 235 //Shortcut.registerSystemCut("microsoft-reserved-37", tr(reserved), VK_TAB, ); // Cycle through programs on the taskbar by using Aero Flip 3-D (TODO: Windows-Tab, how to handle it in Java ?) 236 //Shortcut.registerSystemCut("microsoft-reserved-38", tr(reserved), VK_TAB, CTRL_DOWN_MASK | ); // Use the arrow keys to cycle through programs on the taskbar by using Aero Flip 3-D (TODO: Ctrl-Windows-Tab, how to handle it in Java ?) 237 Shortcut.registerSystemShortcut("microsoft-reserved-39", tr(reserved), VK_ESCAPE, ALT_DOWN_MASK).setAutomatic(); // Cycle through items in the order in which they were opened 238 //Shortcut.registerSystemCut("microsoft-reserved-40", tr(reserved), VK_F6, 0); // Cycle through screen elements in a window or on the desktop 239 //Shortcut.registerSystemCut("microsoft-reserved-41", tr(reserved), VK_F4, 0); // Display the address bar list in Windows Explorer 240 Shortcut.registerSystemShortcut("microsoft-reserved-42", tr(reserved), VK_F10, SHIFT_DOWN_MASK); // Display the shortcut menu for the selected item 241 Shortcut.registerSystemShortcut("microsoft-reserved-43", tr(reserved), VK_ESCAPE, CTRL_DOWN_MASK).setAutomatic(); // Open the Start menu 242 //Shortcut.registerSystemShortcut("microsoft-reserved-44", tr(reserved), VK_F10, 0); // Activate the menu bar in the active program 243 //Shortcut.registerSystemCut("microsoft-reserved-45", tr(reserved), VK_RIGHT, 0); // Open the next menu to the right, or open a submenu 244 //Shortcut.registerSystemCut("microsoft-reserved-46", tr(reserved), VK_LEFT, 0); // Open the next menu to the left, or close a submenu 245 //Shortcut.registerSystemCut("microsoft-reserved-47", tr(reserved), VK_F5, 0); // Refresh the active window 246 //Shortcut.registerSystemCut("microsoft-reserved-48", tr(reserved), VK_UP, ALT_DOWN_MASK); // View the folder one level up in Windows Explorer 247 //Shortcut.registerSystemCut("microsoft-reserved-49", tr(reserved), VK_ESCAPE, 0); // Cancel the current task 248 Shortcut.registerSystemShortcut("microsoft-reserved-50", tr(reserved), VK_ESCAPE, CTRL_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Open Task Manager 249 Shortcut.registerSystemShortcut("microsoft-reserved-51", tr(reserved), VK_SHIFT, ALT_DOWN_MASK).setAutomatic(); // Switch the input language when multiple input languages are enabled 250 Shortcut.registerSystemShortcut("microsoft-reserved-52", tr(reserved), VK_SHIFT, CTRL_DOWN_MASK).setAutomatic(); // Switch the keyboard layout when multiple keyboard layouts are enabled 251 //Shortcut.registerSystemCut("microsoft-reserved-53", tr(reserved), ); // Change the reading direction of text in right-to-left reading languages (TODO: unclear) 251 252 // CHECKSTYLE.ON: LineLength 252 253 } -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java
r18985 r19103 13 13 import org.junit.jupiter.api.BeforeAll; 14 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.condition.EnabledIf; 16 import org.junit.jupiter.api.condition.EnabledOnOs; 17 import org.junit.jupiter.api.condition.OS; 15 18 import org.openstreetmap.josm.spi.preferences.Config; 16 19 … … 35 38 @Test 36 39 void testStartupHook() { 37 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback"),40 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), 38 41 (a, b, c) -> System.out.println("sanity check callback")); 39 42 } … … 51 54 * @throws IOException if an error occurs 52 55 */ 56 @EnabledOnOs(OS.MAC) 53 57 @Test 54 58 void testOpenUrl() throws IOException { 55 assumeTrue(PlatformManager.isPlatformOsx());56 59 hook.openUrl(Config.getUrls().getJOSMWebsite()); 57 60 } -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java
r18985 r19103 46 46 void testStartupHook() { 47 47 final PlatformHook.JavaExpirationCallback javaCallback = (a, b, c, d) -> System.out.println("java callback"); 48 final PlatformHook.WebStartMigrationCallback webstartCallback = u -> System.out.println("webstart callback");49 48 final PlatformHook.SanityCheckCallback sanityCheckCallback = (a, b, c) -> System.out.println("sanity check callback"); 50 assertDoesNotThrow(() -> hook.startupHook(javaCallback, webstartCallback,sanityCheckCallback));49 assertDoesNotThrow(() -> hook.startupHook(javaCallback, sanityCheckCallback)); 51 50 } 52 51 -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r19092 r19103 354 354 355 355 /** 356 * Tests if readBytesFromStream handles null streams (might happen when there is no data on error stream)357 * @throws IOException in case of I/O error358 * @deprecated {@link Utils#readBytesFromStream(InputStream)} is deprecated since the JVM has the same functionality.359 */360 @Test361 @Deprecated362 void testNullStreamForReadBytesFromStream() throws IOException {363 assertEquals(0, Utils.readBytesFromStream(null).length, "Empty on null stream");364 }365 366 /**367 356 * Test of {@link Utils#getLevenshteinDistance} method. 368 357 */
Note:
See TracChangeset
for help on using the changeset viewer.