-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathUIService.java
More file actions
355 lines (316 loc) · 11.5 KB
/
UIService.java
File metadata and controls
355 lines (316 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*
* #%L
* SciJava Common shared library for SciJava software.
* %%
* Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package org.scijava.ui;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import org.scijava.app.StatusService;
import org.scijava.app.event.StatusEvent;
import org.scijava.display.Display;
import org.scijava.plugin.PluginInfo;
import org.scijava.service.SciJavaService;
import org.scijava.ui.viewer.DisplayViewer;
import org.scijava.widget.FileWidget;
/**
* Interface for service that handles user interfaces.
*
* @author Curtis Rueden
*/
public interface UIService extends SciJavaService {
// CTR TODO: Extend SingletonService<UserInterface>.
/** System property to set for overriding the default UI. */
String UI_PROPERTY = "scijava.ui";
/**
* Adds the given UI to those managed by the service.
* <p>
* Note that a UI added explicitly via this method will never be considered
* the default UI unless {@link #setDefaultUI(UserInterface)} is also called.
* </p>
*
* @param ui The UI to add.
*/
void addUI(UserInterface ui);
/**
* Adds the given UI to those managed by the service.
* <p>
* Note that a UI added explicitly via this method will never be considered
* the default UI unless {@link #setDefaultUI(UserInterface)} is also called.
* </p>
*
* @param name The nickname for the UI.
* @param ui The UI to add.
*/
void addUI(String name, UserInterface ui);
/**
* Displays the UI for the default user interface.
*
* @see #getDefaultUI()
* @see #setDefaultUI(UserInterface)
*/
void showUI();
/** Displays the UI with the given name (or class name). */
void showUI(String name);
/** Displays the given UI. */
void showUI(UserInterface ui);
/**
* Gets whether the default UI is visible.
*
* @see #getDefaultUI()
* @see #setDefaultUI(UserInterface)
*/
boolean isVisible();
/** Gets whether the UI with the given name or class name is visible. */
boolean isVisible(String name);
/**
* Sets whether the application should run in headless mode (no UI).
* <p>
* Note that if the system itself is headless—which can be detected via
* the {@code java.awt.headless} system property or by calling
* {@link java.awt.GraphicsEnvironment#isHeadless()}—then calling
* {@code setHeadless(false)} will have no effect; the system will still be
* headless, and {@link #isHeadless()} will still return true.
* </p>
* <p>
* But if the system itself is <em>not</em> headless, calling
* {@code setHeadless(true)} will force {@link #isHeadless()} to return true,
* instructing the application to behave in a headless manner insofar as it
* can.
* </p>
*/
void setHeadless(boolean isHeadless);
/**
* Gets whether the UI is running in headless mode (no UI).
* <p>
* More precisely: returns true when {@code java.awt.headless} system
* property is set, and/or {@link java.awt.GraphicsEnvironment#isHeadless()}
* returns true, and/or {@link #setHeadless(boolean)} was called with {@code
* true} to force headless behavior in an otherwise headful environment.
* </p>
*/
boolean isHeadless();
/**
* Gets the default user interface.
*
* @see #showUI()
* @see #isVisible()
*/
UserInterface getDefaultUI();
/**
* Sets the default user interface.
*
* @see #showUI()
*/
void setDefaultUI(UserInterface ui);
/**
* Gets whether the UI with the given name (or class name) is the default one.
*/
boolean isDefaultUI(String name);
/** Gets the UI with the given name (or class name). */
UserInterface getUI(String name);
/** Gets the user interfaces available to the service. */
List<UserInterface> getAvailableUIs();
/** Gets the user interfaces that are currently visible. */
List<UserInterface> getVisibleUIs();
/** Gets the list of known viewer plugins. */
List<PluginInfo<DisplayViewer<?>>> getViewerPlugins();
/** Registers the given viewer with the service. */
void addDisplayViewer(DisplayViewer<?> viewer);
/** Gets the UI widget being used to visualize the given {@link Display}. */
DisplayViewer<?> getDisplayViewer(Display<?> display);
/**
* Creates a {@link Display} for the given object, and shows it using an
* appropriate UI widget of the default user interface.
*/
void show(Object o);
/**
* Creates a {@link Display} for the given object, and shows it using an
* appropriate UI widget of the default user interface.
*
* @param name The name to use when displaying the object.
* @param o The object to be displayed.
*/
void show(String name, Object o);
/**
* Creates and shows the given {@link Display} using an appropriate UI widget
* of the default user interface.
*/
void show(Display<?> display);
/**
* Displays a dialog prompt.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param message The message in the dialog itself.
* @return The choice selected by the user when dismissing the dialog.
*/
DialogPrompt.Result showDialog(String message);
/**
* Displays a dialog prompt.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param message The message in the dialog itself.
* @param messageType The type of message. This typically is rendered as an
* icon next to the message. For example,
* {@link DialogPrompt.MessageType#WARNING_MESSAGE} typically appears
* as an exclamation point.
* @return The choice selected by the user when dismissing the dialog.
*/
DialogPrompt.Result showDialog(String message,
DialogPrompt.MessageType messageType);
/**
* Displays a dialog prompt.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param message The message in the dialog itself.
* @param messageType The type of message. This typically is rendered as an
* icon next to the message. For example,
* {@link DialogPrompt.MessageType#WARNING_MESSAGE} typically appears
* as an exclamation point.
* @param optionType The choices available when dismissing the dialog. These
* choices are typically rendered as buttons for the user to click.
* @return The choice selected by the user when dismissing the dialog.
*/
DialogPrompt.Result showDialog(String message,
DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType);
/**
* Displays a dialog prompt.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param message The message in the dialog itself.
* @param title The title of the dialog.
* @return The choice selected by the user when dismissing the dialog.
*/
DialogPrompt.Result showDialog(String message, String title);
/**
* Displays a dialog prompt.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param message The message in the dialog itself.
* @param title The title of the dialog.
* @param messageType The type of message. This typically is rendered as an
* icon next to the message. For example,
* {@link DialogPrompt.MessageType#WARNING_MESSAGE} typically appears
* as an exclamation point.
* @return The choice selected by the user when dismissing the dialog.
*/
DialogPrompt.Result showDialog(String message, String title,
DialogPrompt.MessageType messageType);
/**
* Displays a dialog prompt.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param message The message in the dialog itself.
* @param title The title of the dialog.
* @param messageType The type of message. This typically is rendered as an
* icon next to the message. For example,
* {@link DialogPrompt.MessageType#WARNING_MESSAGE} typically appears
* as an exclamation point.
* @param optionType The choices available when dismissing the dialog. These
* choices are typically rendered as buttons for the user to click.
* @return The choice selected by the user when dismissing the dialog.
*/
DialogPrompt.Result showDialog(String message, String title,
DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType);
/**
* Prompts the user to choose a file.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param file The initial value displayed in the file chooser prompt.
* @param style The style of chooser to use:
* <ul>
* <li>{@link FileWidget#OPEN_STYLE}</li>
* <li>{@link FileWidget#SAVE_STYLE}</li>
* <li>{@link FileWidget#DIRECTORY_STYLE}</li>
* </ul>
*/
File chooseFile(File file, String style);
/**
* Prompts the user to choose a file.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param title Title to use in the file chooser dialog.
* @param file The initial value displayed in the file chooser prompt.
* @param style The style of chooser to use:
* <ul>
* <li>{@link FileWidget#OPEN_STYLE}</li>
* <li>{@link FileWidget#SAVE_STYLE}</li>
* <li>{@link FileWidget#DIRECTORY_STYLE}</li>
* </ul>
*/
File chooseFile(String title, File file, String style);
/**
* Prompts the user to select one or multiple files.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param files The initial value displayed in the file chooser prompt.
* @param filter A filter allowing to restrict the choice of files
*/
File[] chooseFiles(File parent, File[] files, FileFilter filter, String style);
/**
* Prompts the user to select one or multiple files.
* <p>
* The prompt is displayed in the default user interface.
* </p>
*
* @param fileList The initial value displayed in the file chooser prompt.
* @param filter A filter allowing to restrict the choice of files
*/
List<File> chooseFiles(File parent, List<File> fileList, FileFilter filter, String style);
/**
* Displays a popup context menu for the given display at the specified
* position.
* <p>
* The context menu is displayed in the default user interface.
* </p>
*/
void showContextMenu(String menuRoot, Display<?> display, int x, int y);
/**
* Gets the status message associated with the given event.
*
* @see StatusService#getStatusMessage(String, StatusEvent)
*/
String getStatusMessage(StatusEvent statusEvent);
}