2011-12-23 15 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); 
関連する問題