关闭视图时 opened/activated
Closing a View whenever it is opened/activated
我正在尝试从我的插件中关闭一个视图。要求如下
- 用户将 select 由我的插件提供的 Menu1(比如说开始)。
- 现在,如果用户尝试 select 特定视图,则在用户 select 另一个菜单之前不应被允许,假设停止。
我在 google 中搜索并发现,我可以使用 activePage.hideView() 方法关闭视图。由于我没有完全删除视图的选项,因此我创建了一个 PartListener 并在 partActivated() 方法中调用了 hideview 方法。
通过采用这种方法,视图将关闭,但会出现运行时异常,显示 "Preventing the recursive activation of org.eclipse.ui.ProjectExplorer before activation of the view ... xyz ...."(我正在关闭)。
请帮助我采取正确的方法在用户 opened/activated 时关闭视图。
尝试使用 Display.asyncExec
延迟 hideView
呼叫。在您的 partActivated
方法中使用:
Display.getDefault().asyncExec(new Runnable()
{
@Override
public void run()
{
... call hideView here
}
});
asyncExec
Runnable
将不会 运行 直到 partActivated
代码具有 运行 之后应该停止递归激活警告。
我正在尝试从我的插件中关闭一个视图。要求如下
- 用户将 select 由我的插件提供的 Menu1(比如说开始)。
- 现在,如果用户尝试 select 特定视图,则在用户 select 另一个菜单之前不应被允许,假设停止。
我在 google 中搜索并发现,我可以使用 activePage.hideView() 方法关闭视图。由于我没有完全删除视图的选项,因此我创建了一个 PartListener 并在 partActivated() 方法中调用了 hideview 方法。
通过采用这种方法,视图将关闭,但会出现运行时异常,显示 "Preventing the recursive activation of org.eclipse.ui.ProjectExplorer before activation of the view ... xyz ...."(我正在关闭)。
请帮助我采取正确的方法在用户 opened/activated 时关闭视图。
尝试使用 Display.asyncExec
延迟 hideView
呼叫。在您的 partActivated
方法中使用:
Display.getDefault().asyncExec(new Runnable()
{
@Override
public void run()
{
... call hideView here
}
});
asyncExec
Runnable
将不会 运行 直到 partActivated
代码具有 运行 之后应该停止递归激活警告。