Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #23894: AIOOBE in SelectLayerView.getLayerNames #7

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openstreetmap.josm.plugins</groupId>
<artifactId>plugin-root</artifactId>
<version>SNAPSHOT</version>
</parent>
<artifactId>PicLayer</artifactId>

<url>${plugin.link}</url>
<developers>
<developer>
<name>Tomasz Stelmach</name>
</developer>
</developers>
<properties>
<plugin.src.dir>src</plugin.src.dir>
<plugin.main.version>18494</plugin.main.version>
<plugin.author>Tomasz Stelmach</plugin.author>
<plugin.class>org.openstreetmap.josm.plugins.piclayer.PicLayerPlugin</plugin.class>
<plugin.description>This plugin allows to display any picture as a background in the editor and align it with the map.</plugin.description>
<plugin.icon>images/layericon.png</plugin.icon>
<plugin.link>https://josm.openstreetmap.de/wiki/Help/Plugin/PicLayer</plugin.link>
<plugin.canloadatruntime>true</plugin.canloadatruntime>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Plugin-Link>${plugin.link}</Plugin-Link>
<Plugin-Icon>${plugin.icon}</Plugin-Icon>
<Plugin-Canloadatruntime>${plugin.canloadatruntime}</Plugin-Canloadatruntime>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JFrame;
Expand All @@ -22,7 +23,6 @@

public class SelectLayerView {

private final String[] labels;
private final JList<Object> list;
private final JFrame frame;
private JScrollPane scrollPane;
Expand All @@ -32,9 +32,7 @@ public class SelectLayerView {


public SelectLayerView() {
labels = new String[10];
getLayerNames();
list = new JList<>(labels);
list = new JList<>(getLayerNames());

frame = new JFrame("Layer Selector");
frame.setSize(400, 200);
Expand All @@ -51,11 +49,9 @@ public SelectLayerView() {
contentPane.add(buttonBar, BorderLayout.SOUTH);
}

private void getLayerNames() {
java.util.List<Layer> layer = MainApplication.getLayerManager().getLayers();
for (int i = 0; i < layer.size(); i++) {
labels[i] = layer.get(i).getName();
}
private static String[] getLayerNames() {
return MainApplication.getLayerManager().getLayers().stream()
.map(Layer::getName).toArray(String[]::new);
}

public void setVisible(boolean value) {
Expand Down
Loading