'From etoys3.0 of 24 February 2008 [latest update: #2081] on 15 September 2008 at 8:55:07 pm'! "Change Set: rewriteHGExplorer Date: 15 September 2008 Author: Yoshiki Ohshima This changeset refactors the way the Explorer queries collection objects. Dictionary, Set, and OrderedCollection had individual methods called #exploreContents, but now there is only one implementation of it and subclasses ovewrites #explorerContentsWithIndexCollect:."! !Object methodsFor: 'accessing' stamp: 'yo 8/27/2008 23:16'! customizeExplorerContents ^ false. ! ! !Collection methodsFor: 'enumerating' stamp: 'yo 8/27/2008 23:45'! explorerContents ^self explorerContentsWithIndexCollect: [:value :index | ObjectExplorerWrapper with: value name: index printString model: self]! ! !Collection methodsFor: 'enumerating' stamp: 'yo 8/27/2008 23:29'! explorerContentsWithIndexCollect: twoArgBlock ^ self asOrderedCollection withIndexCollect: twoArgBlock ! ! !ObjectExplorer methodsFor: 'accessing' stamp: 'yo 8/27/2008 23:54'! explorerFor: anObject | window listMorph | rootObject _ anObject. window _ (SystemWindow labelled: (rootObject printStringLimitedTo: 32)) model: self. window addMorph: (listMorph _ SimpleHierarchicalListMorph on: self list: #getList selected: #getCurrentSelection changeSelected: #noteNewSelection: menu: #genericMenu: keystroke: #explorerKey:from:) frame: (0@0 corner: 1@0.8). window addMorph: ((PluggableTextMorph on: self text: #trash accept: #trash: readSelection: #contentsSelection menu: #codePaneMenu:shifted:) askBeforeDiscardingEdits: false) frame: (0@0.8 corner: 1@1). listMorph autoDeselect: false. ^ window! ! !ObjectExplorerWrapper methodsFor: 'as yet unclassified' stamp: 'yo 8/27/2008 23:39'! contents (item customizeExplorerContents) ifTrue: [^item explorerContents]. "For all others, show named vars first, then indexed vars" ^(item class allInstVarNames asOrderedCollection withIndexCollect: [:each :index | self class with: (item instVarAt: index) name: each model: item parent: self]) , ((1 to: item basicSize) collect: [:index | self class with: (item basicAt: index) name: index printString model: item parent: self])! ! !SequenceableCollection methodsFor: 'accessing' stamp: 'yo 8/27/2008 23:17'! customizeExplorerContents ^ true. ! ! !Set methodsFor: 'explorer' stamp: 'yo 8/27/2008 23:09'! hasContentsInExplorer ^self notEmpty! ! !Dictionary methodsFor: 'accessing' stamp: 'yo 8/27/2008 23:16'! customizeExplorerContents ^ true. ! ! !Dictionary methodsFor: 'user interface' stamp: 'yo 8/27/2008 23:44'! explorerContentsWithIndexCollect: twoArgBlock | sortedKeys | sortedKeys _ self keys asSortedCollection: [:x :y | ((x isString and: [y isString]) or: [x isNumber and: [y isNumber]]) ifTrue: [x < y] ifFalse: [x class == y class ifTrue: [x printString < y printString] ifFalse: [x class name < y class name]]]. ^ sortedKeys collect: [:k | twoArgBlock value: (self at: k) value: k]. ! ! !SimpleButtonMorph methodsFor: 'visual properties' stamp: 'yo 8/27/2008 23:58'! updateVisualState: evt oldColor ifNotNil: [ self color: ((self containsPoint: evt cursorPoint) ifTrue: [oldColor mixed: 0.5 with: Color white] ifFalse: [oldColor])] ! ! Dictionary removeSelector: #explorerContents! Set removeSelector: #explorerContents! SequenceableCollection removeSelector: #explorerContents! ObjectExplorer removeSelector: #label!