As you can read on the "News and Noteworthy" of Eclipse 3.3M4 a new Application Model is introduced. Eclipse now implements the Application Admin Service from the OSGi specification.
When building RCP applications with Eclipse that means that the old IPlatformRunnable interface is deprecated and you should now use org.eclipse.equinox.app.IApplication. Instead of run() we should now provide a start() and stop() method.
To fix your main RCP plugin you may want to change your application class to
look like this:
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
/**
* This class controls all aspects of the application's execution
*/
public class Application implements IApplication {
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
*/
public Object start(IApplicationContext context) throws Exception {
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display,
new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#stop()
*/
public void stop() {
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench == null)
return;
final Display display = workbench.getDisplay();
display.syncExec(new Runnable() {
public void run() {
if (!display.isDisposed())
workbench.close();
}
});
}
}
Hi,
ReplyDeleteI currently using the Eclipse 3.3M5 and i would like to get the program arguments.
With the previous version of Eclipse 3.2.1 i used the code below :
public class PlatformRunnable implements IPlatformRunnable {
public Object run(Object args) throws Exception {
String[] myVar = (String[])args;
...
}
}
If my RCP application was launched like this eclipse.exe temp second, i was getting the parameters temp and second.
Now with the Eclipse 3.3 version i'm using IApplication instead of IPlatformRunnable like in your example.
I'm getting the program arguments thanks to the IApplicationContext parameter from the start method. However i'm receiving a set of strange strings which are -launcher d:\Eclipse\eclipse -name Eclipse 600 temp second. Only the two last parameters are significants.
How do you get only the true paramters? In fact how do you have the same behavior like in the Eclipse 3.2 version.
Thanks a lot
For me it works ...
ReplyDeleteprotected String[] arguments;
public Object start(IApplicationContext context) throws Exception {
arguments = (String[]) context.getArguments().get("application.args");
...
}
Have fun,
Klaus
For me it works ...
ReplyDeletepublic Object start(IApplicationContext context) throws Exception {
String[] arguments = (String[]) context.getArguments().get("application.args");
...
}
Have fun,
wiedkla