Search in sources :

Example 1 with CModuleNode

use of com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode in project binnavi by google.

the class CModuleNodeTest method testChangingName.

@Test
public void testChangingName() throws CouldntSaveDataException {
    final CModuleNode node = new CModuleNode(m_tree, new DefaultMutableTreeNode(), m_database, m_module, new CModuleContainer(m_database, m_module));
    assertEquals("Name (55/66)", node.toString());
    m_module.getConfiguration().setName("Hannes");
    assertEquals("Hannes (55/66)", node.toString());
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) CModuleNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode) Test(org.junit.Test)

Example 2 with CModuleNode

use of com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode in project binnavi by google.

the class CModuleNodeTest method testLoaded.

@Test
public void testLoaded() throws CouldntLoadDataException, CouldntDeleteException, LoadCancelledException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    m_module.load();
    final CModuleNode node = new CModuleNode(m_tree, new DefaultMutableTreeNode(), m_database, m_module, new CModuleContainer(m_database, m_module));
    assertEquals("Name (1/0)", node.toString());
    final CView view = m_module.getContent().getViewContainer().createView("Foo", "Bar");
    assertEquals("Name (1/1)", node.toString());
    m_module.getContent().getViewContainer().deleteView(view);
    assertEquals("Name (1/0)", node.toString());
    node.dispose();
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")) == null);
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_module, "m_listeners"), "m_listeners")).isEmpty());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) CModuleNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode) Test(org.junit.Test)

Example 3 with CModuleNode

use of com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode in project binnavi by google.

the class CModuleNodeTest method testListenersRemoved.

@Test
public void testListenersRemoved() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final CModuleContainer container = new CModuleContainer(m_database, m_module);
    final CModuleNode node = new CModuleNode(m_tree, new DefaultMutableTreeNode(), m_database, m_module, container);
    node.dispose();
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")) == null);
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_module, "m_listeners"), "m_listeners")).isEmpty());
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) CModuleNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode) Test(org.junit.Test)

Example 4 with CModuleNode

use of com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode in project binnavi by google.

the class CModulesToAddressSpaceHandler method drop.

@Override
public void drop(final DNDTree target, final DefaultMutableTreeNode parentNode, final DefaultMutableTreeNode draggedNode) {
    final CModuleNode draggedNodeNode = (CModuleNode) draggedNode;
    final CAddressSpaceNode parentNodeNode = (CAddressSpaceNode) parentNode;
    CAddressSpaceFunctions.addModule(m_parent, parentNodeNode.getObject(), draggedNodeNode.getObject());
    target.setSelectionPath(new TreePath(parentNodeNode.getLastLeaf().getPath()));
    target.setSelectionPath(new TreePath(draggedNodeNode.getPath()));
}
Also used : CAddressSpaceNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.CAddressSpaceNode) TreePath(javax.swing.tree.TreePath) CModuleNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode)

Example 5 with CModuleNode

use of com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode in project binnavi by google.

the class CModulesToAddressSpaceHandler method canHandle.

@Override
public boolean canHandle(final DefaultMutableTreeNode parentNode, final DefaultMutableTreeNode draggedNode) {
    if ((parentNode instanceof CAddressSpaceNode) && (draggedNode instanceof CModuleNode)) {
        final CModuleNode draggedModule = (CModuleNode) draggedNode;
        final CAddressSpaceNode targetAddressSpace = (CAddressSpaceNode) parentNode;
        return targetAddressSpace.getObject().isLoaded() && !targetAddressSpace.getObject().getContent().getModules().contains(draggedModule.getObject()) && targetAddressSpace.getObject().inSameDatabase(draggedModule.getObject());
    }
    return false;
}
Also used : CAddressSpaceNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.CAddressSpaceNode) CModuleNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode)

Aggregations

CModuleNode (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Module.CModuleNode)7 CModuleContainer (com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 Test (org.junit.Test)5 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)3 CAddressSpaceNode (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.CAddressSpaceNode)2 LinkedHashSet (java.util.LinkedHashSet)1 TreePath (javax.swing.tree.TreePath)1