From 0cbb94a51023e72420cd8141bd08477068557ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Fri, 19 Jan 2024 20:30:15 +0100 Subject: [PATCH 1/9] Add bookmark presenter to dialogs and browser. Enable window title in presenters. Replace UIManager reference. Use the same columns by default in all dialogs and browser. Add comments. Minor refactorings --- .../StFileBrowserAbstractPresenter.class.st | 16 ++++ .../StFileBrowserBookmark.class.st | 2 +- .../StFileDialogPresenter.class.st | 59 ++++++++++++-- .../StFileNavigationSystemPresenter.class.st | 76 ++++++++----------- .../StFileSystemPresenter.class.st | 29 +++++-- .../StOpenDirectoryDialog.class.st | 5 +- .../StOpenFileDialog.class.st | 3 +- .../StSaveFileDialog.class.st | 15 ++-- 8 files changed, 137 insertions(+), 68 deletions(-) diff --git a/src/NewTools-FileBrowser/StFileBrowserAbstractPresenter.class.st b/src/NewTools-FileBrowser/StFileBrowserAbstractPresenter.class.st index ecbcfec2..644582d4 100644 --- a/src/NewTools-FileBrowser/StFileBrowserAbstractPresenter.class.st +++ b/src/NewTools-FileBrowser/StFileBrowserAbstractPresenter.class.st @@ -45,6 +45,12 @@ StFileBrowserAbstractPresenter class >> lastVisitedDirectory [ ^ LastVisitedDirectory ] +{ #category : 'instance creation' } +StFileBrowserAbstractPresenter class >> new [ + + ^ self on: StFileSystemModel new +] + { #category : 'instance creation' } StFileBrowserAbstractPresenter class >> open [ @@ -107,6 +113,16 @@ StFileBrowserAbstractPresenter >> currentDirectory: aFileReference [ self model currentDirectory: aFileReference. ] +{ #category : 'initialization' } +StFileBrowserAbstractPresenter >> defaultColumns [ + + ^ { + StFileBrowserModificationDateColumn . + StFileBrowserSizeColumn . + StFileBrowserRightsColumn + } +] + { #category : 'defaults' } StFileBrowserAbstractPresenter >> defaultDirectory [ "See class side comment" diff --git a/src/NewTools-FileBrowser/StFileBrowserBookmark.class.st b/src/NewTools-FileBrowser/StFileBrowserBookmark.class.st index 2448725d..3e9112e1 100644 --- a/src/NewTools-FileBrowser/StFileBrowserBookmark.class.st +++ b/src/NewTools-FileBrowser/StFileBrowserBookmark.class.st @@ -29,7 +29,7 @@ StFileBrowserBookmark class >> defaultBookmarks [ ^ OrderedCollection with: (StFileBrowserGroupBookmark - name: 'Favourites' + name: 'Bookmarks' collection: presets iconName: #book) ] diff --git a/src/NewTools-FileBrowser/StFileDialogPresenter.class.st b/src/NewTools-FileBrowser/StFileDialogPresenter.class.st index d17f43dc..074695c3 100644 --- a/src/NewTools-FileBrowser/StFileDialogPresenter.class.st +++ b/src/NewTools-FileBrowser/StFileDialogPresenter.class.st @@ -52,7 +52,8 @@ Class { #instVars : [ 'fileNavigationSystem', 'okAction', - 'filter' + 'filter', + 'treeNavigationSystem' ], #classVars : [ 'OkAction' @@ -206,6 +207,9 @@ StFileDialogPresenter >> confirmed [ { #category : 'initialization' } StFileDialogPresenter >> connectPresenters [ + treeNavigationSystem + transmitDo: [ : selection | selection ifNotNil: [ self updateWidgetWithFileReference: selection fileReference ] ]. + bookmarksTreeTable whenSelectionChangedDo: [ :selection | selection selectedItem ifNotNil: [ :selectedItem | selectedItem isComposite ifFalse: [ @@ -222,7 +226,11 @@ StFileDialogPresenter >> defaultLayout [ ^ SpPanedLayout newLeftToRight positionOfSlider: 200; - add: bookmarksTreeTable; + add: (SpPanedLayout newTopToBottom + positionOfSlider: 450; + add: treeNavigationSystem; + add: bookmarksTreeTable; + yourself); add: fileNavigationSystem; yourself ] @@ -277,6 +285,17 @@ StFileDialogPresenter >> iconFor: anEntry [ ifAbsent: [ self iconNamed: #page ] ] +{ #category : 'initialization' } +StFileDialogPresenter >> initialExtentForWindow [ + + ^ 1050 @ 750 +] + +{ #category : 'hooks' } +StFileDialogPresenter >> initialTitle [ + ^ self subclassResponsibility +] + { #category : 'initialization' } StFileDialogPresenter >> initialize [ @@ -318,15 +337,20 @@ StFileDialogPresenter >> initializePresenters [ super initializePresenters. fileNavigationSystem := self instantiate: StFileNavigationSystemPresenter on: model. - fileNavigationSystem filter: self filter. + fileNavigationSystem + filter: self filter; + columns: self defaultColumns. + + treeNavigationSystem := self instantiate: StDirectoryTreePresenter on: model. + treeNavigationSystem expandPath: fileNavigationSystem currentDirectory. ] { #category : 'initialization' } -StFileDialogPresenter >> initializeWindow: aWindowPresenter [ +StFileDialogPresenter >> initializeWindow: aSpWindowPresenter [ + + self setTitleTo: aSpWindowPresenter. + self setInitialExtentTo: aSpWindowPresenter - aWindowPresenter - title: self title; - initialExtent: 1050 @ 750 ] { #category : 'accessing' } @@ -384,8 +408,29 @@ StFileDialogPresenter >> selectedEntry [ ^ entry ] +{ #category : 'initialization' } +StFileDialogPresenter >> setInitialExtentTo: aSpWindowPresenter [ + + aSpWindowPresenter initialExtent: self initialExtentForWindow +] + +{ #category : 'initialization' } +StFileDialogPresenter >> setTitleTo: aSpWindowPresenter [ + + aSpWindowPresenter title: self initialTitle + +] + { #category : 'accessing' } StFileDialogPresenter >> showDirectory: aFileReference [ fileNavigationSystem currentDirectory: aFileReference ] + +{ #category : 'initialization' } +StFileDialogPresenter >> updateWidgetWithFileReference: aFileReference [ + + self currentDirectory: aFileReference. + aFileReference exists + ifTrue: [ fileNavigationSystem updateWidgetWithFileReference: aFileReference ] +] diff --git a/src/NewTools-FileBrowser/StFileNavigationSystemPresenter.class.st b/src/NewTools-FileBrowser/StFileNavigationSystemPresenter.class.st index ab819547..1f5108a3 100644 --- a/src/NewTools-FileBrowser/StFileNavigationSystemPresenter.class.st +++ b/src/NewTools-FileBrowser/StFileNavigationSystemPresenter.class.st @@ -1,55 +1,43 @@ " -I'm use by thez fileDialog +This Spec presenter provides: -my job is to navigate across file +* An history of visited folder. +* A text input use to jump to the write path. +* A drop list use to filter the content of the fileReferenceTable +* A text presenter to show a preview of the currently selected file. -I provide: -* an history of visited folder -* a textInput use to jump to the write path -* a dropList use to filter the content of the fileReferenceTable -* a TextPresenter to show the selectedFile +## Example -CUSTOMIZATION -------------- +To open a navigation presenter for PNG files, evaluate: -look at the protocol 'api-customization' +```smalltalk +StFileNavigationSystemPresenter example. +``` -column: aCollectionOfColumn -=========================== +## Customization - to use it you have to give a collection of son of FDAbstractFileReferenceColumn for more information on how to create see documentation of FDAbstractFileReferenceColumn +You can customize how this presenter is displayed, with methods listed at the protocol 'api-customization'. These are some examples: -defaultFoler: aFileReference -============================ - - nothing to say - -filtersCustomization: aCollectionOfFilter -========================================= - - more documentation see FDAbstractPredicate documentation - -previewer: aPreviewer -===================== - - more documentation see FDAbstractPreviewer documentation +* `column: aCollectionOfColumn` : Give a `Collection` of any subclass of `StFileBrowserAbstractColumn`. +* `defaultFoler: aFileReference` +* `filtersCustomization: aCollectionOfFilter` : See `StFileBrowserAbstractFilter` on tge avaiable filters and how to instantiate them. +* `previewer: aPreviewer` : See `StFileBrowserAbstractPreviewer` to check the available previewers. -IV --- - -currentPathTextInputPresenter : It's use to display the current path and there are same feature like in window -nameLabel : -nameText: , use to show the name of the selected item of fileReferenceTable -filtersDropList , use to display all the filter -readPointerHistoryParcour , use for the navigationSystem -currentDirectory , into there is the currentDirectory -hiddenFilter there is a NullFilter or an hiddenFilter -columns it's a collection of Column use by FileReferenceTable -previewer -nextButton use for the navigationSystem -previousButton use for the navigationSystem -notebookPreviewer use by the preview system -fileReferenceTable it's display children of the current directory +## Instance variables + +* currentPathTextInputPresenter : It's use to display the current path and there are same feature like in window +* nameLabel : +* nameText: , use to show the name of the selected item of fileReferenceTable +* filtersDropList , use to display all the filter +* readPointerHistoryParcour , use for the navigationSystem +* currentDirectory , into there is the currentDirectory +* hiddenFilter there is a NullFilter or an hiddenFilter +* columns it's a collection of Column use by FileReferenceTable +* previewer +* nextButton use for the navigationSystem +* previousButton use for the navigationSystem +* notebookPreviewer use by the preview system +* fileReferenceTable it's display children of the current directory " Class { #name : 'StFileNavigationSystemPresenter', @@ -267,6 +255,7 @@ StFileNavigationSystemPresenter >> initialize [ { #category : 'initialization' } StFileNavigationSystemPresenter >> initializeFilesTable [ + fileReferenceTable := self newTable. fileReferenceTable beResizable; columns: StFileBrowserAbstractColumn columns; @@ -306,7 +295,6 @@ StFileNavigationSystemPresenter >> initializePresenters [ super initializePresenters. notebookPreviewer := self instantiate: StNoteBookPreviewerPresenter. - fileReferenceTable := self newTable. currentPathTextInputPresenter := self instantiate: StPathBreadcrumbPresenter on: self model. nameText := self newTextInput. filtersDropList := self newDropList. diff --git a/src/NewTools-FileBrowser/StFileSystemPresenter.class.st b/src/NewTools-FileBrowser/StFileSystemPresenter.class.st index a5c39b13..3aa28ed1 100644 --- a/src/NewTools-FileBrowser/StFileSystemPresenter.class.st +++ b/src/NewTools-FileBrowser/StFileSystemPresenter.class.st @@ -1,5 +1,13 @@ " -General file system presenter, which replaces the older FileList tool. +It provides a File System Spec-based presenter, which replaces the old FileList tool. + +## Example + +To open a default File System Browser, evaluate: + +```smalltalk +StFileSystemPresenter open. +``` " Class { @@ -25,6 +33,13 @@ StFileSystemPresenter class >> lastVisitedDirectory [ ^ LastVisitedDirectory ] +{ #category : 'instance creation' } +StFileSystemPresenter class >> open [ +