public class TreeNodeCollectionResource extends HandleResource implements TreeNodeCollection, DynamicResource
Modifier and Type | Class and Description |
---|---|
(package private) static class |
TreeNodeCollectionResource.Location
Node relative location enum.
|
private static class |
TreeNodeCollectionResource.NodesIterator
Recursive nodes iterator.
|
Modifier and Type | Field and Description |
---|---|
private static int |
CHILD_NODE_RELATIONSHIP |
private static character |
DEFAULT_VALUE
Represents the default key and text values for a new created tree node.
|
private static int |
FIRST_NODE_RELATIONSHIP
The tree relationship constant used by TreeRelationshipConstants
|
private static int |
LAST_NODE_RELATIONSHIP |
protected static java.util.logging.Logger |
LOG
Logger
|
private static int |
NEXT_NODE_RELATIONSHIP |
(package private) java.util.LinkedList<TreeNodeResource> |
nodes
The nodes collection implementation.
|
private TreeNodeResource |
owner
The owning tree node.
|
private static int |
PREVIOUS_NODE_RELATIONSHIP |
private TreeWidgetBase |
tree
The owning tree.
|
instProc
Constructor and Description |
---|
TreeNodeCollectionResource(TreeWidgetBase tree,
TreeNodeResource owner)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) handle |
_addNodeImpl(TreeNodeResource relative,
TreeNodeCollectionResource.Location location,
character key,
character text,
boolean pushNodes)
Allocates new node and inserts it to the collection according to the
location argument. |
boolean |
_dynamic()
Returns
true if the buffer is dynamic. |
(package private) int |
_getCount()
Returns the count of the items in this collection.
|
(package private) TreeNodeResource |
_getNode(int index)
Returns the node at the specified index.
|
(package private) int |
_indexOf(TreeNodeResource node)
Returns the index of the supplied node.
|
(package private) void |
_removeNode(TreeNodeResource node,
java.util.Iterator<TreeNodeResource> it)
Recursively removes the specified node from the collection and the tree.
|
handle |
add()
Adds a new tree node as a last node relative to the root tree node.
|
handle |
add(NumberType anchorIndex,
NumberType relationType,
character key,
character text)
Adds a new tree node as a first, last, next, previous or child node relative to the anchor
node given by its index.
|
handle |
add(NumberType anchorIndex,
NumberType relationType,
character key,
character text,
NumberType nodeIcon,
NumberType selectedNodeIcon)
Adds a new tree node as a first, last, next, previous or child node relative to the anchor
node given by its index.
|
handle |
addChildNode(handle relativeNode,
character key,
character text)
Creates a new node and inserts it as the last child item relative to the supplied node.
|
handle |
addFirstNode(character key,
character text)
Creates a new node and inserts it as the first item in the collection.
|
handle |
addLastNode(character key,
character text)
Creates a new node and inserts it as the last item in the collection.
|
handle |
addNextNode(handle relativeNode,
character key,
character text)
Creates a new node and inserts it as the next item relative to the supplied node.
|
void |
clearNodes()
Removes all the nodes from the collection and all the child nodes recursively.
|
private TreeNodeResource |
createNode(java.lang.String key,
java.lang.String text,
TreeNodeResource parent)
Creates a new node and adds it to the end of the collection
|
void |
delete()
Perform actual delete of an resource.
|
logical |
dynamic()
Checks whether the resource is dynamic or static.
|
integer |
getCount()
Returns the count of all the items in this collection except the internal root node.
|
handle |
getItem(NumberType nodeIndex)
Returns the node at the specified index.
|
integer |
getNodeCount()
Returns the count of all the items in this collection.
|
handle |
getTreeNode(character key)
Returns the node of the specified key.
|
handle |
getTreeNode(NumberType index)
Returns the node at the specified index.
|
java.util.Iterator<TreeNodeResource> |
iterator()
Returns an iterator over elements of type
T . |
java.util.Iterator<TreeNodeResource> |
recursiveIterator(boolean visibleOnly)
Returns a recursive iterator.
|
void |
remove(BaseDataType nodeKeyOrIndex)
Removes the node with the specified key or index.
|
void |
removeNode(character key)
Removes the node at the specified key.
|
void |
removeNode(NumberType index)
Removes the node at the specified index.
|
protected boolean |
resourceDelete()
Worker to be implemented by each resource.
|
boolean |
valid()
Reports if this object is valid for use.
|
doDelete, getResourceType, id, id, implicitDeletion, incrementTrigger, instantiatingProcedure, invalidAttribute, processResource, readOnlyError, readOnlyError, registerResource, setInstantiatingProcedure, toString, type, unableToAssignUnknown, unknown
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
id, id, unknown
protected static final java.util.logging.Logger LOG
private static final character DEFAULT_VALUE
private static final int FIRST_NODE_RELATIONSHIP
private static final int LAST_NODE_RELATIONSHIP
private static final int NEXT_NODE_RELATIONSHIP
private static final int PREVIOUS_NODE_RELATIONSHIP
private static final int CHILD_NODE_RELATIONSHIP
java.util.LinkedList<TreeNodeResource> nodes
private TreeWidgetBase tree
private TreeNodeResource owner
public TreeNodeCollectionResource(TreeWidgetBase tree, TreeNodeResource owner)
tree
- The owning tree view.owner
- The owning node.public java.util.Iterator<TreeNodeResource> iterator()
T
.iterator
in interface java.lang.Iterable<TreeNodeResource>
public java.util.Iterator<TreeNodeResource> recursiveIterator(boolean visibleOnly)
visibleOnly
- When true
only visible and expanded nodes will be iterated, when false
all nodes will be iterated.public handle addFirstNode(character key, character text)
addFirstNode
in interface TreeNodeCollection
key
- The key of the new node.text
- The text of the new node.public handle addLastNode(character key, character text)
addLastNode
in interface TreeNodeCollection
key
- The key of the new node.text
- The text of the new node.public handle addNextNode(handle relativeNode, character key, character text)
addNextNode
in interface TreeNodeCollection
relativeNode
- The relative node, wrapped resource of the type TTreeNode
.key
- The key of the new node.text
- The text of the new node.public handle addChildNode(handle relativeNode, character key, character text)
addChildNode
in interface TreeNodeCollection
relativeNode
- The relative node, wrapped resource of the type TTreeNode
.key
- The key of the new node.text
- The text of the new node.public void removeNode(NumberType index)
removeNode
in interface RemoveNode
index
- A valid index.public void removeNode(character key)
removeNode
in interface TreeNodeCollection
key
- A valid node key.public void clearNodes()
clearNodes
in interface TreeNodeCollection
public integer getNodeCount()
getNodeCount
in interface TreeNodeCollection
public handle getTreeNode(NumberType index)
getTreeNode
in interface TreeNodeCollection
index
- A valid index.public handle getTreeNode(character key)
getTreeNode
in interface TreeNodeCollection
key
- A valid key.public handle getItem(NumberType nodeIndex)
getItem
in interface TreeNodeCollection
nodeIndex
- The node index.unknown
when the invalid index is provided.public void remove(BaseDataType nodeKeyOrIndex)
remove
in interface TreeNodeCollection
nodeKeyOrIndex
- either an integer node index, 1-based, or character node key.public boolean valid()
valid
in interface WrappedResource
true
if we are valid (can be used).public logical dynamic()
dynamic
in interface DynamicResource
true
if the resource is dynamic, false
otherwise.public boolean _dynamic()
true
if the buffer is dynamic.
This is not emitted by conversion, is used internally by FWD.
_dynamic
in interface DynamicResource
true
if the resource is dynamic, false
otherwise.public handle add()
add
in interface TreeNodeCollection
public handle add(NumberType anchorIndex, NumberType relationType, character key, character text)
add
in interface TreeNodeCollection
anchorIndex
- The anchor node index, 1-based indexrelationType
- The relation type: first(0), last(1), next(2), previous(3) and child(4)key
- The key of the new node, this key isn't a unique tree node key.text
- The label of the new nodepublic handle add(NumberType anchorIndex, NumberType relationType, character key, character text, NumberType nodeIcon, NumberType selectedNodeIcon)
add
in interface TreeNodeCollection
anchorIndex
- The anchor node indexrelationType
- The relation type: first(0), last(1), next(2), previous(3) and child(4)key
- The key of the new nodetext
- The label of the new nodenodeIcon
- The node icon index within its tree images list, 1-based indexselectedNodeIcon
- The expand node icon index within its tree images list, 1-based indexpublic void delete()
The method first calls resourceDelete()
, if the method returns false
, the deletion
is aborted.
delete
in interface Deletable
delete
in class HandleResource
public integer getCount()
getCount
in interface TreeNodeCollection
protected boolean resourceDelete()
delete()
.resourceDelete
in class HandleResource
true
if the resource was deleted.void _removeNode(TreeNodeResource node, java.util.Iterator<TreeNodeResource> it)
node
- A valid node.it
- Optional iterator. When set, use it to remove the item from its list.int _getCount()
int _indexOf(TreeNodeResource node)
node
- A valid node.TreeNodeResource _getNode(int index)
index
- 0-based index.java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size())handle _addNodeImpl(TreeNodeResource relative, TreeNodeCollectionResource.Location location, character key, character text, boolean pushNodes)
location
argument.relative
- Relative node, semantics based on the location
argument. The expected handle
resource type is TreeNodeResource
.location
- The location relative to relative
argument.key
- The unique node key to be assigned to the node.text
- Node text.pushNodes
- true
to push the model change to the client.TreeNodeResource
instance, or unknown if the operation fails.private TreeNodeResource createNode(java.lang.String key, java.lang.String text, TreeNodeResource parent)
key
- The key to be assigned to the node.text
- Node text.parent
- Node parent, must not be null
.java.lang.IllegalArgumentException
- when any of the arguments is null
java.lang.RuntimeException
- when the supplied key is not unique