Skip to content

Commit 73a9ca1

Browse files
committed
Inline getCouldNot* methods for less methods to override and lesser code complexity.
1 parent 8a3ac4f commit 73a9ca1

File tree

4 files changed

+24
-41
lines changed

4 files changed

+24
-41
lines changed

src/main/java/net/sf/jabref/external/push/AbstractPushToApplication.java

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public void pushEntries(BibtexDatabase database, BibtexEntry[] entries, String k
9090
// In case it didn't work
9191
catch (IOException excep) {
9292
couldNotCall = true;
93-
LOGGER.warn(getCouldNotCall());
93+
94+
LOGGER.warn(Localization.lang("Error") + ": "
95+
+ Localization.lang("Could not call executable") + " '" + commandPath + "'.");
9496
}
9597
}
9698

@@ -102,9 +104,11 @@ public void operationCompleted(BasePanel panel) {
102104
+ Localization.lang("Path to %0 not defined", getApplicationName()) + ".");
103105
// @formatter:on
104106
} else if (couldNotCall) {
105-
panel.output(getCouldNotCall());
107+
panel.output(Localization.lang("Error") + ": "
108+
+ Localization.lang("Could not call executable") + " '" + commandPath + "'.");
106109
} else if (couldNotConnect) {
107-
panel.output(getCouldNotConnect());
110+
panel.output(Localization.lang("Error") + ": "
111+
+ Localization.lang("Could not connect to ") + getApplicationName() + ".");
108112
} else {
109113
panel.output(Localization.lang("Pushed citations to %0", getApplicationName()) + ".");
110114
}
@@ -178,24 +182,4 @@ public void storeSettings() {
178182
Globals.prefs.put(commandPathPreferenceKey, Path.getText());
179183
}
180184

181-
/**
182-
* @return Error message in case couldNotCall is set
183-
*/
184-
protected String getCouldNotCall() {
185-
// @formatter:off
186-
return Localization.lang("Error") + ": "
187-
+ Localization.lang("Could not call executable") + " '" + commandPath + "'.";
188-
// @formatter:on
189-
}
190-
191-
/**
192-
* @return Error message in case couldNotConnect is set
193-
*/
194-
protected String getCouldNotConnect() {
195-
// @formatter:off
196-
return Localization.lang("Error") + ": "
197-
+ Localization.lang("Could not connect to ") + getApplicationName() + ".";
198-
// @formatter:on
199-
}
200-
201185
}

src/main/java/net/sf/jabref/external/push/PushToEmacs.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ public void operationCompleted(BasePanel panel) {
171171
+ "the emacsclient/gnuclient program installed and available in the PATH."),
172172
Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
173173
// @formatter:on
174+
} else {
175+
super.operationCompleted(panel);
174176
}
175-
super.operationCompleted(panel);
176177
}
177178

178179
@Override

src/main/java/net/sf/jabref/external/push/PushToLyx.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.swing.*;
2424

2525
import net.sf.jabref.*;
26+
import net.sf.jabref.gui.BasePanel;
2627
import net.sf.jabref.gui.IconTheme;
2728
import net.sf.jabref.logic.l10n.Localization;
2829
import net.sf.jabref.model.database.BibtexDatabase;
@@ -46,22 +47,18 @@ protected void initParameters() {
4647
}
4748

4849
@Override
49-
protected String getCouldNotCall() {
50-
// @formatter:off
51-
return Localization.lang("Error") + ": " +
52-
Localization.lang("unable to write to") + " " + commandPath +
53-
".in";
54-
// @formatter:on
55-
}
56-
57-
@Override
58-
protected String getCouldNotConnect() {
59-
// @formatter:off
60-
return Localization.lang("Error") + ": " +
61-
Localization.lang("verify that LyX is running and that the lyxpipe is valid")
62-
+ ". [" + commandPath + "]";
63-
// @formatter:on
64-
50+
public void operationCompleted(BasePanel panel) {
51+
if(couldNotConnect) {
52+
panel.output(Localization.lang("Error") + ": " +
53+
Localization.lang("verify that LyX is running and that the lyxpipe is valid")
54+
+ ". [" + commandPath + "]");
55+
} else if(couldNotCall) {
56+
panel.output(Localization.lang("Error") + ": " +
57+
Localization.lang("unable to write to") + " " + commandPath +
58+
".in");
59+
} else {
60+
super.operationCompleted(panel);
61+
}
6562
}
6663

6764
@Override

src/main/java/net/sf/jabref/external/push/PushToVim.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ public void operationCompleted(BasePanel panel) {
142142
Localization.lang("Could not run the 'vim' program."),
143143
Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
144144
// formatter:on
145+
} else {
146+
super.operationCompleted(panel);
145147
}
146-
super.operationCompleted(panel);
147148
}
148149

149150
@Override

0 commit comments

Comments
 (0)