1
votes

I am trying to select a treenode when a matched editor is activated.

this is the code:

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

   treeViewer.setSelection(selection, true); 
}

But nothing is selected, what am I missing?

1

1 Answers

1
votes

The obvious answer is that input is not in your tree. Perhaps you have files in your tree and you want to do something like:

IFile file = (IFile) input.getAdapter(IFile.class);
StructuredSelection selection = new StructuredSelection(file);