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