Skip to content

Commit

Permalink
Merge pull request #717 from hernanmd/enable_set_filename_in_file_bro…
Browse files Browse the repository at this point in the history
…wser_dialogs

Add pre-filling the name text presenter in file dialogs
  • Loading branch information
jecisc authored Mar 14, 2024
2 parents f5a98fa + a5fdf3b commit 1cbb5a8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
34 changes: 34 additions & 0 deletions src/NewTools-FileBrowser-Tests/StSaveFilePresenterTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Class {
#name : 'StSaveFilePresenterTest',
#superclass : 'StFilePresenterTest',
#category : 'NewTools-FileBrowser-Tests-UI',
#package : 'NewTools-FileBrowser-Tests',
#tag : 'UI'
}

{ #category : 'accessing' }
StSaveFilePresenterTest >> dialogClass [

^ StSaveFilePresenter
]

{ #category : 'tests' }
StSaveFilePresenterTest >> testSetNameText [

| preFillDocName |

preFillDocName := 'mydocument.doc'.
dialog nameText: preFillDocName.
self
assert: dialog nameText
equals: preFillDocName
]

{ #category : 'tests' }
StSaveFilePresenterTest >> testWhenChangeDirectoryShouldFilesListContainsHisChildren [
| newDirectory |
newDirectory := (root / 'dir') asFileReference.
dialog defaultFolder: newDirectory.
self
assert: (dialog fileReferenceTable items includesAll: newDirectory children)
]
13 changes: 13 additions & 0 deletions src/NewTools-FileBrowser/StFileDialogPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ StFileDialogPresenter >> isolate [

]

{ #category : 'accessing - ui' }
StFileDialogPresenter >> nameText [
"Answer a <String> with the text in the name presenter used to display the currently selected file/directory or a manually entered name"

^ fileNavigationSystem nameText text.
]

{ #category : 'accessing' }
StFileDialogPresenter >> nameText: aString [

fileNavigationSystem nameText: aString
]

{ #category : 'api - customization' }
StFileDialogPresenter >> okAction: aOneArgBlock [
okAction := aOneArgBlock
Expand Down
23 changes: 14 additions & 9 deletions src/NewTools-FileBrowser/StFileNavigationSystemPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ StFileNavigationSystemPresenter >> defaultPreviewer [
StFileNavigationSystemPresenter >> fileNameLayout [

^ SpBoxLayout newLeftToRight
vAlignCenter;
add: nameText;
add: filtersDropList expand: false;
yourself
spacing: 2;
vAlignCenter;
add: nameText;
add: filtersDropList expand: false;
yourself
]

{ #category : 'accessing' }
Expand All @@ -195,11 +196,6 @@ StFileNavigationSystemPresenter >> filesListAction [

| previewProcess |

fileReferenceTable
transmitTo: nameText
transform: [ :selectedItem |
selectedItem ifNotNil: [ selectedItem basename ] ifNil: [ '' ] ].

fileReferenceTable whenActivatedDo: [ :selectedItem |
previewProcess ifNotNil: [
previewProcess isTerminated ifFalse: [ previewProcess terminate ] ].
Expand Down Expand Up @@ -264,6 +260,8 @@ StFileNavigationSystemPresenter >> initializeFilesTable [
beResizable;
columns: StFileBrowserAbstractColumn columns;
sortingBlock: self defaultFileSortBlock;
whenSelectedItemChangedDo: [ : selectedItem |
selectedItem ifNotNil: [ self nameText: selectedItem basename ] ];
contextMenuFromCommandsGroup: [ self rootCommandsGroup / 'StFileBrowserNavigationMenu' ]
]

Expand Down Expand Up @@ -326,6 +324,13 @@ StFileNavigationSystemPresenter >> nameText [
^ nameText
]

{ #category : 'accessing' }
StFileNavigationSystemPresenter >> nameText: aString [
"Set the receive's name text to aString. This is displayed in a text presenter to display the currently selected file, or the name of a new file to be saved"

nameText text: aString.
]

{ #category : 'actions' }
StFileNavigationSystemPresenter >> nameTextAction [

Expand Down

0 comments on commit 1cbb5a8

Please sign in to comment.