com.gwtext.client.widgets
Class CycleButton

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.gwtext.client.widgets.Component
              extended by com.gwtext.client.widgets.Button
                  extended by com.gwtext.client.widgets.SplitButton
                      extended by com.gwtext.client.widgets.CycleButton
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, Observable

public class CycleButton
extends SplitButton

A specialized SplitButton that contains a menu of CheckItem elements. The button automatically cycles through each menu item on click, raising the button's change event (or calling the button's changeHandler function, if supplied) for the active menu item. Clicking on the arrow section of the button displays the dropdown menu just like a normal SplitButton.

 
 

CycleButtonConfig config = new CycleButtonConfig(); config.setShowText(true); config.setPrependText("View as "); config.addItem(new CheckItem("text only", true)); config.addItem(new CheckItem("HTML", false)); config.setChangeHandler(new CycleButtonHandler() { public void execute(CycleButton self, CheckItem item) { MessageBox.alert("Change View", item.getText()); } });

CycleButton button = new CycleButton(config);


Field Summary
 
Fields inherited from class com.gwtext.client.widgets.Component
config, id
 
Constructor Summary
CycleButton()
          Create a new CycleButton.
CycleButton(CycleButtonListener listener)
          Create a new CycleButton.
CycleButton(CycleButtonListener listener, java.lang.String icon)
          Create a new CycleButton.
CycleButton(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 
Method Summary
 void addItem(CheckItem item)
          Add a CheckItem config object to be used when creating the button's menu items.
 void addListener(CycleButtonListener listener)
          Add a CycleButton Listener.
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
           
 CheckItem getActiveItem()
          Gets the currently active menu item.
 java.lang.String getForceIcon()
          A css class which sets an image to be used as the static icon for this button.
 java.lang.String getPrependText()
           
 java.lang.String getShowText()
           
 java.lang.String getXType()
          Gets the xtype for this component as registered with ComponentMgr.
 void setActiveItem(CheckItem item)
          Sets the button's active menu item.
 void setActiveItem(CheckItem item, boolean supressEvent)
          Sets the button's active menu item.
 void setForceIcon(java.lang.String forceIcon)
          A css class which sets an image to be used as the static icon for this button.
 void setPrependText(java.lang.String prependText)
          A static string to prepend before the active item's text when displayed as the button's text (only applies when showText = true, defaults to '').
 void setShowText(boolean showText)
          True to display the active item's text as the button text (defaults to false).
 void toggleSelected()
          This is normally called internally on button click, but can be called externally to advance the button's active item programmatically to the next one in the menu.
 
Methods inherited from class com.gwtext.client.widgets.SplitButton
addListener, getArrowTooltip, setArrowTooltip
 
Methods inherited from class com.gwtext.client.widgets.Button
addListener, focus, getBindToForm, getButtonElement, getClickEvent, getConfigPrototype, getHandleMouseEvents, getIcon, getIconCls, getMenuAlign, getMinWidth, getOwnerCt, getTabIndex, getText, getToggleGroup, getTooltip, getTooltipType, getType, hasVisibleMenu, hideMenu, isDisabled, isEnableToggle, isPressed, isRepeat, setClickEvent, setEnableToggle, setFormBind, setHandleMouseEvents, setHidden, setIcon, setIconCls, setMenu, setMenuAlign, setMinWidth, setPressed, setRepeat, setRepeat, setTabIndex, setTemplate, setText, setToggleGroup, setTooltip, setTooltip, setTooltip, setTooltipType, setType, showMenu, toggle, toggle
 
Methods inherited from class com.gwtext.client.widgets.Component
addClass, addClassCreated, addEvent, addEvents, addListener, addListener, addListener, addPlugin, addStyleDependentName, addStyleName, afterRender, beforeDestroy, check, checkExtVer, cloneComponent, cloneComponent, cloneConfig, destroy, disable, enable, equals, error, findParentBy, findParentByType, fireEvent, focus, focus, getApplyTo, getAttribute, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAutoShow, getCls, getComponentJS, getConfig, getConfigAsString, getCtCls, getDisabledClass, getEl, getElement, getElement, getElement, getHideMode, getHideParent, getId, getItemId, getJsObj, getOffsetHeight, getOffsetWidth, getOrCreateJsObj, getOwnerContainer, getRenderTo, getStateEvents, getStateId, getTitle, getXTypes, hashCode, hide, initComponent, isCreated, isHidden, isRendered, isVisible, isXType, isXType, onDestroy, purgeListeners, removeClass, removeStyleDependentName, removeStyleName, render, render, render, render, render, render, resumeEvents, setApplyTo, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoEl, setAutoEl, setAutoShow, setCls, setCtCls, setDisabled, setDisabledClass, setEl, setEl, setElement, setHeight, setHideMode, setHideParent, setId, setRenderTo, setRenderToID, setStateEvents, setStateId, setStyle, setStyle, setStyleName, setStylePrimaryName, setTitle, setVisible, setWidth, show, suspendEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
getAbsoluteLeft, getAbsoluteTop, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, setPixelSize, setSize, setStyleName, setStyleName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CycleButton

public CycleButton()
Create a new CycleButton.


CycleButton

public CycleButton(CycleButtonListener listener)
Create a new CycleButton.

Parameters:
listener - the button listener

CycleButton

public CycleButton(CycleButtonListener listener,
                   java.lang.String icon)
Create a new CycleButton.

Parameters:
listener - the button listener
icon - icon image path

CycleButton

public CycleButton(com.google.gwt.core.client.JavaScriptObject jsObj)
Method Detail

getXType

public java.lang.String getXType()
Description copied from class: Component
Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes, see the Component javadocs.

 
 

TextField field = new TextField(); field.getXType() returns "textfield"

Overrides:
getXType in class SplitButton
Returns:
the xtype

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
Overrides:
create in class SplitButton

getActiveItem

public CheckItem getActiveItem()
Gets the currently active menu item.

Returns:
the active menu item

setActiveItem

public void setActiveItem(CheckItem item)
Sets the button's active menu item.

Parameters:
item - the item to activate

setActiveItem

public void setActiveItem(CheckItem item,
                          boolean supressEvent)
Sets the button's active menu item.

Parameters:
item - the item to activate
supressEvent - true to prevent the button's change event from firing (defaults to false)

toggleSelected

public void toggleSelected()
This is normally called internally on button click, but can be called externally to advance the button's active item programmatically to the next one in the menu. If the current item is the last one in the menu the active item will be set to the first item in the menu.


addListener

public void addListener(CycleButtonListener listener)
Add a CycleButton Listener.

Parameters:
listener - the listener

addItem

public void addItem(CheckItem item)
             throws java.lang.IllegalStateException
Add a CheckItem config object to be used when creating the button's menu items. Note that when initially creating the CycleButton, one CheckItem must be checked ie new CheckItem(s, true).

Parameters:
item - check item config
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setForceIcon

public void setForceIcon(java.lang.String forceIcon)
A css class which sets an image to be used as the static icon for this button. This icon will always be displayed regardless of which item is selected in the dropdown list. This overrides the default behavior of changing the button's icon to match the selected item's icon on change.

Parameters:
forceIcon - the forceIcon
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getForceIcon

public java.lang.String getForceIcon()
A css class which sets an image to be used as the static icon for this button. This icon will always be displayed regardless of which item is selected in the dropdown list. This overrides the default behavior of changing the button's icon to match the selected item's icon on change.

Returns:
the forceIcon

setPrependText

public void setPrependText(java.lang.String prependText)
A static string to prepend before the active item's text when displayed as the button's text (only applies when showText = true, defaults to '').

Parameters:
prependText - the prepend text

getPrependText

public java.lang.String getPrependText()
Returns:
the prepend text

setShowText

public void setShowText(boolean showText)
True to display the active item's text as the button text (defaults to false).

Parameters:
showText - true to display item's text

getShowText

public java.lang.String getShowText()
Returns:
the show text