6772
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
|
13 |
|
|
14 |
SimpleView subclass:#ViewWithAcceptAndCancelBar
|
8332
|
15 |
instanceVariableNames:'slaveView bar reallyModifiedHolder acceptAction cancelAction
|
|
16 |
compareAction'
|
6772
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Views-Basic'
|
|
20 |
!
|
|
21 |
|
|
22 |
SimpleView subclass:#AcceptAndCancelBar
|
8332
|
23 |
instanceVariableNames:'acceptButton cancelButton compareButton'
|
6772
|
24 |
classVariableNames:''
|
|
25 |
poolDictionaries:''
|
|
26 |
privateIn:ViewWithAcceptAndCancelBar
|
|
27 |
!
|
|
28 |
|
6775
|
29 |
Button subclass:#ButtonWithHelpText
|
|
30 |
instanceVariableNames:'helpText'
|
|
31 |
classVariableNames:''
|
|
32 |
poolDictionaries:''
|
|
33 |
privateIn:ViewWithAcceptAndCancelBar::AcceptAndCancelBar
|
|
34 |
!
|
|
35 |
|
6772
|
36 |
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'!
|
|
37 |
|
|
38 |
copyright
|
|
39 |
"
|
|
40 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
41 |
All Rights Reserved
|
|
42 |
|
|
43 |
This software is furnished under a license and may be used
|
|
44 |
only in accordance with the terms of that license and with the
|
|
45 |
inclusion of the above copyright notice. This software may not
|
|
46 |
be provided or otherwise made available to, or used by, any
|
|
47 |
other person. No title to or ownership of the software is
|
|
48 |
hereby transferred.
|
|
49 |
"
|
|
50 |
!
|
|
51 |
|
|
52 |
documentation
|
|
53 |
"
|
|
54 |
experimental - self like accept/cancel bar in the browsers
|
|
55 |
code view.
|
|
56 |
Enable with:
|
|
57 |
UserPreferences current showAcceptCancelBarInBrowser:true
|
|
58 |
"
|
|
59 |
! !
|
|
60 |
|
|
61 |
!ViewWithAcceptAndCancelBar methodsFor:'accessing'!
|
|
62 |
|
|
63 |
acceptAction:something
|
|
64 |
acceptAction := something.
|
|
65 |
!
|
|
66 |
|
|
67 |
cancelAction:something
|
|
68 |
cancelAction := something.
|
|
69 |
!
|
|
70 |
|
8332
|
71 |
compareAction:something
|
|
72 |
compareAction := something.
|
|
73 |
!
|
|
74 |
|
6772
|
75 |
reallyModifiedHolder:aValueHolder
|
|
76 |
reallyModifiedHolder := aValueHolder.
|
|
77 |
reallyModifiedHolder addDependent:self.
|
|
78 |
! !
|
|
79 |
|
8332
|
80 |
!ViewWithAcceptAndCancelBar methodsFor:'action'!
|
|
81 |
|
|
82 |
accept
|
|
83 |
acceptAction value
|
|
84 |
!
|
|
85 |
|
|
86 |
cancel
|
|
87 |
cancelAction notNil ifTrue:[
|
|
88 |
cancelAction value
|
|
89 |
]
|
|
90 |
!
|
|
91 |
|
|
92 |
compare
|
|
93 |
compareAction notNil ifTrue:[
|
|
94 |
compareAction value
|
|
95 |
]
|
|
96 |
! !
|
|
97 |
|
6772
|
98 |
!ViewWithAcceptAndCancelBar methodsFor:'change & update'!
|
|
99 |
|
|
100 |
hideBar
|
|
101 |
bar unmap.
|
|
102 |
bar hiddenOnRealize:true.
|
6775
|
103 |
slaveView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
6772
|
104 |
!
|
|
105 |
|
|
106 |
showBar
|
6775
|
107 |
slaveView origin:(20 @ 0.0) corner:(1.0 @ 1.0).
|
6772
|
108 |
bar hiddenOnRealize:false.
|
|
109 |
bar realize.
|
|
110 |
!
|
|
111 |
|
|
112 |
update:something with:aParameter from:changedObject
|
7309
|
113 |
|app|
|
|
114 |
|
6772
|
115 |
slaveView notNil ifTrue:[
|
|
116 |
changedObject == reallyModifiedHolder ifTrue:[
|
7309
|
117 |
(app := self application) notNil ifTrue:[
|
|
118 |
app
|
|
119 |
enqueueMessage:#updateBarVisibility
|
8240
|
120 |
for:self
|
|
121 |
arguments:#().
|
7309
|
122 |
].
|
6772
|
123 |
].
|
|
124 |
|
|
125 |
changedObject == slaveView modifiedChannel ifTrue:[
|
7309
|
126 |
(app := self application) notNil ifTrue:[
|
|
127 |
app
|
|
128 |
enqueueMessage:#updateBarVisibility
|
8240
|
129 |
for:self
|
|
130 |
arguments:#().
|
7309
|
131 |
].
|
6772
|
132 |
].
|
|
133 |
].
|
|
134 |
super update:something with:aParameter from:changedObject
|
7309
|
135 |
|
|
136 |
"Modified: / 18-09-2006 / 22:46:49 / cg"
|
6772
|
137 |
!
|
|
138 |
|
|
139 |
updateBarVisibility
|
|
140 |
|modified|
|
|
141 |
|
|
142 |
modified := reallyModifiedHolder notNil
|
|
143 |
ifTrue:[ reallyModifiedHolder value ]
|
|
144 |
ifFalse:[ slaveView modifiedChannel value ].
|
|
145 |
|
|
146 |
modified ifTrue:[
|
|
147 |
self showBar
|
|
148 |
] ifFalse:[
|
|
149 |
self hideBar
|
|
150 |
].
|
|
151 |
! !
|
|
152 |
|
|
153 |
!ViewWithAcceptAndCancelBar methodsFor:'initialization'!
|
|
154 |
|
|
155 |
initialize
|
|
156 |
super initialize.
|
|
157 |
|
|
158 |
bar := AcceptAndCancelBar in:self.
|
|
159 |
bar origin:(0.0 @ 0.0) corner:(20 @ 1.0).
|
|
160 |
bar hiddenOnRealize:true.
|
|
161 |
|
|
162 |
bar acceptButton action:[ self accept ].
|
|
163 |
bar cancelButton action:[ self cancel ].
|
8332
|
164 |
bar compareButton action:[ self compare ].
|
6772
|
165 |
|
|
166 |
acceptAction := [ slaveView notNil ifTrue:[ slaveView accept ] ].
|
|
167 |
cancelAction := [ ].
|
|
168 |
|
|
169 |
"
|
|
170 |
self new open
|
|
171 |
"
|
|
172 |
!
|
|
173 |
|
|
174 |
slaveView:aView
|
|
175 |
self add:aView.
|
|
176 |
slaveView := aView.
|
|
177 |
aView origin:(0.0@0.0) corner:(1.0@1.0).
|
|
178 |
aView modifiedChannel addDependent:self.
|
|
179 |
|
|
180 |
"
|
|
181 |
|v|
|
|
182 |
|
|
183 |
v := self new.
|
|
184 |
v slaveView:CodeView new.
|
|
185 |
v open
|
|
186 |
"
|
|
187 |
! !
|
|
188 |
|
|
189 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'accessing'!
|
|
190 |
|
|
191 |
acceptButton
|
|
192 |
^ acceptButton
|
|
193 |
!
|
|
194 |
|
|
195 |
cancelButton
|
|
196 |
^ cancelButton
|
8332
|
197 |
!
|
|
198 |
|
|
199 |
compareButton
|
|
200 |
^ compareButton
|
7761
|
201 |
! !
|
|
202 |
|
|
203 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'help'!
|
6775
|
204 |
|
|
205 |
flyByHelpTextAt:srcPoint
|
|
206 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item)."
|
|
207 |
|
|
208 |
(acceptButton bounds containsPoint:srcPoint) ifTrue:[
|
|
209 |
^ 'Accept'
|
|
210 |
].
|
8332
|
211 |
(cancelButton bounds containsPoint:srcPoint) ifTrue:[
|
6775
|
212 |
^ 'Cancel'
|
|
213 |
].
|
8332
|
214 |
(compareButton bounds containsPoint:srcPoint) ifTrue:[
|
|
215 |
^ 'Compare against Original'
|
|
216 |
].
|
6775
|
217 |
^ nil
|
6772
|
218 |
! !
|
|
219 |
|
|
220 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar methodsFor:'initialization'!
|
|
221 |
|
|
222 |
initialize
|
|
223 |
super initialize.
|
|
224 |
|
6775
|
225 |
acceptButton := ButtonWithHelpText new.
|
8336
|
226 |
acceptButton origin:0.0 @ 0.0 corner:1.0@0.7.
|
6772
|
227 |
acceptButton backgroundColor:Color green.
|
6775
|
228 |
acceptButton flyByHelpText:'Accept'.
|
6772
|
229 |
self add:acceptButton.
|
|
230 |
|
6775
|
231 |
cancelButton := ButtonWithHelpText new.
|
8336
|
232 |
cancelButton origin:0.0 @ 0.7 corner:1.0@0.9.
|
6772
|
233 |
cancelButton backgroundColor:Color red.
|
6775
|
234 |
cancelButton flyByHelpText:'Cancel'.
|
6772
|
235 |
self add:cancelButton.
|
|
236 |
|
8332
|
237 |
compareButton := ButtonWithHelpText new.
|
8336
|
238 |
compareButton origin:0.0 @ 0.9 corner:1.0@1.0.
|
8332
|
239 |
compareButton backgroundColor:Color yellow.
|
|
240 |
compareButton flyByHelpText:'Compare against Original'.
|
|
241 |
compareButton label:'?'.
|
|
242 |
self add:compareButton.
|
|
243 |
|
6772
|
244 |
"
|
|
245 |
AcceptAndCancelBar new open
|
|
246 |
"
|
|
247 |
! !
|
|
248 |
|
6775
|
249 |
!ViewWithAcceptAndCancelBar::AcceptAndCancelBar::ButtonWithHelpText methodsFor:'accessing'!
|
|
250 |
|
|
251 |
flyByHelpText
|
|
252 |
^ helpText
|
|
253 |
!
|
|
254 |
|
|
255 |
flyByHelpText:something
|
|
256 |
helpText := something.
|
|
257 |
! !
|
|
258 |
|
6772
|
259 |
!ViewWithAcceptAndCancelBar class methodsFor:'documentation'!
|
|
260 |
|
|
261 |
version
|
8336
|
262 |
^ '$Header: /cvs/stx/stx/libtool/ViewWithAcceptAndCancelBar.st,v 1.7 2008-10-16 08:40:53 cg Exp $'
|
6772
|
263 |
! !
|