Java Code Examples for com.intellij.openapi.actionSystem.CommonDataKeys#NAVIGATABLE_ARRAY

The following examples show how to use com.intellij.openapi.actionSystem.CommonDataKeys#NAVIGATABLE_ARRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractProjectViewPane.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Object getData(@Nonnull Key<?> dataId) {
  Object data = myTreeStructure instanceof AbstractTreeStructureBase ? ((AbstractTreeStructureBase)myTreeStructure).getDataFromProviders(getSelectedNodes(AbstractTreeNode.class), dataId) : null;
  if (data != null) {
    return data;
  }
  if (CommonDataKeys.NAVIGATABLE_ARRAY == dataId) {
    TreePath[] paths = getSelectionPaths();
    if (paths == null) return null;
    final ArrayList<Navigatable> navigatables = new ArrayList<>();
    for (TreePath path : paths) {
      Object node = path.getLastPathComponent();
      Object userObject = TreeUtil.getUserObject(node);
      if (userObject instanceof Navigatable) {
        navigatables.add((Navigatable)userObject);
      }
      else if (node instanceof Navigatable) {
        navigatables.add((Navigatable)node);
      }
    }
    return navigatables.isEmpty() ? null : navigatables.toArray(new Navigatable[0]);
  }
  return null;
}
 
Example 2
Source File: UsagePreviewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Object getData(@Nonnull @NonNls Key dataId) {
  if (CommonDataKeys.EDITOR == dataId && myEditor != null) {
    return myEditor;
  }
  if (Registry.is("ide.find.preview.navigate.to.caret") && CommonDataKeys.NAVIGATABLE_ARRAY == dataId && myEditor instanceof EditorEx) {
    LogicalPosition position = myEditor.getCaretModel().getLogicalPosition();
    VirtualFile file = FileDocumentManager.getInstance().getFile(myEditor.getDocument());
    if (file != null) {
      return new Navigatable[]{new OpenFileDescriptor(myProject, file, position.line, position.column)};
    }
  }
  return null;
}
 
Example 3
Source File: NavigatableArrayRule.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<Navigatable[]> getKey() {
  return CommonDataKeys.NAVIGATABLE_ARRAY;
}