// Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//     
//     private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
// 
//     public static void displayWindow(Window window) {
//         window.pack();
//         if (window.getParent() != null) {
//             window.setLocationRelativeTo(window.getParent());
//         }
//         window.setVisible(true);
//     }
//     
//     public static void displayWindowCentered(Window window) {
//         window.pack();
//         window.setLocationRelativeTo(null);
//         window.setVisible(true);
//     }
//     
//     public static void closeWindow(Window window) {
//         window.setVisible(false);
//         window.dispose();
//     }
//     
//     public static void sizeForScreen(Component component) {
//         Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
//         int maxHeight =  (int) (screen.height * 0.9);
//         int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
//         component.setMaximumSize(new Dimension(maxWidth, maxHeight));
//         component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
//                 Math.min(800, maxHeight)));
//     }
//     
//     public static void blockOnWindow(final Window window) {
//         final Object lock = new Object();
//                 
//         window.addWindowListener(new WindowAdapter() {
//             @Override
//             public void windowClosed(WindowEvent e) {
//                 synchronized (lock) {
//                     lock.notify();
//                 }
//             }
//         });
//         
//         synchronized (lock) {
//             while (window.isVisible()) {
//                 try {
//                     lock.wait();
//                 } catch (InterruptedException ex) {
//                     LOGGER.log(Level.SEVERE, null, ex);
//                 }
//             }
//         }
//     }
//     
//     public static void safelyRunBlockingRoutine(Runnable runnable) {
//         if (SwingUtilities.isEventDispatchThread()) {
//             new Thread(runnable).start();
//         } else {
//             runnable.run();
//         }
//     }
//     
//     public static boolean isOSX() {
//         return System.getProperty("os.name").contains("OS X");
//     }
//     
//     public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
//         Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
//                 new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
//                         evt.getModifiers(), evt.getX(), evt.getY(),
//                         evt.getClickCount(), evt.isPopupTrigger(),
//                         evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
//     }
//     
//     public static void showError(String message) {
//         JOptionPane.showMessageDialog(null,
//                 message,
//                 LocString.get("STM_ERROR_DIALOG_TITLE"),
//                 JOptionPane.ERROR_MESSAGE);
//     }
// }
// 
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//     
//     private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//     
//     private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//     
//     private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//     
//     public static String get(String id) {
//         for (int i = moreBundles.size() - 1; i >= 0; i--) {
//             try {
//                 return moreBundles.get(i).getString(id);
//             } catch (MissingResourceException ex) {
//                 LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
//             }
//         }
//         return bundle.getString(id);
//     }
//     
//     public static String getFormat(String id, Object... var) {
//         return MessageFormat.format(get(id), var);
//     }
//     
//     public static void addBundle(ResourceBundle bundle) {
//         if (bundle == null) {
//             return;
//         }
//         if (!moreBundles.contains(bundle)) {
//             moreBundles.add(bundle);
//         }
//     }
// }


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString;
    public void setMaximum(int max) {
        maxIsSet = true;
        progressBar.setMaximum(max);
    }
    
    public void setValue(int value) {
        if (!maxIsSet) {
            throw new UnsupportedOperationException("Must set maximum before setting value.");
        }
        progressBar.setIndeterminate(false);
        progressBar.setValue(value);
    }
    
    public void setMustPopup(boolean mustPopUp) {
        this.mustPopUp = mustPopUp;
    }
    
    public void setMessage(String text) {
        label.setText(text);
    }
    
    @Override
    public void actionPerformed(ActionEvent e) {
        // Returning from the timer will be on a different thread,
        // so queue this up so as to prevent spurious exceptions.
        final JFrame popup = this;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (shouldShowPopup()) {
// Path: src/main/java/org/madlonkay/supertmxmerge/util/GuiUtil.java
// public class GuiUtil {
//     
//     private static final Logger LOGGER = Logger.getLogger(GuiUtil.class.getName());
// 
//     public static void displayWindow(Window window) {
//         window.pack();
//         if (window.getParent() != null) {
//             window.setLocationRelativeTo(window.getParent());
//         }
//         window.setVisible(true);
//     }
//     
//     public static void displayWindowCentered(Window window) {
//         window.pack();
//         window.setLocationRelativeTo(null);
//         window.setVisible(true);
//     }
//     
//     public static void closeWindow(Window window) {
//         window.setVisible(false);
//         window.dispose();
//     }
//     
//     public static void sizeForScreen(Component component) {
//         Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
//         int maxHeight =  (int) (screen.height * 0.9);
//         int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
//         component.setMaximumSize(new Dimension(maxWidth, maxHeight));
//         component.setPreferredSize(new Dimension(Math.min(800, maxWidth),
//                 Math.min(800, maxHeight)));
//     }
//     
//     public static void blockOnWindow(final Window window) {
//         final Object lock = new Object();
//                 
//         window.addWindowListener(new WindowAdapter() {
//             @Override
//             public void windowClosed(WindowEvent e) {
//                 synchronized (lock) {
//                     lock.notify();
//                 }
//             }
//         });
//         
//         synchronized (lock) {
//             while (window.isVisible()) {
//                 try {
//                     lock.wait();
//                 } catch (InterruptedException ex) {
//                     LOGGER.log(Level.SEVERE, null, ex);
//                 }
//             }
//         }
//     }
//     
//     public static void safelyRunBlockingRoutine(Runnable runnable) {
//         if (SwingUtilities.isEventDispatchThread()) {
//             new Thread(runnable).start();
//         } else {
//             runnable.run();
//         }
//     }
//     
//     public static boolean isOSX() {
//         return System.getProperty("os.name").contains("OS X");
//     }
//     
//     public static void forwardMouseWheelEvent(JScrollPane target, MouseWheelEvent evt) {
//         Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
//                 new MouseWheelEvent(target, evt.getID(), evt.getWhen(),
//                         evt.getModifiers(), evt.getX(), evt.getY(),
//                         evt.getClickCount(), evt.isPopupTrigger(),
//                         evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation()));
//     }
//     
//     public static void showError(String message) {
//         JOptionPane.showMessageDialog(null,
//                 message,
//                 LocString.get("STM_ERROR_DIALOG_TITLE"),
//                 JOptionPane.ERROR_MESSAGE);
//     }
// }
// 
// Path: src/main/java/org/madlonkay/supertmxmerge/util/LocString.java
// public class LocString {
//     
//     private static final ResourceBundle bundle = ResourceBundle.getBundle("org/madlonkay/supertmxmerge/Strings");
//     
//     private static final List<ResourceBundle> moreBundles = new ArrayList<ResourceBundle>();
//     
//     private static final Logger LOGGER = Logger.getLogger(LocString.class.getName());
//     
//     public static String get(String id) {
//         for (int i = moreBundles.size() - 1; i >= 0; i--) {
//             try {
//                 return moreBundles.get(i).getString(id);
//             } catch (MissingResourceException ex) {
//                 LOGGER.log(Level.FINE, "Resource " + id + " not found in supplied resource bundle", ex);
//             }
//         }
//         return bundle.getString(id);
//     }
//     
//     public static String getFormat(String id, Object... var) {
//         return MessageFormat.format(get(id), var);
//     }
//     
//     public static void addBundle(ResourceBundle bundle) {
//         if (bundle == null) {
//             return;
//         }
//         if (!moreBundles.contains(bundle)) {
//             moreBundles.add(bundle);
//         }
//     }
// }


// Path: src/main/java/org/madlonkay/supertmxmerge/gui/ProgressWindow.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.madlonkay.supertmxmerge.util.GuiUtil;
import org.madlonkay.supertmxmerge.util.LocString;

    public void setMaximum(int max) {
        maxIsSet = true;
        progressBar.setMaximum(max);
    }
    
    public void setValue(int value) {
        if (!maxIsSet) {
            throw new UnsupportedOperationException("Must set maximum before setting value.");
        }
        progressBar.setIndeterminate(false);
        progressBar.setValue(value);
    }
    
    public void setMustPopup(boolean mustPopUp) {
        this.mustPopUp = mustPopUp;
    }
    
    public void setMessage(String text) {
        label.setText(text);
    }
    
    @Override
    public void actionPerformed(ActionEvent e) {
        // Returning from the timer will be on a different thread,
        // so queue this up so as to prevent spurious exceptions.
        final JFrame popup = this;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (shouldShowPopup()) {
                    GuiUtil.displayWindowCentered(popup);