Class GridLayout
-
- All Implemented Interfaces:
ContextClickEvent.ContextClickNotifier
,LayoutEvents.LayoutClickNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,ComponentContainer
,HasComponents
,HasComponents.ComponentAttachDetachNotifier
,Layout
,Layout.AlignmentHandler
,Layout.MarginHandler
,Layout.SpacingHandler
,Serializable
,Iterable<Component>
public class GridLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler, Layout.MarginHandler, LayoutEvents.LayoutClickNotifier
A layout where the components are laid out on a grid using cell coordinates.The GridLayout also maintains a cursor for adding components in left-to-right, top-to-bottom order.
Each component in a
GridLayout
uses a definedarea
(column1,row1,column2,row2) from the grid. The components may not overlap with the existing components - if you try to do so you will get anGridLayout.OverlapsException
. Adding a component with cursor automatically extends the grid by increasing the grid height.The grid coordinates, which are specified by a row and column index, always start from 0 for the topmost row and the leftmost column.
- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
GridLayout.Area
Defines a rectangular area of cells in a GridLayout.class
GridLayout.OutOfBoundsException
AnException
object which is thrown when an area exceeds the bounds of the grid.class
GridLayout.OverlapsException
Gridlayout does not support laying components on top of each other.-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Layout
Layout.AlignmentHandler, Layout.MarginHandler, Layout.SpacingHandler
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
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
Constructors Constructor Description GridLayout()
Constructs an empty (1x1) grid layout that is extended as needed.GridLayout(int columns, int rows)
Constructor for a grid of given size (number of columns and rows).GridLayout(int columns, int rows, Component... children)
Constructs a GridLayout of given size (number of columns and rows) and adds the given components in order to the grid.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addComponent(Component component)
Adds the component into this container to the cursor position.void
addComponent(Component component, int column, int row)
Adds the component to the grid in cells column1,row1 (NortWest corner of the area.) End coordinates (SouthEast corner of the area) are the same as column1,row1.void
addComponent(Component component, int column1, int row1, int column2, int row2)
Adds a component to the grid in the specified area.void
addLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Add a click listener to the layout.void
addListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byaddLayoutClickListener(LayoutClickListener)
void
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the client.float
getColumnExpandRatio(int columnIndex)
Returns the expand ratio of given columnint
getColumns()
Get the number of columns in the grid.Component
getComponent(int x, int y)
Gets the Component at given index.Alignment
getComponentAlignment(Component childComponent)
Returns the current Alignment of given component.GridLayout.Area
getComponentArea(Component component)
Returns information about the area where given component is laid in the GridLayout.int
getComponentCount()
Gets the number of components contained in the layout.int
getCursorX()
Gets the current x-position (column) of the cursor.int
getCursorY()
Gets the current y-position (row) of the cursor.protected Collection<String>
getCustomAttributes()
Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
andAbstractComponent.writeDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
methods.Alignment
getDefaultComponentAlignment()
Returns the alignment used for new components added to this layoutMarginInfo
getMargin()
float
getRowExpandRatio(int rowIndex)
Returns the expand ratio of given row.int
getRows()
Get the number of rows in the grid.protected GridLayoutState
getState()
Returns the shared state bean with information to be sent from the server to the client.protected GridLayoutState
getState(boolean markAsDirty)
Returns the shared state for this connector.void
insertRow(int row)
Inserts an empty row at the specified position in the grid.boolean
isHideEmptyRowsAndColumns()
Checks whether whether empty rows and columns should be considered as non-existent when rendering or not.boolean
isSpacing()
Iterator<Component>
iterator()
Gets an Iterator for the components contained in the layout.void
newLine()
Forces the next component to be added at the beginning of the next line.void
readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the component state from the given design.void
removeAllComponents()
Removes all components from the container.void
removeComponent(int column, int row)
Removes the component specified by its cell coordinates.void
removeComponent(Component component)
Removes the specified component from the layout.void
removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Removes an LayoutClickListener.void
removeListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byremoveLayoutClickListener(LayoutClickListener)
void
removeRow(int row)
Removes a row and all the components in the row.void
replaceComponent(Component oldComponent, Component newComponent)
Replaces the component in the container with another one without changing position.void
setColumnExpandRatio(int columnIndex, float ratio)
Sets the expand ratio of given column.void
setColumns(int columns)
Sets the number of columns in the grid.void
setComponentAlignment(Component childComponent, Alignment alignment)
Set alignment for one contained component in this layout.void
setCursorX(int cursorX)
Sets the current cursor x-position.void
setCursorY(int cursorY)
Sets the current y-coordinate (row) of the cursor.void
setDefaultComponentAlignment(Alignment defaultAlignment)
Sets the alignment used for new components added to this layout.void
setHideEmptyRowsAndColumns(boolean hideEmptyRowsAndColumns)
Sets whether empty rows and columns should be considered as non-existent when rendering or not.void
setMargin(boolean enabled)
Enable layout margins.void
setMargin(MarginInfo marginInfo)
Enable margins for this layout.void
setRowExpandRatio(int rowIndex, float ratio)
Sets the expand ratio of given row.void
setRows(int rows)
Sets the number of rows in the grid.void
setSpacing(boolean spacing)
Enable spacing between child components within this layout.void
space()
Moves the cursor forward by one.void
writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Writes the component state to the given design.-
Methods inherited from class com.vaadin.ui.AbstractLayout
readMargin, writeMargin
-
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addComponentAttachListener, addComponentDetachListener, addComponents, addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, moveComponentsFrom, removeComponentAttachListener, removeComponentDetachListener, removeListener, removeListener, setHeight, setWidth
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, 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
-
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.server.ClientConnector
addAttachListener, addDetachListener, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
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.ui.ComponentContainer
addComponents, addListener, addListener, getComponentIterator, moveComponentsFrom, removeListener, removeListener
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier
addComponentAttachListener, addComponentDetachListener, removeComponentAttachListener, removeComponentDetachListener
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
-
-
-
-
Constructor Detail
-
GridLayout
public GridLayout(int columns, int rows)
Constructor for a grid of given size (number of columns and rows). The grid may grow or shrink later. Grid grows automatically if you add components outside its area.- Parameters:
columns
- Number of columns in the grid.rows
- Number of rows in the grid.
-
GridLayout
public GridLayout()
Constructs an empty (1x1) grid layout that is extended as needed.
-
GridLayout
public GridLayout(int columns, int rows, Component... children)
Constructs a GridLayout of given size (number of columns and rows) and adds the given components in order to the grid.- Parameters:
columns
- Number of columns in the grid.rows
- Number of rows in the grid.children
- Components to add to the grid.- See Also:
AbstractComponentContainer.addComponents(Component...)
-
-
Method Detail
-
getState
protected GridLayoutState getState()
Description copied from class:AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().- Overrides:
getState
in classAbstractLayout
- Returns:
- updated component shared state
-
getState
protected GridLayoutState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnector
Returns the shared state for this connector.- Overrides:
getState
in classAbstractComponent
- Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
addComponent
public void addComponent(Component component, int column1, int row1, int column2, int row2) throws GridLayout.OverlapsException, GridLayout.OutOfBoundsException
Adds a component to the grid in the specified area. The area is defined by specifying the upper left corner (column1, row1) and the lower right corner (column2, row2) of the area. The coordinates are zero-based.
If the area overlaps with any of the existing components already present in the grid, the operation will fail and an
GridLayout.OverlapsException
is thrown.- Parameters:
component
- the component to be added, notnull
.column1
- the column of the upper left corner of the areac
is supposed to occupy. The leftmost column has index 0.row1
- the row of the upper left corner of the areac
is supposed to occupy. The topmost row has index 0.column2
- the column of the lower right corner of the areac
is supposed to occupy.row2
- the row of the lower right corner of the areac
is supposed to occupy.- Throws:
GridLayout.OverlapsException
- if the new component overlaps with any of the components already in the grid.GridLayout.OutOfBoundsException
- if the cells are outside the grid area.
-
addComponent
public void addComponent(Component component, int column, int row) throws GridLayout.OverlapsException, GridLayout.OutOfBoundsException
Adds the component to the grid in cells column1,row1 (NortWest corner of the area.) End coordinates (SouthEast corner of the area) are the same as column1,row1. The coordinates are zero-based. Component width and height is 1.- Parameters:
component
- the component to be added, notnull
.column
- the column index, starting from 0.row
- the row index, starting from 0.- Throws:
GridLayout.OverlapsException
- if the new component overlaps with any of the components already in the grid.GridLayout.OutOfBoundsException
- if the cell is outside the grid area.
-
newLine
public void newLine()
Forces the next component to be added at the beginning of the next line.Sets the cursor column to 0 and increments the cursor row by one.
By calling this function you can ensure that no more components are added right of the previous component.
- See Also:
space()
-
space
public void space()
Moves the cursor forward by one. If the cursor goes out of the right grid border, it is moved to the first column of the next row.- See Also:
newLine()
-
addComponent
public void addComponent(Component component)
Adds the component into this container to the cursor position. If the cursor position is already occupied, the cursor is moved forwards to find free position. If the cursor goes out from the bottom of the grid, the grid is automatically extended.- Specified by:
addComponent
in interfaceComponentContainer
- Overrides:
addComponent
in classAbstractComponentContainer
- Parameters:
component
- the component to be added, notnull
.- See Also:
ComponentContainer.addComponent(Component)
-
removeComponent
public void removeComponent(Component component)
Removes the specified component from the layout.- Specified by:
removeComponent
in interfaceComponentContainer
- Overrides:
removeComponent
in classAbstractComponentContainer
- Parameters:
component
- the component to be removed.- See Also:
ComponentContainer.removeComponent(Component)
-
removeComponent
public void removeComponent(int column, int row)
Removes the component specified by its cell coordinates.- Parameters:
column
- the component's column, starting from 0.row
- the component's row, starting from 0.
-
iterator
public Iterator<Component> iterator()
Gets an Iterator for the components contained in the layout. By using the Iterator it is possible to step through the contents of the layout.- Specified by:
iterator
in interfaceHasComponents
- Specified by:
iterator
in interfaceIterable<Component>
- Returns:
- the Iterator of the components inside the layout.
-
getComponentCount
public int getComponentCount()
Gets the number of components contained in the layout. Consistent with the iterator returned byAbstractComponentContainer.getComponentIterator()
.- Specified by:
getComponentCount
in interfaceComponentContainer
- Returns:
- the number of contained components
-
beforeClientResponse
public void beforeClientResponse(boolean initial)
Description copied from interface:ClientConnector
Called before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.- Specified by:
beforeClientResponse
in interfaceClientConnector
- Overrides:
beforeClientResponse
in classAbstractComponent
- Parameters:
initial
-true
if the client-side connector will be created and initialized after this method has been invoked.false
if there is already an initialized client-side connector.
-
getComponentAlignment
public Alignment getComponentAlignment(Component childComponent)
Description copied from interface:Layout.AlignmentHandler
Returns the current Alignment of given component.- Specified by:
getComponentAlignment
in interfaceLayout.AlignmentHandler
- Returns:
- the
Alignment
-
setColumns
public void setColumns(int columns)
Sets the number of columns in the grid. The column count can not be reduced if there are any areas that would be outside of the shrunk grid.- Parameters:
columns
- the new number of columns in the grid.
-
getColumns
public int getColumns()
Get the number of columns in the grid.- Returns:
- the number of columns in the grid.
-
setRows
public void setRows(int rows)
Sets the number of rows in the grid. The number of rows can not be reduced if there are any areas that would be outside of the shrunk grid.- Parameters:
rows
- the new number of rows in the grid.
-
getRows
public int getRows()
Get the number of rows in the grid.- Returns:
- the number of rows in the grid.
-
getCursorX
public int getCursorX()
Gets the current x-position (column) of the cursor.The cursor position points the position for the next component that is added without specifying its coordinates (grid cell). When the cursor position is occupied, the next component will be added to first free position after the cursor.
- Returns:
- the grid column the cursor is on, starting from 0.
-
setCursorX
public void setCursorX(int cursorX)
Sets the current cursor x-position. This is usually handled automatically by GridLayout.- Parameters:
cursorX
-
-
getCursorY
public int getCursorY()
Gets the current y-position (row) of the cursor.The cursor position points the position for the next component that is added without specifying its coordinates (grid cell). When the cursor position is occupied, the next component will be added to the first free position after the cursor.
- Returns:
- the grid row the Cursor is on.
-
setCursorY
public void setCursorY(int cursorY)
Sets the current y-coordinate (row) of the cursor. This is usually handled automatically by GridLayout.- Parameters:
cursorY
- the row number, starting from 0 for the topmost row.
-
replaceComponent
public void replaceComponent(Component oldComponent, Component newComponent)
Description copied from interface:ComponentContainer
Replaces the component in the container with another one without changing position.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.
- Specified by:
replaceComponent
in interfaceComponentContainer
- Parameters:
oldComponent
- the old component that will be replaced.newComponent
- the new component to be replaced.
-
removeAllComponents
public void removeAllComponents()
Description copied from class:AbstractComponentContainer
Removes all components from the container. This should probably be re-implemented in extending classes for a more powerful implementation.- Specified by:
removeAllComponents
in interfaceComponentContainer
- Overrides:
removeAllComponents
in classAbstractComponentContainer
-
setComponentAlignment
public void setComponentAlignment(Component childComponent, Alignment alignment)
Description copied from interface:Layout.AlignmentHandler
Set alignment for one contained component in this layout. Use predefined alignments from Alignment class. Example:layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT);
- Specified by:
setComponentAlignment
in interfaceLayout.AlignmentHandler
- Parameters:
childComponent
- the component to align within it's layout cell.alignment
- the Alignment value to be set
-
setSpacing
public void setSpacing(boolean spacing)
Description copied from interface:Layout.SpacingHandler
Enable spacing between child components within this layout.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.
- Specified by:
setSpacing
in interfaceLayout.SpacingHandler
- Parameters:
spacing
- true if spacing should be turned on, false if it should be turned off
-
isSpacing
public boolean isSpacing()
- Specified by:
isSpacing
in interfaceLayout.SpacingHandler
- Returns:
- true if spacing between child components within this layout is enabled, false otherwise
-
insertRow
public void insertRow(int row)
Inserts an empty row at the specified position in the grid.- Parameters:
row
- Index of the row before which the new row will be inserted. The leftmost row has index 0.
-
removeRow
public void removeRow(int row)
Removes a row and all the components in the row.Components which span over several rows are removed if the selected row is on the first row of such a component.
If the last row is removed then all remaining components will be removed and the grid will be reduced to one row. The cursor will be moved to the upper left cell of the grid.
- Parameters:
row
- Index of the row to remove. The leftmost row has index 0.
-
setColumnExpandRatio
public void setColumnExpandRatio(int columnIndex, float ratio)
Sets the expand ratio of given column.The expand ratio defines how excess space is distributed among columns. Excess space means space that is left over from components that are not sized relatively. By default, the excess space is distributed evenly.
Note, that width of this GridLayout needs to be defined (fixed or relative, as opposed to undefined height) for this method to have any effect.
Note that checking for relative width for the child components is done on the server so you cannot set a child component to have undefined width on the server and set it to
100%
in CSS. You must set it to100%
on the server.- Parameters:
columnIndex
-ratio
-- See Also:
#setWidth(float, int)
-
getColumnExpandRatio
public float getColumnExpandRatio(int columnIndex)
Returns the expand ratio of given column- Parameters:
columnIndex
-- Returns:
- the expand ratio, 0.0f by default
- See Also:
setColumnExpandRatio(int, float)
-
setRowExpandRatio
public void setRowExpandRatio(int rowIndex, float ratio)
Sets the expand ratio of given row.Expand ratio defines how excess space is distributed among rows. Excess space means the space left over from components that are not sized relatively. By default, the excess space is distributed evenly.
Note, that height of this GridLayout needs to be defined (fixed or relative, as opposed to undefined height) for this method to have any effect.
Note that checking for relative height for the child components is done on the server so you cannot set a child component to have undefined height on the server and set it to
100%
in CSS. You must set it to100%
on the server.- Parameters:
rowIndex
- The row index, starting from 0 for the topmost row.ratio
-- See Also:
#setHeight(float, int)
-
getRowExpandRatio
public float getRowExpandRatio(int rowIndex)
Returns the expand ratio of given row.- Parameters:
rowIndex
- The row index, starting from 0 for the topmost row.- Returns:
- the expand ratio, 0.0f by default
- See Also:
setRowExpandRatio(int, float)
-
getComponent
public Component getComponent(int x, int y)
Gets the Component at given index.- Parameters:
x
- The column index, starting from 0 for the leftmost column.y
- The row index, starting from 0 for the topmost row.- Returns:
- Component in given cell or null if empty
-
getComponentArea
public GridLayout.Area getComponentArea(Component component)
Returns information about the area where given component is laid in the GridLayout.- Parameters:
component
- the component whose area information is requested.- Returns:
- an Area object that contains information how component is laid in the grid
-
addLayoutClickListener
public void addLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Description copied from interface:LayoutEvents.LayoutClickNotifier
Add a click listener to the layout. The listener is called whenever the user clicks inside the layout. An event is also triggered when the click targets a component inside a nested layout or Panel, provided the targeted component does not prevent the click event from propagating. A caption is not considered part of a component. The child component that was clicked is included in theLayoutEvents.LayoutClickEvent
. UseLayoutEvents.LayoutClickNotifier.removeListener(LayoutClickListener)
to remove the listener.- Specified by:
addLayoutClickListener
in interfaceLayoutEvents.LayoutClickNotifier
- Parameters:
listener
- The listener to add
-
addListener
@Deprecated public void addListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byaddLayoutClickListener(LayoutClickListener)
- Specified by:
addListener
in interfaceLayoutEvents.LayoutClickNotifier
-
removeLayoutClickListener
public void removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Description copied from interface:LayoutEvents.LayoutClickNotifier
Removes an LayoutClickListener.- Specified by:
removeLayoutClickListener
in interfaceLayoutEvents.LayoutClickNotifier
- Parameters:
listener
- LayoutClickListener to be removed
-
removeListener
@Deprecated public void removeListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byremoveLayoutClickListener(LayoutClickListener)
- Specified by:
removeListener
in interfaceLayoutEvents.LayoutClickNotifier
-
setMargin
public void setMargin(boolean enabled)
Description copied from interface:Layout.MarginHandler
Enable layout margins. Affects all four sides of the layout. This will tell the client-side implementation to leave extra space around the layout. The client-side implementation decides the actual amount, and it can vary between themes.- Specified by:
setMargin
in interfaceLayout.MarginHandler
- Parameters:
enabled
- true if margins should be enabled on all sides, false to disable all margins
-
setMargin
public void setMargin(MarginInfo marginInfo)
Description copied from interface:Layout.MarginHandler
Enable margins for this layout.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.
- Specified by:
setMargin
in interfaceLayout.MarginHandler
- Parameters:
marginInfo
- MarginInfo object containing the new margins.
-
getMargin
public MarginInfo getMargin()
- Specified by:
getMargin
in interfaceLayout.MarginHandler
- Returns:
- MarginInfo containing the currently enabled margins.
-
getDefaultComponentAlignment
public Alignment getDefaultComponentAlignment()
Description copied from interface:Layout.AlignmentHandler
Returns the alignment used for new components added to this layout- Specified by:
getDefaultComponentAlignment
in interfaceLayout.AlignmentHandler
- Returns:
- The default alignment
-
setDefaultComponentAlignment
public void setDefaultComponentAlignment(Alignment defaultAlignment)
Description copied from interface:Layout.AlignmentHandler
Sets the alignment used for new components added to this layout. The default isAlignment.TOP_LEFT
.- Specified by:
setDefaultComponentAlignment
in interfaceLayout.AlignmentHandler
- Parameters:
defaultAlignment
- The new default alignment
-
setHideEmptyRowsAndColumns
public void setHideEmptyRowsAndColumns(boolean hideEmptyRowsAndColumns)
Sets whether empty rows and columns should be considered as non-existent when rendering or not. If this is set to true then the spacing between multiple empty columns (or rows) will be collapsed. The default behavior is to consider all rows and columns as visible NOTE that this must be set before the initial rendering takes place. Updating this on the fly is not supported.- Parameters:
hideEmptyRowsAndColumns
- true to hide empty rows and columns, false to leave them as-is- Since:
- 7.3
-
isHideEmptyRowsAndColumns
public boolean isHideEmptyRowsAndColumns()
Checks whether whether empty rows and columns should be considered as non-existent when rendering or not.- Returns:
- true if empty rows and columns are hidden, false otherwise
- Since:
- 7.3
- See Also:
setHideEmptyRowsAndColumns(boolean)
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the component state from the given design.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.
After reading the design, cursorY is set to point to a row outside of the GridLayout area. CursorX is reset to 0.
- Specified by:
readDesign
in interfaceComponent
- Overrides:
readDesign
in classAbstractComponent
- Parameters:
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the design
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Description copied from interface:Component
Writes the component state to the given design.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.
- Specified by:
writeDesign
in interfaceComponent
- Overrides:
writeDesign
in classAbstractComponent
- Parameters:
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 design
-
getCustomAttributes
protected Collection<String> getCustomAttributes()
Description copied from class:AbstractComponent
Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
andAbstractComponent.writeDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
methods. Typically these are handled in a custom way in the overridden versions of the above methods- Overrides:
getCustomAttributes
in classAbstractComponent
- Returns:
- the collection of attributes that are not handled by the basic implementation
-
-