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