Programming/Eclipse RCP

현재 Selection 얻기

Lawmin 2012. 1. 10. 10:44
특정 뷰에서 Selection 정보를 넘겨주기 위해선 SelectionProvider를 설정
getSite().setSelectionProvider(tbvRows);

받는 쪽에선 아래와 같이 가능
ISelection selection = HandlerUtil.getCurrentSelection(event); 
//ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
if (selection != null & selection instanceof IStructuredSelection) {
IStructuredSelection strucSelection = (IStructuredSelection) selection;
for (Iterator<Object> iterator = strucSelection.iterator(); iterator.hasNext();) {
Object element = iterator.next();
System.out.println(element.toString());
}
}