public abstract class AbstractOrderedLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler, LayoutEvents.LayoutClickNotifier, Layout.MarginHandler
Layout.AlignmentHandler, Layout.MarginHandler, Layout.SpacingHandler
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
Modifier and Type | Field and Description |
---|---|
static Alignment |
ALIGNMENT_DEFAULT |
protected LinkedList<Component> |
components
Custom layout slots containing the components.
|
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Constructor and Description |
---|
AbstractOrderedLayout()
Constructs an empty AbstractOrderedLayout.
|
Modifier and Type | Method and Description |
---|---|
void |
addComponent(Component c)
Add a component into this container.
|
void |
addComponent(Component c,
int index)
Adds a component into indexed position in this container.
|
void |
addComponentAsFirst(Component c)
Adds a component into this container.
|
void |
addLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Add a click listener to the layout.
|
void |
addListener(LayoutEvents.LayoutClickListener listener)
Deprecated.
As of 7.0, replaced by
#addLayoutClickListener(LayoutClickListener) |
Component |
getComponent(int index)
Returns the component at the given position.
|
Alignment |
getComponentAlignment(Component childComponent)
Returns the current Alignment of given component.
|
int |
getComponentCount()
Gets the number of contained components.
|
int |
getComponentIndex(Component component)
Returns the index of the given component.
|
protected Collection<String> |
getCustomAttributes()
Returns a collection of attributes that should not be handled by the
basic implementation of the
readDesign and writeDesign
methods. |
Alignment |
getDefaultComponentAlignment()
Returns the alignment used for new components added to this layout
|
float |
getExpandRatio(Component component)
Returns the expand ratio of given component.
|
MarginInfo |
getMargin() |
protected AbstractOrderedLayoutState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected AbstractOrderedLayoutState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
boolean |
isSpacing() |
Iterator<Component> |
iterator()
Gets the component container iterator for going trough all the components
in the container.
|
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
void |
removeComponent(Component c)
Removes the component from this container.
|
void |
removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Removes an LayoutClickListener.
|
void |
removeListener(LayoutEvents.LayoutClickListener listener)
Deprecated.
As of 7.0, replaced by
#removeLayoutClickListener(LayoutClickListener) |
void |
replaceComponent(Component oldComponent,
Component newComponent)
Replaces the component in the container with another one without changing
position.
|
void |
setComponentAlignment(Component childComponent,
Alignment alignment)
Set alignment for one contained component in this layout.
|
void |
setDefaultComponentAlignment(Alignment defaultAlignment)
Sets the alignment used for new components added to this layout.
|
void |
setExpandRatio(Component component,
float ratio)
This method is used to control how excess space in layout is distributed
among components.
|
void |
setMargin(boolean enabled)
Enable layout margins.
|
void |
setMargin(MarginInfo marginInfo)
Enable margins for this layout.
|
void |
setSpacing(boolean spacing)
Enable spacing between child components within this layout.
|
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
readMargin, writeMargin
addComponentAttachListener, addComponentDetachListener, addComponents, addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, moveComponentsFrom, removeAllComponents, removeComponentAttachListener, removeComponentDetachListener, removeListener, removeListener, setHeight, setWidth
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
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
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addComponents, addListener, addListener, getComponentIterator, moveComponentsFrom, removeAllComponents, removeListener, removeListener
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
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
forEach, spliterator
addComponentAttachListener, addComponentDetachListener, removeComponentAttachListener, removeComponentDetachListener
public static final Alignment ALIGNMENT_DEFAULT
protected LinkedList<Component> components
public AbstractOrderedLayout()
protected AbstractOrderedLayoutState getState()
AbstractComponent
getState
in class AbstractLayout
protected AbstractOrderedLayoutState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractComponent
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public void addComponent(Component c)
addComponent
in interface ComponentContainer
addComponent
in class AbstractComponentContainer
c
- the component to be added.ComponentContainer.addComponent(Component)
public void addComponentAsFirst(Component c)
c
- the component to be added.public void addComponent(Component c, int index)
c
- the component to be added.index
- the index of the component position. The components currently
in and after the position are shifted forwards.public void removeComponent(Component c)
removeComponent
in interface ComponentContainer
removeComponent
in class AbstractComponentContainer
c
- the component to be removed.ComponentContainer.removeComponent(Component)
public Iterator<Component> iterator()
iterator
in interface HasComponents
iterator
in interface Iterable<Component>
public int getComponentCount()
AbstractComponentContainer.getComponentIterator()
.getComponentCount
in interface ComponentContainer
public void replaceComponent(Component oldComponent, Component newComponent)
ComponentContainer
This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.
replaceComponent
in interface ComponentContainer
oldComponent
- the old component that will be replaced.newComponent
- the new component to be replaced.public void setComponentAlignment(Component childComponent, Alignment alignment)
Layout.AlignmentHandler
layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT);
setComponentAlignment
in interface Layout.AlignmentHandler
childComponent
- the component to align within it's layout cell.alignment
- the Alignment value to be setpublic Alignment getComponentAlignment(Component childComponent)
Layout.AlignmentHandler
getComponentAlignment
in interface Layout.AlignmentHandler
Alignment
public void setSpacing(boolean spacing)
Layout.SpacingHandler
NOTE: This will only affect the space between
components, not the space around all the components in the layout
(i.e. do not confuse this with the cellspacing attribute of a HTML
Table). Use #setMargin(boolean)
to add space around the
layout.
See the reference manual for more information about CSS rules for defining the amount of spacing to use.
setSpacing
in interface Layout.SpacingHandler
spacing
- true if spacing should be turned on, false if it should be
turned offpublic boolean isSpacing()
isSpacing
in interface Layout.SpacingHandler
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components. Excess space may exist if layout is sized and contained non relatively sized components don't consume all available space.
Example how to distribute 1:3 (33%) for component1 and 2:3 (67%) for
component2 :
layout.setExpandRatio(component1, 1);
layout.setExpandRatio(component2, 2);
If no ratios have been set, the excess space is distributed evenly among all components.
Note, that width or height (depending on orientation) needs to be defined for this method to have any effect.
component
- the component in this layout which expand ratio is to be setratio
- new expand ratio (greater or equal to 0)IllegalArgumentException
- if the expand ratio is negative or the component is not a
direct child of the layoutSizeable
public float getExpandRatio(Component component)
component
- which expand ratios is requestedpublic void addLayoutClickListener(LayoutEvents.LayoutClickListener listener)
LayoutEvents.LayoutClickNotifier
LayoutEvents.LayoutClickEvent
.
Use #removeListener(LayoutClickListener)
to remove the
listener.addLayoutClickListener
in interface LayoutEvents.LayoutClickNotifier
listener
- The listener to add@Deprecated public void addListener(LayoutEvents.LayoutClickListener listener)
#addLayoutClickListener(LayoutClickListener)
addListener
in interface LayoutEvents.LayoutClickNotifier
public void removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
LayoutEvents.LayoutClickNotifier
removeLayoutClickListener
in interface LayoutEvents.LayoutClickNotifier
listener
- LayoutClickListener to be removed@Deprecated public void removeListener(LayoutEvents.LayoutClickListener listener)
#removeLayoutClickListener(LayoutClickListener)
removeListener
in interface LayoutEvents.LayoutClickNotifier
public int getComponentIndex(Component component)
component
- The component to look up.public Component getComponent(int index) throws IndexOutOfBoundsException
index
- The position of the component.IndexOutOfBoundsException
- If the index is out of range.public void setMargin(boolean enabled)
Layout.MarginHandler
setMargin
in interface Layout.MarginHandler
enabled
- true if margins should be enabled on all sides, false to
disable all marginspublic MarginInfo getMargin()
getMargin
in interface Layout.MarginHandler
public void setMargin(MarginInfo marginInfo)
Layout.MarginHandler
NOTE: This will only affect the space around the
components in the layout, not space between the components in the
layout. Use #setSpacing(boolean)
to add space between the
components in the layout.
See the reference manual for more information about CSS rules for defining the size of the margin.
setMargin
in interface Layout.MarginHandler
marginInfo
- MarginInfo object containing the new margins.public Alignment getDefaultComponentAlignment()
Layout.AlignmentHandler
getDefaultComponentAlignment
in interface Layout.AlignmentHandler
public void setDefaultComponentAlignment(Alignment defaultAlignment)
Layout.AlignmentHandler
Alignment.TOP_LEFT
.setDefaultComponentAlignment
in interface Layout.AlignmentHandler
defaultAlignment
- The new default alignmentpublic void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
readDesign
in interface Component
readDesign
in class AbstractComponent
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the designpublic void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
writeDesign
in interface Component
writeDesign
in class AbstractComponent
design
- The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the designprotected Collection<String> getCustomAttributes()
AbstractComponent
readDesign
and writeDesign
methods. Typically these are handled in a custom way in the overridden
versions of the above methodsgetCustomAttributes
in class AbstractComponent
Copyright © 2019 Vaadin Ltd. All rights reserved.