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