Eclipse, RCP, Plugin and OSGi Development

Eclipse 4.x vs Eclipse 3.x

Eclipse e4 RCP notes from

The major enhancements in Eclipse 4 compared to Eclipse 3.x are the following.

The Eclipse application is described via a defined structure called the application model This application model can be modified at development and runtime

This application model can be extended

Eclipse 4 supports dependency injection

Eclipse widgets can be styled via external CSS files, similar to webpages

The application model is decoupled from its presentation, e.g. different user interface toolkits such as SWT or JavaFX, can be used to render the model

notes from

The Eclipse Applciation Model

Eclipse lifecycle annotations for Parts

@PostConstruct Is called after the class is constructed and the field and method injection has been performed.

@PreDestroy Is called before the class is destroyed. Can be used to clean up resources.

@Focus Indicates that this method should be called, once the Part gets the focus. It is required to set the focus on one user interface control otherwise certain workbench functionality does not work.

@Persist Is called if a save request on the Part is triggered. Can be used to save the data of the Part.

@PersistState Is called before the model object is disposed, so that the Part can save its state.

@Execute Marks a method in a handler class to be executed. Only one method in a handler should be annotated with @Execute.

@CanExecute Marks a method to be visited by the Command- Framework to check if a handler is enabled.

@GroupUpdates Indicates that updates for this @Inject should be batched. If you change such objects in the IEclipseContext the update will be triggered by the processWaiting() method on IEclipseContext.

@EventTopic and @UIEventTopic Allows you to subscribe to events send by the EventAdmin service.

Lifecycle Hooks

@PostContextCreate Is called after the Application’s IEclipseContext is created, can be used to add objects, services, etc. to the context. This context is created for the MApplication class.

@ProcessAdditions Is called directly before the model is passed to the renderer, can be used to add additional elements to the model.

@ProcessRemovals Same as @ProcessAdditions but for removals.

@PreSave Is called before the application model is saved. You can modify the model before it is persisted.

Every Part needs to assign focus to one of its controls, otherwise certain services will not work.

@Focus private void setFocus() { label.setFocus(); }

Eclipse 4 does not include standard commands anymore. You have to define all your commands.