Class ShellManager


  • public class ShellManager
    extends java.lang.Object
    ShellManager provides a logical grouping for a set of shells

    Note: This class must be used from the SWT display thread

    Version:
    1.0
    See Also:
    org.eclipse.jface.window.WindowManager
    • Constructor Summary

      Constructors 
      Constructor Description
      ShellManager()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addWindow​(org.eclipse.swt.widgets.Shell shell)
      Adds a shell to the shell manager.
      void addWindowAddedListener​(org.eclipse.swt.widgets.Listener listener)
      Adds a listener that will be invoked when a shell has been added to the ShellManager
      void addWindowRemovedListener​(org.eclipse.swt.widgets.Listener listener)
      Adds a listener that will be invoked when a shell has been removed from the ShellManager
      protected java.util.Collection getManagedShellSet()
      Gets the set of managed shells
      int getSize()
      Gets the number of shells the ShellManager manages
      protected org.eclipse.swt.widgets.Event getSWTEvent​(org.eclipse.swt.widgets.Shell shell)
      Gets a generated SWT Event based on the shell
      java.util.Iterator<org.eclipse.swt.widgets.Shell> getWindows()
      Gets the shells managed by the manager as an Iterator
      boolean isEmpty()
      Gets whether the ShellManager manages no shells
      protected void notifyAddListeners​(org.eclipse.swt.widgets.Shell sender)
      Notifies the WindowAddedListener handlers
      protected void notifyRemoveListeners​(org.eclipse.swt.widgets.Shell sender)
      Notifies the WindowRemovedListener handlers
      void performForShells​(org.eclipse.swt.widgets.Listener command)
      Invokes the handleEvent method specified by the SWT listener for each managed shell
      void removeWindow​(org.eclipse.swt.widgets.Shell shell)
      Removes a shell from the shell manager
      void removeWindowAddedListener​(org.eclipse.swt.widgets.Listener listener)
      Removes a listener that will be invoked when a shell has been added to the ShellManager
      void removeWindowRemovedListener​(org.eclipse.swt.widgets.Listener listener)
      Removes a listener that will be invoked when a shell has been removed from the ShellManager
      static ShellManager sharedManager()
      Gets the application's shared shell manager
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • shells

        private final java.util.Collection<org.eclipse.swt.widgets.Shell> shells
      • addHandlers

        private final java.util.List addHandlers
      • removeHandlers

        private final java.util.List removeHandlers
    • Constructor Detail

      • ShellManager

        public ShellManager()
    • Method Detail

      • sharedManager

        public static final ShellManager sharedManager()

        Gets the application's shared shell manager

        This ShellManager has no bearing on other ShellManager instances

        Note: This method must be invoked by the SWT display thread

        Returns:
      • addWindow

        public final void addWindow​(org.eclipse.swt.widgets.Shell shell)
        Adds a shell to the shell manager. If the shell is already managed, it is not added again.

        Note: This method must be invoked by the SWT display thread

        Parameters:
        shell - A SWT Shell
      • removeWindow

        public final void removeWindow​(org.eclipse.swt.widgets.Shell shell)
        Removes a shell from the shell manager

        Note: This method must be invoked by the SWT display thread

        Parameters:
        shell - A SWT Shell
      • getWindows

        public final java.util.Iterator<org.eclipse.swt.widgets.Shell> getWindows()

        Gets the shells managed by the manager as an Iterator

        The order in which the shells were added are retained.

        Note: This method must be invoked by the SWT display thread

        Returns:
        The iterator
      • isEmpty

        public final boolean isEmpty()
        Gets whether the ShellManager manages no shells
        Returns:
        True if ShellManager is empty
      • getSize

        public final int getSize()
        Gets the number of shells the ShellManager manages
        Returns:
        The number
      • performForShells

        public final void performForShells​(org.eclipse.swt.widgets.Listener command)

        Invokes the handleEvent method specified by the SWT listener for each managed shell

        The event's widget is set to the reference of the shell invoking it

        Parameters:
        command - A command implemented as a SWT Listener
      • getManagedShellSet

        protected final java.util.Collection getManagedShellSet()
        Gets the set of managed shells
        Returns:
        The set
      • addWindowAddedListener

        public final void addWindowAddedListener​(org.eclipse.swt.widgets.Listener listener)

        Adds a listener that will be invoked when a shell has been added to the ShellManager

        The listener and the shell will automatically be removed when the shell is disposed

        Parameters:
        listener - A SWT Listener
      • removeWindowAddedListener

        public final void removeWindowAddedListener​(org.eclipse.swt.widgets.Listener listener)
        Removes a listener that will be invoked when a shell has been added to the ShellManager
        Parameters:
        listener - A SWT Listener
      • addWindowRemovedListener

        public final void addWindowRemovedListener​(org.eclipse.swt.widgets.Listener listener)
        Adds a listener that will be invoked when a shell has been removed from the ShellManager
        Parameters:
        listener - A SWT Listener
      • removeWindowRemovedListener

        public final void removeWindowRemovedListener​(org.eclipse.swt.widgets.Listener listener)
        Removes a listener that will be invoked when a shell has been removed from the ShellManager
        Parameters:
        listener - A SWT Listener
      • notifyAddListeners

        protected final void notifyAddListeners​(org.eclipse.swt.widgets.Shell sender)
        Notifies the WindowAddedListener handlers
        Parameters:
        sender - A SWT shell that "sends" the events
      • notifyRemoveListeners

        protected final void notifyRemoveListeners​(org.eclipse.swt.widgets.Shell sender)
        Notifies the WindowRemovedListener handlers
        Parameters:
        sender - A SWT shell that "sends" the events
      • getSWTEvent

        protected org.eclipse.swt.widgets.Event getSWTEvent​(org.eclipse.swt.widgets.Shell shell)

        Gets a generated SWT Event based on the shell

        The widget field of the event should be set to the shell

        Parameters:
        shell - A SWT Shell
        Returns:
        The event