eu.livotov.tpt.i18n
Class TranslatableCustomLayout

java.lang.Object
  extended by com.vaadin.ui.AbstractComponent
      extended by com.vaadin.ui.AbstractComponentContainer
          extended by com.vaadin.ui.AbstractLayout
              extended by com.vaadin.ui.CustomLayout
                  extended by eu.livotov.tpt.i18n.TranslatableCustomLayout
All Implemented Interfaces:
com.vaadin.event.MethodEventSource, com.vaadin.terminal.Paintable, com.vaadin.terminal.Sizeable, com.vaadin.terminal.VariableOwner, com.vaadin.ui.Component, com.vaadin.ui.ComponentContainer, com.vaadin.ui.Layout, com.vaadin.ui.Layout.MarginHandler, java.io.Serializable, java.util.EventListener

public class TranslatableCustomLayout
extends com.vaadin.ui.CustomLayout

This is a wrapper for standard CustomLayout class, that will use the internationalized layout file, based on a current application locale. Use it as normal CustomLayout class, however you must prepare the following structure in your theme-name/layouts folder for all of your supported languages:

+ ITMILL
+ themes
+ your_theme
+ layouts
+ en
my_layout.html
+ ru
my_layout.html
my_layout.html

Once you call new TranslatableLayout("my_layout"), it will adjust the actual layout name according to the current application locale, for instance, for Russian locale, it will load the following actual layout file: layouts/ru/my_layout.html

In case no layout file for current locale is found, TranslatableLayout will try to find layout file for the default language and then (in case of no success) fallback to the normal CustomLayout behaviour and load layout file from base layouts folder, e.g. theme-name/layouts/my_layout.html

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractComponent.ComponentErrorEvent, com.vaadin.ui.AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Layout
com.vaadin.ui.Layout.AlignmentHandler, com.vaadin.ui.Layout.MarginHandler, com.vaadin.ui.Layout.MarginInfo, com.vaadin.ui.Layout.SpacingHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer
com.vaadin.ui.ComponentContainer.ComponentAttachEvent, com.vaadin.ui.ComponentContainer.ComponentAttachListener, com.vaadin.ui.ComponentContainer.ComponentDetachEvent, com.vaadin.ui.ComponentContainer.ComponentDetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.ErrorListener, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable
com.vaadin.terminal.Paintable.RepaintRequestEvent, com.vaadin.terminal.Paintable.RepaintRequestListener
 
Field Summary
 
Fields inherited from class com.vaadin.ui.AbstractLayout
margins
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
TranslatableCustomLayout(com.vaadin.Application app, java.lang.String layoutName)
          Creates a CustomLayout, trying to load the appropriate layout file for the given application locale.
TranslatableCustomLayout(java.io.InputStream inputStream)
          This constructor cannot be interbationalized because the pre-open input stream is provided.
TranslatableCustomLayout(java.lang.String layoutName)
          Creates a CustomLayout, trying to load the appropriate layout file for the current application locale.
 
Method Summary
protected  boolean isLayoutTemplateExists(com.vaadin.Application app, java.lang.String templateName)
           
protected  java.lang.String resolveTemplateNameForTheApplicationLocale(java.util.Locale locale, java.lang.String templateName)
           
 
Methods inherited from class com.vaadin.ui.CustomLayout
addComponent, addComponent, getComponent, getComponentIterator, getTemplateContents, getTemplateName, initTemplateContentsFromInputStream, paintContent, removeComponent, removeComponent, replaceComponent, setMargin, setMargin, setStyle, setTemplateContents, setTemplateName
 
Methods inherited from class com.vaadin.ui.AbstractLayout
getMargin, setMargin
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addListener, addListener, attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeAllComponents, removeListener, removeListener, requestRepaintAll, setEnabled, setHeight, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, changeVariables, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getLocale, getParent, getStyle, getStyleName, getTag, getWidth, getWidthUnits, getWindow, handleError, isEnabled, isImmediate, isReadOnly, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setErrorHandler, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthUnits
 
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.ComponentContainer
addListener, addListener, moveComponentsFrom, removeAllComponents, removeListener, removeListener, requestRepaintAll
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.terminal.Paintable
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId
 
Methods inherited from interface com.vaadin.terminal.VariableOwner
changeVariables, isImmediate
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits
 

Constructor Detail

TranslatableCustomLayout

public TranslatableCustomLayout(java.lang.String layoutName)
Creates a CustomLayout, trying to load the appropriate layout file for the current application locale. Note, that in order to use this method, your application must be extended from ToolkitPlusApplication, not from the regular Application object. In case of second, please use second constructor which accepts an application instance.

Parameters:
layoutName - layout template name, without any language prefixes, just like you use it in plain CustomLayout class.

TranslatableCustomLayout

public TranslatableCustomLayout(com.vaadin.Application app,
                                java.lang.String layoutName)
Creates a CustomLayout, trying to load the appropriate layout file for the given application locale.

Parameters:
layoutName - layout template name, without any language prefixes, just like you use it in plain CustomLayout class.

TranslatableCustomLayout

public TranslatableCustomLayout(java.io.InputStream inputStream)
                         throws java.io.IOException
This constructor cannot be interbationalized because the pre-open input stream is provided. So this will just proxy request to the original CustomLayout implementation. See Javadoc of this constructor in CustomLayout for details.

Parameters:
inputStream -
Throws:
java.io.IOException
Method Detail

resolveTemplateNameForTheApplicationLocale

protected java.lang.String resolveTemplateNameForTheApplicationLocale(java.util.Locale locale,
                                                                      java.lang.String templateName)

isLayoutTemplateExists

protected boolean isLayoutTemplateExists(com.vaadin.Application app,
                                         java.lang.String templateName)