|
1 " |
|
2 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
3 All Rights Reserved |
|
4 |
|
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 |
|
7 inclusion of the above copyright notice. This software may not |
|
8 be provided or otherwise made available to, or used by, any |
|
9 other person. No title to or ownership of the software is |
|
10 hereby transferred. |
|
11 " |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 ApplicationModel subclass:#HierarchicalListEditor |
|
17 instanceVariableNames:'didInstall treeView specClass specSelector' |
|
18 classVariableNames:'CopyBuffer IconCreateChild IconCreateSister' |
|
19 poolDictionaries:'' |
|
20 category:'Interface-UIPainter' |
|
21 ! |
|
22 |
|
23 !HierarchicalListEditor class methodsFor:'documentation'! |
|
24 |
|
25 copyright |
|
26 " |
|
27 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
28 All Rights Reserved |
|
29 |
|
30 This software is furnished under a license and may be used |
|
31 only in accordance with the terms of that license and with the |
|
32 inclusion of the above copyright notice. This software may not |
|
33 be provided or otherwise made available to, or used by, any |
|
34 other person. No title to or ownership of the software is |
|
35 hereby transferred. |
|
36 " |
|
37 |
|
38 |
|
39 |
|
40 ! |
|
41 |
|
42 documentation |
|
43 " |
|
44 HierarchicalListEditor is used by the UIPainter to |
|
45 create or maintain a hierarchical list. |
|
46 |
|
47 [start with:] |
|
48 HierarchicalListEditor open |
|
49 |
|
50 [see also:] |
|
51 UIPainter |
|
52 |
|
53 [author:] |
|
54 Claus Atzkern |
|
55 " |
|
56 |
|
57 |
|
58 |
|
59 ! ! |
|
60 |
|
61 !HierarchicalListEditor class methodsFor:'icons'! |
|
62 |
|
63 iconCreateChild |
|
64 |
|
65 IconCreateChild isNil ifTrue:[ |
|
66 IconCreateChild := Image fromFile:'/home/ca/st/images/ui_hierListChild.xpm'. |
|
67 |
|
68 IconCreateChild isNil ifTrue:[ |
|
69 IconCreateChild := MenuEditor iconCreateMenu |
|
70 ]. |
|
71 ]. |
|
72 ^ IconCreateChild. |
|
73 |
|
74 " |
|
75 IconCreateChild := nil |
|
76 " |
|
77 ! |
|
78 |
|
79 iconCreateSister |
|
80 |
|
81 IconCreateSister isNil ifTrue:[ |
|
82 IconCreateSister := Image fromFile:'/home/ca/st/images/ui_hierListSister.xpm'. |
|
83 |
|
84 IconCreateSister isNil ifTrue:[ |
|
85 IconCreateSister := MenuEditor iconCreateItem |
|
86 ] |
|
87 ]. |
|
88 ^ IconCreateSister. |
|
89 |
|
90 " |
|
91 IconCreateSister := nil |
|
92 " |
|
93 ! ! |
|
94 |
|
95 !HierarchicalListEditor class methodsFor:'interface specs'! |
|
96 |
|
97 classAndMethodSpec |
|
98 "this window spec was automatically generated by the ST/X UIPainter" |
|
99 |
|
100 "do not manually edit this - the painter/builder may not be able to |
|
101 handle the specification if its corrupted." |
|
102 |
|
103 " |
|
104 UIPainter new openOnClass:HierarchicalListEditor andSelector:#classAndMethodSpec |
|
105 HierarchicalListEditor new openInterface:#classAndMethodSpec |
|
106 " |
|
107 |
|
108 <resource: #canvas> |
|
109 |
|
110 ^ |
|
111 |
|
112 #(#FullSpec |
|
113 #'window:' |
|
114 #(#WindowSpec |
|
115 #'name:' 'Painter' |
|
116 #'layout:' #(#LayoutFrame 199 0 167 0 589 0 336 0) |
|
117 #'label:' 'Painter' |
|
118 #'min:' #(#Point 10 10) |
|
119 #'max:' #(#Point 1160 870) |
|
120 #'bounds:' #(#Rectangle 199 167 590 337) |
|
121 ) |
|
122 #'component:' |
|
123 #(#SpecCollection |
|
124 #'collection:' |
|
125 #( |
|
126 #(#LabelSpec |
|
127 #'name:' 'boxLabel' |
|
128 #'layout:' #(#Point 5 10) |
|
129 #'label:' 'class & method for code:' |
|
130 #'adjust:' #left |
|
131 #'resizeForLabel:' true |
|
132 ) |
|
133 #(#LabelSpec |
|
134 #'name:' 'classLabel' |
|
135 #'layout:' #(#AlignmentOrigin 45 0.11 51 0 1 0.5) |
|
136 #'label:' 'class:' |
|
137 #'adjust:' #right |
|
138 #'resizeForLabel:' true |
|
139 ) |
|
140 #(#InputFieldSpec |
|
141 #'name:' 'classField' |
|
142 #'layout:' #(#LayoutFrame 47 0.11 39 0 -2 1.0 61 0) |
|
143 #'tabable:' true |
|
144 #'model:' #specClassChannel |
|
145 ) |
|
146 #(#LabelSpec |
|
147 #'name:' 'methodLabel' |
|
148 #'layout:' #(#AlignmentOrigin 45 0.11 74 0 1 0.5) |
|
149 #'label:' 'method:' |
|
150 #'adjust:' #right |
|
151 #'resizeForLabel:' true |
|
152 ) |
|
153 #(#InputFieldSpec |
|
154 #'name:' 'methodField' |
|
155 #'layout:' #(#LayoutFrame 47 0.11 64 0 -2 1.0 86 0) |
|
156 #'tabable:' true |
|
157 #'model:' #specSelectorChannel |
|
158 #'type:' #string |
|
159 ) |
|
160 #(#HorizontalPanelViewSpec |
|
161 #'name:' 'commitPanel' |
|
162 #'layout:' #(#LayoutFrame 0 0.0 -24 1.0 0 1.0 0 1.0) |
|
163 #'component:' |
|
164 #(#SpecCollection |
|
165 #'collection:' |
|
166 #( |
|
167 #(#ActionButtonSpec |
|
168 #'name:' 'cancel' |
|
169 #'label:' 'cancel' |
|
170 #'tabable:' true |
|
171 #'model:' #cancel |
|
172 #'extent:' #(#Point 191 24) |
|
173 ) |
|
174 #(#ActionButtonSpec |
|
175 #'name:' 'accept' |
|
176 #'label:' 'ok' |
|
177 #'tabable:' true |
|
178 #'isDefault:' true |
|
179 #'model:' #accept |
|
180 #'extent:' #(#Point 191 24) |
|
181 ) |
|
182 ) |
|
183 ) |
|
184 #'horizontalLayout:' #fitSpace |
|
185 #'verticalLayout:' #fit |
|
186 #'horizontalSpace:' 3 |
|
187 #'verticalSpace:' 3 |
|
188 ) |
|
189 ) |
|
190 ) |
|
191 ) |
|
192 ! |
|
193 |
|
194 menuButtons |
|
195 "this window spec was automatically generated by the ST/X MenuEditor" |
|
196 |
|
197 "do not manually edit this - the builder may not be able to |
|
198 handle the specification if its corrupted." |
|
199 |
|
200 " |
|
201 MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuButtons |
|
202 (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuButtons)) startUp |
|
203 " |
|
204 |
|
205 <resource: #menu> |
|
206 |
|
207 ^ |
|
208 |
|
209 #(#Menu |
|
210 |
|
211 #( |
|
212 #(#MenuItem |
|
213 #'label:' 'createChild' |
|
214 #'value:' #doCreateChild |
|
215 #'enabled:' #canCreateChildChannel |
|
216 #'labelImage:' #(#ResourceRetriever #HierarchicalListEditor #iconCreateChild) |
|
217 ) |
|
218 #(#MenuItem |
|
219 #'label:' 'createSister' |
|
220 #'value:' #doCreateSister |
|
221 #'enabled:' #canCreateSisterChannel |
|
222 #'labelImage:' #(#ResourceRetriever #HierarchicalListEditor #iconCreateSister) |
|
223 ) |
|
224 #(#MenuItem |
|
225 #'label:' '-' |
|
226 ) |
|
227 #(#MenuItem |
|
228 #'label:' '' |
|
229 ) |
|
230 #(#MenuItem |
|
231 #'label:' '-' |
|
232 ) |
|
233 #(#MenuItem |
|
234 #'label:' 'stepUp' |
|
235 #'value:' #doStepUp |
|
236 #'enabled:' #canStepOverChannel |
|
237 #'labelImage:' #(#ResourceRetriever #UIPainter #iconStepUp) |
|
238 ) |
|
239 #(#MenuItem |
|
240 #'label:' '-' |
|
241 ) |
|
242 #(#MenuItem |
|
243 #'label:' 'stepDown' |
|
244 #'value:' #doStepDown |
|
245 #'enabled:' #canStepOverChannel |
|
246 #'labelImage:' #(#ResourceRetriever #UIPainter #iconStepDown) |
|
247 ) |
|
248 #(#MenuItem |
|
249 #'label:' '-' |
|
250 ) |
|
251 #(#MenuItem |
|
252 #'label:' 'stepIn' |
|
253 #'value:' #doStepIn |
|
254 #'enabled:' #canStepInChannel |
|
255 #'labelImage:' #(#ResourceRetriever #UIPainter #iconStepIn) |
|
256 ) |
|
257 #(#MenuItem |
|
258 #'label:' '-' |
|
259 ) |
|
260 #(#MenuItem |
|
261 #'label:' 'stepOut' |
|
262 #'value:' #doStepOut |
|
263 #'enabled:' #canStepOutChannel |
|
264 #'labelImage:' #(#ResourceRetriever #UIPainter #iconStepOut) |
|
265 ) |
|
266 #(#MenuItem |
|
267 #'label:' '-' |
|
268 ) |
|
269 ) nil |
|
270 nil |
|
271 ) |
|
272 ! |
|
273 |
|
274 menuMain |
|
275 "this window spec was automatically generated by the ST/X MenuEditor" |
|
276 |
|
277 "do not manually edit this - the builder may not be able to |
|
278 handle the specification if its corrupted." |
|
279 |
|
280 " |
|
281 MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuMain |
|
282 (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuMain)) startUp |
|
283 " |
|
284 |
|
285 <resource: #menu> |
|
286 |
|
287 ^ |
|
288 |
|
289 #(#Menu |
|
290 |
|
291 #( |
|
292 #(#MenuItem |
|
293 #'label:' 'file' |
|
294 #'submenu:' |
|
295 #(#Menu |
|
296 |
|
297 #( |
|
298 #(#MenuItem |
|
299 #'label:' 'new' |
|
300 #'value:' #doNew |
|
301 ) |
|
302 #(#MenuItem |
|
303 #'label:' 'reload' |
|
304 #'value:' #doReload |
|
305 ) |
|
306 #(#MenuItem |
|
307 #'label:' '=' |
|
308 ) |
|
309 #(#MenuItem |
|
310 #'label:' 'quit' |
|
311 #'value:' #closeRequest |
|
312 ) |
|
313 ) nil |
|
314 nil |
|
315 ) |
|
316 ) |
|
317 #(#MenuItem |
|
318 #'label:' 'code' |
|
319 #'submenu:' |
|
320 #(#Menu |
|
321 |
|
322 #( |
|
323 #(#MenuItem |
|
324 #'label:' 'class && method' |
|
325 #'value:' #doDefineClass |
|
326 #'enabled:' #canChangeClassName |
|
327 ) |
|
328 #(#MenuItem |
|
329 #'label:' 'method' |
|
330 #'value:' #doDefineSelector |
|
331 #'enabled:' #hasValidClass |
|
332 ) |
|
333 #(#MenuItem |
|
334 #'label:' '-' |
|
335 ) |
|
336 #(#MenuItem |
|
337 #'label:' 'install spec.' |
|
338 #'value:' #doInstall |
|
339 #'enabled:' #hasValidClass |
|
340 ) |
|
341 #(#MenuItem |
|
342 #'label:' '-' |
|
343 ) |
|
344 #(#MenuItem |
|
345 #'label:' 'browse' |
|
346 #'enabled:' #hasValidClass |
|
347 #'submenu:' |
|
348 #(#Menu |
|
349 |
|
350 #( |
|
351 #(#MenuItem |
|
352 #'label:' 'class' |
|
353 #'value:' #'doBrowse:' |
|
354 #'argument:' #class |
|
355 ) |
|
356 #(#MenuItem |
|
357 #'label:' '-' |
|
358 ) |
|
359 #(#MenuItem |
|
360 #'label:' 'specification' |
|
361 #'value:' #'doBrowse:' |
|
362 #'enabled:' #hasValidSpecSelector |
|
363 #'argument:' #spec |
|
364 ) |
|
365 #(#MenuItem |
|
366 #'label:' 'method' |
|
367 #'value:' #'doBrowse:' |
|
368 #'enabled:' #hasValidMethodSelector |
|
369 #'argument:' #method |
|
370 ) |
|
371 ) nil |
|
372 nil |
|
373 ) |
|
374 ) |
|
375 ) nil |
|
376 nil |
|
377 ) |
|
378 ) |
|
379 ) nil |
|
380 nil |
|
381 ) |
|
382 ! |
|
383 |
|
384 menuTree |
|
385 "this window spec was automatically generated by the ST/X MenuEditor" |
|
386 |
|
387 "do not manually edit this - the builder may not be able to |
|
388 handle the specification if its corrupted." |
|
389 |
|
390 " |
|
391 MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuTree |
|
392 (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuTree)) startUp |
|
393 " |
|
394 |
|
395 <resource: #menu> |
|
396 |
|
397 ^ |
|
398 |
|
399 #(#Menu |
|
400 |
|
401 #( |
|
402 #(#MenuItem |
|
403 #'label:' 'copy' |
|
404 #'value:' #doCopy |
|
405 #'enabled:' #canCopy |
|
406 ) |
|
407 #(#MenuItem |
|
408 #'label:' 'cut' |
|
409 #'value:' #doCut |
|
410 #'enabled:' #canCut |
|
411 ) |
|
412 #(#MenuItem |
|
413 #'label:' 'paste' |
|
414 #'value:' #doPaste |
|
415 #'enabled:' #canPaste |
|
416 ) |
|
417 ) nil |
|
418 nil |
|
419 ) |
|
420 ! |
|
421 |
|
422 methodSpec |
|
423 "this window spec was automatically generated by the ST/X UIPainter" |
|
424 |
|
425 "do not manually edit this - the painter/builder may not be able to |
|
426 handle the specification if its corrupted." |
|
427 |
|
428 " |
|
429 UIPainter new openOnClass:HierarchicalListEditor andSelector:#methodSpec |
|
430 HierarchicalListEditor new openInterface:#methodSpec |
|
431 " |
|
432 |
|
433 <resource: #canvas> |
|
434 |
|
435 ^ |
|
436 |
|
437 #(#FullSpec |
|
438 #'window:' |
|
439 #(#WindowSpec |
|
440 #'name:' 'Painter' |
|
441 #'layout:' #(#LayoutFrame 275 0 381 0 665 0 550 0) |
|
442 #'label:' 'Painter' |
|
443 #'min:' #(#Point 10 10) |
|
444 #'max:' #(#Point 1160 870) |
|
445 #'bounds:' #(#Rectangle 275 381 666 551) |
|
446 ) |
|
447 #'component:' |
|
448 #(#SpecCollection |
|
449 #'collection:' |
|
450 #( |
|
451 #(#LabelSpec |
|
452 #'name:' 'boxLabel' |
|
453 #'layout:' #(#Point 5 10) |
|
454 #'label:' 'class & method for code:' |
|
455 #'adjust:' #left |
|
456 #'resizeForLabel:' true |
|
457 ) |
|
458 #(#LabelSpec |
|
459 #'name:' 'methodLabel' |
|
460 #'layout:' #(#AlignmentOrigin 45 0.11 74 0 1 0.5) |
|
461 #'label:' 'method:' |
|
462 #'adjust:' #right |
|
463 #'resizeForLabel:' true |
|
464 ) |
|
465 #(#InputFieldSpec |
|
466 #'name:' 'methodField' |
|
467 #'layout:' #(#LayoutFrame 47 0.11 64 0 -2 1.0 86 0) |
|
468 #'tabable:' true |
|
469 #'model:' #specSelectorChannel |
|
470 #'type:' #string |
|
471 ) |
|
472 #(#HorizontalPanelViewSpec |
|
473 #'name:' 'commitPanel' |
|
474 #'layout:' #(#LayoutFrame 0 0.0 -24 1.0 0 1.0 0 1.0) |
|
475 #'component:' |
|
476 #(#SpecCollection |
|
477 #'collection:' |
|
478 #( |
|
479 #(#ActionButtonSpec |
|
480 #'name:' 'cancel' |
|
481 #'label:' 'cancel' |
|
482 #'tabable:' true |
|
483 #'model:' #cancel |
|
484 #'extent:' #(#Point 191 24) |
|
485 ) |
|
486 #(#ActionButtonSpec |
|
487 #'name:' 'accept' |
|
488 #'label:' 'ok' |
|
489 #'tabable:' true |
|
490 #'isDefault:' true |
|
491 #'model:' #accept |
|
492 #'extent:' #(#Point 191 24) |
|
493 ) |
|
494 ) |
|
495 ) |
|
496 #'horizontalLayout:' #fitSpace |
|
497 #'verticalLayout:' #fit |
|
498 #'horizontalSpace:' 3 |
|
499 #'verticalSpace:' 3 |
|
500 ) |
|
501 ) |
|
502 ) |
|
503 ) |
|
504 ! |
|
505 |
|
506 windowSpec |
|
507 "this window spec was automatically generated by the ST/X UIPainter" |
|
508 |
|
509 "do not manually edit this - the painter/builder may not be able to |
|
510 handle the specification if its corrupted." |
|
511 |
|
512 " |
|
513 UIPainter new openOnClass:HierarchicalListEditor andSelector:#windowSpec |
|
514 HierarchicalListEditor new openInterface:#windowSpec |
|
515 " |
|
516 "HierarchicalListEditor open" |
|
517 |
|
518 <resource: #canvas> |
|
519 |
|
520 ^ |
|
521 |
|
522 #(#FullSpec |
|
523 #'window:' |
|
524 #(#WindowSpec |
|
525 #'name:' 'HierarchicalListEditor' |
|
526 #'layout:' #(#LayoutFrame 437 0 260 0 1004 0 554 0) |
|
527 #'label:' 'Hierarchical List Editor' |
|
528 #'min:' #(#Point 10 10) |
|
529 #'max:' #(#Point 1160 870) |
|
530 #'bounds:' #(#Rectangle 437 260 1005 555) |
|
531 ) |
|
532 #'component:' |
|
533 #(#SpecCollection |
|
534 #'collection:' |
|
535 #( |
|
536 #(#MenuPanelSpec |
|
537 #'name:' 'menuMain' |
|
538 #'layout:' #(#LayoutFrame 0 0.0 0 0 0 1.0 25 0) |
|
539 #'menu:' #menuMain |
|
540 ) |
|
541 #(#VariableHorizontalPanelSpec |
|
542 #'name:' 'variableHorizontalPanel1' |
|
543 #'layout:' #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0) |
|
544 #'component:' |
|
545 #(#SpecCollection |
|
546 #'collection:' |
|
547 #( |
|
548 #(#ViewSpec |
|
549 #'name:' 'view1' |
|
550 #'component:' |
|
551 #(#SpecCollection |
|
552 #'collection:' |
|
553 #( |
|
554 #(#MenuPanelSpec |
|
555 #'name:' 'menuButtons' |
|
556 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 28 0) |
|
557 #'menu:' #menuButtons |
|
558 ) |
|
559 #(#ArbitraryComponentSpec |
|
560 #'name:' 'treeView' |
|
561 #'layout:' #(#LayoutFrame 0 0.0 28 0.0 0 1.0 0 1.0) |
|
562 #'menu:' #menuTree |
|
563 #'hasHorizontalScrollBar:' true |
|
564 #'hasVerticalScrollBar:' true |
|
565 #'miniScrollerHorizontal:' true |
|
566 #'miniScrollerVertical:' true |
|
567 #'component:' #treeView |
|
568 #'hasBorder:' false |
|
569 ) |
|
570 ) |
|
571 ) |
|
572 ) |
|
573 #(#ViewSpec |
|
574 #'name:' 'view2' |
|
575 #'component:' |
|
576 #(#SpecCollection |
|
577 #'collection:' |
|
578 #( |
|
579 #(#ViewSpec |
|
580 #'name:' 'viewSpec' |
|
581 #'layout:' #(#LayoutFrame 0 0 0 0 0 0 0 0) |
|
582 #'component:' |
|
583 #(#SpecCollection |
|
584 #'collection:' |
|
585 #( |
|
586 #(#LabelSpec |
|
587 #'name:' 'nameLabel' |
|
588 #'layout:' #(#AlignmentOrigin 75 0 36 0 1 0.5) |
|
589 #'label:' 'Name:' |
|
590 #'resizeForLabel:' true |
|
591 ) |
|
592 #(#InputFieldSpec |
|
593 #'name:' 'nameFiled' |
|
594 #'layout:' #(#LayoutFrame 81 0 26 0 -5 1.0 48 0) |
|
595 #'model:' #itemName |
|
596 ) |
|
597 #(#LabelSpec |
|
598 #'name:' 'valueLabel' |
|
599 #'layout:' #(#AlignmentOrigin 75 0 71 0 1 0.5) |
|
600 #'label:' 'Value:' |
|
601 #'resizeForLabel:' true |
|
602 ) |
|
603 #(#InputFieldSpec |
|
604 #'name:' 'valueField' |
|
605 #'layout:' #(#LayoutFrame 81 0 61 0 -5 1.0 83 0) |
|
606 #'model:' #itemValue |
|
607 #'type:' #symbolOrNil |
|
608 ) |
|
609 #(#HorizontalPanelViewSpec |
|
610 #'name:' 'commitPanel' |
|
611 #'layout:' #(#LayoutFrame 0 0.0 -30 1.0 0 1.0 0 1.0) |
|
612 #'component:' |
|
613 #(#SpecCollection |
|
614 #'collection:' |
|
615 #( |
|
616 #(#ActionButtonSpec |
|
617 #'name:' 'cancelButton' |
|
618 #'label:' 'cancel' |
|
619 #'model:' #cancel |
|
620 #'enableChannel:' #modifiedChannel |
|
621 #'extent:' #(#Point 1 22) |
|
622 ) |
|
623 #(#ActionButtonSpec |
|
624 #'name:' 'acceptButton' |
|
625 #'label:' 'ok' |
|
626 #'model:' #accept |
|
627 #'enableChannel:' #modifiedChannel |
|
628 #'extent:' #(#Point 1 22) |
|
629 ) |
|
630 ) |
|
631 ) |
|
632 #'horizontalLayout:' #fitSpace |
|
633 #'verticalLayout:' #center |
|
634 #'horizontalSpace:' 3 |
|
635 #'verticalSpace:' 3 |
|
636 ) |
|
637 ) |
|
638 ) |
|
639 ) |
|
640 ) |
|
641 ) |
|
642 #'borderWidth:' 1 |
|
643 ) |
|
644 ) |
|
645 ) |
|
646 #'handles:' #(#Any 0.5 1.0) |
|
647 ) |
|
648 ) |
|
649 ) |
|
650 ) |
|
651 ! ! |
|
652 |
|
653 !HierarchicalListEditor class methodsFor:'printing'! |
|
654 |
|
655 prettyPrintArray:anArray on:aStream indent:anIndent |
|
656 "print a literal array in a nice format |
|
657 " |
|
658 |arg sol| |
|
659 |
|
660 sol := aStream position. |
|
661 aStream spaces:anIndent. |
|
662 aStream nextPutAll:'#('. |
|
663 |
|
664 anArray first isSymbol ifTrue:[ |
|
665 arg := anArray first. |
|
666 aStream nextPut:$#. |
|
667 aStream nextPutAll:anArray first. |
|
668 aStream cr. |
|
669 anArray size == 2 ifTrue:[ |
|
670 self prettyPrintArray:(anArray last) |
|
671 on:aStream |
|
672 indent:(anIndent + 4). |
|
673 ]. |
|
674 aStream spaces:anIndent. |
|
675 aStream nextPut:$). |
|
676 ^ self |
|
677 ]. |
|
678 |
|
679 aStream nextPut:$'. |
|
680 aStream nextPutAll:(anArray at:1). |
|
681 aStream nextPut:$'. |
|
682 arg := anArray at:2 ifAbsent:nil. |
|
683 |
|
684 arg isString ifTrue:[ |
|
685 aStream spaces:((50 - (aStream position - sol)) max:4). |
|
686 |
|
687 arg isSymbol ifTrue:[ |
|
688 aStream nextPut:$#. |
|
689 ]. |
|
690 aStream nextPut:$'. |
|
691 aStream nextPutAll:arg. |
|
692 aStream nextPut:$'. |
|
693 arg := anArray at:3 ifAbsent:nil. |
|
694 ]. |
|
695 arg isArray ifTrue:[ |
|
696 aStream nextPutAll:' #('. |
|
697 aStream cr. |
|
698 arg do:[:e|self prettyPrintArray:e on:aStream indent:(anIndent + 4)]. |
|
699 aStream spaces:anIndent. |
|
700 aStream nextPut:$). |
|
701 ]. |
|
702 aStream nextPut:$). |
|
703 aStream cr. |
|
704 ! ! |
|
705 |
|
706 !HierarchicalListEditor methodsFor:'accessing'! |
|
707 |
|
708 didInstall |
|
709 "returns true if spec was installed by operator |
|
710 " |
|
711 ^ didInstall ? false |
|
712 ! |
|
713 |
|
714 selectorName |
|
715 "returns current spec. selector |
|
716 " |
|
717 ^ specSelector |
|
718 ! ! |
|
719 |
|
720 !HierarchicalListEditor methodsFor:'actions'! |
|
721 |
|
722 accept |
|
723 "accept changes" |
|
724 |
|
725 |node index| |
|
726 |
|
727 (index := treeView selectedIndex) ~~ 0 ifTrue:[ |
|
728 node := treeView nodeAtIndex:index. |
|
729 node name:(self itemName value). |
|
730 node contents:(self itemValue value). |
|
731 treeView redrawLine:index. |
|
732 ]. |
|
733 self modifiedChannel value:false. |
|
734 |
|
735 ! |
|
736 |
|
737 cancel |
|
738 "reload selected item and update channels |
|
739 " |
|
740 |node| |
|
741 |
|
742 (node := treeView selectedNode) notNil ifTrue:[ |
|
743 self itemName value:node name. |
|
744 self itemValue value:node contents. |
|
745 (builder componentAt:#viewSpec) extent:1.0@1.0. |
|
746 ] ifFalse:[ |
|
747 (builder componentAt:#viewSpec) extent:0@0. |
|
748 self itemName value:''. |
|
749 self itemValue value:nil. |
|
750 ]. |
|
751 self modifiedChannel value:false. |
|
752 ! ! |
|
753 |
|
754 !HierarchicalListEditor methodsFor:'aspects'! |
|
755 |
|
756 canCreateChildChannel |
|
757 "automatically generated by UIPainter ..." |
|
758 |
|
759 ^ builder booleanValueAspectFor:#canCreateChildChannel |
|
760 |
|
761 ! |
|
762 |
|
763 canCreateSisterChannel |
|
764 "automatically generated by UIPainter ..." |
|
765 |
|
766 ^ builder booleanValueAspectFor:#canCreateSisterChannel |
|
767 |
|
768 ! |
|
769 |
|
770 canStepInChannel |
|
771 "automatically generated by UIPainter ..." |
|
772 |
|
773 ^ builder booleanValueAspectFor:#canStepInChannel |
|
774 |
|
775 ! |
|
776 |
|
777 canStepOutChannel |
|
778 "automatically generated by UIPainter ..." |
|
779 |
|
780 ^ builder booleanValueAspectFor:#canStepOutChannel |
|
781 |
|
782 ! |
|
783 |
|
784 canStepOverChannel |
|
785 "automatically generated by UIPainter ..." |
|
786 |
|
787 ^ builder booleanValueAspectFor:#canStepOverChannel |
|
788 |
|
789 ! |
|
790 |
|
791 itemName |
|
792 "automatically generated by UIPainter ..." |
|
793 |
|
794 |holder| |
|
795 |
|
796 (holder := builder bindingAt:#itemName) isNil ifTrue:[ |
|
797 builder aspectAt:#itemName put:(holder := ValueHolder new). |
|
798 holder addDependent:self. |
|
799 ]. |
|
800 ^ holder |
|
801 ! |
|
802 |
|
803 itemValue |
|
804 "automatically generated by UIPainter ..." |
|
805 |
|
806 |holder| |
|
807 |
|
808 (holder := builder bindingAt:#itemValue) isNil ifTrue:[ |
|
809 builder aspectAt:#itemValue put:(holder := ValueHolder new). |
|
810 holder addDependent:self. |
|
811 ]. |
|
812 ^ holder |
|
813 ! |
|
814 |
|
815 modifiedChannel |
|
816 "automatically generated by UIPainter ..." |
|
817 |
|
818 ^ builder booleanValueAspectFor:#modifiedChannel |
|
819 |
|
820 ! |
|
821 |
|
822 treeView |
|
823 "automatically generated by UIPainter ..." |
|
824 |
|
825 ^ treeView |
|
826 ! ! |
|
827 |
|
828 !HierarchicalListEditor methodsFor:'change & update'! |
|
829 |
|
830 update:something with:aParameter from:someObject |
|
831 "one of my models changed |
|
832 " |
|
833 self modifiedChannel value:true |
|
834 ! ! |
|
835 |
|
836 !HierarchicalListEditor methodsFor:'menu buttons'! |
|
837 |
|
838 doCreateChild |
|
839 "create a child within selected parent |
|
840 " |
|
841 |node| |
|
842 |
|
843 (node := treeView selectedNode) notNil ifTrue:[ |
|
844 treeView model add:(self newItem) beforeIndex:1 below:node. |
|
845 treeView selectedNodeExpand:true. |
|
846 self updateChannels. |
|
847 ]. |
|
848 ! |
|
849 |
|
850 doCreateSister |
|
851 "create a sister next to selected item |
|
852 " |
|
853 |node| |
|
854 |
|
855 (node := treeView selectedNode) notNil ifTrue:[ |
|
856 node parent notNil ifTrue:[ |
|
857 treeView model add:(self newItem) after:node |
|
858 ] ifFalse:[ |
|
859 treeView model add:(self newItem) beforeIndex:1 below:node |
|
860 ]. |
|
861 self updateChannels |
|
862 ]. |
|
863 ! |
|
864 |
|
865 doStepDown |
|
866 "move selected item after next item |
|
867 " |
|
868 treeView selectedNodeChangeSequenceOrder:1. |
|
869 self updateChannels. |
|
870 ! |
|
871 |
|
872 doStepIn |
|
873 "lets become the selected item a child of its next sister |
|
874 " |
|
875 treeView selectedNodeBecomeChildOfNext. |
|
876 self updateChannels. |
|
877 ! |
|
878 |
|
879 doStepOut |
|
880 "let selected node become a sister of its current parent |
|
881 " |
|
882 treeView selectedNodeBecomeSisterOfParent. |
|
883 self updateChannels. |
|
884 ! |
|
885 |
|
886 doStepUp |
|
887 "move selected item before previous item |
|
888 " |
|
889 treeView selectedNodeChangeSequenceOrder:-1. |
|
890 self updateChannels. |
|
891 ! |
|
892 |
|
893 menuButtons |
|
894 "this window spec was automatically generated by the ST/X MenuEditor" |
|
895 |
|
896 ^ self class menuButtons |
|
897 |
|
898 |
|
899 ! ! |
|
900 |
|
901 !HierarchicalListEditor methodsFor:'menu main'! |
|
902 |
|
903 doBrowse:what |
|
904 "open a system browser |
|
905 " |
|
906 |cls sel| |
|
907 |
|
908 (cls := specClass) notNil ifTrue:[ |
|
909 what == #class ifFalse:[ |
|
910 (sel := specSelector) isNil ifTrue:[ |
|
911 ^ self |
|
912 ]. |
|
913 what == #spec ifTrue:[cls := cls class] |
|
914 ]. |
|
915 |
|
916 SystemBrowser openInClass:cls selector:sel |
|
917 ] |
|
918 ! |
|
919 |
|
920 doDefineClass |
|
921 "define class and selector |
|
922 " |
|
923 |sel cls bindings accepted| |
|
924 |
|
925 masterApplication notNil ifTrue:[ |
|
926 ^ self information:'only selector could be changed.' |
|
927 ]. |
|
928 accepted := true. |
|
929 bindings := IdentityDictionary new. |
|
930 |
|
931 specClass notNil ifTrue:[cls := specClass name asString] |
|
932 ifFalse:[cls := '']. |
|
933 |
|
934 specSelector notNil ifTrue:[sel := specSelector asString] |
|
935 ifFalse:[sel := '']. |
|
936 |
|
937 bindings at:#specSelectorChannel put:(sel asValue). |
|
938 bindings at:#specClassChannel put:(cls asValue). |
|
939 |
|
940 [accepted] whileTrue:[ |
|
941 accepted := self openDialogInterface:#classAndMethodSpec withBindings:bindings. |
|
942 |
|
943 accepted ifTrue:[ |
|
944 cls := Smalltalk at:(bindings at:#specClassChannel) value asSymbol. |
|
945 |
|
946 cls notNil ifTrue:[ |
|
947 sel := (bindings at:#specSelectorChannel) value withoutSeparators. |
|
948 |
|
949 sel size ~~ 0 ifTrue:[ |
|
950 specClass := cls. |
|
951 specSelector := sel asSymbol. |
|
952 ^ self |
|
953 ] |
|
954 ] |
|
955 ] |
|
956 ] |
|
957 |
|
958 ! |
|
959 |
|
960 doDefineSelector |
|
961 "define selector only |
|
962 " |
|
963 |sel cls bindings accepted| |
|
964 |
|
965 accepted := true. |
|
966 bindings := IdentityDictionary new. |
|
967 |
|
968 specSelector notNil ifTrue:[sel := specSelector asString] |
|
969 ifFalse:[sel := '']. |
|
970 |
|
971 bindings at:#specSelectorChannel put:(sel asValue). |
|
972 |
|
973 [accepted] whileTrue:[ |
|
974 accepted := self openDialogInterface:#methodSpec withBindings:bindings. |
|
975 |
|
976 accepted ifTrue:[ |
|
977 sel := (bindings at:#specSelectorChannel) value withoutSeparators. |
|
978 |
|
979 sel size ~~ 0 ifTrue:[ |
|
980 specSelector := sel asSymbol. |
|
981 ^ self |
|
982 ] |
|
983 ] |
|
984 ] |
|
985 |
|
986 ! |
|
987 |
|
988 doInstall |
|
989 "install code |
|
990 " |
|
991 |code spec category mthd stream| |
|
992 |
|
993 (specClass notNil and:[specSelector notNil]) ifFalse:[ |
|
994 ^ self information:'no valid class & method defined'. |
|
995 ]. |
|
996 |
|
997 spec := (treeView nodeAtIndex:1) literalArrayEncoding. |
|
998 stream := WriteStream on:String new. |
|
999 self class prettyPrintArray:spec on:stream indent:4. |
|
1000 spec := stream contents. |
|
1001 category := 'interface specs'. |
|
1002 didInstall := true. |
|
1003 |
|
1004 (mthd := specClass class compiledMethodAt:specSelector) notNil ifTrue:[ |
|
1005 category := mthd category. |
|
1006 ]. |
|
1007 |
|
1008 code := Character excla asString |
|
1009 , specClass name , ' class methodsFor:' , category storeString |
|
1010 , Character excla asString , '\\' |
|
1011 |
|
1012 , specSelector , '\' |
|
1013 , ' "this window spec was automatically generated by the ST/X HierarchicalListEditor"\\' |
|
1014 , ' "do not manually edit this - the builder may not be able to\' |
|
1015 , ' handle the specification if its corrupted."\\' |
|
1016 , ' "\' |
|
1017 , ' HierarchicalListEditor new openOnClass:' , specClass name , ' andSelector:#' , specSelector , '\' |
|
1018 , ' "\'. |
|
1019 |
|
1020 code := code |
|
1021 , '\' |
|
1022 , ' <resource: #hierarchicalList>\\' |
|
1023 , ' ^\' |
|
1024 , spec |
|
1025 , ' decodeAsLiteralArray\' |
|
1026 , Character excla asString |
|
1027 , ' ' |
|
1028 , Character excla asString |
|
1029 , '\\'. |
|
1030 |
|
1031 code := code withCRs. |
|
1032 (ReadStream on:code) fileIn. |
|
1033 |
|
1034 (specClass compiledMethodAt:specSelector) isNil ifTrue:[ |
|
1035 category := 'aspects'. |
|
1036 |
|
1037 code := Character excla asString |
|
1038 , specClass name , ' methodsFor:' , category storeString |
|
1039 , Character excla asString , '\\' |
|
1040 |
|
1041 , specSelector , '\' |
|
1042 , ' "this window spec was automatically generated by the ST/X HierarchicalListEditor"\\' |
|
1043 , ' |holder root|\\' |
|
1044 , ' (holder := builder bindingAt:#', specSelector, ') isNil ifTrue:[\' |
|
1045 , ' holder := SelectionInTree new.\' |
|
1046 , ' root := self class ', specSelector, '.\' |
|
1047 , ' root expand.\' |
|
1048 , ' holder root:root.\' |
|
1049 , ' ].\' |
|
1050 , ' ^ holder' |
|
1051 , '\' |
|
1052 , Character excla asString |
|
1053 , ' ' |
|
1054 , Character excla asString |
|
1055 , '\\'. |
|
1056 |
|
1057 code := code withCRs. |
|
1058 (ReadStream on:code) fileIn. |
|
1059 ]. |
|
1060 |
|
1061 |
|
1062 ! |
|
1063 |
|
1064 doNew |
|
1065 "remove all items; restart |
|
1066 " |
|
1067 |anchor| |
|
1068 |
|
1069 anchor := TreeItem name:'Anchor' contents:#anchor. |
|
1070 anchor expand. |
|
1071 treeView model:(SelectionInTree new root:anchor). |
|
1072 treeView selection:0. |
|
1073 |
|
1074 ! |
|
1075 |
|
1076 doReload |
|
1077 "reload spec from current class and selector |
|
1078 " |
|
1079 self buildFrom:specClass andSelector:specSelector |
|
1080 |
|
1081 ! |
|
1082 |
|
1083 menuMain |
|
1084 "this window spec was automatically generated by the ST/X MenuEditor" |
|
1085 |
|
1086 ^ self class menuMain |
|
1087 |
|
1088 |
|
1089 ! ! |
|
1090 |
|
1091 !HierarchicalListEditor methodsFor:'menu tree'! |
|
1092 |
|
1093 doCopy |
|
1094 "copy current selected nodes into copy buffer |
|
1095 " |
|
1096 CopyBuffer := OrderedCollection new. |
|
1097 treeView selectedNodesDo:[:aNode| CopyBuffer add:(aNode copy)]. |
|
1098 |
|
1099 ! |
|
1100 |
|
1101 doCut |
|
1102 "cut current selected nodes |
|
1103 " |
|
1104 treeView hasSelection ifTrue:[ |
|
1105 self doCopy. |
|
1106 treeView selectedNodesRemove. |
|
1107 self updateChannels. |
|
1108 ] |
|
1109 ! |
|
1110 |
|
1111 doPaste |
|
1112 "paste after current selected item |
|
1113 " |
|
1114 treeView selectedNodeAdd:CopyBuffer. |
|
1115 self updateChannels. |
|
1116 ! |
|
1117 |
|
1118 menuTree |
|
1119 "this window spec was automatically generated by the ST/X MenuEditor" |
|
1120 |
|
1121 ^ self class menuTree |
|
1122 |
|
1123 |
|
1124 ! ! |
|
1125 |
|
1126 !HierarchicalListEditor methodsFor:'private'! |
|
1127 |
|
1128 newItem |
|
1129 "creates and returns a new default item |
|
1130 " |
|
1131 ^ TreeItem name:'undefined' contents:nil |
|
1132 ! |
|
1133 |
|
1134 updateChannels |
|
1135 "update channels |
|
1136 " |
|
1137 |node parent chnStepIn chnStepOut chnStepOvr chnChild chnSister| |
|
1138 |
|
1139 chnStepIn := chnStepOut := chnStepOvr := chnChild := chnSister := false. |
|
1140 |
|
1141 (node := treeView selectedNode) notNil ifTrue:[ |
|
1142 chnChild := true. |
|
1143 |
|
1144 (parent := node parent) notNil ifTrue:[ |
|
1145 chnSister := true. |
|
1146 chnStepOvr := parent numberOfChildren > 1. |
|
1147 chnStepOut := parent parent notNil. |
|
1148 chnStepIn := node ~~ parent lastChild. |
|
1149 ] |
|
1150 ]. |
|
1151 self canCreateChildChannel value:chnChild. |
|
1152 self canCreateSisterChannel value:chnSister. |
|
1153 self canStepOverChannel value:chnStepOvr. |
|
1154 self canStepOutChannel value:chnStepOut. |
|
1155 self canStepInChannel value:chnStepIn. |
|
1156 ! ! |
|
1157 |
|
1158 !HierarchicalListEditor methodsFor:'queries'! |
|
1159 |
|
1160 canChangeClassName |
|
1161 "returns true if current class could be changed which is dependent on |
|
1162 the mode: standalone or started by UIPainter |
|
1163 " |
|
1164 ^ masterApplication isNil |
|
1165 ! |
|
1166 |
|
1167 canCopy |
|
1168 "returns true if any selection exists |
|
1169 " |
|
1170 ^ treeView selection notNil |
|
1171 ! |
|
1172 |
|
1173 canCut |
|
1174 "returns true if any selection exists and not includes |
|
1175 the anchor (first element into list). |
|
1176 " |
|
1177 treeView selection notNil ifTrue:[ |
|
1178 ^ (treeView isInSelection:1) not |
|
1179 ]. |
|
1180 ^ false |
|
1181 ! |
|
1182 |
|
1183 canPaste |
|
1184 "returns true if something to be paste exists and a |
|
1185 single selection exists |
|
1186 " |
|
1187 ^ (CopyBuffer notNil and:[treeView selectedNode notNil]) |
|
1188 ! |
|
1189 |
|
1190 hasValidClass |
|
1191 "returns true if the class defined allready exists |
|
1192 " |
|
1193 ^ specClass isBehavior |
|
1194 ! |
|
1195 |
|
1196 hasValidMethodSelector |
|
1197 "returns true if the class and the instance selector defined |
|
1198 allready exists. |
|
1199 " |
|
1200 (specSelector notNil and:[self hasValidClass]) ifTrue:[ |
|
1201 ^ (specClass compiledMethodAt:specSelector) notNil |
|
1202 ]. |
|
1203 ^ false |
|
1204 ! |
|
1205 |
|
1206 hasValidSpecSelector |
|
1207 "returns true if the class and the class selector defined |
|
1208 allready exists. |
|
1209 " |
|
1210 (specSelector notNil and:[self hasValidClass]) ifTrue:[ |
|
1211 ^ (specClass class compiledMethodAt:specSelector) notNil |
|
1212 ]. |
|
1213 ! ! |
|
1214 |
|
1215 !HierarchicalListEditor methodsFor:'startup/release'! |
|
1216 |
|
1217 buildFrom:aClass andSelector:aSelector |
|
1218 "rebuild window from a class and selector |
|
1219 " |
|
1220 |sel anchor stream| |
|
1221 |
|
1222 (specClass := aClass) isBehavior ifFalse:[ |
|
1223 specClass notNil ifTrue:[ |
|
1224 specClass := Smalltalk at:aClass asSymbol |
|
1225 ] |
|
1226 ]. |
|
1227 specSelector := nil. |
|
1228 |
|
1229 aSelector size ~~ 0 ifTrue:[ |
|
1230 sel := aSelector asString withoutSeparators. |
|
1231 sel size ~~ 0 ifTrue:[ |
|
1232 specSelector := sel asSymbol |
|
1233 ] |
|
1234 ]. |
|
1235 treeView selection:nil. |
|
1236 |
|
1237 (specSelector notNil and:[specClass notNil]) ifTrue:[ |
|
1238 (specClass respondsTo:specSelector) ifTrue:[ |
|
1239 anchor := specClass perform:specSelector. |
|
1240 |
|
1241 anchor isArray ifTrue:[ |
|
1242 anchor := anchor decodeAsLiteralArray. |
|
1243 ] |
|
1244 ] |
|
1245 ]. |
|
1246 anchor notNil ifTrue:[ |
|
1247 anchor expand. |
|
1248 treeView model root:anchor. |
|
1249 ] ifFalse:[ |
|
1250 self doNew |
|
1251 ]. |
|
1252 ! |
|
1253 |
|
1254 initialize |
|
1255 "setup default values |
|
1256 " |
|
1257 super initialize. |
|
1258 |
|
1259 treeView := SelectionInTreeView new. |
|
1260 treeView multipleSelectOk:true. |
|
1261 treeView action:[:aNr| self updateChannels. self cancel ]. |
|
1262 self doNew. |
|
1263 ! |
|
1264 |
|
1265 openModalOnClass:aClass andSelector:aSelector |
|
1266 "open modal on class and selector |
|
1267 " |
|
1268 specClass := Association key:aClass value:aSelector. |
|
1269 super openInterfaceModal. |
|
1270 |
|
1271 |
|
1272 ! |
|
1273 |
|
1274 openOnClass:aClass andSelector:aSelector |
|
1275 "open on class and selector |
|
1276 " |
|
1277 specClass := Association key:aClass value:aSelector. |
|
1278 super openInterface. |
|
1279 |
|
1280 ! |
|
1281 |
|
1282 postBuildWith:builder |
|
1283 "setup view |
|
1284 " |
|
1285 |cls sel| |
|
1286 |
|
1287 specClass isAssociation ifTrue:[ |
|
1288 cls := specClass key. |
|
1289 sel := specClass value. |
|
1290 ]. |
|
1291 self buildFrom:cls andSelector:sel. |
|
1292 |
|
1293 ! ! |
|
1294 |
|
1295 !HierarchicalListEditor class methodsFor:'documentation'! |
|
1296 |
|
1297 version |
|
1298 ^ '$Header$' |
|
1299 ! ! |