From 9450718881aeeaff0ac844d5bb77bffa285ddeca Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Tue, 31 Jul 2018 17:03:49 +0200 Subject: [PATCH] Add #933 Simplify Edit project dialog: - add root directory - handle deselection (and select root) --- .../instance/directory..st | 2 +- .../class/defaultSpec.st | 4 ---- .../instance/initializeDirectoryTree.st | 3 +-- .../instance/initializePresenter.st | 24 +++++++++---------- .../instance/initializeWidgets.st | 7 +----- .../instance/newDirectoryDataSource.st | 2 +- .../sourceDirectorySelectionChanged..st | 16 ++++++++----- .../instance/useSourceFolder.st | 3 --- .../properties.json | 4 +--- 9 files changed, 26 insertions(+), 39 deletions(-) delete mode 100644 Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/useSourceFolder.st diff --git a/Iceberg-TipUI.package/IceTipDirectoryDataSource.class/instance/directory..st b/Iceberg-TipUI.package/IceTipDirectoryDataSource.class/instance/directory..st index 523f98edb7..f176ab9319 100644 --- a/Iceberg-TipUI.package/IceTipDirectoryDataSource.class/instance/directory..st +++ b/Iceberg-TipUI.package/IceTipDirectoryDataSource.class/instance/directory..st @@ -1,7 +1,7 @@ accessing directory: aDirectory - rootItem := (self class rootItemFor: (self childrenToShowFrom: aDirectory)) + rootItem := (self class rootItemFor: { aDirectory }) dataSource: self; yourself. self rootItem: rootItem \ No newline at end of file diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/class/defaultSpec.st b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/class/defaultSpec.st index 85699927a8..e6eb349dfe 100644 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/class/defaultSpec.st +++ b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/class/defaultSpec.st @@ -17,10 +17,6 @@ defaultSpec newRow: [ :emptyRow | "Fill space" ] ] width: self iceLabelWidth; newColumn: #sourceDirectoryTree ] height: 200; - newRow: [ :row | - row newColumn: [ :emptyColumn | "Fill space" ] width: self iceLabelWidth. - row newColumn: #useSourceFolder ] - height: self inputTextHeight; newRow: [ :row | row newColumn: #formatLabel width: self iceLabelWidth; diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeDirectoryTree.st b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeDirectoryTree.st index a418a89b1f..039fc58b40 100644 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeDirectoryTree.st +++ b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeDirectoryTree.st @@ -7,5 +7,4 @@ initializeDirectoryTree addColumn: (IceTipTableColumn newAction: #name icon: [ :each | self iconNamed: #package ]); dataSource: dataSource; onAnnouncement: FTSelectionChanged do: [ :announcement | - self sourceDirectorySelectionChanged: announcement newSelectedRowIndexes. - useSourceFolder state: true ] \ No newline at end of file + self sourceDirectorySelectionChanged: announcement newSelectedRowIndexes ] \ No newline at end of file diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializePresenter.st b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializePresenter.st index 06abc6883d..78c6a6404b 100644 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializePresenter.st +++ b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializePresenter.st @@ -4,20 +4,18 @@ initializePresenter | path currentNode | super initializePresenter. path := (RelativePath with: model sourceDirectory) segments asOrderedCollection. - - path isEmpty ifFalse: [ - currentNode := self sourceDirectoryTree widget dataSource rootItem. - - [ path isEmpty ] whileFalse: [ | currentSegment | - currentSegment := path removeFirst. - currentNode := currentNode children detect: [ :e | e data basename = currentSegment ] ifFound: [ :node | node expand. node ] ifNone: [ nil ]]. - currentNode ifNotNil: [self sourceDirectoryTree widget selectRowIndex: (self sourceDirectoryTree widget dataSource indexOfElementMatching: [ :elem | elem = currentNode data ])]. - ]. - + currentNode := self sourceDirectoryTree widget dataSource rootItem children first. + currentNode expand. + [ path isEmpty ] whileFalse: [ | currentSegment | + currentSegment := path removeFirst. + currentNode := currentNode children detect: [ :e | (e data basename ifEmpty: [ '/' ]) = currentSegment ] ifFound: [ :node | node expand. node ] ifNone: [ nil ]]. + + currentNode ifNotNil: [ + self sourceDirectoryTree widget + selectRowIndex: (self sourceDirectoryTree widget dataSource indexOfElementMatching: [ :elem | elem = currentNode data ]) ]. + self formatList items: self formats; displayBlock: [ :each | each description ]; - setSelectedItem: model repositoryProperties fileFormat. - - useSourceFolder state: model sourceDirectory isNotEmpty. \ No newline at end of file + setSelectedItem: model repositoryProperties fileFormat. \ No newline at end of file diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeWidgets.st b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeWidgets.st index a438c00119..0873113e70 100644 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeWidgets.st +++ b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/initializeWidgets.st @@ -8,14 +8,9 @@ initializeWidgets formatLabel := self newLabel label: 'Format'. formatList := self newDropList. - - useSourceFolder := self newCheckBox - label: 'Use Source Directory'; - whenChangedDo: [ useSourceFolder state ifFalse: [ sourceDirectoryTree widget selectRowIndexes: #() ] ] . - + self initializeDirectoryTree. self focusOrder add: nameInput; add: sourceDirectoryTree; - add: useSourceFolder; add: formatList \ No newline at end of file diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/newDirectoryDataSource.st b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/newDirectoryDataSource.st index f9527615e8..83becd8528 100644 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/newDirectoryDataSource.st +++ b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/newDirectoryDataSource.st @@ -1,6 +1,6 @@ initialization newDirectoryDataSource - + ^ IceTipDirectoryDataSource new directory: self model fileSystem; yourself \ No newline at end of file diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/sourceDirectorySelectionChanged..st b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/sourceDirectorySelectionChanged..st index 705658acb5..df2549cf02 100644 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/sourceDirectorySelectionChanged..st +++ b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/sourceDirectorySelectionChanged..st @@ -1,14 +1,18 @@ initialization sourceDirectorySelectionChanged: selectedIndexes - | selectedDirectory | + | selectedDirectory selection | selectedIndexes ifEmpty: [ "If the user does not select any directory, we choose the root and we use the default format" selectedDirectoryPath := RelativePath new. - formatList setSelectedItem: defaultFormat ] - ifNotEmpty: [ | selection | + self sourceDirectoryTree widget selectRowIndex: 1. + selection := self sourceDirectoryTree widget dataSource rootItem children first. + selectedDirectory := self sourceDirectoryTree widget dataSource rootItem children first data. + ] ifNotEmpty: [ selection := self sourceDirectoryTree widget dataSource elementAt: selectedIndexes first. - selectedDirectory := selection data. - selectedDirectoryPath := selectedDirectory relativeTo: self model fileSystem. - formatList setSelectedItem: (self guessFormatFromDirectory: selectedDirectory) ]. \ No newline at end of file + ]. + + selectedDirectory := selection data. + selectedDirectoryPath := selectedDirectory relativeTo: self model fileSystem. + formatList setSelectedItem: (self guessFormatFromDirectory: selectedDirectory). \ No newline at end of file diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/useSourceFolder.st b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/useSourceFolder.st deleted file mode 100644 index 67b0eb6b39..0000000000 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/instance/useSourceFolder.st +++ /dev/null @@ -1,3 +0,0 @@ -accessing -useSourceFolder - ^ useSourceFolder \ No newline at end of file diff --git a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/properties.json b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/properties.json index 7322351f99..9ab98249e8 100644 --- a/Iceberg-TipUI.package/IceTipEditProjectDialog.class/properties.json +++ b/Iceberg-TipUI.package/IceTipEditProjectDialog.class/properties.json @@ -12,13 +12,11 @@ "acceptCallback", "sourceDirectoryLabel", "sourceDirectoryTree", - "sourceDirectorySelectionLabel", "selectedDirectoryPath", "formatList", "formatLabel", "formats", - "defaultFormat", - "useSourceFolder" + "defaultFormat" ], "name" : "IceTipEditProjectDialog", "type" : "normal"