edge_app.ui.utils.tree_node_tools package¶
Submodules¶
edge_app.ui.utils.tree_node_tools.abstract_model_node module¶
-
class
edge_app.ui.utils.tree_node_tools.abstract_model_node.
AbstractModelNode
¶ Bases:
traits.has_traits.ABCHasStrictTraits
A base class to represent a node in a data model tree. It allows to create an arbitrary nested tree, aiming at wrapping MS platform domain objects such as FactNode, FactKind or Fact, to display them in a tree view (TreeEditor or DataView).
-
value
= Any()¶ The object represented by this node.
-
children
= List(Instance('AbstractModelNode'))¶ The child nodes of this node, if any.
-
name
= Property(Str)¶ A name to label this instance.
-
get_child
(value)¶ From a given value, returns the child node instance representing that value. If the object isn't present in the tree, returns None.
-
edge_app.ui.utils.tree_node_tools.data_model_nodes module¶
-
class
edge_app.ui.utils.tree_node_tools.data_model_nodes.
FactNodeModelNode
¶ Bases:
edge_app.ui.utils.tree_node_tools.abstract_model_node.AbstractModelNode
A node representing a FactNode object.
-
value
= Instance(FactNode)¶ The object represented by this node.
-
name
= Property(Str, depends_on='value')¶ A name to label this instance.
-
create_tree
(fact_kind_filter=<function FactNodeModelNode.<lambda>>)¶ Populates children of this node, and their children, to reproduce the tree structure represented by the FactNode < value >.
- Parameters
fact_kind_filter (callable) -- A function to filter FactKinds to be displayed in the tree. It should return False for FactKinds that should not be displayed.
-
-
class
edge_app.ui.utils.tree_node_tools.data_model_nodes.
FactKindModelNode
¶ Bases:
edge_app.ui.utils.tree_node_tools.abstract_model_node.AbstractModelNode
A node representing a FactKind object.
-
value
= Instance(FactKind)¶ The object represented by this node.
-
name
= Property(Str, depends_on='value')¶ A name to label this instance.
-
edge_app.ui.utils.tree_node_tools.data_model_tree_nodes module¶
-
class
edge_app.ui.utils.tree_node_tools.data_model_tree_nodes.
FactNodeModelTreeNode
(**traits)¶ Bases:
traitsui.tree_node.TreeNode
This class sets the behavior of a node corresponding to a FactNodeModelNode object.
-
node_for
= [FactNodeModelNode]¶ List of objects represented by this node.
-
children
= 'children'¶ Trait corresponding to the children of this node.
-
label
= 'name'¶ Trait corresponding to the label to use for this node.
-
auto_open
= True¶ Should this node be expanded automatically ?
-
add
= [FactNodeModelNode, FactKindModelNode]¶ List of objects appendable as children.
-
icon_path
= ICON_PATH¶ Path of the directory where icons are stored
-
icon_group
= ICONS.get('default_node')¶ Name of group item icon
Right-click context menu.
-
rename_me
= False¶ Can the object be renamed?
-
copy
= False¶ Can the children of that object be copied ?
-
delete_me
= False¶ Can the object be deleted ?
-
can_add
(object, add_object)¶ Returns whether a given object is droppable on the node.
-
get_icon
(object, is_expanded)¶ Sets icons to be used.
-
-
class
edge_app.ui.utils.tree_node_tools.data_model_tree_nodes.
FactKindModelTreeNode
(**traits)¶ Bases:
traitsui.tree_node.TreeNode
This class sets the behavior of a node corresponding to a FactKindModelNode object.
-
node_for
= [FactKindModelNode]¶ List of objects represented by this node.
-
label
= 'name'¶ Trait corresponding to the label to use for this node.
-
icon_path
= ICON_PATH¶ Path of the directory where icons are stored
-
icon_group
= ICONS.get('default_kind')¶ Name of group item icon
Right-click context menu.
-
rename_me
= False¶ Can the object be renamed?
-
copy
= False¶ Can the children of that object be copied ?
-
delete_me
= False¶ Can the object be deleted ?
-
can_add
(object, add_object)¶ Returns whether a given object is droppable on the node.
-
get_icon
(object, is_expanded)¶ Sets icons to be used.
-
edge_app.ui.utils.tree_node_tools.entity_kind_data_model module¶
-
class
edge_app.ui.utils.tree_node_tools.entity_kind_data_model.
NodeValue
¶ Bases:
pyface.data_view.value_types.text_value.TextValue
A value type that will display an icon for FactNode and FactKind instances in a tree representing an EntityKind.
-
has_image
(model, row_index, column_index)¶ Whether or not the value has an image associated with it.
The default implementation returns True if
get_image
returns a non-None value.- Parameters
model (AbstractDataModel) -- The data model holding the data.
row_index (sequence of int) -- The row in the data model being queried.
column_index (sequence of int) -- The column in the data model being queried.
- Returns
has_image -- Whether or not the value has an image associated with it.
- Return type
bool
-
get_image
(model, row_index, column_index)¶ Returns the cross, tick or default icon, to be used in the nodes of the FactKind match tree in the Data Importer.
- Parameters
model (AbstractDataModel) -- The data model holding the data.
row_index (sequence of int) -- The row in the data model being queried.
column_index (sequence of int) -- The column in the data model being queried.
- Returns
image -- The image associated with the underlying value.
- Return type
IImageResource
-
-
class
edge_app.ui.utils.tree_node_tools.entity_kind_data_model.
EntityKindDataModel
¶ Bases:
pyface.data_view.abstract_data_model.AbstractDataModel
A Data Model ready to use to render a list of EntityKinds' data model using DataView.
-
root_nodes
= List(Instance(AbstractModelNode))¶ The list of ModelNode for the root nodes of each EntityKinds
-
column_headers
= Dict(Tuple, Str)¶ A dictionary mapping column indexes to column headers
-
highlighted_roots
= Bool(False)¶ Shall the root nodes be highlighted?
-
index_manager
= Instance(TupleIndexManager, args=())¶ An index manager for tree-like data structures
-
changed_root_nodes
(event)¶
-
get_column_count
()¶ How many columns in the data view model.
- Returns
column_count -- The number of columns that the data view provides. This count should not include the row header.
- Return type
non-negative int
-
can_have_children
(row_index)¶ Whether or not a row can have child rows. FactNodes can have child rows, FactKinds cannot. The root row should always return True.
- Parameters
row_index (sequence of int) -- The indices of the row as a sequence from root to leaf.
- Returns
Whether or not the row can ever have child rows.
- Return type
bool
-
get_row_count
(row_index)¶ How many child rows the row currently has.
- Parameters
row_index (sequence of int) -- The indices of the row as a sequence from root to leaf.
- Returns
The number of child rows that the row has.
- Return type
non-negative int
-
get_value
(row_index, column_index)¶ Returns the Python value for the row and column. The values for column headers are returned by calling this method with row equal to (). The values for row headers are returned by calling this method with column equal to ().
- Parameters
row_index (sequence of int) -- The indices of the row as a sequence from root to leaf.
column_index (sequence of int) -- The indices of the column as a sequence of length 0 or 1.
- Returns
The value represented by the given row and column.
- Return type
any
-
get_value_type
(row_index, column_index)¶ Returns the value type of the given row and column. The value type for column headers are returned by calling this method with row equal to (). The value types for row headers are returned by calling this method with column equal to ().
- Parameters
row_index (sequence of int) -- The indices of the row as a sequence from root to leaf.
column_index (sequence of int) -- The indices of the column as a sequence of length 0 or 1.
- Returns
The value type of the given row and column, or None if no value should be displayed.
- Return type
AbstractValueType or None
-
get_row_by_index
(row_index)¶ Returns the ModelNode instance represented by the currently selected row.
- Parameters
row_index (sequence of int) -- The indices of the row as a sequence from root to leaf.
- Returns
row -- The ModelNode instance represented by the selected row.
- Return type
ModelNode
-
get_row_index_for_item
(item)¶ Returns the row index for a specified item, if found.
- Parameters
item (FactNode/FactKind) -- The item to search for within this EntityKindDataModel. Returns the index of an AbstractModelNode whose value attribute is item.
- Returns
row_index -- The indices of the row as a sequence from root to leaf. Returns None if the item is not found.
- Return type
tuple(int) or None
-