org.scijava.ui
Class DefaultUIService

java.lang.Object
  extended by org.scijava.AbstractContextual
      extended by org.scijava.plugin.AbstractRichPlugin
          extended by org.scijava.service.AbstractService
              extended by org.scijava.ui.DefaultUIService
All Implemented Interfaces:
Comparable<Prioritized>, Contextual, Disposable, HasPluginInfo, RichPlugin, SciJavaPlugin, Prioritized, SciJavaService, Service, UIService

public final class DefaultUIService
extends AbstractService
implements UIService

Default service for handling ImageJ user interfaces.

Author:
Curtis Rueden

Field Summary
 
Fields inherited from interface org.scijava.ui.UIService
UI_PROPERTY
 
Constructor Summary
DefaultUIService()
           
 
Method Summary
 void addDisplayViewer(DisplayViewer<?> viewer)
          Registers the given viewer with the service.
 void addUI(String name, UserInterface ui)
          Adds the given UI to those managed by the service.
 void addUI(UserInterface ui)
          Adds the given UI to those managed by the service.
 File chooseFile(File file, String style)
          Prompts the user to choose a file.
 void dispose()
          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.
 UserInterface getDefaultUI()
          Gets the default user interface.
 DisplayViewer<?> getDisplayViewer(Display<?> display)
          Gets the UI widget being used to visualize the given Display.
 String getStatusMessage(StatusEvent statusEvent)
          Gets the status message associated with the given event.
 UserInterface getUI(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.
 boolean isDefaultUI(String name)
          Gets whether the UI with the given name (or class name) is the default one.
 boolean isVisible()
          Gets whether the default UI is visible.
 boolean isVisible(String name)
          Gets whether the UI with the given name or class name is visible.
protected  void onEvent(AppQuitEvent event)
           
protected  void onEvent(DisplayActivatedEvent e)
          Called when a display is activated.
protected  void onEvent(DisplayCreatedEvent e)
          Called when a display is created.
protected  void onEvent(DisplayDeletedEvent e)
          Called when a display is deleted.
protected  void onEvent(DisplayUpdatedEvent e)
          Called when a display is updated.
protected  void onEvent(StatusEvent event)
           
 void setDefaultUI(UserInterface ui)
          Sets the default user interface.
 void show(Display<?> display)
          Creates and shows the given Display using an appropriate UI widget of the default user interface.
 void show(Object o)
          Creates a Display for the given object, and shows it using an appropriate UI widget of the default user interface.
 void show(String name, Object o)
          Creates a Display for the given object, and shows it using an appropriate UI widget of the default user interface.
 void showContextMenu(String menuRoot, Display<?> display, int x, int y)
          Displays a popup context menu for the given display at the specified position.
 DialogPrompt.Result showDialog(String message)
          Displays a dialog prompt.
 DialogPrompt.Result showDialog(String message, DialogPrompt.MessageType messageType)
          Displays a dialog prompt.
 DialogPrompt.Result showDialog(String message, DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType)
          Displays a dialog prompt.
 DialogPrompt.Result showDialog(String message, String title)
          Displays a dialog prompt.
 DialogPrompt.Result showDialog(String message, String title, DialogPrompt.MessageType messageType)
          Displays a dialog prompt.
 DialogPrompt.Result showDialog(String message, String title, DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType)
          Displays a dialog prompt.
 void showUI()
          Displays the UI for the default user interface.
 void showUI(String name)
          Displays the UI with the given name (or class name).
 void showUI(UserInterface ui)
          Displays the given UI.
 
Methods inherited from class org.scijava.service.AbstractService
getContext, initialize, registerEventHandlers, setContext, toString
 
Methods inherited from class org.scijava.plugin.AbstractRichPlugin
compareTo, 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.service.Service
initialize, registerEventHandlers
 
Methods inherited from interface org.scijava.Contextual
context, getContext, setContext
 
Methods inherited from interface org.scijava.Prioritized
getPriority, setPriority
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.scijava.plugin.HasPluginInfo
getInfo, setInfo
 

Constructor Detail

DefaultUIService

public DefaultUIService()
Method Detail

addUI

public void addUI(UserInterface ui)
Description copied from interface: UIService
Adds 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.

Specified by:
addUI in interface UIService
Parameters:
ui - The UI to add.

addUI

public void addUI(String name,
                  UserInterface ui)
Description copied from interface: UIService
Adds 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.

Specified by:
addUI in interface UIService
Parameters:
name - The nickname for the UI.
ui - The UI to add.

showUI

public void showUI()
Description copied from interface: UIService
Displays the UI for the default user interface.

Specified by:
showUI in interface UIService
See Also:
UIService.getDefaultUI(), UIService.setDefaultUI(UserInterface)

showUI

public void showUI(String name)
Description copied from interface: UIService
Displays the UI with the given name (or class name).

Specified by:
showUI in interface UIService

showUI

public void showUI(UserInterface ui)
Description copied from interface: UIService
Displays the given UI.

Specified by:
showUI in interface UIService

isVisible

public boolean isVisible()
Description copied from interface: UIService
Gets whether the default UI is visible.

Specified by:
isVisible in interface UIService
See Also:
UIService.getDefaultUI(), UIService.setDefaultUI(UserInterface)

isVisible

public boolean isVisible(String name)
Description copied from interface: UIService
Gets whether the UI with the given name or class name is visible.

Specified by:
isVisible in interface UIService

getDefaultUI

public UserInterface getDefaultUI()
Description copied from interface: UIService
Gets the default user interface.

Specified by:
getDefaultUI in interface UIService
See Also:
UIService.showUI(), UIService.isVisible()

setDefaultUI

public void setDefaultUI(UserInterface ui)
Description copied from interface: UIService
Sets the default user interface.

Specified by:
setDefaultUI in interface UIService
See Also:
UIService.showUI()

isDefaultUI

public boolean isDefaultUI(String name)
Description copied from interface: UIService
Gets whether the UI with the given name (or class name) is the default one.

Specified by:
isDefaultUI in interface UIService

getUI

public UserInterface getUI(String name)
Description copied from interface: UIService
Gets the UI with the given name (or class name).

Specified by:
getUI in interface UIService

getAvailableUIs

public List<UserInterface> getAvailableUIs()
Description copied from interface: UIService
Gets the user interfaces available to the service.

Specified by:
getAvailableUIs in interface UIService

getVisibleUIs

public List<UserInterface> getVisibleUIs()
Description copied from interface: UIService
Gets the user interfaces that are currently visible.

Specified by:
getVisibleUIs in interface UIService

getViewerPlugins

public List<PluginInfo<DisplayViewer<?>>> getViewerPlugins()
Description copied from interface: UIService
Gets the list of known viewer plugins.

Specified by:
getViewerPlugins in interface UIService

show

public void show(Object o)
Description copied from interface: UIService
Creates a Display for the given object, and shows it using an appropriate UI widget of the default user interface.

Specified by:
show in interface UIService

show

public void show(String name,
                 Object o)
Description copied from interface: UIService
Creates a Display for the given object, and shows it using an appropriate UI widget of the default user interface.

Specified by:
show in interface UIService
Parameters:
name - The name to use when displaying the object.
o - The object to be displayed.

show

public void show(Display<?> display)
Description copied from interface: UIService
Creates and shows the given Display using an appropriate UI widget of the default user interface.

Specified by:
show in interface UIService

addDisplayViewer

public void addDisplayViewer(DisplayViewer<?> viewer)
Description copied from interface: UIService
Registers the given viewer with the service.

Specified by:
addDisplayViewer in interface UIService

getDisplayViewer

public DisplayViewer<?> getDisplayViewer(Display<?> display)
Description copied from interface: UIService
Gets the UI widget being used to visualize the given Display.

Specified by:
getDisplayViewer in interface UIService

showDialog

public DialogPrompt.Result showDialog(String message)
Description copied from interface: UIService
Displays a dialog prompt.

The prompt is displayed in the default user interface.

Specified by:
showDialog in interface UIService
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: UIService
Displays a dialog prompt.

The prompt is displayed in the default user interface.

Specified by:
showDialog in interface UIService
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_MESSAGE typically 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: UIService
Displays a dialog prompt.

The prompt is displayed in the default user interface.

Specified by:
showDialog in interface UIService
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_MESSAGE typically 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: UIService
Displays a dialog prompt.

The prompt is displayed in the default user interface.

Specified by:
showDialog in interface UIService
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: UIService
Displays a dialog prompt.

The prompt is displayed in the default user interface.

Specified by:
showDialog in interface UIService
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_MESSAGE typically 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: UIService
Displays a dialog prompt.

The prompt is displayed in the default user interface.

Specified by:
showDialog in interface UIService
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_MESSAGE typically 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: UIService
Prompts the user to choose a file.

The prompt is displayed in the default user interface.

Specified by:
chooseFile in interface UIService
Parameters:
file - The initial value displayed in the file chooser prompt.
style - The style of chooser to use:

showContextMenu

public void showContextMenu(String menuRoot,
                            Display<?> display,
                            int x,
                            int y)
Description copied from interface: UIService
Displays a popup context menu for the given display at the specified position.

The context menu is displayed in the default user interface.

Specified by:
showContextMenu in interface UIService

getStatusMessage

public String getStatusMessage(StatusEvent statusEvent)
Description copied from interface: UIService
Gets the status message associated with the given event.

Specified by:
getStatusMessage in interface UIService
See Also:
StatusService.getStatusMessage(String, StatusEvent)

dispose

public void dispose()
Description copied from interface: Disposable
Performs any needed cleanup of the object's services, in preparation for the object being retired (e.g., to make garbage collection possible).

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractService

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)


Copyright © 2009–2014 SciJava. All rights reserved.