如何禁用视图关闭选项?
我创建了 2 个视图。在视图 1 中,有一个按钮 B 1,单击按钮后,视图 1 将隐藏,视图 2 将打开。
但是视图2向用户显示了关闭选项。我希望禁用此关闭选项。 (窗口右上角的 X 标记)
下面是我的代码片段:
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference viewToClose = activePage.findViewReference(viewIdToClose);
activePage.hideView(viewToClose);
try {
activePage.showView(viewIdToOpen);
} catch (PartInitException e) {
e.printStackTrace();
}
How can I disable the close option in View 2?
I created 2 views. In the View 1 there is a button B 1 and upon button click View 1 gets hidden and View 2 opens.
But View 2 shows the close option to the user. I want this close option to be disabled. (The X mark at top right of window)
Below is my code snippet:
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference viewToClose = activePage.findViewReference(viewIdToClose);
activePage.hideView(viewToClose);
try {
activePage.showView(viewIdToOpen);
} catch (PartInitException e) {
e.printStackTrace();
}
How can I disable the close option in View 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 org.eclipse.ui.perspectiveExtensions 扩展点放置视图,并将
closeable
属性设置为false
。Place the view using
org.eclipse.ui.perspectiveExtensions
extension point and just set thecloseable
attribute tofalse
.一种方法是使用方法 addStandaloneView(String viewId, boolean showTitle,
IPageLayout
类的 int 关系、浮点数比例、String refId)。 务必使第二个参数showTitle 为 false。基本上,您将在 Perspective 类中调用此方法,如下所示:<代码>
One way to do this is to use method
addStandaloneView(String viewId, boolean showTitle,
of classint relationship, float ratio, String refId)
IPageLayout
. Be Sure to make the second argument showTitle to be false. Basically, you will call this method in Perspective class like: