【问题标题】:Cannot reduce size of RCP view when migrated to Eclipse 4迁移到 Eclipse 4 时无法减小 RCP 视图的大小
【发布时间】:2015-11-18 14:52:32
【问题描述】:

我目前正在将一组 Eclipse RCP 应用程序从 3.6 迁移到 4.2。 我正在努力解决 RCP 透视图的问题,即视图高度不能降低到一定尺寸以下(看起来像窗口高度的 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

    }

}

【问题讨论】:

    标签: eclipse migration rcp perspective e4


    【解决方案1】:

    这看起来像值

    int minSashPercent = 10;
    

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

    似乎没有办法改变这个值。所以你唯一能做的就是通过提供你自己的Renderer Factory 来编写一个自定义的 Sash Renderer 类。

    【讨论】:

    • 该解决方案有效。谢谢@Greg-449!我认为这个 10% 的默认值是非常严格的,如果在 'org.eclipse.e4.ui.workbench.renderers.swt.SashLayout' 中设置为 1% 左右会很好。
    • 如果一个答案可以帮助您考虑accepting,以便其他人清楚它是有用的。
    猜你喜欢
    • 1970-01-01
    • 2012-07-31
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 2014-02-11
    • 2021-11-09
    • 2012-12-08
    • 1970-01-01
    相关资源
    最近更新 更多