[squeak-dev] The Inbox: ToolBuilder-Morphic-ct.280.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Oct 26 18:18:32 UTC 2021

A new version of ToolBuilder-Morphic was added to project The Inbox:

==================== Summary ====================

Name: ToolBuilder-Morphic-ct.280
Author: ct
Time: 26 October 2021, 8:18:30.773896 pm
UUID: 91f3cb18-a5b1-a74b-b494-e3e025cd5a26
Ancestors: ToolBuilder-Morphic-ct.279

UX improvements for file dialogs: Adds a small menu to the selected directory for creating or removing a directory. Fixes tree updates after creating a directory. Decouples dialogs from the Files package by providing clearer hooks that may be overridden by subclasses such as DirectoryChooserDialog (git browser).

Depends indeed on ToolBuilder-Morphic-ct.279 for comparing containingDirectories correctly when signaling #objectChanged.

=============== Diff against ToolBuilder-Morphic-ct.279 ===============

Item was changed:
  ----- Method: FileAbstractSelectionDialog>>buildDirectoryTreeWith: (in category 'toolbuilder') -----
  buildDirectoryTreeWith: builder 
  	| treeSpec |
  	treeSpec := builder pluggableTreeSpec new.
  		 model: self ;
  		 roots: #rootDirectoryList ;
  		 hasChildren: #hasMoreDirectories: ;
  		 getChildren: #subDirectoriesOf: ;
  		 getSelectedPath: #selectedPath ;
  		 setSelected: #setDirectoryTo: ;
  		 getSelected: #directory;
  		 label: #directoryNameOf: ;
+ 		 menu: #directoryMenu: ;
- 		 menu: nil ;
  		 autoDeselect: false ;
  		 hScrollBarPolicy: #whenNeeded.
  	^ treeSpec!

Item was added:
+ ----- Method: FileAbstractSelectionDialog>>defaultDirectory (in category 'directory tree') -----
+ defaultDirectory
+ 	^ FileDirectory default!

Item was changed:
  ----- Method: FileAbstractSelectionDialog>>directory (in category 'directory tree') -----
  	"If nobody has set a specific directory we need a plausible default"
+ 	^ directory ifNil: [ directory := self defaultDirectory]!
- 	^ directory ifNil: [ directory := FileDirectory default]!

Item was added:
+ ----- Method: FileAbstractSelectionDialog>>directoryMenu: (in category 'toolbuilder') -----
+ directoryMenu: menu
+ 	self directory ifNil: [^ menu].
+ 	menu defaultTarget: self.
+ 	menu add: 'new directory' translated action: #newDirectoryName.
+ 	(self rootDirectoryList includes: self directory) ifFalse: [
+ 		menu add: 'remove directory' translated action: #removeDirectoryName].
+ 	^ menu!

Item was changed:
  ----- Method: FileAbstractSelectionDialog>>newDirectoryName (in category 'directory tree') -----
  	"Create a new directory; will be a subdirectory of the current chosen directory. 
  	If the user input is empty, or if the directory creation fails, fail this method.
  	Update the directory tree display afterwards and set the current directory to the newly created directory"
  	userInput := UIManager default request: 'New directory name' translated initialAnswer: 'newDir'.
  	userInput isEmptyOrNil ifTrue: [^nil].
  	[self directory createDirectory: userInput] ifError:[^nil]. "I hate using ifError: - it's so indiscriminate. Really ought to be a more precise error to catch properly"
+ 	self changed: #objectChanged with: self directory.
- 	self changed: #rootDirectoryList.
  	self directory: (self directory / userInput).
  	self changed: #selectedPath!

Item was added:
+ ----- Method: FileAbstractSelectionDialog>>removeDirectoryName (in category 'directory tree') -----
+ removeDirectoryName
+ 	"Remove the current chosen directory. Update the directory tree display afterwards."
+ 	| parent |
+ 	parent := self directory containingDirectory.
+ 	parent deleteDirectory: self directory localName.
+ 	self changed: #objectChanged with: parent.
+ 	self directory: parent.
+ 	self changed: #selectedPath.!

Item was added:
+ ----- Method: FileAbstractSelectionDialog>>root (in category 'directory tree') -----
+ root
+ 	^ FileDirectory root!

Item was changed:
  ----- Method: FileAbstractSelectionDialog>>rootDirectoryList (in category 'directory tree') -----
  	"Return a list of know root directories; forms the root nodes ot the directory tree morph"
  	| dirList dir |
+ 	dir := self root.
- 	dir := FileDirectory root.
  	dirList := self subDirectoriesOf: dir.
+ 	dirList isEmpty ifTrue: [dirList := Array with: self defaultDirectory].
+ 	^dirList , (ServerDirectory servers values) "looks odd because #servers returns the Dictionary of known servers with local names instead of the actaul server directories"!
- 	dirList isEmpty ifTrue:[dirList := Array with: FileDirectory default].
- 	^dirList ,(ServerDirectory servers values) "looks odd because #servers returns the Dictionary of known servers with local names instead of the actaul server directories"!

Item was changed:
  ----- Method: FileAbstractSelectionDialog>>selectedPath (in category 'path and pattern') -----
  	"Return an array of directories representing the path from directory up to the root; used to build the directory tree morph"
  	| top here |
+ 	top := self root.
- 	top := FileDirectory root.
  	here := self directory.
  	^(Array streamContents:[:s| | next |
  		s nextPut: here.
  		[next := here containingDirectory.
  		top pathName = next pathName] whileFalse:[
  			s nextPut: next.
  			here := next.
  		]]) reversed.!

More information about the Squeak-dev mailing list