CodeGeneratorTool.st
author Claus Gittinger <cg@exept.de>
Mon, 11 Feb 2008 15:24:42 +0100
changeset 7973 7fb67608aa3e
parent 7967 2560906ca552
child 8258 77eecb901a6a
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5141
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     1
"
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     2
 COPYRIGHT (c) 2002 by eXept Software AG
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     3
              All Rights Reserved
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     4
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     5
 This software is furnished under a license and may be used
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     6
 only in accordance with the terms of that license and with the
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
     9
 other person.  No title to or ownership of the software is
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    10
 hereby transferred.
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    11
"
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libtool' }"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Object subclass:#CodeGeneratorTool
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
    15
	instanceVariableNames:'compositeChangeCollector compositeChangeNesting'
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
    16
	classVariableNames:'GenerateCommentsForGetters GenerateCommentsForSetters'
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Interface-Browsers'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
3719
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    21
!CodeGeneratorTool class methodsFor:'documentation'!
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    22
5141
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    23
copyright
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    24
"
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    25
 COPYRIGHT (c) 2002 by eXept Software AG
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    26
              All Rights Reserved
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    27
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    28
 This software is furnished under a license and may be used
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    29
 only in accordance with the terms of that license and with the
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    31
 be provided or otherwise made available to, or used by, any
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    32
 other person.  No title to or ownership of the software is
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    33
 hereby transferred.
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    34
"
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    35
!
ffd2a0198999 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5124
diff changeset
    36
3719
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    37
documentation
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    38
"
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
    39
    This utility class contains various code generation facilites;
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
    40
    these were extracted from the old and newBrowser.
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
    41
    There is probably more to come...
3719
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    42
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    43
    [author:]
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    44
        Claus Gittiner
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    45
"
d7f6eb94a693 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3716
diff changeset
    46
! !
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!CodeGeneratorTool class methodsFor:'code generation'!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
    51
    "create accessors in aClass"
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
    52
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
    53
    ^ self new 
6313
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    54
        createAccessMethodsFor:aCollectionOfVarNames 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    55
        in:aClass 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    56
        withChange:withChange 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    57
        asValueHolder:asValueHolder 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    58
        readersOnly:readersOnly 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    59
        writersOnly:writersOnly
4444
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    60
!
6b077945517c generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents: 4351
diff changeset
    61
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
createApplicationCodeFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "create an empty application framework"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
    65
    ^ self new createApplicationCodeFor:aClass
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
3804
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
    68
createClassResponsibleProtocolFor:aClass
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
    69
    "create stubs for the required protocol"
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
    70
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
    71
    ^ self new createClassResponsibleProtocolFor:aClass
3804
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
    72
!
d2bc07d678f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3800
diff changeset
    73
5124
487a63f34ac0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5013
diff changeset
    74
createClassTypeTestMethodsIn:aClass forClasses:subClasses
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
    75
    "create a #isXXX test methods (I'm tired of typing)"
4351
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
    76
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
    77
    ^ self new createClassTypeTestMethodsIn:aClass forClasses:subClasses
4351
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
    78
!
cc4739c4797b create test methods
Claus Gittinger <cg@exept.de>
parents: 4108
diff changeset
    79
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
createDocumentationMethodsFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "create empty documentation methods"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
    83
    ^ self new createDocumentationMethodsFor:aClass
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
6313
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    86
createEnumTypeCodeFor:aClass
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    87
    ^ self new createEnumTypeCodeFor:aClass
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    88
!
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
    89
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    90
createInitializedInstanceCreationMethodsIn:aClass
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
    91
    "create a #new and #initialize methods (I'm tired of typing)"
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    93
    ^ self new createInitializedInstanceCreationMethodsIn:aClass
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    94
!
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    95
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    96
createParametrizedInstanceCreationMethodsNamed:selector in:aClass
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    97
    "create a #selector instance creation method (I'm tired of typing)"
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    98
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
    99
    ^ self new createParametrizedInstanceCreationMethodsNamed:selector in:aClass
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
createTestCaseSampleCodeFor:aClass
4590
2447e35a81d4 testCase stub code
Claus Gittinger <cg@exept.de>
parents: 4512
diff changeset
   103
    "create an (almost) empty testCase class"
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   105
    ^ self new createTestCaseSampleCodeFor:aClass
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   109
    "create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)"
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   111
    ^ self new createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   114
createWebApplicationCodeFor:aClass
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   115
    "create an empty webApplication framework"
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   116
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   117
    ^ self new createWebApplicationCodeFor:aClass
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   118
!
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   119
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   120
createWebServiceCodeFor:aClass
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   121
    "create an empty webService framework"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   122
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   123
    ^ self new createWebServiceCodeFor:aClass
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   124
!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   125
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
initialMenuSpecMethodSourceForApplications
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   127
    "return a menuSpec with typical stuff in it"
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   128
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
'mainMenu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    "This resource specification was automatically generated by the CodeGeneratorTool."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    "Do not manually edit this!! If it is corrupted,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
     the MenuEditor may not be able to read the specification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
     MenuEditor new openOnClass:%1 andSelector:#mainMenu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    <resource: #menu>
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    ^ #(#Menu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
           #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
             #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
                #label: ''File''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
                #submenu: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
                 #(#Menu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                     #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
                          #label: ''New''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
                          #value: #menuNew
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                          #label: ''Open...''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                          #value: #menuOpen
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
                          #label: ''Save''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
                          #value: #menuSave
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
                          #label: ''Save As...''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
                          #value: #menuSaveAs
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
                          #label: ''Exit''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
                          #value: #closeRequest
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
                    ) nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
                    nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
                )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
            )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
             #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
                #label: ''Help''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
                #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
                #startGroup: #right
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
                #submenu: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
                 #(#Menu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
                     #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
                          #label: ''Documentation''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
                          #value: #openDocumentation
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
                       #(#MenuItem
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
                          #label: ''-''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
                       #(#MenuItem
6643
abd4749a00ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6350
diff changeset
   204
                          #label: ''About this Application...''
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
                          #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
                          #value: #openAboutThisApplication
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
                      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
                    ) nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
                    nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
                )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
            )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
          ) nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
          nil
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   218
initialPageMenuSpec
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   219
    "return a menuSpec with typical stuff in it"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   220
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   221
    "This resource specification was automatically generated by the CodeGeneratorTool."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   222
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   223
    "Do not manually edit this!! If it is corrupted,
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   224
     the MenuEditor may not be able to read the specification."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   225
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   226
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   227
     MenuEditor new openOnClass:%1 andSelector:#mainMenu
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   228
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   229
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   230
    <resource: #menu>
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   231
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   232
    ^ #(#Menu
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   233
           #(
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   234
             #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   235
                #label: 'AAA'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   236
                #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   237
                #submenu: 
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   238
                 #(#Menu
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   239
                     #(
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   240
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   241
                          #label: 'New'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   242
                          #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   243
                          #value: #menuNew
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   244
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   245
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   246
                          #label: '-'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   247
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   248
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   249
                          #label: 'Open...'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   250
                          #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   251
                          #value: #menuOpen
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   252
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   253
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   254
                          #label: '-'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   255
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   256
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   257
                          #label: 'Save'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   258
                          #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   259
                          #value: #menuSave
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   260
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   261
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   262
                          #label: 'Save As...'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   263
                          #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   264
                          #value: #menuSaveAs
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   265
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   266
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   267
                          #label: '-'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   268
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   269
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   270
                          #label: 'Exit'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   271
                          #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   272
                          #value: #closeRequest
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   273
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   274
                    ) nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   275
                    nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   276
                )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   277
            )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   278
             #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   279
                #label: 'Help'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   280
                #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   281
                #startGroup: #right
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   282
                #submenu: 
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   283
                 #(#Menu
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   284
                     #(
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   285
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   286
                          #label: 'Documentation'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   287
                          #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   288
                          #value: #openDocumentation
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   289
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   290
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   291
                          #label: '-'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   292
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   293
                       #(#MenuItem
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   294
                          #label: 'About this Application...'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   295
                          #translateLabel: true
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   296
                          #value: #openAboutThisApplication
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   297
                      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   298
                    ) nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   299
                    nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   300
                )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   301
            )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   302
          ) nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   303
          nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   304
      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   305
!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   306
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   307
initialPageMenuSpecMethodSourceForWebApplications
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   308
    "return a menuSpec with typical stuff in it"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   309
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   310
    ^
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   311
'mainMenu
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   312
    "This resource specification was automatically generated by the CodeGeneratorTool."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   313
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   314
    "Do not manually edit this!! If it is corrupted,
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   315
     the MenuEditor may not be able to read the specification."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   316
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   317
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   318
     MenuEditor new openOnClass:%1 andSelector:#mainMenu
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   319
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   320
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   321
    <resource: #menu>
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   322
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   323
    ^ ',(self initialPageMenuSpec decodeAsLiteralArray literalArrayEncoding storeString),'
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   324
'.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   325
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   326
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   327
     self initialPageMenuSpecMethodSourceForWebApplications
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   328
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   329
!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   330
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   331
initialPageSpecMethodSourceForWebApplications
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   332
    "return an empty pageSpec"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   333
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   334
    ^
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   335
'pageSpec
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   336
    "This resource specification was automatically generated by the CodeGeneratorTool."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   337
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   338
    "Do not manually edit this!! If it is corrupted,
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   339
     the UIPainter may not be able to read the specification."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   340
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   341
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   342
     UIPainter new openOnClass:%1 andSelector:#windowSpec
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   343
    "
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   344
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   345
    <resource: #canvas>
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   346
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   347
    ^ #(#FullSpec
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   348
          #window: 
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   349
           #(#WindowSpec
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   350
              #name: ''%1''
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   351
              #layout: #(#LayoutFrame 204 0 162 0 503 0 461 0)
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   352
              #label: ''%1''
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   353
              #min: #(#Point 10 10)
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   354
              #max: #(#Point 1024 768)
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   355
              #bounds: #(#Rectangle 204 162 504 462)
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   356
              #menu: #pageMenu
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   357
              #usePreferredExtent: false
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   358
          )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   359
          #component: 
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   360
           #(#SpecCollection
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   361
              #collection: #()
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   362
          )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   363
      )
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   364
'.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   365
!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   366
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
initialWindowSpecMethodSourceForApplications
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   368
    "return an empty windowSpec with an initial menubar in it"
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   369
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
'windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    "This resource specification was automatically generated by the CodeGeneratorTool."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
    "Do not manually edit this!! If it is corrupted,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
     the UIPainter may not be able to read the specification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
     UIPainter new openOnClass:%1 andSelector:#windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    <resource: #canvas>
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    ^ #(#FullSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
          #window: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
           #(#WindowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
              #name: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
              #layout: #(#LayoutFrame 204 0 162 0 503 0 461 0)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
              #label: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
              #min: #(#Point 10 10)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
              #max: #(#Point 1024 768)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
              #bounds: #(#Rectangle 204 162 504 462)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
              #menu: #mainMenu
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
              #usePreferredExtent: false
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
          #component: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
           #(#SpecCollection
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
              #collection: #()
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
initialWindowSpecMethodSourceForDialogs
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   404
    "return an empty windowSpec for dialogs"
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   405
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
'windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
    "This resource specification was automatically generated by the CodeGeneratorTool."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
    "Do not manually edit this!! If it is corrupted,
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
     the UIPainter may not be able to read the specification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
     UIPainter new openOnClass:%1 andSelector:#windowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    "
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    <resource: #canvas>
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
    ^
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
       #(#FullSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
          #window: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
           #(#WindowSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
              #name: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
              #layout: #(#LayoutFrame 221 0 118 0 520 0 417 0)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
              #level: 0
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
              #label: ''%1''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
              #min: #(#Point 10 10)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
              #max: #(#Point 1024 768)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
              #bounds: #(#Rectangle 221 118 521 418)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
              #usePreferredExtent: false
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
          #component: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
           #(#SpecCollection
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
              #collection: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
               #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
                 #(#HorizontalPanelViewSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
                    #name: ''buttonPanel''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
                    #layout: #(#LayoutFrame 0 0.0 -45 1 0 1.0 0 1.0)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
                    #component: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
                     #(#SpecCollection
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
                        #collection: 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
                         #(
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
                          #(#ActionButtonSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
                             #name: ''cancelButton''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
                             #label: ''Cancel''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
                             #tabable: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
                             #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
                             #model: #cancel
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
                             #extent: #(#Point 125 22)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
                           )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
                           #(#ActionButtonSpec
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
                              #name: ''okButton''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
                              #label: ''OK''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
                              #tabable: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
                              #translateLabel: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
                              #isDefault: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
                              #model: #accept
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
                              #extent: #(#Point 125 22)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
                          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
                        )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
                    )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
                    #reverseOrderIfOKAtLeft: true
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
                    #horizontalLayout: #spreadSpaceMax
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
                    #verticalLayout: #center
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
                    #horizontalSpace: 3
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
                    #verticalSpace: 3
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
                )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
              )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
          )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
      )
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
! !
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   475
!CodeGeneratorTool class methodsFor:'code generation-basic'!
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   476
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   477
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   478
    "workhorse for creating access methods for instvars."
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
   479
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   480
    ^ self new 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   481
        createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   482
! !
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   483
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   484
!CodeGeneratorTool class methodsFor:'code generation-individual methods'!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   485
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   486
createAcceptVisitorMethod:selector in:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   487
    "create an acceptVisitor: method
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   488
     (I'm tired of typing)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   489
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   490
    ^ self new createAcceptVisitorMethod:selector in:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   491
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   492
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   493
createAcceptVisitorMethodIn:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   494
    "create an acceptVisitor: method
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   495
     (I'm tired of typing)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   496
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   497
    ^ self new createAcceptVisitorMethodIn:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   498
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   499
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   500
createCopyrightMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   501
    "add copyright method containing your/your companies
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   502
     copyright template but only if not already present.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   503
     this is only added, if specified in the 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   504
     COPYRIGHT_TEMPLATE_FILE resources."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   505
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   506
    ^ self new createCopyrightMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   507
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   508
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   509
createDocumentationMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   510
    "add documentation method containing doc template
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   511
     but only if not already present."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   512
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   513
    ^ self new createDocumentationMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   514
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   515
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   516
createExamplesMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   517
    "add examples method containing examples template
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   518
     but only if not already present."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   519
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   520
    ^ self new createExamplesMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   521
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   522
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   523
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   524
    ^ self new createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   525
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   526
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   527
createInitialHistoryMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   528
    "add history method containing created-entry
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   529
     but only if not already present."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   530
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   531
    ^ self new createInitialHistoryMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   532
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   533
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   534
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   535
    "add an inst-creation method"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   536
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   537
    ^ self new createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   538
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   539
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   540
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   541
    "create a multi-setter method for instvars."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   542
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   543
    ^ self new createMultiSetterMethodFor:aCollectionOfVarNames in:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   544
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   545
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   546
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   547
    "add a subclassResponsibility method;
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   548
     but only if not already present."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   549
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   550
    ^ self new createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   551
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   552
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   553
createUpdateMethodIn:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   554
    "create an update:with:from:-method
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   555
     (I'm tired of typing)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   556
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   557
    ^ self new createUpdateMethodIn:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   558
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   559
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   560
createVersionMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   561
    "add version method containing RCS template
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   562
     but only if not already present and its not a private class."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   563
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   564
    ^ self new createVersionMethodFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   565
! !
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   566
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   567
!CodeGeneratorTool class methodsFor:'code generation-menus'!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   568
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   569
createActionMethodFor:aSelector in:aClass category:aCategory redefine:redefine
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   570
    |alreadyInSuperclass method code|
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   571
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   572
    (aClass includesSelector:aSelector) ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   573
        ^ nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   574
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   575
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   576
    alreadyInSuperclass := aClass superclass canUnderstand:aSelector.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   577
    (alreadyInSuperclass and:[redefine not]) ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   578
        ^ nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   579
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   580
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   581
    method := self methodNameTemplateFor:aSelector.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   582
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   583
    code := '%1
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   584
    "automatically generated by UIEditor ..."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   585
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   586
    "*** the code below performs no action"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   587
    "*** (except for some feedback on the Transcript)"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   588
    "*** Please change as required and accept in the browser."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   589
    "*** (and replace this comment by something more useful ;-)"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   590
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   591
    "action to be added ..."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   592
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   593
    Transcript showCR:self class name, '': action for #%2 ...''.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   594
' bindWith:method with:aSelector.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   595
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   596
    alreadyInSuperclass ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   597
        code := code, (('\    super %1\' bindWith:method) withCRs).
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   598
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   599
    self compile:code forClass:aClass inCategory:(aCategory ? 'actions').
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   600
    ^ code
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   601
!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   602
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   603
createAspectMethodFor:aSelector in:aClass category:aCategory redefine:redefine
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   604
    |alreadyInSuperclass method code text|
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   605
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   606
    (aClass includesSelector:aSelector) ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   607
        ^ nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   608
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   609
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   610
    alreadyInSuperclass := aClass superclass canUnderstand:aSelector.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   611
    (alreadyInSuperclass and:[redefine not]) ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   612
        ^ nil
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   613
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   614
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   615
    method := self methodNameTemplateFor:aSelector.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   616
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   617
    code := '%1
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   618
    "automatically generated by UIEditor ..."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   619
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   620
    "*** the code below creates a default model when invoked"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   621
    "*** (which may not be the one you wanted)"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   622
    "*** Please change as required and accept in the browser."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   623
    "*** (and replace this comment by something more useful ;-)"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   624
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   625
    "aspect to be added ..."
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   626
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   627
    Transcript showCR:self class name, '': aspect for #%2 ...''.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   628
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   629
' bindWith:method with:aSelector.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   630
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   631
    alreadyInSuperclass ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   632
        text := '    ^ super %1\' bindWith:method.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   633
    ] ifFalse:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   634
        text := '    ^ builder valueAspectFor:#''%1'' initialValue:true\' bindWith:aSelector.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   635
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   636
    code := code, (text withCRs).
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   637
    self compile:code forClass:aClass inCategory:(aCategory ? 'actions').
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   638
    ^ code
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   639
! !
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   640
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   641
!CodeGeneratorTool class methodsFor:'compilation'!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   642
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   643
compile:theCode forClass:aClass inCategory:cat 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   644
    "install some code for a class.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   645
     If refactory browser stuff is avaliable the refactory tools are used to support undo"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   646
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   647
    ^ self new compile:theCode forClass:aClass inCategory:cat
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   648
! !
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   649
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   650
!CodeGeneratorTool class methodsFor:'private'!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   651
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   652
canUseRefactoringSupport
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   653
    "check if refactory browser stuff is avaliable"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   654
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   655
     ^ RefactoryChangeManager notNil 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   656
    and:[RefactoryChangeManager isLoaded
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   657
    and:[UserPreferences current useRefactoringSupport]]
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   658
!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   659
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   660
methodNameTemplateFor:aSelector
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   661
    |numArgs method|
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   662
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   663
    numArgs := aSelector numArgs.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   664
    numArgs == 1 ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   665
        method := aSelector, 'anArgument'.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   666
    ] ifFalse:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   667
        numArgs == 0 ifTrue:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   668
            method := aSelector
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   669
        ] ifFalse:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   670
            method := ''.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   671
            aSelector keywords keysAndValuesDo:[:i :key|
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   672
                method := method, key, 'arg', i printString, ' '.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   673
            ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   674
        ]
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   675
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
   676
    ^ method
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   677
! !
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   678
5759
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   679
!CodeGeneratorTool methodsFor:'buld changes'!
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   680
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   681
addChange:aChange
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   682
    compositeChangeCollector addChange:aChange
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   683
!
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   684
5759
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   685
executeCollectedChangesNamed:name
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   686
    compositeChangeCollector notNil ifTrue:[
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   687
        compositeChangeNesting := compositeChangeNesting - 1.
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   688
        compositeChangeNesting == 0 ifTrue:[
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   689
            compositeChangeCollector name:name.
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   690
            compositeChangeCollector changesSize == 0 ifTrue:[
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   691
                self information:'Nothing generated.'.
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   692
            ] ifFalse:[
7037
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
   693
                RefactoryChangeManager performChange:compositeChangeCollector.
5759
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   694
            ].
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   695
            compositeChangeCollector := nil.
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   696
        ]
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   697
    ]
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   698
!
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   699
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   700
startCollectChanges
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   701
    (self canUseRefactoringSupport) ifTrue:[
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   702
        compositeChangeCollector isNil ifTrue:[
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   703
            compositeChangeCollector := CompositeRefactoryChange new.
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   704
            compositeChangeNesting := 0.
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   705
        ].
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   706
        compositeChangeNesting := compositeChangeNesting + 1.
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   707
    ]
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   708
! !
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   709
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   710
!CodeGeneratorTool methodsFor:'code generation'!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   711
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   712
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   713
    "create accessors in aClass"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   714
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   715
    self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   716
        createAccessMethodsFor:aCollectionOfVarNames 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   717
        in:aClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   718
        withChange:withChange 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   719
        asValueHolder:asValueHolder 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   720
        readersOnly:readersOnly 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   721
        writersOnly:writersOnly 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   722
        lazyInitialization:false
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   723
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   724
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   725
createApplicationCodeFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   726
    "create an empty application framework"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   727
7480
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   728
    |nonMetaClass metaClass className txt isDialog 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   729
     categoryForMenuActionsMethods compileMenuAction compileTemplateAction|
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   730
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   731
    self startCollectChanges.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   732
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   733
    categoryForMenuActionsMethods := UserPreferences current categoryForMenuActionsMethods.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   734
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   735
    nonMetaClass := aClass theNonMetaclass.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   736
    metaClass := aClass theMetaclass.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   737
    className := nonMetaClass name.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   738
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   739
    isDialog := (nonMetaClass isSubclassOf:SimpleDialog).
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   740
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   741
    "/ add a windowSpec method for an empty applicationWindow,
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   742
    "/ with a menuPanel.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   743
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   744
    (metaClass includesSelector:#windowSpec) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   745
        isDialog ifTrue:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   746
            txt := self class initialWindowSpecMethodSourceForDialogs.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   747
        ] ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   748
            txt := self class initialWindowSpecMethodSourceForApplications.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   749
        ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   750
        self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   751
            compile:(txt bindWith:className)
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   752
            forClass:metaClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   753
            inCategory:'interface specs'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   754
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   755
7480
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   756
    compileTemplateAction := 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   757
        [:selector :category |
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   758
            (nonMetaClass includesSelector:selector) ifFalse:[
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   759
                |codeTemplateSelector|
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   760
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   761
                codeTemplateSelector := ('codeFor_',(selector upTo:$:)) asSymbol.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   762
                txt := self perform:codeTemplateSelector.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   763
                self
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   764
                    compile:txt
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   765
                    forClass:nonMetaClass 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   766
                    inCategory:(category = '*' ifTrue:categoryForMenuActionsMethods ifFalse:category).
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   767
            ]
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   768
        ].
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   769
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   770
    #(
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   771
        #'postBuildWith:'   'initialization & release'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   772
        #'postOpenWith:'    'initialization & release'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   773
    ) pairWiseDo:compileTemplateAction.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   774
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   775
    isDialog ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   776
        "/ add a topMenu method 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   777
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   778
        (metaClass includesSelector:#mainMenu) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   779
            txt := self class initialMenuSpecMethodSourceForApplications.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   780
            self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   781
                compile:(txt bindWith:className)
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   782
                forClass:metaClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   783
                inCategory:'menu specs'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   784
        ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   785
7480
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   786
        #(
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   787
            #'hasUnsavedChanges'        'private queries'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   788
            #'closeRequest'             'initialization & release'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   789
            #'closeDownViews'           'initialization & release'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   790
            #'menuSaveAs'               '*'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   791
            #'menuNew'                  '*'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   792
            #'menuOpen'                 '*'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   793
            #'menuSave'                 '*'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   794
            #'doSaveAs'                 '*'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   795
            #'openDocumentation'        '*'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   796
            #'openAboutThisApplication' '*'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   797
        ) pairWiseDo:compileTemplateAction.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   798
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   799
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   800
    isDialog ifTrue:[
7480
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   801
        #(
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   802
            #'closeAccept'      'user actions'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   803
        ) pairWiseDo:compileTemplateAction.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   804
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   805
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   806
    self executeCollectedChangesNamed:('Add Application Code for ' , className).
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   807
7480
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
   808
    "Modified: / 27-10-2006 / 10:21:58 / cg"
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   809
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   810
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   811
createClassResponsibleProtocolFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   812
    "create stubs for the required protocol"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   813
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   814
    |nonMetaClass metaClass className|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   815
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   816
    nonMetaClass := aClass theNonMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   817
    metaClass := aClass theMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   818
    className := nonMetaClass name.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   819
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   820
    self startCollectChanges.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   821
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   822
    self privCreateClassResponsibleProtocolFor:nonMetaClass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   823
    self privCreateClassResponsibleProtocolFor:metaClass.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   824
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   825
    self executeCollectedChangesNamed:('Add Required Protocol to ' , className).
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   826
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   827
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   828
createClassTypeTestMethodsIn:aClass forClasses:subClasses
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   829
    "create a #isXXX test methods (I'm tired of typing)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   830
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   831
    | code|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   832
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   833
    self startCollectChanges.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   834
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   835
    subClasses do:[:eachSubClass |
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   836
        |nm selector|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   837
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   838
        nm := eachSubClass nameWithoutPrefix.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   839
        selector := 'is' , nm.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   840
        (aClass includesSelector:selector) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   841
            code := (selector , '\    ^ false') withCRs.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   842
            self 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   843
                compile:code
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   844
                forClass:aClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   845
                inCategory:'testing'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   846
        ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   847
        (eachSubClass includesSelector:selector) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   848
            code := (selector , '\    ^ true') withCRs.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   849
            self 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   850
                compile:code
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   851
                forClass:eachSubClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   852
                inCategory:'testing'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   853
        ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   854
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   855
5759
b6cea74440db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5758
diff changeset
   856
    self executeCollectedChangesNamed:'Add ClassType Tests'
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   857
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   858
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   859
createDocumentationMethodsFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   860
    "create empty documentation methods"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   861
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   862
    |nonMetaClass metaClass className|
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   863
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   864
    nonMetaClass := aClass theNonMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   865
    metaClass := aClass theMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   866
    className := nonMetaClass name.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   867
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   868
    self startCollectChanges.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   869
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   870
    self createVersionMethodFor:metaClass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   871
    self createCopyrightMethodFor:metaClass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   872
    self createDocumentationMethodFor:metaClass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   873
    self createInitialHistoryMethodFor:metaClass.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   874
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   875
    self executeCollectedChangesNamed:('Add Documentation to ' , className).
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   876
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   877
6313
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   878
createEnumTypeCodeFor:aClass
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   879
    |nonMetaClass metaClass className enumValues code initCode runValue maxValue|
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   880
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   881
    self startCollectChanges.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   882
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   883
    nonMetaClass := aClass theNonMetaclass.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   884
    metaClass := aClass theMetaclass.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   885
    className := nonMetaClass name.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   886
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   887
    enumValues := nonMetaClass classVarNames.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   888
    enumValues do:[:eachVariableName |
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   889
        self 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   890
            createAccessMethodsFor:(Array with:eachVariableName)
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   891
            in:metaClass  
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   892
            withChange:false
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   893
            asValueHolder:false
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   894
            readersOnly:true    
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   895
            writersOnly:false
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   896
    ].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   897
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   898
    maxValue := enumValues inject:0 into:[:maxSoFar :eachVariableName | |oldVal val| 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   899
                                                                                oldVal := nonMetaClass classVarAt:eachVariableName.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   900
                                                                                oldVal notNil ifTrue:[ val := oldVal numericValue ].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   901
                                                                                (val ? maxSoFar) max:maxSoFar].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   902
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   903
    initCode := WriteStream on: String new.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   904
    initCode nextPutLine:'initialize'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   905
    runValue := maxValue + 1.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   906
    enumValues keysAndValuesDo:[:idx :eachVariableName |
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   907
        |oldValue thisValue|
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   908
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   909
        oldValue := nonMetaClass classVarAt:eachVariableName.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   910
        oldValue notNil ifTrue:[
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   911
            thisValue := oldValue numericValue.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   912
        ] ifFalse:[
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   913
            thisValue := runValue.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   914
            runValue := runValue + 1.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   915
        ].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   916
        initCode 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   917
            nextPutAll:'    ';
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   918
            nextPutAll:eachVariableName;
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   919
            nextPutAll:' := self basicNew'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   920
        (aClass canUnderstand:#'setNumericValue:') ifTrue:[
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   921
            initCode nextPutAll:' setNumericValue: ',thisValue printString.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   922
        ].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   923
        (aClass canUnderstand:#'setCssClassString:') ifTrue:[
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   924
            initCode nextPutAll:('; setCssClassString: ''' , nonMetaClass nameWithoutPrefix asLowercaseFirst , eachVariableName , '''').
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   925
        ].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   926
        (aClass canUnderstand:#'setName:') ifTrue:[
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   927
            initCode nextPutAll:('; setName: ''' , eachVariableName asLowercaseFirst , '''').
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   928
        ].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   929
        initCode nextPutLine:'.'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   930
    ].
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   931
    initCode cr.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   932
    initCode nextPutLine:'    "'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   933
    initCode nextPutLine:'     ',className, ' initialize'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   934
    initCode nextPutLine:'    "'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   935
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   936
    self
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   937
        compile:(initCode contents)
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   938
        forClass:metaClass 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   939
        inCategory:'class initialization'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   940
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   941
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   942
    code := 'allStateNames\    ^ #( ' ,
6341
200c762ce0ed *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6313
diff changeset
   943
                ((enumValues collect:[:each | '#''',each asLowercaseFirst,'''']) asStringWith:' ') , ')',
6313
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   944
                '\\    "\' ,
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   945
                '     ',className, ' allStateNames\' ,
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   946
                '    "\'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   947
    self
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   948
        compile:code withCRs
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   949
        forClass:metaClass 
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   950
        inCategory:'queries'.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   951
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   952
    self executeCollectedChangesNamed:('Generate EnumType Code for ' , className).
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   953
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   954
    aClass initialize.
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   955
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   956
    "Modified: / 1.2.1998 / 16:10:03 / cg"
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   957
!
e73b5d2d07f9 enumType generator
Claus Gittinger <cg@exept.de>
parents: 6159
diff changeset
   958
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   959
createInitializedInstanceCreationMethodsIn:aClass
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   960
    "create a #new and #initialize methods (I'm tired of typing)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   961
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   962
    |nonMetaClass metaClass className code initializer m|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   963
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   964
    nonMetaClass := aClass theNonMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   965
    metaClass := aClass theMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   966
    className := nonMetaClass name.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   967
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   968
    self startCollectChanges.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   969
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   970
    (nonMetaClass includesSelector:#'initialize') ifFalse:[
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   971
        code :=
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   972
'initialize
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   973
    "Invoked when a new instance is created."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   974
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   975
    "/ please change as required (and remove this comment)
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   976
'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   977
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   978
        nonMetaClass instVarNames do:[:eachInstVar |
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   979
            initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ...
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   980
            code := code , ('    "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr).
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   981
        ].
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   982
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   983
        m := nonMetaClass responseTo:#initialize.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   984
        (m notNil and:[m messagesSent size == 0]) ifTrue:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   985
            "/ inherits an empty initialize.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   986
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   987
            code := code , '
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   988
    "/ super initialize.   -- commented since inherited method does nothing
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   989
'.
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   990
        ] ifFalse:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   991
            code := code , '
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   992
    super initialize.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
   993
'.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   994
        ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   995
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   996
        self 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   997
            compile:code
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
   998
            forClass:nonMetaClass 
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
   999
            inCategory:'initialization'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1000
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1001
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1002
    (metaClass includesSelector:#'new') ifFalse:[
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1003
        m := metaClass responseTo:#new.
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1004
        (m isNil 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1005
        or:[ (m sends:#initialize) not 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1006
        or:[ |answer|
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1007
            (Dialog 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1008
                confirmWithCancel:'The inherited #new method already seems to invoke #initialize. Redefine ?'
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1009
                onCancel:[^ self]) ]]) ifTrue:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1010
            code :=
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1011
'new
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1012
    ^ self basicNew initialize.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1013
'.
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1014
            self 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1015
                compile:code
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1016
                forClass:metaClass 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1017
                inCategory:'instance creation'.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1018
        ].
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1019
    ].
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1020
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1021
    self executeCollectedChangesNamed:('Add Initialized Instance Creation to ' , className).
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1022
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1023
    "Created: / 11.10.2001 / 22:18:55 / cg"
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1024
!
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1025
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1026
createParametrizedInstanceCreationMethodsNamed:selector in:aClass
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1027
    "create a #selector instance creation method (I'm tired of typing)"
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1028
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1029
    |nonMetaClass metaClass className code initializer m dfn|
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1030
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1031
    dfn := Method methodDefinitionTemplateForSelector:selector.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1032
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1033
    nonMetaClass := aClass theNonMetaclass.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1034
    metaClass := aClass theMetaclass.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1035
    className := nonMetaClass name.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1036
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1037
    self startCollectChanges.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1038
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1039
    (nonMetaClass includesSelector:selector asSymbol) ifFalse:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1040
        code :=
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1041
'initialize',dfn asUppercaseFirst,'
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1042
    "Invoked when a new instance is created for arg."
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1043
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1044
    "/ please change as required (and remove these comments)
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1045
    "/ do something with arg here (instVar-foo := arg)
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1046
'.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1047
        nonMetaClass instVarNames do:[:eachInstVar |
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1048
            initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ...
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1049
            code := code , ('    "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr).
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1050
        ].
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1051
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1052
        m := nonMetaClass responseTo:#initialize.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1053
        (m notNil and:[ m messagesSent size == 0 ]) ifTrue:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1054
            "/ inherits an empty initialize.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1055
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1056
            code := code , '
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1057
    "/ super initialize.   -- commented since inherited method does nothing
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1058
'.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1059
        ] ifFalse:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1060
            code := code , '
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1061
    super initialize.  
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1062
'.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1063
        ].
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1064
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1065
        self 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1066
            compile:code
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1067
            forClass:nonMetaClass 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1068
            inCategory:'initialization'.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1069
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1070
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1071
    (metaClass includesSelector:selector) ifFalse:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1072
        m := metaClass responseTo:selector.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1073
        (m isNil 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1074
        or:[ (Dialog confirmWithCancel:'The ',selector,'- method is already inherited. Redefine ?' onCancel:[^ self]) ])
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1075
        ifTrue:[
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1076
            code :=
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1077
dfn,'
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1078
    "Create & return a new instance for arg."
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1079
6718
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1080
    ^ self basicNew initialize',dfn asUppercaseFirst,'
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1081
'.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1082
            self 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1083
                compile:code
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1084
                forClass:metaClass 
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1085
                inCategory:'instance creation'.
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1086
        ].
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1087
    ].
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1088
d6e9cae51834 more generators;
Claus Gittinger <cg@exept.de>
parents: 6643
diff changeset
  1089
    self executeCollectedChangesNamed:('Add Parametrized Instance Creation to ' , className).
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1090
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1091
7470
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1092
createPoolInitializationCodeFor:aClass
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1093
    |nonMetaClass metaClass className poolVars code initCode runValue maxValue|
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1094
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1095
    self startCollectChanges.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1096
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1097
    nonMetaClass := aClass theNonMetaclass.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1098
    metaClass := aClass theMetaclass.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1099
    className := nonMetaClass name.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1100
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1101
    poolVars := nonMetaClass classVarNames.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1102
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1103
    initCode := WriteStream on: String new.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1104
    initCode nextPutLine:'initialize'.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1105
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1106
    poolVars do:[:eachVariableName |
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1107
        |oldValue thisValue|
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1108
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1109
        oldValue := nonMetaClass classVarAt:eachVariableName.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1110
        oldValue notNil ifTrue:[
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1111
            thisValue := oldValue.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1112
        ] ifFalse:[
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1113
            thisValue := nil.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1114
        ].
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1115
        initCode 
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1116
            nextPutAll:'    ';
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1117
            nextPutAll:eachVariableName;
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1118
            nextPutAll:' := ';
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1119
            nextPutAll:thisValue storeString;
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1120
            nextPutLine:'.'.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1121
    ].
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1122
    initCode cr.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1123
    initCode nextPutLine:'    "'.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1124
    initCode nextPutLine:'     ',className, ' initialize'.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1125
    initCode nextPutLine:'    "'.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1126
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1127
    self
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1128
        compile:(initCode contents)
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1129
        forClass:metaClass 
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1130
        inCategory:'class initialization'.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1131
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1132
    self executeCollectedChangesNamed:('Generate Pool Initialization Code for ' , className).
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1133
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1134
    aClass initialize.
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1135
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1136
    "Created: / 25-10-2006 / 09:28:40 / cg"
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1137
!
12c6eb575d88 pool code generation
Claus Gittinger <cg@exept.de>
parents: 7085
diff changeset
  1138
5953
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1139
createStandardPrintOnMethodIn:aClass
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1140
    "create a #printOn: method (I'm tired of typing)"
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1141
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1142
    |code nonMetaClass|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1143
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1144
    nonMetaClass := aClass theNonMetaclass.
5953
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1145
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1146
    self startCollectChanges.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1147
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1148
    (nonMetaClass includesSelector:#'printOn:') ifFalse:[
5953
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1149
        code :=
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1150
'printOn:aStream
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1151
    "append a printed representation if the receiver to the argument, aStream"
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1152
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1153
    super printOn:aStream.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1154
'.
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1155
        nonMetaClass instVarNames do:[:eachInstVarName |
5953
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1156
            code := code , '    '.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1157
            code := code , 'aStream nextPutAll:'''.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1158
            code := code , eachInstVarName.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1159
            code := code , ': ''.' , Character cr.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1160
            code := code , '    '.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1161
            code := code , eachInstVarName.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1162
            code := code , ' printOn:aStream.' , Character cr.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1163
        
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1164
        ].
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1165
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1166
        self 
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1167
            compile:code
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1168
            forClass:nonMetaClass 
5953
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1169
            inCategory:'printing & storing'.
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1170
    ].
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1171
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1172
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1173
    self executeCollectedChangesNamed:('Add #printOn: to ' , nonMetaClass name).
5953
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1174
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1175
    "Created: / 11.10.2001 / 22:18:55 / cg"
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1176
!
bf6cdc968a53 *** empty log message ***
ca
parents: 5817
diff changeset
  1177
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1178
createTestCaseSampleCodeFor:aClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1179
    "create an (almost) empty testCase class"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1180
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1181
    |nonMetaClass metaClass|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1182
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1183
    nonMetaClass := aClass theNonMetaclass.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1184
    metaClass := aClass theMetaclass.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1185
    "/ className := nonMetaClass name.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1186
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1187
    ( nonMetaClass includesSelector:#test1 ) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1188
        self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1189
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1190
'test1
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1191
    "This is a demonstration testCase - it is meant to be removed eventually.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1192
     This testCase will PASS.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1193
     Double click on the TestCase class or open a TestRunner to see me checking...
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1194
     - please add more methods like this..."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1195
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1196
    |o|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1197
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1198
    o := Array new:2.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1199
    self assert: ( o size == 2 ).
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1200
    self should: [ o at:0 ] raise:Error.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1201
    self shouldnt: [ o at:1 ] raise:Error.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1202
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1203
    "
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1204
     self run:#test1
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1205
     self new test1
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1206
    "
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1207
'
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1208
            forClass:nonMetaClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1209
            inCategory:'tests'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1210
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1211
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1212
    ( nonMetaClass includesSelector:#test2 ) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1213
        self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1214
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1215
'test2
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1216
    "This is a demonstration testCase - it is meant to be removed eventually..
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1217
     This testCase WILL FAIL.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1218
     Double click on the TestCase class or open a TestRunner to see me checking...
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1219
     - please add more methods like this..."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1220
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1221
    |o|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1222
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1223
    o := Array new:2.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1224
    self assert: ( o size == 3 ).
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1225
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1226
    "
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1227
     self run:#test2
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1228
     self new test2
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1229
    "
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1230
'
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1231
            forClass:nonMetaClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1232
            inCategory:'tests'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1233
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1234
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1235
    ( nonMetaClass includesSelector:#test3 ) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1236
        self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1237
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1238
'test3
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1239
    "This is a demonstration testCase - it is meant to be removed eventually..
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1240
     This testCase WILL generate an ERROR.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1241
     Double click on the TestCase class or open a TestRunner to see me checking...
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1242
     - please add more methods like this..."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1243
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1244
    |o|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1245
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1246
    o := Array new:2.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1247
    self assert: ( o foo ).
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1248
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1249
    "
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1250
     self run:#test3
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1251
     self new test3
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1252
    "
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1253
'
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1254
            forClass:nonMetaClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1255
            inCategory:'tests'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1256
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1257
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1258
    ( nonMetaClass includesSelector:#setUp ) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1259
        self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1260
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1261
'setUp
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1262
    "common setup - invoked before testing."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1263
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1264
    super setUp
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1265
'
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1266
            forClass:nonMetaClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1267
            inCategory:'initialize / release'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1268
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1269
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1270
    ( nonMetaClass includesSelector:#tearDown ) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1271
        self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1272
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1273
'tearDown
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1274
    "common cleanup - invoked after testing."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1275
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1276
    super tearDown
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1277
'
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1278
            forClass:nonMetaClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1279
            inCategory:'initialize / release'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1280
    ]
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1281
!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1282
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1283
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1284
    "create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1285
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1286
    |sel|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1287
6921
821413de0099 leftover halt.
Claus Gittinger <cg@exept.de>
parents: 6839
diff changeset
  1288
    self assert:( visitedClass isMeta not ).
821413de0099 leftover halt.
Claus Gittinger <cg@exept.de>
parents: 6839
diff changeset
  1289
    self assert:( visitorClass isMeta not ).
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1290
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1291
    self startCollectChanges.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1292
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1293
    sel := ('visit' , visitedClass nameWithoutPrefix , ':').
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1294
    self createAcceptVisitorMethod:sel in:visitedClass.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1295
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1296
    (visitorClass includesSelector:sel) ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1297
        self 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1298
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1299
(('%1anObject 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1300
    "dispatched back from the visited %2-object (visitor pattern)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1301
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1302
    "fall back to general object-case - please change as required"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1303
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1304
    ^ self visitObject:anObject
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1305
') bindWith:sel with:visitedClass nameWithoutPrefix asLowercaseFirst)
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1306
            forClass:visitorClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1307
            inCategory:'visiting'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1308
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1309
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1310
    (visitorClass includesSelector:#'visitObject:') ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1311
        self 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1312
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1313
('visitObject:anObject 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1314
    "dispatched back from the visited objects (visitor pattern)"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1315
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1316
    "general fallBack - please change as required"
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1317
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1318
    self halt:''not yet implemented''
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1319
')
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1320
            forClass:visitorClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1321
            inCategory:'visiting'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1322
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1323
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1324
    (visitorClass includesSelector:#'visit:') ifFalse:[
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1325
        self 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1326
            compile:
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1327
('visit:anObject 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1328
    "visit anObject (visitor pattern).
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1329
     The object should call back one of my visitXXXX methods."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1330
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1331
    ^ anObject acceptVisitor:self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1332
')
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1333
            forClass:visitorClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1334
            inCategory:'visiting'.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1335
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1336
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1337
    self executeCollectedChangesNamed:('Add Visitor Pattern').
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1338
!
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1339
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1340
createWebApplicationCodeFor:aClass
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1341
    "create an empty webApplication framework"
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1342
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1343
    |nonMetaClass metaClass className txt|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1344
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1345
    self startCollectChanges.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1346
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1347
    nonMetaClass := aClass theNonMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1348
    metaClass := aClass theMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1349
    className := nonMetaClass name.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1350
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1351
    (metaClass includesSelector:#pageSpec) ifFalse:[
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1352
        txt := self class initialPageSpecMethodSourceForWebApplications.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1353
        self
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1354
            compile:(txt bindWith:className)
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1355
            forClass:metaClass 
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1356
            inCategory:'page specs'.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1357
    ].
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1358
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1359
    self executeCollectedChangesNamed:('Add WebApplication Code for ' , className).
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1360
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1361
    "Modified: / 1.2.1998 / 16:10:03 / cg"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1362
!
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1363
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1364
createWebServiceCodeFor:aClass
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1365
    "create an empty webService framework"
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1366
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1367
    |nonMetaClass metaClass className txt|
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1368
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1369
    self startCollectChanges.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1370
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1371
    nonMetaClass := aClass theNonMetaclass.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1372
    metaClass := aClass theMetaclass.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1373
    className := nonMetaClass name.
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1374
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1375
    (nonMetaClass includesSelector:#process:) ifFalse:[
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1376
        txt :=
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1377
'process:aRequest
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1378
    "This is the web services main processing method.
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1379
     It will be invoked for every incoming webBrowser-request.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1380
     The argument, aRequest contains the parameters (url, fields, parameters etc.)."
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1381
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1382
    |response|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1383
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1384
    response := aRequest response.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1385
    response nextPutLine:''<HTML>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1386
    response nextPutLine:''  <HEAD>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1387
    response nextPutLine:''  <TITLE>Hello</TITLE>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1388
    response nextPutLine:''  </HEAD>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1389
    response nextPutLine:''  <BODY>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1390
    response nextPutLine:''    <H1>Hello World !!</H1>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1391
    response nextPutLine:''  </BODY>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1392
    response nextPutLine:''</HTML>''.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1393
'.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1394
        self
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1395
            compile:txt
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1396
            forClass:nonMetaClass 
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1397
            inCategory:'response generation'.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1398
    ].
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1399
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1400
    (metaClass includesSelector:#linkName) ifFalse:[
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1401
        txt :=
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1402
'linkName
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1403
    "return the default linkName path (with slash)."
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1404
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1405
    ^ ''/NewService''
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1406
'.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1407
        self
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1408
            compile:txt
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1409
            forClass:metaClass 
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1410
            inCategory:'defaults'.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1411
    ].
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1412
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1413
    (metaClass includesSelector:#settingsApplicationClass) ifFalse:[
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1414
        txt :=
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1415
'settingsApplicationClass
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1416
    "a SettingsApplication class - or nil (used in the settings dialog if non-nil)."
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1417
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1418
    ^ nil
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1419
'.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1420
        self
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1421
            compile:txt
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1422
            forClass:metaClass 
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1423
            inCategory:'defaults'.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1424
    ].
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1425
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1426
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  1427
    self executeCollectedChangesNamed:('Add WebService Code for ' , className).
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1428
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1429
    "Modified: / 1.2.1998 / 16:10:03 / cg"
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1430
! !
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1431
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1432
!CodeGeneratorTool methodsFor:'code generation-basic'!
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1433
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1434
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1435
    "workhorse for creating access methods for instvars."
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1436
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1437
    |classesClassVars generateComments generateCommentsForSetters generateCommentsForGetters|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1438
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1439
    self startCollectChanges.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1440
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1441
    generateComments := UserPreferences current generateComments.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1442
    generateCommentsForSetters := UserPreferences current generateCommentsForSetters.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1443
    generateCommentsForGetters := UserPreferences current generateCommentsForGetters.
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1444
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1445
    classesClassVars := aClass theNonMetaclass allClassVarNames.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1446
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1447
    aCollectionOfVarNames do:[:name |
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1448
        |source varType methodName defaultMethodName|
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1449
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1450
        varType := (classesClassVars includes:name) 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1451
                        ifTrue:['static'] 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1452
                        ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1453
                            (aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1454
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1455
        methodName := name.
6643
abd4749a00ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6350
diff changeset
  1456
        name isUppercaseFirst ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1457
            methodName := methodName asLowercaseFirst. 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1458
        ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1459
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1460
        "/ the GETTER
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1461
        writersOnly ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1462
            lazyInitialization ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1463
                defaultMethodName := 'default' , name asUppercaseFirst.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1464
            ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1465
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1466
            "check, if method is not already present"
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1467
            (aClass includesSelector:(methodName asSymbol)) ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1468
                asValueHolder ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1469
                    source := methodName , '\'.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1470
                    generateComments ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1471
                        source := source , '    "return/create the ''%2'' value holder (automatically generated)"\\'. 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1472
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1473
                    source := source , '    %2 isNil ifTrue:[\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1474
                    lazyInitialization ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1475
                        source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1476
                                   , '        %2 := self class %3 asValue.\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1477
                    ] ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1478
                        source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1479
                                   , '        %2 := ValueHolder new.\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1480
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1481
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1482
                    withChange ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1483
                    source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1484
                               , '        %2 addDependent:self.\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1485
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1486
                    source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1487
                               , '    ].\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1488
                               , '    ^ %2'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1489
                ] ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1490
                    source := methodName , '\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1491
                    lazyInitialization ifTrue:[
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1492
                        generateCommentsForGetters ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1493
                            source := source , '    "return the %1 instance variable ''%2'' with lazy instance creation (automatically generated)"\\'. 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1494
                        ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1495
                        source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1496
                                    , '    %2 isNil ifTrue:[\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1497
                                    , '        %2 := self class %3.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1498
                                    , '    ].\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1499
                                    , '    ^ %2'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1500
                    ] ifFalse:[
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1501
                        generateCommentsForGetters ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1502
                            source := source , '    "return the %1 instance variable ''%2'' (automatically generated)"\\'. 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1503
                        ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1504
                        source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1505
                                    , '    ^ %2'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1506
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1507
                ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1508
                source := (source bindWith:varType with:name with:defaultMethodName) withCRs.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1509
                self compile:source forClass:aClass inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']).
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1510
            ] ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1511
                Transcript showCR:'method ''', methodName , ''' already present'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1512
            ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1513
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1514
            "/ default for lazy on class side
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1515
            lazyInitialization ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1516
                (aClass class includesSelector:(defaultMethodName asSymbol)) ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1517
                    source := defaultMethodName , '\'.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1518
                    generateComments ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1519
                        source := source , '    "default value for the ''%2'' instance variable (automatically generated)"\\'. 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1520
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1521
                    source := source    
6839
c25218305e50 Send #shouldImplement instead of #halt:.
Stefan Vogel <sv@exept.de>
parents: 6791
diff changeset
  1522
                               , '    self shouldImplement.\'
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1523
                               , '    ^ nil.'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1524
                    source := (source bindWith:varType with:name) withCRs.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1525
                    self compile:source forClass:aClass class inCategory:'defaults'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1526
                ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1527
            ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1528
        ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1529
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1530
        "/ the SETTER
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1531
        readersOnly ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1532
            (aClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1533
                asValueHolder ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1534
                    source := methodName , ':something\'.
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1535
                    generateComments ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1536
                        source := source , '    "set the ''%2'' value holder' , ' (automatically generated)"\\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1537
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1538
                    withChange ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1539
                        source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1540
                                  , '    |oldValue newValue|\\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1541
                                  , '    %2 notNil ifTrue:[\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1542
                                  , '        oldValue := %2 value.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1543
                                  , '        %2 removeDependent:self.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1544
                                  , '    ].\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1545
                                  , '    %2 := something.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1546
                                  , '    %2 notNil ifTrue:[\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1547
                                  , '        %2 addDependent:self.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1548
                                  , '    ].\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1549
                                  , '    newValue := %2 value.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1550
                                  , '    oldValue ~~ newValue ifTrue:[\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1551
                                  , '        self update:#value with:newValue from:%2.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1552
                                  , '    ].\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1553
                    ] ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1554
                        source := source 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1555
                                  , '    %2 := something.'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1556
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1557
                ] ifFalse:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1558
                    source := methodName , ':something\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1559
                    withChange ifTrue:[
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1560
                        generateComments ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1561
                            source := source , '    "set the value of the %1 variable ''%2'''.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1562
                            source := source , ' and send a change notification (automatically generated)"\\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1563
                        ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1564
                        source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1565
                                  , '    (%2 ~~ something) ifTrue:[\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1566
                                  , '        %2 := something.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1567
                                  , '        self changed:#%2.\'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1568
                                  , '     ].\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1569
                    ] ifFalse:[
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1570
                        generateCommentsForSetters ifTrue:[
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1571
                            source := source , '    "set the value of the %1 variable ''%2'''.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1572
                            source := source , ' (automatically generated)"\\'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1573
                        ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1574
                        source := source
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1575
                                  , '    %2 := something.'.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1576
                    ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1577
                ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1578
                source := (source bindWith:varType with:name) withCRs.
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1579
                self 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1580
                    compile:source 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1581
                    forClass:aClass 
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1582
                    inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']).
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1583
            ] ifTrue:[
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1584
                Transcript showCR:'method ''', methodName , ':'' already present'
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1585
            ].
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1586
        ].
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1587
    ].
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1588
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1589
    self executeCollectedChangesNamed:('Add Accessors').
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1590
!
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1591
7615
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1592
createCollectionAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1593
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1594
    |classesClassVars generateComments generateCommentsForSetters generateCommentsForGetters|
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1595
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1596
    self startCollectChanges.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1597
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1598
    generateComments := UserPreferences current generateComments.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1599
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1600
    classesClassVars := aClass theNonMetaclass allClassVarNames.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1601
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1602
    aCollectionOfVarNames do:[:name |
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1603
        |source varType methodNameBase methodName defaultMethodName|
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1604
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1605
        varType := (classesClassVars includes:name) 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1606
                        ifTrue:['static'] 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1607
                        ifFalse:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1608
                            (aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])].
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1609
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1610
        methodNameBase := name asUppercaseFirst.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1611
        (methodNameBase endsWith:'s') ifTrue:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1612
            methodNameBase := methodNameBase copyWithoutLast:1.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1613
        ].
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1614
        methodName := 'add' , methodNameBase, ':'. 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1615
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1616
        "check, if method is not already present"
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1617
        (aClass includesSelector:(methodName asSymbol)) ifFalse:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1618
            source := methodName , 'a%1\'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1619
            generateComments ifTrue:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1620
                source := source , '    "add a ',methodNameBase,'"\\'. 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1621
            ].
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1622
            source := source , '    %2 isNil ifTrue:[\'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1623
                source := source
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1624
                           , '        %2 := OrderedCollection new.\'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1625
            source := source
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1626
                       , '    ].\'
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1627
                       , '    %2 add: a%1'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1628
            source := (source bindWith:methodNameBase with:name) withCRs.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1629
            self compile:source forClass:aClass inCategory:'accessing'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1630
        ] ifTrue:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1631
            Transcript showCR:'method ''', methodName , ''' already present'
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1632
        ].
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1633
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1634
        methodName := 'remove' , methodNameBase, ':'. 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1635
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1636
        "check, if method is not already present"
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1637
        (aClass includesSelector:(methodName asSymbol)) ifFalse:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1638
            source := methodName , 'a%1\'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1639
            generateComments ifTrue:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1640
                source := source , '    "remove a ',methodNameBase,'"\\'. 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1641
            ].
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1642
            source := source
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1643
                       , '    %2 remove: a%1'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1644
            source := (source bindWith:methodNameBase with:name) withCRs.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1645
            self compile:source forClass:aClass inCategory:'accessing'.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1646
        ] ifTrue:[
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1647
            Transcript showCR:'method ''', methodName , ''' already present'
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1648
        ].
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1649
    ].
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1650
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1651
    self
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1652
        createAccessMethodsFor:aCollectionOfVarNames 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1653
        in:aClass 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1654
        withChange:withChange 
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1655
        asValueHolder:false
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1656
        readersOnly:true
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1657
        writersOnly:false
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1658
        lazyInitialization:false.
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1659
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1660
    self executeCollectedChangesNamed:('Add Collection Access').
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1661
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1662
    "Created: / 04-02-2007 / 15:52:31 / cg"
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1663
!
d059ea04b8f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7545
diff changeset
  1664
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1665
createValueHoldersFor:aCollectionOfVarNames in:aClass lazyInitialization:lazyInitialization
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1666
    "workhorse for creating access methods for instvars."
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1667
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1668
    |nonMetaClass metaClass classesClassVars generateComments generateCommentsForSetters generateCommentsForGetters|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1669
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1670
    nonMetaClass := aClass theNonMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1671
    metaClass := aClass theMetaclass.
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1672
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1673
    self startCollectChanges.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1674
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1675
    generateComments := UserPreferences current generateComments.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1676
    generateCommentsForSetters := UserPreferences current generateCommentsForSetters.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1677
    generateCommentsForGetters := UserPreferences current generateCommentsForGetters.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1678
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1679
    classesClassVars := nonMetaClass allClassVarNames.
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1680
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1681
    aCollectionOfVarNames do:[:name |
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1682
        |source varType methodName holderMethodName defaultMethodName|
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1683
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1684
        holderMethodName := name.
6643
abd4749a00ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6350
diff changeset
  1685
        name isUppercaseFirst ifTrue:[
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1686
            holderMethodName := holderMethodName asLowercaseFirst. 
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1687
        ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1688
        (holderMethodName endsWith:'Holder') ifTrue:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1689
            methodName := holderMethodName copyWithoutLast:6.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1690
        ] ifFalse:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1691
            methodName := holderMethodName.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1692
            holderMethodName := methodName , 'Holder'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1693
        ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1694
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1695
        methodName notNil ifTrue:[
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1696
            (metaClass includesSelector:(methodName asSymbol)) ifFalse:[
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1697
                source := '%1\'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1698
                generateComments ifTrue:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1699
                    source := source , '    "return the value in ''%2''"\\'. 
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1700
                ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1701
                source := source , '    ^ self %2 value'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1702
                source := (source bindWith:methodName with:holderMethodName) withCRs.
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1703
                self compile:source forClass:nonMetaClass inCategory:('accessing').
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1704
            ] ifTrue:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1705
                Transcript showCR:'method ''', methodName , ''' already present'
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1706
            ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1707
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1708
            (metaClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1709
                source := '%1: newValue\'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1710
                generateComments ifTrue:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1711
                    source := source , '    "set the value in ''%2''"\\'. 
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1712
                ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1713
                source := source , '    self %2 value: newValue'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1714
                source := (source bindWith:methodName with:holderMethodName) withCRs.
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1715
                self compile:source forClass:nonMetaClass inCategory:('accessing').
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1716
            ] ifTrue:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1717
                Transcript showCR:'method ''', methodName , ':'' already present'
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1718
            ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1719
        ].
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1720
        (metaClass includesSelector:(holderMethodName asSymbol)) ifFalse:[
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1721
            source := '%1\'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1722
            generateComments ifTrue:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1723
                source := source , '    "return/create the valueHolder ''%1''"\\'. 
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1724
            ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1725
            source := source , '    %1 isNil ifTrue:[\'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1726
            source := source , '        %1 := ValueHolder with:nil "defaultValue here".\'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1727
            source := source , '    ].\'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1728
            source := source , '    ^ %1\'.
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1729
            source := (source bindWith:holderMethodName) withCRs.
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1730
            self compile:source forClass:nonMetaClass inCategory:('accessing').
5763
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1731
        ] ifTrue:[
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1732
            Transcript showCR:'method ''', methodName , ''' already present'
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1733
        ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1734
    ].
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1735
8cce359fd150 add valueHolder
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
  1736
    self executeCollectedChangesNamed:('Add ValueHolder').
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1737
! !
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  1738
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1739
!CodeGeneratorTool methodsFor:'code generation-individual methods'!
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
createAcceptVisitorMethod:selector in:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
    "create an acceptVisitor: method
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1743
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1744
6921
821413de0099 leftover halt.
Claus Gittinger <cg@exept.de>
parents: 6839
diff changeset
  1745
    self assert:( aClass isMeta not ).
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1746
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1747
    (aClass includesSelector:#'acceptVisitor:') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1749
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
(('acceptVisitor:aVisitor 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
    "Double dispatch back to the visitor, passing my type encoded in
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
     the selector (visitor pattern)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
    "stub code automatically generated - please change if required"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
    ^ aVisitor %1self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1757
') bindWith:selector)
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
            forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
            inCategory:'visiting'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
    ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1763
createAcceptVisitorMethodIn:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1764
    "create an acceptVisitor: method
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
    self
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
        createAcceptVisitorMethod:('visit' , aClass nameWithoutPrefix , ':') asSymbol
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
        in:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
createCopyrightMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
    "add copyright method containing your/your companies
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
     copyright template but only if not already present.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1775
     this is only added, if specified in the 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1776
     COPYRIGHT_TEMPLATE_FILE resources."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
    |fn txt|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1779
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1780
    (aClass includesSelector:#copyright) ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1781
        fn := SystemBrowser classResources at:#'COPYRIGHT_TEMPLATE_FILE' default:nil.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1782
        fn notNil ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1783
            fn := fn asFilename.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1784
            fn exists ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1785
                txt := fn contents asString
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1786
            ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1787
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1788
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1789
        txt notNil ifTrue:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
            txt := txt bindWith:(Date today year).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
            self compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
'copyright
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
' , txt , '
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
'             forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1797
              inCategory:'documentation'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1798
        ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1799
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1800
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1802
createDocumentationMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1803
    "add documentation method containing doc template
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1804
     but only if not already present."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1805
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1806
    |metaClass nonMetaClass userName loginName hostName emailAddress code existingComment|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1807
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1808
    metaClass := aClass theMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1809
    nonMetaClass := aClass theNonMetaclass.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1811
    (metaClass includesSelector:#documentation) ifFalse:[
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1812
        existingComment := nonMetaClass comment.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1813
        existingComment isEmptyOrNil ifTrue:[
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1814
            (nonMetaClass isSubclassOf:HTTPService) ifTrue:[
6159
2707b35f964c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  1815
                existingComment := '    [start Server with:]
7545
df2fc5dbee78 changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents: 7480
diff changeset
  1816
        HTTPServer startServerOnPort:8080
6159
2707b35f964c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  1817
2707b35f964c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  1818
    [start with:]
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1819
        (self new)
7545
df2fc5dbee78 changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents: 7480
diff changeset
  1820
            registerServiceOn:(HTTPServer runningServerOnPort:8080)'.
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1821
            ].
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1822
        ].
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1823
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1824
        userName := OperatingSystem getFullUserName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1825
        loginName := OperatingSystem getLoginName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1826
        hostName := OperatingSystem getHostName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1827
        emailAddress := loginName , '@' , hostName.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1828
5756
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1829
        "/ ugly; should ask the class for that    
6350
421d6bb17db5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6349
diff changeset
  1830
        metaClass isJavaScriptMetaclass ifTrue:[
5756
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1831
            code :=
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1832
'function documentation() {
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1833
/*
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1834
' , (existingComment ? '    documentation to be added.') , '
5756
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1835
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1836
    [author:]
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1837
        ' , userName 
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1838
          , ' (' , emailAddress , ')' , '
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1839
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1840
    [instance variables:]
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1841
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1842
    [class variables:]
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1843
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1844
    [see also:]
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1845
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1846
*/
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1847
}
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1848
'
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1849
        ] ifFalse:[
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1850
            code:= 
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1851
'documentation
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
"
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1853
' , (existingComment ? '    documentation to be added.') , '
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1854
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
    [author:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1856
        ' , userName 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1857
          , ' (' , emailAddress , ')' , '
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1858
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1859
    [instance variables:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1861
    [class variables:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1862
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1863
    [see also:]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1864
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
"
5756
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1866
'
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1867
        ].
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1868
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1869
        self 
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1870
            compile:code
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1871
            forClass:metaClass 
5756
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  1872
            inCategory:'documentation'.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1873
    ].
7545
df2fc5dbee78 changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents: 7480
diff changeset
  1874
df2fc5dbee78 changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents: 7480
diff changeset
  1875
    "Modified: / 24-11-2006 / 15:54:27 / cg"
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1876
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1877
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1878
createExamplesMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1879
    "add examples method containing examples template
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1880
     but only if not already present."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1881
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1882
    |nonMetaclass fragment|
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1883
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1884
    nonMetaclass := aClass theNonMetaclass.
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1885
    (nonMetaclass isSubclassOf:ApplicationModel) ifFalse:[
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1886
        ^ self
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1887
    ].
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1888
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1889
    (aClass includesSelector:#examples) ifFalse:[
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1890
        (nonMetaclass isSubclassOf:ApplicationModel) ifTrue:[
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
            fragment := '  Starting the application:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1892
                                                                [exBegin]
6050
300b21c10c71 *** empty log message ***
ca
parents: 5953
diff changeset
  1893
    ' , nonMetaclass name , ' open
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1894
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1895
                                                                [exEnd]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1896
'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1897
        ] ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1898
            fragment := ''
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1900
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1901
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1902
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1903
'examples
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1904
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1905
' , fragment , '
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1906
  more examples to be added:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1907
                                                                [exBegin]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1908
    ... add code fragment for 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1909
    ... executable example here ...
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1910
                                                                [exEnd]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1911
"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1912
'                   
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1913
            forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1914
            inCategory:'documentation'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1915
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1916
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1917
3822
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1918
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
  1919
    |imageStoreStream mthd imageKey category|
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1920
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1921
    anImage storeOn: (imageStoreStream := WriteStream on: '').
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1922
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1923
    "/ 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
  1924
    category := 'image specs'.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1925
    (mthd := aClass compiledMethodAt:sel) notNil ifTrue:[
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1926
        category := mthd category.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1927
    ].
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1928
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1929
    imageKey :=  (aClass name, ' ', sel) asSymbol.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1930
    Icon constantNamed: imageKey put:nil.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1931
    aClass
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1932
        compile: ((sel,
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1933
            '\', comment,
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1934
            '\\' , 
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1935
            '    "\',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1936
            '     self ' , sel , ' inspect\',
3823
1ed101fe88a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3822
diff changeset
  1937
            '     ImageEditor openOnClass:self andSelector:#', sel, '\',
3822
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1938
            '     Icon flushCachedIcons', 
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1939
            '\    "',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1940
            '\\',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1941
            '    <resource: #image>',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1942
            '\\',
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1943
            '    ^Icon\') withCRs, 
7967
2560906ca552 use string-key in constantNamed:-icon caching
Claus Gittinger <cg@exept.de>
parents: 7615
diff changeset
  1944
            '        constantNamed:''', imageKey, '''\' withCRs,
3822
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1945
            '        ifAbsentPut:[', imageStoreStream contents, ']')
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1946
       classified: category.
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1947
!
4e9f2f69875f code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
  1948
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1949
createInitialHistoryMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1950
    "add history method containing created-entry
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1951
     but only if not already present."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1952
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1953
    |code|
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1954
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1955
    (aClass includesSelector:#history) ifFalse:[ 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1956
        HistoryManager notNil ifTrue:[
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1957
            code := HistoryManager codeForInitialHistoryMethodIn:aClass.
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1958
            self
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1959
                compile:code
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1960
                forClass:aClass 
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  1961
                inCategory:'documentation'.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1962
        ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1963
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1964
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1965
4512
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1966
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1967
    "add an inst-creation method"
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1968
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1969
    |template|
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1970
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1971
    (aMetaClass includesSelector:selector) ifFalse:[
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1972
        template := Parser methodSpecificationForSelector:selector.
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1973
        self 
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1974
            compile:
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1975
template , '
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1976
    ^ self new ' , template , '
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1977
'                   
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1978
            forClass:aMetaClass 
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1979
            inCategory:category.
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1980
    ].
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1981
!
117fa43d16eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4444
diff changeset
  1982
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1983
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1984
    "create a multi-setter method for instvars."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1985
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1986
    |source|
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1987
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
    source := ''.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
    aCollectionOfVarNames do:[:eachVar |
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1990
        source := source , (eachVar , ':' , eachVar , 'Arg ').
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1991
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1992
    source := source , Character cr.
6992
93d4212a20d5 no comment in multi-setter
Claus Gittinger <cg@exept.de>
parents: 6972
diff changeset
  1993
    (UserPreferences current generateCommentsForSetters) ifTrue:[
6993
22233dd2489d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6992
diff changeset
  1994
        source := source , ('    "set instance variables"' , Character cr , Character cr).
6992
93d4212a20d5 no comment in multi-setter
Claus Gittinger <cg@exept.de>
parents: 6972
diff changeset
  1995
    ].
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1996
    aCollectionOfVarNames do:[:eachVar |
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1997
        source := source , ('    ' , eachVar , ' := ' , eachVar , 'Arg.' , Character cr).
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1998
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1999
    self compile:source forClass:aClass inCategory:'accessing'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2000
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2001
3800
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2002
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2003
    "add a subclassResponsibility method;
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2004
     but only if not already present."
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2005
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2006
    (aClass includesSelector:aSelector) ifFalse:[
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2007
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2008
        self compile:
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2009
(Method methodDefinitionTemplateForSelector:aSelector) ,
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2010
'
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2011
    "raise an error: must be redefined in concrete subclass(es)"
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2012
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2013
    ^ self subclassResponsibility
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2014
' 
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2015
              forClass:aClass 
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2016
              inCategory:cat.
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2017
    ].
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2018
!
a5c75c369855 added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents: 3719
diff changeset
  2019
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2020
createUpdateMethodIn:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2021
    "create an update:with:from:-method
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2022
     (I'm tired of typing)"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2023
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2024
    (aClass includesSelector:#'update:with:from:') ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2025
        self 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2026
            compile:
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
'update:something with:aParameter from:changedObject
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2028
    "Invoked when an object that I depend upon sends a change notification."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2029
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2030
    "stub code automatically generated - please change as required"
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2031
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2032
    "/ changedObject == someOfMyValueHolders ifTrue:[
4926
f0ab6bb01771 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4908
diff changeset
  2033
    "/     self doSomethingApropriate.
f0ab6bb01771 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4908
diff changeset
  2034
    "/     ^ self.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2035
    "/ ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2036
    super update:something with:aParameter from:changedObject
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2037
'
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2038
            forClass:aClass 
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2039
            inCategory:'change & update'.
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2040
    ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2041
!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2042
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2043
createVersionMethodFor:aClass
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2044
    "add version method containing RCS template
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2045
     but only if not already present and its not a private class."
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2046
5756
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2047
    |code|
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2048
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2049
    aClass isPrivate ifFalse:[
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2050
        (aClass includesSelector:#version) ifFalse:[
5756
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2051
            "/ ugly; should ask the class for that    
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2052
            aClass isJavaScriptClass ifTrue:[
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2053
                code:= ('function version() {\    return ("$' , 'Header$");\}') withCRs
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2054
            ] ifFalse:[
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2055
                code:= ('version\    ^ ''$' , 'Header$''') withCRs
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2056
            ].
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2057
            self 
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2058
                compile:code
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2059
                forClass:aClass 
66261b5c4659 *** empty log message ***
ca
parents: 5494
diff changeset
  2060
                inCategory:'documentation'.
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2061
        ]
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2062
    ].
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2063
! !
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2064
7480
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2065
!CodeGeneratorTool methodsFor:'code templates'!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2066
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2067
codeFor_closeAccept
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2068
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2069
'closeAccept
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2070
    "This is a hook method generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2071
     It will be invoked when your dialog-window is closed with OK."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2072
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2073
    "/ add any actions as required here ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2074
    Transcript showCR:''dialog accepted''.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2075
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2076
    "/ do not remove the one below (otherwise, the dialog will not close itself)...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2077
    ^ super closeAccept
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2078
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2079
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2080
    "Created: / 27-10-2006 / 10:03:31 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2081
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2082
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2083
codeFor_closeDownViews
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2084
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2085
'closeDownViews
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2086
    "This is a hook method generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2087
     It will be invoked when your app/dialog-window is really closed.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2088
     See also #closeDownViews, which is invoked before and may suppress the close
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2089
     or ask the user for confirmation."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2090
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2091
    "/ change the code below as required ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2092
    "/ This should cleanup any leftover resources
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2093
    "/ (for example, temporary files)
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2094
    "/ super closeRequest will initiate the closeDown
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2095
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2096
    "/ add your code here
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2097
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2098
    "/ do not remove the one below ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2099
    ^ super closeDownViews
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2100
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2101
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2102
    "Created: / 27-10-2006 / 10:01:32 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2103
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2104
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2105
codeFor_closeRequest
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2106
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2107
'closeRequest
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2108
    "This is a hook method generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2109
     It will be invoked when your app/dialog-window is about to be
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2110
     closed (this method has a chance to suppress the close).
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2111
     See also #closeDownViews, which is invoked when the close is really done."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2112
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2113
    "/ change the code below as required ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2114
    "/ Closing can be suppressed, by simply returning.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2115
    "/ The ''super closeRequest'' at the end will initiate the real closeDown
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2116
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2117
    self hasUnsavedChanges ifTrue:[
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2118
        (self confirm:(resources string:''Close without saving ?'')) ifFalse:[
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2119
            ^ self
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2120
        ]
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2121
    ].
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2122
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2123
    ^ super closeRequest
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2124
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2125
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2126
    "Created: / 27-10-2006 / 10:01:06 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2127
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2128
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2129
codeFor_doSaveAs
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2130
    ^ self codeFor_emptyMenuActionCodeFor:#doSaveAs menuItem:'save/saveAs'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2131
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2132
    "Created: / 27-10-2006 / 10:22:06 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2133
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2134
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2135
codeFor_emptyMenuActionCodeFor:selector menuItem:item
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2136
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2137
selector,'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2138
    "This method was generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2139
     It will be invoked when the menu-item ''',item,''' is selected."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2140
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2141
    "/ change below and add any actions as required here ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2142
    self warn:''no action for ''''',item,''''' defined.''.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2143
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2144
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2145
    "Created: / 27-10-2006 / 10:16:43 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2146
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2147
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2148
codeFor_hasUnsavedChanges
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2149
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2150
'hasUnsavedChanges
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2151
    "Return true, if any unsaved changes are present 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2152
     (i.e. the contents needs to be saved or else will be lost)"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2153
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2154
    "/ add real code as required (or remove the halt and always return false)...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2155
    self halt:''check this code''.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2156
    ^ false.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2157
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2158
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2159
    "Created: / 27-10-2006 / 10:00:36 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2160
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2161
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2162
codeFor_menuNew
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2163
    ^ self codeFor_emptyMenuActionCodeFor:#menuNew menuItem:'new'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2164
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2165
    "Created: / 27-10-2006 / 10:17:08 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2166
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2167
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2168
codeFor_menuOpen
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2169
    ^ self codeFor_emptyMenuActionCodeFor:#menuOpen menuItem:'open'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2170
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2171
    "Created: / 27-10-2006 / 10:17:18 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2172
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2173
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2174
codeFor_menuSave
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2175
    ^ self codeFor_emptyMenuActionCodeFor:#menuSave menuItem:'save'
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2176
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2177
    "Created: / 27-10-2006 / 10:17:25 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2178
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2179
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2180
codeFor_menuSaveAs
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2181
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2182
'menuSaveAs
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2183
    "This method was generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2184
     It will be invoked when the menu-item ''saveAs'' is selected."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2185
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2186
    "/ change below as required... (see examples in Dialog class for more options)
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2187
    Dialog
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2188
        requestSaveFileName:(resources string:''Save'') 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2189
        default:''foo.txt'' 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2190
        fromDirectory:nil 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2191
        action:[:fileName | self doSaveAs:fileName] 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2192
        appendAction:nil.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2193
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2194
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2195
    "Created: / 27-10-2006 / 10:01:57 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2196
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2197
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2198
codeFor_openAboutThisApplication
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2199
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2200
'openAboutThisApplication
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2201
    "This method was generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2202
     It will be invoked when the menu-item ''help-about'' is selected."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2203
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2204
    "/ could open a customized aboutBox here ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2205
    super openAboutThisApplication
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2206
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2207
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2208
    "Created: / 27-10-2006 / 10:03:13 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2209
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2210
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2211
codeFor_openDocumentation
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2212
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2213
'openDocumentation
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2214
    "This method was generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2215
     It will be invoked when the menu-item ''help-documentation'' is selected."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2216
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2217
    "/ change below as required ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2218
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2219
    "/ to open an HTML viewer on some document (under ''doc/online/<language>/'' ):
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2220
    HTMLDocumentView openFullOnDocumentationFile:''TOP.html''.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2221
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2222
    "/ add application-specific help files under the ''doc/online/<language>/help/appName''
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2223
    "/ directory, and open a viewer with:
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2224
    "/ HTMLDocumentView openFullOnDocumentationFile:''help/<MyApplication>/TOP.html''.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2225
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2226
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2227
    "Created: / 27-10-2006 / 10:02:55 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2228
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2229
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2230
codeFor_postBuildWith
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2231
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2232
'postBuildWith:aBuilder
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2233
    "This is a hook method generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2234
     It will be invoked during the initialization of your app/dialog,
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2235
     after all of the visual components have been built, 
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2236
     but BEFORE the top window is made visible.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2237
     Add any app-specific actions here (reading files, setting up values etc.)
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2238
     See also #postOpenWith:, which is invoked after opening."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2239
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2240
    "/ add any code here ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2241
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2242
    ^ super postBuildWith:aBuilder
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2243
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2244
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2245
    "Created: / 27-10-2006 / 09:59:33 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2246
!
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2247
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2248
codeFor_postOpenWith
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2249
    ^
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2250
'postOpenWith:aBuilder
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2251
    "This is a hook method generated by the Browser.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2252
     It will be invoked right after the applications window has been opened.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2253
     Add any app-specific actions here (starting background processes etc.).
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2254
     See also #postBuildWith:, which is invoked before opening."
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2255
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2256
    "/ add any code here ...
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2257
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2258
    ^ super postOpenWith:aBuilder
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2259
'.
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2260
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2261
    "Created: / 27-10-2006 / 09:59:56 / cg"
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2262
! !
33930379ab27 code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents: 7470
diff changeset
  2263
6938
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2264
!CodeGeneratorTool methodsFor:'compilation'!
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2265
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2266
compile:theCode forClass:aClass inCategory:cat 
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2267
    "install some code for a class.
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2268
     If refactory browser stuff is avaliable the refactory tools are used to support undo"
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2269
7037
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2270
    self
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2271
        compile:theCode forClass:aClass inCategory:cat 
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2272
        skipIfSame:true
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2273
!
6938
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2274
7037
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2275
compile:theCode forClass:aClass inCategory:cat skipIfSame:skipIfSame 
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2276
    "install some code for a class.
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2277
     If refactory browser stuff is avaliable the refactory tools are used to support undo"
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2278
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2279
    |change compiler selector oldMthd isSame|
6938
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2280
7037
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2281
    isSame := false.
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2282
    skipIfSame ifTrue:[
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2283
        compiler := aClass compilerClass new.
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2284
        compiler parseMethod:theCode in:aClass ignoreErrors:true ignoreWarnings:true.
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2285
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2286
        selector := compiler selector.
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2287
        selector notNil ifTrue:[
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2288
            oldMthd := aClass compiledMethodAt:selector.
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2289
            isSame := (oldMthd notNil and:[oldMthd source = theCode]).
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2290
            isSame ifTrue:[ ^ self ].
6938
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2291
        ].
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2292
    ].
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2293
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2294
    self canUseRefactoringSupport ifFalse:[
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2295
        "/ compile immediately
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2296
        aClass compile:theCode classified:cat.
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2297
        ^ self.
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2298
    ].
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2299
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2300
    change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:cat.
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2301
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2302
    "/ if collecting, add to changes (to be executed as one change at the end,
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2303
    "/ in order to have only one change in the undo-list (instead of many)
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2304
    compositeChangeCollector notNil ifTrue:[
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2305
        compositeChangeCollector addChange:change
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2306
    ] ifFalse:[
7037
ec9705009031 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6993
diff changeset
  2307
        RefactoryChangeManager performChange:change.
6938
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2308
    ]
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2309
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2310
    "Modified: / 21-08-2006 / 18:39:06 / cg"
6cf52649971c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6937
diff changeset
  2311
! !
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2312
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  2313
!CodeGeneratorTool methodsFor:'private'!
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2314
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  2315
canUseRefactoringSupport
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  2316
    "check if refactory browser stuff is avaliable"
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  2317
5758
8f88193a4a93 collect changes
Claus Gittinger <cg@exept.de>
parents: 5756
diff changeset
  2318
     ^ self class canUseRefactoringSupport
5013
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  2319
!
0f2c39fc6e8c comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents: 4926
diff changeset
  2320
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2321
privCreateClassResponsibleProtocolFor:aClass
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2322
    "create stubs for the required protocol.
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2323
     aClass may be a a MetaClass or a non-MetaClass"
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2324
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2325
    |selectors|
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2326
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2327
    selectors := IdentitySet new.
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2328
    aClass allSuperclassesDo:[:eachSuperClass |
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2329
        eachSuperClass methodDictionary keysAndValuesDo:[:eachSelector :eachMethod |
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2330
            (eachMethod sends:#subclassResponsibility) ifTrue:[
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2331
                selectors add:eachSelector.
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2332
            ]
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2333
        ]
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2334
    ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2335
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2336
    selectors do:[:eachSelector |
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2337
        |mthd comment implClass methodBodyStream|
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2338
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2339
        implClass := aClass whichClassIncludesSelector:eachSelector.
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2340
        implClass ~~ aClass ifTrue:[
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2341
            mthd := implClass compiledMethodAt:eachSelector.
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2342
            (mthd sends:#subclassResponsibility) ifTrue:[
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2343
                methodBodyStream := '' writeStream.
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2344
                methodBodyStream 
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2345
                    nextPutAll:mthd methodDefinitionTemplate; cr;
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2346
                    nextPutAll:'    "'.
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2347
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2348
                comment := mthd methodComment.
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2349
                comment isEmptyOrNil ifTrue:[
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2350
                    methodBodyStream 
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2351
                        nextPutAll:('Superclass <1s> says that I am responsible to implement this method'  
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2352
                                    expandMacrosWith:implClass name)
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2353
                ] ifFalse:[
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2354
                    comment asStringCollection do:[:eachLine|
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2355
                        methodBodyStream nextPutAll:eachLine.
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2356
                    ] separatedBy:[
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2357
                        methodBodyStream cr; nextPutAll:'     '.
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2358
                    ].
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2359
                ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2360
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2361
                methodBodyStream 
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2362
                    nextPut:$"; cr; cr;
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2363
                    nextPutAll:'    self shouldImplement'; cr.
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2364
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2365
                self 
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2366
                    compile:methodBodyStream contents
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2367
                    forClass:aClass 
6791
6559c9ebb561 Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents: 6718
diff changeset
  2368
                    inCategory:mthd category.
4108
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2369
            ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2370
        ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2371
    ].
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2372
! !
19af32811dfd Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents: 3823
diff changeset
  2373
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2374
!CodeGeneratorTool class methodsFor:'documentation'!
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2375
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2376
version
7973
7fb67608aa3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7967
diff changeset
  2377
    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.55 2008-02-11 14:24:42 cg Exp $'
3712
293c44b3c910 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2378
! !