Christoph Thiede uploaded a new version of System to project The Inbox:
http://source.squeak.org/inbox/System-ct.1156.mcz ==================== Summary ==================== Name: System-ct.1156 Author: ct Time: 5 May 2020, 5:41:10.96399 pm UUID: 2ce2496e-92e9-f744-9a58-d9e9320adfab Ancestors: System-mt.1155 Fixes double prompt for handling a dropped file when the first dialog was cancelled. Cleans up duplication between ExternalDropHandler >> #lookupServiceBasedHandler: and DefaultExternalDropHandler by deprecating the first one. Maybe we can also remove this method? =============== Diff against System-mt.1155 =============== Item was changed: ----- Method: DefaultExternalDropHandler>>chooseServiceFrom: (in category 'private') ----- chooseServiceFrom: aCollection + "private - choose a service from aCollection asking the user if needed" + ^ aCollection size = 1 - "private - choose a service from aCollection asking the user if needed" - ^aCollection size = 1 ifTrue: [aCollection anyOne] + ifFalse: [UIManager default + chooseFrom: (aCollection collect: [:each | each label]) - ifFalse:[UIManager default - chooseFrom: (aCollection collect:[:each| each label]) values: aCollection title: 'You dropped a file. Please choose a service:' translated withCRs].! Item was changed: ----- Method: DefaultExternalDropHandler>>handle:in:dropEvent: (in category 'event handling') ----- handle: dropStream in: pasteUp dropEvent: anEvent "the file was just droped, let's do our job" | fileName services chosen | fileName := dropStream name. services := self servicesForFileNamed: fileName. + - "no service, default behavior" + services ifEmpty: [ + ^ UIManager default edit: dropStream contentsOfEntireFile]. + - services isEmpty - ifTrue: [^UIManager default edit: dropStream contentsOfEntireFile]. - chosen := self chooseServiceFrom: services. + chosen ifNotNil: [chosen performServiceFor: dropStream].! - chosen ifNotNil:[chosen performServiceFor: dropStream]! Item was changed: ----- Method: DefaultExternalDropHandler>>servicesForFileNamed: (in category 'private') ----- servicesForFileNamed: aString + "private - answer a collection of file-services for the file named aString" + + ^ (FileServices itemsForFile: aString) + copyWithoutAll: self unwantedSelectors! - "private - answer a collection of file-services for the file named - aString" - | allServices | - allServices := FileServices itemsForFile: aString. - ^ allServices - reject: [:svc | self unwantedSelectors includes: svc selector]! Item was changed: ----- Method: ExternalDropHandler class>>defaultHandler (in category 'accessing') ----- defaultHandler + + ^ DefaultHandler ifNil: [ + DefaultHandler := ExternalDropHandler + type: nil + extension: nil + action: #edit]! - DefaultHandler ifNil: [DefaultHandler := ExternalDropHandler type: nil extension: nil action: [:dropStream | dropStream edit]]. - ^DefaultHandler! Item was changed: ----- Method: ExternalDropHandler class>>lookupExternalDropHandler: (in category 'accessing') ----- lookupExternalDropHandler: stream | types extension serviceHandler | types := stream mimeTypes. types ifNotNil: [ + self registeredHandlers + detect: [:handler | handler matchesTypes: types] + ifFound: [:handler | ^ handler]]. - self registeredHandlers do: [:handler | - (handler matchesTypes: types) - ifTrue: [^handler]]]. extension := FileDirectory extensionFor: stream name. + self registeredHandlers + detect: [:handler | handler matchesExtension: extension] + ifFound: [:handler | ^ handler]. + + ^ serviceHandler ifNil: [self defaultHandler]! - self registeredHandlers do: [:handler | - (handler matchesExtension: extension) - ifTrue: [^handler]]. - serviceHandler := self lookupServiceBasedHandler: stream. - ^serviceHandler - ifNil: [self defaultHandler]! Item was changed: ----- Method: ExternalDropHandler class>>lookupServiceBasedHandler: (in category 'accessing') ----- lookupServiceBasedHandler: dropStream + - "The file was just dropped; let's do our job" | fileName services theOne | + self deprecated: 'ct: Use DefaultExternalDropHandler'. fileName := dropStream name. - services := (FileServices itemsForFile: fileName) reject: [:svc | self unwantedSelectors includes: svc selector]. + - "no service, default behavior" + services ifEmpty: [^ nil]. + - services isEmpty - ifTrue: [^nil]. - theOne := self chooseServiceFrom: services. + ^ theOne ifNotNil: [ + ExternalDropHandler type: nil extension: nil action: [:stream | theOne performServiceFor: stream]]! - ^theOne - ifNotNil: [ExternalDropHandler type: nil extension: nil action: [:stream | theOne performServiceFor: stream]]! |
I like the duplicate prompt. :-D Because the first is never at the position I acctually dropped the file. Only the second one is. Best, Marcel
|
Free forum by Nabble | Edit this page |