FileBrowser.st
changeset 3953 4fd0ed70cf36
parent 3943 e95eccd089a9
child 3954 78e29a3ea4c1
equal deleted inserted replaced
3952:c04d4781a37e 3953:4fd0ed70cf36
    11 "
    11 "
    12 
    12 
    13 "{ Package: 'stx:libtool' }"
    13 "{ Package: 'stx:libtool' }"
    14 
    14 
    15 StandardSystemView subclass:#FileBrowser
    15 StandardSystemView subclass:#FileBrowser
    16 	instanceVariableNames:'menuPanel labelView filterField fileListView subView
    16         instanceVariableNames:'menuPanel labelView filterField fileListView subView
    17 		currentDirectory fileList checkBlock checkDelta timeOfLastCheck
    17                 currentDirectory fileList checkBlock checkDelta timeOfLastCheck
    18 		myName killButton pauseToggle compressTabs lockUpdate
    18                 myName killButton pauseToggle compressTabs lockUpdate
    19 		previousDirectory currentFileName timeOfFileRead tabSpec
    19                 previousDirectory currentFileName timeOfFileRead tabSpec
    20 		commandView commandIndex fileEncoding tabRulerView scrollView
    20                 commandView commandIndex fileEncoding tabRulerView scrollView
    21 		icons matchedIcons listUpdateProcess currentFileInFileName
    21                 icons matchedIcons listUpdateProcess currentFileInFileName
    22 		lastFileDiffDirectory sortByWhat sortCaseless showingDetails
    22                 lastFileDiffDirectory sortByWhat sortCaseless showingDetails
    23 		showingTimeAndDate showingHiddenFiles showingBigImagePreview
    23                 showingTimeAndDate showingHiddenFiles showingBigImagePreview
    24 		imagePreviewView imageRenderProcess dosEOLMode doAutoUpdate
    24                 imagePreviewView imageRenderProcess dosEOLMode doAutoUpdate
    25 		doNotShowFontDialog lastEnforcedNameSpace'
    25                 doNotShowFontDialog lastEnforcedNameSpace'
    26 	classVariableNames:'DirectoryHistory DirectoryHistoryWhere DirectoryBookmarks
    26         classVariableNames:'DirectoryBookmarks HistorySize DefaultIcon CommandHistory
    27 		HistorySize DefaultIcon CommandHistory CommandHistorySize Icons
    27                 CommandHistorySize Icons MatchedIcons DefaultCommandPerSuffix
    28 		MatchedIcons DefaultCommandPerSuffix DefaultCommandPerMIME
    28                 DefaultCommandPerMIME VisitedFileHistory LastEnforcedNameSpace'
    29 		VisitedFileHistory LastEnforcedNameSpace'
    29         poolDictionaries:''
    30 	poolDictionaries:''
    30         category:'Interface-Tools-File'
    31 	category:'Interface-Tools-File'
       
    32 !
    31 !
    33 
    32 
    34 !FileBrowser class methodsFor:'documentation'!
    33 !FileBrowser class methodsFor:'documentation'!
    35 
    34 
    36 copyright
    35 copyright
   147      FileBrowser openOnFileNamed:'../Makefile'
   146      FileBrowser openOnFileNamed:'../Makefile'
   148      FileBrowser openOnFileNamed:'/tmp/foo'
   147      FileBrowser openOnFileNamed:'/tmp/foo'
   149     "
   148     "
   150 
   149 
   151     "Modified: / 17.6.1998 / 11:25:29 / cg"
   150     "Modified: / 17.6.1998 / 11:25:29 / cg"
       
   151 ! !
       
   152 
       
   153 !FileBrowser class methodsFor:'aspects'!
       
   154 
       
   155 directoryHistory
       
   156 
       
   157     ^ AbstractFileBrowser directoryHistory.
   152 ! !
   158 ! !
   153 
   159 
   154 !FileBrowser class methodsFor:'class initialization'!
   160 !FileBrowser class methodsFor:'class initialization'!
   155 
   161 
   156 icons
   162 icons
   389             ]
   395             ]
   390         ]
   396         ]
   391     ]
   397     ]
   392 
   398 
   393     "Created: 14.11.1996 / 14:58:13 / cg"
   399     "Created: 14.11.1996 / 14:58:13 / cg"
   394 !
       
   395 
       
   396 addToHistory:path
       
   397     |pos idx|
       
   398 
       
   399     idx := self directoryHistory indexOf:path.
       
   400     idx == 0 ifTrue:[
       
   401         self directoryHistory size >= HistorySize ifTrue:[
       
   402             self directoryHistory removeLast.
       
   403             self directoryHistoryWhere removeLast
       
   404         ]
       
   405     ] ifFalse:[
       
   406         "already been there before; move the entry to
       
   407          the beginning, so it will fall out later."
       
   408 
       
   409         self directoryHistory removeIndex:idx.
       
   410         pos := self directoryHistoryWhere at:idx.
       
   411         self directoryHistoryWhere removeIndex:idx.
       
   412     ].
       
   413     self directoryHistory addFirst:path.
       
   414     self directoryHistoryWhere addFirst:pos.
       
   415 
       
   416     "Created: / 8.11.1997 / 17:16:29 / cg"
       
   417 !
   400 !
   418 
   401 
   419 addToVisitedFileHistory:path
   402 addToVisitedFileHistory:path
   420     |idx|
   403     |idx|
   421 
   404 
   800     ^ m
   783     ^ m
   801 
   784 
   802     "Modified: / 17.8.1998 / 10:13:05 / cg"
   785     "Modified: / 17.8.1998 / 10:13:05 / cg"
   803 !
   786 !
   804 
   787 
   805 directoryHistory
       
   806 
       
   807     DirectoryHistory isNil ifTrue:[
       
   808         DirectoryHistory := OrderedCollection new.
       
   809     ].
       
   810     ^ DirectoryHistory
       
   811 !
       
   812 
       
   813 directoryHistoryWhere
       
   814 
       
   815     DirectoryHistoryWhere isNil ifTrue:[
       
   816         DirectoryHistoryWhere := OrderedCollection new.
       
   817     ].
       
   818     ^ DirectoryHistoryWhere
       
   819 !
       
   820 
       
   821 directoryMenuSpec
   788 directoryMenuSpec
   822     "This resource specification was automatically generated
   789     "This resource specification was automatically generated
   823      by the MenuEditor of ST/X."
   790      by the MenuEditor of ST/X."
   824 
   791 
   825     "Do not manually edit this!! If it is corrupted,
   792     "Do not manually edit this!! If it is corrupted,
   913     "/ add the history items ...
   880     "/ add the history items ...
   914 
   881 
   915     self directoryHistory size > 0 ifTrue:[
   882     self directoryHistory size > 0 ifTrue:[
   916         m := Menu new.
   883         m := Menu new.
   917 
   884 
   918         self directoryHistory do:[:dirName |
   885         self directoryHistory do:[:item |
       
   886             | dirName |
       
   887             dirName := item path.
   919             m addItem:((MenuItem label:dirName value:#changeDirectoryTo:)
   888             m addItem:((MenuItem label:dirName value:#changeDirectoryTo:)
   920                             argument:dirName;
   889                             argument:dirName;
   921                             yourself).
   890                             yourself).
   922         ].
   891         ].
   923     ].
   892     ].
  1557             #isVisible: #hasJava
  1526             #isVisible: #hasJava
  1558             #value: #openAppletViewer
  1527             #value: #openAppletViewer
  1559             #enabled: #hasJavaAndSelection
  1528             #enabled: #hasJavaAndSelection
  1560           )
  1529           )
  1561          #(#MenuItem
  1530          #(#MenuItem
       
  1531             #label: 'Image Inspector'
       
  1532             #translateLabel: true
       
  1533             #value: #openImageInspector
       
  1534             #enabled: #hasSelection
       
  1535           )
       
  1536          #(#MenuItem
  1562             #label: 'Image'
  1537             #label: 'Image'
  1563             #translateLabel: true
  1538             #translateLabel: true
  1564             #submenu: 
  1539             #submenu: 
  1565            #(#Menu
  1540            #(#Menu
  1566               #(
  1541               #(
  1839 
  1814 
  1840     "Modified: / 4.8.1998 / 14:10:57 / cg"
  1815     "Modified: / 4.8.1998 / 14:10:57 / cg"
  1841     "Created: / 14.8.1998 / 12:07:10 / cg"
  1816     "Created: / 14.8.1998 / 12:07:10 / cg"
  1842 !
  1817 !
  1843 
  1818 
       
  1819 directoryHistory
       
  1820 
       
  1821     ^ self class directoryHistory
       
  1822 !
       
  1823 
  1844 dosEOLMode
  1824 dosEOLMode
  1845     ^ dosEOLMode
  1825     ^ dosEOLMode
  1846 
  1826 
  1847     "Created: / 6.5.1999 / 11:37:25 / cg"
  1827     "Created: / 6.5.1999 / 11:37:25 / cg"
  1848     "Modified: / 6.5.1999 / 11:39:38 / cg"
  1828     "Modified: / 6.5.1999 / 11:39:38 / cg"
  1942     "Created: / 4.8.1998 / 14:10:31 / cg"
  1922     "Created: / 4.8.1998 / 14:10:31 / cg"
  1943     "Modified: / 4.8.1998 / 14:10:57 / cg"
  1923     "Modified: / 4.8.1998 / 14:10:57 / cg"
  1944 !
  1924 !
  1945 
  1925 
  1946 hasVisitHistory
  1926 hasVisitHistory
  1947     ^ [self class directoryHistory size > 0]
  1927     ^ [self directoryHistory size > 0]
  1948 
  1928 
  1949     "Created: / 14.8.1998 / 19:17:02 / cg"
  1929     "Created: / 14.8.1998 / 19:17:02 / cg"
  1950     "Modified: / 14.8.1998 / 19:17:17 / cg"
  1930     "Modified: / 14.8.1998 / 19:17:17 / cg"
  1951 !
  1931 !
  1952 
  1932 
  4626     DirectoryBookmarks isNil ifTrue:[
  4606     DirectoryBookmarks isNil ifTrue:[
  4627         DirectoryBookmarks := OrderedCollection new
  4607         DirectoryBookmarks := OrderedCollection new
  4628     ].
  4608     ].
  4629     idx := DirectoryBookmarks indexOf:path.
  4609     idx := DirectoryBookmarks indexOf:path.
  4630     idx == 0 ifTrue:[
  4610     idx == 0 ifTrue:[
  4631 "/        DirectoryBookmarks size >= HistorySize ifTrue:[
       
  4632 "/            DirectoryBookmarks removeLast.
       
  4633 "/        ].
       
  4634         DirectoryBookmarks addLast:path.
  4611         DirectoryBookmarks addLast:path.
  4635     ].
  4612     ].
  4636 !
  4613 !
  4637 
  4614 
  4638 copyCommandHistory
  4615 copyCommandHistory
  6180     "Modified: 18.9.1997 / 16:58:40 / stefan"
  6157     "Modified: 18.9.1997 / 16:58:40 / stefan"
  6181 ! !
  6158 ! !
  6182 
  6159 
  6183 !FileBrowser methodsFor:'private - directory stuff'!
  6160 !FileBrowser methodsFor:'private - directory stuff'!
  6184 
  6161 
  6185 addToHistory:path
       
  6186     self class addToHistory:path
       
  6187 !
       
  6188 
       
  6189 changeToPreviousDirectory
  6162 changeToPreviousDirectory
  6190     "if text was modified show a queryBox, 
  6163     "if text was modified show a queryBox, 
  6191      otherwise change immediately to previous directory."
  6164      otherwise change immediately to previous directory."
  6192 
  6165 
  6193     previousDirectory isNil ifTrue:[^ self].
  6166     previousDirectory isNil ifTrue:[^ self].
  6291 
  6264 
  6292 doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory 
  6265 doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory 
  6293     "verify argument is name of a readable & executable directory
  6266     "verify argument is name of a readable & executable directory
  6294      and if so, go there"
  6267      and if so, go there"
  6295 
  6268 
  6296     |msg path idx f|
  6269     |msg path f pos|
  6297 
  6270 
  6298     self label:myName; iconLabel:myName.
  6271     self label:myName; iconLabel:myName.
  6299     fileName notNil ifTrue:[
  6272     fileName notNil ifTrue:[
  6300         (f := fileName asFilename) isAbsolute ifFalse:[
  6273         (f := fileName asFilename) isAbsolute ifFalse:[
  6301             f := currentDirectory filenameFor:fileName.
  6274             f := currentDirectory filenameFor:fileName.
  6309 
  6282 
  6310                     "
  6283                     "
  6311                      remember where we are positioned in the fileList
  6284                      remember where we are positioned in the fileList
  6312                      (in case we want to return)
  6285                      (in case we want to return)
  6313                     "
  6286                     "
  6314                     idx := self class directoryHistory indexOf:path.
  6287                     self directoryHistory setPosition:(fileListView firstLineShown) for:path.
  6315                     idx ~~ 0 ifTrue:[
       
  6316                         self class directoryHistoryWhere at:idx put:fileListView firstLineShown
       
  6317                     ].
       
  6318 
  6288 
  6319                     updateHistory ifTrue:[
  6289                     updateHistory ifTrue:[
  6320                         self addToHistory:path.
  6290                         self directoryHistory addToHistory:path.
  6321                     ].
  6291                     ].
  6322 
  6292 
  6323                     self setCurrentDirectory:(f pathName).
  6293                     self setCurrentDirectory:(f pathName).
  6324 
  6294 
  6325                     "/ fetch the new path.
  6295                     "/ fetch the new path.
  6327 
  6297 
  6328                     "
  6298                     "
  6329                      if we have already been there, look for the
  6299                      if we have already been there, look for the
  6330                      position offset, and scroll the fileList
  6300                      position offset, and scroll the fileList
  6331                     "
  6301                     "
  6332                     idx := self class directoryHistory indexOf:path.
  6302                     pos := self directoryHistory getPositionFor:path.
  6333                     idx ~~ 0 ifTrue:[
  6303                     pos notNil ifTrue:[
  6334                         |pos|
  6304                         fileListView scrollToLine:pos.
  6335 
       
  6336                         pos := self class directoryHistoryWhere at:idx.
       
  6337                         pos notNil ifTrue:[
       
  6338                             fileListView scrollToLine:pos.
       
  6339                         ]
       
  6340                     ].
  6305                     ].
  6341 
  6306 
  6342                     updateHistory ifTrue:[
  6307                     updateHistory ifTrue:[
  6343                         self addToHistory:path.
  6308                         self directoryHistory addToHistory:path.
  6344                     ].
  6309                     ].
  6345 
  6310 
  6346                     ^ self
  6311                     ^ self
  6347                 ].
  6312                 ].
  6348                 msg := 'cannot change directory to ''%1'' !!'
  6313                 msg := 'cannot change directory to ''%1'' !!'
  8146 ! !
  8111 ! !
  8147 
  8112 
  8148 !FileBrowser class methodsFor:'documentation'!
  8113 !FileBrowser class methodsFor:'documentation'!
  8149 
  8114 
  8150 version
  8115 version
  8151     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.505 2002-10-02 09:10:46 ca Exp $'
  8116     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.506 2002-10-08 08:20:09 penk Exp $'
  8152 ! !
  8117 ! !