Skip to content

Commit

Permalink
Make ClassSearchWidget a quick reference browser
Browse files Browse the repository at this point in the history
  • Loading branch information
swsch committed Jan 28, 2011
1 parent 918d5af commit 5528664
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions More/Examples/ILClassSearchWidget.st
Expand Up @@ -45,21 +45,23 @@ ILWidget subclass: ILClassSearchWidget [
<category: 'accessing'>
^resultsWidget ifNil: [resultsWidget := self widgetFor: [:widget |
(self search: self searchText) do: [:each |
widget div
widget a
class: 'results';
onClickDo: [
self selectedClass: each.
self infoWidget markDirty ];
text: each name asString.
text: each displayString.
widget br]]]
]

infoWidget [
<category: 'accessing'>
^infoWidget ifNil: [ infoWidget := self widgetFor: [ :widget |
widget style: 'float:left; text-align:left; width:40%; margin-left:5em;'.
self selectedClass ifNotNil: [ :aClass | |ul|
widget h2 text: aClass name asString.
widget style: 'float:left; text-align:left; width:60%; margin-left:5em;'.
self selectedClass ifNotNil: [ :aClass | | ul|
widget h2 text: aClass displayString.
self renderSuperclassOf: aClass on: widget div.
self renderSubclassesOf: aClass on: widget div.
widget p text: aClass comment.
ul := widget ul.
( self sortedMessagesForClass: aClass)
Expand All @@ -68,6 +70,28 @@ ILWidget subclass: ILClassSearchWidget [
]]
]

renderSubclassesOf: aClass on: aContainer [
<category: 'private'>
aContainer text: 'subclass(es): '.
aClass allSubclasses
do: [ :each |
aContainer a
onClickDo: [ self selectedClass: each. self infoWidget markDirty ];
text: each displayString ]
separatedBy: [ aContainer text: ', ' ].
]

renderSuperclassOf: aClass on: aContainer [
<category: 'private'>
aContainer text: 'superclass: '.
aClass superclass
ifNil: [ aContainer text: 'nil' ]
ifNotNil: [:supa |
aContainer a
onClickDo: [ self selectedClass: supa. self infoWidget markDirty ];
text: supa displayString].
]

sortedMessagesForClass: aClass [
<category: 'private'>
^aClass methodDictionary keys asSortedCollection
Expand All @@ -80,7 +104,7 @@ ILWidget subclass: ILClassSearchWidget [
ifFalse: [
(Class allSubclasses
select: [:each |
each instanceClass name asString beginsWith: aString])
each instanceClass displayString beginsWith: aString])
collect: [ :each | each instanceClass ]]
]
]

0 comments on commit 5528664

Please sign in to comment.