package com.voxelmodpack.hdskins.upload.awt;

import net.minecraft.client.Minecraft;

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;

/**
 * Base class for "open file" dialog threads
 *
 * @author Adam Mummery-Smith
 */
public abstract class ThreadOpenFile extends Thread {

    protected String dialogTitle;

    /**
     * Delegate to call back when the dialog box is closed
     */
    protected final IOpenFileCallback parentScreen;

    private JFileChooser fileDialog;

    private static String lastChosenFile = null;

    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!");
        }

        this.parentScreen = callback;
        this.dialogTitle = dialogTitle;
    }

    @Override
    public void run() {
        fileDialog = new JFileChooser();
        fileDialog.setDialogTitle(this.dialogTitle);

        if (lastChosenFile != null) {
            fileDialog.setSelectedFile(new File(lastChosenFile));
        }
        fileDialog.setFileFilter(this.getFileFilter());

        int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());

        File f = fileDialog.getSelectedFile();

        if (f != null) {
            lastChosenFile = f.getAbsolutePath();
        }

        this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
    }

    /**
     * Subclasses should override this to return a file filter
     */
    protected abstract FileFilter getFileFilter();
}

@@ -178,16 +178,62 @@
 ilter;%0A%0A
+import org.apache.commons.lang3.StringUtils;%0A%0A
 /**%0A * B
@@ -532,46 +532,8 @@
 n;%0A%0A
-    private JFileChooser fileDialog;%0A%0A
     
@@ -675,28 +675,16 @@
 allback)
-%0A           
  throws 
@@ -996,32 +996,45 @@
 run() %7B%0A        
+JFileChooser 
 fileDialog = new
@@ -1084,21 +1084,16 @@
 ogTitle(
-this.
 dialogTi
@@ -1110,16 +1110,37 @@
      if 
+(!StringUtils.isBlank
 (lastCho
@@ -1146,24 +1146,17 @@
 osenFile
- != null
+)
 ) %7B%0A    
@@ -1260,21 +1260,16 @@
 eFilter(
-this.
 getFileF
@@ -1500,37 +1500,32 @@
      %7D%0A%0A        
-this.
 parentScreen.onF

Check for empty-ish strings, not just null