mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-23 12:58:01 +01:00
Check for empty-ish strings, not just null
This commit is contained in:
parent
d19b649d6d
commit
9780379a9e
1 changed files with 8 additions and 9 deletions
|
@ -7,6 +7,8 @@ import java.io.File;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for "open file" dialog threads
|
* Base class for "open file" dialog threads
|
||||||
*
|
*
|
||||||
|
@ -21,12 +23,9 @@ public abstract class ThreadOpenFile extends Thread {
|
||||||
*/
|
*/
|
||||||
protected final IOpenFileCallback parentScreen;
|
protected final IOpenFileCallback parentScreen;
|
||||||
|
|
||||||
private JFileChooser fileDialog;
|
|
||||||
|
|
||||||
private static String lastChosenFile = null;
|
private static String lastChosenFile = null;
|
||||||
|
|
||||||
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback)
|
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) throws IllegalStateException {
|
||||||
throws IllegalStateException {
|
|
||||||
if (minecraft.isFullScreen()) {
|
if (minecraft.isFullScreen()) {
|
||||||
throw new IllegalStateException("Cannot open an awt window whilst minecraft is in full screen mode!");
|
throw new IllegalStateException("Cannot open an awt window whilst minecraft is in full screen mode!");
|
||||||
}
|
}
|
||||||
|
@ -37,13 +36,13 @@ public abstract class ThreadOpenFile extends Thread {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
fileDialog = new JFileChooser();
|
JFileChooser fileDialog = new JFileChooser();
|
||||||
fileDialog.setDialogTitle(this.dialogTitle);
|
fileDialog.setDialogTitle(dialogTitle);
|
||||||
|
|
||||||
if (lastChosenFile != null) {
|
if (!StringUtils.isBlank(lastChosenFile)) {
|
||||||
fileDialog.setSelectedFile(new File(lastChosenFile));
|
fileDialog.setSelectedFile(new File(lastChosenFile));
|
||||||
}
|
}
|
||||||
fileDialog.setFileFilter(this.getFileFilter());
|
fileDialog.setFileFilter(getFileFilter());
|
||||||
|
|
||||||
int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());
|
int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ public abstract class ThreadOpenFile extends Thread {
|
||||||
lastChosenFile = f.getAbsolutePath();
|
lastChosenFile = f.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
|
parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue