|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjaxx.runtime.swing.nav.NavHelper<M,U,B,N>
U - Type of ui to bridgepublic abstract class NavHelper<M,U,B extends NavBridge<M,N>,N extends NavNode<M,N>>
Tree helper to deal with the build of trees and other usefull operations.
A helper acts as an handler for atree. It owns the getModel() of
the #tree.
Note: A helper can NOT be used to manage multi-trees.
createModel(NavNode, Object...) given a
root node.
To obtain the model, use method getModel().
Note: The helper internal model can be different from the tree model,
but must be the lowest model, other models must listen nicely this
model to obtain model modification and selection notifications.
setUI(Object, boolean, TreeSelectionListener).
To obtain the tree, use method getUI().
NavDataProvider.
To register the data provider, use method setDataProvider(NavDataProvider).
To obtain the data provider, use method getDataProvider().
expandListenerNavNode.isLoaded() method.
treeModelListenerpopulateNode(NavNode, Object[], boolean).
selectionListenercreateModel(NavNode, Object...)insertNode(NavNode, NavNode)removeNode(NavNode)moveNode(NavNode, NavNode, int)refreshNode(NavNode, boolean)loadAllNodes(NavNode, NavDataProvider)NavNodeChildLoador, use the method
getChildLoador(Class) to obtain the correct child loador given his type.
NavNode,
NavNodeChildLoador,
AbstractNavTreeCellRenderer| Field Summary | |
|---|---|
protected static Set<? super NavNodeChildLoador<?,?,?,?,?>> |
childLoadors
Cache of child loadors. |
protected NavDataProvider |
dataProvider
The shared data provider used to obtain datas to populate nodes and render them. |
protected TreeWillExpandListener |
expandListener
A TreeWillExpandListener used to listen when tree should expand. |
protected TreeSelectionListener |
selectionListener
pour ouvrir les fils d'un noeud que l'on vient de sélectionner pour éviter d'avoir à faire des doubles clics. |
protected TreeModelListener |
treeModelListener
pour recharger le rendu des noeuds (et charger les fils si nécessaires) lors d'une modification dans le modèle de l'arbre. |
| Constructor Summary | |
|---|---|
NavHelper(B bridge)
|
|
| Method Summary | ||
|---|---|---|
abstract void |
addSelectionPath(TreePath path)
|
|
abstract void |
addSelectionPaths(TreePath[] paths)
|
|
protected boolean |
checkModel()
Checks if internal model was created. |
|
protected abstract M |
createModel(N node,
Object... extraArgs)
Register a new root node. |
|
abstract void |
expandPath(TreePath pathToExpand)
|
|
N |
findNode(N node,
String... ids)
Finds a node from the given root node, applying the path given
by ids. |
|
protected B |
getBridge()
Obtains the bridge . |
|
N |
getChild(N node,
String id)
Finds a node from the given root node, and return child searched |
|
static
|
getChildLoador(Class<L> type)
Obtains the NavNodeChildLoador of the given type from
internal cache. |
|
protected static Set<? super NavNodeChildLoador<?,?,?,?,?>> |
getChildLoadors()
|
|
protected NavDataProvider |
getDataProvider()
Obtains the attached data provider used to populate and render nodes. |
|
M |
getModel()
Obtains the model. |
|
protected N |
getNode(TreePath path)
Convinient method to objet the casted node of a TreePath. |
|
N |
getRootNode()
|
|
String[] |
getSelectedIds()
Obtains the path of ids fro the root node to the selected node on the registred tree. |
|
abstract N |
getSelectedNode()
Obtains the selected node of the registred tree. |
|
abstract List<N> |
getSelectedNodes()
Obtains the selected nodes of the registred tree. |
|
abstract TreeSelectionModel |
getSelectionModel()
|
|
abstract AbstractNavTreeCellRenderer<M,N> |
getTreeCellRenderer()
Obtains the AbstractNavTreeCellRenderer renderer of the
registred tree. |
|
U |
getUI()
Obtains the ui associated with model in helper. |
|
void |
insertNode(N parentNode,
N newNode)
Inserts the given node to the given parentNode. |
|
void |
insertNode(N parentNode,
N newNode,
int position)
Inserts the given node to the given parentNode. |
|
abstract boolean |
isExpanded(TreePath pathToExpand)
|
|
void |
loadAllNodes(N node,
NavDataProvider dataProvider)
To load all nodes of a model. |
|
void |
moveNode(N parentNode,
N node,
int position)
Moves the given node to the new position. |
|
protected void |
populateNode(N node,
Object[] children,
boolean recurse)
Populates nodes. |
|
void |
refreshNode(N node,
boolean deep)
Refreshs the given node. |
|
N |
removeNode(N node)
Removes the given node from the registred tree model and returns
his parent. |
|
abstract void |
removeSelectionPath(TreePath path)
|
|
abstract void |
removeSelectionPaths(TreePath[] paths)
|
|
abstract void |
scrollPathToVisible(TreePath path)
|
|
void |
selectNode(N node)
Selects the given node in the registred tree. |
|
void |
selectNode(String... path)
Selects the node described by his given path of ids. |
|
void |
selectNodes(List<N> nodes)
Selects the given nodes in the registred tree. |
|
void |
selectParentNode()
Selects the parent of the currently selected node. |
|
void |
setDataProvider(NavDataProvider dataProvider)
Registers the dataProvider for the helper. |
|
abstract void |
setSelectionPath(TreePath path)
|
|
protected void |
setUI(U ui)
|
|
void |
setUI(U tree,
boolean addExpandTreeListener)
Registers the given tree for this helper. |
|
void |
setUI(U tree,
boolean addExpandTreeListener,
boolean addOneClickSelectionListener,
TreeSelectionListener listener)
Registers the given tree for this helper. |
|
abstract void |
setUI(U tree,
boolean addExpandTreeListener,
boolean addOneClickSelectionListener,
TreeSelectionListener listener,
TreeWillExpandListener willExpandListener)
Registers the given tree for this helper. |
|
void |
setUI(U tree,
boolean addExpandTreeListener,
TreeSelectionListener listener)
Registers the given tree for this helper. |
|
void |
unSelectNode(N node)
Unselects the given node in the registred tree. |
|
void |
unSelectNodes(List<N> nodes)
Selects the given nodes in the registred tree. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected NavDataProvider dataProvider
protected TreeWillExpandListener expandListener
TreeWillExpandListener used to listen when tree should expand.
If so, the listener will load selected node childs if required
(says when the NavNode.isLoaded() is sets to false).
protected TreeSelectionListener selectionListener
protected TreeModelListener treeModelListener
protected static Set<? super NavNodeChildLoador<?,?,?,?,?>> childLoadors
| Constructor Detail |
|---|
public NavHelper(B bridge)
| Method Detail |
|---|
public abstract void scrollPathToVisible(TreePath path)
public abstract void setSelectionPath(TreePath path)
public abstract void addSelectionPath(TreePath path)
public abstract void addSelectionPaths(TreePath[] paths)
public abstract void removeSelectionPath(TreePath path)
public abstract void removeSelectionPaths(TreePath[] paths)
public abstract TreeSelectionModel getSelectionModel()
public abstract boolean isExpanded(TreePath pathToExpand)
public abstract void expandPath(TreePath pathToExpand)
protected abstract M createModel(N node,
Object... extraArgs)
getModel() does not exists, creates a new one from
his given root node, otherwise just set the new root on the
existing model.
Note: As a side-effect, the model will be keep in field getModel()
and the treeModelListener will be registred on this model.
node - the root node of the new modelextraArgs - extra args to create initial model
public abstract AbstractNavTreeCellRenderer<M,N> getTreeCellRenderer()
AbstractNavTreeCellRenderer renderer of the
registred tree.
AbstractNavTreeCellRenderer.public abstract N getSelectedNode()
null if no registred tree nor
selection empty.public abstract List<N> getSelectedNodes()
null if no registred tree nor
selection empty.
public abstract void setUI(U tree,
boolean addExpandTreeListener,
boolean addOneClickSelectionListener,
TreeSelectionListener listener,
TreeWillExpandListener willExpandListener)
tree for this helper.
Note: as a side-effect, it will register (if required) the
expandListener listener and (if required) the
selectionListener.
Note : as a second side-effect, it will register the given willExpandListener (if not null)
for the ui and do it BEFORE the expandListener. The main
idea here is to be able to block any expand (or collapse).
tree - the tree to registeraddExpandTreeListener - a flag to add expand listeneraddOneClickSelectionListener - a flag to expend when selectionlistener - the optional selection listener to addwillExpandListener - the optional will expand listener to add BEFORE the default expand tree listener (if he was required)protected static Set<? super NavNodeChildLoador<?,?,?,?,?>> getChildLoadors()
public static <L extends NavNodeChildLoador<?,?,?,?,?>> L getChildLoador(Class<L> type)
NavNodeChildLoador of the given type from
internal cache.
Note: The loador will be instanciated if not found, and push in cache.
L - the type of loador to gettype - the type of loador to get
protected NavDataProvider getDataProvider()
public M getModel()
null if none was created.protected B getBridge()
public U getUI()
null if no ui attached)public N getRootNode()
public String[] getSelectedIds()
public void setUI(U tree,
boolean addExpandTreeListener)
tree for this helper.
Note: as a side-effect, it will register (if required) the
expandListener listener and the selectionListener.
tree - the tree to registeraddExpandTreeListener - a flag to add expand listener
public void setUI(U tree,
boolean addExpandTreeListener,
TreeSelectionListener listener)
tree for this helper.
Note: as a side-effect, it will register (if required) the
expandListener listener and the selectionListener.
tree - the tree to registeraddExpandTreeListener - a flag to add expand listenerlistener - the optional selection listener to add
public void setUI(U tree,
boolean addExpandTreeListener,
boolean addOneClickSelectionListener,
TreeSelectionListener listener)
tree for this helper.
Note: as a side-effect, it will register (if required) the
expandListener listener and (if required) the
selectionListener.
tree - the tree to registeraddExpandTreeListener - a flag to add expand listeneraddOneClickSelectionListener - a flag to expend when selectionlistener - the optional selection listener to addpublic void setDataProvider(NavDataProvider dataProvider)
dataProvider for the helper.
Node: As a side-effect, the provider will be propagate to the
renderer of the registred tree (if any).
dataProvider - the data provider to use
public void insertNode(N parentNode,
N newNode)
parentNode.
The node will be added to his parent, then creation listeners will be
fired.
parentNode - the parent node where to insert the new node *newNode - the node to insert
public void insertNode(N parentNode,
N newNode,
int position)
parentNode.
The node will be added to his parent, then creation listeners will be
fired.
parentNode - the parent node where to insert the new node *newNode - the node to insertposition - position of node is insertedpublic N removeNode(N node)
node from the registred tree model and returns
his parent.
node - the node to remove
public void moveNode(N parentNode,
N node,
int position)
node to the new position.
parentNode - the parent nodenode - the node to moveposition - the new position of the node
public void refreshNode(N node,
boolean deep)
node.
If flag deep is set to true, then it will refresh
recursively children nodes.
Note:As a side-effect, evvery node involved will become
dirty.
node - the node to refreshdeep - un flag pour activer la repainte de la descendance du
noeudNavNode.isDirty()
public void loadAllNodes(N node,
NavDataProvider dataProvider)
node - the root node to loaddataProvider - the data provider used to populate nodes
public void selectParentNode()
throws NullPointerException
NullPointerException - if selection is emptypublic void selectNode(N node)
node in the registred tree.
node - the node to selectpublic void selectNodes(List<N> nodes)
nodes in the registred tree.
nodes - the nodes to selectpublic void unSelectNode(N node)
node in the registred tree.
node - the node to selectpublic void unSelectNodes(List<N> nodes)
nodes in the registred tree.
nodes - the nodes to selectpublic void selectNode(String... path)
path of ids.
path - the absolute path of ids from root node to node to select.
public N findNode(N node,
String... ids)
node, applying the path given
by ids.
node - the starting nodeids - the path of ids to apply on the node.
null if no node matchs.
public N getChild(N node,
String id)
node, and return child searched
node - the starting nodeid - id of searched child
null if no node matchs.protected boolean checkModel()
true if model was created, false otherwise.
protected void populateNode(N node,
Object[] children,
boolean recurse)
node is not null, then populate it.
If children is not null, then populate them, moreover
if recurse is set to true then do a recurse refresh on
children.
node - the parent node to populate (optional)children - the child nodes to populate (optional)recurse - flag sets to true if should do recurse refresh on
given children nodes.protected N getNode(TreePath path)
TreePath.
path - the path contaning the node.
protected void setUI(U ui)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||