Skip to content

Commit

Permalink
Form and file dialog improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Nov 8, 2024
1 parent aafa5a0 commit eb0c530
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 26 deletions.
38 changes: 38 additions & 0 deletions repository/OpenPonk-Core/StDirectoryTreePresenter.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Extension { #name : 'StDirectoryTreePresenter' }

{ #category : '*OpenPonk-Core' }
StDirectoryTreePresenter >> expandPath: aFileLocator [
"Expand the receiver's tree to aFileLocator reference"

| path aPathForSpec currentNode |
self flag: 'Remove (replace by NewTools version) in Pharo 13'.
path := aFileLocator absolutePath segments asOrderedCollection.
aPathForSpec := OrderedCollection with: 1.

currentNode := directoryTreePresenter roots anyOne.
Smalltalk os isWindows ifTrue: [
currentNode := currentNode asFileReference parent.
aPathForSpec := OrderedCollection new ].

path do: [ :aPart |
| subdirs |
subdirs := currentNode directories sorted: [ :a :b |
a basename caseInsensitiveLessOrEqual: b basename ].
currentNode := nil.
subdirs doWithIndex: [ :subdir :index |
(currentNode isNil and: [ subdir basename = aPart ]) ifTrue: [
currentNode := subdir.
aPathForSpec add: index ] ].
currentNode ifNil: [ ^ self ] ].

directoryTreePresenter
selectPath: aPathForSpec
scrollToSelection: true.

"The Morphic `configureScrolling` is executed **AFTER** the desired scroll was configured from the `StDirectoryTreePresenter`. Furthermore, the `configureScrolling` uses the `desiredVisibleRow` which is always set to 1. This statement updates the desired visible row to the last visible index of whatever the selection is pointing to."

directoryTreePresenter verticalAlignment lastVisibleRowIndex ifNil: [
^ self ].
directoryTreePresenter verticalAlignment desiredVisibleRow:
directoryTreePresenter verticalAlignment lastVisibleRowIndex
]
40 changes: 40 additions & 0 deletions repository/OpenPonk-Core/StFileBrowserBookmark.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Extension { #name : 'StFileBrowserBookmark' }

{ #category : '*OpenPonk-Core' }
StFileBrowserBookmark class >> defaultBookmarks [

| presets |
self flag: 'Remove (let NewTools to replace it) in Pharo 13'.
presets := {
self home.
self workingDirectory.
self desktop.
self documents.
self downloads }.

^ OrderedCollection with: (StFileBrowserGroupBookmark
name: 'Bookmarks'
collection: presets
iconName: #book)
]

{ #category : '*OpenPonk-Core' }
StFileBrowserBookmark class >> root [

self flag: 'Remove in Pharo 13'.
^ self
name: '/'
location: FileLocator root
icon: (self iconNamed: #smallWindow)
]

{ #category : '*OpenPonk-Core' }
StFileBrowserBookmark class >> windowsDrives [

self flag: 'Remove in Pharo 13'.
^ FileLocator root asFileReference directories collect: [ :each |
self
name: each basename
location: each
icon: (self iconNamed: #smallWindow) ]
]
14 changes: 14 additions & 0 deletions repository/OpenPonk-Core/StFileSystemItemWrapper.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Extension { #name : 'StFileSystemItemWrapper' }

{ #category : '*OpenPonk-Core' }
StFileSystemItemWrapper class >> roots [

self flag: 'Remove (let it be replaced by NewTools version) in Pharo 13'.
^ Smalltalk os isWindows
ifTrue: [
FileSystem root directories
select: [ :each | each exists and: [ each isReadable ] ]
thenCollect: [ :each | StRootDriveWrapper on: each ] ]
ifFalse: [
Array with: (StRootDirectoryWrapper on: FileSystem root) ]
]
15 changes: 15 additions & 0 deletions repository/OpenPonk-Core/StPathPresenter.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Extension { #name : 'StPathPresenter' }

{ #category : '*OpenPonk-Core' }
StPathPresenter >> file: aFile [

| parts |
self flag: 'Remove (replace by version in NewTools) in Pharo 13'.
self initializeLayout.
parts := aFile asAbsolute fullPath withParents.
Smalltalk os isWindows ifTrue: [
parts first isRoot ifTrue: [ parts := parts copyWithoutFirst ] ].
parts
do: [ :path | self addLinkTo: path ]
separatedBy: [ self addSeparator ]
]
13 changes: 0 additions & 13 deletions repository/OpenPonk-Core/StRootDriveWrapper.extension.st

This file was deleted.

26 changes: 16 additions & 10 deletions repository/OpenPonk-Spec/OPDynamicForm.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ OPDynamicForm >> addControl: aControl [
{ #category : 'public - adding' }
OPDynamicForm >> addDroplist: aName [
| control |
self addLabel: aName.
self addHeadingLabel: aName.

control := self newDropList.

Expand All @@ -136,7 +136,7 @@ OPDynamicForm >> addDroplist: aName [
OPDynamicForm >> addEditableDroplist: aName [

| control |
self addLabel: aName.
self addHeadingLabel: aName.
control := self instantiate: OPEditableDropListPresenter.
self addControl: control.
^ control
Expand All @@ -145,20 +145,26 @@ OPDynamicForm >> addEditableDroplist: aName [
{ #category : 'public - adding' }
OPDynamicForm >> addEntity: aName [
| control |
self addLabel: aName.
self addHeadingLabel: aName.
control := self instantiate: SpSelectEntity.
self addControl: control.
^ control
]

{ #category : 'public - adding' }
OPDynamicForm >> addHeadingLabel: aLabel [

^ (self addLabel: aLabel)
displayBold: [ true ];
yourself
]

{ #category : 'public - adding' }
OPDynamicForm >> addLabel: aLabel [

| control |
control := self newLabel.
control label: aLabel.
"control addStyle: 'bold'."
self flag: 'implement bold'.

self addControl: control.
^ control
Expand All @@ -167,7 +173,7 @@ OPDynamicForm >> addLabel: aLabel [
{ #category : 'public - adding' }
OPDynamicForm >> addList: aName [
| control |
self addLabel: aName.
self addHeadingLabel: aName.

control := self newList.

Expand All @@ -179,7 +185,7 @@ OPDynamicForm >> addList: aName [
OPDynamicForm >> addLongText: aName [

| control |
self addLabel: aName.
self addHeadingLabel: aName.

control := self instantiate: OPLongTextPresenter.

Expand All @@ -191,7 +197,7 @@ OPDynamicForm >> addLongText: aName [
OPDynamicForm >> addNumberInput: aName [

| control |
self addLabel: aName.
self addHeadingLabel: aName.

control := self newNumberInput.

Expand All @@ -208,7 +214,7 @@ OPDynamicForm >> addSeparator [
OPDynamicForm >> addText: aName [

| control |
self addLabel: aName.
self addHeadingLabel: aName.

control := self newText.

Expand All @@ -220,7 +226,7 @@ OPDynamicForm >> addText: aName [
OPDynamicForm >> addTextInput: aName [

| control |
self addLabel: aName.
self addHeadingLabel: aName.

control := self newTextInput.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ OPDynamicFormMagritteVisitor >> visitBooleanDescription: aBooleanDescription [
{ #category : 'visiting' }
OPDynamicFormMagritteVisitor >> visitLabelDescription: aStringDescription [

form addLabel: aStringDescription label.
form addHeadingLabel: aStringDescription label.
form addLabel: (aStringDescription accessor read: controller)
]

Expand Down Expand Up @@ -102,7 +102,7 @@ OPDynamicFormMagritteVisitor >> visitMultipleOptionDescription: aMultipleOptionD
{ #category : 'visiting' }
OPDynamicFormMagritteVisitor >> visitPriorityContainer: aContainer [
(self shouldIncludeLabelFor: aContainer)
ifTrue: [ form addLabel: aContainer label ].
ifTrue: [ form addHeadingLabel: aContainer label ].
aContainer children do: [ :each | self visit: each ].
form addSeparator
]
Expand Down Expand Up @@ -154,6 +154,7 @@ OPDynamicFormMagritteVisitor >> visitStringDescription: aStringDescription [

{ #category : 'visiting' }
OPDynamicFormMagritteVisitor >> visitToManyRelationDescription: aMAToManyRelationDescription [
form addLabel: aMAToManyRelationDescription label.

form addHeadingLabel: aMAToManyRelationDescription label.
(form addButton: 'Edit ') action: [ controller maEdit ]
]

0 comments on commit eb0c530

Please sign in to comment.