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.

FixedView.zip

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse and tagged , . Bookmark the permalink.

5 Responses to Eclipse RCP – Removing the minimize and maximize buttons from Views

  1. Bogdan says:

    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!

  2. 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. 😉

  3. 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.

  4. Lars Vogel says:

    @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

Comments are closed.