我们在运行Eclipse平台是,每次都要启动ecipse的工作台,非常占资源,而且启动速度较慢。我们可以将它做成RCP应用程序。以解决这个问题。
其实RCP应用程序并不难。接下来我们就制作一个简单的RCP程序,我们在这里制作的RCP应用程序,是最简单的,它不含有任何信息,只是一个空界面。
首先,我们需要选择扩展,我们对org.eclipse.core.runtime.applications进行扩展设置该扩展点的id,添加子类application 设置它的class,这里是RCPApplication。之后我们要编写两个类。
下面是部分代码:
public class RCPApplication implements IPlatformRunnable {
public Object run(Object args) throws Exception {
WorkbenchAdvisor workbenchAdvisor = new RCPWorkbenchAdvisor();
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
if (returnCode == PlatformUI.RETURN_RESTART) {
return IPlatformRunnable.EXIT_RESTART;
} else
return IPlatformRunnable.EXIT_OK;
} finally {
display.dispose();
}
}
}
|
public class RCPWorkbenchAdvisor extends WorkbenchAdvisor {
public String getInitialWindowPerspectiveId() {
return null;
}
}
|
这样我们就可以运新我们的程序了
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}