--- a/FileSelectionBox.st Tue Aug 22 16:15:32 2000 +0200
+++ b/FileSelectionBox.st Wed Aug 23 14:57:40 2000 +0200
@@ -10,8 +10,10 @@
hereby transferred.
"
+"{ Package: 'stx:libwidg' }"
+
ListSelectionBox subclass:#FileSelectionBox
- instanceVariableNames:'patternField selectingDirectory'
+ instanceVariableNames:'patternField selectingDirectory allowMakeDirectory'
classVariableNames:'LastFileSelectionDirectory'
poolDictionaries:''
category:'Views-DialogBoxes'
@@ -288,8 +290,45 @@
^ FileSelectionList
! !
+!FileSelectionBox class methodsFor:'menu specs'!
+
+fileListMenu
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+ "
+ MenuEditor new openOnClass:FileSelectionBox andSelector:#menu
+ (Menu new fromLiteralArrayEncoding:(FileSelectionBox menu)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'New Folder...'
+ #translateLabel: true
+ #value: #fileListMenuNewFolder
+ )
+ )
+ nil
+ nil
+ )
+! !
+
!FileSelectionBox methodsFor:'accessing'!
+allowMakeDirectory:aBoolean
+ "allow or deny creation of new directories;
+ The default is to allow it."
+
+ allowMakeDirectory := aBoolean.
+!
+
contents
"return the current entered value (i.e. the enterFields string).
redefined to return the full pathname."
@@ -449,6 +488,7 @@
super initialize.
selectingDirectory := false.
+ allowMakeDirectory := true.
label := resources string:'File dialog'.
@@ -473,6 +513,8 @@
enterField addDependent:self.
+ selectionList menuHolder:self; menuMessage:#fileListMenu; menuPerformer:self.
+
"
FileSelectionBox open
FileSelectionBox new show
@@ -497,6 +539,36 @@
"Created: 24.7.1997 / 18:19:14 / cg"
! !
+!FileSelectionBox methodsFor:'menu'!
+
+fileListMenu
+ allowMakeDirectory ifFalse:[^ self].
+ ^ self class fileListMenu
+!
+
+fileListMenuNewFolder
+ |newDirName d|
+
+ newDirName := Dialog request:'Name of new Folder:'.
+ newDirName size == 0 ifTrue:[^ self].
+
+ d := self directory asFilename construct:newDirName.
+ d exists ifTrue:[
+ d isDirectory ifTrue:[
+ ^ self
+ ].
+ self warn:(resources string:'A file named %1 already exists.' with:newDirName).
+ ^ self
+ ].
+
+ d makeDirectory.
+ self updateList.
+
+ "
+ self open
+ "
+! !
+
!FileSelectionBox methodsFor:'private'!
updateList
@@ -644,5 +716,5 @@
!FileSelectionBox class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.56 1999-03-19 21:12:13 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.57 2000-08-23 12:57:40 cg Exp $'
! !