Search in sources :

Example 6 with TreeModel

use of javax.swing.tree.TreeModel in project zaproxy by zaproxy.

the class JCheckBoxTreeUnitTest method shouldFailToSetATreeModelWithChildNonDefaultMutableTreeNodes.

@Test(expected = ClassCastException.class)
public void shouldFailToSetATreeModelWithChildNonDefaultMutableTreeNodes() {
    // Given
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    rootNode.add(new MutableTreeNodeImpl());
    TreeModel treeModel = new DefaultTreeModel(rootNode);
    JCheckBoxTree checkBoxTree = new JCheckBoxTree();
    // When
    checkBoxTree.setModel(treeModel);
// Then = ClassCastException
}
Also used : TreeModel(javax.swing.tree.TreeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Test(org.junit.Test)

Example 7 with TreeModel

use of javax.swing.tree.TreeModel in project zaproxy by zaproxy.

the class JCheckBoxTreeUnitTest method shouldNotFailToSetAnUndefinedTreeModel.

@Test
public void shouldNotFailToSetAnUndefinedTreeModel() {
    // Given
    TreeModel undefinedTreeModel = null;
    JCheckBoxTree checkBoxTree = new JCheckBoxTree();
    // When
    checkBoxTree.setModel(undefinedTreeModel);
// Then = No exception.
}
Also used : TreeModel(javax.swing.tree.TreeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Test(org.junit.Test)

Example 8 with TreeModel

use of javax.swing.tree.TreeModel in project zaproxy by zaproxy.

the class JCheckBoxTreeUnitTest method shouldFailToSetATreeModelWithRootNonDefaultMutableTreeNode.

@Test(expected = ClassCastException.class)
public void shouldFailToSetATreeModelWithRootNonDefaultMutableTreeNode() {
    // Given
    TreeModel treeModel = new DefaultTreeModel(new TreeNodeImpl());
    JCheckBoxTree checkBoxTree = new JCheckBoxTree();
    // When
    checkBoxTree.setModel(treeModel);
// Then = ClassCastException
}
Also used : TreeModel(javax.swing.tree.TreeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Test(org.junit.Test)

Example 9 with TreeModel

use of javax.swing.tree.TreeModel in project intellij-community by JetBrains.

the class ProjectViewTestUtil method getNodeForElement.

public static DefaultMutableTreeNode getNodeForElement(PsiElement element, AbstractProjectViewPSIPane pane) {
    JTree tree = pane.getTree();
    TreeModel model = tree.getModel();
    Object root = model.getRoot();
    return getNodeForElement(root, model, element);
}
Also used : TreeModel(javax.swing.tree.TreeModel)

Example 10 with TreeModel

use of javax.swing.tree.TreeModel in project intellij-community by JetBrains.

the class TreeUpdater method dispose.

@Override
public void dispose() {
    myTree.removePropertyChangeListener(JTree.TREE_MODEL_PROPERTY, myPropertyChangeListener);
    TreeModel model = myTree.getModel();
    if (model != null)
        model.removeTreeModelListener(myTreeModelListener);
    super.dispose();
}
Also used : TreeModel(javax.swing.tree.TreeModel)

Aggregations

TreeModel (javax.swing.tree.TreeModel)17 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)8 TreePath (javax.swing.tree.TreePath)4 Test (org.junit.Test)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)1 PsiElement (com.intellij.psi.PsiElement)1 Insets (java.awt.Insets)1 Rectangle (java.awt.Rectangle)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 HashSet (java.util.HashSet)1 JLabel (javax.swing.JLabel)1 TreeModelEvent (javax.swing.event.TreeModelEvent)1 TreeModelListener (javax.swing.event.TreeModelListener)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 Element (javax.swing.text.Element)1 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)1 TreeCellRenderer (javax.swing.tree.TreeCellRenderer)1