Search in sources :

Example 36 with INaviGroupNode

use of com.google.security.zynamics.binnavi.disassembly.INaviGroupNode in project binnavi by google.

the class CGraphGrouper method toggleSelectedGroups.

/**
   * Toggles the state of all selected group nodes in a graph.
   * 
   * @param graph The graph whose group nodes are toggled.
   */
public static void toggleSelectedGroups(final ZyGraph graph) {
    for (final NaviNode node : graph.getSelectedNodes()) {
        if (node.getRawNode() instanceof INaviGroupNode) {
            final INaviGroupNode gnode = (INaviGroupNode) node.getRawNode();
            gnode.setCollapsed(!gnode.isCollapsed());
        }
    }
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)

Example 37 with INaviGroupNode

use of com.google.security.zynamics.binnavi.disassembly.INaviGroupNode in project binnavi by google.

the class CGraphGrouper method groupNodes.

/**
   * Creates a new group node from a list of nodes.
   * 
   * @param graph The graph where the group node is created.
   * @param nodes The nodes to be grouped.
   */
private static void groupNodes(final ZyGraph graph, final List<NaviNode> nodes) {
    final StringBuilder stringBuilder = new StringBuilder();
    final List<INaviViewNode> rawNodes = new ArrayList<INaviViewNode>();
    // ATTENTION: DO NOT MOVE THIS LINE BELOW THE REMOVEELEMENT LINE
    final INaviGroupNode commonParent = getCommonParent(nodes);
    for (final NaviNode node : nodes) {
        if (node.getRawNode().getParentGroup() != null) {
            node.getRawNode().getParentGroup().removeElement(node.getRawNode());
        }
        rawNodes.add(node.getRawNode());
        stringBuilder.append(determineNodeText(node));
        stringBuilder.append('\n');
    }
    final CGroupNode groupNode = graph.getRawView().getContent().createGroupNode(rawNodes);
    if (commonParent != null) {
        commonParent.addElement(groupNode);
    }
    try {
        groupNode.appendComment(stringBuilder.toString());
    } catch (CouldntSaveDataException | CouldntLoadDataException exception) {
        CUtilityFunctions.logException(exception);
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode)

Example 38 with INaviGroupNode

use of com.google.security.zynamics.binnavi.disassembly.INaviGroupNode in project binnavi by google.

the class PostgreSQLGroupNodeCommentTests method editGroupNodeComment3.

@Test(expected = NullPointerException.class)
public void editGroupNodeComment3() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException {
    final INaviGroupNode groupNode = setupGroupNode();
    getProvider().editGroupNodeComment(groupNode, 1, null, "");
}
Also used : INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 39 with INaviGroupNode

use of com.google.security.zynamics.binnavi.disassembly.INaviGroupNode in project binnavi by google.

the class PostgreSQLGroupNodeCommentTests method editGroupNodeComment6.

@Test(expected = CouldntSaveDataException.class)
public void editGroupNodeComment6() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException {
    final INaviGroupNode groupNode = setupGroupNode();
    final List<IComment> comments = groupNode.getComments() == null ? new ArrayList<IComment>() : groupNode.getComments();
    final IComment lastComment = comments.size() == 0 ? null : Iterables.getLast(comments);
    final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    final String commentText = " CODE NODE COMMENT TEST BEFORE EDIT ";
    final Integer commentId = getProvider().appendGroupNodeComment(groupNode, commentText, user.getUserId());
    final IComment newComment = new CComment(commentId, user, lastComment, commentText);
    final ArrayList<IComment> newComments = getProvider().loadCommentById(commentId);
    assertNotNull(newComments);
    assertEquals(comments.size() + 1, newComments.size());
    assertEquals(newComment, Iterables.getLast(newComments));
    final IUser wrongUser = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    getProvider().editGroupNodeComment(groupNode, commentId, wrongUser.getUserId(), " FAIL ");
}
Also used : CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) UniqueTestUserGenerator(com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 40 with INaviGroupNode

use of com.google.security.zynamics.binnavi.disassembly.INaviGroupNode in project binnavi by google.

the class PostgreSQLGroupNodeCommentTests method editGroupNodeComment2.

@Test(expected = NullPointerException.class)
public void editGroupNodeComment2() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException {
    final INaviGroupNode groupNode = setupGroupNode();
    getProvider().editGroupNodeComment(groupNode, null, 1, "");
}
Also used : INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)40 Test (org.junit.Test)23 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)16 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)15 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)11 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)9 IUser (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser)9 UniqueTestUserGenerator (com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator)8 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)7 ArrayList (java.util.ArrayList)7 CGroupNode (com.google.security.zynamics.binnavi.disassembly.CGroupNode)6 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)5 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)4 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)4 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)4 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)3 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 GroupNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer)3 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3