繁体   English   中英

Eclipse RCP应用程序活动标题栏

[英]Eclipse RCP application Active Title Bar

我在类似于Eclipse的RCP应用程序中工作,用户可以在Project Explorer树中导航并在编辑器中打开任何文件

我在将“ WorkbenchWindowAdvisor ”扩展为以下类的类中设置RCP应用程序标题:

  IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); configurer.setTitle("My RCP Application title"); 

但是我需要在标题栏中显示透视图名称和打开的文件路径,就像在常规Eclipse中一样:

Eclipse标题栏的图像,显​​示透视图和最近打开的文件名

有什么建议么

谢谢

这需要在您的WorkbenchWindowAdvisor中收听很多事件。

preWindowOpen方法中,您需要为以下项添加侦听器:

  • 使用configurer.getWindow().addPageListener(listener)进行页面激活和关闭的方法pageActivatedpageClosed侦听器方法需要更新标题。
  • 使用configurer.getWindow().addPerspectiveListener(listener)更改透视图。 perspectiveActivatedperspectiveSavedAsperspectiveDeactivated方法需要更新标题。
  • 使用configurer.getWindow().getPartService().addPartListener(listener)激活零件。 这需要使用IPartListener2 partActivatedpartBroughtToToppartClosedpartHiddenpartVisible方法需要更新标题。

您可以从活动的编辑器中获取打开的文件路径:

IWorkbenchPage currentPage = configurer.getWindow().getActivePage();
IEditorPart activeEditor = currentPage.getActiveEditor();
if (activeEditor != null) {
   path = activeEditor.getTitleToolTip();
}

以及透视图名称:

IPerspectiveDescriptor persp = currentPage.getPerspective();
if (persp != null) {
    label = persp.getLabel();
}

完整的甚至更复杂的代码在org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM