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