public DependenciesTab()

in tapestry/src/main/java/com/intellij/tapestry/intellij/toolwindow/DependenciesTab.java [46:154]


    public DependenciesTab() {
        _splitPane.setDividerLocation(0.5);

        _dependenciesTree.setCellRenderer(new DependenciesTreeCellRenderer());

        _navigateToElementAction = new NavigateToElementAction();
        _navigateToUsageAction = new NavigateToUsageAction();

      _dependenciesTree.addMouseListener(new PopupHandler() {
        @Override
        public void invokePopup(Component comp, int x, int y) {
          TreePath selected = _dependenciesTree.getSelectionPath();

          // When object it's selected
          if (selected != null) {
            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) _dependenciesTree.getSelectionPath().getLastPathComponent();
            Object selectedObject = selectedNode.getUserObject();

            if (selectedObject instanceof InjectedElement || selectedObject instanceof PresentationLibraryElement || selectedObject instanceof IResource) {
              DefaultActionGroup actions = DefaultActionGroup.createPopupGroup(() -> "NavigateToGroup");

              actions.add(_navigateToElementAction);
              actions.add(_navigateToUsageAction);

              actions.addSeparator();

              actions.add(new CollapseAllAction(_dependenciesTree));
              actions.add(new ExpandAllAction(_dependenciesTree));

              ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu("ElementUsagesTree", actions);
              popupMenu.getComponent().show(comp, x, y);
            }
          }

          // When object it's not selected
          if (selected == null) {
            DefaultActionGroup actions = DefaultActionGroup.createPopupGroup(() -> "NavigateToGroup");

            actions.add(new CollapseAllAction(_dependenciesTree));
            actions.add(new ExpandAllAction(_dependenciesTree));

            ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu("ElementUsagesTree", actions);
            popupMenu.getComponent().show(comp, x, y);
          }
        }
      });

      new DoubleClickListener() {
        @Override
        protected boolean onDoubleClick(@NotNull MouseEvent e) {
          TreePath selected = _dependenciesTree.getSelectionPath();

          // When is double click
          if (selected != null) {
            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) _dependenciesTree.getSelectionPath().getLastPathComponent();
            Object selectedObject = selectedNode.getUserObject();

            if (selectedNode.getParent() instanceof InjectedPagesNode || selectedNode.getParent() instanceof EmbeddedComponentsNode) {
              if (selectedObject instanceof InjectedElement) {
                ((IntellijJavaField) ((InjectedElement) selectedObject).getField()).getPsiField().navigate(true);
              }
            }
            return true;
          }
          return false;
        }
      }.installOn(_dependenciesTree);


        _dependenciesTree.addTreeSelectionListener(
                new TreeSelectionListener() {
                    @Override
                    public void valueChanged(TreeSelectionEvent event) {
                        if (event.getNewLeadSelectionPath() != null) {
                          _dependenciesTree.getSelectionCount();
                          _documentationPane.setText(null);

                          myPresentations.getPresentation(_navigateToElementAction).setEnabled(false);
                          myPresentations.getPresentation(_navigateToUsageAction).setEnabled(false);
                        }
                    }
                }
        );
        _dependenciesTree.setVisible(false);

        myPresentations.getPresentation(_navigateToElementAction).setEnabled(false);
        myPresentations.getPresentation(_navigateToUsageAction).setEnabled(false);

        CollapseAllAction collapseAllAction = new CollapseAllAction(_dependenciesTree);
        ExpandAllAction expandAllAction = new ExpandAllAction(_dependenciesTree);

        ActionButton navigateToElement = new ActionButton(_navigateToElementAction, myPresentations.getPresentation(_navigateToElementAction), "Navigate to Element", new Dimension(24, 24));
        navigateToElement.setToolTipText("Navigate to Element");
        _toolbar.add(navigateToElement);

        ActionButton navigateToUsage = new ActionButton(_navigateToUsageAction, myPresentations.getPresentation(_navigateToUsageAction), "Navigate to Usage", new Dimension(24, 24));
        navigateToUsage.setToolTipText("Navigate to Usage");
        _toolbar.add(navigateToUsage);
        _toolbar.addSeparator();

        ActionButton expandAll = new ActionButton(expandAllAction, myPresentations.getPresentation(expandAllAction), expandAllAction.getTemplatePresentation().getText(), new Dimension(24, 24));
        expandAll.setToolTipText("Expand All");
        _toolbar.add(expandAll);

        ActionButton collapseAll = new ActionButton(collapseAllAction, myPresentations.getPresentation(collapseAllAction), collapseAllAction.getTemplatePresentation().getText(), new Dimension(24, 24));
        collapseAll.setToolTipText("Collapse All");
        _toolbar.add(collapseAll);

    }