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