com.tensegrity.gui.swing.control
Class SwingToolBar

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JToolBar
                  extended bycom.tensegrity.gui.swing.control.SwingToolBar
All Implemented Interfaces:
javax.accessibility.Accessible, BasicComponent, DocumentListener, Evaluable, EventListenerTag, GraphPanelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants, ToolBar

public class SwingToolBar
extends javax.swing.JToolBar
implements ToolBar, Evaluable, DocumentListener, GraphPanelListener

This SwingToolBar keeps care of its components when it comes to switching languages. All AbstractButtons laid out in this toolbar will get informed about this kind of change and the tooltips get adjusted by means of the information set in the UIManager instance. SwingToolBar overwrites the updateUI-method to get notified when the current LookAndFeel is switched. The Toolbar then decides which Icons to use for the specific Button.

Version:
$Id: SwingToolBar.java,v 1.29 2004/09/13 14:48:20 BurkhardWick Exp $
Author:
Andreas Ebbert
See Also:
UIManager, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JToolBar
javax.swing.JToolBar.AccessibleJToolBar, javax.swing.JToolBar.Separator
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
  SwingToolBar(SwingToolBar toolBar)
          Copy constructor.
protected SwingToolBar(UIManager uiManager)
          Do not use this constructor.
protected SwingToolBar(UIManager uiManager, int orientation)
          Do not use this constructor.
  SwingToolBar(UIManager uiManager, java.lang.String id)
          Creates a new ToolBar with the specified id as resource id for the title.
  SwingToolBar(UIManager uiManager, java.lang.String id, int orientation)
          Creates a new ToolBar with the specified id as resource id for the title.
 
Method Summary
 void acted(int actID)
          Invoked after each interaction cycle.
 javax.swing.JButton add(javax.swing.Action action, int index)
          Returns a JButton for the specified Action at index index.
 void addSeparator()
          Appends a separator of default size to the end of the tool bar.
 void applyEvList()
          Retrieves the id of the command associated with each AbstractButton of this ToolBar and refreshes the tooltip string the string provided by the UIManager.
 void documentAdded(DocumentEvent documentevent)
          Invoked after a document was added to the mdicomponent.
 void documentModelChanged(DocumentEvent documentevent)
          Invoked after a document's model has changed.
 void documentPreAdd(DocumentEvent documentevent)
          Invoked when a document is about to be added to a mdicomponent.
 void documentPreRemove(DocumentEvent documentevent)
          Invoked when a document is about to be removed from a mdicomponent.
 void documentRemoved(DocumentEvent documentevent)
          Invoked after a document was removed from the mdicomponent.
 void documentSelected(DocumentEvent documentevent)
          Invoked after a document was selected in the mdicomponent.
 void documentUnselected(DocumentEvent documentevent)
          Invoked after a document was unselected in the mdicomponent.
 java.lang.String getId()
          Accessors for the id associated with this ToolBar.
 java.lang.String getName()
          A toolbar should provide a human readable name.
 BasicComponent getParentComponent()
          Returns the parent Component of this instance.
 int indexOf(java.lang.String id)
          Returns the index of a component associated with a the given id.
 void installEvList()
          Tells the component to setup its internal state.
 void postAction()
          Invoked when a user interaction has completed on a GraphPanel this instance of GraphPanelListener is registered with.
 void postDropBaseComposite(BaseComposite baseComposite)
          Invoked when a BaseComposite was dragged and dropped onto the GraphPanel this GraphPanelListener.
 void postMouseClick()
          Invoked when a mouse click has completed on a GraphPanel this instance of GraphPanelListener is registered with.
 void preAction()
          Invoked when a user interaction is about to begin on a GraphPanel this instance of GraphPanelListener is registered with.
 void updateStatus()
          This method is used to keep the state of the toolbar up-to-date.
 void updateUI()
          This method checks whether the LookAndFeel has changed and applies this change to the icons of the bar.
 
Methods inherited from class javax.swing.JToolBar
add, addImpl, addSeparator, createActionChangeListener, createActionComponent, getAccessibleContext, getComponentAtIndex, getComponentIndex, getMargin, getOrientation, getUI, getUIClassID, isBorderPainted, isFloatable, isRollover, paintBorder, paramString, setBorderPainted, setFloatable, setLayout, setMargin, setOrientation, setRollover, setUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 
Methods inherited from interface com.tensegrity.gui.component.BasicComponent
getHeight, getWidth, repaint
 

Constructor Detail

SwingToolBar

protected SwingToolBar(UIManager uiManager)
Do not use this constructor. Therefore its declared as protected. Maybe subclasses do have a need for it.

Parameters:
uiManager - UIManager to obtain localized strings.

SwingToolBar

public SwingToolBar(UIManager uiManager,
                    java.lang.String id)
Creates a new ToolBar with the specified id as resource id for the title. This resulting string will be used as the window-title if the ToolBar is un-docked. This ToolBar has a HORIZONTAL-orientation.

Parameters:
uiManager - UIManager to obtain localized strings.
id - identifier of the GUI resource for the title of this ToolBar.

SwingToolBar

protected SwingToolBar(UIManager uiManager,
                       int orientation)
Do not use this constructor. Therefore its declared as protected. Maybe subclasses do have a need for it.

Parameters:
uiManager - UIManager to obtain localized strings.
orientation - the desired orientation. Must be either HORIZONTAL or VERTICAL.

SwingToolBar

public SwingToolBar(UIManager uiManager,
                    java.lang.String id,
                    int orientation)
Creates a new ToolBar with the specified id as resource id for the title. This resulting string will be used as the window-title if the ToolBar is un-docked. Use the orientation parameter to specify a whether the ToolBar is directed horizontal or vertical.

Parameters:
uiManager - UIManager to obtain localized strings.
id - identifier of the GUI resource for the title of this ToolBar.
orientation - the desired orientation. Must be either HORIZONTAL or VERTICAL.

SwingToolBar

public SwingToolBar(SwingToolBar toolBar)
Copy constructor.

Parameters:
toolBar - the SwingToolBar to copy.
Method Detail

add

public javax.swing.JButton add(javax.swing.Action action,
                               int index)
Returns a JButton for the specified Action at index index.

Parameters:
action - the Action of this JButton.
index - the index.
Returns:
a JButton for the specified Action at index index.

updateUI

public void updateUI()
This method checks whether the LookAndFeel has changed and applies this change to the icons of the bar. This requires, that the custom properties DEFAULT_ICON and TENSEGRITY_ICONhas been set. If not, its ignored.

See Also:
JToolBar.updateUI()

indexOf

public int indexOf(java.lang.String id)
Description copied from interface: ToolBar
Returns the index of a component associated with a the given id. The component of a toolbar are usually not directly associated to such an id, rather their internal Command instance.

Specified by:
indexOf in interface ToolBar
Parameters:
id - the id of command.
Returns:
the index of the component or -1 if no such component was found.

updateStatus

public void updateStatus()
Description copied from interface: ToolBar
This method is used to keep the state of the toolbar up-to-date.

Specified by:
updateStatus in interface ToolBar

installEvList

public void installEvList()
Description copied from interface: Evaluable
Tells the component to setup its internal state.

Specified by:
installEvList in interface Evaluable

getName

public java.lang.String getName()
Description copied from interface: ToolBar
A toolbar should provide a human readable name. That allows to identify such a toolbar in a Toolbar menu or allows to give the enclosing frame a title, when such a bar is dragged out of its container.

Specified by:
getName in interface ToolBar

applyEvList

public void applyEvList()
Retrieves the id of the command associated with each AbstractButton of this ToolBar and refreshes the tooltip string the string provided by the UIManager. Also updates the title of the ToolBar.

Specified by:
applyEvList in interface Evaluable
See Also:
Evaluable.applyEvList()

addSeparator

public void addSeparator()
Appends a separator of default size to the end of the tool bar. The default size is determined by the current look and feel. This method ignores the call, if there is already a separator at the end of the component list.


documentAdded

public void documentAdded(DocumentEvent documentevent)
Description copied from interface: DocumentListener
Invoked after a document was added to the mdicomponent.

Specified by:
documentAdded in interface DocumentListener
Parameters:
documentevent - the documentevent structure carrying information.

documentModelChanged

public void documentModelChanged(DocumentEvent documentevent)
Description copied from interface: DocumentListener
Invoked after a document's model has changed. This means the data behind the document has changed subtantially and needs to be rehashed.

Specified by:
documentModelChanged in interface DocumentListener
Parameters:
documentevent - the documentevent structure carrying information.

documentPreAdd

public void documentPreAdd(DocumentEvent documentevent)
                    throws DocumentEventVetoException
Description copied from interface: DocumentListener
Invoked when a document is about to be added to a mdicomponent. If the implementor throws the declared exception then the documentevent will be veto'd and the corresponding action will not be commence.

Specified by:
documentPreAdd in interface DocumentListener
Parameters:
documentevent - the documentevent structure carrying information.
Throws:
DocumentEventVetoException - indicates that the documentevent is not desired.

documentPreRemove

public void documentPreRemove(DocumentEvent documentevent)
                       throws DocumentEventVetoException
Description copied from interface: DocumentListener
Invoked when a document is about to be removed from a mdicomponent. If the implementor throws the declared exception then the documentevent will be veto'd and the corresponding action will not be commence.

Specified by:
documentPreRemove in interface DocumentListener
Parameters:
documentevent - the documentevent structure carrying information.
Throws:
DocumentEventVetoException - indicates that the documentevent is not desired.

documentRemoved

public void documentRemoved(DocumentEvent documentevent)
Description copied from interface: DocumentListener
Invoked after a document was removed from the mdicomponent.

Specified by:
documentRemoved in interface DocumentListener
Parameters:
documentevent - the documentevent structure carrying information.

documentSelected

public void documentSelected(DocumentEvent documentevent)
Description copied from interface: DocumentListener
Invoked after a document was selected in the mdicomponent.

Specified by:
documentSelected in interface DocumentListener
Parameters:
documentevent - the documentevent structure carrying information.

documentUnselected

public void documentUnselected(DocumentEvent documentevent)
Description copied from interface: DocumentListener
Invoked after a document was unselected in the mdicomponent.

Specified by:
documentUnselected in interface DocumentListener
Parameters:
documentevent - the documentevent structure carrying information.

postDropBaseComposite

public void postDropBaseComposite(BaseComposite baseComposite)
Description copied from interface: GraphPanelListener
Invoked when a BaseComposite was dragged and dropped onto the GraphPanel this GraphPanelListener.

Specified by:
postDropBaseComposite in interface GraphPanelListener
Parameters:
baseComposite - the

preAction

public void preAction()
Description copied from interface: GraphPanelListener
Invoked when a user interaction is about to begin on a GraphPanel this instance of GraphPanelListener is registered with. the GraphPanel this GraphPanelListener.

Specified by:
preAction in interface GraphPanelListener

acted

public void acted(int actID)
Description copied from interface: GraphPanelListener
Invoked after each interaction cycle. This method should be used with care, as the operations that are potentially done in this method affect the perceived and actual performance of interaction.

Specified by:
acted in interface GraphPanelListener
Parameters:
actID - integer id that holds one of the values defined in InteractionConstants that are prefixed with ACT*; The id gives additional info about the type of interaction that actually occured (e.g. whether a composite was manipulated or whether one or many composites were moved.

postAction

public void postAction()
Description copied from interface: GraphPanelListener
Invoked when a user interaction has completed on a GraphPanel this instance of GraphPanelListener is registered with. the GraphPanel this GraphPanelListener.

Specified by:
postAction in interface GraphPanelListener

postMouseClick

public void postMouseClick()
Description copied from interface: GraphPanelListener
Invoked when a mouse click has completed on a GraphPanel this instance of GraphPanelListener is registered with.

Specified by:
postMouseClick in interface GraphPanelListener

getParentComponent

public BasicComponent getParentComponent()
Description copied from interface: BasicComponent
Returns the parent Component of this instance.

Specified by:
getParentComponent in interface BasicComponent
Returns:
the parent component or null if no parent exists.

getId

public java.lang.String getId()
Accessors for the id associated with this ToolBar.

Returns:
Returns the id.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.