SetInspectorView.st
author Claus Gittinger <cg@exept.de>
Fri, 16 Jul 1999 19:26:38 +0200
changeset 2271 0cf238543cb1
parent 2236 257f587ad7dc
child 2627 e633d9928ddd
permissions -rw-r--r--
fixed and improved fieldNameList generation & use. Enhanced DictionaryInspector to handle namespaces.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     1
InspectorView subclass:#SetInspectorView
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     2
	instanceVariableNames:'keys'
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     3
	classVariableNames:''
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     4
	poolDictionaries:''
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     5
	category:'Interface-Inspector'
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     6
!
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     7
794
b4b902784e00 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
     8
!SetInspectorView class methodsFor:'documentation'!
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     9
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    10
documentation
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    11
"
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    12
    A modified inspector for Sets
510
6543e55fb227 documentation
Claus Gittinger <cg@exept.de>
parents: 370
diff changeset
    13
6543e55fb227 documentation
Claus Gittinger <cg@exept.de>
parents: 370
diff changeset
    14
    [author:]
6543e55fb227 documentation
Claus Gittinger <cg@exept.de>
parents: 370
diff changeset
    15
        Stefan Vogel
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    16
"
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    17
!
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    18
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    19
examples
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    20
"
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    21
    #(a b c d e) asSet inspect
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    22
"
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    23
! !
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    24
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    25
!SetInspectorView methodsFor:'initialization'!
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    26
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    27
fieldMenu
1361
20c353524524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 956
diff changeset
    28
    <resource: #programMenu >
20c353524524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 956
diff changeset
    29
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    30
    |menu|
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    31
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    32
    menu := super fieldMenu.
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    33
    menu addLabels:#(
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    34
                       '-'
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    35
                       'remove element'
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    36
                   )
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    37
         selectors:#(
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    38
                       nil 
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    39
                       doRemoveKey
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    40
                   ).
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    41
2236
257f587ad7dc migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
    42
    (self keyIndexForLine:selectionIndex) isNil ifTrue:[
2193
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    43
        menu disableAll:#(doRemoveKey)
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    44
    ].
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    45
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    46
    ^ menu
1361
20c353524524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 956
diff changeset
    47
20c353524524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 956
diff changeset
    48
    "Modified: / 29.10.1997 / 03:41:47 / cg"
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    49
! !
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    50
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    51
!SetInspectorView methodsFor:'private'!
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    52
2193
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    53
baseInspectedObjectClass
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    54
    ^ Set
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    55
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    56
!
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
    57
647
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    58
defaultLabel
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    59
    ^ 'contents'
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    60
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    61
    "
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    62
     (Set with:1 with:2 with:3) inspect
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    63
    "
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    64
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    65
    "Modified: 28.6.1996 / 16:05:42 / cg"
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    66
!
1791ceddf2ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
    67
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    68
indexedFieldList 
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    69
    "return a list of indexed-variable names to show in the selectionList.
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    70
     Set hasMore to true, if a '...' entry should be added."
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    71
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    72
    |aList n cls|
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    73
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    74
    keys := inspectedObject asSortedCollection:[:a :b | a displayString < b displayString].
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    75
    ^ keys collect:[:k | k isSymbol ifTrue:[
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    76
                             k printString
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    77
                         ] ifFalse:[
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    78
                             k displayString
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    79
                         ]
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    80
                   ].
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    81
2191
06957119a0ac show named instvars - except for Set instvars
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    82
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    83
!
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    84
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    85
release 
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    86
    "release inspected object"
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    87
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    88
    keys := nil.
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    89
    super release
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    90
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    91
    "Created: 9.2.1996 / 12:04:30 / stefan"
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    92
! !
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    93
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    94
!SetInspectorView methodsFor:'user interaction'!
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    95
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    96
doRemoveKey
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    97
    "remove selected item from keys"
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    98
2192
c7bce869223c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
    99
    |key idx|
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   100
2236
257f587ad7dc migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
   101
    idx := self keyIndexForLine:selectionIndex.
2193
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
   102
    idx notNil ifTrue:[
2192
c7bce869223c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
   103
        key := keys at:idx.
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   104
        (inspectedObject includes:key) ifTrue:[
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   105
            listView cursor:(Cursor wait).
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   106
            inspectedObject remove:key.
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   107
            keys := nil.
2236
257f587ad7dc migrate instvars 'inspectedObject' to 'object'
Claus Gittinger <cg@exept.de>
parents: 2193
diff changeset
   108
            selectionIndex := selectedLine := nil.
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   109
            inspectedObject changed.
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   110
            listView cursor:(Cursor hand).
2193
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
   111
            self reinspect.
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   112
        ].
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   113
    ]
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   114
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   115
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   116
!
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   117
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   118
indexedValueAtIndex:idx
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   119
    ^ keys at:idx
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   120
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   121
!
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   122
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   123
valueAtLine:lineNr put:newValue
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   124
    "store newValue;
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   125
     For non-named instvars, we add the new value - ignoring the selection"
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   126
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   127
    |idx|
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   128
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   129
    idx := self instVarIndexForLine:selectionIndex.
2193
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
   130
    idx notNil ifTrue:[
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   131
        inspectedObject instVarAt:idx put:newValue.
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   132
    ] ifFalse:[
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   133
        inspectedObject add:newValue.
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   134
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   135
"/        inspectedObject changed.
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   136
        self reinspect.
2193
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
   137
    ].
3d7b1044e8c8 fixed access to namedInstvars
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
   138
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   139
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   140
! !
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   141
794
b4b902784e00 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   142
!SetInspectorView class methodsFor:'documentation'!
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   143
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   144
version
2271
0cf238543cb1 fixed and improved fieldNameList generation & use.
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   145
    ^ '$Header: /cvs/stx/stx/libtool/SetInspectorView.st,v 1.13 1999-07-16 17:25:33 cg Exp $'
370
7476940ca13f New SetInspectorView.
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   146
! !