|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractComponentContainer
com.vaadin.ui.AbstractLayout
com.vaadin.ui.AbstractOrderedLayout
com.vaadin.ui.VerticalLayout
eu.livotov.tpt.gui.widgets.TPTMultiView
public class TPTMultiView
Provides lightweight multi-view component, that can hold an unlimited number of actual UI components, each associated with it's unique name and only one component can be displayed at a time, providing also fast switching between views.
TPTMultiView also allow to use view names, combined with the view parameters, separated by a '/' (slash) chatacter. In combination with view component that implements TPTView interface this will cause the parameters to be passed to a view that is switched on. This feature spicifically done for work with the combination of URIFragmentUtility, allowing not only to control your views from an URL programmatically or by a end user but also pass custom parameters from an URL to a view each time it is become active.
Nested Class Summary | |
---|---|
static interface |
TPTMultiView.TPTView
An optional interface, your component representing a single view may implement. |
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 | |
---|---|
private java.lang.String |
currentView
Name of currently displayed view |
private java.util.Map<java.lang.String,java.lang.Class<? extends com.vaadin.ui.Component>> |
delayedViews
Map to store lazy-loading views. |
private java.lang.String |
failsafeView
Contains a failsafe view, to which view manager should switch in case actual view name will be invalid or view will not exists. |
private java.lang.String |
lastChangedFragment
Last fragment, which was set by an URI Fragment Utility. |
private com.vaadin.ui.UriFragmentUtility |
uriManager
URI manager, that tracks browser address bar changes and automatically switches the view, if enabled. |
private boolean |
uriManagerEnabled
URI manager activation flag. |
private java.util.Map<java.lang.String,com.vaadin.ui.Component> |
views
Internal map, where we'll store all registered views |
Fields inherited from class com.vaadin.ui.AbstractOrderedLayout |
---|
components |
Fields inherited from class com.vaadin.ui.AbstractLayout |
---|
margins |
Fields inherited from interface com.vaadin.ui.Layout.AlignmentHandler |
---|
ALIGNMENT_BOTTOM, ALIGNMENT_HORIZONTAL_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP, ALIGNMENT_VERTICAL_CENTER |
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 | |
---|---|
TPTMultiView()
Creates a multiview with uri manager disabled. |
|
TPTMultiView(boolean uriManagerEnabled)
Creates a multiview, optionaly activating or deactivating the uri manager. |
Method Summary | |
---|---|
void |
addView(java.lang.String viewName,
java.lang.Class<? extends com.vaadin.ui.Component> viewClass)
Adds a lazy loading view. |
TPTMultiView |
addView(java.lang.String viewName,
com.vaadin.ui.Component view)
Registers a new view. |
protected void |
fireViewActivatedMessage(com.vaadin.ui.Component view,
java.lang.String previousViewId,
java.lang.String parameters)
Checks if view component implements the TPTView interface and if so, invokes the appropriate method to notify a view on event happened |
protected void |
fireViewAttachedMessage(com.vaadin.ui.Component view)
Checks if view component implements the TPTView interface and if so, invokes the appropriate method to notify a view on event happened |
protected void |
fireViewDeactivatedMessage(com.vaadin.ui.Component view,
java.lang.String newViewId)
Checks if view component implements the TPTView interface and if so, invokes the appropriate method to notify a view on event happened |
protected void |
fireViewRemovedMessage(com.vaadin.ui.Component view)
Checks if view component implements the TPTView interface and if so, invokes the appropriate method to notify a view on event happened |
void |
fragmentChanged(com.vaadin.ui.UriFragmentUtility.FragmentChangedEvent fragmentChangedEvent)
|
com.vaadin.ui.Component |
getCurrentView()
Provides the actual component of the current view |
java.lang.String |
getCurrentViewName()
Provides name of the currently active view |
java.lang.String |
getFailsafeViewName()
Provides the current failsafe view name (null by default) set by a setFailsafeViewName |
protected java.lang.String |
getPureViewName(java.lang.String viewName)
Extracts the pure name from the view name, combined with the parameters. |
com.vaadin.ui.Component |
getView(java.lang.String viewName)
Get the actual view component by the view name |
java.lang.String |
getViewName(com.vaadin.ui.Component view)
Resolves view name by the actual view component instance. |
protected java.lang.String |
getViewParameters(java.lang.String viewName)
Extracts the parameters from a view name if it was combined with such parameters. |
boolean |
isViewActive(java.lang.String viewName)
Checks, if the specified view available and active |
boolean |
isViewAvailable(java.lang.String viewName)
Checks if the specified view exists in the component |
void |
removeAllComponents()
Removes all components but uri manager. |
TPTMultiView |
removeView(java.lang.String viewName)
Removes view. |
TPTMultiView |
replaceView(java.lang.String viewName,
com.vaadin.ui.Component view)
Replaces an old view with the new one. |
void |
setFailsafeViewName(java.lang.String name)
Sets the failsafe view name. |
void |
switchView(java.lang.String viewId)
Switches the active view to a new one, causing display to update. |
Methods inherited from class com.vaadin.ui.AbstractOrderedLayout |
---|
addComponent, addComponent, addComponentAsFirst, addListener, changeVariables, getComponentAlignment, getComponentIterator, getExpandRatio, isSpacing, isSpacingEnabled, paintContent, removeComponent, removeListener, replaceComponent, setComponentAlignment, setComponentAlignment, setComponentAlignment, setExpandRatio, setSpacing |
Methods inherited from class com.vaadin.ui.AbstractLayout |
---|
getMargin, setMargin, setMargin, setMargin |
Methods inherited from class com.vaadin.ui.AbstractComponentContainer |
---|
addListener, addListener, attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeListener, removeListener, requestRepaintAll, setEnabled, setHeight, setWidth |
Methods inherited from class com.vaadin.ui.AbstractComponent |
---|
addListener, addListener, addListener, addListener, addListener, addStyleName, 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, setStyle, 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, 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 |
---|
isImmediate |
Methods inherited from interface com.vaadin.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits |
Field Detail |
---|
private java.util.Map<java.lang.String,com.vaadin.ui.Component> views
private java.util.Map<java.lang.String,java.lang.Class<? extends com.vaadin.ui.Component>> delayedViews
private java.lang.String currentView
private com.vaadin.ui.UriFragmentUtility uriManager
private boolean uriManagerEnabled
false
, uri changes will not cause the
current view to switch.
private java.lang.String lastChangedFragment
private java.lang.String failsafeView
Constructor Detail |
---|
public TPTMultiView()
public TPTMultiView(boolean uriManagerEnabled)
uriManagerEnabled
- enables or disabled the URI manager. Enabling the URI manager will
cause this component to automatically switch the current view if URI
text in the browser is changed.Method Detail |
---|
public void setFailsafeViewName(java.lang.String name)
name
- view name to switch to in case actual view is not found.public java.lang.String getFailsafeViewName()
public TPTMultiView addView(java.lang.String viewName, com.vaadin.ui.Component view)
If you'll try to add a view with duplicate name, an IllegalArgumentException will be thrown.
viewName
- unique name of this viewview
- actual component of a view
public void addView(java.lang.String viewName, java.lang.Class<? extends com.vaadin.ui.Component> viewClass)
viewName
- view nameviewClass
- class, that represnets the view. Class must have a default constructor.public TPTMultiView replaceView(java.lang.String viewName, com.vaadin.ui.Component view)
If you'll try to replace a view with that is not yet exists, an IllegalArgumentException will be thrown.
viewName
- view name to replaceview
- new view component
public TPTMultiView removeView(java.lang.String viewName)
If you'll try to remove a view that is not exists, an IllegalArgumentException will be thrown.
viewName
- view name to remove.
public void switchView(java.lang.String viewId)
If you'll try to switch to a view that does not exists, an IllegalArgumentException will be thrown in casd URI manager is not enabled or noting will happen otherwise.
viewId
- new active view name or name, combined with the view parameters, separated by a
slash character, for instance: myview equals myview/12345 but in
second case, string 12345 will be passed to a view as viewActivated method
parameter, in case the view object being swithced to implements TPTView
interface. If not - custom parameter will be simply ignored.public boolean isViewAvailable(java.lang.String viewName)
viewName
- view name to check
public boolean isViewActive(java.lang.String viewName)
viewName
- view nameto chexk
public com.vaadin.ui.Component getView(java.lang.String viewName)
viewName
- view name.
public java.lang.String getCurrentViewName()
public com.vaadin.ui.Component getCurrentView()
public void removeAllComponents()
removeAllComponents
in interface com.vaadin.ui.ComponentContainer
removeAllComponents
in class com.vaadin.ui.AbstractComponentContainer
public java.lang.String getViewName(com.vaadin.ui.Component view)
view
- view component instance to resolve name of
public void fragmentChanged(com.vaadin.ui.UriFragmentUtility.FragmentChangedEvent fragmentChangedEvent)
fragmentChanged
in interface com.vaadin.ui.UriFragmentUtility.FragmentChangedListener
protected void fireViewActivatedMessage(com.vaadin.ui.Component view, java.lang.String previousViewId, java.lang.String parameters)
view
- view being activated (showing)parameters
- parameters, passed to a view (if any)protected void fireViewDeactivatedMessage(com.vaadin.ui.Component view, java.lang.String newViewId)
view
- view being deactivated (hidden)protected void fireViewAttachedMessage(com.vaadin.ui.Component view)
view
- new view being added to a multiview component (added)protected void fireViewRemovedMessage(com.vaadin.ui.Component view)
view
- view being removed from a multiview component (removed)protected java.lang.String getPureViewName(java.lang.String viewName)
viewName
- view name or view name,combined with the view parameters
protected java.lang.String getViewParameters(java.lang.String viewName)
viewName
- view name or view name, combined with the view parameters
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |