开发者

How to disable view close option?

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 activ开发者_Go百科ePage = 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?


Place the view using org.eclipse.ui.perspectiveExtensions extension point and just set the closeable attribute to false.


One way to do this is to use method addStandaloneView(String viewId, boolean showTitle, int relationship, float ratio, String refId) of class IPageLayout. Be Sure to make the second argument showTitle to be false. Basically, you will call this method in Perspective class like:

public class Perspective implements IPerspectiveFactory {
      public void createInitialLayout(IPageLayout layout) {
        layout.setEditorAreaVisible(false);
        layout.addStandaloneView(Contact.ID, false, IPageLayout.LEFT, 0.3f,
                layout.getEditorArea());
        }
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜