Intellij equivalent for checkedTreeSelectionDialog

Hi,

In eclipse we can show hierarchical view of objects using org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.
Could you please suggest how this can be done in intellij. Please provide pointers to some examples if possible.

6 comments
Comment actions Permalink

You can look how are these used:

com.intellij.ui.CheckboxTree
com.intellij.ui.CheckboxTreeTable

0
Comment actions Permalink

Could you please refrain from cross-posting your questions here and on StackOverflow? The official plugin development support channel is this forum, and we will answer all of your questions here.

0
Comment actions Permalink

Hi,

I m new to Intellij. Could you please guide with some example.

In eclipse, CheckedTreeSelection Dialog, we have a implement the ITreeContentProvider and ILabelProvider. The content provider has getElements, getChildren, getParent and hasChildren methods. These are invoked internally. We put in the required code into these methods and thats it.

Do we have to do something similar for the CheckboxTree or do we need to do something else. Please guide.



PS: deleted the post from stackoverflow.

0
Comment actions Permalink

CheckboxTree uses a different API style. You need to add the nodes to the tree explicitly, using DefaultMutableTreeNode.add(), similarly to how you would work with a regular Swing JTree component (for which you can find many tutorials online).

To see how CheckboxTree is used, you can open the source code of IntelliJ IDEA Community Edition and invoke the "Find Usages" action on the CheckboxTree class.

0
Comment actions Permalink

Hi,

I was just trying out the same way. Below is my code snippet. I need to show it up in the editor. The dialog does not come up. Could you please point out what could be wrong.

CheckboxTree.CheckboxTreeCellRenderer renderer = new CheckboxTree.CheckboxTreeCellRenderer() {
            @Override
            public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {}
        };
        CheckboxTree checkboxTree;
        CheckedTreeNode root = new CheckedTreeNode(null);
        checkboxTree = new CheckboxTree(renderer, root);
        checkboxTree.setRootVisible(false);

for(MyObject myObj : myObjList) {
            DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode(myObj);
               if (myObj has children) {
                 for (MyObj children : myObj.getChildren()) {
                     CheckedTreeNode newChild = new CheckedTreeNode(children);
                     newChild.setChecked(false);
                     parentNode.add(newChild);
                 }
               }
            root.add(parentNode);
        }

checkboxTree.setRootVisible(false);
        TreeUtil.expandAll(checkboxTree);
        checkboxTree.setVisible(true);
        checkboxTree.repaint();
        editor.getComponent().add(checkboxTree, BorderLayout.CENTER);  // where editor is com.intellij.openapi.editor.Editor object,, which is the current editor that is open, from where this code is invoked

0
Comment actions Permalink

You cannot add any components to the editor directly. You need to enclose the tree into a dialog or a popup.

0

Please sign in to leave a comment.