[Q] Help on using Services

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Q] Help on using Services

Edgar J. De Cleene
Folks:

I like export objects and loading again in the same Squeak .image or in
another which could understand it.
So I try to have a Service for it and have this (from older Squeaks)

!Object class methodsFor: 'objects from disk' stamp: 'edc 2/14/2008 08:19'!
readAndInspect: inputStream
(inputStream fileInObjectAndCode ) inspect! !

!Object class methodsFor: '*services-extras' stamp: 'edc 2/14/2008 08:45'!
fileReaderServicesForFile: fullName suffix: suffix
    | services |
    services _ OrderedCollection new.
   
    (fullName asLowercase endsWith: '.obj')
        ifTrue: [ services add: self serviceLoadObject ].
    ^services! !

!Object class methodsFor: '*services-extras' stamp: 'edc 2/14/2008 09:04'!
registeredServices
    ^ {
    Service new
        label: 'Open saved objects';
        shortLabel: 'object';
        description: 'load back saved object ';
        action: [:stream | self readAndInspect: (FileStream
oldFileOrNoneNamed:stream name)];
        shortcut: nil;
        categories: Service worldServiceCat}! !

!Object class methodsFor: '*services-extras' stamp: 'edc 2/14/2008 08:49'!
serviceLoadObject
"Answer a service for opening a saved Object"

    ^ (SimpleServiceEntry
        provider: self
        label: 'saved Object'
        selector: #readAndInspect:)
       
        buttonLabel: 'Object';
        argumentGetter: [:fileList | fileList readOnlyStream]! !
       




Works, but I have two "Object" buttons on FileList.

What I doing wrong ?

Very thanks in advance.

Edgar