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

"Select Resource Pack" allow multi-selection #217

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Fixed for Java8
  • Loading branch information
Tiefseetauchner committed Mar 12, 2023
commit b748f5484e5c8cc8111e222d6423ee8c3bae5dc3
15 changes: 9 additions & 6 deletions src/org/jmc/gui/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

Expand All @@ -26,6 +24,7 @@
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
Expand Down Expand Up @@ -313,12 +312,16 @@ public void actionPerformed(ActionEvent e) {
jfc.setCurrentDirectory(Filesystem.getMinecraftDir());
jfc.showDialog(Settings.this, Messages.getString("TexsplitDialog.SEL_RP"));

DefaultListModel<File> listPacksModel = listPacks.getModel();
File[] selectedFiles = jfc.getSelectedFiles();

List<File> selectedFilesList = Arrays.asList(selectedFiles);
selectedFilesList.removeIf(Objects::isNull);

listPacks.getModel().addAll(0, selectedFilesList);
for (File selectedFile : selectedFiles) {
if (selectedFile == null) {
return;
}

listPacksModel.add(0, selectedFile);
}

listPacks.setSelectedIndex(0);
saveSettings();
Expand Down