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