JIDE 3.5.15

com.jidesoft.grid
Class AbstractExpandable

java.lang.Object
  extended by com.jidesoft.grid.AbstractNode
      extended by com.jidesoft.grid.AbstractExpandable
All Implemented Interfaces:
Expandable, Node
Direct Known Subclasses:
AbstractExpandableRow, DefaultExpandable

public abstract class AbstractExpandable
extends AbstractNode
implements Expandable

An abstract implementation of Expandable.


Field Summary
protected  boolean _expandable
           
protected  boolean _expanded
          Used internally to keep track of if the property is expanded.
 
Fields inherited from class com.jidesoft.grid.AbstractNode
_parent, PROPERTY_PARENT
 
Fields inherited from interface com.jidesoft.grid.Expandable
PROPERTY_EXPANDABLE, PROPERTY_EXPANDED
 
Fields inherited from interface com.jidesoft.grid.Node
PROPERTY_ADJUSTING
 
Constructor Summary
AbstractExpandable()
          Constructs an AbstractExpandable.
 
Method Summary
 Object addChild(int index, Object child)
          Adds a child.
 Object addChild(Object child)
          Adds a child.
 void addChildren(int index, List<? extends Row> children)
          Adds a list of children.
 int getAllChildrenCount(boolean leafOnly)
          Gets all children count.
 int getAllVisibleChildrenCount()
          Deprecated. please use TableModelWrapperUtils.getVisibleChildrenCount(TableModel, ROW) instead to get visible children count
 Object getChildAt(int index)
          Gets the child at the specified index.
 int getChildIndex(Object child)
          Gets the child at the specified index.
 int getChildrenCount()
          Gets children count.
 int getNumberOfVisibleChildren()
          Gets the number of visible immediate children of this expandable.
 int getNumberOfVisibleExpandable()
          Gets the number of visible descendants of this expandable.
 TreeTableModel getTreeTableModel()
           
 boolean hasChildren()
          Returns true if this expandable has any children.
 boolean hasVisibleChildren()
          Gets the number of visible immediate children of this expandable.
 boolean isAdjusting()
           
 boolean isExpandable()
          Checks if it is expandable.
 boolean isExpanded()
          Is this expandable expanded.
 boolean moveDownChild(Object child)
          Moves down the child in the children list.
 boolean moveUpChild(Object child)
          Moves up the child in the children list.
 void notifyChildDeleted(Object child)
          Notifies a child is deleted.
 void notifyChildInserted(Object child, int childIndex)
          Notifies the child is inserted as the specified index of this expandable.
 void notifyChildrenDeleted(List<? extends Row> children)
          Notifies the children are deleted.
 void notifyChildrenInserted(List children, int firstIndex)
          Notifies the children are inserted as the specified index arrange of this expandable.
 void notifyChildrenUpdated(List<? extends Row> children)
          Notifies the children are updated.
 void notifyChildUpdated(Object child)
          Notifies the child is updated.
 void removeAllChildren()
          Removes all children from this expandable.
 boolean removeChild(Object child)
          Removes a child.
 boolean removeChildren(List<? extends Row> children)
          Removes children from the list of children.
 void setAdjusting(boolean adjusting)
           
 void setExpandable(boolean expandable)
          Sets the expandable attribute.
 void setExpanded(boolean expanded)
          Makes the children expanded.
 
Methods inherited from class com.jidesoft.grid.AbstractNode
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getLevel, getNextSibling, getParent, getPreviousSibling, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jidesoft.grid.Expandable
getChildren, setChildren
 
Methods inherited from interface com.jidesoft.grid.Node
getLevel, getNextSibling, getParent, getPreviousSibling, setParent
 

Field Detail

_expanded

protected boolean _expanded
Used internally to keep track of if the property is expanded.


_expandable

protected boolean _expandable
Constructor Detail

AbstractExpandable

public AbstractExpandable()
Constructs an AbstractExpandable.

Method Detail

isExpanded

public boolean isExpanded()
Is this expandable expanded.

Specified by:
isExpanded in interface Expandable
Returns:
expanded

setExpanded

public void setExpanded(boolean expanded)
Makes the children expanded.

Please note this method will not notify the TreeTableModel. So it'd better to use TreeTableModel.expandRow(ExpandableRow, boolean) method to expand a row than using this method.

Specified by:
setExpanded in interface Expandable
Parameters:
expanded - true to expand the node. False to collapse it.

isExpandable

public boolean isExpandable()
Description copied from interface: Expandable
Checks if it is expandable. If it's not expandable, the expand icon should be grayed out.

Specified by:
isExpandable in interface Expandable
Returns:
true if it is expandable

setExpandable

public void setExpandable(boolean expandable)
Description copied from interface: Expandable
Sets the expandable attribute.

Specified by:
setExpandable in interface Expandable
Parameters:
expandable - true or false.

hasChildren

public boolean hasChildren()
Returns true if this expandable has any children.

Specified by:
hasChildren in interface Expandable
Returns:
true if this expandable has any children

removeAllChildren

public void removeAllChildren()
Removes all children from this expandable.

Specified by:
removeAllChildren in interface Expandable

getNumberOfVisibleExpandable

public int getNumberOfVisibleExpandable()
Gets the number of visible descendants of this expandable. The number is actually include itself. So if this expandable has no child, it will return 1.

Specified by:
getNumberOfVisibleExpandable in interface Expandable
Returns:
number of visible expandable.

getNumberOfVisibleChildren

public int getNumberOfVisibleChildren()
Gets the number of visible immediate children of this expandable. The number doesn't include itself. If it has no visible children, it will return 0.

Returns:
the number of visible immediate children.

hasVisibleChildren

public boolean hasVisibleChildren()
Gets the number of visible immediate children of this expandable. The number doesn't include itself. If it has no visible children, it will return 0.

Returns:
the number of visible immediate children.

getChildrenCount

public int getChildrenCount()
Gets children count.

Specified by:
getChildrenCount in interface Expandable
Returns:
the children count

getAllVisibleChildrenCount

@Deprecated
public int getAllVisibleChildrenCount()
Deprecated. please use TableModelWrapperUtils.getVisibleChildrenCount(TableModel, ROW) instead to get visible children count

Gets children count after filtering.

Specified by:
getAllVisibleChildrenCount in interface Expandable
Returns:
the children count after filtering

getAllChildrenCount

public int getAllChildrenCount(boolean leafOnly)
Gets all children count. It will include all its children, grand-children etc. You can use this method to get the number of children of the parent so that you can display it somewhere in the UI. Of course, you need to be careful when using this method. If there are unlimited number of children due to recursively definition, you should never call this method.

Parameters:
leafOnly - if true, the children count will only includes the leaf node. Otherwise, all nodes will be included in the count.
Returns:
the children count

addChild

public Object addChild(Object child)
Adds a child.

Specified by:
addChild in interface Expandable
Parameters:
child - the child to be added.
Returns:
the child just added.

addChild

public Object addChild(int index,
                       Object child)
Adds a child.

Specified by:
addChild in interface Expandable
Parameters:
index - the index where the child to be inserted.
child - the child to be added.
Returns:
the child just added.

addChildren

public void addChildren(int index,
                        List<? extends Row> children)
Adds a list of children.

Specified by:
addChildren in interface Expandable
Parameters:
index - the index where the children to be inserted.
children - the children to be added.

removeChild

public boolean removeChild(Object child)
Removes a child.

Specified by:
removeChild in interface Expandable
Parameters:
child - child to be removed.
Returns:
true if child is removed successfully. If the child doesn't exist in the children list, return false.

removeChildren

public boolean removeChildren(List<? extends Row> children)
Description copied from interface: Expandable
Removes children from the list of children.

It's not correct if you invoke this method without creating a new list. For example, the following line is incorrect.

 removeChildren(getChildren());
 
You would use the following line to remove all children.
 List children = getChildren();
 List cloneList = new ArrayList();
 cloneList.addAll(children);
 removeChildren(cloneList);
 

Specified by:
removeChildren in interface Expandable
Parameters:
children - the child to be removed.
Returns:
true if children are all removed. false if no element of the children exists at all.

getChildAt

public Object getChildAt(int index)
Gets the child at the specified index.

Specified by:
getChildAt in interface Expandable
Parameters:
index - the index.
Returns:
the child at the specified index. Null if the index is out of bounds.

getChildIndex

public int getChildIndex(Object child)
Gets the child at the specified index.

Specified by:
getChildIndex in interface Expandable
Parameters:
child - the child.
Returns:
the index of the child if it exists. Otherwise, return -1.

moveUpChild

public boolean moveUpChild(Object child)
Moves up the child in the children list.

Specified by:
moveUpChild in interface Expandable
Parameters:
child - the child to be moved up.
Returns:
true if the child is moved up. Otherwise false.

moveDownChild

public boolean moveDownChild(Object child)
Moves down the child in the children list.

Specified by:
moveDownChild in interface Expandable
Parameters:
child - the child to be moved down.
Returns:
true if the child is moved down. Otherwise false.

notifyChildInserted

public void notifyChildInserted(Object child,
                                int childIndex)
Description copied from interface: Expandable
Notifies the child is inserted as the specified index of this expandable.

Specified by:
notifyChildInserted in interface Expandable
Parameters:
child - the child which is inserted.
childIndex - the index where it is inserted. -1 if the child is inserted as the last one.

notifyChildrenInserted

public void notifyChildrenInserted(List children,
                                   int firstIndex)
Description copied from interface: Expandable
Notifies the children are inserted as the specified index arrange of this expandable.

Specified by:
notifyChildrenInserted in interface Expandable
Parameters:
children - the children which are inserted.
firstIndex - the first index where it is inserted.

notifyChildDeleted

public void notifyChildDeleted(Object child)
Description copied from interface: Expandable
Notifies a child is deleted.

Specified by:
notifyChildDeleted in interface Expandable
Parameters:
child - the child that is deleted

notifyChildrenDeleted

public void notifyChildrenDeleted(List<? extends Row> children)
Description copied from interface: Expandable
Notifies the children are deleted.

Specified by:
notifyChildrenDeleted in interface Expandable
Parameters:
children - the children that are deleted

notifyChildUpdated

public void notifyChildUpdated(Object child)
Description copied from interface: Expandable
Notifies the child is updated.

Specified by:
notifyChildUpdated in interface Expandable
Parameters:
child - the child which is updated

notifyChildrenUpdated

public void notifyChildrenUpdated(List<? extends Row> children)
Description copied from interface: Expandable
Notifies the children are updated.

Specified by:
notifyChildrenUpdated in interface Expandable
Parameters:
children - the children which are updated

getTreeTableModel

public TreeTableModel getTreeTableModel()

isAdjusting

public boolean isAdjusting()

setAdjusting

public void setAdjusting(boolean adjusting)

JIDE 3.5.15