org.vostok.vaadin.addon.button.push
Class PushButton

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractComponentContainer
              extended by com.vaadin.ui.AbstractLayout
                  extended by com.vaadin.ui.CssLayout
                      extended by org.vostok.vaadin.addon.button.push.PushButton
All Implemented Interfaces:
com.vaadin.data.Property<java.lang.Integer>, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer, com.vaadin.event.ContextClickEvent.ContextClickNotifier, com.vaadin.event.LayoutEvents.LayoutClickNotifier, com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Sizeable, com.vaadin.shared.Connector, com.vaadin.ui.Button.ClickListener, com.vaadin.ui.Component, com.vaadin.ui.ComponentContainer, com.vaadin.ui.HasComponents, com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.Layout, java.io.Serializable, java.lang.Iterable<com.vaadin.ui.Component>

public class PushButton
extends com.vaadin.ui.CssLayout
implements com.vaadin.data.Property<java.lang.Integer>, com.vaadin.data.Property.Viewer, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.ui.Button.ClickListener

PushButton is a on/off state button component. It accepts 3 differents modes :


Single mode is explicitly selected when adding a single button.

PushButton accept the scss variable :
// colour when button activated $vfv-push-background: $v-app-background-color !default; See sample at http://vaadin.vostoksystem.eu

Version:
1.0.2
Author:
levreau.jerome@vostoksystem.eu
See Also:
Serialized Form

Nested Class Summary
static class PushButton.Mode
          Switch mode policy for PushButton
static interface PushButton.PushButtonListener
          PushButton button changes listener.
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
com.vaadin.data.Property.Editor, com.vaadin.data.Property.ReadOnlyException, com.vaadin.data.Property.ReadOnlyStatusChangeEvent, com.vaadin.data.Property.ReadOnlyStatusChangeListener, com.vaadin.data.Property.ReadOnlyStatusChangeNotifier, com.vaadin.data.Property.Transactional<T>, com.vaadin.data.Property.ValueChangeEvent, com.vaadin.data.Property.ValueChangeListener, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Layout
com.vaadin.ui.Layout.AlignmentHandler, com.vaadin.ui.Layout.MarginHandler, com.vaadin.ui.Layout.SpacingHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
com.vaadin.server.Sizeable.Unit
 
Field Summary
static java.lang.String MAINCSS
           
static java.lang.String PUSHCSS
           
static java.lang.String SELECTED
           
 
Fields inherited from class com.vaadin.ui.CssLayout
components
 
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
 
Fields inherited from interface com.vaadin.ui.Button.ClickListener
BUTTON_CLICK_METHOD
 
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
PushButton()
          add an empty push button
PushButton(PushButton.PushButtonListener listener, com.vaadin.ui.Button... button)
          create new PushButton
 
Method Summary
 void addAnyComponent(com.vaadin.ui.Component c)
          addcomponent c and don't add it to the pool of managed button
 void addComponent(com.vaadin.ui.Component c)
          Add compoment c at the end of the list If c instance of com.vaadin.ui.Button it's added to the pool
 void addComponent(com.vaadin.ui.Component c, int index)
          Add component c at index index If c instance of com.vaadin.ui.Button it's added to the pool
 void addComponentAsFirst(com.vaadin.ui.Component c)
          Add compoment c at the top of the list If c instance of com.vaadin.ui.Button it's added to the pool
 void addListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void addPushButtonListener(PushButton.PushButtonListener listener)
          add a push button listener.
 void addValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void buttonClick(com.vaadin.ui.Button.ClickEvent event)
           
 boolean getComponentState(int index)
          return component state.
 PushButton.Mode getMode()
          return button mode policy. default to ONEMANY
 com.vaadin.data.Property getPropertyDataSource()
           
 java.lang.Class<? extends java.lang.Integer> getType()
           
 java.lang.Integer getValue()
          value depend on PushButton's mode
 void removeListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void removePushButtonListener(PushButton.PushButtonListener listener)
          remove a push button listener.
 void removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void setButtonOn(int index, boolean fireEvent)
          set button to on.
 void setMode(PushButton.Mode mode)
          set button mode policy.
 void setPropertyDataSource(com.vaadin.data.Property newDataSource)
           
 void setValue(java.lang.Integer newValue)
          value depend on PushButton's mode
protected  boolean switchButtonOn(int index)
           
 
Methods inherited from class com.vaadin.ui.CssLayout
addLayoutClickListener, addListener, beforeClientResponse, getComponent, getComponentCount, getComponentIndex, getCss, getState, iterator, readDesign, removeComponent, removeLayoutClickListener, removeListener, replaceComponent, writeDesign
 
Methods inherited from class com.vaadin.ui.AbstractLayout
readMargin, writeMargin
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addComponentAttachListener, addComponentDetachListener, addComponents, addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, moveComponentsFrom, removeAllComponents, removeComponentAttachListener, removeComponentDetachListener, removeListener, removeListener, setHeight, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidthUndefined
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.data.Property
isReadOnly, setReadOnly
 
Methods inherited from interface com.vaadin.ui.ComponentContainer
addComponents, addListener, addListener, getComponentIterator, moveComponentsFrom, removeAllComponents, removeListener, removeListener
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
 
Methods inherited from interface com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier
addComponentAttachListener, addComponentDetachListener, removeComponentAttachListener, removeComponentDetachListener
 

Field Detail

MAINCSS

public static final java.lang.String MAINCSS
See Also:
Constant Field Values

PUSHCSS

public static final java.lang.String PUSHCSS
See Also:
Constant Field Values

SELECTED

public static final java.lang.String SELECTED
See Also:
Constant Field Values
Constructor Detail

PushButton

public PushButton()
add an empty push button


PushButton

public PushButton(PushButton.PushButtonListener listener,
                  com.vaadin.ui.Button... button)
create new PushButton

Parameters:
listener - action listener, can be null
button - initial button list
Method Detail

addComponent

public void addComponent(com.vaadin.ui.Component c,
                         int index)
Add component c at index index If c instance of com.vaadin.ui.Button it's added to the pool

Overrides:
addComponent in class com.vaadin.ui.CssLayout
Parameters:
c -
index -

addComponentAsFirst

public void addComponentAsFirst(com.vaadin.ui.Component c)
Add compoment c at the top of the list If c instance of com.vaadin.ui.Button it's added to the pool

Overrides:
addComponentAsFirst in class com.vaadin.ui.CssLayout
Parameters:
c -

addComponent

public void addComponent(com.vaadin.ui.Component c)
Add compoment c at the end of the list If c instance of com.vaadin.ui.Button it's added to the pool

Specified by:
addComponent in interface com.vaadin.ui.ComponentContainer
Overrides:
addComponent in class com.vaadin.ui.CssLayout
Parameters:
c -

addAnyComponent

public void addAnyComponent(com.vaadin.ui.Component c)
addcomponent c and don't add it to the pool of managed button

Parameters:
c -

getComponentState

public boolean getComponentState(int index)
return component state. Note index against any container component, not only push button

Parameters:
index -
Returns:
true if button pushed, false else (including not a push button)

setButtonOn

public void setButtonOn(int index,
                        boolean fireEvent)
set button to on. If button already selected, do nothing

Parameters:
index -
fireEvent - true change buttons state and fire PushListener, false just change buttons state

getMode

public PushButton.Mode getMode()
return button mode policy. default to ONEMANY

Returns:
current mode

setMode

public void setMode(PushButton.Mode mode)
set button mode policy.
Note this method won't trigger a PushButtonListener. Mode.ONEMANY doesn't make sence (and will be discarded) unless pushbutton already has 2 buttons

Parameters:
mode -

getValue

public java.lang.Integer getValue()
value depend on PushButton's mode

Specified by:
getValue in interface com.vaadin.data.Property<java.lang.Integer>
See Also:
PushButton.Mode

setValue

public void setValue(java.lang.Integer newValue)
              throws com.vaadin.data.Property.ReadOnlyException
value depend on PushButton's mode

Specified by:
setValue in interface com.vaadin.data.Property<java.lang.Integer>
Parameters:
newValue -
Throws:
com.vaadin.data.Property.ReadOnlyException
See Also:
PushButton.Mode

getType

public java.lang.Class<? extends java.lang.Integer> getType()
Specified by:
getType in interface com.vaadin.data.Property<java.lang.Integer>

setPropertyDataSource

public void setPropertyDataSource(com.vaadin.data.Property newDataSource)
Specified by:
setPropertyDataSource in interface com.vaadin.data.Property.Viewer

getPropertyDataSource

public com.vaadin.data.Property getPropertyDataSource()
Specified by:
getPropertyDataSource in interface com.vaadin.data.Property.Viewer

addValueChangeListener

public void addValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
addValueChangeListener in interface com.vaadin.data.Property.ValueChangeNotifier

addListener

public void addListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
addListener in interface com.vaadin.data.Property.ValueChangeNotifier

removeValueChangeListener

public void removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
removeValueChangeListener in interface com.vaadin.data.Property.ValueChangeNotifier

removeListener

public void removeListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
removeListener in interface com.vaadin.data.Property.ValueChangeNotifier

switchButtonOn

protected boolean switchButtonOn(int index)
Parameters:
index -
Returns:
true if succesfull

addPushButtonListener

public void addPushButtonListener(PushButton.PushButtonListener listener)
add a push button listener.

Parameters:
listener - PushButtonListener to add, can be null

removePushButtonListener

public void removePushButtonListener(PushButton.PushButtonListener listener)
remove a push button listener.

Parameters:
listener - PushButtonListener to remove

buttonClick

public void buttonClick(com.vaadin.ui.Button.ClickEvent event)
Specified by:
buttonClick in interface com.vaadin.ui.Button.ClickListener