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