author | Claus Gittinger <cg@exept.de> |
Sat, 06 Jun 1998 17:25:53 +0200 | |
changeset 860 | 3e5171aad09f |
parent 835 | 13793eec85d5 |
child 868 | dfa9d6df10d8 |
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 |
^ |
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 |
#(#Menu |
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 |
#( |
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 |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
384 |
|
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 |
|
419 |
||
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' |
|
442 |
#startGroup: #right |
|
835 | 443 |
#translateLabel: true |
750 | 444 |
#submenu: |
445 |
#(#Menu |
|
446 |
||
447 |
#( |
|
448 |
#(#MenuItem |
|
449 |
#label: 'Documentation' |
|
450 |
#value: #openHTMLDocument: |
|
835 | 451 |
#translateLabel: true |
750 | 452 |
#activeHelpKey: #helpHelpTool |
453 |
#argument: 'tools/uipainter/HelpTool.html' |
|
454 |
) |
|
455 |
#(#MenuItem |
|
456 |
#label: '-' |
|
457 |
) |
|
458 |
#(#MenuItem |
|
459 |
#label: 'Show Help Texts' |
|
835 | 460 |
#translateLabel: true |
750 | 461 |
#activeHelpKey: #helpShowHelp |
462 |
#indication: #showHelp: |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
463 |
) |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
464 |
) nil |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
465 |
nil |
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 |
) |
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 |
nil |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
470 |
) |
835 | 471 |
|
472 |
"Modified: / 20.5.1998 / 01:08:12 / cg" |
|
148 | 473 |
! ! |
474 |
||
475 |
!UIHelpTool methodsFor:'accessing'! |
|
476 |
||
710 | 477 |
dictionaries |
779 | 478 |
"returns the dictionary of the help dictionaries of the classes having help specs" |
479 |
||
710 | 480 |
^dictionaries |
481 |
! |
|
482 |
||
483 |
dictionaries:aDictionaryOfDictionaries |
|
779 | 484 |
"sets a dictionary of the help dictionaries of the classes having help specs" |
485 |
||
710 | 486 |
(dictionaries := aDictionaryOfDictionaries) isNil ifTrue:[ |
487 |
dictionaries := Dictionary new. |
|
488 |
]. |
|
715 | 489 |
self updateList. |
710 | 490 |
! |
491 |
||
151 | 492 |
dictionary |
779 | 493 |
"returns the dictionary of the selected class" |
494 |
||
722 | 495 |
^dictionary |
710 | 496 |
! |
151 | 497 |
|
498 |
dictionary:aDictionary |
|
779 | 499 |
"sets dictionary of the selected class" |
500 |
||
286 | 501 |
(dictionary := aDictionary) isNil ifTrue:[ |
700 | 502 |
dictionary := Dictionary new. |
286 | 503 |
]. |
504 |
self updateList |
|
505 |
! |
|
506 |
||
507 |
helpKey |
|
779 | 508 |
"returns the help key of selected help text" |
509 |
||
286 | 510 |
listSelection size ~~ 0 ifTrue:[ |
511 |
^ listSelection asSymbol |
|
151 | 512 |
]. |
286 | 513 |
^ nil |
514 |
! |
|
515 |
||
516 |
helpKey:aKey |
|
779 | 517 |
"sets the help key into the selection channel in order to show the help text" |
518 |
||
286 | 519 |
|key| |
520 |
aKey size ~~ 0 ifTrue:[ |
|
521 |
key := aKey asString |
|
522 |
]. |
|
523 |
self listModel value:key |
|
459 | 524 |
|
151 | 525 |
! |
526 |
||
740 | 527 |
modified |
779 | 528 |
"returns whether the help tool was modified" |
529 |
||
740 | 530 |
^modified |
700 | 531 |
! |
532 |
||
740 | 533 |
modified: aBoolean |
779 | 534 |
"sets the help tool as modified" |
535 |
||
740 | 536 |
modified := aBoolean |
700 | 537 |
! |
538 |
||
286 | 539 |
modifiedHolder:aValueHolder |
779 | 540 |
"sets the value holder to true in case of modifying attributes" |
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 |
|
549 |
self editTextView notNil ifTrue: [ |
|
550 |
self editTextView modifiedChannel onChangeSend:#value to:[ |
|
551 |
modifiedHolder notNil ifTrue:[ |
|
552 |
self editTextView modifiedChannel value ifTrue:[ |
|
553 |
modifiedHolder value:true |
|
554 |
] |
|
555 |
] |
|
556 |
] |
|
557 |
] |
|
558 |
] |
|
286 | 559 |
|
560 |
||
715 | 561 |
! |
562 |
||
563 |
specClass |
|
779 | 564 |
"returns the class on which the help tool works" |
565 |
||
715 | 566 |
^specClass |
354 | 567 |
! ! |
568 |
||
148 | 569 |
!UIHelpTool methodsFor:'aspects'! |
570 |
||
571 |
listChannel |
|
779 | 572 |
"returns the value holder of the help texts" |
573 |
||
148 | 574 |
|holder| |
575 |
(holder := builder bindingAt:#listChannel) isNil ifTrue:[ |
|
354 | 576 |
builder aspectAt:#listChannel put:(holder := OrderedCollection new asValue). |
148 | 577 |
]. |
578 |
^ holder |
|
579 |
! |
|
580 |
||
286 | 581 |
listModel |
779 | 582 |
"returns the value holder of the help key" |
583 |
||
148 | 584 |
|holder| |
286 | 585 |
(holder := builder bindingAt:#listModel) isNil ifTrue:[ |
586 |
holder := AspectAdaptor new subject:self; forAspect:#listSelection. |
|
587 |
builder aspectAt:#listModel put:holder. |
|
148 | 588 |
]. |
589 |
^ holder |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
590 |
! |
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 |
listOfHelpSpecClasses |
779 | 593 |
"returns the value holder of the specClass and its superclasses |
594 |
which are subclasses of ApplicationModel" |
|
595 |
||
750 | 596 |
|holder| |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
597 |
(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
|
598 |
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
|
599 |
]. |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
600 |
^ holder |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
601 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
602 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
603 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
604 |
selectionOfHelpSpecClass |
779 | 605 |
"returns the value holder of the selected help spec class" |
606 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
607 |
|holder| |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
608 |
(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
|
609 |
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
|
610 |
]. |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
611 |
^ holder |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
612 |
|
148 | 613 |
! ! |
614 |
||
750 | 615 |
!UIHelpTool methodsFor:'building'! |
616 |
||
617 |
buildFromClass:aClass |
|
779 | 618 |
"reads the help dictionary from aClass and find remaining classes |
619 |
'between' aClass and ApplicationModel" |
|
620 |
||
750 | 621 |
modified := false. |
622 |
specClass notNil |
|
623 |
ifTrue: |
|
624 |
[ |
|
625 |
dictionary := Dictionary new. |
|
626 |
dictionaries := Dictionary new. |
|
627 |
]. |
|
628 |
specClass := self getHelpSpecClassFromClass:aClass. |
|
629 |
(specClass isClass and: [specClass isLoaded]) |
|
630 |
ifTrue: |
|
631 |
[ |
|
632 |
(specClass class implements:specSelector) ifFalse:[ |
|
633 |
dictionaries at: specClass name put: dictionary |
|
634 |
]. |
|
635 |
self listOfHelpSpecClasses contents: (specClass withAllSuperclasses reverse collect: [:cls| cls name]). |
|
636 |
(self listOfHelpSpecClasses includes: #ApplicationModel) |
|
637 |
ifTrue: [self listOfHelpSpecClasses removeAll: (ApplicationModel withAllSuperclasses collect: [:cls| cls name])]. |
|
638 |
self selectionOfHelpSpecClass value: specClass name. |
|
639 |
(builder componentAt: #listOfHelpSpecClassesView) selection: |
|
640 |
(self listOfHelpSpecClasses value indexOf: specClass name). |
|
641 |
self helpSpecClassSelected. |
|
642 |
]. |
|
643 |
||
644 |
self updateList |
|
645 |
! |
|
646 |
||
647 |
buildFromClass: aClass andSelector: aSelector |
|
779 | 648 |
"sets aSelector and reads the help dictionary from aClass" |
750 | 649 |
|
650 |
specSelector := aSelector. |
|
651 |
self buildFromClass:aClass |
|
652 |
||
653 |
! ! |
|
654 |
||
740 | 655 |
!UIHelpTool methodsFor:'callbacks'! |
148 | 656 |
|
740 | 657 |
helpSpecClassSelected |
779 | 658 |
"extracts the help dictionary from the selected class and make it current" |
659 |
||
740 | 660 |
|clsName| |
661 |
||
662 |
clsName := self selectionOfHelpSpecClass value. |
|
663 |
||
664 |
(dictionary := dictionaries at: clsName ifAbsent: nil) isNil |
|
665 |
ifTrue: |
|
666 |
[ |
|
667 |
dictionary := dictionaries at: clsName put: (self extractHelpSpecForClass: (Smalltalk at: clsName)) |
|
668 |
]. |
|
669 |
||
670 |
self updateList. |
|
722 | 671 |
|
740 | 672 |
listSelection notNil |
673 |
ifTrue: |
|
674 |
[ |
|
675 |
(dictionary keys includes: listSelection asSymbol) |
|
676 |
ifTrue: [(builder componentAt: #listOfHelpKeysView) selection: |
|
677 |
(self listChannel value indexOf: (builder componentAt: #helpKeyInputField) contents)] |
|
678 |
ifFalse: [(builder componentAt: #listOfHelpKeysView) selection: nil]. |
|
679 |
]. |
|
680 |
listSelection notNil |
|
681 |
ifTrue: |
|
682 |
[ |
|
683 |
self editTextView contents: (dictionary at: listSelection asSymbol ifAbsent: '') |
|
684 |
] |
|
685 |
||
369 | 686 |
|
286 | 687 |
! ! |
688 |
||
750 | 689 |
!UIHelpTool methodsFor:'help'! |
690 |
||
691 |
defaultInfoLabel |
|
779 | 692 |
"returns the default label for the info bar" |
750 | 693 |
|
694 |
specClass isClass |
|
695 |
ifTrue: |
|
696 |
[ |
|
697 |
(specClass class implements: specSelector) |
|
698 |
ifFalse: |
|
699 |
[ |
|
700 |
^specSelector isNil |
|
701 |
ifTrue: [specClass name, ' >> ? (no selector defined)'] |
|
702 |
ifFalse: [specClass name, ' >> ', specSelector, ' (not implemented)'] |
|
703 |
]. |
|
704 |
^specClass name, ' >> ', specSelector |
|
705 |
]. |
|
706 |
^'No class and selector defined.' |
|
707 |
||
708 |
||
709 |
||
710 |
! ! |
|
711 |
||
286 | 712 |
!UIHelpTool methodsFor:'private'! |
713 |
||
750 | 714 |
askForModification |
779 | 715 |
"asks for modification" |
740 | 716 |
|
750 | 717 |
modified |
718 |
ifTrue: |
|
719 |
[ |
|
720 |
((YesNoBox title: 'List was modified!!') |
|
721 |
noText:'Cancel'; |
|
722 |
yesText:'Waste it and proceed'; |
|
723 |
showAtPointer; |
|
724 |
accepted) ifFalse: [^false]. |
|
725 |
modified := false |
|
740 | 726 |
]. |
750 | 727 |
^true |
728 |
||
740 | 729 |
|
730 |
||
731 |
! |
|
732 |
||
286 | 733 |
editTextView |
779 | 734 |
"returns the editTextView or nil" |
735 |
||
286 | 736 |
|view| |
737 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
738 |
(view := builder componentAt:#helpTextView) notNil ifTrue:[ |
286 | 739 |
view := view scrolledView. |
740 |
||
741 |
view acceptAction isNil ifTrue:[ |
|
742 |
view acceptAction:[:aList| self accept ]. |
|
743 |
]. |
|
744 |
||
745 |
view left ~~ 0 ifTrue:[ |
|
746 |
(maxCharsPerLine := view extent x // view font width) < 10 ifTrue:[ |
|
747 |
maxCharsPerLine := nil |
|
748 |
] |
|
749 |
]. |
|
454 | 750 |
]. |
286 | 751 |
^ view |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
752 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
753 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
754 |
extractHelpSpecForClass: aClass |
779 | 755 |
"extracts the help dictionary of aClass, it current and return it" |
756 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
757 |
|helpSpecSuperClass superHelpSpecKeys helpSpec| |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
758 |
|
750 | 759 |
((aClass class implements: specSelector) |
760 |
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
|
761 |
ifTrue: |
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 |
superHelpSpecKeys := helpSpecSuperClass helpSpec keys. |
700 | 764 |
helpSpec := Dictionary new. |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
765 |
aClass helpSpec associationsDo: |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
766 |
[:asso| |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
767 |
(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
|
768 |
]. |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
769 |
^dictionary := helpSpec |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
770 |
]. |
700 | 771 |
^dictionary := Dictionary new |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
772 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
773 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
774 |
findHelpSpecForKey: aHelpKey |
779 | 775 |
"finds the help spec class including aHelpKey in its help dictionary and make it current" |
776 |
||
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
777 |
|dictTemp| |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
778 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
779 |
aHelpKey isNil ifTrue: [^nil]. |
700 | 780 |
dictTemp := dictionary. |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
781 |
self listOfHelpSpecClasses value do: |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
782 |
[:clsName| |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
783 |
(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
|
784 |
ifTrue: |
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 |
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
|
787 |
]. |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
788 |
(dictionary includesKey: aHelpKey asSymbol) |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
789 |
ifTrue: |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
790 |
[ |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
791 |
self updateList. |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
792 |
^(builder componentAt: #listOfHelpSpecClassesView) selection: |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
793 |
(self listOfHelpSpecClasses value indexOf: clsName). |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
794 |
] |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
795 |
]. |
700 | 796 |
dictionary := dictTemp |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
797 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
798 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
799 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
800 |
|
750 | 801 |
getHelpSpecClassFromClass:aClass |
779 | 802 |
"returns application class keeping the associated help text or nil" |
803 |
||
750 | 804 |
|cls| |
805 |
||
806 |
((cls := self resolveName:aClass) notNil and:[cls respondsTo: #helpSpecClass]) ifTrue:[ |
|
807 |
^cls helpSpecClass |
|
808 |
]. |
|
809 |
^cls |
|
810 |
||
811 |
||
812 |
! |
|
813 |
||
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
814 |
getUnformattedHelpText: aHelpText |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
815 |
"unformats aHelpText and returns it" |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
816 |
|
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
817 |
|helpText| |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
818 |
helpText := aHelpText asString replaceAll: Character cr with: Character space. |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
819 |
(helpText endsWith:Character space) ifTrue:[ |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
820 |
helpText := helpText copyWithoutLast:1 |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
821 |
]. |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
822 |
^helpText |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
823 |
! |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
824 |
|
740 | 825 |
installHelpSpecOnClass:aClass |
779 | 826 |
"saves the help dicts in aClass which is subclass of ApplicationModel" |
740 | 827 |
|
828 |
|cls src helpSpec| |
|
829 |
||
750 | 830 |
cls := self getHelpSpecClassFromClass: aClass. |
740 | 831 |
|
832 |
cls isNil ifTrue:[ |
|
833 |
self information:'No application class defined!!'. |
|
834 |
^nil |
|
835 |
]. |
|
836 |
||
837 |
(cls isSubclassOf: ApplicationModel) ifFalse:[ |
|
838 |
self information: 'Cannot save help spec into class ', cls name asBoldText, ',\because it is not a subclass of ApplicationModel!!' withCRs. |
|
839 |
^nil |
|
840 |
]. |
|
841 |
||
842 |
helpSpec := dictionaries |
|
843 |
at: cls name |
|
844 |
ifAbsent: [specClass notNil |
|
845 |
ifTrue: [dictionaries at: aClass put: (self extractHelpSpecForClass: (Smalltalk at: aClass))] |
|
846 |
ifFalse: [dictionary size > 0 ifTrue: [dictionary] ifFalse: [Dictionary new]]]. |
|
847 |
||
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
848 |
helpSpec associationsDo: |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
849 |
[:h| |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
850 |
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
|
851 |
]. |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
852 |
|
750 | 853 |
(cls class implements: specSelector) |
740 | 854 |
ifTrue: |
855 |
[ |
|
856 |
|superclassHelpKeys implementedHelpSpec hasChanged| |
|
857 |
implementedHelpSpec := Dictionary new. |
|
750 | 858 |
superclassHelpKeys := (cls superclass respondsTo: specSelector) |
740 | 859 |
ifTrue: [cls superclass helpSpec keys] |
860 |
ifFalse: [Array new]. |
|
861 |
||
862 |
cls helpSpec associationsDo: [:h| (superclassHelpKeys includes: h key) |
|
863 |
ifFalse: [implementedHelpSpec at: h key put: h value]]. |
|
864 |
||
865 |
hasChanged := false. |
|
866 |
implementedHelpSpec associationsDo: [:h| (helpSpec includesAssociation: h) ifFalse: [hasChanged := true]]. |
|
867 |
helpSpec associationsDo: [:h| (implementedHelpSpec includesAssociation: h) ifFalse: [hasChanged := true]]. |
|
868 |
||
869 |
(implementedHelpSpec notEmpty and: [hasChanged and: |
|
870 |
[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 ']]) |
|
871 |
ifTrue: |
|
872 |
[ |
|
873 |
implementedHelpSpec associationsDo: [:h| (helpSpec includesKey: h key) |
|
874 |
ifFalse: [helpSpec at: h key put: h value]]. |
|
875 |
] |
|
876 |
]. |
|
877 |
||
878 |
helpSpec isEmpty ifTrue:[ |
|
750 | 879 |
^(cls superclass respondsTo: specSelector) ifTrue: [cls class removeSelector: specSelector]. |
740 | 880 |
]. |
881 |
||
882 |
src := '' writeStream. |
|
883 |
||
884 |
src nextPutAll: |
|
750 | 885 |
specSelector, '\' withCRs, |
740 | 886 |
(ResourceSpecEditor codeGenerationCommentForClass: UIHelpTool) withCRs, |
887 |
'\\' withCRs, |
|
888 |
' "\' withCRs, |
|
889 |
' UIHelpTool openOnClass:', cls name asString ,' |
|
890 |
" |
|
891 |
||
892 |
<resource: #help> |
|
893 |
||
750 | 894 |
^super ', specSelector, ' addPairsFrom:#( |
740 | 895 |
|
896 |
'. |
|
897 |
||
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
898 |
helpSpec keys asSortedCollection do: |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
899 |
[:key| |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
900 |
src nextPutLine: key storeString. |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
901 |
src nextPutLine: (helpSpec at: key) storeString; cr. |
740 | 902 |
]. |
903 |
src nextPutLine:')'. |
|
904 |
||
905 |
Compiler |
|
906 |
compile:(src contents) |
|
907 |
forClass:cls class |
|
908 |
inCategory:'help specs'. |
|
909 |
! |
|
910 |
||
911 |
installHelpSpecsOnClass:aClass |
|
779 | 912 |
"saves the help dicts on aClass and its superclasses which are subclasses of ApplicationModel" |
913 |
||
740 | 914 |
|cls helpSpecClasses| |
915 |
||
750 | 916 |
cls := self getHelpSpecClassFromClass:aClass. |
917 |
cls isNil ifTrue: [^self information:'No application class defined!!']. |
|
918 |
||
740 | 919 |
modified ifFalse:[ |
750 | 920 |
masterApplication isNil ifTrue: [self information:'Nothing was modified!!']. |
740 | 921 |
^nil |
922 |
]. |
|
923 |
||
924 |
(helpSpecClasses := self listOfHelpSpecClasses value) notNil |
|
925 |
ifTrue: |
|
750 | 926 |
[ |
927 |
(helpSpecClasses includes: cls name) ifFalse: [helpSpecClasses add: cls name]. |
|
740 | 928 |
helpSpecClasses do: [:clsName| (self installHelpSpecOnClass: clsName) isNil ifTrue: [^modified := false]]. |
929 |
] |
|
930 |
ifFalse: |
|
750 | 931 |
[ |
740 | 932 |
self installHelpSpecOnClass: cls |
933 |
]. |
|
934 |
||
935 |
modified := false. |
|
936 |
||
937 |
! |
|
938 |
||
750 | 939 |
resourceMessage: aString |
779 | 940 |
"extracts from aString the specClass and the specSelector" |
750 | 941 |
|
942 |
(aString notNil and: [self askForModification]) |
|
943 |
ifTrue: |
|
944 |
[ |
|
945 |
|msg cls sel| |
|
946 |
msg := aString asCollectionOfWords. |
|
947 |
(msg size == 2 and: |
|
948 |
[(cls := self resolveName:(msg at:1)) notNil]) |
|
949 |
ifTrue: |
|
950 |
[ |
|
951 |
specClass := cls name. |
|
952 |
specSelector := (msg at: 2) asSymbol. |
|
953 |
^true |
|
954 |
] |
|
955 |
]. |
|
956 |
^false |
|
957 |
||
958 |
! |
|
959 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
960 |
updateList |
779 | 961 |
"updates the list channel from dictionary" |
962 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
963 |
self listChannel value: dictionary keys asSortedCollection |
286 | 964 |
! ! |
965 |
||
966 |
!UIHelpTool methodsFor:'selection'! |
|
967 |
||
968 |
listSelection |
|
779 | 969 |
"returns current selection" |
970 |
||
286 | 971 |
^ listSelection |
972 |
! |
|
973 |
||
974 |
listSelection:aSelection |
|
779 | 975 |
"sets current selection" |
976 |
||
299 | 977 |
|txt view sel| |
286 | 978 |
|
722 | 979 |
aSelection isNil |
980 |
ifTrue: [(builder componentAt: #listOfHelpKeysView) selection: nil] |
|
981 |
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
|
982 |
|
286 | 983 |
aSelection isNumber ifTrue:[ |
984 |
aSelection ~~ 0 ifTrue:[ |
|
985 |
sel := self listChannel value at:aSelection |
|
986 |
] |
|
987 |
] ifFalse:[ |
|
988 |
aSelection size ~~ 0 ifTrue:[ |
|
989 |
sel := aSelection withoutSeparators. |
|
990 |
sel size == 0 ifTrue:[ |
|
991 |
sel := nil |
|
992 |
] |
|
993 |
] |
|
994 |
]. |
|
995 |
||
299 | 996 |
listSelection = sel ifFalse:[ |
997 |
listSelection := sel. |
|
286 | 998 |
|
299 | 999 |
modifiedHolder notNil ifTrue:[ |
1000 |
modifiedHolder value:true. |
|
1001 |
]. |
|
286 | 1002 |
|
299 | 1003 |
(view := self editTextView) notNil ifTrue:[ |
1004 |
listSelection notNil ifTrue:[ |
|
1005 |
txt := dictionary at:(listSelection asSymbol) ifAbsent:nil. |
|
286 | 1006 |
|
299 | 1007 |
(txt isNil or:[maxCharsPerLine isNil]) ifFalse:[ |
369 | 1008 |
txt := UIPainter convertString:(txt asString) maxLineSize:maxCharsPerLine skipLineFeed:false. |
286 | 1009 |
] |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1010 |
]. |
459 | 1011 |
view contents:txt. |
1012 |
view modified:false. |
|
299 | 1013 |
] |
1014 |
] |
|
286 | 1015 |
|
1016 |
! ! |
|
1017 |
||
369 | 1018 |
!UIHelpTool methodsFor:'startup / release'! |
1019 |
||
1020 |
closeRequest |
|
779 | 1021 |
"asks for permission before closing" |
1022 |
||
750 | 1023 |
(self masterApplication isNil and:[self askForModification]) ifTrue:[super closeRequest] |
740 | 1024 |
! |
1025 |
||
1026 |
initialize |
|
779 | 1027 |
"initializes instance variables" |
1028 |
||
740 | 1029 |
super initialize. |
1030 |
||
750 | 1031 |
specSelector := #helpSpec. |
740 | 1032 |
dictionary := Dictionary new. |
1033 |
dictionaries := Dictionary new. |
|
1034 |
modified := false. |
|
1035 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1036 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1037 |
|
750 | 1038 |
loadFromMessage:aString |
779 | 1039 |
"loads a help spec by evaluating aString" |
750 | 1040 |
|
1041 |
(aString notNil and: [self askForModification]) |
|
1042 |
ifTrue: |
|
1043 |
[ |
|
1044 |
|msg cls sel| |
|
1045 |
msg := aString asCollectionOfWords. |
|
1046 |
(msg size == 2 and: |
|
1047 |
[(cls := self resolveName:(msg at:1)) notNil and: |
|
1048 |
[cls class implements: (sel := (msg at: 2) asSymbol)]]) |
|
1049 |
ifTrue: |
|
1050 |
[ |
|
1051 |
self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel). |
|
1052 |
^true |
|
1053 |
] |
|
1054 |
]. |
|
1055 |
^false |
|
1056 |
||
1057 |
! |
|
1058 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1059 |
openInterface:aSymbol |
779 | 1060 |
"do not open as stand alone" |
1061 |
||
750 | 1062 |
|
1063 |
||
1064 |
! |
|
1065 |
||
1066 |
openOnClass:aClass |
|
779 | 1067 |
"opens the UIHelpTool on aClass" |
750 | 1068 |
|
1069 |
super openInterface: #windowSpecForStandAlone. |
|
1070 |
self masterApplication isNil ifTrue: [(builder componentAt: #RemoveButton) beInvisible]. |
|
1071 |
builder window label: 'Help Tool'. |
|
1072 |
self buildFromClass: aClass |
|
369 | 1073 |
! ! |
1074 |
||
740 | 1075 |
!UIHelpTool methodsFor:'user actions'! |
286 | 1076 |
|
722 | 1077 |
accept |
779 | 1078 |
"accepts the help text" |
1079 |
||
722 | 1080 |
|view key txt list listChgd| |
1081 |
||
1082 |
(listSelection size == 0 or:[(view := self editTextView) isNil]) ifFalse:[ |
|
1083 |
txt := view contents asString. |
|
1084 |
key := listSelection asSymbol. |
|
1085 |
list := self listChannel value. |
|
1086 |
||
1087 |
(listChgd := (dictionary at:key ifAbsent:nil) isNil) ifTrue:[ |
|
1088 |
list add:key. |
|
1089 |
]. |
|
1090 |
dictionary at:key put:txt. |
|
1091 |
||
1092 |
listChgd ifTrue:[ |
|
1093 |
self updateList. |
|
1094 |
(builder componentAt: #listOfHelpKeysView) selection: (list indexOf: key). |
|
1095 |
]. |
|
1096 |
||
740 | 1097 |
modified := true. |
722 | 1098 |
modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
1099 |
] |
|
1100 |
! |
|
1101 |
||
750 | 1102 |
doAdd |
779 | 1103 |
"adds a help key" |
1104 |
||
750 | 1105 |
|helpKey| |
1106 |
(helpKey := (builder componentAt: #helpKeyInputField asSymbol) contents) size > 0 |
|
1107 |
ifTrue: |
|
1108 |
[ |
|
1109 |
self listModel value: helpKey. |
|
1110 |
self accept |
|
1111 |
] |
|
1112 |
ifFalse: |
|
1113 |
[ |
|
835 | 1114 |
self warn:'No key was entered !!' |
750 | 1115 |
] |
835 | 1116 |
|
1117 |
"Modified: / 20.5.1998 / 01:15:06 / cg" |
|
722 | 1118 |
! |
1119 |
||
750 | 1120 |
doDelete |
779 | 1121 |
"deletes the selected help key" |
1122 |
||
722 | 1123 |
listSelection notNil |
1124 |
ifTrue: |
|
1125 |
[ |
|
1126 |
dictionary removeKey: listSelection asSymbol ifAbsent: nil. |
|
750 | 1127 |
self doRemove. |
722 | 1128 |
self updateList. |
740 | 1129 |
modified := true. |
722 | 1130 |
modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
1131 |
] |
|
750 | 1132 |
ifFalse: |
1133 |
[ |
|
835 | 1134 |
self warn:'No key selected !!' |
750 | 1135 |
] |
835 | 1136 |
|
1137 |
"Modified: / 20.5.1998 / 01:15:00 / cg" |
|
722 | 1138 |
! |
1139 |
||
750 | 1140 |
doLoad |
779 | 1141 |
"opens a Resource Selection Browser in order to get a resource message" |
286 | 1142 |
|
750 | 1143 |
self loadFromMessage: |
1144 |
(ResourceSelectionBrowser |
|
779 | 1145 |
request: 'Load Help Spec From Class' |
750 | 1146 |
onSuperclass: nil |
1147 |
andClass: specClass |
|
779 | 1148 |
andSelector: specSelector ? #help |
1149 |
withResourceTypes: (Array with: #help)). |
|
1150 |
||
1151 |
self updateInfoLabel |
|
286 | 1152 |
|
750 | 1153 |
! |
286 | 1154 |
|
750 | 1155 |
doNew |
779 | 1156 |
"resets the help tool" |
1157 |
||
750 | 1158 |
specClass := listSelection := nil. |
1159 |
self dictionary: nil. |
|
1160 |
self dictionaries: nil. |
|
1161 |
self listOfHelpSpecClasses removeAll. |
|
1162 |
modified := false. |
|
286 | 1163 |
! |
1164 |
||
1165 |
doReload |
|
779 | 1166 |
"reloads the help dictionaries" |
1167 |
||
286 | 1168 |
|oldSel model| |
1169 |
||
1170 |
model := self listModel. |
|
1171 |
oldSel := model value. |
|
1172 |
model value:nil. |
|
1173 |
self helpSpecFrom:specClass. |
|
1174 |
model value:oldSel. |
|
740 | 1175 |
modified := false. |
369 | 1176 |
|
722 | 1177 |
! |
1178 |
||
750 | 1179 |
doRemove |
779 | 1180 |
"removes the selected help key" |
1181 |
||
750 | 1182 |
listSelection notNil |
1183 |
ifTrue: |
|
1184 |
[ |
|
1185 |
self listModel value: nil. |
|
1186 |
self updateList. |
|
1187 |
modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
|
1188 |
] |
|
1189 |
ifFalse: |
|
1190 |
[ |
|
835 | 1191 |
self warn:'No key selected !!' |
750 | 1192 |
] |
835 | 1193 |
|
1194 |
"Modified: / 20.5.1998 / 01:15:11 / cg" |
|
750 | 1195 |
! |
1196 |
||
722 | 1197 |
doSave |
779 | 1198 |
"saves the help dictionaries on specClass" |
1199 |
||
722 | 1200 |
self installHelpSpecsOnClass:specClass |
148 | 1201 |
! ! |
1202 |
||
1203 |
!UIHelpTool class methodsFor:'documentation'! |
|
1204 |
||
1205 |
version |
|
1206 |
^ '$Header$' |
|
1207 |
! ! |