FileBrowserV2SettingsAppl.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Jun 2013 16:04:25 +0200
changeset 13007 d71b508f4592
parent 13006 f5c4d034874d
child 13178 c9bf900fe729
child 14120 c0edd37113db
permissions -rw-r--r--
class: FileBrowserV2SettingsAppl changed: #windowSpec

"
 COPYRIGHT (c) 2002 by eXept Software AG
              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' }"

AbstractSettingsApplication subclass:#FileBrowserV2SettingsAppl
	instanceVariableNames:'sortDirectoriesBeforeFiles showDirectoryTree sortCaseless
		showHiddenFiles openMultipleApplicationsForType
		toolBarVisibleHolder viewDirectoryDescription
		openAlwaysInTextEditor viewFilesInDirectoryTree viewDescription
		viewPreview viewTime viewSize viewSizeInBytes viewType
		viewDetails viewPermissions viewGroup viewDirsInContentsBrowser
		viewOwner filenameEntryFieldVisibleHolder viewSizeInKiloBytes
		useCodeView2InTools'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Tools-File'
!

!FileBrowserV2SettingsAppl class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2002 by eXept Software AG
              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.
"
! !

!FileBrowserV2SettingsAppl class methodsFor:'help specs'!

flyByHelpSpec
    <resource: #help>

    ^ super flyByHelpSpec addPairsFrom:(self helpPairs)
!

helpPairs
    ^ #(

#autoOpenDirectoryDescription
'When changing directories, automatically show the contents of a README or .dirInfo file if present.'

#openMultipleApplications
'Show new selected files in a new tab, instead of changing the contents of an existing tab'

#textEditorForAllTypes
'Show all files as text, i.e. do not open specialized viewers as per mime type'

)
! !

!FileBrowserV2SettingsAppl class methodsFor:'icon'!

defaultIcon
    <resource: #programImage>

    ^ FileBrowserV2 applicationIcon
! !

!FileBrowserV2SettingsAppl 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:FileBrowserV2SettingsAppl andSelector:#windowSpec
     FileBrowserV2SettingsAppl new openInterface:#windowSpec
     FileBrowserV2SettingsAppl open
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'Settings'
          name: 'Settings'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 620 559)
        )
        component: 
       (SpecCollection
          collection: (
           (VerticalPanelViewSpec
              name: 'VerticalPanel2'
              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
              horizontalLayout: fit
              verticalLayout: top
              horizontalSpace: 3
              verticalSpace: 3
              component: 
             (SpecCollection
                collection: (
                 (FramedBoxSpec
                    label: 'Show'
                    name: 'FramedBox1'
                    labelPosition: topLeft
                    translateLabel: true
                    component: 
                   (SpecCollection
                      collection: (
                       (CheckBoxSpec
                          label: 'Hidden Files'
                          name: 'CheckBox1'
                          layout: (LayoutFrame 0 0.0 7 0 0 1.0 27 0)
                          model: showHiddenFiles
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Directory Tree'
                          name: 'CheckBox2'
                          layout: (LayoutFrame 0 0.0 29 0 0 1.0 49 0)
                          model: showDirectoryTree
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Regular Files in TreeView (Left)'
                          name: 'CheckBox3'
                          layout: (LayoutFrame 20 0 51 0 0 1.0 71 0)
                          model: viewFilesInDirectoryTree
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Directories in ContentsView (Right)'
                          name: 'CheckBox4'
                          layout: (LayoutFrame 0 0.0 73 0 0 1.0 93 0)
                          model: viewDirsInContentsBrowser
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Toolbar'
                          name: 'CheckBox11'
                          layout: (LayoutFrame 0 0.0 95 0 0 1.0 115 0)
                          model: toolBarVisibleHolder
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Path Entry && Filter'
                          name: 'CheckBox12'
                          layout: (LayoutFrame 0 0.0 117 0 0 1.0 137 0)
                          model: filenameEntryFieldVisibleHolder
                          translateLabel: true
                        )
                       )
                     
                    )
                    extent: (Point 620 175)
                  )
                 (FramedBoxSpec
                    label: 'Sort'
                    name: 'FramedBox2'
                    labelPosition: topLeft
                    translateLabel: true
                    component: 
                   (SpecCollection
                      collection: (
                       (CheckBoxSpec
                          label: 'Ignore Case'
                          name: 'CheckBox6'
                          layout: (LayoutFrame 0 0.0 7 0 0 1.0 27 0)
                          model: sortCaseless
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Directories before Files'
                          name: 'CheckBox7'
                          layout: (LayoutFrame 0 0.0 29 0 0 1.0 49 0)
                          model: sortDirectoriesBeforeFiles
                          translateLabel: true
                        )
                       )
                     
                    )
                    extent: (Point 620 87)
                  )
                 (FramedBoxSpec
                    label: 'Columns in Filelist'
                    name: 'FramedBox4'
                    labelPosition: topLeft
                    translateLabel: true
                    component: 
                   (SpecCollection
                      collection: (
                       (CheckBoxSpec
                          label: 'Details'
                          name: 'CheckBox22'
                          layout: (LayoutFrame 0 0.0 7 0 0 1.0 27 0)
                          model: viewDetails
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Suffix'
                          name: 'CheckBox13'
                          layout: (LayoutFrame 20 0.0 29 0 170 0 49 0)
                          enableChannel: viewDetails
                          model: viewType
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Permissions'
                          name: 'CheckBox21'
                          layout: (LayoutFrame 170 0.0 29 0 -5 1 49 0)
                          enableChannel: viewDetails
                          model: viewPermissions
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Owner'
                          name: 'CheckBox14'
                          layout: (LayoutFrame 20 0.0 51 0 170 0 71 0)
                          enableChannel: viewDetails
                          model: viewOwner
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Group'
                          name: 'CheckBox18'
                          layout: (LayoutFrame 170 0.0 51 0 -5 1 71 0)
                          enableChannel: viewDetails
                          model: viewGroup
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Size'
                          name: 'CheckBox15'
                          layout: (LayoutFrame 20 0.0 73 0 170 0 93 0)
                          enableChannel: viewDetails
                          model: viewSize
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Date && Time'
                          name: 'CheckBox19'
                          layout: (LayoutFrame 170 0.0 73 0 -5 1 93 0)
                          enableChannel: viewDetails
                          model: viewTime
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Size (Byte)'
                          name: 'CheckBox16'
                          layout: (LayoutFrame 20 0.0 95 0 170 0 115 0)
                          enableChannel: viewDetails
                          model: viewSizeInBytes
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Size (KByte)'
                          name: 'CheckBox20'
                          layout: (LayoutFrame 170 0.0 95 0 -5 1 115 0)
                          enableChannel: viewDetails
                          model: viewSizeInKiloBytes
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'File Info'
                          name: 'CheckBox23'
                          layout: (LayoutFrame 20 0.0 117 0 170 0 137 0)
                          enableChannel: viewDetails
                          model: viewDescription
                          translateLabel: true
                        )
                       (CheckBoxSpec
                          label: 'Preview'
                          name: 'CheckBox24'
                          layout: (LayoutFrame 170 0.0 117 0 -5 1 137 0)
                          enableChannel: viewDetails
                          model: viewPreview
                          translateLabel: true
                        )
                       )
                     
                    )
                    extent: (Point 620 174)
                  )
                 (FramedBoxSpec
                    label: 'Application Notebook'
                    name: 'FramedBox3'
                    labelPosition: topLeft
                    translateLabel: true
                    component: 
                   (SpecCollection
                      collection: (
                       (VerticalPanelViewSpec
                          name: 'VerticalPanel3'
                          layout: (LayoutFrame 0 0 5 0 0 1 0 1)
                          horizontalLayout: left
                          verticalLayout: top
                          horizontalSpace: 3
                          verticalSpace: 3
                          component: 
                         (SpecCollection
                            collection: (
                             (CheckBoxSpec
                                label: 'Text Editor for all Types'
                                name: 'CheckBox25'
                                activeHelpKey: textEditorForAllTypes
                                model: openAlwaysInTextEditor
                                translateLabel: true
                                extent: (Point 435 20)
                              )
                             (CheckBoxSpec
                                label: 'Open Multiple Applications'
                                name: 'CheckBox9'
                                activeHelpKey: openMultipleApplications
                                model: openMultipleApplicationsForType
                                translateLabel: true
                                extent: (Point 435 20)
                              )
                             (CheckBoxSpec
                                label: 'Auto Open Directory Description (README)'
                                name: 'CheckBox10'
                                activeHelpKey: autoOpenDirectoryDescription
                                model: viewDirectoryDescription
                                translateLabel: true
                                extent: (Point 435 20)
                              )
                             )
                           
                          )
                        )
                       )
                     
                    )
                    extent: (Point 620 108)
                  )
                 )
               
              )
            )
           )
         
        )
      )
! !

!FileBrowserV2SettingsAppl class methodsFor:'resources'!

classResources
    ^ FileBrowserV2 classResources
! !

!FileBrowserV2SettingsAppl methodsFor:'accessing'!

requestor
    "return the value of the instance variable 'requestor' (automatically generated)"

    | masterApplication |
    masterApplication := self masterApplication.
    masterApplication notNil ifTrue:[
        ^ masterApplication requestor.
    ].
    ^ nil
! !

!FileBrowserV2SettingsAppl methodsFor:'actions'!

basicSaveSettings
    |aspectList writeToCurrentFileBrowser|

    aspectList := AbstractFileBrowser userPreferencesAspectList.

    writeToCurrentFileBrowser := (settingsDialog notNil and:[settingsDialog isKindOf:AbstractFileBrowser]).
    aspectList keysDo:[ :anAspect | |value|
        value := (self perform:anAspect) value.
        (currentUserPrefs perform:((anAspect asString, ':') asSymbol) with:value).
        writeToCurrentFileBrowser ifTrue:[
            (settingsDialog perform:anAspect) value:value.
        ].
    ].

    "Modified: / 15-10-2010 / 10:29:28 / cg"
!

helpFilename
    ^ 'FileBrowserV2/settings.html'
!

readSettings
    |receiver aspectList|

    receiver := (settingsDialog notNil and:[settingsDialog isKindOf:AbstractFileBrowser]) ifTrue:[
                settingsDialog
            ] ifFalse:[
                currentUserPrefs
            ].
    aspectList := AbstractFileBrowser userPreferencesAspectList.
    aspectList keysDo:[:anAspect |
        |value|
        value := (receiver perform:anAspect) value.
        (self perform:anAspect) value:value
    ].
    self modifiedChannel value:false

    "Modified: / 03-04-2007 / 08:45:12 / cg"
! !

!FileBrowserV2SettingsAppl methodsFor:'aspects'!

filenameEntryFieldVisibleHolder
    filenameEntryFieldVisibleHolder isNil ifTrue:[
        filenameEntryFieldVisibleHolder := true asValue.
        filenameEntryFieldVisibleHolder onChangeSend:#updateModifiedChannel
            to:self
    ].
    ^ filenameEntryFieldVisibleHolder
!

openAlwaysInTextEditor
    openAlwaysInTextEditor isNil ifTrue:[
        openAlwaysInTextEditor := true asValue.
        openAlwaysInTextEditor onChangeSend:#updateModifiedChannel to:self
    ].
    ^ openAlwaysInTextEditor
!

openMultipleApplicationsForType
    openMultipleApplicationsForType isNil ifTrue:[
        openMultipleApplicationsForType := true asValue.
        openMultipleApplicationsForType onChangeSend:#updateModifiedChannel
            to:self
    ].
    ^ openMultipleApplicationsForType
!

showDirectoryTree
    showDirectoryTree isNil ifTrue:[
        showDirectoryTree := true asValue.
        showDirectoryTree onChangeSend:#updateModifiedChannel to:self
    ].
    ^ showDirectoryTree
!

showHiddenFiles
    showHiddenFiles isNil ifTrue:[
        showHiddenFiles := true asValue.
        showHiddenFiles onChangeSend:#updateModifiedChannel to:self
    ].
    ^ showHiddenFiles

    "Modified: / 15-10-2010 / 10:28:07 / cg"
!

sortCaseless
    sortCaseless isNil ifTrue:[
        sortCaseless := true asValue.
        sortCaseless onChangeSend:#updateModifiedChannel to:self
    ].
    ^ sortCaseless
!

sortDirectoriesBeforeFiles
    sortDirectoriesBeforeFiles isNil ifTrue:[
        sortDirectoriesBeforeFiles := true asValue.
        sortDirectoriesBeforeFiles onChangeSend:#updateModifiedChannel to:self
    ].
    ^ sortDirectoriesBeforeFiles
!

toolBarVisibleHolder
    toolBarVisibleHolder isNil ifTrue:[
        toolBarVisibleHolder := true asValue.
        toolBarVisibleHolder onChangeSend:#updateModifiedChannel to:self
    ].
    ^ toolBarVisibleHolder
!

useCodeView2InTools
    "/ obsolete - will vanish
    useCodeView2InTools isNil ifTrue:[
        useCodeView2InTools := true asValue.
        useCodeView2InTools onChangeSend:#updateModifiedChannel to:self
    ].
    ^ useCodeView2InTools

    "Created: / 06-10-2011 / 11:30:42 / cg"
!

viewDescription
    viewDescription isNil ifTrue:[
        viewDescription := false asValue.
        viewDescription onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewDescription
!

viewDetails
    viewDetails isNil ifTrue:[
        viewDetails := true asValue.
        viewDetails onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewDetails
!

viewDirectoryDescription
    viewDirectoryDescription isNil ifTrue:[
        viewDirectoryDescription := true asValue.
        viewDirectoryDescription onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewDirectoryDescription
!

viewDirsInContentsBrowser
    viewDirsInContentsBrowser isNil ifTrue:[
        viewDirsInContentsBrowser := true asValue.
        viewDirsInContentsBrowser onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewDirsInContentsBrowser
!

viewFilesInDirectoryTree
    viewFilesInDirectoryTree isNil ifTrue:[
        viewFilesInDirectoryTree := true asValue.
        viewFilesInDirectoryTree onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewFilesInDirectoryTree
!

viewGroup
    viewGroup isNil ifTrue:[
        viewGroup := true asValue.
        viewGroup onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewGroup
!

viewOwner
    viewOwner isNil ifTrue:[
        viewOwner := true asValue.
        viewOwner onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewOwner
!

viewPermissions
    viewPermissions isNil ifTrue:[
        viewPermissions := true asValue.
        viewPermissions onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewPermissions
!

viewPreview
    viewPreview isNil ifTrue:[
        viewPreview := true asValue.
        viewPreview onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewPreview
!

viewSize
    viewSize isNil ifTrue:[
        viewSize := true asValue.
        viewSize onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewSize
!

viewSizeInBytes
    viewSizeInBytes isNil ifTrue:[
        viewSizeInBytes := false asValue.
        viewSizeInBytes onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewSizeInBytes
!

viewSizeInKiloBytes
    viewSizeInKiloBytes isNil ifTrue:[
        viewSizeInKiloBytes := false asValue.
        viewSizeInKiloBytes onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewSizeInKiloBytes
!

viewTime
    viewTime isNil ifTrue:[
        viewTime := true asValue.
        viewTime onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewTime
!

viewType
    viewType isNil ifTrue:[
        viewType := true asValue.
        viewType onChangeSend:#updateModifiedChannel to:self
    ].
    ^ viewType
! !

!FileBrowserV2SettingsAppl methodsFor:'queries'!

hasUnsavedChanges

    |aspectList receiver|

    receiver := (settingsDialog notNil 
                and:[settingsDialog isKindOf:AbstractFileBrowser]) 
                    ifTrue:[ settingsDialog ] 
                    ifFalse:[ currentUserPrefs ].

    aspectList := AbstractFileBrowser userPreferencesAspectList.
    aspectList keysDo:[:anAspect |
        (self perform:anAspect) value ~= (receiver perform:anAspect) value ifTrue:[ 
            ^ true
        ]
    ].
    ^ false

    "Modified: / 03-04-2007 / 08:45:27 / cg"
    "Modified (format): / 25-11-2011 / 15:24:25 / cg"
! !

!FileBrowserV2SettingsAppl class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/FileBrowserV2SettingsAppl.st,v 1.31 2013-06-25 14:04:25 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/FileBrowserV2SettingsAppl.st,v 1.31 2013-06-25 14:04:25 cg Exp $'
! !