eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'TreeItem':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: TreeItem


Inheritance:

   Object
   |
   +--TreeItem
      |
      +--FileSelectionItem
      |
      +--TreeItemWithImage

Package:
stx:libwidg2
Category:
Interface-Support
Version:
rev: 1.66 date: 2019/06/28 07:22:40
user: cg
file: TreeItem.st directory: libwidg2
module: stx stc-classLibrary: libwidg2
Author:
W. Olberding
Claus Atzkern

Description:


THIS CLASS HAS BEEN OBSOLETED by HierarchicalItem with its corresponding
view class HierarchicalListView. Please use these new ones.

Class to build up tree-like structures to represent file-trees, class tress etc.
Especially suited for use with (also now obsolete) SelectionInTree and SelectionInTreeView.


Related information:

    SelectionInTree
    SelectionInTreeView

Class protocol:

class initialization
o  initialize
self initialize

default icons
o  keysAndIcons
returns an IdentityDictionary containing a list of images and keys used
by any file entry; could be redefined by subclass

example-instance creation
o  newAsTreeFromNestedList: aListOfElementsOrSublists named: name
create a tree of nodes with fix elements from aListOfElementsOrSublists.
The tree will contain leafs for any non-collection elements in aListOfElementsOrSublists,
and sub-trees for 2-element array-elements.
Useful to be shown in long selection lists, if some grouping is possible

o  newAsTreeFromSmalltalkClass: aClass
create a tree of nodes with aClass and all its
subclasses as contents. Set the initial level as given.

instance creation
o  contents: aContents

o  name: aName

o  name: aName contents: aContents

o  name: aName value: aContents

o  new


Instance protocol:

accessing
o  contents
get the contents;
usually, the contents is computed lazily
i.e. #retrieveContents is invoked when the contents has not yet been set.

o  contents: something
set the contents

o  editor
returns an editor on the editable value or nil

o  hide
retrieve the hide flag

o  hide: aBoolean
set hide flag

o  icon
get the icon

o  label
for protocol compatibility with herarchical item

o  labelPath
for protocol compatibility with herarchical item

o  level
get the nesting level

o  middleButtonMenu
returns the middleButtonMenu of the item or nil

o  name
get name

o  name: aString

o  parent
get parent

o  parent: something
set parent

o  string

o  value
get contents

o  value: something
allow TreeItem to be used as a model

accessing-children
o  basicLastChild
returns the last child without checking for valid sequence

o  children
get list of children

o  children: aCollection
set children

o  firstChild
returns first child in sequence

o  lastChild
returns the last child in sequence

o  readChildren: aBoolean
set MUSTread children flag

accessing-dimensions
o  childrenWidthOn: aDevice
returns the maximum name length of my children

accessing-hierarchy
o  allParents
return a collection of all parents (in parent, grandparent, ... order)

o  collapse
hide all my children

o  collapseAll
hide all my children and sub children

o  expand
show all my children

o  expandAll
show all my children and sub children

o  parentsDo: aBlock
evaluate a block for each parent

accessing-mvc
o  model
get my model (an instance of selection in tree) or nil

o  model: aSelectionInTree
set my model (an instance of selection in tree) or nil

o  tree
get my model (an instance of selection in tree) or nil

o  tree: aSelectionInTree
set my model (an instance of selection in tree) or nil

adding & removing
o  add: something
add a child or collection of children add end

o  add: something after: aChild
add a child or collection of children add end

o  add: something afterIndex: anIndex
add a child or collection after an index

o  add: something before: aChild
add a child or collection of children add end

o  add: something beforeIndex: anIndex
add a child or collection before an index

o  addFirst: something
add a child at the beginning

o  remove: something
remove a child or collection of children

o  removeAll
remove all children

o  removeChild: aChild
remove a aChild

o  removeIndex: anIndex
remove child at index

change & update
o  changed
node changed; raise notification to model

o  changed: what
node changed; raise notification to model

o  changedSelected
called if the node is selected

o  update: something with: aParameter from: anItem
raise change notification to my model

converting
o  fromLiteralArrayEncoding: aLiteralEncodedArray
read my contents from a aLiteralEncodedArray.

o  literalArrayEncoding
return myself encoded as a literal array

copying
o  copy

enumerating
o  allChildrenDo: aOneArgBlock
recursively enumerate children
and evaluate a block on each child and subchildren

o  allWithParentAndChildrenDo: aTwoArgBlock

o  childrenDo: aOneArgBlock
evaluate a block on each child (excluding sub-children)

o  detectParent: aBlock
evaluate aBlock for my parent-chain;
return the parent for which it returns true

o  each: itemOrCollectionOfItems do: aOneArgBlock
evaluate a block for something or in case of a collection for each
element in the collection

initialization & release
o  initialize
setup defaults

printing & storing
o  asString
sometimes used by the SelectionInListView to get the name

o  displayOn: aGCOrStream
Compatibility
append a printed desription on some stream (Dolphin, Squeak)
OR:
display the receiver in a graphicsContext at 0@0 (ST80).
This method allows for any object to be displayed in some view
(although the fallBack is to display its printString ...)

o  printOn: aStream
sometimes used by the SelectionInListView to get the name

o  printString
sometimes used by the SelectionInListView to get the name

o  printableEditValue
returns the printable edit value or nil

queries
o  canEdit
returns true if field is editable

o  hasChildren
returns true if any child exists

o  hasChildrenWithSubChildren
returns true if any child exists and has children too

o  hasExpandedChildren
returns true if any of my children is expanded

o  hidden
returns true if node is not visible

o  isCollapsable
is collabsable; children existing and shown

o  isContainedByParent: aParent
returns true if contained in subtree of a parent

o  isExpandable
is expandable; children existing and hidden

o  isExpanded
return true if I am expanded

o  numberOfChildren
returns number of children

o  showIndicator
returns true if children exists

o  shown
returns true if node is visible

recomputation
o  addVisibleChildrenTo: aList
add all visible children and sub-children to the list

o  numberOfAllVisibleChildren
returns number of all visible children including all the children of children

retrieving
o  childrenAction
get children action block

o  contentsAction
get contents action block

o  iconAction
get icon action block

o  labelAction
get label action block

o  retrieveAll
retrieve all values from model

o  retrieveAndEvaluate: selectorToReturnABlockOrValueHolder
retrieve a specific value from the model;
if no model exists, nil is returned.

The model mist return a block or valueHolder,
which is evaluate with self as optopal argument.
So the model can compute icons, labels, etc. dynamically.

Typical selectors are:
#iconAction
#childrenAction
#contentsAction
#labelAction

o  retrieveChildren
retrieve children from model

o  retrieveContents
retrieve contents value from model;

o  retrieveLabel
retrieve label from model

searching
o  childAt: anIndex
get child at an index or nil

o  detectChild: aOneArgBlock
evaluate the block on each child;
returns the child's node or nil.
This searches my direct children only - not walking down sublevels.

o  detectChild: aTwoArgBlock arguments: args
detect a child the evaluation of the block returns true. The
first argument to the block is the item, the second argument
the value derived from the argument list at node-level ...
I.e. for each sublevel, a different block arg can be specified.
The number of arguments also defines the search level.
i.e. if you pass (1 to:10) as args, the block will get the sub-level
as second argument and stop the search after 10 levels.

o  detectFirstChild: anOneArgBlock
detect the first child which evaluation of anOneArgBlock returns true.
Recursively walks down the node-tree.

o  indexOfChild: aChild
get index of a child or 0

searching-private
o  detectChild: aTwoArgBlock arguments: args index: idxArgs
helper for limited search.
detect a child the evaluation of the block returns true. The
first argument to the block is the item, the second argument
the value derived from the argument list at an index.
This one recursively walks down the tree searching for a node.



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 16 Apr 2021 11:12:19 GMT