1361 #activeHelpKey: #editCopy |
1362 #activeHelpKey: #editCopy |
1362 #enabled: #valueOfCanCopy |
1363 #enabled: #valueOfCanCopy |
1363 #labelImage: #(#ResourceRetriever nil #copyIcon) |
1364 #labelImage: #(#ResourceRetriever nil #copyIcon) |
1364 ) |
1365 ) |
1365 #(#MenuItem |
1366 #(#MenuItem |
1366 #label: 'Paste' |
1367 #label: 'Paste With Layout' |
1367 #isButton: true |
1368 #isButton: true |
1368 #value: #pasteBuffer |
1369 #value: #pasteWithLayout |
1369 #activeHelpKey: #editPaste |
1370 #activeHelpKey: #editPaste |
1370 #enabled: #valueOfCanPaste |
1371 #enabled: #valueOfCanPasteWithKeepingLayout |
1371 #labelImage: #(#ResourceRetriever nil #pasteIcon) |
1372 #labelImage: #(#ResourceRetriever nil #pasteIcon) |
1372 ) |
1373 ) |
1373 #(#MenuItem |
1374 #(#MenuItem |
1374 #label: 'Delete' |
1375 #label: 'Delete' |
1375 #isButton: true |
1376 #isButton: true |
1896 ! |
1911 ! |
1897 |
1912 |
1898 openEditMenu |
1913 openEditMenu |
1899 "opens a menu editor on current widget |
1914 "opens a menu editor on current widget |
1900 " |
1915 " |
1901 |cls aspect editor| |
1916 |cls selectorOrMenu editor selectedSpec| |
1902 |
1917 |
1903 cls := self resolveName:specClass. |
1918 cls := self resolveName:specClass. |
1904 |
1919 |
1905 cls isNil ifTrue:[ |
1920 cls isNil ifTrue:[ |
1906 ^ self warn:'No application class defined yet!!' |
1921 ^ self warn:'No application class defined yet!!' |
1907 ]. |
1922 ]. |
1908 |
1923 |
1909 cls notNil ifTrue:[ |
1924 cls notNil ifTrue:[ |
1910 (aspect := self specTool specification menuSelector) notNil ifTrue:[ |
1925 (selectorOrMenu := self specTool specification menuSelector) notNil ifTrue:[ |
1911 aspect := aspect asSymbol |
1926 selectorOrMenu := selectorOrMenu asSymbol |
1912 ] ifFalse:[ |
1927 ] ifFalse:[ |
1913 "/ cg: q&d hack ... |
1928 "/ cg: q&d hack ... |
1914 |
1929 |
1915 aspect := treeView propertySelected. |
1930 (selectedSpec := treeView propertySelected) notNil ifTrue:[ |
1916 aspect notNil ifTrue:[ |
|
1917 Object errorSignal handle:[:ex | |
1931 Object errorSignal handle:[:ex | |
1918 aspect := nil. |
1932 selectorOrMenu := nil. |
1919 ] do:[ |
1933 ] do:[ |
1920 aspect := aspect view asMenu. |
1934 selectorOrMenu := selectedSpec view asMenu. |
1921 ] |
1935 ] |
1922 ]. |
1936 ]. |
1923 ]. |
1937 ]. |
1924 |
1938 |
1925 editor := MenuEditor new. |
1939 editor := MenuEditor new. |
1926 editor masterApplication:self. |
1940 editor masterApplication:self. |
1927 editor specClass: cls. |
1941 editor specClass: cls. |
1928 editor useHelpTool: self helpTool. |
1942 editor useHelpTool: self helpTool. |
1929 editor openModalOnClass:cls andSelector:aspect. |
1943 selectorOrMenu class ~~ Menu |
|
1944 ifTrue: [editor openModalOnClass:cls andSelector:selectorOrMenu] |
|
1945 ifFalse: [editor openModalOnMenu:selectorOrMenu]. |
1930 self helpTool updateList. |
1946 self helpTool updateList. |
1931 |
1947 |
1932 editor selectorName ~= aspect ifTrue:[ |
1948 editor selectorName ~= selectorOrMenu ifTrue:[ |
1933 editor didInstall ifTrue:[ |
1949 editor didInstall ifTrue:[ |
1934 self specTool specification menuSelector:editor selectorName asSymbol. |
1950 self specTool specification menuSelector:editor selectorName asSymbol. |
1935 self modifiedChannel value:true. |
1951 self modifiedChannel value:true. |
1936 self accept |
1952 self accept |
1937 ] |
1953 ] |
1978 self accept |
1994 self accept |
1979 ] |
1995 ] |
1980 ] |
1996 ] |
1981 ! |
1997 ! |
1982 |
1998 |
1983 openSubSpecGuiPainter |
1999 openSubSpecGUIPainter |
1984 "opens a GUI Painter on the current subspecification" |
2000 "opens a GUI Painter on the current subspecification" |
1985 |
2001 |
1986 |spec cls meta sel| |
2002 |spec cls meta sel| |
1987 |
2003 |
1988 spec := self specTool specification. |
2004 spec := self specTool specification. |
1989 cls := spec majorKey. |
2005 cls := spec majorKey. |
1990 cls isNil ifTrue:[ |
2006 cls isNil ifTrue:[ |
1991 cls := self specClass. |
2007 cls := specClass. |
1992 ]. |
2008 ]. |
1993 (cls isNil or:[(cls := self resolveName:cls) isNil]) ifTrue:[ |
2009 (cls isNil or:[(cls := self resolveName:cls) isNil]) ifTrue:[ |
1994 spec majorKey isNil ifTrue:[ |
2010 spec majorKey isNil ifTrue:[ |
1995 ^ self warn:'Cannot find class (no majorKey specified)'. |
2011 ^ self warn:'Cannot find class (no majorKey specified)'. |
1996 ]. |
2012 ]. |
2144 |
2160 |
2145 ! ! |
2161 ! ! |
2146 |
2162 |
2147 !UIPainter methodsFor:'private'! |
2163 !UIPainter methodsFor:'private'! |
2148 |
2164 |
|
2165 askForModification |
|
2166 "check interface modification |
|
2167 " |
|
2168 |
|
2169 self treeSelection. "accept modifications" |
|
2170 |
|
2171 (modified or: [self painter isModified or: [self helpTool isModified]]) |
|
2172 ifTrue: |
|
2173 [ |
|
2174 ((YesNoBox title:'Window Spec was modified!!') |
|
2175 noText:'Cancel'; |
|
2176 yesText:'Waste it and proceed'; |
|
2177 showAtPointer; |
|
2178 accepted) ifFalse: [^false]. |
|
2179 modified := false. |
|
2180 self painter resetModification |
|
2181 ]. |
|
2182 ^true |
|
2183 ! |
|
2184 |
2149 checkModified |
2185 checkModified |
2150 "check interface modification |
2186 "check interface modification |
2151 " |
2187 " |
2152 (self painter isModified or: [self helpTool isModified]) |
2188 (self isModified and: [self isModified or: [self helpTool isModified]]) |
2153 ifTrue: |
2189 ifTrue: |
2154 [ |
2190 [ |
2155 ((YesNoBox title:'Window Spec was modified!!') |
2191 ((YesNoBox title:'Window Spec was modified!!') |
2156 noText:'Cancel'; |
2192 noText:'Cancel'; |
2157 yesText:'Waste it and proceed'; |
2193 yesText:'Waste it and proceed'; |
2455 or: [self canPasteInto: treeView selectedNode contents view]]] |
2491 or: [self canPasteInto: treeView selectedNode contents view]]] |
2456 ]. |
2492 ]. |
2457 |
2493 |
2458 self valueOfCanCut value: canCutOrCopy. |
2494 self valueOfCanCut value: canCutOrCopy. |
2459 self valueOfCanCopy value: canCutOrCopy. |
2495 self valueOfCanCopy value: canCutOrCopy. |
2460 self valueOfCanPaste value: canPaste |
2496 self valueOfCanPaste value: canPaste. |
2461 |
2497 self valueOfCanPasteWithKeepingLayout value: (canPaste & self canKeepLayoutInSelection) |
2462 ! ! |
2498 ! ! |
2463 |
2499 |
2464 !UIPainter methodsFor:'startup / release'! |
2500 !UIPainter methodsFor:'startup / release'! |
2465 |
2501 |
2466 closeRequest |
2502 closeRequest |
2467 "close all windows open by builder |
2503 "close all windows open by builder |
2468 " |
2504 " |
2469 |
2505 |
2470 self checkModified ifFalse:[^self]. |
2506 self askForModification ifFalse:[^self]. |
2471 |
2507 |
2472 treeView model removeDependent:self. |
2508 treeView model removeDependent:self. |
2473 self painter release. |
2509 self painter release. |
2474 ColorMenu releaseResources. |
2510 ColorMenu releaseResources. |
2475 |
2511 |
2513 openInterface:aSymbol |
2549 openInterface:aSymbol |
2514 "open interfaces |
2550 "open interfaces |
2515 " |
2551 " |
2516 |painterView painter cls topView| |
2552 |painterView painter cls topView| |
2517 |
2553 |
|
2554 modified := false. |
|
2555 |
2518 aspects := IdentityDictionary new. |
2556 aspects := IdentityDictionary new. |
2519 |
2557 |
2520 aspects at:#classNameChannel put:( |
2558 aspects at:#classNameChannel put:( |
2521 (specClass notNil ifTrue:[specClass] |
2559 (specClass notNil ifTrue:[specClass] |
2522 ifFalse:['NewApplication']) asValue |
2560 ifFalse:['NewApplication']) asValue |
2758 ! |
2805 ! |
2759 |
2806 |
2760 doNew |
2807 doNew |
2761 "remove all components and associated resources |
2808 "remove all components and associated resources |
2762 " |
2809 " |
2763 self painter isModified ifTrue:[ |
2810 |
2764 (self confirm:'Edit a new window spec without saving current?') ifFalse:[ |
2811 self askForModification ifFalse: [^nil]. |
2765 ^ self |
2812 specClass := specSelector := nil. |
2766 ] |
|
2767 ]. |
|
2768 self painter removeAll. |
2813 self painter removeAll. |
|
2814 treeView canvas topView name: UIPainter defaultNameOfCanvas. |
|
2815 treeView canvas topView label: UIPainter defaultNameOfCanvas. |
|
2816 treeView selection:#(1). |
|
2817 self treeSelection. |
|
2818 self updateInfoLabel. |
2769 ! |
2819 ! |
2770 |
2820 |
2771 doPickAView |
2821 doPickAView |
2772 "pick a view and setup specifications |
2822 "pick a view and setup specifications |
2773 " |
2823 " |
2774 |painter view cls spec app| |
2824 |painter view cls spec app| |
2775 |
2825 |
2776 self painter isModified ifTrue:[ |
2826 self askForModification ifFalse: [^nil]. |
2777 (self confirm:'Pick another window spec without saving your modifications?') ifFalse:[ |
|
2778 ^ self |
|
2779 ] |
|
2780 ]. |
|
2781 |
2827 |
2782 (view := Screen current viewFromUser) notNil ifTrue:[ |
2828 (view := Screen current viewFromUser) notNil ifTrue:[ |
2783 view == Screen current rootView ifFalse:[ |
2829 view == Screen current rootView ifFalse:[ |
2784 painter := self painter. |
2830 painter := self painter. |
2785 spec := UISpecification fromView:view topView. |
2831 spec := UISpecification fromView:view topView. |
2786 |
2832 |
2787 "/ ok, got it |
2833 "/ ok, got it |
2788 |
2834 |
2789 (app := view application) notNil ifTrue:[ |
2835 " (app := view application) notNil ifTrue:[ |
2790 cls := app class |
2836 cls := app class |
2791 ] ifFalse:[ |
2837 ] ifFalse:[ |
2792 cls := view class |
2838 cls := view class |
2793 ]. |
2839 ]. |
2794 self setClass:cls selector:nil. |
2840 self setClass:cls selector:nil. |
2795 |
2841 " |
2796 painter setupFromSpec:spec. |
2842 painter setupFromSpec:spec. |
2797 ] |
2843 ] |
2798 ] |
2844 ]. |
2799 |
2845 |
2800 "Modified: / 1.11.1997 / 13:47:49 / cg" |
2846 self updateInfoLabel |
|
2847 |
2801 ! |
2848 ! |
2802 |
2849 |
2803 doRedefineMethods |
2850 doRedefineMethods |
2804 "redefine methods yes or no. If a method is defined in super class |
2851 "redefine methods yes or no. If a method is defined in super class |
2805 should the message be reinstalled ? |
2852 should the message be reinstalled ? |
2854 (ReadStream on:code) fileIn. |
2903 (ReadStream on:code) fileIn. |
2855 |
2904 |
2856 self helpTool installHelpSpecsOnClass:specClass. |
2905 self helpTool installHelpSpecsOnClass:specClass. |
2857 |
2906 |
2858 self updateInfoLabel. |
2907 self updateInfoLabel. |
|
2908 modified := false. |
2859 self painter resetModification. |
2909 self painter resetModification. |
2860 |
2910 |
2861 ((Smalltalk at: specClass asSymbol) class implements: specSelector) |
2911 ((Smalltalk at: specClass asSymbol) class implements: specSelector) |
2862 ifTrue: |
2912 ifTrue: |
2863 [ |
2913 [ |
2869 |
2919 |
2870 doSaveAs |
2920 doSaveAs |
2871 "launch a dialog to define class, superclass and method" |
2921 "launch a dialog to define class, superclass and method" |
2872 |
2922 |
2873 |resourceMessage| |
2923 |resourceMessage| |
|
2924 |
|
2925 self treeSelection. "ask for modification" |
2874 |
2926 |
2875 (resourceMessage := ResourceSelectionBrowser |
2927 (resourceMessage := ResourceSelectionBrowser |
2876 request: 'Save In Class' |
2928 request: 'Save In Class' |
2877 onSuperclass: #Object |
2929 onSuperclass: #Object |
2878 andClass: specClass ? #ApplicationModel |
2930 andClass: specClass ? #ApplicationModel |
2893 doStartApplication |
2945 doStartApplication |
2894 "start current edited application |
2946 "start current edited application |
2895 " |
2947 " |
2896 |cls app infoMessage| |
2948 |cls app infoMessage| |
2897 |
2949 |
|
2950 self treeSelection. "accept modifications" |
|
2951 |
2898 (specClass isNil or:[specSelector size < 2]) ifTrue:[ |
2952 (specClass isNil or:[specSelector size < 2]) ifTrue:[ |
2899 self painter isModified ifTrue:[ |
2953 self painter isModified ifTrue:[ |
2900 infoMessage := 'Class and selector must be defined,\and the window spec must be saved first!!' withCRs. |
2954 infoMessage := 'Class and selector must be defined,\and the window spec must be saved first!!' withCRs. |
2901 ] ifFalse:[ |
2955 ] ifFalse:[ |
2902 infoMessage := 'No class and selector defined!!'. |
2956 infoMessage := 'No class and selector defined!!'. |
2949 "create the window specification but do not write to application; instead |
3003 "create the window specification but do not write to application; instead |
2950 open a view |
3004 open a view |
2951 " |
3005 " |
2952 |code v| |
3006 |code v| |
2953 |
3007 |
|
3008 self treeSelection. "accept modifications" |
|
3009 |
2954 code := self painter generateWindowSpecMethodSource. |
3010 code := self painter generateWindowSpecMethodSource. |
2955 |
3011 |
2956 v := CodeView open. |
3012 v := CodeView open. |
2957 v contents:code. |
3013 v contents:code. |
2958 v label:'windowSpec'. |
3014 v label:'windowSpec'. |
2959 |
3015 |
2960 ! |
3016 ! |
2961 |
3017 |
2962 loadFromMessage: aMessage |
3018 loadFromMessage: aMessage |
2963 |
3019 |
2964 ((aMessage size > 0) and: [self checkModified]) |
3020 ((aMessage size > 0) and: [self askForModification]) |
2965 ifTrue: |
3021 ifTrue: |
2966 [ |
3022 [ |
2967 |readStream aClass aSelector| |
3023 |readStream aClass aSelector| |
2968 readStream := aMessage readStream. |
3024 readStream := aMessage readStream. |
2969 (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil |
3025 (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil |
2997 |
3053 |
2998 superclass isNil ifTrue:[ |
3054 superclass isNil ifTrue:[ |
2999 self warn:'No class named ' , specSuperclass , ' exists!!'. |
3055 self warn:'No class named ' , specSuperclass , ' exists!!'. |
3000 ^ false. |
3056 ^ false. |
3001 ]. |
3057 ]. |
3002 (self confirm:'Create ' , specClass , '?') ifTrue:[ |
3058 (self confirm:'Create class ' , specClass asBoldText, '?') ifTrue:[ |
3003 superclass subclass:(specClass asSymbol) |
3059 superclass subclass:(specClass asSymbol) |
3004 instanceVariableNames:'' |
3060 instanceVariableNames:'' |
3005 classVariableNames:'' |
3061 classVariableNames:'' |
3006 poolDictionaries:'' |
3062 poolDictionaries:'' |
3007 category:'Applications'. |
3063 category:'Applications'. |
3292 self canvas subViews copy do:[:aView| |
3352 self canvas subViews copy do:[:aView| |
3293 (aView isKindOf:InputView) ifFalse:[aView destroy] |
3353 (aView isKindOf:InputView) ifFalse:[aView destroy] |
3294 ]. |
3354 ]. |
3295 model root name: UIPainter defaultNameOfCanvas asBoldText. |
3355 model root name: UIPainter defaultNameOfCanvas asBoldText. |
3296 model root children:(OrderedCollection new). |
3356 model root children:(OrderedCollection new). |
3297 model recomputeList. |
3357 model recomputeList. |
3298 self selection:nil. |
|
3299 |
|
3300 |
3358 |
3301 ! |
3359 ! |
3302 |
3360 |
3303 removeView:aView |
3361 removeView:aView |
3304 "remove a view |
3362 "remove a view |