Skip to content

Commit 9beaba8

Browse files
committed
OptionsLookAndFeel: defer usage of services
This works around early accesses to the OptionsService, particularly from the LegacyService in imagej-legacy.
1 parent 9ae23af commit 9beaba8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main/java/org/scijava/ui/swing/options/OptionsLookAndFeel.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ public class OptionsLookAndFeel extends OptionsPlugin {
7474

7575
// -- Parameters --
7676

77-
@Parameter
78-
private UIService uiService;
79-
80-
@Parameter
81-
private DisplayService displayService;
82-
8377
@Parameter
8478
private LogService log;
8579

@@ -164,14 +158,14 @@ private void refreshSwingComponents() {
164158
final Set<Component> components = new HashSet<>();
165159

166160
// add Swing UI components from visible UIs
167-
for (final UserInterface ui : uiService.getVisibleUIs()) {
161+
for (final UserInterface ui : uiService().getVisibleUIs()) {
168162
findComponents(components, ui.getApplicationFrame());
169163
findComponents(components, ui.getConsolePane());
170164
}
171165

172166
// add Swing UI components from visible displays
173-
for (final Display<?> d : displayService.getDisplays()) {
174-
final DisplayViewer<?> viewer = uiService.getDisplayViewer(d);
167+
for (final Display<?> d : displayService().getDisplays()) {
168+
final DisplayViewer<?> viewer = uiService().getDisplayViewer(d);
175169
if (viewer == null) continue;
176170
findComponents(components, viewer.getWindow());
177171
}
@@ -201,11 +195,19 @@ else if (o instanceof Component) {
201195
}
202196
}
203197

198+
private UIService uiService() {
199+
return getContext().service(UIService.class);
200+
}
201+
202+
private DisplayService displayService() {
203+
return getContext().service(DisplayService.class);
204+
}
205+
204206
// -- Deprecated methods --
205207

206208
@Deprecated
207209
public UserInterface getUI() {
208-
return uiService.getDefaultUI();
210+
return uiService().getDefaultUI();
209211
}
210212

211213
@Deprecated

0 commit comments

Comments
 (0)