equal
deleted
inserted
replaced
1 " |
1 " |
2 COPYRIGHT (c) 1997 by eXept Software AG |
2 COPYRIGHT (c) 1997 by eXept Software AG |
3 All Rights Reserved |
3 All Rights Reserved |
4 |
4 |
5 This software is furnished under a license and may be used |
5 This software is furnished under a license and may be used |
6 only in accordance with the terms of that license and with the |
6 only in accordance with the terms of that license and with the |
7 inclusion of the above copyright notice. This software may not |
7 inclusion of the above copyright notice. This software may not |
8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 |
13 |
14 |
14 |
15 "{ NameSpace: NewInspector }" |
15 "{ NameSpace: Tools }" |
16 |
16 |
17 SelectionInListView subclass:#NewInspectorListView |
17 SelectionInListView subclass:#NewInspectorListView |
18 instanceVariableNames:'actionHolder inspectorList includesSelf' |
18 instanceVariableNames:'actionHolder inspectorList includesSelf' |
19 classVariableNames:'' |
19 classVariableNames:'' |
20 poolDictionaries:'' |
20 poolDictionaries:'' |
24 !NewInspectorListView class methodsFor:'documentation'! |
24 !NewInspectorListView class methodsFor:'documentation'! |
25 |
25 |
26 copyright |
26 copyright |
27 " |
27 " |
28 COPYRIGHT (c) 1997 by eXept Software AG |
28 COPYRIGHT (c) 1997 by eXept Software AG |
29 All Rights Reserved |
29 All Rights Reserved |
30 |
30 |
31 This software is furnished under a license and may be used |
31 This software is furnished under a license and may be used |
32 only in accordance with the terms of that license and with the |
32 only in accordance with the terms of that license and with the |
33 inclusion of the above copyright notice. This software may not |
33 inclusion of the above copyright notice. This software may not |
34 be provided or otherwise made available to, or used by, any |
34 be provided or otherwise made available to, or used by, any |
39 |
39 |
40 ! |
40 ! |
41 |
41 |
42 examples |
42 examples |
43 " |
43 " |
44 open a list view on an instance |
44 open a list view on an instance |
45 [exBegin] |
45 [exBegin] |
46 |top slv a| |
46 |top slv a| |
47 |
47 |
48 a := OrderedCollection new. |
48 a := OrderedCollection new. |
49 a add:1. |
49 a add:1. |
50 |
50 |
51 top := StandardSystemView new |
51 top := StandardSystemView new |
52 label:'select'; |
52 label:'select'; |
53 extent:200@200. |
53 extent:200@200. |
54 |
54 |
55 slv := ScrollableView for:self in:top. |
55 slv := ScrollableView for:self in:top. |
56 slv origin:0.0@0.0 corner:1.0@1.0. |
56 slv origin:0.0@0.0 corner:1.0@1.0. |
57 slv := slv scrolledView. |
57 slv := slv scrolledView. |
58 slv inspect:top. |
58 slv inspect:top. |
59 slv action:[:el|Transcript showCR:(el printString)]. |
59 slv action:[:el|Transcript showCR:(el printString)]. |
60 top open |
60 top open |
61 [exEnd] |
61 [exEnd] |
62 " |
62 " |
63 ! ! |
63 ! ! |
64 |
64 |
65 !NewInspectorListView methodsFor:'accessing'! |
65 !NewInspectorListView methodsFor:'accessing'! |
66 |
66 |
74 |
74 |
75 list:aList |
75 list:aList |
76 "set the lists contents from another list |
76 "set the lists contents from another list |
77 " |
77 " |
78 aList notNil ifTrue:[inspectorList := aList list] |
78 aList notNil ifTrue:[inspectorList := aList list] |
79 ifFalse:[inspectorList := NewInspectorList new]. |
79 ifFalse:[inspectorList := NewInspectorList new]. |
80 |
80 |
81 inspectorList includesSelf:includesSelf. |
81 inspectorList includesSelf:includesSelf. |
82 super list:(inspectorList instanceNames). |
82 super list:(inspectorList instanceNames). |
83 ! |
83 ! |
84 |
84 |
102 !NewInspectorListView methodsFor:'drawing'! |
102 !NewInspectorListView methodsFor:'drawing'! |
103 |
103 |
104 drawVisibleLineSelected:visLineNr with:fg and:bg |
104 drawVisibleLineSelected:visLineNr with:fg and:bg |
105 "redraw a single line as selected. |
105 "redraw a single line as selected. |
106 " |
106 " |
107 |nr| |
107 |nr| |
108 |
108 |
109 (nr := self visibleLineToListLine:visLineNr) notNil ifTrue:[ |
109 (nr := self visibleLineToListLine:visLineNr) notNil ifTrue:[ |
110 ^ self drawVisibleLine:visLineNr with:fg and:bg. |
110 ^ self drawVisibleLine:visLineNr with:fg and:bg. |
111 ]. |
111 ]. |
112 ^ super drawVisibleLine:visLineNr with:fg and:bg |
112 ^ super drawVisibleLine:visLineNr with:fg and:bg |
113 |
113 |
114 ! |
114 ! |
115 |
115 |
119 |nr| |
119 |nr| |
120 |
120 |
121 nr := self visibleLineToListLine:visLineNr. |
121 nr := self visibleLineToListLine:visLineNr. |
122 |
122 |
123 (inspectorList instanceTypeAt:nr) == #directory ifTrue:[ |
123 (inspectorList instanceTypeAt:nr) == #directory ifTrue:[ |
124 self drawRightArrowInVisibleLine:visLineNr |
124 self drawRightArrowInVisibleLine:visLineNr |
125 ] |
125 ] |
126 |
126 |
127 |
127 |
128 ! |
128 ! |
129 |
129 |
131 "redefined to look for directory in every line |
131 "redefined to look for directory in every line |
132 " |
132 " |
133 super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. |
133 super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. |
134 |
134 |
135 startVisLineNr to:endVisLineNr do:[:visLineNr| |
135 startVisLineNr to:endVisLineNr do:[:visLineNr| |
136 self redrawArrowVisibleLine:visLineNr |
136 self redrawArrowVisibleLine:visLineNr |
137 ] |
137 ] |
138 ! |
138 ! |
139 |
139 |
140 redrawVisibleLine:visLineNr |
140 redrawVisibleLine:visLineNr |
141 "if the line is one for a directory, draw a right arrow |
141 "if the line is one for a directory, draw a right arrow |
150 |nr| |
150 |nr| |
151 |
151 |
152 nr := self visibleLineToListLine:visLineNr. |
152 nr := self visibleLineToListLine:visLineNr. |
153 |
153 |
154 (inspectorList instanceTypeAt:nr) == #directory ifTrue:[ |
154 (inspectorList instanceTypeAt:nr) == #directory ifTrue:[ |
155 ^ true |
155 ^ true |
156 ]. |
156 ]. |
157 ^ super visibleLineNeedsSpecialCare:visLineNr |
157 ^ super visibleLineNeedsSpecialCare:visLineNr |
158 |
158 |
159 ! |
159 ! |
160 |
160 |
188 includesSelf := false. |
188 includesSelf := false. |
189 actionHolder := [:el|]. |
189 actionHolder := [:el|]. |
190 inspectorList := NewInspectorList new. |
190 inspectorList := NewInspectorList new. |
191 |
191 |
192 actionBlock := [:dummy| |
192 actionBlock := [:dummy| |
193 self setSelection:selection. |
193 self setSelection:selection. |
194 actionHolder value:(self selectedInstanceVar) |
194 actionHolder value:(self selectedInstanceVar) |
195 ]. |
195 ]. |
196 ! ! |
196 ! ! |
197 |
197 |
198 !NewInspectorListView methodsFor:'private'! |
198 !NewInspectorListView methodsFor:'private'! |
199 |
199 |
200 doesNotUnderstand:aMessage |
200 doesNotUnderstand:aMessage |
201 "forward a message to the inspectorList |
201 "forward a message to the inspectorList |
202 " |
202 " |
203 (inspectorList respondsTo:(aMessage selector)) ifTrue:[ |
203 (inspectorList respondsTo:(aMessage selector)) ifTrue:[ |
204 ^ aMessage sendTo:inspectorList |
204 ^ aMessage sendTo:inspectorList |
205 ]. |
205 ]. |
206 ^ super doesNotUnderstand:aMessage |
206 ^ super doesNotUnderstand:aMessage |
207 |
207 |
208 |
208 |
209 ! |
209 ! |
214 |
214 |
215 "somewhat of a kludge: if selection is first line, |
215 "somewhat of a kludge: if selection is first line, |
216 we have to remove the highlight frame by hand here" |
216 we have to remove the highlight frame by hand here" |
217 |
217 |
218 (shown and:[hilightLevel ~~ 0]) ifTrue:[ |
218 (shown and:[hilightLevel ~~ 0]) ifTrue:[ |
219 selection == firstLineShown ifTrue:[ |
219 selection == firstLineShown ifTrue:[ |
220 self paint:bgColor. |
220 self paint:bgColor. |
221 self fillRectangleX:margin y:margin |
221 self fillRectangleX:margin y:margin |
222 width:(width - (margin * 2)) |
222 width:(width - (margin * 2)) |
223 height:(hilightLevel abs). |
223 height:(hilightLevel abs). |
224 ]. |
224 ]. |
225 ]. |
225 ]. |
226 listAttributes := nil. |
226 listAttributes := nil. |
227 super list:aCollection expandTabs:false. |
227 super list:aCollection expandTabs:false. |
228 super setSelection:(inspectorList selection). |
228 super setSelection:(inspectorList selection). |
229 |
229 |
240 |oldSize| |
240 |oldSize| |
241 |
241 |
242 oldSize := inspectorList size. |
242 oldSize := inspectorList size. |
243 inspectorList setSelection:aNumberOrNil. |
243 inspectorList setSelection:aNumberOrNil. |
244 oldSize == inspectorList size ifTrue:[super setSelection:(inspectorList selection)] |
244 oldSize == inspectorList size ifTrue:[super setSelection:(inspectorList selection)] |
245 ifFalse:[super list:(inspectorList instanceNames)]. |
245 ifFalse:[super list:(inspectorList instanceNames)]. |
246 ! ! |
246 ! ! |
247 |
247 |
248 !NewInspectorListView methodsFor:'user interaction'! |
248 !NewInspectorListView methodsFor:'user interaction'! |
249 |
249 |
250 accept:aText notifying:aView |
250 accept:aText notifying:aView |
255 |res| |
255 |res| |
256 |
256 |
257 res := inspectorList accept:aText notifying:aView. |
257 res := inspectorList accept:aText notifying:aView. |
258 |
258 |
259 res ~~ #Error ifTrue:[ |
259 res ~~ #Error ifTrue:[ |
260 super list:(inspectorList instanceNames) |
260 super list:(inspectorList instanceNames) |
261 ]. |
261 ]. |
262 ^ res |
262 ^ res |
263 ! |
263 ! |
264 |
264 |
265 doIt:aCode notifying:aView |
265 doIt:aCode notifying:aView |
270 |res| |
270 |res| |
271 |
271 |
272 res := inspectorList doIt:aCode notifying:aView. |
272 res := inspectorList doIt:aCode notifying:aView. |
273 |
273 |
274 res ~~ #Error ifTrue:[ |
274 res ~~ #Error ifTrue:[ |
275 super list:(inspectorList instanceNames) |
275 super list:(inspectorList instanceNames) |
276 ]. |
276 ]. |
277 ^ res |
277 ^ res |
278 |
278 |
279 ! |
279 ! |
280 |
280 |
281 inspect:anObject |
281 inspect:anObject |
282 "inspect a new instance; update contents |
282 "inspect a new instance; update contents |
283 " |
283 " |
284 (inspectorList inspectedObject) == anObject ifTrue:[ |
284 (inspectorList inspectedObject) == anObject ifTrue:[ |
285 ^ self update |
285 ^ self update |
286 ]. |
286 ]. |
287 inspectorList := NewInspectorList for:anObject. |
287 inspectorList := NewInspectorList for:anObject. |
288 inspectorList includesSelf:includesSelf. |
288 inspectorList includesSelf:includesSelf. |
289 |
289 |
290 super list:(inspectorList instanceNames). |
290 super list:(inspectorList instanceNames). |