Jface TreeViewer setSelection - PullRequest
       8

Jface TreeViewer setSelection

1 голос
/ 23 декабря 2011

Я пытаюсь выбрать триод, когда активирован соответствующий редактор.

это код:

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

   treeViewer.setSelection(selection, true); 
}

Но ничего не выбрано, что мне не хватает?

1 Ответ

1 голос
/ 24 декабря 2011

Очевидный ответ таков: input нет в вашем дереве. Возможно, у вас есть файлы в вашем дереве, и вы хотите сделать что-то вроде:

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