FileSelectionBox.st
author Claus Gittinger <cg@exept.de>
Tue, 19 Jun 2001 17:02:00 +0200
changeset 2376 ec58e7de7023
parent 2375 1e3b7281d4ac
child 2441 50238eab2de4
permissions -rw-r--r--
do not scroll after remove.
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
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
    13
"{ Package: 'stx:libwidg' }"
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
ListSelectionBox subclass:#FileSelectionBox
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
    16
	instanceVariableNames:'patternField selectingDirectory allowMakeDirectory'
1320
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
    17
	classVariableNames:'LastFileSelectionDirectory'
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
    18
	poolDictionaries:''
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
    19
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
849
3f3371dd8222 commentary
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
    22
!FileSelectionBox class methodsFor:'documentation'!
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    23
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    24
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    25
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    26
 COPYRIGHT (c) 1990 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 44
diff changeset
    27
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    28
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    29
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    30
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    32
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    33
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    34
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    35
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    36
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    37
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    38
documentation
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    39
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    40
    this class implements file selection boxes. Instances show a list of
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    41
    files, and perform an action block with the selected pathname as
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    42
    argument when ok is clicked. It is also possible, to open the box
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    43
    without action and ask it afterward if it has been left with ok
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    44
    (i.e. the ST-80 way, asking 'aBox accepted ifTrue:[...]')
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    45
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    46
    There is an optional PatternField, which shows itself when a pattern
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    47
    is defined (i.e. if there is no pattern, it is hidden). 
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    48
    If there is a pattern, only files matching the pattern are shown in 
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    49
    the list. Directories are not affected by the patternField.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    50
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    51
    In addition, there is an optional matchBlock (actually this is defined 
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    52
    in the FileSelectionList). Only names for which this matchblock
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    53
    returns true will be presented. The matchBlock affects both regular files
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    54
    and names of directories. The argument passed to the matchBlock is the full
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    55
    pathname.
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    56
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    57
    All of the actual work is done in the fileList; see the documentation
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    58
    of FileSelectionList for more options 
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    59
    (you can access a boxes fileList via 'aBox>>listView' and get access to all
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    60
     of those fancy settings)
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    61
    For example, by accessing the list, it is possible to hide all directories 
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    62
    ('aBox listView ignoreDirectories:true'), to hide the parentDirectory alone 
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    63
    ('aBox listView ignoreParentDirectory') and to turn off the marking 
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    64
    of subdirectories ('aBox listView markSubdirectories:false').
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
    65
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
    66
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
    67
        Claus Gittinger
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
    68
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
    69
    [see also:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
    70
        DialogBox
648
fcf02d58882e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    71
        EnterBox2 FilenameEnterBox YesNoBox
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    72
        ListSelectionBox FileSaveBox
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    73
        FileSelectionList SelectionInListView
62
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    74
"
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    75
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    76
62
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    77
examples 
7cc1e330da47 *** empty log message ***
claus
parents: 59
diff changeset
    78
"
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    79
  simple standard queries
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
    80
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
    81
    very simple:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    82
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
    83
        |name|
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
    84
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    85
        name := FileSelectionBox requestFileName.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
    86
        Transcript showCR:name
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    87
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    88
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
    89
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
    90
    simple:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    91
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
    92
        |name|
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
    93
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    94
        name := FileSelectionBox requestFileName:'which file ?'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
    95
        Transcript showCR:name
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
    96
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
    97
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
    98
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
    99
    with initial selection:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   100
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   101
        |name|
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   102
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   103
        name := FileSelectionBox requestFileName:'which file ?' default:'Make.proto'.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   104
        Transcript showCR:name
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   105
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   106
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   107
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   108
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   109
  more detailed setup
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   110
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   111
    setting title:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   112
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   113
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   114
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   115
        box title:'Which file ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   116
        box open.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   117
        box accepted ifTrue:[
1411
c11734cd83ee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
   118
            Transcript showCR:'you selected: ' , box pathName
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   119
        ]
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   120
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   121
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   122
    setting a matchpattern:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   123
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   124
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   125
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   126
        box title:'Which file ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   127
        box pattern:'*.rc'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   128
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   129
                                                                        [exEnd]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   130
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   131
    setting multiple patterns:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   132
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   133
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   134
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   135
        box title:'Which file ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   136
        box pattern:'*.rc;*.st'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   137
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   138
                                                                        [exEnd]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   139
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   140
    setting a matchblock:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   141
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   142
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   143
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   144
        box title:'Which file ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   145
        box directory:'/etc'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   146
        box pattern:'*'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   147
        box matchBlock:[:name | name asFilename baseName first between:$a and:$z].
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   148
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   149
                                                                        [exEnd]
44
f5e3a267fe4e pass fullname to matchblock
claus
parents: 41
diff changeset
   150
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   151
    both pattern and matchBlock:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   152
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   153
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   154
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   155
        box title:'Which directory ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   156
        box selectingDirectory:true.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   157
        box pattern:'l*'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   158
        box matchBlock:[:name | OperatingSystem isDirectory:name].
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   159
        box action:[:fn | Transcript showCR:fn].
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   160
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   161
                                                                        [exEnd]
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   162
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   163
    dont show the parent directory:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   164
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   165
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   166
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   167
        box title:'Which directory ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   168
        box listView ignoreParentDirectory:true.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   169
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   170
                                                                        [exEnd]
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   171
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   172
    dont show any directory:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   173
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   174
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   175
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   176
        box title:'Which file ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   177
        box listView ignoreDirectories:true.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   178
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   179
                                                                        [exEnd]
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   180
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   181
    dont show any directory or hidden file:
842
a27a1c6ddde0 Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 800
diff changeset
   182
    (notice the basename extraction - we are not interested in the full pathName)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   183
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   184
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   185
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   186
        box title:'Which file ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   187
        box listView ignoreDirectories:true.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   188
        box matchBlock:[:name | (name asFilename baseName startsWith:'.') not].
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   189
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   190
                                                                        [exEnd]
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   191
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   192
    dont allow direct filename entry:
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   193
    (i.e. avoid the user choosing files from other directories)
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   194
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   195
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   196
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   197
        box title:'Which one ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   198
        box enterField beInvisible.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   199
        box open.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   200
        box accepted ifTrue:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   201
            Transcript showCR:'path is ' , box pathName
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   202
        ].
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   203
                                                                        [exEnd]
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   204
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   205
    combined with above directory ignoring,
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   206
    this limits selection of files from a single directory:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   207
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   208
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   209
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   210
        box title:'Which file ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   211
        box enterField beInvisible.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   212
        box listView ignoreDirectories:true.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   213
        box open.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   214
        box accepted ifTrue:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   215
            Transcript showCR:'path is ' , box pathName
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   216
        ].
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   217
                                                                        [exEnd]
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   218
238
a81e517187e4 examples
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   219
    finally, an action:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   220
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   221
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   222
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   223
        box title:'Which directory ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   224
        box pattern:'l*'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   225
        box matchBlock:[:name | OperatingSystem isDirectory:name].
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   226
        box action:[:name | Transcript showCR:name].
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   227
        box open
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   228
                                                                        [exEnd]
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   229
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   230
  concrete examples:
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   231
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   232
    only show files beginning with lowercase characters
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   233
    and ending in '.c':
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   234
                                                                        [exBegin]
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   235
        |box|
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   236
        box := FileSelectionBox new.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   237
        box title:'Which directory ?'.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   238
        box matchBlock:[:name |
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   239
                            box pathName asFilename isDirectory
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   240
                            or:[name first isLowercase
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   241
                                and:[name endsWith:'.c']]
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   242
                       ].
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   243
        box open.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   244
        box accepted ifTrue:[
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   245
            Transcript showCR:'full path:  ' , box pathName.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   246
            Transcript showCR:'files name: ' , box fileName.
1643
2710f3be2a77 fixed #fileName - return fileName only (not full path)
Claus Gittinger <cg@exept.de>
parents: 1639
diff changeset
   247
            Transcript showCR:'directory : ' , box directory pathName.
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   248
        ]
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   249
                                                                        [exEnd]
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   250
"
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   251
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   252
1320
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   253
!FileSelectionBox class methodsFor:'accessing'!
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   254
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   255
lastFileSelectionDirectory
1571
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   256
    "return the name of the directory used in the previous
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   257
     fileSelection dialog. This will be used as default for the next dialog,
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   258
     if no explicit path is specified (see requestFileName:* methods)"
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   259
1574
471b68cfa6ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
   260
    |f|
471b68cfa6ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
   261
1571
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   262
    LastFileSelectionDirectory notNil ifTrue:[
1574
471b68cfa6ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
   263
        ((f := LastFileSelectionDirectory asFilename) exists 
471b68cfa6ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
   264
        and:[f isDirectory]) ifFalse:[
471b68cfa6ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
   265
            LastFileSelectionDirectory := nil.
471b68cfa6ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
   266
        ]
1571
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   267
    ].
1320
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   268
    ^ LastFileSelectionDirectory
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   269
1571
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   270
    "Created: / 9.9.1997 / 10:03:17 / cg"
1574
471b68cfa6ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
   271
    "Modified: / 16.6.1998 / 15:11:20 / cg"
1320
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   272
!
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   273
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   274
lastFileSelectionDirectory:aDirectoryString
1571
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   275
    "set the name of the directory used in the previous
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   276
     fileSelection dialog. This will be used as default for the next dialog,
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   277
     if no explicit path is specified (see requestFileName:* methods)"
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   278
1320
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   279
    LastFileSelectionDirectory := aDirectoryString
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   280
1571
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   281
    "Created: / 9.9.1997 / 10:03:42 / cg"
fdaa3b9aa746 flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   282
    "Modified: / 15.6.1998 / 14:05:21 / cg"
1320
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   283
! !
47ff27735939 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1271
diff changeset
   284
849
3f3371dd8222 commentary
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   285
!FileSelectionBox class methodsFor:'defaults'!
12
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   286
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   287
listViewType
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   288
    "return the type of listView - using a FileSelectionList here"
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   289
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   290
    ^ FileSelectionList
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   291
! !
1c8e8c53e8cf *** empty log message ***
claus
parents: 7
diff changeset
   292
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   293
!FileSelectionBox class methodsFor:'menu specs'!
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   294
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   295
fileListMenu
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   296
    "This resource specification was automatically generated
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   297
     by the MenuEditor of ST/X."
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   298
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   299
    "Do not manually edit this!! If it is corrupted,
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   300
     the MenuEditor may not be able to read the specification."
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   301
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   302
    "
2354
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   303
     MenuEditor new openOnClass:FileSelectionBox andSelector:#fileListMenu
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   304
     (Menu new fromLiteralArrayEncoding:(FileSelectionBox fileListMenu)) startUp
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   305
    "
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   306
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   307
    <resource: #menu>
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   308
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   309
    ^ 
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   310
     #(#Menu
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   311
        #(
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   312
         #(#MenuItem
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   313
            #label: 'New Folder...'
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   314
            #translateLabel: true
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   315
            #value: #fileListMenuNewFolder
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   316
          )
2354
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   317
         #(#MenuItem
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   318
            #label: '-'
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   319
          )
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   320
         #(#MenuItem
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   321
            #label: 'Remove...'
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   322
            #translateLabel: true
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   323
            #value: #fileListMenuRemove
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   324
          )
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   325
         )
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   326
        nil
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   327
        nil
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   328
      )
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   329
! !
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   330
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   331
!FileSelectionBox methodsFor:'accessing'!
3
claus
parents: 0
diff changeset
   332
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   333
allowMakeDirectory:aBoolean
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   334
    "allow or deny creation of new directories;
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   335
     The default is to allow it."
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   336
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   337
    allowMakeDirectory := aBoolean.
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   338
!
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   339
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   340
contents
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   341
    "return the current entered value (i.e. the enterFields string).
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   342
     redefined to return the full pathname."
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   343
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1674
diff changeset
   344
    |string|
3
claus
parents: 0
diff changeset
   345
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   346
    string := super contents.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   347
    string isNil ifTrue:[
1670
8d24855a9f0b oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents: 1643
diff changeset
   348
        ^ selectionList directory pathName
121
claus
parents: 120
diff changeset
   349
    ].
1670
8d24855a9f0b oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents: 1643
diff changeset
   350
    (string asFilename isAbsolute) ifTrue:[
8d24855a9f0b oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents: 1643
diff changeset
   351
        ^ string
77
565b052f5277 *** empty log message ***
claus
parents: 62
diff changeset
   352
    ].
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   353
    ^ (selectionList directory pathName asFilename construct:string) asString
1670
8d24855a9f0b oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents: 1643
diff changeset
   354
8d24855a9f0b oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents: 1643
diff changeset
   355
    "Modified: / 9.9.1998 / 21:23:16 / cg"
132
claus
parents: 130
diff changeset
   356
!
claus
parents: 130
diff changeset
   357
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   358
directory
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   359
    "return the directory which is currently shown"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   360
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   361
    ^ selectionList directory
296
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   362
!
e1b9431b3aef more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents: 240
diff changeset
   363
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   364
directory:directoryName
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   365
    "change the directory shown in the list."
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   366
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   367
    selectionList directory:directoryName
132
claus
parents: 130
diff changeset
   368
!
claus
parents: 130
diff changeset
   369
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   370
fileName
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   371
    "if some filename has been entered, return it (without the directory path)
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   372
     otherwise, return nil"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   373
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   374
    |string|
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   375
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   376
    string := super contents.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   377
    string isNil ifTrue:[^ nil].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   378
    ^ self pathName asFilename baseName
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   379
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   380
    "Modified: / 12.8.1998 / 09:54:01 / cg"
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   381
!
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   382
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   383
matchBlock:aBlock
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   384
    "set the matchBlock (in the selectionList). Only files
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   385
     for which the block returns true are shown.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   386
     The matching is actually done in the fileSelectionList."
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   387
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   388
    selectionList matchBlock:aBlock 
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   389
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   390
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   391
openOn:aPath
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   392
    "open the box showing files in aPath.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   393
     This is only a shortcut message - no new functionality."
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   394
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   395
    self directory:aPath.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   396
    self showAtPointer
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   397
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   398
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   399
pathName
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   400
    "same as contents - return the full pathname of the selected file,
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   401
     or the pathname of the directory if nothing has been entered"
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   402
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   403
    ^ self contents
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   404
!
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   405
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   406
pattern:aPattern
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   407
    "set the pattern - this also enables the PatternField
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   408
     (if the pattern is non-nil) or hides it (if nil)."
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   409
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   410
    |focusSequence|
130
claus
parents: 121
diff changeset
   411
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   412
    patternField initialText:aPattern.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   413
    selectionList pattern:aPattern.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   414
    aPattern isNil ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   415
        patternField beInvisible.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   416
        self makeUntabable:patternField.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   417
        focusSequence := (Array 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   418
                             with:enterField 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   419
                             with:selectionList 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   420
                             with:okButton 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   421
                             with:abortButton)
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   422
    ] ifFalse:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   423
        patternField beVisible.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   424
        self makeTabable:patternField before:enterField.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   425
        focusSequence := (Array 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   426
                             with:patternField 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   427
                             with:enterField 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   428
                             with:selectionList 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   429
                             with:okButton 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   430
                             with:abortButton)
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   431
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   432
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   433
    windowGroup notNil ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   434
        windowGroup focusSequence:focusSequence
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   435
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   436
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   437
    "Modified: 18.10.1997 / 03:02:05 / cg"
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   438
!
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   439
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   440
selectingDirectory:aBoolean
849
3f3371dd8222 commentary
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   441
    "setup the box for directory selection (hides regular files).
3f3371dd8222 commentary
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   442
     Use this, to ask the user for a directories name"
3f3371dd8222 commentary
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   443
548
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   444
    selectingDirectory := aBoolean.
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   445
    aBoolean ifTrue:[
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   446
        selectionList directoryChangeAction:[:entry | self directoryChanged].
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   447
        selectionList directorySelectAction:[:entry | self directorySelected].
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   448
        selectionList ignoreFiles:true.
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   449
    ]
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   450
849
3f3371dd8222 commentary
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   451
    "Modified: 22.10.1996 / 13:24:50 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   452
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   453
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   454
!FileSelectionBox methodsFor:'change & update'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   456
update:something with:argument from:changedObject
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   457
    |commonName index s|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   458
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   459
    something == #directory ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   460
	"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   461
	 sent by fileNameEnterField, if a filename
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   462
	 completion was not possible due to multiple
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   463
	 matches.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   464
	"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   465
	selectionList directory:argument.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
	s := enterField contents.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   467
	s notNil ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   468
	    commonName := s asFilename baseName.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   469
	    commonName size > 0 ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   470
		index := selectionList list findFirst:[:entry | entry startsWith:commonName].
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   471
		index ~~ 0 ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   472
		    selectionList makeLineVisible:index
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   473
		]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   474
	    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   475
	]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   476
    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   477
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   478
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   479
!FileSelectionBox methodsFor:'initialization'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   480
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   481
createEnterField
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   482
    "if the (optional) class FilenameEditField is present, use
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   483
     it, since it provides filename completion. Otherwise, we have
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   484
     to live with the dumb (default) field ...
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   485
    "
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   486
    FilenameEditField notNil ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   487
        ^ FilenameEditField new.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   488
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   489
    ^ super createEnterField
548
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   490
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   491
    "Modified: 18.4.1996 / 20:02:24 / cg"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   492
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   493
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   494
initialize
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   495
    |corner|
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   496
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   497
    super initialize.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   498
    selectingDirectory := false.
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   499
    allowMakeDirectory := true.
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   500
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   501
    label := resources string:'File dialog'.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   502
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   503
    labelField extent:(0.7 @ labelField height).
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   504
    labelField label:(resources string:'select a file:').
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   505
    labelField adjust:#left.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   506
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   507
    patternField := EditField in:self.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   508
    self is3D ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   509
        corner := (1.0 @ (labelField origin y+patternField heightIncludingBorder)).
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   510
    ] ifFalse:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   511
        corner := [(width - ViewSpacing - (patternField borderWidth * 2)) @ (labelField origin y+patternField height"IncludingBorder")].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   512
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   513
    patternField origin:(0.7 @ labelField origin y) corner:corner.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   514
    patternField rightInset:ViewSpacing.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   515
    patternField initialText:'*'.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   516
    patternField leaveAction:[:reason | self patternChanged]. 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   517
    patternField crAction:[self patternChanged].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   518
    patternField hiddenOnRealize:true. "delay showing, until a pattern is defined"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   519
"/ no, since its invisible
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   520
"/    self makeTabable:patternField before:enterField.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   521
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   522
    enterField addDependent:self.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   523
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   524
    selectionList menuHolder:self; menuMessage:#fileListMenu; menuPerformer:self.
2375
1e3b7281d4ac added optional ignoreCase in matchpattern
Claus Gittinger <cg@exept.de>
parents: 2354
diff changeset
   525
    selectionList ignoreCaseInPattern:true.
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   526
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   527
    "
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   528
     FileSelectionBox open
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   529
     FileSelectionBox new show
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   530
    "
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   531
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   532
    "Modified: 18.10.1997 / 02:47:49 / cg"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   533
!
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   534
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   535
postRealize
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   536
    "if some default is present in the enterField,
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   537
     scroll to make this one visible"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   538
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   539
    |contents|
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   540
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   541
    super postRealize.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   542
    (contents := enterField contents) notNil ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   543
        contents notEmpty ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   544
            selectionList makeVisible:contents
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   545
        ]
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   546
    ]
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   547
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   548
    "Created: 24.7.1997 / 18:19:14 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   549
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   550
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   551
!FileSelectionBox methodsFor:'menu'!
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   552
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   553
fileListMenu
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   554
    allowMakeDirectory ifFalse:[^ self].
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   555
    ^ self class fileListMenu
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   556
!
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   557
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   558
fileListMenuNewFolder
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   559
    |newDirName d|
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   560
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   561
    newDirName := Dialog request:'Name of new Folder:'.
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   562
    newDirName size == 0 ifTrue:[^ self].
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   563
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   564
    d := self directory asFilename construct:newDirName.
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   565
    d exists ifTrue:[
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   566
        d isDirectory ifTrue:[
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   567
            ^ self
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   568
        ].
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   569
        self warn:(resources string:'A file named %1 already exists.' with:newDirName).
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   570
        ^ self
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   571
    ].
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   572
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   573
    d makeDirectory.
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   574
    self updateList.
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   575
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   576
    "
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   577
     self open
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   578
    "
2354
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   579
!
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   580
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   581
fileListMenuRemove
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   582
    |selectedFilename baseName|
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   583
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   584
    selectedFilename := self pathName asFilename.
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   585
    baseName := selectedFilename baseName.
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   586
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   587
    (Dialog confirm:(resources string:'Really remove ''%1'' ?' with:baseName allBold)) ifFalse:[
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   588
        ^ self.
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   589
    ].
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   590
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   591
    selectedFilename isDirectory ifTrue:[
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   592
        self warn:(resources string:'%1 is a directory..' with:baseName).
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   593
        ^ self.
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   594
    ].
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   595
373ee1f525e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2231
diff changeset
   596
    selectedFilename delete.
2376
ec58e7de7023 do not scroll after remove.
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   597
    self updateListWithoutScrolling.
2231
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   598
! !
48ab82d819bc added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   599
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   600
!FileSelectionBox methodsFor:'private'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   601
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   602
updateList
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   603
    selectionList updateList
2376
ec58e7de7023 do not scroll after remove.
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   604
!
ec58e7de7023 do not scroll after remove.
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   605
ec58e7de7023 do not scroll after remove.
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   606
updateListWithoutScrolling
ec58e7de7023 do not scroll after remove.
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   607
    selectionList updateListWithoutScrolling
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   608
! !
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   609
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   610
!FileSelectionBox methodsFor:'queries'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   611
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   612
preferredExtent
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   613
    "return my preferred extent - thats the minimum size 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   614
     to make everything visible"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   615
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   616
    |wWanted hWanted mm|
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   617
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   618
    "/ If I have an explicit preferredExtent ..
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   619
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   620
    preferredExtent notNil ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   621
        ^ preferredExtent
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   622
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   623
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   624
    mm := ViewSpacing.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   625
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   626
    wWanted := mm + 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   627
               labelField preferredExtent x + 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   628
               (mm * 2) + 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   629
               patternField preferredExtent x + 
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   630
               mm.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   631
    (wWanted < width) ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   632
        wWanted := width
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   633
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   634
    hWanted := mm + labelField height +
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   635
               mm + enterField height +
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   636
               mm + selectionList height +
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   637
               mm + buttonPanel preferredExtent y +
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   638
               mm.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   639
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   640
    (hWanted < height) ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   641
        hWanted := height
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   642
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   643
    ^ (wWanted @ hWanted)
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   644
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   645
    "Modified: 19.7.1996 / 20:44:04 / cg"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   646
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   647
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   648
!FileSelectionBox methodsFor:'user actions'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   649
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   650
directoryChanged
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   651
    selectingDirectory ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   652
        selectionList changeDirectory.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   653
        enterField contents:(selectionList directory pathName).
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   654
        selectionList setSelection:nil.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   655
    ].
548
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   656
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   657
    "Created: 18.4.1996 / 18:38:21 / cg"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   658
    "Modified: 25.5.1996 / 12:27:05 / cg"
548
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   659
!
c418699a90c0 moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents: 438
diff changeset
   660
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   661
directorySelected
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   662
    "a directory was selected - show the new path in the inputField,
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   663
     if we are in directory mode"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   664
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   665
    selectingDirectory ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   666
        |newDir|
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   667
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   668
        newDir := (selectionList directory)
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   669
                      construct:selectionList selectionValue.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   670
        enterField contents:newDir pathName.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   671
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   673
    "Created: / 18.4.1996 / 18:46:15 / cg"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   674
    "Modified: / 7.8.1998 / 17:19:26 / cg"
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   675
!
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   676
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   677
doubleClick
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   678
    |entry|
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   679
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   680
    entry := selectionList selectionValue.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   681
    entry notNil ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   682
        ((selectionList directory asFilename construct:entry) isDirectory) ifFalse:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   683
            selectingDirectory ifFalse:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   684
                enterField contents:entry.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   685
                self okPressed
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   686
            ]
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   687
        ]
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   688
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   689
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   690
    "Modified: 19.10.1997 / 00:17:37 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   691
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   692
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   693
okPressed
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   694
    "called for both on ok-press and on return-key"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   695
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   696
    |dir string fname|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   697
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   698
    string := enterField contents.
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   699
    (string notNil and:[string notEmpty]) ifTrue:[
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   700
        string := string withoutSeparators.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   701
        string asFilename isAbsolute ifTrue:[
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   702
            fname := string asFilename
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   703
        ] ifFalse:[
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   704
            dir := selectionList directory pathName asFilename.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   705
            fname := dir construct:string
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   706
        ].
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   707
        fname isDirectory ifTrue:[
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   708
            selectingDirectory ifFalse:[
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   709
                selectionList directory:fname asString.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   710
                self updateList.
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   711
                ^ self
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   712
            ]    
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   713
        ]
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   714
    ] ifFalse:[
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   715
        selectingDirectory ifTrue:[
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   716
            enterField contents:(selectionList directory pathName).
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   717
        ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 21
diff changeset
   718
    ].
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   719
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   720
    super okPressed
351
24a527f86c7b allow multiple patterns sep'd by semi
ca
parents: 296
diff changeset
   721
1674
75149fa16b10 oops - leftover halt removed.
Claus Gittinger <cg@exept.de>
parents: 1672
diff changeset
   722
    "Modified: / 10.9.1998 / 22:19:11 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   723
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   724
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   725
patternChanged
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   726
    selectionList pattern:patternField contents. 
746
4442a4d4121f dont want return in patternField to be accept of box
Claus Gittinger <cg@exept.de>
parents: 740
diff changeset
   727
    self updateList
4442a4d4121f dont want return in patternField to be accept of box
Claus Gittinger <cg@exept.de>
parents: 740
diff changeset
   728
4442a4d4121f dont want return in patternField to be accept of box
Claus Gittinger <cg@exept.de>
parents: 740
diff changeset
   729
    "Created: 4.6.1996 / 20:30:23 / cg"
1672
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   730
!
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   731
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   732
selectionChanged
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   733
    |entry|
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   734
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   735
    entry := selectionList selectionValue.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   736
    (selectionList directory asFilename construct:entry) type == #directory ifFalse:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   737
        selectingDirectory ifTrue:[
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   738
            enterField contents:(selectionList directory pathName).
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   739
            selectionList setSelection:nil.
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   740
            ^ self
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   741
        ]
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   742
    ].
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   743
    enterField contents:entry
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   744
4ad88fcbc3ac oops - bad checkin
Claus Gittinger <cg@exept.de>
parents: 1671
diff changeset
   745
    "Modified: 21.9.1997 / 12:07:55 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   746
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   747
849
3f3371dd8222 commentary
Claus Gittinger <cg@exept.de>
parents: 842
diff changeset
   748
!FileSelectionBox class methodsFor:'documentation'!
240
75a3b67bd91d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   749
75a3b67bd91d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   750
version
2376
ec58e7de7023 do not scroll after remove.
Claus Gittinger <cg@exept.de>
parents: 2375
diff changeset
   751
    ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.60 2001-06-19 15:02:00 cg Exp $'
240
75a3b67bd91d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   752
! !