'From Squeak3.5 of ''11 April 2003'' [latest update: #5180] on 8 April 2004 at 3:39:16 pm'! "Change Set: DefaultExternalDropHandler-dgd Date: 5 April 2004 Author: Diego Gomez Deck This changes provides a new default external drop handler that uses the FileList services to handle the file droped. Installing this ExternalDropHandler all the file-types registered in FileList become available when a file is droped in the Squeak windows. If only one service was elected, this is automatically executed, otherwise the user will be interrogated with the list of posible services via a menu. Really useful to stress the new drag&drop support in the Unix VM. -- Thanks Ian!! -- "! Object subclass: #DefaultExternalDropHandler instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'System-Support'! !DefaultExternalDropHandler commentStamp: 'dgd 4/5/2004 19:07' prior: 0! An alternative default handler that uses the file-list services to process files. ! !DefaultExternalDropHandler methodsFor: 'event handling' stamp: 'dgd 4/5/2004 20:55'! handle: dropStream in: pasteUp dropEvent: anEvent "the file was just droped, let's do our job" | fileName services theOne | fileName := dropStream name. "" services := self servicesForFileNamed: fileName. "" "no service, default behavior" services isEmpty ifTrue: ["" dropStream edit. ^ self]. "" theOne := self chooseServiceFrom: services. theOne isNil ifFalse: [theOne performServiceFor: dropStream name]! ! !DefaultExternalDropHandler methodsFor: 'private' stamp: 'dgd 4/5/2004 20:53'! chooseServiceFrom: aCollection "private - choose a service from aCollection asking the user if needed" | menu | aCollection size = 1 ifTrue: [^ aCollection anyOne]. "" menu := CustomMenu new. aCollection do: [:each | menu add: each label action: each]. ^ menu startUp! ! !DefaultExternalDropHandler methodsFor: 'private' stamp: 'dgd 4/5/2004 19:23'! servicesForFileNamed: aString "private - answer a collection of file-services for the file named aString" | allServices | allServices := FileList itemsForFile: aString. ^ allServices reject: [:svc | self unwantedSelectors includes: svc selector]! ! !DefaultExternalDropHandler methodsFor: 'private' stamp: 'dgd 4/5/2004 19:23'! unwantedSelectors "private - answer a collection well known unwanted selectors " ^ #(#removeLineFeeds: #addFileToNewZip: #compressFile: #putUpdate: )! ! !DefaultExternalDropHandler class methodsFor: 'class initialization' stamp: 'dgd 4/5/2004 19:10'! initialize "initialize the receiver" ExternalDropHandler defaultHandler: self new! ! !DefaultExternalDropHandler class methodsFor: 'class initialization' stamp: 'dgd 4/5/2004 19:09'! unload "initialize the receiver" ExternalDropHandler defaultHandler: nil! ! DefaultExternalDropHandler initialize! !DefaultExternalDropHandler class reorganize! ('class initialization' initialize unload) ! !DefaultExternalDropHandler reorganize! ('event handling' handle:in:dropEvent:) ('private' chooseServiceFrom: servicesForFileNamed: unwantedSelectors) !