Skip to content

Commit a5b9075

Browse files
committed
Notify user how to reset python mode
In case python mode fails Closes #7 Closes #4
1 parent 4058aea commit a5b9075

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/org/scijava/plugins/scripting/python/OptionsPython.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import org.scijava.plugin.Menu;
4646
import org.scijava.plugin.Parameter;
4747
import org.scijava.plugin.Plugin;
48+
import org.scijava.ui.DialogPrompt;
49+
import org.scijava.ui.UIService;
4850
import org.scijava.widget.Button;
4951

5052
/**
@@ -77,6 +79,11 @@ public class OptionsPython extends OptionsPlugin {
7779
persist = false)
7880
private boolean pythonMode;
7981

82+
@Parameter(required = false)
83+
private UIService uiService;
84+
85+
private boolean initialPythonMode = false;
86+
8087
// -- OptionsPython methods --
8188

8289
public File getPythonDir() {
@@ -132,6 +139,9 @@ public void load() {
132139
.resolve("python").resolve(platform);
133140
pythonDir = pythonPath.toFile();
134141
}
142+
143+
// Store the initial value of pythonMode for later comparison
144+
initialPythonMode = pythonMode;
135145
}
136146

137147
public void rebuildEnv() {
@@ -176,6 +186,16 @@ public void save() {
176186
// Proceed gracefully if config file cannot be written.
177187
log.debug(exc);
178188
}
189+
190+
// Warn the user if pythonMode was just enabled and wasn't before
191+
if (!initialPythonMode && pythonMode && uiService != null) {
192+
String msg =
193+
"You have just enabled Python mode. Please restart for these changes to take effect!\n\n" +
194+
"If Fiji fails to start, try deleting your configuration file and restarting.\n\nConfiguration file: " +
195+
configFile;
196+
uiService.showDialog(msg, "Python Mode Enabled",
197+
DialogPrompt.MessageType.WARNING_MESSAGE);
198+
}
179199
}
180200

181201
// -- Utility methods --

0 commit comments

Comments
 (0)