author | Claus Gittinger <cg@exept.de> |
Fri, 21 Feb 2003 18:17:22 +0100 | |
changeset 1684 | 34b35b8ae80f |
parent 1681 | 7a8e5df3f07d |
child 1723 | 30d20151ed81 |
permissions | -rw-r--r-- |
156 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
1669 | 3 |
All Rights Reserved |
156 | 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 |
||
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
13 |
"{ Package: 'stx:libtool2' }" |
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
14 |
|
750 | 15 |
ToolApplicationModel subclass:#UIHelpTool |
1669 | 16 |
instanceVariableNames:'specClass specSelector classItemList classItemModel keyItemModel |
17 |
helpTextView modifiedHolder contentsModifiedChannel editModel' |
|
148 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-UIPainter' |
|
21 |
! |
|
22 |
||
1669 | 23 |
HierarchicalItem subclass:#ClassItem |
24 |
instanceVariableNames:'theClass list modified' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:UIHelpTool |
|
28 |
! |
|
29 |
||
30 |
HierarchicalItem subclass:#KeyItem |
|
1681 | 31 |
instanceVariableNames:'helpKey helpText flyByText modified icon' |
1669 | 32 |
classVariableNames:'' |
33 |
poolDictionaries:'' |
|
34 |
privateIn:UIHelpTool |
|
35 |
! |
|
36 |
||
148 | 37 |
!UIHelpTool class methodsFor:'documentation'! |
38 |
||
156 | 39 |
copyright |
40 |
" |
|
41 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
1669 | 42 |
All Rights Reserved |
156 | 43 |
|
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
" |
|
51 |
! |
|
52 |
||
148 | 53 |
documentation |
54 |
" |
|
779 | 55 |
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
|
56 |
window applications. The tool are able to run stand alone or in other master |
740 | 57 |
applications like the GUI Painter and the Menu Editor. |
58 |
If the application responds to the selector #showHelp:aHelpText for:aView, |
|
59 |
this selector is called by the widget's view when the mouse cursor moves over. |
|
60 |
If the application does not responds to that selector, and the activeHelp mode |
|
61 |
is enabled, an active help bubble is shown at the widget's view. |
|
156 | 62 |
|
779 | 63 |
[instance variables:] |
1669 | 64 |
specClass <Symbol> class implementing the help spec |
65 |
specSelector <Symbol> selector returning the help spec |
|
66 |
classItemList the list of classItems |
|
67 |
classItemModel keeps the selected class |
|
68 |
keyItemModel keeps the selected helpKey |
|
69 |
modifiedHolder <ValueHolder> true if the editField or contents changed |
|
70 |
editModel keeps the current helpKey |
|
71 |
helpTextView the view which shows the helpText |
|
72 |
contentsModifiedChannel true if the helpText is modified |
|
779 | 73 |
|
156 | 74 |
[author:] |
1669 | 75 |
Claus Atzkern, eXept Software AG |
76 |
Thomas Zwick, eXept Software AG |
|
148 | 77 |
" |
78 |
! ! |
|
79 |
||
286 | 80 |
!UIHelpTool class methodsFor:'instance creation'! |
81 |
||
832
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
82 |
open |
833 | 83 |
^ self openOnClass:nil. |
832
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
84 |
! |
2c5b61b168e8
allow #open (its in the docu !)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
85 |
|
286 | 86 |
openOnClass:aClass |
1669 | 87 |
"opens a Help Tool on aClass |
286 | 88 |
" |
1669 | 89 |
^ self openOnClass:aClass andSelector:#helpSpec |
940 | 90 |
! |
91 |
||
92 |
openOnClass:aClass andSelector: aSelector |
|
1669 | 93 |
"opens a Help Tool on aClass and aSelector |
94 |
" |
|
95 |
^ self new openOnClass:aClass andSelector:aSelector |
|
750 | 96 |
! ! |
97 |
||
286 | 98 |
!UIHelpTool class methodsFor:'constants'! |
99 |
||
100 |
label |
|
1669 | 101 |
"returns the label; used if embedded as sub canvas in the GUI Painter or Menu Editor |
102 |
" |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
103 |
^'Help' |
286 | 104 |
! ! |
105 |
||
151 | 106 |
!UIHelpTool class methodsFor:'help specs'! |
107 |
||
108 |
helpSpec |
|
740 | 109 |
"This resource specification was automatically generated |
110 |
by the UIHelpTool of ST/X." |
|
111 |
||
112 |
"Do not manually edit this!! If it is corrupted, |
|
113 |
the UIHelpTool may not be able to read the specification." |
|
292 | 114 |
|
172 | 115 |
" |
740 | 116 |
UIHelpTool openOnClass:UIHelpTool |
292 | 117 |
" |
118 |
||
740 | 119 |
<resource: #help> |
120 |
||
1669 | 121 |
^ super helpSpec addPairsFrom:#( |
151 | 122 |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
123 |
#addHelpTextKey |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
124 |
'Adds the key to the help spec.' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
125 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
126 |
#currentHelpTexts |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
127 |
'Selected help text key.' |
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 |
#deleteHelpTextKey |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
130 |
'Deletes the key from the help spec.' |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
131 |
|
750 | 132 |
#fileLoad |
133 |
'Opens a dialog for selecting and loading a help spec from a class.' |
|
134 |
||
135 |
#fileSave |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
136 |
'Saves the current help spec.' |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
137 |
|
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
138 |
#fileUpdate |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
139 |
'Reload the 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 |
1622 | 142 |
'Shows the help text. Menu action ''Accept'' commits changes' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
143 |
|
1646 | 144 |
#listOfClasses |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
145 |
'Classes where help specs can be/are implemented.' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
146 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
147 |
#listOfHelpTexts |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
148 |
'List of help text keys.' |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
149 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
150 |
#removeHelpTextKey |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
151 |
'Removes the help message from the widget.' |
172 | 152 |
|
1646 | 153 |
#updateHelpTextKey |
154 |
'Refetch the help spec.' |
|
155 |
||
172 | 156 |
) |
151 | 157 |
! ! |
158 |
||
148 | 159 |
!UIHelpTool class methodsFor:'interface specs'! |
160 |
||
161 |
windowSpec |
|
740 | 162 |
"This resource specification was automatically generated |
163 |
by the UIPainter of ST/X." |
|
148 | 164 |
|
740 | 165 |
"Do not manually edit this!! If it is corrupted, |
166 |
the UIPainter may not be able to read the specification." |
|
148 | 167 |
|
168 |
" |
|
151 | 169 |
UIPainter new openOnClass:UIHelpTool andSelector:#windowSpec |
170 |
UIHelpTool new openInterface:#windowSpec |
|
740 | 171 |
UIHelpTool open |
148 | 172 |
" |
173 |
||
174 |
<resource: #canvas> |
|
175 |
||
1302 | 176 |
^ |
177 |
#(#FullSpec |
|
1669 | 178 |
#name: #windowSpec |
179 |
#window: |
|
1302 | 180 |
#(#WindowSpec |
1669 | 181 |
#label: 'UIHelpTool' |
182 |
#name: 'UIHelpTool' |
|
183 |
#min: #(#Point 10 10) |
|
184 |
#max: #(#Point 1024 768) |
|
185 |
#bounds: #(#Rectangle 30 292 491 585) |
|
186 |
) |
|
187 |
#component: |
|
1302 | 188 |
#(#SpecCollection |
1669 | 189 |
#collection: #( |
190 |
#(#VariableVerticalPanelSpec |
|
191 |
#name: 'PanelVrt' |
|
192 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
193 |
#component: |
|
194 |
#(#SpecCollection |
|
195 |
#collection: #( |
|
196 |
#(#VariableHorizontalPanelSpec |
|
197 |
#name: 'PanelHrz' |
|
198 |
#component: |
|
199 |
#(#SpecCollection |
|
200 |
#collection: #( |
|
201 |
#(#HierarchicalListViewSpec |
|
202 |
#name: 'keyItemModel' |
|
203 |
#model: #keyItemModel |
|
204 |
#menu: #keyItemMenu |
|
205 |
#hasHorizontalScrollBar: true |
|
206 |
#hasVerticalScrollBar: true |
|
207 |
#miniScrollerHorizontal: true |
|
208 |
#miniScrollerVertical: false |
|
209 |
#listModel: #keyItemListHolder |
|
210 |
#useIndex: false |
|
211 |
#highlightMode: #label |
|
212 |
#showLines: false |
|
213 |
#showIndicators: false |
|
214 |
#showLeftIndicators: false |
|
215 |
#useDefaultIcons: false |
|
216 |
#autoScrollHorizontal: false |
|
217 |
) |
|
218 |
#(#ViewSpec |
|
219 |
#name: 'classItemList' |
|
220 |
#component: |
|
221 |
#(#SpecCollection |
|
222 |
#collection: #( |
|
223 |
#(#InputFieldSpec |
|
224 |
#name: 'editModel' |
|
225 |
#layout: #(#LayoutFrame 0 0.0 2 0 -1 1.0 25 0) |
|
226 |
#activeHelpKey: #currentHelpTexts |
|
227 |
#model: #editModel |
|
228 |
#immediateAccept: true |
|
229 |
#acceptOnReturn: false |
|
230 |
#acceptOnTab: false |
|
231 |
#acceptOnLostFocus: false |
|
232 |
#acceptOnPointerLeave: false |
|
233 |
) |
|
234 |
#(#SelectionInListModelViewSpec |
|
235 |
#name: 'classItemModel' |
|
236 |
#layout: #(#LayoutFrame 0 0.0 27 0.0 0 1.0 0 1.0) |
|
237 |
#model: #classItemModel |
|
238 |
#hasHorizontalScrollBar: true |
|
239 |
#hasVerticalScrollBar: true |
|
240 |
#miniScrollerHorizontal: true |
|
241 |
#miniScrollerVertical: true |
|
242 |
#autoHideScrollBars: false |
|
243 |
#listModel: #classItemListHolder |
|
244 |
#useIndex: false |
|
245 |
#highlightMode: #label |
|
246 |
) |
|
247 |
) |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
248 |
|
1669 | 249 |
) |
250 |
) |
|
251 |
) |
|
1646 | 252 |
|
1669 | 253 |
) |
254 |
#handles: #(#Any 0.607375 1.0) |
|
255 |
) |
|
256 |
#(#ArbitraryComponentSpec |
|
257 |
#name: 'helpTextView' |
|
258 |
#hasHorizontalScrollBar: true |
|
259 |
#hasVerticalScrollBar: true |
|
260 |
#miniScrollerHorizontal: true |
|
261 |
#miniScrollerVertical: true |
|
262 |
#hasBorder: false |
|
263 |
#component: #helpTextView |
|
264 |
) |
|
265 |
) |
|
1302 | 266 |
|
1669 | 267 |
) |
268 |
#handles: #(#Any 0.679181 1.0) |
|
269 |
) |
|
270 |
) |
|
1302 | 271 |
|
1669 | 272 |
) |
148 | 273 |
) |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
274 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
275 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
276 |
windowSpecForStandAlone |
740 | 277 |
"This resource specification was automatically generated |
278 |
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
|
279 |
|
740 | 280 |
"Do not manually edit this!! If it is corrupted, |
281 |
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
|
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 |
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
|
285 |
UIHelpTool new openInterface:#windowSpecForStandAlone |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
286 |
" |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
287 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
288 |
<resource: #canvas> |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
289 |
|
1646 | 290 |
^ |
291 |
#(#FullSpec |
|
1669 | 292 |
#name: #windowSpecForStandAlone |
293 |
#window: |
|
1646 | 294 |
#(#WindowSpec |
1669 | 295 |
#label: 'Help Tool' |
296 |
#name: 'Help Tool' |
|
297 |
#min: #(#Point 300 300) |
|
298 |
#max: #(#Point 1152 900) |
|
299 |
#bounds: #(#Rectangle 11 332 509 761) |
|
300 |
#menu: #menu |
|
301 |
) |
|
302 |
#component: |
|
1646 | 303 |
#(#SpecCollection |
1669 | 304 |
#collection: #( |
305 |
#(#UISubSpecification |
|
306 |
#name: 'windowSpec' |
|
307 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -50 1.0) |
|
308 |
#minorKey: #windowSpec |
|
309 |
) |
|
310 |
#(#UISubSpecification |
|
311 |
#name: 'windowSpecForCommit' |
|
312 |
#layout: #(#LayoutFrame 0 0.0 -50 1.0 0 1.0 -24 1.0) |
|
313 |
#majorKey: #ToolApplicationModel |
|
314 |
#minorKey: #windowSpecForCommit |
|
315 |
) |
|
316 |
#(#UISubSpecification |
|
317 |
#name: 'windowSpecForInfoBar' |
|
318 |
#layout: #(#LayoutFrame 0 0 -24 1 0 1 0 1) |
|
319 |
#majorKey: #ToolApplicationModel |
|
320 |
#minorKey: #windowSpecForInfoBar |
|
321 |
) |
|
322 |
) |
|
1646 | 323 |
|
1669 | 324 |
) |
696
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 |
! ! |
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 |
!UIHelpTool class methodsFor:'menu specs'! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
329 |
|
1646 | 330 |
helpTextMenu |
331 |
"This resource specification was automatically generated |
|
332 |
by the MenuEditor of ST/X." |
|
333 |
||
334 |
"Do not manually edit this!! If it is corrupted, |
|
335 |
the MenuEditor may not be able to read the specification." |
|
336 |
||
337 |
" |
|
338 |
MenuEditor new openOnClass:UIHelpTool andSelector:#helpTextMenu |
|
339 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool helpTextMenu)) startUp |
|
340 |
" |
|
341 |
||
342 |
<resource: #menu> |
|
343 |
||
344 |
^ |
|
345 |
#(#Menu |
|
1669 | 346 |
#( |
347 |
#(#MenuItem |
|
348 |
#activeHelpKey: #commitOK |
|
349 |
#enabled: #contentsModifiedChannel |
|
350 |
#label: 'Accept' |
|
351 |
#itemValue: #accept |
|
352 |
#translateLabel: true |
|
353 |
) |
|
354 |
#(#MenuItem |
|
355 |
#activeHelpKey: #commitCancel |
|
356 |
#enabled: #contentsModifiedChannel |
|
357 |
#label: 'Cancel' |
|
358 |
#itemValue: #cancel |
|
359 |
#translateLabel: true |
|
360 |
) |
|
361 |
) |
|
362 |
nil |
|
363 |
nil |
|
364 |
) |
|
365 |
! |
|
366 |
||
367 |
keyItemMenu |
|
368 |
"This resource specification was automatically generated |
|
369 |
by the MenuEditor of ST/X." |
|
370 |
||
371 |
"Do not manually edit this!! If it is corrupted, |
|
372 |
the MenuEditor may not be able to read the specification." |
|
373 |
||
374 |
" |
|
375 |
MenuEditor new openOnClass:UIHelpTool andSelector:#keyItemMenu |
|
376 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool keyItemMenu)) startUp |
|
377 |
" |
|
378 |
||
379 |
<resource: #menu> |
|
380 |
||
381 |
^ |
|
382 |
#(#Menu |
|
383 |
#( |
|
384 |
#(#MenuItem |
|
385 |
#activeHelpKey: #deleteHelpTextKey |
|
386 |
#label: 'Delete' |
|
387 |
#itemValue: #doDelete |
|
388 |
#translateLabel: true |
|
389 |
) |
|
390 |
) |
|
391 |
nil |
|
392 |
nil |
|
1646 | 393 |
) |
394 |
! |
|
395 |
||
396 |
listOfKeysMenu |
|
397 |
"This resource specification was automatically generated |
|
398 |
by the MenuEditor of ST/X." |
|
399 |
||
400 |
"Do not manually edit this!! If it is corrupted, |
|
401 |
the MenuEditor may not be able to read the specification." |
|
402 |
||
403 |
" |
|
404 |
MenuEditor new openOnClass:UIHelpTool andSelector:#listOfKeysMenu |
|
405 |
(Menu new fromLiteralArrayEncoding:(UIHelpTool listOfKeysMenu)) startUp |
|
406 |
" |
|
407 |
||
408 |
<resource: #menu> |
|
409 |
||
410 |
^ |
|
411 |
#(#Menu |
|
1669 | 412 |
#( |
413 |
#(#MenuItem |
|
414 |
#activeHelpKey: #deleteHelpTextKey |
|
415 |
#label: 'Delete' |
|
416 |
#itemValue: #doDelete |
|
417 |
#translateLabel: true |
|
418 |
) |
|
419 |
) |
|
420 |
nil |
|
421 |
nil |
|
1646 | 422 |
) |
423 |
! |
|
424 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
425 |
menu |
740 | 426 |
"This resource specification was automatically generated |
427 |
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
|
428 |
|
740 | 429 |
"Do not manually edit this!! If it is corrupted, |
430 |
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
|
431 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
432 |
" |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
433 |
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
|
434 |
(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
|
435 |
" |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
436 |
|
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
437 |
<resource: #menu> |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
438 |
|
1646 | 439 |
^ |
440 |
#(#Menu |
|
1669 | 441 |
#( |
442 |
#(#MenuItem |
|
443 |
#label: 'File' |
|
444 |
#translateLabel: true |
|
445 |
#submenu: |
|
446 |
#(#Menu |
|
447 |
#( |
|
448 |
#(#MenuItem |
|
449 |
#activeHelpKey: #fileLoad |
|
450 |
#label: 'Load...' |
|
451 |
#itemValue: #doLoad |
|
452 |
#translateLabel: true |
|
453 |
) |
|
454 |
#(#MenuItem |
|
455 |
#activeHelpKey: #fileSave |
|
456 |
#label: 'Save' |
|
457 |
#itemValue: #doSave |
|
458 |
#translateLabel: true |
|
459 |
) |
|
460 |
#(#MenuItem |
|
461 |
#label: 'New' |
|
462 |
#itemValue: #doNew |
|
463 |
#translateLabel: true |
|
464 |
) |
|
465 |
#(#MenuItem |
|
466 |
#label: '-' |
|
467 |
) |
|
468 |
#(#MenuItem |
|
469 |
#activeHelpKey: #fileExit |
|
470 |
#label: 'Exit' |
|
471 |
#itemValue: #closeRequest |
|
472 |
#translateLabel: true |
|
473 |
) |
|
474 |
) |
|
475 |
nil |
|
476 |
nil |
|
477 |
) |
|
478 |
) |
|
479 |
#(#MenuItem |
|
480 |
#activeHelpKey: #history |
|
481 |
#label: 'History' |
|
482 |
#translateLabel: true |
|
483 |
#submenuChannel: #menuHistory |
|
484 |
) |
|
485 |
#(#MenuItem |
|
486 |
#label: 'Edit' |
|
487 |
#translateLabel: true |
|
488 |
#submenuChannel: #keyItemMenu |
|
489 |
#keepLinkedMenu: true |
|
490 |
) |
|
491 |
#(#MenuItem |
|
492 |
#activeHelpKey: #help |
|
493 |
#label: 'Help' |
|
494 |
#translateLabel: true |
|
495 |
#startGroup: #right |
|
496 |
#submenuChannel: #menuHelp |
|
497 |
) |
|
498 |
) |
|
499 |
nil |
|
500 |
nil |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
501 |
) |
148 | 502 |
! ! |
503 |
||
504 |
!UIHelpTool methodsFor:'accessing'! |
|
505 |
||
1669 | 506 |
helpKey |
507 |
"returns the helpKey as symbol or nil |
|
508 |
" |
|
509 |
|key| |
|
710 | 510 |
|
1669 | 511 |
key := editModel value. |
151 | 512 |
|
1669 | 513 |
key size ~~ 0 ifTrue:[ |
514 |
key := key withoutSeparators. |
|
515 |
key notEmpty ifTrue:[ ^ key asSymbol ] |
|
151 | 516 |
]. |
286 | 517 |
^ nil |
518 |
! |
|
519 |
||
520 |
helpKey:aKey |
|
1669 | 521 |
"change the helpKey without any change notification (modifiedHolder). |
522 |
" |
|
286 | 523 |
|key| |
1646 | 524 |
|
1669 | 525 |
self withoutModifyDo:[ |
526 |
aKey size ~~ 0 ifTrue:[ |
|
527 |
key := aKey withoutSeparators. |
|
528 |
key isEmpty ifTrue:[ key := nil ] |
|
529 |
] ifFalse:[ |
|
530 |
key := nil |
|
531 |
]. |
|
532 |
editModel value:key. |
|
286 | 533 |
]. |
1646 | 534 |
self cancel. |
151 | 535 |
! |
536 |
||
740 | 537 |
modified |
1669 | 538 |
"true if any items are added, deleted or modified |
1646 | 539 |
" |
1669 | 540 |
classItemList do:[:aClassItem| |
541 |
aClassItem modified ifTrue:[^ true]. |
|
542 |
]. |
|
543 |
^ false |
|
700 | 544 |
! |
545 |
||
1669 | 546 |
modified:aBoolean |
547 |
"true if any items are added, deleted or modified |
|
1646 | 548 |
" |
1669 | 549 |
classItemList do:[:aClassItem| aClassItem modified:aBoolean ]. |
550 |
! |
|
551 |
||
552 |
modifiedHolder |
|
553 |
"boolean holder which is set to true if the helpKey or contents changed |
|
554 |
" |
|
555 |
^ modifiedHolder |
|
700 | 556 |
! |
557 |
||
286 | 558 |
modifiedHolder:aValueHolder |
1669 | 559 |
"boolean holder which is set to true if the helpKey or contents changed |
560 |
" |
|
286 | 561 |
modifiedHolder notNil ifTrue:[ |
1669 | 562 |
modifiedHolder removeDependent:self. |
286 | 563 |
]. |
1646 | 564 |
modifiedHolder := aValueHolder. |
459 | 565 |
|
1646 | 566 |
modifiedHolder notNil ifTrue:[ |
1669 | 567 |
modifiedHolder addDependent:self. |
568 |
]. |
|
1604 | 569 |
! |
570 |
||
715 | 571 |
specClass |
1669 | 572 |
"returns the class on which the help tool works on |
1646 | 573 |
" |
574 |
^ specClass |
|
575 |
! |
|
779 | 576 |
|
1646 | 577 |
specSelector |
1681 | 578 |
"returns the selector of the edited helpSpec method |
1646 | 579 |
" |
1681 | 580 |
^ specSelector ? #helpSpec |
354 | 581 |
! ! |
582 |
||
148 | 583 |
!UIHelpTool methodsFor:'aspects'! |
584 |
||
1669 | 585 |
classItemListHolder |
586 |
"returns the holder which keeps the class items |
|
587 |
" |
|
588 |
|holder| |
|
589 |
||
590 |
holder := builder bindingAt:#classItemListHolder. |
|
591 |
||
592 |
holder isNil ifTrue:[ |
|
593 |
holder := nil asValue. |
|
594 |
holder value:classItemList. |
|
595 |
builder aspectAt:#classItemListHolder put:holder. |
|
596 |
]. |
|
597 |
^ holder |
|
598 |
! |
|
599 |
||
600 |
classItemModel |
|
601 |
"returns the holder which keeps the current selected class |
|
602 |
" |
|
603 |
^ classItemModel |
|
604 |
! |
|
605 |
||
1646 | 606 |
contentsModifiedChannel |
1669 | 607 |
"boolean holder, which is set to true if the contents assigned to the |
608 |
helpKey changed |
|
1646 | 609 |
" |
610 |
^ contentsModifiedChannel |
|
611 |
! |
|
779 | 612 |
|
1646 | 613 |
editModel |
1669 | 614 |
"string holder, which keeps the current editing helpKey as string |
1646 | 615 |
" |
1669 | 616 |
^ editModel. |
1646 | 617 |
! |
618 |
||
1669 | 619 |
helpTextView |
620 |
"the editView which keeps the current help contents assigned to the key |
|
1646 | 621 |
" |
1669 | 622 |
^ helpTextView |
148 | 623 |
! |
624 |
||
1669 | 625 |
keyItemListHolder |
626 |
"holder, which keeps the current hierarchical list |
|
627 |
assigned to the selected class item |
|
1646 | 628 |
" |
1669 | 629 |
|holder| |
630 |
||
631 |
holder := builder bindingAt:#keyItemListHolder. |
|
632 |
||
633 |
holder isNil ifTrue:[ |
|
634 |
holder := nil asValue. |
|
635 |
holder value:(classItemList last list). |
|
636 |
builder aspectAt:#keyItemListHolder put:holder. |
|
637 |
]. |
|
638 |
^ holder |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
639 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
640 |
|
1669 | 641 |
keyItemModel |
642 |
"model which keeps the current selected helpKey or nil |
|
1646 | 643 |
" |
1669 | 644 |
^ keyItemModel. |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
645 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
646 |
|
1669 | 647 |
valueOfEnablingCommitButtons |
648 |
"returns the enabling of the commit of this tool as value holder |
|
1646 | 649 |
" |
1669 | 650 |
masterApplication notNil ifTrue:[ |
651 |
^ masterApplication valueOfEnablingCommitButtons |
|
652 |
]. |
|
653 |
^ contentsModifiedChannel |
|
1336
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
654 |
! |
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
655 |
|
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
656 |
valueOfInfoLabel |
1669 | 657 |
"returns the info label as value holder |
658 |
" |
|
1336
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
659 |
masterApplication notNil ifTrue:[ |
1669 | 660 |
^ masterApplication valueOfInfoLabel |
1336
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
661 |
]. |
3c84dc6f8d4b
delegate valueOfInfoLabel to masterApplication if exists
ca
parents:
1329
diff
changeset
|
662 |
^ super valueOfInfoLabel |
148 | 663 |
! ! |
664 |
||
750 | 665 |
!UIHelpTool methodsFor:'building'! |
666 |
||
1663 | 667 |
buildAndMergeFromClass:aClass |
1669 | 668 |
"setup a new specClass, merge the current items into |
669 |
" |
|
670 |
|root mergeItems| |
|
1663 | 671 |
|
1669 | 672 |
root := classItemList first. |
673 |
||
674 |
root isUnspecified ifTrue:[ mergeItems := root children ] |
|
675 |
ifFalse:[ mergeItems := nil ]. |
|
676 |
||
677 |
self buildFromClass:aClass. |
|
1663 | 678 |
|
1669 | 679 |
mergeItems size ~~ 0 ifTrue:[ |
680 |
root := classItemList first. |
|
681 |
||
682 |
mergeItems do:[:anItem| |item hkey| |
|
683 |
hkey := anItem helpKey. |
|
684 |
item := root detectItemWithKey:hkey. |
|
1663 | 685 |
|
1669 | 686 |
item isNil ifTrue:[ |
687 |
item := KeyItem helpKey:hkey helpText:(anItem helpText). |
|
688 |
root add:item sortBlock:[:a :b| a label < b label ]. |
|
689 |
] ifFalse:[ |
|
690 |
item helpText:(anItem helpText). |
|
691 |
] |
|
692 |
] |
|
1663 | 693 |
]. |
694 |
! |
|
695 |
||
750 | 696 |
buildFromClass:aClass |
779 | 697 |
"reads the help dictionary from aClass and find remaining classes |
1669 | 698 |
'between' aClass and ApplicationModel |
699 |
" |
|
1681 | 700 |
|lastContents root list resource helpSpecSelector| |
779 | 701 |
|
1681 | 702 |
helpSpecSelector := self specSelector. |
1646 | 703 |
specClass := self getHelpSpecClassFromClass:aClass. |
704 |
||
1669 | 705 |
list := OrderedCollection new. |
706 |
||
707 |
(specClass isClass and:[specClass isLoaded]) ifTrue:[ |
|
1670 | 708 |
lastContents := nil. |
1681 | 709 |
resource := specClass name, ' ', helpSpecSelector. |
1670 | 710 |
self addToHistory:(Association key:resource value:#'loadFromMessage:'). |
1669 | 711 |
|
1670 | 712 |
specClass withAllSuperclasses reverse do:[:aClass| |value name| |
713 |
lastContents isNil ifTrue:[ |
|
714 |
aClass == ApplicationModel ifTrue:[ |
|
715 |
lastContents := IdentityDictionary new |
|
716 |
]. |
|
717 |
] ifFalse:[ |
|
718 |
root := ClassItem onClass:aClass. |
|
1669 | 719 |
|
1681 | 720 |
(aClass class includesSelector:helpSpecSelector) ifTrue:[ |
721 |
value := aClass perform:helpSpecSelector. |
|
1669 | 722 |
|
1670 | 723 |
value keysAndValuesDo:[:k :v| |cval| |
724 |
cval := lastContents at:k ifAbsent:self. |
|
725 |
cval = v ifFalse:[ root add:(KeyItem helpKey:k helpText:v) ]. |
|
726 |
]. |
|
727 |
lastContents := value. |
|
728 |
]. |
|
729 |
root sort:[:a :b| a label < b label ]. |
|
730 |
root modified:false. |
|
731 |
list add:root. |
|
732 |
] |
|
733 |
] |
|
1669 | 734 |
]. |
735 |
list isEmpty ifTrue:[ |
|
1670 | 736 |
list add:(ClassItem onClass:nil) |
1646 | 737 |
]. |
738 |
||
1669 | 739 |
self withoutModifyDo:[ |
1670 | 740 |
classItemList contents:list. |
741 |
self updateIcons. |
|
742 |
classItemModel value:(list last) |
|
1646 | 743 |
]. |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
744 |
! |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
745 |
|
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
746 |
buildFromClass: aClass andSelector: aSelector |
1669 | 747 |
"sets aSelector and reads the help dictionary from aClass |
748 |
" |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
749 |
specSelector := aSelector. |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
750 |
self buildFromClass:aClass |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
751 |
! |
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
752 |
|
1646 | 753 |
buildFromHelpTool:aHelpTool |
1669 | 754 |
"build from another helpTool |
755 |
" |
|
756 |
specClass := aHelpTool specClass. |
|
757 |
specSelector := aHelpTool specSelector. |
|
758 |
classItemList := aHelpTool classItemListHolder value. |
|
1646 | 759 |
|
1669 | 760 |
self classItemListHolder value:classItemList. |
1646 | 761 |
|
1669 | 762 |
classItemModel triggerValue:(classItemList last). |
1646 | 763 |
! ! |
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
764 |
|
1646 | 765 |
!UIHelpTool methodsFor:'change & update'! |
766 |
||
767 |
editModelChanged |
|
1669 | 768 |
"called if the editModel changed |
1646 | 769 |
" |
770 |
|key| |
|
1340
4276358d937b
added update function; changed layout
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
771 |
|
1646 | 772 |
key := self helpKey. |
773 |
||
1669 | 774 |
modifiedHolder notNil ifTrue:[ |
775 |
modifiedHolder value:true |
|
776 |
]. |
|
963
62cdb7923a3b
care for setup, before view components are built
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
777 |
|
1669 | 778 |
contentsModifiedChannel value:false. |
963
62cdb7923a3b
care for setup, before view components are built
Claus Gittinger <cg@exept.de>
parents:
946
diff
changeset
|
779 |
|
1646 | 780 |
key notNil ifTrue:[ |
1669 | 781 |
keyItemModel value = key ifTrue:[^ self]. |
782 |
||
783 |
classItemList reverseDo:[:root| |item| |
|
784 |
item := root detectItemWithKey:key. |
|
1646 | 785 |
|
1669 | 786 |
item notNil ifTrue:[ |
787 |
classItemModel value:root. |
|
788 |
keyItemModel value:item. |
|
789 |
^ self. |
|
790 |
]. |
|
791 |
]. |
|
792 |
||
793 |
masterApplication isNil ifTrue:[ |
|
794 |
"entered a new helpKey |
|
795 |
" |
|
796 |
self valueOfEnablingCommitButtons value:true. |
|
797 |
]. |
|
750 | 798 |
]. |
1669 | 799 |
keyItemModel value:nil. |
1646 | 800 |
! |
779 | 801 |
|
1646 | 802 |
update:something with:aParameter from:changedObject |
1669 | 803 |
"Invoked when an object that I depend upon sends a change notification. |
804 |
" |
|
805 |
|root item list| |
|
722 | 806 |
|
1669 | 807 |
changedObject == keyItemModel ifTrue:[ |
808 |
item := keyItemModel value. |
|
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
809 |
|
1669 | 810 |
item notNil ifTrue:[ |
811 |
editModel value:(item helpKey). |
|
812 |
]. |
|
813 |
self cancel. |
|
814 |
^ self |
|
1646 | 815 |
]. |
816 |
||
1669 | 817 |
changedObject == classItemModel ifTrue:[ |
818 |
root := classItemModel value. |
|
819 |
||
820 |
root notNil ifTrue:[ |
|
821 |
item := root detectItemWithKey:(self helpKey). |
|
822 |
list := root list. |
|
823 |
] ifFalse:[ |
|
824 |
list := item := nil. |
|
825 |
]. |
|
826 |
||
827 |
item notNil ifTrue:[ |
|
828 |
keyItemModel value:nil withoutNotifying:self. |
|
829 |
]. |
|
830 |
self keyItemListHolder value:list. |
|
831 |
keyItemModel value:item. |
|
832 |
^ self |
|
740 | 833 |
]. |
1646 | 834 |
|
1669 | 835 |
changedObject == editModel ifTrue:[ |
836 |
self editModelChanged. |
|
837 |
^ self |
|
838 |
]. |
|
750 | 839 |
|
1669 | 840 |
changedObject == contentsModifiedChannel ifTrue:[ |
841 |
modifiedHolder notNil ifTrue:[ |
|
842 |
modifiedHolder value:true |
|
843 |
]. |
|
844 |
^ self |
|
845 |
]. |
|
846 |
super update:something with:aParameter from:changedObject |
|
847 |
! |
|
904 | 848 |
|
1669 | 849 |
withoutModifyDo:aBlock |
850 |
"discard modifications; trigger not the modifiedHolder during |
|
851 |
the action is active. |
|
852 |
" |
|
853 |
|holder| |
|
854 |
||
855 |
holder := modifiedHolder. |
|
856 |
||
857 |
holder isNil ifTrue:[ |
|
858 |
^ aBlock value |
|
859 |
]. |
|
860 |
^ aBlock valueNowOrOnUnwindDo:[ modifiedHolder := holder ] |
|
750 | 861 |
! ! |
862 |
||
286 | 863 |
!UIHelpTool methodsFor:'private'! |
864 |
||
750 | 865 |
askForModification |
1669 | 866 |
"asks for modification; launch a dialog if something is modified; |
867 |
returns true if the modifications are accepted by user otherwise |
|
868 |
false. |
|
869 |
" |
|
870 |
|dialog| |
|
740 | 871 |
|
1669 | 872 |
self modified ifTrue:[ |
873 |
dialog := YesNoBox title:(resources string:'List was modified !!') |
|
874 |
yesText:(resources string:'Forget it and proceed') |
|
875 |
noText:(resources string:'Cancel'). |
|
876 |
||
877 |
dialog showAtPointer. |
|
878 |
dialog accepted ifFalse:[^ false]. |
|
879 |
self modified:false. |
|
740 | 880 |
]. |
1646 | 881 |
^ true |
740 | 882 |
! |
883 |
||
1669 | 884 |
extractResourceFrom:aString |
885 |
"extracts class and selector from a resource string. On success |
|
886 |
an association with the key a class and the selector as value |
|
887 |
is returned. Otherwise nil is returned |
|
1646 | 888 |
" |
1669 | 889 |
|words newClass newSel| |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
890 |
|
1669 | 891 |
aString size ~~ 0 ifTrue:[ |
892 |
words := aString asCollectionOfWords. |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
893 |
|
1669 | 894 |
words size == 2 ifTrue:[ |
895 |
newClass := self resolveName:(words first). |
|
1646 | 896 |
|
1669 | 897 |
(newClass isClass and:[newClass isLoaded]) ifTrue:[ |
898 |
newSel := words last asSymbol. |
|
1646 | 899 |
|
1669 | 900 |
(newClass class includesSelector:newSel) ifTrue:[ |
901 |
^ Association key:newClass value:newSel |
|
902 |
]. |
|
903 |
]. |
|
904 |
]. |
|
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
905 |
]. |
1669 | 906 |
^ nil |
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
907 |
! |
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
908 |
|
750 | 909 |
getHelpSpecClassFromClass:aClass |
1669 | 910 |
"oops |
911 |
" |
|
750 | 912 |
|cls| |
913 |
||
1669 | 914 |
aClass notNil ifTrue:[ |
915 |
cls := self resolveName:aClass. |
|
750 | 916 |
|
1669 | 917 |
cls notNil ifTrue:[ |
918 |
cls := cls perform:#helpSpecClass ifNotUnderstood:cls. |
|
750 | 919 |
|
1669 | 920 |
(cls isClass and:[cls isLoaded]) ifTrue:[ |
921 |
^ cls |
|
922 |
]. |
|
923 |
]. |
|
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
924 |
]. |
1669 | 925 |
^ nil |
761
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
926 |
! |
91e524583390
do not save, if help texts have not changed (unformatting)
tz
parents:
750
diff
changeset
|
927 |
|
1669 | 928 |
loadFromMessage:aString |
929 |
"Set and rebuild the specClass and specSelector from a resource string. |
|
930 |
On success true is returned otherwise false. If the current spec is |
|
931 |
modified, a dialog is launched. |
|
932 |
" |
|
933 |
|association| |
|
740 | 934 |
|
1669 | 935 |
association := self extractResourceFrom:aString. |
740 | 936 |
|
1669 | 937 |
association notNil ifTrue:[ |
938 |
self askForModification ifTrue:[ |
|
939 |
self buildFromClass:(association key) andSelector:(association value). |
|
940 |
^ true |
|
941 |
]. |
|
740 | 942 |
]. |
1669 | 943 |
^ false |
740 | 944 |
! |
945 |
||
1669 | 946 |
resourceMessage:aString |
947 |
"Set the specClass and specSelector from a resource string. On |
|
948 |
success true is returned otherwise false. |
|
949 |
" |
|
950 |
|association| |
|
740 | 951 |
|
1669 | 952 |
association := self extractResourceFrom:aString. |
750 | 953 |
|
1669 | 954 |
association notNil ifTrue:[ |
955 |
specClass := association key. |
|
956 |
specSelector := association value. |
|
957 |
^ true |
|
750 | 958 |
]. |
1669 | 959 |
^ false |
1670 | 960 |
! |
961 |
||
962 |
updateIcons |
|
963 |
"update all icons (redefinitions below above or both) |
|
964 |
" |
|
965 |
|iconBelow iconAbove iconAboveAndBelow isBehind redefinedAbove redefinedBelow icon| |
|
966 |
||
967 |
"/ if only one class exists, its not possible to have redefinitions |
|
968 |
classItemList size > 1 ifFalse:[ ^ self ]. |
|
969 |
||
970 |
iconBelow := SystemBrowser medium_methodRedefinedBelowIcon. |
|
971 |
iconAbove := SystemBrowser medium_methodInheritedFromAboveIcon. |
|
972 |
iconAboveAndBelow := SystemBrowser medium_methodInheritedFromAboveAndRedefinedBelowIcon. |
|
973 |
||
974 |
classItemList do:[:runClass| |
|
975 |
runClass do:[:aKeyItem| |
|
976 |
isBehind := redefinedBelow := redefinedAbove := false. |
|
977 |
||
978 |
classItemList do:[:testClass| |
|
979 |
testClass == runClass ifTrue:[ |
|
980 |
isBehind := true |
|
981 |
] ifFalse:[ |
|
982 |
(testClass detectItemWithKey:(aKeyItem helpKey)) notNil ifTrue:[ |
|
983 |
isBehind ifTrue:[ redefinedBelow := true ] |
|
984 |
ifFalse:[ redefinedAbove := true ]. |
|
985 |
] |
|
986 |
] |
|
987 |
]. |
|
988 |
||
989 |
redefinedBelow ifTrue:[ |
|
990 |
redefinedAbove ifTrue:[ icon := iconAboveAndBelow ] |
|
991 |
ifFalse:[ icon := iconBelow ] |
|
992 |
] ifFalse:[ |
|
993 |
redefinedAbove ifTrue:[ icon := iconAbove ] |
|
994 |
ifFalse:[ icon := nil ] |
|
995 |
]. |
|
996 |
aKeyItem icon:icon. |
|
997 |
] |
|
998 |
]. |
|
286 | 999 |
! ! |
1000 |
||
1669 | 1001 |
!UIHelpTool methodsFor:'startup & release'! |
369 | 1002 |
|
1003 |
closeRequest |
|
1669 | 1004 |
"asks for permission before closing |
1005 |
" |
|
1006 |
(masterApplication isNil and:[self askForModification]) ifTrue:[ |
|
1007 |
super closeRequest. |
|
1008 |
]. |
|
740 | 1009 |
! |
1010 |
||
1011 |
initialize |
|
1669 | 1012 |
"setup default attributes |
1013 |
" |
|
1014 |
super initialize. |
|
1015 |
self createBuilder. |
|
779 | 1016 |
|
1669 | 1017 |
specSelector := #helpSpec. |
1018 |
||
1019 |
classItemList := List new. |
|
740 | 1020 |
|
1669 | 1021 |
classItemModel := nil asValue. |
1022 |
classItemModel addDependent:self. |
|
1023 |
||
1024 |
keyItemModel := nil asValue. |
|
1025 |
keyItemModel addDependent:self. |
|
1026 |
||
1027 |
contentsModifiedChannel := false asValue. |
|
1028 |
contentsModifiedChannel addDependent:self. |
|
1029 |
||
1030 |
helpTextView := EditTextView new. |
|
1031 |
helpTextView acceptAction:[:dummy| self accept ]. |
|
1032 |
helpTextView modifiedChannel:contentsModifiedChannel. |
|
1646 | 1033 |
|
1034 |
editModel := nil asValue. |
|
1035 |
editModel addDependent:self. |
|
740 | 1036 |
|
1669 | 1037 |
self buildFromClass:nil. |
750 | 1038 |
! |
1039 |
||
696
e91402372900
popup menu replaced by a list + supporting of help specs from different classes
tz
parents:
479
diff
changeset
|
1040 |
openInterface:aSymbol |
1669 | 1041 |
"do not open as stand alone |
1042 |
" |
|
750 | 1043 |
! |
1044 |
||
1045 |
openOnClass:aClass |
|
1669 | 1046 |
"opens the UIHelpTool on aClass |
1047 |
" |
|
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1048 |
self openOnClass:aClass andSelector:nil |
940 | 1049 |
! |
1050 |
||
1051 |
openOnClass:aClass andSelector: aSelector |
|
1052 |
"opens the UIHelpTool on aClass and aSelector" |
|
1053 |
||
1669 | 1054 |
super openInterface:#windowSpecForStandAlone. |
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1055 |
|
940 | 1056 |
builder window label: 'Help Tool'. |
1597
b670ad8c30e1
builder componentAt: -> self componentAt:
Claus Gittinger <cg@exept.de>
parents:
1554
diff
changeset
|
1057 |
self buildFromClass:aClass andSelector:aSelector |
369 | 1058 |
! ! |
1059 |
||
740 | 1060 |
!UIHelpTool methodsFor:'user actions'! |
286 | 1061 |
|
722 | 1062 |
accept |
1669 | 1063 |
"accepts the help text |
1064 |
" |
|
1065 |
|helpKey helpItem root| |
|
779 | 1066 |
|
1669 | 1067 |
helpKey := self helpKey. |
1068 |
helpKey isNil ifTrue:[^ self]. |
|
1646 | 1069 |
|
1669 | 1070 |
root := classItemModel value. |
1071 |
root isNil ifTrue:[^ self]. |
|
1072 |
||
1073 |
helpItem := root detectItemWithKey:helpKey. |
|
1648
d88ec5777284
empty help string - add key anyway
Claus Gittinger <cg@exept.de>
parents:
1646
diff
changeset
|
1074 |
|
1669 | 1075 |
helpItem isNil ifTrue:[ |
1670 | 1076 |
helpItem := KeyItem helpKey:helpKey helpText:(helpTextView contents). |
1077 |
root add:helpItem sortBlock:[:a :b| a label < b label ]. |
|
1078 |
self updateIcons. |
|
1669 | 1079 |
] ifFalse:[ |
1670 | 1080 |
helpItem helpText:(helpTextView contents). |
1646 | 1081 |
]. |
722 | 1082 |
|
1669 | 1083 |
contentsModifiedChannel value:false. |
1084 |
keyItemModel triggerValue:helpItem. |
|
722 | 1085 |
! |
1086 |
||
1646 | 1087 |
cancel |
1669 | 1088 |
"cancel modifications, reload helpText |
1089 |
" |
|
1090 |
|item contents modified| |
|
1646 | 1091 |
|
1669 | 1092 |
item := keyItemModel value. |
1093 |
modified := false. |
|
779 | 1094 |
|
1669 | 1095 |
item notNil ifTrue:[ |
1096 |
contents := item helpText. |
|
1097 |
] ifFalse:[ |
|
1098 |
contents := nil. |
|
1099 |
||
1100 |
modifiedHolder isNil ifTrue:[ |
|
1101 |
modified := self helpKey notNil |
|
1102 |
] |
|
1646 | 1103 |
]. |
1669 | 1104 |
helpTextView contents:contents. |
1105 |
contentsModifiedChannel value:modified. |
|
722 | 1106 |
! |
1107 |
||
750 | 1108 |
doDelete |
1646 | 1109 |
"deletes the selected help key |
1110 |
" |
|
1669 | 1111 |
|item| |
1646 | 1112 |
|
1669 | 1113 |
item := keyItemModel value. |
1670 | 1114 |
|
1115 |
item notNil ifTrue:[ |
|
1116 |
item remove. |
|
1117 |
item icon notNil ifTrue:[ self updateIcons ]. |
|
1118 |
]. |
|
1669 | 1119 |
editModel value:nil. |
722 | 1120 |
! |
1121 |
||
750 | 1122 |
doLoad |
1669 | 1123 |
"opens a Resource Selection Browser in order to get a resource message |
1124 |
" |
|
750 | 1125 |
self loadFromMessage: |
1681 | 1126 |
(ResourceSelectionBrowser |
1127 |
request: 'Load Help Spec From Class' |
|
1128 |
onSuperclass: nil |
|
1129 |
andClass: specClass |
|
1130 |
andSelector: (self specSelector) |
|
1131 |
withResourceTypes: (Array with: #help)). |
|
779 | 1132 |
|
1133 |
self updateInfoLabel |
|
750 | 1134 |
! |
286 | 1135 |
|
750 | 1136 |
doNew |
1669 | 1137 |
"reset all to empty |
1138 |
" |
|
1139 |
contentsModifiedChannel value:false. |
|
1140 |
self helpKey:nil. |
|
1141 |
self buildFromClass:nil. |
|
750 | 1142 |
! |
1143 |
||
722 | 1144 |
doSave |
1669 | 1145 |
"save the help spec to the spec-class(es) |
1146 |
" |
|
1147 |
specClass isNil ifTrue:[ |
|
1148 |
self information:(resources string:'No class specified !!'). |
|
1149 |
^ nil |
|
1150 |
]. |
|
1151 |
(specClass isSubclassOf:ApplicationModel) ifFalse:[ |
|
1152 |
self information:(resources string:'Cannot save help into none Application class'). |
|
1153 |
^ nil |
|
1154 |
]. |
|
1155 |
||
1681 | 1156 |
classItemList do:[:aClassItem| |
1157 |
aClassItem createHelpMethodNamed:(self specSelector) |
|
1158 |
]. |
|
1669 | 1159 |
! |
1160 |
||
1161 |
openDocumentation |
|
1162 |
"opens the documentation file of the Help Tool |
|
1163 |
" |
|
1164 |
self openHTMLDocument: 'tools/uipainter/HelpTool.html' |
|
1165 |
! ! |
|
1166 |
||
1167 |
!UIHelpTool::ClassItem class methodsFor:'instance creation'! |
|
1168 |
||
1169 |
onClass:aClass |
|
1170 |
|root| |
|
1171 |
||
1172 |
root := self new. |
|
1173 |
root onClass:aClass. |
|
1174 |
^ root |
|
1175 |
! ! |
|
1176 |
||
1177 |
!UIHelpTool::ClassItem methodsFor:'accessing'! |
|
1178 |
||
1179 |
list |
|
1180 |
"returns the hierarchical list assigned to the classItem; the |
|
1181 |
list contains the keyItems |
|
1182 |
" |
|
1183 |
list isNil ifTrue:[ |
|
1184 |
list := HierarchicalList new. |
|
1185 |
list showRoot:false. |
|
1186 |
list root:self. |
|
1187 |
]. |
|
1188 |
^ list |
|
1189 |
! |
|
1190 |
||
1191 |
theClass |
|
1192 |
"returns the class or nil if unspecified |
|
1193 |
" |
|
1194 |
^ theClass |
|
1195 |
! ! |
|
1196 |
||
1197 |
!UIHelpTool::ClassItem methodsFor:'change & update'! |
|
1198 |
||
1199 |
helpTextChangedFor:anItem |
|
1200 |
"called if an helpKey changed its contents |
|
1201 |
" |
|
1202 |
self model notNil ifTrue:[ |
|
1203 |
self modified:true. |
|
1204 |
anItem modified:true. |
|
1205 |
]. |
|
1206 |
! ! |
|
1207 |
||
1208 |
!UIHelpTool::ClassItem methodsFor:'code generation'! |
|
1209 |
||
1210 |
createHelpMethodNamed:aMethodName |
|
1211 |
|stream| |
|
1212 |
||
1213 |
(modified and:[theClass notNil]) ifFalse:[ |
|
1214 |
^ self |
|
1215 |
]. |
|
1216 |
stream := '' writeStream. |
|
1217 |
||
1218 |
stream nextPutAll: |
|
1219 |
aMethodName, '\' withCRs, |
|
1220 |
(ResourceSpecEditor codeGenerationCommentForClass:UIHelpTool) withCRs, |
|
1221 |
'\\' withCRs, |
|
1222 |
' "\' withCRs, |
|
1223 |
' UIHelpTool openOnClass:', theClass name asString ,' |
|
1224 |
" |
|
1225 |
||
1226 |
<resource: #help> |
|
1227 |
||
1228 |
^ super ', aMethodName, ' addPairsFrom:#( |
|
1229 |
||
1230 |
'. |
|
1231 |
||
1232 |
self do:[:aKeyItem| |helpText| |
|
1233 |
helpText := aKeyItem helpText. |
|
1234 |
helpText isNil ifTrue:[ helpText := '' ]. |
|
1235 |
||
1236 |
stream nextPutLine:(aKeyItem helpKey storeString). |
|
1237 |
stream nextPutLine:(helpText storeString); cr. |
|
1238 |
]. |
|
1239 |
stream nextPutLine:')'. |
|
1240 |
||
1241 |
Compiler |
|
1242 |
compile:(stream contents) |
|
1243 |
forClass:theClass class |
|
1244 |
inCategory:'help specs'. |
|
1245 |
||
1246 |
self modified:false. |
|
1247 |
! ! |
|
1248 |
||
1249 |
!UIHelpTool::ClassItem methodsFor:'displaying'! |
|
1250 |
||
1251 |
icon |
|
1252 |
"returns the display icon (always nil) |
|
1253 |
" |
|
1254 |
^ nil |
|
1255 |
! |
|
1256 |
||
1257 |
label |
|
1258 |
"returns the display label |
|
1259 |
" |
|
1260 |
|label| |
|
1261 |
||
1262 |
theClass notNil ifTrue:[ label := theClass name ] |
|
1263 |
ifFalse:[ label := '** not yet defined **' ]. |
|
1264 |
||
1265 |
modified ifTrue:[ |
|
1266 |
label := Text string:label color:(Color red). |
|
1267 |
]. |
|
1268 |
^ label |
|
1269 |
! ! |
|
1270 |
||
1271 |
!UIHelpTool::ClassItem methodsFor:'instance creation'! |
|
1272 |
||
1273 |
initialize |
|
1274 |
"setup defaults |
|
1275 |
" |
|
1276 |
super initialize. |
|
1277 |
||
1278 |
children := OrderedCollection new. |
|
1279 |
isExpanded := true. |
|
1280 |
modified := false. |
|
1281 |
! |
|
1282 |
||
1283 |
onClass:aClass |
|
1284 |
"the class the ys are assigned to; if the class is nil, |
|
1285 |
the class is not yet specified. |
|
1286 |
" |
|
1287 |
theClass := aClass. |
|
1288 |
! ! |
|
1289 |
||
1290 |
!UIHelpTool::ClassItem methodsFor:'private'! |
|
1291 |
||
1292 |
basicAdd:aChild sortBlock:aBlock |
|
1293 |
"catch low-level add to update the modification flag |
|
1294 |
" |
|
1295 |
self modified:true. |
|
1296 |
aChild modified:true. |
|
1297 |
||
1298 |
^ super basicAdd:aChild sortBlock:aBlock. |
|
1299 |
! |
|
1300 |
||
1301 |
basicAddAll:aList beforeIndex:anIndex |
|
1302 |
"catch low-level add to update the modification flag |
|
1303 |
" |
|
1304 |
self modified:true. |
|
1305 |
||
1306 |
aList do:[:el| el modified:true ]. |
|
1307 |
^ super basicAddAll:aList beforeIndex:anIndex. |
|
1308 |
! |
|
779 | 1309 |
|
1669 | 1310 |
basicRemoveFromIndex:startIndex toIndex:stopIndex |
1311 |
"catch low-level remove to update the modification flag |
|
1312 |
" |
|
1313 |
self isUnspecified ifFalse:[ |
|
1314 |
self modified:true. |
|
1315 |
]. |
|
1316 |
^ super basicRemoveFromIndex:startIndex toIndex:stopIndex |
|
1317 |
! ! |
|
1318 |
||
1319 |
!UIHelpTool::ClassItem methodsFor:'queries'! |
|
1320 |
||
1321 |
isUnspecified |
|
1322 |
"true if the class is unspecified |
|
1323 |
" |
|
1324 |
^ theClass isNil |
|
1325 |
! |
|
1326 |
||
1327 |
modified |
|
1328 |
"true, if any item is modified, created or deleted |
|
1329 |
" |
|
1330 |
^ modified |
|
1331 |
! |
|
1332 |
||
1333 |
modified:aBoolean |
|
1334 |
"true, if any item is modified, created or deleted |
|
1335 |
" |
|
1336 |
modified ~~ aBoolean ifTrue:[ |
|
1337 |
modified := aBoolean. |
|
1338 |
||
1339 |
modified ifFalse:[ |
|
1340 |
self do:[:el| el modified:false ]. |
|
1341 |
]. |
|
1342 |
]. |
|
1343 |
! ! |
|
1344 |
||
1345 |
!UIHelpTool::ClassItem methodsFor:'searching'! |
|
1346 |
||
1347 |
detectItemWithKey:aKey |
|
1348 |
"returns the item assigned to a helpKey or nil |
|
1349 |
" |
|
1350 |
|key| |
|
1351 |
||
1352 |
aKey size ~~ 0 ifTrue:[ |
|
1353 |
key := aKey asSymbol. |
|
1354 |
||
1355 |
self do:[:anItem| |
|
1356 |
anItem helpKey == key ifTrue:[ ^ anItem ]. |
|
1357 |
] |
|
1358 |
]. |
|
1359 |
^ nil |
|
1360 |
! ! |
|
1361 |
||
1362 |
!UIHelpTool::KeyItem class methodsFor:'instance creation'! |
|
1363 |
||
1681 | 1364 |
helpKey:aKey helpText:aText |
1669 | 1365 |
|key| |
1366 |
||
1367 |
key := self new. |
|
1368 |
key helpKey:aKey helpText:aText. |
|
1369 |
^ key |
|
1370 |
! ! |
|
1371 |
||
1372 |
!UIHelpTool::KeyItem methodsFor:'accessing'! |
|
1373 |
||
1374 |
helpKey |
|
1375 |
"returns the helpKey, a symbol |
|
1376 |
" |
|
1377 |
^ helpKey |
|
1378 |
! |
|
1379 |
||
1380 |
helpText |
|
1381 |
"returns the contents assigned to the helpKey or nil |
|
1382 |
" |
|
1383 |
^ helpText |
|
1384 |
! |
|
1385 |
||
1386 |
helpText:aText |
|
1681 | 1387 |
"set the contents assigned to the helpKey; if the contents changes, |
1669 | 1388 |
a notification is raised. |
1389 |
" |
|
1390 |
|text| |
|
1391 |
||
1392 |
text := self formatText:aText. |
|
1393 |
||
1394 |
text ~= helpText ifTrue:[ |
|
1681 | 1395 |
helpText := text. |
1669 | 1396 |
|
1681 | 1397 |
(modified or:[parent isNil]) ifFalse:[ |
1398 |
parent helpTextChangedFor:self. |
|
1399 |
] |
|
1669 | 1400 |
]. |
1401 |
! ! |
|
1402 |
||
1403 |
!UIHelpTool::KeyItem methodsFor:'displaying'! |
|
1404 |
||
1405 |
icon |
|
1406 |
"returns the display icon (always nil) |
|
1407 |
" |
|
1670 | 1408 |
^ icon |
1409 |
! |
|
1410 |
||
1411 |
icon:anIcon |
|
1412 |
||
1413 |
icon ~= anIcon ifTrue:[ |
|
1414 |
icon := anIcon. |
|
1415 |
self changed:#icon. |
|
1416 |
]. |
|
1669 | 1417 |
! |
1418 |
||
1419 |
label |
|
1420 |
"returns the display label |
|
1421 |
" |
|
1422 |
modified ifTrue:[ |
|
1423 |
^ Text string:helpKey color:(Color red) |
|
1424 |
]. |
|
1425 |
^ helpKey |
|
1426 |
! ! |
|
1427 |
||
1428 |
!UIHelpTool::KeyItem methodsFor:'instance creation'! |
|
1429 |
||
1430 |
helpKey:aKey helpText:aText |
|
1431 |
"set the key and contents without a change notification |
|
1432 |
" |
|
1433 |
helpKey := aKey asSymbol. |
|
1434 |
helpText := self formatText:aText. |
|
1435 |
! |
|
1436 |
||
1437 |
initialize |
|
1438 |
"setup defaults |
|
1439 |
" |
|
1440 |
super initialize. |
|
1441 |
children := #(). |
|
1442 |
modified := false. |
|
1443 |
! ! |
|
1444 |
||
1445 |
!UIHelpTool::KeyItem methodsFor:'private'! |
|
1446 |
||
1447 |
formatText:aText |
|
1448 |
"format the text, replace carriage return by spaces and compress spaces |
|
1449 |
" |
|
1450 |
|text result| |
|
1451 |
||
1452 |
aText size ~~ 0 ifTrue:[ |
|
1453 |
text := aText asString asCollectionOfWords. |
|
1454 |
||
1455 |
text notEmpty ifTrue:[ |
|
1456 |
result := text first. |
|
1457 |
||
1458 |
text from:2 do:[:t| result := result, ' ', t ]. |
|
1459 |
^ result |
|
1460 |
]. |
|
1461 |
]. |
|
1462 |
^ nil |
|
1463 |
! ! |
|
1464 |
||
1465 |
!UIHelpTool::KeyItem methodsFor:'queries'! |
|
1466 |
||
1467 |
modified |
|
1468 |
"returns true if the helpText is modified |
|
1469 |
" |
|
1470 |
^ modified |
|
1471 |
! |
|
1472 |
||
1473 |
modified:aBoolean |
|
1474 |
"set the modification flag |
|
1475 |
" |
|
1476 |
aBoolean == modified ifFalse:[ |
|
1477 |
modified := aBoolean. |
|
1478 |
self changed:#redraw. |
|
1479 |
]. |
|
148 | 1480 |
! ! |
1481 |
||
1482 |
!UIHelpTool class methodsFor:'documentation'! |
|
1483 |
||
1484 |
version |
|
1485 |
^ '$Header$' |
|
1486 |
! ! |