com.inmethod.grid.treegrid
Class TreeGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.html.panel.Panel
                  extended by com.inmethod.grid.common.AbstractGrid<T,I,S>
                      extended by com.inmethod.grid.treegrid.TreeGrid<T,I,S>
Type Parameters:
T - tree model object type
I - node model object type
All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IConverterLocator, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable

public class TreeGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
extends AbstractGrid<T,I,S>

Advanced grid with a tree. Supports resizable and reorderable columns.

Author:
Matej Knopp
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.inmethod.grid.common.AbstractGrid
CSS, INTERNAL_TOOLBAR_ITEM_ID, JS_DOM, JS_EVENT, JS_SCRIPT, JS_SCRIPT_JQ, JS_YAHOO, THEME_VISTA
 
Fields inherited from class org.apache.wicket.markup.html.panel.Panel
PANEL
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
TreeGrid(String id, IModel<T> model, List<IGridColumn<T,I,S>> columns)
          Creates a new TreeGrid instance.
TreeGrid(String id, T model, List<IGridColumn<T,I,S>> columns)
          Creates a new TreeGrid instance.
 
Method Summary
 WebMarkupContainer findParentRow(Component child)
          Returns the row in DataTable that contains the child component
protected  WebMarkupContainer findRowComponent(IModel<I> rowModel)
          Returns the row component for specified item.
 Collection<IModel<I>> getSelectedItems()
          Returns the collection of models of all currently selected items.
 AbstractTree getTree()
          Returns the inner tree of the TreeGrid.
 ITreeState getTreeState()
          Returns the tree state
 boolean isAllowSelectMultiple()
          Returns whether user will be able to select more than one item at a time.
 boolean isAutoSelectChildren()
          Returns whether children of selected nodes should be automatically treated as selected node.
 boolean isItemSelected(IModel<I> itemModel)
          Queries whether the item specified by itemModel is currently selected.
 void markItemDirty(IModel<I> model)
          Marks the item from the given model as dirty.
protected  void onJunctionLinkClicked(AjaxRequestTarget target, Object node)
          Callback function called after user clicked on an junction link.
 void resetSelectedItems()
          Deselects all items.
 void selectAllVisibleItems()
          Marks all currently displayed items as selected.
 void selectItem(IModel<I> itemModel, boolean selected)
          Alters the selection state of item specified by the item model.
 void setAllowSelectMultiple(boolean value)
          Sets whether user will be able to select more than one item.
 void setAutoSelectChildren(boolean autoSelectChildren)
          Sets whether children of selected node should automatically be treated as selected nodes (default true).
 void update()
          During Ajax request updates the changed parts of tree.
 
Methods inherited from class com.inmethod.grid.common.AbstractGrid
addBottomToolbar, addHeaderToolbar, addTopToolbar, cleanLastClickedColumn, columnSanityCheck, disableRowClickNotifications, getActiveColumns, getAllColumns, getColumnState, getContentHeight, getContentHeightSizeUnit, getForm, getLastClickedColumn, getSortState, getTheme, isClickRowToDeselect, isClickRowToSelect, isItemEdited, isSelectToEdit, isUseYui, onAfterRender, onBeforeRender, onCellClicked, onColumnStateChanged, onComponentTag, onInitialize, onItemSelectionChanged, onRowClicked, onRowPopulated, onSortStateChanged, renderHead, setClickRowToDeselect, setClickRowToSelect, setColumnState, setContentHeight, setItemEdit, setSelectToEdit, setTheme, setUseYui
 
Methods inherited from class org.apache.wicket.markup.html.panel.Panel
newMarkupSourcingStrategy
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebPage, getWebRequest, getWebResponse, getWebSession
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onConfigure, onDetach, onEvent, onModelChanged, onModelChanging, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeGrid

public TreeGrid(String id,
                IModel<T> model,
                List<IGridColumn<T,I,S>> columns)
Creates a new TreeGrid instance.

Parameters:
id - component id
model - model used to access the TreeModel
columns - list of IGridColumns.

TreeGrid

public TreeGrid(String id,
                T model,
                List<IGridColumn<T,I,S>> columns)
Creates a new TreeGrid instance.

Parameters:
id - component id
model - tree model
columns - list of IGridColumns.
Method Detail

getTree

public AbstractTree getTree()
Returns the inner tree of the TreeGrid.

Returns:
inner tree

getTreeState

public ITreeState getTreeState()
Returns the tree state

Returns:
tree state

update

public final void update()
During Ajax request updates the changed parts of tree.

Specified by:
update in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>

onJunctionLinkClicked

protected void onJunctionLinkClicked(AjaxRequestTarget target,
                                     Object node)
Callback function called after user clicked on an junction link. The node has already been expanded/collapsed (depending on previous status).

Parameters:
target - Request target - may be null on non-ajax call
node - Node for which this callback is relevant

getSelectedItems

public Collection<IModel<I>> getSelectedItems()
Returns the collection of models of all currently selected items.

Specified by:
getSelectedItems in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Returns:
collection of models of currently selected items

isAllowSelectMultiple

public boolean isAllowSelectMultiple()
Returns whether user will be able to select more than one item at a time.

Specified by:
isAllowSelectMultiple in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Returns:
true if multiple items can be selected at a time, false otherwise.

setAllowSelectMultiple

public void setAllowSelectMultiple(boolean value)
Sets whether user will be able to select more than one item.

Specified by:
setAllowSelectMultiple in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Parameters:
value - true if the user will be able to select more than one item at a time, false otherwise (single selection mode).

isItemSelected

public boolean isItemSelected(IModel<I> itemModel)
Queries whether the item specified by itemModel is currently selected.

Specified by:
isItemSelected in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Parameters:
itemModel - item model
Returns:
true if the item is selected, false otherwise

resetSelectedItems

public void resetSelectedItems()
Deselects all items. This method marks all items (not just visible items) as no selected.

Specified by:
resetSelectedItems in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>

selectAllVisibleItems

public void selectAllVisibleItems()
Marks all currently displayed items as selected. For DataGrid this selects all items on current page, for TreeGrid this selects all currently visible nodes.

Specified by:
selectAllVisibleItems in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>

findRowComponent

protected WebMarkupContainer findRowComponent(IModel<I> rowModel)
Description copied from class: AbstractGrid
Returns the row component for specified item.

Specified by:
findRowComponent in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Returns:

markItemDirty

public void markItemDirty(IModel<I> model)
Description copied from class: AbstractGrid
Marks the item from the given model as dirty. Dirty items are updated during Ajax requests when AbstractGrid.update() method is called.

Specified by:
markItemDirty in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Parameters:
model - model used to access the item

selectItem

public void selectItem(IModel<I> itemModel,
                       boolean selected)
Alters the selection state of item specified by the item model.

Specified by:
selectItem in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Parameters:
itemModel - item model
selected - true if the item should be selected, false otherwise.

findParentRow

public WebMarkupContainer findParentRow(Component child)
Description copied from class: AbstractGrid
Returns the row in DataTable that contains the child component

Specified by:
findParentRow in class AbstractGrid<T extends TreeModel & Serializable,I extends TreeNode & Serializable,S>
Returns:

setAutoSelectChildren

public void setAutoSelectChildren(boolean autoSelectChildren)
Sets whether children of selected node should automatically be treated as selected nodes (default true). Such children can not be deselected individually. Also ITreeState.isNodeSelected(Object) returns true if any of node parent is selected. On the contrary, ITreeState.getSelectedNodes() only returns "top level" selected nodes.

Parameters:
autoSelectChildren -

isAutoSelectChildren

public boolean isAutoSelectChildren()
Returns whether children of selected nodes should be automatically treated as selected node.

Returns:


Copyright © 2007–2014 inMethod s.r.o.. All rights reserved.