gpt4 book ai didi

java - 如何修复 Eclipse View 中布局的位置

转载 作者:行者123 更新时间:2023-12-01 04:56:10 25 4
gpt4 key购买 nike

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

在我添加这个新过滤器作为 这是 git repo View 在更改后加载时的样子 on load

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

maximize

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

代码已更改

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);
}
}

最佳答案

正如 @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);
}
}

关于java - 如何修复 Eclipse View 中布局的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14108384/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com