MediaBindingBean bindings, boolean locked

This commit is contained in:
Reinhard Pointner 2017-03-26 11:34:55 +08:00
parent 7ae7e745bd
commit 38410c1676
3 changed files with 13 additions and 5 deletions

View File

@ -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); super(owner, ModalityType.DOCUMENT_MODAL);
// initialize hidden // initialize hidden
@ -226,9 +226,10 @@ public class FormatDialog extends JDialog {
content.add(help, "growx, wrap 25px:push"); content.add(help, "growx, wrap 25px:push");
if (lockOnBinding == null) { if (bindings == null) {
content.add(new JButton(switchEditModeAction), "tag left"); content.add(new JButton(switchEditModeAction), "tag left");
} }
content.add(new JButton(approveFormatAction), "tag apply"); content.add(new JButton(approveFormatAction), "tag apply");
content.add(new JButton(cancelAction), "tag cancel"); content.add(new JButton(cancelAction), "tag cancel");
@ -273,8 +274,15 @@ public class FormatDialog extends JDialog {
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setMinimumSize(new Dimension(650, 520)); 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 // initialize data
setState(initMode, lockOnBinding != null ? lockOnBinding : restoreSample(initMode), lockOnBinding != null); setState(initMode, bindings, locked);
} }
public void setState(Mode mode, MediaBindingBean bindings, boolean locked) { public void setState(Mode mode, MediaBindingBean bindings, boolean locked) {

View File

@ -314,7 +314,7 @@ public class PresetEditor extends JDialog {
sample = file = files.get(0); 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.setFormatCode(formatEditor.getText());
dialog.setLocation(getOffsetLocation(dialog.getOwner())); dialog.setLocation(getOffsetLocation(dialog.getOwner()));
dialog.setVisible(true); dialog.setVisible(true);

View File

@ -581,7 +581,7 @@ public class RenamePanel extends JComponent {
private void showFormatEditor(MediaBindingBean binding) { private void showFormatEditor(MediaBindingBean binding) {
withWaitCursor(this, () -> { 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.setLocation(getOffsetLocation(dialog.getOwner()));
dialog.setVisible(true); dialog.setVisible(true);