Java 类com.intellij.ui.treeStructure.Tree 实例源码

项目:intellij-ce-playground    文件:CyclicDependenciesPanel.java   
@Nullable
private static PackageNode getSelectedPackage(final Tree tree) {
  TreePath[] paths = tree.getSelectionPaths();
  if (paths == null || paths.length != 1) return null;
  PackageDependenciesNode node = (PackageDependenciesNode)paths[0].getLastPathComponent();
  if (node.isRoot()) return null;
  if (node instanceof PackageNode) {
    return (PackageNode)node;
  }
  if (node instanceof FileNode) {
    return (PackageNode)node.getParent();
  }
  if (node instanceof ModuleNode){
    return (PackageNode)node.getChildAt(0);
  }
  return null;
}
项目:intellij-ce-playground    文件:ToDoTreeStructureTest.java   
public void testToDo1() throws Exception {
   AllTodosTreeBuilder all = new AllTodosTreeBuilder(new Tree(), new DefaultTreeModel(new DefaultMutableTreeNode()), myProject);
   all.init();

   AbstractTreeStructure structure = all.getTreeStructure();
   ((TodoTreeStructure)structure).setFlattenPackages(true);
   ProjectViewTestUtil.assertStructureEqual(structure,
                                            "Root\n" +
                                            " Summary\n" +
                                            "  package2 toDoFileCount=1,toDoItemCount=2\n" +
                                            "   JavaClass.java\n" +
                                            "    Item: (62,78)\n" +
                                            "    Item: (145,162)\n",
                                            myPrintInfo);

   checkOccurrences(all, new String[]{"Item: (62,78)", "Item: (145,162)"});
   Disposer.dispose(all);
}
项目:intellij-ce-playground    文件:MasterDetailsComponent.java   
private void createUIComponents() {
  myTree = new Tree() {
    public Dimension getPreferredScrollableViewportSize() {
      Dimension size = super.getPreferredScrollableViewportSize();
      size = new Dimension(size.width + 20, size.height);
      return size;
    }

    @SuppressWarnings({"NonStaticInitializer"})
    public JToolTip createToolTip() {
      final JToolTip toolTip = new JToolTip() {
        {
          setUI(new MultiLineTooltipUI());
        }
      };
      toolTip.setComponent(this);
      return toolTip;
    }
  };
}
项目:intellij-ce-playground    文件:AntExplorer.java   
public void dispose() {
  final KeymapListener listener = myKeymapListener;
  if (listener != null) {
    myKeymapListener = null;
    listener.stopListen();
  }

  final AntExplorerTreeBuilder builder = myBuilder;
  if (builder != null) {
    Disposer.dispose(builder);
    myBuilder = null;
  }

  final Tree tree = myTree;
  if (tree != null) {
    ToolTipManager.sharedInstance().unregisterComponent(tree);
    for (KeyStroke keyStroke : tree.getRegisteredKeyStrokes()) {
      tree.unregisterKeyboardAction(keyStroke);
    }
    myTree = null;
  }

  myProject = null;
  myConfig = null;
}
项目:intellij-ce-playground    文件:TreeUtilTest.java   
public void testRemoveSelected() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root);
  DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(child1, root, 0);
  DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(child2, root, 1);
  DefaultMutableTreeNode child11 = new DefaultMutableTreeNode("11");
  model.insertNodeInto(child11, child1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.clearSelection();
  TreeUtil.removeSelected(tree);
  assertEquals(2, model.getChildCount(root));
  assertEquals(1, model.getChildCount(child1));
  tree.setSelectionPath(TreeUtil.getPathFromRoot(child11));
  TreeUtil.removeSelected(tree);
  assertSame(child1, tree.getSelectionPath().getLastPathComponent());
  TreeUtil.removeSelected(tree);
  assertSame(child2, tree.getSelectionPath().getLastPathComponent());
  tree.setSelectionPath(new TreePath(root));
  assertEquals(1, model.getChildCount(root));
  TreeUtil.removeSelected(tree);
  assertSame(root, model.getRoot());
  assertEquals(1, model.getChildCount(root));
}
项目:intellij-ce-playground    文件:TreeUtilTest.java   
public void testMultiLevelRemove() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
  DefaultTreeModel model = new DefaultTreeModel(root) {
      @Override
      public void removeNodeFromParent(MutableTreeNode mutableTreeNode) {
        super.removeNodeFromParent((MutableTreeNode) mutableTreeNode.getParent());
      }
    };
  DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("1");
  model.insertNodeInto(node1, root, 0);
  DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("2");
  model.insertNodeInto(node2, node1, 0);
  JTree tree = new Tree(model);
  TreeExpandCollapse.expandAll(tree);
  tree.setSelectionPath(TreeUtil.getPathFromRoot(node2));
  TreeUtil.removeSelected(tree);
  assertEquals(0, root.getChildCount());
  assertEquals(root, tree.getSelectionPath().getLastPathComponent());
}
项目:intellij-ce-playground    文件:ExistingTemplatesComponent.java   
private static Tree createTree(TreeModel treeModel) {
  final Tree tree = new Tree(treeModel);

  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.setDragEnabled(false);
  tree.setEditable(false);
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);


  final TreeSpeedSearch speedSearch = new TreeSpeedSearch(
    tree,
    new Convertor<TreePath, String>() {
      public String convert(TreePath object) {
        final Object userObject = ((DefaultMutableTreeNode)object.getLastPathComponent()).getUserObject();
        return (userObject instanceof Configuration) ? ((Configuration)userObject).getName() : userObject.toString();
      }
    }
  );
  tree.setCellRenderer(new ExistingTemplatesTreeCellRenderer(speedSearch));

  return tree;
}
项目:intellij-ce-playground    文件:TestTreeView.java   
private static void paintRowData(Tree tree, String duration, Rectangle bounds, Graphics2D g, boolean isSelected, boolean hasFocus) {
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  g.setFont(tree.getFont().deriveFont(Font.PLAIN, UIUtil.getFontSize(UIUtil.FontSize.SMALL)));
  final FontMetrics metrics = tree.getFontMetrics(g.getFont());
  int totalWidth = metrics.stringWidth(duration) + 2;
  int x = bounds.x + bounds.width - totalWidth;
  g.setColor(isSelected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeBackground());
  final int leftOffset = 5;
  g.fillRect(x - leftOffset, bounds.y, totalWidth + leftOffset, bounds.height);
  g.translate(0, bounds.y - 1);
  if (isSelected) {
    if (!hasFocus && UIUtil.isUnderAquaBasedLookAndFeel()) {
      g.setColor(UIUtil.getTreeForeground());
    }
    else {
      g.setColor(UIUtil.getTreeSelectionForeground());
    }
  }
  else {
    g.setColor(new JBColor(0x808080, 0x808080));
  }
  g.drawString(duration, x, SimpleColoredComponent.getTextBaseLine(tree.getFontMetrics(tree.getFont()), bounds.height) + 1);
  g.translate(0, -bounds.y + 1);
  config.restore();
}
项目:intellij-ce-playground    文件:XDebuggerTreeCreator.java   
@NotNull
@Override
public Tree createTree(@NotNull Pair<XValue, String> descriptor) {
  final XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
  final XValueNodeImpl root = new XValueNodeImpl(tree, null, descriptor.getSecond(), descriptor.getFirst());
  tree.setRoot(root, true);
  tree.setSelectionRow(0);
  // expand root on load
  tree.expandNodesOnLoad(new Condition<TreeNode>() {
    @Override
    public boolean value(TreeNode node) {
      return node == root;
    }
  });
  return tree;
}
项目:intellij-ce-playground    文件:XDebuggerInstanceTreeCreator.java   
@NotNull
@Override
public Tree createTree(@NotNull Pair<XInstanceEvaluator, String> descriptor) {
  final XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
  final XValueNodeImpl root = new XValueNodeImpl(tree, null, descriptor.getSecond(),
                                                 new InstanceEvaluatorTreeRootValue(descriptor.getFirst(), descriptor.getSecond()));
  tree.setRoot(root, false);
  Condition<TreeNode> visibleRootCondition = new Condition<TreeNode>() {
    @Override
    public boolean value(TreeNode node) {
      return node.getParent() == root;
    }
  };
  tree.expandNodesOnLoad(visibleRootCondition);
  tree.selectNodeOnLoad(visibleRootCondition);

  return tree;
}
项目:intellij-ce-playground    文件:CvsTree.java   
public void init() {
  final TreeNode root = createRoot(myProject);
  myModel = new DefaultTreeModel(root, true);
  myTree = new Tree(myModel);
  add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);

  myTree.getSelectionModel().setSelectionMode(mySelectionMode);
  myTree.setCellRenderer(new Cvs2Renderer());
  addSelectionListener();

  final TreeUIHelper uiHelper = TreeUIHelper.getInstance();
  uiHelper.installTreeSpeedSearch(myTree);
  TreeUtil.installActions(myTree);

  myTree.requestFocus();
}
项目:intellij-ce-playground    文件:StructureFilteringStrategy.java   
public MyUI() {
  myStructureTree = new Tree();
  myStructureTree.setRootVisible(false);
  myStructureTree.setShowsRootHandles(true);
  myStructureTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(final TreeSelectionEvent e) {
      final List<FilePath> filePaths = new ArrayList<FilePath>(mySelection);

      mySelection.clear();
      final TreePath[] selectionPaths = myStructureTree.getSelectionPaths();
      if (selectionPaths != null) {
        for (TreePath selectionPath : selectionPaths) {
          Collections.addAll(mySelection, ((ChangesBrowserNode)selectionPath.getLastPathComponent()).getFilePathsUnder());
        }
      }

      if (Comparing.haveEqualElements(filePaths, mySelection)) return;

      for (ChangeListener listener : myListeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
  });
  myScrollPane = ScrollPaneFactory.createScrollPane(myStructureTree);
  myBuilder = new TreeModelBuilder(myProject, false);
}
项目:intellij-ce-playground    文件:ModulesDependenciesPanel.java   
public ModulesDependenciesPanel(final Project project, final Module[] modules) {
  super(new BorderLayout());
  myProject = project;
  myModules = modules;

  //noinspection HardCodedStringLiteral
  myRightTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("Root"));
  myRightTree = new Tree(myRightTreeModel);
  initTree(myRightTree, true);

  initLeftTree();

  mySplitter = new Splitter();
  mySplitter.setFirstComponent(new MyTreePanel(myLeftTree, myProject));
  mySplitter.setSecondComponent(new MyTreePanel(myRightTree, myProject));

  setSplitterProportion();
  add(mySplitter, BorderLayout.CENTER);
  add(createNorthPanel(), BorderLayout.NORTH);

  project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, this);
}
项目:intellij-ce-playground    文件:ModulesDependenciesPanel.java   
private static void initTree(Tree tree, boolean isRightTree) {
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setCellRenderer(new MyTreeCellRenderer());
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath o) {
      return o.getLastPathComponent().toString();
    }
  }, true);
  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree, tree), ActionManager.getInstance());
}
项目:intellij-ce-playground    文件:AssociationsEditor.java   
private void initUI() {
  myComponent = new JPanel(new BorderLayout());
  mySplitter = new JBSplitter("AssociationsEditor.dividerProportion", 0.3f);
  myComponent.add(mySplitter, BorderLayout.CENTER);

  JPanel leftPanel = new JPanel(new BorderLayout());
  leftPanel.setBorder(IdeBorderFactory.createTitledBorder("Project XSLT Files", false, new Insets(0, 0, 0, 0)));
  myTree = new Tree();
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(false);
  leftPanel.add(new JBScrollPane(myTree), BorderLayout.CENTER);
  mySplitter.setFirstComponent(leftPanel);

  myList = new JBList();
  myList.setCellRenderer(new MyCellRenderer());
  myList.setMinimumSize(new Dimension(120, 200));
  myList.getEmptyText().setText("No associated files");
  JPanel rightPanel = ToolbarDecorator.createDecorator(myList)
    .addExtraAction(AnActionButton.fromAction(new AddAssociationActionWrapper()))
    .addExtraAction(AnActionButton.fromAction(new RemoveAssociationAction()))
    .disableUpDownActions().disableAddAction().disableRemoveAction().createPanel();
  UIUtil.addBorder(rightPanel, IdeBorderFactory.createTitledBorder("Associated Files", false, new Insets(0, 0, 0, 0)));
  mySplitter.setSecondComponent(rightPanel);
}
项目:intellij-ce-playground    文件:ContentEntryTreeEditor.java   
public ContentEntryTreeEditor(Project project, List<ModuleSourceRootEditHandler<?>> editHandlers) {
  myProject = project;
  myEditHandlers = editHandlers;
  myTree = new Tree();
  myTree.setRootVisible(true);
  myTree.setShowsRootHandles(true);

  myEditingActionsGroup = new DefaultActionGroup();

  TreeUtil.installActions(myTree);
  new TreeSpeedSearch(myTree);

  myTreePanel = new MyPanel(new BorderLayout());
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
  myTreePanel.add(scrollPane, BorderLayout.CENTER);

  myTreePanel.setVisible(false);
  myDescriptor = FileChooserDescriptorFactory.createMultipleFoldersDescriptor();
  myDescriptor.setShowFileSystemRoots(false);
}
项目:intellij-ce-playground    文件:DisposerDebugger.java   
private DisposerTree(Disposable parent) {
  myModificationToFilter = -1;

  final DisposerStructure structure = new DisposerStructure(this);
  final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
  final Tree tree = new Tree(model);
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  myTreeBuilder = new FilteringTreeBuilder(tree, DisposerTree.this, structure, AlphaComparator.INSTANCE) {
    @Override
    public boolean isAutoExpandNode(NodeDescriptor nodeDescriptor) {
      return structure.getRootElement() == getOriginalNode(nodeDescriptor);
    }
  };
  myTreeBuilder.setFilteringMerge(200, MergingUpdateQueue.ANY_COMPONENT);
  Disposer.register(this, myTreeBuilder);
  myTree = tree;

  setLayout(new BorderLayout());
  add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);

  Disposer.getTree().addListener(this);

  Disposer.register(parent, this);
}
项目:intellij-ce-playground    文件:TodoPanel.java   
/**
 * @param currentFileMode if <code>true</code> then view doesn't have "Group By Packages" and "Flatten Packages"
 *                        actions.
 */
TodoPanel(Project project, TodoPanelSettings settings, boolean currentFileMode, Content content) {
  super(false, true);

  myProject = project;
  mySettings = settings;
  myCurrentFileMode = currentFileMode;
  myContent = content;

  DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
  myTree = new Tree(model);
  myTreeExpander = new MyTreeExpander();
  myOccurenceNavigator = new MyOccurenceNavigator();
  initUI();
  myTodoTreeBuilder = createTreeBuilder(myTree, model, myProject);
  Disposer.register(myProject, myTodoTreeBuilder);
  updateTodoFilter();
  myTodoTreeBuilder.setShowPackages(mySettings.arePackagesShown);
  myTodoTreeBuilder.setShowModules(mySettings.areModulesShown);
  myTodoTreeBuilder.setFlattenPackages(mySettings.areFlattenPackages);

  myVisibilityWatcher = new MyVisibilityWatcher();
  myVisibilityWatcher.install(this);
}
项目:intellij-ce-playground    文件:FileTemplateTabAsTree.java   
protected FileTemplateTabAsTree(String title) {
  super(title);
  myRoot = initModel();
  MyTreeModel treeModel = new MyTreeModel(myRoot);
  myTree = new Tree(treeModel);
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(myTree);

  myTree.expandPath(TreeUtil.getPathFromRoot(myRoot));
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  myTree.setCellRenderer(new MyTreeCellRenderer());
  myTree.expandRow(0);

  myTree.addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      onTemplateSelected();
    }
  });
  new TreeSpeedSearch(myTree);
}
项目:intellij-ce-playground    文件:DirectoryChooserModuleTreeView.java   
public DirectoryChooserModuleTreeView(@NotNull Project project) {
  myRootNode = new DefaultMutableTreeNode();
  myTree = new Tree(myRootNode);
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  myFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  myProject = project;
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.setCellRenderer(new MyTreeCellRenderer());
  new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath o) {
      final Object userObject = ((DefaultMutableTreeNode)o.getLastPathComponent()).getUserObject();
      if (userObject instanceof Module) {
        return ((Module)userObject).getName();
      }
      else {
        if (userObject == null) return "";
        return userObject.toString();
      }
    }
  }, true);
}
项目:intellij-ce-playground    文件:PyCharmEduInitialConfigurator.java   
private static void patchMainMenu() {
  final CustomActionsSchema schema = new CustomActionsSchema();

  final JTree actionsTree = new Tree();
  Group rootGroup = new Group("root", null, null);
  final DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootGroup);
  DefaultTreeModel model = new DefaultTreeModel(root);
  actionsTree.setModel(model);

  schema.fillActionGroups(root);
  for (int i = 0; i < root.getChildCount(); i++) {
    final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)root.getChildAt(i);
    if ("Main menu".equals(getItemId(treeNode))) {
      hideActionFromMainMenu(root, schema, treeNode);
    }
    hideActions(schema, root, treeNode, HIDDEN_ACTIONS);
  }
  CustomActionsSchema.getInstance().copyFrom(schema);
}
项目:IdeaCurrency    文件:Util.java   
public static void expandAll(Tree tree, TreePath parent, boolean expand) {
    TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (node.getChildCount() >= 0) {
        for (Enumeration e = node.children() ; e.hasMoreElements() ; ) {
            TreeNode n = (TreeNode) e.nextElement();
            TreePath path = parent.pathByAddingChild(n);
            expandAll(tree, path, expand);
        }
    }
    if (expand) {
        tree.expandPath(parent);
    } else {
        tree.collapsePath(parent);
    }
}
项目:SmartQQ4IntelliJ    文件:IMContactView.java   
protected void initTrees(Tree... trees) {
    for (Tree tree : trees) {
        if (tree != null) {
            initTree(tree);
        }
    }
}
项目:SmartQQ4IntelliJ    文件:IMContactView.java   
protected void initTree(Tree tree) {
    tree.setCellRenderer(new ContactTreeCellRenderer());
    tree.setShowsRootHandles(false);
    tree.setRootVisible(false);
    tree.addMouseListener(new IMContactDoubleClicker(getImPanel()));
    tree.setUI(new WideSelectionTreeUI() {

    });
}
项目:SmartQQ4IntelliJ    文件:IMContactView.java   
public void updateTrees(Tree... trees) {
    for (Tree tree : trees) {
        if (tree != null) {
            tree.updateUI();
        }
    }
}
项目:jfrog-idea-plugin    文件:ComponentUtils.java   
public static ActionToolbar createActionToolbar(Tree componentsTree) {
    DefaultActionGroup defaultActionGroup = new DefaultActionGroup();
    defaultActionGroup.addAction(ActionManager.getInstance().getAction("Xray.Refresh"));
    defaultActionGroup.addAction(new CollapseAllAction(componentsTree));
    defaultActionGroup.addAction(new ExpandAllAction(componentsTree));
    return ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR, defaultActionGroup, true);
}
项目:arma-intellij-plugin    文件:ArmaAddonsSettingsForm.java   
private void createUIComponents() {
    bundle = ResourceBundle.getBundle("com.kaylerrenslow.armaplugin.ProjectSettingsBundle");

    tfWithBrowseReferenceDirectory = new TextFieldWithBrowseButton(new JTextField(40));

    treeAddonsRoots_rootNode = new RootTreeNode();
    treeAddonsRoots = new Tree(treeAddonsRoots_rootNode);
    treeAddonsRoots.setCellRenderer(new MyColoredTreeCellRenderer());
    treeAddonsRoots.setHoldSize(true);
    treeAddonsRoots.addTreeSelectionListener(e -> {
        System.out.println("ArmaAddonsSettingsForm.createUIComponents e=" + e);
    });
}
项目:LineCounter-Plugin    文件:UIManager.java   
public static JPanel initUI(ToolWindow toolWindow) {
    // create UI
    final JPanel myToolWindowContent = new JPanel();
    final Content content = ContentFactory.SERVICE.getInstance().createContent(myToolWindowContent, "", false);
    myToolWindowContent.setLayout(new BoxLayout(myToolWindowContent, BoxLayout.Y_AXIS));
    toolWindow.getContentManager().removeAllContents(true);
    toolWindow.getContentManager().addContent(content);

    //create the tree by passing in the root node
    JTree tree = new Tree(new DefaultMutableTreeNode(new TreeNodeEntity(TreeNodeTypeEnum.ROOT, "Result")));
    tree.setOpaque(false);
    tree.setCellRenderer(new CustomTreeCellRenderer());
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setRootVisible(false);
    tree.setRowHeight(DimensionManager.reDimension(20));

    final JBScrollPane contentScrollPanel = new JBScrollPane(tree, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    contentScrollPanel.setName("contentScrollPanel");

    myToolWindowContent.add(Box.createRigidArea(new Dimension(0, DimensionManager.reDimension(10))));
    myToolWindowContent.add(createHeaderPanel()); // Header
    myToolWindowContent.add(Box.createRigidArea(new Dimension(0, DimensionManager.reDimension(10))));

    myToolWindowContent.add(contentScrollPanel); // Content scroll

    myToolWindowContent.add(Box.createRigidArea(new Dimension(0, DimensionManager.reDimension(10))));
    myToolWindowContent.add(createFooterPanel()); // Footer
    myToolWindowContent.add(Box.createRigidArea(new Dimension(0, DimensionManager.reDimension(10))));

    return myToolWindowContent;
}
项目:intellij-ce-playground    文件:ValueNodeDnD.java   
private DebuggerTreeNodeImpl[] getNodesToDrag() {
  return myTree.getSelectedNodes(DebuggerTreeNodeImpl.class, new Tree.NodeFilter<DebuggerTreeNodeImpl>() {
    public boolean accept(final DebuggerTreeNodeImpl node) {
      return node.getDescriptor() instanceof ValueDescriptorImpl;
    }
  });
}
项目:intellij-ce-playground    文件:CyclicDependenciesPanel.java   
private static void expandFirstLevel(Tree tree) {
  PackageDependenciesNode root = (PackageDependenciesNode)tree.getModel().getRoot();
  int count = root.getChildCount();
  if (count < 10) {
    for (int i = 0; i < count; i++) {
      PackageDependenciesNode child = (PackageDependenciesNode)root.getChildAt(i);
      expandNodeIfNotTooWide(tree, child);
    }
  }
}
项目:intellij-ce-playground    文件:CyclicDependenciesPanel.java   
private static Set<PsiFile> getSelectedScope(final Tree tree) {
  TreePath[] paths = tree.getSelectionPaths();
  if (paths == null || paths.length != 1) return EMPTY_FILE_SET;
  PackageDependenciesNode node = (PackageDependenciesNode)paths[0].getLastPathComponent();
  if (node.isRoot()) return EMPTY_FILE_SET;
  Set<PsiFile> result = new HashSet<PsiFile>();
  node.fillFiles(result, true);
  return result;
}
项目:intellij-ce-playground    文件:MigrationPanel.java   
private void initTree(final Tree tree) {
  final MigrationRootsTreeCellRenderer rootsTreeCellRenderer = new MigrationRootsTreeCellRenderer();
  tree.setCellRenderer(rootsTreeCellRenderer);
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  TreeUtil.expandAll(tree);
  SmartExpander.installOn(tree);
  EditSourceOnDoubleClickHandler.install(tree);
  new TreeSpeedSearch(tree);
  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(), ActionManager.getInstance());
}
项目:intellij-ce-playground    文件:AnalyzeDependenciesComponent.java   
/**
 * @return a created tree component (to be used as
 */
private JComponent createTreeComponent() {
  myExplanationTree = new Tree(new DefaultTreeModel(buildTree()));
  myExplanationTree.setRootVisible(false);
  myExplanationTree.setCellRenderer(new ExplanationTreeRenderer());
  DataManager.registerDataProvider(myExplanationTree, this);
  TreeUtil.expandAll(myExplanationTree);
  final NavigateAction navigateAction = new NavigateAction();
  navigateAction.registerCustomShortcutSet(new CustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1.getShortcuts()[0]), myExplanationTree);
  DefaultActionGroup group = new DefaultActionGroup();
  group.addAction(navigateAction);
  PopupHandler.installUnknownPopupHandler(myExplanationTree, group, ActionManager.getInstance());
  return new JBScrollPane(myExplanationTree);
}
项目:intellij-ce-playground    文件:CheckboxTreeHelper.java   
public void initTree(@NotNull final Tree tree, JComponent mainComponent, CheckboxTreeBase.CheckboxTreeCellRendererBase cellRenderer) {
  tree.setCellRenderer(cellRenderer);
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.setLineStyleAngled();
  TreeUtil.installActions(tree);

  setupKeyListener(tree, mainComponent);
  setupMouseListener(tree, mainComponent, cellRenderer);
}
项目:intellij-ce-playground    文件:CheckboxTreeHelper.java   
private void setupKeyListener(final Tree tree, final JComponent mainComponent) {
  mainComponent.addKeyListener(new KeyAdapter() {
    public void keyPressed(@NotNull KeyEvent e) {
      if (isToggleEvent(e, mainComponent)) {
        TreePath treePath = tree.getLeadSelectionPath();
        if (treePath == null) return;
        final Object o = treePath.getLastPathComponent();
        if (!(o instanceof CheckedTreeNode)) return;
        CheckedTreeNode firstNode = (CheckedTreeNode)o;
        if (!firstNode.isEnabled()) return;
        toggleNode(tree, firstNode);
        boolean checked = firstNode.isChecked();

        TreePath[] selectionPaths = tree.getSelectionPaths();
        for (int i = 0; selectionPaths != null && i < selectionPaths.length; i++) {
          final TreePath selectionPath = selectionPaths[i];
          final Object o1 = selectionPath.getLastPathComponent();
          if (!(o1 instanceof CheckedTreeNode)) continue;
          CheckedTreeNode node = (CheckedTreeNode)o1;
          setNodeState(tree, node, checked);
        }

        e.consume();
      }
    }
  });
}
项目:intellij-ce-playground    文件:CheckboxTreeHelper.java   
private void setupMouseListener(final Tree tree, JComponent mainComponent, final CheckboxTreeBase.CheckboxTreeCellRendererBase cellRenderer) {
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      int row = tree.getRowForLocation(e.getX(), e.getY());
      if (row < 0) return false;
      final Object o = tree.getPathForRow(row).getLastPathComponent();
      if (!(o instanceof CheckedTreeNode)) return false;
      Rectangle rowBounds = tree.getRowBounds(row);
      cellRenderer.setBounds(rowBounds);
      Rectangle checkBounds = cellRenderer.myCheckbox.getBounds();
      checkBounds.setLocation(rowBounds.getLocation());

      if (checkBounds.height == 0) checkBounds.height = checkBounds.width = rowBounds.height;

      final CheckedTreeNode node = (CheckedTreeNode)o;
      if (checkBounds.contains(e.getPoint())) {
        if (node.isEnabled()) {
          toggleNode(tree, node);
          tree.setSelectionRow(row);
          return true;
        }
      }
      else if (clickCount > 1 && clickCount % 2 == 0) {
        myEventDispatcher.getMulticaster().mouseDoubleClicked(node);
        return true;
      }

      return false;
    }
  }.installOn(mainComponent);
}
项目:intellij-ce-playground    文件:CheckboxTreeHelper.java   
@SuppressWarnings("unchecked")
public static <T> T[] getCheckedNodes(final Class<T> nodeType, @Nullable final Tree.NodeFilter<T> filter, final TreeModel model) {
  final ArrayList<T> nodes = new ArrayList<T>();
  final Object root = model.getRoot();
  if (!(root instanceof CheckedTreeNode)) {
    throw new IllegalStateException(
      "The root must be instance of the " + CheckedTreeNode.class.getName() + ": " + root.getClass().getName());
  }
  new Object() {
    @SuppressWarnings("unchecked")
    public void collect(CheckedTreeNode node) {
      if (node.isLeaf()) {
        Object userObject = node.getUserObject();
        if (node.isChecked() && userObject != null && nodeType.isAssignableFrom(userObject.getClass())) {
          final T value = (T)userObject;
          if (filter != null && !filter.accept(value)) return;
          nodes.add(value);
        }
      }
      else {
        for (int i = 0; i < node.getChildCount(); i++) {
          final TreeNode child = node.getChildAt(i);
          if (child instanceof CheckedTreeNode) {
            collect((CheckedTreeNode)child);
          }
        }
      }
    }
  }.collect((CheckedTreeNode)root);
  T[] result = (T[])Array.newInstance(nodeType, nodes.size());
  nodes.toArray(result);
  return result;
}
项目:intellij-ce-playground    文件:FilteringTreeBuilder.java   
public FilteringTreeBuilder(Tree tree,
                            ElementFilter filter,
                            AbstractTreeStructure structure,
                            @Nullable Comparator<NodeDescriptor> comparator) {
  super(tree,
        (DefaultTreeModel)tree.getModel(),
        structure instanceof FilteringTreeStructure ? structure
                                                    : new FilteringTreeStructure(filter, structure),
        comparator);

  myTree = tree;
  initRootNode();

  if (filter instanceof ElementFilter.Active) {
    ((ElementFilter.Active)filter).addListener(new ElementFilter.Listener() {
      @Override
      public ActionCallback update(final Object preferredSelection, final boolean adjustSelection, final boolean now) {
        return refilter(preferredSelection, adjustSelection, now);
      }
    }, this);
  }

  myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      TreePath newPath = e.getNewLeadSelectionPath();
      if (newPath != null) {
        Object element = getElementFor(newPath.getLastPathComponent());
        if (element != null) {
          myLastSuccessfulSelect = element;
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:CertificateTreeBuilder.java   
public void selectFirstCertificate() {
  if (!isEmpty()) {
    Tree tree = (Tree)getTree();
    TreePath path = TreeUtil.getFirstLeafNodePath(tree);
    tree.addSelectionPath(path);
  }
}
项目:intellij-ce-playground    文件:AbstractTreeUi.java   
private void maybeSetBusyAndScheduleWaiterForReady(boolean forcedBusy, @Nullable Object element) {
  if (!myShowBusyIndicator.asBoolean()) return;

  boolean canUpdateBusyState = false;

  if (forcedBusy) {
    if (canYield() || element != null && getTreeStructure().isToBuildChildrenInBackground(element)) {
      canUpdateBusyState = true;
    }
  } else {
    canUpdateBusyState = true;
  }

  if (!canUpdateBusyState) return;

  if (myTree instanceof Tree) {
    final Tree tree = (Tree)myTree;
    final boolean isBusy = !isReady(true) || forcedBusy;
    if (isBusy && tree.isShowing()) {
      tree.setPaintBusy(true);
      myBusyAlarm.cancelAllRequests();
      myBusyAlarm.addRequest(myWaiterForReady, myWaitForReadyTime.asInteger());
    }
    else {
      tree.setPaintBusy(false);
    }
  }
}