gpt4 book ai didi

java - JFace DialogCellEditor : how to make buttons always appear?

转载 作者:行者123 更新时间:2023-12-04 05:14:29 24 4
gpt4 key购买 nike

我使用 JFace DialogCellEditor在我的 JFace 的一行单元格中显示一个按钮 TableViewer激活时触发对话框。此行为适用于以下代码,但仅当显式选择托管该按钮的表格单元格时,该按钮才会出现。

public class CompareDialogCellEditor extends DialogCellEditor {
public CompareDialogCellEditor(Composite parent) {
super(parent);
}

@Override
protected Button createButton(Composite parent) {
Button button = super.createButton(parent);
button.setText("");
button.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, IImageKeys.COMPARE_ICON).createImage());
return button;
}

@Override
protected Object openDialogBox(Control cellEditorWindow) {
MessageDialog.openInformation(cellEditorWindow.getShell(), "Test", "It works");
return null;
}
}

有没有办法强制按钮始终出现在表格中,而不仅仅是在选择单元格时? (相同的行为适用于由重写方法设置的标签 setContents(...) )

谢谢

最佳答案

您只能编辑一个 Viewer一次单元格。 Viewer除非您进行一些自定义,否则将不支持一次编辑多个单元格。

我可以想到以下解决方案。

  • 绘制小部件(按钮、文本、组合等),如表格单元格上的图像并调用CellEditor当用户激活它时。
    你可以在这里找到一些关于如何在 Table 上绘画的例子。细胞。
    http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html
  • 我在这里发布了一个关于如何在表格单元格中显示按钮的答案。您可以使用 CellEditor 遵循相同的概念
    SWT - Tableviewer adding a remove button to a column in the table
  • 关于java - JFace DialogCellEditor : how to make buttons always appear?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14464611/

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