【问题标题】:How to display gef editor?如何显示gef编辑器?
【发布时间】:2014-12-01 07:02:42
【问题描述】:

我正在尝试使用 GEF 在 RCP 中显示和编辑流程图。我使用GraphicalEditorWithFlyoutPalette 作为我的编辑查看互联网上的各种示例。在所有这些示例中,我没有找到关于如何在我的 RCP 应用程序首次启动时显示此编辑器的提示。以前我使用 ViewPart 来显示流程图并且效果很好。现在我很震惊,不知道如何在我设计的编辑器上打开它。

【问题讨论】:

  • 您可以使用启动扩展点打开编辑器:stackoverflow.com/a/21660164/2670892
  • 这是否相当于 ViewPart 的 showView 方法?或如何以编程方式打开GraphicalEditor

标签: eclipse-rcp eclipse-gef


【解决方案1】:

IDE 类有几种打开编辑器的方法,例如:

IFile file = ... file you want to open

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

IEditorInput input = new FileEditorInput(file);

IDE.openEditor(page, input, "editor id");

您可以使用 org.eclipse.ui.startup 扩展点在 Eclipse 启动的早期运行代码,但上面的代码不会在启动的早期运行。但是您可以安排UIJob 来运行代码:

@Override
public void earlyStartup()
{
  new StartJob().schedule();
}


class StartJob extends UIJob
{
  public StartJob()
  {
    super("Start Job");
  }

  @Override
  public IStatus runInUIThread(final IProgressMonitor monitor)
  {
    .. open editor code   

    return Status.OK_STATUS;
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-29
    • 1970-01-01
    • 1970-01-01
    • 2014-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多