我正在努力在 SWT 中阐述一个观点。为了简单起见,它没有编辑器,只有 1 个或多个 View 。有一个默认 View ,默认情况下应占据整个查看器区域(可以最大化,但不是必须如此),而没有其他查看器打开。还有少量 (2-3) 个其他 View 可以通过用户输入打开,也可以不打开。当它们打开时,默认 View 应占据约 75% 的屏幕空间,而其他堆叠的 View 应占据约 25% 的屏幕空间。
我有一个始终设置为不可见的 View ,称为 anchor 。默认值与左图所示的 anchor 相关。其他 View 作为堆栈与该 anchor 相关。
这似乎工作正常,但需要空间。默认情况下,我可以将 25% 的屏幕留空,或者几乎没有空间分配给辅助 View 。
我的问题:
- 使用“ anchor ”是一个好的模式还是有更好的模式?
- 如何在打开的一个 View 和多个 View 之间进行条件切换?
谢谢!
中号
最佳答案
我不太确定是否收到你的问题,但这是我通常使用的:
public class PerspectiveExplore implements IPerspectiveFactory {
public static final String ID = "UF.PerspectiveExplore";
@Override
public void createInitialLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
layout.setEditorAreaVisible(false);
IFolderLayout workflowSelection = layout.createFolder("Workflow Selection", IPageLayout.LEFT, 0.20f, editorArea);
workflowSelection.addPlaceholder(WorkflowSelection.ID + ":*");
workflowSelection.addView(WorkflowSelection.ID);
IFolderLayout filter = layout.createFolder("Filter", IPageLayout.BOTTOM, 0.5f, WorkflowSelection.ID);
filter.addPlaceholder(FilterView.ID + ":*");
filter.addView(FilterView.ID);
IFolderLayout resultSelection = layout.createFolder("Result Selection", IPageLayout.BOTTOM, 0.5f, editorArea);
resultSelection.addPlaceholder(ResultSelection.ID + ":*");
resultSelection.addView(ResultSelection.ID);
IFolderLayout canvas = layout.createFolder("Plot", IPageLayout.TOP, 0.6f, ResultSelection.ID);
canvas.addPlaceholder(Plot.ID + ":*");
canvas.addView(Plot.ID);
}
}
这将创建一个具有相对大小的布局,即工作流选择位于左侧,占据透视宽度的 20%。过滤器位于工作流程选择下方,占据高度的 50%,依此类推。
也许您可以以此为起点。
关于java - SWT 中不同大小的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12355264/