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