Search code examples
eclipse-plugineclipse-rcprcp

How to avoid that the user can close the editor window in a RCP-eclipse-plugin programmatically?


How to do away the "X" at the editor window of a RCP-eclipse-plugin and avoid that the user can close the editor programmatically?

Would it be possible and if so how?


Solution

  • For an Eclipse e4 application you can just uncheck the 'closeable' option in the part design.

    For a 3.x compatibility mode RCP you can't use the closeable option. One way to make the part uncloseable would be to use a custom renderer to override the part stack renderer org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer and override the isCloseable method:

    public class MyStackRenderer extends StackRenderer
    {
      @Override
      protected boolean isClosable(final MPart part)
      {
        if (part.getObject() instanceof MyEditor) {
          return false;
        }
    
        return super.isClosable(part);
      }
    }
    

    where MyEditor is your editor class.

    This require Eclipse 4 but can be used with 3.x compatibility mode RCPs.