Eclipse E4 Notes

1. What is Eclipse e4?

Eclipse e4 is the next generation platform to simplify the Eclipse programming model. It provides lot of new features. Some of them are

1. Application is defined as EMF model which can be modified at run time.

2. The model can be extended by other plug-ins.

3. Dependency injection(DI) – Objects can be injected using dependency injection and It uses EclipseContext hierarchy to search for an object. This design allows to reduce the line of code considerably, For example we can store domain model in eclipse context and using DI we can get these objects in UI and business logic.

4. New renderer can be used as presentation engine. In eclipse 3.x versions, SWT/JFace is used as default presentation toolkit.  But using this new presentation engine, UI is defined as EMF Model and different UI kits can be used as renderer. So we can use swings, JavaFx, QT tool kits as presentation engines.  Existing swing applications can be ported on e4 platform using this design. These applications can enjoy the additional benefits of osgi plugin model. Kai has demonstrated this one in http://www.toedter.com/blog/?p=709

5. Eclipse Juno is based on this e4 platform and future Eclipse releases will be based on this platform.

2. what are all the advantages of using e4 with swing application?

Existing java swing applications can be ported on E4 platform and can enjoy the benefits of e4 platform. ( Plugins, modularity, dependency injection and lot of ready made osgi bundles).

3. How to create an instance using dependency injection?

1. get the IEclipseContext

2. Make the instance using ContextInjectionFactory.make method

example to create the NavigatorPart UI

IEclipseContext context  = …

ContextInjectionFactory.make(NavigatorPart.class, context);

4. How to get the IEclipseContext

From Application model Object : if the model object implements MContext ( MPart, MWindow, MApplication,MPerspective), then we can use

IEclipseContext context  = context.getContext();

From OSGI Bundle:

Bundle bundle = Framework.getBundle(this.getClass());

BundleContext bc = bundle.getBundleContext();

IEclipseContext ecContext = EclipseContextFactory.getServiceContext(bc);

ContextInjectionFactory.make(NavigatorPart.class, ecContext);

5. How to create child eclipse context?

1. using the exisiting context

If the object is managed by eclipse context, we can get it

@Inject

public void createContext(IEclipseContext parent){

parent.createChild();

or

parent.createChild(String name);

}

2. Create separate and attach it with parent

IEcliseContext child = EclipseContextFactory.create();

child.setParent(child);

Advertisements
This entry was posted in Eclipse and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s