Class CmsEditableGroup
- java.lang.Object
-
- org.opencms.ui.components.editablegroup.CmsEditableGroup
-
public class CmsEditableGroup extends java.lang.Object
Manages a group of widgets used as a multivalue input.This class is not itself a widget, it just coordinates the other widgets actually used to display the multivalue widget group.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsEditableGroup.AddButtonEmptyHandler
Empty handler which shows or hides an 'Add' button to add new rows, depending on whether the group is empty.static class
CmsEditableGroup.DefaultRowBuilder
Default implementation for row builder.static interface
CmsEditableGroup.I_EmptyHandler
Handles state changes when the group becomes empty/not empty.static interface
CmsEditableGroup.I_HasError
Interface for group row components that can have errors.static interface
CmsEditableGroup.I_RowBuilder
Builds editable group rows by wrapping other components.
-
Constructor Summary
Constructors Constructor Description CmsEditableGroup(com.vaadin.ui.AbstractOrderedLayout container, com.google.common.base.Supplier<com.vaadin.ui.Component> componentFactory, java.lang.String addButtonCaption)
Creates a new instance.CmsEditableGroup(com.vaadin.ui.AbstractOrderedLayout container, com.google.common.base.Supplier<com.vaadin.ui.Component> componentFactory, CmsEditableGroup.I_EmptyHandler emptyHandler)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRow(com.vaadin.ui.Component component)
Adds a row for the given component at the end of the group.void
addRowAfter(I_CmsEditableGroupRow row)
Adds a new row after the given one.com.vaadin.ui.AbstractOrderedLayout
getContainer()
Gets the row container.com.vaadin.ui.Component.Listener
getErrorListener()
Gets the error listener.com.google.common.base.Supplier<com.vaadin.ui.Component>
getNewComponentFactory()
Gets the factory used for creating new components.java.lang.String
getRowCaption()
Returns the row caption.java.util.List<I_CmsEditableGroupRow>
getRows()
Gets all rows.protected boolean
hasError(com.vaadin.ui.Component component)
Checks if the given group component has an error.void
init()
Initializes the multivalue group.void
moveDown(I_CmsEditableGroupRow row)
Moves the given row down.void
moveUp(I_CmsEditableGroupRow row)
Moves the given row up.void
onEdit(I_CmsEditableGroupRow row)
void
remove(I_CmsEditableGroupRow row)
Removes the given row.void
removeAll()
void
setAddButtonVisible(boolean visible)
void
setEditEnabled(boolean enabled)
Enables / disables edit button.void
setErrorMessage(java.lang.String errorMessage)
Sets the error message.void
setRowBuilder(CmsEditableGroup.I_RowBuilder rowBuilder)
Sets the row builder.void
setRowCaption(java.lang.String rowCaption)
Sets the row caption.
-
-
-
Constructor Detail
-
CmsEditableGroup
public CmsEditableGroup(com.vaadin.ui.AbstractOrderedLayout container, com.google.common.base.Supplier<com.vaadin.ui.Component> componentFactory, CmsEditableGroup.I_EmptyHandler emptyHandler)
Creates a new instance.- Parameters:
container
- the container in which to render the individual rowscomponentFactory
- the factory used to create new input fieldsplaceholder
- the placeholder to display when there are no rows
-
CmsEditableGroup
public CmsEditableGroup(com.vaadin.ui.AbstractOrderedLayout container, com.google.common.base.Supplier<com.vaadin.ui.Component> componentFactory, java.lang.String addButtonCaption)
Creates a new instance.- Parameters:
container
- the container in which to render the individual rowscomponentFactory
- the factory used to create new input fieldsaddButtonCaption
- the caption for the button which is used to add a new row to an empty list
-
-
Method Detail
-
addRow
public void addRow(com.vaadin.ui.Component component)
Adds a row for the given component at the end of the group.- Parameters:
component
- the component to wrap in the row to be added
-
addRowAfter
public void addRowAfter(I_CmsEditableGroupRow row)
Adds a new row after the given one.- Parameters:
row
- the row after which a new one should be added
-
getContainer
public com.vaadin.ui.AbstractOrderedLayout getContainer()
Gets the row container.- Returns:
- the row container
-
getErrorListener
public com.vaadin.ui.Component.Listener getErrorListener()
Gets the error listener.- Returns:
- t
-
getNewComponentFactory
public com.google.common.base.Supplier<com.vaadin.ui.Component> getNewComponentFactory()
Gets the factory used for creating new components.- Returns:
- the factory used for creating new components
-
getRowCaption
public java.lang.String getRowCaption()
Returns the row caption.- Returns:
- the row caption
-
getRows
public java.util.List<I_CmsEditableGroupRow> getRows()
Gets all rows.- Returns:
- the list of all rows
-
init
public void init()
Initializes the multivalue group.
-
moveDown
public void moveDown(I_CmsEditableGroupRow row)
Moves the given row down.- Parameters:
row
- the row to move
-
moveUp
public void moveUp(I_CmsEditableGroupRow row)
Moves the given row up.- Parameters:
row
- the row to move
-
onEdit
public void onEdit(I_CmsEditableGroupRow row)
-
remove
public void remove(I_CmsEditableGroupRow row)
Removes the given row.- Parameters:
row
- the row to remove
-
removeAll
public void removeAll()
-
setAddButtonVisible
public void setAddButtonVisible(boolean visible)
- See Also:
org.opencms.ui.components.editablegroup.I_CmsEditableGroup#setAddButtonVisible(boolean)
-
setEditEnabled
public void setEditEnabled(boolean enabled)
Enables / disables edit button.- Parameters:
enabled
- true if edit button should be enabled
-
setErrorMessage
public void setErrorMessage(java.lang.String errorMessage)
Sets the error message.- Parameters:
errorMessage
- the error message
-
setRowBuilder
public void setRowBuilder(CmsEditableGroup.I_RowBuilder rowBuilder)
Sets the row builder.- Parameters:
rowBuilder
- the row builder
-
setRowCaption
public void setRowCaption(java.lang.String rowCaption)
Sets the row caption.- Parameters:
rowCaption
- the row caption to set
-
hasError
protected boolean hasError(com.vaadin.ui.Component component)
Checks if the given group component has an error.- Parameters:
component
- the component to check- Returns:
- true if the component has an error
-
-