gossi
gossi

Reputation: 554

Eclipse: Active Context somehow deactivated

I have an e3 RCP application. The app consists of a toolbar and two views. One standalone on the left and a container on the right (a classical two column layout).

My app layout in hierarchical order:

- Perspective
  |- View
  |`- TableViewer
  `- ViewContainer
   `- View2 (multiple)

And I have defined a context in plugin.xml:

<extension point="org.eclipse.ui.contexts">
    <context
        id="my.context.MY_ID"
        name="MY_CONTEXT">
        parentId="org.eclipse.ui.contexts.window">
    </context>
</extension>

Whenever something gets selected in the TableViewer, my gets activated and a specific view gets opened in the view container. The selection in the TableViewer and the view opened on the right are connected. The context state should stay persistent, means: either the TableViewer is selected or the corresponding view is active which should also turn the active state of my context on (or keep it). However, when the TableViewer looses focus (e.g. view on the right is active), the context is deactivated. This is not done programmatically by me, this is something eclipse is doing (I have added a listener on the context service to track this) and I want to get rid of. I want to control the activation and deactivation of my context. Any ideas?

Upvotes: 1

Views: 368

Answers (1)

greg-449
greg-449

Reputation: 111142

I assume you are using IContextService to activate the context.

If you get the IContextService using something like:

getSite().getService(IContextService.class);

then the content service is specific to your part and will be deactivated when another part becomes active.

Using

PlatformUI.getWorkbench().getAdapter(IContextService.class);

gives you the workbench context service. Contexts activated in this service should stay active for all parts.

Upvotes: 2

Related Questions