com.intellij.util.EditSourceOnDoubleClickHandler Java Examples

The following examples show how to use com.intellij.util.EditSourceOnDoubleClickHandler. 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 vote down vote up
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: TestTreeView.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void installHandlers() {
  EditSourceOnDoubleClickHandler.install(this);
  new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
    public String convert(final TreePath path) {
      final AbstractTestProxy testProxy = getSelectedTest(path);
      if (testProxy == null) return null;
      return testProxy.getName();
    }
  });
  TreeUtil.installActions(this);
  PopupHandler.installPopupHandler(this, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
}
 
Example #3
Source File: SpecificFilesViewDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected SpecificFilesViewDialog(@Nonnull Project project,
                                  @Nonnull String title,
                                  @Nonnull Key<Stream<VirtualFile>> shownDataKey,
                                  @Nonnull List<VirtualFile> initDataFiles) {
  super(project, true);
  setTitle(title);
  myProject = project;
  final Runnable closer = () -> this.close(0);
  myView = new ChangesListView(project) {
    @Override
    public void calcData(Key<?> key, DataSink sink) {
      super.calcData(key, sink);
      if (shownDataKey == key) {
        sink.put(shownDataKey, getSelectedFiles());
      }
    }

    @Override
    protected void editSourceRegistration() {
      EditSourceOnDoubleClickHandler.install(this, closer);
      EditSourceOnEnterKeyHandler.install(this, closer);
    }
  };
  myChangeListManager = ChangeListManager.getInstance(project);
  createPanel();
  setOKButtonText("Close");

  init();
  initData(initDataFiles);
  myView.setMinimumSize(new Dimension(100, 100));
}
 
Example #4
Source File: DependenciesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initTree(final MyTree tree, boolean isRightTree) {
  tree.setCellRenderer(new MyTreeCellRenderer());
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  SmartExpander.installOn(tree);
  EditSourceOnDoubleClickHandler.install(tree);
  new TreeSpeedSearch(tree);

  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree), ActionManager.getInstance());


}
 
Example #5
Source File: AbstractProjectViewPSIPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #6
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #7
Source File: PantsConsoleViewPanel.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
public PantsConsoleViewPanel(Project project, ConsoleView console) {
  myProject = project;
  myConfiguration = ErrorTreeViewConfiguration.getInstance(project);
  setLayout(new BorderLayout());

  AutoScrollToSourceHandler autoScrollToSourceHandler = new AutoScrollToSourceHandler() {
    @Override
    protected boolean isAutoScrollMode() {
      return myConfiguration.isAutoscrollToSource();
    }

    @Override
    protected void setAutoScrollMode(boolean state) {
      myConfiguration.setAutoscrollToSource(state);
    }
  };

  JPanel myMessagePanel = new JPanel(new BorderLayout());

  DefaultMutableTreeNode root = new DefaultMutableTreeNode();
  final DefaultTreeModel treeModel = new DefaultTreeModel(root);
  Tree tree = createTree(treeModel);
  tree.getEmptyText().setText(IdeBundle.message("errortree.noMessages"));

  autoScrollToSourceHandler.install(tree);
  TreeUtil.installActions(tree);

  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.setLargeModel(true);

  JScrollPane scrollPane = NewErrorTreeRenderer.install(tree);
  scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
  myMessagePanel.add(console.getComponent(), BorderLayout.CENTER);

  add(createToolbarPanel(), BorderLayout.WEST);

  add(myMessagePanel, BorderLayout.CENTER);

  EditSourceOnDoubleClickHandler.install(tree);
}
 
Example #8
Source File: DualView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void installEditSourceOnDoubleClickHandler() {
  EditSourceOnDoubleClickHandler.install(myTreeView);
  EditSourceOnDoubleClickHandler.install(myFlatView);
}
 
Example #9
Source File: TreeUIHelperImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void installEditSourceOnDoubleClick(final JTree tree) {
  EditSourceOnDoubleClickHandler.install(tree);
}
 
Example #10
Source File: NewErrorTreeViewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) {
  myProject = project;
  myHelpId = helpId;
  myConfiguration = ErrorTreeViewConfiguration.getInstance(project);
  setLayout(new BorderLayout());

  myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() {
    @Override
    protected boolean isAutoScrollMode() {
      return myConfiguration.isAutoscrollToSource();
    }

    @Override
    protected void setAutoScrollMode(boolean state) {
      myConfiguration.setAutoscrollToSource(state);
    }
  };

  myMessagePanel = new JPanel(new BorderLayout());

  myErrorViewStructure = new ErrorViewStructure(project, canHideWarningsOrInfos());
  DefaultMutableTreeNode root = new DefaultMutableTreeNode();
  root.setUserObject(myErrorViewStructure.createDescriptor(myErrorViewStructure.getRootElement(), null));
  final DefaultTreeModel treeModel = new DefaultTreeModel(root);
  myTree = new Tree(treeModel) {
    @Override
    public void setRowHeight(int i) {
      super.setRowHeight(0);
      // this is needed in order to make UI calculate the height for each particular row
    }
  };
  myBuilder = new ErrorViewTreeBuilder(myTree, treeModel, myErrorViewStructure);

  myExporterToTextFile = new ErrorViewTextExporter(myErrorViewStructure);
  myOccurenceNavigatorSupport = new MyOccurenceNavigatorSupport(myTree);

  myAutoScrollToSourceHandler.install(myTree);
  TreeUtil.installActions(myTree);
  UIUtil.setLineStyleAngled(myTree);
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.setLargeModel(true);

  JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree);
  scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
  myMessagePanel.add(scrollPane, BorderLayout.CENTER);

  if (createToolbar) {
    add(createToolbarPanel(rerunAction), BorderLayout.WEST);
  }

  add(myMessagePanel, BorderLayout.CENTER);

  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        navigateToSource(false);
      }
    }
  });

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

  EditSourceOnDoubleClickHandler.install(myTree);
}
 
Example #11
Source File: UpdateInfoTree.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void createTree() {
  SmartExpander.installOn(myTree);
  SelectionSaver.installOn(myTree);
  createTreeModel();

  myTree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent e) {
      AbstractTreeNode treeNode = (AbstractTreeNode)e.getPath().getLastPathComponent();
      VirtualFilePointer pointer = null;
      if (treeNode instanceof FileTreeNode) {
        pointer = ((FileTreeNode)treeNode).getFilePointer();
        if (!pointer.isValid()) pointer = null;
      }
      if (pointer != null) {
        mySelectedUrl = getFilePath(pointer);
        mySelectedFile = pointer.getFile();
      }
      else {
        mySelectedUrl = null;
        mySelectedFile = null;
      }
    }
  });
  myTree.setCellRenderer(new UpdateTreeCellRenderer());
  TreeUtil.installActions(myTree);
  new TreeSpeedSearch(myTree, path -> {
    Object last = path.getLastPathComponent();
    if (last instanceof AbstractTreeNode) {
      return ((AbstractTreeNode)last).getText();
    }
    return TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING.convert(path);
  }, true);

  myTree.addMouseListener(new PopupHandler() {
    public void invokePopup(Component comp, int x, int y) {
      final DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction("UpdateActionGroup");
      if (group != null) { //if no UpdateActionGroup was configured
        ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UPDATE_POPUP, group);
        popupMenu.getComponent().show(comp, x, y);
      }
    }
  });
  EditSourceOnDoubleClickHandler.install(myTree);
  EditSourceOnEnterKeyHandler.install(myTree);

  myTree.setSelectionRow(0);
}
 
Example #12
Source File: ChangesListView.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void editSourceRegistration() {
  EditSourceOnDoubleClickHandler.install(this);
  EditSourceOnEnterKeyHandler.install(this);
}