FileBrowserV2.st
changeset 17374 b5dded40c579
parent 17210 7febc2ec2898
child 17375 a766e86b4498
equal deleted inserted replaced
17373:62c44bf0d8d5 17374:b5dded40c579
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 2002 by eXept Software AG
     4  COPYRIGHT (c) 2002 by eXept Software AG
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
    85 ! !
    87 ! !
    86 
    88 
    87 !FileBrowserV2 class methodsFor:'instance creation'!
    89 !FileBrowserV2 class methodsFor:'instance creation'!
    88 
    90 
    89 on:aDirectoryPath
    91 on:aDirectoryPath
    90     "return a new FileBrowserV2 in a pathname"
    92     "return a new FileBrowserV2 in a pathname.
       
    93      The browser is not yet open"
    91 
    94 
    92     |instance|
    95     |instance|
    93 
    96 
    94     instance := self new.
    97     instance := self new.
    95     instance onDirectory:aDirectoryPath.
    98     instance onDirectory:aDirectoryPath.
    96     ^ instance
    99     ^ instance
       
   100 
       
   101     "
       
   102      (self on:'/etc') open
       
   103     "
    97 !
   104 !
    98 
   105 
    99 open
   106 open
   100     "start a new FileBrowserV2"
   107     "start a new FileBrowserV2 (in the current directory)"
   101 
   108 
   102     | instance |
   109     | instance |
   103     instance := self new.
   110     instance := self new.
   104     instance open.
   111     instance open.
   105     ^ instance
   112     ^ instance
   106 
   113 
   107     "
   114     "
       
   115      FileBrowserV2 open.
   108      FileBrowserV2 openOn:(OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) withExtent:800@600
   116      FileBrowserV2 openOn:(OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) withExtent:800@600
   109     "
   117     "
   110 !
   118 !
   111 
   119 
   112 openIn:aDirectoryPath
   120 openIn:aDirectoryPath
   114 
   122 
   115     ^ self openOn:aDirectoryPath
   123     ^ self openOn:aDirectoryPath
   116 !
   124 !
   117 
   125 
   118 openOn:aFileOrDirectoryPath
   126 openOn:aFileOrDirectoryPath
   119     "start a new FileBrowserV2 in a pathname"
   127     "start a new FileBrowserV2 on aFileOrDirectoryPath.
       
   128      if it represents a file, it is opened and shown for editing;
       
   129      if it represents a directory, the directory is shown."
   120 
   130 
   121     |fn|
   131     |fn|
   122 
   132 
   123     fn := aFileOrDirectoryPath asFilename.
   133     fn := aFileOrDirectoryPath asFilename.
   124     fn isDirectory ifFalse:[
   134     fn isDirectory ifFalse:[
   125 	^ self openOnFileNamed:aFileOrDirectoryPath
   135         ^ self openOnFileNamed:aFileOrDirectoryPath
   126     ] ifTrue:[
   136     ] ifTrue:[
   127 	^ self openOn:fn withExtent:nil
   137         ^ self openOn:fn withExtent:nil
   128     ].
   138     ].
   129 
   139 
   130     "
   140     "
   131      FileBrowserV2 openOn:(Filename currentDirectory asAbsoluteFilename)
   141      FileBrowserV2 openOn:(Filename currentDirectory asAbsoluteFilename)
   132      FileBrowserV2 openOn:'Makefile'
   142      FileBrowserV2 openOn:'Makefile'
   134 
   144 
   135     "Modified (comment): / 06-09-2012 / 14:46:54 / cg"
   145     "Modified (comment): / 06-09-2012 / 14:46:54 / cg"
   136 !
   146 !
   137 
   147 
   138 openOn:aDirectoryPath withExtent:extentOrNil
   148 openOn:aDirectoryPath withExtent:extentOrNil
   139     "start a new FileBrowserV2 in a pathname"
   149     "start a new FileBrowserV2 on aDirectoryPath"
   140 
   150 
   141     |instance builder|
   151     |instance builder|
   142 
   152 
   143     instance := self on:aDirectoryPath.
   153     instance := self on:aDirectoryPath.
   144     builder := instance open.
   154     builder := instance open.
   145     extentOrNil notNil ifTrue:[
   155     extentOrNil notNil ifTrue:[
   146 	builder window extent:extentOrNil.
   156         builder window extent:extentOrNil.
   147     ].
   157     ].
   148     ^ instance
   158     ^ instance
   149 
   159 
   150     "
   160     "
   151      FileBrowserV2 openOn:(OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) withExtent:800@600
   161      FileBrowserV2 openOn:(OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) withExtent:800@600
   156     "start a new FileBrowserV2 in a pathname"
   166     "start a new FileBrowserV2 in a pathname"
   157 
   167 
   158     ^ self openOn:aDirectoryPath withExtent:nil
   168     ^ self openOn:aDirectoryPath withExtent:nil
   159 
   169 
   160     "
   170     "
   161      FileBrowserV2 openOn:(OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) withExtent:800@600
   171      FileBrowserV2 
       
   172             openOn:(OrderedCollection 
       
   173                         with:(Filename currentDirectory asAbsoluteFilename)
       
   174                    ) 
       
   175             withExtent:800@600
   162     "
   176     "
   163 !
   177 !
   164 
   178 
   165 openOnFileNamed:aFilename
   179 openOnFileNamed:aFilename
   166     "start a new FileBrowserV2 on a aFilename.
   180     "start a new FileBrowserV2 on a aFilename.
   189      FileBrowserV2 openOnFileNamed:'Makefile'
   203      FileBrowserV2 openOnFileNamed:'Makefile'
   190     "
   204     "
   191 !
   205 !
   192 
   206 
   193 openWithAspects:someAspects withExtent:extent
   207 openWithAspects:someAspects withExtent:extent
   194     "start a new FileBrowserV2 in a pathname"
   208     "start a new FileBrowserV2 taking aspects from a dictionary
       
   209      (internal interface - only for spawn)"
   195 
   210 
   196     |dir clone|
   211     |dir clone|
   197 
   212 
   198     dir := someAspects at:#currentFileNameHolder ifAbsent:nil.
   213     dir := someAspects at:#currentFileNameHolder ifAbsent:nil.
   199     clone := self openOn:(dir value) withExtent:extent.
   214     clone := self openOn:(dir value) withExtent:extent.
  2468     self infoBarVisibleHolder addDependent:self.
  2483     self infoBarVisibleHolder addDependent:self.
  2469     self previewVisibleHolder addDependent:self.
  2484     self previewVisibleHolder addDependent:self.
  2470 !
  2485 !
  2471 
  2486 
  2472 onDirectory:aDirectoryPathOrNil
  2487 onDirectory:aDirectoryPathOrNil
  2473     |files|
  2488     |directory|
  2474 
  2489 
  2475     self createBuilder.
  2490     self createBuilder.
  2476     aDirectoryPathOrNil notNil ifTrue:[
  2491     aDirectoryPathOrNil notNil ifTrue:[
  2477 	aDirectoryPathOrNil isCollection ifTrue:[
  2492         directory := aDirectoryPathOrNil asFilename.
  2478 	    files := aDirectoryPathOrNil
  2493         self currentFileNameHolder value:{ directory }.
  2479 	] ifFalse:[
       
  2480 	    files := Array with:aDirectoryPathOrNil.
       
  2481 	].
       
  2482 	self currentFileNameHolder value:files.
       
  2483     ].
  2494     ].
  2484 !
  2495 !
  2485 
  2496 
  2486 openOnDirectory:aDirectoryPath
  2497 openOnDirectory:aDirectoryPath
  2487     self onDirectory:aDirectoryPath.
  2498     self onDirectory:aDirectoryPath.