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:
*
* - it returns KeyEvent.CTRL_MASK instead of KeyEvent.CTRL_DOWN_MASK. We used the extended
* modifier for years, and Oracle recommends to use it instead, so it's best to keep it
@@ -257,7 +257,9 @@ default boolean isHtmlSupportedInMenuTooltips() {
* @since 12748 (as a replacement to {@code GuiHelper.getMenuShortcutKeyMaskEx()})
*/
default int getMenuShortcutKeyMaskEx() {
- // To remove when switching to Java 10+, and use Toolkit.getMenuShortcutKeyMaskEx instead
+ if (!GraphicsEnvironment.isHeadless()) {
+ return Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
+ }
return InputEvent.CTRL_DOWN_MASK;
}
diff --git a/src/org/openstreetmap/josm/tools/PlatformHookOsx.java b/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
index 48810f76c0f..c6df45473b8 100644
--- a/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
+++ b/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
@@ -105,11 +105,6 @@ public boolean isHtmlSupportedInMenuTooltips() {
&& ("Aqua".equals(laf) || laf.contains("Mac")));
}
- @Override
- public int getMenuShortcutKeyMaskEx() {
- return InputEvent.META_DOWN_MASK;
- }
-
/**
* Registers Apple handlers.
*
diff --git a/src/org/openstreetmap/josm/tools/StreamUtils.java b/src/org/openstreetmap/josm/tools/StreamUtils.java
index 38cdc47c6d4..af23eb269c5 100644
--- a/src/org/openstreetmap/josm/tools/StreamUtils.java
+++ b/src/org/openstreetmap/josm/tools/StreamUtils.java
@@ -67,7 +67,7 @@ public static Stream reversedStream(List list) {
* @since 16436
*/
public static Collector> toUnmodifiableList() {
- // Java 10: use java.util.stream.Collectors.toUnmodifiableList
+ // Java 10: use java.util.stream.Collectors.toUnmodifiableList (note: does not like null checks OR null entries)
return Collectors.collectingAndThen(Collectors.toList(), Utils::toUnmodifiableList);
}
}
diff --git a/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTestFT.java b/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTestFT.java
index 6a6fb074204..f0dafc06fd0 100644
--- a/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTestFT.java
+++ b/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTestFT.java
@@ -2,8 +2,6 @@
package org.openstreetmap.josm.gui.conflict.pair.nodes;
import java.awt.BorderLayout;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
import javax.swing.JFrame;
@@ -23,8 +21,7 @@ protected void populate() {
for (int i = 0; i < 20; i++) {
n1.put("key" + i, "value" + i);
}
- // Java 11: use String.repeat
- String note = IntStream.range(0, 50).mapToObj(i -> " A very long text ").collect(Collectors.joining());
+ String note = " A very long text ".repeat(50);
n1.put("note", note);
w1.addNode(new Node(2));
w1.addNode(new Node(3));
diff --git a/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java b/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java
index 0b12470601d..edb92459bf2 100644
--- a/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java
+++ b/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java
@@ -13,8 +13,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import org.openstreetmap.josm.data.Bounds;
@@ -56,8 +54,7 @@ void testSetKeys() {
// Add a map with too long values => IllegalArgumentException
keys = new HashMap<>();
- // Java 11: use String.repeat
- keys.put("test", IntStream.range(0, MAX_CHANGESET_TAG_LENGTH + 1).mapToObj(i -> "x").collect(Collectors.joining()));
+ keys.put("test", "x".repeat(MAX_CHANGESET_TAG_LENGTH + 1));
try {
cs.setKeys(keys);
fail("Should have thrown an IllegalArgumentException as we gave a too long value.");