Hi all,
I just tried to figure out how to use the service browser and got pretty throughly stumped. The lack of concrete examples is hindering my understanding of the documentation. Which though copious is to me somewhat dense. (Or maybe I am somewhat dense to it.) I tried playing with the create new service in a browser method menu. It asks for a service identifier and then a selector. Since it doesn't suggest what would be a good choice I am at sea. And keep running into error messages. I need something that lets me start of dumb and get smarter. This seems to prerequire you know what your doing. Which is a shame since it looks like it might be clever and useful. For me a couple of use cases and examples of running thru the dialogs will probably set me on the right path. Does anyone know where I can find some? Can anyone direct me to useful sources of help? Yours in curiosity, -- Jerome Peace __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
Hi Peace,
Take a look at: World Menu->Preferences & Services->Help on Services Romain put a little documentation on services there On 9/13/06, Peace Jerome <[hidden email]> wrote: > Hi all, > > I just tried to figure out how to use the service > browser and got pretty throughly stumped. > > The lack of concrete examples is hindering my > understanding of the documentation. Which though > copious is to me somewhat dense. (Or maybe I am > somewhat dense to it.) > > I tried playing with the create new service in a > browser method menu. It asks for a service identifier > and then a selector. > > Since it doesn't suggest what would be a good choice I > am at sea. And keep running into error messages. > > I need something that lets me start of dumb and get > smarter. This seems to prerequire you know what your > doing. Which is a shame since it looks like it might > be clever and useful. > > For me a couple of use cases and examples of running > thru the dialogs will probably set me on the right > path. Does anyone know where I can find some? > > Can anyone direct me to useful sources of help? > > Yours in curiosity, -- Jerome Peace > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > |
Hi Jerome, The framework is looking for services in subclasses of ServiceProvider. Each service has an identifier which become the name of the method where the service is implemented. What 'create new service' does is to ask you for an identifier, and then looks for a ServiceProvider (possibly creating one), to implement the method template at the right place. Then you use the service browser to define where your service should appear, and if you want to bind it to a keyboard shortcut. If you want to have it in the class menu of the browser, append the name of your service to the content of the 'items in browserClassMenu' preference. If you want to bind it to ctrl-2, put it in the 'ctrl-2' preference. As Diego said, there are more details in the world menu help item. Hope it helps, Romain Il giorno Sep 14, 2006, alle ore 3:20 AM, Diego Fernandez ha scritto:
-- Romain Robbes |
In reply to this post by Jerome Peace
Hi Edgar,
This starts to help. I need an example that goes just a little slower than this. I need it to start with the user story. Something like... What I would like to do is: have a menu item that when I select it does... it must appear in the ... menu and no others it should say... So to get this to happen using services you do this here and that there and test it by doing x. My difficulty is that the service stuff is introducing new language to allow me to do what I used to do by modifing menu methods. I am having trouble thinking in the service language. And I want some way to link what I know to what I need to understand. If you can add the story part to your example I think that would help. Thanks amigo, -- Jer --- "Lic. Edgar J. De Cleene" <[hidden email]> wrote: > Peace Jerome puso en su mail : > > > Hi all, > > > > I just tried to figure out how to use the service > > browser and got pretty throughly stumped. > > > > I need something that lets me start of dumb and > get > > smarter. > > > > For me a couple of use cases and examples of > running > > thru the dialogs will probably set me on the right > > path. Does anyone know where I can find some? > > > > Can anyone direct me to useful sources of help? > > > > Yours in curiosity, -- Jerome Peace > Jerome; > This was for SqueakLight, but should be similar in > 3.9 > > Adding Services > The example is for class MiStack > > > initialize > " MiStack initialize" > FileList registerFileReader: self. > > > This method should be adecuated to service > > > registeredServices > ^ { > Service new > label: 'Open saved SqueakBook'; > shortLabel: 'SqueakBook'; > description: 'load back saved notes '; > action: [:stream | self reloadMeFromDisk: > ((RWBinaryOrTextStream > with: stream contents asString)reset)]; > shortcut: nil; > categories: Service worldServiceCat.} > > > This is for in FileList you could select and load > > fileReaderServicesForFile: fullName suffix: suffix > | services | > services _ OrderedCollection new. > > (fullName asLowercase endsWith: '.shc') > ifTrue: [ services add: self > serviceLoadSqueakBook ]. > ^services > > > > serviceLoadSqueakBook > "Answer a service for opening a saved SqueakBook" > > ^ (SimpleServiceEntry > provider: self > label: 'saved SqueakBook' > selector: #reloadMeFromDisk: > description: 'open a SqueakBook' > buttonLabel: 'SqueakBook') > argumentGetter: [:fileList | fileList > readOnlyStream] > > > Hope this helps. > > Edgar > > > > > > > __________________________________________________ > Preguntá. Respondé. Descubrí. > Todo lo que querías saber, y lo que ni imaginabas, > está en Yahoo! Respuestas (Beta). > ¡Probalo ya! > http://www.yahoo.com.ar/respuestas > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
Hi Jerome, Il giorno Sep 15, 2006, alle ore 7:16 AM, Peace Jerome ha scritto:
If you are using Squeak 3.9, the framework has changed, so Edgar's approach no longer works.
Let's say your menu item tells you the name of the class which is currently selected in your browser, but reversed (this is extremely useful):
in that case, it can appear in the browser class menu
Supposing this function is needed for your package Foo: You already have a class named ClassReverser in Foo, with a method: reverseClass: aClass self inform: (aClass name reversed) To do that with services: You find this method in a browser, and select the 'create new service' in the method menu. This item asks you for the name of the service. You can call it 'reverseClass' (without quotes). Services will create for you a FooServiceProvider class, a method category named 'services' in it, and compile the following method for you: reverseClass ^ ServiceAction text: 'you should fill me' button: 'fill me' description: 'fill me with a longer text' action: [:r | "Actual action to to"] condition: [:r | "condition to enable/disable the service (must return a boolean"] which you can now modify to have: reverseClass ^ ServiceAction text: 'reverse class name' button: 'reverse' description: 'Show the name of the current select class, but reversed' action: [:r | ClassReverser new reverseClass: r getClass] condition: [:r | true] The argument of the block is an intance of (in this case) BrowserRequestor, which implements methods to get information from a browser. You can either enter a fancier condition for the block, or drop the last keyword altogether (using only text:button:description:action:). Now your service is defined, we just have to put it in the right place: Open the Services Browser (World menu > preferences & services > services browser). You have several categories in the left panel. Since you want to add your service to the browser, you can select the 'BrowserProvider' category. In it there should be a text field with the caption 'Items in browserClassMenu'. To add you service there, you need to append the name of your service to the contents of this field. 'foo bar' -> ''foo bar reverseClass' changing the order of the items will change the order in the menus. Hope it helps, Romain
-- Romain Robbes |
If you are using Squeak 3.9, the framework has changed, so Edgar's approach no longer works. Romain: Your framework is wonderful and the provided example very good!!. I afraid I stealing all good ideas from 3.9 and try to have in SqueakLight. I should made some compromises so I start using some old code from you at this time. So Jerome, I hope you don’t feel disappointed one more time, but I try harder on improve all. Edgar |
In reply to this post by Romain Robbes
romain
why do we need to create a class > Services will create for you a FooServiceProvider class, a method > category named 'services' in it, and compile the following method > for you: > > stef > |
This way all the functionality you wish to export via services is regrouped in a service provider, rather than scattered in class methods as it was in the previous design. Each service provider implements methods returning the ServiceAction objects it wishes to define, and also act as a placeholder for the preferences that are set through the UI. Then the framework has only to search in subclasses of ServiceProvider to find all the services defined in the system. Romain Il giorno Sep 15, 2006, alle ore 5:50 PM, stephane ducasse ha scritto:
-- Romain Robbes |
On 15 sept. 06, at 18:51, Romain Robbes wrote: > > This way all the functionality you wish to export via services is > regrouped in a service provider, rather than scattered in class > methods as it was in the previous design. Ok we can define the class we want I guess (in your example you used a convenient method is it correct?) > > Each service provider implements methods returning the > ServiceAction objects it wishes to define, and also act as a > placeholder for the preferences that are set through the UI. > > Then the framework has only to search in subclasses of > ServiceProvider to find all the services defined in the system. > > Romain > > Il giorno Sep 15, 2006, alle ore 5:50 PM, stephane ducasse ha scritto: > >> romain >> >> why do we need to create a class >> >>> Services will create for you a FooServiceProvider class, a method >>> category named 'services' in it, and compile the following method >>> for you: >>> >>> >> >> stef >> >>> >> >> > > -- > Romain Robbes > http://romain.robb.es > > > > |
Il giorno Sep 15, 2006, alle ore 7:45 PM, stephane ducasse ha scritto:
Yes, the service which automates the task uses a default name which is the name of the package, but you can always do that step manually. You just have to make sure to make it a subclass of ServiceProvider.
-- Romain Robbes |
Free forum by Nabble | Edit this page |