343 by the MenuEditor of ST/X." |
345 by the MenuEditor of ST/X." |
344 |
346 |
345 "Do not manually edit this!! If it is corrupted, |
347 "Do not manually edit this!! If it is corrupted, |
346 the MenuEditor may not be able to read the specification." |
348 the MenuEditor may not be able to read the specification." |
347 |
349 |
|
350 |
348 " |
351 " |
349 MenuEditor new openOnClass:UIHelpTool andSelector:#helpTextMenu |
352 MenuEditor new openOnClass:UIHelpTool andSelector:#helpTextMenu |
350 (Menu new fromLiteralArrayEncoding:(UIHelpTool helpTextMenu)) startUp |
353 (Menu new fromLiteralArrayEncoding:(UIHelpTool helpTextMenu)) startUp |
351 " |
354 " |
352 |
355 |
353 <resource: #menu> |
356 <resource: #menu> |
354 |
357 |
355 ^ |
358 ^ |
356 #(#Menu |
359 #(Menu |
357 #( |
360 ( |
358 #(#MenuItem |
361 (MenuItem |
359 #activeHelpKey: #commitOK |
362 activeHelpKey: commitOK |
360 #enabled: #contentsModifiedChannel |
363 enabled: contentsModifiedChannel |
361 #label: 'Accept' |
364 label: 'Accept' |
362 #itemValue: #accept |
365 itemValue: accept |
363 #translateLabel: true |
366 ) |
364 ) |
367 (MenuItem |
365 #(#MenuItem |
368 activeHelpKey: commitCancel |
366 #activeHelpKey: #commitCancel |
369 enabled: contentsModifiedChannel |
367 #enabled: #contentsModifiedChannel |
370 label: 'Cancel' |
368 #label: 'Cancel' |
371 itemValue: cancel |
369 #itemValue: #cancel |
372 ) |
370 #translateLabel: true |
373 ) |
371 ) |
374 nil |
372 ) |
375 nil |
373 nil |
|
374 nil |
|
375 ) |
376 ) |
376 ! |
377 ! |
377 |
378 |
378 keyItemMenu |
379 keyItemMenu |
379 "This resource specification was automatically generated |
380 "This resource specification was automatically generated |
380 by the MenuEditor of ST/X." |
381 by the MenuEditor of ST/X." |
381 |
382 |
382 "Do not manually edit this!! If it is corrupted, |
383 "Do not manually edit this!! If it is corrupted, |
383 the MenuEditor may not be able to read the specification." |
384 the MenuEditor may not be able to read the specification." |
384 |
385 |
|
386 |
385 " |
387 " |
386 MenuEditor new openOnClass:UIHelpTool andSelector:#keyItemMenu |
388 MenuEditor new openOnClass:UIHelpTool andSelector:#keyItemMenu |
387 (Menu new fromLiteralArrayEncoding:(UIHelpTool keyItemMenu)) startUp |
389 (Menu new fromLiteralArrayEncoding:(UIHelpTool keyItemMenu)) startUp |
388 " |
390 " |
389 |
391 |
390 <resource: #menu> |
392 <resource: #menu> |
391 |
393 |
392 ^ |
394 ^ |
393 #(#Menu |
395 #(Menu |
394 #( |
396 ( |
395 #(#MenuItem |
397 (MenuItem |
396 #activeHelpKey: #deleteHelpTextKey |
398 activeHelpKey: deleteHelpTextKey |
397 #label: 'Delete' |
399 enabled: hasKeyItemSelectedHolder |
398 #itemValue: #doDelete |
400 label: 'Delete Key' |
399 #translateLabel: true |
401 itemValue: doDelete |
400 ) |
402 ) |
401 ) |
403 (MenuItem |
402 nil |
404 label: '-' |
403 nil |
405 ) |
|
406 (MenuItem |
|
407 activeHelpKey: extractHelpTextKeys |
|
408 label: 'Extract used Keys from Application' |
|
409 itemValue: doExtractUsedKeys |
|
410 enabled: hasSpecClassDefined |
|
411 ) |
|
412 ) |
|
413 nil |
|
414 nil |
404 ) |
415 ) |
|
416 |
|
417 "Modified: / 24-05-2018 / 15:52:24 / Claus Gittinger" |
405 ! |
418 ! |
406 |
419 |
407 listOfKeysMenu |
420 listOfKeysMenu |
408 "This resource specification was automatically generated |
421 "This resource specification was automatically generated |
409 by the MenuEditor of ST/X." |
422 by the MenuEditor of ST/X." |
410 |
423 |
411 "Do not manually edit this!! If it is corrupted, |
424 "Do not manually edit this!! If it is corrupted, |
412 the MenuEditor may not be able to read the specification." |
425 the MenuEditor may not be able to read the specification." |
413 |
426 |
|
427 |
414 " |
428 " |
415 MenuEditor new openOnClass:UIHelpTool andSelector:#listOfKeysMenu |
429 MenuEditor new openOnClass:UIHelpTool andSelector:#listOfKeysMenu |
416 (Menu new fromLiteralArrayEncoding:(UIHelpTool listOfKeysMenu)) startUp |
430 (Menu new fromLiteralArrayEncoding:(UIHelpTool listOfKeysMenu)) startUp |
417 " |
431 " |
418 |
432 |
419 <resource: #menu> |
433 <resource: #menu> |
420 |
434 |
421 ^ |
435 ^ |
422 #(#Menu |
436 #(Menu |
423 #( |
437 ( |
424 #(#MenuItem |
438 (MenuItem |
425 #activeHelpKey: #deleteHelpTextKey |
439 activeHelpKey: deleteHelpTextKey |
426 #label: 'Delete' |
440 label: 'Delete' |
427 #itemValue: #doDelete |
441 itemValue: doDelete |
428 #translateLabel: true |
442 ) |
429 ) |
443 ) |
430 ) |
444 nil |
431 nil |
445 nil |
432 nil |
|
433 ) |
446 ) |
434 ! |
447 ! |
435 |
448 |
436 menu |
449 menu |
437 "This resource specification was automatically generated |
450 "This resource specification was automatically generated |
1061 ! ! |
1093 ! ! |
1062 |
1094 |
1063 !UIHelpTool methodsFor:'user actions'! |
1095 !UIHelpTool methodsFor:'user actions'! |
1064 |
1096 |
1065 accept |
1097 accept |
1066 "accepts the help text |
1098 "accepts the help text; |
1067 " |
1099 take the contents of the helpTextView and store it under the current helpKey" |
1068 |helpKey helpItem root| |
1100 |
|
1101 |helpKey| |
1069 |
1102 |
1070 helpKey := self helpKey. |
1103 helpKey := self helpKey. |
1071 helpKey isNil ifTrue:[^ self]. |
1104 helpKey isNil ifTrue:[^ self]. |
1072 |
1105 |
1073 root := classItemModel value. |
1106 self store:(helpTextView contents) forKey:helpKey |
1074 root isNil ifTrue:[^ self]. |
1107 |
1075 |
1108 "Modified: / 24-05-2018 / 16:31:25 / Claus Gittinger" |
1076 helpItem := root detectItemWithKey:helpKey. |
|
1077 |
|
1078 helpItem isNil ifTrue:[ |
|
1079 helpItem := KeyItem helpKey:helpKey helpText:(helpTextView contents). |
|
1080 root add:helpItem sortBlock:[:a :b| a label < b label ]. |
|
1081 self updateIcons. |
|
1082 ] ifFalse:[ |
|
1083 helpItem helpText:(helpTextView contents). |
|
1084 ]. |
|
1085 |
|
1086 contentsModifiedChannel value:false. |
|
1087 keyItemModel triggerValue:helpItem. |
|
1088 ! |
1109 ! |
1089 |
1110 |
1090 cancel |
1111 cancel |
1091 "cancel modifications, reload helpText" |
1112 "cancel modifications, reload helpText" |
1092 |
1113 |
1120 item notNil ifTrue:[ |
1141 item notNil ifTrue:[ |
1121 item remove. |
1142 item remove. |
1122 item icon notNil ifTrue:[ self updateIcons ]. |
1143 item icon notNil ifTrue:[ self updateIcons ]. |
1123 ]. |
1144 ]. |
1124 editModel value:nil. |
1145 editModel value:nil. |
|
1146 ! |
|
1147 |
|
1148 doExtractUsedKeys |
|
1149 "goes through the classes menu- and interface specs, |
|
1150 and extracts possible activeHelpKeys" |
|
1151 |
|
1152 |allHelpKeys existingKeys cls missingKeys| |
|
1153 |
|
1154 allHelpKeys := Set new. |
|
1155 |
|
1156 specClass theMetaclass methodsDo:[:mthd | |
|
1157 |spec bodyNode retVal specArray menu| |
|
1158 |
|
1159 (mthd hasMenuResource or:[mthd hasCanvasResource]) ifTrue:[ |
|
1160 bodyNode := mthd parseTree body. |
|
1161 bodyNode lastIsReturn ifTrue:[ |
|
1162 (retVal := bodyNode statements last value) isLiteralArray ifTrue:[ |
|
1163 specArray := retVal value. |
|
1164 spec := specArray decodeAsLiteralArray. |
|
1165 spec do:[:eachSpec | |
|
1166 |k| |
|
1167 |
|
1168 (k := eachSpec activeHelpKey) notNil ifTrue:[ |
|
1169 allHelpKeys add:k. |
|
1170 ]. |
|
1171 ]. |
|
1172 ] |
|
1173 ]. |
|
1174 ]. |
|
1175 ]. |
|
1176 |
|
1177 existingKeys := Set new. |
|
1178 (cls := specClass theMetaclass whichClassImplements:self specSelector) notNil ifTrue:[ |
|
1179 |specThere| |
|
1180 |
|
1181 specThere := cls theNonMetaclass perform:self specSelector. |
|
1182 specThere isDictionary ifFalse:[ |
|
1183 Transcript showCR:('oops - helpSpec from ',cls name,'>>',self specSelector,' is not a dictionary'). |
|
1184 ] ifTrue:[ |
|
1185 existingKeys addAll:(specThere keys). |
|
1186 ]. |
|
1187 ]. |
|
1188 |
|
1189 missingKeys := OrderedCollection new. |
|
1190 |
|
1191 allHelpKeys do:[:each | |
|
1192 (existingKeys includes:each) ifFalse:[ |
|
1193 missingKeys add:each. |
|
1194 ]. |
|
1195 ]. |
|
1196 missingKeys do:[:eachKey | |
|
1197 self store:'no tooltip yet' forKey:eachKey |
|
1198 ]. |
|
1199 |
|
1200 "Created: / 24-05-2018 / 16:00:08 / Claus Gittinger" |
1125 ! |
1201 ! |
1126 |
1202 |
1127 doLoad |
1203 doLoad |
1128 "opens a Resource Selection Browser in order to get a resource message" |
1204 "opens a Resource Selection Browser in order to get a resource message" |
1129 |
1205 |
1151 |
1227 |
1152 specClass isNil ifTrue:[ |
1228 specClass isNil ifTrue:[ |
1153 self information:'No class specified !!'. |
1229 self information:'No class specified !!'. |
1154 ^ nil |
1230 ^ nil |
1155 ]. |
1231 ]. |
1156 "/ cg: the following test is rubbish !! |
1232 |
1157 "/ (specClass isSubclassOf:ApplicationModel) ifFalse:[ |
1233 "/ cg: the following test is rubbish !! |
1158 "/ self information:(resources string:'Cannot save help into non-Application class'). |
1234 "/ (specClass isSubclassOf:ApplicationModel) ifFalse:[ |
1159 "/ ^ nil |
1235 "/ self information:(resources string:'Cannot save help into non-Application class'). |
1160 "/ ]. |
1236 "/ ^ nil |
|
1237 "/ ]. |
1161 |
1238 |
1162 classItemList do:[:aClassItem| |
1239 classItemList do:[:aClassItem| |
1163 aClassItem theClass isNil ifTrue:[ |
1240 aClassItem theClass isNil ifTrue:[ |
1164 aClassItem onClass:specClass |
1241 aClassItem onClass:specClass |
1165 ]. |
1242 ]. |
1166 aClassItem createHelpMethodNamed:(self specSelector) |
1243 aClassItem createHelpMethodNamed:(self specSelector) |
1167 ]. |
1244 ]. |
|
1245 |
|
1246 "Modified (format): / 24-05-2018 / 16:25:31 / Claus Gittinger" |
1168 ! |
1247 ! |
1169 |
1248 |
1170 openDocumentation |
1249 openDocumentation |
1171 "opens the documentation file of the Help Tool |
1250 "opens the documentation file of the Help Tool |
1172 " |
1251 " |
1173 self openHTMLDocument: 'tools/uipainter/HelpTool.html' |
1252 self openHTMLDocument: 'tools/uipainter/HelpTool.html' |
|
1253 ! |
|
1254 |
|
1255 store:helpText forKey:helpKey |
|
1256 "store helpText under helpKey" |
|
1257 |
|
1258 |helpItem root| |
|
1259 |
|
1260 root := classItemModel value. |
|
1261 root isNil ifTrue:[^ self]. |
|
1262 |
|
1263 helpItem := root detectItemWithKey:helpKey. |
|
1264 |
|
1265 helpItem isNil ifTrue:[ |
|
1266 helpItem := KeyItem helpKey:helpKey helpText:helpText. |
|
1267 root add:helpItem sortBlock:[:a :b| a label < b label ]. |
|
1268 self updateIcons. |
|
1269 ] ifFalse:[ |
|
1270 helpItem helpText:(helpTextView contents). |
|
1271 ]. |
|
1272 |
|
1273 contentsModifiedChannel value:false. |
|
1274 keyItemModel triggerValue:helpItem. |
|
1275 |
|
1276 "Created: / 24-05-2018 / 16:31:08 / Claus Gittinger" |
1174 ! ! |
1277 ! ! |
1175 |
1278 |
1176 !UIHelpTool::ClassItem class methodsFor:'instance creation'! |
1279 !UIHelpTool::ClassItem class methodsFor:'instance creation'! |
1177 |
1280 |
1178 onClass:aClass |
1281 onClass:aClass |