From 02e2b9f4d12d025e6e19c47c43240838092ca960 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 30 Nov 2015 06:47:35 +0000 Subject: [PATCH] * refactor --- source/net/filebot/format/MediaBindingBean.java | 8 ++++++-- source/net/filebot/ui/rename/FormatDialog.java | 12 +++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index 4b1d0253..6c25b447 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -89,7 +89,7 @@ public class MediaBindingBean { @Define(undefined) public T undefined(String name) { // omit expressions that depend on undefined values - throw new BindingException(name, "undefined"); + throw new BindingException(name, EXCEPTION_UNDEFINED); } @Define("n") @@ -746,7 +746,7 @@ public class MediaBindingBean { public File getMediaFile() { // make sure file is not null, and that it is an existing file if (mediaFile == null) { - throw new IllegalStateException("Sample file has not been set. Click \"Change Sample\" to select a sample file."); + throw new IllegalStateException(EXCEPTION_SAMPLE_FILE_NOT_SET); } return mediaFile; @@ -1004,4 +1004,8 @@ public class MediaBindingBean { public String toString() { return String.format("%s ⇔ %s", infoObject, mediaFile == null ? null : mediaFile.getName()); } + + public static final String EXCEPTION_UNDEFINED = "undefined"; + public static final String EXCEPTION_SAMPLE_FILE_NOT_SET = "Sample file has not been set. Click \"Change Sample\" to select a sample file."; + } diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 3c0a56d3..5a5d97a7 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -271,7 +271,7 @@ public class FormatDialog extends JDialog { // initialize window properties setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - setMinimumSize(new Dimension(715, 470)); + setMinimumSize(new Dimension(650, 470)); // initialize data setState(initMode, lockOnBinding != null ? lockOnBinding : restoreSample(initMode), lockOnBinding != null); @@ -544,10 +544,12 @@ public class FormatDialog extends JDialog { // ignore, cancelled tasks are obsolete anyway } catch (Exception e) { BindingException issue = findCause(e, BindingException.class); - if (issue != null) { - String msg = getMessage(issue); - status.setText(msg); - status.setIcon(ResourceManager.getIcon(msg.contains("Change Sample") ? "action.variables" : "status.info")); + if (issue != null && getMessage(issue).contains(MediaBindingBean.EXCEPTION_SAMPLE_FILE_NOT_SET)) { + status.setText(getMessage(issue)); + status.setIcon(ResourceManager.getIcon("action.variables")); + } else if (issue != null) { + status.setText(getMessage(issue)); + status.setIcon(ResourceManager.getIcon("status.info")); } else { status.setText(String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage())); status.setIcon(ResourceManager.getIcon("status.warning"));