FileBrowser.st
changeset 1157 667a57034e40
parent 1156 f3df28086973
child 1158 ea2cd788ef59
equal deleted inserted replaced
1156:f3df28086973 1157:667a57034e40
  1735         self warn:'%1 already exists.' with:newName.
  1735         self warn:'%1 already exists.' with:newName.
  1736         ^ self
  1736         ^ self
  1737     ].
  1737     ].
  1738 
  1738 
  1739     (currentDirectory createDirectory:newName) ifTrue:[
  1739     (currentDirectory createDirectory:newName) ifTrue:[
  1740         self updateCurrentDirectory
  1740         self updateCurrentDirectoryIfChanged
  1741     ] ifFalse:[
  1741     ] ifFalse:[
  1742         self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName)
  1742         self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName)
  1743                   with:(OperatingSystem lastErrorString)
  1743                   with:(OperatingSystem lastErrorString)
  1744     ]
  1744     ]
       
  1745 
       
  1746     "Modified: 19.4.1997 / 15:30:32 / cg"
  1745 !
  1747 !
  1746 
  1748 
  1747 doCreateFile:newName
  1749 doCreateFile:newName
  1748     |aStream|
  1750     |aStream|
  1749 
  1751 
  1755     ].
  1757     ].
  1756 
  1758 
  1757     aStream := FileStream newFileNamed:newName in:currentDirectory.
  1759     aStream := FileStream newFileNamed:newName in:currentDirectory.
  1758     aStream notNil ifTrue:[
  1760     aStream notNil ifTrue:[
  1759         aStream close.
  1761         aStream close.
  1760         self updateCurrentDirectory
  1762         self updateCurrentDirectoryIfChanged
  1761     ] ifFalse:[
  1763     ] ifFalse:[
  1762         self showAlert:(resources string:'cannot create file ''%1'' !!' with:newName)
  1764         self showAlert:(resources string:'cannot create file ''%1'' !!' with:newName)
  1763                   with:(FileStream lastErrorString)
  1765                   with:(FileStream lastErrorString)
  1764     ]
  1766     ]
  1765 
  1767 
  1766     "Modified: 21.2.1996 / 01:24:16 / cg"
  1768     "Modified: 19.4.1997 / 15:30:35 / cg"
  1767 !
  1769 !
  1768 
  1770 
  1769 doExecuteCommand:command replace:replace
  1771 doExecuteCommand:command replace:replace
  1770     "execute a unix command inserting the output of the command.
  1772     "execute a unix command inserting the output of the command.
  1771      If replace is true, all text is replaced by the commands output;
  1773      If replace is true, all text is replaced by the commands output;
  1888                         Processor yield
  1890                         Processor yield
  1889                     ].
  1891                     ].
  1890                 ] valueNowOrOnUnwindDo:[
  1892                 ] valueNowOrOnUnwindDo:[
  1891                     stream shutDown "close". stream := nil.
  1893                     stream shutDown "close". stream := nil.
  1892                 ].
  1894                 ].
  1893                 self updateCurrentDirectory
  1895 
       
  1896                 self updateCurrentDirectoryIfChanged
       
  1897 
  1894             ].
  1898             ].
  1895             replace ifTrue:[
  1899             replace ifTrue:[
  1896                 subView modified:false.
  1900                 subView modified:false.
  1897             ].
  1901             ].
  1898         ]
  1902         ]
  1934     subView size > 10000 ifTrue:[
  1938     subView size > 10000 ifTrue:[
  1935         self warn:'text quite large now - please cut off some lines'
  1939         self warn:'text quite large now - please cut off some lines'
  1936     ]
  1940     ]
  1937 
  1941 
  1938     "Modified: 21.9.1995 / 11:18:46 / claus"
  1942     "Modified: 21.9.1995 / 11:18:46 / claus"
  1939     "Modified: 11.4.1997 / 14:42:07 / cg"
  1943     "Modified: 19.4.1997 / 15:29:54 / cg"
  1940 !
  1944 !
  1941 
  1945 
  1942 doFileGet:viaDoubleClick
  1946 doFileGet:viaDoubleClick
  1943     "get selected file - show contents in subView"
  1947     "get selected file - show contents in subView"
  1944 
  1948 
  2062 
  2066 
  2063 doRename:oldName to:newName
  2067 doRename:oldName to:newName
  2064     (oldName notNil and:[newName notNil]) ifTrue:[
  2068     (oldName notNil and:[newName notNil]) ifTrue:[
  2065         (oldName isBlank or:[newName isBlank]) ifFalse:[
  2069         (oldName isBlank or:[newName isBlank]) ifFalse:[
  2066             currentDirectory renameFile:oldName newName:newName.
  2070             currentDirectory renameFile:oldName newName:newName.
  2067             self updateCurrentDirectory.
  2071             self updateCurrentDirectoryIfChanged.
  2068         ]
  2072         ]
  2069     ]
  2073     ]
       
  2074 
       
  2075     "Modified: 19.4.1997 / 15:30:49 / cg"
  2070 !
  2076 !
  2071 
  2077 
  2072 fileCommentStrings
  2078 fileCommentStrings
  2073     "return useful comment definition; based upon the fileName for now"
  2079     "return useful comment definition; based upon the fileName for now"
  2074 
  2080 
  2532     ] ifFalse:[
  2538     ] ifFalse:[
  2533         n := (size * 10 // 1024 // 1024 / 10.0).
  2539         n := (size * 10 // 1024 // 1024 / 10.0).
  2534         unitString := ' Mb'
  2540         unitString := ' Mb'
  2535     ].
  2541     ].
  2536     ^ (n printStringLeftPaddedTo:5) , unitString.
  2542     ^ (n printStringLeftPaddedTo:5) , unitString.
       
  2543 !
       
  2544 
       
  2545 updateCurrentDirectoryIfChanged
       
  2546     (currentDirectory timeOfLastChange > timeOfLastCheck) ifTrue:[
       
  2547         self updateCurrentDirectory
       
  2548     ]
       
  2549 
       
  2550     "Modified: 19.4.1997 / 15:30:03 / cg"
  2537 !
  2551 !
  2538 
  2552 
  2539 validateFontEncodingFor:newEncoding ask:ask
  2553 validateFontEncodingFor:newEncoding ask:ask
  2540     "if required, query user if he/she wants to change to another font,
  2554     "if required, query user if he/she wants to change to another font,
  2541      which is able to display text encoded as specified by newEncoding"
  2555      which is able to display text encoded as specified by newEncoding"
  3418 ! !
  3432 ! !
  3419 
  3433 
  3420 !FileBrowser class methodsFor:'documentation'!
  3434 !FileBrowser class methodsFor:'documentation'!
  3421 
  3435 
  3422 version
  3436 version
  3423     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.147 1997-04-19 13:23:34 cg Exp $'
  3437     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.148 1997-04-19 13:32:01 cg Exp $'
  3424 ! !
  3438 ! !
  3425 FileBrowser initialize!
  3439 FileBrowser initialize!