mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-23 04:57:58 +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.filechooser.FileFilter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Base class for "open file" dialog threads
|
||||
*
|
||||
|
@ -21,12 +23,9 @@ public abstract class ThreadOpenFile extends Thread {
|
|||
*/
|
||||
protected final IOpenFileCallback parentScreen;
|
||||
|
||||
private JFileChooser fileDialog;
|
||||
|
||||
private static String lastChosenFile = null;
|
||||
|
||||
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback)
|
||||
throws IllegalStateException {
|
||||
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) throws IllegalStateException {
|
||||
if (minecraft.isFullScreen()) {
|
||||
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
|
||||
public void run() {
|
||||
fileDialog = new JFileChooser();
|
||||
fileDialog.setDialogTitle(this.dialogTitle);
|
||||
JFileChooser fileDialog = new JFileChooser();
|
||||
fileDialog.setDialogTitle(dialogTitle);
|
||||
|
||||
if (lastChosenFile != null) {
|
||||
if (!StringUtils.isBlank(lastChosenFile)) {
|
||||
fileDialog.setSelectedFile(new File(lastChosenFile));
|
||||
}
|
||||
fileDialog.setFileFilter(this.getFileFilter());
|
||||
fileDialog.setFileFilter(getFileFilter());
|
||||
|
||||
int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());
|
||||
|
||||
|
@ -53,7 +52,7 @@ public abstract class ThreadOpenFile extends Thread {
|
|||
lastChosenFile = f.getAbsolutePath();
|
||||
}
|
||||
|
||||
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
|
||||
parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue