如何在 TabFolder 中嵌入 SWT TableViewer?

发布于 2024-08-24 00:12:46 字数 1329 浏览 7 评论 0 原文

我正在尝试在 SWT TableViewer http://www.jdocs.com/swt/3.1/org/eclipse/swt/widgets/TabFolder.html" rel="nofollow noreferrer">TabFolder,但是当我这样做时,表格不显示向上。我的 GitToDo 代码看起来像(参见 此 Git 存储库):

    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Git ToDo");
    FillLayout layout = new FillLayout();
    shell.setLayout(layout);

    final GitToDoTree tableViewer = new GitToDoTree(shell);

后者

    super(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.FILL);
    this.shell = parent;
    table = this.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

github/gittodo/rcp/views/GitToDoTree.java" rel="nofollow noreferrer">GitToDoTree 使用此构造函数扩展 TableViewer 因此,当我从Shell 它可以工作,但是一旦我尝试从 TabFolder 或(也尝试过)Composite 构建它,就不再显示任何内容。

如何让我的 TableViewer 显示在 TabFolder 中?

I am trying to embed a JFace TableViewer in a SWT TabFolder, but when I do so, the table does not show up. The current (working code) in my GitToDo code looks like (see this Git repos):

    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Git ToDo");
    FillLayout layout = new FillLayout();
    shell.setLayout(layout);

    final GitToDoTree tableViewer = new GitToDoTree(shell);

Where the latter GitToDoTree extends TableViewer, with this constructor:

    super(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.FILL);
    this.shell = parent;
    table = this.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

So, when I construct the TableViewer-extending GitToDoTree from a Shell it works, but as soon as I try to build it from a TabFolder or (tried that too) a Composite, nothing shows up anymore.

How can I get my TableViewer to show up in the TabFolder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十雾 2024-08-31 00:12:46

如果您的 TableViewer 类在您将其添加到 Composite 时没有显示,我想说您很可能没有为嵌套的 Composite 设置布局。

final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Git ToDo");
FillLayout layout = new FillLayout();
shell.setLayout(layout);

Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new FillLayout()); // Possible missing layout?

final GitToDoTree tableViewer = new GitToDoTree(composite);

至于 TabFolder 可能是您没有在 TabItem 上设置客户端控件

TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText("Table");

GitToDoTree viewer = new GitToDoTree(tabFolder);
item.setControl(viewer.getTable()); // Possible setControl call?

TabItem item2= new TabItem(tabFolder, SWT.NONE);
item2.setText("Empty");

If your TableViewer class isn't showing up when you add it to a Composite I would say that chances are that you are not setting a layout for the nested Composite.

final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Git ToDo");
FillLayout layout = new FillLayout();
shell.setLayout(layout);

Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new FillLayout()); // Possible missing layout?

final GitToDoTree tableViewer = new GitToDoTree(composite);

And as for the TabFolder that may be that you are not setting the client control on the TabItem

TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText("Table");

GitToDoTree viewer = new GitToDoTree(tabFolder);
item.setControl(viewer.getTable()); // Possible setControl call?

TabItem item2= new TabItem(tabFolder, SWT.NONE);
item2.setText("Empty");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文