com.vaadin.addon.touchkit.ui
Class NavigationButton

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.addon.touchkit.ui.NavigationButton
All Implemented Interfaces:
com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Sizeable, com.vaadin.shared.Connector, com.vaadin.ui.Component, Serializable

public class NavigationButton
extends com.vaadin.ui.AbstractComponent

The NavigationButton is a Button implementation optimized to be used inside a NavigationManager or generally in touch devices.

Clicking button will automatically navigate to the target view, if defined in this button (via constructor or setTargetView(Component) ). On the client side, the NavigationManager will start animation immediately when clicked, while the client is waiting for a response from the server.

Note that navigation will only work when the button is used inside a NavigationManager, otherwise it will work as a regular Button.

See Also:
Serialized Form

Nested Class Summary
 class NavigationButton.NavigationButtonClickEvent
          Click event.
static interface NavigationButton.NavigationButtonClickListener
          Interface for listening for a NavigationButton.NavigationButtonClickEvent fired by a Component.
 
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
 
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
NavigationButton()
          Creates a navigation button without any caption nor target view.
NavigationButton(com.vaadin.ui.Component targetView)
          Constructs a button with the specified target view, and sets the caption to equal that of the target view.
NavigationButton(String caption)
          Constructs a new NavigationButton with the given caption.
NavigationButton(String caption, com.vaadin.ui.Component targetView)
          Constructs a button with the specified target view, and sets the caption explicitly.
 
Method Summary
 void addClickListener(NavigationButton.NavigationButtonClickListener listener)
          Adds a navigation button click listener.
 void attach()
           
 void beforeClientResponse(boolean initial)
           
 void click()
          Simulates a button click, notifying all server-side listeners.
 void detach()
           
protected  void fireClick()
          Fires a click event to all listeners without any event details.
 String getCaption()
          Gets the caption for this button.
 NavigationManager getNavigationManager()
          Gets the NavigationManager in which this button is contained.
 NavigationButtonSharedState getState()
           
 com.vaadin.ui.Component getTargetView()
          Gets the target view that will be navigated to when the button is pressed.
 String getTargetViewCaption()
          Returns the caption that is expected to be on the view this button navigates to.
 void removeClickListener(NavigationButton.NavigationButtonClickListener listener)
          Removes a navigation button click listener.
 void setDescription(String description)
          Description in NavigationButton is show on the right side of the button.
 void setTargetView(com.vaadin.ui.Component targetView)
          Sets the view that will be navigated to when the button is pressed.
 void setTargetViewCaption(String targetViewCaption)
          Sets the caption that is expected to be on the view this button navigates to.
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getStyleName, getWidth, getWidthUnits, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setEnabled, setHeight, setHeight, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hasListeners, isAttached, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
getUI
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 

Constructor Detail

NavigationButton

public NavigationButton(String caption)
Constructs a new NavigationButton with the given caption.

Parameters:
caption - the caption

NavigationButton

public NavigationButton(com.vaadin.ui.Component targetView)
Constructs a button with the specified target view, and sets the caption to equal that of the target view.

Parameters:
targetView - the view to navigate to when pressed

NavigationButton

public NavigationButton(String caption,
                        com.vaadin.ui.Component targetView)
Constructs a button with the specified target view, and sets the caption explicitly.

Parameters:
caption - the caption
targetView - the view to navigate to when pressed

NavigationButton

public NavigationButton()
Creates a navigation button without any caption nor target view.

Method Detail

getState

public NavigationButtonSharedState getState()
Overrides:
getState in class com.vaadin.ui.AbstractComponent

beforeClientResponse

public void beforeClientResponse(boolean initial)
Specified by:
beforeClientResponse in interface com.vaadin.server.ClientConnector
Overrides:
beforeClientResponse in class com.vaadin.ui.AbstractComponent

getNavigationManager

public NavigationManager getNavigationManager()
Gets the NavigationManager in which this button is contained.

Returns:
the NavigationManager or null if not inside one

setTargetView

public void setTargetView(com.vaadin.ui.Component targetView)
Sets the view that will be navigated to when the button is pressed.

The client side widget communicates directly with a NavigationManager to make the actual navigation work.

Parameters:
targetView - The view to navigate to when pressed.

attach

public void attach()
Specified by:
attach in interface com.vaadin.server.ClientConnector
Specified by:
attach in interface com.vaadin.ui.Component
Overrides:
attach in class com.vaadin.ui.AbstractComponent

detach

public void detach()
Specified by:
detach in interface com.vaadin.server.ClientConnector
Overrides:
detach in class com.vaadin.ui.AbstractComponent

getCaption

public String getCaption()
Gets the caption for this button.

If the caption is explicitly set, it will be used - otherwise the caption is fetched from the target view, if one is set.

Specified by:
getCaption in interface com.vaadin.ui.Component
Overrides:
getCaption in class com.vaadin.ui.AbstractComponent
Returns:
the caption
See Also:
AbstractComponent.getCaption()

getTargetView

public com.vaadin.ui.Component getTargetView()
Gets the target view that will be navigated to when the button is pressed.

Returns:
the target view
See Also:
setTargetView(Component)

getTargetViewCaption

public String getTargetViewCaption()
Returns the caption that is expected to be on the view this button navigates to. Used for the placeholder, which is visible before the client has a chance to render the real target view.

If the caption is not set explicitly with setTargetViewCaption(String), the caption of target view is used. In case neither explicit target view caption or the target view is not defined the button caption is used.

Returns:
the caption that will be used for the placeholder of the target view.

setTargetViewCaption

public void setTargetViewCaption(String targetViewCaption)
Sets the caption that is expected to be on the view this button navigates to. This is used for the placeholder, which is visible before the client has a chance to render the real target view.

Parameters:
targetViewCaption - the explicit caption of the target view.

addClickListener

public void addClickListener(NavigationButton.NavigationButtonClickListener listener)
Adds a navigation button click listener.

Parameters:
listener - the Listener to add.

removeClickListener

public void removeClickListener(NavigationButton.NavigationButtonClickListener listener)
Removes a navigation button click listener.

Parameters:
listener - the Listener to remove.

click

public void click()
Simulates a button click, notifying all server-side listeners. No action is taken if the button is disabled.


fireClick

protected void fireClick()
Fires a click event to all listeners without any event details. In subclasses, override AbstractClientConnector.fireEvent(java.util.EventObject) instead of this method.


setDescription

public void setDescription(String description)
Description in NavigationButton is show on the right side of the button. Normally with bit smaller and gray text.

Overrides:
setDescription in class com.vaadin.ui.AbstractComponent
See Also:
StyleNames.NAVIGATION_BUTTON_DESC_PILL, AbstractComponent.setDescription(java.lang.String)


Copyright © 2014 Vaadin Ltd. All rights reserved.