FSelBox.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Nov 1995 15:37:40 +0100
changeset 202 01f3cbb8e20e
parent 197 00927189c882
child 235 bbd0a7433459
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1990 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
ListSelectionBox subclass:#FileSelectionBox
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    14
	 instanceVariableNames:'patternField'
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    15
	 classVariableNames:''
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    16
	 poolDictionaries:''
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    17
	 category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    20
!FileSelectionBox class methodsFor:'documentation'!
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    21
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    22
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    23
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    24
 COPYRIGHT (c) 1990 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    25
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    26
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    27
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    28
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    30
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    31
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    32
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    33
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    34
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    35
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    36
documentation
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    37
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    38
    this class implements file selection boxes. Instances show a list of
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    39
    files, and perform an action block with the selected pathname as
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    40
    argument when ok is clicked.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    41
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    42
    There is an optional PatternField, which shows itself when a pattern
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    43
    is defined (i.e. if there is no pattern, it is hidden). 
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    44
    If there is a pattern, only files matching the pattern will be shown in 
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    45
    the list (and directories).
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    46
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    47
    In addition, there is an optional matchBlock (actually this is defined 
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    48
    in the FileSelectionList). Only filenames for which this matchblock
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    49
    returns true will be presented.
62
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    50
"
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    51
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    52
62
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    53
examples 
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    54
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    55
    Example1:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    56
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    57
	FileSelectionBox open
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    58
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    59
    Example2:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    60
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    61
	FileSelectionBox new open
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
    62
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    63
    Example3:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    64
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    65
	|box|
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    66
	box := FileSelectionBox new.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    67
	box title:'Which file ?'.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    68
	box open
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    69
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    70
    Example4:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    71
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    72
	|box|
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    73
	box := FileSelectionBox new.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    74
	box title:'Which file ?'.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    75
	box pattern:'*.doc'.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    76
	box open
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    77
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    78
    Example5:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    79
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    80
	|box|
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    81
	box := FileSelectionBox new.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    82
	box title:'Which file ?'.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    83
	box pattern:'*'.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    84
	box matchBlock:[:name | name first isLowercase].
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    85
	box open
44
f5e3a267fe4e pass fullname to matchblock
claus
parents: 41
diff changeset
    86
120
claus
parents: 110
diff changeset
    87
    Example6:
44
f5e3a267fe4e pass fullname to matchblock
claus
parents: 41
diff changeset
    88
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    89
	|box|
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    90
	box := FileSelectionBox new.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    91
	box title:'Which directory ?'.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    92
	box pattern:'l*'.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    93
	box matchBlock:[:name | OperatingSystem isDirectory:name].
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    94
	box open
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    95
"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    96
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    97
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
version
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    99
    ^ '$Header: /cvs/stx/stx/libwidg/Attic/FSelBox.st,v 1.23 1995-11-23 02:25:26 cg Exp $'
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   100
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   101
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   102
!FileSelectionBox class methodsFor:'defaults'!
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   103
77
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   104
requestFilename
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   105
    ^ self requestFilename:'filename:'
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   106
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   107
    "
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   108
     FileSelectionBox requestFilename
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   109
    "
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   110
!
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   111
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   112
requestFilename:title
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   113
    |fileBox|
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   114
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   115
    fileBox := self
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   116
		    title:title
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   117
		    okText:'ok'
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   118
		    abortText:'cancel'
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   119
		    action:[:fileName | ^ fileName].
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   120
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   121
    fileBox showAtPointer.
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   122
    ^ nil
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   123
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   124
    "
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   125
     FileSelectionBox requestFilename:'which file ?'
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   126
    "
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   127
! !
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   128
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   129
!FileSelectionBox class methodsFor:'requests'!
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   130
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   131
listViewType
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   132
    "return the type of listView - using a FileSelectionList here"
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   133
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   134
    ^ FileSelectionList
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   135
! !
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   136
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   137
!FileSelectionBox methodsFor:'accessing'!
3
claus
parents: 0
diff changeset
   138
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   139
contents
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   140
    "return the current entered value (i.e. the enterFields string).
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   141
     redefined to return the full pathname."
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   142
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   143
    |string sep|
3
claus
parents: 0
diff changeset
   144
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   145
    string := super contents.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   146
    string isNil ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   147
	^ selectionList directory pathName
121
claus
parents: 120
diff changeset
   148
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   149
    sep := Filename separator.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   150
    (string startsWith:sep) ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   151
	^ string
77
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   152
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   153
    ^ (selectionList directory pathName asFilename construct:string) asString
132
claus
parents: 130
diff changeset
   154
!
claus
parents: 130
diff changeset
   155
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   156
directory:directoryName
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   157
    "change the directory shown in the list."
41
2f8d0f8e796b update list when namefiled cannot complete name
claus
parents: 38
diff changeset
   158
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   159
    selectionList directory:directoryName
132
claus
parents: 130
diff changeset
   160
!
claus
parents: 130
diff changeset
   161
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   162
matchBlock:aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   163
    "set the matchBlock (in the selectionList). Only files
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   164
     for which the block returns true are shown.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   165
     The matching is actually done in the fileSelectionList."
77
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   166
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   167
    selectionList matchBlock:aBlock 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   168
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   169
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   170
openOn:aPath
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   171
    "open the box showing files in aPath.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   172
     This is only a shortcut message - no new functionality."
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   173
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   174
    self directory:aPath.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   175
    self showAtPointer
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   176
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   177
3
claus
parents: 0
diff changeset
   178
pattern:aPattern
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   179
    "set the pattern - this also enables the PatternField
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   180
     (if the pattern is non-nil) or hides it (if nil)."
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   181
130
claus
parents: 121
diff changeset
   182
    |hidePatternField focusSequence|
claus
parents: 121
diff changeset
   183
3
claus
parents: 0
diff changeset
   184
    patternField initialText:aPattern.
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   185
    selectionList pattern:aPattern.
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   186
    aPattern isNil ifTrue:[
130
claus
parents: 121
diff changeset
   187
	hidePatternField := true.
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
   188
	realized ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
   189
	    patternField hide.
77
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   190
	].
130
claus
parents: 121
diff changeset
   191
	focusSequence := (Array 
claus
parents: 121
diff changeset
   192
			     with:enterField 
claus
parents: 121
diff changeset
   193
			     with:selectionList 
claus
parents: 121
diff changeset
   194
			     with:okButton 
claus
parents: 121
diff changeset
   195
			     with:abortButton)
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   196
    ] ifFalse:[
130
claus
parents: 121
diff changeset
   197
	hidePatternField := false.
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
   198
	realized ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
   199
	    patternField realize.
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
   200
	].
130
claus
parents: 121
diff changeset
   201
	focusSequence := (Array 
claus
parents: 121
diff changeset
   202
			     with:patternField 
claus
parents: 121
diff changeset
   203
			     with:enterField 
claus
parents: 121
diff changeset
   204
			     with:selectionList 
claus
parents: 121
diff changeset
   205
			     with:okButton 
claus
parents: 121
diff changeset
   206
			     with:abortButton)
claus
parents: 121
diff changeset
   207
    ].
claus
parents: 121
diff changeset
   208
claus
parents: 121
diff changeset
   209
    patternField hiddenOnRealize:hidePatternField.
claus
parents: 121
diff changeset
   210
    windowGroup notNil ifTrue:[
claus
parents: 121
diff changeset
   211
	windowGroup focusSequence:focusSequence
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   212
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   213
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   214
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   215
!FileSelectionBox methodsFor:'change & update'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   216
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   217
update:something with:argument from:changedObject
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   218
    |commonName index s|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   219
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   220
    something == #directory ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   221
	"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   222
	 sent by fileNameEnterField, if a filename
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   223
	 completion was not possible due to multiple
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   224
	 matches.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   225
	"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   226
	selectionList directory:argument.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   227
	s := enterField contents.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   228
	s notNil ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   229
	    commonName := s asFilename baseName.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   230
	    commonName size > 0 ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   231
		index := selectionList list findFirst:[:entry | entry startsWith:commonName].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   232
		index ~~ 0 ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   233
		    selectionList makeLineVisible:index
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   234
		]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   235
	    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   236
	]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   237
    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   238
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   239
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   240
!FileSelectionBox methodsFor:'initialization'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   241
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   242
createEnterField
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   243
    "if the (optional) class FilenameEditField is present, use
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   244
     it, since it provides filename completion. Otherwise, we have
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   245
     to live with the dump (default) field ...
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   246
    "
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   247
    FilenameEditField notNil ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   248
	^ FilenameEditField new.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   249
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   250
    ^ super createEnterField
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   251
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   252
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   253
focusSequence
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   254
    patternField shown ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   255
	^ Array 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   256
	    with:patternField 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   257
	    with:enterField 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   258
	    with:selectionList 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   259
	    with:abortButton
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   260
	    with:okButton 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   261
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
    ^ super focusSequence
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   264
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   265
initialize
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   266
    |corner|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   267
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   268
    super initialize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   269
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   270
    label := resources string:'File dialog'.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   271
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   272
    labelField extent:(0.7 @ labelField height).
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   273
    labelField label:(resources string:'select a file:').
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   274
    labelField adjust:#left.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   275
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   276
    patternField := EditField in:self.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   277
    self is3D ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   278
	corner := (1.0 @ (labelField origin y+patternField heightIncludingBorder)).
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   279
    ] ifFalse:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   280
	corner := [(width - ViewSpacing - (patternField borderWidth * 2)) @ (labelField origin y+patternField height"IncludingBorder")].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   281
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   282
    patternField origin:(0.7 @ labelField origin y) corner:corner.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   283
    patternField rightInset:ViewSpacing.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   284
    patternField initialText:'*'.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   285
    patternField leaveAction:[:reason | 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   286
	selectionList pattern:patternField contents. 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   287
	self updateList
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   288
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   289
    patternField hiddenOnRealize:true. "delay showing, until a pattern is defined"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   290
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   291
    enterField addDependent:self.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   292
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   293
    "
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   294
     FileSelectionBox open
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   295
     FileSelectionBox new show
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   296
    "
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   297
!
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   298
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   299
realize
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   300
    "if some default is present in the enterField,
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   301
     scroll to make this one visible"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   302
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   303
    |contents|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   304
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   305
    super realize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   306
    (contents := enterField contents) notNil ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   307
	contents notEmpty ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   308
	    selectionList makeVisible:contents
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   309
	]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   310
    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   311
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   312
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   313
!FileSelectionBox methodsFor:'private'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   314
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   315
updateList
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   316
    selectionList updateList
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   317
! !
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   318
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   319
!FileSelectionBox methodsFor:'queries'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   320
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   321
preferredExtent
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   322
    "return my preferred extent - thats the minimum size 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   323
     to make everything visible"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   324
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   325
    |wWanted hWanted|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   326
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   327
    wWanted := ViewSpacing + 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   328
	       labelField preferredExtent x + 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   329
	       (ViewSpacing * 2) + 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   330
	       patternField preferredExtent x + 
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   331
	       ViewSpacing.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   332
    (wWanted < width) ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   333
	wWanted := width
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   334
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   335
    hWanted := ViewSpacing + labelField height +
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   336
	       ViewSpacing + enterField height +
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   337
	       ViewSpacing + selectionList height +
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   338
	       ViewSpacing + buttonPanel preferredExtent y +
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   339
	       ViewSpacing.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   340
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   341
    (hWanted < height) ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   342
	hWanted := height
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   343
    ].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   344
    ^ (wWanted @ hWanted)
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   345
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   346
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   347
!FileSelectionBox methodsFor:'user actions'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   348
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   349
doubleClick
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   350
    |entry|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   351
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   352
    entry := selectionList selectionValue.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   353
    entry notNil ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   354
	((selectionList directory typeOf:entry) == #directory) ifFalse:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   355
	    enterField contents:entry.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   356
	    self okPressed
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   357
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   358
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   359
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   360
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   361
okPressed
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   362
    "called for both on ok-press and on return-key"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   363
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   364
    |dir string fname|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   365
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   366
    string := enterField contents.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   367
    string notNil ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   368
	string := string withoutSeparators.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   369
	string asFilename isAbsolute ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   370
	    fname := string asFilename
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   371
	] ifFalse:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   372
	    dir := selectionList directory pathName asFilename.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   373
	    fname := dir construct:string
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   374
	].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   375
	fname isDirectory ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   376
	    selectionList directory:fname asString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   377
	    self updateList.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   378
	    ^ self
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   379
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   380
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   381
    super okPressed
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   382
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   383
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   384
selectionChanged
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   385
    |entry|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   386
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   387
    entry := selectionList selectionValue.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   388
    enterField contents:entry
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   389
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   390