I have a standard E3 editor in the current E4 world:
public class ProjectEditor extends EditorPart {
// implement
}
Registered like that:
<extension point="org.eclipse.ui.editors">
<editor
class="com.qualitype.gpm.project.rcp.ProjectEditor"
icon="icons/obj16/project.gif"
id="com.qualitype.gpm.project.rcp.ProjectEditor"
name="%view.project" >
</editor>
</extension>
I want that editor to be always open. But a parameter like for the views is missing in the extension point.
Also, for views this would work:
public class ProjectPerspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
final IViewLayout projectLayout = layout.getViewLayout(ProjectEditor.ID);
projectLayout.setCloseable(false);
}
}
But of course not for editors. Since both editors and view are technically the same thing (workbench parts), it should be possible.
How do I prevent the user from closing my editor?
You can remove the close 'X' on the editor tab by clearing the MPart
closeable flag. You could do this in the editor's init
method:
@Override
public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException
{
super.init(site, editorInput);
MPart part = getSite().getService(MPart.class);
part.setCloseable(false);
But the 'File > Close' action will still be able to close the editor as it doesn't check the closeable flag and has no concept of un-closeable editors.