Skip to content

Commit

Permalink
Inline getCouldNot* methods for less methods to override and lesser c…
Browse files Browse the repository at this point in the history
…ode complexity.
  • Loading branch information
simonharrer committed Oct 9, 2015
1 parent 8a3ac4f commit 73a9ca1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public void pushEntries(BibtexDatabase database, BibtexEntry[] entries, String k
// In case it didn't work
catch (IOException excep) {
couldNotCall = true;
LOGGER.warn(getCouldNotCall());

LOGGER.warn(Localization.lang("Error") + ": "
+ Localization.lang("Could not call executable") + " '" + commandPath + "'.");
}
}

Expand All @@ -102,9 +104,11 @@ public void operationCompleted(BasePanel panel) {
+ Localization.lang("Path to %0 not defined", getApplicationName()) + ".");
// @formatter:on
} else if (couldNotCall) {
panel.output(getCouldNotCall());
panel.output(Localization.lang("Error") + ": "
+ Localization.lang("Could not call executable") + " '" + commandPath + "'.");
} else if (couldNotConnect) {
panel.output(getCouldNotConnect());
panel.output(Localization.lang("Error") + ": "
+ Localization.lang("Could not connect to ") + getApplicationName() + ".");
} else {
panel.output(Localization.lang("Pushed citations to %0", getApplicationName()) + ".");
}
Expand Down Expand Up @@ -178,24 +182,4 @@ public void storeSettings() {
Globals.prefs.put(commandPathPreferenceKey, Path.getText());
}

/**
* @return Error message in case couldNotCall is set
*/
protected String getCouldNotCall() {
// @formatter:off
return Localization.lang("Error") + ": "
+ Localization.lang("Could not call executable") + " '" + commandPath + "'.";
// @formatter:on
}

/**
* @return Error message in case couldNotConnect is set
*/
protected String getCouldNotConnect() {
// @formatter:off
return Localization.lang("Error") + ": "
+ Localization.lang("Could not connect to ") + getApplicationName() + ".";
// @formatter:on
}

}
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/external/push/PushToEmacs.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ public void operationCompleted(BasePanel panel) {
+ "the emacsclient/gnuclient program installed and available in the PATH."),
Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
// @formatter:on
} else {
super.operationCompleted(panel);
}
super.operationCompleted(panel);
}

@Override
Expand Down
29 changes: 13 additions & 16 deletions src/main/java/net/sf/jabref/external/push/PushToLyx.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.swing.*;

import net.sf.jabref.*;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.gui.IconTheme;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.database.BibtexDatabase;
Expand All @@ -46,22 +47,18 @@ protected void initParameters() {
}

@Override
protected String getCouldNotCall() {
// @formatter:off
return Localization.lang("Error") + ": " +
Localization.lang("unable to write to") + " " + commandPath +
".in";
// @formatter:on
}

@Override
protected String getCouldNotConnect() {
// @formatter:off
return Localization.lang("Error") + ": " +
Localization.lang("verify that LyX is running and that the lyxpipe is valid")
+ ". [" + commandPath + "]";
// @formatter:on

public void operationCompleted(BasePanel panel) {
if(couldNotConnect) {
panel.output(Localization.lang("Error") + ": " +
Localization.lang("verify that LyX is running and that the lyxpipe is valid")
+ ". [" + commandPath + "]");
} else if(couldNotCall) {
panel.output(Localization.lang("Error") + ": " +
Localization.lang("unable to write to") + " " + commandPath +
".in");
} else {
super.operationCompleted(panel);
}
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/external/push/PushToVim.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ public void operationCompleted(BasePanel panel) {
Localization.lang("Could not run the 'vim' program."),
Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
// formatter:on
} else {
super.operationCompleted(panel);
}
super.operationCompleted(panel);
}

@Override
Expand Down

0 comments on commit 73a9ca1

Please sign in to comment.