Skip to content

Commit f3df873

Browse files
committed
Remove unneeded case logic and improve javadoc
1 parent 8573d13 commit f3df873

File tree

2 files changed

+45
-37
lines changed

2 files changed

+45
-37
lines changed

src/main/java/org/scijava/ui/swing/script/InterpreterPane.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,32 @@ public class InterpreterPane implements UIComponent<JComponent> {
7171
private LogService log;
7272

7373
/**
74-
* Constructs an interpreter UI pane for a SciJava scripting REPL, with a given language preference.
74+
* Constructs an interpreter UI pane for a SciJava scripting REPL.
7575
*
76-
* @param context The SciJava application context to use
77-
* @param languagePreference The given language to use, or null to fall back to the default.
76+
* @param context The SciJava application context to use.
7877
*/
79-
public InterpreterPane(final Context context, final String languagePreference) {
78+
public InterpreterPane(final Context context) {
79+
this(context, null);
80+
}
81+
82+
/**
83+
* Constructs an interpreter UI pane for a SciJava scripting REPL, with a
84+
* given language preference.
85+
*
86+
* @param context The SciJava application context to use.
87+
* @param languagePreference The given language to use, or null to fall back
88+
* to the default.
89+
*/
90+
public InterpreterPane(final Context context,
91+
final String languagePreference)
92+
{
8093
context.inject(this);
8194
output = new OutputPane(log);
8295
final JScrollPane outputScroll = new JScrollPane(output);
8396
outputScroll.setPreferredSize(new Dimension(440, 400));
8497

85-
if(languagePreference == null) {
86-
repl = new ScriptREPL(context, output.getOutputStream());
87-
} else {
88-
repl = new ScriptREPL(context, languagePreference, output.getOutputStream());
89-
}
98+
repl = new ScriptREPL(context, languagePreference, //
99+
output.getOutputStream());
90100
repl.initialize();
91101

92102
final Writer writer = output.getOutputWriter();
@@ -142,10 +152,6 @@ public void quit() {
142152
mainPane.setDividerLocation(300);
143153
}
144154

145-
public InterpreterPane(final Context context) {
146-
this(context, null);
147-
}
148-
149155
// -- InterpreterPane methods --
150156

151157
/** Gets the associated script REPL. */

src/main/java/org/scijava/ui/swing/script/InterpreterWindow.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,40 +59,42 @@ public class InterpreterWindow extends JFrame {
5959
@Parameter
6060
private LogService log;
6161

62-
/** Constructs the scripting interpreter window. */
63-
public InterpreterWindow(final Context context, final String languagePreference) {
62+
/**
63+
* Constructs the scripting interpreter window.
64+
*
65+
* @param context The SciJava application context to use.
66+
*/
67+
public InterpreterWindow(final Context context) {
68+
this(context, null);
69+
}
70+
71+
/**
72+
* Constructs the scripting interpreter window.
73+
*
74+
* @param context The SciJava application context to use.
75+
* @param languagePreference The given language to use, or null to fall back
76+
* to the default.
77+
*/
78+
public InterpreterWindow(final Context context,
79+
final String languagePreference)
80+
{
6481
super("Script Interpreter");
6582
context.inject(this);
6683

67-
if(languagePreference == null) {
68-
pane = new InterpreterPane(context) {
69-
@Override
70-
public void dispose() {
71-
super.dispose();
72-
InterpreterWindow.super.dispose();
73-
}
74-
};
75-
} else {
76-
pane = new InterpreterPane(context, languagePreference) {
77-
@Override
78-
public void dispose() {
79-
super.dispose();
80-
InterpreterWindow.super.dispose();
81-
}
82-
};
83-
}
84+
pane = new InterpreterPane(context, languagePreference) {
85+
@Override
86+
public void dispose() {
87+
super.dispose();
88+
InterpreterWindow.super.dispose();
89+
}
90+
};
8491
setContentPane(pane.getComponent());
8592

8693
pack();
8794

8895
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
8996
}
9097

91-
/** Construct the scripting interpreter with a given language preference. */
92-
public InterpreterWindow(final Context context) {
93-
this(context, null);
94-
}
95-
9698
/** Gets the window's associated {@link ScriptREPL}. */
9799
public ScriptREPL getREPL() {
98100
return pane.getREPL();

0 commit comments

Comments
 (0)