【问题标题】:Eclipse: Active Context somehow deactivatedEclipse:活动上下文以某种方式停用
【发布时间】:2015-04-22 02:43:21
【问题描述】:

我有一个 e3 RCP 应用程序。该应用程序由一个工具栏和两个视图组成。左侧一个独立,右侧一个容器(经典的两列布局)。

我的应用程序布局按层次顺序排列:

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

我在 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>

每当在 TableViewer 中选择某些内容时,my 就会被激活并在视图容器中打开特定视图。 TableViewer 中的选择和右侧打开的视图是相连的。上下文状态应该保持不变,这意味着:选择 TableViewer 或相应的视图处于活动状态,这也应该打开我的上下文的活动状态(或保持它)。但是,当 TableViewer 失去焦点时(例如,右侧的视图处于活动状态),上下文将被停用。这不是我以编程方式完成的,这是 eclipse 正在做的事情(我在上下文服务上添加了一个监听器来跟踪它),我想摆脱它。我想控制上下文的激活和停用。有什么想法吗?

【问题讨论】:

  • 您是否使用IContextService 来激活上下文?你是怎么得到它的?
  • 没错。这就是我激活上下文的方式:IContextService contextService = (IContextService) getSite().getService(IContextService.class); context = contextService.activateContext(MyConstants.CONTEXT);

标签: eclipse eclipse-rcp


【解决方案1】:

我假设您正在使用IContextService 来激活上下文。

如果您使用以下方式获得IContextService

getSite().getService(IContextService.class);

那么内容服务是特定于您的部分,并且会在另一部分变为活动状态时停用。

使用

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

为您提供工作台上下文服务。在此服务中激活的上下文应该对所有部分保持活动状态。

【讨论】:

  • 这正是我的问题。非常感谢!
猜你喜欢
  • 2021-03-26
  • 2013-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-28
  • 1970-01-01
  • 2021-09-05
  • 2020-11-19
相关资源
最近更新 更多