FileBrowserV2.st
author penk
Fri, 08 Nov 2002 16:51:08 +0100
changeset 4223 170e44ddba6e
parent 4217 199986655f96
child 4236 0a2732929a41
permissions -rw-r--r--
after rename reread directory not change filename directly anymore

"
 COPYRIGHT (c) 1991 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

"{ Package: 'stx:libtool' }"

AbstractFileBrowser subclass:#FileBrowserV2
	instanceVariableNames:'fileEntryFieldHolder pathEntryField'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Tools-File'
!

ApplicationModel subclass:#SettingDialog
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:FileBrowserV2
!

!FileBrowserV2 class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1991 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    FileBrowserV2 is based on Filebrowser created by Claus Gittinger

    WARNING: files edited with FileBrowser will have leading spaces (multiple-8)
             being replaced by tabs. If tabs are to be preserved at other
             positions (for example, sendmail-config files) they will be
             corrupt after being written.

    [instance variables]:

        checkDelta      <Integer>       number of seconds of check interval
                                        (looks ever so often if shown directory
                                         has changed). You may make this number
                                        higher, if your network-times are
                                        incorrect and thus, the filebrowser
                                        checks too often.

        compressTabs    <Boolean>       if true, leading spaces will be
                                        replaced by tabs when saving text

    some of the defaults (long/short list etc.) can be set by the resource file;
    see FileBrowser>>initialize for more details..

    [author:]
        Christian Penk

    [start with:]
        FileBrowserV2 open
"
! !

!FileBrowserV2 class methodsFor:'instance creation'!

on:aDirectoryPath
    "return a new FileBrowserV2 in a pathname"

    |instance files|
    instance := self new createBuilder.
    aDirectoryPath isCollection ifTrue:[
        files := aDirectoryPath
    ] ifFalse:[
        files := Array with:aDirectoryPath.
    ].
    instance currentFileNameHolder value:files.
    ^ instance

"/    | instance builder|
"/
"/    builder := super open.
"/    instance := builder application.
"/    instance currentFileNameHolder value:aDirectoryPath.
"/    ^ instance

    "
     (FileBrowserV2 on:'/usr/local/bin') open
     (FileBrowserV2 on:'/etc'          ) open
     (FileBrowserV2 on:'..'            ) open
     (FileBrowserV2 on:'.'             ) open
    "
!

open
    "start a new FileBrowserV2"

    | instance |
    instance := self new.
    instance open.
    ^ instance
    "
     FileBrowserV2 openOn:'/etc'           withExtent:800@600
     FileBrowserV2 openOn:'..'             withExtent:200@300
     FileBrowserV2 openOn:'.'              withExtent:1024@768
    "
!

openOn:aDirectoryPath 
    "start a new FileBrowserV2 in a pathname"

    | instance|
    instance := self on:aDirectoryPath asFilename.
    ^ instance open.
    "
     FileBrowserV2 openOn:'/etc'           
     FileBrowserV2 openOn:'..'           
     FileBrowserV2 openOn:'.'             
    "
!

openOn:aDirectoryPath withExtent:extent
    "start a new FileBrowserV2 in a pathname"

    | instance builder|
    instance := self on:aDirectoryPath.
    builder := instance open.
    builder window extent:extent.
    ^ instance
    "
     FileBrowserV2 openOn:'/etc'           withExtent:800@600
     FileBrowserV2 openOn:'..'             withExtent:200@300
     FileBrowserV2 openOn:'.'              withExtent:1024@768
    "
!

openWithAspects:someAspects withExtent:extent
    "start a new FileBrowserV2 in a pathname"

    |dir clone|

    dir := someAspects at:#currentFileNameHolder ifAbsent:nil.
    clone := self openOn:(dir value) withExtent:extent.

    "
     FileBrowserV2 openOn:'/etc'           withExtent:800@600
     FileBrowserV2 openOn:'..'             withExtent:200@300
     FileBrowserV2 openOn:'.'              withExtent:1024@768
    "
! !

!FileBrowserV2 class methodsFor:'class initialization'!

applicationIcon
    ^ NewLauncher startNewFileBrowserIcon
!

clearHistoryIcon
    ^ Icon deleteIcon
!

initialize

    self installInLauncher.
!

initializeDefaultCommands
    DefaultCommandPerMIME := Dictionary new.

    DefaultCommandPerMIME at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'.
    DefaultCommandPerMIME at:'application/pdf'              put:'acroread %1'.

    "
     self initializeDefaultCommands
    "
!

installInLauncher
    "add myself to the launcher menu and toolBar"

    |menuItem icon action currentLauncher|

    FileBrowserV2 isNil ifTrue:[^ self].

    action := [FileBrowserV2 open].

    icon := self applicationIcon. "/ self defaultIcon magnifiedTo:28@28.

    menuItem := MenuItem new 
                    translateLabel: true;
                    value: action;
                    isButton: false;
                    label:'File Browser V2' icon:icon;
                    nameKey: #fileBrowserV2;
                    activeHelpKey: #fileBrowserV2;
                    submenuChannel: #menuFileHistory;
                    showBusyCursorWhilePerforming:true.

    NewLauncher addMenuItem:menuItem in:'menu.file' position:#( #before #fileBrowser) space:true.

    menuItem := MenuItem new 
                    translateLabel: true;
                    value: action;
                    isButton: true;
                    "label:'File Browser V2'" icon:icon;
                    nameKey: #fileBrowserV2;
                    activeHelpKey: #fileBrowserV2;
                    submenuChannel: #menuFileHistory;
                    showBusyCursorWhilePerforming:true.

    NewLauncher addMenuItem:menuItem in:'toolbar' position:#( #before #fileBrowser) space:false.

    currentLauncher := NewLauncher current.
    currentLauncher notNil ifTrue:[
        currentLauncher fileBrowserItemVisible value:false
    ].

    "
     self installInLauncher
     self removeFromLauncher
    "
!

removeFromLauncher
    "/
    "/ remove myself from the launcher menu
    "/

    |currentLauncher|

    NewLauncher isNil ifTrue:[^ self].
    NewLauncher removeUserTool:#fileBrowserV2.
    currentLauncher := NewLauncher current.
    currentLauncher notNil ifTrue:[
        currentLauncher fileBrowserItemVisible value:false
    ].

    "
     self removeFromLauncher
    "
! !

!FileBrowserV2 class methodsFor:'defaults'!

entryFieldEndStringForMultipleSelection

    ^ ('[*]')
! !

!FileBrowserV2 class methodsFor:'help specs'!

flyByHelpSpec
    <resource: #help>

    |spec|

    spec := super flyByHelpSpec addPairsFrom:#(

#addTerminal
'Shell Terminal'

#searchFile
'Search a File'

#directoryUp
'Directory Up'

#directoryBack
'Directory Back'

#copyFile
'Copy File'

#cutFile
'Cut File'

#fileHome
'Home Directory'

#pasteFile
'PasteFile'

#deleteFile
'Delete File'

#fileIn
'File In'

#directoryForward
'Directory Forward'

#directoryHistory
'Directory'

#fileHistory
'File History'

#hideToolBar
'Hide Toolbar'

#hideFilenameEntryField
'Hide Filename Field'

#showFileDetails
'Show File Details'

#hideFileDetails
'Hide File Details'

#toggleDetails
'Show/Hide File Details'

).

    ^ spec.
!

helpSpec
    "This resource specification was automatically generated
     by the UIHelpTool of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIHelpTool may not be able to read the specification."

    "
     UIHelpTool openOnClass:FileBrowserV2    
    "

    <resource: #help>

    ^super helpSpec addPairsFrom:#(


)
! !

!FileBrowserV2 class methodsFor:'icon'!

defaultIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     self defaultIcon inspect
     ImageEditor openOnClass:self andSelector:#defaultIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'FileBrowserV2 class defaultIcon'
        ifAbsentPut:[(Depth4Image new) width: 28; height: 28; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@@@@@@@@@@CLA&Y&Y&Y&X@@ADP@@@L0F@@@@@@A @ADAD@@@3@XN;.;.8F@ADPDQ@@CLA ;.@@@@@@D@@@D@@L0FC.8O[6=/@QDADP@@3@X@; 
[6=/[0DPDP@@CLA DNC6<@@F<ADP@@@L0F@A@F= [0= @@@@@@3@X@@P=/[6=/@@@@@@CLA @@A/[6=/X@@@@@@L0FC0@O[6=/[0@@@@@@3@XF<@@@@@@@@@
@@@@CLA = @@@@@@@@@@@@@L0FA/[6=/A @@@@@@@@3@XO[6=/XF@@@@@@@@CLA @@@@@@X@@@@@@@@L0FY&Y&Y&Y @@@@@@@@C@Y&Y&Y&Y&@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@N@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@C @b') ; colorMapFromArray:#[0 0 0 255 255 255 255 0 0 0 255 0 0 0 255 0 255 255 255 255 0 255 0 255 127 0 0 0 127 0 0 0 127 0 127 127 127 127 0 127 0 127 127 127 127 170 170 170]; mask:((Depth1Image new) width: 28; height: 28; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
O??# C??9<@??>? O???<C????@????0O???8C???<@???>@O??<@C???@@???0@O??<@C??8@@??>@@O?? @C??8@@??>@@G?? @@??8@@@@@@@G.P=0AAD
HP@PQBD@GDP8 AADHD@PQBA@DN^=0@@a') ; yourself); yourself]
!

hideFilenameEntryFieldIcon
    <resource: #programImage>

    ^ ToolbarIconLibrary hideToolbarIconH14
!

hideToolBarIcon
    <resource: #programImage>

    ^ ToolbarIconLibrary hideToolbarIconH26
! !

!FileBrowserV2 class methodsFor:'image specs'!

viewDetailsIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     self viewDetailsIcon inspect
     ImageEditor openOnClass:self andSelector:#viewDetailsIcon
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:#'FileBrowserV2 class viewDetailsIcon'
        ifAbsentPut:[(Depth1Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@]+X@@@@@]+X@@@@@]+X@@@@@]+X@@@@@@@@b') ; yourself); yourself]
!

viewNoDetailsIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     self viewNoDetailsIcon inspect
     ImageEditor openOnClass:self andSelector:#viewNoDetailsIcon
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:#'FileBrowserV2 class viewNoDetailsIcon'
        ifAbsentPut:[(Depth1Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@A<@@@@@@A<@@@@@@A<@@@@@@A<@@@@@@@@@b') ; yourself); yourself]
! !

!FileBrowserV2 class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:FileBrowserV2 andSelector:#windowSpec
     FileBrowserV2 new openInterface:#windowSpec
     FileBrowserV2 open
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #windowSpec
        #window: 
       #(#WindowSpec
          #label: #FileBrowser
          #name: #FileBrowser
          #min: #(#Point 10 10)
          #bounds: #(#Rectangle 216 173 1016 773)
          #menu: #mainMenu
          #icon: #applicationIcon
        )
        #component: 
       #(#SpecCollection
          #collection: #(
           #(#ViewSpec
              #name: 'ToolbarBox'
              #layout: #(#LayoutFrame 0 0 0 0 0 1 30 0)
              #level: 0
              #visibilityChannel: #toolBarVisibleHolder
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'hideToolBarIcon'
                    #name: 'HideToolBarButton'
                    #layout: #(#LayoutFrame 0 0 0 0 13 0 30 0)
                    #activeHelpKey: #hideToolBar
                    #hasCharacterOrientedLabel: false
                    #translateLabel: true
                    #model: #hideToolbar
                    #postBuildCallback: #hideToolBarButtonCreated:
                  )
                 #(#MenuPanelSpec
                    #name: 'ToolBar'
                    #layout: #(#LayoutFrame 13 0 0 0 0 1 30 0)
                    #menu: #toolBarMainMenu
                    #textDefault: true
                  )
                 )
               
              )
            )
           #(#ViewSpec
              #name: 'FilenameEntryFieldBox'
              #layout: #(#LayoutFrame 0 0 30 0 0 1 55 0)
              #level: 0
              #visibilityChannel: #filenameEntryFieldVisibleHolder
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#ActionButtonSpec
                    #label: 'hideFilenameEntryFieldIcon'
                    #name: 'HideFilenameEntryFieldButton'
                    #layout: #(#LayoutFrame 0 0 0 0 13 0 0 1)
                    #activeHelpKey: #hideFilenameEntryField
                    #hasCharacterOrientedLabel: false
                    #translateLabel: true
                    #model: #hideFilenameEntryField
                    #postBuildCallback: #hideFilenameEntryFieldButtonCreated:
                  )
                 #(#ViewSpec
                    #name: 'Box1'
                    #layout: #(#LayoutFrame 13 0.0 0 0.0 0 1.0 0 1.0)
                    #level: 1
                    #component: 
                   #(#SpecCollection
                      #collection: #(
                       #(#VariableHorizontalPanelSpec
                          #name: 'VariableHorizontalPanel1'
                          #layout: #(#LayoutFrame 1 0.0 1 0.0 -1 1.0 -1 1.0)
                          #level: 0
                          #showHandle: true
                          #component: 
                         #(#SpecCollection
                            #collection: #(
                             #(#FilenameInputFieldSpec
                                #name: 'FilenameEntryField'
                                #level: 1
                                #model: #fileEntryFieldHolder
                                #acceptOnPointerLeave: false
                                #postBuildCallback: #postBuildPathField:
                              )
                             #(#ViewSpec
                                #name: 'FilterBox'
                                #component: 
                               #(#SpecCollection
                                  #collection: #(
                                   #(#LabelSpec
                                      #label: 'Filter:'
                                      #name: 'Filter'
                                      #layout: #(#LayoutFrame 0 0 0 0 40 0 0 1)
                                      #translateLabel: true
                                      #adjust: #left
                                      #postBuildCallback: #postBuildPathViewBox:
                                    )
                                   #(#ComboBoxSpec
                                      #name: 'FilterSelectionBox'
                                      #layout: #(#LayoutFrame 40 0 0 0 0 1 0 1)
                                      #model: #filterModel
                                      #immediateAccept: true
                                      #acceptOnPointerLeave: false
                                      #comboList: #filterListModel
                                    )
                                   )
                                 
                                )
                                #postBuildCallback: #postBuildPathViewBox:
                              )
                             )
                           
                          )
                          #handles: #(#Any 0.8 1.0)
                          #postBuildCallback: #postBuildPathViewBox:
                        )
                       )
                     
                    )
                    #postBuildCallback: #postBuildPathViewBox:
                  )
                 )
               
              )
            )
           #(#ViewSpec
              #name: 'BrowserBox'
              #layout: #(#LayoutFrame 0 0.0 55 0 0 1.0 -20 1)
              #level: 0
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#'FileBrowserV2UISpecifications::PanelSpec'
                    #name: 'VerticalPanel'
                    #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
                    #level: 0
                    #whichView: #last
                    #orientation: #vertical
                    #visibility: #viewNoteBookApplicationHolder
                    #component: 
                   #(#SpecCollection
                      #collection: #(
                       #(#'FileBrowserV2UISpecifications::PanelSpec'
                          #name: 'HorizontalPanel'
                          #level: 0
                          #whichView: #first
                          #orientation: #horizontal
                          #visibility: #showDirectoryTree
                          #component: 
                         #(#SpecCollection
                            #collection: #(
                             #(#SubCanvasSpec
                                #name: 'DirectoryTreeBrowser'
                                #hasHorizontalScrollBar: false
                                #hasVerticalScrollBar: false
                                #majorKey: #DirectoryTreeBrowser
                                #createNewApplication: true
                                #createNewBuilder: true
                              )
                             #(#SubCanvasSpec
                                #name: 'DirectoryContentsBrowser'
                                #hasHorizontalScrollBar: false
                                #hasVerticalScrollBar: false
                                #majorKey: #DirectoryContentsBrowser
                                #createNewApplication: true
                                #createNewBuilder: true
                              )
                             )
                           
                          )
                          #handles: #(#Any 0.229621 1.0)
                        )
                       #(#SubCanvasSpec
                          #name: 'FileApplicationNoteBook'
                          #tabable: false
                          #hasHorizontalScrollBar: false
                          #hasVerticalScrollBar: false
                          #majorKey: #FileApplicationNoteBook
                          #createNewApplication: true
                          #createNewBuilder: true
                        )
                       )
                     
                    )
                    #handles: #(#Any 0.5 1.0)
                  )
                 )
               
              )
            )
           #(#ViewSpec
              #name: 'Box2'
              #layout: #(#LayoutFrame 0 0 -20 1 0 1 0 1)
              #level: 0
              #component: 
             #(#SpecCollection
                #collection: #(
                 #(#LabelSpec
                    #label: 'NotifyLabel'
                    #name: 'NotifyLabel'
                    #layout: #(#LayoutFrame 1 0.0 1 0.0 -50 1 1 1.0)
                    #level: -1
                    #translateLabel: true
                    #labelChannel: #notifyChannel
                    #adjust: #left
                  )
                 #(#LabelSpec
                    #label: 'Shown Files'
                    #name: 'Label1'
                    #layout: #(#LayoutFrame -50 1 1 0.0 1 1 1 1.0)
                    #level: -1
                    #translateLabel: true
                    #labelChannel: #shownFiles
                    #adjust: #left
                    #postBuildCallback: #postBuildFilterBox:
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!FileBrowserV2 class methodsFor:'menu specs'!

mainMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:FileBrowserV2 andSelector:#mainMenu
     (Menu new fromLiteralArrayEncoding:(FileBrowserV2 mainMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(#Menu
        #(
         #(#MenuItem
            #label: 'Browser'
            #translateLabel: true
            #submenuChannel: #browserMenu
          )
         #(#MenuItem
            #label: 'Directory'
            #translateLabel: true
            #submenuChannel: #directoryMenu
          )
         #(#MenuItem
            #label: 'File'
            #translateLabel: true
            #submenuChannel: #fileMenu
          )
         #(#MenuItem
            #label: 'Edit'
            #translateLabel: true
            #submenuChannel: #editMenu
          )
         #(#MenuItem
            #label: 'View'
            #translateLabel: true
            #submenu: 
           #(#Menu
              #(
               #(#MenuItem
                  #label: 'Show'
                  #translateLabel: true
                  #submenuChannel: #showMenuSpec
                )
               #(#MenuItem
                  #label: 'Sort'
                  #translateLabel: true
                  #submenuChannel: #sortMenu
                )
               #(#MenuItem
                  #label: 'Details'
                  #translateLabel: true
                  #submenuChannel: #viewInContentsBrowserMenu
                )
               #(#MenuItem
                  #label: '-'
                )
               #(#MenuItem
                  #label: 'Toolbar'
                  #translateLabel: true
                  #hideMenuOnActivated: false
                  #indication: #toolBarVisibleHolder
                )
               #(#MenuItem
                  #label: 'Path Entry && Filter'
                  #translateLabel: true
                  #hideMenuOnActivated: false
                  #indication: #filenameEntryFieldVisibleHolder
                )
               #(#MenuItem
                  #label: '-'
                )
               #(#MenuItem
                  #label: 'Update'
                  #translateLabel: true
                )
               )
              nil
              nil
            )
          )
         #(#MenuItem
            #label: 'Tools'
            #translateLabel: true
            #submenuChannel: #toolsMenuSpec
          )
         #(#MenuItem
            #label: 'CVS'
            #translateLabel: true
            #submenuChannel: #cvsMenu
          )
         #(#MenuItem
            #label: 'Help'
            #translateLabel: true
            #startGroup: #right
            #submenu: 
           #(#Menu
              #(
               #(#MenuItem
                  #label: 'FileBrowser Documentation'
                  #translateLabel: true
                )
               #(#MenuItem
                  #label: '-'
                )
               #(#MenuItem
                  #label: 'About FileBrowser...'
                  #translateLabel: true
                )
               )
              nil
              nil
            )
          )
         )
        nil
        nil
      )
!

toolBarMainMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:FileBrowserV2 andSelector:#toolBarMainMenu
     (Menu new fromLiteralArrayEncoding:(FileBrowserV2 toolBarMainMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(#Menu
        #(
         #(#MenuItem
            #activeHelpKey: #directoryUp
            #enabled: #enableDirectoryUp
            #label: 'DirectoryUp'
            #itemValue: #doGoDirectoryUp
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #upArrowIcon)
          )
         #(#MenuItem
            #label: ''
          )
         #(#MenuItem
            #activeHelpKey: #directoryBack
            #enabled: #enableBack
            #label: 'Back'
            #itemValue: #doBack
            #translateLabel: true
            #isButton: true
            #submenuChannel: #menuDirHistoryBack
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #leftArrowIcon)
          )
         #(#MenuItem
            #label: ''
          )
         #(#MenuItem
            #activeHelpKey: #directoryForward
            #enabled: #enableForward
            #label: 'Forward'
            #itemValue: #doForward
            #translateLabel: true
            #isButton: true
            #submenuChannel: #menuDirHistoryForward
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #rightArrowIcon)
          )
         #(#MenuItem
            #label: ''
          )
         #(#MenuItem
            #activeHelpKey: #fileHome
            #enabled: #enableHome
            #label: 'Home'
            #itemValue: #doGotoHomeDirectory
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #goHomeIcon)
          )
         #(#MenuItem
            #label: ''
          )
         #(#MenuItem
            #activeHelpKey: #fileHistory
            #enabled: #enableFileHistory
            #label: 'File History'
            #translateLabel: true
            #isButton: true
            #submenuChannel: #menuFileHistory
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #historyIcon)
          )
         #(#MenuItem
            #label: ''
          )
         #(#MenuItem
            #activeHelpKey: #copyFile
            #enabled: #hasSelection
            #label: 'Copy'
            #itemValue: #copyInDirContentsBrowser
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #copyIcon)
          )
         #(#MenuItem
            #activeHelpKey: #cutFile
            #enabled: #hasSelection
            #label: 'Cut'
            #itemValue: #cutInDirContentsBrowser
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #cutIcon)
          )
         #(#MenuItem
            #activeHelpKey: #pasteFile
            #enabled: #canPaste
            #label: 'Paste'
            #itemValue: #pasteFiles
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #pasteIcon)
          )
         #(#MenuItem
            #activeHelpKey: #deleteFile
            #enabled: #hasSelection
            #label: 'Delete'
            #itemValue: #deleteInDirContentsBrowser
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #deleteIcon)
          )
         #(#MenuItem
            #label: ''
          )
         #(#MenuItem
            #activeHelpKey: #fileIn
            #enabled: #hasSelection
            #label: 'File In'
            #itemValue: #fileFileIn
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #fileInIcon)
          )
         #(#MenuItem
            #label: ''
          )
         #(#MenuItem
            #activeHelpKey: #searchFile
            #label: 'Search File'
            #itemValue: #doOpenSearchFile
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #searchIcon)
          )
         #(#MenuItem
            #activeHelpKey: #addTerminal
            #label: 'VT100'
            #itemValue: #doAddTerminal
            #translateLabel: true
            #isButton: true
            #labelImage: #(#ResourceRetriever #AbstractFileBrowser #shellWithoutTextIcon)
          )
         #(#MenuItem
            #activeHelpKey: #toggleDetails
            #label: 'viewDetails'
            #translateLabel: true
            #isButton: true
            #startGroup: #right
            #indication: #viewDetails
            #submenuChannel: #viewDetailsMenuSpec
            #labelImage: #(#ResourceRetriever nil #viewDetailsIcon)
          )
         )
        nil
        nil
      )
! !

!FileBrowserV2 methodsFor:'actions'!

changeFileBrowserTitleTo:aString

    |string|

    string := 'FileBrowser ', aString.
    self window label:string.
!

doSpawn

    self saveRuntimeAspectValues.
    self class openWithAspects:aspects withExtent:self builder window extent.
!

hideFilenameEntryField
    self filenameEntryFieldVisibleHolder value:false.
!

hideToolbar
    self toolBarVisibleHolder value:false.
!

toggleFileDetailsFor:anItem
    |viewDetails|

    viewDetails := self viewDetails value not.
    self viewDetails value:viewDetails.

    viewDetails ifTrue:[
        anItem activeHelpKey:#hideFileDetails.
        anItem label:(self class viewNoDetailsIcon).
    ] ifFalse:[
        anItem activeHelpKey:#showFileDetails.
        anItem label:(self class viewDetailsIcon).
    ].
! !

!FileBrowserV2 methodsFor:'aspects'!

fileEntryFieldHolder

    fileEntryFieldHolder isNil ifTrue:[
        fileEntryFieldHolder := ValueHolder new.
        fileEntryFieldHolder addDependent:self.
    ].
    ^ fileEntryFieldHolder.
! !

!FileBrowserV2 methodsFor:'change & update'!

currentFileNameHolderChanged

    | files|

    files := self currentFileNameHolder value.

    (files isEmpty) ifTrue:[
        self fileEntryFieldHolder value:nil withoutNotifying:self.
    ] ifFalse:[
        files size == 1 ifTrue:[
            self fileEntryFieldHolder value:(files first) withoutNotifying:self.    
        ] ifFalse:[
            self fileEntryFieldHolder value:self getCommonForCurrentFiles withoutNotifying:self.
        ].
    ].
!

fileEntryFieldHolderChanged

    (fileEntryFieldHolder value asFilename exists) ifFalse:[ pathEntryField flash. ^ self].
    self currentFileNameHolder value:(OrderedCollection with:(fileEntryFieldHolder value asFilename)).
!

update:something with:aParameter from:changedObject


    changedObject == self fileEntryFieldHolder ifTrue:[
        self fileEntryFieldHolderChanged.
        ^ self.
    ].
    changedObject == self currentFileNameHolder ifTrue:[
        super update:something with:aParameter from:changedObject.
        self currentFileNameHolderChanged.
        ^ self.
    ].
    (changedObject == self toolBarVisibleHolder 
    or:[changedObject == self filenameEntryFieldVisibleHolder]) ifTrue:[
        self updateToolVisibility.
        ^ self.
    ].
    (changedObject == self sortBlockProperty or:[changedObject == self sortDirectoriesBeforeFiles]) ifTrue:[
        self sortFileListsBy:(self sortBlockProperty value) withReverse:false.
        ^ self.
    ].             

    ^ super update:something with:aParameter from:changedObject.
!

updateToolVisibility
    |builder toolBar filenameEntryField vPanel topOffset visible d|

    builder := self builder.

    topOffset := 0.
    visible := self toolBarVisibleHolder value.
    visible ifTrue:[
        toolBar := builder componentAt:#ToolbarBox.
        topOffset := topOffset + toolBar height.
    ].

    visible := self filenameEntryFieldVisibleHolder value.
    visible ifTrue:[
        filenameEntryField := builder componentAt:#FilenameEntryFieldBox.
        d := filenameEntryField layout bottomOffset - filenameEntryField layout topOffset.
        filenameEntryField layout topOffset:topOffset bottomOffset:topOffset + d.
        topOffset := topOffset + filenameEntryField height.
        filenameEntryField container notNil ifTrue:[
            filenameEntryField containerChangedSize.
        ].
    ].

    vPanel := builder componentAt:#BrowserBox.
    vPanel layout topOffset:topOffset+1.
    vPanel container notNil ifTrue:[
        vPanel containerChangedSize.
    ].
! !

!FileBrowserV2 methodsFor:'event handling'!

processEvent:anEvent
    "filter keyboard events.
     Return true, if I have eaten the event"

    |focusView key rawKey fileName|

    anEvent isKeyPressEvent ifTrue:[
        focusView := anEvent targetView.
        key := anEvent key.
        rawKey := anEvent rawKey.

        (focusView isSameOrComponentOf:self window) ifTrue:[

            ((focusView == pathEntryField) not) ifTrue:[ ^ false].

            (key == #Return) ifTrue:[
                fileName := pathEntryField list first asFilename.
                (fileName exists and:[fileName isDirectory not]) ifTrue:[
                    self openApplForFile:fileName
                ].
            ].
        ]
    ].
    ^ false
! !

!FileBrowserV2 methodsFor:'startup & release'!

closeRequest

    (self application:#FileApplicationNoteBook do:#tryCloseApplications) not ifTrue:[
        ^ self
    ].
    ^ super closeRequest.
!

hideFilenameEntryFieldButtonCreated:aButton

    aButton passiveLevel:(MenuPanel defaultLevel). 
    aButton activeLevel:-1.
    aButton backgroundColor:(MenuPanel defaultBackgroundColor).
!

hideToolBarButtonCreated:aButton

    aButton passiveLevel:(MenuPanel defaultLevel). 
    aButton activeLevel:-1.
    aButton backgroundColor:(MenuPanel defaultBackgroundColor).
!

initialize

    self masterApplication:nil.
    self dirHistory resetForwardBackward.
!

makeDependent

    super makeDependent.
    self sortBlockProperty addDependent:self.
    self filenameEntryFieldVisibleHolder addDependent:self.
    self toolBarVisibleHolder addDependent:self.
!

postBuildFilterBox:aWidget

    self filterValueBox value:aWidget.
    self filterBackgroundColor value:aWidget backgroundColor.
!

postBuildPathField:aWidget
    "
        set the pramters that not can be changed in the window spec
    "

    pathEntryField := aWidget.
    aWidget level:-1.

"/    sClr := aWidget shadowColor.
"/    lClr := aWidget lightColor.
"/    sClr := (self builder componentAt:#ToolBar) shadowColor.
"/    lClr := (self builder componentAt:#ToolBar) lightColor.

"/    aWidget backgroundColor:(aWidget superView viewBackground).
"/    aWidget shadowColor:sClr.
!

postBuildPathViewBox:aWidget

    aWidget backgroundColor:(MenuPanel defaultBackgroundColor).
!

postBuildWith:aBuilder

    super postBuildWith:aBuilder.
    self updateToolVisibility.
!

postOpenWith:aBuilder

    super postOpenWith:aBuilder.
    self abstractCurrentFileNameHolderChanged.
    self currentFileNameHolderChanged.

    self windowGroup addPreEventHook:self.
!

release

    self saveRuntimeAspectValues.
    ^ super release
! !

!FileBrowserV2::SettingDialog class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:FileBrowserV2::SettingDialog andSelector:#windowSpec
     FileBrowserV2::SettingDialog new openInterface:#windowSpec
     FileBrowserV2::SettingDialog open
    "

    <resource: #canvas>

    ^ 
     #(#FullSpec
        #name: #windowSpec
        #window: 
       #(#WindowSpec
          #label: 'FileBrowser V2 Settings'
          #name: 'FileBrowser V2 Settings'
          #min: #(#Point 10 10)
          #max: #(#Point 1024 768)
          #bounds: #(#Rectangle 12 22 512 272)
        )
        #component: 
       #(#SpecCollection
          #collection: #()
        )
      )
! !

!FileBrowserV2::SettingDialog methodsFor:'initialization & release'!

closeDownViews
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is really closed.
     See also #closeDownViews, which is invoked before and may suppress the close
     or ask the user for confirmation."

    "/ change the code below as required ...
    "/ This should cleanup any leftover resources
    "/ (for example, temporary files)
    "/ super closeRequest will initiate the closeDown

    "/ add your code here

    "/ do not remove the one below ...
    ^ super closeDownViews
!

closeRequest
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is about to be
     closed (this method has a chance to suppress the close).
     See also #closeDownViews, which is invoked when the close is really done."

    "/ change the code below as required ...
    "/ Closing can be suppressed, by simply returning.
    "/ The 'super closeRequest' at the end will initiate the real closeDown

    ^ super closeRequest
!

postBuildWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked during the initialization of your app/dialog,
     after all of the visual components have been built, 
     but BEFORE the top window is made visible.
     Add any app-specific actions here (reading files, setting up values etc.)
     See also #postOpenWith:, which is invoked after opening."

    "/ add any code here ...

    ^ super postBuildWith:aBuilder
!

postOpenWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked right after the applications window has been opened.
     Add any app-specific actions here (starting background processes etc.).
     See also #postBuildWith:, which is invoked before opening."

    "/ add any code here ...

    ^ super postOpenWith:aBuilder
! !

!FileBrowserV2::SettingDialog methodsFor:'menu actions'!

help
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'help-documentation' is selected."

    "/ change below as required ...

    "/ to open an HTML viewer on some document (under 'doc/online/<language>/' ):
"/    HTMLDocumentView openFullOnDocumentationFile:'TOP.html'.

    "/ add application-specific help files under the 'doc/online/<language>/help/appName'
    "/ directory, and open a viewer with:
    "/ HTMLDocumentView openFullOnDocumentationFile:'help/<MyApplication>/TOP.html'.
! !

!FileBrowserV2 class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/FileBrowserV2.st,v 1.42 2002-11-08 15:51:08 penk Exp $'
! !

FileBrowserV2 initialize!