|
45 | 45 | import org.scijava.plugin.Menu; |
46 | 46 | import org.scijava.plugin.Parameter; |
47 | 47 | import org.scijava.plugin.Plugin; |
| 48 | +import org.scijava.ui.DialogPrompt; |
| 49 | +import org.scijava.ui.UIService; |
48 | 50 | import org.scijava.widget.Button; |
49 | 51 |
|
50 | 52 | /** |
@@ -77,6 +79,11 @@ public class OptionsPython extends OptionsPlugin { |
77 | 79 | persist = false) |
78 | 80 | private boolean pythonMode; |
79 | 81 |
|
| 82 | + @Parameter(required = false) |
| 83 | + private UIService uiService; |
| 84 | + |
| 85 | + private boolean initialPythonMode = false; |
| 86 | + |
80 | 87 | // -- OptionsPython methods -- |
81 | 88 |
|
82 | 89 | public File getPythonDir() { |
@@ -132,6 +139,9 @@ public void load() { |
132 | 139 | .resolve("python").resolve(platform); |
133 | 140 | pythonDir = pythonPath.toFile(); |
134 | 141 | } |
| 142 | + |
| 143 | + // Store the initial value of pythonMode for later comparison |
| 144 | + initialPythonMode = pythonMode; |
135 | 145 | } |
136 | 146 |
|
137 | 147 | public void rebuildEnv() { |
@@ -176,6 +186,16 @@ public void save() { |
176 | 186 | // Proceed gracefully if config file cannot be written. |
177 | 187 | log.debug(exc); |
178 | 188 | } |
| 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 | + } |
179 | 199 | } |
180 | 200 |
|
181 | 201 | // -- Utility methods -- |
|
0 commit comments