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