You, sir, are a genius!  Seriously, thanks very much - I thought I had tried that first, but obviously nott.  I was afraid I had ran across a limitation.  Whew!

Thanks again,
Mark.
----------------------------------------------------------



Jeff Emanuel <jemanuel@frii.com>

01/06/2006 06:48 PM

To
Mark_Melvin@amis.com
cc
Subject
Re: [Jython-users] How to get reference to <someInterface>.class?





Pass ICommandService instead of ICommandService.__class__.

Mark_Melvin@amis.com wrote:
> My last email was too big with the embedded graphic so I am re-sending...
>
> __________________
>
> I am using Jython with Eclipse, and I am stuck on something.  Eclipse uses
> the notion of 'getAdapter()' a lot.  I'll give you an example:
>
> One way this method is used is in the Workbench class as follows:
>
> final Map services = new HashMap();
> .
> .
> commandManager = new CommandManager();
> final CommandService commandService = new CommandService(commandManager);
> services.put(ICommandService.class, commandService);
>
> public final Object getAdapter(final Class key) {
>         return services.get(key);
> }
>
> Now, when you call getAdapter() with ICommandService.class as the
> argument, you should get the cached commandService object back.  But it
> doesn't seem to work from Jython.  My Jython code is as follows:
>
> from org.eclipse.ui.commands import ICommandService
>
> wb = PlatformUI.getWorkbench().getInstance()
> if wb is not None:
>         cs = wb.getAdapter(ICommandService.__class__)
>         print cs
>
> I always get None back in the cs variable because, while
> ICommandService.__class__ in Jython gives me a valid instance of
> java.lang.Class - it is clearly not the same instance stored in Eclipse as
> I can see in my debugger.
>
> In Java the cached interface is:
>
> Class<T> (org.eclipse.ui.commands.ICommandService) (id=119)
>
> And in Jython it is:
>
> Class<T> (java.lang.Class) (id=110)
>
>
> What am I doing wrong here?  How to I get a reference to the actual raw
> "interface" ICommandService?
>
> Thanks in advance,
> Mark.
> ----------------------------------------------------------