org.wings
Class SAbstractButton

java.lang.Object
  extended by org.wings.SComponent
      extended by org.wings.SAbstractIconTextCompound
          extended by org.wings.SAbstractButton
All Implemented Interfaces:
ItemSelectable, Serializable, Cloneable, LowLevelEventListener, Renderable
Direct Known Subclasses:
SButton, SCheckBox, SRadioButton, SToggleButton

public abstract class SAbstractButton
extends SAbstractIconTextCompound
implements LowLevelEventListener

Base class for components with button functionality, ie. the need to handle ActionListener notification.

Author:
Armin Haaf
See Also:
Serialized Form

Field Summary
protected  String actionCommand
           
static String CHECKBOX
           
static String IMAGE_BUTTON
           
static String RADIOBUTTON
           
static String RESET_BUTTON
           
static String SUBMIT_BUTTON
           
 
Fields inherited from class org.wings.SAbstractIconTextCompound
changeEvent, changeListener, DISABLED_ICON, DISABLED_SELECTED_ICON, ENABLED_ICON, ICON_COUNT, PRESSED_ICON, ROLLOVER_ICON, ROLLOVER_SELECTED_ICON, SELECTED_ICON, SELECTOR_SELECTED
 
Fields inherited from class org.wings.SComponent
DONE_RENDERING, dynamicStyles, enabled, propertyChangeSupport, SELECTOR_ALL, START_RENDERING, visible, WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_FRAME
 
Constructor Summary
SAbstractButton()
          Creates a new submit button
SAbstractButton(Action action)
           
SAbstractButton(String text)
          Create a button with given text.
SAbstractButton(String text, String type)
          Creates a new Button with the given Text and the given Type.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds an ActionListener to the button.
protected  void configurePropertiesFromAction(Action a)
           
protected  PropertyChangeListener createActionPropertyChangeListener(Action a)
           
 void doClick()
          Simulates an click on the Button
protected  void fireActionPerformed(ActionEvent event)
          Fire an ActionEvent at each registered listener.
 void fireFinalEvents()
          Internal event trigger used by CGs.
 void fireIntermediateEvents()
          fire events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...
 Action getAction()
          Returns the action for this ActionEvent source, or null if no Action is set.
 String getActionCommand()
          Returns the action command for this button.
 ActionListener[] getActionListeners()
          Returns an array of all the ActionListeners added to this AbstractButton with addActionListener().
 String getDeselectionParameter()
           
 String getEventTarget()
           
 SButtonGroup getGroup()
          Return the Button group where this button lies in
 String getMnemonic()
           
 String getSelectionParameter()
           
 String getToggleSelectionParameter()
           
 String getType()
          Delifers the Button Type
 boolean isEpochCheckEnabled()
          Asks the low-level event listener if epoch checking should be perfomed on it.
 boolean isWordWrap()
          Determiens if the label text word wrap inside the browser.
protected  boolean parseSelectionToggle(String toggleParameter)
           
 void processLowLevelEvent(String action, String[] values)
          Deliver low level/http events (parameters).
 void removeActionListener(ActionListener listener)
          Removes the supplied Listener from the listener list
 void setAction(Action a)
          Sets the action for the ActionEvent source.
 void setActionCommand(String ac)
          Sets the action command for this button.
 void setCG(ButtonCG cg)
           
 void setEpochCheckEnabled(boolean epochCheckEnabled)
           
 void setEventTarget(String target)
           
protected  void setGroup(SButtonGroup g)
          Add this button to a button group.
 void setMnemonic(String mnemonic)
           
protected  void setParentFrame(SFrame f)
          Sets the parent frame.
 void setSelected(boolean b)
          Sets the state of the button.
 void setType(String t)
          Sets the button type.
 void setWordWrap(boolean wordWrap)
          Defines if the label is allowed to wrap.
 
Methods inherited from class org.wings.SAbstractIconTextCompound
addChangeListener, addItemListener, delayEvents, fireItemStateChanged, fireStateChanged, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getModel, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getSelectionBackground, getSelectionFont, getSelectionForeground, getText, getVerticalTextPosition, isSelected, removeChangeListener, removeItemListener, setDisabledIcon, setDisabledSelectedIcon, setHorizontalTextPosition, setIcon, setIcons, setIconTextGap, setModel, setPressedIcon, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setSelectionBackground, setSelectionFont, setSelectionForeground, setText, setVerticalTextPosition, shouldDelayEvents
 
Methods inherited from class org.wings.SComponent
addComponentListener, addDynamicStyle, addEventListener, addNotify, addParentFrameListener, addPropertyChangeListener, addPropertyChangeListener, addRenderListener, addScriptListener, addStyle, clone, fireComponentChangeEvent, fireKeyEvents, fireRenderEvent, getActionMap, getBackground, getBorder, getCG, getClientProperty, getComponentPopupMenu, getDynamicStyle, getDynamicStyles, getFocusTraversalIndex, getFont, getForeground, getHorizontalAlignment, getInputMap, getInputMap, getListenerCount, getListenerList, getListeners, getLowLevelEventId, getName, getParent, getParentFrame, getPreferredSize, getRequestURL, getResidesInForm, getScriptListenerList, getScriptListeners, getSession, getShowAsFormComponent, getStyle, getToolTipText, getVerticalAlignment, invite, isDifferent, isEnabled, isFocusOwner, isRecursivelyVisible, isReloadForced, isUpdatePossible, isVisible, paramString, processComponentEvent, processKeyEvents, putClientProperty, reload, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, removeComponentListener, removeDynamicStyle, removeEventListener, removeNotify, removeParentFrameListener, removePropertyChangeListener, removePropertyChangeListener, removeRenderListener, removeScriptListener, removeStyle, requestFocus, scrollRectToVisible, setActionMap, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setBackground, setBorder, setCG, setComponentPopupMenu, setDynamicStyles, setEnabled, setFocusTraversalIndex, setFont, setForeground, setHorizontalAlignment, setInputMap, setInputMap, setName, setNameRaw, setParent, setPreferredSize, setReloadForced, setShowAsFormComponent, setStyle, setToolTipText, setVerticalAlignment, setVisible, toString, update, updateCG, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.wings.LowLevelEventListener
getLowLevelEventId, getName, isEnabled
 

Field Detail

SUBMIT_BUTTON

public static final String SUBMIT_BUTTON
See Also:
Constant Field Values

RESET_BUTTON

public static final String RESET_BUTTON
See Also:
Constant Field Values

IMAGE_BUTTON

public static final String IMAGE_BUTTON
See Also:
Constant Field Values

CHECKBOX

public static final String CHECKBOX
See Also:
Constant Field Values

RADIOBUTTON

public static final String RADIOBUTTON
See Also:
Constant Field Values

actionCommand

protected String actionCommand
Constructor Detail

SAbstractButton

public SAbstractButton(String text)
Create a button with given text.

Parameters:
text - the button text

SAbstractButton

public SAbstractButton(Action action)

SAbstractButton

public SAbstractButton(String text,
                       String type)
Creates a new Button with the given Text and the given Type.

Parameters:
text - the button text
type - the button type
See Also:
setType(java.lang.String)

SAbstractButton

public SAbstractButton()
Creates a new submit button

Method Detail

setActionCommand

public void setActionCommand(String ac)
Sets the action command for this button.

Parameters:
ac - the action command for this button

getActionCommand

public final String getActionCommand()
Returns the action command for this button.

Returns:
the action command for this button

getGroup

public final SButtonGroup getGroup()
Return the Button group where this button lies in

Returns:
Button Group or null if not in a group

setParentFrame

protected void setParentFrame(SFrame f)
Description copied from class: SComponent
Sets the parent frame.

Overrides:
setParentFrame in class SComponent
Parameters:
f - the frame

setGroup

protected void setGroup(SButtonGroup g)
Add this button to a button group. This influences the event-prefix this button reports to the request dispatcher: it will change to the button group's prefix.


addActionListener

public void addActionListener(ActionListener listener)
Adds an ActionListener to the button.

Parameters:
listener - the ActionListener to be added

removeActionListener

public void removeActionListener(ActionListener listener)
Removes the supplied Listener from the listener list


getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the ActionListeners added to this AbstractButton with addActionListener().

Returns:
all of the ActionListeners added or an empty array if no listeners have been added

fireActionPerformed

protected void fireActionPerformed(ActionEvent event)
Fire an ActionEvent at each registered listener.

Parameters:
event - supplied ActionEvent

setType

public void setType(String t)
Sets the button type. Use one of the following types:


getType

public final String getType()
Delifers the Button Type

Returns:
Button Type

doClick

public void doClick()
Simulates an click on the Button


setSelected

public void setSelected(boolean b)
Sets the state of the button. *

Overrides:
setSelected in class SAbstractIconTextCompound
Parameters:
b - true if the button is selected, otherwise false

processLowLevelEvent

public void processLowLevelEvent(String action,
                                 String[] values)
Description copied from interface: LowLevelEventListener
Deliver low level/http events (parameters). The name-value-pairs of the HTTPRequest are considered low level events.

Specified by:
processLowLevelEvent in interface LowLevelEventListener
Overrides:
processLowLevelEvent in class SComponent
Parameters:
action - the name-value-pair's name
values - the name-value-pair's values

fireIntermediateEvents

public void fireIntermediateEvents()
Description copied from interface: LowLevelEventListener
fire events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...

Specified by:
fireIntermediateEvents in interface LowLevelEventListener
Overrides:
fireIntermediateEvents in class SAbstractIconTextCompound

fireFinalEvents

public void fireFinalEvents()
Description copied from class: SComponent
Internal event trigger used by CGs. This Method is called internal and should not be called directly

Specified by:
fireFinalEvents in interface LowLevelEventListener
Overrides:
fireFinalEvents in class SAbstractIconTextCompound

getEventTarget

public final String getEventTarget()

setEventTarget

public void setEventTarget(String target)

parseSelectionToggle

protected boolean parseSelectionToggle(String toggleParameter)

getToggleSelectionParameter

public String getToggleSelectionParameter()

getSelectionParameter

public String getSelectionParameter()

getDeselectionParameter

public String getDeselectionParameter()

setAction

public void setAction(Action a)
Sets the action for the ActionEvent source. the new action code will replace the old one but not the one bound to the actionListener

Parameters:
a - the Action for the AbstractButton,

getAction

public Action getAction()
Returns the action for this ActionEvent source, or null if no Action is set.

Returns:
the Action for this ActionEvent source, or null

setCG

public void setCG(ButtonCG cg)

configurePropertiesFromAction

protected void configurePropertiesFromAction(Action a)

createActionPropertyChangeListener

protected PropertyChangeListener createActionPropertyChangeListener(Action a)

setMnemonic

public void setMnemonic(String mnemonic)

getMnemonic

public String getMnemonic()

isEpochCheckEnabled

public boolean isEpochCheckEnabled()
Description copied from interface: LowLevelEventListener
Asks the low-level event listener if epoch checking should be perfomed on it. If true the Dispatcher will ignore request originating from old views (typically iniated by triggering browser back and clicking somewhere.)

Specified by:
isEpochCheckEnabled in interface LowLevelEventListener
Returns:
true if epoch checking should be perfomed, false if all request for this component should be processed.
See Also:
LowLevelEventListener.isEpochCheckEnabled()

setEpochCheckEnabled

public void setEpochCheckEnabled(boolean epochCheckEnabled)
See Also:
LowLevelEventListener.isEpochCheckEnabled()

isWordWrap

public boolean isWordWrap()
Determiens if the label text word wrap inside the browser. Defaults to false (Swing).

Returns:
false if the label should not word wrap an be in line as in Swing.

setWordWrap

public void setWordWrap(boolean wordWrap)
Defines if the label is allowed to wrap.

Parameters:
wordWrap - Set to true if you want labels to allow to break into more lines than passed.


wingS Swings ;-)