Changeset 19103 in josm for trunk/src


Ignore:
Timestamp:
2024-06-13T00:23:03+02:00 (5 months ago)
Author:
taylor.smock
Message:

Cleanup some new PMD warnings from PMD 7.x (followup of r19101)

Location:
trunk/src/org/openstreetmap/josm
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r18399 r19103  
    102102
    103103    private final GpxTrackChangeListener proxy = e -> invalidate();
    104     private boolean modified, updating, initializing;
     104    private boolean modified;
     105    private boolean updating;
     106    private boolean initializing;
    105107    private boolean suppressedInvalidate;
    106108
     
    109111     * @see #getTracks()
    110112     */
    111     public final Collection<IGpxTrack> tracks = new ListeningCollection<IGpxTrack>(privateTracks, this::invalidate) {
     113    public final Collection<IGpxTrack> tracks = new ListeningCollection<>(privateTracks, this::invalidate) {
    112114
    113115        @Override
     
    418420                OptionalLong i1 = getTrackFirstWaypointMin(t1);
    419421                OptionalLong i2 = getTrackFirstWaypointMin(t2);
    420                 boolean i1absent = !i1.isPresent();
    421                 boolean i2absent = !i2.isPresent();
     422                boolean i1absent = i1.isEmpty();
     423                boolean i2absent = i2.isEmpty();
    422424                if (i1absent && i2absent) {
    423425                    return 0;
     
    537539                    HashMap<String, Object> attrs = new HashMap<>(trk.getAttributes());
    538540                    ensureUniqueName(attrs, counts, srcLayerName);
    539                     return new GpxTrack(Arrays.asList(seg), attrs);
     541                    return new GpxTrack(Collections.singletonList(seg), attrs);
    540542                }))
    541543            .collect(Collectors.toCollection(ArrayList<GpxTrack>::new));
     
    548550     * Split tracks into layers, the result is one layer for each track.
    549551     * If this layer currently has only one GpxTrack this is a no-operation.
    550      *
     552     * <p>
    551553     * The new GpxLayers are added to the LayerManager, the original GpxLayer
    552554     * is untouched as to preserve potential route or wpt parts.
     
    12581260     */
    12591261    public static class XMLNamespace {
    1260         private final String uri, prefix;
     1262        private final String uri;
     1263        private final String prefix;
    12611264        private String location;
    12621265
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java

    r18208 r19103  
    229229        stream(prefix, key)
    230230        .collect(Collectors.toList()) //needs to be collected to avoid concurrent modification
    231         .forEach(e -> super.remove(e));
     231        .forEach(super::remove);
    232232    }
    233233
     
    240240        .filter(e -> Objects.equals(prefix, e.getPrefix()))
    241241        .collect(Collectors.toList()) //needs to be collected to avoid concurrent modification
    242         .forEach(e -> super.remove(e));
     242        .forEach(super::remove);
    243243    }
    244244
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r18989 r19103  
    8080         */
    8181        @Override
    82         public final String getTypeString() {
     82        public String getTypeString() {
    8383            return typeString;
    8484        }
     
    143143         */
    144144        @Override
    145         public final String getCategoryString() {
     145        public String getCategoryString() {
    146146            return category;
    147147        }
     
    152152         */
    153153        @Override
    154         public final String getDescription() {
     154        public String getDescription() {
    155155            return description;
    156156        }
     
    163163         */
    164164        @Override
    165         public final ImageIcon getIcon(ImageSizes size) {
     165        public ImageIcon getIcon(ImageSizes size) {
    166166            return iconCache
    167167                    .computeIfAbsent(size, x -> Collections.synchronizedMap(new EnumMap<>(ImageryCategory.class)))
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java

    r17975 r19103  
    7070     */
    7171    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());
    7373    }
    7474
     
    9797     */
    9898    public static ThreadPoolExecutor getNewThreadPoolExecutor(String name) {
    99         return getNewThreadPoolExecutor(name, THREAD_LIMIT.get().intValue());
     99        return getNewThreadPoolExecutor(name, THREAD_LIMIT.get());
    100100    }
    101101
  • trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/MVTTile.java

    r18478 r19103  
    5656            for (ProtobufRecord protoBufRecord : protobufRecords) {
    5757                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())) {
    5960                        this.layers.add(new Layer(tParser.allRecords()));
    6061                    } catch (IOException e) {
    6162                        Logging.error(e);
    62                     } finally {
    63                         // Cleanup bytes
    64                         protoBufRecord.close();
    6563                    }
    6664                }
  • trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/Layers.java

    r19080 r19103  
    5959    }
    6060
     61    private static final String DEFAULT_COLOR = "#000000";
    6162    private static final char SEMI_COLON = ';';
    6263    private static final Pattern CURLY_BRACES = Pattern.compile("(\\{(.*?)})");
     
    186187        // line-blur, default 0 (px)
    187188        // 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);
    189190        sb.append(StyleKeys.COLOR).append(':').append(color).append(SEMI_COLON);
    190191        // line-opacity, default 1 (0-1)
     
    210211        if (paintObject.containsKey("line-dasharray")) {
    211212            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);
    216217        }
    217218        // line-gap-width
     
    235236          // circle-blur
    236237          // 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);
    238239        // circle-opacity
    239240        final JsonNumber fillOpacity = paintObject.getJsonNumber("circle-opacity");
     
    246247          // circle-sort-key
    247248          // 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);
    249250        // circle-stroke-opacity
    250251        final JsonNumber strokeOpacity = paintObject.getJsonNumber("circle-stroke-opacity");
     
    277278            }
    278279            Matcher matcher = CURLY_BRACES.matcher(layoutObject.getString("icon-image"));
    279             StringBuffer stringBuffer = new StringBuffer();
     280            StringBuilder stringBuffer = new StringBuilder();
    280281            int previousMatch;
    281282            if (matcher.lookingAt()) {
     
    299300                stringBuffer.append('"');
    300301            }
    301             StringBuffer tail = new StringBuffer();
     302            StringBuilder tail = new StringBuilder();
    302303            matcher.appendTail(tail);
    303304            if (tail.length() > 0) {
     
    375376                        .orElseGet(() -> fontMatches.stream().filter(font -> font.getFamily().equals(fontString)).findAny().orElse(null))));
    376377                    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);
    380381                        break;
    381382                    }
     
    439440          // fill-antialias
    440441          // 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);
    442443        // fill-opacity
    443444        final JsonNumber opacity = paintObject.getJsonNumber(StyleKeys.FILL_OPACITY);
     
    445446          // fill-outline-color
    446447          .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);
    448449        // fill-pattern
    449450        // fill-sort-key
  • trunk/src/org/openstreetmap/josm/data/osm/OsmData.java

    r17862 r19103  
    283283     */
    284284    default void clearHighlightedVirtualNodes() {
    285         setHighlightedVirtualNodes(new ArrayList<WaySegment>());
     285        setHighlightedVirtualNodes(new ArrayList<>());
    286286    }
    287287
     
    290290     */
    291291    default void clearHighlightedWaySegments() {
    292         setHighlightedWaySegments(new ArrayList<WaySegment>());
     292        setHighlightedWaySegments(new ArrayList<>());
    293293    }
    294294
     
    327327     * Replies an unmodifiable collection of primitives currently selected
    328328     * in this dataset, except deleted ones. May be empty, but not null.
    329      *
     329     * <p>
    330330     * When iterating through the set it is ordered by the order in which the primitives were added to the selection.
    331331     *
     
    339339     * Replies an unmodifiable collection of primitives currently selected
    340340     * in this dataset, including deleted ones. May be empty, but not null.
    341      *
     341     * <p>
    342342     * When iterating through the set it is ordered by the order in which the primitives were added to the selection.
    343343     *
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r19050 r19103  
    397397
    398398    /**
    399      * Asks user to migrate to OpenWebStart
    400      * @param url download URL
    401      * @since 17679
    402      */
    403     public static void askMigrateWebStart(String url) {
    404         // CHECKSTYLE.OFF: LineLength
    405         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: LineLength
    414     }
    415 
    416     /**
    417399     * Tells the user that a sanity check failed
    418400     * @param title The title of the message to show
  • trunk/src/org/openstreetmap/josm/gui/MainInitialization.java

    r19050 r19103  
    7272            new InitializationTask(tr("Starting file watcher"), FileWatcher.getDefaultInstance()::start),
    7373            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)),
    7675            new InitializationTask(tr("Building main menu"), application::initializeMainWindow),
    7776            new InitializationTask(tr("Updating user interface"), () -> {
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r18287 r19103  
    7979    /**
    8080     * used by {@link ChooseTrackVisibilityAction} to determine which tracks to show/hide
    81      *
     81     * <p>
    8282     * Call {@link #invalidate()} after each change!
    83      *
     83     * <p>
    8484     * TODO: Make it private, make it respond to track changes.
    8585     */
     
    146146        if (data == null)
    147147            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);
    149149        return c.length == 1 ? c[0] : null; //only return if exactly one distinct color present
    150150    }
     
    210210
    211211        if (!data.getTracks().isEmpty()) {
     212            String tdSep = "</td><td>";
    212213            info.append("<table><thead align='center'><tr><td colspan='5'>")
    213214                .append(trn("{0} track, {1} track segments", "{0} tracks, {1} track segments",
     
    215216                        data.getTrackSegsCount(), data.getTrackSegsCount()))
    216217                .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"))
    222223                .append("</td></tr></thead>");
    223224
    224225            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);
    236237                if (trk.getAttributes().containsKey("url")) {
    237238                    info.append(trk.get("url"));
     
    287288        if (isExpertMode && expert.stream().anyMatch(Action::isEnabled)) {
    288289            entries.add(SeparatorLayerAction.INSTANCE);
    289             expert.stream().filter(Action::isEnabled).forEach(entries::add);
     290            entries.addAll(expert.stream().filter(Action::isEnabled).collect(Collectors.toList()));
    290291        }
    291292
     
    621622
    622623    private void jumpToNext(List<IGpxTrackSegment> segments) {
    623         if (segments.isEmpty()) {
    624             return;
    625         } else if (currentSegment == null) {
     624        if (!segments.isEmpty() && currentSegment == null) {
    626625            currentSegment = segments.get(0);
    627626            MainApplication.getMap().mapView.zoomTo(currentSegment.getBounds());
    628         } else {
     627        } else if (!segments.isEmpty()) {
    629628            try {
    630629                int index = segments.indexOf(currentSegment);
    631630                currentSegment = segments.listIterator(index + 1).next();
    632631                MainApplication.getMap().mapView.zoomTo(currentSegment.getBounds());
    633             } catch (IndexOutOfBoundsException | NoSuchElementException ignore) {
    634                 Logging.trace(ignore);
     632            } catch (IndexOutOfBoundsException | NoSuchElementException exception) {
     633                Logging.trace(exception);
    635634            }
    636635        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/TMSSettingsPanel.java

    r15586 r19103  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.GridBagConstraints;
    67import java.awt.GridBagLayout;
    78
     
    4041        super(new GridBagLayout());
    4142        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),
    4344                TMSLayer.MIN_ZOOM,
    4445                TMSLayer.MAX_ZOOM, 1));
    4546        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),
    4748                TMSLayer.MIN_ZOOM,
    4849                TMSLayer.MAX_ZOOM, 1));
     
    5556        add(new JLabel(tr("Auto zoom by default: ")), GBC.std());
    5657        add(GBC.glue(5, 0), GBC.std());
    57         add(autozoomActive, GBC.eol().fill(GBC.HORIZONTAL));
     58        add(autozoomActive, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    5859
    5960        add(new JLabel(tr("Autoload tiles by default: ")), GBC.std());
    6061        add(GBC.glue(5, 0), GBC.std());
    61         add(autoloadTiles, GBC.eol().fill(GBC.HORIZONTAL));
     62        add(autoloadTiles, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    6263
    6364        add(new JLabel(tr("Min. zoom level: ")), GBC.std());
     
    7172        add(new JLabel(tr("Add to slippymap chooser: ")), GBC.std());
    7273        add(GBC.glue(5, 0), GBC.std());
    73         add(addToSlippyMapChosser, GBC.eol().fill(GBC.HORIZONTAL));
     74        add(addToSlippyMapChosser, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    7475
    7576        add(new JLabel(tr("Maximum concurrent downloads: ")), GBC.std());
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java

    r18871 r19103  
    107107    }
    108108
     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     */
    109114    static class HashSetWithLast<E> extends LinkedHashSet<E> {
    110115        private static final long serialVersionUID = 1L;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java

    r18260 r19103  
    1111import java.awt.event.ComponentAdapter;
    1212import java.awt.event.ComponentEvent;
    13 import java.util.Arrays;
     13import java.util.Collections;
    1414import java.util.Comparator;
    1515
     
    104104        addEntry(PresetListEntry.ENTRY_EMPTY);
    105105
    106         usage.map.forEach((value, count) -> {
    107             addEntry(new PresetListEntry(value, this));
    108         });
     106        usage.map.forEach((value, count) -> addEntry(new PresetListEntry(value, this)));
    109107
    110108        combobox = new JosmComboBox<>(dropDownModel);
     
    125123
    126124        autoCompModel = new AutoCompComboBoxModel<>(Comparator.<AutoCompletionItem>naturalOrder());
    127         getAllForKeys(Arrays.asList(key)).forEach(autoCompModel::addElement);
     125        getAllForKeys(Collections.singletonList(key)).forEach(autoCompModel::addElement);
    128126        getDisplayValues().forEach(s -> autoCompModel.addElement(new AutoCompletionItem(s, AutoCompletionPriority.IS_IN_STANDARD)));
    129127
     
    131129        tf.setModel(autoCompModel);
    132130
    133         if (TaggingPresetItem.DISPLAY_KEYS_AS_HINT.get()) {
     131        if (Boolean.TRUE.equals(TaggingPresetItem.DISPLAY_KEYS_AS_HINT.get())) {
    134132            combobox.setHint(key);
    135133        }
     
    218216        if (sel instanceof String) {
    219217            // 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, eg. if the user did an
     218            // to avoid that we write a display_value to the tag's value, e.g. if the user did an
    221219            // undo.
    222220            PresetListEntry selItem = dropDownModel.find((String) sel);
  • trunk/src/org/openstreetmap/josm/gui/widgets/ChangesetIdTextField.java

    r19080 r19103  
    7979                id = 0;
    8080                try {
    81                     if (value.matches("http.*/changeset/[0-9]+")) {
     81                    if (value.matches("http.*/changeset/\\d+")) {
    8282                        // full URL given, extract id
    8383                        value = value.substring(value.lastIndexOf('/') + 1);
  • trunk/src/org/openstreetmap/josm/gui/widgets/EditableList.java

    r18211 r19103  
    3434     * The list items
    3535     */
    36     public final JList<String> sourcesList = new JList<>(new DefaultListModel<String>());
     36    public final JList<String> sourcesList = new JList<>(new DefaultListModel<>());
    3737    /**
    3838     * The add button
  • trunk/src/org/openstreetmap/josm/gui/widgets/HistoryComboBoxModel.java

    r18173 r19103  
    3131     */
    3232    public void addAllStrings(List<String> strings) {
    33         strings.forEach(s -> addElement(s));
     33        strings.forEach(this::addElement);
    3434    }
    3535
     
    4141    public List<String> asStringList() {
    4242        List<String> list = new ArrayList<>(getSize());
    43         this.forEach(item -> list.add(item));
     43        this.forEach(list::add);
    4444        return list;
    4545    }
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBox.java

    r18313 r19103  
    6767     */
    6868    public JosmComboBox() {
    69         super(new JosmComboBoxModel<E>());
     69        super(new JosmComboBoxModel<>());
    7070        init();
    7171    }
     
    8585     * @deprecated use {@link #setPrototypeDisplayValue} instead.
    8686     */
    87     @Deprecated
     87    @Deprecated(since = "18221", forRemoval = true)
    8888    public JosmComboBox(E prototypeDisplayValue) {
    89         super(new JosmComboBoxModel<E>());
     89        super(new JosmComboBoxModel<>());
    9090        setPrototypeDisplayValue(prototypeDisplayValue);
    9191        init();
     
    111111     * @deprecated use {@link #setPrototypeDisplayValue} instead.
    112112     */
    113     @Deprecated
     113    @Deprecated(since = "18221", forRemoval = true)
    114114    public JosmComboBox(JosmComboBoxModel<E> aModel, E prototypeDisplayValue) {
    115115        super(aModel);
     
    126126     */
    127127    public JosmComboBox(E[] items) {
    128         super(new JosmComboBoxModel<E>());
     128        super(new JosmComboBoxModel<>());
    129129        init();
    130130        for (E elem : items) {
     
    206206    /**
    207207     * Selects an item and/or sets text
    208      *
     208     * <p>
    209209     * Selects the item whose {@code toString()} equals {@code text}. If an item could not be found,
    210210     * selects nothing and sets the text anyway.
     
    234234     * Sets the hint to display when no text has been entered.
    235235     *
    236      * @param hint the hint to set
     236     * @param newHint the hint to set
    237237     * @return the old hint
    238238     * @since 18221
    239239     */
    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;
    243243        JosmTextField tf = getEditorComponent();
    244244        if (tf != null)
    245             tf.setHint(hint);
     245            tf.setHint(newHint);
    246246        return old;
    247247    }
     
    288288     * <p>
    289289     * Set this to -1 to get the default behaviour back.
    290      *
     290     * <p>
    291291     * See also: #6157
    292292     *
     
    310310    public JList getList() {
    311311        Object popup = getUI().getAccessibleChild(this, 0);
    312         if (popup != null && popup instanceof javax.swing.plaf.basic.ComboPopup) {
     312        if (popup instanceof javax.swing.plaf.basic.ComboPopup) {
    313313            return ((javax.swing.plaf.basic.ComboPopup) popup).getList();
    314314        }
     
    421421            int rowCount = Math.min(configMaximumRowCount, getItemCount());
    422422            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;
    424425            for (i = 0; i < rowCount; ++i) {
    425426                Component c = r.getListCellRendererComponent(jList, getModel().getElementAt(i), i, false, false);
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBoxModel.java

    r18283 r19103  
    5050    /**
    5151     * Returns the index of the specified element
    52      *
     52     * <p>
    5353     * Note: This is not part of the {@link javax.swing.ComboBoxModel} interface but is defined in
    5454     * {@link javax.swing.DefaultComboBoxModel}.
     
    184184    public void addAllElements(Collection<E> elems) {
    185185        int index0 = elements.size();
    186         elems.forEach(e -> doAddElement(e));
     186        elems.forEach(this::doAddElement);
    187187        int index1 = elements.size() - 1;
    188188        if (index0 <= index1)
     
    269269
    270270        /** 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;
    272272        /** A {@code Function} that serializes {@code <E>} to a {@code String}. */
    273         private Function<E, String> writeE;
     273        private final Function<E, String> writeE;
    274274
    275275        /**
  • trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java

    r18871 r19103  
    7777     * Create a MultiSplitLayout with a default model with a single
    7878     * Leaf node named "default".
    79      *
     79     * <p>
    8080     * #see setModel
    8181     */
     
    8686    /**
    8787     * Create a MultiSplitLayout with the specified model.
    88      *
     88     * <p>
    8989     * #see setModel
    9090     * @param model model
     
    127127
    128128    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))) {
    130130            pcs.firePropertyChange(propertyName, oldValue, newValue);
    131131        }
     
    149149     * property is a Leaf named "default".
    150150     *
    151      * @param model the root of the tree of Split, Leaf, and Divider node
     151     * @param newModel the root of the tree of Split, Leaf, and Divider node
    152152     * @throws IllegalArgumentException if model is a Divider or null
    153153     * @see #getModel
    154154     */
    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))
    157157            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);
    161161    }
    162162
     
    270270            return preferredComponentSize(root);
    271271        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);
    274274        } else {
    275275            Split split = (Split) root;
     
    299299            return (child != null) ? child.getMinimumSize() : new Dimension(0, 0);
    300300        } 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);
    303303        } else {
    304304            Split split = (Split) root;
     
    611611            Iterator<Node> splitChildren = split.getChildren().iterator();
    612612            Rectangle childBounds;
    613             int dividerSize = getDividerSize();
     613            int currentDividerSize = getDividerSize();
    614614
    615615            /* Layout the Split's child Nodes' along the X axis.  The bounds
     
    647647                    if (getFloatingDividers() && (dividerChild != null)) {
    648648                        double dividerX = childBounds.getMaxX();
    649                         Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, dividerSize);
     649                        Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, currentDividerSize);
    650650                        dividerChild.setBounds(dividerBounds);
    651651                    }
     
    680680                    if (getFloatingDividers() && (dividerChild != null)) {
    681681                        double dividerY = childBounds.getMaxY();
    682                         Rectangle dividerBounds = boundsWithYandHeight(bounds, dividerY, dividerSize);
     682                        Rectangle dividerBounds = boundsWithYandHeight(bounds, dividerY, currentDividerSize);
    683683                        dividerChild.setBounds(dividerBounds);
    684684                    }
     
    854854        /**
    855855         * Returns the Split parent of this Node, or null.
    856          *
     856         * <p>
    857857         * This method isn't called getParent(), in order to avoid problems
    858858         * with recursive object creation when using XmlDecoder.
     
    868868         * Set the value of this Node's parent property.  The default
    869869         * value of this property is null.
    870          *
     870         * <p>
    871871         * This method isn't called setParent(), in order to avoid problems
    872872         * with recursive object creation when using XmlEncoder.
     
    936936
    937937        private Node siblingAtOffset(int offset) {
    938             Split parent = getParent();
    939             if (parent == null)
     938            Split currentParent = getParent();
     939            if (currentParent == null)
    940940                return null;
    941             List<Node> siblings = parent.getChildren();
     941            List<Node> siblings = currentParent.getChildren();
    942942            int index = siblings.indexOf(this);
    943943            if (index == -1)
     
    10501050         */
    10511051        public final Node lastWeightedChild() {
    1052             List<Node> children = getChildren();
     1052            List<Node> currentChildren = getChildren();
    10531053            Node weightedChild = null;
    1054             for (Node child : children) {
     1054            for (Node child : currentChildren) {
    10551055                if (child.getWeight() > 0.0) {
    10561056                    weightedChild = child;
     
    10631063        public String toString() {
    10641064            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();
    10721070        }
    10731071    }
  • trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java

    r19080 r19103  
    22package org.openstreetmap.josm.io;
    33
     4import static org.openstreetmap.josm.tools.I18n.marktr;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    3132 */
    3233public 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";
    3337
    3438    /**
     
    102106    /**
    103107     * Restricts the query to changesets owned by the user with user name <code>username</code>.
    104      *
     108     * <p>
    105109     * Caveat: for historical reasons the username might not be unique! It is recommended to use
    106110     * {@link #forUser(int)} to restrict the query to a specific user.
     
    226230            throw new IllegalArgumentException(tr("Illegal latitude value for parameter ''{0}'', got {1}", "minLat", minLat));
    227231        if (!LatLon.isValidLat(maxLat))
    228             throw new IllegalArgumentException(tr("Illegal longitude value for parameter ''{0}'', got {1}", "maxLat", maxLat));
     232            throw new IllegalArgumentException(tr("Illegal latitude value for parameter ''{0}'', got {1}", "maxLat", maxLat));
    229233
    230234        return inBbox(new LatLon(minLon, minLat), new LatLon(maxLon, maxLat));
     
    356360                sb.append('&');
    357361            }
    358             sb.append("time=").append(closedAfter);
    359             sb.append(',').append(createdBefore);
     362            sb.append("time=").append(closedAfter)
     363                    .append(',').append(createdBefore);
    360364        } else if (closedAfter != null) {
    361365            if (sb.length() > 0) {
     
    369373                sb.append('&');
    370374            }
    371             sb.append("open=").append(Boolean.toString(open));
     375            sb.append("open=").append(open);
    372376        } else if (closed != null) {
    373377            if (sb.length() > 0) {
     
    433437        protected int parseUid(String value) throws ChangesetQueryUrlException {
    434438            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));
    437440            int id;
    438441            try {
    439442                id = Integer.parseInt(value);
    440443                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));
    443445            } 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);
    446447            }
    447448            return id;
     
    450451        protected boolean parseBoolean(String value, String parameter) throws ChangesetQueryUrlException {
    451452            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));
    454454            switch (value) {
    455455            case "true":
     
    458458                return false;
    459459            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));
    462461            }
    463462        }
     
    465464        protected Instant parseDate(String value, String parameter) throws ChangesetQueryUrlException {
    466465            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));
    469467            try {
    470468                return DateUtils.parseInstant(value);
    471469            } 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);
    474471            }
    475472        }
     
    478475            String[] dates = value.split(",", -1);
    479476            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));
    482478            if (dates.length == 1)
    483479                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")};
    487482        }
    488483
    489484        protected Collection<Long> parseLongs(String value) {
    490485            if (Utils.isEmpty(value)) {
    491                 return Collections.<Long>emptySet();
     486                return Collections.emptySet();
    492487            } else {
    493488                return Stream.of(value.split(",", -1)).map(Long::valueOf).collect(Collectors.toSet());
     
    502497                switch (k) {
    503498                case "uid":
    504                     if (queryParams.containsKey("display_name"))
     499                    if (queryParams.containsKey(DISPLAY_NAME))
    505500                        throw new ChangesetQueryUrlException(
    506501                                tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''"));
    507502                    csQuery.forUser(parseUid(queryParams.get("uid")));
    508503                    break;
    509                 case "display_name":
     504                case DISPLAY_NAME:
    510505                    if (queryParams.containsKey("uid"))
    511506                        throw new ChangesetQueryUrlException(
    512507                                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));
    514509                    break;
    515510                case "open":
     
    566561        /**
    567562         * 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,
    570565         * see <a href="http://wiki.openstreetmap.org/wiki/API_v0.6#Query:_GET_.2Fapi.2F0.6.2Fchangesets">OSM API</a>.
    571          *
     566         * <p>
    572567         * Example for a query string:<br>
    573568         * <pre>
  • trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java

    r15386 r19103  
    22package org.openstreetmap.josm.io.session;
    33
     4import java.io.IOException;
    45import java.io.OutputStream;
    56import java.io.OutputStreamWriter;
    67import java.io.PrintWriter;
     8import java.io.UncheckedIOException;
    79import java.io.Writer;
    810import java.nio.charset.StandardCharsets;
     
    1214import org.openstreetmap.josm.io.OsmWriter;
    1315import org.openstreetmap.josm.io.OsmWriterFactory;
     16import org.openstreetmap.josm.tools.JosmRuntimeException;
    1417
    1518/**
     
    4043    public static void exportData(DataSet data, OutputStream out) {
    4144        Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
    42         OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, data.getVersion());
    4345        data.getReadLock().lock();
    44         try {
     46        try (OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, data.getVersion())) {
    4547            w.write(data);
    4648            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);
    4753        } finally {
    4854            data.getReadLock().unlock();
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r18986 r19103  
    66import java.awt.GraphicsEnvironment;
    77import java.awt.Toolkit;
    8 import java.awt.event.KeyEvent;
     8import java.awt.event.InputEvent;
    99import java.io.BufferedReader;
    1010import java.io.File;
     
    3939     * Visitor to construct a PlatformHook from a given {@link Platform} object.
    4040     */
    41     PlatformVisitor<PlatformHook> CONSTRUCT_FROM_PLATFORM = new PlatformVisitor<PlatformHook>() {
     41    PlatformVisitor<PlatformHook> CONSTRUCT_FROM_PLATFORM = new PlatformVisitor<>() {
    4242        @Override
    4343        public PlatformHook visitUnixoid() {
     
    6565      * The preStartupHook will be called extremely early. It is
    6666      * guaranteed to be called before the GUI setup has started.
    67       *
     67      * <p>
    6868      * Reason: On OSX we need to inform the Swing libraries
    6969      * that we want to be integrated with the OS before we setup our GUI.
     
    8484
    8585    /**
    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) {
    9796        startupSanityChecks(sanityCheckCallback);
    9897    }
    9998
    10099    /**
    101       * The openURL hook will be used to open an URL in the
     100      * The openURL hook will be used to open a URL in the
    102101      * default web browser.
    103102     * @param url The URL to open
     
    111110      * from the config, but before any shortcuts are read from
    112111      * it or registered from within the application.
    113       *
     112      * <p>
    114113      * Please note that you are not allowed to register any
    115114      * shortcuts from this hook, but only "systemCuts"!
    116       *
     115      * <p>
    117116      * BTW: SystemCuts should be named "system:&lt;whatever&gt;",
    118117      * and it'd be best if you'd recycle the names already used
    119       * by the Windows and OSX hooks. Especially the later has
     118      * by the Windows and OSX hooks. Especially the latter has
    120119      * really many of them.
    121       *
     120      * <p>
    122121      * You should also register any and all shortcuts that the
    123       * operation system handles itself to block JOSM from trying
     122      * operating system handles itself to block JOSM from trying
    124123      * to use them---as that would just not work. Call setAutomatic
    125124      * on them to prevent the keyboard preferences from allowing the
     
    260259    default int getMenuShortcutKeyMaskEx() {
    261260        // To remove when switching to Java 10+, and use Toolkit.getMenuShortcutKeyMaskEx instead
    262         return KeyEvent.CTRL_DOWN_MASK;
     261        return InputEvent.CTRL_DOWN_MASK;
    263262    }
    264263
     
    277276         */
    278277        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 17679
    284      */
    285     @FunctionalInterface
    286     interface WebStartMigrationCallback {
    287         /**
    288          * Asks user to migrate to OpenWebStart.
    289          * @param url download URL
    290          */
    291         void askMigrateWebStart(String url);
    292278    }
    293279
     
    379365
    380366    /**
    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     */
    391370    default void startupSanityChecks(SanityCheckCallback sanityCheckCallback) {
    392371        final String arch = System.getProperty("os.arch");
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r18985 r19103  
    22package org.openstreetmap.josm.tools;
    33
     4import static org.openstreetmap.josm.tools.I18n.marktr;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
     
    78import java.awt.Desktop;
    89import java.awt.GraphicsEnvironment;
     10import java.awt.HeadlessException;
    911import java.awt.Image;
    1012import java.awt.Window;
     13import java.awt.event.InputEvent;
    1114import java.awt.event.KeyEvent;
    1215import java.io.ByteArrayInputStream;
    1316import java.io.File;
    1417import 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;
     18import java.net.URISyntaxException;
    1919import java.nio.charset.StandardCharsets;
    2020import java.security.KeyStoreException;
     
    2424import java.security.cert.X509Certificate;
    2525import java.util.Arrays;
    26 import java.util.List;
    2726import java.util.Objects;
    2827import java.util.concurrent.ExecutionException;
     
    3938 * @since 1023
    4039 */
    41 public class PlatformHookOsx implements PlatformHook, InvocationHandler {
     40public class PlatformHookOsx implements PlatformHook {
    4241
    4342    private String oSBuildNumber;
     
    6968
    7069    @Override
    71     public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback,
    72             SanityCheckCallback sanityCheckCallback) {
     70    public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) {
    7371        // Here we register callbacks for the menu entries in the system menu and file opening through double-click
    7472        // https://openjdk.java.net/jeps/272
    7573        // https://bugs.openjdk.java.net/browse/JDK-8048731
    7674        // https://cr.openjdk.java.net/~azvegint/jdk/9/8143227/10/jdk/
    77         // This method must be cleaned up after we switch to Java 9
    7875        try {
    7976            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();
    9380            }
    9481            // setup the dock icon. It is automatically set with application bundle and Web start but we need
     
    10794        warnSoonToBeUnsupportedJava(javaCallback);
    10895        checkExpiredJava(javaCallback);
    109         checkWebStartMigration(webStartCallback);
    110         PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback);
     96        PlatformHook.super.startupHook(javaCallback, sanityCheckCallback);
    11197    }
    11298
     
    122108    @Override
    123109    public int getMenuShortcutKeyMaskEx() {
    124         return KeyEvent.META_DOWN_MASK;
     110        return InputEvent.META_DOWN_MASK;
    125111    }
    126112
    127113    /**
    128114     * 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     *
    139116     */
    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());
    164135    }
    165136
     
    186157    }
    187158
    188     @SuppressWarnings("unchecked")
    189     @Override
    190     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 instead
    215                     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 
    231159    @Override
    232160    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
    237171    public void initSystemShortcuts() {
     172        final String reserved = marktr("reserved");
    238173        // 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.
    260195        //auto(Shortcut.registerSystemShortcut("apple-reserved-22", tr("reserved"), KeyEvent.VK_F9, 0)); // Tile or untile all open windows.
    261196        //auto(Shortcut.registerSystemShortcut("apple-reserved-23", tr("reserved"), KeyEvent.VK_F10, 0)); // Tile or untile all open windows in the currently active application.
    262197        //auto(Shortcut.registerSystemShortcut("apple-reserved-24", tr("reserved"), KeyEvent.VK_F11, 0)); // Hide or show all open windows.
    263198        //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."
    272207        // 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.
    280215
    281216        // 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."
    311246        // 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)); // About
    370 
    371         //Shortcut.registerSystemShortcut("view:zoomin", tr("reserved"), KeyEvent.VK_ADD, KeyEvent.META_DOWN_MASK); // Zoom in
    372         //Shortcut.registerSystemShortcut("view:zoomout", tr("reserved"), KeyEvent.VK_SUBTRACT, KeyEvent.META_DOWN_MASK); // Zoom out
     247        //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
    373308        // CHECKSTYLE.ON: LineLength
    374309    }
     
    380315    }
    381316
     317    private static String getHome() {
     318        return getSystemProperty("user.home");
     319    }
     320
    382321    @Override
    383322    public String getDefaultStyle() {
     
    399338        StringBuilder sb = new StringBuilder();
    400339        try {
    401             sb.append(exec("sw_vers", "-productName"))
     340            String swVers = "sw_vers";
     341            sb.append(exec(swVers, "-productName"))
    402342              .append(' ')
    403               .append(exec("sw_vers", "-productVersion"))
     343              .append(exec(swVers, "-productVersion"))
    404344              .append(" (")
    405               .append(exec("sw_vers", "-buildVersion"))
     345              .append(exec(swVers, "-buildVersion"))
    406346              .append(')');
    407347        } catch (IOException e) {
     
    421361    @Override
    422362    public File getDefaultCacheDirectory() {
    423         return new File(getSystemProperty("user.home")+"/Library/Caches",
     363        return new File(getHome() + "/Library/Caches",
    424364                Preferences.getJOSMDirectoryBaseName());
    425365    }
     
    427367    @Override
    428368    public File getDefaultPrefDirectory() {
    429         return new File(getSystemProperty("user.home")+"/Library/Preferences",
     369        return new File(getHome() + "/Library/Preferences",
    430370                Preferences.getJOSMDirectoryBaseName());
    431371    }
     
    433373    @Override
    434374    public File getDefaultUserDataDirectory() {
    435         return new File(getSystemProperty("user.home")+"/Library",
     375        return new File(getHome() + "/Library",
    436376                Preferences.getJOSMDirectoryBaseName());
    437377    }
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r18985 r19103  
    22package org.openstreetmap.josm.tools;
    33
     4import static org.openstreetmap.josm.tools.I18n.marktr;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
     
    78
    89import java.awt.Desktop;
     10import java.awt.event.InputEvent;
    911import java.awt.event.KeyEvent;
    1012import java.io.BufferedReader;
     
    2931import java.util.Set;
    3032import java.util.concurrent.ExecutionException;
     33import java.util.regex.Matcher;
     34import java.util.regex.Pattern;
    3135
    3236import org.openstreetmap.josm.data.Preferences;
     
    5155        // See #12022, #16666 - Disable GNOME ATK Java wrapper as it causes a lot of serious trouble
    5256        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);
    7067    }
    7168
     
    9188
    9289    @Override
     90    @SuppressWarnings("squid:S103") // NOSONAR LineLength
    9391    public void initSystemShortcuts() {
     92        final String reserved = marktr("reserved");
    9493        // CHECKSTYLE.OFF: LineLength
    9594        // TODO: Insert system shortcuts here. See Windows and especially OSX to see how to.
    9695        for (int i = KeyEvent.VK_F1; i <= KeyEvent.VK_F12; ++i) {
    97             Shortcut.registerSystemShortcut("screen:toogle"+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)
    9897                .setAutomatic();
    9998        }
    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)
    101100            .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)
    103102            .setAutomatic();
    104103        // CHECKSTYLE.ON: LineLength
     
    175174    /**
    176175     * Get the Java package name including detailed version.
    177      *
     176     * <p>
    178177     * Some Java bugs are specific to a certain security update, so in addition
    179178     * to the Java version, we also need the exact package version.
     
    183182    public String getJavaPackageDetails() {
    184183        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");
    195191        } else if (home.contains("java-openjdk")) {
    196192            return getPackageDetails("java-openjdk");
     
    205201    /**
    206202     * Get the Web Start package name including detailed version.
    207      *
     203     * <p>
    208204     * OpenJDK packages are shipped with icedtea-web package,
    209205     * but its version generally does not match main java package version.
    210      *
     206     * <p>
    211207     * Simply return {@code null} if there's no separate package for Java WebStart.
    212208     *
     
    222218    /**
    223219     * Get the Gnome ATK wrapper package name including detailed version.
    224      *
     220     * <p>
    225221     * Debian and Ubuntu derivatives come with a pre-enabled accessibility software
    226222     * completely buggy that makes Swing crash in a lot of different ways.
    227      *
     223     * <p>
    228224     * Simply return {@code null} if it's not found.
    229225     *
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r19041 r19103  
    2626import static java.awt.event.KeyEvent.VK_Y;
    2727import static java.awt.event.KeyEvent.VK_Z;
     28import static org.openstreetmap.josm.tools.I18n.marktr;
    2829import static org.openstreetmap.josm.tools.I18n.tr;
    2930import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
     
    9394    /**
    9495     * Simple data class to hold information about a font.
    95      *
     96     * <p>
    9697     * Used for fontconfig.properties files.
    9798     */
     
    154155
    155156    @Override
    156     public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback,
    157             SanityCheckCallback sanityCheckCallback) {
     157    public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) {
    158158        warnSoonToBeUnsupportedJava(javaCallback);
    159159        checkExpiredJava(javaCallback);
    160         checkWebStartMigration(webStartCallback);
    161         PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback);
     160        PlatformHook.super.startupHook(javaCallback, sanityCheckCallback);
    162161    }
    163162
     
    181180
    182181    @Override
     182    @SuppressWarnings("squid:S103") // NOSONAR LineLength
    183183    public void initSystemShortcuts() {
     184        final String reserved = marktr("reserved");
    184185        // 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 results
     186        //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
    187188
    188189        // Windows 7 shortcuts: http://windows.microsoft.com/en-US/windows7/Keyboard-shortcuts
     
    191192
    192193        // 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();
    194195
    195196        // 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 off
    197         Shortcut.registerSystemShortcut("microsoft-reserved-02", tr("reserved"), VK_NUM_LOCK, ALT_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Turn Mouse Keys on or off
    198         //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 ?)
    199200
    200201        // General keyboard shortcuts
    201         //Shortcut.registerSystemShortcut("system:help", tr("reserved"), VK_F1, 0);                            // Display Help
    202         Shortcut.registerSystemShortcut("system:copy", tr("reserved"), VK_C, CTRL_DOWN_MASK);                // Copy the selected item
    203         Shortcut.registerSystemShortcut("system:cut", tr("reserved"), VK_X, CTRL_DOWN_MASK);                 // Cut the selected item
    204         Shortcut.registerSystemShortcut("system:paste", tr("reserved"), VK_V, CTRL_DOWN_MASK);               // Paste the selected item
    205         Shortcut.registerSystemShortcut("system:undo", tr("reserved"), VK_Z, CTRL_DOWN_MASK);                // Undo an action
    206         Shortcut.registerSystemShortcut("system:redo", tr("reserved"), VK_Y, CTRL_DOWN_MASK);                // Redo an action
    207         //Shortcut.registerSystemCut("microsoft-reserved-10", tr("reserved"), VK_DELETE, 0);                  // Delete the selected item and move it to the Recycle Bin
    208         //Shortcut.registerSystemCut("microsoft-reserved-11", tr("reserved"), VK_DELETE, SHIFT_DOWN_MASK);    // Delete the selected item without moving it to the Recycle Bin first
    209         //Shortcut.registerSystemCut("system:rename", tr("reserved"), VK_F2, 0);                          // Rename the selected item
    210         Shortcut.registerSystemShortcut("system:movefocusright", tr("reserved"), VK_RIGHT, CTRL_DOWN_MASK);  // Move the cursor to the beginning of the next word
    211         Shortcut.registerSystemShortcut("system:movefocusleft", tr("reserved"), VK_LEFT, CTRL_DOWN_MASK);    // Move the cursor to the beginning of the previous word
    212         Shortcut.registerSystemShortcut("system:movefocusdown", tr("reserved"), VK_DOWN, CTRL_DOWN_MASK);    // Move the cursor to the beginning of the next paragraph
    213         Shortcut.registerSystemShortcut("system:movefocusup", tr("reserved"), VK_UP, CTRL_DOWN_MASK);        // Move the cursor to the beginning of the previous paragraph
    214         //Shortcut.registerSystemCut("microsoft-reserved-17", tr("reserved"), VK_RIGHT, CTRL_DOWN_MASK | SHIFT_DOWN_MASK); // Select a block of text
    215         //Shortcut.registerSystemCut("microsoft-reserved-18", tr("reserved"), VK_LEFT, CTRL_DOWN_MASK | SHIFT_DOWN_MASK);  // Select a block of text
    216         //Shortcut.registerSystemCut("microsoft-reserved-19", tr("reserved"), VK_DOWN, CTRL_DOWN_MASK | SHIFT_DOWN_MASK);  // Select a block of text
    217         //Shortcut.registerSystemCut("microsoft-reserved-20", tr("reserved"), VK_UP, CTRL_DOWN_MASK | SHIFT_DOWN_MASK);    // Select a block of text
    218         //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
    219         //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
    220         //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
    221         //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
    222         //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 window
    227         //Shortcut.registerSystemCut("system:search", tr("reserved"), VK_F3, 0);                          // Search for a file or folder
    228         Shortcut.registerSystemShortcut("microsoft-reserved-31", tr("reserved"), VK_ENTER, ALT_DOWN_MASK).setAutomatic();   // Display properties for the selected item
    229         Shortcut.registerSystemShortcut("system:exit", tr("reserved"), VK_F4, ALT_DOWN_MASK).setAutomatic(); // Close the active item, or exit the active program
    230         Shortcut.registerSystemShortcut("microsoft-reserved-33", tr("reserved"), VK_SPACE, ALT_DOWN_MASK).setAutomatic();   // Open the shortcut menu for the active window
    231         //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 items
    233         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
    234         //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 opened
    237         //Shortcut.registerSystemCut("microsoft-reserved-40", tr("reserved"), VK_F6, 0);                  // Cycle through screen elements in a window or on the desktop
    238         //Shortcut.registerSystemCut("microsoft-reserved-41", tr("reserved"), VK_F4, 0);                  // Display the address bar list in Windows Explorer
    239         Shortcut.registerSystemShortcut("microsoft-reserved-42", tr("reserved"), VK_F10, SHIFT_DOWN_MASK);   // Display the shortcut menu for the selected item
    240         Shortcut.registerSystemShortcut("microsoft-reserved-43", tr("reserved"), VK_ESCAPE, CTRL_DOWN_MASK).setAutomatic(); // Open the Start menu
    241         //Shortcut.registerSystemShortcut("microsoft-reserved-44", tr("reserved"), VK_F10, 0);                 // Activate the menu bar in the active program
    242         //Shortcut.registerSystemCut("microsoft-reserved-45", tr("reserved"), VK_RIGHT, 0);               // Open the next menu to the right, or open a submenu
    243         //Shortcut.registerSystemCut("microsoft-reserved-46", tr("reserved"), VK_LEFT, 0);                // Open the next menu to the left, or close a submenu
    244         //Shortcut.registerSystemCut("microsoft-reserved-47", tr("reserved"), VK_F5, 0);                  // Refresh the active window
    245         //Shortcut.registerSystemCut("microsoft-reserved-48", tr("reserved"), VK_UP, ALT_DOWN_MASK);      // View the folder one level up in Windows Explorer
    246         //Shortcut.registerSystemCut("microsoft-reserved-49", tr("reserved"), VK_ESCAPE, 0);              // Cancel the current task
    247         Shortcut.registerSystemShortcut("microsoft-reserved-50", tr("reserved"), VK_ESCAPE, CTRL_DOWN_MASK | SHIFT_DOWN_MASK).setAutomatic(); // Open Task Manager
    248         Shortcut.registerSystemShortcut("microsoft-reserved-51", tr("reserved"), VK_SHIFT, ALT_DOWN_MASK).setAutomatic();   // Switch the input language when multiple input languages are enabled
    249         Shortcut.registerSystemShortcut("microsoft-reserved-52", tr("reserved"), VK_SHIFT, CTRL_DOWN_MASK).setAutomatic();  // Switch the keyboard layout when multiple keyboard layouts are enabled
    250         //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)
    251252        // CHECKSTYLE.ON: LineLength
    252253    }
Note: See TracChangeset for help on using the changeset viewer.