use of com.google.security.zynamics.binnavi.disassembly.types.TypeMember 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;
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeMember 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);
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeMember in project binnavi by google.
the class TypesTreeModel method removeNodes.
/**
* Removes a list of given nodes from the model and updates node maps.
*/
private void removeNodes(final List<DefaultMutableTreeNode> nodes) {
for (final DefaultMutableTreeNode node : nodes) {
if (node instanceof TypeMemberTreeNode) {
final TypeMember member = ((TypeMemberTreeNode) node).getTypeMember();
nestedStructNodes.get(member.getBaseType()).removeAll(memberNodes.get(member));
memberNodes.remove(member, node);
}
node.removeFromParent();
}
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeMember in project binnavi by google.
the class TypesTreeModel method createTypeNodes.
// Recursively creates all tree nodes for the given base type instance.
private void createTypeNodes(final DefaultMutableTreeNode currentNode, final BaseType baseType) {
if (baseType.getCategory() == BaseTypeCategory.ARRAY) {
// without creating that member node.
return;
} else {
for (final TypeMember member : baseType) {
switch(member.getBaseType().getCategory()) {
case ARRAY:
case ATOMIC:
case POINTER:
final TypeMemberTreeNode memberNode = new TypeMemberTreeNode(member);
currentNode.add(memberNode);
memberNodes.put(member, memberNode);
break;
case FUNCTION_PROTOTYPE:
break;
case STRUCT:
case UNION:
// This member has a base type that itself has multiple members: we need to go deeper!
final TypeMemberTreeNode nestedNode = new TypeMemberTreeNode(member);
memberNodes.put(member, nestedNode);
nestedStructNodes.put(member.getBaseType(), nestedNode);
currentNode.add(nestedNode);
createTypeNodes(nestedNode, member.getBaseType());
break;
default:
NaviLogger.warning("Unknown type category: %d", member.getBaseType().getCategory());
break;
}
}
}
}
Aggregations