1
私はEclipseアプリケーションと製品構成を作成しました。RCPアプリケーションでプログラムの引数を読み取っていますか?
「起動」タブの製品構成では、「プログラム引数」と「VM引数」を指定できます。
これらの引数にはApplicationクラスからアクセスできますか?現在、このクラスは次のようになります。
public class Application implements IApplication {
@Override
public Object start(IApplicationContext context) throws Exception {
Map<?, ?> arguments = context.getArguments(); // this is empty!
// This actually does the trick but is a bit ugly - must be parsed
String[] strings = (String[]) context.getArguments()
.get("application.args");
Display display = PlatformUI.createDisplay();
try {
ApplicationWorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
int returnCode = PlatformUI.createAndRunWorkbench(display, advisor);
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
} else {
return IApplication.EXIT_OK;
}
} finally {
display.dispose();
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#stop()
*/
@Override
public void stop() {
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench == null) {
return;
}
final Display display = workbench.getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
if (!display.isDisposed()) {
workbench.close();
}
}
});
}
は、よりアプリケーションの引数を抽出するためのより良い方法があります。
// This actually does the trick but is a bit ugly
String[] strings = (String[]) context.getArguments()
.get("application.args");