CodeGeneratorTool.st
author Claus Gittinger <cg@exept.de>
Wed, 07 May 2003 16:52:53 +0200
changeset 4867 269d62a1ed27
parent 4590 2447e35a81d4
child 4908 1e145ba4eab7
permissions -rw-r--r--
method category rename
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:libtool' }"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
Object subclass:#CodeGeneratorTool
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'Interface-Browsers'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
3719
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    10
!CodeGeneratorTool class methodsFor:'documentation'!
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    11
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    12
documentation
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    13
"
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    14
    extracted code generation stuff from old and newBrowser.
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    15
    There is probably more to gome...
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    16
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    17
    [author:]
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    18
        Claus Gittiner
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    19
"
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    20
! !
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!CodeGeneratorTool class methodsFor:'code generation'!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    25
    ^ self
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    26
        createAccessMethodsFor:aCollectionOfVarNames 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    27
        in:aClass 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    28
        withChange:withChange 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    29
        asValueHolder:asValueHolder 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    30
        readersOnly:readersOnly 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    31
        writersOnly:writersOnly 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    32
        lazyInitialization:false
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    33
!
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    34
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    35
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
    "workhorse for creating access methods for instvars."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    |classesClassVars|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    classesClassVars := aClass theNonMetaclass allClassVarNames.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    aCollectionOfVarNames do:[:name |
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    43
        |source varType methodName defaultMethodName|
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
        varType := (classesClassVars includes:name) 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
                        ifTrue:['static'] 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
                        ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
                            (aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        methodName := name.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
        name first isUppercase ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
            methodName := methodName asLowercaseFirst. 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    55
        "/ the GETTER
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        writersOnly ifFalse:[
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    57
            lazyInitialization ifTrue:[
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    58
                defaultMethodName := 'default' , name asUppercaseFirst.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    59
            ].
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    60
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
            "check, if method is not already present"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
            (aClass includesSelector:(methodName asSymbol)) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
                asValueHolder ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
                    source := methodName
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
                               , '\    "return/create the ''%2'' value holder (automatically generated)"\\' 
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    66
                               , '    %2 isNil ifTrue:[\'.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    67
                    lazyInitialization ifTrue:[
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    68
                        source := source
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    69
                                   , '        %2 := self class %3 asValue.\'.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    70
                    ] ifFalse:[
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    71
                        source := source
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    72
                                   , '        %2 := ValueHolder new.\'.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    73
                    ].
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    74
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
                    withChange ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
                    source := source
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
                               , '        %2 addDependent:self.\'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
                    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
                    source := source
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
                               , '    ].\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
                               , '    ^ %2'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
                ] ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
                    source := methodName
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    84
                               , '\    "return the value of the %1 variable ''%2'' (automatically generated)"\\'. 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    85
                    lazyInitialization ifTrue:[
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    86
                        source := source
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    87
                                    , '    %2 isNil ifTrue:[\'
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    88
                                    , '        %2 := self class %3.\'
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    89
                                    , '    ].\'
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    90
                                    , '    ^ %2'.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    91
                    ] ifFalse:[
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    92
                        source := source
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    93
                                    , '    ^ %2'.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    94
                    ].
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
                ].
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    96
                source := (source bindWith:varType with:name with:defaultMethodName) withCRs.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
                self compile:source forClass:aClass inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
            ] ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
                Transcript showCR:'method ''', methodName , ''' already present'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
            ].
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   101
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   102
            "/ default for lazy on class side
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   103
            lazyInitialization ifTrue:[
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   104
                (aClass class includesSelector:(defaultMethodName asSymbol)) ifFalse:[
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   105
                    source := defaultMethodName
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   106
                               , '\    "default value for the ''%2'' instance variable (automatically generated)"\\' 
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   107
                               , '    self halt:''unfinished code''.\'
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   108
                               , '    ^ nil.'.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   109
                    source := (source bindWith:varType with:name) withCRs.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   110
                    self compile:source forClass:aClass class inCategory:'defaults'.
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   111
                ].
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   112
            ].
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
   115
        "/ the SETTER
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
        readersOnly ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
            (aClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
                asValueHolder ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
                    source := methodName
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
                              , ':something\    "set the ''%2'' value holder'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
                    withChange ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
                        source := source
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
                                  , ' (automatically generated)"\\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
                                  , '    |oldValue newValue|\\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
                                  , '    %2 notNil ifTrue:[\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
                                  , '        oldValue := %2 value.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
                                  , '        %2 removeDependent:self.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
                                  , '    ].\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
                                  , '    %2 := something.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
                                  , '    %2 notNil ifTrue:[\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
                                  , '        %2 addDependent:self.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
                                  , '    ].\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
                                  , '    newValue := %2 value.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
                                  , '    oldValue ~~ newValue ifTrue:[\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
                                  , '        self update:#value with:newValue from:%2.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
                                  , '    ].\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
                    ] ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
                        source := source 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
                                  , ' (automatically generated)"\\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
                                  , '    %2 := something.'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
                    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
                ] ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
                    source := methodName
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
                              , ':something\    "set the value of the %1 variable ''%2'''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
                    withChange ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                        source := source
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
                                  , ' and send a change notification (automatically generated)"\\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
                                  , '    (%2 ~~ something) ifTrue:[\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                                  , '        %2 := something.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
                                  , '        self changed:#%2.\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
                                  , '     ].\'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
                    ] ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
                        source := source 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
                                  , ' (automatically generated)"\\'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                                  , '    %2 := something.'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
                    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
                ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                source := (source bindWith:varType with:name) withCRs.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                    compile:source 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                    forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
                    inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
            ] ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
                Transcript showCR:'method ''', methodName , ':'' already present'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
            ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
createApplicationCodeFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    "create an empty application framework"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    |nonMetaClass metaClass className txt isDialog|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    nonMetaClass := aClass theNonMetaclass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    metaClass := aClass theMetaclass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    className := nonMetaClass name.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    isDialog := (nonMetaClass isSubclassOf:SimpleDialog).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    "/ add a windowSpec method for an empty applicationWindow,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    "/ with a menuPanel.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    (metaClass includesSelector:#windowSpec) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
        isDialog ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
            txt := self initialWindowSpecMethodSourceForDialogs.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
        ] ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
            txt := self initialWindowSpecMethodSourceForApplications.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
            compile:(txt bindWith:className)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
            forClass:metaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
            inCategory:'interface specs'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
        "/ add a topMenu method 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
        (metaClass includesSelector:#mainMenu) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
            txt := self initialMenuSpecMethodSourceForApplications.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
                compile:(txt bindWith:className)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
                forClass:metaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
                inCategory:'menu specs'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    (metaClass includesSelector:#postBuildWith:) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
        txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
'postBuildWith:aBuilder
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    "This is a hook method generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
     It will be invoked during the initialization of your app/dialog,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
     after all of the visual components have been built, 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
     but BEFORE the top window is made visible.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
     Add any app-specific actions here (reading files, setting up values etc.)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
     See also #postOpenWith:, which is invoked after opening."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    "/ add any code here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    ^ super postBuildWith:aBuilder
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
        self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
            compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
            forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
            inCategory:'initialization & release'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    (metaClass includesSelector:#postOpenWith:) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
        txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
'postOpenWith:aBuilder
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    "This is a hook method generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
     It will be invoked right after the applications window has been opened.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
     Add any app-specific actions here (starting background processes etc.).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
     See also #postBuildWith:, which is invoked before opening."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "/ add any code here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    ^ super postOpenWith:aBuilder
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
        self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
            compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
            forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
            inCategory:'initialization & release'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
        (metaClass includesSelector:#closeRequest) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
'closeRequest
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    "This is a hook method generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
     It will be invoked when your app/dialog-window is about to be
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
     closed (this method has a chance to suppress the close).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
     See also #closeDownViews, which is invoked when the close is really done."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    "/ change the code below as required ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    "/ Closing can be suppressed, by simply returning.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    "/ The ''super closeRequest'' at the end will initiate the real closeDown
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    ("self hasUnsavedChanges" true) ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
        (self confirm:(resources string:''Close without saving ?'')) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
            ^ self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
        ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    ^ super closeRequest
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
                inCategory:'initialization & release'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
        (metaClass includesSelector:#closeDownViews) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
'closeDownViews
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    "This is a hook method generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
     It will be invoked when your app/dialog-window is really closed.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
     See also #closeDownViews, which is invoked before and may suppress the close
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
     or ask the user for confirmation."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "/ change the code below as required ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    "/ This should cleanup any leftover resources
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    "/ (for example, temporary files)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    "/ super closeRequest will initiate the closeDown
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    "/ add your code here
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    "/ do not remove the one below ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    ^ super closeDownViews
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
                inCategory:'initialization & release'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    isDialog ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
        (metaClass includesSelector:#accept) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
'closeAccept
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    "This is a hook method generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
     It will be invoked when your dialog-window is closed with OK."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
    "/ add any actions as required here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    Transcript showCR:''dialog accepted''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "/ do not remove the one below ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    ^ super closeAccept
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
                inCategory:'user actions'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
        (metaClass includesSelector:#menuNew) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
'menuNew
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    "This method was generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
     It will be invoked when the menu-item ''new'' is selected."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    "/ change below and add any actions as required here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    self warn:''no action for ''''new'''' available.''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
                inCategory:'menu actions'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
        (metaClass includesSelector:#menuOpen) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
'menuOpen
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    "This method was generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
     It will be invoked when the menu-item ''open'' is selected."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
    "/ change below and add any actions as required here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    self warn:''no action for ''''open'''' available.''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
                inCategory:'menu actions'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
        (metaClass includesSelector:#menuSave) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
'menuSave
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    "This method was generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
     It will be invoked when the menu-item ''save'' is selected."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    "/ change below and add any actions as required here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    self warn:''no action for ''''save'''' available.''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
                inCategory:'menu actions'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
        (metaClass includesSelector:#menuSaveAs) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
'menuSaveAs
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    "This method was generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
     It will be invoked when the menu-item ''saveAs'' is selected."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    "/ change below and add any actions as required here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
    self warn:''no action for ''''saveAs'''' available.''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
                inCategory:'menu actions'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
        (metaClass includesSelector:#openDocumentation) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
'openDocumentation
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
    "This method was generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
     It will be invoked when the menu-item ''help-documentation'' is selected."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    "/ change below as required ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    "/ to open an HTML viewer on some document (under ''doc/online/<language>/'' ):
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
    HTMLDocumentView openFullOnDocumentationFile:''TOP.html''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
    "/ add application-specific help files under the ''doc/online/<language>/help/appName''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    "/ directory, and open a viewer with:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    "/ HTMLDocumentView openFullOnDocumentationFile:''help/<MyApplication>/TOP.html''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
                inCategory:'menu actions'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
    isDialog ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
        (metaClass includesSelector:#openAboutThisApplication) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
            txt :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
'openAboutThisApplication
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
    "This method was generated by the Browser.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
     It will be invoked when the menu-item ''help-about'' is selected."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    "/ could open a customized aboutBox here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
    super openAboutThisApplication
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
            self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
                compile:txt
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
                forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
                inCategory:'menu actions'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
    "Modified: / 1.2.1998 / 16:10:03 / cg"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
3804
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
   428
createClassResponsibleProtocolFor:aClass
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
   429
    "create stubs for the required protocol"
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
   430
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
   431
    self privCreateClassResponsibleProtocolFor:aClass theNonMetaclass.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
   432
    self privCreateClassResponsibleProtocolFor:aClass theMetaclass.
3804
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
   433
!
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
   434
4351
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   435
createClassTypeTestMethodsIn:aClass
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   436
    "create a #isXXX test methods
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   437
     (I'm tired of typing)"
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   438
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   439
    |subClasses code|
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   440
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   441
    subClasses := aClass subclasses.
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   442
    subClasses do:[:eachSubClass |
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   443
        |nm selector|
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   444
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   445
        nm := eachSubClass nameWithoutPrefix.
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   446
        selector := 'is' , nm.
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   447
        (aClass includesSelector:selector) ifFalse:[
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   448
            code := (selector , '\    ^ false') withCRs.
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   449
            self 
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   450
                compile:code
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   451
                forClass:aClass 
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   452
                inCategory:'testing'.
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   453
        ].
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   454
        (eachSubClass includesSelector:selector) ifFalse:[
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   455
            code := (selector , '\    ^ true') withCRs.
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   456
            self 
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   457
                compile:code
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   458
                forClass:eachSubClass 
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   459
                inCategory:'testing'.
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   460
        ].
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   461
    ].
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   462
!
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
   463
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
createDocumentationMethodsFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
    "create empty documentation methods"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
    |cls|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
    cls := aClass theMetaclass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
    self createVersionMethodFor:cls.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
    self createCopyrightMethodFor:aClass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
    self createDocumentationMethodFor:aClass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
    self createInitialHistoryMethodFor:aClass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
createStandardInitializationMethodsIn:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
    "create a #new and #initialize methods
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
    |code initializer m|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
    (aClass includesSelector:#'initialize') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
        code :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
'initialize
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
    "Invoked when a new instance is created."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
    super initialize.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
    "/ please change as required (and remove this comment)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
        m := aClass responseTo:#initialize.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
        m notNil ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
            m messagesSent size == 0 ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
                "/ inherits an empty initialize.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
                code :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
'initialize
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
    "Invoked when a new instance is created."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    "/ please change as required (and remove this comment)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
    "/ super initialize.   -- commented since inherited method does nothing
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
            ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
        aClass instVarNames do:[:eachInstVar |
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
            initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
            code := code , ('    ' , eachInstVar , ' := ' , initializer , Character cr).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
            compile:code
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
            forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
            inCategory:'initialization'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
    (aClass class includesSelector:#'new') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
        m := aClass class responseTo:#new.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
        m notNil ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
            (m sends:#initialize) ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
                (self confirm:'The inherited #new method already seems to invoke #initialize. Redefine ?')
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
                ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
                    ^ self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
                ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
            ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
        code :=
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
'new
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    ^ self basicNew initialize.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
            compile:code
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
            forClass:aClass class 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
            inCategory:'instance creation'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
    "Created: / 11.10.2001 / 22:18:55 / cg"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
createTestCaseSampleCodeFor:aClass
4590
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   546
    "create an (almost) empty testCase class"
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
    |nonMetaClass metaClass|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    nonMetaClass := aClass theNonMetaclass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
    metaClass := aClass theMetaclass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
    "/ className := nonMetaClass name.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
    ( nonMetaClass includesSelector:#test1 ) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
        self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
'test1
4590
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   558
    "This is a demonstration testCase - it is meant to be removed eventually.
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   559
     This testCase will PASS.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
     Double click on the TestCase class or open a TestRunner to see me checking...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
     - please add more methods like this..."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
    |o|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
    o := Array new:2.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
    self assert: ( o size == 2 ).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
    self should: [ o at:0 ] raise:Error.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    self shouldnt: [ o at:1 ] raise:Error.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
     self run:#test1
4590
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   572
     self new test1
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   573
    "
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   574
'
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   575
            forClass:nonMetaClass 
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   576
            inCategory:'tests'.
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   577
    ].
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   578
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   579
    ( nonMetaClass includesSelector:#test2 ) ifFalse:[
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   580
        self
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   581
            compile:
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   582
'test2
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   583
    "This is a demonstration testCase - it is meant to be removed eventually..
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   584
     This testCase WILL FAIL.
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   585
     Double click on the TestCase class or open a TestRunner to see me checking...
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   586
     - please add more methods like this..."
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   587
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   588
    |o|
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   589
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   590
    o := Array new:2.
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   591
    self assert: ( o size == 3 ).
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   592
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   593
    "
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   594
     self run:#test2
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   595
     self new test2
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   596
    "
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   597
'
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   598
            forClass:nonMetaClass 
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   599
            inCategory:'tests'.
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   600
    ].
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   601
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   602
    ( nonMetaClass includesSelector:#test3 ) ifFalse:[
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   603
        self
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   604
            compile:
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   605
'test3
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   606
    "This is a demonstration testCase - it is meant to be removed eventually..
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   607
     This testCase WILL generate an ERROR.
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   608
     Double click on the TestCase class or open a TestRunner to see me checking...
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   609
     - please add more methods like this..."
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   610
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   611
    |o|
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   612
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   613
    o := Array new:2.
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   614
    self assert: ( o foo ).
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   615
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   616
    "
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   617
     self run:#test3
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   618
     self new test3
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
            forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
            inCategory:'tests'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
    ( nonMetaClass includesSelector:#setUp ) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
        self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
'setUp
4590
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   629
    "common setup - invoked before testing."
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    super setUp
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
            forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
            inCategory:'initialize / release'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
    ( nonMetaClass includesSelector:#tearDown ) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
        self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
'tearDown
4590
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   641
    "common cleanup - invoked after testing."
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    super tearDown
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
            forClass:nonMetaClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
            inCategory:'initialize / release'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
    "create acceptVisitor: in visitedClass and acceptXXX in visitorClass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
    |sel|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
    visitedClass isMeta ifTrue:[self halt].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    visitorClass isMeta ifTrue:[self halt].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
    sel := ('visit' , visitedClass nameWithoutPrefix , ':').
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
    self createAcceptVisitorMethod:sel in:visitedClass.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
    (visitorClass includesSelector:sel) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
(('%1anObject 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
    "dispatched back from the visited %2-object (visitor pattern)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
    "fall back to general object-case - please change as required"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
    ^ self visitObject:anObject
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
') bindWith:sel with:visitedClass nameWithoutPrefix asLowercaseFirst)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
            forClass:visitorClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
            inCategory:'visiting'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
    (visitorClass includesSelector:#'visitObject:') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
('visitObject:anObject 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
    "dispatched back from the visited objects (visitor pattern)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
    "general fallBack - please change as required"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
    self halt:''not yet implemented''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
')
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
            forClass:visitorClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
            inCategory:'visiting'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
    (visitorClass includesSelector:#'visit:') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
('visit:anObject 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
    "visit anObject (visitor pattern).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
     The object should call back one of my visitXXXX methods."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
    ^ anObject acceptVisitor:self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
')
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
            forClass:visitorClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
            inCategory:'visiting'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
    ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
initialMenuSpecMethodSourceForApplications
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
'mainMenu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
    "This resource specification was automatically generated by the CodeGeneratorTool."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
    "Do not manually edit this!! If it is corrupted,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
     the MenuEditor may not be able to read the specification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
     MenuEditor new openOnClass:%1 andSelector:#mainMenu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
    <resource: #menu>
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
    ^ #(#Menu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
           #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
             #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
                #label: ''File''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
                #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
                #submenu: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
                 #(#Menu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
                     #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
                          #label: ''New''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
                          #value: #menuNew
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
                          #label: ''Open...''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
                          #value: #menuOpen
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
                          #label: ''Save''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
                          #value: #menuSave
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
                          #label: ''Save As...''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
                          #value: #menuSaveAs
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
                          #label: ''Exit''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
                          #value: #closeRequest
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
                    ) nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
                    nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
                )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
            )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
             #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
                #label: ''Help''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
                #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
                #startGroup: #right
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
                #submenu: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
                 #(#Menu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
                     #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
                          #label: ''Documentation''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
                          #value: #openDocumentation
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
                          #label: ''About this Application''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
                          #value: #openAboutThisApplication
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
                    ) nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
                    nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
                )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
            )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
          ) nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
          nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
initialWindowSpecMethodSourceForApplications
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
'windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
    "This resource specification was automatically generated by the CodeGeneratorTool."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
    "Do not manually edit this!! If it is corrupted,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
     the UIPainter may not be able to read the specification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
     UIPainter new openOnClass:%1 andSelector:#windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
    <resource: #canvas>
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
    ^ #(#FullSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
          #window: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
           #(#WindowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
              #name: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
              #layout: #(#LayoutFrame 204 0 162 0 503 0 461 0)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
              #label: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
              #min: #(#Point 10 10)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
              #max: #(#Point 1024 768)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
              #bounds: #(#Rectangle 204 162 504 462)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
              #menu: #mainMenu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
              #usePreferredExtent: false
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
          #component: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
           #(#SpecCollection
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
              #collection: #()
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
initialWindowSpecMethodSourceForDialogs
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
'windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
    "This resource specification was automatically generated by the CodeGeneratorTool."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
    "Do not manually edit this!! If it is corrupted,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
     the UIPainter may not be able to read the specification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
     UIPainter new openOnClass:%1 andSelector:#windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
    <resource: #canvas>
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
       #(#FullSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
          #window: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
           #(#WindowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
              #name: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
              #layout: #(#LayoutFrame 221 0 118 0 520 0 417 0)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
              #level: 0
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
              #label: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
              #min: #(#Point 10 10)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
              #max: #(#Point 1024 768)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
              #bounds: #(#Rectangle 221 118 521 418)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
              #usePreferredExtent: false
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
          #component: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
           #(#SpecCollection
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
              #collection: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
               #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
                 #(#HorizontalPanelViewSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
                    #name: ''buttonPanel''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
                    #layout: #(#LayoutFrame 0 0.0 -45 1 0 1.0 0 1.0)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
                    #component: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
                     #(#SpecCollection
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
                        #collection: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
                         #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
                          #(#ActionButtonSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
                             #name: ''cancelButton''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
                             #label: ''Cancel''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
                             #tabable: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
                             #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
                             #model: #cancel
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
                             #extent: #(#Point 125 22)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
                           )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
                           #(#ActionButtonSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
                              #name: ''okButton''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
                              #label: ''OK''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
                              #tabable: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
                              #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
                              #isDefault: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
                              #model: #accept
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
                              #extent: #(#Point 125 22)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
                          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
                        )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
                    )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
                    #reverseOrderIfOKAtLeft: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
                    #horizontalLayout: #spreadSpaceMax
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
                    #verticalLayout: #center
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
                    #horizontalSpace: 3
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
                    #verticalSpace: 3
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
                )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
              )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
! !
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
!CodeGeneratorTool class methodsFor:'code generation - individual methods'!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
createAcceptVisitorMethod:selector in:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
    "create an acceptVisitor: method
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
    aClass isMeta ifTrue:[self halt].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
    (aClass includesSelector:#'acceptVisitor:') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
(('acceptVisitor:aVisitor 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
    "Double dispatch back to the visitor, passing my type encoded in
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
     the selector (visitor pattern)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
    "stub code automatically generated - please change if required"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
    ^ aVisitor %1self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
') bindWith:selector)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
            forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
            inCategory:'visiting'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
    ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
createAcceptVisitorMethodIn:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
    "create an acceptVisitor: method
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   924
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
        createAcceptVisitorMethod:('visit' , aClass nameWithoutPrefix , ':') asSymbol
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
        in:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   931
createCopyrightMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   932
    "add copyright method containing your/your companies
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
     copyright template but only if not already present.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   934
     this is only added, if specified in the 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   935
     COPYRIGHT_TEMPLATE_FILE resources."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   936
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
    |fn txt|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
    (aClass includesSelector:#copyright) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
        fn := SystemBrowser classResources at:#'COPYRIGHT_TEMPLATE_FILE' default:nil.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
        fn notNil ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
            fn := fn asFilename.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
            fn exists ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
                txt := fn contents asString
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
            ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
        txt notNil ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
            txt := txt bindWith:(Date today year).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
            self compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
'copyright
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
' , txt , '
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
'             forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
              inCategory:'documentation'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   957
        ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
createDocumentationMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
    "add documentation method containing doc template
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
     but only if not already present."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
    |userName loginName hostName emailAddress|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
    (aClass includesSelector:#documentation) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
        userName := OperatingSystem getFullUserName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   969
        loginName := OperatingSystem getLoginName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
        hostName := OperatingSystem getHostName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
        emailAddress := loginName , '@' , hostName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
        self compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
'documentation
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
    documentation to be added.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
    [author:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
        ' , userName 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
          , ' (' , emailAddress , ')' , '
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
    [instance variables:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
    [class variables:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
    [see also:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
'             forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
              inCategory:'documentation'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
createExamplesMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
    "add examples method containing examples template
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
     but only if not already present."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
    |fragment|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
    (aClass includesSelector:#examples) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
        (aClass theNonMetaclass isSubclassOf:ApplicationModel) ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
            fragment := '  Starting the application:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
                                                                [exBegin]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
    ' , aClass theNonMetaclass name , ' open
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
                                                                [exEnd]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
        ] ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
            fragment := ''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
'examples
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
' , fragment , '
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
  more examples to be added:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
                                                                [exBegin]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
    ... add code fragment for 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
    ... executable example here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
                                                                [exEnd]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
'                   
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
            forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
            inCategory:'documentation'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
3822
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1029
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1030
    |imageStoreStream mthd imageKey category|
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1031
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1032
    anImage storeOn: (imageStoreStream := WriteStream on: '').
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1033
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1034
    "/ if that method already exists, do not overwrite the category
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1035
    category := 'image specs'.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1036
    (mthd := aClass compiledMethodAt:sel) notNil ifTrue:[
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1037
        category := mthd category.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1038
    ].
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1039
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1040
    imageKey :=  (aClass name, ' ', sel) asSymbol.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1041
    Icon constantNamed: imageKey put:nil.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1042
    aClass
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1043
        compile: ((sel,
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1044
            '\', comment,
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1045
            '\\' , 
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1046
            '    "\',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1047
            '     self ' , sel , ' inspect\',
3823
1ed101fe88a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3822
diff changeset
  1048
            '     ImageEditor openOnClass:self andSelector:#', sel, '\',
3822
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1049
            '     Icon flushCachedIcons', 
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1050
            '\    "',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1051
            '\\',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1052
            '    <resource: #image>',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1053
            '\\',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1054
            '    ^Icon\') withCRs, 
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1055
            '        constantNamed:#''', imageKey, '''\' withCRs,
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1056
            '        ifAbsentPut:[', imageStoreStream contents, ']')
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1057
       classified: category.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1058
!
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1059
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
createInitialHistoryMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
    "add history method containing created-entry
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
     but only if not already present."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
    (aClass includesSelector:#history) ifFalse:[ 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
        HistoryManager notNil ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
            HistoryManager createInitialHistoryMethodIn:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
4512
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1071
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1072
    "add an inst-creation method"
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1073
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1074
    |template|
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1075
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1076
    (aMetaClass includesSelector:selector) ifFalse:[
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1077
        template := Parser methodSpecificationForSelector:selector.
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1078
        self 
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1079
            compile:
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1080
template , '
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1081
    ^ self new ' , template , '
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1082
'                   
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1083
            forClass:aMetaClass 
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1084
            inCategory:category.
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1085
    ].
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1086
!
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1087
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
    "create a multi-setter method for instvars."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    |source|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
    source := ''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
    aCollectionOfVarNames do:[:eachVar |
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
        source := source , (eachVar , ':' , eachVar , 'Arg ').
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
    source := source , Character cr.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
    source := source , ('    "set instance variables (automatically generated)"' , Character cr , Character cr).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
    aCollectionOfVarNames do:[:eachVar |
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
        source := source , ('    ' , eachVar , ' := ' , eachVar , 'Arg.' , Character cr).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
    self compile:source forClass:aClass inCategory:'accessing'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
3800
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1105
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1106
    "add a subclassResponsibility method;
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1107
     but only if not already present."
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1108
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1109
    (aClass includesSelector:aSelector) ifFalse:[
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1110
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1111
        self compile:
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1112
(Method methodDefinitionTemplateForSelector:aSelector) ,
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1113
'
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1114
    "raise an error: must be redefined in concrete subclass(es)"
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1115
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1116
    ^ self subclassResponsibility
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1117
' 
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1118
              forClass:aClass 
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1119
              inCategory:cat.
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1120
    ].
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1121
!
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  1122
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
createUpdateMethodIn:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
    "create an update:with:from:-method
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
    (aClass includesSelector:#'update:with:from:') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
'update:something with:aParameter from:changedObject
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
    "Invoked when an object that I depend upon sends a change notification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
    "stub code automatically generated - please change as required"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    "/ changedObject == someOfMyValueHolders ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
    "/     self doSomethingApropriate
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
    "/     ^ self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
    "/ ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
    super update:something with:aParameter from:changedObject
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
            forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
            inCategory:'change & update'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
    ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
createVersionMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
    "add version method containing RCS template
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
     but only if not already present and its not a private class."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
    aClass isPrivate ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
        (aClass includesSelector:#version) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
            self compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
'version
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
    ^ ''$' , 'Header$''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
' 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
                  forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
                  inCategory:'documentation'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
        ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
! !
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
!CodeGeneratorTool class methodsFor:'compilation'!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
canUseRefactoringSupport
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
     ^ RefactoryChangeManager notNil and:[RefactoryChangeManager isLoaded]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
compile:theCode forClass:aClass inCategory:cat 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
    |change|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
    self canUseRefactoringSupport ifFalse:[
3716
cbaffbf250f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3712
diff changeset
  1172
        aClass compile:theCode classified:cat.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
        ^ self.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
3716
cbaffbf250f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3712
diff changeset
  1176
    change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:cat.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
    RefactoryChangeManager instance performChange:change.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
! !
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1180
!CodeGeneratorTool class methodsFor:'private'!
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1181
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1182
privCreateClassResponsibleProtocolFor:aClass
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1183
    "create stubs for the required protocol aClass may be a a MetaClass
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1184
     or a NonMetaClass"
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1185
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1186
    |selectors|
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1187
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1188
    selectors := IdentitySet new.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1189
    aClass allSuperclassesDo:[:cls |
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1190
        cls methodDictionary keysAndValuesDo:[:sel :mthd |
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1191
            (mthd sends:#subclassResponsibility) ifTrue:[
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1192
                selectors add:sel.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1193
            ]
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1194
        ]
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1195
    ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1196
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1197
    selectors do:[:eachSelector |
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1198
        |cat comment mthd implClass|
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1199
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1200
        implClass := aClass whichClassImplements:eachSelector.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1201
        implClass ~~ aClass ifTrue:[
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1202
            mthd := implClass compiledMethodAt:eachSelector.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1203
            (mthd sends:#subclassResponsibility) ifTrue:[
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1204
                cat := mthd category.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1205
                comment := mthd methodComment.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1206
                comment size == 0 ifTrue:[
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1207
                    comment := 'Superclass says that I am responsible to implement this method'
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1208
                ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1209
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1210
                self 
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1211
                    compile:
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1212
(Method methodDefinitionTemplateForSelector:eachSelector), Character cr, '    "', comment,
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1213
'"
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1214
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1215
    self shouldImplement
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1216
' 
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1217
                    forClass:aClass 
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1218
                    inCategory:cat.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1219
            ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1220
        ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1221
    ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1222
! !
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  1223
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
!CodeGeneratorTool class methodsFor:'documentation'!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
version
4590
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
  1227
    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.12 2003-02-21 09:54:32 cg Exp $'
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
! !