1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-03-10 06:20:27 -04:00

* properly finish dialog when dialog is canceled via X

This commit is contained in:
Reinhard Pointner 2009-06-02 18:51:09 +00:00
parent 0c698902df
commit f9d08bd57d

View File

@ -82,14 +82,14 @@ public class EpisodeFormatDialog extends JDialog {
private Color defaultColor = preview.getForeground(); private Color defaultColor = preview.getForeground();
private Color errorColor = Color.red; private Color errorColor = Color.red;
public enum Option { public enum Option {
APPROVE, APPROVE,
CANCEL, CANCEL,
USE_DEFAULT USE_DEFAULT
} }
public EpisodeFormatDialog(Window owner) { public EpisodeFormatDialog(Window owner) {
super(owner, "Episode Format", ModalityType.DOCUMENT_MODAL); super(owner, "Episode Format", ModalityType.DOCUMENT_MODAL);
@ -165,11 +165,20 @@ public class EpisodeFormatDialog extends JDialog {
} }
}); });
// finish dialog and close window manually
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
finish(Option.CANCEL);
}
});
// update preview to current format // update preview to current format
firePreviewSampleChanged(); firePreviewSampleChanged();
// initialize window properties // initialize window properties
setDefaultCloseOperation(DISPOSE_ON_CLOSE); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setLocation(TunedUtilities.getPreferredLocation(this)); setLocation(TunedUtilities.getPreferredLocation(this));
pack(); pack();
} }
@ -446,12 +455,14 @@ public class EpisodeFormatDialog extends JDialog {
private void finish(Option option) { private void finish(Option option) {
selectedOption = option; selectedOption = option;
// force shutdown
previewExecutor.shutdownNow(); previewExecutor.shutdownNow();
setVisible(false); setVisible(false);
dispose(); dispose();
} }
protected final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) { protected final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) {
@Override @Override
@ -489,7 +500,7 @@ public class EpisodeFormatDialog extends JDialog {
} }
}; };
protected void firePreviewSampleChanged() { protected void firePreviewSampleChanged() {
firePropertyChange("previewSample", null, previewSample); firePropertyChange("previewSample", null, previewSample);
} }