com.intellij.util.OpenSourceUtil Java Examples
The following examples show how to use
com.intellij.util.OpenSourceUtil.
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: GlobalConfigsToolWindowPanel.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: EditSourceForDialogAction.java From consulo with Apache License 2.0 | 6 votes |
@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(); } } }
Example #3
Source File: BlazeProblemsViewPanel.java From intellij with Apache License 2.0 | 5 votes |
private void scrollToSource(Component tree) { DataContext dataContext = DataManager.getInstance().getDataContext(tree); getReady(dataContext) .doWhenDone( () -> TransactionGuard.submitTransaction( ApplicationManager.getApplication(), () -> { DataContext context = DataManager.getInstance().getDataContext(tree); Navigatable navigatable = BLAZE_CONSOLE_NAVIGATABLE_DATA_KEY.getData(context); if (navigatable != null) { OpenSourceUtil.navigate(false, true, navigatable); } })); }
Example #4
Source File: AutoScrollToSourceHandler.java From consulo with Apache License 2.0 | 5 votes |
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); } }); }
Example #5
Source File: EditSourceInCommitAction.java From consulo with Apache License 2.0 | 5 votes |
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(); } }
Example #6
Source File: AbstractProjectViewPSIPane.java From consulo with Apache License 2.0 | 5 votes |
private void initTree() { myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.expandPath(new TreePath(myTree.getModel().getRoot())); EditSourceOnDoubleClickHandler.install(myTree); ToolTipManager.sharedInstance().registerComponent(myTree); TreeUtil.installActions(myTree); new MySpeedSearch(myTree); myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { TreePath path = getSelectedPath(); if (path != null && !myTree.getModel().isLeaf(path.getLastPathComponent())) { return; } DataContext dataContext = DataManager.getInstance().getDataContext(myTree); OpenSourceUtil.openSourcesFrom(dataContext, ScreenReader.isActive()); } 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(); } } } }); CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP); }
Example #7
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
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); }
Example #8
Source File: SMTestRunnerResultsForm.java From consulo with Apache License 2.0 | 4 votes |
@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; }
Example #9
Source File: BaseNavigateToSourceAction.java From consulo with Apache License 2.0 | 4 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { DataContext dataContext = e.getDataContext(); OpenSourceUtil.navigate(myFocusEditor, getNavigatables(dataContext)); }
Example #10
Source File: SelectInEditorHandler.java From consulo with Apache License 2.0 | 4 votes |
public static void selectInEditor(final JComponent component) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(component), false); }