Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] Dynamic Eclipse 4 with Clojure language

On Thu, Nov 21, 2013 at 10:00 AM, Laurent PETIT <laurent.petit@xxxxxxxxx> wrote:
Hello,

I'm Laurent Petit, main developer of Counterclockwise, the open source Clojure Plugin for Eclipse.

Hi Laurent,

I love your work :-)
 
So I'm currently experimenting with an interactive Clojure Console to modify the Model on the fly.
I've been successful in getting parts from the IEclipseContext, and from them creating parts via MBasicFactory, etc.

What version of eclipse are you targetting?  If you are targetting Kepler and beyond, you can use org.eclipse.e4.ui.workbench.modeling.EModelService.createModelElement(Class<T>) to create model elements instead of tracking down each individual EMF Factory.  If you need to support Juno as well, though, then you are correct to use the factories.
 

My current problem is the apparent requirement for implementing Handlers to :
- have the classes pre-compiled (as opposed to being dynamically created via in-memory bytecode generation as Clojure does). I'm thinking this because of the required "class URI".

AFAICT for handlers we use the class URI if the contribution object has not yet been instantiated.  If you create an instance from your class and call MHandler.setObject(theInstance) then set the URI to a string that provides a default failover NO-OP class just in case.


There's also the runtime EHandlerService system.  You can associate an handler instance object with a command using org.eclipse.e4.core.commands.EHandlerService.activateHandler(String, Object) and bypassing the model completely.  This might be the way to go since if you add MHandler objects to the model, they'll be persisted (and how do you re-create the dynamic classes on the next startup?  Not impossible, but you'd probably have to do extra work to save other information in the model).

 
- use @Execute annotation instead of implementing an interface.

If you're generating the bytes for your classes on the fly, can you simply insert the runtime bytes for @Execute and @CanExecute in front of those methods (I'm not that familiar with byte code generation)?

Let us know how it goes.

Later,
Paul


--
Paul Webster
Hi floor.  Make me a sammich! - GIR

Back to the top