Package com.simplicite.util
Class TreeView
- java.lang.Object
-
- com.simplicite.util.TreeView
-
- All Implemented Interfaces:
java.io.Serializable
public class TreeView extends java.lang.Object implements java.io.Serializable
TreeView definition per user session- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TreeView.TreeViewNode
Node definition
-
Field Summary
Fields Modifier and Type Field Description static int
ITEM_ACTION
Actionstatic int
ITEM_EXTERNAL
External pagestatic int
ITEM_NEXT
Next list pagestatic int
ITEM_OBJECT
Object liststatic int
ITEM_PREVIOUS
Previous list pagestatic int
ITEM_PROCESS
Process startstatic int
ITEM_ROOT
Tree rootstatic int
ITEM_ROWLEAF
Object record without childstatic int
ITEM_ROWTREE
Object record with childrenstatic int
ITEM_SHORTCUT
Short cutstatic int
MODE_AUTO_FULL
Automatic mode (full)static int
MODE_AUTO_LINKSONLY
Automatic mode (links only)static int
MODE_MANUAL
Manual mode
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRootObject(java.lang.String obj)
Add object to the tree rootvoid
addUserMenu(java.lang.String object, java.lang.String id)
Store user preference MENU_TREEVIEW = [{ treeview, object, rowid }]void
delUserMenu(java.lang.String object, java.lang.String id)
Remove menu preference MENU_TREEVIEW = [{ treeview, object, rowid }]java.lang.String
getDisplay()
Get the treeview display labelorg.json.JSONArray
getHistory(Grant g)
Get the TREEVIEW_PREFS as a JSON arrayjava.lang.String
getId()
Get the treeview IDint
getMode()
Get modejava.lang.String
getName()
Get the treeview namejava.util.List<java.lang.String>
getObjects()
Get objects in tree definition (to limit index search)TreeView.TreeViewNode
getRoot()
Get the root nodeTreeView.TreeViewNode
getRootObject(java.lang.String obj)
Search object node in root onlyjava.util.List<java.lang.String>
getRootObjectNames()
Get objects on the tree rootTreeView.TreeViewNode
getTreeObject(java.lang.String obj)
Deep node search matching objectTreeView.TreeViewNode
getTreeObject(java.lang.String obj, TreeView.TreeViewNode root)
Deep node search matching objectstatic java.lang.String
getUserMenu(Grant g)
Get user preference MENU_TREEVIEW = [{ treeview, object, rowid }]java.lang.String
importJSON(org.json.JSONObject json, ObjectDB obj)
Import the JSON tree as an XML importboolean
isDynamic()
Is dynamic: mode is not TreeView.MODE_MANUALjava.lang.String
jsonPage(java.lang.String parent, java.lang.String rowId, java.lang.String child, int page)
Search a page for UI service (stateless)static java.lang.String
jsonReflexiveTree(ObjectDB obj, java.util.List<java.lang.String[]> rows, java.lang.String fk, int treeDepth, Parameters.InlineParam inlines, int context, Parameters.ContextParam params, boolean metadata, boolean timestamp, boolean visibleOnly, java.lang.String edit)
Build the reflexive object tree (for search service)void
removeId(java.lang.String id)
Remove IDTreeView.TreeViewNode
searchLevel(java.lang.String level)
Search levelvoid
setDisplay(java.lang.String label)
Set treeview display labelvoid
setMode(int mode)
Set modevoid
storeHistory(ObjectDB obj, int max)
Store the tree in user's preferences TREEVIEW_PREFSjava.lang.String
toJSON()
Treeview definition { id, name, mode, label, root: { node }}java.lang.String
toJSON(ObjectDB object, Parameters.InlineParam inlines, boolean metadata, TreeView.TreeViewNode node, int depth, boolean hist, java.lang.String path)
Get the tree from a root nodejava.lang.String
toJSON(TreeView.TreeViewNode node, ObjectDB obj, Parameters.InlineParam inlines, boolean metadata, int depth, boolean hist, java.lang.String path)
Export the object root as a JSON tree.java.lang.String
toString()
Get as string
-
-
-
Field Detail
-
ITEM_ROOT
public static final int ITEM_ROOT
Tree root- See Also:
- Constant Field Values
-
ITEM_OBJECT
public static final int ITEM_OBJECT
Object list- See Also:
- Constant Field Values
-
ITEM_ACTION
public static final int ITEM_ACTION
Action- See Also:
- Constant Field Values
-
ITEM_SHORTCUT
public static final int ITEM_SHORTCUT
Short cut- See Also:
- Constant Field Values
-
ITEM_EXTERNAL
public static final int ITEM_EXTERNAL
External page- See Also:
- Constant Field Values
-
ITEM_PROCESS
public static final int ITEM_PROCESS
Process start- See Also:
- Constant Field Values
-
ITEM_ROWLEAF
public static final int ITEM_ROWLEAF
Object record without child- See Also:
- Constant Field Values
-
ITEM_ROWTREE
public static final int ITEM_ROWTREE
Object record with children- See Also:
- Constant Field Values
-
ITEM_PREVIOUS
public static final int ITEM_PREVIOUS
Previous list page- See Also:
- Constant Field Values
-
ITEM_NEXT
public static final int ITEM_NEXT
Next list page- See Also:
- Constant Field Values
-
MODE_MANUAL
public static final int MODE_MANUAL
Manual mode- See Also:
- Constant Field Values
-
MODE_AUTO_FULL
public static final int MODE_AUTO_FULL
Automatic mode (full)- See Also:
- Constant Field Values
-
MODE_AUTO_LINKSONLY
public static final int MODE_AUTO_LINKSONLY
Automatic mode (links only)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TreeView
public TreeView(Grant g, java.lang.String id, java.lang.String name, int mode, java.lang.String display)
Constructor- Parameters:
g
- User rightsid
- Treeview idname
- Treeview namemode
- Treeview mode
-
-
Method Detail
-
getObjects
public java.util.List<java.lang.String> getObjects()
Get objects in tree definition (to limit index search)- Returns:
- Objects
-
getId
public java.lang.String getId()
Get the treeview ID- Returns:
- Treeview ID
-
getName
public java.lang.String getName()
Get the treeview name- Returns:
- treeview name
-
getRoot
public TreeView.TreeViewNode getRoot()
Get the root node- Returns:
- Root node
-
getDisplay
public java.lang.String getDisplay()
Get the treeview display label- Returns:
- Treeview display label
-
setDisplay
public void setDisplay(java.lang.String label)
Set treeview display label- Parameters:
label
- Treeview display label
-
getRootObjectNames
public java.util.List<java.lang.String> getRootObjectNames()
Get objects on the tree root- Returns:
- List of objects
-
addRootObject
public void addRootObject(java.lang.String obj)
Add object to the tree root- Parameters:
obj
- Object
-
setMode
public void setMode(int mode)
Set mode- Parameters:
mode
- Mode: one of TreeView.MODE_*
-
getMode
public int getMode()
Get mode- Returns:
- one of TreeView.MODE_*
-
isDynamic
public boolean isDynamic()
Is dynamic: mode is not TreeView.MODE_MANUAL- Returns:
- True if mod is dynamic
-
removeId
public void removeId(java.lang.String id)
Remove ID- Parameters:
id
- ID
-
searchLevel
public TreeView.TreeViewNode searchLevel(java.lang.String level)
Search level- Parameters:
level
- Level- Returns:
- Node
-
getRootObject
public TreeView.TreeViewNode getRootObject(java.lang.String obj)
Search object node in root only- Parameters:
obj
- Optional object name- Returns:
- Matching root or first root with object
-
getTreeObject
public TreeView.TreeViewNode getTreeObject(java.lang.String obj)
Deep node search matching object- Parameters:
obj
- Object- Returns:
- Node
-
getTreeObject
public TreeView.TreeViewNode getTreeObject(java.lang.String obj, TreeView.TreeViewNode root)
Deep node search matching object- Parameters:
obj
- Objectroot
- Root node- Returns:
- Node
-
getUserMenu
public static java.lang.String getUserMenu(Grant g)
Get user preference MENU_TREEVIEW = [{ treeview, object, rowid }]- Parameters:
g
- Grant
-
addUserMenu
public void addUserMenu(java.lang.String object, java.lang.String id)
Store user preference MENU_TREEVIEW = [{ treeview, object, rowid }]- Parameters:
object
- Objectid
- ID
-
delUserMenu
public void delUserMenu(java.lang.String object, java.lang.String id)
Remove menu preference MENU_TREEVIEW = [{ treeview, object, rowid }]- Parameters:
object
- Objectid
- ID
-
toJSON
public java.lang.String toJSON()
Treeview definition { id, name, mode, label, root: { node }}
-
jsonPage
public java.lang.String jsonPage(java.lang.String parent, java.lang.String rowId, java.lang.String child, int page)
Search a page for UI service (stateless)- Parameters:
parent
- ParentrowId
- Row IDchild
- Childpage
- Page- Returns:
- JSON
-
toJSON
public java.lang.String toJSON(ObjectDB object, Parameters.InlineParam inlines, boolean metadata, TreeView.TreeViewNode node, int depth, boolean hist, java.lang.String path)
Get the tree from a root node- Parameters:
object
- selected objectinlines
- inline documents|thumbs|objectsmetadata
- get metadatanode
- optional node (default is root object)depth
- depth of recursion (-1 = search all to leafs on manual tree)hist
- true to store the requested tree in the user's historypath
- optional sub-tree path- Returns:
- JSON
-
toJSON
public java.lang.String toJSON(TreeView.TreeViewNode node, ObjectDB obj, Parameters.InlineParam inlines, boolean metadata, int depth, boolean hist, java.lang.String path)
Export the object root as a JSON tree. Structure with all metadata:{ object: "myObject", // Node object name row_id: "123", // Object row ID item: { field1:"value", field2:"value", ... }, // record of the row_id userkey: "user key", // object user key label nid: "3", // node definition id level: 5, // node level (0=root) path: "obj:id/.../myObject:123" // node path from root object style: "tv-blue", // from optional getStyleTree hook image: "leaf", // from optional getImageTree hook links: [ { object: "childObject1", // child object name path: "obj:id/.../childObject1" // path from root object label: "child name", // object label count: 20, // children count page: 0, // current page (if pagination) maxpage: 3, // pages count (if pagination) icon: "cup", // object icon field: "foreignkey", // foreign key to parent object filters: { "foreignkey":"123" }, // filter to search children nolist: true, // to hide this list level = show only object items list: [ { object, row_id...}, ... ] // recursive }, ... ] }
- Parameters:
node
- Node definition in treeobj
- Related objectinlines
- Inlined infos (doc, image...)metadata
- Get tree metadatadepth
- Deep search limithist
- true to store the requested tree in the user's historypath
- optional sub-tree path- Returns:
- JSON
-
storeHistory
public void storeHistory(ObjectDB obj, int max)
Store the tree in user's preferences TREEVIEW_PREFS- Parameters:
obj
- Business object rootmax
- Max history size
-
getHistory
public org.json.JSONArray getHistory(Grant g)
Get the TREEVIEW_PREFS as a JSON array- Parameters:
g
- User rights
-
importJSON
public java.lang.String importJSON(org.json.JSONObject json, ObjectDB obj)
Import the JSON tree as an XML import- Parameters:
json
- JSON objectobj
- Optional root object- Returns:
- Import logs
-
toString
public java.lang.String toString()
Get as string- Overrides:
toString
in classjava.lang.Object
- Returns:
- String
-
jsonReflexiveTree
public static java.lang.String jsonReflexiveTree(ObjectDB obj, java.util.List<java.lang.String[]> rows, java.lang.String fk, int treeDepth, Parameters.InlineParam inlines, int context, Parameters.ContextParam params, boolean metadata, boolean timestamp, boolean visibleOnly, java.lang.String edit)
Build the reflexive object tree (for search service)- Parameters:
obj
- Root objectrows
- List of recordsfk
- Reflexive foreign-key nametreeDepth
- max level (-1 = deep search)- Returns:
- JSON tree of rows [{ data, meta, count, list:[...]}, ...]
-
-