use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode in project binnavi by google.
the class CCriteriumFunctionsTest method testInsertCriterium.
@Test
public void testInsertCriterium() {
final CCriteriumTree cCriteriumTree = new CCriteriumTree();
final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
CCriteriumFunctions.insertCriterium(cCriteriumTree, cCriteriumTree.getRoot(), new COrCriterium());
assertTrue(cCriteriumTree.getRoot().getChildren().get(0).getCriterium() instanceof COrCriterium);
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode in project binnavi by google.
the class CCriteriumFunctionsTest method testRemoveAll.
@Test
public void testRemoveAll() {
final CCriteriumTree cCriteriumTree = new CCriteriumTree();
final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
final CCriteriumTreeNode child2 = new CCriteriumTreeNode(new COrCriterium());
cCriteriumTree.appendNode(child, child2);
CCriteriumFunctions.removeAll(cCriteriumTree);
assertEquals(0, cCriteriumTree.getRoot().getChildren().size());
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode 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());
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode 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());
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode 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);
}
}
}
}
Aggregations