158 !UIPainterView methodsFor:'copy & cut & paste'! |
177 !UIPainterView methodsFor:'copy & cut & paste'! |
159 |
178 |
160 copySelection |
179 copySelection |
161 "copy the selection into the cut&paste-buffer |
180 "copy the selection into the cut&paste-buffer |
162 " |
181 " |
163 |specs coll| |
182 |specs coll sel| |
|
183 |
|
184 sel := treeView selection. |
164 |
185 |
165 coll := self minSetOfSuperViews:(self selection). |
186 coll := self minSetOfSuperViews:(self selection). |
166 |
187 |
167 coll notNil ifTrue:[ |
188 coll notNil ifTrue:[ |
168 self select:nil. |
189 self select:nil. |
169 specs := coll collect:[:aView| self fullSpecFor:aView ]. |
190 specs := coll collect:[:aView| self fullSpecFor:aView ]. |
170 self setSelection:specs |
191 self setSelection:specs. |
171 ]. |
192 treeView selection: sel |
172 |
193 ]. |
173 |
194 |
174 ! |
195 |
175 |
196 ! |
176 deleteSelection |
197 |
177 "delete the selection; copy the selection into the cut&paste-buffer |
198 cutSelection |
|
199 "cut the selection into the cut&paste-buffer |
178 and open a transaction |
200 and open a transaction |
179 " |
201 " |
180 |specs coll| |
202 |specs coll| |
181 |
203 |
182 coll := self minSetOfSuperViews:(self selection). |
204 coll := self minSetOfSuperViews:(self selection). |
604 |cls code skip menuSelector protoSpec thisCode| |
649 |cls code skip menuSelector protoSpec thisCode| |
605 |
650 |
606 code := ''. |
651 code := ''. |
607 |
652 |
608 className isNil ifTrue:[ |
653 className isNil ifTrue:[ |
609 self warn:'set the class first'. |
654 self warn:'Set first the class!!'. |
610 ^ code |
655 ^ code |
611 ]. |
656 ]. |
612 cls := self resolveName:className. |
657 |
|
658 (cls := self resolveName:className) isNil ifTrue:[ |
|
659 self warn:'Class ', className asString, ' does not exist!!'. |
|
660 ^ code |
|
661 ]. |
613 |
662 |
614 treeView propertiesDo:[:aProp| |
663 treeView propertiesDo:[:aProp| |
615 |modelSelector menuSelector| |
664 |modelSelector menuSelector| |
616 |
665 |
617 protoSpec := aProp spec. |
666 protoSpec := aProp spec. |
618 |
667 |
619 (modelSelector := aProp model) notNil ifTrue:[ |
668 (modelSelector := aProp model) notNil ifTrue:[ |
620 (modelSelector isArray not) ifTrue:[ |
669 self generateCodeFrom:(Array with:modelSelector) in:cls |
621 (cls implements:modelSelector asSymbol) ifFalse:[ |
670 do:[:aSel| |
622 skip := false. |
671 skip := false. |
|
672 |
623 (cls isSubclassOf:SimpleDialog) ifTrue:[ |
673 (cls isSubclassOf:SimpleDialog) ifTrue:[ |
624 skip := SimpleDialog implements:modelSelector asSymbol |
674 skip := SimpleDialog implements:aSel asSymbol |
625 ]. |
675 ]. |
|
676 |
626 skip ifFalse:[ |
677 skip ifFalse:[ |
627 "/ kludge .. |
678 "/ kludge .. |
628 (protoSpec isKindOf:ActionButtonSpec) ifTrue:[ |
679 (protoSpec isKindOf:ActionButtonSpec) ifTrue:[ |
629 thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
680 thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
630 ] ifFalse:[ |
681 ] ifFalse:[ |
631 thisCode := (self generateAspectMethodFor:modelSelector spec:protoSpec inClass:cls). |
682 thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
632 ]. |
683 ]. |
633 code := code , thisCode |
684 code := code, thisCode |
634 ]. |
685 ] |
635 ]. |
686 ] |
636 ]. |
687 ]. |
637 ]. |
688 |
638 |
689 self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
639 aProp spec aspectSelectors do:[:aSel| |
690 do:[:aSel| |
640 (aSel isArray not) ifTrue:[ |
|
641 (cls implements:aSel asSymbol) ifFalse:[ |
|
642 thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
691 thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
643 code := code , thisCode |
692 code := code , thisCode |
644 ] |
693 ]. |
645 ] |
694 |
646 ]. |
695 self generateCodeFrom:(aProp spec actionSelectors) in:cls |
647 aProp spec actionSelectors do:[:aSel| |
696 do:[:aSel| |
648 (aSel isArray not) ifTrue:[ |
|
649 (cls implements:aSel asSymbol) ifFalse:[ |
|
650 thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
697 thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
651 code := code , thisCode |
698 code := code , thisCode |
652 ] |
699 ]. |
653 ] |
700 |
654 ]. |
701 self generateCodeFrom:(aProp spec valueSelectors) in:cls |
655 aProp spec valueSelectors do:[:aSel| |
702 do:[:aSel| |
656 (aSel isArray not) ifTrue:[ |
703 "/ uppercase: - assume its a globals name. |
657 "/ uppercase: - assume its a globals name. |
704 aSel first isUppercase ifFalse:[ |
658 aSel first isUppercase ifFalse:[ |
|
659 (cls implements:aSel asSymbol) ifFalse:[ |
|
660 thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
705 thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
661 code := code , thisCode |
706 code := code , thisCode |
662 ] |
707 ] |
663 ] |
708 ]. |
|
709 ]. |
|
710 |
|
711 ^ code |
|
712 |
|
713 ! |
|
714 |
|
715 generateCodeFrom:aListOfSelectors in:aClass do:aBlock |
|
716 |
|
717 self class redefineMethods ifTrue:[ |
|
718 aListOfSelectors do:[:aSelector| |
|
719 (aSelector isArray or:[aClass implements:aSelector]) ifFalse:[ |
|
720 aBlock value:aSelector |
664 ] |
721 ] |
665 ] |
722 ] |
666 ]. |
723 ] ifFalse:[ |
667 |
724 aListOfSelectors do:[:aSelector| |
668 ^ code |
725 (aSelector isArray or:[aClass canUnderstand:aSelector]) ifFalse:[ |
|
726 aBlock value:aSelector |
|
727 ] |
|
728 ] |
|
729 ] |
|
730 |
|
731 |
669 ! |
732 ! |
670 |
733 |
671 generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
734 generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
672 ^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
735 ^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
673 selectorSpec , '\' , |
736 selectorSpec , '\' , |