124 ^ |
124 ^ |
125 |
125 |
126 #(#FullSpec |
126 #(#FullSpec |
127 #window: |
127 #window: |
128 #(#WindowSpec |
128 #(#WindowSpec |
129 #name: 'HelpTool' |
129 #name: 'unnamed canvas' |
130 #layout: #(#LayoutFrame 90 0 295 0 375 0 565 0) |
130 #layout: #(#LayoutFrame 118 0 430 0 403 0 700 0) |
131 #label: 'unnamed canvas' |
131 #label: 'unnamed canvas' |
132 #min: #(#Point 10 10) |
132 #min: #(#Point 10 10) |
133 #max: #(#Point 1160 870) |
133 #max: #(#Point 1160 870) |
134 #bounds: #(#Rectangle 90 295 376 566) |
134 #bounds: #(#Rectangle 118 430 404 701) |
135 #usePreferredExtent: false |
135 #usePreferredExtent: false |
136 ) |
136 ) |
137 #component: |
137 #component: |
138 #(#SpecCollection |
138 #(#SpecCollection |
139 #collection: |
139 #collection: |
188 #(#InputFieldSpec |
188 #(#InputFieldSpec |
189 #name: 'helpKeyInputField' |
189 #name: 'helpKeyInputField' |
190 #layout: #(#LayoutFrame 1 0.5 29 0 -3 1 51 0) |
190 #layout: #(#LayoutFrame 1 0.5 29 0 -3 1 51 0) |
191 #activeHelpKey: #currentHelpTexts |
191 #activeHelpKey: #currentHelpTexts |
192 #model: #listModel |
192 #model: #listModel |
|
193 #immediateAccept: false |
193 ) |
194 ) |
194 #(#SequenceViewSpec |
195 #(#SequenceViewSpec |
195 #name: 'listOfHelpSpecClassesView' |
196 #name: 'listOfHelpSpecClassesView' |
196 #layout: #(#LayoutFrame 1 0.5 53 0 -3 1 -1 0.5) |
197 #layout: #(#LayoutFrame 1 0.5 53 0 -3 1 -1 0.5) |
197 #activeHelpKey: #listOfHelpSpecClasses |
198 #activeHelpKey: #listOfHelpSpecClasses |
320 ! ! |
321 ! ! |
321 |
322 |
322 !UIHelpTool methodsFor:'accessing'! |
323 !UIHelpTool methodsFor:'accessing'! |
323 |
324 |
324 dictionaries |
325 dictionaries |
325 "return dictionaries" |
326 "get the dictionary of the help dictionaries of the classes having help specs |
326 |
327 " |
327 ^dictionaries |
328 ^dictionaries |
328 ! |
329 ! |
329 |
330 |
330 dictionaries:aDictionaryOfDictionaries |
331 dictionaries:aDictionaryOfDictionaries |
331 "set dictionaries" |
332 "set a dictionary of the help dictionaries of the classes having help specs |
332 |
333 " |
333 (dictionaries := aDictionaryOfDictionaries) isNil ifTrue:[ |
334 (dictionaries := aDictionaryOfDictionaries) isNil ifTrue:[ |
334 dictionaries := Dictionary new. |
335 dictionaries := Dictionary new. |
335 ]. |
336 ]. |
336 self updateList. |
337 self updateList. |
337 ! |
338 ! |
338 |
339 |
339 dictionary |
340 dictionary |
340 "return dictionary" |
341 "get the dictionary of the selected class |
341 |
342 " |
342 ^ dictionary |
343 ^dictionary |
343 ! |
344 ! |
344 |
345 |
345 dictionary:aDictionary |
346 dictionary:aDictionary |
346 "set dictionary" |
347 "set dictionary of the selected class |
347 |
348 " |
348 (dictionary := aDictionary) isNil ifTrue:[ |
349 (dictionary := aDictionary) isNil ifTrue:[ |
349 dictionary := Dictionary new. |
350 dictionary := Dictionary new. |
350 ]. |
351 ]. |
351 self updateList |
352 self updateList |
352 ! |
353 ! |
353 |
354 |
354 helpKey |
355 helpKey |
|
356 "get the help key of selected help text |
|
357 " |
355 listSelection size ~~ 0 ifTrue:[ |
358 listSelection size ~~ 0 ifTrue:[ |
356 ^ listSelection asSymbol |
359 ^ listSelection asSymbol |
357 ]. |
360 ]. |
358 ^ nil |
361 ^ nil |
359 ! |
362 ! |
360 |
363 |
361 helpKey:aKey |
364 helpKey:aKey |
|
365 "set the help key into the selection channel in order to show the help text |
|
366 " |
362 |key| |
367 |key| |
363 |
|
364 aKey size ~~ 0 ifTrue:[ |
368 aKey size ~~ 0 ifTrue:[ |
365 key := aKey asString |
369 key := aKey asString |
366 ]. |
370 ]. |
367 self listModel value:key |
371 self listModel value:key |
368 |
372 |
369 ! |
373 ! |
370 |
374 |
371 helpSpecFrom:aClass |
375 helpSpecFrom:aClass |
372 "read help text from an application associated with the class |
376 "read the help dictionary from aClass and find remaining classes |
|
377 'between' aClass and ApplicationModel |
373 " |
378 " |
374 |help| |
379 |help| |
375 |
380 |
376 isModified := false. |
381 isModified := false. |
377 specClass notNil |
382 specClass notNil |
431 |
439 |
432 |
440 |
433 ! |
441 ! |
434 |
442 |
435 specClass |
443 specClass |
436 |
444 "get the class on which the help tool works |
|
445 " |
437 ^specClass |
446 ^specClass |
438 ! ! |
447 ! ! |
439 |
448 |
440 !UIHelpTool methodsFor:'actions'! |
449 !UIHelpTool methodsFor:'actions'! |
441 |
450 |
442 accept |
|
443 "accept the text |
|
444 " |
|
445 |view key txt list listChgd| |
|
446 |
|
447 (listSelection size == 0 or:[(view := self editTextView) isNil]) ifFalse:[ |
|
448 txt := view contents asString. |
|
449 key := listSelection asSymbol. |
|
450 list := self listChannel value. |
|
451 |
|
452 (listChgd := (dictionary at:key ifAbsent:nil) isNil) ifTrue:[ |
|
453 list add:key. |
|
454 ]. |
|
455 dictionary at:key put:txt. |
|
456 |
|
457 listChgd ifTrue:[ |
|
458 self updateList. |
|
459 (builder componentAt: #listOfHelpKeysView) selection: (list indexOf: key). |
|
460 ]. |
|
461 |
|
462 isModified := true. |
|
463 modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
|
464 ] |
|
465 ! |
|
466 |
|
467 delete |
|
468 "delete selected help key |
|
469 " |
|
470 listSelection notNil |
|
471 ifTrue: |
|
472 [ |
|
473 dictionary removeKey: listSelection asSymbol ifAbsent: nil. |
|
474 self remove. |
|
475 |
|
476 self updateList. |
|
477 |
|
478 isModified := true. |
|
479 modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
|
480 ] |
|
481 ! |
|
482 |
|
483 helpSpecClassSelected |
451 helpSpecClassSelected |
484 |
452 "extract the help dictionary from the selected class and make it current |
|
453 " |
485 |clsName| |
454 |clsName| |
486 |
455 |
487 clsName := self selectionOfHelpSpecClass value. |
456 clsName := self selectionOfHelpSpecClass value. |
488 |
457 |
489 (dictionary := dictionaries at: clsName ifAbsent: nil) isNil |
458 (dictionary := dictionaries at: clsName ifAbsent: nil) isNil |
509 ] |
478 ] |
510 |
479 |
511 |
480 |
512 ! |
481 ! |
513 |
482 |
514 installHelpSpecInto:aClass |
483 installHelpSpecOnClass:aClass |
515 "install help text |
484 "save the help dicts in aClass which is subclass of ApplicationModel" |
516 " |
485 |
517 |cls src helpSpec| |
486 |cls src helpSpec| |
518 |
487 |
519 cls := self applicationClassAssociatedWith:aClass. |
488 cls := self applicationClassAssociatedWith:aClass. |
520 |
489 |
521 cls isNil ifTrue:[ |
490 cls isNil ifTrue:[ |
522 ^ self information:'No application class defined!!'. |
491 self information:'No application class defined!!'. |
523 ]. |
492 ^nil |
524 |
493 ]. |
525 aClass = cls name asString |
494 |
526 ifTrue: [self listOfHelpSpecClasses value do: [:c| c ~~ cls name ifTrue: [self installHelpSpecInto: (Smalltalk at: c). isModified := true]]]. |
495 (cls isSubclassOf: ApplicationModel) ifFalse:[ |
527 |
496 self information: 'Cannot save help spec into class ', cls name asBoldText, ',\because it is not a subclass of ApplicationModel!!' withCRs. |
528 isModified not ifTrue:[ |
|
529 ^nil |
497 ^nil |
530 ]. |
498 ]. |
531 |
499 |
532 helpSpec := dictionaries at: cls name |
500 helpSpec := dictionaries at: cls name |
533 ifAbsent: [aClass = cls name asString ifTrue: [dictionary] ifFalse: [Dictionary new]]. |
501 ifAbsent: [aClass = cls name asString ifTrue: [dictionary] ifFalse: [Dictionary new]]. |
592 ]. |
559 ]. |
593 src nextPutLine:t storeString; cr. |
560 src nextPutLine:t storeString; cr. |
594 ]. |
561 ]. |
595 src nextPutLine:')'. |
562 src nextPutLine:')'. |
596 |
563 |
597 Compiler compile:(src contents) |
564 Compiler |
598 forClass:cls class |
565 compile:(src contents) |
599 inCategory:'help specs'. |
566 forClass:cls class |
|
567 inCategory:'help specs'. |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 ! |
|
573 |
|
574 installHelpSpecsOnClass:aClass |
|
575 "save the help dicts on aClass and its superclasses which are subclasses of ApplicationModel |
|
576 " |
|
577 |cls helpSpecClasses| |
|
578 |
|
579 isModified ifFalse:[ |
|
580 ^nil |
|
581 ]. |
|
582 |
|
583 cls := aClass isClass ifTrue: [aClass name] ifFalse: [aClass]. |
|
584 |
|
585 (helpSpecClasses := self listOfHelpSpecClasses value) notNil |
|
586 ifTrue: |
|
587 [ |
|
588 (helpSpecClasses includes: cls) ifFalse: [helpSpecClasses add: cls]. |
|
589 helpSpecClasses do: [:clsName| (self installHelpSpecOnClass: clsName) isNil ifTrue: [^isModified := false]]. |
|
590 ] |
|
591 ifFalse: |
|
592 [ |
|
593 self installHelpSpecOnClass: cls |
|
594 ]. |
600 |
595 |
601 isModified := false. |
596 isModified := false. |
602 |
597 |
603 |
|
604 ! |
|
605 |
|
606 remove |
|
607 "remove selected help key |
|
608 " |
|
609 |
|
610 self listModel value: nil. |
|
611 |
|
612 self updateList. |
|
613 |
|
614 modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
|
615 ! ! |
598 ! ! |
616 |
599 |
617 !UIHelpTool methodsFor:'aspects'! |
600 !UIHelpTool methodsFor:'aspects'! |
618 |
601 |
619 listChannel |
602 listChannel |
620 |
603 "get the value holder of the help texts |
|
604 " |
621 |holder| |
605 |holder| |
622 |
|
623 (holder := builder bindingAt:#listChannel) isNil ifTrue:[ |
606 (holder := builder bindingAt:#listChannel) isNil ifTrue:[ |
624 builder aspectAt:#listChannel put:(holder := OrderedCollection new asValue). |
607 builder aspectAt:#listChannel put:(holder := OrderedCollection new asValue). |
625 ]. |
608 ]. |
626 ^ holder |
609 ^ holder |
627 ! |
610 ! |
628 |
611 |
629 listModel |
612 listModel |
630 |
613 "get the value holder of the help key |
|
614 " |
631 |holder| |
615 |holder| |
632 |
|
633 (holder := builder bindingAt:#listModel) isNil ifTrue:[ |
616 (holder := builder bindingAt:#listModel) isNil ifTrue:[ |
634 holder := AspectAdaptor new subject:self; forAspect:#listSelection. |
617 holder := AspectAdaptor new subject:self; forAspect:#listSelection. |
635 builder aspectAt:#listModel put:holder. |
618 builder aspectAt:#listModel put:holder. |
636 ]. |
619 ]. |
637 ^ holder |
620 ^ holder |
638 ! |
621 ! |
639 |
622 |
640 listOfHelpSpecClasses |
623 listOfHelpSpecClasses |
641 |
624 "get the value holder of the specClass and its superclasses |
|
625 which are subclasses of ApplicationModel |
|
626 " |
642 |holder| |
627 |holder| |
643 (holder := builder bindingAt:#listOfHelpSpecClasses) isNil ifTrue:[ |
628 (holder := builder bindingAt:#listOfHelpSpecClasses) isNil ifTrue:[ |
644 builder aspectAt:#listOfHelpSpecClasses put: (holder := List new) |
629 builder aspectAt:#listOfHelpSpecClasses put: (holder := List new) |
645 ]. |
630 ]. |
646 ^ holder |
631 ^ holder |
647 |
632 |
648 ! |
633 ! |
649 |
634 |
650 selectionOfHelpSpecClass |
635 selectionOfHelpSpecClass |
651 |
636 "get the value holder of the selected help spec class |
|
637 " |
652 |holder| |
638 |holder| |
653 (holder := builder bindingAt:#selectionOfHelpSpecClass) isNil ifTrue:[ |
639 (holder := builder bindingAt:#selectionOfHelpSpecClass) isNil ifTrue:[ |
654 builder aspectAt:#selectionOfHelpSpecClass put: (holder := ValueHolder new) |
640 builder aspectAt:#selectionOfHelpSpecClass put: (holder := ValueHolder new) |
655 ]. |
641 ]. |
656 ^ holder |
642 ^ holder |
691 ]. |
678 ]. |
692 ^ view |
679 ^ view |
693 ! |
680 ! |
694 |
681 |
695 extractHelpSpecForClass: aClass |
682 extractHelpSpecForClass: aClass |
696 |
683 "extract the help dictionary of aClass, it current and return it |
|
684 " |
697 |helpSpecSuperClass superHelpSpecKeys helpSpec| |
685 |helpSpecSuperClass superHelpSpecKeys helpSpec| |
698 |
686 |
699 ((aClass class implements: #helpSpec) |
687 ((aClass class implements: #helpSpec) |
700 and: [(helpSpecSuperClass := aClass allSuperclasses detect: [:cls| cls class implements: #helpSpec] ifNone: nil) notNil]) |
688 and: [(helpSpecSuperClass := aClass allSuperclasses detect: [:cls| cls class implements: #helpSpec] ifNone: nil) notNil]) |
701 ifTrue: |
689 ifTrue: |
710 ]. |
698 ]. |
711 ^dictionary := Dictionary new |
699 ^dictionary := Dictionary new |
712 ! |
700 ! |
713 |
701 |
714 findHelpSpecForKey: aHelpKey |
702 findHelpSpecForKey: aHelpKey |
715 "update list from dictionary |
703 "find the help spec class including aHelpKey in its help dictionary and make it current |
716 " |
704 " |
717 |dictTemp helpSpecClass superHelpSpecKeys helpSpec| |
705 |dictTemp helpSpecClass superHelpSpecKeys helpSpec| |
718 |
706 |
719 aHelpKey isNil ifTrue: [^nil]. |
707 aHelpKey isNil ifTrue: [^nil]. |
720 dictTemp := dictionary. |
708 dictTemp := dictionary. |
749 applicationClassAssociatedWith:aClass |
737 applicationClassAssociatedWith:aClass |
750 "get application class keeping the associated help text or nil |
738 "get application class keeping the associated help text or nil |
751 " |
739 " |
752 |cls| |
740 |cls| |
753 |
741 |
754 cls := self resolveName:aClass. |
742 ((cls := self resolveName:aClass) notNil and:[cls includesBehavior:UISpecification]) ifTrue:[ |
755 |
743 ^UISpecificationTool |
756 (cls notNil and:[cls includesBehavior:UISpecification]) ifTrue:[ |
744 ]. |
757 ^ UISpecificationTool |
745 ^cls |
758 ]. |
|
759 ^ cls |
|
760 |
746 |
761 |
747 |
762 ! ! |
748 ! ! |
763 |
749 |
764 !UIHelpTool methodsFor:'selection'! |
750 !UIHelpTool methodsFor:'selection'! |
772 listSelection:aSelection |
758 listSelection:aSelection |
773 "current selection changed |
759 "current selection changed |
774 " |
760 " |
775 |txt view sel| |
761 |txt view sel| |
776 |
762 |
777 aSelection isNil ifTrue: [(builder componentAt: #listOfHelpKeysView) selection: nil]. |
763 aSelection isNil |
778 self findHelpSpecForKey: aSelection. |
764 ifTrue: [(builder componentAt: #listOfHelpKeysView) selection: nil] |
|
765 ifFalse: [(dictionary includesKey: aSelection asSymbol) ifFalse: [self findHelpSpecForKey: aSelection]]. |
779 |
766 |
780 aSelection isNumber ifTrue:[ |
767 aSelection isNumber ifTrue:[ |
781 aSelection ~~ 0 ifTrue:[ |
768 aSelection ~~ 0 ifTrue:[ |
782 sel := self listChannel value at:aSelection |
769 sel := self listChannel value at:aSelection |
783 ] |
770 ] |
829 " |
817 " |
830 super openInterface: #windowSpecForStandAlone |
818 super openInterface: #windowSpecForStandAlone |
831 ! ! |
819 ! ! |
832 |
820 |
833 !UIHelpTool methodsFor:'user interactions'! |
821 !UIHelpTool methodsFor:'user interactions'! |
|
822 |
|
823 accept |
|
824 "accept the help text |
|
825 " |
|
826 |view key txt list listChgd| |
|
827 |
|
828 (listSelection size == 0 or:[(view := self editTextView) isNil]) ifFalse:[ |
|
829 txt := view contents asString. |
|
830 key := listSelection asSymbol. |
|
831 list := self listChannel value. |
|
832 |
|
833 (listChgd := (dictionary at:key ifAbsent:nil) isNil) ifTrue:[ |
|
834 list add:key. |
|
835 ]. |
|
836 dictionary at:key put:txt. |
|
837 |
|
838 listChgd ifTrue:[ |
|
839 self updateList. |
|
840 (builder componentAt: #listOfHelpKeysView) selection: (list indexOf: key). |
|
841 ]. |
|
842 |
|
843 isModified := true. |
|
844 modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
|
845 ] |
|
846 ! |
|
847 |
|
848 add |
|
849 "add help key |
|
850 " |
|
851 self listModel value: (builder componentAt: #helpKeyInputField asSymbol) contents. |
|
852 self accept |
|
853 ! |
|
854 |
|
855 delete |
|
856 "delete selected help key |
|
857 " |
|
858 listSelection notNil |
|
859 ifTrue: |
|
860 [ |
|
861 dictionary removeKey: listSelection asSymbol ifAbsent: nil. |
|
862 self remove. |
|
863 |
|
864 self updateList. |
|
865 |
|
866 isModified := true. |
|
867 modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
|
868 ] |
|
869 ! |
834 |
870 |
835 doFromClass |
871 doFromClass |
836 "setup new specification from a class accessed through to a dialog |
872 "setup new specification from a class accessed through to a dialog |
837 " |
873 " |
838 |cls cls2 accepted| |
874 |cls cls2 accepted| |
857 ]. |
893 ]. |
858 self warn:'No help spec found in class ', cls value asBoldText, '!!'. |
894 self warn:'No help spec found in class ', cls value asBoldText, '!!'. |
859 ] |
895 ] |
860 ! |
896 ! |
861 |
897 |
862 doInstallHelpSpec |
|
863 "install help spec |
|
864 " |
|
865 self installHelpSpecInto:specClass |
|
866 ! |
|
867 |
|
868 doReload |
898 doReload |
869 "reload specification |
899 "reload the help dictionaries |
870 " |
900 " |
871 |oldSel model| |
901 |oldSel model| |
872 |
902 |
873 model := self listModel. |
903 model := self listModel. |
874 oldSel := model value. |
904 oldSel := model value. |
875 model value:nil. |
905 model value:nil. |
876 self helpSpecFrom:specClass. |
906 self helpSpecFrom:specClass. |
877 model value:oldSel. |
907 model value:oldSel. |
878 isModified := false. |
908 isModified := false. |
879 |
909 |
|
910 ! |
|
911 |
|
912 doSave |
|
913 "save the help dictionaries |
|
914 " |
|
915 self installHelpSpecsOnClass:specClass |
|
916 ! |
|
917 |
|
918 remove |
|
919 "remove selected help key |
|
920 " |
|
921 self listModel value: nil. |
|
922 self updateList. |
|
923 modifiedHolder notNil ifTrue: [modifiedHolder value:true] |
880 ! ! |
924 ! ! |
881 |
925 |
882 !UIHelpTool class methodsFor:'documentation'! |
926 !UIHelpTool class methodsFor:'documentation'! |
883 |
927 |
884 version |
928 version |