Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify Edit project dialog:
 - add root directory
 - handle deselection (and select root)
  • Loading branch information
guillep committed Jul 31, 2018
1 parent 69585b0 commit 9450718
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
self sourceDirectorySelectionChanged: announcement newSelectedRowIndexes ]
Original file line number Diff line number Diff line change
Expand Up @@ -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.
setSelectedItem: model repositoryProperties fileFormat.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
initialization
newDirectoryDataSource

^ IceTipDirectoryDataSource new
directory: self model fileSystem;
yourself
Original file line number Diff line number Diff line change
@@ -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) ].
].

selectedDirectory := selection data.
selectedDirectoryPath := selectedDirectory relativeTo: self model fileSystem.
formatList setSelectedItem: (self guessFormatFromDirectory: selectedDirectory).

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
"acceptCallback",
"sourceDirectoryLabel",
"sourceDirectoryTree",
"sourceDirectorySelectionLabel",
"selectedDirectoryPath",
"formatList",
"formatLabel",
"formats",
"defaultFormat",
"useSourceFolder"
"defaultFormat"
],
"name" : "IceTipEditProjectDialog",
"type" : "normal"
Expand Down

0 comments on commit 9450718

Please sign in to comment.