Eclipse RCP – Removing the minimize and maximize buttons from Views
I got the question how someone could remove the maximize and minimize buttons from a view in an Eclipse RCP application.
To archive this I know two ways.
Either set the layout to fixed in initialLayout() in Perspective.java
package de.vogella.intro.rcp.fixedview;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
layout.setEditorAreaVisible(false);
layout.setFixed(true);
// layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea);
}
}
Or use the Perspective.java to add a standalone view.
package de.vogella.intro.rcp.fixedview;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
layout.setEditorAreaVisible(false);
// layout.setFixed(true);
layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea);
}
}
If I add a standalone view via the extension “org.eclipse.ui.perspectiveExtensions” then the minimize and maximize buttons are still there.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="application"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="de.vogella.intro.rcp.fixedview.Application">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="Perspective"
class="de.vogella.intro.rcp.fixedview.Perspective"
id="de.vogella.intro.rcp.fixedview.perspective">
</perspective>
</extension>
<extension
point="org.eclipse.ui.views">
<view
name="View"
class="de.vogella.intro.rcp.fixedview.View"
id="de.vogella.intro.rcp.fixedview.view">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="*">
<view
id="de.vogella.intro.rcp.fixedview.view"
minimized="false"
ratio="1.0f"
relationship="left"
relative="org.eclipse.ui.editorss"
standalone="true"
visible="true">
</view>
</perspectiveExtension>
</extension>
</plugin>
The behavior seems inconsistent. If I use coding to add a standalone view the minimize / maximize buttons are not there, if I use extension points they are still there.
Does anymore know if I’m missing something? Or is this a bug? If you know please comment on this blog post or contact me via twitter.
Update: Projekt attached.
November 13th, 2009 at 11:38 am
Hi Lars,
another aspect: layout.setFixed(true) might be doing the job for views, but it is not doing it for editors. The minimize and maximize buttons are visible in the editor area (IEditorSite), although they are not doing anything (not for RCP and also not for RAP) – not nice at all.
I searched into FormEditor.getEditorSite.getActionBars but could not find them there.
I also tried ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getActionBars() – not there either.
Even my ActionBarAdvisor extension did not help.
I am wondering if I’ve missed something there.
Anyway, if you find a way to do it, please keep me also informed!
November 13th, 2009 at 3:08 pm
Did you wipe your runtime workspace first, or at least its workbench.xml file? The perspective may have been cached and the (plugin.xml) contribution was ignored. If yes, it certainly sounds like a bug, if it is the expected behaviour, then it needs to be documented somewhere.
November 13th, 2009 at 5:42 pm
Lars, generally I run into this issue if I’ve been testing a variety of RCP applications in my workbench and my configuration area or workspace hasn’t been clean.
November 13th, 2009 at 6:01 pm
@Remy @Chris: I did use the clear workspace flag in the runtime configuration. If you want to give it a try I attached the project. It is basically the “RCP with a view” template I only removed set fixedLayout and add the view via XML
November 13th, 2009 at 7:04 pm
I opened a bug for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=295088