use of org.omegat.util.gui.TooltipAttribute in project omegat by omegat-org.
the class DictionaryGlossaryRenderer method render.
@Override
public void render(GlossaryEntry entry, IRenderTarget<?> trg) {
trg.append(entry.getSrcText(), SOURCE_ATTRIBUTES);
trg.append(": ");
String[] targets = entry.getLocTerms(false);
String[] comments = entry.getComments();
boolean[] priorities = entry.getPriorities();
String[] origins = entry.getOrigins(false);
boolean hasComments = false;
for (int i = 0; i < targets.length; i++) {
if (i == 0 || (!targets[i].equals(targets[i - 1]))) {
if (hasComments) {
trg.startIndent(null);
hasComments = false;
}
SimpleAttributeSet attrs = new SimpleAttributeSet(TARGET_ATTRIBUTES);
if (priorities[i]) {
StyleConstants.setBold(attrs, true);
}
attrs.addAttribute(TooltipAttribute.ATTRIBUTE_KEY, new TooltipAttribute(origins[i]));
trg.append(bracketEntry(targets[i]), attrs);
if (i < targets.length - 1) {
trg.append(", ", null);
}
}
if (!comments[i].equals("")) {
trg.startIndent(NOTES_ATTRIBUTES);
trg.append("- " + comments[i], NOTES_ATTRIBUTES);
hasComments = true;
}
}
}
use of org.omegat.util.gui.TooltipAttribute in project omegat by omegat-org.
the class GlossaryTextArea method getToolTipText.
@Override
public String getToolTipText(MouseEvent event) {
StyledDocument doc = getStyledDocument();
Element elem = doc.getCharacterElement(Java8Compat.viewToModel(this, event.getPoint()));
AttributeSet as = elem.getAttributes();
Object attr = as.getAttribute(TooltipAttribute.ATTRIBUTE_KEY);
if (attr instanceof TooltipAttribute) {
return ((TooltipAttribute) attr).getPayload();
} else {
return super.getToolTipText(event);
}
}
use of org.omegat.util.gui.TooltipAttribute in project omegat by omegat-org.
the class DefaultGlossaryRenderer method render.
@Override
public void render(GlossaryEntry entry, IRenderTarget<?> trg) {
trg.append(entry.getSrcText(), SOURCE_ATTRIBUTES);
trg.append(" = ");
String[] targets = entry.getLocTerms(false);
String[] comments = entry.getComments();
boolean[] priorities = entry.getPriorities();
String[] origins = entry.getOrigins(false);
StringBuilder commentsBuf = new StringBuilder();
for (int i = 0, commentIndex = 0; i < targets.length; i++) {
if (i > 0 && targets[i].equals(targets[i - 1])) {
if (!comments[i].equals("")) {
commentsBuf.append("\n");
commentsBuf.append(commentIndex);
commentsBuf.append(". ");
commentsBuf.append(comments[i]);
}
continue;
}
SimpleAttributeSet attrs = new SimpleAttributeSet(TARGET_ATTRIBUTES);
if (i > 0) {
trg.append(", ", attrs);
}
if (priorities[i]) {
StyleConstants.setBold(attrs, true);
}
attrs.addAttribute(TooltipAttribute.ATTRIBUTE_KEY, new TooltipAttribute(origins[i]));
trg.append(bracketEntry(targets[i]), attrs);
commentIndex++;
if (!comments[i].equals("")) {
commentsBuf.append("\n");
commentsBuf.append(commentIndex);
commentsBuf.append(". ");
commentsBuf.append(comments[i]);
}
}
trg.append(commentsBuf.toString(), NOTES_ATTRIBUTES);
}
Aggregations