Search in sources :

Example 1 with BaseTypeTreeNode

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode in project binnavi by google.

the class ViewReferencesTableModel method removeFromTree.

/**
   * Given a {@link DefaultMutableTreeNode node} removes the node from the tree. Also it removes all
   * parent nodes which after the removal of the child have no other children any more.
   *
   * @param node The {@link DefaultMutableTreeNode node} which to remove from the tree.
   */
private void removeFromTree(DefaultMutableTreeNode node) {
    Preconditions.checkNotNull(node, "Error: node argument can not be null.");
    Preconditions.checkArgument(!node.isRoot(), "Error: node argument can not be the root node.");
    final Set<DefaultMutableTreeNode> nodesToDelete = Sets.newHashSet();
    nodesToDelete.add(node);
    while (node.getSiblingCount() == 1 && node.getParent() != getRoot()) {
        node = (DefaultMutableTreeNode) node.getParent();
        nodesToDelete.add(node);
    }
    for (DefaultMutableTreeNode currentNode : nodesToDelete) {
        removeNodeFromParent(currentNode);
        if (currentNode instanceof InstructionNode) {
            multiIndex.removeInstructionNode((InstructionNode) currentNode);
        }
        if (currentNode instanceof BaseTypeTreeNode) {
            baseTypeToTreeNode.remove(((BaseTypeTreeNode) currentNode).getBaseType());
        }
        if (currentNode instanceof TypeMemberTreeNode) {
            typeMemberToTreeNode.remove(((TypeMemberTreeNode) currentNode).getTypeMember(), currentNode);
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BaseTypeTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode) TypeMemberTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode)

Example 2 with BaseTypeTreeNode

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode in project binnavi by google.

the class ViewReferencesTableModel method addBaseType.

/**
   * Adds a {@link BaseType base type} node to the tree and the internal storage if it is not
   * already present.
   *
   * @param baseType The {@link BaseType base type} to be added to the tree.
   */
private void addBaseType(final BaseType baseType) {
    if (!baseTypeToTreeNode.containsKey(baseType)) {
        final BaseTypeTreeNode baseTypeNode = new BaseTypeTreeNode(baseType);
        baseTypeToTreeNode.put(baseType, baseTypeNode);
        insertNodeInto(baseTypeNode, (DefaultMutableTreeNode) getRoot(), ((DefaultMutableTreeNode) getRoot()).getChildCount());
        // TODO(timkornau): This reload is needed for the situation where the tree was initially empty
        // on view open and a new type substitution gets added. This needs to be investigated further
        // as it is unclear why this behavior is triggered at all.
        reload((DefaultMutableTreeNode) getRoot());
    }
}
Also used : BaseTypeTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode)

Example 3 with BaseTypeTreeNode

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode in project binnavi by google.

the class ViewReferencesTableModel method addTypeSubstitutionToTree.

/**
   * Adds a {@link TypeSubstitution type substitution} for the given {@link INaviInstruction
   * instruction} to the tree.
   *
   * @param operandNode The {@link INaviOperandTreeNode operand node} which holds the
   *        {@link TypeSubstitution type substitution}.
   * @param instruction The {@link INaviInstruction instruction} which holds the
   *        {@link INaviOperandTreeNode operand node}.
   */
private void addTypeSubstitutionToTree(final INaviOperandTreeNode operandNode, final INaviInstruction instruction) {
    final TypeSubstitution typeSubstitution = operandNode.getTypeSubstitution();
    final BaseTypeCategory category = typeSubstitution.getBaseType().getCategory();
    if (category == BaseTypeCategory.STRUCT || category == BaseTypeCategory.ARRAY || category == BaseTypeCategory.UNION) {
        addCompoundTypeSubstitutionToTree(operandNode, instruction, typeSubstitution);
    } else {
        addBaseType(typeSubstitution.getBaseType());
        BaseTypeTreeNode currentNode = baseTypeToTreeNode.get(typeSubstitution.getBaseType());
        insertNodeInto(multiIndex.putTypeSubstitution(typeSubstitution, instruction), currentNode, currentNode.getChildCount());
    }
}
Also used : TypeSubstitution(com.google.security.zynamics.binnavi.disassembly.types.TypeSubstitution) BaseTypeTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode) BaseTypeCategory(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeCategory)

Aggregations

BaseTypeTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode)3 TypeMemberTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode)1 BaseTypeCategory (com.google.security.zynamics.binnavi.disassembly.types.BaseTypeCategory)1 TypeSubstitution (com.google.security.zynamics.binnavi.disassembly.types.TypeSubstitution)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1