[英]JFace tableViewer checkbox selection returns null in eclipse e4
I am using tableviewer with Check box style in the following way 我通过以下方式使用具有复选框样式的tableviewer
tableViewer = new TableViewer(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER| SWT.CHECK);
I used the following code to listen to tableviewer. 我使用以下代码来监听tableviewer。 I know it is wrong because it listens to the selection and not to check box selection.
我知道这是错误的,因为它会监听选择内容而不是复选框选择内容。
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection)tableViewer.getSelection();
Object firstElement = selection.getFirstElement();
System.out.println("firstElement"+firstElement);
// Do something with it
}
});
I need to listen to checkbox selection in JFace TableViewer. 我需要听JFace TableViewer中的复选框选择。
Thanks in advance 提前致谢
The selection listener on a check box table still responds to normal row selection, it does not respond to clicking the check boxes. 复选框表上的选择侦听器仍然响应普通的行选择,它不响应单击复选框。
To add a listener for check box changes you need to use CheckboxTableViewer
and use the addCheckStateListener
method. 要为复选框更改添加侦听器,您需要使用
CheckboxTableViewer
并使用addCheckStateListener
方法。
CheckboxTableViewer
also has many helper methods for managing the check box states. CheckboxTableViewer
还具有许多用于管理复选框状态的帮助器方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.