我们可以从单个Main类启动Eclipse RCP应用程序吗?

时间:2012-01-13 10:56:03

标签: class rcp main

我的问题是:我们可以通过包含public static void main(String x []){}方法的自定义Main.java启动Eclipse RCP应用程序来运行RCP应用程序吗?毫无疑问,RCP应用程序可以像往常一样在Eclipse中使用默认配置启动。

1 个答案:

答案 0 :(得分:1)

我不确定你想做什么,但如果你想在不运行整个RCP的情况下运行一些对话框/编辑器,你就可以做到。

例如,如果要打开表单/编辑器/首选项页面:

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    new YourFormPageFromEditor().createFormContent(shell); // or some kind of code that insert here some UI

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();

}

您可以按类型

打开的对话框
public static void main(String[] args) {    
  new YourDialogThatExtendsTitleAreaDialog(null).open()
}

希望它有所帮助。