Java 类com.intellij.util.OpenSourceUtil 实例源码

项目:mule-intellij-plugins    文件:GlobalConfigsToolWindowPanel.java   
private void addTreeMouseListeners() {
    EditSourceOnDoubleClickHandler.install(getTree(), new Runnable() {
        @Override
        public void run() {
            TreePath path = getTree().getSelectionPath();
            if (path == null)
                return;
            DefaultMutableTreeNode selectedElement = (DefaultMutableTreeNode)path.getLastPathComponent();
            if (selectedElement == null)
                return;
            GlobalConfigsTreeStructure.GlobalConfigNode configNode = (GlobalConfigsTreeStructure.GlobalConfigNode)selectedElement.getUserObject();
            if (configNode == null)
                return;
            PsiElement element = configNode.getXmlTag();
            if (element == null)
                return;
            OpenSourceUtil.navigate((Navigatable)element);
        }
    });

    CustomizationUtil.installPopupHandler(getTree(), IdeActions.GROUP_STRUCTURE_VIEW_POPUP, ActionPlaces.STRUCTURE_VIEW_POPUP);
}
项目:tools-idea    文件:StructureViewComponent.java   
private void addTreeKeyListener() {
  getTree().addKeyListener(
      new KeyAdapter() {
      @Override
      public void keyPressed(KeyEvent e) {
        if (KeyEvent.VK_ENTER == e.getKeyCode()) {
          DataContext dataContext = DataManager.getInstance().getDataContext(getTree());
          OpenSourceUtil.openSourcesFrom(dataContext, false);
        }
        else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
          if (e.isConsumed())
          {
            return;
          }
          PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
          boolean[] isCopied = new boolean[1];
          if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
            copyPasteManager.clear();
            e.consume();
          }
        }
      }
    });
}
项目:consulo    文件:EditSourceForDialogAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
  if (navigatableArray != null && navigatableArray.length > 0) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        OpenSourceUtil.navigate(navigatableArray);
      }
    });
    DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
    if (dialog != null && dialog.isModal()) {
      dialog.doCancelAction();
    }
  }
}
项目:intellij-ce-playground    文件:AutoScrollToSourceHandler.java   
protected void scrollToSource(final Component tree) {
  DataContext dataContext=DataManager.getInstance().getDataContext(tree);
  getReady(dataContext).doWhenDone(new Runnable() {
    @Override
    public void run() {
      DataContext context = DataManager.getInstance().getDataContext(tree);
      final VirtualFile vFile = CommonDataKeys.VIRTUAL_FILE.getData(context);
      if (vFile != null) {
        // Attempt to navigate to the virtual file with unknown file type will show a modal dialog
        // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
        if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType) return;

        //IDEA-84881 Don't autoscroll to very large files
        if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
      }
      Navigatable[] navigatables = CommonDataKeys.NAVIGATABLE_ARRAY.getData(context);
      if (navigatables != null) {
        if (navigatables.length > 1) {
          return;
        }
        for (Navigatable navigatable : navigatables) {
          // we are not going to open modal dialog during autoscrolling
          if (!navigatable.canNavigateToSource()) return;
        }
      }
      OpenSourceUtil.navigate(false, true, navigatables);
    }
  });
}
项目:intellij-ce-playground    文件:SMTRunnerUIActionsHandler.java   
public void onSelected(@Nullable final SMTestProxy selectedTestProxy,
                       @NotNull final TestResultsViewer viewer,
                       @NotNull final TestFrameworkRunningModel model) {
  //TODO: tests o "onSelected"
  SMRunnerUtil.runInEventDispatchThread(new Runnable() {
    public void run() {
      if (ScrollToTestSourceAction.isScrollEnabled(model)) {
        final Navigatable descriptor = TestsUIUtil.getOpenFileDescriptor(selectedTestProxy, model);
        if (descriptor != null) {
          OpenSourceUtil.navigate(false, descriptor);
        }
      }
    }
  }, ModalityState.NON_MODAL);
}
项目:intellij-ce-playground    文件:EditSourceForDialogAction.java   
public void actionPerformed(AnActionEvent e) {
  final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
  if (navigatableArray != null && navigatableArray.length > 0) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      public void run() {
        OpenSourceUtil.navigate(navigatableArray);
      }
    });
    DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
    if (dialog != null && dialog.isModal()) {
      dialog.doCancelAction();
    }
  }
}
项目:intellij-ce-playground    文件:ScopeTreeViewPanel.java   
private void initTree() {
  myTree.setCellRenderer(new MyTreeCellRenderer());
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(myTree);
  TreeUtil.installActions(myTree);
  EditSourceOnDoubleClickHandler.install(myTree);
  new TreeSpeedSearch(myTree);
  myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) {
    @Override
    @NotNull
    protected PsiElement[] getSelectedElements() {
      return getSelectedPsiElements();
    }
  };
  myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject);
  final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject);
  for (ScopeTreeStructureExpander expander : extensions) {
    myTree.addTreeWillExpandListener(expander);
  }
  if (extensions.length == 0) {
    myTree.addTreeWillExpandListener(new SortingExpandListener());
  }
  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (KeyEvent.VK_ENTER == e.getKeyCode()) {
        final Object component = myTree.getLastSelectedPathComponent();
        if (component instanceof DefaultMutableTreeNode) {
          final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component;
          if (selectedNode.isLeaf()) {
            OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
          }
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:OverridingDefineRenderer.java   
static void doClickAction(AnActionEvent e, Collection<Define> set, String title) {
  if (set.size() == 1) {
    final Navigatable n = (Navigatable)set.iterator().next().getPsiElement();
    OpenSourceUtil.navigate(true, n);
  } else {
    final Define[] array = set.toArray(new Define[set.size()]);
    NavigationUtil.getPsiElementPopup(ContainerUtil.map(array, new Function<Define, PsiElement>() {
      @Override
      public PsiElement fun(Define define) {
        return define.getPsiElement();
      }
    }, PsiElement.EMPTY_ARRAY), title).show(new RelativePoint((MouseEvent)e.getInputEvent()));
  }
}
项目:intellij-ce-playground    文件:TestNGResults.java   
public void valueChanged(TreeSelectionEvent e) {
  TreePath path = e.getPath();
  if (path == null) return;
  TestProxy proxy = (TestProxy)tree.getSelectedTest();
  if (proxy == null) return;
  if (ScrollToTestSourceAction.isScrollEnabled(TestNGResults.this)) {
    OpenSourceUtil.openSourcesFrom(tree, false);
  }
}
项目:tools-idea    文件:AutoScrollToSourceHandler.java   
protected void scrollToSource(final Component tree) {
  DataContext dataContext=DataManager.getInstance().getDataContext(tree);
  getReady(dataContext).doWhenDone(new Runnable() {
    @Override
    public void run() {
      DataContext context = DataManager.getInstance().getDataContext(tree);
      final VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(context);
      if (vFile != null) {
        // Attempt to navigate to the virtual file with unknown file type will show a modal dialog
        // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
        if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType) return;

        //IDEA-84881 Don't autoscroll to very large files
        if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
      }
      Navigatable[] navigatables = PlatformDataKeys.NAVIGATABLE_ARRAY.getData(context);
      if (navigatables != null) {
        if (navigatables.length > 1) {
          return;
        }
        for (Navigatable navigatable : navigatables) {
          // we are not going to open modal dialog during autoscrolling
          if (!navigatable.canNavigateToSource()) return;
        }
      }
      OpenSourceUtil.navigate(false, true, navigatables);
    }
  });
}
项目:tools-idea    文件:SMTRunnerUIActionsHandler.java   
public void onSelected(@Nullable final SMTestProxy selectedTestProxy,
                       @NotNull final TestResultsViewer viewer,
                       @NotNull final TestFrameworkRunningModel model) {
  //TODO: tests o "onSelected"
  SMRunnerUtil.runInEventDispatchThread(new Runnable() {
    public void run() {
      if (ScrollToTestSourceAction.isScrollEnabled(model)) {
        OpenSourceUtil.openSourcesFrom(model.getTreeView(), false);
      }
    }
  }, ModalityState.NON_MODAL);
}
项目:tools-idea    文件:EditSourceInCommitAction.java   
public void actionPerformed(AnActionEvent e) {
  final Navigatable[] navigatableArray = e.getData(PlatformDataKeys.NAVIGATABLE_ARRAY);
  if (navigatableArray != null && navigatableArray.length > 0) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        OpenSourceUtil.navigate(navigatableArray);
      }
    });
    myDialogWrapper.doCancelAction();
  }
}
项目:tools-idea    文件:ScopeTreeViewPanel.java   
private void initTree() {
  myTree.setCellRenderer(new MyTreeCellRenderer());
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(myTree);
  TreeUtil.installActions(myTree);
  EditSourceOnDoubleClickHandler.install(myTree);
  new TreeSpeedSearch(myTree);
  myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) {
    @Override
    @NotNull
    protected PsiElement[] getSelectedElements() {
      return getSelectedPsiElements();
    }
  };
  myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject);
  final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject);
  for (ScopeTreeStructureExpander expander : extensions) {
    myTree.addTreeWillExpandListener(expander);
  }
  if (extensions.length == 0) {
    myTree.addTreeWillExpandListener(new SortingExpandListener());
  }
  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (KeyEvent.VK_ENTER == e.getKeyCode()) {
        final Object component = myTree.getLastSelectedPathComponent();
        if (component instanceof DefaultMutableTreeNode) {
          final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component;
          if (selectedNode.isLeaf()) {
            OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
          }
        }
      }
    }
  });
  CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
项目:tools-idea    文件:OverridingDefineRenderer.java   
static void doClickAction(AnActionEvent e, Collection<Define> set, String title) {
  if (set.size() == 1) {
    final Navigatable n = (Navigatable)set.iterator().next().getPsiElement();
    OpenSourceUtil.navigate(true, n);
  } else {
    final Define[] array = set.toArray(new Define[set.size()]);
    NavigationUtil.getPsiElementPopup(ContainerUtil.map(array, new Function<Define, PsiElement>() {
      public PsiElement fun(Define define) {
        return define.getPsiElement();
      }
    }, PsiElement.EMPTY_ARRAY), title).show(new RelativePoint((MouseEvent)e.getInputEvent()));
  }
}
项目:tools-idea    文件:TestNGResults.java   
public void valueChanged(TreeSelectionEvent e) {
  TreePath path = e.getPath();
  if (path == null) return;
  TestProxy proxy = (TestProxy)tree.getSelectedTest();
  if (proxy == null) return;
  if (ScrollToTestSourceAction.isScrollEnabled(TestNGResults.this)) {
    OpenSourceUtil.openSourcesFrom(tree, false);
  }
}
项目:consulo    文件:AutoScrollToSourceHandler.java   
protected void scrollToSource(final Component tree) {
  DataContext dataContext=DataManager.getInstance().getDataContext(tree);
  getReady(dataContext).doWhenDone(new Runnable() {
    @Override
    public void run() {
      DataContext context = DataManager.getInstance().getDataContext(tree);
      final VirtualFile vFile = context.getData(PlatformDataKeys.VIRTUAL_FILE);
      if (vFile != null) {
        // Attempt to navigate to the virtual file with unknown file type will show a modal dialog
        // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
        if (vFile.getFileType() == UnknownFileType.INSTANCE || vFile.getFileType() instanceof INativeFileType) return;

        //IDEA-84881 Don't autoscroll to very large files
        if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
      }
      Navigatable[] navigatables = context.getData(PlatformDataKeys.NAVIGATABLE_ARRAY);
      if (navigatables != null) {
        if (navigatables.length > 1) {
          return;
        }
        for (Navigatable navigatable : navigatables) {
          // we are not going to open modal dialog during autoscrolling
          if (!navigatable.canNavigateToSource()) return;
        }
      }
      OpenSourceUtil.openSourcesFrom(context, false);
    }
  });
}
项目:consulo    文件:EditSourceInCommitAction.java   
public void actionPerformed(AnActionEvent e) {
  final Navigatable[] navigatableArray = e.getData(PlatformDataKeys.NAVIGATABLE_ARRAY);
  if (navigatableArray != null && navigatableArray.length > 0) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        OpenSourceUtil.navigate(navigatableArray);
      }
    });
    myDialogWrapper.doCancelAction();
  }
}
项目:consulo    文件:ScopeTreeViewPanel.java   
private void initTree() {
  myTree.setCellRenderer(new MyTreeCellRenderer());
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(myTree);
  TreeUtil.installActions(myTree);
  EditSourceOnDoubleClickHandler.install(myTree);
  new TreeSpeedSearch(myTree);
  myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) {
    @Override
    @Nonnull
    protected PsiElement[] getSelectedElements() {
      return getSelectedPsiElements();
    }
  };
  myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject);
  final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject);
  for (ScopeTreeStructureExpander expander : extensions) {
    myTree.addTreeWillExpandListener(expander);
  }
  if (extensions.length == 0) {
    myTree.addTreeWillExpandListener(new SortingExpandListener());
  }
  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (KeyEvent.VK_ENTER == e.getKeyCode()) {
        final Object component = myTree.getLastSelectedPathComponent();
        if (component instanceof DefaultMutableTreeNode) {
          final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component;
          if (selectedNode.isLeaf()) {
            OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
          }
        }
      }
    }
  });
  CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
项目:consulo-xml    文件:OverridingDefineRenderer.java   
static void doClickAction(AnActionEvent e, Collection<Define> set, String title) {
  if (set.size() == 1) {
    final Navigatable n = (Navigatable)set.iterator().next().getPsiElement();
    OpenSourceUtil.navigate(true, n);
  } else {
    final Define[] array = set.toArray(new Define[set.size()]);
    NavigationUtil.getPsiElementPopup(ContainerUtil.map(array, define -> define.getPsiElement(), PsiElement.EMPTY_ARRAY), title).show(new RelativePoint((MouseEvent)e.getInputEvent()));
  }
}
项目:intellij-ce-playground    文件:BaseNavigateToSourceAction.java   
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  OpenSourceUtil.navigate(myFocusEditor, getNavigatables(dataContext));
}
项目:intellij-ce-playground    文件:SelectInEditorHandler.java   
public static void selectInEditor(final JComponent component) {
  OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(component), false);
}
项目:intellij-ce-playground    文件:TreeView.java   
private JPanel createPanel() {
  createModel();
  myTree = new MyTree();
  myTree.setLineStyleAngled();
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.updateUI();
  myTree.setLargeModel(true);

  myTree.addKeyListener(new KeyAdapter() {
    public void keyPressed(KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
      }
    }
  });

  myTree.addMouseListener(new PopupHandler() {
    public void invokePopup(Component comp, int x, int y) {
      popupInvoked(comp, x, y);
    }
  });

  EditSourceOnDoubleClickHandler.install(myTree);

  myAutoScrollToSourceHandler.install(myTree);

  myOccurenceNavigatorSupport = new OccurenceNavigatorSupport(myTree) {
    protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) {
      if (!(node instanceof MessageNode)) {
        return null;
      }
      MessageNode messageNode = (MessageNode)node;
      AntBuildMessageView.MessageType type = messageNode.getType();

      if (type != AntBuildMessageView.MessageType.MESSAGE && type != AntBuildMessageView.MessageType.ERROR) {
        return null;
      }

      if (!isValid(messageNode.getFile())) {
        return null;
      }

      return new OpenFileDescriptor(myProject, messageNode.getFile(), messageNode.getOffset());
    }

    @Nullable
    public String getNextOccurenceActionName() {
      return AntBundle.message("ant.execution.next.error.warning.action.name");
    }

    @Nullable
    public String getPreviousOccurenceActionName() {
      return AntBundle.message("ant.execution.previous.error.warning.action.name");
    }
  };

  return JBUI.Panels.simplePanel(MessageTreeRenderer.install(myTree));
}
项目:intellij-ce-playground    文件:BrowserPanel.java   
public void actionPerformed(AnActionEvent e) {
  final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
  if (navigatableArray != null && navigatableArray.length > 0) {
    OpenSourceUtil.navigate(navigatableArray);
  }
}
项目:MvnRunner    文件:MvnOpenPomAction.java   
@Override
public void actionPerformed(AnActionEvent event) {
    MavenProject project = MvnModuleContextAction.getProject(event.getDataContext());
    VirtualFile pomFile = LocalFileSystem.getInstance().findFileByPath(project.getDirectory() + "/pom.xml");
    OpenSourceUtil.navigate(true, MavenNavigationUtil.createNavigatableForPom(event.getProject(), pomFile));
}
项目:tools-idea    文件:BaseNavigateToSourceAction.java   
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  OpenSourceUtil.navigate(myFocusEditor, getNavigatables(dataContext));
}
项目:tools-idea    文件:SelectInEditorHandler.java   
public static void selectInEditor(final JComponent component) {
  OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(component), false);
}
项目:tools-idea    文件:TreeView.java   
private JPanel createPanel() {
  createModel();
  myTree = new MyTree();
  myTree.setLineStyleAngled();
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.updateUI();
  myTree.setLargeModel(true);

  myTree.addKeyListener(new KeyAdapter() {
    public void keyPressed(KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
      }
    }
  });

  myTree.addMouseListener(new PopupHandler() {
    public void invokePopup(Component comp, int x, int y) {
      popupInvoked(comp, x, y);
    }
  });

  EditSourceOnDoubleClickHandler.install(myTree);

  myAutoScrollToSourceHandler.install(myTree);

  myOccurenceNavigatorSupport = new OccurenceNavigatorSupport(myTree) {
    protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) {
      if (!(node instanceof MessageNode)) {
        return null;
      }
      MessageNode messageNode = (MessageNode)node;
      AntBuildMessageView.MessageType type = messageNode.getType();

      if (type != AntBuildMessageView.MessageType.MESSAGE && type != AntBuildMessageView.MessageType.ERROR) {
        return null;
      }

      if (!isValid(messageNode.getFile())) {
        return null;
      }

      return new OpenFileDescriptor(myProject, messageNode.getFile(), messageNode.getOffset());
    }

    @Nullable
    public String getNextOccurenceActionName() {
      return AntBundle.message("ant.execution.next.error.warning.action.name");
    }

    @Nullable
    public String getPreviousOccurenceActionName() {
      return AntBundle.message("ant.execution.previous.error.warning.action.name");
    }
  };

  JPanel panel = new JPanel(new BorderLayout());

  JScrollPane scrollPane = MessageTreeRenderer.install(myTree);
  panel.add(scrollPane, BorderLayout.CENTER);
  return panel;
}
项目:tools-idea    文件:BrowserPanel.java   
public void actionPerformed(AnActionEvent e) {
  final Navigatable[] navigatableArray = e.getData(PlatformDataKeys.NAVIGATABLE_ARRAY);
  if (navigatableArray != null && navigatableArray.length > 0) {
    OpenSourceUtil.navigate(navigatableArray);
  }
}
项目:consulo-apache-ant    文件:TreeView.java   
private JPanel createPanel() {
  createModel();
  myTree = new MyTree();
  myTree.setLineStyleAngled();
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.updateUI();
  myTree.setLargeModel(true);

  myTree.addKeyListener(new KeyAdapter() {
    public void keyPressed(KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
      }
    }
  });

  myTree.addMouseListener(new PopupHandler() {
    public void invokePopup(Component comp, int x, int y) {
      popupInvoked(comp, x, y);
    }
  });

  EditSourceOnDoubleClickHandler.install(myTree);

  myAutoScrollToSourceHandler.install(myTree);

  myOccurenceNavigatorSupport = new OccurenceNavigatorSupport(myTree) {
    protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) {
      if (!(node instanceof MessageNode)) {
        return null;
      }
      MessageNode messageNode = (MessageNode)node;
      AntBuildMessageView.MessageType type = messageNode.getType();

      if (type != AntBuildMessageView.MessageType.MESSAGE && type != AntBuildMessageView.MessageType.ERROR) {
        return null;
      }

      if (!isValid(messageNode.getFile())) {
        return null;
      }

      return new OpenFileDescriptor(myProject, messageNode.getFile(), messageNode.getOffset());
    }

    @Nullable
    public String getNextOccurenceActionName() {
      return AntBundle.message("ant.execution.next.error.warning.action.name");
    }

    @Nullable
    public String getPreviousOccurenceActionName() {
      return AntBundle.message("ant.execution.previous.error.warning.action.name");
    }
  };

  JPanel panel = new JPanel(new BorderLayout());

  JScrollPane scrollPane = MessageTreeRenderer.install(myTree);
  panel.add(scrollPane, BorderLayout.CENTER);
  return panel;
}
项目:consulo-javaee    文件:OpenSourceAction.java   
@Override
public void actionPerformed(AnActionEvent event) {
    OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(component), true);
}
项目:consulo-javaee    文件:JamNodeDescriptor.java   
@Override
public void handleDoubleClickOrEnter(final SimpleTree tree, final InputEvent inputEvent) {
  OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(tree), false);
}
项目:consulo    文件:SMTestRunnerResultsForm.java   
@Override
protected JComponent createTestTreeView() {
  myTreeView = new SMTRunnerTestTreeView();

  myTreeView.setLargeModel(true);
  myTreeView.attachToModel(this);
  myTreeView.setTestResultsViewer(this);
  if (Registry.is("tests.view.old.statistics.panel")) {
    addTestsTreeSelectionListener(new TreeSelectionListener() {
      @Override
      public void valueChanged(TreeSelectionEvent e) {
        AbstractTestProxy selectedTest = getTreeView().getSelectedTest();
        if (selectedTest instanceof SMTestProxy) {
          myStatisticsPane.selectProxy(((SMTestProxy)selectedTest), this, false);
        }
      }
    });
  }

  final SMTRunnerTreeStructure structure = new SMTRunnerTreeStructure(myProject, myTestsRootNode);
  myTreeBuilder = new SMTRunnerTreeBuilder(myTreeView, structure);
  myTreeBuilder.setTestsComparator(TestConsoleProperties.SORT_ALPHABETICALLY.value(myProperties));
  Disposer.register(this, myTreeBuilder);

  myAnimator = new TestsProgressAnimator(myTreeBuilder);

  TrackRunningTestUtil.installStopListeners(myTreeView, myProperties, new Pass<AbstractTestProxy>() {
    @Override
    public void pass(AbstractTestProxy testProxy) {
      if (testProxy == null) return;
      final AbstractTestProxy selectedProxy = testProxy;
      //drill to the first leaf
      while (!testProxy.isLeaf()) {
        final List<? extends AbstractTestProxy> children = testProxy.getChildren();
        if (!children.isEmpty()) {
          final AbstractTestProxy firstChild = children.get(0);
          if (firstChild != null) {
            testProxy = firstChild;
            continue;
          }
        }
        break;
      }

      //pretend the selection on the first leaf
      //so if test would be run, tracking would be restarted
      myLastSelected = testProxy;

      //ensure scroll to source on explicit selection only
      if (ScrollToTestSourceAction.isScrollEnabled(SMTestRunnerResultsForm.this)) {
        final Navigatable descriptor = TestsUIUtil.getOpenFileDescriptor(selectedProxy, SMTestRunnerResultsForm.this);
        if (descriptor != null) {
          OpenSourceUtil.navigate(false, descriptor);
        }
      }
    }
  });

  //TODO always hide root node
  //myTreeView.setRootVisible(false);
  myUpdateQueue = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this);
  return myTreeView;
}
项目:consulo    文件:BaseNavigateToSourceAction.java   
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  OpenSourceUtil.navigate(myFocusEditor, getNavigatables(dataContext));
}
项目:consulo    文件:SelectInEditorHandler.java   
public static void selectInEditor(final JComponent component) {
  OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(component), false);
}