import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.nio.file.Paths;

/**
 * A very basic graphical user interface that allows to easily specify
 * the FROM and TO excel file paths and start the actual cell copy process.
 */
public class Gui extends Frame {

    private final int width = 400;
    private final int height = 100;
    private final Panel panel = new Panel();
    private FileDialog fileDialog;

    private String[] userInput;
    private String fromExcelPath = "";
    private String toExcelPath = "";

    /**
     * Build a new GUI to extract and copy the content of certain excel files.
     *
     * @param userInput optional provided user input
     */
    public Gui(String[] userInput) {
        this.userInput = userInput;

        setTitle("Excel2Excel");
        setSize(width, height);
        Button copyFromButton = new Button("From Excel File");
        Button copyToButton = new Button("To Excel File");
        Button copyButton = new Button("Copy");

        panel.add(copyFromButton);
        panel.add(copyToButton);
        panel.add(copyButton);

        fileDialog = new FileDialog(this, "Choose From Excel File");
        copyFromButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                fileDialog.setVisible(true);
                fromExcelPath = Paths.get(fileDialog.getDirectory(), fileDialog.getFile()).toString();
            }
        });

        fileDialog = new FileDialog(this, "Choose To Excel File");
        copyToButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                fileDialog.setVisible(true);
                toExcelPath = Paths.get(fileDialog.getDirectory(), fileDialog.getFile()).toString();
            }
        });

        copyButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                // TODO set mapping and translation file as well
                String[] args = {
                        fromExcelPath,
                        toExcelPath
                };
                Properties.initialize(args);
                try {
                    Properties.reportPaths();
                    Logger.println("Reading excel files...");
                    ExcelFile fromExcel = new ExcelFile(Properties.getFromExcelFilePath());
                    ExcelFile toExcel = new ExcelFile(Properties.getToExcelFilePath());
                    Logger.println(" => Excel files read.");
                    Logger.println("Copying content from FROM excel file to TO file...");
                    new Consolidator(Properties.getMappingFilePath(), fromExcel, toExcel);
                    Logger.println(" => Content copied.");
                    Logger.println("Saving TO excel file...");
                    toExcel.save();
                    Logger.println(" => TO file saved.");
                    Logger.println("Excel2Excel successfully finished.");
                    Logger.writeLog();
                } catch (Exception e) {
                    System.err.println(e.getMessage());
                }
            }
        });

        add(panel);
        addWindowListener(new GuiEventListener());
        pack();
        setVisible(true);
        setResizable(false);
    }

    class GuiEventListener extends WindowAdapter {
        public void windowClosing(WindowEvent e) {
            e.getWindow().dispose();
            System.exit(0);
        }
    }
}
@@ -525,16 +525,49 @@
 eDialog;
+%0A    private boolean useGuiInput;
 %0A%0A    pr
@@ -839,16 +839,22 @@
 lic Gui(
+final 
 String%5B%5D
@@ -898,24 +898,53 @@
 = userInput;
+%0A        useGuiInput = false;
 %0A%0A        se
@@ -1599,32 +1599,68 @@
 ()).toString();%0A
+                useGuiInput = true;%0A
             %7D%0A  
@@ -1994,32 +1994,68 @@
 ()).toString();%0A
+                useGuiInput = true;%0A
             %7D%0A  
@@ -2182,24 +2182,61 @@
 nt event) %7B%0A
+                Properties.clear();%0A%0A
             
@@ -2397,16 +2397,16 @@
 celPath%0A
-
         
@@ -2416,16 +2416,313 @@
      %7D;%0A
+%0A                if (userInput.length %3E 0 && !useGuiInput) %7B%0A                    Logger.println(%22Program was invoked with user specified runtime arguments.%22);%0A                    Logger.println(%22 =%3E Using these arguments to setup paths.%22);%0A                    args = userInput;%0A                %7D%0A%0A
         

Allow to run the program several times using different files