Search in sources :

Example 1 with ICriteriumCreator

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator in project binnavi by google.

the class CCriteriumFunctionsTest method findNode.

@Test
public void findNode() {
    final CCriteriumTree cCriteriumTree = new CCriteriumTree();
    final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
    final List<ICriteriumCreator> criteria = cCriteriaFactory.getConditions();
    final CConditionBox box = new CConditionBox(criteria);
    final JCriteriumTree jtree = new JCriteriumTree(cCriteriumTree, criteria);
    final CColorCriterium colorado = new CColorCriterium(m_graph);
    final CCriteriumTreeNode child = new CCriteriumTreeNode(colorado);
    cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
    final TreePath path = new TreePath(((JCriteriumTreeNode) jtree.getModel().getRoot()).getFirstChild());
    jtree.setSelectionPath(path);
    box.setSelectedIndex(6);
    CCriteriumFunctions.appendCriterium(jtree, cCriteriumTree, box);
    assertEquals(null, CCriteriumFunctions.findNode(cCriteriumTree.getRoot(), new CTextCriterium()));
    assertEquals(child, CCriteriumFunctions.findNode(cCriteriumTree.getRoot(), colorado));
}
Also used : JCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTree) TreePath(javax.swing.tree.TreePath) CConditionBox(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CConditionBox) CTextCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CTextCriterium) CColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriterium) CCriteriaFactory(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory) 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) Test(org.junit.Test)

Example 2 with ICriteriumCreator

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator in project binnavi by google.

the class CCriteriumFunctionsTest method testAppendTwoNoPath.

@Test
public void testAppendTwoNoPath() {
    final CCriteriumTree cCriteriumTree = new CCriteriumTree();
    final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
    final List<ICriteriumCreator> criteria = cCriteriaFactory.getConditions();
    final CConditionBox box = new CConditionBox(criteria);
    final JCriteriumTree jtree = new JCriteriumTree(cCriteriumTree, criteria);
    final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
    cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
    final TreePath path = new TreePath(((JCriteriumTreeNode) jtree.getModel().getRoot()).getFirstChild());
    jtree.setSelectionPath(path);
    box.setSelectedIndex(6);
    CCriteriumFunctions.appendCriterium(jtree, cCriteriumTree, box);
    assertTrue(cCriteriumTree.getRoot().getChildren().get(0).getChildren().get(0).getCriterium() instanceof CSelectionCriterium);
    assertFalse(cCriteriumTree.getRoot().getChildren().get(0).getChildren().get(0).getCriterium() instanceof CTagCriterium);
}
Also used : CSelectionCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CSelectionCriterium) JCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTree) TreePath(javax.swing.tree.TreePath) CConditionBox(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CConditionBox) CColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriterium) CCriteriaFactory(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory) CCriteriumTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTree) CCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode) CTagCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CTagCriterium) ICriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator) Test(org.junit.Test)

Example 3 with ICriteriumCreator

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator 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 4 with ICriteriumCreator

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator in project binnavi by google.

the class CCriteriaFactory method getConditions.

/**
   * Returns all available criterium creators.
   *
   * @return All available criterium creators.
   */
public List<ICriteriumCreator> getConditions() {
    final List<ICriteriumCreator> conditions = new ArrayList<ICriteriumCreator>();
    conditions.add(new CTextCriteriumCreator());
    conditions.add(new CTagCriteriumCreator(m_tagManager));
    conditions.add(new CColorCriteriumCreator(m_graph));
    conditions.add(new CIndegreeCriteriumCreator());
    conditions.add(new COutdegreeCriteriumCreator());
    conditions.add(new CVisibilityCriteriumCreator());
    conditions.add(new CSelectionCriteriumCreator());
    for (@SuppressWarnings("rawtypes") final IPlugin plugin : PluginInterface.instance().getPluginRegistry()) {
        if (plugin instanceof ICriteriaSelectionPlugin) {
            final ICriteriaSelectionPlugin cplugin = (ICriteriaSelectionPlugin) plugin;
            conditions.add(new CPluginCriteriumCreator(m_view2D, cplugin));
        }
    }
    return conditions;
}
Also used : CVisibilityCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Visibillity.CVisibilityCriteriumCreator) ICriteriaSelectionPlugin(com.google.security.zynamics.binnavi.API.plugins.ICriteriaSelectionPlugin) ArrayList(java.util.ArrayList) CTextCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CTextCriteriumCreator) IPlugin(com.google.security.zynamics.binnavi.api2.plugins.IPlugin) COutdegreeCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.OutDegree.COutdegreeCriteriumCreator) CIndegreeCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.InDegrees.CIndegreeCriteriumCreator) CSelectionCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CSelectionCriteriumCreator) CColorCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriteriumCreator) ICriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator) CTagCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CTagCriteriumCreator)

Aggregations

ICriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator)4 CCriteriumTree (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTree)3 CCriteriumTreeNode (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode)3 JCriteriumTree (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTree)3 CConditionBox (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CConditionBox)2 CCriteriaFactory (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory)2 CColorCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriterium)2 TreePath (javax.swing.tree.TreePath)2 Test (org.junit.Test)2 ICriteriaSelectionPlugin (com.google.security.zynamics.binnavi.API.plugins.ICriteriaSelectionPlugin)1 CIndegreeCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.InDegrees.CIndegreeCriteriumCreator)1 CColorCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriteriumCreator)1 COutdegreeCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.OutDegree.COutdegreeCriteriumCreator)1 CSelectionCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CSelectionCriterium)1 CSelectionCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CSelectionCriteriumCreator)1 CTagCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CTagCriterium)1 CTagCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CTagCriteriumCreator)1 CTextCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CTextCriterium)1 CTextCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CTextCriteriumCreator)1 CVisibilityCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Visibillity.CVisibilityCriteriumCreator)1