FileSelectionBrowser.st
changeset 1353 701e41f8ff9f
parent 1260 6f81c1d73e75
child 1379 1a2e94a447e1
equal deleted inserted replaced
1352:73f656cea457 1353:701e41f8ff9f
    52 ! !
    52 ! !
    53 
    53 
    54 !FileSelectionBrowser class methodsFor:'instance creation'!
    54 !FileSelectionBrowser class methodsFor:'instance creation'!
    55 
    55 
    56 request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
    56 request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
       
    57     "ask for a file in some directory,
       
    58      using a fileFilter (list of mathcPatterns).
       
    59      Initial selection is aFileName.
       
    60      return the pathName or nil if canceled."
       
    61 
    57     ^self new
    62     ^self new
    58         title: aTitle;
    63         title: aTitle;
    59         fileName: aFileName;
    64         fileName: aFileName;
    60         directory: dir;
    65         directory: dir;
    61         listOfFileFilters: fileFilters;
    66         listOfFileFilters: fileFilters;
    62         open
    67         open
    63 
    68 
    64     "
    69     "
    65     self 
    70      self 
    66         request: 'Select Your Profile File' 
    71          request: 'Select Your Profile File' 
    67         fileName: '.profile' 
    72          fileName: '.profile' 
    68         inDirectory: Filename homeDirectory 
    73          inDirectory: Filename homeDirectory 
    69         withFileFilters: #('.*')
    74          withFileFilters: #('.*')
    70     "
    75     "
    71 
    76 
    72     "Modified: / 17.8.1998 / 10:15:50 / cg"
    77     "Modified: / 17.8.1998 / 10:15:50 / cg"
    73 !
    78 !
    74 
    79 
    75 request: aTitle fileName: aFileName withFileFilters: fileFilters
    80 request:aTitle fileName:aFileName withFileFilters:fileFilters
    76     ^self new
    81     "ask for a file in some directory,
       
    82      using a fileFilter (list of mathcPatterns).
       
    83      Initial selection is aFileName.
       
    84      return the pathName or nil if canceled."
       
    85 
       
    86     ^ self new
    77         title: aTitle;
    87         title: aTitle;
    78         fileName: aFileName;
    88         fileName: aFileName;
    79         listOfFileFilters: fileFilters;
    89         listOfFileFilters: fileFilters;
    80         open
    90         open
    81 
    91 
    82     "
    92     "
    83     self 
    93      self 
    84         request: 'Select Your Profile File' 
    94          request: 'Select Your Profile File' 
    85         fileName: '/etc/fstab' 
    95          fileName: '/etc/fstab' 
    86         withFileFilters: #('*')  
    96          withFileFilters: #('*')  
    87     "
    97     "
    88 
    98 
    89     "Modified: / 17.8.1998 / 10:15:50 / cg"
    99     "Modified: / 17.8.1998 / 10:15:50 / cg"
    90 !
   100 !
    91 
   101 
    92 request: aTitle pathName: aPath withFileFilters: fileFilters
   102 request:aTitle inDirectory:aPath withFileFilters:fileFilters 
    93     ^self new
   103     "ask for a file in some directory,
    94         title: aTitle;
   104      using a fileFilter (list of mathcPatterns)
    95         directory: aPath;
   105      return the pathName or nil if canceled."
    96         listOfFileFilters: fileFilters;
   106 
       
   107     ^ (self new)
       
   108         title:aTitle;
       
   109         directory:aPath;
       
   110         listOfFileFilters:fileFilters;
    97         open
   111         open
    98 
   112 
    99     "
   113     "
   100     self 
   114      self 
   101         request: 'Select A File' 
   115          request: 'Select A File' 
   102         pathName: '/etc' 
   116          inDirectory: '/etc' 
   103         withFileFilters: #('*.conf')
   117          withFileFilters: #('*.conf')
   104     "
   118     "
   105 
   119 
   106     "Modified: / 17.8.1998 / 10:15:50 / cg"
   120     "Modified: / 17.8.1998 / 10:15:50 / cg"
   107 !
   121 !
   108 
   122 
   109 request: aTitle withFileFilters: fileFilters
   123 request:aTitle pathName:aPath withFileFilters:fileFilters 
   110     ^ self new
   124     "ask for a file in some directory,
   111         title: aTitle;
   125      using a fileFilter (list of mathcPatterns)
   112         listOfFileFilters: fileFilters;
   126      return the pathName or nil if canceled.
       
   127      Obsolete - for backward compatibility."
       
   128 
       
   129     ^ self
       
   130         request:aTitle inDirectory:aPath withFileFilters:fileFilters
       
   131 
       
   132     "
       
   133      self 
       
   134          request: 'Select A File' 
       
   135          pathName: '/etc' 
       
   136          withFileFilters: #('*.conf')
       
   137     "
       
   138 
       
   139     "Modified: / 17.8.1998 / 10:15:50 / cg"
       
   140 !
       
   141 
       
   142 request:aTitle withFileFilters:fileFilters 
       
   143     "ask for a file in the current directory,
       
   144      using a fileFilter (list of mathcPatterns)
       
   145      return the pathName or nil if canceled"
       
   146 
       
   147     ^ (self new)
       
   148         title:aTitle;
       
   149         listOfFileFilters:fileFilters;
   113         open
   150         open
   114     "
   151 
   115     self request: 'Select A File' withFileFilters: #('.*')
   152     "
       
   153      self request:'Select A File' withFileFilters:#('.*')
       
   154      self request:'Select A File' withFileFilters:#('*.mak;*.st')
   116     "
   155     "
   117 
   156 
   118     "Modified: / 17.8.1998 / 10:15:49 / cg"
   157     "Modified: / 17.8.1998 / 10:15:49 / cg"
   119 !
   158 !
   120 
   159 
   121 requestFileName
   160 requestFileName
   122     ^self new title: 'Select A File'; open
   161     "ask for a file in the current directory;
   123     "
   162      return the pathName or nil if canceled"
   124     self requestFileName
   163 
       
   164     ^ self new 
       
   165         title:'Select A File';
       
   166         open
       
   167 
       
   168     "
       
   169      self requestFileName
       
   170     "
       
   171 
       
   172     "Modified: / 17.8.1998 / 10:15:48 / cg"
       
   173 !
       
   174 
       
   175 requestFileNameInDirectory:aPath
       
   176     "ask for a file in a directory;
       
   177      return the pathName or nil if canceled"
       
   178 
       
   179     ^ self new 
       
   180         title:'Select A File'; 
       
   181         directory:aPath; 
       
   182         open
       
   183 
       
   184     "
       
   185      self requestFileNameInDirectory:'/etc' 
   125     "
   186     "
   126 
   187 
   127     "Modified: / 17.8.1998 / 10:15:48 / cg"
   188     "Modified: / 17.8.1998 / 10:15:48 / cg"
   128 ! !
   189 ! !
   129 
   190 
   460     super closeRequest
   521     super closeRequest
   461 
   522 
   462 !
   523 !
   463 
   524 
   464 open
   525 open
   465 
       
   466     super open.
   526     super open.
       
   527 
       
   528     "return the selected file or nil"
   467     accept value ifTrue:[
   529     accept value ifTrue:[
   468         ^ (self selectionOfDirectory value ? '') asFilename 
   530         ^ (self selectionOfDirectory value ? '') asFilename 
   469                 constructString:(self valueOfFileName value ? '')
   531                 constructString:(self valueOfFileName value ? '')
   470     ].
   532     ].
   471     ^ nil
   533     ^ nil