es.prodevelop.gvsig.mobile.gui.tool
Class TBComboButton

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byes.prodevelop.gvsig.mobile.gui.tool.GenericButton
              extended byes.prodevelop.gvsig.mobile.gui.tool.TBWidget
                  extended byes.prodevelop.gvsig.mobile.gui.tool.TBButton
                      extended byes.prodevelop.gvsig.mobile.gui.tool.TBComboButton
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, java.awt.image.ImageObserver, IToolContainer, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

public class TBComboButton
extends TBButton
implements IToolContainer, java.awt.event.MouseListener

A button that is aimed to be placed in a tool bar, with the ability to contain several buttons inside. Only one button is shown in the tool bar, the rest are accesible trough a list under a combo box style.

A TBComboButton must be placed in a ToolBar and contains:

Author:
mmontesinos
See Also:
ToolBar, TBButton, TBDropDownButton, Serialized Form

Field Summary
 
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
TBComboButton(ToolBar _owner, TBButton defaultTBButton, java.awt.event.MouseListener ml)
          Creates an instance of a TBComboButton button by calling to the superclass constructor given the owner where it should be placed (which must be a ToolBar), the default button (which must be a TBButton and the listener of the events for this new instance
 
Method Summary
 void addButton(TBButton button, int index)
          Adds a button to the combo list.
 void createMenu()
          Create a Drop-down menu associated to the combo button with the buttons added to the TBComboButton as the items list
 boolean equals(java.lang.Object obj)
          Override method of java.lang.Object.equals for inspecting equals in the buttons of the list
 TBButton getActiveTool()
          Returns the active tool in the combo list
 int getButtonCount()
          Returns the number of buttons existing in the combo button.
 TBButton[] getButtons()
          Returns the array of buttons of type TBButton that the Combo Button contains
 TBDropDownButton getDropDown()
           
 int getIndex()
          Gets the index of the active button in the list
 TBMenu getMenu()
           
 MainWindow getWindow()
          Returns the MainWindow of the combo button
 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)
           
 void paint(java.awt.Graphics g)
          Override method of paint method which forces the paint of the active button (the visible one in the tool bar) and the arrow
 void removeMenu()
          Removes the menu associated to the combo button
 void setActiveTool(int _index)
          Sets the active tool in the combo list
 void setActiveTool(TBButton b)
          Sets the active tool in the combo list
 void setIndex(int index)
          Sets the index of the active button in the list
 void setSelected(boolean _selected)
          Sets all the buttons in the list to selected/unselected status
 void setVisible(boolean b)
          Override method of java.awt.Component.setVisible It sets visible only the active button and the drop-down button.
 
Methods inherited from class es.prodevelop.gvsig.mobile.gui.tool.TBButton
buttonClone, getHeight, getHelpText, getStatusBarId, getWidth, setHeight, setStatusBarId, setWidth
 
Methods inherited from class es.prodevelop.gvsig.mobile.gui.tool.TBWidget
getOwner, setOwner
 
Methods inherited from class es.prodevelop.gvsig.mobile.gui.tool.GenericButton
isSelected
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface es.prodevelop.gvsig.mobile.gui.tool.IToolContainer
repaint
 

Constructor Detail

TBComboButton

public TBComboButton(ToolBar _owner,
                     TBButton defaultTBButton,
                     java.awt.event.MouseListener ml)
Creates an instance of a TBComboButton button by calling to the superclass constructor given the owner where it should be placed (which must be a ToolBar), the default button (which must be a TBButton and the listener of the events for this new instance

Parameters:
_owner - Toolbar parent of the TBComboButton (ToolBar) where the button is to be added
defaultTBButton - Default button of the combo buttons list. The one that will be seen at the beginning in the Toolbar. Must be a previously created TBButton
ml - Listener of Mouse Events, which must be a MouseListener
Method Detail

addButton

public void addButton(TBButton button,
                      int index)
               throws GvsigMobileException
Adds a button to the combo list. The button must be of type TBButton

Specified by:
addButton in interface IToolContainer
Parameters:
button - TBButton to be added to the ToolBar
index - number of the position that the new button will have in the array of buttons that the TBComboButton contains. It must be an int between 0 and the actual size of the array.
Throws:
GvsigMobileException

createMenu

public void createMenu()
Create a Drop-down menu associated to the combo button with the buttons added to the TBComboButton as the items list


removeMenu

public void removeMenu()
Removes the menu associated to the combo button


getButtonCount

public int getButtonCount()
Returns the number of buttons existing in the combo button.

Specified by:
getButtonCount in interface IToolContainer
Returns:
the number of buttons

getButtons

public TBButton[] getButtons()
Returns the array of buttons of type TBButton that the Combo Button contains

Specified by:
getButtons in interface IToolContainer
Returns:
array of buttons of type TBButton

getIndex

public int getIndex()
Gets the index of the active button in the list

Returns:
index number inside buttons list (from 0)

setIndex

public void setIndex(int index)
Sets the index of the active button in the list

Parameters:
index - of the new active button in the list

getActiveTool

public TBButton getActiveTool()
Returns the active tool in the combo list

Returns:
a TBButton with the Active Button

setActiveTool

public void setActiveTool(int _index)
Sets the active tool in the combo list

Specified by:
setActiveTool in interface IToolContainer
Parameters:
_index - new index to be the active tool

setActiveTool

public void setActiveTool(TBButton b)
Sets the active tool in the combo list

Parameters:
b - new tool to be the active tool

equals

public boolean equals(java.lang.Object obj)
Override method of java.lang.Object.equals for inspecting equals in the buttons of the list

Overrides:
equals in class TBButton
Parameters:
obj - Object to inspect if it's equal
Returns:
boolean true if the object equal any of the buttons in the combo button's button list
See Also:
java.lang.Object.equals

setVisible

public void setVisible(boolean b)
Override method of java.awt.Component.setVisible It sets visible only the active button and the drop-down button.


setSelected

public void setSelected(boolean _selected)
Sets all the buttons in the list to selected/unselected status

Overrides:
setSelected in class GenericButton
Parameters:
_selected - true: Set the active button to selected status false: Sets all the buttons to unselected status

getDropDown

public TBDropDownButton getDropDown()
Returns:
Returns the dropDown button in the combo button.

getMenu

public TBMenu getMenu()
Returns:
Returns the drop-down menu

getWindow

public MainWindow getWindow()
Returns the MainWindow of the combo button

Specified by:
getWindow in interface IToolContainer
Returns:
MainWindow where the toolbar which contains the combo button has been placed

paint

public void paint(java.awt.Graphics g)
Override method of paint method which forces the paint of the active button (the visible one in the tool bar) and the arrow

Overrides:
paint in class GenericButton

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