Search in sources :

Example 1 with JCriteriumTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode in project binnavi by google.

the class JCriteriumTreeModelTest method testRemoveNode.

@Test
public void testRemoveNode() {
    final JTree tree = new JTree();
    final CCriteriumTree cCriteriumTree = new CCriteriumTree();
    final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
    final JCriteriumTreeModel jCriterumTreeModel = new JCriteriumTreeModel(tree, cCriteriumTree, cCriteriaFactory.getConditions());
    final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
    cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
    final CCriteriumTreeNode child2 = new CCriteriumTreeNode(new CAndCriterium());
    cCriteriumTree.insertNode(cCriteriumTree.getRoot(), child2);
    final CCriteriumTreeNode child3 = new CCriteriumTreeNode(new CColorCriterium(m_graph));
    cCriteriumTree.appendNode(child2, child3);
    cCriteriumTree.remove(child);
    assertEquals(1, ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildCount());
    assertEquals(1, ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getChildCount());
    assertEquals(child2.getCriterium(), ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getCriterium());
}
Also used : JTree(javax.swing.JTree) JCriteriumTreeModel(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeModel) CColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriterium) CCriteriaFactory(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory) CAndCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CAndCriterium) JCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode) CCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTree) CCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode) Test(org.junit.Test)

Example 2 with JCriteriumTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode in project binnavi by google.

the class JCriteriumTreeModelTest method testAppendNode.

@Test
public void testAppendNode() {
    final JTree tree = new JTree();
    final CCriteriumTree cCriteriumTree = new CCriteriumTree();
    final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
    final JCriteriumTreeModel jCriterumTreeModel = new JCriteriumTreeModel(tree, cCriteriumTree, cCriteriaFactory.getConditions());
    final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
    cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
    assertEquals(1, ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildCount());
    assertEquals(child.getCriterium(), ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getCriterium());
}
Also used : JTree(javax.swing.JTree) JCriteriumTreeModel(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeModel) CColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriterium) CCriteriaFactory(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory) JCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode) CCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTree) CCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode) Test(org.junit.Test)

Example 3 with JCriteriumTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode in project binnavi by google.

the class CCriteriumFunctions method appendCriterium.

/**
   * Appends a criterium to the criterium tree. The criterium is selected through the given combo
   * box.
   *
   * @param jtree Visible criteria tree.
   * @param ctree Backs the visible criteria tree.
   * @param conditionBox Provides the criterium to add.
   */
public static void appendCriterium(final JCriteriumTree jtree, final CCriteriumTree ctree, final CConditionBox conditionBox) {
    final TreePath path = jtree.getSelectionPath();
    if (path != null) {
        final JCriteriumTreeNode criteriumTreeNode = (JCriteriumTreeNode) path.getLastPathComponent();
        final CCriteriumTreeNode parent = CCriteriumFunctions.findNode(ctree.getRoot(), criteriumTreeNode.getCriterium());
        final CCriteriumWrapper selectedItem = (CCriteriumWrapper) conditionBox.getSelectedItem();
        if (selectedItem != null) {
            final ICriterium criterium = selectedItem.getObject().createCriterium();
            if (criterium != null) {
                appendCriterium(ctree, parent, criterium);
            }
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) ICriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriterium) JCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode) CCriteriumWrapper(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.CCriteriumWrapper) CCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode)

Example 4 with JCriteriumTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode in project binnavi by google.

the class SetupCriteriaGraphTest method setUp.

public void setUp() throws CouldntLoadDataException, LoadCancelledException, FileReadException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final CCriteriaFactory criteriaFactory = new CCriteriaFactory(graph, null, null);
    final List<ICriteriumCreator> criteria = criteriaFactory.getConditions();
    final CCriteriumTree m_ctree = new CCriteriumTree();
    final JCriteriumTree jtree = new JCriteriumTree(m_ctree, criteria);
    jtree.getModel().setRoot(new JCriteriumTreeNode(m_ctree, m_ctree.getRoot().getCriterium(), criteria));
    final CCriteriumTreeNode parent = new CCriteriumTreeNode(null);
    final CCriteriumTreeNode child = new CCriteriumTreeNode(null);
    m_ctree.appendNode(parent, child);
}
Also used : JCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTree) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) JCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode) CCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTree) CCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode) ICriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator)

Example 5 with JCriteriumTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode in project binnavi by google.

the class JCriteriumTreeModelTest method testInsertNode.

@Test
public void testInsertNode() {
    final JTree tree = new JTree();
    final CCriteriumTree cCriteriumTree = new CCriteriumTree();
    final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
    final JCriteriumTreeModel jCriterumTreeModel = new JCriteriumTreeModel(tree, cCriteriumTree, cCriteriaFactory.getConditions());
    final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
    cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
    final CCriteriumTreeNode child2 = new CCriteriumTreeNode(new CAndCriterium());
    cCriteriumTree.insertNode(cCriteriumTree.getRoot(), child2);
    assertEquals(1, ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildCount());
    assertEquals(child2.getCriterium(), ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getCriterium());
    assertEquals(child.getCriterium(), ((JCriteriumTreeNode) ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getChildAt(0)).getCriterium());
}
Also used : JTree(javax.swing.JTree) JCriteriumTreeModel(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeModel) CColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriterium) CCriteriaFactory(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory) CAndCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CAndCriterium) JCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode) CCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTree) CCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode) Test(org.junit.Test)

Aggregations

CCriteriumTreeNode (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode)5 JCriteriumTreeNode (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode)5 CCriteriumTree (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTree)4 CCriteriaFactory (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory)3 CColorCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriterium)3 JCriteriumTreeModel (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeModel)3 JTree (javax.swing.JTree)3 Test (org.junit.Test)3 CAndCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CAndCriterium)2 CCriteriumWrapper (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.CCriteriumWrapper)1 ICriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriterium)1 ICriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator)1 JCriteriumTree (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTree)1 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)1 TreePath (javax.swing.tree.TreePath)1