Skip to content
This repository was archived by the owner on Aug 18, 2024. It is now read-only.

Commit dc09fda

Browse files
committed
0.3.2
1 parent 80bdf42 commit dc09fda

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'com.redlimerl'
7-
version '0.3.1'
7+
version '0.3.2'
88
repositories {
99
mavenCentral()
1010
}

src/main/java/com/pistacium/modcheck/ModCheckConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public class ModCheckConstants {
44

5-
public static final String APPLICATION_VERSION = "0.3.1";
5+
public static final String APPLICATION_VERSION = "0.3.2";
66

77
}

src/main/java/com/pistacium/modcheck/ModCheckFrame.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
import com.pistacium.modcheck.mod.version.ModVersion;
88
import com.pistacium.modcheck.util.ModCheckStatus;
99
import com.pistacium.modcheck.util.ModCheckUtils;
10+
import com.pistacium.modcheck.util.SwingUtils;
1011

1112
import javax.swing.*;
1213
import javax.swing.border.EmptyBorder;
1314
import javax.swing.plaf.FontUIResource;
15+
import javax.swing.plaf.basic.BasicComboBoxEditor;
1416
import java.awt.*;
1517
import java.io.File;
1618
import java.net.URI;
@@ -77,12 +79,27 @@ private static void setUIFont(){
7779
private void initHeaderLayout() {
7880
JPanel instanceSelectPanel = new JPanel();
7981

80-
JButton selectPathButton = new JButton("Select Instances Path");
82+
JButton selectPathButton = new JButton("Select Instance Paths");
8183
selectPathButton.addActionListener(e -> {
8284
JFileChooser pathSelector = new JFileChooser();
8385
pathSelector.setMultiSelectionEnabled(true);
8486
pathSelector.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
85-
int showDialog = pathSelector.showSaveDialog(null);
87+
pathSelector.setDialogType(JFileChooser.CUSTOM_DIALOG);
88+
pathSelector.setDialogTitle("Select Instance Paths");
89+
JComboBox<?> jComboBox = SwingUtils.getDescendantsOfType(JComboBox.class, pathSelector).get(0);
90+
jComboBox.setEditable(true);
91+
jComboBox.setEditor(new BasicComboBoxEditor.UIResource() {
92+
@Override
93+
public Object getItem() {
94+
try {
95+
return new File((String) super.getItem());
96+
} catch (Exception e) {
97+
return super.getItem();
98+
}
99+
}
100+
});
101+
102+
int showDialog = pathSelector.showDialog(this, "Select");
86103
File[] files = pathSelector.getSelectedFiles();
87104
if (pathSelector.getSelectedFiles() != null && showDialog == JFileChooser.APPROVE_OPTION) {
88105
selectDirs = files;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.pistacium.modcheck.util;
2+
/*
3+
* @(#)SwingUtils.java 1.02 11/15/08
4+
*
5+
*/
6+
7+
import javax.swing.*;
8+
import java.awt.*;
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
/**
13+
* A collection of utility methods for Swing.
14+
*
15+
* @author Darryl Burke
16+
*/
17+
public final class SwingUtils {
18+
19+
private SwingUtils() {
20+
throw new Error("SwingUtils is just a container for static methods");
21+
}
22+
23+
public static <T extends JComponent> List<T> getDescendantsOfType(
24+
Class<T> clazz, Container container) {
25+
return getDescendantsOfType(clazz, container, true);
26+
}
27+
28+
29+
public static <T extends JComponent> List<T> getDescendantsOfType(
30+
Class<T> clazz, Container container, boolean nested) {
31+
List<T> tList = new ArrayList<>();
32+
for (Component component : container.getComponents()) {
33+
if (clazz.isAssignableFrom(component.getClass())) {
34+
tList.add(clazz.cast(component));
35+
}
36+
if (nested || !clazz.isAssignableFrom(component.getClass())) {
37+
tList.addAll(SwingUtils.getDescendantsOfType(clazz,
38+
(Container) component, nested));
39+
}
40+
}
41+
return tList;
42+
}
43+
}

0 commit comments

Comments
 (0)