开发者

How to disable view close option?

开发者 https://www.devze.com 2023-03-29 03:12 出处:网络
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.

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

精彩评论

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