FileBrowser.st
changeset 1418 c6cce50bf135
parent 1410 e2af551da1d1
child 1481 71a3292de680
equal deleted inserted replaced
1417:9c3590232965 1418:c6cce50bf135
   282      a keyPress in some other view ?"
   282      a keyPress in some other view ?"
   283 
   283 
   284     <resource: #keyboard (#GotoLine #InspectIt #CmdI #Cmdu #DoIt #Delete #BackSpace #Accept #CmdF #CmdD)>
   284     <resource: #keyboard (#GotoLine #InspectIt #CmdI #Cmdu #DoIt #Delete #BackSpace #Accept #CmdF #CmdD)>
   285 
   285 
   286     view == fileListView ifTrue:[
   286     view == fileListView ifTrue:[
   287         (key == #Delete 
   287 	(key == #Delete 
   288         or:[key == #BackSpace
   288 	or:[key == #BackSpace
   289         or:[key == #Accept
   289 	or:[key == #Accept
   290         or:[key == #CmdI
   290 	or:[key == #CmdI
   291         or:[key == #CmdF
   291 	or:[key == #CmdF
   292         or:[key == #CmdD
   292 	or:[key == #CmdD
   293         or:[key == #Cmdu
   293 	or:[key == #Cmdu
   294         or:[key == #InspectIt
   294 	or:[key == #InspectIt
   295         or:[key == #GotoLine
   295 	or:[key == #GotoLine
   296         or:[key == #DoIt]]]]]]]]]) ifTrue:[^ true].
   296 	or:[key == #DoIt]]]]]]]]]) ifTrue:[^ true].
   297     ].
   297     ].
   298     ^ false
   298     ^ false
   299 
   299 
   300     "Created: / 28.1.1997 / 14:03:20 / stefan"
   300     "Created: / 28.1.1997 / 14:03:20 / stefan"
   301     "Modified: / 20.6.1997 / 16:35:01 / cg"
   301     "Modified: / 20.6.1997 / 16:35:01 / cg"
   306     "this method is reached via delegation from the fileListView"
   306     "this method is reached via delegation from the fileListView"
   307 
   307 
   308     <resource: #keyboard (#GotoLine #InspectIt #CmdI #Cmdu #DoIt #Delete #BackSpace #Accept)>
   308     <resource: #keyboard (#GotoLine #InspectIt #CmdI #Cmdu #DoIt #Delete #BackSpace #Accept)>
   309 
   309 
   310     (key == #Delete or:[key == #BackSpace]) ifTrue:[
   310     (key == #Delete or:[key == #BackSpace]) ifTrue:[
   311         self fileRemove.
   311 	self fileRemove.
   312         ^ self
   312 	^ self
   313     ].
   313     ].
   314     (key == #Accept) ifTrue:[
   314     (key == #Accept) ifTrue:[
   315         self fileFileIn.
   315 	self fileFileIn.
   316         ^ self
   316 	^ self
   317     ].
   317     ].
   318     (key == #GotoLine) ifTrue:[
   318     (key == #GotoLine) ifTrue:[
   319         self fileGet.
   319 	self fileGet.
   320         ^ self
   320 	^ self
   321     ].
   321     ].
   322     (key == #DoIt) ifTrue:[
   322     (key == #DoIt) ifTrue:[
   323         self fileExecute.
   323 	self fileExecute.
   324         ^ self
   324 	^ self
   325     ].
   325     ].
   326     (key == #InspectIt) ifTrue:[
   326     (key == #InspectIt) ifTrue:[
   327         self fileGetInfo.
   327 	self fileGetInfo.
   328         ^ self
   328 	^ self
   329     ].
   329     ].
   330     (key == #CmdI) ifTrue:[
   330     (key == #CmdI) ifTrue:[
   331         self fileGetLongInfo.
   331 	self fileGetLongInfo.
   332         ^ self
   332 	^ self
   333     ].
   333     ].
   334     (key == #Cmdu) ifTrue:[
   334     (key == #Cmdu) ifTrue:[
   335         self updateCurrentDirectory.
   335 	self updateCurrentDirectory.
   336         ^ self
   336 	^ self
   337     ].
   337     ].
   338     (key == #CmdF) ifTrue:[
   338     (key == #CmdF) ifTrue:[
   339         self newFile.
   339 	self newFile.
   340         ^ self
   340 	^ self
   341     ].
   341     ].
   342     (key == #CmdD) ifTrue:[
   342     (key == #CmdD) ifTrue:[
   343         self newDirectory.
   343 	self newDirectory.
   344         ^ self
   344 	^ self
   345     ].
   345     ].
   346     fileListView keyPress:key x:x y:y
   346     fileListView keyPress:key x:x y:y
   347 
   347 
   348     "Created: / 28.1.1997 / 14:03:56 / stefan"
   348     "Created: / 28.1.1997 / 14:03:56 / stefan"
   349     "Modified: / 20.6.1997 / 16:35:08 / cg"
   349     "Modified: / 20.6.1997 / 16:35:08 / cg"
   640     <resource: #programMenu>
   640     <resource: #programMenu>
   641 
   641 
   642     |labels shorties selectors m sel ns subLabels subSelectors|
   642     |labels shorties selectors m sel ns subLabels subSelectors|
   643 
   643 
   644     labels := #(
   644     labels := #(
   645                  'spawn'                   
   645 		 'spawn'                   
   646                  '-'                               
   646 		 '-'                               
   647                  'get contents'                    
   647 		 'get contents'                    
   648                  'insert contents'                    
   648 		 'insert contents'                    
   649                  'show info'             
   649 		 'show info'             
   650                  'show full info'
   650 		 'show full info'
   651                ).
   651 	       ).
   652 
   652 
   653     ((ns := Project current defaultNameSpace) notNil 
   653     ((ns := Project current defaultNameSpace) notNil 
   654     and:[ns ~~ Smalltalk]) ifTrue:[
   654     and:[ns ~~ Smalltalk]) ifTrue:[
   655         labels := labels copyWith:'fileIn (into ''' , Project current defaultNameSpace name , ''')'
   655 	labels := labels copyWith:'fileIn (into ''' , Project current defaultNameSpace name , ''')'
   656     ] ifFalse:[
   656     ] ifFalse:[
   657         labels := labels copyWith:'fileIn'
   657 	labels := labels copyWith:'fileIn'
   658     ].
   658     ].
   659 
   659 
   660     labels := labels , #(
   660     labels := labels , #(
   661                  '-'                               
   661 		 '-'                               
   662                  'update'                 
   662 		 'update'                 
   663                  '-'                               
   663 		 '-'                               
   664                  'execute unix command ...'                
   664 		 'execute unix command ...'                
   665                  'st/x tools'                
   665 		 'st/x tools'                
   666                  '-'                               
   666 		 '-'                               
   667                  'remove'                 
   667 		 'remove'                 
   668                  'rename ...'                 
   668 		 'rename ...'                 
   669                  '-'                               
   669 		 '-'                               
   670                  'display long list'           
   670 		 'display long list'           
   671                  'show all files'           
   671 		 'show all files'           
   672                  'encoding ...'           
   672 		 'encoding ...'           
   673                  '-'                               
   673 		 '-'                               
   674                  'create directory ...'         
   674 		 'create directory ...'         
   675                  'create file ...'
   675 		 'create file ...'
   676                ).             
   676 	       ).             
   677 
   677 
   678     selectors := #(
   678     selectors := #(
   679                  fileSpawn
   679 		 fileSpawn
   680                  nil
   680 		 nil
   681                  fileGet
   681 		 fileGet
   682                  fileInsert
   682 		 fileInsert
   683                  fileGetInfo
   683 		 fileGetInfo
   684                  fileGetLongInfo
   684 		 fileGetLongInfo
   685                  fileFileIn
   685 		 fileFileIn
   686                  nil
   686 		 nil
   687                  updateCurrentDirectory
   687 		 updateCurrentDirectory
   688                  nil
   688 		 nil
   689                  fileExecute
   689 		 fileExecute
   690                  stxTools
   690 		 stxTools
   691                  nil
   691 		 nil
   692                  fileRemove
   692 		 fileRemove
   693                  fileRename
   693 		 fileRename
   694                  nil
   694 		 nil
   695                  changeDisplayMode
   695 		 changeDisplayMode
   696                  changeDotFileVisibility
   696 		 changeDotFileVisibility
   697                  fileEncoding
   697 		 fileEncoding
   698                  nil
   698 		 nil
   699                  newDirectory
   699 		 newDirectory
   700                  newFile
   700 		 newFile
   701                 ).
   701 		).
   702 
   702 
   703     shorties := #(
   703     shorties := #(
   704                  nil
   704 		 nil
   705                  nil
   705 		 nil
   706                  GotoLine
   706 		 GotoLine
   707                  nil
   707 		 nil
   708                  InspectIt
   708 		 InspectIt
   709                  CmdI
   709 		 CmdI
   710                  Accept
   710 		 Accept
   711                  nil
   711 		 nil
   712                  Cmdu
   712 		 Cmdu
   713                  nil
   713 		 nil
   714                  DoIt
   714 		 DoIt
   715                  nil
   715 		 nil
   716                  nil
   716 		 nil
   717                  Delete
   717 		 Delete
   718                  nil
   718 		 nil
   719                  nil
   719 		 nil
   720                  nil
   720 		 nil
   721                  nil
   721 		 nil
   722                  nil
   722 		 nil
   723                  nil
   723 		 nil
   724                  CmdD
   724 		 CmdD
   725                  CmdF
   725 		 CmdF
   726                 ).
   726 		).
   727 
   727 
   728     m := PopUpMenu 
   728     m := PopUpMenu 
   729             labels:(resources array:labels)
   729 	    labels:(resources array:labels)
   730             selectors:selectors
   730 	    selectors:selectors
   731             accelerators:shorties
   731 	    accelerators:shorties
   732             receiver:self.
   732 	    receiver:self.
   733 
   733 
   734     showDotFiles ifTrue:[
   734     showDotFiles ifTrue:[
   735         m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files')
   735 	m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files')
   736     ].
   736     ].
   737     showLongList ifTrue:[
   737     showLongList ifTrue:[
   738         m labelAt:#changeDisplayMode put:(resources string:'display short list')
   738 	m labelAt:#changeDisplayMode put:(resources string:'display short list')
   739     ].
   739     ].
   740 
   740 
   741     subLabels := #(
   741     subLabels := #(
   742                               'Changes browser'
   742 			      'Changes browser'
   743                               'Editor'
   743 			      'Editor'
   744                               'HTML reader'
   744 			      'HTML reader'
   745                               'Image inspect'
   745 			      'Image inspect'
   746                               'show file differences'
   746 			      'show file differences'
   747                   ).
   747 		  ).
   748 
   748 
   749     subSelectors := #(
   749     subSelectors := #(
   750                               openChangesBrowser
   750 			      openChangesBrowser
   751                               openEditor
   751 			      openEditor
   752                               openHTMLReader
   752 			      openHTMLReader
   753                               openImageInspector
   753 			      openImageInspector
   754                               openDiffView
   754 			      openDiffView
   755                      ).
   755 		     ).
   756 
   756 
   757     JavaInterpreter notNil ifTrue:[
   757     JavaInterpreter notNil ifTrue:[
   758         subLabels := subLabels , #('Java Applet Viewer').
   758 	subLabels := subLabels , #('Java Applet Viewer').
   759         subSelectors := subSelectors , #(openAppletViewer).
   759 	subSelectors := subSelectors , #(openAppletViewer).
   760     ].
   760     ].
   761 
   761 
   762     m subMenuAt:#stxTools 
   762     m subMenuAt:#stxTools 
   763             put:(PopUpMenu
   763 	    put:(PopUpMenu
   764                     labels:(resources array:subLabels)
   764 		    labels:(resources array:subLabels)
   765                     selectors:subSelectors
   765 		    selectors:subSelectors
   766                     receiver:self).
   766 		    receiver:self).
   767 
   767 
   768     ((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[
   768     ((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[
   769         m disableAll:#(fileGet fileInsert
   769 	m disableAll:#(fileGet fileInsert
   770                        fileGetInfo fileGetLongInfo
   770 		       fileGetInfo fileGetLongInfo
   771                        fileFileIn fileFileInLazy
   771 		       fileFileIn fileFileInLazy
   772                        fileRemove fileRename).
   772 		       fileRemove fileRename).
   773         (m subMenuAt:#stxTools)
   773 	(m subMenuAt:#stxTools)
   774             disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector)
   774 	    disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector)
   775     ] ifFalse:[
   775     ] ifFalse:[
   776         fileListView selection size > 1 ifTrue:[
   776 	fileListView selection size > 1 ifTrue:[
   777             m disableAll:#( fileGet fileInsert fileGetInfo fileGetLongInfo fileRename )
   777 	    m disableAll:#( fileGet fileInsert fileGetInfo fileGetLongInfo fileRename )
   778         ]
   778 	]
   779     ].
   779     ].
   780 
   780 
   781     ^m
   781     ^m
   782 
   782 
   783     "Modified: / 15.8.1997 / 04:33:26 / cg"
   783     "Modified: / 15.8.1997 / 04:33:26 / cg"
   896     "ask for and create a new file"
   896     "ask for and create a new file"
   897 
   897 
   898     |sel queryBox|
   898     |sel queryBox|
   899 
   899 
   900     queryBox := FilenameEnterBox 
   900     queryBox := FilenameEnterBox 
   901                     title:(resources at:'create new file:') withCRs
   901 		    title:(resources at:'create new file:') withCRs
   902                     okText:(resources at:'create')
   902 		    okText:(resources at:'create')
   903                     action:[:newName | newName isEmpty ifFalse:[self doCreateFile:newName]].
   903 		    action:[:newName | newName isEmpty ifFalse:[self doCreateFile:newName]].
   904     sel := subView selection.
   904     sel := subView selection.
   905     sel notNil ifTrue:[
   905     sel notNil ifTrue:[
   906         queryBox initialText:(sel asString)
   906 	queryBox initialText:(sel asString)
   907     ].
   907     ].
   908     queryBox showAtPointer
   908     queryBox showAtPointer
   909 
   909 
   910     "Modified: / 23.4.1997 / 13:04:38 / cg"
   910     "Modified: / 23.4.1997 / 13:04:38 / cg"
   911     "Modified: / 16.1.1998 / 16:54:00 / stefan"
   911     "Modified: / 16.1.1998 / 16:54:00 / stefan"
  1140     "return the sequence in which ALT-CursorRight steps focus"
  1140     "return the sequence in which ALT-CursorRight steps focus"
  1141 
  1141 
  1142     |fs|
  1142     |fs|
  1143 
  1143 
  1144     fs := Array 
  1144     fs := Array 
       
  1145 	with:labelView
  1145 	with:filterField 
  1146 	with:filterField 
  1146 	with:fileListView 
  1147 	with:fileListView 
  1147 	with:subView.
  1148 	with:subView.
  1148 
  1149 
  1149     commandView notNil ifTrue:[
  1150     commandView notNil ifTrue:[
  1631     <resource: #programMenu>
  1632     <resource: #programMenu>
  1632 
  1633 
  1633     |labels selectors args menu|
  1634     |labels selectors args menu|
  1634 
  1635 
  1635     labels := #(
  1636     labels := #(
  1636                    'copy path'
  1637 		   'copy path'
  1637                    '-'                               
  1638 		   '-'                               
  1638                    'up'
  1639 		   'up'
  1639                    'back'
  1640 		   'back'
  1640                    'change to home-directory'
  1641 		   'change to home-directory'
  1641                    'change to default-directory'
  1642 		   'change to default-directory'
  1642                    'change directory ...'
  1643 		   'change directory ...'
  1643                ).             
  1644 	       ).             
  1644 
  1645 
  1645     selectors := #(
  1646     selectors := #(
  1646                     copyPath
  1647 		    copyPath
  1647                     nil
  1648 		    nil
  1648                     changeToParentDirectory
  1649 		    changeToParentDirectory
  1649                     changeToPreviousDirectory
  1650 		    changeToPreviousDirectory
  1650                     changeToHomeDirectory
  1651 		    changeToHomeDirectory
  1651                     changeToDefaultDirectory
  1652 		    changeToDefaultDirectory
  1652                     changeCurrentDirectory
  1653 		    changeCurrentDirectory
  1653                   ).
  1654 		  ).
  1654 
  1655 
  1655     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  1656     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  1656         labels := labels , #('-' 'add to JavaClassPath' 'add to JavaSourcePath' 'remove from JavaClassPath' 'remove from JavaSourcePath').
  1657 	labels := labels , #('-' 'add to JavaClassPath' 'add to JavaSourcePath' 'remove from JavaClassPath' 'remove from JavaSourcePath').
  1657         selectors := selectors , #(nil #addDirToJavaClassPath #addDirToJavaSourcePath #removeDirFromJavaClassPath #removeDirFromJavaSourcePath).
  1658 	selectors := selectors , #(nil #addDirToJavaClassPath #addDirToJavaSourcePath #removeDirFromJavaClassPath #removeDirFromJavaSourcePath).
  1658     ].
  1659     ].
  1659 
  1660 
  1660     args := Array new:(labels size).
  1661     args := Array new:(labels size).
  1661 
  1662 
  1662     DirectoryHistory size > 0 ifTrue:[
  1663     DirectoryHistory size > 0 ifTrue:[
  1663         labels := labels copyWith:'-'.
  1664 	labels := labels copyWith:'-'.
  1664         selectors := selectors copyWith:nil.
  1665 	selectors := selectors copyWith:nil.
  1665         args := args copyWith:nil.
  1666 	args := args copyWith:nil.
  1666 
  1667 
  1667         DirectoryHistory do:[:dirName |
  1668 	DirectoryHistory do:[:dirName |
  1668             labels := labels copyWith:dirName.
  1669 	    labels := labels copyWith:dirName.
  1669             selectors := selectors copyWith:#changeDirectoryTo:.
  1670 	    selectors := selectors copyWith:#changeDirectoryTo:.
  1670             args := args copyWith:dirName
  1671 	    args := args copyWith:dirName
  1671         ]
  1672 	]
  1672     ].
  1673     ].
  1673 
  1674 
  1674     menu := PopUpMenu 
  1675     menu := PopUpMenu 
  1675                 labels:(resources array:labels)
  1676 		labels:(resources array:labels)
  1676                 selectors:selectors
  1677 		selectors:selectors
  1677                 args:args
  1678 		args:args
  1678                 receiver:self.
  1679 		receiver:self.
  1679 
  1680 
  1680     previousDirectory isNil ifTrue:[
  1681     previousDirectory isNil ifTrue:[
  1681         menu disable:#changeToPreviousDirectory.
  1682 	menu disable:#changeToPreviousDirectory.
  1682     ].
  1683     ].
  1683     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  1684     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  1684         (Java classPath includes:currentDirectory pathName) ifTrue:[
  1685 	(Java classPath includes:currentDirectory pathName) ifTrue:[
  1685             menu disable:#addDirToJavaClassPath
  1686 	    menu disable:#addDirToJavaClassPath
  1686         ] ifFalse:[
  1687 	] ifFalse:[
  1687             menu disable:#removeDirFromJavaClassPath
  1688 	    menu disable:#removeDirFromJavaClassPath
  1688         ].
  1689 	].
  1689         (Java sourcePath includes:currentDirectory pathName) ifTrue:[
  1690 	(Java sourcePath includes:currentDirectory pathName) ifTrue:[
  1690             menu disable:#addDirToJavaSourcePath
  1691 	    menu disable:#addDirToJavaSourcePath
  1691         ] ifFalse:[
  1692 	] ifFalse:[
  1692             menu disable:#removeDirFromJavaSourcePath
  1693 	    menu disable:#removeDirFromJavaSourcePath
  1693         ].
  1694 	].
  1694     ].
  1695     ].
  1695     ^menu.
  1696     ^menu.
  1696 
  1697 
  1697     "Modified: / 17.1.1998 / 10:49:16 / cg"
  1698     "Modified: / 17.1.1998 / 10:49:16 / cg"
  1698 !
  1699 !
  2180 
  2181 
  2181     |img|
  2182     |img|
  2182 
  2183 
  2183     (Image isImageFileSuffix:(aFilename asFilename suffix))
  2184     (Image isImageFileSuffix:(aFilename asFilename suffix))
  2184     ifTrue:[
  2185     ifTrue:[
  2185         img := Image fromFile:(currentDirectory construct:aFilename).
  2186 	img := Image fromFile:(currentDirectory construct:aFilename).
  2186         img notNil ifTrue:[
  2187 	img notNil ifTrue:[
  2187             ImageEditor openOnImage:img.
  2188 	    ImageEditor openOnImage:img.
  2188 "/            img inspect.
  2189 "/            img inspect.
  2189             ^ true
  2190 	    ^ true
  2190         ]
  2191 	]
  2191     ].
  2192     ].
  2192     ^ false
  2193     ^ false
  2193 
  2194 
  2194     "Created: 19.6.1996 / 09:43:50 / cg"
  2195     "Created: 19.6.1996 / 09:43:50 / cg"
  2195     "Modified: 18.4.1997 / 14:56:04 / cg"
  2196     "Modified: 18.4.1997 / 14:56:04 / cg"
  4012 ! !
  4013 ! !
  4013 
  4014 
  4014 !FileBrowser class methodsFor:'documentation'!
  4015 !FileBrowser class methodsFor:'documentation'!
  4015 
  4016 
  4016 version
  4017 version
  4017     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.215 1998-01-22 12:36:49 ca Exp $'
  4018     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.216 1998-01-25 14:10:24 cg Exp $'
  4018 ! !
  4019 ! !