Java 在Eclipse中如何从欢迎页面打开透视图,因为它';欢迎仪式下面有什么?

Java 在Eclipse中如何从欢迎页面打开透视图,因为它';欢迎仪式下面有什么?,java,eclipse,eclipse-plugin,eclipse-rcp,Java,Eclipse,Eclipse Plugin,Eclipse Rcp,根据,我已经实现了一个IIntroAction,它将从介绍页面在Eclipse中打开一个透视图(我的操作几乎完全相同) 我的与上面显示的稍有不同,但本质上它被调用(作为url)如下所示: http://org.eclipse.ui.intro/runAction?class=my.plugin.actions.OpenPerspectiveAction&pluginId=my.plugin&;pId=my.other.plugin.MyPerspective 其中pId是我要打开的

根据,我已经实现了一个IIntroAction,它将从介绍页面在Eclipse中打开一个透视图(我的操作几乎完全相同)

我的与上面显示的稍有不同,但本质上它被调用(作为url)如下所示:
http://org.eclipse.ui.intro/runAction?class=my.plugin.actions.OpenPerspectiveAction&pluginId=my.plugin&;pId=my.other.plugin.MyPerspective

其中pId是我要打开的透视图的id。(这很管用!…大多数时候。)

正如上面的链接中所述,此操作的问题在于,如果MyPerspective在欢迎页面下打开,那么它将不会打开(或者更确切地说,欢迎页面将不会关闭…)

我如何在操作调用时显示所需的透视图,即使它在欢迎页面下方打开

我探索的可能解决方案的一些途径(不完全如此,所以我可能错过了一些东西):

  • 使用PerspectiveRegistry做一些事情(尽管没有看到任何结果…)
  • 检查工作台以查看开放透视图是什么,并从中切换
  • 检查工作台以查看什么是开放透视图,以及它是否是所需的透视图

这些只是概念性的解决方案——我不知道它们是否真的可以实现!如果有人能告诉我如何解决这个问题,我将不胜感激。

以下代码在我的RCP项目中运行良好

介绍页面链接:

<a id="a-ism" href="http://org.eclipse.ui.intro/runAction?pluginId=sernet.gs.ui.rcp.main&#38;class=sernet.gs.ui.rcp.main.actions.ShowISMPerspectiveIntroAction">
动作基类:

import  org.eclipse.ui.intro.config.IIntroAction;

public abstract class ShowPerspectiveIntroAction implements IIntroAction {

  private static final Logger LOG = Logger.getLogger(ShowPerspectiveIntroAction.class);

  @Override
  public void run(IIntroSite arg0, Properties arg1) {
    // Switch to perspective
    final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IPerspectiveDescriptor activePerspective = workbenchWindow.getActivePage().getPerspective();
    if(activePerspective==null || !activePerspective.getId().equals(getPerspectiveId())) {           
        Display.getCurrent().asyncExec(new Runnable() {
            public void run() {
                // switch perspective           
                try {
                    workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(),workbenchWindow);
                } catch (WorkbenchException e) {
                    LOG.error("Can not switch to perspective: " + getPerspectiveId(), e);
                }
            }
        });
    }

    // close intro/welcome page
    final IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro(); 
    PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);

    // Show CheatSheet
    ShowCheatSheetAction action = new ShowCheatSheetAction("Show security assessment cheat sheet", getCheatSheetId());
    action.run();
  }

  public abstract String getCheatSheetId();
  public abstract String getPerspectiveId();
}

这比我以前做的要好得多。谢谢你的帮助!
import  org.eclipse.ui.intro.config.IIntroAction;

public abstract class ShowPerspectiveIntroAction implements IIntroAction {

  private static final Logger LOG = Logger.getLogger(ShowPerspectiveIntroAction.class);

  @Override
  public void run(IIntroSite arg0, Properties arg1) {
    // Switch to perspective
    final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IPerspectiveDescriptor activePerspective = workbenchWindow.getActivePage().getPerspective();
    if(activePerspective==null || !activePerspective.getId().equals(getPerspectiveId())) {           
        Display.getCurrent().asyncExec(new Runnable() {
            public void run() {
                // switch perspective           
                try {
                    workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(),workbenchWindow);
                } catch (WorkbenchException e) {
                    LOG.error("Can not switch to perspective: " + getPerspectiveId(), e);
                }
            }
        });
    }

    // close intro/welcome page
    final IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro(); 
    PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);

    // Show CheatSheet
    ShowCheatSheetAction action = new ShowCheatSheetAction("Show security assessment cheat sheet", getCheatSheetId());
    action.run();
  }

  public abstract String getCheatSheetId();
  public abstract String getPerspectiveId();
}