Search code examples
eclipsercp

Eclipse RCP - Programmatically setting a view to not be closeable


I'm trying to create an RCP view that is not closeable. I need a way to set this property programmatically because I'm creating views with secondary IDs in in the code. I can't do it through the extension editor dialogs because of this.

Is there a way to remove the x from a view programmatically?


Solution

  • I was finally able to figure this out.

    In your perspective's createInitialLayout() function you can get the layout of the view and set its closeable property:

    IViewLayout vLayout = layout.getViewLayout(View.ID);
    vLayout.setCloseable(false);
    

    This will work for views with secondary ids too. The code would be exactly the same in that case, because it will apply the closeable property to all secondary views that share the same primary id.

    I've found that the following won't work:

    IViewLayout vLayout = layout.getViewLayout(View.ID + ":1");
    vLayout.setCloseable(false);
    

    So you can't make individual views closeable based on their secondary ids. Either the whole group is or isn't.