org.vostok.vaadin.addon.toolbar
Class Toolbar

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.AbstractOrderedLayout
                      extended by com.vaadin.ui.HorizontalLayout
                          extended by org.vostok.vaadin.addon.toolbar.Toolbar
All Implemented Interfaces:
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.Component, com.vaadin.ui.ComponentContainer, com.vaadin.ui.HasComponents, com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.Layout, com.vaadin.ui.Layout.AlignmentHandler, com.vaadin.ui.Layout.MarginHandler, com.vaadin.ui.Layout.SpacingHandler, java.io.Serializable, java.lang.Iterable<com.vaadin.ui.Component>

public class Toolbar
extends com.vaadin.ui.HorizontalLayout

Toolbar is a widget for rendering an horizontal toolbar, filled with buttons, selectors, etc.
It aims to be simple and versatile. It also provide a set of scss variables.

Toolbar provides two banks, left and right, and can accept any components (*). It's dynamic, you can add, remove, hide components at any time.
It also provides build in for the most common widget such as button, separator, label.

(*) might require some additionnal css.
>Generated html code :

<div class="toolbar layout-panel [YOUR CSS CLASS HERE]">
        <div>
                <div class="v-slot-left-panel">
                        <div class="left-panel">[LEFT CONTENT HERE]</div>
                </div>
                <div class="v-spacing"></div>
                <div class="v-slot-right-panel">
                        <div class="right-panel">[RIGHT CONTENT HERE]</div>
                </div>
        </div>
</div>
See sample at http://vaadin.vostoksystem.eu

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

Nested Class Summary
static class Toolbar.BANK
          where to add new component too
static class Toolbar.DISPLAY
          layout for button.
 
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
protected  com.vaadin.ui.CssLayout left
           
static java.lang.String LEFTCSS
           
static java.lang.String MODEBOTTOM
           
static java.lang.String MODECAPTION
           
static java.lang.String MODEICON
           
static java.lang.String MODERIGHT
           
protected  com.vaadin.ui.CssLayout right
           
static java.lang.String RIGHTCSS
           
static java.lang.String SEPARATORCSS
           
static java.lang.String TOOLBARCSS
           
 
Fields inherited from class com.vaadin.ui.AbstractOrderedLayout
ALIGNMENT_DEFAULT, components
 
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
 
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
Toolbar()
          create a new toolbar, with button default to icon only
Toolbar(Toolbar.DISPLAY mode)
          create a new toolbar
 
Method Summary
 com.vaadin.ui.Button addButton(java.lang.String caption, java.lang.String description, java.lang.Object style)
          add a new button to the left toolbar's panel.
 com.vaadin.ui.Button addButton(java.lang.String caption, java.lang.String description, java.lang.Object style, com.vaadin.ui.Button.ClickListener listener)
          add a new button to the left toolbar's panel.
 com.vaadin.ui.Button addButton(java.lang.String caption, java.lang.String description, java.lang.Object style, com.vaadin.ui.Button.ClickListener listener, Toolbar.BANK location)
          Build and add a new button.
 com.vaadin.ui.Button addButton(java.lang.String caption, java.lang.String description, java.lang.Object style, Toolbar.BANK location)
          add a new button
 void addComponent(com.vaadin.ui.Component component)
          add a component to the left toolbar's panel
 com.vaadin.ui.Component addComponent(com.vaadin.ui.Component component, Toolbar.BANK location)
          Add a new component to the toolbar.
 com.vaadin.ui.Label addLabel(java.lang.String caption)
          add a new label to the left toolbar's panel
 com.vaadin.ui.Label addLabel(java.lang.String caption, java.lang.String style)
          add a new label to the left toolbar's panel
 com.vaadin.ui.Label addLabel(java.lang.String caption, java.lang.String style, Toolbar.BANK location)
          add a new label to the toolbar
 com.vaadin.ui.Component addSeparator()
          add a new vertical separator to the left panel.
 com.vaadin.ui.Component addSeparator(Toolbar.BANK location)
          add a new vertical separator. default look and feel depends on css.
 com.vaadin.ui.Component getComponent(int index, Toolbar.BANK location)
          return component at index index from bank location if comonent can be found, return null
 Toolbar.DISPLAY getMode()
          current button display
 void removeComponent(int index, Toolbar.BANK location)
          remove component at index index from bank location
if component does't exist, does nothing.
 void setEnable(int index, Toolbar.BANK location, boolean enable)
          a convenience method to call Component.setEnable for component at index index from bank location
if component does't exist, does nothing.
 void setMode(Toolbar.DISPLAY mode)
          set a new mode for display.
static void setSeparatorResource(com.vaadin.server.Resource resource)
          Default rules for separator is to create a Label with css Toolbar.SEPARATORCSS ("separator").
 
Methods inherited from class com.vaadin.ui.HorizontalLayout
getState
 
Methods inherited from class com.vaadin.ui.AbstractOrderedLayout
addComponent, addComponentAsFirst, addLayoutClickListener, addListener, getComponent, getComponentAlignment, getComponentCount, getComponentIndex, getCustomAttributes, getDefaultComponentAlignment, getExpandRatio, getMargin, getState, isSpacing, iterator, readDesign, removeComponent, removeLayoutClickListener, removeListener, replaceComponent, setComponentAlignment, setDefaultComponentAlignment, setExpandRatio, setMargin, setMargin, setSpacing, 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, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, 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.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, beforeClientResponse, 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

TOOLBARCSS

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

SEPARATORCSS

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

LEFTCSS

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

RIGHTCSS

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

MODEICON

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

MODECAPTION

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

MODERIGHT

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

MODEBOTTOM

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

left

protected com.vaadin.ui.CssLayout left

right

protected com.vaadin.ui.CssLayout right
Constructor Detail

Toolbar

public Toolbar()
create a new toolbar, with button default to icon only


Toolbar

public Toolbar(Toolbar.DISPLAY mode)
create a new toolbar

Parameters:
mode - mode for button.
Method Detail

getMode

public Toolbar.DISPLAY getMode()
current button display

Returns:
display mode for toolbar
See Also:
Toolbar.DISPLAY

setMode

public final void setMode(Toolbar.DISPLAY mode)
set a new mode for display. Note change is immeddiate and affect both bank.

Parameters:
mode - new mode for toolbar
See Also:
Toolbar.DISPLAY

addComponent

public com.vaadin.ui.Component addComponent(com.vaadin.ui.Component component,
                                            Toolbar.BANK location)
Add a new component to the toolbar.
Note whether location is left or righ, component are added at the end of "panel" .
If of type button/ native button will automatically manage icon-only state

Parameters:
component - the component. If null, does nothing
location - which panel to add component too
Returns:
component passed as argument

addComponent

public void addComponent(com.vaadin.ui.Component component)
add a component to the left toolbar's panel

Specified by:
addComponent in interface com.vaadin.ui.ComponentContainer
Overrides:
addComponent in class com.vaadin.ui.AbstractOrderedLayout
Parameters:
component - the component. If null, does nothing.

addButton

public com.vaadin.ui.Button addButton(java.lang.String caption,
                                      java.lang.String description,
                                      java.lang.Object style,
                                      com.vaadin.ui.Button.ClickListener listener,
                                      Toolbar.BANK location)
Build and add a new button.
Though you can use resource for icon, consider css rules instead.

Parameters:
caption - caption for the button, Can be null.
description - description (title) for the button. can be null.
style - if of type String, css style for the button. If of type Resource, considered to be a resource icon. If null or invalid type, does nothing
listener - listener for the button. Can be null.
location - where to add button
Returns:
com.vaadin.ui.Button instance

addButton

public com.vaadin.ui.Button addButton(java.lang.String caption,
                                      java.lang.String description,
                                      java.lang.Object style,
                                      com.vaadin.ui.Button.ClickListener listener)
add a new button to the left toolbar's panel.

Parameters:
caption - caption for the button, Can be null.
description - description (title) for the button. can be null.
style - if of type String, css style for the button. If of type Resource, considered to be a resource icon. If null or invalid type, does nothing
listener - listener for the button. Can be null.
Returns:
com.vaadin.ui.Button instance

addButton

public com.vaadin.ui.Button addButton(java.lang.String caption,
                                      java.lang.String description,
                                      java.lang.Object style)
add a new button to the left toolbar's panel.

Parameters:
caption - caption caption for the button, Can be null.
description - description description (title) for the button. can be null.
style - style if of type String, css style for the button. If of type Resource, considered to be a resource icon. If null or invalid type, does nothing
Returns:
com.vaadin.ui.Button instance

addButton

public com.vaadin.ui.Button addButton(java.lang.String caption,
                                      java.lang.String description,
                                      java.lang.Object style,
                                      Toolbar.BANK location)
add a new button

Parameters:
caption - caption caption for the button, Can be null.
description - description description (title) for the button. can be null.
style - style if of type String, css style for the button. If of type Resource, considered to be a resource icon. If null or invalid type, does nothing
location - where to add button
Returns:
com.vaadin.ui.Button instance

addSeparator

public com.vaadin.ui.Component addSeparator(Toolbar.BANK location)
add a new vertical separator. default look and feel depends on css.

Parameters:
location - where to add separator
Returns:
a com.vaadin.ui.Label instance representing the separator

addSeparator

public com.vaadin.ui.Component addSeparator()
add a new vertical separator to the left panel.

Returns:
a com.vaadin.ui.Label instance representing the separator

addLabel

public com.vaadin.ui.Label addLabel(java.lang.String caption,
                                    java.lang.String style,
                                    Toolbar.BANK location)
add a new label to the toolbar

Parameters:
caption - text for label.
style - user's css for label. Can be null.
location - where to add button
Returns:
a com.vaadin.ui.Label

addLabel

public com.vaadin.ui.Label addLabel(java.lang.String caption,
                                    java.lang.String style)
add a new label to the left toolbar's panel

Parameters:
caption - text for label.
style - user's css for label. Can be null.
Returns:
a com.vaadin.ui.Label

addLabel

public com.vaadin.ui.Label addLabel(java.lang.String caption)
add a new label to the left toolbar's panel

Parameters:
caption - text for label.
Returns:
a com.vaadin.ui.Label

getComponent

public com.vaadin.ui.Component getComponent(int index,
                                            Toolbar.BANK location)
return component at index index from bank location if comonent can be found, return null

Parameters:
index - index for component to look for. 0 based.
location - bank to look component from
Returns:
com.vaadin.ui.component, or null if not found

removeComponent

public void removeComponent(int index,
                            Toolbar.BANK location)
remove component at index index from bank location
if component does't exist, does nothing.

Parameters:
index - index for component to look for. 0 based.
location - bank to look component from

setEnable

public void setEnable(int index,
                      Toolbar.BANK location,
                      boolean enable)
a convenience method to call Component.setEnable for component at index index from bank location
if component does't exist, does nothing.

Parameters:
index - index for component to look for. 0 based.
location - bank to look component from
enable - action
See Also:
Component

setSeparatorResource

public static void setSeparatorResource(com.vaadin.server.Resource resource)
Default rules for separator is to create a Label with css Toolbar.SEPARATORCSS ("separator").
If you feel the need or using plain icon instead, call this method before creating a toolbar.

Parameters:
resource - com.vaadin.server.Resource for the new separator image, or null to reset to default (css)