迁移到 Eclipse 4 时无法减小 RCP 视图的大小

Cannot reduce size of RCP view when migrated to Eclipse 4

我目前正在将一组 eclipse RCP 应用程序从 3.6 迁移到 4.2。 我正在努力解决 RCP 视角的问题,即视图高度不能降低到特定大小以下(看起来比 window 高度低 10%)。 该代码在 eclipse 3.x 中运行良好,用户可以通过拖动边框来降低视图高度。

但是,在4.x中,最顶层视图(按钮视图)的高度只能减小到一定值。 有人可以帮忙吗?

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

    }

}

这看起来像值

int minSashPercent = 10;

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

似乎没有办法改变这个值。因此,您唯一可以做的就是通过提供您自己的 Renderer Factory 来编写自定义 Sash 渲染器 class。