45 [author:] |
45 [author:] |
46 Claus Atzkern |
46 Claus Atzkern |
47 " |
47 " |
48 ! ! |
48 ! ! |
49 |
49 |
|
50 !UIHelpTool class methodsFor:'instance creation'! |
|
51 |
|
52 openOnClass:aClass |
|
53 " |
|
54 UIHelpTool openOnClass:UIPainter |
|
55 " |
|
56 |helpTool| |
|
57 |
|
58 helpTool := UIHelpTool new. |
|
59 helpTool openInterface:#standAloneSpec. |
|
60 helpTool helpSpecFrom:UIPainter |
|
61 |
|
62 |
|
63 ! ! |
|
64 |
|
65 !UIHelpTool class methodsFor:'constants'! |
|
66 |
|
67 label |
|
68 ^ 'Help' |
|
69 ! ! |
|
70 |
50 !UIHelpTool class methodsFor:'help specs'! |
71 !UIHelpTool class methodsFor:'help specs'! |
51 |
72 |
52 helpSpec |
73 helpSpec |
53 "return a dictionary filled with helpKey -> helptext associations. |
74 "return a dictionary filled with helpKey -> helptext associations. |
54 These are used by the activeHelp tool. |
75 These are used by the activeHelp tool. |
55 " |
76 " |
56 ^ super helpSpec addPairsFrom:#( |
77 ^ super helpSpec addPairsFrom:#( |
57 |
78 |
58 #activeHelpAccessKey |
79 #activeHelpAccessKey |
59 'This ID is used to access an active |
80 'This ID is used to access an active help text for the selected component' |
60 help text for the selected component' |
|
61 |
81 |
62 ) |
82 ) |
63 |
83 |
64 ! ! |
84 ! ! |
65 |
85 |
66 !UIHelpTool class methodsFor:'interface specs'! |
86 !UIHelpTool class methodsFor:'interface specs'! |
67 |
87 |
68 windowSpec |
88 menuPanelStandAlone |
|
89 "this window spec was automatically generated by the ST/X MenuEditor" |
|
90 |
|
91 "do not manually edit this - the builder may not be able to |
|
92 handle the specification if its corrupted." |
|
93 |
|
94 " |
|
95 MenuEditor new openOnClass:UIHelpTool andSelector:#menuPanelStandAlone |
|
96 (Menu new fromLiteralArrayEncoding:(UIHelpTool menuPanelStandAlone)) startUp |
|
97 " |
|
98 |
|
99 <resource: #menu> |
|
100 |
|
101 ^ |
|
102 |
|
103 #(#Menu |
|
104 |
|
105 #( |
|
106 #(#MenuItem |
|
107 #'label:' 'file' |
|
108 #'submenu:' |
|
109 #(#Menu |
|
110 |
|
111 #( |
|
112 #(#MenuItem |
|
113 #'label:' 'reload' |
|
114 #'value:' #doReload |
|
115 ) |
|
116 #(#MenuItem |
|
117 #'label:' '-' |
|
118 ) |
|
119 #(#MenuItem |
|
120 #'label:' 'close' |
|
121 #'value:' #closeRequest |
|
122 ) |
|
123 ) nil |
|
124 nil |
|
125 ) |
|
126 ) |
|
127 #(#MenuItem |
|
128 #'label:' 'code' |
|
129 #'submenu:' |
|
130 #(#Menu |
|
131 |
|
132 #( |
|
133 #(#MenuItem |
|
134 #'label:' 'class' |
|
135 #'value:' #doFromClass |
|
136 ) |
|
137 #(#MenuItem |
|
138 #'label:' '-' |
|
139 ) |
|
140 #(#MenuItem |
|
141 #'label:' 'install help spec.' |
|
142 #'value:' #doInstallHelpSpec |
|
143 ) |
|
144 ) nil |
|
145 nil |
|
146 ) |
|
147 ) |
|
148 ) nil |
|
149 nil |
|
150 ) |
|
151 ! |
|
152 |
|
153 standAloneSpec |
69 "this window spec was automatically generated by the ST/X UIPainter" |
154 "this window spec was automatically generated by the ST/X UIPainter" |
70 |
155 |
71 "do not manually edit this - the painter/builder may not be able to |
156 "do not manually edit this - the painter/builder may not be able to |
72 handle the specification if its corrupted." |
157 handle the specification if its corrupted." |
73 |
158 |
74 " |
159 " |
75 UIPainter new openOnClass:UIHelpTool andSelector:#windowSpec |
160 UIPainter new openOnClass:UIHelpTool andSelector:#standAloneSpec |
76 UIHelpTool new openInterface:#windowSpec |
161 UIHelpTool new openInterface:#standAloneSpec |
77 " |
162 " |
78 "UIHelpTool open" |
|
79 |
163 |
80 <resource: #canvas> |
164 <resource: #canvas> |
81 |
165 |
82 ^ |
166 ^ |
83 |
167 |
84 #(#FullSpec |
168 #(#FullSpec |
85 #'window:' |
169 #'window:' |
86 #(#WindowSpec |
170 #(#WindowSpec |
87 #'name:' 'uIPainterView' |
171 #'name:' 'HelpTool' |
88 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
172 #'layout:' #(#LayoutFrame 199 0 167 0 794 0 664 0) |
89 #'label:' 'unnamed canvas' |
173 #'label:' 'HelpTool' |
90 #'bounds:' #(#Rectangle 0 0 286 272) |
174 #'min:' #(#Point 10 10) |
|
175 #'max:' #(#Point 1160 870) |
|
176 #'bounds:' #(#Rectangle 199 167 795 665) |
91 ) |
177 ) |
92 #'component:' |
178 #'component:' |
93 #(#SpecCollection |
179 #(#SpecCollection |
94 #'collection:' |
180 #'collection:' |
95 #( |
181 #( |
|
182 #(#MenuPanelSpec |
|
183 #'name:' 'menuPanelStandAlone' |
|
184 #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 25 0) |
|
185 #'menu:' #menuPanelStandAlone |
|
186 ) |
|
187 #(#VariableHorizontalPanelSpec |
|
188 #'name:' 'variableHorizontalPanel1' |
|
189 #'layout:' #(#LayoutFrame 0 0.0 25 0.0 0 1.0 0 1.0) |
|
190 #'component:' |
|
191 #(#SpecCollection |
|
192 #'collection:' |
|
193 #( |
|
194 #(#TextEditorSpec |
|
195 #'name:' 'textView' |
|
196 #'hasHorizontalScrollBar:' true |
|
197 #'hasVerticalScrollBar:' true |
|
198 #'miniScrollerHorizontal:' true |
|
199 #'miniScrollerVertical:' true |
|
200 ) |
|
201 #(#SequenceViewSpec |
|
202 #'name:' 'selectionList' |
|
203 #'model:' #selectionListModel |
|
204 #'hasHorizontalScrollBar:' true |
|
205 #'hasVerticalScrollBar:' true |
|
206 #'miniScrollerHorizontal:' true |
|
207 #'miniScrollerVertical:' true |
|
208 ) |
|
209 ) |
|
210 ) |
|
211 ) |
|
212 ) |
|
213 ) |
|
214 ) |
|
215 ! |
|
216 |
|
217 windowSpec |
|
218 "this window spec was automatically generated by the ST/X UIPainter" |
|
219 |
|
220 "do not manually edit this - the painter/builder may not be able to |
|
221 handle the specification if its corrupted." |
|
222 |
|
223 " |
|
224 UIPainter new openOnClass:UIHelpTool andSelector:#windowSpec |
|
225 UIHelpTool new openInterface:#windowSpec |
|
226 " |
|
227 "UIHelpTool open" |
|
228 |
|
229 <resource: #canvas> |
|
230 |
|
231 ^ |
|
232 |
|
233 #(#FullSpec |
|
234 #'window:' |
|
235 #(#WindowSpec |
|
236 #'name:' 'HelpTool' |
|
237 #'layout:' #(#LayoutFrame 199 0 167 0 484 0 437 0) |
|
238 #'label:' 'unnamed canvas' |
|
239 #'min:' #(#Point 10 10) |
|
240 #'max:' #(#Point 1160 870) |
|
241 #'bounds:' #(#Rectangle 199 167 485 438) |
|
242 ) |
|
243 #'component:' |
|
244 #(#SpecCollection |
|
245 #'collection:' |
|
246 #( |
|
247 #(#LabelSpec |
|
248 #'name:' 'keyLabel' |
|
249 #'layout:' #(#AlignmentOrigin 3 0.0 42 0.0 0 1) |
|
250 #'label:' 'Key:' |
|
251 #'adjust:' #left |
|
252 #'resizeForLabel:' true |
|
253 ) |
|
254 #(#ComboBoxSpec |
|
255 #'name:' 'comboBox' |
|
256 #'layout:' #(#LayoutFrame 48 0 22 0 -3 1.0 44 0) |
|
257 #'activeHelpKey:' #activeHelpAccessKey |
|
258 #'tabable:' true |
|
259 #'model:' #listModel |
|
260 #'type:' #symbolOrNil |
|
261 #'comboList:' #listChannel |
|
262 ) |
96 #(#TextEditorSpec |
263 #(#TextEditorSpec |
97 #'name:' 'textView' |
264 #'name:' 'textView' |
98 #'layout:' #(#LayoutFrame 46 0 25 0.0 0 1.0 0 1.0) |
265 #'layout:' #(#LayoutFrame 3 0.0 45 0.0 -3 1.0 -3 1.0) |
99 #'model:' #textChannel |
|
100 #'hasHorizontalScrollBar:' true |
266 #'hasHorizontalScrollBar:' true |
101 #'hasVerticalScrollBar:' true |
267 #'hasVerticalScrollBar:' true |
102 #'miniScrollerHorizontal:' true |
268 #'miniScrollerHorizontal:' true |
103 #'miniScrollerVertical:' true |
269 #'miniScrollerVertical:' true |
104 ) |
270 ) |
105 #(#LabelSpec |
|
106 #'name:' 'keyLabel' |
|
107 #'layout:' #(#LayoutFrame 0 0.0 1 0.0 41 0 21 0) |
|
108 #'label:' 'Key:' |
|
109 #'adjust:' #left |
|
110 #'resizeForLabel:' false |
|
111 ) |
|
112 #(#ComboBoxSpec |
|
113 #'name:' 'comboBox' |
|
114 #'layout:' #(#LayoutFrame 48 0 1 0 0 1.0 23 0) |
|
115 #'activeHelpKey:' #activeHelpAccessKey |
|
116 #'tabable:' true |
|
117 #'comboList:' #listChannel |
|
118 ) |
|
119 #(#LabelSpec |
|
120 #'name:' 'textLabel' |
|
121 #'layout:' #(#LayoutFrame 0 0.0 25 0.0 41 0 45 0) |
|
122 #'label:' 'Text:' |
|
123 #'adjust:' #left |
|
124 #'resizeForLabel:' false |
|
125 ) |
|
126 ) |
271 ) |
127 ) |
272 ) |
128 ) |
273 ) |
129 |
|
130 "Modified: 28.7.1997 / 14:15:27 / cg" |
|
131 ! ! |
274 ! ! |
132 |
275 |
133 !UIHelpTool class methodsFor:'misc'! |
276 !UIHelpTool class methodsFor:'misc'! |
134 |
277 |
135 applicationClassAssociatedWith:aClass |
278 applicationClassAssociatedWith:aClass |
157 ^ dictionary! |
300 ^ dictionary! |
158 |
301 |
159 dictionary:aDictionary |
302 dictionary:aDictionary |
160 "set the value of the instance variable 'dictionary' (automatically generated)" |
303 "set the value of the instance variable 'dictionary' (automatically generated)" |
161 |
304 |
162 (dictionary := aDictionary) notNil ifTrue:[ |
305 (dictionary := aDictionary) isNil ifTrue:[ |
163 list := dictionary keys asOrderedCollection |
|
164 ] ifFalse:[ |
|
165 dictionary := IdentityDictionary new. |
306 dictionary := IdentityDictionary new. |
166 list := nil |
307 ]. |
167 ]. |
308 self updateList |
|
309 ! |
|
310 |
|
311 helpKey |
|
312 listSelection size ~~ 0 ifTrue:[ |
|
313 ^ listSelection asSymbol |
|
314 ]. |
|
315 ^ nil |
|
316 ! |
|
317 |
|
318 helpKey:aKey |
|
319 |key| |
|
320 |
|
321 aKey size ~~ 0 ifTrue:[ |
|
322 key := aKey asString |
|
323 ]. |
|
324 self listModel value:key |
168 ! |
325 ! |
169 |
326 |
170 helpSpecFrom:aClass |
327 helpSpecFrom:aClass |
171 "read help text from an application associated with the class |
328 "read help text from an application associated with the class |
172 " |
329 " |
173 |help cls| |
330 |help| |
174 |
331 |
175 cls := self class applicationClassAssociatedWith:aClass. |
332 specClass := self class applicationClassAssociatedWith:aClass. |
176 |
333 |
177 (cls respondsTo:#helpSpec) ifTrue:[ |
334 (specClass respondsTo:#helpSpec) ifTrue:[ |
178 help := cls helpSpec |
335 help := specClass helpSpec |
|
336 ] ifFalse:[ |
|
337 specClass := nil |
179 ]. |
338 ]. |
180 self dictionary:help |
339 self dictionary:help |
181 ! |
340 ! |
182 |
341 |
183 key |
342 modifiedHolder:aValueHolder |
184 "get the key from the edit field as symbol or nil |
343 "set the value holder set to true in case of modifying attributes |
185 " |
344 " |
186 |key| |
345 modifiedHolder notNil ifTrue:[ |
187 |
346 modifiedHolder removeDependent:self. |
188 key := model value. |
347 ]. |
189 |
348 |
190 ( key size ~~ 0 |
349 (modifiedHolder := aValueHolder) notNil ifTrue:[ |
191 and:[(key indexOfSeparatorStartingAt:1) == 0 |
350 modifiedHolder addDependent:self. |
192 or:[(key := key withoutSeparators) notEmpty]] |
351 ]. |
193 ) ifTrue:[ |
352 |
194 ^ key asSymbol |
353 |
195 ]. |
354 ! |
196 ^ nil |
355 |
197 ! |
356 updateList |
198 |
357 "update list from dictionary |
199 model:aKeyHolder |
358 " |
200 "set the model on the edit field |
359 self listChannel value:(dictionary keys asSortedCollection) |
201 " |
|
202 model notNil ifTrue:[ |
|
203 model removeDependent:self |
|
204 ]. |
|
205 (model := aKeyHolder) notNil ifTrue:[ |
|
206 model addDependent:self |
|
207 ]. |
|
208 (builder componentAt:#comboBox) model:model. |
|
209 self update:nil with:#model from:model. |
|
210 ! ! |
360 ! ! |
211 |
361 |
212 !UIHelpTool methodsFor:'actions'! |
362 !UIHelpTool methodsFor:'actions'! |
213 |
363 |
214 accept |
364 accept |
215 "accept the text |
365 "accept the text |
216 " |
366 " |
217 |key txt| |
367 |view key txt list| |
218 |
368 |
219 key := self key. |
369 (listSelection size == 0 or:[(view := self editTextView) isNil]) ifFalse:[ |
220 txt := self textChannel. |
370 txt := view contents asString. |
221 |
371 key := listSelection asSymbol. |
222 key notNil ifTrue:[ |
372 list := self listChannel value. |
223 txt dependentsDo:[:edt| edt accept]. |
|
224 |
373 |
225 (dictionary at:key ifAbsent:nil) isNil ifTrue:[ |
374 (dictionary at:key ifAbsent:nil) isNil ifTrue:[ |
226 list add:key. |
375 list add:key. |
227 self listChannel value:list |
|
228 ]. |
376 ]. |
229 dictionary at:key put:(txt value) |
377 dictionary at:key put:txt |
230 ] ifFalse:[ |
|
231 key := nil. |
|
232 txt value:nil. |
|
233 ]. |
|
234 |
|
235 model notNil ifTrue:[ |
|
236 model value:key |
|
237 ] |
378 ] |
238 ! |
379 ! |
239 |
380 |
240 installHelpSpecInto:aClass |
381 installHelpSpecInto:aClass |
241 "install help text |
382 "install help text |
287 |
429 |
288 |holder| |
430 |holder| |
289 |
431 |
290 (holder := builder bindingAt:#listChannel) isNil ifTrue:[ |
432 (holder := builder bindingAt:#listChannel) isNil ifTrue:[ |
291 builder aspectAt:#listChannel put:(holder := ValueHolder new). |
433 builder aspectAt:#listChannel put:(holder := ValueHolder new). |
292 holder value:list. |
434 holder value:(OrderedCollection new). |
293 ]. |
435 ]. |
294 ^ holder |
436 ^ holder |
295 ! |
437 ! |
296 |
438 |
297 textChannel |
439 listModel |
298 "automatically generated by UIPainter ..." |
440 "automatically generated by UIPainter ..." |
299 |
441 |
300 |holder| |
442 |holder| |
301 |
443 |
302 (holder := builder bindingAt:#textChannel) isNil ifTrue:[ |
444 (holder := builder bindingAt:#listModel) isNil ifTrue:[ |
303 builder aspectAt:#textChannel put:(holder := ValueHolder new). |
445 holder := AspectAdaptor new subject:self; forAspect:#listSelection. |
|
446 builder aspectAt:#listModel put:holder. |
304 ]. |
447 ]. |
305 ^ holder |
448 ^ holder |
306 ! ! |
449 ! |
307 |
450 |
308 !UIHelpTool methodsFor:'change & update'! |
451 selectionListModel |
309 |
452 "automatically generated by UIPainter ..." |
310 update:something with:aParameter from:someObject |
453 |
311 "model might change |
454 |holder| |
312 " |
455 |
313 |text key| |
456 (holder := builder bindingAt:#selectionListModel) isNil ifTrue:[ |
314 |
457 builder aspectAt:#selectionListModel put:(holder := SelectionInList new). |
315 (key := self key) notNil ifTrue:[ |
458 holder listHolder:(self listChannel). |
316 (text := dictionary at:key ifAbsent:nil) notNil ifTrue:[ |
459 holder selectionIndexHolder:(self listModel). |
317 self textChannel value:text |
460 ]. |
318 ] |
461 ^ holder |
319 ] |
|
320 ! ! |
462 ! ! |
321 |
463 |
322 !UIHelpTool methodsFor:'initialization'! |
464 !UIHelpTool methodsFor:'initialization'! |
323 |
465 |
324 initialize |
466 initialize |
325 "setup instance attributes |
467 "setup instance attributes |
326 " |
468 " |
327 super initialize. |
469 super initialize. |
328 dictionary := IdentityDictionary new. |
470 dictionary := IdentityDictionary new. |
329 list := OrderedCollection new. |
471 ! ! |
|
472 |
|
473 !UIHelpTool methodsFor:'private'! |
|
474 |
|
475 editTextView |
|
476 "get the editTextView or nil. |
|
477 " |
|
478 |view| |
|
479 |
|
480 (view := builder componentAt:#textView) notNil ifTrue:[ |
|
481 view := view scrolledView. |
|
482 |
|
483 view acceptAction isNil ifTrue:[ |
|
484 view acceptAction:[:aList| self accept ]. |
|
485 ]. |
|
486 |
|
487 view left ~~ 0 ifTrue:[ |
|
488 (maxCharsPerLine := view extent x // view font width) < 10 ifTrue:[ |
|
489 maxCharsPerLine := nil |
|
490 ] |
|
491 ]. |
|
492 ]. |
|
493 ^ view |
|
494 ! ! |
|
495 |
|
496 !UIHelpTool methodsFor:'selection'! |
|
497 |
|
498 listSelection |
|
499 "returns current selection |
|
500 " |
|
501 ^ listSelection |
|
502 ! |
|
503 |
|
504 listSelection:aSelection |
|
505 "current selection changed |
|
506 " |
|
507 |txt col line view sel| |
|
508 |
|
509 aSelection isNumber ifTrue:[ |
|
510 aSelection ~~ 0 ifTrue:[ |
|
511 sel := self listChannel value at:aSelection |
|
512 ] |
|
513 ] ifFalse:[ |
|
514 aSelection size ~~ 0 ifTrue:[ |
|
515 sel := aSelection withoutSeparators. |
|
516 sel size == 0 ifTrue:[ |
|
517 sel := nil |
|
518 ] |
|
519 ] |
|
520 ]. |
|
521 |
|
522 listSelection = sel ifTrue:[ |
|
523 ^ self |
|
524 ]. |
|
525 listSelection := sel. |
|
526 |
|
527 modifiedHolder notNil ifTrue:[ |
|
528 modifiedHolder value:true. |
|
529 ]. |
|
530 |
|
531 (view := self editTextView) isNil ifTrue:[ |
|
532 ^ self |
|
533 ]. |
|
534 |
|
535 listSelection notNil ifTrue:[ |
|
536 txt := dictionary at:(listSelection asSymbol) ifAbsent:nil. |
|
537 ]. |
|
538 |
|
539 (txt isNil or:[maxCharsPerLine isNil]) ifTrue:[ |
|
540 col := txt. |
|
541 ] ifFalse:[ |
|
542 col := OrderedCollection new. |
|
543 |
|
544 txt asString asCollectionOfWords do:[:aWord| |
|
545 line isNil ifTrue:[ |
|
546 line := aWord |
|
547 ] ifFalse:[ |
|
548 (line size + aWord size) >= maxCharsPerLine ifTrue:[ |
|
549 col add:line. |
|
550 line := aWord |
|
551 ] ifFalse:[ |
|
552 line := line, ' ', aWord |
|
553 ] |
|
554 ]. |
|
555 ]. |
|
556 line notNil ifTrue:[col add:line]. |
|
557 ]. |
|
558 view contents:col. |
|
559 |
|
560 |
|
561 ! ! |
|
562 |
|
563 !UIHelpTool methodsFor:'user interactions'! |
|
564 |
|
565 doFromClass |
|
566 "setup new specification from a class accessed through to a dialog |
|
567 " |
|
568 |cls accepted| |
|
569 |
|
570 specClass notNil ifTrue:[cls := specClass name asValue] |
|
571 ifFalse:[cls := '' asValue]. |
|
572 |
|
573 [true] whileTrue:[ |
|
574 accepted := |
|
575 (DialogBox new |
|
576 addTextLabel:'Classes name:'; |
|
577 addInputFieldOn:cls; |
|
578 addAbortButton; |
|
579 addOkButton; |
|
580 open |
|
581 ) accepted. |
|
582 |
|
583 accepted ifFalse:[^ self]. |
|
584 cls := self class applicationClassAssociatedWith:cls value. |
|
585 |
|
586 cls notNil ifTrue:[ |
|
587 ^ self helpSpecFrom:cls |
|
588 ]. |
|
589 self warn:'no such class'. |
|
590 ] |
|
591 ! |
|
592 |
|
593 doInstallHelpSpec |
|
594 "install help spec |
|
595 " |
|
596 self installHelpSpecInto:specClass |
|
597 ! |
|
598 |
|
599 doReload |
|
600 "reload specification |
|
601 " |
|
602 |oldSel model| |
|
603 |
|
604 model := self listModel. |
|
605 oldSel := model value. |
|
606 model value:nil. |
|
607 self helpSpecFrom:specClass. |
|
608 model value:oldSel. |
330 ! ! |
609 ! ! |
331 |
610 |
332 !UIHelpTool class methodsFor:'documentation'! |
611 !UIHelpTool class methodsFor:'documentation'! |
333 |
612 |
334 version |
613 version |