"
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
InspectorView subclass:#DictionaryInspectorView
instanceVariableNames:'keys hideClassVars hideClasses hideAliases'
classVariableNames:''
poolDictionaries:''
category:'Interface-Inspector'
!
!DictionaryInspectorView class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
a modified Inspector for Dictionaries
[author:]
Claus Gittinger
"
! !
!DictionaryInspectorView methodsFor:'menu'!
fieldMenu
<resource: #programMenu >
|items m idx|
inspectedObject isNamespace ifTrue:[
items := #(
('copy key' doCopyKey )
('-')
('inspect' doInspect )
('inspect key' doInspectKey )
('basicInspect' doBasicInspect )
('inspect hierarchical' doNewInspect )
('-')
('ref chains' showReferences )
('references to key' showKeyReferences )
('-')
('add key' doAddKey )
('remove key' doRemoveKey )
('-')
).
hideClassVars == true ifTrue:[
items := items , #(
('show classVars' doShowClassVars )
).
] ifFalse:[
items := items , #(
('hide classVars' doHideClassVars )
).
].
hideClasses == true ifTrue:[
items := items , #(
('show classes' doShowClasses )
).
] ifFalse:[
items := items , #(
('hide classes' doHideClasses )
).
].
hideAliases == true ifTrue:[
items := items , #(
('show aliases' doShowAliases )
).
] ifFalse:[
items := items , #(
('hide aliases' doHideAliases )
).
]
] ifFalse:[
items := #(
('copy key' doCopyKey )
('-')
('inspect' doInspect )
('inspect key' doInspectKey )
('basicInspect' doBasicInspect )
('inspect hierarchical' doNewInspect )
('-')
('ref chains' showReferences )
('-')
('add key' doAddKey )
('remove key' doRemoveKey )
).
].
monitorProcess isNil ifTrue:[
items := items , #(
('-')
('start monitor' doStartMonitor )
).
] ifFalse:[
items := items , #(
('-')
('stop monitor' doStopMonitor )
).
].
m := PopUpMenu itemList:items resources:resources.
selectionIndex isNil ifTrue:[
m disableAll:#(doInspect doInspectKey doBasicInspect doNewInspect
doRemoveKey doStartMonitor doStopMonitor doCopyKey
)
] ifFalse:[
(self keyIndexForLine:selectionIndex) isNil ifTrue:[
m disableAll:#(doInspectKey doRemoveKey doCopyKey)
]
].
^ m.
"Modified: / 21.5.1998 / 13:25:10 / cg"
! !
!DictionaryInspectorView methodsFor:'menu actions'!
doAddKey
"add a key"
|keyName key val l|
keyName := Dialog request:'key to add:' initialAnswer:''.
keyName notEmpty ifTrue:[
key := keyName asSymbol.
(inspectedObject includesKey:key) ifFalse:[
val := Dialog request:'value to add:' initialAnswer:''.
val notNil ifTrue:[
val := Object readFromString:val onError:nil.
].
inspectedObject at:key put:val.
selectionIndex := selectedLine := nil.
inspectedObject changed.
l := listView firstLineShown.
self reinspect. "force list update"
listView scrollToLine:l
]
]
!
doHideAliases
hideAliases := true.
self reinspect
!
doHideClassVars
hideClassVars := true.
self reinspect
!
doHideClasses
hideClasses := true.
self reinspect
!
doInspectKey
"inspect selected items key"
|idx|
idx := self keyIndexForLine:selectionIndex.
idx notNil ifTrue:[
(keys at:idx) inspect
]
!
doReferences
"show users of selected key (i.e. global).
Only useful when inspecting smalltalk"
|idx|
idx := self keyIndexForLine:selectionIndex.
idx notNil ifTrue:[
SystemBrowser browseReferendsOf:(keys at:idx) asSymbol.
^ self
].
!
doRemoveKey
"remove selected item from keys"
|idx key l|
idx := self keyIndexForLine:selectionIndex.
idx notNil ifTrue:[
key := keys at:idx.
(inspectedObject includesKey:key) ifTrue:[
listView cursor:(Cursor wait).
inspectedObject removeKey:key.
keys := nil.
selectionIndex := selectedLine := nil.
inspectedObject changed.
listView cursor:(Cursor hand).
l := listView firstLineShown.
self reinspect. "force list update"
listView scrollToLine:l.
].
]
!
doShowAliases
hideAliases := false.
self reinspect
!
doShowClassVars
hideClassVars := false.
self reinspect
!
doShowClasses
hideClasses := false.
self reinspect
!
showKeyReferences
"show users of selected key (i.e. global).
Only useful when inspecting smalltalk"
|idx key|
idx := self keyIndexForLine:selectionIndex.
idx notNil ifTrue:[
self topView withWaitCursorDo:[
SystemBrowser browseReferendsOf:(keys at:idx) asSymbol
].
]
! !
!DictionaryInspectorView methodsFor:'private'!
baseInspectedObjectClass
(inspectedObject isMemberOf:Dictionary) ifFalse:[
(inspectedObject class inheritsFrom:Dictionary) ifFalse:[
"this is true for e.g. MethodDictionary"
^ Object
]
].
^ Dictionary
"Modified: / 23.7.1999 / 10:39:11 / stefan"
!
defaultLabel
^ 'keys'
"Created: 28.6.1996 / 19:46:51 / cg"
!
indexedFieldList
"return a list of indexed-variable names to show in the selectionList.
Set hasMore to true, if a '...' entry should be added."
|aList n cls|
inspectedObject isNamespace ifTrue:[
keys := SortedCollection new:1000.
(hideClassVars or:[hideClasses or:[hideAliases]]) ifTrue:[
inspectedObject keysDo:[:k |
|hidden i o|
hidden := false.
hideClassVars == true ifTrue:[
(i := k lastIndexOf:$:) ~~ 0 ifTrue:[
(i > 1 and:[(k at:i-1) ~~ $:]) ifTrue:[
hidden := true
].
].
].
(hidden not and:[hideClasses == true]) ifTrue:[
o := inspectedObject at:k ifAbsent:nil.
o isBehavior ifTrue:[
inspectedObject == Smalltalk ifTrue:[
o name == k ifTrue:[
hidden := true
]
] ifFalse:[
o nameWithoutNameSpacePrefix = k ifTrue:[
hidden := true
]
]
].
].
(hidden not and:[hideAliases == true]) ifTrue:[
o := inspectedObject at:k ifAbsent:nil.
o isBehavior ifTrue:[
inspectedObject == Smalltalk ifTrue:[
o name ~~ k ifTrue:[
hidden := true
]
] ifFalse:[
o nameWithoutNameSpacePrefix ~= k ifTrue:[
hidden := true
].
].
].
].
hidden ifFalse:[keys add:k]
].
] ifFalse:[
inspectedObject keysDo:[:k | keys add:k].
].
^ keys
].
keys := inspectedObject keys asSortedCollection:[:a :b | a displayString < b displayString].
^ keys collect:[:k | k isSymbol ifTrue:[
k printString
] ifFalse:[
k displayString
]
].
!
instVarIndexForLine:lineNr
"helper - return the index for a named instVar;
nil, if self or a keyed instvar is selected."
inspectedObject isNamespace ifTrue:[
^ nil
].
^ super instVarIndexForLine:lineNr
!
keyIndexForLine:lineNr
"helper - return the index of the key-list"
inspectedObject isNamespace ifTrue:[
(hideReceiver not
and:[lineNr == 1 or:[lineNr isNil]]) ifTrue:[
^ nil "/ self selected
].
^ lineNr - 1
].
^ super keyIndexForLine:lineNr
!
namedFieldList
"return a list of instVar names to show in the selectionList."
inspectedObject isNamespace ifTrue:[
"/ empty ...
^ OrderedCollection new
].
^ super namedFieldList
!
release
"release inspected object"
keys := nil.
super release
! !
!DictionaryInspectorView methodsFor:'user interaction'!
indexedValueAtIndex:idx
|key|
key := keys at:idx.
^ inspectedObject at:key ifAbsent:nil.
!
indexedValueAtIndex:idx put:newValue
|key|
key := keys at:idx.
inspectedObject at:key put:newValue.
! !
!DictionaryInspectorView class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libtool/DictionaryInspectorView.st,v 1.44 1999-07-23 21:04:37 cg Exp $'
! !