From 38410c1676bfd43a6a0826f97d2e31623a8a9d60 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 26 Mar 2017 11:34:55 +0800 Subject: [PATCH] MediaBindingBean bindings, boolean locked --- source/net/filebot/ui/rename/FormatDialog.java | 14 +++++++++++--- source/net/filebot/ui/rename/PresetEditor.java | 2 +- source/net/filebot/ui/rename/RenamePanel.java | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 17633953..df4b3281 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -186,7 +186,7 @@ public class FormatDialog extends JDialog { } } - public FormatDialog(Window owner, Mode initMode, MediaBindingBean lockOnBinding) { + public FormatDialog(Window owner, Mode initMode, MediaBindingBean bindings, boolean locked) { super(owner, ModalityType.DOCUMENT_MODAL); // initialize hidden @@ -226,9 +226,10 @@ public class FormatDialog extends JDialog { content.add(help, "growx, wrap 25px:push"); - if (lockOnBinding == null) { + if (bindings == null) { content.add(new JButton(switchEditModeAction), "tag left"); } + content.add(new JButton(approveFormatAction), "tag apply"); content.add(new JButton(cancelAction), "tag cancel"); @@ -273,8 +274,15 @@ public class FormatDialog extends JDialog { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setMinimumSize(new Dimension(650, 520)); + // restore sample file if necessary + if (bindings == null) { + bindings = restoreSample(initMode); + } else if (bindings.getFileObject() == null && !locked) { + bindings = new MediaBindingBean(bindings.getInfoObject(), restoreSample(initMode).getMediaFile()); + } + // initialize data - setState(initMode, lockOnBinding != null ? lockOnBinding : restoreSample(initMode), lockOnBinding != null); + setState(initMode, bindings, locked); } public void setState(Mode mode, MediaBindingBean bindings, boolean locked) { diff --git a/source/net/filebot/ui/rename/PresetEditor.java b/source/net/filebot/ui/rename/PresetEditor.java index 4bb1db39..a347a6b4 100644 --- a/source/net/filebot/ui/rename/PresetEditor.java +++ b/source/net/filebot/ui/rename/PresetEditor.java @@ -314,7 +314,7 @@ public class PresetEditor extends JDialog { sample = file = files.get(0); } - FormatDialog dialog = new FormatDialog(getWindow(evt.getSource()), mode, new MediaBindingBean(sample, file, singletonMap(file, sample))); + FormatDialog dialog = new FormatDialog(getWindow(evt.getSource()), mode, new MediaBindingBean(sample, file, singletonMap(file, sample)), false); dialog.setFormatCode(formatEditor.getText()); dialog.setLocation(getOffsetLocation(dialog.getOwner())); dialog.setVisible(true); diff --git a/source/net/filebot/ui/rename/RenamePanel.java b/source/net/filebot/ui/rename/RenamePanel.java index 9025d35e..f75be0fc 100644 --- a/source/net/filebot/ui/rename/RenamePanel.java +++ b/source/net/filebot/ui/rename/RenamePanel.java @@ -581,7 +581,7 @@ public class RenamePanel extends JComponent { private void showFormatEditor(MediaBindingBean binding) { withWaitCursor(this, () -> { - FormatDialog dialog = new FormatDialog(getWindowAncestor(RenamePanel.this), getFormatEditorMode(binding), binding); + FormatDialog dialog = new FormatDialog(getWindowAncestor(RenamePanel.this), getFormatEditorMode(binding), binding, binding != null); dialog.setLocation(getOffsetLocation(dialog.getOwner())); dialog.setVisible(true);