Search code examples
eclipsemigrationrcpperspectivee4

Cannot reduce size of RCP view when migrated to Eclipse 4


I'm currently working on migrating a set of eclipse RCP applications from 3.6 to 4.2. I'm struggling with an issue with RCP perspectives that view height cannot be reduced below a certain size (looks like 10% from the window height). The code works fine in eclipse 3.x and user can reduce the view height by dragging the border.

However, in 4.x the height of top most view (button view) can only be reduced upto a certain value. Can anybody help with this, please?

public class Perspective implements IPerspectiveFactory {

    public static final String ID = "im.rcpTest2.fixedperspective";

    public void createInitialLayout(IPageLayout layout) {
        String editorArea = layout.getEditorArea();
        layout.setEditorAreaVisible(false);

        layout.addStandaloneView(ButtonView.ID, false, IPageLayout.TOP,
                0.1f, editorArea);

        layout.addStandaloneView(View.ID, false, IPageLayout.LEFT,
                0.25f, editorArea);
        IFolderLayout folder = layout.createFolder("messages", IPageLayout.TOP,
                0.5f, editorArea);
        folder.addPlaceholder(View2.ID + ":*");
        folder.addView(View2.ID+":2");
        folder.addView(View2.ID+":3");

        layout.getViewLayout(ButtonView.ID).setCloseable(false);

        layout.getViewLayout(View.ID).setCloseable(false);
    }

}

public class ButtonView extends ViewPart  {
    public ButtonView() {
    }

    public static final String ID = "im.rcptest2.ButtonView"; //$NON-NLS-1$
    private Text text;


    /**
     * Create contents of the view part.
     * @param parent
     */
    @Override
    public void createPartControl(Composite parent) {
        Composite container = new Composite(parent, SWT.NONE);
        container.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
        container.setLayout(new GridLayout(2, false));
        text = new Text(container, SWT.BORDER);
        text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
        {
            Button btnMybutton = new Button(container, SWT.NONE);
            btnMybutton.setText("MyButton");
        }
    }

    @Override
    public void setFocus() {
        // TODO Auto-generated method stub

    }

}

Solution

  • This looks like the value

    int minSashPercent = 10;
    

    in org.eclipse.e4.ui.workbench.renderers.swt.SashLayout

    There does not seem to be a way to change this value. So the only thing you could do would be to write a custom Sash Renderer class by providing your own Renderer Factory.