2011-12-23 4 views
1

일치하는 편집기가 활성화되었을 때 treenode를 선택하려고합니다.Jface TreeViewer setSelection

private void selectNodeInTree(IEditorPart activatedEditor) { 
    IEditorInput input = activatedEditor.getEditorInput(); 
    StructuredSelection selection = new StructuredSelection(input); //Selection is not null! 

    treeViewer.setSelection(selection, true); 
} 

그러나 아무것도 선택되어 있지 않은, 내가 무엇을 놓치고 :

코드인가?

답변

1

명백한 대답은 input이 (가) 당신의 나무에 없다는 것입니다. 아마도 당신은 당신의 나무에 파일을 가지고 있고 당신은 다음과 같이하고 싶을 것입니다 :

IFile file = (IFile) input.getAdapter(IFile.class); 
StructuredSelection selection = new StructuredSelection(file); 
관련 문제