HierarchyNode.st
author ca
Mon, 30 Jun 1997 13:00:13 +0200
changeset 435 14705c0b1ab9
parent 359 a4f931c5a7d9
child 438 19f0f3a171f6
permissions -rw-r--r--
add childCollectionClass:aCollectionClass
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by AEG Industry Automation
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
 COPYRIGHT (c) 1994 by Claus Gittinger
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	      All Rights Reserved
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 This software is furnished under a license and may be used
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 hereby transferred.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Object subclass:#HierarchyNode
435
ca
parents: 359
diff changeset
    15
	instanceVariableNames:'name id parent children contents disabled hide level
ca
parents: 359
diff changeset
    16
		childCollectionClass'
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    17
	classVariableNames:''
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    18
	poolDictionaries:''
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    19
	category:'Interface-Support'
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    22
!HierarchyNode class methodsFor:'documentation'!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright 
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 COPYRIGHT (c) 1994 by AEG Industry Automation
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 1994 by Claus Gittinger
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
	      All Rights Reserved
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    class to build up tree like structures to represent
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    file-trees, class tress etc.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    Especially suited for use with SelectionInHierarchy and
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    SelectionInHierarchyView.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    See examples in SelectionInHierarchyView.
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    46
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    47
    [Author:]
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    48
        W. Olberding AEG Factory Automation
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    49
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    50
    [See also:]
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    51
        SelectionInHierarchy
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    52
        SelectionInHierarchyView
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
118
2821a094ba30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    54
! !
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    56
!HierarchyNode class methodsFor:'instance creation'!
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    57
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    58
new
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    59
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    60
	^super new initialize
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    61
!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    63
newAsTreeFromSmalltalkClass:aClass
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    64
    "create a tree of nodes with aClass and all its
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    65
    subclasses as contents."
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    67
    ^ self
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    68
        newAsTreeFromSmalltalkClass:aClass
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    69
        level:(aClass allSuperclasses size).
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    70
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    71
    "Modified: 15.4.1997 / 16:34:23 / cg"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    74
newAsTreeFromSmalltalkClass:aClass level:level
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    75
    "create a tree of nodes with aClass and all its
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    76
     subclasses as contents. Set the initial level as given."
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    77
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    78
    |newInst|
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    79
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    80
    newInst := super new initialize.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    81
    newInst name:aClass name.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    82
    newInst contents:aClass.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    83
    newInst level:level.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    84
    aClass subclasses do:[:aSubClass |
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    85
        newInst addChild:(self newAsTreeFromSmalltalkClass:aSubClass level:level+1).
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    86
    ].
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    87
    ^newInst
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    89
    "Created: 15.4.1997 / 16:33:52 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    90
    "Modified: 15.4.1997 / 16:34:52 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    91
!
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    92
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    93
newWithName:aString
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    94
    "create a new node with a name"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    95
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    96
    |newInst|
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    97
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    98
    newInst := super new initialize.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    99
    newInst name: aString.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   100
    ^newInst
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   101
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   102
    "Modified: 15.4.1997 / 16:32:06 / cg"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
newWithName: aString andId: anId
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   106
    "create a new node with a name and id"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   108
    |newInst|
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   109
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   110
    newInst := super new initialize.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   111
    newInst name: aString.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   112
    newInst id:   anId.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   113
    ^newInst
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   114
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   115
    "Modified: 15.4.1997 / 16:32:22 / cg"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
! !
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
!HierarchyNode methodsFor:'accessing'!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
435
ca
parents: 359
diff changeset
   120
childCollectionClass:aCollectionClass
ca
parents: 359
diff changeset
   121
    "set the class of the child-collection.
ca
parents: 359
diff changeset
   122
     Default is Set."
ca
parents: 359
diff changeset
   123
ca
parents: 359
diff changeset
   124
     childCollectionClass := aCollectionClass.
ca
parents: 359
diff changeset
   125
     children := aCollectionClass withAll:children.
ca
parents: 359
diff changeset
   126
!
ca
parents: 359
diff changeset
   127
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   128
children
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   129
    "Answer my immediate children."
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   130
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   131
    ^ children
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   132
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   133
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   134
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   135
children:aCollectionWithElementsOfMyKind 
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   136
    "set my children"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   137
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   138
    aCollectionWithElementsOfMyKind do:[:child | 
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   139
         child parent: self.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   140
         child level: level + 1.
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   141
    ].
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   142
    children := aCollectionWithElementsOfMyKind.
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   143
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   144
    "Modified: 10.10.1994 / 16:13:33 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   145
    "Modified: 15.4.1997 / 16:48:38 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   146
!
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   147
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
contents
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "Answer the contents of me (e.g. a set of items)"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    ^contents
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
contents: anObject 
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    "Set the contents of me to any object (e.g. a set of items)"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    ^contents:= anObject
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   162
disabled
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   163
    "return disabled"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   164
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   165
    ^ disabled
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   166
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   167
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   168
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   169
disabled: aBool 
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   170
    "set disabled"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   171
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   172
    disabled := aBool.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   173
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   174
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   175
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
hide: aBoolean
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
   "Set hide to aBoolean"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
   hide:= aBoolean
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
hideToFalseForPath
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    "set the hide-flag to false"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
      hide:= false.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
      parent isNil ifTrue: [^self].
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
      parent hideToFalseForPath
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
id
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "return id"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    ^ id
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
id:something
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    "set id"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    id := something.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   207
level
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   208
    "answer the level in hierarchy (0=root)"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   209
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   210
    ^level
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   212
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   213
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   214
level: anInteger 
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   215
    "set the level in hierarchy (0=root)"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   216
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   217
    level := anInteger.
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   221
name
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   222
    "return name"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   224
    ^ name
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   228
name: aString 
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   229
    "set the name that identifys me within my parent's context."
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   230
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   231
    name :=   aString.
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   233
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   234
435
ca
parents: 359
diff changeset
   235
ordered:aBoolean
ca
parents: 359
diff changeset
   236
    "set/clear the children-are-ordered flag.
ca
parents: 359
diff changeset
   237
     If unordered (the default), children are kept in a set;
ca
parents: 359
diff changeset
   238
     if ordered, they are kept in an orderedCollection."
ca
parents: 359
diff changeset
   239
ca
parents: 359
diff changeset
   240
     aBoolean ifTrue:[
ca
parents: 359
diff changeset
   241
        children := children asOrderedCollection
ca
parents: 359
diff changeset
   242
     ] ifFalse:[
ca
parents: 359
diff changeset
   243
        children := children asSet
ca
parents: 359
diff changeset
   244
     ].
ca
parents: 359
diff changeset
   245
!
ca
parents: 359
diff changeset
   246
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   247
parent:something
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   248
    "set parent"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   249
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   250
    parent := something.
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
pathName
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    "return a full path name to me"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   257
    |n|
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   259
    n := self delimiterString , name.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   260
    parent isNil ifTrue: [^ n].
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   261
    ^ parent pathName , n.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   262
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   263
    "Modified: 10.10.1994 / 16:13:33 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   264
    "Modified: 15.4.1997 / 16:52:02 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   265
! !
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   267
!HierarchyNode methodsFor:'constants'!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   269
delimiter
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   270
	"Answer the delimiter character"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   272
	^$/
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   274
	"Modified: 10.10.94 / 16:13:35 / W.Olberding"!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   276
delimiterString
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   277
	"Answer the delimiter character asString"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   279
	^self delimiter asString
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   281
	"Modified: 10.10.94 / 16:13:35 / W.Olberding"! !
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
!HierarchyNode methodsFor:'hierarchy operations'!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   285
addChild:anObjectOfMyKind 
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   286
    "add anObjectOfMyKind to my children"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   287
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   288
    anObjectOfMyKind parent: self.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   289
    anObjectOfMyKind level: level +1.
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   290
    self children add:anObjectOfMyKind.
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   291
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   292
    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   293
    "Modified: 15.4.1997 / 16:49:17 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   294
!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   296
addChildren: aCollectionWithElementsOfMyKind 
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   297
    "add aCollectionWithElementsOfMyKind to my children"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   298
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   299
    aCollectionWithElementsOfMyKind do:[:child | 
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   300
         child parent: self.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   301
         child level: level +1.
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   302
    ].
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   303
    self children addAll:aCollectionWithElementsOfMyKind.
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   305
    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   306
    "Modified: 15.4.1997 / 16:49:03 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   307
!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
allChildren
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "Answer my immediate children plus all my grandchildren
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
      -- in hierachical order and alphabeticaly sorted by name within one level."
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
     | kids |
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
     kids := OrderedCollection new.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
     self addAllChildrenTo: kids.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
     ^kids.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   320
allParents 
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   321
    "return all my parents (next first - root last)"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   322
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   323
    parent isNil ifTrue:  [ ^OrderedCollection new: 0  ]
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   324
		 ifFalse: [ ^parent, parent allParents ].
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   325
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   326
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   327
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   328
collapse 
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   329
      "Hide my children in hierachical printouts."
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   330
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   331
	 hide := true
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   332
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   333
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   334
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   335
collapseAll 
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   336
    "Hide my children and all my grandchildren in hierachical printouts."
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   337
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   338
    hide := true.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   339
    self children do: [:kid | kid collapseAll ].
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   341
    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   342
    "Modified: 15.4.1997 / 16:49:34 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   343
!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
expand 
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
      "Show my immediate children in hierachical printouts."
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
	 hide := false.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   352
expandAll 
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   353
    "Show my children and all grand children in hierachical printouts."
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   354
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   355
    hide := false.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   356
    self children do: [:kid | kid expandAll ].
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   357
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   358
    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   359
    "Modified: 15.4.1997 / 16:49:48 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   360
!
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   361
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   362
parent
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   363
    "return parent"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   365
    ^ parent
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   366
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   367
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   368
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   369
removeAllChildren
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   370
    "Remove all children of me from the tree, i.e. let them
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   371
     forget myself as parent."
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   372
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   373
    | kids |
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   375
    kids := self allChildren.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   376
    kids do: [:kid | kid parent: nil ].
435
ca
parents: 359
diff changeset
   377
    children := childCollectionClass new.
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   378
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   379
    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   380
    "Modified: 15.4.1997 / 16:50:01 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   381
!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
removeChild: anObjectOfMyKind 
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   384
    "remove anObjectOfMyKind from my children"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    anObjectOfMyKind parent: nil.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    children rehash.
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   388
    children remove: anObjectOfMyKind.
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   390
    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   391
    "Modified: 15.4.1997 / 16:50:23 / cg"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
removeYourself
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
    "remove me and all my children"
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
    parent isNil ifTrue: [^nil].
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    parent removeChild: self.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   400
    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   401
    "Modified: 15.4.1997 / 16:52:33 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   402
!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
withAllChildren
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
    "Answer me, my immediate children and all my grandchildren
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
      -- in hierachical order and alphabeticaly sorted by name within one level."
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
     | kids |
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
     kids := OrderedCollection with: self .
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
     self addAllChildrenTo: kids.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
     ^kids.
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   415
withAllShownChildren
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   416
    "Answer me, my immediate children and all my grandchildren which are
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   417
     currently not hidden.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   418
      -- in hierachical order and alphabeticaly sorted by name within one level."
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
     | kids |
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   421
     kids := OrderedCollection with: self .
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   422
     self addAllShownChildrenTo: kids.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   423
     ^kids.
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
	"Modified: 10.10.94 / 16:13:34 / W.Olberding"! !
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
!HierarchyNode methodsFor:'initialize-release'!
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
initialize
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   430
        "init some defaults"
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
     "  name 
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   433
        id 
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   434
        parent --"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   435
435
ca
parents: 359
diff changeset
   436
    childCollectionClass := Set.
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   437
    children := Set new.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   438
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
       " contents    := Set new."
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   441
    disabled := false.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   442
    hide     := false.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   443
    level    := 0. "=root"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   444
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   445
    "Modified: 10.10.1994 / 16:13:35 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   446
    "Modified: 15.4.1997 / 16:50:44 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   447
! !
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   449
!HierarchyNode methodsFor:'private'!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   450
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   451
addAllChildrenTo:aCollection
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   452
    "Add all my children in hierachical and alphabetical order
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   453
     to aCollection."
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   454
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   455
    |myChildren|
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
435
ca
parents: 359
diff changeset
   457
    "/ myChildren := children asSortedCollection:[:x :y | x name < y name ].
ca
parents: 359
diff changeset
   458
    myChildren := self children.
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   459
    myChildren do:[:aChild |
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   460
        aCollection addLast: aChild.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   461
        aChild addAllChildrenTo:aCollection.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   462
    ].
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   464
    "Modified: 10.10.1994 / 16:13:35 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   465
    "Modified: 15.4.1997 / 16:47:53 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   466
!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   468
addAllShownChildrenTo: aCollection
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   469
    "Add all my children in hierachical and alphabetical order
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   470
     if they are not hidden."
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   471
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   472
    |myChildren|
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   474
    hide ifTrue: [^self].
435
ca
parents: 359
diff changeset
   475
"/    myChildren := self children asSortedCollection:[:x :y | x name < y name ].
ca
parents: 359
diff changeset
   476
    myChildren := self children.
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   477
    myChildren do: [:aChild |
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   478
        aCollection addLast: aChild.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   479
        aChild addAllShownChildrenTo: aCollection.
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   480
    ].
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   482
    "Modified: 10.10.1994 / 16:13:35 / W.Olberding"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   483
    "Modified: 15.4.1997 / 16:53:08 / cg"
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   484
! !
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   486
!HierarchyNode methodsFor:'queries'!
84
4478ea2d40c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   488
childrenHidden
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   489
      "Answer true if my children shall be hidden
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   490
       in hierachical printouts etc."
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   491
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   492
      ^hide.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   493
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   494
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   495
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   496
childrenShown
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   497
      "Answer true if my children shall be shown
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   498
       in hierachical printouts etc."
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   499
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   500
      ^hide not.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   501
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   502
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   503
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   504
hasChildren
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   505
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   506
	^children size > 0.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   507
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   508
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   509
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   510
isCollapsable
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   511
	"Answer true if I have shown children"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   512
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   513
	self hasChildren ifTrue: [ ^hide == false ].
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   514
	^false.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   515
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   516
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   517
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   518
isExpandable
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   519
	"Answer true if I have hidden children"
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   520
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   521
	self hasChildren ifTrue: [ ^hide == true ].
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   522
	^false.
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   523
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   524
	"Modified: 10.10.94 / 16:13:33 / W.Olberding"! !
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   525
359
a4f931c5a7d9 comments
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   526
!HierarchyNode class methodsFor:'documentation'!
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   527
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   528
version
435
ca
parents: 359
diff changeset
   529
    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchyNode.st,v 1.6 1997-06-30 11:00:13 ca Exp $'
253
01498f4ffcca comment
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   530
! !