1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 01:08:52 -05:00

* refactor

This commit is contained in:
Reinhard Pointner 2015-11-30 06:47:35 +00:00
parent 376881f77c
commit 02e2b9f4d1
2 changed files with 13 additions and 7 deletions

View File

@ -89,7 +89,7 @@ public class MediaBindingBean {
@Define(undefined) @Define(undefined)
public <T> T undefined(String name) { public <T> T undefined(String name) {
// omit expressions that depend on undefined values // omit expressions that depend on undefined values
throw new BindingException(name, "undefined"); throw new BindingException(name, EXCEPTION_UNDEFINED);
} }
@Define("n") @Define("n")
@ -746,7 +746,7 @@ public class MediaBindingBean {
public File getMediaFile() { public File getMediaFile() {
// make sure file is not null, and that it is an existing file // make sure file is not null, and that it is an existing file
if (mediaFile == null) { 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; return mediaFile;
@ -1004,4 +1004,8 @@ public class MediaBindingBean {
public String toString() { public String toString() {
return String.format("%s ⇔ %s", infoObject, mediaFile == null ? null : mediaFile.getName()); 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.";
} }

View File

@ -271,7 +271,7 @@ public class FormatDialog extends JDialog {
// initialize window properties // initialize window properties
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setMinimumSize(new Dimension(715, 470)); setMinimumSize(new Dimension(650, 470));
// initialize data // initialize data
setState(initMode, lockOnBinding != null ? lockOnBinding : restoreSample(initMode), lockOnBinding != null); setState(initMode, lockOnBinding != null ? lockOnBinding : restoreSample(initMode), lockOnBinding != null);
@ -544,10 +544,12 @@ public class FormatDialog extends JDialog {
// ignore, cancelled tasks are obsolete anyway // ignore, cancelled tasks are obsolete anyway
} catch (Exception e) { } catch (Exception e) {
BindingException issue = findCause(e, BindingException.class); BindingException issue = findCause(e, BindingException.class);
if (issue != null) { if (issue != null && getMessage(issue).contains(MediaBindingBean.EXCEPTION_SAMPLE_FILE_NOT_SET)) {
String msg = getMessage(issue); status.setText(getMessage(issue));
status.setText(msg); status.setIcon(ResourceManager.getIcon("action.variables"));
status.setIcon(ResourceManager.getIcon(msg.contains("Change Sample") ? "action.variables" : "status.info")); } else if (issue != null) {
status.setText(getMessage(issue));
status.setIcon(ResourceManager.getIcon("status.info"));
} else { } else {
status.setText(String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage())); status.setText(String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()));
status.setIcon(ResourceManager.getIcon("status.warning")); status.setIcon(ResourceManager.getIcon("status.warning"));