Search code examples
javaeclipseeclipse-plugineclipse-rcprcp

Eclipse RCP application Active Title Bar


I am working in an RCP application similar to Eclipse where the user can navigate in Project Explorer tree and opens any file in the Editor

i am Setting the RCP application title in a class which extends "WorkbenchWindowAdvisor" as the following:

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

But what i need to show up in title bar the perspective name and the opened file path like in normal eclipse:

Image of Eclipse title bar showing perspective and recent opened file name

any suggestions

Thanks


Solution

  • This is requires listening to a lot of events in your WorkbenchWindowAdvisor.

    In the preWindowOpen method you need to add listeners for:

    • Page activation and closing using configurer.getWindow().addPageListener(listener) The pageActivated and pageClosed listener methods need to update the title.
    • Perspective changes using configurer.getWindow().addPerspectiveListener(listener). The perspectiveActivated, perspectiveSavedAs, perspectiveDeactivated methods need to update the title.
    • Part activations using configurer.getWindow().getPartService().addPartListener(listener). This need to use an IPartListener2. The partActivated, partBroughtToTop, partClosed, partHidden, partVisible methods need to update the title.

    You get the open file path from the active editor:

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

    and the perspective name:

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

    The full, even more complex, code for this is in org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor