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());
}
}
}
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);
}
}
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, "");
}
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 ");
}
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, "");
}
Aggregations