[Setools] Ways to extends OB-Standard

Colin Putney cputney at wiresong.ca
Tue Oct 17 18:55:12 UTC 2006


On Oct 17, 2006, at 11:36 AM, Damien Cassou wrote:

> Hi,
>
> I'm working on two packages, each currently overriding an existing  
> method. Is there a solution to avoid this ?
>
> First Case : DynamicProtocols. It overrides  
> OBCodeBrowser>>addTo:class:comment:metaclass: adding a call to the  
> following method at the end:
>
> DynamicProtocols>>installDPOnClass: class metaClass: metaclass  
> method: method
> "Install our dynamic protocol system in OmniBrowser"
>   | protocols |
>   protocols := OBMetaNode named: 'DynamicProtocols'.
>   class childAt: #dynamicProtocols put: protocols.
>   metaclass childAt: #dynamicProtocols put: protocols.
>   protocols
>      childAt: #methods put: method;
>      addActor: (OBNodeActor onNodeClass: OBMethodCategoryNode)

Yeah, I haven't figured out a way to extend metagraphs  just yet, so  
this is the best way for now.

Note, however, that OBNodeActor is no longer needed on  
MethodCategoryNodes, since all the category operations have been  
rewritten as services.

> Second Case : FileOutClasses. This package just want to add 2  
> entries in the action menu for classes, methods and protocols. I  
> may be able to use services or prefix a method with 'svc' as I read  
> through your comments.

1. Create a subclass of OBService that implements the menu items you  
need. There are lots of examples of this in the latest versions of OB- 
Standard. You'll probably need 4 methods.

#label - answers a string to be used in the menu
#isActive - answers whether the service should appear in the menu
#isEnabled - if it answers false, the menu item will be greyed out
#execute - the menu item has been selected, so do the action

2. Extend OBCodeBrowser with a method that begins with 'svc' and  
answers your new service classes.

That's it. The next browser you open should have your new menu items.  
By the way, I've already done this for file out of classes, methods  
and categories. Do you have some other fileout mechanism in mind?

Note, however, that very shortly I'll be renaming 'service' to  
'command' so as not to be associated with Romains services work.

Colin



More information about the Setools mailing list