Skip to content

Instantly share code, notes, and snippets.

@claudius108
Created June 13, 2016 14:22
Show Gist options
  • Save claudius108/97354c5cbddd2118cbc4a959b91867f1 to your computer and use it in GitHub Desktop.
Save claudius108/97354c5cbddd2118cbc4a959b91867f1 to your computer and use it in GitHub Desktop.
authorEditorAccess.addAuthorCaretListener(new AuthorCaretListener() {
@Override
public void caretMoved(AuthorCaretEvent caretEvent) {
AuthorNode currentNode = caretEvent.getNode();
if (currentNode.getType() != AuthorNode.NODE_TYPE_ELEMENT) {
return;
}
AttrValue xmlIdAttrValue = ((AuthorElement) currentNode).getAttribute("xml:lang");
if (xmlIdAttrValue == null) {
return;
}
Styles styles = authorEditorAccess.getStyles(currentNode);
StaticContent[] mixedContent = styles.getMixedContent();
if (mixedContent == null) {
return;
}
for (int i = 0; i < mixedContent.length; i++) {
if (mixedContent[i].getType() == 4) {
EditorContent editorContent = (EditorContent) mixedContent[i];
Map<String, Object> editorProperties = editorContent.getProperties();
String editorType = (String) editorProperties.get("type");
if (!editorType.equals("text")) {
continue;
}
String lang = xmlIdAttrValue.getValue();
PluginWorkspaceProvider.getPluginWorkspace().setGlobalObjectProperty("recently.used.characters",
scripts.get(lang));
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment