Skip to content

Commit ea8c647

Browse files
committed
DefaultUIService: give a hint why no UIs are found
Multiple people have now been confused by this error. So let's give a suggestion how to overcome it. See: * http://forum.imagej.net/t/basic-imagej2-question-how-to-open-imagej/1179 * http://forum.imagej.net/t/register-virtual-stack-slices-plugin-hangs-on-macos/1123/12
1 parent f9967e1 commit ea8c647

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/org/scijava/ui/DefaultUIService.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ public void addUI(final String name, final UserInterface ui) {
159159
public void showUI() {
160160
if (disposed) return;
161161
final UserInterface ui = getDefaultUI();
162-
if (ui == null) {
163-
throw new IllegalStateException("No UIs available.");
164-
}
162+
if (ui == null) throw noUIsAvailableException();
165163
showUI(ui);
166164
}
167165

@@ -188,9 +186,7 @@ public void showUI(final UserInterface ui) {
188186
@Override
189187
public boolean isVisible() {
190188
final UserInterface ui = getDefaultUI();
191-
if (ui == null) {
192-
throw new IllegalStateException("No UIs available.");
193-
}
189+
if (ui == null) throw noUIsAvailableException();
194190
return ui.isVisible();
195191
}
196192

@@ -547,4 +543,10 @@ private void addUserInterface(final String name, final UserInterface ui) {
547543
private String getTitle() {
548544
return appService.getApp().getTitle();
549545
}
546+
547+
private IllegalStateException noUIsAvailableException() {
548+
return new IllegalStateException("No UIs available. " +
549+
"Please add a component containing a UIPlugin " +
550+
"(e.g., scijava-ui-swing) to your class-path.");
551+
}
550552
}

0 commit comments

Comments
 (0)