[英]add selection listener to the rows of the jface tableviewer table without allowing multiple selection
I have a jface tableviewer and I need to implement a selection listener on the row, where on selecting a row a view has to be fired. 我有一个jface tableviewer,我需要在行上实现一个选择监听器,在那里选择一行必须触发一个视图。 I have implemented it by:
我通过以下方式实现了它:
viewer.getTable().addListener(SWT.Selection, new Listener() {
@Override public void handleEvent(Event e)
{
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("E2E_tab_view.view5");
}
catch (PartInitException e1)
{
e1.printStackTrace();
}
}});
But I face a problem of multiple selection with this. 但是我面临着多重选择的问题。 I actually dont want to allow multiple selection for the row but now i am able to select more than one row which is not required.
我实际上不想允许多行选择,但现在我可以选择不需要的多行。
So could anybody help me to implement this. 所以有人可以帮我实现这个。 I need to allow a feature of either selecting a row or on click of the row view should be fired.
我需要允许选择行或点击行视图的功能。
If your table allows multi-selection then you are probably creating it with the SWT.MULTI
style bit and you should use SWT.SINGLE
instead. 如果您的表允许多选,那么您可能正在使用
SWT.MULTI
样式位创建它,您应该使用SWT.SINGLE
。 The latter is the default for Windows; 后者是Windows的默认值; although this might be different on other OSs.
虽然这在其他操作系统上可能有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.