JFace DialogCellEditor:如何使按钮始终出现?

2024-04-28

我用的是JFaceDialogCellEditor在 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(...) )

Thanks


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

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

  1. 在表格单元格上绘制小部件(按钮、文本、组合等),例如图像并调用CellEditor当用户激活它时。 您可以在这里找到一些有关如何绘画的示例Table Cell. http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html

  2. 我在这里发布了有关如何在表格单元格中显示按钮的答案。你可以遵循相同的概念CellEditor SWT - Tableviewer 添加删除按钮到表中的列 https://stackoverflow.com/questions/12480402/swt-tableviewer-adding-a-remove-button-to-a-column-in-the-table/12486929#12486929

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JFace DialogCellEditor:如何使按钮始终出现? 的相关文章

随机推荐