Search in sources :

Example 41 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class ZyNodeBuilder method addCommentLines.

/**
   * Creates line content objects for a single comment string. If necessary, the string comment is
   * broken into several lines.
   * 
   * @param content The label content where the line content objects are added.
   * @param comments The comment string to add to the label content.
   * @param color The color used for the comment line.
   * @param object The object to associate with the comment lines.
   */
private static void addCommentLines(final ZyLabelContent content, final List<IComment> comments, final Color color, final Object object) {
    Preconditions.checkNotNull(content, "IE01180: Content argument can't be null");
    Preconditions.checkNotNull(comments, "IE01181: Comment argument can not be null");
    Preconditions.checkNotNull(color, "IE01183: Color argument can not be null");
    Preconditions.checkNotNull(object, "IE01191: Object argument can not be null");
    for (final IComment comment : comments) {
        final CommentContainer currentCommentContainer = new CommentContainer(comment);
        for (final String commentString : currentCommentContainer.getCommentingString()) {
            final ZyLineContent lineContent = new ZyLineContent(commentString, ITALIC_FONT, null);
            lineContent.setTextColor(Color.BLACK);
            lineContent.setObject(0, commentString.length(), object);
            if (commentString.equals(currentCommentContainer.getCommentingString().get(0))) {
                lineContent.setTextColor(0, currentCommentContainer.getCommentUserNameLength(), currentCommentContainer.getCommentColor());
            }
            content.addLineContent(lineContent);
        }
    }
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 42 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class ZyNodeBuilder method addTagLines.

/**
   * Adds the name of a tag to the content of a label.
   * 
   * @param content The label content where the line content object is added.
   * @param node The node that provides the tags.
   * @param prefix The prefix that is written in front of all tag lines.
   * @param color The color used for the tag line.
   */
private static void addTagLines(final ZyLabelContent content, final INaviViewNode node, final String prefix, final Color color) {
    Preconditions.checkNotNull(content, "IE00918: Content argument can't be null");
    Preconditions.checkNotNull(node, "IE00919: Node argument can't be null");
    Preconditions.checkNotNull(color, "IE00920: Color argument can't be null");
    final Iterator<CTag> it = node.getTagsIterator();
    while (it.hasNext()) {
        final CTag tag = it.next();
        if (!"".equals(tag.getName())) {
            final ZyLineContent lineComment = new ZyLineContent(prefix + tag.getName(), null);
            lineComment.setTextColor(color);
            lineComment.setFont(ITALIC_BOLD_FONT);
            content.addLineContent(lineComment);
        }
    }
}
Also used : CTag(com.google.security.zynamics.binnavi.Tagging.CTag) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 43 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class CAbstractKeyBehavior method getMultilineComment.

protected String getMultilineComment(final int lineYPos, final String changedLine) {
    final StringBuilder commentText = new StringBuilder();
    final int nonCommentLine = m_labelContent.getNonPureCommentLineIndexOfModelAt(lineYPos);
    final int firstModelLine = m_labelContent.getFirstLineIndexOfModelAt(lineYPos);
    final int lastModelLine = m_labelContent.getLastLineIndexOfModelAt(lineYPos);
    int startIndex = isAboveLineComment(lineYPos) ? firstModelLine : nonCommentLine;
    int endIndex = isAboveLineComment(lineYPos) ? nonCommentLine - 1 : lastModelLine;
    if (nonCommentLine == -1) {
        startIndex = firstModelLine;
        endIndex = lastModelLine;
    }
    for (int index = startIndex; index <= endIndex; ++index) {
        if (index == lineYPos) {
            commentText.append(changedLine);
        } else {
            final ZyLineContent curLineContent = m_labelContent.getLineContent(index);
            final String lineText = getSingleLineCommentText(curLineContent);
            commentText.append(lineText);
        }
    }
    return commentText.toString().equals("") ? changedLine : commentText.toString();
}
Also used : ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Example 44 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class CAbstractKeyBehavior method isDeleteableSelection.

protected boolean isDeleteableSelection() {
    final int mouseStartY = Math.min(getCaretMousePressedY(), getCaretMouseReleasedY());
    final int mouseEndY = Math.max(getCaretMousePressedY(), getCaretMouseReleasedY());
    final int caretStartX = Math.min(getCaretStartPosX(), getCaretEndPosX());
    final int caretEndX = Math.max(getCaretStartPosX(), getCaretEndPosX());
    final ZyLineContent firstLineContent = getLineContent(mouseStartY);
    final ZyLineContent lastLineContent = getLineContent(mouseEndY);
    final IZyEditableObject firstEditObject = firstLineContent.getLineFragmentObjectAt(caretStartX);
    final IZyEditableObject lastEditObject = firstLineContent.getLineFragmentObjectAt(caretEndX);
    if (firstLineContent.getLineObject() != lastLineContent.getLineObject()) {
        return false;
    }
    if (isComment(caretStartX, mouseStartY)) {
        if (mouseEndY > mouseStartY) {
            final int noneCommentLine = m_labelContent.getNonPureCommentLineIndexOfModelAt(mouseStartY);
            if (noneCommentLine != -1) {
                if ((mouseStartY < noneCommentLine) && (mouseEndY >= noneCommentLine)) {
                    return false;
                } else if ((mouseStartY >= noneCommentLine) && (mouseEndY < noneCommentLine)) {
                    return false;
                }
            }
        }
    } else {
        if ((firstEditObject != lastEditObject) || ((firstEditObject == null) && (lastEditObject == null))) {
            return false;
        }
    }
    return true;
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Example 45 with ZyLineContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.

the class CAbstractKeyBehavior method getNextModelLineContent.

protected ZyLineContent getNextModelLineContent(final int lineYPos) {
    final ZyLineContent lineContent = m_labelContent.getLineContent(lineYPos);
    final IZyEditableObject lineObject = lineContent.getLineObject();
    for (int index = lineYPos + 1; index < m_labelContent.getLineCount(); ++index) {
        final ZyLineContent nextLineContent = m_labelContent.getLineContent(index);
        if (nextLineContent == null) {
            return null;
        }
        final IZyEditableObject nextLineObject = nextLineContent.getLineObject();
        if ((lineObject != nextLineObject) && !nextLineObject.isPlaceholder()) {
            return nextLineContent;
        }
    }
    return null;
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Aggregations

ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)56 IZyEditableObject (com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject)24 Point (java.awt.Point)15 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)8 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)8 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)8 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)8 Test (org.junit.Test)8 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)5 CStyleRunData (com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)3 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)2 ArrayList (java.util.ArrayList)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)1 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 DefaultAddressConverter (com.google.security.zynamics.binnavi.debug.debugger.DefaultAddressConverter)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1