コード例 #1
0
  private void createTree() {
    SmartExpander.installOn(myTree);
    SelectionSaver.installOn(myTree);
    refreshTree();

    myTree.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {
            AbstractTreeNode treeNode = (AbstractTreeNode) e.getPath().getLastPathComponent();
            if (treeNode instanceof FileTreeNode) {
              final VirtualFilePointer pointer = ((FileTreeNode) treeNode).getFilePointer();
              mySelectedUrl = pointer.getUrl();
              mySelectedFile = pointer.getFile();
            } else {
              mySelectedUrl = null;
              mySelectedFile = null;
            }
          }
        });
    myTree.setCellRenderer(new UpdateTreeCellRenderer());
    TreeUtil.installActions(myTree);
    new TreeSpeedSearch(
        myTree,
        new Convertor<TreePath, String>() {
          public String convert(TreePath path) {
            Object last = path.getLastPathComponent();
            if (last instanceof AbstractTreeNode) {
              return ((AbstractTreeNode) last).getName();
            }
            return TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING.convert(path);
          }
        });

    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);
  }
コード例 #2
0
  public ChangesListView(final Project project) {
    myProject = project;

    getModel().setRoot(ChangesBrowserNode.create(myProject, TreeModelBuilder.ROOT_NODE_VALUE));

    setShowsRootHandles(true);
    setRootVisible(false);

    new TreeSpeedSearch(this, new NodeToTextConvertor());
    SmartExpander.installOn(this);
    myCopyProvider = new TreeCopyProvider(this);
    new TreeLinkMouseListener(new ChangesBrowserNodeRenderer(myProject, false, false))
        .installOn(this);
  }
コード例 #3
0
  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());
  }
コード例 #4
0
  private void initTreeListeners() {
    myTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              @Override
              public void valueChanged(TreeSelectionEvent e) {
                syncBrowser();
                if (isAutoScrollMode()) {
                  OpenSourceUtil.openSourcesFrom(
                      DataManager.getInstance().getDataContext(InspectionResultsView.this), false);
                }
              }
            });

    EditSourceOnDoubleClickHandler.install(myTree);

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

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

    SmartExpander.installOn(myTree);
  }
コード例 #5
0
  private void initTree(Tree tree) {
    tree.setCellRenderer(new MyTreeCellRenderer());
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.setLineStyleAngled();

    TreeUtil.installActions(tree);
    SmartExpander.installOn(tree);
    new TreeSpeedSearch(tree);
    tree.addTreeWillExpandListener(
        new TreeWillExpandListener() {
          @Override
          public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
            ((PackageDependenciesNode) event.getPath().getLastPathComponent()).sortChildren();
          }

          @Override
          public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {}
        });

    PopupHandler.installUnknownPopupHandler(
        tree, createTreePopupActions(), ActionManager.getInstance());
  }
コード例 #6
0
  private void initTree() {
    myTree.setRootVisible(false);
    myTree.setShowsRootHandles(true);
    SmartExpander.installOn(myTree);
    TreeUtil.installActions(myTree);
    EditSourceOnDoubleClickHandler.install(myTree);
    myTree.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
              TreePath leadSelectionPath = myTree.getLeadSelectionPath();
              if (leadSelectionPath == null) return;

              DefaultMutableTreeNode node =
                  (DefaultMutableTreeNode) leadSelectionPath.getLastPathComponent();
              if (node instanceof UsageNode) {
                final Usage usage = ((UsageNode) node).getUsage();
                usage.navigate(false);
                usage.highlightInEditor();
              } else if (node.isLeaf()) {
                Navigatable navigatable = getNavigatableForNode(node);
                if (navigatable != null && navigatable.canNavigate()) {
                  navigatable.navigate(false);
                }
              }
            }
          }
        });

    TreeUtil.selectFirstNode(myTree);
    PopupHandler.installPopupHandler(
        myTree, IdeActions.GROUP_USAGE_VIEW_POPUP, ActionPlaces.USAGE_VIEW_POPUP);
    // TODO: install speed search. Not in openapi though. It makes sense to create a common
    // TreeEnchancer service.
  }