JFace DialogCellEditor:如何使按钮总是出现? [英] JFace DialogCellEditor: how to make buttons always appear?
问题描述
我使用JFace DialogCellEditor
在我的JFace TableViewer
的一行单元格中显示一个按钮,触发一个激活时对话框。此行为适用于以下代码,但仅当显式选择托管该按钮的表格的单元格时,该按钮才会显示。
I use JFace DialogCellEditor
to show a button in a cell of a row of my JFace TableViewer
which triggers a dialog when activated. This behaviour works well with the following code but the button only appears when the cell of the table hosting the button is explicitly selected.
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(...)
)
Is there a way to force the button to always appear in the table and not only when the cell is selected? (the same behaviour goes for a label set by the overridden method setContents(...)
)
谢谢
推荐答案
一次只能编辑一个查看器
单元格。 查看器
不会一直支持编辑多个单元格,除非您进行某些自定义。
You can only edit one Viewer
cell at a time. Viewer
won't support editing multiple cells at a time unless you do some customization.
我可以想到以下解决方案
I can think of following solutions.
-
绘制小部件(按钮,文本,combo..etc)像表单元格上的图像一样,并调用
CellEditor
当用户激活它。
您可以在这里找到有关如何在表
单元格上绘制的示例。
http://www.eclipse。 org / articles / article.php?file = Article-CustomDrawingTableAndTreeItems / index.html
Paint widget ( button, text, combo..etc) like image on table cell and invoke
CellEditor
when user activates it. You can find some examples here about how to paint onTable
Cell. http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html
我发表了一个关于如何在表中显示按钮的答案这里的细胞。您可以按照 CellEditor
SWT - 表格添加一个删除按钮到列表中的列
I posted an answer about how to show button in table cell here. you can following the same concept with CellEditor
SWT - Tableviewer adding a remove button to a column in the table
这篇关于JFace DialogCellEditor:如何使按钮总是出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!