diff --git a/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java b/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java index 3483442798e..02cec89f12e 100644 --- a/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java +++ b/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java @@ -112,9 +112,8 @@ public static String getReportHeader() { DisplayMode dm = gd.getDisplayMode(); if (dm != null) { AffineTransform transform = gd.getDefaultConfiguration().getDefaultTransform(); - // Java 11: use DisplayMode#toString - text.format(Locale.ROOT, " %d\u00D7%d (scaling %.2f\u00D7%.2f)", - dm.getWidth(), dm.getHeight(), transform.getScaleX(), transform.getScaleY()); + text.format(Locale.ROOT, " %s (scaling %.2f\u00D7%.2f)", + dm, transform.getScaleX(), transform.getScaleY()); } } text.println(); diff --git a/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java b/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java index 77bc3e3eef8..c5d417df1e2 100644 --- a/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java +++ b/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java @@ -48,7 +48,7 @@ /** * Panel to inspect one or more OsmPrimitives. - * + *

* Gives an unfiltered view of the object's internal state. * Might be useful for power users to give more detailed bug reports and * to better understand the JOSM data representation. @@ -128,7 +128,7 @@ protected static String buildMapPaintText() { for (IPrimitive osm : sel) { String heading = tr("Styles for \"{0}\":", osm.getDisplayName(DefaultNameFormatter.getInstance())); txtMappaint.println(heading); - txtMappaint.println(repeatString("=", heading.length())); + txtMappaint.println("=".repeat(heading.length())); MultiCascade mc = new MultiCascade(); @@ -136,7 +136,7 @@ protected static String buildMapPaintText() { if (s.active) { heading = tr("{0} style \"{1}\"", getSort(s), s.getDisplayString()); txtMappaint.println(heading); - txtMappaint.println(repeatString("-", heading.length())); + txtMappaint.println("-".repeat(heading.length())); s.apply(mc, osm, scale, false); txtMappaint.println(tr("Display range: {0}", mc.range)); for (Entry e : mc.getLayers()) { @@ -149,7 +149,7 @@ protected static String buildMapPaintText() { txtMappaint.println(); heading = tr("List of generated Styles:"); txtMappaint.println(heading); - txtMappaint.println(repeatString("-", heading.length())); + txtMappaint.println("-".repeat(heading.length())); StyleElementList sl = elemstyles.get(osm, scale, nc); for (StyleElement s : sl) { txtMappaint.print(" * "); @@ -178,11 +178,6 @@ protected static String buildMapPaintText() { return stringWriter.toString(); } - private static String repeatString(String string, int count) { - // Java 11: use String.repeat - return new String(new char[count]).replace("\0", string); - } - /* Future Ideas: Calculate the most recent edit date from o.getTimestamp(). Sort by the count for presentation, so the most active editors are on top. diff --git a/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java b/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java index 40bd9c55482..9eb761c5642 100644 --- a/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java +++ b/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java @@ -89,7 +89,7 @@ public boolean hasSelectedChangesets() { * @return the list of selected changesets */ public List getSelectedChangesets() { - return Arrays.stream(TableHelper.getSelectedIndices(selectionModel)) + return Arrays.stream(selectionModel.getSelectedIndices()) .map(sorter::convertRowIndexToModel).mapToObj(data::get).collect(Collectors.toList()); } diff --git a/src/org/openstreetmap/josm/gui/util/ReorderableTableModel.java b/src/org/openstreetmap/josm/gui/util/ReorderableTableModel.java index f023fc8de74..f8c3f56e3a6 100644 --- a/src/org/openstreetmap/josm/gui/util/ReorderableTableModel.java +++ b/src/org/openstreetmap/josm/gui/util/ReorderableTableModel.java @@ -41,7 +41,7 @@ public interface ReorderableTableModel extends ReorderableModel { * @see #selectedIndices() */ default int[] getSelectedIndices() { - return TableHelper.getSelectedIndices(getSelectionModel()); + return getSelectionModel().getSelectedIndices(); } /** diff --git a/src/org/openstreetmap/josm/gui/util/TableHelper.java b/src/org/openstreetmap/josm/gui/util/TableHelper.java index 15a4d7e7696..f88fe02a521 100644 --- a/src/org/openstreetmap/josm/gui/util/TableHelper.java +++ b/src/org/openstreetmap/josm/gui/util/TableHelper.java @@ -122,7 +122,7 @@ public static void computeColumnsWidth(JTable tbl) { * Returns an array of all of the selected indices in the selection model, in increasing order. * Unfortunately this method is not available in OpenJDK before version 11, see * https://bugs.openjdk.java.net/browse/JDK-8199395 - * + *

* To be removed when we switch to Java 11 or later. * * @param selectionModel list selection model. @@ -131,9 +131,11 @@ public static void computeColumnsWidth(JTable tbl) { * or an empty array if nothing is selected * @see #selectedIndices(ListSelectionModel) * @since 15226 + * @deprecated Use {@link ListSelectionModel#getSelectedIndices()} instead */ + @Deprecated(since = "19120") public static int[] getSelectedIndices(ListSelectionModel selectionModel) { - return selectedIndices(selectionModel).toArray(); + return selectionModel.getSelectedIndices(); } /** diff --git a/src/org/openstreetmap/josm/tools/PlatformHook.java b/src/org/openstreetmap/josm/tools/PlatformHook.java index 08e191343de..23e62b0af2b 100644 --- a/src/org/openstreetmap/josm/tools/PlatformHook.java +++ b/src/org/openstreetmap/josm/tools/PlatformHook.java @@ -247,7 +247,7 @@ default boolean isHtmlSupportedInMenuTooltips() { /** * Returns extended modifier key used as the appropriate accelerator key for menu shortcuts. - * It is advised everywhere to use {@link Toolkit#getMenuShortcutKeyMask()} to get the cross-platform modifier, but: + * It was advised everywhere to use {@link Toolkit#getMenuShortcutKeyMask()} to get the cross-platform modifier, but: *