org.vostok.vaadin.addon.button.i18n
Class I18nButton

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractFocusable
              extended by com.vaadin.ui.Button
                  extended by org.vostok.vaadin.addon.button.i18n.I18nButton
All Implemented Interfaces:
com.vaadin.event.Action.ShortcutNotifier, com.vaadin.event.ContextClickEvent.ContextClickNotifier, com.vaadin.event.FieldEvents.BlurNotifier, com.vaadin.event.FieldEvents.FocusNotifier, com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Sizeable, com.vaadin.shared.Connector, com.vaadin.ui.Component, com.vaadin.ui.Component.Focusable, java.io.Serializable

public class I18nButton
extends com.vaadin.ui.Button

I18nButton extends com.vaadin.ui.Button, it helps creating recurring button. With a single key passed to constructor, caption and icon are automatically set. Caption is internationalized too..

There's over 200 defaults actions already defined and this can be easilly extended. .
Current button list http://vaadin.vostoksystem.eu/#!/i18nbuttonlist
Default language set to user locale ( UI.getCurrent().getLocale() ).
Current translation status available at : http://vaadin.vostoksystem.eu/Sample#!/i18nstate
German translation by Julie Rabier. See sample at http://vaadin.vostoksystem.eu

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

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.Button
com.vaadin.ui.Button.ClickEvent, com.vaadin.ui.Button.ClickListener, com.vaadin.ui.Button.ClickShortcut
 
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 class com.vaadin.ui.Button
clickShortcut
 
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
I18nButton()
          backward compatibility.
I18nButton(java.lang.String key)
          create a new button with key key.
I18nButton(java.lang.String key, com.vaadin.ui.Button.ClickListener listener)
          create a new button with key key.
I18nButton(java.lang.String key, java.lang.String style)
          create a new button with key key. and add an user's style.
I18nButton(java.lang.String key, java.lang.String style, com.vaadin.ui.Button.ClickListener listener)
          create a new button with key key. and add an user's style.
I18nButton(java.lang.String key, java.lang.String style, java.util.Locale locale, com.vaadin.ui.Button.ClickListener listener)
          Create an i18nButton for a specific locale
 
Method Summary
static java.lang.String getCaptionFor(java.lang.String key)
          Return caption for key key with user's Locale.
static java.lang.String getCaptionFor(java.lang.String key, java.util.Locale locale)
          Return caption for key key with locale locale.
 void setBorderless()
          borderless icon, helper method, same as adding the valo class 'borderless'
 void setCaptionLess()
          an helper method to create a button without caption, same as calling setCaption(null)
 void setHuge()
          bigger icon, helper method, same as adding the valo class 'huge'
 
Methods inherited from class com.vaadin.ui.Button
addClickListener, addListener, click, fireClick, fireClick, getCustomAttributes, getIconAlternateText, getState, getState, isDisableOnClick, isHtmlContentAllowed, readDesign, removeClickListener, removeClickShortcut, removeListener, setClickShortcut, setDisableOnClick, setHtmlContentAllowed, setIcon, setIconAlternateText, writeDesign
 
Methods inherited from class com.vaadin.ui.AbstractFocusable
addBlurListener, addFocusListener, addListener, addListener, focus, getTabIndex, removeBlurListener, removeFocusListener, removeListener, removeListener, setTabIndex
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, 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, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, 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.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
 
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
 

Constructor Detail

I18nButton

public I18nButton()
backward compatibility.

Throws:
java.lang.IllegalArgumentException - : always.

I18nButton

public I18nButton(java.lang.String key)
create a new button with key key. If fail forkey, return a default button.
Will use use locale (UI.getCurrent().getLocale()) NOTA : though this constructor has the same signature as Button, it is a button key, not a caption.

Parameters:
key - key for button, if not found, will be used as caption.
See Also:
I18n

I18nButton

public I18nButton(java.lang.String key,
                  com.vaadin.ui.Button.ClickListener listener)
create a new button with key key. If fail forkey, return a default button.
Will use use locale (UI.getCurrent().getLocale())

Parameters:
key - key for button, if not found, will be used as caption.
listener - ClickListener to attach.
See Also:
I18n

I18nButton

public I18nButton(java.lang.String key,
                  java.lang.String style)
create a new button with key key. and add an user's style. Note this add, not replace style. If fail forkey, return a default button.
Will use use locale (UI.getCurrent().getLocale())

Parameters:
key - key for button, if not found, will be used as caption.
style - user style. Can be null.
See Also:
I18n

I18nButton

public I18nButton(java.lang.String key,
                  java.lang.String style,
                  com.vaadin.ui.Button.ClickListener listener)
create a new button with key key. and add an user's style. Note this add, not replace style. If fail forkey, return a default button.
Will use use locale (UI.getCurrent().getLocale())

Parameters:
key - key for button, if not found, will be used as caption.
style - user style. Can be null
listener - ClickListener to attach.
See Also:
I18n

I18nButton

public I18nButton(java.lang.String key,
                  java.lang.String style,
                  java.util.Locale locale,
                  com.vaadin.ui.Button.ClickListener listener)
Create an i18nButton for a specific locale

Parameters:
key - key for button, if not found, will be used as caption.
style - user style. Can be null
locale - java.util.Locale to use. If null, default to UI.getCurrent().getLocale()
listener - ClickListener to attach.
See Also:
I18n
Method Detail

setCaptionLess

public void setCaptionLess()
an helper method to create a button without caption, same as calling setCaption(null)

Since:
1.5

setHuge

public void setHuge()
bigger icon, helper method, same as adding the valo class 'huge'


setBorderless

public void setBorderless()
borderless icon, helper method, same as adding the valo class 'borderless'


getCaptionFor

public static java.lang.String getCaptionFor(java.lang.String key)
Return caption for key key with user's Locale.

Parameters:
key - key for button
Returns:
Localized string for key, or "unknow"
See Also:
I18n

getCaptionFor

public static java.lang.String getCaptionFor(java.lang.String key,
                                             java.util.Locale locale)
Return caption for key key with locale locale.

Parameters:
key - key for button
locale - Locale to use
Returns:
Localized string for key, or "unknow"
See Also:
I18n