Patrick Rein uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-pre.232.mcz ==================== Summary ==================== Name: Network-pre.232 Author: pre Time: 24 April 2019, 4:20:02.674678 pm UUID: 17eda7a7-5862-8b44-8b69-af531de862ef Ancestors: Network-tpr.231 Improves the MailComposition dialog to show whether the sending is in progress. Adapts the new sending interface internally. Refactors the creation of specs to allow for easier extension by subclasses. =============== Diff against Network-tpr.231 =============== Item was changed: Model subclass: #MailComposition + instanceVariableNames: 'mailMessage isSending' - instanceVariableNames: 'mailMessage' classVariableNames: '' poolDictionaries: '' category: 'Network-MailSending'! !MailComposition commentStamp: 'pre 5/16/2017 20:00' prior: 0! a message being composed in a fancy way. The mail is send via the registered MailSender by default. Fields do not have to be saved, they are saved automatically on send. ! Item was changed: ----- Method: MailComposition class>>open (in category 'opening') ----- open ^ ToolBuilder default open: self! Item was changed: ----- Method: MailComposition class>>openOn: (in category 'opening') ----- openOn: aMessage ^ ToolBuilder default open: (self new on: aMessage; yourself)! Item was added: + ----- Method: MailComposition>>addAttachment:named: (in category 'private') ----- + addAttachment: stream named: attachmentName + + stream binary. + mailMessage + addAttachmentFrom: stream + withName: attachmentName! Item was changed: ----- Method: MailComposition>>buildButtonBarSpecWith: (in category 'toolbuilder') ----- buildButtonBarSpecWith: aBuilder | buttonBarSpec | buttonBarSpec := aBuilder pluggablePanelSpec new children: OrderedCollection new; layout: #horizontal; frame: (LayoutFrame new leftFraction: 0 offset: 0; topFraction: 0 offset: 0; rightFraction: 1 offset: 0; bottomFraction: 0 offset: self buttonBarHeight); yourself. buttonBarSpec children add: (aBuilder pluggableButtonSpec new model: self; action: #sendMail; label: #sendMailButtonLabel; + color: #sendMailButtonColor; yourself). buttonBarSpec children add: (aBuilder pluggableButtonSpec new model: self; action: #addAttachment; label: #addAttachmentButtonLabel; yourself). buttonBarSpec children add: (aBuilder pluggableButtonSpec new model: self; action: #removeAttachment; label: #removeAttachmentButtonLabel; yourself). ^ buttonBarSpec! Item was changed: ----- Method: MailComposition>>buildWith: (in category 'toolbuilder') ----- buildWith: aBuilder + | spec | - | windowSpec detailsPanelSpec textSpec | + spec := self createSpecsWith: aBuilder. - windowSpec := aBuilder pluggableWindowSpec new - model: self; - label: self dialogTitle; - children: OrderedCollection new. - - windowSpec children add: (self buildButtonBarSpecWith: aBuilder). - - detailsPanelSpec := aBuilder pluggablePanelSpec new - children: OrderedCollection new; - layout: #vertical; - yourself. - windowSpec children add: detailsPanelSpec. + ^ aBuilder build: spec! - self createDetailsFieldsIn: detailsPanelSpec by: aBuilder. - - detailsPanelSpec children: detailsPanelSpec children reversed. - detailsPanelSpec frame: (LayoutFrame new - leftFraction: 0 offset: 0; - topFraction: 0 offset: self buttonBarHeight; - rightFraction: 1 offset: 0; - bottomFraction: 0 offset: self buttonBarHeight + (detailsPanelSpec children size * self lineHeight)). - - textSpec := aBuilder pluggableTextSpec new - model: self; - indicateUnacceptedChanges: true; - getText: #messageText; - setText: #messageText:; - frame: (LayoutFrame new - leftFraction: 0 offset: 0; - topFraction: 0 offset: self buttonBarHeight + (detailsPanelSpec children size * self lineHeight); - rightFraction: 1 offset: 0; - bottomFraction: 1 offset: 0); - yourself. - windowSpec children add: textSpec. - - ^ aBuilder build: windowSpec! Item was changed: ----- Method: MailComposition>>createFieldInputNamed:getter:setter:with: (in category 'toolbuilder') ----- createFieldInputNamed: fieldLabelGetter getter: fieldGetter setter: fieldSetter with: aBuilder ^ aBuilder pluggableInputFieldSpec new model: self; indicateUnacceptedChanges: false; getText: fieldGetter; setText: fieldSetter; + name: fieldGetter; frame: (LayoutFrame new leftFraction: 0 offset: 0; topFraction: 0 offset: 0; rightFraction: 1 offset: 0; bottomFraction: 0 offset: self lineHeight); help: fieldLabelGetter; yourself! Item was added: + ----- Method: MailComposition>>createSpecsWith: (in category 'toolbuilder') ----- + createSpecsWith: aBuilder + + | detailsPanelSpec textSpec windowSpec | + windowSpec := self createWindowSpecWith: aBuilder. + windowSpec children add: (self buildButtonBarSpecWith: aBuilder). + + detailsPanelSpec := aBuilder pluggablePanelSpec new + children: OrderedCollection new; + layout: #vertical; + yourself. + windowSpec children add: detailsPanelSpec. + + self createDetailsFieldsIn: detailsPanelSpec by: aBuilder. + + detailsPanelSpec children: detailsPanelSpec children reversed. + detailsPanelSpec frame: (LayoutFrame new + leftFraction: 0 offset: 0; + topFraction: 0 offset: self buttonBarHeight; + rightFraction: 1 offset: 0; + bottomFraction: 0 offset: self buttonBarHeight + (detailsPanelSpec children size * self lineHeight)). + + textSpec := aBuilder pluggableTextSpec new + model: self; + indicateUnacceptedChanges: true; + getText: #messageText; + setText: #messageText:; + name: #messageText; + frame: (LayoutFrame new + leftFraction: 0 offset: 0; + topFraction: 0 offset: self buttonBarHeight + (detailsPanelSpec children size * self lineHeight); + rightFraction: 1 offset: 0; + bottomFraction: 1 offset: 0); + yourself. + windowSpec children add: textSpec. + + ^ windowSpec! Item was added: + ----- Method: MailComposition>>createWindowSpecWith: (in category 'toolbuilder') ----- + createWindowSpecWith: aBuilder + + ^ aBuilder pluggableWindowSpec new + model: self; + label: #dialogTitle; + children: OrderedCollection new.! Item was changed: ----- Method: MailComposition>>doSendMail (in category 'private') ----- doSendMail (SMTPClient openOnHostNamed: self smtpServer port: self smtpServerPort) user: self smtpUser; password: self smtpPassword; login; + mailFrom: mailMessage from to: (mailMessage to findTokens: ',') text: mailMessage asSendableText.! - sendMailMessage: mailMessage! Item was changed: ----- Method: MailComposition>>initialize (in category 'initialize-release') ----- initialize + mailMessage := MailMessage empty. + isSending := false.! - mailMessage := MailMessage empty! Item was added: + ----- Method: MailComposition>>isSending (in category 'private') ----- + isSending + + ^ isSending! Item was added: + ----- Method: MailComposition>>resetSending (in category 'private') ----- + resetSending + + isSending := false. + self changed.! Item was changed: ----- Method: MailComposition>>sendMail (in category 'actions') ----- sendMail + self isSending ifFalse: [ + self saveFields. + + self setSending. - self saveFields. + [[self doSendMail] on: Error do: [:e | self resetSending. e signal]. + Project current addDeferredUIMessage: [self changed: #close].] + forkAt: 30. + + self + changed: #sendMailButtonLabel; + changed: #sendMailButtonColor]! - [self doSendMail. - Project current addDeferredUIMessage: [self changed: #close]] - forkAt: 30! Item was added: + ----- Method: MailComposition>>sendMailButtonColor (in category 'ui constants') ----- + sendMailButtonColor + + ^ self isSending + ifTrue: [Color green lighter duller] + ifFalse: [PluggableButtonMorph new userInterfaceTheme color]! Item was changed: ----- Method: MailComposition>>sendMailButtonLabel (in category 'ui constants') ----- sendMailButtonLabel + ^ (self isSending + ifTrue: ['sending...'] + ifFalse: ['send mail']) translated! - ^ 'send mail' translated! Item was added: + ----- Method: MailComposition>>setSending (in category 'private') ----- + setSending + + isSending := true.! |
Free forum by Nabble | Edit this page |