use of com.intellij.ide.todo.nodes.TodoFileNode in project intellij-community by JetBrains.
the class TodoPanel method getData.
@Override
public Object getData(String dataId) {
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
TreePath path = myTree.getSelectionPath();
if (path == null) {
return null;
}
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
Object userObject = node.getUserObject();
if (!(userObject instanceof NodeDescriptor)) {
return null;
}
Object element = ((NodeDescriptor) userObject).getElement();
if (!(element instanceof TodoFileNode || element instanceof TodoItemNode)) {
// allow user to use F4 only on files an TODOs
return null;
}
TodoItemNode pointer = myTodoTreeBuilder.getFirstPointerForElement(element);
if (pointer != null) {
return new OpenFileDescriptor(myProject, pointer.getValue().getTodoItem().getFile().getVirtualFile(), pointer.getValue().getRangeMarker().getStartOffset());
} else {
return null;
}
} else if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) {
final PsiFile file = getSelectedFile();
return file != null ? file.getVirtualFile() : null;
} else if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
return getSelectedElement();
} else if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
PsiFile file = getSelectedFile();
if (file != null) {
return new VirtualFile[] { file.getVirtualFile() };
} else {
return VirtualFile.EMPTY_ARRAY;
}
} else if (PlatformDataKeys.HELP_ID.is(dataId)) {
//noinspection HardCodedStringLiteral
return "find.todoList";
}
return super.getData(dataId);
}
Aggregations