com.vaadin.ui
Class Tree

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractField<java.lang.Object>
              extended by com.vaadin.ui.AbstractSelect
                  extended by com.vaadin.ui.Tree
All Implemented Interfaces:
Buffered, BufferedValidatable, Container, Container.Hierarchical, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Viewer, Property<java.lang.Object>, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.Container, Action.ShortcutNotifier, ConnectorEventListener, DragSource, DropTarget, ItemClickEvent.ItemClickNotifier, MethodEventSource, ClientConnector, Sizeable, VariableOwner, com.vaadin.shared.Connector, Component, Component.Focusable, Field<java.lang.Object>, LegacyComponent, java.io.Serializable, java.util.EventListener

public class Tree
extends AbstractSelect
implements Container.Hierarchical, Action.Container, ItemClickEvent.ItemClickNotifier, DragSource, DropTarget

Tree component. A Tree can be used to select an item (or multiple items) from a hierarchical set of items.

Since:
3.0
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
static class Tree.CollapseEvent
          Collapse event
static interface Tree.CollapseListener
          Collapse event listener.
static class Tree.ExpandEvent
          Event to fired when a node is expanded.
static interface Tree.ExpandListener
          Expand event listener.
static interface Tree.ItemStyleGenerator
          ItemStyleGenerator can be used to add custom styles to tree items.
 class Tree.TargetInSubtree
          An accept criterion that checks the parent node (or parent hierarchy) for the item identifier given in constructor.
static class Tree.TargetItemAllowsChildren
          A criterion that accepts Transferable only directly on a tree node that can have children.
static class Tree.TreeDragMode
          Supported drag modes for Tree.
static class Tree.TreeDropCriterion
          Lazy loading accept criterion for Tree.
 class Tree.TreeTargetDetails
          A TargetDetails implementation with Tree specific api.
protected  class Tree.TreeTransferable
          Concrete implementation of DataBoundTransferable for data transferred from a tree.
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractSelect
AbstractSelect.AbstractSelectTargetDetails, AbstractSelect.AcceptItem, AbstractSelect.CaptionChangeListener, AbstractSelect.DefaultNewItemHandler, AbstractSelect.Filtering, AbstractSelect.ItemCaptionMode, AbstractSelect.ItemDescriptionGenerator, AbstractSelect.NewItemHandler, AbstractSelect.TargetItemIs, AbstractSelect.VerticalLocationIs
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Container
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer
 
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.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Field Summary
 
Fields inherited from class com.vaadin.ui.AbstractSelect
ITEM_CAPTION_MODE_EXPLICIT, ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID, ITEM_CAPTION_MODE_ICON_ONLY, ITEM_CAPTION_MODE_ID, ITEM_CAPTION_MODE_INDEX, ITEM_CAPTION_MODE_ITEM, ITEM_CAPTION_MODE_PROPERTY, itemIdMapper, items
 
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
Tree()
          Creates a new empty tree.
Tree(java.lang.String caption)
          Creates a new empty tree with caption.
Tree(java.lang.String caption, Container dataSource)
          Creates a new tree with caption and connect it to a Container.
 
Method Summary
 void addActionHandler(Action.Handler actionHandler)
          Adds an action handler.
 void addCollapseListener(Tree.CollapseListener listener)
          Adds the collapse listener.
 void addExpandListener(Tree.ExpandListener listener)
          Adds the expand listener.
 void addItemClickListener(ItemClickEvent.ItemClickListener listener)
          Register a listener to handle ItemClickEvents.
 void addListener(ItemClickEvent.ItemClickListener listener)
          Deprecated. As of 7.0, replaced by #addItemClickListener(ItemClickListener)
 void addListener(Tree.CollapseListener listener)
          Deprecated. As of 7.0, replaced by addCollapseListener(CollapseListener)
 void addListener(Tree.ExpandListener listener)
          Deprecated. As of 7.0, replaced by addExpandListener(ExpandListener)
 boolean areChildrenAllowed(java.lang.Object itemId)
          Tests if the Item with given ID can have any children.
 void changeVariables(java.lang.Object source, java.util.Map<java.lang.String,java.lang.Object> variables)
          Invoked when the value of a variable has changed.
 boolean collapseItem(java.lang.Object itemId)
          Collapses an item.
 boolean collapseItemsRecursively(java.lang.Object startItemId)
          Collapses the items recursively.
 void containerItemSetChange(Container.ItemSetChangeEvent event)
          Lets the listener know a Containers Item set has changed.
 boolean expandItem(java.lang.Object itemId)
          Expands an item.
 boolean expandItemsRecursively(java.lang.Object startItemId)
          Expands the items recursively Expands all the children recursively starting from an item.
protected  void fireCollapseEvent(java.lang.Object itemId)
          Emits collapse event.
protected  void fireExpandEvent(java.lang.Object itemId)
          Emits the expand event.
 java.util.Collection<?> getChildren(java.lang.Object itemId)
          Gets the IDs of all Items that are children of the specified Item.
 Tree.TreeDragMode getDragMode()
           
 DropHandler getDropHandler()
           
 AbstractSelect.ItemDescriptionGenerator getItemDescriptionGenerator()
          Get the item description generator which generates tooltips for tree items
 java.lang.String getItemIconAlternateText(java.lang.Object itemId)
          Return the alternate text of an icon in a tree item.
 Tree.ItemStyleGenerator getItemStyleGenerator()
           
 com.vaadin.shared.ui.MultiSelectMode getMultiselectMode()
          Returns the mode the multiselect is in.
 java.lang.Object getParent(java.lang.Object itemId)
          Gets the ID of the parent Item of the specified Item.
 Transferable getTransferable(java.util.Map<java.lang.String,java.lang.Object> payload)
          DragSource may convert data added by client side component to meaningful values for server side developer or add other data based on it.
 java.util.Collection<?> getVisibleItemIds()
          Gets the visible item ids.
 boolean hasChildren(java.lang.Object itemId)
          Tests if the Item specified with itemId has child Items.
 boolean isExpanded(java.lang.Object itemId)
          Check is an item is expanded
 boolean isRoot(java.lang.Object itemId)
          Tests if the Item specified with itemId is a root Item.
 boolean isSelectable()
          Returns the current selectable state.
 void markAsDirty()
          Marks that this connector's state might have changed.
 void paintContent(PaintTarget target)
          Paints any needed component-specific things to the given UIDL stream.
protected  java.lang.String readItem(org.jsoup.nodes.Element node, java.util.Set<java.lang.String> selected, DesignContext context)
          Reads an Item from a design and inserts it into the data source.
 void removeActionHandler(Action.Handler actionHandler)
          Removes an action handler.
 void removeAllActionHandlers()
          Removes all action handlers
 void removeCollapseListener(Tree.CollapseListener listener)
          Removes the collapse listener.
 void removeExpandListener(Tree.ExpandListener listener)
          Removes the expand listener.
 boolean removeItem(java.lang.Object itemId)
          Removes the Item identified by ItemId from the Container.
 void removeItemClickListener(ItemClickEvent.ItemClickListener listener)
          Removes an ItemClickListener.
 void removeListener(ItemClickEvent.ItemClickListener listener)
          Deprecated. As of 7.0, replaced by #removeItemClickListener(ItemClickListener)
 void removeListener(Tree.CollapseListener listener)
          Deprecated. As of 7.0, replaced by removeCollapseListener(CollapseListener)
 void removeListener(Tree.ExpandListener listener)
          Deprecated. As of 7.0, replaced by removeExpandListener(ExpandListener)
 java.util.Collection<?> rootItemIds()
          Gets the IDs of all Items in the container that don't have a parent.
 boolean setChildrenAllowed(java.lang.Object itemId, boolean areChildrenAllowed)
          Sets the given Item's capability to have children.
 void setContainerDataSource(Container newDataSource)
          Sets the Container that serves as the data source of the viewer.
 void setDragMode(Tree.TreeDragMode dragMode)
          Sets the drag mode that controls how Tree behaves as a DragSource .
 void setDropHandler(DropHandler dropHandler)
           
 void setItemDescriptionGenerator(AbstractSelect.ItemDescriptionGenerator generator)
          Set the item description generator which generates tooltips for the tree items
 void setItemIcon(java.lang.Object itemId, Resource icon)
          Sets the icon for an item.
 void setItemIcon(java.lang.Object itemId, Resource icon, java.lang.String altText)
          Sets the icon for an item.
 void setItemIconAlternateText(java.lang.Object itemId, java.lang.String altText)
          Set the alternate text for an item.
 void setItemStyleGenerator(Tree.ItemStyleGenerator itemStyleGenerator)
          Sets the Tree.ItemStyleGenerator to be used with this tree.
 void setMultiselectMode(com.vaadin.shared.ui.MultiSelectMode mode)
          Sets the behavior of the multiselect mode
 void setNewItemsAllowed(boolean allowNewOptions)
          Adding new items is not supported.
 void setNullSelectionItemId(java.lang.Object nullSelectionItemId)
          Tree does not support setNullSelectionItemId.
 boolean setParent(java.lang.Object itemId, java.lang.Object newParentId)
           Sets the parent of an Item.
 void setSelectable(boolean selectable)
          Sets the selectable state.
 Tree.TreeTargetDetails translateDropTargetDetails(java.util.Map<java.lang.String,java.lang.Object> clientVariables)
          Called before the DragAndDropEvent is passed to DropHandler.
protected  org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element design, java.lang.Object itemId, DesignContext context)
          Recursively writes a data source Item and its children to a design.
protected  void writeItems(org.jsoup.nodes.Element design, DesignContext context)
          Recursively writes the root items and their children to a design.
 
Methods inherited from class com.vaadin.ui.AbstractSelect
addContainerProperty, addItem, addItem, addItems, addItems, addItemSetChangeListener, addListener, addListener, addPropertySetChangeListener, attach, containerPropertySetChange, containsId, detach, fireItemSetChange, firePropertySetChange, getCaptionChangeListener, getContainerDataSource, getContainerProperty, getContainerPropertyIds, getItem, getItemCaption, getItemCaptionMode, getItemCaptionPropertyId, getItemIcon, getItemIconPropertyId, getItemIds, getListeners, getNewItemHandler, getNullSelectionItemId, getType, getType, getValue, isEmpty, isMultiSelect, isNewItemsAllowed, isNullSelectionAllowed, isSelected, paintItem, readDesign, readItems, removeAllItems, removeContainerProperty, removeItemSetChangeListener, removeListener, removeListener, removePropertySetChangeListener, sanitizeSelection, select, setItemCaption, setItemCaptionMode, setItemCaptionPropertyId, setItemIconPropertyId, setMultiSelect, setNewItemHandler, setNullSelectionAllowed, setValue, setValue, size, unselect, writeDesign
 
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, beforeClientResponse, clear, commit, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getCustomAttributes, getErrorMessage, getInternalValue, getModelType, getPropertyDataSource, getRequiredError, getState, getState, getTabIndex, getValidators, isBuffered, isImmediate, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setLocale, setPropertyDataSource, setReadOnly, setRequired, setRequiredError, setTabIndex, setValidationVisible, shouldHideErrors, toString, validate, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, 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, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, 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, wait, wait, wait
 
Methods inherited from interface com.vaadin.data.Container
addContainerProperty, addItem, addItem, containsId, getContainerProperty, getContainerPropertyIds, getItem, getItemIds, getType, removeAllItems, removeContainerProperty, size
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, readDesign, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible, writeDesign
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
 
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled, isImmediate
 
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
 

Constructor Detail

Tree

public Tree()
Creates a new empty tree.


Tree

public Tree(java.lang.String caption)
Creates a new empty tree with caption.

Parameters:
caption -

Tree

public Tree(java.lang.String caption,
            Container dataSource)
Creates a new tree with caption and connect it to a Container.

Parameters:
caption -
dataSource -
Method Detail

setItemIcon

public void setItemIcon(java.lang.Object itemId,
                        Resource icon)
Description copied from class: AbstractSelect
Sets the icon for an item.

Overrides:
setItemIcon in class AbstractSelect
Parameters:
itemId - the id of the item to be assigned an icon.
icon - the icon to use or null.

setItemIcon

public void setItemIcon(java.lang.Object itemId,
                        Resource icon,
                        java.lang.String altText)
Sets the icon for an item.

Parameters:
itemId - the id of the item to be assigned an icon.
icon - the icon to use or null.
altText - the alternative text for the icon

setItemIconAlternateText

public void setItemIconAlternateText(java.lang.Object itemId,
                                     java.lang.String altText)
Set the alternate text for an item. Used when the item has an icon.

Parameters:
itemId - the id of the item to be assigned an icon.
altText - the alternative text for the icon

getItemIconAlternateText

public java.lang.String getItemIconAlternateText(java.lang.Object itemId)
Return the alternate text of an icon in a tree item.

Parameters:
itemId - Object with the ID of the item
Returns:
String with the alternate text of the icon, or null when no icon was set

isExpanded

public boolean isExpanded(java.lang.Object itemId)
Check is an item is expanded

Parameters:
itemId - the item id.
Returns:
true iff the item is expanded.

expandItem

public boolean expandItem(java.lang.Object itemId)
Expands an item.

Parameters:
itemId - the item id.
Returns:
True iff the expand operation succeeded

markAsDirty

public void markAsDirty()
Description copied from interface: ClientConnector
Marks that this connector's state might have changed. When the framework is about to send new data to the client-side, it will run ClientConnector.beforeClientResponse(boolean) followed by ClientConnector.encodeState() for all connectors that are marked as dirty and send any updated state info to the client.

Specified by:
markAsDirty in interface ClientConnector
Specified by:
markAsDirty in interface LegacyComponent
Overrides:
markAsDirty in class AbstractClientConnector
See Also:
ClientConnector.markAsDirty()

expandItemsRecursively

public boolean expandItemsRecursively(java.lang.Object startItemId)
Expands the items recursively Expands all the children recursively starting from an item. Operation succeeds only if all expandable items are expanded.

Parameters:
startItemId -
Returns:
True iff the expand operation succeeded

collapseItem

public boolean collapseItem(java.lang.Object itemId)
Collapses an item.

Parameters:
itemId - the item id.
Returns:
True iff the collapse operation succeeded

collapseItemsRecursively

public boolean collapseItemsRecursively(java.lang.Object startItemId)
Collapses the items recursively. Collapse all the children recursively starting from an item. Operation succeeds only if all expandable items are collapsed.

Parameters:
startItemId -
Returns:
True iff the collapse operation succeeded

isSelectable

public boolean isSelectable()
Returns the current selectable state. Selectable determines if the a node can be selected on the client side. Selectable does not affect AbstractSelect.setValue(Object) or AbstractSelect.select(Object).

The tree is selectable by default.

Returns:
the current selectable state.

setSelectable

public void setSelectable(boolean selectable)
Sets the selectable state. Selectable determines if the a node can be selected on the client side. Selectable does not affect AbstractSelect.setValue(Object) or AbstractSelect.select(Object).

The tree is selectable by default.

Parameters:
selectable - The new selectable state.

setMultiselectMode

public void setMultiselectMode(com.vaadin.shared.ui.MultiSelectMode mode)
Sets the behavior of the multiselect mode

Parameters:
mode - The mode to set

getMultiselectMode

public com.vaadin.shared.ui.MultiSelectMode getMultiselectMode()
Returns the mode the multiselect is in. The mode controls how multiselection can be done.

Returns:
The mode

changeVariables

public void changeVariables(java.lang.Object source,
                            java.util.Map<java.lang.String,java.lang.Object> variables)
Description copied from class: AbstractSelect
Invoked when the value of a variable has changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractSelect
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.
See Also:
com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, java.util.Map)

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints any needed component-specific things to the given UIDL stream.

Specified by:
paintContent in interface LegacyComponent
Overrides:
paintContent in class AbstractSelect
Parameters:
target - the Paint Event.
Throws:
PaintException - if the paint operation failed.
See Also:
com.vaadin.ui.AbstractComponent#paintContent(PaintTarget)

areChildrenAllowed

public boolean areChildrenAllowed(java.lang.Object itemId)
Tests if the Item with given ID can have any children.

Specified by:
areChildrenAllowed in interface Container.Hierarchical
Parameters:
itemId - ID of the Item in the container whose child capability is to be tested
Returns:
true if the specified Item exists in the Container and it can have children, false if it's not found from the container or it can't have children.
See Also:
Container.Hierarchical.areChildrenAllowed(Object)

getChildren

public java.util.Collection<?> getChildren(java.lang.Object itemId)
Gets the IDs of all Items that are children of the specified Item.

Specified by:
getChildren in interface Container.Hierarchical
Parameters:
itemId - ID of the Item whose children the caller is interested in
Returns:
An unmodifiable collection containing the IDs of all other Items that are children in the container hierarchy
See Also:
Container.Hierarchical.getChildren(Object)

getParent

public java.lang.Object getParent(java.lang.Object itemId)
Gets the ID of the parent Item of the specified Item.

Specified by:
getParent in interface Container.Hierarchical
Parameters:
itemId - ID of the Item whose parent the caller wishes to find out.
Returns:
the ID of the parent Item. Will be null if the specified Item is a root element.
See Also:
Container.Hierarchical.getParent(Object)

hasChildren

public boolean hasChildren(java.lang.Object itemId)
Tests if the Item specified with itemId has child Items.

Specified by:
hasChildren in interface Container.Hierarchical
Parameters:
itemId - ID of the Item to be tested
Returns:
true if the specified Item has children, false if not (is a leaf)
See Also:
Container.Hierarchical.hasChildren(Object)

isRoot

public boolean isRoot(java.lang.Object itemId)
Tests if the Item specified with itemId is a root Item.

Specified by:
isRoot in interface Container.Hierarchical
Parameters:
itemId - ID of the Item whose root status is to be tested
Returns:
true if the specified Item is a root, false if not
See Also:
Container.Hierarchical.isRoot(Object)

rootItemIds

public java.util.Collection<?> rootItemIds()
Gets the IDs of all Items in the container that don't have a parent.

Specified by:
rootItemIds in interface Container.Hierarchical
Returns:
An unmodifiable collection containing IDs of all root elements of the container
See Also:
Container.Hierarchical.rootItemIds()

setChildrenAllowed

public boolean setChildrenAllowed(java.lang.Object itemId,
                                  boolean areChildrenAllowed)
Sets the given Item's capability to have children.

Specified by:
setChildrenAllowed in interface Container.Hierarchical
Parameters:
itemId - ID of the Item in the container whose child capability is to be set
areChildrenAllowed - boolean value specifying if the Item can have children or not
Returns:
true if the operation succeeded, false if not
See Also:
Container.Hierarchical.setChildrenAllowed(Object, boolean)

setParent

public boolean setParent(java.lang.Object itemId,
                         java.lang.Object newParentId)
Description copied from interface: Container.Hierarchical

Sets the parent of an Item. The new parent item must exist and be able to have children. ( Container.Hierarchical.areChildrenAllowed(Object) == true ). It is also possible to detach a node from the hierarchy (and thus make it root) by setting the parent null.

This operation is optional.

Specified by:
setParent in interface Container.Hierarchical
Parameters:
itemId - ID of the item to be set as the child of the Item identified with newParentId
newParentId - ID of the Item that's to be the new parent of the Item identified with itemId
Returns:
true if the operation succeeded, false if not

setContainerDataSource

public void setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer.

Specified by:
setContainerDataSource in interface Container.Viewer
Overrides:
setContainerDataSource in class AbstractSelect
Parameters:
newDataSource - the new data source.
See Also:
Container.Viewer.setContainerDataSource(Container)

containerItemSetChange

public void containerItemSetChange(Container.ItemSetChangeEvent event)
Description copied from class: AbstractSelect
Lets the listener know a Containers Item set has changed.

Specified by:
containerItemSetChange in interface Container.ItemSetChangeListener
Overrides:
containerItemSetChange in class AbstractSelect
Parameters:
event - change event text
See Also:
Container.ItemSetChangeListener.containerItemSetChange(com.vaadin.data.Container.ItemSetChangeEvent)

addExpandListener

public void addExpandListener(Tree.ExpandListener listener)
Adds the expand listener.

Parameters:
listener - the Listener to be added.

addListener

@Deprecated
public void addListener(Tree.ExpandListener listener)
Deprecated. As of 7.0, replaced by addExpandListener(ExpandListener)


removeExpandListener

public void removeExpandListener(Tree.ExpandListener listener)
Removes the expand listener.

Parameters:
listener - the Listener to be removed.

removeListener

@Deprecated
public void removeListener(Tree.ExpandListener listener)
Deprecated. As of 7.0, replaced by removeExpandListener(ExpandListener)


fireExpandEvent

protected void fireExpandEvent(java.lang.Object itemId)
Emits the expand event.

Parameters:
itemId - the item id.

addCollapseListener

public void addCollapseListener(Tree.CollapseListener listener)
Adds the collapse listener.

Parameters:
listener - the Listener to be added.

addListener

@Deprecated
public void addListener(Tree.CollapseListener listener)
Deprecated. As of 7.0, replaced by addCollapseListener(CollapseListener)


removeCollapseListener

public void removeCollapseListener(Tree.CollapseListener listener)
Removes the collapse listener.

Parameters:
listener - the Listener to be removed.

removeListener

@Deprecated
public void removeListener(Tree.CollapseListener listener)
Deprecated. As of 7.0, replaced by removeCollapseListener(CollapseListener)


fireCollapseEvent

protected void fireCollapseEvent(java.lang.Object itemId)
Emits collapse event.

Parameters:
itemId - the item id.

addActionHandler

public void addActionHandler(Action.Handler actionHandler)
Adds an action handler.

Specified by:
addActionHandler in interface Action.Container
Parameters:
actionHandler - the new handler to be added.
See Also:
Action.Container.addActionHandler(Action.Handler)

removeActionHandler

public void removeActionHandler(Action.Handler actionHandler)
Removes an action handler.

Specified by:
removeActionHandler in interface Action.Container
Parameters:
actionHandler - the handler to be removed.
See Also:
Action.Container.removeActionHandler(Action.Handler)

removeAllActionHandlers

public void removeAllActionHandlers()
Removes all action handlers


getVisibleItemIds

public java.util.Collection<?> getVisibleItemIds()
Gets the visible item ids.

Overrides:
getVisibleItemIds in class AbstractSelect
See Also:
AbstractSelect.getVisibleItemIds()

setNullSelectionItemId

public void setNullSelectionItemId(java.lang.Object nullSelectionItemId)
                            throws java.lang.UnsupportedOperationException
Tree does not support setNullSelectionItemId.

Overrides:
setNullSelectionItemId in class AbstractSelect
Parameters:
nullSelectionItemId - the nullSelectionItemId to set.
Throws:
java.lang.UnsupportedOperationException
See Also:
AbstractSelect.setNullSelectionItemId(java.lang.Object)

setNewItemsAllowed

public void setNewItemsAllowed(boolean allowNewOptions)
                        throws java.lang.UnsupportedOperationException
Adding new items is not supported.

Overrides:
setNewItemsAllowed in class AbstractSelect
Parameters:
allowNewOptions - the New value of property allowNewOptions.
Throws:
java.lang.UnsupportedOperationException - if set to true.
See Also:
AbstractSelect.setNewItemsAllowed(boolean)

addItemClickListener

public void addItemClickListener(ItemClickEvent.ItemClickListener listener)
Description copied from interface: ItemClickEvent.ItemClickNotifier
Register a listener to handle ItemClickEvents.

Specified by:
addItemClickListener in interface ItemClickEvent.ItemClickNotifier
Parameters:
listener - ItemClickListener to be registered

addListener

@Deprecated
public void addListener(ItemClickEvent.ItemClickListener listener)
Deprecated. As of 7.0, replaced by #addItemClickListener(ItemClickListener)

Specified by:
addListener in interface ItemClickEvent.ItemClickNotifier

removeItemClickListener

public void removeItemClickListener(ItemClickEvent.ItemClickListener listener)
Description copied from interface: ItemClickEvent.ItemClickNotifier
Removes an ItemClickListener.

Specified by:
removeItemClickListener in interface ItemClickEvent.ItemClickNotifier
Parameters:
listener - ItemClickListener to be removed

removeListener

@Deprecated
public void removeListener(ItemClickEvent.ItemClickListener listener)
Deprecated. As of 7.0, replaced by #removeItemClickListener(ItemClickListener)

Specified by:
removeListener in interface ItemClickEvent.ItemClickNotifier

setItemStyleGenerator

public void setItemStyleGenerator(Tree.ItemStyleGenerator itemStyleGenerator)
Sets the Tree.ItemStyleGenerator to be used with this tree.

Parameters:
itemStyleGenerator - item style generator or null to remove generator

getItemStyleGenerator

public Tree.ItemStyleGenerator getItemStyleGenerator()
Returns:
the current Tree.ItemStyleGenerator for this tree. Null if Tree.ItemStyleGenerator is not set.

removeItem

public boolean removeItem(java.lang.Object itemId)
                   throws java.lang.UnsupportedOperationException
Description copied from interface: Container
Removes the Item identified by ItemId from the Container.

Containers that support filtering should also allow removing an item that is currently filtered out.

This functionality is optional.

Specified by:
removeItem in interface Container
Specified by:
removeItem in interface Container.Hierarchical
Overrides:
removeItem in class AbstractSelect
Parameters:
itemId - ID of the Item to remove
Returns:
true if the operation succeeded, false if not
Throws:
java.lang.UnsupportedOperationException - if the container does not support removing individual items

getDropHandler

public DropHandler getDropHandler()
Specified by:
getDropHandler in interface DropTarget
Returns:
the drop hanler that will receive the dragged data or null if drops are not currently accepted

setDropHandler

public void setDropHandler(DropHandler dropHandler)

translateDropTargetDetails

public Tree.TreeTargetDetails translateDropTargetDetails(java.util.Map<java.lang.String,java.lang.Object> clientVariables)
Description copied from interface: DropTarget
Called before the DragAndDropEvent is passed to DropHandler. Implementation may for example translate the drop target details provided by the client side (drop target) to meaningful server side values. If null is returned the terminal implementation will automatically create a TargetDetails with raw client side data.

Specified by:
translateDropTargetDetails in interface DropTarget
Parameters:
clientVariables - data passed from the DropTargets client side counterpart.
Returns:
A DropTargetDetails object with the translated data or null to use a default implementation.
See Also:
DragSource.getTransferable(Map)

setDragMode

public void setDragMode(Tree.TreeDragMode dragMode)
Sets the drag mode that controls how Tree behaves as a DragSource .

Parameters:
dragMode -

getDragMode

public Tree.TreeDragMode getDragMode()
Returns:
the drag mode that controls how Tree behaves as a DragSource.
See Also:
Tree.TreeDragMode

getTransferable

public Transferable getTransferable(java.util.Map<java.lang.String,java.lang.Object> payload)
Description copied from interface: DragSource
DragSource may convert data added by client side component to meaningful values for server side developer or add other data based on it.

For example Tree converts item identifiers to generated string keys for the client side. Vaadin developer don't and can't know anything about these generated keys, only about item identifiers. When tree node is dragged client puts that key to Transferables client side counterpart. In getTransferable(Map) the key is converted back to item identifier that the server side developer can use.

Specified by:
getTransferable in interface DragSource
Parameters:
payload - the data that client side initially included in Transferables client side counterpart.
Returns:
the Transferable instance that will be passed to DropHandler (and/or AcceptCriterion)

setItemDescriptionGenerator

public void setItemDescriptionGenerator(AbstractSelect.ItemDescriptionGenerator generator)
Set the item description generator which generates tooltips for the tree items

Parameters:
generator - The generator to use or null to disable

getItemDescriptionGenerator

public AbstractSelect.ItemDescriptionGenerator getItemDescriptionGenerator()
Get the item description generator which generates tooltips for tree items


readItem

protected java.lang.String readItem(org.jsoup.nodes.Element node,
                                    java.util.Set<java.lang.String> selected,
                                    DesignContext context)
Reads an Item from a design and inserts it into the data source. Recursively handles any children of the item as well.

Overrides:
readItem in class AbstractSelect
Parameters:
node - an element representing the item (tree node).
selected - A set accumulating selected items. If the item that is read is marked as selected, its item id should be added to this set.
context - the DesignContext instance used in parsing
Returns:
the item id of the new item
Throws:
DesignException - if the tag name of the node element is not node.
Since:
7.5.0

writeItems

protected void writeItems(org.jsoup.nodes.Element design,
                          DesignContext context)
Recursively writes the root items and their children to a design.

Overrides:
writeItems in class AbstractSelect
Parameters:
design - the element into which to insert the items
context - the DesignContext instance used in writing
Since:
7.5.0

writeItem

protected org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element design,
                                            java.lang.Object itemId,
                                            DesignContext context)
Recursively writes a data source Item and its children to a design.

Overrides:
writeItem in class AbstractSelect
Parameters:
design - the element into which to insert the item
itemId - the id of the item to write
context - the DesignContext instance used in writing
Returns:
Since:
7.5.0


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.