A common requirement for Eclipse RCP applications is that the perspective should be fixed so that the user cannot change the layout, e.g. layout parts cannot be moved or zoomed, and the initial set of views cannot be closed.
According to the Javadoc this behavior should happen if the perspective is set to fixed. There seems to be bug in the implementation or in the Javadoc as the position in Perspective.java is important. The following works:
public void createInitialLayout(IPageLayout layout) {
layout.setEditorAreaVisible(true);
layout.setFixed(true);
layout.addView("de.vogella.rcp.fixedperspective.view",
IPageLayout.LEFT, 0.5f, layout.getEditorArea());
layout.addView("de.vogella.rcp.fixedperspective.view2",
IPageLayout.RIGHT, 0.5f, layout.getEditorArea());
}
The following does not fix the perspective:
public void createInitialLayout(IPageLayout layout) {
layout.setEditorAreaVisible(false);
// does not work
layout.addView("de.vogella.rcp.fixedperspective.view",
IPageLayout.LEFT, 0.5f, layout.getEditorArea());
layout.addView("de.vogella.rcp.fixedperspective.view2",
IPageLayout.RIGHT, 0.5f, layout.getEditorArea());
layout.setFixed(true);
}
Does anyone know if that is a bug or a feature?
Another question which sometimes comes up is how to fix a specific view which is added via the Perspective.java. This is possible by getting IViewLayout from the layout.
public void createInitialLayout(IPageLayout layout) {
layout.addView("com.example.view.view", IPageLayout.LEFT, 0.95f, layout.getEditorArea());
IViewLayout viewLayout = layout.getViewLayout("com.example.view.view");
viewLayout.setCloseable(false);
viewLayout.setMoveable(false);
layout.setEditorAreaVisible(true);
}
Why do you use the parameter false in
layout.setFixed(false);
?
Gerd
layout.setFixed(false): “does not fix” the perspective. That’s the expected behaviour? I don’t understand your request?
You use two different calls of setFixed: the working with “true” and the second with “false”.
Could it be that simple?
setFixed(true) was a typo. Sorry for this. Corrected.
Ups, looks like I opened myself a bug for this a while ago.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=331402
Thanks to Remy Suen to letting me know.