--- a/HierarchicalItem.st Fri Aug 08 16:28:15 2003 +0200
+++ b/HierarchicalItem.st Sat Aug 09 22:59:01 2003 +0200
@@ -273,14 +273,14 @@
!
expand:enforced
- "expand children
- "
+ "expand children"
+
|index list|
"/ test whether the item already is expanded; #canExpand could be redefined
"/ without checking whether the node is expanded (happens already) !!
- isExpanded == true ifTrue:[ ^ self ].
+ isExpanded ifTrue:[ ^ self ].
(enforced or:[self canExpand]) ifFalse:[ ^ self ].
self criticalDo:[
@@ -356,8 +356,8 @@
"/ test whether the item already is expanded; #canExpand could be redefined
"/ without checking whether the node is expanded (happens already) !!
- isExpanded == true ifTrue:[ ^ self ].
- self canExpand ifFalse:[ ^ self ].
+ isExpanded ifTrue:[ ^ self ].
+ self canExpand ifFalse:[ ^ self ].
isExpanded := true.
@@ -382,9 +382,9 @@
recursiveToggleExpand
"if the item is collapsed, the item and all its sub-items
- are expanded otherwise collapsed
- "
- isExpanded == true ifTrue:[
+ are expanded otherwise collapsed"
+
+ isExpanded ifTrue:[
self recursiveCollapse
] ifFalse:[
self recursiveExpand
@@ -393,9 +393,9 @@
toggleExpand
"if the item is collapsed, the item is expanded otherwise
- collapsed.
- "
- isExpanded == true ifTrue:[
+ collapsed"
+
+ isExpanded ifTrue:[
self collapse
] ifFalse:[
self expand
@@ -702,11 +702,11 @@
^ aList
].
- (isExpanded == true) ifFalse:[
+ isExpanded ifFalse:[
notify notNil ifTrue:[
notify changed
].
- ^ aList
+ ^ aList
].
(index := self listIndex) isNil ifTrue:[
^ aList
@@ -1092,9 +1092,9 @@
!HierarchicalItem methodsFor:'private'!
addVisibleChildrenTo:aList
- "add all visible children and sub-children to the list
- "
- isExpanded == true ifFalse:[^ self].
+ "add all visible children and sub-children to the list"
+
+ isExpanded ifFalse:[^ self].
self nonCriticalFrom:1 to:nil do:[:el|
aList add:el.
@@ -1129,11 +1129,11 @@
!
numberOfVisibleChildren
- "returns number of all visible children including subchildren
- "
+ "returns number of all visible children including subchildren"
+
|size|
- isExpanded == true ifFalse:[^ 0].
+ isExpanded ifFalse:[^ 0].
size := 0.
self nonCriticalFrom:1 to:nil do:[:el|
@@ -1149,8 +1149,8 @@
!
setExpanded:aBoolean
- "set expanded flag without any computation or notification
- "
+ "set expanded flag without any computation or notification"
+
isExpanded := aBoolean
! !
@@ -1326,25 +1326,27 @@
!HierarchicalItem methodsFor:'private-hierarchy'!
recursiveSetCollapsed
- "collapse all children and sub-children without notifications
- "
+ "collapse all children and sub-children without notifications"
+
isExpanded := false.
- "/ do not call :#size: children will be autoloaded !!!!
+ "/ do not call #size: children will be autoloaded !!!!
children size ~~ 0 ifTrue:[
- self nonCriticalFrom:1 to:nil do:[:el| el recursiveSetCollapsed ].
+ self nonCriticalFrom:1 to:nil do:[:el| el canRecursiveCollapse ifTrue:[el recursiveSetCollapsed]].
]
!
recursiveSetExpandedAndAddToList:aList
"expand all children and sub-children without notifications;
- add children to list
- "
+ add children to list"
+
isExpanded := true.
- self do:[:anItem|
- aList add:anItem.
- anItem recursiveSetExpandedAndAddToList:aList.
+ self do:[:eachChild|
+ eachChild canRecursiveExpand ifTrue:[
+ aList add:eachChild.
+ eachChild recursiveSetExpandedAndAddToList:aList.
+ ].
].
! !
@@ -1500,16 +1502,30 @@
canCollapse
"called before collapsing the item; can be redefined
- by subclass to omit the collapse operation
- "
- ^ (isExpanded == true)
+ by subclass to omit the collapse operation"
+
+ ^ isExpanded
!
canExpand
"called before expanding the item; can be redefined
- by subclass to omit the collapse operation
- "
- ^ (isExpanded == true) not and:[self hasChildren]
+ by subclass to omit the collapse operation"
+
+ ^ isExpanded not and:[self hasChildren]
+!
+
+canRecursiveCollapse
+ "called before collapsing the item; can be redefined
+ by subclass to omit the collapse operation "
+
+ ^ self canCollapse
+!
+
+canRecursiveExpand
+ "called before expanding the item; can be redefined
+ by subclass to omit the collapse operation"
+
+ ^ self canExpand
!
drawHorizontalLineUpToText
@@ -1587,15 +1603,15 @@
!
isCollapsed
- "returns true if the item is collapsed
- "
- ^ (isExpanded ~~ true)
+ "returns true if the item is collapsed"
+
+ ^ isExpanded not
!
isExpanded
- "returns true if the item is expanded
- "
- ^ (isExpanded == true)
+ "returns true if the item is expanded"
+
+ ^ isExpanded
!
isHierarchicalItem
@@ -1898,5 +1914,5 @@
!HierarchicalItem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.59 2003-05-27 06:15:34 james Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.60 2003-08-09 20:59:01 stefan Exp $'
! !