Class DefaultUIService

    • 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​(String name)
        Description copied from interface: UIService
        Displays the UI with the given name (or class name).
        Specified by:
        showUI in interface UIService
      • 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
      • setHeadless

        public void setHeadless​(boolean headless)
        Description copied from interface: UIService
        Sets 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.headless system property or by calling GraphicsEnvironment.isHeadless()—then calling setHeadless(false) will have no effect; the system will still be headless, and UIService.isHeadless() will still return true.

        But if the system itself is not headless, calling setHeadless(true) will force UIService.isHeadless() to return true, instructing the application to behave in a headless manner insofar as it can.

        Specified by:
        setHeadless in interface UIService
      • 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
      • 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
      • 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.
      • chooseFiles

        public File[] chooseFiles​(File parent,
                                  File[] files,
                                  FileFilter filter,
                                  String style)
        Description copied from interface: UIService
        Prompts the user to select one or multiple files.

        The prompt is displayed in the default user interface.

        Specified by:
        chooseFiles in interface UIService
        files - 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: UIService
        Prompts the user to select one or multiple files.

        The prompt is displayed in the default user interface.

        Specified by:
        chooseFiles in interface UIService
        fileList - 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: 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
      • 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
      • 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​(StatusEvent event)