Search in sources :

Example 1 with SimpleTreeBuilder

use of com.intellij.ui.treeStructure.SimpleTreeBuilder in project intellij-community by JetBrains.

the class ChooseLibrariesDialogBase method createCenterPanel.

@Override
@Nullable
protected JComponent createCenterPanel() {
    myBuilder = new SimpleTreeBuilder(myTree, new DefaultTreeModel(new DefaultMutableTreeNode()), new MyStructure(getProject()), WeightBasedComparator.FULL_INSTANCE);
    myBuilder.initRootNode();
    myTree.setDragEnabled(false);
    myTree.setShowsRootHandles(true);
    UIUtil.setLineStyleAngled(myTree);
    myTree.setRootVisible(false);
    myTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(final TreeSelectionEvent e) {
            updateOKAction();
        }
    });
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            if (isOKActionEnabled()) {
                doOKAction();
                return true;
            }
            return false;
        }
    }.installOn(myTree);
    myTree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER");
    myTree.getActionMap().put("ENTER", getOKAction());
    final JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);
    pane.setPreferredSize(JBUI.size(500, 400));
    return pane;
}
Also used : SimpleTreeBuilder(com.intellij.ui.treeStructure.SimpleTreeBuilder) MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DoubleClickListener(com.intellij.ui.DoubleClickListener) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DoubleClickListener (com.intellij.ui.DoubleClickListener)1 SimpleTreeBuilder (com.intellij.ui.treeStructure.SimpleTreeBuilder)1 MouseEvent (java.awt.event.MouseEvent)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 Nullable (org.jetbrains.annotations.Nullable)1