4

I got a custom perspecitve with an editor area declared in plugin.xml only. In addtion, I got a custom view, that is opened programatically. I want to stack this view with the editor area. If I set it in the perspective extension as initially visible, everything works fine.

        <view
              id="my.viewID"
              minimized="false"
              relationship="stack"
              relative="org.eclipse.ui.editorss"
              visible="false">
        </view>

However, if I set visible="false", and use the following code to open it programmatically, it always appears in the bottom area stacked with the ConsoleView.

    IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                .showView("my.viewID", "secondID", IWorkbenchPage.VIEW_ACTIVATE);

Does anybody know how to have an initially invisble view stacked to the editor area when opened programmatically?

I already tried the recommendations given in this thread but without any success: Eclipse RCP - relative field of view perspective extension not working

Community
  • 1
  • 1
Benjamin
  • 813
  • 8
  • 11

3 Answers3

3

Sometimes you can't imagine how simple solutions can be:

Simply adding :* at the end of the view id in the plugin.xml solved this issue:

<view
          id="my.viewID:*"
          minimized="false"
          relationship="stack"
          relative="org.eclipse.ui.editorss"
          visible="false">
</view>

Unbelievable how many times you find people saying this would not be possible at all...

Benjamin
  • 813
  • 8
  • 11
2

Well, I've read most stuff about placing a view over the editor area, and none worked. The Answer 1 above causes the plugin.xml to have warnings. In Eclipse Luna, this works however when your perspective is initialized:

public void createInitialLayout(IPageLayout layout) {
  if ( layout instanceof org.eclipse.ui.internal.e4.compatibility.ModeledPageLayout ) {
    org.eclipse.ui.internal.e4.compatibility.ModeledPageLayout layout4=(org.eclipse.ui.internal.e4.compatibility.ModeledPageLayout)layout;
    layout4.stackView(ID+":*",layout.getEditorArea(),false);
  }
  ...

The code above adds a view with "ID" that is a multiple view, added to the stack of editors hidden (last parameter is false="not visible").

It may also work with other Eclipse versions, but I haven't tried it.

Good luck!

0

The simplest way to achieve this is to add the view to the perspective extensions like this:

<extension point="org.eclipse.ui.perspectiveExtensions">
  <perspectiveExtension targetID="org.my.perspective">
    <view id="org.my.view"
          minimized="false"
          relationship="stack"
          relative="org.eclipse.ui.editorss"
          visible="false">
     </view>
  </perspectiveExtension>
</extension>

and then calling IWorkbenchPage::showView() without a secondary ID, i.e. only with one argument like this:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.my.view");
davidpace
  • 405
  • 4
  • 7