JimmyD JimmyD - 4 years ago 95
Java Question

How to inject objects in custom object

I'm implementing a update function that will use a server response to handle the update. Now my update need to ask the user (in a dialog) to restart the application. The only injection I can do in the class is the IEclipseContext.

Now how can I get the UISynchronize of the current running Eclipse RCP application? So that I safely can run this method:

private void showMessage(UISynchronize sync, final String message) {
sync.syncExec(new Runnable() {

public void run() {
MessageDialog.openInformation(null, "Information", message);

Answer Source

UISynchronize is in the application IEclipseContext so it will be available in any context except the OSGi services context.

All that UISynchronize does is call Display.asyncExec so if you haven't got a context available just use the traditional

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download