'From etoys4.0 of 9 October 2008 [latest update: #2287] on 11 September 2009 at 10:34:07 am'! "Change Set: HierListAutomaticallyExpand-yo Date: 11 September 2009 Author: Yoshiki Ohshima When the name part of indented list is clicked the content is automatically expand. (not just the small triangle). Now each hierarchical morph and list items have #autoExpand property. When it is true (per item basis), it automatically expands. In this change set, only the use from FileList2 is taking advantage of it, but if it is found useful the other parts (like explorer) and do the same."! !FileList2 methodsFor: 'user interface' stamp: 'yo 9/11/2009 10:28'! morphicDirectoryTreePaneFiltered: aSymbol ^(SimpleHierarchicalListMorph on: self list: aSymbol selected: #currentDirectorySelected changeSelected: #setSelectedDirectoryTo: menu: #volumeMenu: keystroke: nil autoExpand: true) autoDeselect: false; enableDrag: false; enableDrop: true; yourself ! ! !IndentingListItemMorph methodsFor: 'initialization' stamp: 'yo 9/11/2009 10:24'! initWithContents: anObject prior: priorMorph forList: hostList indentLevel: newLevel container _ hostList. complexContents _ anObject. self initWithContents: anObject asString font: Preferences standardListFont emphasis: nil. indentLevel _ 0. isExpanded _ false. nextSibling _ firstChild _ nil. priorMorph ifNotNil: [ priorMorph nextSibling: self. ]. indentLevel _ newLevel. self setProperty: #autoExpand toValue: true. ! ! !IndentingListItemMorph methodsFor: 'initialization' stamp: 'yo 9/11/2009 10:24'! initialize "initialize the state of the receiver" super initialize. "" indentLevel _ 0. isExpanded _ false. self setProperty: #autoExpand toValue: true. ! ! !IndentingListItemMorph methodsFor: 'mouse events' stamp: 'yo 9/11/2009 10:24'! inToggleArea: aPoint ^ (self valueOfProperty: #autoExpand ifAbsent: [false]) ifFalse: [ self toggleRectangle containsPoint: aPoint ] ifTrue: [ self bounds containsPoint: aPoint ].! ! !SimpleHierarchicalListMorph methodsFor: 'event handling' stamp: 'yo 9/11/2009 10:25'! mouseDown: evt | aMorph selectors | aMorph _ self itemFromPoint: evt position. (aMorph notNil and:[aMorph inToggleArea: (aMorph point: evt position from: self)]) ifTrue:[ self toggleExpandedState: aMorph event: evt. (aMorph valueOfProperty: #autoExpand ifAbsent: [false]) ifFalse: [^ self]]. evt yellowButtonPressed "First check for option (menu) click" ifTrue: [^ self yellowButtonActivity: evt shiftPressed]. aMorph ifNil:[^super mouseDown: evt]. aMorph highlightForMouseDown. selectors _ Array with: #click: with: nil with: nil with: (self dragEnabled ifTrue:[#startDrag:] ifFalse:[nil]). evt hand waitForClicksOrDrag: self event: evt selectors: selectors threshold: 10 "pixels".! ! !SimpleHierarchicalListMorph methodsFor: 'initialization' stamp: 'yo 9/11/2009 10:25'! initialize "initialize the state of the receiver" super initialize. self setProperty: #autoExpand toValue: false. self on: #mouseMove send: #mouseStillDown:onItem: to: self! ! !SimpleHierarchicalListMorph methodsFor: 'initialization' stamp: 'yo 9/11/2009 10:24'! on: anObject list: getListSel selected: getSelectionSel changeSelected: setSelectionSel menu: getMenuSel keystroke: keyActionSel self on: anObject list: getListSel selected: getSelectionSel changeSelected: setSelectionSel menu: getMenuSel keystroke: keyActionSel autoExpand: false. ! ! !SimpleHierarchicalListMorph methodsFor: 'initialization' stamp: 'yo 9/11/2009 10:27'! on: anObject list: getListSel selected: getSelectionSel changeSelected: setSelectionSel menu: getMenuSel keystroke: keyActionSel autoExpand: aBoolean self setProperty: #autoExpand toValue: aBoolean. self model: anObject. getListSelector _ getListSel. getSelectionSelector _ getSelectionSel. setSelectionSelector _ setSelectionSel. getMenuSelector _ getMenuSel. keystrokeActionSelector _ keyActionSel. autoDeselect _ true. self borderWidth: 1. self list: self getList. ! ! !SimpleHierarchicalListMorph methodsFor: 'private' stamp: 'yo 9/11/2009 10:29'! addMorphsTo: morphList from: aCollection allowSorting: sortBoolean withExpandedItems: expandedItems atLevel: newIndent | priorMorph newCollection firstAddition | priorMorph _ nil. newCollection _ (sortBoolean and: [sortingSelector notNil]) ifTrue: [ (aCollection asSortedCollection: [ :a :b | (a perform: sortingSelector) <= (b perform: sortingSelector)]) asOrderedCollection ] ifFalse: [ aCollection ]. firstAddition _ nil. newCollection do: [:item | priorMorph _ self indentingItemClass basicNew initWithContents: item prior: priorMorph forList: self indentLevel: newIndent. priorMorph setProperty: #autoExpand toValue: (self valueOfProperty: #autoExpand ifAbsent: [false]). firstAddition ifNil: [firstAddition _ priorMorph]. morphList add: priorMorph. ((item hasEquivalentIn: expandedItems) or: [priorMorph isExpanded]) ifTrue: [ priorMorph isExpanded: true. priorMorph addChildrenForList: self addingTo: morphList withExpandedItems: expandedItems. ]. ]. ^firstAddition ! ! !SimpleHierarchicalListMorph methodsFor: 'private' stamp: 'yo 9/11/2009 10:27'! addSubmorphsAfter: parentMorph fromCollection: aCollection allowSorting: sortBoolean | priorMorph morphList newCollection | priorMorph _ nil. newCollection _ (sortBoolean and: [sortingSelector notNil]) ifTrue: [ (aCollection asSortedCollection: [ :a :b | (a perform: sortingSelector) <= (b perform: sortingSelector)]) asOrderedCollection ] ifFalse: [ aCollection ]. morphList _ OrderedCollection new. newCollection do: [:item | priorMorph _ self indentingItemClass basicNew initWithContents: item prior: priorMorph forList: self indentLevel: parentMorph indentLevel + 1. priorMorph setProperty: #autoExpand toValue: (self valueOfProperty: #autoExpand ifAbsent: [false]). morphList add: priorMorph. ]. scroller addAllMorphs: morphList after: parentMorph. ^morphList ! ! !SimpleHierarchicalListMorph class methodsFor: 'instance creation' stamp: 'yo 9/11/2009 10:23'! on: anObject list: getListSel selected: getSelectionSel changeSelected: setSelectionSel menu: getMenuSel keystroke: keyActionSel autoExpand: aBoolean "Create a 'pluggable' list view on the given model parameterized by the given message selectors. See ListView>>aboutPluggability comment." ^ self new on: anObject list: getListSel selected: getSelectionSel changeSelected: setSelectionSel menu: getMenuSel keystroke: keyActionSel autoExpand: aBoolean ! !