author | Claus Gittinger <cg@exept.de> |
Wed, 12 Nov 2008 14:11:36 +0100 | |
changeset 3593 | f11c5a41d4a9 |
parent 3590 | c3c778e11564 |
child 3594 | 8bdad6d9c51a |
permissions | -rw-r--r-- |
3318 | 1 |
" |
2 |
COPYRIGHT (c) 2007 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 |
" |
|
3251 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
14 |
SimpleView subclass:#FilenameWidgetWithHistory |
|
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
15 |
instanceVariableNames:'fileNameEntryField browseButton history directoriesOnly filesOnly |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
16 |
dialogTitle' |
3251 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Views-Interactors' |
|
20 |
! |
|
21 |
||
22 |
!FilenameWidgetWithHistory class methodsFor:'documentation'! |
|
23 |
||
3318 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 2007 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
3471 | 38 |
documentation |
39 |
" |
|
40 |
A Filename InputField with history-list and a browse-button, which opens a file dialog. |
|
41 |
||
42 |
[author:] |
|
43 |
Claus Gittinger |
|
44 |
||
45 |
[see also:] |
|
46 |
ComboBoxView |
|
47 |
FilenameEditField |
|
48 |
FilenameComboBoxView |
|
49 |
" |
|
50 |
! |
|
51 |
||
3251 | 52 |
examples |
53 |
" |
|
54 |
[exBegin] |
|
55 |
|top b| |
|
56 |
||
57 |
top := StandardSystemView new. |
|
58 |
top extent:(300 @ 200). |
|
59 |
||
60 |
b := FilenameWidgetWithHistory in:top. |
|
61 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
62 |
b bottomInset:(b preferredExtent y negated). |
|
63 |
||
64 |
top open. |
|
65 |
[exEnd] |
|
66 |
" |
|
67 |
! ! |
|
68 |
||
69 |
!FilenameWidgetWithHistory methodsFor:'accessing'! |
|
70 |
||
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
71 |
dialogTitle:something |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
72 |
"set the dialogs title" |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
73 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
74 |
dialogTitle := something. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
75 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
76 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
77 |
directoriesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
78 |
"if true, directories are selectable only. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
79 |
If both filesOnly and directoriesOnly are false, which is the default, |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
80 |
anything is selectable." |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
81 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
82 |
directoriesOnly := aBoolean. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
83 |
directoriesOnly ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
84 |
filesOnly := false. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
85 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
86 |
fileNameEntryField notNil ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
87 |
fileNameEntryField directoriesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
88 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
89 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
90 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
91 |
filesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
92 |
"if true, files are selectable only. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
93 |
If both filesOnly and directoriesOnly are false, which is the default, |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
94 |
anything is selectable." |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
95 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
96 |
filesOnly := aBoolean. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
97 |
filesOnly ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
98 |
directoriesOnly := false. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
99 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
100 |
fileNameEntryField notNil ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
101 |
fileNameEntryField filesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
102 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
103 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
104 |
|
3251 | 105 |
historyList |
3474 | 106 |
history isNil ifTrue:[ |
107 |
history := nil asValue |
|
108 |
]. |
|
109 |
^ history |
|
3251 | 110 |
! |
111 |
||
3593 | 112 |
historyList:aList |
113 |
"set the history - useful when two or more such fields shall share a common history" |
|
114 |
||
115 |
history := aList |
|
116 |
! |
|
117 |
||
3251 | 118 |
model |
119 |
^ fileNameEntryField model |
|
120 |
! |
|
121 |
||
122 |
model:aFilenameHolder |
|
123 |
fileNameEntryField model:aFilenameHolder. |
|
124 |
! ! |
|
125 |
||
3546 | 126 |
!FilenameWidgetWithHistory methodsFor:'accessing-channels'! |
127 |
||
128 |
enableChannel:aValueHolder |
|
129 |
fileNameEntryField enableChannel:aValueHolder. |
|
130 |
browseButton enableChannel:aValueHolder. |
|
131 |
! ! |
|
132 |
||
133 |
!FilenameWidgetWithHistory methodsFor:'accessing-editField attributes'! |
|
3472 | 134 |
|
135 |
acceptIfUnchanged:aBoolean |
|
136 |
fileNameEntryField acceptIfUnchanged:aBoolean |
|
137 |
! |
|
138 |
||
139 |
acceptOnLeave:aBoolean |
|
140 |
fileNameEntryField acceptOnLeave:aBoolean |
|
141 |
! |
|
142 |
||
143 |
acceptOnLostFocus:aBoolean |
|
144 |
fileNameEntryField acceptOnLostFocus:aBoolean |
|
145 |
! |
|
146 |
||
147 |
acceptOnPointerLeave:aBoolean |
|
148 |
fileNameEntryField acceptOnPointerLeave:aBoolean |
|
149 |
! |
|
150 |
||
151 |
acceptOnReturn:aBoolean |
|
152 |
fileNameEntryField acceptOnReturn:aBoolean |
|
153 |
! |
|
154 |
||
155 |
acceptOnTab:aBoolean |
|
156 |
fileNameEntryField acceptOnTab:aBoolean |
|
157 |
! |
|
158 |
||
159 |
contents:aString |
|
160 |
fileNameEntryField contents:aString |
|
161 |
! |
|
162 |
||
163 |
immediateAccept:aBoolean |
|
164 |
fileNameEntryField immediateAccept:aBoolean |
|
165 |
! |
|
166 |
||
167 |
maxChars:aBoolean |
|
168 |
fileNameEntryField maxChars:aBoolean |
|
169 |
! |
|
170 |
||
171 |
readOnly:aBoolean |
|
172 |
fileNameEntryField readOnly:aBoolean |
|
173 |
! ! |
|
174 |
||
3251 | 175 |
!FilenameWidgetWithHistory methodsFor:'initialization'! |
176 |
||
177 |
initialize |
|
178 |
super initialize. |
|
179 |
||
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
180 |
directoriesOnly := filesOnly := false. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
181 |
|
3251 | 182 |
fileNameEntryField := FilenameComboBoxView in:self. |
183 |
fileNameEntryField layout:(LayoutFrame |
|
184 |
leftFraction:0 offset:0 |
|
185 |
rightFraction:1 offset:-22 |
|
186 |
topFraction:0 offset:0 |
|
187 |
bottomFraction:1 offset:0). |
|
188 |
fileNameEntryField listHolder:(self historyList). |
|
189 |
||
190 |
browseButton := Button in:self. |
|
191 |
browseButton label:'...'. |
|
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
192 |
browseButton action:[ self browseForFileOrDirectory ]. |
3251 | 193 |
browseButton layout:(LayoutFrame |
194 |
leftFraction:1 offset:-22 |
|
195 |
rightFraction:1 offset:-2 |
|
196 |
topFraction:0 offset:0 |
|
197 |
bottomFraction:1 offset:0). |
|
198 |
! ! |
|
199 |
||
200 |
!FilenameWidgetWithHistory methodsFor:'queries'! |
|
201 |
||
202 |
preferredExtent |
|
3568
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
203 |
"/ If I have an explicit preferredExtent.. |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
204 |
explicitExtent notNil ifTrue:[ |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
205 |
^ explicitExtent |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
206 |
]. |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
207 |
|
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
208 |
"/ If I have a cached preferredExtent value.. |
3251 | 209 |
preferredExtent notNil ifTrue:[ |
210 |
^ preferredExtent |
|
211 |
]. |
|
212 |
||
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
213 |
preferredExtent := (fileNameEntryField preferredWidth + browseButton preferredWidth) |
3251 | 214 |
@ |
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
215 |
(fileNameEntryField preferredHeight "max: browseButton preferredExtent y"). |
3251 | 216 |
^ preferredExtent |
217 |
! ! |
|
218 |
||
219 |
!FilenameWidgetWithHistory methodsFor:'user actions'! |
|
220 |
||
221 |
browseForDestinationDirectory |
|
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
222 |
<resource: #obsolete> |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
223 |
self obsoleteMethodWarning. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
224 |
self browseForFileOrDirectory |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
225 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
226 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
227 |
browseForFileOrDirectory |
3251 | 228 |
|dir| |
229 |
||
230 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
231 |
|dialog| |
|
232 |
||
233 |
dialog := ex parameter. |
|
234 |
dialog perform:#browseVisibleHolder with:true ifNotUnderstood:[]. |
|
235 |
ex proceed. |
|
236 |
] do:[ |
|
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
237 |
|title| |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
238 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
239 |
title := dialogTitle notNil |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
240 |
ifTrue:[ dialogTitle ] |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
241 |
ifFalse:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
242 |
directoriesOnly |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
243 |
ifTrue:[ resources string:'Select Directory' ] |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
244 |
ifFalse:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
245 |
filesOnly |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
246 |
ifTrue:[ resources string:'Select File' ] |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
247 |
ifFalse:[ resources string:'Select Path' ]]]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
248 |
|
3251 | 249 |
dir := Dialog |
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
250 |
requestFileName:title |
3251 | 251 |
default:(self model value ? '.' asFilename pathName). |
252 |
]. |
|
253 |
dir isEmptyOrNil ifTrue:[ ^ self ]. |
|
254 |
||
255 |
self model value:dir. |
|
256 |
||
257 |
"Modified: / 02-10-2006 / 14:45:54 / cg" |
|
258 |
! ! |
|
259 |
||
260 |
!FilenameWidgetWithHistory class methodsFor:'documentation'! |
|
261 |
||
262 |
version |
|
3593 | 263 |
^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.11 2008-11-12 13:11:36 cg Exp $' |
3251 | 264 |
! ! |