Class DefaultUIService
- java.lang.Object
-
- org.scijava.AbstractContextual
-
- org.scijava.plugin.AbstractRichPlugin
-
- org.scijava.service.AbstractService
-
- org.scijava.ui.DefaultUIService
-
- All Implemented Interfaces:
Comparable<Prioritized>,Contextual,Disposable,Identifiable,Initializable,Locatable,Logged,HasPluginInfo,RichPlugin,SciJavaPlugin,Prioritized,SciJavaService,Service,UIService,Versioned
public final class DefaultUIService extends AbstractService implements UIService
Default service for handling SciJava user interfaces.- Author:
- Curtis Rueden
-
-
Field Summary
-
Fields inherited from interface org.scijava.ui.UIService
UI_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description DefaultUIService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDisplayViewer(DisplayViewer<?> viewer)Registers the given viewer with the service.voidaddUI(String name, UserInterface ui)Adds the given UI to those managed by the service.voidaddUI(UserInterface ui)Adds the given UI to those managed by the service.FilechooseFile(File file, String style)Prompts the user to choose a file.FilechooseFile(String title, File file, String style)Prompts the user to choose a file.File[]chooseFiles(File parent, File[] files, FileFilter filter, String style)Prompts the user to select one or multiple files.List<File>chooseFiles(File parent, List<File> fileList, FileFilter filter, String style)Prompts the user to select one or multiple files.voiddispose()Performs any needed cleanup of the object's services, in preparation for the object being retired (e.g., to make garbage collection possible).List<UserInterface>getAvailableUIs()Gets the user interfaces available to the service.UserInterfacegetDefaultUI()Gets the default user interface.DisplayViewer<?>getDisplayViewer(Display<?> display)Gets the UI widget being used to visualize the givenDisplay.StringgetStatusMessage(StatusEvent statusEvent)Gets the status message associated with the given event.UserInterfacegetUI(String name)Gets the UI with the given name (or class name).List<PluginInfo<DisplayViewer<?>>>getViewerPlugins()Gets the list of known viewer plugins.List<UserInterface>getVisibleUIs()Gets the user interfaces that are currently visible.booleanisDefaultUI(String name)Gets whether the UI with the given name (or class name) is the default one.booleanisHeadless()Gets whether the UI is running in headless mode (no UI).booleanisVisible()Gets whether the default UI is visible.booleanisVisible(String name)Gets whether the UI with the given name or class name is visible.protected voidonEvent(StatusEvent event)protected voidonEvent(DisplayActivatedEvent e)Called when a display is activated.protected voidonEvent(DisplayCreatedEvent e)Called when a display is created.protected voidonEvent(DisplayDeletedEvent e)Called when a display is deleted.protected voidonEvent(DisplayUpdatedEvent e)Called when a display is updated.protected voidonEvent(AppQuitEvent event)voidsetDefaultUI(UserInterface ui)Sets the default user interface.voidsetHeadless(boolean headless)Sets whether the application should run in headless mode (no UI).voidshow(Object o)Creates aDisplayfor the given object, and shows it using an appropriate UI widget of the default user interface.voidshow(String name, Object o)Creates aDisplayfor the given object, and shows it using an appropriate UI widget of the default user interface.voidshow(Display<?> display)Creates and shows the givenDisplayusing an appropriate UI widget of the default user interface.voidshowContextMenu(String menuRoot, Display<?> display, int x, int y)Displays a popup context menu for the given display at the specified position.DialogPrompt.ResultshowDialog(String message)Displays a dialog prompt.DialogPrompt.ResultshowDialog(String message, String title)Displays a dialog prompt.DialogPrompt.ResultshowDialog(String message, String title, DialogPrompt.MessageType messageType)Displays a dialog prompt.DialogPrompt.ResultshowDialog(String message, String title, DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType)Displays a dialog prompt.DialogPrompt.ResultshowDialog(String message, DialogPrompt.MessageType messageType)Displays a dialog prompt.DialogPrompt.ResultshowDialog(String message, DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType)Displays a dialog prompt.voidshowUI()Displays the UI for the default user interface.voidshowUI(String name)Displays the UI with the given name (or class name).voidshowUI(UserInterface ui)Displays the given UI.-
Methods inherited from class org.scijava.service.AbstractService
getContext, setContext, toString
-
Methods inherited from class org.scijava.plugin.AbstractRichPlugin
getInfo, getPriority, setInfo, setPriority
-
Methods inherited from class org.scijava.AbstractContextual
context
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.scijava.Contextual
context, getContext, setContext
-
Methods inherited from interface org.scijava.plugin.HasPluginInfo
getInfo, setInfo
-
Methods inherited from interface org.scijava.Locatable
getLocation
-
Methods inherited from interface org.scijava.Prioritized
compareTo, getPriority, setPriority
-
Methods inherited from interface org.scijava.plugin.RichPlugin
getIdentifier, log
-
Methods inherited from interface org.scijava.service.Service
initialize, registerEventHandlers
-
Methods inherited from interface org.scijava.Versioned
getVersion
-
-
-
-
Method Detail
-
addUI
public void addUI(UserInterface ui)
Description copied from interface:UIServiceAdds the given UI to those managed by the service.Note that a UI added explicitly via this method will never be considered the default UI unless
UIService.setDefaultUI(UserInterface)is also called.
-
addUI
public void addUI(String name, UserInterface ui)
Description copied from interface:UIServiceAdds the given UI to those managed by the service.Note that a UI added explicitly via this method will never be considered the default UI unless
UIService.setDefaultUI(UserInterface)is also called.
-
showUI
public void showUI()
Description copied from interface:UIServiceDisplays the UI for the default user interface.- Specified by:
showUIin interfaceUIService- See Also:
UIService.getDefaultUI(),UIService.setDefaultUI(UserInterface)
-
showUI
public void showUI(String name)
Description copied from interface:UIServiceDisplays the UI with the given name (or class name).
-
showUI
public void showUI(UserInterface ui)
Description copied from interface:UIServiceDisplays the given UI.
-
isVisible
public boolean isVisible()
Description copied from interface:UIServiceGets whether the default UI is visible.- Specified by:
isVisiblein interfaceUIService- See Also:
UIService.getDefaultUI(),UIService.setDefaultUI(UserInterface)
-
isVisible
public boolean isVisible(String name)
Description copied from interface:UIServiceGets whether the UI with the given name or class name is visible.
-
setHeadless
public void setHeadless(boolean headless)
Description copied from interface:UIServiceSets whether the application should run in headless mode (no UI).Note that if the system itself is headless—which can be detected via the
java.awt.headlesssystem property or by callingGraphicsEnvironment.isHeadless()—then callingsetHeadless(false)will have no effect; the system will still be headless, andUIService.isHeadless()will still return true.But if the system itself is not headless, calling
setHeadless(true)will forceUIService.isHeadless()to return true, instructing the application to behave in a headless manner insofar as it can.- Specified by:
setHeadlessin interfaceUIService
-
isHeadless
public boolean isHeadless()
Description copied from interface:UIServiceGets whether the UI is running in headless mode (no UI).More precisely: returns true when
java.awt.headlesssystem property is set, and/orGraphicsEnvironment.isHeadless()returns true, and/orUIService.setHeadless(boolean)was called withtrueto force headless behavior in an otherwise headful environment.- Specified by:
isHeadlessin interfaceUIService
-
getDefaultUI
public UserInterface getDefaultUI()
Description copied from interface:UIServiceGets the default user interface.- Specified by:
getDefaultUIin interfaceUIService- See Also:
UIService.showUI(),UIService.isVisible()
-
setDefaultUI
public void setDefaultUI(UserInterface ui)
Description copied from interface:UIServiceSets the default user interface.- Specified by:
setDefaultUIin interfaceUIService- See Also:
UIService.showUI()
-
isDefaultUI
public boolean isDefaultUI(String name)
Description copied from interface:UIServiceGets whether the UI with the given name (or class name) is the default one.- Specified by:
isDefaultUIin interfaceUIService
-
getUI
public UserInterface getUI(String name)
Description copied from interface:UIServiceGets the UI with the given name (or class name).
-
getAvailableUIs
public List<UserInterface> getAvailableUIs()
Description copied from interface:UIServiceGets the user interfaces available to the service.- Specified by:
getAvailableUIsin interfaceUIService
-
getVisibleUIs
public List<UserInterface> getVisibleUIs()
Description copied from interface:UIServiceGets the user interfaces that are currently visible.- Specified by:
getVisibleUIsin interfaceUIService
-
getViewerPlugins
public List<PluginInfo<DisplayViewer<?>>> getViewerPlugins()
Description copied from interface:UIServiceGets the list of known viewer plugins.- Specified by:
getViewerPluginsin interfaceUIService
-
show
public void show(Object o)
Description copied from interface:UIServiceCreates aDisplayfor the given object, and shows it using an appropriate UI widget of the default user interface.
-
show
public void show(String name, Object o)
Description copied from interface:UIServiceCreates aDisplayfor the given object, and shows it using an appropriate UI widget of the default user interface.
-
show
public void show(Display<?> display)
Description copied from interface:UIServiceCreates and shows the givenDisplayusing an appropriate UI widget of the default user interface.
-
addDisplayViewer
public void addDisplayViewer(DisplayViewer<?> viewer)
Description copied from interface:UIServiceRegisters the given viewer with the service.- Specified by:
addDisplayViewerin interfaceUIService
-
getDisplayViewer
public DisplayViewer<?> getDisplayViewer(Display<?> display)
Description copied from interface:UIServiceGets the UI widget being used to visualize the givenDisplay.- Specified by:
getDisplayViewerin interfaceUIService
-
showDialog
public DialogPrompt.Result showDialog(String message)
Description copied from interface:UIServiceDisplays a dialog prompt.The prompt is displayed in the default user interface.
- Specified by:
showDialogin interfaceUIService- Parameters:
message- The message in the dialog itself.- Returns:
- The choice selected by the user when dismissing the dialog.
-
showDialog
public DialogPrompt.Result showDialog(String message, DialogPrompt.MessageType messageType)
Description copied from interface:UIServiceDisplays a dialog prompt.The prompt is displayed in the default user interface.
- Specified by:
showDialogin interfaceUIService- Parameters:
message- The message in the dialog itself.messageType- The type of message. This typically is rendered as an icon next to the message. For example,DialogPrompt.MessageType.WARNING_MESSAGEtypically appears as an exclamation point.- Returns:
- The choice selected by the user when dismissing the dialog.
-
showDialog
public DialogPrompt.Result showDialog(String message, DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType)
Description copied from interface:UIServiceDisplays a dialog prompt.The prompt is displayed in the default user interface.
- Specified by:
showDialogin interfaceUIService- Parameters:
message- The message in the dialog itself.messageType- The type of message. This typically is rendered as an icon next to the message. For example,DialogPrompt.MessageType.WARNING_MESSAGEtypically appears as an exclamation point.optionType- The choices available when dismissing the dialog. These choices are typically rendered as buttons for the user to click.- Returns:
- The choice selected by the user when dismissing the dialog.
-
showDialog
public DialogPrompt.Result showDialog(String message, String title)
Description copied from interface:UIServiceDisplays a dialog prompt.The prompt is displayed in the default user interface.
- Specified by:
showDialogin interfaceUIService- Parameters:
message- The message in the dialog itself.title- The title of the dialog.- Returns:
- The choice selected by the user when dismissing the dialog.
-
showDialog
public DialogPrompt.Result showDialog(String message, String title, DialogPrompt.MessageType messageType)
Description copied from interface:UIServiceDisplays a dialog prompt.The prompt is displayed in the default user interface.
- Specified by:
showDialogin interfaceUIService- Parameters:
message- The message in the dialog itself.title- The title of the dialog.messageType- The type of message. This typically is rendered as an icon next to the message. For example,DialogPrompt.MessageType.WARNING_MESSAGEtypically appears as an exclamation point.- Returns:
- The choice selected by the user when dismissing the dialog.
-
showDialog
public DialogPrompt.Result showDialog(String message, String title, DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType)
Description copied from interface:UIServiceDisplays a dialog prompt.The prompt is displayed in the default user interface.
- Specified by:
showDialogin interfaceUIService- Parameters:
message- The message in the dialog itself.title- The title of the dialog.messageType- The type of message. This typically is rendered as an icon next to the message. For example,DialogPrompt.MessageType.WARNING_MESSAGEtypically appears as an exclamation point.optionType- The choices available when dismissing the dialog. These choices are typically rendered as buttons for the user to click.- Returns:
- The choice selected by the user when dismissing the dialog.
-
chooseFile
public File chooseFile(File file, String style)
Description copied from interface:UIServicePrompts the user to choose a file.The prompt is displayed in the default user interface.
- Specified by:
chooseFilein interfaceUIService- Parameters:
file- The initial value displayed in the file chooser prompt.style- The style of chooser to use:
-
chooseFile
public File chooseFile(String title, File file, String style)
Description copied from interface:UIServicePrompts the user to choose a file.The prompt is displayed in the default user interface.
- Specified by:
chooseFilein interfaceUIService- Parameters:
title- Title to use in the file chooser dialog.file- The initial value displayed in the file chooser prompt.style- The style of chooser to use:
-
chooseFiles
public File[] chooseFiles(File parent, File[] files, FileFilter filter, String style)
Description copied from interface:UIServicePrompts the user to select one or multiple files.The prompt is displayed in the default user interface.
- Specified by:
chooseFilesin interfaceUIServicefiles- The initial value displayed in the file chooser prompt.filter- A filter allowing to restrict the choice of files
-
chooseFiles
public List<File> chooseFiles(File parent, List<File> fileList, FileFilter filter, String style)
Description copied from interface:UIServicePrompts the user to select one or multiple files.The prompt is displayed in the default user interface.
- Specified by:
chooseFilesin interfaceUIServicefileList- The initial value displayed in the file chooser prompt.filter- A filter allowing to restrict the choice of files
-
showContextMenu
public void showContextMenu(String menuRoot, Display<?> display, int x, int y)
Description copied from interface:UIServiceDisplays a popup context menu for the given display at the specified position.The context menu is displayed in the default user interface.
- Specified by:
showContextMenuin interfaceUIService
-
getStatusMessage
public String getStatusMessage(StatusEvent statusEvent)
Description copied from interface:UIServiceGets the status message associated with the given event.- Specified by:
getStatusMessagein interfaceUIService- See Also:
StatusService.getStatusMessage(String, StatusEvent)
-
dispose
public void dispose()
Description copied from interface:DisposablePerforms any needed cleanup of the object's services, in preparation for the object being retired (e.g., to make garbage collection possible).- Specified by:
disposein interfaceDisposable
-
onEvent
protected void onEvent(DisplayCreatedEvent e)
Called when a display is created. This is the magical place where the display model is connected with the real UI.
-
onEvent
protected void onEvent(DisplayDeletedEvent e)
Called when a display is deleted. The display viewer is not removed from the list of viewers until after this returns.
-
onEvent
protected void onEvent(DisplayUpdatedEvent e)
Called when a display is updated.
-
onEvent
protected void onEvent(DisplayActivatedEvent e)
Called when a display is activated.The goal here is to eventually synchronize the window activation state with the display activation state if the display activation state changed programmatically. We queue a call on the UI thread to activate the display viewer of the currently active window.
-
onEvent
protected void onEvent(AppQuitEvent event)
-
onEvent
protected void onEvent(StatusEvent event)
-
-