0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
0
|
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 |
|
|
13 |
ListSelectionBox subclass:#FileSelectionBox
|
12
|
14 |
instanceVariableNames:'patternField'
|
0
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Interactors'
|
|
18 |
!
|
|
19 |
|
|
20 |
FileSelectionBox comment:'
|
|
21 |
|
5
|
22 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
0
|
23 |
All Rights Reserved
|
|
24 |
|
21
|
25 |
$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.6 1994-01-08 17:27:15 claus Exp $
|
7
|
26 |
written Jan 90 by claus
|
|
27 |
'!
|
|
28 |
|
|
29 |
!FileSelectionBox class methodsFor:'documentation'!
|
|
30 |
|
|
31 |
documentation
|
|
32 |
"
|
12
|
33 |
this class implements file selection boxes. Instances show a list of
|
0
|
34 |
files, and perform an action block with the selected pathname as
|
|
35 |
argument when ok is clicked.
|
12
|
36 |
|
7
|
37 |
There is an optional PatternField, which shows itself when a pattern
|
|
38 |
is defined. If there is such a pattern, only files matching the pattern
|
|
39 |
will be shown in the list (and directories).
|
|
40 |
"
|
|
41 |
! !
|
0
|
42 |
|
12
|
43 |
!FileSelectionBox class methodsFor:'defaults'!
|
|
44 |
|
|
45 |
listViewType
|
|
46 |
"return the type of listView - using a FileSelectionList here"
|
|
47 |
|
|
48 |
^ FileSelectionList
|
|
49 |
! !
|
|
50 |
|
0
|
51 |
!FileSelectionBox methodsFor:'initialization'!
|
|
52 |
|
|
53 |
initialize
|
|
54 |
super initialize.
|
|
55 |
|
3
|
56 |
labelField extent:(0.7 @ labelField height).
|
|
57 |
labelField label:(resources string:'select a file:').
|
|
58 |
labelField adjust:#left.
|
|
59 |
|
|
60 |
patternField := EditField
|
|
61 |
origin:(0.7 @ labelField origin y)
|
|
62 |
corner:(1.0 @ labelField corner y)
|
|
63 |
in:self.
|
|
64 |
patternField initialText:'*'.
|
21
|
65 |
patternField leaveAction:[:reason |
|
|
66 |
selectionList pattern:patternField contents.
|
|
67 |
self updateList
|
|
68 |
].
|
3
|
69 |
patternField hidden:true.
|
|
70 |
|
12
|
71 |
selectionList action:[:line |
|
0
|
72 |
|entry|
|
|
73 |
|
|
74 |
entry := selectionList selectionValue.
|
12
|
75 |
enterField contents:entry
|
|
76 |
].
|
|
77 |
selectionList doubleClickAction:[:line |
|
|
78 |
|entry|
|
|
79 |
|
|
80 |
entry := selectionList selectionValue.
|
|
81 |
enterField contents:entry.
|
|
82 |
self okPressed
|
|
83 |
].
|
0
|
84 |
|
|
85 |
"FileSelectionBox new show"
|
|
86 |
! !
|
|
87 |
|
21
|
88 |
!FileSelectionBox methodsFor:'private'!
|
|
89 |
|
|
90 |
updateList
|
|
91 |
selectionList updateList
|
|
92 |
! !
|
|
93 |
|
0
|
94 |
!FileSelectionBox methodsFor:'accessing'!
|
|
95 |
|
|
96 |
directory:nameOrDirectory
|
12
|
97 |
"change the directory shown in the list"
|
0
|
98 |
|
12
|
99 |
selectionList directory:nameOrDirectory
|
3
|
100 |
!
|
|
101 |
|
|
102 |
pattern:aPattern
|
7
|
103 |
"set the pattern - this enables the PatternField."
|
|
104 |
|
3
|
105 |
patternField initialText:aPattern.
|
12
|
106 |
selectionList pattern:aPattern.
|
|
107 |
aPattern isNil ifTrue:[
|
|
108 |
patternField hidden:true.
|
|
109 |
realized ifTrue:[
|
|
110 |
patternField hide.
|
|
111 |
]
|
|
112 |
] ifFalse:[
|
|
113 |
patternField hidden:false.
|
|
114 |
realized ifTrue:[
|
|
115 |
patternField realize.
|
|
116 |
].
|
0
|
117 |
].
|
|
118 |
! !
|
|
119 |
|
|
120 |
!FileSelectionBox methodsFor:'user interaction'!
|
|
121 |
|
|
122 |
okPressed
|
|
123 |
"redefined, since action will be evaluated with full path as argument
|
|
124 |
(instead of enterfields contents only as inherited by EnterBox"
|
|
125 |
|
7
|
126 |
|absPath|
|
|
127 |
|
0
|
128 |
self hideAndEvaluate:[:string |
|
|
129 |
okAction notNil ifTrue:[
|
7
|
130 |
(string startsWith:(Filename separator)) ifTrue:[
|
|
131 |
absPath := string
|
|
132 |
] ifFalse:[
|
12
|
133 |
absPath := selectionList directory pathName , Filename separator asString , string
|
7
|
134 |
].
|
|
135 |
okAction value:absPath
|
0
|
136 |
]
|
|
137 |
]
|
|
138 |
! !
|