2011-10-09 55 views
1

我在我的Eclipse RCP應用程序中使用Viewer Framework時,遇到了一個情況,我需要從TableViewer中獲取(知道用戶界面中選擇了哪一行)所選行。 在UI用戶能夠選擇row.Below是我TableViewer的聲明如何知道在TableViewer中選擇了哪一行?

TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION 
    | SWT.HIDE_SELECTION); 

我能夠在這個意義上選中一行時,在對特定行用戶點擊它得到凸顯,我想知道用戶選擇哪一行並準確提取行詳細信息?我怎樣才能做到這一點?

回答

11

在JFace中,您可以將一個selectionListener添加到TableViewer中。而不是選定的行,您會收到有關所選對象的通知。繼承人代碼:

this.viewer.addSelectionChangedListener(new ISelectionChangedListener() { 
    public void selectionChanged(final SelectionChangedEvent event) { 
     IStructuredSelection selection = (IStructuredSelection)event.getSelection(); 
    } 
}); 
+0

直截了當地回答謝意 – srk

相關問題