public Couple<String> setText(@Nullable final String text, @Nullable final String requestor) { if (StringUtil.isEmpty(text) && !Comparing.equal(requestor, myCurrentRequestor) && !EventLog.LOG_REQUESTOR.equals(requestor)) { return Couple.of(myInfoPanel.getText(), myCurrentRequestor); } boolean logMode = myInfoPanel.updateText(EventLog.LOG_REQUESTOR.equals(requestor) ? "" : text); myCurrentRequestor = logMode ? EventLog.LOG_REQUESTOR : requestor; return Couple.of(text, requestor); }
private static Couple<Integer> composeText( StringBuilder sb, List<Pair<String, HighlightInfo>> list, int index, String text, int endPos, int startPos) { int i = index; while (i < list.size()) { Pair<String, HighlightInfo> pair = list.get(i); HighlightInfo info = pair.second; if (info.endOffset <= startPos) { break; } String severity = pair.first; HighlightInfo prev = i < list.size() - 1 ? list.get(i + 1).second : null; sb.insert(0, text.substring(info.endOffset, endPos)); sb.insert(0, "</" + severity + ">"); endPos = info.endOffset; if (prev != null && prev.endOffset > info.startOffset) { Couple<Integer> result = composeText(sb, list, i + 1, text, endPos, info.startOffset); i = result.first - 1; endPos = result.second; } sb.insert(0, text.substring(info.startOffset, endPos)); sb.insert(0, "<" + severity + " descr=\"" + info.getDescription() + "\">"); endPos = info.startOffset; i++; } return Couple.newOne(i, endPos); }
private static Couple<Integer> composeText( StringBuilder sb, List<Pair<String, HighlightInfo>> list, int index, String text, int endPos, int startPos, boolean showAttributesKeys) { int i = index; while (i < list.size()) { Pair<String, HighlightInfo> pair = list.get(i); HighlightInfo info = pair.second; if (info.endOffset <= startPos) { break; } String severity = pair.first; HighlightInfo prev = i < list.size() - 1 ? list.get(i + 1).second : null; sb.insert(0, text.substring(info.endOffset, endPos)); sb.insert(0, "</" + severity + ">"); endPos = info.endOffset; if (prev != null && prev.endOffset > info.startOffset) { Couple<Integer> result = composeText(sb, list, i + 1, text, endPos, info.startOffset, showAttributesKeys); i = result.first - 1; endPos = result.second; } sb.insert(0, text.substring(info.startOffset, endPos)); String str = "<" + severity + " descr=\"" + StringUtil.escapeQuotes(String.valueOf(info.getDescription())) + "\""; if (showAttributesKeys) { str += " textAttributesKey=\"" + info.forcedTextAttributesKey + "\""; } str += ">"; sb.insert(0, str); endPos = info.startOffset; i++; } return Couple.of(i, endPos); }