Search in sources :

Example 11 with BaseType

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

the class ViewReferencesTableModel method addTypeInstancesToTree.

/**
   * Adds the list of {@link TypeInstanceReference type instance references} for the given
   * {@link INaviInstruction instruction} to the tree.
   *
   * @param typeInstanceReferences A List of {@link TypeInstanceReference type instance references}.
   * @param instruction The {@link INaviInstruction instruction} to which the list of references
   *        belongs.
   */
private void addTypeInstancesToTree(final List<TypeInstanceReference> typeInstanceReferences, final INaviInstruction instruction) {
    for (TypeInstanceReference typeInstanceReference : typeInstanceReferences) {
        final BaseType baseType = typeInstanceReference.getTypeInstance().getBaseType();
        addBaseType(baseType);
        insertNodeInto(multiIndex.putTypeReference(typeInstanceReference, instruction), baseTypeToTreeNode.get(baseType), baseTypeToTreeNode.get(baseType).getChildCount());
    }
}
Also used : TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType)

Example 12 with BaseType

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

the class TypeEditorMouseHandler method createNodeClickedMenu.

private JPopupMenu createNodeClickedMenu(final TreeNode clickedNode) {
    final JPopupMenu popupMenu = new JPopupMenu();
    if (clickedNode instanceof TypeMemberTreeNode) {
        final TypeMember selectedMember = ((TypeMemberTreeNode) clickedNode).getTypeMember();
        final AbstractAction editMemberAction = new EditMemberAction(owner, typeManager, selectedMember);
        final AbstractAction insertAction = new InsertMemberAction(owner, typeManager, selectedMember);
        if (tree.getSelectionCount() > 1) {
            editMemberAction.setEnabled(false);
            insertAction.setEnabled(false);
        }
        if (selectedMember.getParentType() != null && selectedMember.getParentType().getCategory() == BaseTypeCategory.STRUCT) {
            popupMenu.add(new AppendMemberAction(owner, typeManager, selectedMember.getParentType()));
            popupMenu.add(insertAction);
        }
        popupMenu.add(editMemberAction);
        popupMenu.add(new DeleteMemberAction(owner, typeManager, typeEditor));
    } else if (clickedNode instanceof BaseTypeTreeNode) {
        final BaseType selectedType = ((BaseTypeTreeNode) clickedNode).getBaseType();
        final AbstractAction editAction = new EditTypeAction(owner, typeManager, selectedType);
        final AbstractAction appendAction = new AppendMemberAction(owner, typeManager, selectedType);
        if (tree.getSelectionCount() > 1) {
            editAction.setEnabled(false);
            appendAction.setEnabled(false);
        } else if (selectedType.getCategory() != BaseTypeCategory.STRUCT) {
            appendAction.setEnabled(false);
        }
        popupMenu.add(editAction);
        popupMenu.add(appendAction);
        popupMenu.add(new DeleteTypeAction(owner, typeManager, typeEditor));
    }
    return popupMenu;
}
Also used : AppendMemberAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.AppendMemberAction) EditMemberAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditMemberAction) BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember) EditTypeAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditTypeAction) InsertMemberAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.InsertMemberAction) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu)

Example 13 with BaseType

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

the class TypeEditorPanel method getSelectedTypes.

@Override
public ImmutableList<BaseType> getSelectedTypes() {
    final Builder<BaseType> builder = ImmutableList.<BaseType>builder();
    final TreePath[] paths = typesTree.getSelectionPaths();
    if (paths != null) {
        for (final TreePath path : typesTree.getSelectionPaths()) {
            final Object node = path.getLastPathComponent();
            if (node instanceof BaseTypeTreeNode) {
                builder.add(((BaseTypeTreeNode) node).getBaseType());
            }
        }
    }
    return builder.build();
}
Also used : TreePath(javax.swing.tree.TreePath) BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType)

Example 14 with BaseType

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

the class TypesTree method determineTypePath.

/**
   * Returns a {@link TypeSelectionPath} instance that describes the path to the selected member or
   * base type. Returns null if no selection exists.
   */
public TypeSelectionPath determineTypePath() {
    final TreePath path = getSelectionModel().getSelectionPath();
    if (path == null || path.getPathCount() == 0) {
        return new TypeSelectionPath(null, new ArrayList<TypeMember>());
    }
    // The first node is the invisible root node, the second a base type node. Afterwards, a list
    // of member nodes.
    final Object[] nodes = path.getPath();
    final BaseType rootType = ((BaseTypeTreeNode) nodes[1]).getBaseType();
    final List<TypeMember> memberPath = Lists.newArrayList();
    for (int i = 2; i < path.getPathCount(); ++i) {
        memberPath.add(((TypeMemberTreeNode) nodes[i]).getTypeMember());
    }
    return new TypeSelectionPath(rootType, memberPath);
}
Also used : TreePath(javax.swing.tree.TreePath) BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember)

Example 15 with BaseType

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

the class BaseTypeTableCellRenderer method renderAtomic.

private static void renderAtomic(final TypeInstance instance, final StyledDocument document, final boolean renderData) {
    final Style atomicStyle = createDeclarationStyle(document);
    try {
        document.remove(0, document.getLength());
        final BaseType baseType = instance.getBaseType();
        appendString(document, baseType.getName(), atomicStyle);
        if (renderData) {
            appendString(document, renderInstanceData(baseType, instance.getAddress().getOffset(), instance.getSection()), createDataStyle(document));
        }
    } catch (final BadLocationException exception) {
        CUtilityFunctions.logException(exception);
    }
}
Also used : BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) Style(javax.swing.text.Style) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

BaseType (com.google.security.zynamics.binnavi.disassembly.types.BaseType)18 TypeMember (com.google.security.zynamics.binnavi.disassembly.types.TypeMember)6 BadLocationException (javax.swing.text.BadLocationException)3 Style (javax.swing.text.Style)3 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)2 MemberDialog (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.MemberDialog)2 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)2 TreePath (javax.swing.tree.TreePath)2 Test (org.junit.Test)2 Node (y.base.Node)2 AppendMemberAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.AppendMemberAction)1 EditMemberAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditMemberAction)1 EditTypeAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditTypeAction)1 InsertMemberAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.InsertMemberAction)1 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)1 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)1 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)1 RawTypeInstance (com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance)1 Section (com.google.security.zynamics.binnavi.disassembly.types.Section)1 TypeInstance (com.google.security.zynamics.binnavi.disassembly.types.TypeInstance)1