Package weka.gui

# Class PerspectiveManager

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
weka.gui.PerspectiveManager

All Implemented Interfaces:
  `ImageObserver`, `MenuContainer`, `Serializable`, `Accessible`

public class PerspectiveManager extends JPanel
Manages perspectives and the main menu bar (if visible), holds the currently selected perspective, and implements the perspective button bar.

Version:
  $Revision: $
Author:
  Mark Hall (mhall{[at]}pentaho{[dot]}com)
See Also:
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `PerspectiveManager.SelectedPerspectivePreferences`
  Class to manage user preferences with respect to visible perspectives and whether the perspectives toolbar is always hidden or is visible on application startup

  ## Nested classes/interfaces inherited from class javax.swing.JComponent

  `JComponent.AccessibleJComponent`

  ## Nested classes/interfaces inherited from class java.awt.Component

  `Component.BaselineResizeBehavior`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `PERSPECTIVE_INTERFACE`
  Interface name of perspectives
  `static final Settings.SettingKey`
  `VISIBLE_PERSPECTIVES_KEY`
  Settings key for visible perspectives in an application

  ### Fields inherited from class javax.swing.JComponent

  `TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

  ### Fields inherited from class java.awt.Component

  `BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

  ### Fields inherited from interface java.awt.image.ImageObserver

  `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PerspectiveManager(GUIApplication mainApp, String... perspectivePrefixesToAllow)`
  Constructor
  `PerspectiveManager(GUIApplication mainApp, String[] perspectivePrefixesToAllow, String[] perspectivePrefixesToDisallow)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addSettingsMenuItemToProgramMenu(Settings settings)`
  Applications can call this to allow access to the settings editor from the program menu (in addition to the toolbar widget that pops up the settings editor)
  `void`
  `disableAllPerspectiveTabs()`
  Disable the tab/button for each visible perspective
  `void`
  `enableAllPerspectiveTabs()`
  Enable the tab/button for each visible perspective
  `List<Perspective>`
  `getLoadedPerspectives()`
  Get a list of all loaded perspectives.
  `Perspective`
  `getMainPerspective()`
  Get the main application perspective.
  `Perspective`
  `getPerspective(String ID)`
  Get the perspective with the given ID
  `JPanel`
  `getPerspectiveToolBar()`
  Get the panel that contains the perspectives toolbar
  `List<Perspective>`
  `getVisiblePerspectives()`
  Get a list of visible perspectives.
  `boolean`
  `perspectiveToolBarIsVisible()`
  Returns true if the perspective toolbar is visible
  `void`
  `setActivePerspective(int theIndex)`
  Set the active perspective
  `void`
  `setActivePerspective(String perspectiveID)`
  Set the active perspective
  `void`
  `setEnablePerspectiveTab(String perspectiveID, boolean enabled)`
  Enable/disable a perspective's button/tab
  `void`
  `setEnablePerspectiveTabs(List<String> perspectiveIDs, boolean enabled)`
  Enable/disable the tab/button for each perspective in the supplied list of perspective IDs
  `void`
  `setMainApplicationForAllPerspectives()`
  Set the main application on all perspectives managed by this manager
  `void`
  `setPerspectiveToolbarAlwaysHidden(Settings settings)`
  Set whether the perspectives toolbar should always be hidden.
  `void`
  `setPerspectiveToolBarIsVisible(boolean v)`
  `void`
  `showMenuBar(JFrame topLevelAncestor)`
  Tell the perspective manager to show the menu bar
  `void`
  `terminate()`
  Method to be called when GUI application is no longer needed, to free up resources so that they can be garbage collected.
  `boolean`
  `userRequestedPerspectiveToolbarVisibleOnStartup(Settings settings)`
  Returns true if the user has requested that the perspective toolbar is visible when the application starts up

  ### Methods inherited from class javax.swing.JPanel

  `getAccessibleContext, getUI, getUIClassID, setUI, updateUI`

  ### Methods inherited from class javax.swing.JComponent

  `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

  ### Methods inherited from class java.awt.Container

  `add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate`

  ### Methods inherited from class java.awt.Component

  `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

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

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### PERSPECTIVE_INTERFACE

    public static final String PERSPECTIVE_INTERFACE
    Interface name of perspectives

  - ### VISIBLE_PERSPECTIVES_KEY

    public static final Settings.SettingKey VISIBLE_PERSPECTIVES_KEY
    Settings key for visible perspectives in an application

- ## Constructor Details

  - ### PerspectiveManager

    public PerspectiveManager(GUIApplication mainApp, String... perspectivePrefixesToAllow)
    Constructor
    Parameters:
      `mainApp` - the application that owns this perspective manager
      `perspectivePrefixesToAllow` - a list of perspective class name prefixes that are to be allowed in this perspective manager. Any perspectives not covered by this list are ignored. An empty list means allow all.

  - ### PerspectiveManager

    public PerspectiveManager(GUIApplication mainApp, String[] perspectivePrefixesToAllow, String[] perspectivePrefixesToDisallow)
    Constructor
    Parameters:
      `mainApp` - the application that owns this perspective manager
      `perspectivePrefixesToAllow` - a list of perspective class name prefixes that are to be allowed in this perspective manager. Any perspectives not covered by this list are ignored. An empty list means allow all.
      `perspectivePrefixesToDisallow` - a list of perspective class name prefixes that are disallowed in this perspective manager. Any matches in this list are prevented from appearing in this perspective manager. Overrides a successful match in the allowed list. This enables fine-grained exclusion of perspectives (e.g. allowed might specify all perspectives in weka.gui.funky, while disallowed vetoes just weka.gui.funky.NonFunkyPerspective.)

- ## Method Details

  - ### terminate

    public void terminate()
    Method to be called when GUI application is no longer needed, to free up resources so that they can be garbage collected.

  - ### setMainApplicationForAllPerspectives

    public void setMainApplicationForAllPerspectives()
    Set the main application on all perspectives managed by this manager

  - ### setPerspectiveToolbarAlwaysHidden

    public void setPerspectiveToolbarAlwaysHidden(Settings settings)
    Set whether the perspectives toolbar should always be hidden. This allows just menu-based access to the perspectives and their settings
    Parameters:
      `settings` - the settings object to set this property on

  - ### addSettingsMenuItemToProgramMenu

    public void addSettingsMenuItemToProgramMenu(Settings settings)
    Applications can call this to allow access to the settings editor from the program menu (in addition to the toolbar widget that pops up the settings editor)
    Parameters:
      `settings` - the settings object for the application

  - ### setActivePerspective

    public void setActivePerspective(int theIndex)
    Set the active perspective
    Parameters:
      `theIndex` - the index of the perspective to make the active one

  - ### setActivePerspective

    public void setActivePerspective(String perspectiveID)
    Set the active perspective
    Parameters:
      `perspectiveID` - the ID of the perspective to make the active one

  - ### getLoadedPerspectives

    public List<Perspective> getLoadedPerspectives()
    Get a list of all loaded perspectives. I.e. all perspectives that this manager knows about. Note that this list does not include the main application perspective - use getMainPerspective() to retrieve this.
    Returns:
      a list of all loaded (but not necessary visible) perspectives

  - ### getVisiblePerspectives

    public List<Perspective> getVisiblePerspectives()
    Get a list of visible perspectives. I.e. those that are available to be selected in the perspective toolbar
    Returns:
      a list of visible perspectives

  - ### getPerspectiveToolBar

    public JPanel getPerspectiveToolBar()
    Get the panel that contains the perspectives toolbar
    Returns:
      the panel that contains the perspecitves toolbar

  - ### disableAllPerspectiveTabs

    public void disableAllPerspectiveTabs()
    Disable the tab/button for each visible perspective

  - ### enableAllPerspectiveTabs

    public void enableAllPerspectiveTabs()
    Enable the tab/button for each visible perspective

  - ### setEnablePerspectiveTabs

    public void setEnablePerspectiveTabs(List<String> perspectiveIDs, boolean enabled)
    Enable/disable the tab/button for each perspective in the supplied list of perspective IDs
    Parameters:
      `perspectiveIDs` - the list of perspective IDs
      `enabled` - true or false to enable or disable the perspective buttons

  - ### setEnablePerspectiveTab

    public void setEnablePerspectiveTab(String perspectiveID, boolean enabled)
    Enable/disable a perspective's button/tab
    Parameters:
      `perspectiveID` - the ID of the perspective to enable/disable
      `enabled` - true or false to enable or disable

  - ### perspectiveToolBarIsVisible

    public boolean perspectiveToolBarIsVisible()
    Returns true if the perspective toolbar is visible
    Returns:
      true if the perspective toolbar is visible

  - ### setPerspectiveToolBarIsVisible

    public void setPerspectiveToolBarIsVisible(boolean v)

  - ### getMainPerspective

    public Perspective getMainPerspective()
    Get the main application perspective. This is the perspective that is visible on startup of the application and is usually the entry point for the application.
    Returns:
      the main perspective

  - ### getPerspective

    public Perspective getPerspective(String ID)
    Get the perspective with the given ID
    Parameters:
      `ID` - the ID of the perspective to get
    Returns:
      the perspective, or null if there is no perspective with the supplied ID

  - ### showMenuBar

    public void showMenuBar(JFrame topLevelAncestor)
    Tell the perspective manager to show the menu bar
    Parameters:
      `topLevelAncestor` - the owning application's Frame

  - ### userRequestedPerspectiveToolbarVisibleOnStartup

    public boolean userRequestedPerspectiveToolbarVisibleOnStartup(Settings settings)
    Returns true if the user has requested that the perspective toolbar is visible when the application starts up
    Parameters:
      `settings` - the settings object for the application
    Returns:
      true if the user has specified that the perspective toolbar should be visible when the application first starts up