author | Claus Gittinger <cg@exept.de> |
Fri, 20 Dec 2002 16:00:55 +0100 | |
changeset 1667 | f02a0dad97c5 |
parent 1665 | f6427f12f173 |
child 1669 | e6ea33c843a0 |
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 |
||
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
15 |
"{ Package: 'stx:libtool2' }" |
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
16 |
|
750 | 17 |
ToolApplicationModel subclass:#UIHelpTool |
1646 | 18 |
instanceVariableNames:'specClass specSelector dictionary dictionaries modifiedHolder |
19 |
modified listOfKeys listOfKeysModel listOfClasses |
|
20 |
listOfClassesModel contentsModifiedChannel editModel editTextView' |
|
148 | 21 |
classVariableNames:'' |
22 |
poolDictionaries:'' |
|
23 |
category:'Interface-UIPainter' |
|
24 |
! |
|
25 |
||
26 |
!UIHelpTool class methodsFor:'documentation'! |
|
27 |
||
156 | 28 |
copyright |
29 |
" |
|
30 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
31 |
All Rights Reserved |
|
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
||
41 |
||
42 |
! |
|
43 |
||
148 | 44 |
documentation |
45 |
" |
|
779 | 46 |
The Help Tool allows you to define help dictionaries for the widgets in |
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
47 |
window applications. The tool are able to run stand alone or in other master |
740 | 48 |
applications like the GUI Painter and the Menu Editor. |
49 |
If the application responds to the selector #showHelp:aHelpText for:aView, |
|
50 |
this selector is called by the widget's view when the mouse cursor moves over. |
|
51 |
If the application does not responds to that selector, and the activeHelp mode |
|
52 |
is enabled, an active help bubble is shown at the widget's view. |
|
156 | 53 |
|
779 | 54 |
[instance variables:] |
55 |
specClass <Symbol> class implementing the help spec |
|
56 |
specSelector <Symbol> selector returning the help spec |
|
57 |
dictionary <Dictionary> dictionary containing pairs of help keys/texts |
|
58 |
dictionaries <Dictionary> dictionary containing pairs of help spec classes/help dictionaries |
|
59 |
listSelection <String> current selected help key |
|
60 |
maxCharsPerLine <Integer> maximum number of allowed characters per text line |
|
61 |
modifiedHolder <ValueHolder> value holder for setting as modified |
|
62 |
modified <Boolean> flag whether the help spec was modified |
|
63 |
||
156 | 64 |
[author:] |
750 | 65 |
Claus Atzkern, eXept Software AG |
66 |
Thomas Zwick, eXept Software AG |
|
148 | 67 |
" |
68 |
! ! |
|
69 |
||
286 | 70 |
!UIHelpTool class methodsFor:'instance creation'! |
71 |
||
832
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
72 |
open |
833 | 73 |
^ self openOnClass:nil. |
832
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
74 |
|
833 | 75 |
"/ |className cls| |
76 |
"/ |
|
77 |
"/ className := Dialog request:(ClassResources string:'Open on which class ?'). |
|
78 |
"/ className size > 0 ifTrue:[ |
|
79 |
"/ cls := Smalltalk at:className asSymbol. |
|
80 |
"/ cls notNil ifTrue:[ |
|
81 |
"/ ^ self openOnClass:cls. |
|
82 |
"/ ]. |
|
83 |
"/ self warn:(ClassResources string:'No such class'). |
|
84 |
"/ ]. |
|
85 |
"/ |
|
86 |
"/ "Created: / 20.5.1998 / 00:55:05 / cg" |
|
87 |
"/ |
|
832
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
88 |
|
833 | 89 |
"Modified: / 20.5.1998 / 01:06:07 / cg" |
832
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
90 |
! |
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
91 |
|
286 | 92 |
openOnClass:aClass |
779 | 93 |
"opens a Help Tool on aClass" |
94 |
||
1646 | 95 |
^ self openOnClass:aClass andSelector:#helpSpec |
833 | 96 |
|
286 | 97 |
" |
750 | 98 |
UIHelpTool openOnClass:self |
286 | 99 |
" |
100 |
||
833 | 101 |
"Modified: / 20.5.1998 / 01:06:14 / cg" |
940 | 102 |
! |
103 |
||
104 |
openOnClass:aClass andSelector: aSelector |
|
105 |
"opens a Help Tool on aClass and aSelector" |
|
106 |
||
946 | 107 |
^self new openOnClass:aClass andSelector: aSelector |
940 | 108 |
|
750 | 109 |
! ! |
110 |
||
286 | 111 |
!UIHelpTool class methodsFor:'constants'! |
112 |
||
113 |
label |
|
779 | 114 |
"returns the label; used if embedded as sub canvas in the GUI Painter or Menu Editor" |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
115 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
116 |
^'Help' |
286 | 117 |
! ! |
118 |
||
151 | 119 |
!UIHelpTool class methodsFor:'help specs'! |
120 |
||
121 |
helpSpec |
|
740 | 122 |
"This resource specification was automatically generated |
123 |
by the UIHelpTool of ST/X." |
|
124 |
||
125 |
"Do not manually edit this!! If it is corrupted, |
|
126 |
the UIHelpTool may not be able to read the specification." |
|
292 | 127 |
|
172 | 128 |
" |
740 | 129 |
UIHelpTool openOnClass:UIHelpTool |
292 | 130 |
" |
131 |
||
740 | 132 |
<resource: #help> |
133 |
||
134 |
^super helpSpec addPairsFrom:#( |
|
151 | 135 |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
136 |
#addHelpTextKey |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
137 |
'Adds the key to the help spec.' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
138 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
139 |
#currentHelpTexts |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
140 |
'Selected help text key.' |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
141 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
142 |
#deleteHelpTextKey |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
143 |
'Deletes the key from the help spec.' |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
144 |
|
750 | 145 |
#fileLoad |
146 |
'Opens a dialog for selecting and loading a help spec from a class.' |
|
147 |
||
148 |
#fileSave |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
149 |
'Saves the current help spec.' |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
150 |
|
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
151 |
#fileUpdate |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
152 |
'Reload the help spec.' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
153 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
154 |
#helpTextView |
1622 | 155 |
'Shows the help text. Menu action ''Accept'' commits changes' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
156 |
|
1646 | 157 |
#listOfClasses |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
158 |
'Classes where help specs can be/are implemented.' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
159 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
160 |
#listOfHelpTexts |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
161 |
'List of help text keys.' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
162 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
163 |
#removeHelpTextKey |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
164 |
'Removes the help message from the widget.' |
172 | 165 |
|
1646 | 166 |
#updateHelpTextKey |
167 |
'Refetch the help spec.' |
|
168 |
||
172 | 169 |
) |
151 | 170 |
! ! |
171 |
||
148 | 172 |
!UIHelpTool class methodsFor:'interface specs'! |
173 |
||
174 |
windowSpec |
|
740 | 175 |
"This resource specification was automatically generated |
176 |
by the UIPainter of ST/X." |
|
148 | 177 |
|
740 | 178 |
"Do not manually edit this!! If it is corrupted, |
179 |
the UIPainter may not be able to read the specification." |
|
148 | 180 |
|
181 |
" |
|
151 | 182 |
UIPainter new openOnClass:UIHelpTool andSelector:#windowSpec |
183 |
UIHelpTool new openInterface:#windowSpec |
|
740 | 184 |
UIHelpTool open |
148 | 185 |
" |
186 |
||
187 |
<resource: #canvas> |
|
188 |
||
1302 | 189 |
^ |
190 |
#(#FullSpec |
|
191 |
#name: #windowSpec |
|
192 |
#window: |
|
193 |
#(#WindowSpec |
|
194 |
#label: 'Help Tool' |
|
195 |
#name: 'Help Tool' |
|
196 |
#min: #(#Point 10 10) |
|
197 |
#max: #(#Point 1160 870) |
|
1646 | 198 |
#bounds: #(#Rectangle 31 306 317 577) |
1302 | 199 |
) |
200 |
#component: |
|
201 |
#(#SpecCollection |
|
202 |
#collection: #( |
|
203 |
#(#VariableVerticalPanelSpec |
|
204 |
#name: 'VariableVerticalPanel' |
|
205 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
206 |
#component: |
|
207 |
#(#SpecCollection |
|
208 |
#collection: #( |
|
1646 | 209 |
#(#VariableHorizontalPanelSpec |
210 |
#name: 'VariableHorizontalPanel' |
|
750 | 211 |
#component: |
1302 | 212 |
#(#SpecCollection |
213 |
#collection: #( |
|
1646 | 214 |
#(#SelectionInListModelViewSpec |
215 |
#name: 'listOfKeys' |
|
216 |
#activeHelpKey: #listOfHelpTexts |
|
217 |
#model: #listOfKeysModel |
|
218 |
#menu: #listOfKeysMenu |
|
219 |
#hasHorizontalScrollBar: true |
|
220 |
#hasVerticalScrollBar: true |
|
221 |
#miniScrollerHorizontal: true |
|
222 |
#listModel: #listOfKeys |
|
223 |
#useIndex: false |
|
224 |
#highlightMode: #line |
|
225 |
) |
|
226 |
#(#ViewSpec |
|
227 |
#name: 'Box' |
|
1302 | 228 |
#component: |
229 |
#(#SpecCollection |
|
230 |
#collection: #( |
|
1646 | 231 |
#(#InputFieldSpec |
232 |
#name: 'helpKeyInputField' |
|
233 |
#layout: #(#LayoutFrame 2 0.0 2 0 -2 1.0 25 0) |
|
234 |
#activeHelpKey: #currentHelpTexts |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
235 |
#tabable: true |
1646 | 236 |
#model: #editModel |
237 |
#immediateAccept: true |
|
238 |
#acceptOnReturn: false |
|
239 |
#acceptOnTab: false |
|
240 |
#acceptOnPointerLeave: false |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
241 |
) |
1646 | 242 |
#(#SelectionInListModelViewSpec |
243 |
#name: 'listOfClasses' |
|
244 |
#layout: #(#LayoutFrame 0 0.0 27 0 0 1.0 0 1.0) |
|
245 |
#activeHelpKey: #listOfClasses |
|
246 |
#model: #listOfClassesModel |
|
247 |
#hasHorizontalScrollBar: true |
|
248 |
#hasVerticalScrollBar: true |
|
249 |
#miniScrollerHorizontal: true |
|
250 |
#miniScrollerVertical: true |
|
251 |
#listModel: #listOfClasses |
|
252 |
#useIndex: false |
|
253 |
#highlightMode: #line |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
254 |
) |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
255 |
) |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
256 |
|
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
257 |
) |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
258 |
) |
1646 | 259 |
) |
260 |
||
261 |
) |
|
262 |
#handles: #(#Any 0.5 1.0) |
|
263 |
) |
|
264 |
#(#ViewSpec |
|
265 |
#name: 'Box1' |
|
266 |
#component: |
|
267 |
#(#SpecCollection |
|
268 |
#collection: #( |
|
269 |
#(#MenuPanelSpec |
|
270 |
#name: 'helpTextMenu' |
|
271 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0) |
|
272 |
#menu: #helpTextMenu |
|
273 |
#textDefault: true |
|
274 |
) |
|
275 |
#(#TextEditorSpec |
|
276 |
#name: 'helpTextView' |
|
277 |
#layout: #(#LayoutFrame 0 0.0 24 0.0 0 1.0 0 1.0) |
|
278 |
#activeHelpKey: #helpTextView |
|
279 |
#tabable: true |
|
280 |
#hasHorizontalScrollBar: true |
|
281 |
#hasVerticalScrollBar: true |
|
282 |
#miniScrollerHorizontal: true |
|
283 |
#miniScrollerVertical: true |
|
284 |
#modifiedChannel: #contentsModifiedChannel |
|
285 |
#postBuildCallback: #postBuildTextView: |
|
750 | 286 |
) |
1302 | 287 |
) |
288 |
||
750 | 289 |
) |
1302 | 290 |
) |
291 |
) |
|
292 |
||
148 | 293 |
) |
1302 | 294 |
#handles: #(#Any 0.5 1.0) |
295 |
) |
|
296 |
) |
|
297 |
||
298 |
) |
|
148 | 299 |
) |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
300 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
301 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
302 |
windowSpecForStandAlone |
740 | 303 |
"This resource specification was automatically generated |
304 |
by the UIPainter of ST/X." |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
305 |
|
740 | 306 |
"Do not manually edit this!! If it is corrupted, |
307 |
the UIPainter may not be able to read the specification." |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
308 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
309 |
" |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
310 |
UIPainter new openOnClass:UIHelpTool andSelector:#windowSpecForStandAlone |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
311 |
UIHelpTool new openInterface:#windowSpecForStandAlone |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
312 |
" |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
313 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
314 |
<resource: #canvas> |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
315 |
|
1646 | 316 |
^ |
317 |
#(#FullSpec |
|
318 |
#name: #windowSpecForStandAlone |
|
319 |
#window: |
|
320 |
#(#WindowSpec |
|
321 |
#label: 'Help Tool' |
|
322 |
#name: 'Help Tool' |
|
323 |
#min: #(#Point 300 300) |
|
324 |
#max: #(#Point 1152 900) |
|
325 |
#bounds: #(#Rectangle 83 333 796 896) |
|
326 |
#menu: #menu |
|
327 |
) |
|
328 |
#component: |
|
329 |
#(#SpecCollection |
|
330 |
#collection: #( |
|
331 |
#(#UISubSpecification |
|
332 |
#name: 'windowSpec' |
|
333 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -26 1.0) |
|
334 |
#minorKey: #windowSpec |
|
335 |
) |
|
336 |
#(#UISubSpecification |
|
337 |
#name: 'windowSpecForInfoBar' |
|
338 |
#layout: #(#LayoutFrame 0 0 -24 1 0 1 0 1) |
|
339 |
#majorKey: #ToolApplicationModel |
|
340 |
#minorKey: #windowSpecForInfoBar |
|
341 |
) |
|
342 |
) |
|
343 |
||
344 |
) |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
345 |
) |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
346 |
! ! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
347 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
348 |
!UIHelpTool class methodsFor:'menu specs'! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
349 |
|
1646 | 350 |
helpTextMenu |
351 |
"This resource specification was automatically generated |
|
352 |
by the MenuEditor of ST/X." |
|
353 |
||
354 |
"Do not manually edit this!! If it is corrupted, |
|
355 |
the MenuEditor may not be able to read the specification." |
|
356 |
||
357 |
" |
|
358 |
MenuEditor new openOnClass:UIHelpTool andSelector:#helpTextMenu |
|
359 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool helpTextMenu)) startUp |
|
360 |
" |
|
361 |
||
362 |
<resource: #menu> |
|
363 |
||
364 |
^ |
|
365 |
#(#Menu |
|
366 |
#( |
|
367 |
#(#MenuItem |
|
368 |
#activeHelpKey: #commitOK |
|
369 |
#enabled: #contentsModifiedChannel |
|
370 |
#label: 'Accept' |
|
371 |
#itemValue: #accept |
|
372 |
#translateLabel: true |
|
373 |
) |
|
374 |
#(#MenuItem |
|
375 |
#activeHelpKey: #commitCancel |
|
376 |
#enabled: #contentsModifiedChannel |
|
377 |
#label: 'Cancel' |
|
378 |
#itemValue: #cancel |
|
379 |
#translateLabel: true |
|
380 |
) |
|
381 |
) |
|
382 |
nil |
|
383 |
nil |
|
384 |
) |
|
385 |
! |
|
386 |
||
387 |
listOfKeysMenu |
|
388 |
"This resource specification was automatically generated |
|
389 |
by the MenuEditor of ST/X." |
|
390 |
||
391 |
"Do not manually edit this!! If it is corrupted, |
|
392 |
the MenuEditor may not be able to read the specification." |
|
393 |
||
394 |
" |
|
395 |
MenuEditor new openOnClass:UIHelpTool andSelector:#listOfKeysMenu |
|
396 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool listOfKeysMenu)) startUp |
|
397 |
" |
|
398 |
||
399 |
<resource: #menu> |
|
400 |
||
401 |
^ |
|
402 |
#(#Menu |
|
403 |
#( |
|
404 |
#(#MenuItem |
|
405 |
#activeHelpKey: #deleteHelpTextKey |
|
406 |
#label: 'Delete' |
|
407 |
#itemValue: #doDelete |
|
408 |
#translateLabel: true |
|
409 |
) |
|
410 |
) |
|
411 |
nil |
|
412 |
nil |
|
413 |
) |
|
414 |
! |
|
415 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
416 |
menu |
740 | 417 |
"This resource specification was automatically generated |
418 |
by the MenuEditor of ST/X." |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
419 |
|
740 | 420 |
"Do not manually edit this!! If it is corrupted, |
421 |
the MenuEditor may not be able to read the specification." |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
422 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
423 |
" |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
424 |
MenuEditor new openOnClass:UIHelpTool andSelector:#menu |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
425 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool menu)) startUp |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
426 |
" |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
427 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
428 |
<resource: #menu> |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
429 |
|
1646 | 430 |
^ |
431 |
#(#Menu |
|
432 |
#( |
|
433 |
#(#MenuItem |
|
434 |
#label: 'File' |
|
435 |
#translateLabel: true |
|
436 |
#submenu: |
|
437 |
#(#Menu |
|
438 |
#( |
|
439 |
#(#MenuItem |
|
440 |
#activeHelpKey: #fileLoad |
|
441 |
#label: 'Load...' |
|
442 |
#itemValue: #doLoad |
|
443 |
#translateLabel: true |
|
444 |
) |
|
445 |
#(#MenuItem |
|
446 |
#activeHelpKey: #fileSave |
|
447 |
#label: 'Save' |
|
448 |
#itemValue: #doSave |
|
449 |
#translateLabel: true |
|
450 |
) |
|
451 |
#(#MenuItem |
|
452 |
#label: '-' |
|
453 |
) |
|
454 |
#(#MenuItem |
|
455 |
#activeHelpKey: #fileExit |
|
456 |
#label: 'Exit' |
|
457 |
#itemValue: #closeRequest |
|
458 |
#translateLabel: true |
|
750 | 459 |
) |
1646 | 460 |
) |
461 |
nil |
|
462 |
nil |
|
750 | 463 |
) |
1646 | 464 |
) |
465 |
#(#MenuItem |
|
466 |
#label: 'Edit' |
|
467 |
#translateLabel: true |
|
468 |
#submenu: |
|
469 |
#(#Menu |
|
470 |
#( |
|
471 |
#(#MenuItem |
|
472 |
#activeHelpKey: #deleteHelpTextKey |
|
473 |
#label: 'Delete' |
|
474 |
#itemValue: #doDelete |
|
475 |
#translateLabel: true |
|
750 | 476 |
) |
1646 | 477 |
) |
478 |
nil |
|
479 |
nil |
|
750 | 480 |
) |
1646 | 481 |
) |
482 |
#(#MenuItem |
|
483 |
#activeHelpKey: #help |
|
484 |
#label: 'Help' |
|
485 |
#translateLabel: true |
|
486 |
#startGroup: #right |
|
487 |
#submenuChannel: #menuHelp |
|
488 |
) |
|
489 |
) |
|
490 |
nil |
|
491 |
nil |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
492 |
) |
148 | 493 |
! ! |
494 |
||
495 |
!UIHelpTool methodsFor:'accessing'! |
|
496 |
||
710 | 497 |
dictionaries |
779 | 498 |
"returns the dictionary of the help dictionaries of the classes having help specs" |
499 |
||
710 | 500 |
^dictionaries |
501 |
! |
|
502 |
||
503 |
dictionaries:aDictionaryOfDictionaries |
|
779 | 504 |
"sets a dictionary of the help dictionaries of the classes having help specs" |
505 |
||
710 | 506 |
(dictionaries := aDictionaryOfDictionaries) isNil ifTrue:[ |
507 |
dictionaries := Dictionary new. |
|
508 |
]. |
|
715 | 509 |
self updateList. |
710 | 510 |
! |
511 |
||
151 | 512 |
dictionary |
779 | 513 |
"returns the dictionary of the selected class" |
514 |
||
722 | 515 |
^dictionary |
710 | 516 |
! |
151 | 517 |
|
1646 | 518 |
helpKey |
519 |
"returns the help key as symbol or nil |
|
520 |
" |
|
521 |
|value| |
|
779 | 522 |
|
1646 | 523 |
value := editModel value. |
286 | 524 |
|
1646 | 525 |
value notNil ifTrue:[ |
526 |
value := value withoutSeparators. |
|
527 |
value notEmpty ifTrue:[ ^ value asSymbol ] |
|
151 | 528 |
]. |
286 | 529 |
^ nil |
530 |
! |
|
531 |
||
532 |
helpKey:aKey |
|
779 | 533 |
"sets the help key into the selection channel in order to show the help text" |
534 |
||
286 | 535 |
|key| |
1646 | 536 |
|
286 | 537 |
aKey size ~~ 0 ifTrue:[ |
1646 | 538 |
aKey isSymbol ifTrue:[ |
539 |
key := aKey |
|
540 |
] ifFalse:[ |
|
541 |
key := aKey withoutSeparators. |
|
542 |
key notEmpty ifTrue:[ key := key asSymbol ] |
|
543 |
ifFalse:[ key := nil ]. |
|
544 |
] |
|
545 |
] ifFalse:[ |
|
546 |
key := nil |
|
286 | 547 |
]. |
1646 | 548 |
editModel value:key. |
549 |
self cancel. |
|
151 | 550 |
! |
551 |
||
740 | 552 |
modified |
1646 | 553 |
"true if the helpSpec is modified, items are added, deleted or modified |
554 |
" |
|
555 |
^ modified |
|
700 | 556 |
! |
557 |
||
740 | 558 |
modified: aBoolean |
1646 | 559 |
"true if the helpSpec is modified, items are added, deleted or modified |
560 |
" |
|
561 |
modified := aBoolean. |
|
700 | 562 |
! |
563 |
||
286 | 564 |
modifiedHolder:aValueHolder |
779 | 565 |
"sets the value holder to true in case of modifying attributes" |
566 |
||
286 | 567 |
modifiedHolder notNil ifTrue:[ |
568 |
modifiedHolder removeDependent:self. |
|
569 |
]. |
|
1646 | 570 |
modifiedHolder := aValueHolder. |
459 | 571 |
|
1646 | 572 |
modifiedHolder notNil ifTrue:[ |
573 |
modifiedHolder addDependent:self. |
|
459 | 574 |
] |
715 | 575 |
! |
576 |
||
1604 | 577 |
setHelpKey:aKey |
578 |
"set the helpKey without notification |
|
579 |
" |
|
580 |
|model| |
|
581 |
||
582 |
model := modifiedHolder. |
|
583 |
modifiedHolder := nil. |
|
584 |
self helpKey:aKey. |
|
585 |
modifiedHolder := model. |
|
586 |
! |
|
587 |
||
715 | 588 |
specClass |
1646 | 589 |
"returns the class on which the help tool works |
590 |
" |
|
591 |
^ specClass |
|
592 |
! |
|
779 | 593 |
|
1646 | 594 |
specSelector |
595 |
"returns the selector on which the class is opened |
|
596 |
" |
|
597 |
^ specSelector |
|
354 | 598 |
! ! |
599 |
||
148 | 600 |
!UIHelpTool methodsFor:'aspects'! |
601 |
||
1646 | 602 |
contentsModifiedChannel |
603 |
"returns the model which indicates whether the current helpText is modified |
|
604 |
" |
|
605 |
^ contentsModifiedChannel |
|
606 |
! |
|
779 | 607 |
|
1646 | 608 |
editModel |
609 |
"returns the model which keeps the current editing key |
|
610 |
" |
|
611 |
^ editModel |
|
612 |
! |
|
613 |
||
614 |
listOfClasses |
|
615 |
"returns the list which keeps the classes |
|
616 |
" |
|
617 |
^ listOfClasses |
|
148 | 618 |
! |
619 |
||
1646 | 620 |
listOfClassesModel |
621 |
"returns the model which keeps the current class selection |
|
622 |
or nil |
|
623 |
" |
|
624 |
^ listOfClassesModel |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
625 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
626 |
|
1646 | 627 |
listOfKeys |
628 |
"returns the list which keeps the current keys |
|
629 |
" |
|
630 |
^ listOfKeys |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
631 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
632 |
|
1646 | 633 |
listOfKeysModel |
634 |
"returns the model which keeps the current list selection |
|
635 |
or nil |
|
636 |
" |
|
637 |
^ listOfKeysModel |
|
1336
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
638 |
! |
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
639 |
|
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
640 |
valueOfInfoLabel |
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
641 |
|
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
642 |
masterApplication notNil ifTrue:[ |
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
643 |
^ masterApplication valueOfInfoLabel |
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
644 |
]. |
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
645 |
^ super valueOfInfoLabel |
148 | 646 |
! ! |
647 |
||
750 | 648 |
!UIHelpTool methodsFor:'building'! |
649 |
||
1663 | 650 |
buildAndMergeFromClass:aClass |
651 |
"class and selector changed; merge old definitions |
|
652 |
into definitions loaded from a class |
|
653 |
" |
|
654 |
|saveDictionary saveHelpKey| |
|
655 |
||
656 |
saveDictionary := dictionary. |
|
657 |
saveHelpKey := self helpKey. |
|
658 |
||
659 |
self buildFromClass:aClass. |
|
660 |
||
661 |
saveDictionary notEmpty ifTrue:[ |
|
662 |
dictionary declareAllFrom:saveDictionary. |
|
663 |
self updateList. |
|
664 |
]. |
|
665 |
self helpKey:saveHelpKey. |
|
666 |
self modified:true. |
|
667 |
! |
|
668 |
||
750 | 669 |
buildFromClass:aClass |
779 | 670 |
"reads the help dictionary from aClass and find remaining classes |
671 |
'between' aClass and ApplicationModel" |
|
672 |
||
1646 | 673 |
|list| |
674 |
||
675 |
modified := false. |
|
676 |
specClass := self getHelpSpecClassFromClass:aClass. |
|
677 |
||
678 |
specClass notNil ifTrue:[ |
|
679 |
dictionary := Dictionary new. |
|
680 |
dictionaries removeAll. |
|
681 |
]. |
|
682 |
||
683 |
(specClass isClass and:[specClass isLoaded]) ifFalse:[ |
|
684 |
self updateList. |
|
685 |
^ self |
|
686 |
]. |
|
687 |
(specClass class includesSelector:specSelector) ifFalse:[ |
|
688 |
dictionaries at:(specClass name) put:dictionary. |
|
689 |
]. |
|
690 |
list := specClass withAllSuperclasses reverse collect:[:cls| cls name ]. |
|
691 |
||
692 |
(list includes: #ApplicationModel) ifTrue:[ |
|
693 |
list := list asOrderedCollection. |
|
694 |
list removeAll:(ApplicationModel withAllSuperclasses collect:[:cls| cls name]) |
|
695 |
]. |
|
696 |
listOfClasses contents:list. |
|
697 |
listOfClassesModel triggerValue:(specClass name). |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
698 |
! |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
699 |
|
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
700 |
buildFromClass: aClass andSelector: aSelector |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
701 |
"sets aSelector and reads the help dictionary from aClass" |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
702 |
|
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
703 |
specSelector := aSelector. |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
704 |
self buildFromClass:aClass |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
705 |
|
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
706 |
! |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
707 |
|
1646 | 708 |
buildFromHelpTool:aHelpTool |
709 |
||
710 |
self doNew. |
|
711 |
||
712 |
dictionaries := aHelpTool dictionaries. |
|
713 |
dictionary := aHelpTool dictionary. |
|
714 |
||
715 |
specSelector := aHelpTool specSelector. |
|
716 |
specClass := aHelpTool specClass. |
|
717 |
||
718 |
listOfClasses contents:(aHelpTool listOfClasses). |
|
719 |
listOfClassesModel triggerValue:(listOfClasses at:1 ifAbsent:nil). |
|
720 |
! ! |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
721 |
|
1646 | 722 |
!UIHelpTool methodsFor:'change & update'! |
723 |
||
724 |
editModelChanged |
|
725 |
"called if the edit model changed |
|
726 |
" |
|
727 |
|key| |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
728 |
|
1646 | 729 |
key := self helpKey. |
730 |
modifiedHolder notNil ifTrue:[ modifiedHolder value:true ]. |
|
731 |
||
732 |
(key notNil and:[(dictionary at:key ifAbsent:nil) isNil]) ifTrue:[ |
|
733 |
listOfClasses do:[:name| |dir| |
|
734 |
dir := self dictionaryForClassNamed:name. |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
735 |
|
1646 | 736 |
(dir includesKey:key) ifTrue:[ |
737 |
"/ setup new class |
|
738 |
listOfKeysModel setValue:key. |
|
739 |
listOfClassesModel value:name. |
|
740 |
^ self |
|
741 |
]. |
|
750 | 742 |
]. |
1646 | 743 |
key := nil. |
744 |
]. |
|
745 |
listOfKeysModel value:key. |
|
746 |
! |
|
747 |
||
748 |
listOfClassesModelChanged |
|
749 |
"called if the class selection changed |
|
750 |
" |
|
751 |
|clsName| |
|
752 |
||
753 |
clsName := listOfClassesModel value. |
|
754 |
clsName isNil ifTrue:[^ self]. |
|
963
62cdb7923a3b
care for setup, before view components are built
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
755 |
|
1646 | 756 |
dictionary := self dictionaryForClassNamed:clsName. |
757 |
self updateList. |
|
758 |
! |
|
759 |
||
760 |
listOfKeysModelChanged |
|
761 |
"called if the selection of the key list changed |
|
762 |
" |
|
763 |
|key txt| |
|
764 |
||
765 |
key := listOfKeysModel value. |
|
963
62cdb7923a3b
care for setup, before view components are built
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
766 |
|
1646 | 767 |
key notNil ifTrue:[ |
768 |
key := key asSymbol. |
|
769 |
txt := dictionary at:key ifAbsent:nil. |
|
770 |
||
771 |
txt isNil ifTrue:[ |
|
772 |
listOfKeysModel value:nil. |
|
773 |
^ self |
|
963
62cdb7923a3b
care for setup, before view components are built
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
774 |
]. |
1646 | 775 |
editModel value ~= key ifTrue:[ |
776 |
editModel value:key withoutNotifying:self. |
|
777 |
modifiedHolder notNil ifTrue:[ modifiedHolder value:true ]. |
|
778 |
]. |
|
750 | 779 |
]. |
780 |
||
1646 | 781 |
contentsModifiedChannel value ifFalse:[ |
782 |
self cancel |
|
783 |
]. |
|
784 |
! |
|
779 | 785 |
|
1646 | 786 |
update:something with:aParameter from:changedObject |
787 |
"Invoked when an object that I depend upon sends a change notification." |
|
740 | 788 |
|
1646 | 789 |
editModel == changedObject ifTrue:[ |
790 |
self editModelChanged. |
|
791 |
^ self |
|
792 |
]. |
|
722 | 793 |
|
1646 | 794 |
listOfKeysModel == changedObject ifTrue:[ |
795 |
self listOfKeysModelChanged. |
|
796 |
^ self |
|
797 |
]. |
|
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
798 |
|
1646 | 799 |
listOfClassesModel == changedObject ifTrue:[ |
800 |
self listOfClassesModelChanged. |
|
801 |
^ self |
|
802 |
]. |
|
803 |
||
804 |
contentsModifiedChannel == changedObject ifTrue:[ |
|
805 |
contentsModifiedChannel value ifTrue:[ |
|
806 |
modifiedHolder notNil ifTrue:[modifiedHolder value:true]. |
|
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
807 |
]. |
1646 | 808 |
^ self |
740 | 809 |
]. |
1646 | 810 |
|
811 |
super update:something with:aParameter from:changedObject |
|
286 | 812 |
! ! |
813 |
||
750 | 814 |
!UIHelpTool methodsFor:'help'! |
815 |
||
904 | 816 |
openDocumentation |
817 |
"opens the documentation file of the Help Tool" |
|
818 |
||
819 |
self openHTMLDocument: 'tools/uipainter/HelpTool.html' |
|
750 | 820 |
! ! |
821 |
||
286 | 822 |
!UIHelpTool methodsFor:'private'! |
823 |
||
750 | 824 |
askForModification |
779 | 825 |
"asks for modification" |
740 | 826 |
|
1646 | 827 |
modified ifTrue:[ |
828 |
( (YesNoBox title: 'List was modified!!') |
|
829 |
noText:'Cancel'; |
|
830 |
yesText:'Waste it and proceed'; |
|
750 | 831 |
showAtPointer; |
1646 | 832 |
accepted |
833 |
) ifFalse:[ |
|
834 |
^ false |
|
835 |
]. |
|
750 | 836 |
modified := false |
740 | 837 |
]. |
1646 | 838 |
^ true |
740 | 839 |
! |
840 |
||
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
841 |
dictionaryForClassNamed:clsName |
1646 | 842 |
"returns the directory assigned to a class name |
843 |
" |
|
844 |
^ dictionaries at:clsName |
|
845 |
ifAbsentPut:[ self extractHelpSpecForClass: (Smalltalk at:clsName) ]. |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
846 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
847 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
848 |
extractHelpSpecForClass: aClass |
779 | 849 |
"extracts the help dictionary of aClass, it current and return it" |
850 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
851 |
|helpSpecSuperClass superHelpSpecKeys helpSpec| |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
852 |
|
1646 | 853 |
helpSpec := Dictionary new. |
854 |
||
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
855 |
((aClass class includesSelector: specSelector) |
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
856 |
and: [(helpSpecSuperClass := aClass allSuperclasses detect: [:cls| cls class includesSelector: specSelector] ifNone: nil) notNil]) |
1198 | 857 |
ifTrue:[ |
1665 | 858 |
superHelpSpecKeys := (helpSpecSuperClass perform:specSelector) keys. |
1646 | 859 |
|
1665 | 860 |
(aClass perform:specSelector) keysAndValuesDo:[:key :value | |
1198 | 861 |
(superHelpSpecKeys includes:key) ifFalse: [ |
862 |
helpSpec at:key put:value |
|
863 |
] |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
864 |
]. |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
865 |
]. |
1646 | 866 |
^ helpSpec |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
867 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
868 |
|
750 | 869 |
getHelpSpecClassFromClass:aClass |
779 | 870 |
"returns application class keeping the associated help text or nil" |
871 |
||
750 | 872 |
|cls| |
873 |
||
874 |
((cls := self resolveName:aClass) notNil and:[cls respondsTo: #helpSpecClass]) ifTrue:[ |
|
875 |
^cls helpSpecClass |
|
876 |
]. |
|
877 |
^cls |
|
878 |
||
879 |
||
880 |
! |
|
881 |
||
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
882 |
getUnformattedHelpText: aHelpText |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
883 |
"unformats aHelpText and returns it" |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
884 |
|
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
885 |
|helpText| |
896 | 886 |
|
887 |
helpText := aHelpText asString copyReplaceAll:(Character cr) with:(Character space). |
|
888 |
(helpText endsWith:(Character space)) ifTrue:[ |
|
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
889 |
helpText := helpText copyWithoutLast:1 |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
890 |
]. |
896 | 891 |
^ helpText |
892 |
||
893 |
"Modified: / 20.7.1998 / 13:17:52 / cg" |
|
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
894 |
! |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
895 |
|
740 | 896 |
installHelpSpecOnClass:aClass |
779 | 897 |
"saves the help dicts in aClass which is subclass of ApplicationModel" |
740 | 898 |
|
899 |
|cls src helpSpec| |
|
900 |
||
750 | 901 |
cls := self getHelpSpecClassFromClass: aClass. |
740 | 902 |
|
903 |
cls isNil ifTrue:[ |
|
904 |
self information:'No application class defined!!'. |
|
905 |
^nil |
|
906 |
]. |
|
907 |
||
908 |
(cls isSubclassOf: ApplicationModel) ifFalse:[ |
|
909 |
self information: 'Cannot save help spec into class ', cls name asBoldText, ',\because it is not a subclass of ApplicationModel!!' withCRs. |
|
910 |
^nil |
|
911 |
]. |
|
912 |
||
913 |
helpSpec := dictionaries |
|
914 |
at: cls name |
|
915 |
ifAbsent: [specClass notNil |
|
916 |
ifTrue: [dictionaries at: aClass put: (self extractHelpSpecForClass: (Smalltalk at: aClass))] |
|
917 |
ifFalse: [dictionary size > 0 ifTrue: [dictionary] ifFalse: [Dictionary new]]]. |
|
918 |
||
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
919 |
helpSpec associationsDo: |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
920 |
[:h| |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
921 |
helpSpec at: h key put: (self getUnformattedHelpText: h value) |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
922 |
]. |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
923 |
|
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
924 |
(cls class includesSelector: specSelector) |
740 | 925 |
ifTrue: |
926 |
[ |
|
927 |
|superclassHelpKeys implementedHelpSpec hasChanged| |
|
928 |
implementedHelpSpec := Dictionary new. |
|
750 | 929 |
superclassHelpKeys := (cls superclass respondsTo: specSelector) |
1665 | 930 |
ifTrue: [(cls superclass perform:specSelector) keys] |
740 | 931 |
ifFalse: [Array new]. |
932 |
||
1665 | 933 |
(cls perform:specSelector) associationsDo: [:h| (superclassHelpKeys includes: h key) |
740 | 934 |
ifFalse: [implementedHelpSpec at: h key put: h value]]. |
935 |
||
936 |
hasChanged := false. |
|
937 |
implementedHelpSpec associationsDo: [:h| (helpSpec includesAssociation: h) ifFalse: [hasChanged := true]]. |
|
938 |
helpSpec associationsDo: [:h| (implementedHelpSpec includesAssociation: h) ifFalse: [hasChanged := true]]. |
|
939 |
||
940 |
(implementedHelpSpec notEmpty and: [hasChanged and: |
|
941 |
[DialogBox confirm: 'Class ', cls name asBoldText, ' already implements\a help spec!!\\Do only replace, if you have removed\help keys in an existing help spec.\' withCRs yesLabel: ' Merge ' noLabel: ' Replace ']]) |
|
942 |
ifTrue: |
|
943 |
[ |
|
944 |
implementedHelpSpec associationsDo: [:h| (helpSpec includesKey: h key) |
|
945 |
ifFalse: [helpSpec at: h key put: h value]]. |
|
946 |
] |
|
947 |
]. |
|
948 |
||
949 |
helpSpec isEmpty ifTrue:[ |
|
750 | 950 |
^(cls superclass respondsTo: specSelector) ifTrue: [cls class removeSelector: specSelector]. |
740 | 951 |
]. |
952 |
||
953 |
src := '' writeStream. |
|
954 |
||
955 |
src nextPutAll: |
|
750 | 956 |
specSelector, '\' withCRs, |
740 | 957 |
(ResourceSpecEditor codeGenerationCommentForClass: UIHelpTool) withCRs, |
958 |
'\\' withCRs, |
|
959 |
' "\' withCRs, |
|
960 |
' UIHelpTool openOnClass:', cls name asString ,' |
|
961 |
" |
|
962 |
||
963 |
<resource: #help> |
|
964 |
||
750 | 965 |
^super ', specSelector, ' addPairsFrom:#( |
740 | 966 |
|
967 |
'. |
|
968 |
||
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
969 |
helpSpec keys asSortedCollection do: |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
970 |
[:key| |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
971 |
src nextPutLine: key storeString. |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
972 |
src nextPutLine: (helpSpec at: key) storeString; cr. |
740 | 973 |
]. |
974 |
src nextPutLine:')'. |
|
975 |
||
976 |
Compiler |
|
977 |
compile:(src contents) |
|
978 |
forClass:cls class |
|
979 |
inCategory:'help specs'. |
|
980 |
! |
|
981 |
||
982 |
installHelpSpecsOnClass:aClass |
|
779 | 983 |
"saves the help dicts on aClass and its superclasses which are subclasses of ApplicationModel" |
984 |
||
740 | 985 |
|cls helpSpecClasses| |
986 |
||
750 | 987 |
cls := self getHelpSpecClassFromClass:aClass. |
1646 | 988 |
|
989 |
cls isNil ifTrue: [ |
|
990 |
self information:'No application class defined!!'. |
|
991 |
^ self |
|
992 |
]. |
|
750 | 993 |
|
740 | 994 |
modified ifFalse:[ |
750 | 995 |
masterApplication isNil ifTrue: [self information:'Nothing was modified!!']. |
1646 | 996 |
^ self |
740 | 997 |
]. |
1646 | 998 |
helpSpecClasses := listOfClasses copy. |
999 |
||
1000 |
helpSpecClasses notEmpty ifTrue:[ |
|
1001 |
(helpSpecClasses includes: cls name) ifFalse: [helpSpecClasses add: cls name]. |
|
740 | 1002 |
|
1646 | 1003 |
helpSpecClasses do:[:clsName| |
1004 |
(self installHelpSpecOnClass: clsName) isNil ifTrue:[ |
|
1005 |
modified := false. |
|
1006 |
^ self |
|
1007 |
] |
|
1008 |
]. |
|
740 | 1009 |
] |
1010 |
ifFalse: |
|
750 | 1011 |
[ |
740 | 1012 |
self installHelpSpecOnClass: cls |
1013 |
]. |
|
1014 |
||
1015 |
modified := false. |
|
1016 |
! |
|
1017 |
||
750 | 1018 |
resourceMessage: aString |
779 | 1019 |
"extracts from aString the specClass and the specSelector" |
750 | 1020 |
|
1021 |
(aString notNil and: [self askForModification]) |
|
1022 |
ifTrue: |
|
1023 |
[ |
|
1024 |
|msg cls sel| |
|
1025 |
msg := aString asCollectionOfWords. |
|
1026 |
(msg size == 2 and: |
|
1027 |
[(cls := self resolveName:(msg at:1)) notNil]) |
|
1028 |
ifTrue: |
|
1029 |
[ |
|
1030 |
specClass := cls name. |
|
1031 |
specSelector := (msg at: 2) asSymbol. |
|
1032 |
^true |
|
1033 |
] |
|
1034 |
]. |
|
1035 |
^false |
|
1036 |
||
1037 |
! |
|
1038 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1039 |
updateList |
1646 | 1040 |
"updates the list of keys |
1041 |
" |
|
1042 |
|key| |
|
286 | 1043 |
|
1646 | 1044 |
listOfKeysModel setValue:nil. |
1045 |
listOfKeys contents:(dictionary keys asSortedCollection). |
|
1243 | 1046 |
|
1646 | 1047 |
key := self helpKey. |
286 | 1048 |
|
1646 | 1049 |
(key notNil and:[listOfKeys includes:key]) ifFalse:[ |
1050 |
key := nil. |
|
1243 | 1051 |
]. |
1646 | 1052 |
listOfKeysModel triggerValue:key |
286 | 1053 |
! ! |
1054 |
||
369 | 1055 |
!UIHelpTool methodsFor:'startup / release'! |
1056 |
||
1057 |
closeRequest |
|
779 | 1058 |
"asks for permission before closing" |
1059 |
||
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
1060 |
(self masterApplication isNil and:[self askForModification]) ifTrue:[ |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
1061 |
super closeRequest |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
1062 |
] |
740 | 1063 |
! |
1064 |
||
1065 |
initialize |
|
779 | 1066 |
"initializes instance variables" |
1067 |
||
740 | 1068 |
super initialize. |
1069 |
||
750 | 1070 |
specSelector := #helpSpec. |
740 | 1071 |
dictionary := Dictionary new. |
1072 |
dictionaries := Dictionary new. |
|
1646 | 1073 |
modified := false. |
1074 |
||
1075 |
editModel := nil asValue. |
|
1076 |
editModel addDependent:self. |
|
740 | 1077 |
|
1646 | 1078 |
listOfKeys := List new. |
1079 |
listOfKeysModel := nil asValue. |
|
1080 |
listOfKeysModel addDependent:self. |
|
1081 |
||
1082 |
listOfClasses := List new. |
|
1083 |
listOfClassesModel := nil asValue. |
|
1084 |
listOfClassesModel addDependent:self. |
|
1085 |
||
1086 |
contentsModifiedChannel := false asValue. |
|
1087 |
contentsModifiedChannel addDependent:self. |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1088 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1089 |
|
750 | 1090 |
loadFromMessage:aString |
779 | 1091 |
"loads a help spec by evaluating aString" |
750 | 1092 |
|
1093 |
(aString notNil and: [self askForModification]) |
|
1094 |
ifTrue: |
|
1095 |
[ |
|
1096 |
|msg cls sel| |
|
1097 |
msg := aString asCollectionOfWords. |
|
1098 |
(msg size == 2 and: |
|
1099 |
[(cls := self resolveName:(msg at:1)) notNil and: |
|
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1100 |
[cls class includesSelector: (sel := (msg at: 2) asSymbol)]]) |
750 | 1101 |
ifTrue: |
1102 |
[ |
|
1103 |
self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel). |
|
1104 |
^true |
|
1105 |
] |
|
1106 |
]. |
|
1107 |
^false |
|
1108 |
! |
|
1109 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1110 |
openInterface:aSymbol |
779 | 1111 |
"do not open as stand alone" |
1112 |
||
750 | 1113 |
|
1114 |
||
1115 |
! |
|
1116 |
||
1117 |
openOnClass:aClass |
|
779 | 1118 |
"opens the UIHelpTool on aClass" |
750 | 1119 |
|
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1120 |
self openOnClass:aClass andSelector:nil |
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1121 |
|
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1122 |
" |
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1123 |
self openOnClass:NewLauncher |
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1124 |
" |
940 | 1125 |
! |
1126 |
||
1127 |
openOnClass:aClass andSelector: aSelector |
|
1128 |
"opens the UIHelpTool on aClass and aSelector" |
|
1129 |
||
1130 |
super openInterface: #windowSpecForStandAlone. |
|
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1131 |
|
940 | 1132 |
builder window label: 'Help Tool'. |
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1133 |
self buildFromClass:aClass andSelector:aSelector |
1646 | 1134 |
! |
1135 |
||
1136 |
postBuildTextView:aView |
|
1137 |
||
1138 |
editTextView := aView scrolledView. |
|
1139 |
editTextView acceptAction:[:dummy| self accept ]. |
|
369 | 1140 |
! ! |
1141 |
||
740 | 1142 |
!UIHelpTool methodsFor:'user actions'! |
286 | 1143 |
|
722 | 1144 |
accept |
779 | 1145 |
"accepts the help text" |
1146 |
||
1646 | 1147 |
|key txt| |
1148 |
||
1149 |
key := self helpKey. |
|
1150 |
key isNil ifTrue:[^ self]. |
|
1151 |
||
1648
d88ec5777284
empty help string - add key anyway
Claus Gittinger <cg@exept.de>
parents:
1646
diff
changeset
|
1152 |
contentsModifiedChannel value ifFalse:[ |
d88ec5777284
empty help string - add key anyway
Claus Gittinger <cg@exept.de>
parents:
1646
diff
changeset
|
1153 |
(dictionary includes:key) ifTrue:[^ self]. |
d88ec5777284
empty help string - add key anyway
Claus Gittinger <cg@exept.de>
parents:
1646
diff
changeset
|
1154 |
]. |
d88ec5777284
empty help string - add key anyway
Claus Gittinger <cg@exept.de>
parents:
1646
diff
changeset
|
1155 |
contentsModifiedChannel value:false. |
d88ec5777284
empty help string - add key anyway
Claus Gittinger <cg@exept.de>
parents:
1646
diff
changeset
|
1156 |
|
1646 | 1157 |
txt := editTextView contents ? ''. |
1158 |
txt := txt asString. |
|
722 | 1159 |
|
1646 | 1160 |
dictionary at:key put:txt. |
722 | 1161 |
|
1646 | 1162 |
listOfKeys detect:[:el| el = key ] ifNone:[ |idx| |
1163 |
idx := listOfKeys findFirst:[:el| el > key ]. |
|
1164 |
idx == 0 ifTrue:[ listOfKeys add:key ] |
|
1165 |
ifFalse:[ listOfKeys add:key beforeIndex:idx] |
|
1166 |
]. |
|
722 | 1167 |
|
1646 | 1168 |
listOfKeysModel value:key withoutNotifying:self. |
1169 |
||
1170 |
modified := true. |
|
1171 |
modifiedHolder notNil ifTrue:[ modifiedHolder value:true ]. |
|
722 | 1172 |
! |
1173 |
||
1646 | 1174 |
cancel |
1175 |
|key txt| |
|
1176 |
||
1177 |
editTextView notNil ifTrue:[ |
|
1178 |
key := listOfKeysModel value. |
|
779 | 1179 |
|
1646 | 1180 |
key notNil ifTrue:[ |
1181 |
txt := dictionary at:key ifAbsent:nil. |
|
1182 |
] ifFalse:[ |
|
1183 |
txt := nil |
|
1184 |
]. |
|
1185 |
editTextView contents:txt. |
|
1186 |
]. |
|
1187 |
contentsModifiedChannel value:false. |
|
722 | 1188 |
! |
1189 |
||
750 | 1190 |
doDelete |
1646 | 1191 |
"deletes the selected help key |
1192 |
" |
|
1193 |
|key| |
|
1194 |
||
1195 |
key := listOfKeysModel value. |
|
779 | 1196 |
|
1646 | 1197 |
key isNil ifTrue:[ |
1198 |
self warn:'No key selected !!'. |
|
1199 |
^ self |
|
1200 |
]. |
|
1201 |
||
1202 |
listOfKeysModel value:nil. |
|
1203 |
||
1204 |
key := key asSymbol. |
|
1205 |
listOfKeys remove:key ifAbsent:nil. |
|
1206 |
||
1207 |
(dictionary removeKey:key ifAbsent:nil) notNil ifTrue:[ |
|
740 | 1208 |
modified := true. |
1646 | 1209 |
modifiedHolder notNil ifTrue: [modifiedHolder value:true]. |
1210 |
]. |
|
722 | 1211 |
! |
1212 |
||
750 | 1213 |
doLoad |
779 | 1214 |
"opens a Resource Selection Browser in order to get a resource message" |
286 | 1215 |
|
750 | 1216 |
self loadFromMessage: |
1217 |
(ResourceSelectionBrowser |
|
779 | 1218 |
request: 'Load Help Spec From Class' |
750 | 1219 |
onSuperclass: nil |
1220 |
andClass: specClass |
|
779 | 1221 |
andSelector: specSelector ? #help |
1222 |
withResourceTypes: (Array with: #help)). |
|
1223 |
||
1224 |
self updateInfoLabel |
|
286 | 1225 |
|
750 | 1226 |
! |
286 | 1227 |
|
750 | 1228 |
doNew |
779 | 1229 |
"resets the help tool" |
1230 |
||
1646 | 1231 |
specClass := nil. |
286 | 1232 |
|
1646 | 1233 |
editModel value:nil withoutNotifying:self. |
1234 |
listOfKeysModel value:nil. |
|
1235 |
listOfClassesModel value:nil. |
|
369 | 1236 |
|
1646 | 1237 |
listOfKeys removeAll. |
1238 |
listOfClasses removeAll. |
|
1239 |
dictionaries removeAll. |
|
779 | 1240 |
|
1646 | 1241 |
dictionary := Dictionary new. |
1242 |
modified := false. |
|
750 | 1243 |
! |
1244 |
||
722 | 1245 |
doSave |
779 | 1246 |
"saves the help dictionaries on specClass" |
1247 |
||
722 | 1248 |
self installHelpSpecsOnClass:specClass |
148 | 1249 |
! ! |
1250 |
||
1251 |
!UIHelpTool class methodsFor:'documentation'! |
|
1252 |
||
1253 |
version |
|
1254 |
^ '$Header$' |
|
1255 |
! ! |