org.millstone.base.ui
Class Button

java.lang.Object
  |
  +--org.millstone.base.ui.AbstractComponent
        |
        +--org.millstone.base.ui.AbstractField
              |
              +--org.millstone.base.ui.Button
All Implemented Interfaces:
Buffered, BufferedValidatable, Component, java.util.EventListener, MethodEventSource, Paintable, Property, Property.Editor, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, VariableOwner

public class Button
extends AbstractField

A generic button component.

Since:
3.0
Version:
3.0.3
Author:
IT Mill Ltd.

Nested Class Summary
 class Button.ClickEvent
          Click event.
static interface Button.ClickListener
          Button click listener
 
Nested classes inherited from class org.millstone.base.ui.AbstractField
AbstractField.ReadOnlyStatusChangeEvent, AbstractField.ValueChangeEvent
 
Nested classes inherited from class org.millstone.base.data.Buffered
Buffered.SourceException
 
Nested classes inherited from class org.millstone.base.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeEvent, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Nested classes inherited from class org.millstone.base.ui.Component
Component.Listener
 
Nested classes inherited from class org.millstone.base.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Constructor Summary
Button(java.lang.String caption)
          Creates a new push button.
Button(java.lang.String caption, boolean initialState)
          Creates new switch button with initial value.
Button(java.lang.String caption, Button.ClickListener listener)
          Creates a new push button with click listener.
Button(java.lang.String caption, java.lang.Object target, java.lang.String methodName)
          Creates a new push button with a method listening button clicks.
Button(java.lang.String caption, Property dataSource)
          Creates new switch button that is connected to a boolean property.
 
Method Summary
 void addListener(Button.ClickListener listener)
          Add button click listener
 void changeVariables(java.lang.Object source, java.util.Map variables)
          Invoked when the value of a variable has changed.
protected  void fireClick()
          Emit options change event.
 java.lang.String getTag()
          Get component UIDL tag.
 java.lang.Class getType()
          The type of the button as a property.
 boolean isSwitchMode()
          Returns the switchMode.
 void paintContent(PaintTarget target)
          Paint the content of this component.
 void removeListener(Button.ClickListener listener)
          Remove button click listener
 void setImmediate(boolean immediate)
          Set immediate mode.
 void setSwitchMode(boolean switchMode)
          Sets the switchMode.
 
Methods inherited from class org.millstone.base.ui.AbstractField
addListener, addListener, addValidator, commit, constructField, discard, fireReadOnlyStatusChange, fireValueChange, focus, getErrorMessage, getPropertyDataSource, getValidators, getValue, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isValid, isWriteThrough, removeListener, removeListener, removeValidator, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setValue, setWriteThrough, toString, validate, valueChange
 
Methods inherited from class org.millstone.base.ui.AbstractComponent
addListener, addListener, addListener, addListener, attach, childRequestedRepaint, dependsOn, detach, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setDescription, setEnabled, setIcon, setLocale, setParent, setStyle, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Button

public Button(java.lang.String caption)
Creates a new push button. The value of the push button is allways false and they are immediate by default.

Parameters:
caption - Button caption

Button

public Button(java.lang.String caption,
              Button.ClickListener listener)
Creates a new push button with click listener.

Parameters:
caption - Button caption
listener - Button click listener

Button

public Button(java.lang.String caption,
              java.lang.Object target,
              java.lang.String methodName)
Creates a new push button with a method listening button clicks. The method must have either no parameters, or only one parameter of Button.ClickEvent type.

Parameters:
caption - Button caption
target - Object having the method for listening button clicks
methodName - The name of the method in target object, that receives button click events.

Button

public Button(java.lang.String caption,
              boolean initialState)
Creates new switch button with initial value.


Button

public Button(java.lang.String caption,
              Property dataSource)
Creates new switch button that is connected to a boolean property.

Method Detail

getTag

public java.lang.String getTag()
Get component UIDL tag.

Specified by:
getTag in class AbstractComponent
Returns:
Component UIDL tag as string.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paint the content of this component.

Overrides:
paintContent in class AbstractField
Parameters:
target - target UIDL stream where the component should paint itself to
Throws:
IOException - Passed from the UIDLStream.
PaintException - The paint operation failed.

changeVariables

public void changeVariables(java.lang.Object source,
                            java.util.Map variables)
Invoked when the value of a variable has changed. Button listeners are notified if the button is clicked.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractComponent
Parameters:
source - Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - Mapping from variable names to new variable values

isSwitchMode

public boolean isSwitchMode()
Returns the switchMode.

Returns:
boolean

setSwitchMode

public void setSwitchMode(boolean switchMode)
Sets the switchMode.

Parameters:
switchMode - The switchMode to set

setImmediate

public void setImmediate(boolean immediate)
Set immediate mode.

Overrides:
setImmediate in class AbstractComponent
Parameters:
immediate - boolean value specifying if the component should be in the immediate mode after the call.
See Also:
Push buttons can not be set in non-immediate mode.

getType

public java.lang.Class getType()
The type of the button as a property.

Specified by:
getType in interface Property
Specified by:
getType in class AbstractField
Returns:
type of the Property
See Also:
Property.getType()

addListener

public void addListener(Button.ClickListener listener)
Add button click listener

Parameters:
listener - Listener to be added.

removeListener

public void removeListener(Button.ClickListener listener)
Remove button click listener

Parameters:
listener - Listener to be removed.

fireClick

protected void fireClick()
Emit options change event.



Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.