|
Class: TreeItem
Object
|
+--TreeItem
|
+--FileSelectionItem
|
+--TreeItemWithImage
- Package:
- stx:libwidg2
- Category:
- Interface-Support
- Version:
- rev:
1.73
date: 2023/09/07 21:39:17
- user: stefan
- file: TreeItem.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
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.
copyrightCOPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
class initialization
-
initialize
-
self initialize
default icons
-
keysAndIcons
-
returns an IdentityDictionary containing a list of images and keys used
by any file entry; could be redefined by subclass
example-instance creation
-
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
Usage example(s):
|top model sel root|
root := TreeItem
newAsTreeFromNestedList:
#(
'one-1'
'two-1'
('three...'
('three-1'
'three-2'
'three-3'))
'four-1'
('five...'
('five-1'
'five-2'
'five-3'
'five-4'
'five-5'))
('six...'
('six-1'
'six-2'
('six-3...'
('six-3-1'
'six-3-2'
'six-3-3'))
'six-4'
('six-5...'
('six-5-1'
'five-5-2'))
)
)
'seven-1'
).
root expand.
model := SelectionInTree new root:root.
top := StandardSystemView new.
top extent:300@300.
sel := SelectionInTreeView new.
sel showDirectoryIndicator:true.
sel showRoot:false.
sel imageOpened:nil.
sel imageClosed:nil.
sel imageItem:nil.
sel model: model.
sel action:[:nr | Transcript show:'selected:'; showCR:nr].
top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
top open.
|
-
newAsTreeFromSmalltalkClass: aClass
-
create a tree of nodes with aClass and all its
subclasses as contents. Set the initial level as given.
Usage example(s):
|top model sel root|
root := TreeItem newAsTreeFromSmalltalkClass:ByteArray.
root expand.
model := SelectionInTree new root:root.
top := StandardSystemView new.
top extent:300@300.
sel := SelectionInTreeView new.
sel model: model.
sel action:[:nr | Transcript show:'selected:'; showCR:nr].
top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
top open.
|
instance creation
-
contents: aContents
-
-
name: aName
-
-
name: aName contents: aContents
-
-
name: aName value: aContents
-
-
new
-
(comment from inherited method)
return an instance of myself without indexed variables
accessing
-
contents
-
get the contents;
usually, the contents is computed lazily
i.e. #retrieveContents is invoked when the contents has not yet been set.
-
contents: something
-
set the contents
-
editor
-
returns an editor on the editable value or nil
-
hide
-
retrieve the hide flag
-
hide: aBoolean
-
set hide flag
-
icon
-
get the icon
-
label
-
for protocol compatibility with herarchical item
-
labelPath
-
for protocol compatibility with hierarchical item
-
level
-
get the nesting level
-
middleButtonMenu
-
returns the middleButtonMenu of the item or nil
-
name
-
get name
-
name: aString
-
-
parent
-
get parent
-
parent: something
-
set parent
-
string
-
-
value
-
get contents
-
value: something
-
allow TreeItem to be used as a model
accessing-children
-
basicLastChild
-
returns the last child without checking for valid sequence
-
children
-
get list of children
-
children: aCollection
-
set children
-
firstChild
-
returns first child in sequence
-
lastChild
-
returns the last child in sequence
-
readChildren: aBoolean
-
set MUSTread children flag
accessing-dimensions
-
childrenWidthOn: aDevice
-
returns the maximum name length of my children
accessing-hierarchy
-
allParents
-
return a collection of all parents (in parent, grandparent, ... order)
-
collapse
-
hide all my children
-
collapseAll
-
hide all my children and sub children
-
expand
-
show all my children
-
expandAll
-
show all my children and sub children
-
parentsDo: aBlock
-
evaluate a block for each parent
accessing-mvc
-
model
-
get my model (an instance of selection in tree) or nil
-
model: aSelectionInTree
-
set my model (an instance of selection in tree) or nil
-
tree
-
get my model (an instance of selection in tree) or nil
-
tree: aSelectionInTree
-
set my model (an instance of selection in tree) or nil
adding & removing
-
add: something
-
add a child or collection of children add end
-
add: something after: aChild
-
add a child or collection of children add end
-
add: something afterIndex: anIndex
-
add a child or collection after an index
-
add: something before: aChild
-
add a child or collection of children add end
-
add: something beforeIndex: anIndex
-
add a child or collection before an index
-
addFirst: something
-
add a child at the beginning
-
remove: something
-
remove a child or collection of children
-
removeAll
-
remove all children
-
removeChild: aChild
-
remove a aChild
-
removeIndex: anIndex
-
remove child at index
change & update
-
changed
-
node changed; raise notification to model
-
changed: what
-
node changed; raise notification to model
-
changedSelected
-
called if the node is selected
-
update: something with: aParameter from: anItem
-
raise change notification to my model
converting
-
fromLiteralArrayEncoding: aLiteralEncodedArray
-
read my contents from a aLiteralEncodedArray.
-
literalArrayEncoding
-
return myself encoded as a literal array
copying
-
copy
-
(comment from inherited method)
return a copy of the receiver - defaults to shallowcopy here.
Notice, that copy does not copy dependents.
enumerating
-
allChildrenDo: aOneArgBlock
-
recursively enumerate children
and evaluate a block on each child and subchildren
-
allWithParentAndChildrenDo: aTwoArgBlock
-
-
childrenDo: aOneArgBlock
-
evaluate a block on each child (excluding sub-children)
-
detectParent: aBlock
-
evaluate aBlock for my parent-chain;
return the parent for which it returns true
-
each: itemOrCollectionOfItems do: aOneArgBlock
-
evaluate a block for something or in case of a collection for each
element in the collection
initialization & release
-
initialize
-
setup defaults
printing & storing
-
asString
-
sometimes used by the SelectionInListView to get the name
-
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 ...)
-
printOn: aStream
-
sometimes used by the SelectionInListView to get the name
-
printString
-
sometimes used by the SelectionInListView to get the name
-
printableEditValue
-
returns the printable edit value or nil
queries
-
canCollapse
-
children existing and shown?
-
canEdit
-
returns true if field is editable
-
canExpand
-
is expandable: children exist and not already expanded
-
hasChildren
-
returns true if any child exists
-
hasChildrenWithSubChildren
-
returns true if any child exists and has children too
-
hasExpandedChildren
-
returns true if any of my children is expanded
-
hidden
-
returns true if node is not visible
-
isCollapsable
-
children existing and shown
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
isContainedByParent: aParent
-
returns true if contained in subtree of a parent
-
isExpandable
-
is expandable; children existing and hidden
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
isExpanded
-
return true if I am expanded
-
numberOfChildren
-
returns number of children
-
showIndicator
-
returns true if children exists
-
shown
-
returns true if node is visible
recomputation
-
addVisibleChildrenTo: aList
-
add all visible children and sub-children to the list
-
numberOfAllVisibleChildren
-
returns number of all visible children including all the children of children
retrieving
-
childrenAction
-
get children action block
-
contentsAction
-
get contents action block
-
iconAction
-
get icon action block
-
labelAction
-
get label action block
-
retrieveAll
-
retrieve all values from model
-
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
-
retrieveChildren
-
retrieve children from model
-
retrieveContents
-
retrieve contents value from model;
-
retrieveLabel
-
retrieve label from model
searching
-
childAt: anIndex
-
get child at an index or nil
-
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.
-
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.
-
detectFirstChild: anOneArgBlock
-
detect the first child which evaluation of anOneArgBlock returns true.
Recursively walks down the node-tree.
-
indexOfChild: aChild
-
get index of a child or 0
searching-private
-
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.
|