author | tz |
Thu, 29 Jan 1998 15:30:48 +0100 | |
changeset 518 | 435dcb241555 |
parent 479 | 83ebfc3320aa |
child 696 | e91402372900 |
permissions | -rw-r--r-- |
156 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
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 |
||
148 | 15 |
ApplicationModel subclass:#UIHelpTool |
369 | 16 |
instanceVariableNames:'isModified specClass dictionary listSelection maxCharsPerLine |
17 |
modifiedHolder' |
|
148 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-UIPainter' |
|
21 |
! |
|
22 |
||
23 |
!UIHelpTool class methodsFor:'documentation'! |
|
24 |
||
156 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
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 |
||
148 | 41 |
documentation |
42 |
" |
|
43 |
used by the UIPainter to add help text to any component which will be shown |
|
44 |
during runing an application with enabled activeHelp mode. |
|
156 | 45 |
|
46 |
[author:] |
|
47 |
Claus Atzkern |
|
148 | 48 |
" |
49 |
! ! |
|
50 |
||
286 | 51 |
!UIHelpTool class methodsFor:'instance creation'! |
52 |
||
53 |
openOnClass:aClass |
|
54 |
" |
|
55 |
UIHelpTool openOnClass:UIPainter |
|
56 |
" |
|
57 |
|helpTool| |
|
58 |
||
59 |
helpTool := UIHelpTool new. |
|
60 |
helpTool openInterface:#standAloneSpec. |
|
292 | 61 |
helpTool helpSpecFrom:aClass |
286 | 62 |
|
63 |
||
64 |
! ! |
|
65 |
||
66 |
!UIHelpTool class methodsFor:'constants'! |
|
67 |
||
68 |
label |
|
69 |
^ 'Help' |
|
70 |
! ! |
|
71 |
||
151 | 72 |
!UIHelpTool class methodsFor:'help specs'! |
73 |
||
74 |
helpSpec |
|
75 |
"return a dictionary filled with helpKey -> helptext associations. |
|
292 | 76 |
These are used by the activeHelp tool." |
77 |
||
172 | 78 |
" |
292 | 79 |
UIHelpTool openOnClass:UIHelpTool |
80 |
" |
|
81 |
||
172 | 82 |
^ super helpSpec addPairsFrom:#( |
151 | 83 |
|
172 | 84 |
#activeHelpAccessKey |
286 | 85 |
'This ID is used to access an active help text for the selected component' |
172 | 86 |
|
87 |
) |
|
151 | 88 |
! ! |
89 |
||
148 | 90 |
!UIHelpTool class methodsFor:'interface specs'! |
91 |
||
354 | 92 |
keyMenu |
93 |
"this window spec was automatically generated by the ST/X MenuEditor" |
|
94 |
||
95 |
"do not manually edit this - the builder may not be able to |
|
96 |
handle the specification if its corrupted." |
|
97 |
||
98 |
" |
|
99 |
MenuEditor new openOnClass:UIHelpTool andSelector:#keyMenu |
|
100 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool keyMenu)) startUp |
|
101 |
" |
|
102 |
||
103 |
<resource: #menu> |
|
104 |
||
105 |
^ |
|
106 |
||
107 |
#(#Menu |
|
108 |
||
109 |
#( |
|
110 |
#(#MenuItem |
|
369 | 111 |
#'label:' 'save as ...' |
112 |
#'value:' #saveAs |
|
354 | 113 |
) |
114 |
#(#MenuItem |
|
115 |
#'label:' '-' |
|
116 |
) |
|
117 |
#(#MenuItem |
|
118 |
#'label:' 'remove' |
|
119 |
#'value:' #removeKey |
|
120 |
) |
|
121 |
) nil |
|
122 |
nil |
|
123 |
) |
|
124 |
||
125 |
"Created: / 27.10.1997 / 00:55:20 / cg" |
|
126 |
! |
|
127 |
||
286 | 128 |
menuPanelStandAlone |
129 |
"this window spec was automatically generated by the ST/X MenuEditor" |
|
130 |
||
131 |
"do not manually edit this - the builder may not be able to |
|
132 |
handle the specification if its corrupted." |
|
133 |
||
134 |
" |
|
135 |
MenuEditor new openOnClass:UIHelpTool andSelector:#menuPanelStandAlone |
|
136 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool menuPanelStandAlone)) startUp |
|
137 |
" |
|
138 |
||
139 |
<resource: #menu> |
|
140 |
||
141 |
^ |
|
142 |
||
143 |
#(#Menu |
|
144 |
||
145 |
#( |
|
146 |
#(#MenuItem |
|
147 |
#'label:' 'file' |
|
148 |
#'submenu:' |
|
149 |
#(#Menu |
|
150 |
||
151 |
#( |
|
152 |
#(#MenuItem |
|
153 |
#'label:' 'reload' |
|
154 |
#'value:' #doReload |
|
155 |
) |
|
156 |
#(#MenuItem |
|
157 |
#'label:' '-' |
|
158 |
) |
|
159 |
#(#MenuItem |
|
292 | 160 |
#'label:' 'quit' |
286 | 161 |
#'value:' #closeRequest |
162 |
) |
|
163 |
) nil |
|
164 |
nil |
|
165 |
) |
|
166 |
) |
|
167 |
#(#MenuItem |
|
168 |
#'label:' 'code' |
|
169 |
#'submenu:' |
|
170 |
#(#Menu |
|
171 |
||
172 |
#( |
|
173 |
#(#MenuItem |
|
174 |
#'label:' 'class' |
|
175 |
#'value:' #doFromClass |
|
176 |
) |
|
177 |
#(#MenuItem |
|
178 |
#'label:' '-' |
|
179 |
) |
|
180 |
#(#MenuItem |
|
181 |
#'label:' 'install help spec.' |
|
182 |
#'value:' #doInstallHelpSpec |
|
183 |
) |
|
184 |
) nil |
|
185 |
nil |
|
186 |
) |
|
187 |
) |
|
188 |
) nil |
|
189 |
nil |
|
190 |
) |
|
191 |
! |
|
192 |
||
193 |
standAloneSpec |
|
194 |
"this window spec was automatically generated by the ST/X UIPainter" |
|
195 |
||
196 |
"do not manually edit this - the painter/builder may not be able to |
|
197 |
handle the specification if its corrupted." |
|
198 |
||
199 |
" |
|
200 |
UIPainter new openOnClass:UIHelpTool andSelector:#standAloneSpec |
|
201 |
UIHelpTool new openInterface:#standAloneSpec |
|
202 |
" |
|
203 |
||
204 |
<resource: #canvas> |
|
205 |
||
206 |
^ |
|
207 |
||
208 |
#(#FullSpec |
|
209 |
#'window:' |
|
210 |
#(#WindowSpec |
|
211 |
#'name:' 'HelpTool' |
|
369 | 212 |
#'layout:' #(#LayoutFrame 219 0 193 0 814 0 690 0) |
286 | 213 |
#'label:' 'HelpTool' |
214 |
#'min:' #(#Point 10 10) |
|
215 |
#'max:' #(#Point 1160 870) |
|
369 | 216 |
#'bounds:' #(#Rectangle 219 193 815 691) |
217 |
#'usePreferredExtent:' false |
|
286 | 218 |
) |
219 |
#'component:' |
|
220 |
#(#SpecCollection |
|
221 |
#'collection:' |
|
222 |
#( |
|
223 |
#(#MenuPanelSpec |
|
224 |
#'name:' 'menuPanelStandAlone' |
|
225 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 25 0) |
|
226 |
#'menu:' #menuPanelStandAlone |
|
227 |
) |
|
228 |
#(#VariableHorizontalPanelSpec |
|
229 |
#'name:' 'variableHorizontalPanel1' |
|
230 |
#'layout:' #(#LayoutFrame 0 0.0 25 0.0 0 1.0 0 1.0) |
|
231 |
#'component:' |
|
232 |
#(#SpecCollection |
|
233 |
#'collection:' |
|
234 |
#( |
|
235 |
#(#TextEditorSpec |
|
236 |
#'name:' 'textView' |
|
237 |
#'hasHorizontalScrollBar:' true |
|
238 |
#'hasVerticalScrollBar:' true |
|
239 |
#'miniScrollerHorizontal:' true |
|
240 |
#'miniScrollerVertical:' true |
|
241 |
) |
|
242 |
#(#SequenceViewSpec |
|
243 |
#'name:' 'selectionList' |
|
339 | 244 |
#'model:' #listModel |
354 | 245 |
#'menu:' #keyMenu |
286 | 246 |
#'hasHorizontalScrollBar:' true |
247 |
#'hasVerticalScrollBar:' true |
|
248 |
#'miniScrollerHorizontal:' true |
|
249 |
#'miniScrollerVertical:' true |
|
339 | 250 |
#'useIndex:' false |
251 |
#'sequenceList:' #listChannel |
|
286 | 252 |
) |
253 |
) |
|
254 |
) |
|
369 | 255 |
#'handles:' #(#Any 0.647651 1.0) |
286 | 256 |
) |
257 |
) |
|
258 |
) |
|
259 |
) |
|
260 |
! |
|
261 |
||
148 | 262 |
windowSpec |
263 |
"this window spec was automatically generated by the ST/X UIPainter" |
|
264 |
||
265 |
"do not manually edit this - the painter/builder may not be able to |
|
266 |
handle the specification if its corrupted." |
|
267 |
||
268 |
" |
|
151 | 269 |
UIPainter new openOnClass:UIHelpTool andSelector:#windowSpec |
270 |
UIHelpTool new openInterface:#windowSpec |
|
148 | 271 |
" |
151 | 272 |
"UIHelpTool open" |
148 | 273 |
|
274 |
<resource: #canvas> |
|
275 |
||
276 |
^ |
|
277 |
||
278 |
#(#FullSpec |
|
279 |
#'window:' |
|
280 |
#(#WindowSpec |
|
286 | 281 |
#'name:' 'HelpTool' |
282 |
#'layout:' #(#LayoutFrame 199 0 167 0 484 0 437 0) |
|
148 | 283 |
#'label:' 'unnamed canvas' |
286 | 284 |
#'min:' #(#Point 10 10) |
285 |
#'max:' #(#Point 1160 870) |
|
286 |
#'bounds:' #(#Rectangle 199 167 485 438) |
|
148 | 287 |
) |
288 |
#'component:' |
|
289 |
#(#SpecCollection |
|
290 |
#'collection:' |
|
291 |
#( |
|
286 | 292 |
#(#LabelSpec |
293 |
#'name:' 'keyLabel' |
|
294 |
#'layout:' #(#AlignmentOrigin 3 0.0 42 0.0 0 1) |
|
295 |
#'label:' 'Key:' |
|
296 |
#'adjust:' #left |
|
297 |
#'resizeForLabel:' true |
|
298 |
) |
|
299 |
#(#ComboBoxSpec |
|
300 |
#'name:' 'comboBox' |
|
301 |
#'layout:' #(#LayoutFrame 48 0 22 0 -3 1.0 44 0) |
|
302 |
#'activeHelpKey:' #activeHelpAccessKey |
|
303 |
#'tabable:' true |
|
304 |
#'model:' #listModel |
|
305 |
#'type:' #symbolOrNil |
|
306 |
#'comboList:' #listChannel |
|
307 |
) |
|
148 | 308 |
#(#TextEditorSpec |
309 |
#'name:' 'textView' |
|
286 | 310 |
#'layout:' #(#LayoutFrame 3 0.0 45 0.0 -3 1.0 -3 1.0) |
148 | 311 |
#'hasHorizontalScrollBar:' true |
312 |
#'hasVerticalScrollBar:' true |
|
313 |
#'miniScrollerHorizontal:' true |
|
314 |
#'miniScrollerVertical:' true |
|
315 |
) |
|
316 |
) |
|
317 |
) |
|
318 |
) |
|
319 |
! ! |
|
320 |
||
321 |
!UIHelpTool methodsFor:'accessing'! |
|
322 |
||
151 | 323 |
dictionary |
324 |
"return the value of the instance variable 'dictionary' (automatically generated)" |
|
325 |
||
326 |
^ dictionary! |
|
327 |
||
328 |
dictionary:aDictionary |
|
329 |
"set the value of the instance variable 'dictionary' (automatically generated)" |
|
330 |
||
286 | 331 |
(dictionary := aDictionary) isNil ifTrue:[ |
204 | 332 |
dictionary := IdentityDictionary new. |
286 | 333 |
]. |
334 |
self updateList |
|
335 |
! |
|
336 |
||
337 |
helpKey |
|
338 |
listSelection size ~~ 0 ifTrue:[ |
|
339 |
^ listSelection asSymbol |
|
151 | 340 |
]. |
286 | 341 |
^ nil |
342 |
! |
|
343 |
||
344 |
helpKey:aKey |
|
345 |
|key| |
|
346 |
||
347 |
aKey size ~~ 0 ifTrue:[ |
|
348 |
key := aKey asString |
|
349 |
]. |
|
350 |
self listModel value:key |
|
459 | 351 |
|
151 | 352 |
! |
353 |
||
196 | 354 |
helpSpecFrom:aClass |
355 |
"read help text from an application associated with the class |
|
356 |
" |
|
286 | 357 |
|help| |
358 |
||
369 | 359 |
specClass := self applicationClassAssociatedWith:aClass. |
360 |
isModified := false. |
|
196 | 361 |
|
286 | 362 |
(specClass respondsTo:#helpSpec) ifTrue:[ |
363 |
help := specClass helpSpec |
|
364 |
] ifFalse:[ |
|
365 |
specClass := nil |
|
196 | 366 |
]. |
367 |
self dictionary:help |
|
368 |
! |
|
369 |
||
286 | 370 |
modifiedHolder:aValueHolder |
371 |
"set the value holder set to true in case of modifying attributes |
|
148 | 372 |
" |
286 | 373 |
modifiedHolder notNil ifTrue:[ |
374 |
modifiedHolder removeDependent:self. |
|
375 |
]. |
|
148 | 376 |
|
286 | 377 |
(modifiedHolder := aValueHolder) notNil ifTrue:[ |
378 |
modifiedHolder addDependent:self. |
|
459 | 379 |
|
380 |
self editTextView notNil ifTrue: [ |
|
381 |
self editTextView modifiedChannel onChangeSend:#value to:[ |
|
382 |
modifiedHolder notNil ifTrue:[ |
|
383 |
self editTextView modifiedChannel value ifTrue:[ |
|
384 |
modifiedHolder value:true |
|
385 |
] |
|
386 |
] |
|
387 |
] |
|
388 |
] |
|
389 |
] |
|
286 | 390 |
|
391 |
||
148 | 392 |
! |
393 |
||
286 | 394 |
updateList |
395 |
"update list from dictionary |
|
148 | 396 |
" |
286 | 397 |
self listChannel value:(dictionary keys asSortedCollection) |
148 | 398 |
! ! |
399 |
||
354 | 400 |
!UIHelpTool methodsFor:'accessing menu'! |
401 |
||
402 |
keyMenu |
|
403 |
"this window spec was automatically generated by the UI Builder" |
|
404 |
||
405 |
^ self class keyMenu |
|
406 |
||
407 |
"Created: / 27.10.1997 / 00:55:20 / cg" |
|
408 |
! ! |
|
409 |
||
148 | 410 |
!UIHelpTool methodsFor:'actions'! |
411 |
||
412 |
accept |
|
413 |
"accept the text |
|
414 |
" |
|
393 | 415 |
|view key txt list listChgd| |
148 | 416 |
|
286 | 417 |
(listSelection size == 0 or:[(view := self editTextView) isNil]) ifFalse:[ |
393 | 418 |
txt := view contents asString. |
419 |
key := listSelection asSymbol. |
|
420 |
list := self listChannel value. |
|
148 | 421 |
|
393 | 422 |
(listChgd := (dictionary at:key ifAbsent:nil) isNil) ifTrue:[ |
148 | 423 |
list add:key. |
424 |
]. |
|
369 | 425 |
dictionary at:key put:txt. |
426 |
isModified := true. |
|
393 | 427 |
|
428 |
listChgd ifTrue:[ |
|
429 |
self updateList |
|
454 | 430 |
]. |
479 | 431 |
modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
148 | 432 |
] |
196 | 433 |
! |
434 |
||
435 |
installHelpSpecInto:aClass |
|
436 |
"install help text |
|
437 |
" |
|
479 | 438 |
|cls src superHelpSpecKeys helpSpec| |
196 | 439 |
|
335 | 440 |
cls := self applicationClassAssociatedWith:aClass. |
196 | 441 |
|
442 |
cls isNil ifTrue:[ |
|
465 | 443 |
^ self information:'No application class defined!!'. |
196 | 444 |
]. |
478 | 445 |
isModified not ifTrue:[ |
465 | 446 |
^nil |
196 | 447 |
]. |
456 | 448 |
|
449 |
superHelpSpecKeys := cls superclass helpSpec keys. |
|
479 | 450 |
|
451 |
helpSpec := IdentityDictionary new. |
|
452 |
dictionary associationsDo: |
|
453 |
[:asso| |
|
454 |
(superHelpSpecKeys includes: asso key) ifFalse: [helpSpec at: asso key put: asso value] |
|
455 |
]. |
|
456 |
helpSpec isEmpty ifTrue:[ |
|
478 | 457 |
^nil |
458 |
]. |
|
456 | 459 |
|
196 | 460 |
src := '' writeStream. |
461 |
||
462 |
src nextPutAll: |
|
463 |
||
464 |
'helpSpec |
|
465 |
"return a dictionary filled with helpKey -> helptext associations. |
|
292 | 466 |
These are used by the activeHelp tool." |
467 |
||
196 | 468 |
" |
292 | 469 |
UIHelpTool openOnClass:', cls name asString ,' |
470 |
" |
|
471 |
||
196 | 472 |
^ super helpSpec addPairsFrom:#( |
473 |
||
474 |
'. |
|
475 |
||
479 | 476 |
helpSpec keys asSortedCollection |
456 | 477 |
do:[:key | |
354 | 478 |
|txt t| |
479 |
||
479 | 480 |
txt := helpSpec at:key. |
196 | 481 |
src nextPutLine:key storeString. |
482 |
||
319
f16aa0e8541e
dont crash with nonexisting bitmaps
Claus Gittinger <cg@exept.de>
parents:
299
diff
changeset
|
483 |
t := txt asString replaceAll:(Character cr) with:(Character space). |
286 | 484 |
|
485 |
(t endsWith:Character space) ifTrue:[ |
|
196 | 486 |
t := t copyWithoutLast:1 |
487 |
]. |
|
488 |
src nextPutLine:t storeString; cr. |
|
489 |
]. |
|
490 |
src nextPutLine:')'. |
|
491 |
||
492 |
Compiler compile:(src contents) |
|
493 |
forClass:cls class |
|
369 | 494 |
inCategory:'help specs'. |
196 | 495 |
|
369 | 496 |
isModified := false. |
497 |
||
148 | 498 |
! ! |
499 |
||
500 |
!UIHelpTool methodsFor:'aspects'! |
|
501 |
||
502 |
listChannel |
|
503 |
"automatically generated by UIPainter ..." |
|
504 |
||
505 |
|holder| |
|
506 |
||
507 |
(holder := builder bindingAt:#listChannel) isNil ifTrue:[ |
|
354 | 508 |
builder aspectAt:#listChannel put:(holder := OrderedCollection new asValue). |
148 | 509 |
]. |
510 |
^ holder |
|
354 | 511 |
|
512 |
"Modified: / 27.10.1997 / 01:50:33 / cg" |
|
148 | 513 |
! |
514 |
||
286 | 515 |
listModel |
148 | 516 |
"automatically generated by UIPainter ..." |
517 |
||
518 |
|holder| |
|
519 |
||
286 | 520 |
(holder := builder bindingAt:#listModel) isNil ifTrue:[ |
521 |
holder := AspectAdaptor new subject:self; forAspect:#listSelection. |
|
522 |
builder aspectAt:#listModel put:holder. |
|
148 | 523 |
]. |
524 |
^ holder |
|
525 |
! ! |
|
526 |
||
527 |
!UIHelpTool methodsFor:'initialization'! |
|
528 |
||
529 |
initialize |
|
530 |
"setup instance attributes |
|
531 |
" |
|
532 |
super initialize. |
|
286 | 533 |
dictionary := IdentityDictionary new. |
369 | 534 |
isModified := false. |
535 |
||
286 | 536 |
! ! |
537 |
||
354 | 538 |
!UIHelpTool methodsFor:'menu actions'! |
539 |
||
540 |
removeKey |
|
541 |
|k sym| |
|
542 |
||
543 |
k := Dialog request:'name of key to remove:' initialAnswer:listSelection. |
|
544 |
k size > 0 ifTrue:[ |
|
545 |
((dictionary includesKey:k) |
|
546 |
or:[(sym := k asSymbolIfInterned) notNil |
|
547 |
and:[dictionary includesKey:sym]]) |
|
548 |
ifFalse:[ |
|
549 |
^ self warn:'key is not present.'. |
|
550 |
]. |
|
551 |
sym notNil ifTrue:[ |
|
552 |
dictionary removeKey:sym ifAbsent:nil. |
|
553 |
]. |
|
554 |
dictionary removeKey:k ifAbsent:nil. |
|
369 | 555 |
isModified := true. |
354 | 556 |
self updateList |
557 |
]. |
|
558 |
||
559 |
"Created: / 27.10.1997 / 01:48:48 / cg" |
|
560 |
"Modified: / 27.10.1997 / 02:25:30 / cg" |
|
369 | 561 |
! |
562 |
||
563 |
saveAs |
|
564 |
|key new| |
|
565 |
||
566 |
key := Dialog request:'save under key:' initialAnswer:(listSelection ? ''). |
|
567 |
key := key withoutSeparators. |
|
568 |
||
569 |
key size ~~ 0 ifTrue:[ |
|
570 |
key := key asSymbol. |
|
571 |
new := (dictionary at:key ifAbsent:nil) isNil. |
|
572 |
||
573 |
dictionary at:key put:(self editTextView contents asString). |
|
574 |
||
575 |
new ifTrue:[ |
|
576 |
self updateList |
|
577 |
]. |
|
578 |
isModified := true. |
|
579 |
self listModel value:key. |
|
580 |
]. |
|
354 | 581 |
! ! |
582 |
||
286 | 583 |
!UIHelpTool methodsFor:'private'! |
584 |
||
585 |
editTextView |
|
586 |
"get the editTextView or nil. |
|
587 |
" |
|
588 |
|view| |
|
589 |
||
590 |
(view := builder componentAt:#textView) notNil ifTrue:[ |
|
591 |
view := view scrolledView. |
|
592 |
||
593 |
view acceptAction isNil ifTrue:[ |
|
594 |
view acceptAction:[:aList| self accept ]. |
|
595 |
]. |
|
596 |
||
597 |
view left ~~ 0 ifTrue:[ |
|
598 |
(maxCharsPerLine := view extent x // view font width) < 10 ifTrue:[ |
|
599 |
maxCharsPerLine := nil |
|
600 |
] |
|
601 |
]. |
|
454 | 602 |
]. |
286 | 603 |
^ view |
604 |
! ! |
|
605 |
||
335 | 606 |
!UIHelpTool methodsFor:'queries'! |
607 |
||
608 |
applicationClassAssociatedWith:aClass |
|
609 |
"get application class keeping the associated help text or nil |
|
610 |
" |
|
611 |
|cls| |
|
612 |
||
613 |
cls := self resolveName:aClass. |
|
614 |
||
615 |
(cls notNil and:[cls includesBehavior:UISpecification]) ifTrue:[ |
|
616 |
^ UISpecificationTool |
|
617 |
]. |
|
618 |
^ cls |
|
619 |
||
620 |
||
369 | 621 |
! |
622 |
||
623 |
isModified |
|
624 |
^ isModified |
|
335 | 625 |
! ! |
626 |
||
286 | 627 |
!UIHelpTool methodsFor:'selection'! |
628 |
||
629 |
listSelection |
|
630 |
"returns current selection |
|
631 |
" |
|
632 |
^ listSelection |
|
633 |
! |
|
634 |
||
635 |
listSelection:aSelection |
|
636 |
"current selection changed |
|
637 |
" |
|
299 | 638 |
|txt view sel| |
286 | 639 |
|
640 |
aSelection isNumber ifTrue:[ |
|
641 |
aSelection ~~ 0 ifTrue:[ |
|
642 |
sel := self listChannel value at:aSelection |
|
643 |
] |
|
644 |
] ifFalse:[ |
|
645 |
aSelection size ~~ 0 ifTrue:[ |
|
646 |
sel := aSelection withoutSeparators. |
|
647 |
sel size == 0 ifTrue:[ |
|
648 |
sel := nil |
|
649 |
] |
|
650 |
] |
|
651 |
]. |
|
652 |
||
299 | 653 |
listSelection = sel ifFalse:[ |
654 |
listSelection := sel. |
|
286 | 655 |
|
299 | 656 |
modifiedHolder notNil ifTrue:[ |
657 |
modifiedHolder value:true. |
|
658 |
]. |
|
286 | 659 |
|
299 | 660 |
(view := self editTextView) notNil ifTrue:[ |
661 |
listSelection notNil ifTrue:[ |
|
662 |
txt := dictionary at:(listSelection asSymbol) ifAbsent:nil. |
|
286 | 663 |
|
299 | 664 |
(txt isNil or:[maxCharsPerLine isNil]) ifFalse:[ |
369 | 665 |
txt := UIPainter convertString:(txt asString) maxLineSize:maxCharsPerLine skipLineFeed:false. |
286 | 666 |
] |
667 |
]. |
|
459 | 668 |
view contents:txt. |
669 |
view modified:false. |
|
299 | 670 |
] |
671 |
] |
|
286 | 672 |
|
673 |
! ! |
|
674 |
||
369 | 675 |
!UIHelpTool methodsFor:'startup / release'! |
676 |
||
677 |
closeRequest |
|
678 |
||
679 |
(isModified and:[self masterApplication isNil]) ifTrue:[ |
|
459 | 680 |
(self confirm:'Exit without saving your modifications?') ifFalse:[ |
369 | 681 |
^ self |
682 |
] |
|
683 |
]. |
|
684 |
^ super closeRequest. |
|
685 |
! ! |
|
686 |
||
286 | 687 |
!UIHelpTool methodsFor:'user interactions'! |
688 |
||
689 |
doFromClass |
|
690 |
"setup new specification from a class accessed through to a dialog |
|
691 |
" |
|
692 |
|cls accepted| |
|
693 |
||
694 |
specClass notNil ifTrue:[cls := specClass name asValue] |
|
695 |
ifFalse:[cls := '' asValue]. |
|
696 |
||
697 |
[true] whileTrue:[ |
|
698 |
accepted := |
|
699 |
(DialogBox new |
|
700 |
addTextLabel:'Classes name:'; |
|
701 |
addInputFieldOn:cls; |
|
702 |
addAbortButton; |
|
703 |
addOkButton; |
|
704 |
open |
|
705 |
) accepted. |
|
706 |
||
707 |
accepted ifFalse:[^ self]. |
|
335 | 708 |
cls := self applicationClassAssociatedWith:cls value. |
286 | 709 |
|
710 |
cls notNil ifTrue:[ |
|
711 |
^ self helpSpecFrom:cls |
|
712 |
]. |
|
713 |
self warn:'no such class'. |
|
714 |
] |
|
715 |
! |
|
716 |
||
717 |
doInstallHelpSpec |
|
718 |
"install help spec |
|
719 |
" |
|
720 |
self installHelpSpecInto:specClass |
|
721 |
! |
|
722 |
||
723 |
doReload |
|
724 |
"reload specification |
|
725 |
" |
|
726 |
|oldSel model| |
|
727 |
||
728 |
model := self listModel. |
|
729 |
oldSel := model value. |
|
730 |
model value:nil. |
|
731 |
self helpSpecFrom:specClass. |
|
732 |
model value:oldSel. |
|
369 | 733 |
isModified := false. |
734 |
||
148 | 735 |
! ! |
736 |
||
737 |
!UIHelpTool class methodsFor:'documentation'! |
|
738 |
||
739 |
version |
|
740 |
^ '$Header$' |
|
741 |
! ! |