JFace TableViewer 单元格中的小部件?
我正在 Eclipse 3.6 上使用 JFace 开发一个应用程序,我希望在 TableViewer 中拥有实际的小部件 - 主要是复选框和按钮。我发现的一切似乎都表明目前这是不可能的。
我当前的解决方法涉及为包装的 Table 控件提供一个 MouseListener,其中使用 getCell() 方法并执行操作。然后,我使用内容提供程序来提供图像和格式化文本,这些文本在某种程度上接近各个小部件的外观。
问题是结果根本不是原生的。有一些解决方法涉及对实际本机小部件进行屏幕截图,但这有一些问题:
- 这是一种黑客行为
- 捕获的小部件偶尔会变得可见,在屏幕上创建闪烁的伪影
- 它需要图像处理技巧来使捕获的图像与表格颜色
- 当需要具有不同内容的按钮时,它不能很好地缩放
有没有一种方法可以在 TableViewer 单元格中嵌入小部件而不使用如此繁琐的方法?底层的SWT Table当然可以做到这一点,但是TableViewer接口似乎不支持这一点......
I am developing an application using JFace on Eclipse 3.6 and I would like to have actual widgets - mostly checkboxes and buttons - in a TableViewer. Everything I have found seems to suggest that this is not possible at the moment.
My current workaround involves having a MouseListener for the wrapped Table control, where the mouseDown event coordinates are translated to cells using the getCell() method and acted upon. I then use the content provider to supply images and formatted text that somewhat approach the look of the respective widgets.
The problem is that the result is not native-looking at all. There are some workarounds involving taking screenshots of the actual native widgets, but this has a few problems:
- It's a hack
- The captured widgets ocassionally become visible, creating a flickering artifact on the screen
- It requires image handling tricks to make the captured image blend with the table colours
- It does not scale well when e.g. buttons with different contents are required
Is there a way to embed widgets in TableViewer cells without using such cumbersome methods? The underlying SWT Table can certainly do that, but the TableViewer interface does not seem to support this...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为此使用单元格编辑器。这并不完全是您想要的,因为小部件仅在编辑期间显示,但我认为,它非常接近。
请参阅 http://wiki.eclipse.org/JFaceSnippets#Snippet027ComboBoxCellEditors 或维基页面。
You can use celleditors for this. It is not exactly what you want, as the widgets are only displayed during editing, but I think, it is quite close.
See http://wiki.eclipse.org/JFaceSnippets#Snippet027ComboBoxCellEditors or the other CellEditor examples on the wiki page.