use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class GenericCommentsTableModel method editComment.
private IComment editComment(IComment comment, String newComment) {
IComment newlySetComment = null;
try {
if (newComment.isEmpty()) {
commentAccessor.deleteComment(comment);
} else {
newlySetComment = commentAccessor.editComment(comment, newComment);
}
} catch (CouldntSaveDataException | CouldntDeleteException e) {
CUtilityFunctions.logException(e);
}
resetCachedComments();
return newlySetComment;
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class GenericCommentsTableModel method keyPressedOrTyped.
@Override
public /**
* Please read the comment in the base class regarding this method - it is somewhat counter-
* intuitive for people used to the Swing keyboard handling model.
*/
void keyPressedOrTyped(CodeDisplayCoordinate coordinate, KeyEvent event) {
int commentRow = coordinate.getRow();
IComment comment = null;
if (commentRow < cachedComments.size()) {
comment = cachedComments.get(commentRow);
}
if (!isEditable(coordinate)) {
return;
}
switch(event.getKeyCode()) {
// VK_UNDEFINED implies that this was a KEY_TYPED event.
case KeyEvent.VK_UNDEFINED:
if (commentRow >= cachedComments.size()) {
// Create a new comment.
try {
commentAccessor.appendComment(String.format("%c", event.getKeyChar()));
coordinate.setFieldIndex(1);
} catch (CouldntSaveDataException | CouldntLoadDataException e) {
CUtilityFunctions.logException(e);
}
resetCachedComments();
// the handling code below.
break;
}
switch(event.getKeyChar()) {
case KeyEvent.VK_ENTER:
comment = handleRegularKeyInComment(comment, coordinate, event);
coordinate.setLine(coordinate.getLine() < (comment.getNumberOfCommentLines() - 1) ? coordinate.getLine() + 1 : comment.getNumberOfCommentLines() - 1);
coordinate.setFieldIndex(0);
break;
case KeyEvent.VK_BACK_SPACE:
comment = handleBackspaceKeyInComment(comment, coordinate);
break;
case KeyEvent.VK_DELETE:
comment = handleDeleteKeyInComment(comment, coordinate);
break;
default:
comment = handleRegularKeyInComment(comment, coordinate, event);
coordinate.setFieldIndex(coordinate.getFieldIndex() + 1);
break;
}
break;
case KeyEvent.VK_HOME:
coordinate.setFieldIndex(0);
break;
case KeyEvent.VK_END:
coordinate.setFieldIndex(columns[coordinate.getColumn()].getWidth());
break;
default:
throw new IllegalArgumentException();
}
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class InstructionCommentsDataModel method getCommentUserCharacterBuffer.
private FormattedCharacterBuffer getCommentUserCharacterBuffer(int rowIndex, int columnIndex, int lineIndex) {
// Return the user string associated with the comment.
ArrayList<IComment> comments = internalData.get(rowIndex).second();
int currentLineIndex = 0;
String username = "";
for (IComment comment : comments) {
if ((currentLineIndex + comment.getNumberOfCommentLines() > lineIndex) && (currentLineIndex == lineIndex)) {
// Found the right comment.
String temp = comment.getUser().getUserName();
if (temp != null) {
username = temp;
}
break;
}
currentLineIndex += comment.getNumberOfCommentLines();
}
username = CodeDisplay.padRight(username, getColumnWidthInCharacters(columnIndex));
return new FormattedCharacterBuffer(username, STANDARD_FONT, columns[USER_INDEX].getDefaultFontColor(), columns[USER_INDEX].getDefaultBackgroundColor());
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class LocalInstructionCommentAccessor method getAllComments.
@Override
public ArrayList<Pair<INaviInstruction, IComment>> getAllComments() {
final ArrayList<Pair<INaviInstruction, IComment>> values = new ArrayList<>();
final CCodeNodeComments currentComments = m_codeNode.getComments();
for (final INaviInstruction instruction : m_codeNode.getInstructions()) {
final List<IComment> comments = currentComments.getLocalInstructionComment(instruction);
if ((comments == null) || comments.isEmpty()) {
values.add(new Pair<INaviInstruction, IComment>(instruction, new EmptyComment()));
continue;
} else {
for (final IComment comment : comments) {
values.add(new Pair<INaviInstruction, IComment>(instruction, comment));
}
values.add(new Pair<INaviInstruction, IComment>(instruction, new EmptyComment()));
}
}
return values;
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class CGraphDebuggerTest method testToggleBreakpoint3.
@Test
public void testToggleBreakpoint3() {
final MockModule module = new MockModule();
module.getConfiguration().setDebugger(m_debugger);
m_debugger.setAddressTranslator(module, m_fileBase, m_imageBase);
final DebugTargetSettings target = new ModuleTargetSettings(module);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
debuggerProvider.addDebugger(m_debugger);
final CFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, m_provider);
final ArrayList<IComment> comments = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Mock Comment"));
final INaviCodeNode codeNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, false, comments, function, new HashSet<CTag>(), new MockSqlProvider());
codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x124), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
assertEquals(1, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
assertEquals(0x124, m_debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, 0).getAddress().getAddress().getAddress().toLong());
assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, m_debugger.getBreakpointManager().getBreakpointStatus(BreakpointType.REGULAR, 0));
CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
assertEquals(0, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
}
Aggregations