Check for empty-ish strings, not just null

This commit is contained in:
Sollace 2018-08-08 14:52:44 +02:00
parent d19b649d6d
commit 9780379a9e

View file

@ -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);
}
/**