'From etoys4.0 of 9 October 2008 [latest update: #2296] on 11 September 2009 at 7:57:14 pm'! "Change Set: ProjectDAV5-yo Date: 11 September 2009 Author: Yoshiki Ohshima Change the layout of login box and put default label when not logged in. Also the default path name is changed to everyone from public."! FileList subclass: #FileList2 instanceVariableNames: 'showDirsInFileList currentDirectorySelected fileSelectionBlock dirSelectionBlock optionalButtonSpecs modalView directoryChangeBlock ok loginButton loginField loginDialog ' classVariableNames: '' poolDictionaries: '' category: 'Tools-FileList'! !DAVMultiUserServerDirectory methodsFor: 'as yet unclassified' stamp: 'yo 9/11/2009 19:10'! createPersonalDirectory: aString aString ifNil: [^ self]. directory := origDirectory, '/', self pathToUserAccount. altURL := server, directory. self createDirectory: aString. ! ! !DAVMultiUserServerDirectory methodsFor: 'as yet unclassified' stamp: 'yo 9/11/2009 19:10'! pathToUserAccount ^ 'everyone/accounts/'! ! !DAVMultiUserServerDirectory methodsFor: 'as yet unclassified' stamp: 'yo 9/11/2009 19:10'! setupPersonalDirectory: aString aString ifNil: [^ self]. directory := origDirectory, '/', self pathToUserAccount, aString. altURL := server, directory. ! ! !EToyProjectDetailsMorph methodsFor: 'project details' stamp: 'yo 9/11/2009 19:53'! copyOutDetails "Prepare a new Dictionary holding project-info details as noted in the dialog." | newDetails elements item user | newDetails := Dictionary new. self fieldToDetailsMappings do: [ :each | namedFields at: each first ifPresent: [ :field | (#('age' 'subject' 'region') includes: each first) ifFalse: [newDetails at: each second put: field contents string] ifTrue: [elements := self choicesFor: each first. "triplet" item := elements detect: [:el | el third = field contents string translated] ifNone: [nil]. item ifNotNil: [newDetails at: each second put: item first]]]]. namedFields at: 'projectname' ifPresent: [ :field | newDetails at: 'projectname' put: field contents string withBlanksTrimmed]. namedFields at: 'author' ifPresent: [:field | user := field contents string withBlanksTrimmed. newDetails at: 'projectauthor' put: user. user isEmpty ifTrue: [user := nil]. theProject ifNotNil: [theProject forgetExistingURL]]. ^ newDetails! ! !EtoyDAVLoginMorph methodsFor: 'private' stamp: 'yo 9/11/2009 19:17'! loginAndDo: aBlock ifCanceled: cb "EtoyDAVLoginMorph loginAndDo:[:n :p | true] ifCanceled:[]" self name: '' actionBlock: aBlock cancelBlock: cb; fullBounds; position: Display extent - self extent // 2. self position: self position + (0@40). ActiveWorld addMorphInLayer: self! ! !EtoyDAVLoginMorph class methodsFor: 'instance creation' stamp: 'yo 9/11/2009 19:18'! loginAndDo: aBlock ifCanceled: cancelBlock "EtoyDAVLoginMorph loginAndDo:[:n :p | true] ifCanceled:[]" | | self new loginAndDo: aBlock ifCanceled: cancelBlock. ! ! !FileList2 methodsFor: 'private' stamp: 'yo 9/11/2009 17:55'! directoryNamesFor: item "item may be file directory or server directory" | entries | entries _ [item directoryNames] on: LoginFailedException do: [:ex | self loginHit. ^ #()]. dirSelectionBlock ifNotNil:[entries _ entries select: dirSelectionBlock]. ^entries! ! !FileList2 methodsFor: 'private' stamp: 'yo 9/11/2009 19:56'! loginHit | s failed ret | loginDialog ifNotNil: [^ false]. s := ServerDirectory servers at: 'My Squeakland' ifAbsent: [^ false]. failed := [Utilities loggedIn: false. loginDialog := nil. s user: nil]. ret := true. loginDialog := EtoyDAVLoginMorph new. loginDialog loginAndDo: [:n :p | s ifNotNil: [ s user: n. s password: p. [s copy createPersonalDirectory: n] on: ProtocolClientError do: [:ex | "either directory already exists or could not create. Here, it is just eaten as the following test will tell us whether it can be read."]. [s entries] on: LoginFailedException do: [:ex | failed value. self inform: 'Login failed.'. ret := false]. ret ifTrue: [Utilities authorName: n. Utilities loggedIn: true]]. self updateLoginButtonAppearance. Utilities loggedIn ifTrue: [ self directory: directory. brevityState := #FileList. "self addPath: path." self changed: #fileList. self changed: #contents. self changed: #currentDirectorySelected]. loginDialog := nil. true. ] ifCanceled: failed. ! ! !FileList2 methodsFor: 'private' stamp: 'yo 9/11/2009 17:14'! updateLoginButtonAppearance | old oldField | old := loginButton. oldField := loginField. loginField := Morph new color: Color white. loginField borderWidth: 2. loginField borderColor: ScriptingSystem baseColor. loginField beSticky. loginField width: 150. loginField height: 30. loginField clipSubmorphs: true. Utilities loggedIn ifTrue: [ loginButton := self class buildButtonText: 'Logout' translated balloonText: nil receiver: self selector: #logoutHit. loginButton color: ScriptingSystem baseColor. loginField addMorphCentered: (StringMorph contents: (Utilities authorNamePerSe ifNil: ['(not logged in)']) font: Preferences standardEToysButtonFont). loginButton setBalloonText: 'Log out from the Squeakland server' translated. loginField setBalloonText: 'Your Squeakland user name' translated. ] ifFalse: [ loginButton := self class buildButtonText: 'Login' translated balloonText: nil receiver: self selector: #loginHit. loginButton color: ScriptingSystem baseColor. loginField addMorphCentered: (StringMorph contents: '(not logged in)' font: Preferences standardEToysButtonFont). loginButton setBalloonText: 'Log in to share projects on the Squeakland server' translated. loginField setBalloonText: 'Your Squeakland user name' translated ]. loginButton setNamePropertyTo: 'login'. loginButton width: 150. old ifNotNil: [ old owner addMorph: loginButton inFrontOf: old. old delete]. oldField ifNotNil: [ oldField owner addMorph: loginField inFrontOf: oldField. oldField delete]. ! ! !FileList2 class methodsFor: 'blue ui' stamp: 'yo 9/11/2009 17:12'! buildLoadButtons: window fileList: aFileList reallyLoad: aBoolean | aRow okButton cancelButton | okButton := self buildButtonText: 'OK' translated balloonText: nil receiver: aFileList selector: (aBoolean ifTrue: [#okHitForProjectLoader] ifFalse: [#okHit]). okButton width: 150. cancelButton := self buildButtonText: 'Cancel' translated balloonText: nil receiver: aFileList selector: #cancelHit. cancelButton width: 150. aFileList updateLoginButtonAppearance. aRow := window addARow: {aFileList loginButton. aFileList loginField. okButton. cancelButton}. aRow color: ScriptingSystem paneColor. aRow listCentering: #bottomRight. aRow layoutInset: 3 @ 3. aRow cellInset: 6 @ 3. ^ aRow! ! !FileList2 class methodsFor: 'blue ui' stamp: 'yo 9/11/2009 17:12'! buildSaveButtons: window fileList: aFileList | buttonData buttons aRow | buttonData := Preferences enableLocalSave ifTrue: [#(#('Save' #okHit 'Save in the place specified above') #('Save on local disk only' #saveLocalOnlyHit 'saves in the Squeaklets folder') #('Cancel' #cancelHit 'return without saving') ) translatedNoop] ifFalse: [#(#('Save' #okHit 'Save in the place specified above') #('Cancel' #cancelHit 'return without saving') ) translatedNoop]. buttons := buttonData collect: [:each | self buildButtonText: each first translated balloonText: each third translated receiver: aFileList selector: each second]. aFileList updateLoginButtonAppearance. buttons := {aFileList loginButton. aFileList loginField. Morph new color: Color transparent; width: 50}, buttons. aRow := window addARow: buttons. aRow color: ScriptingSystem paneColor. aRow listCentering: #bottomRight. aRow layoutInset: 3 @ 3. aRow cellInset: 6 @ 3. ^ aRow! ! FileList subclass: #FileList2 instanceVariableNames: 'showDirsInFileList currentDirectorySelected fileSelectionBlock dirSelectionBlock optionalButtonSpecs modalView directoryChangeBlock ok loginButton loginField loginDialog' classVariableNames: '' poolDictionaries: '' category: 'Tools-FileList'! "Postscript: Leave the line above, and replace the rest of this comment by a useful one. Executable statements should follow this comment, and should be separated by periods, with no exclamation points (!!). Be sure to put any further comments in double-quotes, like this one." ReleaseBuilderSqueakland new setupServerDirectoryForSqueakland. !