org.crosswire.common.swing.desktop

## Class ViewManager

- java.lang.Object
- - org.crosswire.common.swing.desktop.ViewManager

- All Implemented Interfaces:
    Iterable<Component>, EventListener, TitleChangedListener, ViewEventListener, Viewable

      public class ViewManager
      extends Object
      implements Viewable, TitleChangedListener, ViewEventListener

  A ViewManager is an abstraction of a desktop that displays views as tabs or sub-windows. All the views are of the same type.
  Author:
    Joe Walker, Mark Goodwin, DM Smith
  See Also:
    `The GNU General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CLEAR_VIEW`
    `static String` | `CLOSE_ALL_VIEWS`
    `static String` | `CLOSE_OTHER_VIEWS`
    `static String` | `CLOSE_VIEW`
    `private ActionFactory` | `contextActions`
    `private LayoutType` | `current` The current way the views are laid out
    `private GridBagConstraints` | `gbc` A shared, reusable constraint that makes its contents grow to fill the area.
    `private ViewGenerator` | `generator`
    `private static LayoutType` | `initial` The initial layout state
    `private JRadioButtonMenuItem` | `mdiView`
    `static String` | `NEW_TAB`
    `private JPanel` | `panel`
    `static String` | `TAB_MODE`
    `private JRadioButtonMenuItem` | `tdiView`
    `static String` | `WINDOW_MODE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ViewManager(ViewGenerator generator)` Construct a ViewManager.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Component` | `addView()` Adds a view to the list in this Desktop.
    `void` | `addView(Component component)` Add a view to the set.
    `void` | `addViewEventListener(ViewEventListener listener)` Adds a view event listener for notification of any changes to the view.
    `void` | `clear(Component view)` Reset a view so that it can be reused.
    `void` | `closeAll()` Close all the views.
    `void` | `closeOthers(Component component)` Close all the views but the one provided.
    `void` | `doClearView()` Close the current passage window.
    `void` | `doCloseAllViews()` Close all the passage windows.
    `void` | `doCloseOtherViews()` Close all other passage windows.
    `void` | `doCloseView()` Close the current passage window.
    `void` | `doNewTab()` For creating a new window.
    `void` | `doTabMode()` View the Tabbed Document Interface (TDI) interface.
    `void` | `doWindowMode()` View the Multiple Document/Window Interface (MDI) interface.
    `(package private) Object` | `getConstraint()`
    `Action` | `getContextAction(String key)` Get a particular action by internal name
    `JPanel` | `getDesktop()`
    `static int` | `getInitialLayoutType()` What is the initial layout state?
    `private static LayoutType` | `getInitialViewLayoutType()` Get the initial layout type.
    `JRadioButtonMenuItem` | `getMdiView()`
    `Component` | `getSelected()` Returns the top view.
    `JRadioButtonMenuItem` | `getTdiView()`
    `Component` | `getView(int i)` Get the view by position.
    `int` | `getViewCount()` The number of views held by this layout.
    `AbstractViewLayout` | `getViewLayout()` What is the current layout?
    `private LayoutType` | `getViewLayoutType()` What is the current layout type?
    `Collection<Component>` | `getViews()` Get a snapshot of the views as a collection.
    `Iterator<Component>` | `iterator()`
    `void` | `moveTo(AbstractViewLayout other)` Copies all the views from the one layout to the other
    `void` | `removeView(Component view)` Remove a view from the set.
    `void` | `removeViewEventListener(ViewEventListener listener)` Removes a view event listener.
    `void` | `select(Component component)` Find the view and select it.
    `void` | `setActionFactory(ActionFactory actions)` Before first use, the ViewGenerator must supply an action factory.
    `static void` | `setInitialLayoutType(int initialLayout)` What should the initial layout state be?
    `void` | `setLayoutType(LayoutType next)` Setup the current view
    `private void` | `setViewLayoutType(LayoutType newLayoutType)` Set the current layout type
    `void` | `titleChanged(TitleChangedEvent ev)` A Select pane is telling us that it has changed, and we might want to update the BibleViewPane and the AbstractViewLayout to reflect any potentially new titles
    `void` | `updateTitle(Component component)` Update the title of the view.
    `void` | `viewRemoved(ViewEvent event)`
    `void` | `visit(ViewVisitor visitor)` Visit every view in the order that they were added.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TAB_MODE

          public static final String TAB_MODE

      See Also:
        Constant Field Values

    - #### WINDOW_MODE

          public static final String WINDOW_MODE

      See Also:
        Constant Field Values

    - #### NEW_TAB

          public static final String NEW_TAB

      See Also:
        Constant Field Values

    - #### CLEAR_VIEW

          public static final String CLEAR_VIEW

      See Also:
        Constant Field Values

    - #### CLOSE_VIEW

          public static final String CLOSE_VIEW

      See Also:
        Constant Field Values

    - #### CLOSE_ALL_VIEWS

          public static final String CLOSE_ALL_VIEWS

      See Also:
        Constant Field Values

    - #### CLOSE_OTHER_VIEWS

          public static final String CLOSE_OTHER_VIEWS

      See Also:
        Constant Field Values

    - #### initial

          private static LayoutType initial

      The initial layout state

    - #### generator

          private ViewGenerator generator

    - #### panel

          private JPanel panel

    - #### current

          private LayoutType current

      The current way the views are laid out

    - #### contextActions

          private ActionFactory contextActions

    - #### tdiView

          private JRadioButtonMenuItem tdiView

    - #### mdiView

          private JRadioButtonMenuItem mdiView

    - #### gbc

          private GridBagConstraints gbc

      A shared, reusable constraint that makes its contents grow to fill the area.

  - ### Constructor Detail

    - #### ViewManager

          public ViewManager(ViewGenerator generator)

      Construct a ViewManager. The supplied action factory has this as it's bean and has actions for the following keys:
      - ViewManager.TAB_MODE
      - ViewManager.WINDOW_MODE
      - ViewManager.NEW_TAB
      - ViewManager.CLOSE_VIEW
      - ViewManager.CLEAR_VIEW
      - ViewManager.CLEAR_ALL_VIEWS
      - ViewManager.CLOSE_OTHER_VIEWS
      Parameters:
        `generator` - a ViewGenerator that this ViewManager manages.

  - ### Method Detail

    - #### setActionFactory

          public void setActionFactory(ActionFactory actions)

      Before first use, the ViewGenerator must supply an action factory. The supplied action factory has this as it's bean and has actions for the following keys:
      - ViewManager.TAB_MODE
      - ViewManager.WINDOW_MODE
      - ViewManager.NEW_TAB
      - ViewManager.CLEAR_VIEW
      - ViewManager.CLOSE_VIEW
      - ViewManager.CLOSE_ALL_VIEWS
      - ViewManager.CLOSE_OTHER_VIEWS
      Parameters:
        `actions` - the class for which i18n properties are defined

    - #### getDesktop

          public JPanel getDesktop()

      Returns:
        the desktop

    - #### getMdiView

          public JRadioButtonMenuItem getMdiView()

      Returns:
        Returns the mdiView.

    - #### getTdiView

          public JRadioButtonMenuItem getTdiView()

      Returns:
        Returns the tdiView.

    - #### addView

          public final void addView(Component component)

      Description copied from interface: `Viewable`
      Add a view to the set.
      Specified by:
        `addView` in interface `Viewable`

    - #### addView

          public final Component addView()

      Adds a view to the list in this Desktop.

    - #### closeAll

          public void closeAll()

      Description copied from interface: `Viewable`
      Close all the views. Note the policy is enforced that one view is kept. This will keep the last one added.
      Specified by:
        `closeAll` in interface `Viewable`

    - #### closeOthers

          public void closeOthers(Component component)

      Description copied from interface: `Viewable`
      Close all the views but the one provided.
      Specified by:
        `closeOthers` in interface `Viewable`
      Parameters:
        `component` - the view that is to remain open.

    - #### getView

          public Component getView(int i)

      Description copied from interface: `Viewable`
      Get the view by position. Note that adding and removing views changes the indexes of the views. Do not use this for iteration as it is not thread safe.
      Specified by:
        `getView` in interface `Viewable`
      Parameters:
        `i` - the index of the view
      Returns:
        the requested view.

    - #### getViews

          public Collection<Component> getViews()

      Description copied from interface: `Viewable`
      Get a snapshot of the views as a collection.
      Specified by:
        `getViews` in interface `Viewable`
      Returns:
        the views

    - #### moveTo

          public void moveTo(AbstractViewLayout other)

      Description copied from interface: `Viewable`
      Copies all the views from the one layout to the other
      Specified by:
        `moveTo` in interface `Viewable`
      Parameters:
        `other` - the other layout

    - #### updateTitle

          public void updateTitle(Component component)

      Description copied from interface: `Viewable`
      Update the title of the view. If the component does not implement Titleable, then a generated title will be used.
      Specified by:
        `updateTitle` in interface `Viewable`
      Parameters:
        `component` - the component whose title is to be used

    - #### removeView

          public void removeView(Component view)

      Description copied from interface: `Viewable`
      Remove a view from the set.
      Specified by:
        `removeView` in interface `Viewable`

    - #### clear

          public void clear(Component view)

      Reset a view so that it can be reused. If the Component does not implement Clearable, then nothing is done.
      Parameters:
        `view` - the view to be cleared

    - #### iterator

          public Iterator<Component> iterator()

      Specified by:
        `iterator` in interface `Iterable<Component>`

    - #### visit

          public void visit(ViewVisitor visitor)

      Description copied from interface: `Viewable`
      Visit every view in the order that they were added.
      Specified by:
        `visit` in interface `Viewable`
      Parameters:
        `visitor` - The visitor for the view

    - #### getViewCount

          public int getViewCount()

      Description copied from interface: `Viewable`
      The number of views held by this layout.
      Specified by:
        `getViewCount` in interface `Viewable`
      Returns:
        the number of views held by this layout

    - #### getSelected

          public Component getSelected()

      Description copied from interface: `Viewable`
      Returns the top view. If no view is the top, it returns the first one added.
      Specified by:
        `getSelected` in interface `Viewable`

    - #### select

          public void select(Component component)

      Description copied from interface: `Viewable`
      Find the view and select it.
      Specified by:
        `select` in interface `Viewable`

    - #### getInitialViewLayoutType

          private static LayoutType getInitialViewLayoutType()

      Get the initial layout type. This is to be used by "config"

    - #### getViewLayoutType

          private LayoutType getViewLayoutType()

      What is the current layout type?

    - #### setViewLayoutType

          private void setViewLayoutType(LayoutType newLayoutType)

      Set the current layout type

    - #### getViewLayout

          public final AbstractViewLayout getViewLayout()

      What is the current layout?

    - #### setLayoutType

          public void setLayoutType(LayoutType next)

      Setup the current view

    - #### getInitialLayoutType

          public static int getInitialLayoutType()

      What is the initial layout state?

    - #### viewRemoved

          public void viewRemoved(ViewEvent event)

      Specified by:
        `viewRemoved` in interface `ViewEventListener`

    - #### setInitialLayoutType

          public static void setInitialLayoutType(int initialLayout)

      What should the initial layout state be?

    - #### titleChanged

          public void titleChanged(TitleChangedEvent ev)

      Description copied from interface: `TitleChangedListener`
      A Select pane is telling us that it has changed, and we might want to update the BibleViewPane and the AbstractViewLayout to reflect any potentially new titles
      Specified by:
        `titleChanged` in interface `TitleChangedListener`

    - #### addViewEventListener

          public final void addViewEventListener(ViewEventListener listener)

      Description copied from interface: `Viewable`
      Adds a view event listener for notification of any changes to the view.
      Specified by:
        `addViewEventListener` in interface `Viewable`
      Parameters:
        `listener` - the listener

    - #### removeViewEventListener

          public void removeViewEventListener(ViewEventListener listener)

      Description copied from interface: `Viewable`
      Removes a view event listener.
      Specified by:
        `removeViewEventListener` in interface `Viewable`
      Parameters:
        `listener` - the listener

    - #### getContextAction

          public Action getContextAction(String key)

      Get a particular action by internal name
      Parameters:
        `key` - the internal name for the action
      Returns:
        the action requested or null if it does not exist

    - #### getConstraint

          final Object getConstraint()

    - #### doTabMode

          public void doTabMode()

      View the Tabbed Document Interface (TDI) interface.

    - #### doWindowMode

          public void doWindowMode()

      View the Multiple Document/Window Interface (MDI) interface.

    - #### doNewTab

          public void doNewTab()

      For creating a new window.

    - #### doCloseView

          public void doCloseView()

      Close the current passage window.

    - #### doClearView

          public void doClearView()

      Close the current passage window.

    - #### doCloseAllViews

          public void doCloseAllViews()

      Close all the passage windows.

    - #### doCloseOtherViews

          public void doCloseOtherViews()

      Close all other passage windows.