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