simtools.ui
Class DesktopCardPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by simtools.ui.DesktopCardPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener
Direct Known Subclasses:
FiledDesktopCardPanel

public class DesktopCardPanel
extends javax.swing.JPanel
implements javax.swing.event.ChangeListener, java.awt.event.MouseListener, java.awt.event.ActionListener

This class manages a list of swing components inside either internal frames (one per component) on a desktop or a single panel which displays only the selected component. Component selection is performed through a tab pane which displays components names using Component.getName(). The selected component is inside a frame which is at the top of the desktop when desktop mode is used. The selected component is displayed inside a panel under the tab pane when the single panel mode is used. A maximize action on one of the frame of the desktop leads to the single panel mode with the selected component Using the menu provided by the getMenu fonction, one can switch to the desktop pane by clicking on the cascade item This menu displays also all the available components and menu items to select components one after each other.

Version:
1.0 1999
Author:
Claude Cazenave
See Also:
Serialized Form

Nested Class Summary
 class DesktopCardPanel.CardPopupMenu
          A popup menu to be displayed when a card is selected
 class DesktopCardPanel.ComponentRadioButton
          The radio button to choose a component in the menu
 class DesktopCardPanel.PanelsPaneLayout
          The Layout for the panel which holds the component panels
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JPopupMenu _cardPopup
          popup menu to be displayed when the right mouse is clicked above a card item
protected  java.util.Vector _components
          list of components
protected  DesktopCardPanelMode _desktopCardPanelMode
           
protected static MenuResourceBundle _resources
          resources
protected  java.util.Stack backwardStack
          Two stacks to manage previous and next sheet actions.
static int CARD_MODE
          constant for the card display mode
static int DESKTOP_MODE
          constant for the desktop display mode
static int EXTERNAL_MODE
          constant for the external frame display mode
protected  java.util.Stack forwardStack
          Two stacks to manage previous and next sheet actions.
static int SCROLLING_MODE
          the scrolling mode as defined in JViewPort
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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
DesktopCardPanel(boolean scrollable)
          Creates a new DesktopCardPanel The single pane mode is selected The list of components is empty
DesktopCardPanel(boolean scrollable, boolean closable)
          Creates a new DesktopCardPanel The single pane mode is selected The list of components is empty
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addComponent(javax.swing.JComponent d)
          Adds a component
 void addListener(DesktopCardPanelListener dcpl)
          Adds a new Listener on component selection
protected  void back()
           
protected  void createCardPopupMenu()
           
 javax.swing.JMenu createMenu(java.lang.String name)
          Creates a menu to switch between components Each component is displayed in the menu using toString()
 javax.swing.JMenu createMenu(java.lang.String name, boolean enableCloseAll)
          Creates a menu to switch between components Each component is displayed in the menu using toString()
 javax.swing.JButton createNextButton()
           
 javax.swing.JButton createPreviousButton()
           
 javax.swing.JComponent getComponentAt(int index)
           
 java.util.Iterator getComponentIterator()
          Gets an iterator on the component list
 java.awt.Container getContainer(javax.swing.JComponent d)
          returns the ComponentContainer that contains the specified component
 boolean getDesktopState()
          Deprecated. use get mode instead Gets desktop mode
 int getMode()
          Gets desktop current mode
 javax.swing.JComponent getSelectedComponent()
          Gets selected component
 int getSelectedIndex()
          Gets selected component index
 int indexOfComponent(javax.swing.JComponent d)
          Gets the index of a component
 boolean is_closable()
           
 boolean is_scrollable()
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void next()
           
 void removeAllComponents()
          Removes all components
 void removeAllListeners()
          Removes all Listeners on component selection
 void removeComponent(javax.swing.JComponent d)
          Removes a component
 void removeListener(DesktopCardPanelListener dcpl)
          Removes a Listener on component selection
 void removeOtherComponents(javax.swing.JComponent jc)
          Removes all components
 void saveAllComponents()
          Save all components.
 void selectComponent(javax.swing.JComponent d)
          Selects a component
protected  void setDesktopCardPanelMode(DesktopCardPanelMode newMode)
          set the implementation of the _desktopCardPanelMode wich handles the display of the desktop components
 void setDesktopState(boolean state)
          Deprecated. use setMode(int mode) instead Changes desktop mode
 void setMode(int mode)
          set the desktop display mode
 void stateChanged(javax.swing.event.ChangeEvent e)
           
 void updateComponentName(javax.swing.JComponent d)
          Updates the name of a component
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_resources

protected static MenuResourceBundle _resources
resources


CARD_MODE

public static final int CARD_MODE
constant for the card display mode

See Also:
Constant Field Values

DESKTOP_MODE

public static final int DESKTOP_MODE
constant for the desktop display mode

See Also:
Constant Field Values

EXTERNAL_MODE

public static final int EXTERNAL_MODE
constant for the external frame display mode

See Also:
Constant Field Values

SCROLLING_MODE

public static int SCROLLING_MODE
the scrolling mode as defined in JViewPort


_components

protected java.util.Vector _components
list of components


_cardPopup

protected javax.swing.JPopupMenu _cardPopup
popup menu to be displayed when the right mouse is clicked above a card item


_desktopCardPanelMode

protected DesktopCardPanelMode _desktopCardPanelMode

backwardStack

protected java.util.Stack backwardStack
Two stacks to manage previous and next sheet actions. Contains pointers to existing sheets.


forwardStack

protected java.util.Stack forwardStack
Two stacks to manage previous and next sheet actions. Contains pointers to existing sheets.

Constructor Detail

DesktopCardPanel

public DesktopCardPanel(boolean scrollable)
Creates a new DesktopCardPanel The single pane mode is selected The list of components is empty

Parameters:
scrollable - true if scrollable pane and frames are required

DesktopCardPanel

public DesktopCardPanel(boolean scrollable,
                        boolean closable)
Creates a new DesktopCardPanel The single pane mode is selected The list of components is empty

Parameters:
scrollable - true if scrollable pane and frames are required
closable - true if inner frames created will be closable
Method Detail

is_closable

public boolean is_closable()
Returns:
true if inner frames created will be closable

is_scrollable

public boolean is_scrollable()
Returns:
true if pane and frames are scrollable

createCardPopupMenu

protected void createCardPopupMenu()

setDesktopState

public void setDesktopState(boolean state)
Deprecated. use setMode(int mode) instead Changes desktop mode

Parameters:
state - true if desktop is selected

setMode

public void setMode(int mode)
set the desktop display mode

Parameters:
mode - CARD_MODE, DESKTOP_MODE or EXTERNAL_MODE

setDesktopCardPanelMode

protected void setDesktopCardPanelMode(DesktopCardPanelMode newMode)
set the implementation of the _desktopCardPanelMode wich handles the display of the desktop components

Parameters:
newMode - the new implementation of DesktopCardPanelMode

getMode

public int getMode()
Gets desktop current mode

Returns:
the current mode

getDesktopState

public boolean getDesktopState()
Deprecated. use get mode instead Gets desktop mode

Returns:
true if desktop is selected

indexOfComponent

public int indexOfComponent(javax.swing.JComponent d)
Gets the index of a component

Parameters:
d - the component
Returns:
the component index or -1 if it doesn't exist

getComponentIterator

public java.util.Iterator getComponentIterator()
Gets an iterator on the component list

Returns:
the iterator

getComponentAt

public javax.swing.JComponent getComponentAt(int index)

getContainer

public java.awt.Container getContainer(javax.swing.JComponent d)
returns the ComponentContainer that contains the specified component

Parameters:
d - the component
Returns:
the container

addComponent

public void addComponent(javax.swing.JComponent d)
Adds a component

Parameters:
d - the component

updateComponentName

public void updateComponentName(javax.swing.JComponent d)
Updates the name of a component

Parameters:
d - the component

removeComponent

public void removeComponent(javax.swing.JComponent d)
Removes a component

Parameters:
d - the component

removeAllComponents

public void removeAllComponents()
Removes all components


removeOtherComponents

public void removeOtherComponents(javax.swing.JComponent jc)
Removes all components


saveAllComponents

public void saveAllComponents()
Save all components.


getSelectedComponent

public javax.swing.JComponent getSelectedComponent()
Gets selected component

Returns:
the component or null if none

getSelectedIndex

public int getSelectedIndex()
Gets selected component index

Returns:
-1 if none

selectComponent

public void selectComponent(javax.swing.JComponent d)
Selects a component

Parameters:
d - the component

addListener

public void addListener(DesktopCardPanelListener dcpl)
Adds a new Listener on component selection


removeListener

public void removeListener(DesktopCardPanelListener dcpl)
Removes a Listener on component selection


removeAllListeners

public void removeAllListeners()
Removes all Listeners on component selection


createPreviousButton

public javax.swing.JButton createPreviousButton()
Returns:
the previous sheet button

createNextButton

public javax.swing.JButton createNextButton()
Returns:
the next sheet button

createMenu

public javax.swing.JMenu createMenu(java.lang.String name)
Creates a menu to switch between components Each component is displayed in the menu using toString()

Parameters:
the - menu name
Returns:
a new menu or null is one already created

createMenu

public javax.swing.JMenu createMenu(java.lang.String name,
                                    boolean enableCloseAll)
Creates a menu to switch between components Each component is displayed in the menu using toString()

Parameters:
name - the menu name
enableCloseAll - a boolean indicating if the 'Close all' menu item is showed
Returns:
a new menu or null is one already created

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

back

protected void back()

next

protected void next()

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener