UIPainterView.st
author Claus Gittinger <cg@exept.de>
Tue, 22 Feb 2000 16:35:23 +0100
changeset 1363 0a7e7a1ade85
parent 1362 b710bba663cb
child 1366 ffb95ba845ec
permissions -rw-r--r--
trace aspect-method generation on Transcript
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     1
"
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
     3
              All Rights Reserved
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     4
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     5
 This software is furnished under a license and may be used
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     6
 only in accordance with the terms of that license and with the
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
     7
 inclusion of the above copyright notice. This software may not
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     9
 other person.  No title to or ownership of the software is
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    10
 hereby transferred.
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    11
"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    12
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    13
UIObjectView subclass:#UIPainterView
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    14
	instanceVariableNames:'treeView listHolder superclassName className methodName
770
96f106b0a61e set color on device
ca
parents: 768
diff changeset
    15
		categoryName handleColor handleMasterColor'
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    16
	classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances'
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    17
	poolDictionaries:''
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    18
	category:'Interface-UIPainter'
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    19
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    20
211
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    21
Object subclass:#ViewProperty
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    22
	instanceVariableNames:'view spec identifier'
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    23
	classVariableNames:'Identifier'
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    24
	poolDictionaries:''
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    25
	privateIn:UIPainterView
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    26
!
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    27
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    28
!UIPainterView class methodsFor:'documentation'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    29
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    30
copyright
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    31
"
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    32
 COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    33
              All Rights Reserved
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    34
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    35
 This software is furnished under a license and may be used
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    36
 only in accordance with the terms of that license and with the
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
    37
 inclusion of the above copyright notice. This software may not
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    38
 be provided or otherwise made available to, or used by, any
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    39
 other person.  No title to or ownership of the software is
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    40
 hereby transferred.
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    41
"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    42
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    43
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    44
documentation
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    45
"
128
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    46
    buildIn view used by the UIPainter; from this view, the layout of the
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    47
    new application derives from.
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    48
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    49
    [see also:]
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    50
        UIBuilder
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
    51
        UIObjectView
156
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    52
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    53
    [author:]
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    54
        Claus Gittinger
b332d7117c40 added copyrights
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    55
        Claus Atzkern
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    56
"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    57
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
    58
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    59
!UIPainterView class methodsFor:'initialization'!
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    60
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    61
initialize
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    62
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    63
    AspectsAsInstances := false.
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    64
    RedefineAspectMethods := false.
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    65
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    66
    "Created: / 22.9.1999 / 12:32:31 / stefan"
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    67
! !
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    68
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    69
!UIPainterView class methodsFor:'code generation mode'!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    70
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    71
generateAspectsAsInstanceVariables
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    72
    "if on, aspects are held as instance variables;
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    73
     if off (the default), they are kept in the bindings dictionary.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    74
    "
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    75
    ^ AspectsAsInstances
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    76
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    77
    "Created: / 29.7.1998 / 11:21:38 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    78
    "Modified: / 29.7.1998 / 11:22:01 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    79
!
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    80
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    81
generateAspectsAsInstanceVariables:aBoolean
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    82
    "if on, aspects are held as instance variables;
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    83
     if off (the default), they are kept in the bindings dictionary.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    84
    "
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    85
    AspectsAsInstances := aBoolean
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    86
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    87
    "Created: / 29.7.1998 / 11:21:26 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    88
    "Modified: / 29.7.1998 / 11:22:11 / cg"
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    89
!
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
    90
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
    91
redefineAspectMethods
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    92
    "redefine methods yes or no. If a method is defined in super class
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    93
     should the message be reinstalled ?
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    94
    "
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    95
    ^ RedefineAspectMethods
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    96
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
    97
    "Modified: / 22.9.1999 / 12:33:03 / stefan"
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    98
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
    99
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
   100
redefineAspectMethods:aBoolean
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   101
    "redefine methods yes or no. If a method is defined in super class
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   102
     should the message be reinstalled ?
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   103
    "
742
688fd0a0b0fd code generation comment
tz
parents: 723
diff changeset
   104
    RedefineAspectMethods := aBoolean
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   105
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   106
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   107
! !
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   108
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   109
!UIPainterView class methodsFor:'defaults'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   110
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   111
defaultMenuMessage   
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   112
    "This message is the default yo be sent to the menuHolder to get a menu
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   113
    "
121
96d6feeeb049 middleButtonMen:
ca
parents: 119
diff changeset
   114
    ^ #showMiddleButtonMenu
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   115
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   116
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   117
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   118
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   119
!UIPainterView methodsFor:'accessing'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   120
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   121
application
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   122
    ^ nil
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   123
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   124
    "Modified: 6.9.1995 / 00:46:44 / claus"
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   125
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   126
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   127
applicationName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   128
    ^ self className
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   129
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   130
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   131
applicationName:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   132
    self className:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   133
!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   134
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   135
className
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   136
    ^ className
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   137
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   138
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   139
className:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   140
    className := aName
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   141
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   142
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   143
className:aClassName superclassName:aSuperclassName selector:aSelector
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   144
    className      := aClassName.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   145
    superclassName := aSuperclassName.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   146
    methodName     := aSelector.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   147
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   148
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   149
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   150
findInputViewIn:aSuperView
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   151
    "returns index of input view into superview or nil
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   152
    "
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   153
    aSuperView == self ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   154
        ^ self subViews findFirst:[:v| v == inputView ]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   155
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   156
  ^ 0
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   157
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   158
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   159
inputView
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   160
    ^ inputView
111
ca
parents: 103
diff changeset
   161
!
ca
parents: 103
diff changeset
   162
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   163
methodName
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   164
    ^ methodName
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   165
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   166
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   167
methodName:aName
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   168
    methodName := aName
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   169
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   170
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   171
selectNames:aStringOrCollection
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   172
    |prop coll s n newSel|
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   173
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   174
    (aStringOrCollection size == 0) ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   175
        newSel := nil.
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   176
    ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   177
        (s := aStringOrCollection) isString ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   178
            s size == 1 ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   179
                s := s first
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   180
            ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   181
                coll := OrderedCollection new.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   182
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   183
                s do:[:aName|
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   184
                    (prop := self propertyOfName:aName) notNil ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   185
                        coll add:(prop view)
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   186
                    ]
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   187
                ].
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   188
                (n := coll size) == 1 ifTrue:[ 
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   189
                    newSel := coll at:1 
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   190
                ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   191
                    n == 0 ifTrue:[ 
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   192
                        newSel := nil
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   193
                    ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   194
                        newSel := coll
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   195
                    ]
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   196
                ].
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   197
                ^ self select:newSel.
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   198
            ]
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   199
        ].
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   200
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   201
        prop := self propertyOfName:s.
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   202
        prop isNil ifTrue:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   203
            newSel := nil
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   204
        ] ifFalse:[
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   205
            newSel := prop view
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   206
        ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   207
    ].
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   208
1031
7ce4b97f2c43 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1030
diff changeset
   209
    ^ self select:newSel
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   210
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   211
111
ca
parents: 103
diff changeset
   212
!UIPainterView methodsFor:'change & update'!
ca
parents: 103
diff changeset
   213
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   214
layoutChanged
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   215
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   216
    treeView layoutChanged
111
ca
parents: 103
diff changeset
   217
! !
ca
parents: 103
diff changeset
   218
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   219
!UIPainterView methodsFor:'copy & cut & paste'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   220
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   221
copySelection
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   222
    "copy the selection into the cut&paste-buffer
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   223
    "
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   224
    |specs coll sel|
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   225
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   226
    sel := treeView selection.
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   227
128
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
   228
    coll := self minSetOfSuperViews:(self selection).
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   229
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   230
    coll notNil ifTrue:[
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   231
"/        self select:nil.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   232
        specs := coll collect:[:aView| self fullSpecFor:aView ].
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   233
        self setSelection:specs.
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   234
"/        treeView selection: sel
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   235
    ].
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   236
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   237
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   238
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   239
723
60e8ffac2f38 #deleteSelection in #deleteTotalSelection renamed
tz
parents: 712
diff changeset
   240
deleteSelection
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   241
    "delete the selection buffered
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   242
    "
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   243
    self deleteSelectionBuffered: true
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   244
!
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   245
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   246
deleteSelectionBuffered: buffered
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   247
    "cut the selection into the cut&paste-buffer
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   248
     and open a transaction
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   249
    "
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   250
    |specs coll oldSelectedNode newSelectedNode newSelection|
71
407d25aca670 checkin from browser
ca
parents: 69
diff changeset
   251
128
9779b7459a1c selection and update from selection
ca
parents: 121
diff changeset
   252
    coll := self minSetOfSuperViews:(self selection).
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   253
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   254
    coll notNil ifTrue:[
238
882be7e03af4 renamed claus instVar (;-)
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   255
        treeView cvsEventsDisabledDo:[
886
3c67610b9631 after deleting a widget do select the neighbour then the parent
tz
parents: 858
diff changeset
   256
1015
a5d37f30faa8 multiple selection/first node=root/delete - error fixed
tz
parents: 1013
diff changeset
   257
            ((oldSelectedNode := (treeView model selectedNodes at: 1 ifAbsent: nil)) notNil and:
a5d37f30faa8 multiple selection/first node=root/delete - error fixed
tz
parents: 1013
diff changeset
   258
            [oldSelectedNode parent notNil]) ifTrue: [
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   259
                oldSelectedNode parent children size <= 1 ifTrue: [
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   260
                    newSelectedNode := oldSelectedNode parent
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   261
                ]
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   262
                ifFalse: [
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   263
                    newSelectedNode := oldSelectedNode parent children 
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   264
                        at: (oldSelectedNode parent indexOfChild: oldSelectedNode) - 1 
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   265
                        ifAbsent: [oldSelectedNode parent children at: 2]
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   266
                ].
886
3c67610b9631 after deleting a widget do select the neighbour then the parent
tz
parents: 858
diff changeset
   267
            ].
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   268
            self hideSelection.
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   269
            selection := nil.
111
ca
parents: 103
diff changeset
   270
            specs := coll collect:[:aView| self fullSpecFor:aView ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   271
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   272
            self withinTransaction:#cut objects:coll do:[
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   273
                coll reverseDo:[:aView|
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   274
                    self createUndoRemove:aView.
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   275
                    self remove:aView.
111
ca
parents: 103
diff changeset
   276
                ]
ca
parents: 103
diff changeset
   277
            ].
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   278
            buffered ifTrue: [self setSelection: specs].
886
3c67610b9631 after deleting a widget do select the neighbour then the parent
tz
parents: 858
diff changeset
   279
            treeView selection: nil. 
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   280
            (newSelection := (treeView model indexOf:newSelectedNode)) > 0 ifFalse: [
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   281
                 newSelection := 1
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   282
            ].
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   283
            treeView selection: (Array with: newSelection).
886
3c67610b9631 after deleting a widget do select the neighbour then the parent
tz
parents: 858
diff changeset
   284
            self setSelection:treeView selectedNode contents view withRedraw: true.
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   285
        ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   286
    ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   287
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   288
723
60e8ffac2f38 #deleteSelection in #deleteTotalSelection renamed
tz
parents: 712
diff changeset
   289
deleteTotalSelection
887
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   290
    "delete the selection
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   291
    "            
79a6e12e1d0f after deleting a widget do select the neighbour then the parent (step 2)
tz
parents: 886
diff changeset
   292
    self deleteSelectionBuffered: false
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   293
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   294
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   295
pasteBuffer
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   296
    "add the objects in the paste-buffer to the object view
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   297
    "
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   298
    |sel|
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   299
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   300
    sel := self pasteSpecifications:(self getSelection) keepLayout:false.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   301
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   302
    sel notNil ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   303
        self select:sel.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   304
    ].
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   305
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   306
!
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   307
392
ca
parents: 376
diff changeset
   308
pasteFromClipBoard:aString
ca
parents: 376
diff changeset
   309
    ^ self
ca
parents: 376
diff changeset
   310
ca
parents: 376
diff changeset
   311
ca
parents: 376
diff changeset
   312
!
ca
parents: 376
diff changeset
   313
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   314
pasteKeepingPosition
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   315
    "add the objects in the paste-buffer to the object view; 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   316
     translate the layout as appropriate, to position the component
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   317
     at the same absolute position (relative to topView) as before
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   318
    "
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   319
    |sel|
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   320
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   321
    sel := self
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   322
        pasteSpecifications:(self getSelection) 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   323
        keepLayout:true 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   324
        keepPosition:true 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   325
        at:nil.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   326
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   327
    sel notNil ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   328
        self select:sel.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   329
    ].
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   330
!
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   331
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   332
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   333
    "add the specs to the object view; returns list of pasted components
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   334
    "
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   335
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   336
    ^ self
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   337
        pasteSpecifications:aSpecificationOrList 
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   338
        keepLayout:keepLayout 
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   339
        at:nil
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   340
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   341
    "Modified: 11.8.1997 / 01:00:35 / cg"
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   342
!
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   343
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   344
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   345
    "add the specs to the object view; returns list of pasted components
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   346
    "
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   347
    self 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   348
        pasteSpecifications:aSpecificationOrList 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   349
        keepLayout:keepLayout 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   350
        keepPosition:false 
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   351
        at:aPointOrNil
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   352
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   353
!
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   354
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   355
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   356
    "add the specs to the object view; returns list of pasted components
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   357
    "
312
386932d91a97 paste at a point; first translate the point
ca
parents: 310
diff changeset
   358
    |paste frame pasteOrigin pasteOffset builder newSel bounds|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   359
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   360
    (self canPaste:aSpecificationOrList) ifFalse:[
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   361
        ^ nil
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   362
    ].
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   363
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   364
    aSpecificationOrList isCollection ifTrue:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   365
        paste := aSpecificationOrList
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   366
    ] ifFalse:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   367
        paste := Array with:aSpecificationOrList
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   368
    ].
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   369
    (frame := self singleSelection) isNil ifTrue:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   370
        frame := self
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   371
    ].
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   372
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   373
    self selection:nil.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   374
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   375
    newSel  := OrderedCollection new.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   376
    builder := UIBuilder new isEditing:true.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   377
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   378
    className notNil ifTrue:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   379
        builder applicationClass:(self resolveName:className)
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   380
    ].
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   381
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   382
    (keepLayout not or:[keepPosition]) ifTrue:[
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   383
        pasteOffset := 0@0.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   384
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   385
        keepPosition ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   386
            pasteOrigin := device translatePoint:0@0
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   387
                                            from:self id
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   388
                                              to:frame id.
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   389
        ] ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   390
            aPointOrNil isNil ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   391
                pasteOrigin := self sensor mousePoint.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   392
                pasteOrigin := device translatePoint:pasteOrigin
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   393
                                            from:device rootView id
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   394
                                              to:frame id.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   395
            ] ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   396
                pasteOrigin := device translatePoint:aPointOrNil
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   397
                                                from:self id
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   398
                                                  to:frame id.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   399
            ]
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   400
        ].
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   401
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   402
        bounds := Rectangle origin:0@0 extent:(frame bounds extent)
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   403
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   404
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   405
    paste do:[:aSpec|
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   406
        |view newOrigin|
395
d39076243277 sett UIBuilder isEditing to true
ca
parents: 392
diff changeset
   407
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   408
        view := self addSpec:aSpec builder:builder in:frame.
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   409
1338
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   410
        keepPosition ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   411
            self moveObject:view to:(view origin + pasteOrigin).
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   412
        ] ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   413
            keepLayout ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   414
                (bounds containsPoint:pasteOrigin) ifFalse:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   415
                    newOrigin := pasteOffset.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   416
                ] ifTrue:[
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   417
                    newOrigin := pasteOrigin + pasteOffset.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   418
                ].
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   419
                self moveObject:view to:newOrigin.
3c1a528c50db added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   420
                pasteOffset := pasteOffset + 4
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   421
            ].
312
386932d91a97 paste at a point; first translate the point
ca
parents: 310
diff changeset
   422
        ].
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   423
        view realize.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   424
        newSel add:view.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   425
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   426
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   427
    self withinTransaction:#paste objects:newSel do:[
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   428
        undoHistory addUndoSelector:#undoCreate:
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   429
                           withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier])
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   430
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   431
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   432
    self realizeAllSubViews.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   433
    newSel do:[:v| v raise].
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   434
    inputView raise.
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   435
    self elementChangedSize:frame.
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   436
776
1df0525eeec9 reuse methods provided by the model
ca
parents: 770
diff changeset
   437
    newSel size == 1 ifTrue:[newSel := newSel at:1].
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   438
    ^ newSel
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   439
!
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   440
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   441
pasteWithLayout
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   442
    "add the objects in the paste-buffer to the object view; don't change the
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   443
     layout
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   444
    "
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   445
    |sel|
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   446
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   447
    sel := self pasteSpecifications:(self getSelection) keepLayout:true.
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   448
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   449
    sel notNil ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   450
        self select:sel.
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   451
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   452
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   453
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   454
!UIPainterView methodsFor:'drag & drop'!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   455
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   456
canDrop:something
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   457
    "returns true if something can be droped
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   458
    "      
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   459
    (something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   460
      ^ something first theObject isKindOf:UISpecification
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   461
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   462
    ^ false
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   463
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   464
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   465
canPaste
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   466
    "returns true if something to be past exists and can be paste into
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   467
     the selection if exists
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   468
    "
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   469
    ^ self canPaste:(self getSelection)
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   470
!
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   471
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   472
canPaste:something
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   473
    "returns true if something could be paste
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   474
    "
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   475
    |el size|
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   476
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   477
    ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   478
        ^ false
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   479
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   480
    something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   481
                          ifFalse:[el := something].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   482
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   483
    (el isKindOf:UISpecification) ifFalse:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   484
        ^ false
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   485
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   486
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   487
    size == 1 ifTrue:[
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   488
        ^ self canPasteInto:(self singleSelection)
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   489
    ].
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   490
  ^ true
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   491
!
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   492
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   493
canPasteInto:aView
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   494
    "can paste into a view
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   495
    "
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   496
    |prop|
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   497
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   498
    aView notNil ifTrue:[
285
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   499
        (prop := self propertyRespondsToView:aView) notNil ifTrue:[
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   500
            ^ prop spec class supportsSubComponents
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   501
        ].
d80b3c6a4373 don't use superView instead parent properties derived
ca
parents: 281
diff changeset
   502
      ^ aView specClass supportsSubComponents.
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   503
    ].
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   504
    ^ false
96
73725336b4fe dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   505
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   506
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   507
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   508
drop:anObjectOrCollection at:aPoint
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   509
    |spec newSel oldSel dragOffset|
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   510
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   511
    self selection notNil ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   512
        oldSel := self singleSelection.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   513
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   514
        (self canPasteInto:oldSel) ifFalse:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   515
            oldSel := nil.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   516
            self setSelection:nil withRedraw:true
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   517
        ]
231
75de472d579f check whether selection is a view or a collection
ca
parents: 223
diff changeset
   518
    ].
89
35c5711729c2 so far so good
ca
parents: 86
diff changeset
   519
    spec := (anObjectOrCollection at:1) theObject.
1060
0332a41de5c5 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1058
diff changeset
   520
    dragOffset := DragAndDropManager dragOffsetQuerySignal query.
278
5b7dfe33b497 drag & drop offset
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   521
    newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   522
223
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   523
    oldSel isNil ifTrue:[self select:newSel]
203460df426e change selection handling caused by new tree view
ca
parents: 219
diff changeset
   524
                ifFalse:[self select:oldSel]
1060
0332a41de5c5 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1058
diff changeset
   525
0332a41de5c5 Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents: 1058
diff changeset
   526
    "Modified: / 18.3.1999 / 18:29:43 / stefan"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   527
! !
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   528
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   529
!UIPainterView methodsFor:'event handling'!
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   530
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   531
keyPress:key x:x y:y view:aView
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   532
    "a delegated keyEvent from aView"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   533
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   534
    self keyPress:key x:x y:y
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   535
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   536
    "Modified: / 31.10.1997 / 20:27:22 / cg"
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   537
!
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   538
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   539
keyRelease:key x:x y:y view:aView
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   540
    "a delegated keyEvent from aView"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   541
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   542
    self keyRelease:key x:x y:y
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   543
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   544
    "Modified: / 31.10.1997 / 20:27:32 / cg"
754
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   545
!
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   546
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   547
sizeChanged:how
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   548
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   549
    super sizeChanged:how. 
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   550
04e802a6a920 color master selection in red + grid background colored
tz
parents: 744
diff changeset
   551
    self layoutChanged
361
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   552
! !
6624bb5d9a1a configuration of grid parameters
ca
parents: 352
diff changeset
   553
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   554
!UIPainterView methodsFor:'generating output'!
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   555
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   556
aspectMethods
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   557
    "extract a list of aspect methods - for browsing"
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   558
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   559
    |cls methods skip selector protoSpec|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   560
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   561
    className isNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   562
        self warn:'set the class first'.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   563
        ^ #()
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   564
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   565
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   566
    cls := self resolveName:className.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   567
    methods := IdentitySet new.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   568
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   569
    treeView propertiesDo:[:aProp|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   570
        |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   571
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   572
        (selector := aProp model) notNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   573
            selector isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   574
                selector := selector asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   575
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   576
                    skip := false.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   577
                    (cls isSubclassOf:SimpleDialog) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   578
                        skip := SimpleDialog implements:selector asSymbol
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   579
                    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   580
                    skip ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   581
                        methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   582
                    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   583
                ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   584
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   585
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   586
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   587
        (selector := aProp menu) notNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   588
            selector isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   589
                selector := selector asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   590
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   591
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   592
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   593
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   594
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   595
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   596
        (aProp spec aspectSelectors) do:[:aSel |
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   597
            |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   598
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   599
            aSel isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   600
                selector := aSel asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   601
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   602
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   603
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   604
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   605
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   606
        aProp spec actionSelectors do:[:aSel|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   607
            |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   608
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   609
            aSel isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   610
                selector := aSel asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   611
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   612
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   613
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   614
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   615
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   616
        aProp spec valueSelectors do:[:aSel|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   617
            |selector|
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   618
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   619
            aSel isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   620
                selector := aSel asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   621
                (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   622
                    methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   623
                ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   624
            ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   625
        ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   626
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   627
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   628
    protoSpec := treeView canvasSpec.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   629
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   630
    (selector := protoSpec menu) notNil ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   631
        selector isArray ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   632
            selector := selector asSymbol.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   633
            (cls implements:selector) ifTrue:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   634
                methods add:(cls compiledMethodAt:selector)
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   635
            ]
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   636
        ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   637
    ].
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   638
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   639
    ^ methods
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   640
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   641
    "Created: / 25.10.1997 / 18:58:25 / cg"
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   642
    "Modified: / 26.10.1997 / 15:06:18 / cg"
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   643
!
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   644
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   645
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   646
    |selector args showIt code alreadyInSuperclass numArgs method|
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   647
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   648
    selector := aspect asSymbol.
141
d06c04391233 generate actions with argument
ca
parents: 137
diff changeset
   649
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   650
    alreadyInSuperclass := targetClass superclass canUnderstand:selector.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   651
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   652
    numArgs := selector numArgs.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   653
    method  := aspect.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   654
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   655
    numArgs == 1 ifTrue:[
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   656
        args := 'anArgument'.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   657
        showIt := ''' , anArgument printString , '' ...''.\'.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   658
    ] ifFalse:[    
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   659
        args := ''.
149
e652608690b1 help ...
ca
parents: 146
diff changeset
   660
        showIt := ' ...''.\'.
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   661
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   662
        numArgs ~~ 0 ifTrue:[
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   663
            method := ''.
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   664
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   665
            selector keywords keysAndValuesDo:[:i :key|
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   666
                method := method, key, 'arg', i printString, ' '
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   667
            ]
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   668
        ]
149
e652608690b1 help ...
ca
parents: 146
diff changeset
   669
    ].
141
d06c04391233 generate actions with argument
ca
parents: 137
diff changeset
   670
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   671
    code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
568
7c4482bf37cf allow more than 1 numArg for an action
ca
parents: 511
diff changeset
   672
                method , args , '\' ,
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   673
                '    "automatically generated by UIPainter ..."\\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   674
                '    "*** the code below performs no action"\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   675
                '    "*** (except for some feedback on the Transcript)"\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   676
                '    "*** Please change as required and accept in the browser."\' ,
288
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   677
                '\' .
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   678
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   679
    alreadyInSuperclass ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   680
        code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   681
                    '    "action for ' , aspect , ' is already provided in a superclass."\' ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   682
                    '    "It may be redefined here ..."\\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   683
    ] ifFalse:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   684
        code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   685
                    '    "action to be added ..."\\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   686
    ].
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   687
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   688
    code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   689
                '    Transcript showCR:self class name, '': '.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   690
    alreadyInSuperclass ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   691
        code := code , 'inherited '.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   692
    ].
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   693
    code := code , 'action for ' , aspect , showIt.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   694
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   695
    alreadyInSuperclass ifTrue:[
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   696
        code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   697
                        '    super ' , aspect , args , '.\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   698
    ].
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   699
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   700
    code := code ,
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   701
                '!! !!\\'.
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   702
    ^ code withCRs
675327dd4d7d change drop mechanism:
ca
parents: 285
diff changeset
   703
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   704
    "Modified: / 25.10.1997 / 19:18:50 / cg"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   705
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   706
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   707
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass
1257
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   708
    |modelClass modelValueString modelValue modelGen code|
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   709
149
e652608690b1 help ...
ca
parents: 146
diff changeset
   710
    modelClass := protoSpec defaultModelClassFor:aspect.
1257
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   711
    modelValueString := protoSpec defaultModelValueStringFor:aspect.
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   712
    modelValueString notNil ifTrue:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   713
        modelGen := modelValueString
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   714
    ] ifFalse:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   715
        modelValue := protoSpec defaultModelValueFor:aspect.
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   716
        modelValue isNil ifTrue:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   717
            modelGen := modelClass name , ' new'
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   718
        ] ifFalse:[
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   719
            modelGen := modelValue storeString , ' asValue'
acb8c0a58ef3 dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents: 1252
diff changeset
   720
        ].
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   721
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   722
    ].
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   723
655
093cba68e10a simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents: 588
diff changeset
   724
    code := '!!' , targetClass name , ' methodsFor:''aspects''!!\\' ,
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   725
      aspect , '\' ,
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   726
      '    "automatically generated by UIPainter ..."\\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   727
      '    "*** the code below creates a default model when invoked."\' ,
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   728
      '    "*** (which may not be the one you wanted)"\' ,
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   729
      '    "*** Please change as required and accept it in the browser."\'.
655
093cba68e10a simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents: 588
diff changeset
   730
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   731
    AspectsAsInstances ifTrue:[
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   732
        code := (code , '\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   733
          '    ' , aspect , ' isNil ifTrue:[\' ,
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   734
          '       ' , aspect , ' := ' , ' ' , modelGen , '.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   735
          '"/       ' , aspect , ' addDependent:self.\' ,
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   736
          '    ].\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   737
          '    ^ ' , aspect ,'.\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   738
          '!! !!\\') 
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   739
    ] ifFalse:[
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   740
        code := (code , '\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   741
          '    |holder|\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   742
          '\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   743
          '    (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' ,
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   744
          '        holder := ', modelGen, '.\',
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   745
          '        builder aspectAt:#' , aspect , ' put:holder.\',
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   746
          '"/        holder addDependent:self.\' ,
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   747
          '    ].\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   748
          '    ^ holder.\' ,
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   749
          '!! !!\\') 
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   750
    ].
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   751
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   752
    ^ code withCRs
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   753
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   754
    "Modified: / 29.7.1998 / 11:29:16 / cg"
1225
0aa39cc5f0a3 Initialize class vars.
Stefan Vogel <sv@exept.de>
parents: 1201
diff changeset
   755
    "Modified: / 22.9.1999 / 12:33:47 / stefan"
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   756
!
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   757
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   758
generateAspectMethods
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   759
    "generate aspect, action & menu methods
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   760
     - but do not overwrite existing ones.
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   761
     Return a string ready to compile into the application class."
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   762
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   763
    |cls code skip protoSpec thisCode
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   764
     definedMethodSelectors iVars t exportSels|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   765
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   766
    definedMethodSelectors := IdentitySet new.
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   767
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   768
    code := ''.
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   769
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   770
    className isNil ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   771
        self warn:'Set first the class!!'.
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   772
        ^ code
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   773
    ].
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   774
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   775
    (cls := self resolveName:className) isNil ifTrue:[
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   776
        self warn:'Class ', className asString, ' does not exist!!'.
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   777
        ^ code
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   778
    ].
60
7542ab7fbbfe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
   779
316
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
   780
    treeView propertiesDo:[:aProp|
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
   781
        |modelSelector|
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   782
134
d5ab85ec27fd undo history; keep view identifier
ca
parents: 131
diff changeset
   783
        protoSpec := aProp spec.
175
0b0b4d99e3e7 isResizeable
ca
parents: 165
diff changeset
   784
78
a0a00603a8b6 keep spec in properties
ca
parents: 75
diff changeset
   785
        (modelSelector := aProp model) notNil ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   786
            self generateCodeFrom:(Array with:modelSelector) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   787
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   788
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   789
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   790
                    sym := aSel asSymbol.
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   791
                    skip := false.
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   792
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   793
                    (cls isSubclassOf:SimpleDialog) ifTrue:[
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   794
                        skip := SimpleDialog implements:sym
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   795
                    ].
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   796
                    (definedMethodSelectors includes:sym) ifTrue:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   797
                        skip := true.
158
6e7f892308ae do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   798
                    ].
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   799
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   800
                    skip ifFalse:[
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   801
                        "/ kludge ..
796
05b2883a23b0 fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   802
                        "/ (protoSpec isKindOf:ActionButtonSpec) 
05b2883a23b0 fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   803
                        (protoSpec defaultModelIsCallBackMethodSelector:aSel)
05b2883a23b0 fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
   804
                        ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   805
                            thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls).
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   806
                        ] ifFalse:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   807
                            thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls).
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   808
                        ].
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   809
                        code := code, thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   810
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   811
                        Transcript showCR:'code generated for aspect: ' , sym
1030
0b9fbaecbe88 output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   812
                    ] ifTrue:[
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   813
                        Transcript showCR:'*** no code generated for aspect: ' , sym , ' (method already exists)'
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   814
                    ].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   815
                ].
62
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   816
        ].
0e8573b4329a so far so good ...
ca
parents: 60
diff changeset
   817
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   818
        "/ for each aspect, generate getter (if not yet implemented)
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   819
        self generateCodeFrom:(aProp spec aspectSelectors) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   820
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   821
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   822
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   823
                    sym := aSel asSymbol.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   824
                    (definedMethodSelectors includes:sym) ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   825
                        thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls).
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   826
                        code := code , thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   827
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   828
                        Transcript showCR:'code generated for aspect: ' , sym
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   829
                    ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   830
                ].
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   831
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   832
        "/ exported aspects - need setter methods
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   833
        exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   834
        self generateCodeFrom:exportSels in:cls
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   835
                do:[:aSel|
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   836
                    |sym aspect|
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   837
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   838
                    sym := aSel asSymbol.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   839
                    (definedMethodSelectors includes:sym) ifFalse:[
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   840
                        aspect := (aSel copyWithoutLast:1) asSymbol.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   841
                        thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls).
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   842
                        code := code , thisCode.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   843
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   844
                        Transcript showCR:'export code generated for aspect: ' , sym
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   845
                    ]
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   846
                ].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   847
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   848
        self generateCodeFrom:(aProp spec actionSelectors) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   849
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   850
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   851
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   852
                    sym := aSel asSymbol.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   853
                    (definedMethodSelectors includes:sym) ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   854
                        thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls).
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   855
                        code := code , thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   856
                        definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   857
                        Transcript showCR:'action generated for aspect: ' , sym
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   858
                    ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   859
                ].
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   860
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   861
        self generateCodeFrom:(aProp spec valueSelectors) in:cls
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   862
                do:[:aSel|
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   863
                    |sym|
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   864
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   865
                    sym := aSel asSymbol.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   866
                    (definedMethodSelectors includes:sym) ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   867
                        "/ uppercase: - assume its a globals name.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   868
                        aSel first isUppercase ifFalse:[
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   869
                            thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls).
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   870
                            code := code , thisCode.
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   871
                            definedMethodSelectors add:sym.
1363
0a7e7a1ade85 trace aspect-method generation on Transcript
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   872
                            Transcript showCR:'code generated for aspect: ' , sym
858
6b2e9e31cf06 do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents: 796
diff changeset
   873
                        ]
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
   874
                    ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   875
                ].
316
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
   876
    ].
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
   877
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   878
    AspectsAsInstances ifTrue:[
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   879
        iVars := cls instVarNames asOrderedCollection.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   880
        definedMethodSelectors do:[:ivar |
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   881
            (iVars includes:ivar) ifFalse:[
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   882
                iVars add:ivar
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   883
            ]
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   884
        ].
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   885
        iVars := iVars asArray.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   886
        t := cls shallowCopy.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   887
        t setInstanceVariableString:iVars asStringCollection asString.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   888
        code := (t definition) , '!!\' withCRs , code.
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   889
    ].
352
088174fc1e71 support for constant lists;
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   890
    ^ code
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   891
925
e6ddd46581c3 added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents: 887
diff changeset
   892
    "Modified: / 29.7.1998 / 12:21:19 / cg"
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   893
!
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   894
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   895
generateAspectSelectorsMethod
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   896
    "generate aspectSelectors method.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   897
     Return a string ready to compile into the application class."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   898
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   899
    |cls code spec|
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   900
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   901
    className isNil ifTrue:[
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   902
        self warn:'Set first the class!!'.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   903
        ^ nil
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   904
    ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   905
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   906
    (cls := self resolveName:className) isNil ifTrue:[
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   907
        self warn:'Class ', className asString, ' does not exist!!'.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   908
        ^ nil
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   909
    ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   910
    spec := treeView exportedAspects.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   911
    spec size == 0 ifTrue:[^ nil].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   912
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   913
    "/ make it an array ...
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   914
    spec := spec collect:[:entry | |subAspect type|
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   915
                subAspect := entry subAspect asSymbol.
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   916
                (type := entry type) isNil ifTrue:[
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   917
                    subAspect
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   918
                ] ifFalse:[
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   919
                    Array with:subAspect with:type asSymbol
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   920
                ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   921
            ].
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   922
    spec := spec asArray.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   923
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   924
    code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' .
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   925
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   926
    code := code , 'aspectSelectors
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   927
    "This resource specification was automatically generated
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   928
     by the UIPainter of ST/X."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   929
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   930
    "Do not manually edit this. If it is corrupted,
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   931
     the UIPainter may not be able to read the specification."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   932
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   933
    "Return a description of exported aspects;
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   934
     these can be connected to aspects of an embedding application
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   935
     (if this app is embedded in a subCanvas)."
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   936
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   937
    ^ #(\'.
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   938
    spec do:[:el | code := code , ('        ' , el storeString , '\') ].
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   939
    code := code , '      ).\'.
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   940
    code := code , '\!!\'.
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   941
    code := code withCRs.
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   942
    ^ code
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   943
1362
b710bba663cb fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   944
    "Modified: / 18.2.2000 / 02:08:34 / cg"
1358
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   945
!
c0116e25a2ac generateAspectSelectorsMethod
ca
parents: 1347
diff changeset
   946
1361
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   947
generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   948
    |code|
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   949
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   950
    code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   951
      aspect , ':something\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   952
      '    "automatically generated by UIPainter ..."\\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   953
      '    "This method is used when I am embedded as subApplication,"\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   954
      '    "and the mainApp wants to connect its aspects to mine."\'.
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   955
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   956
    AspectsAsInstances ifTrue:[
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   957
        code := (code , '\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   958
          '    "/ ' , aspect , ' notNil ifTrue:[\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   959
          '    "/    ' , aspect , ' removeDependent:self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   960
          '    "/ ].\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   961
          '    ' , aspect ,' := something.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   962
          '    "/ ' , aspect ,' notNil ifTrue:[\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   963
          '    "/    ' , aspect , ' addDependent:self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   964
          '    "/ ].\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   965
          '    ^ self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   966
          '!! !!\\') 
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   967
    ] ifFalse:[
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   968
        code := (code , '\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   969
          '    "/ |holder|\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   970
          '\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   971
          '    "/ (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   972
          '    "/     holder removeDependent:self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   973
          '    "/ ].\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   974
          '    builder aspectAt:#' , aspect , ' put:something.\',
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   975
          '    "/ something notNil ifTrue:[\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   976
          '    "/     something addDependent:self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   977
          '    "/ ].\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   978
          '    ^ self.\' ,
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   979
          '!! !!\\') 
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   980
    ].
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   981
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   982
    ^ code withCRs
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   983
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   984
    "Modified: / 29.7.1998 / 11:29:16 / cg"
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   985
    "Modified: / 22.9.1999 / 12:33:47 / stefan"
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   986
!
9020214f03e6 generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   987
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   988
generateCodeFrom:aListOfSelectors in:aClass do:aBlock
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   989
744
20cbba6d7e96 oops - no #redefineMethods found
tz
parents: 742
diff changeset
   990
    self class redefineAspectMethods ifTrue:[
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   991
        aListOfSelectors do:[:aSelector|
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   992
            (aSelector isArray or:[aClass implements:aSelector]) ifFalse:[
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   993
                aBlock value:aSelector
1030
0b9fbaecbe88 output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   994
            ] ifTrue:[
0b9fbaecbe88 output a warning on the transcript, when an aspect method
Claus Gittinger <cg@exept.de>
parents: 1029
diff changeset
   995
                Transcript showCR:'#' , aSelector , ' skipped - already implemented in the class'
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   996
            ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   997
        ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   998
    ] ifFalse:[
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
   999
        aListOfSelectors do:[:aSelector|
1092
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1000
            aSelector isArray ifFalse:[
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1001
                (aClass canUnderstand:aSelector) ifFalse:[
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1002
                    aBlock value:aSelector
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1003
                ] ifTrue:[
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1004
                    Transcript showCR:'#' , aSelector , ' skipped - already implemented in the class (or superclass)'
60e029255679 oops - failed to generate code for constant-list-holders.
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  1005
                ]
698
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1006
            ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1007
        ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1008
    ]
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1009
5bf234e0e451 redefine methods flag
tz
parents: 662
diff changeset
  1010
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1011
!
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1012
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1013
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1014
    ^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1015
      selectorSpec , '\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1016
      '    "automatically generated by UIPainter ..."\\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1017
      '    "*** the code here does nothing. It is invoked when"\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1018
      '    "*** ' , commentWhen , '"\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1019
      '    "*** Please change as required and accept in the browser."\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1020
      '\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1021
      '    "specific code to be added below ..."\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1022
      '    "' , (noteOrNil ? '') , '"\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1023
      '\' ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1024
      (defaultCode ? '^ self.') ,
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1025
      '!! !!\\') withCRs
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1026
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1027
    "Modified: / 25.10.1997 / 19:22:17 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1028
    "Created: / 31.10.1997 / 17:31:53 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1029
!
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1030
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1031
generateHookMethods
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1032
    "generate hook methods
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1033
     - but do not overwrite existing ones.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1034
     Return a string ready to compile into the application class."
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1035
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1036
    |cls code|
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1037
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1038
    code := ''.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1039
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1040
    className isNil ifTrue:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1041
        self warn:'set the class first'.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1042
        ^ code
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1043
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1044
    cls := self resolveName:className.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1045
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1046
    code := code , (self generateHookMethodsInClass:cls).
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1047
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1048
    ^ code
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1049
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1050
    "Created: / 31.10.1997 / 17:21:29 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1051
    "Modified: / 31.10.1997 / 17:38:11 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1052
!
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1053
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1054
generateHookMethodsInClass:targetClass
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1055
    |code|
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1056
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1057
    code := ''.
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1058
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1059
    (targetClass implements:#postBuildWith:) ifFalse:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1060
        code := code 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1061
                , (self 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1062
                    generateHookMethodFor:'postBuildWith:aBuilder'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1063
                    comment:'the widgets have been built, but before the view is opened'
708
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1064
                    note:'or after the super send'
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1065
                    defaultCode:'    super postBuildWith:aBuilder'
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1066
                    inClass:targetClass)
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1067
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1068
    (targetClass implements:#postOpenWith:) ifFalse:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1069
        code := code 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1070
                , (self 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1071
                    generateHookMethodFor:'postOpenWith:aBuilder'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1072
                    comment:'the topView has been opened, but before events are dispatched for it'
708
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1073
                    note:'or after the super send'
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1074
                    defaultCode:'    super postOpenWith:aBuilder'
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1075
                    inClass:targetClass)
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1076
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1077
    (targetClass implements:#closeRequest) ifFalse:[
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1078
        code := code 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1079
                , (self 
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1080
                    generateHookMethodFor:'closeRequest'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1081
                    comment:'the topView has been asked to close'
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1082
                    note:'return without the ''super closeRequest'' to stay open'
708
b5f3169a0ba7 super sends for the hook methods
tz
parents: 698
diff changeset
  1083
                    defaultCode:'    ^super closeRequest'
376
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1084
                    inClass:targetClass)
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1085
    ].
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1086
    ^ code
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1087
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1088
    "Modified: / 31.10.1997 / 17:30:34 / cg"
3023fc08ee35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 361
diff changeset
  1089
    "Created: / 31.10.1997 / 17:32:49 / cg"
316
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
  1090
!
053e2d3089b7 support of menu performer
ca
parents: 315
diff changeset
  1091
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1092
generateMenuMethodFor:menuSel inClass:targetClass
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1093
    |selector args showIt code alreadyInSuperclass numArgs method|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1094
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1095
    selector := menuSel asSymbol.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1096
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1097
    alreadyInSuperclass := targetClass superclass canUnderstand:selector.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1098
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1099
    code := '!!' , targetClass name , ' methodsFor:''menu actions''!!\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1100
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1101
    selector = 'openAboutThisApplication' ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1102
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1103
                'openAboutThisApplication\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1104
                '    "opens an about box for this application."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1105
                '    "automatically generated by UIPainter ..."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1106
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1107
                '    |rev box myClass clsRev image msg|\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1108
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1109
                '    rev := ''''.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1110
                '    myClass := self class.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1111
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1112
                '    (clsRev := myClass revision) notNil ifTrue:[\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1113
                '       rev := ''  (rev: '', clsRev printString, '')''].\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1114
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1115
                '    msg := Character cr asString , myClass name asBoldText, rev.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1116
                '    msg := (msg , ''\\*** add more info here ***\\'') withCRs.\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1117
                '    box := AboutBox title:msg.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1118
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1119
                '    "/ *** add a #defaultIcon method in the class\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1120
                '    "/ *** and uncomment the following line:\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1121
                '    "/ image := self class defaultIcon.\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1122
                '    image notNil ifTrue:[\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1123
                '        box image:image\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1124
                '    ].\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1125
                '    box   label:(resources string:''About %1'' with:myClass name).\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1126
                '    box   autoHideAfter:10 with:[].\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1127
                '    box   showAtPointer.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1128
                '!! !!\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1129
        ^ code withCRs
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1130
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1131
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1132
    selector = 'menuOpen' ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1133
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1134
                'menuOpen\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1135
                '    "automatically generated by UIPainter ..."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1136
                '    "*** the code below opens a dialog for file selection"\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1137
                '    "*** and invokes the #doOpen: method with the selected file."\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1138
                '    "*** Please change as required and accept in the browser."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1139
                '    |file|\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1140
                '    file :=\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1141
                '        (FileSelectionBrowser\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1142
                '            request: ''Open''\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1143
                '            fileName: ''''\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1144
                '            "/ inDirectory: lastOpenDirectory\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1145
                '            withFileFilters: #(''*'')).\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1146
                '    file notNil ifTrue:[\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1147
                '       "/ lastOpenDirectory := file asFilename directory.\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1148
                '       self doOpen:file\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1149
                '    ]\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1150
                '!! !!\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1151
        ^ code withCRs
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1152
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1153
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1154
    numArgs := selector numArgs.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1155
    method  := selector.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1156
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1157
    numArgs == 1 ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1158
        args := 'anArgument'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1159
        showIt := ''' , anArgument printString , '' ...''.\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1160
    ] ifFalse:[    
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1161
        args := ''.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1162
        showIt := ' ...''.\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1163
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1164
        numArgs ~~ 0 ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1165
            method := ''.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1166
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1167
            selector keywords keysAndValuesDo:[:i :key|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1168
                method := method, key, 'arg', i printString, ' '
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1169
            ]
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1170
        ]
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1171
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1172
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1173
    code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1174
                method , args , '\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1175
                '    "automatically generated by UIPainter ..."\\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1176
                '    "*** the code below performs no action"\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1177
                '    "*** (except for some feedback on the Transcript)"\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1178
                '    "*** Please change as required and accept in the browser."\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1179
                '\' .
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1180
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1181
    alreadyInSuperclass ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1182
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1183
                    '    "action for ' , selector , ' is already provided in a superclass."\' ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1184
                    '    "It may be redefined here ..."\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1185
    ] ifFalse:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1186
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1187
                    '    "action to be added ..."\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1188
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1189
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1190
    code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1191
                '    Transcript showCR:self class name, '': '.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1192
    alreadyInSuperclass ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1193
        code := code , 'inherited '.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1194
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1195
    code := code , 'menu action for ' , selector , showIt.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1196
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1197
    alreadyInSuperclass ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1198
        code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1199
                        '    super ' , selector , args , '.\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1200
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1201
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1202
    code := code ,
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1203
                '!! !!\\'.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1204
    ^ code withCRs
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1205
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1206
    "Created: / 23.8.1998 / 16:46:51 / cg"
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1207
    "Modified: / 23.8.1998 / 18:13:05 / cg"
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1208
!
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1209
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1210
generateMenuMethods
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1211
    "generate menu methods
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1212
     - but do not overwrite existing ones.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1213
     Return a string ready to compile into the application class."
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1214
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1215
    |cls code menuSelector thisCode
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1216
     definedMethodSelectors
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1217
     specArray fullSpec winSpec menuSpec
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1218
     |
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1219
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1220
    className isNil ifTrue:[
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1221
        self warn:'Define the class first !!'.
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1222
        ^ nil
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1223
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1224
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1225
    (cls := self resolveName:className) isNil ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1226
        self warn:'Class ', className asString, ' does not exist!!'.
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1227
        ^ nil
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1228
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1229
1058
243d945b1daf name the (full-)spec
tm
parents: 1050
diff changeset
  1230
    specArray := treeView generateFullSpecForComponents:#() named:nil.
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1231
    fullSpec := specArray decodeAsLiteralArray.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1232
    winSpec := fullSpec window.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1233
    menuSelector := winSpec menu.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1234
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1235
    (menuSelector notNil 
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1236
    and:[ (cls respondsTo:menuSelector) ]) ifFalse:[
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1237
        self warn:'No menu defined (yet)'.
1069
7196ca547f5d code cleanup
Claus Gittinger <cg@exept.de>
parents: 1060
diff changeset
  1238
        ^ nil.
965
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1239
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1240
    menuSpec := cls perform:menuSelector.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1241
    menuSpec := menuSpec decodeAsLiteralArray.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1242
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1243
    definedMethodSelectors := IdentitySet new.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1244
    code := ''.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1245
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1246
    menuSpec allItemsDo:[:item |
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1247
        |sel|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1248
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1249
        (sel := item value) notNil ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1250
            (definedMethodSelectors includes:sel) ifFalse:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1251
                self generateCodeFrom:(Array with:sel) in:cls do:[:aSel|
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1252
                    thisCode := (self generateMenuMethodFor:aSel inClass:cls).
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1253
                    code := code, thisCode.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1254
                ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1255
                definedMethodSelectors add:sel.
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1256
            ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1257
        ]
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1258
    ].
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1259
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1260
    (definedMethodSelectors includes:#menuOpen) ifTrue:[
4f786b46a569 added menu-action code generation
Claus Gittinger <cg@ex&#