1

我在 Git repo 页面中添加了一个过滤器并修改了类RepositoryView。我刚刚提到了这一点,以便您可以在需要时在线找到此代码。我的问题更像是一个通用的对齐问题。

在我添加了这个新过滤器之后,这就是 git repo 视图在此更改后加载时的样子 负载

最大化视图后,它看起来像这样。这里对齐出错了。过滤器工具栏位于中心。

最大化

之后,如果我将其最小化,过滤器工具栏就会从视图中消失。 最小化

代码已更改

public void createPartControl(Composite aParent) {
        Composite displayArea = new Composite(aParent, SWT.NONE);
        displayArea.setLayout(new GridLayout());

        displayArea.setLayoutData(new GridData(SWT.FILL,6));


        final Composite temp = new Composite(displayArea, SWT.FILL);//XXX

        layout = new StackLayout();
        temp.setLayout(layout);
        createEmptyArea(temp);

        super.createPartControl(temp);

        IWorkbenchWindow w = PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow();
        ICommandService csrv = (ICommandService) w
                .getService(ICommandService.class);
        Command command = csrv
                .getCommand("org.eclipse.egit.ui.RepositoriesLinkWithSelection"); //$NON-NLS-1$
        reactOnSelection = (Boolean) command.getState(
                RegistryToggleState.STATE_ID).getValue();

        GridDataFactory.fillDefaults().grab(true, true).applyTo(temp);//XXX
//      GridDataFactory.fillDefaults().grab(true, true).applyTo(displayArea);//XXX
        filterToolbar = new FilterToolbar(this, displayArea);
        IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
                .getService(IWorkbenchSiteProgressService.class);
        if (service != null) {
            service.showBusyForFamily(JobFamilies.REPO_VIEW_REFRESH);
            service.showBusyForFamily(JobFamilies.CLONE);
        }
    }
4

1 回答 1

0

正如@WaqasIlyas 所提到的,我GridData今天大部分时间都在尝试参数,并且碰巧按照你所说的那样工作

public void createPartControl(Composite aParent) {
        Composite displayArea = new Composite(aParent, SWT.FILL);
        displayArea.setLayout(new GridLayout());
        displayArea.setLayoutData(new GridData(GridData.FILL,GridData.FILL, true, true));
        Composite historyComposite = new Composite(displayArea, SWT.NONE);

        layout = new StackLayout();
        historyComposite.setLayout(layout);
        historyComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL,GridData.VERTICAL_ALIGN_FILL, true, true));
        createEmptyArea(historyComposite);

        super.createPartControl(historyComposite);

        IWorkbenchWindow w = PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow();
        ICommandService csrv = (ICommandService) w
                .getService(ICommandService.class);
        Command command = csrv
                .getCommand("org.eclipse.egit.ui.RepositoriesLinkWithSelection"); //$NON-NLS-1$
        reactOnSelection = (Boolean) command.getState(
                RegistryToggleState.STATE_ID).getValue();
//XXX added this code and changed the position of some statement to make it work
        GridDataFactory.fillDefaults().grab(true, true).applyTo(historyComposite);
        filterToolbar = new FilterToolbar(this, displayArea);
        ((GridData) filterToolbar.getLayoutData()).verticalAlignment = SWT.END;
        Point computeSize = filterToolbar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        ((GridData) filterToolbar.getLayoutData()).minimumWidth = computeSize.x;
        ((GridData) filterToolbar.getLayoutData()).minimumHeight = computeSize.y;
        GridDataFactory.fillDefaults().grab(true, true).align(GridData.FILL, GridData.FILL).applyTo(displayArea);
//xxx code change ends
        IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
                .getService(IWorkbenchSiteProgressService.class);
        if (service != null) {
            service.showBusyForFamily(JobFamilies.REPO_VIEW_REFRESH);
            service.showBusyForFamily(JobFamilies.CLONE);
        }
    }
于 2013-01-03T12:03:52.960 回答