Created
June 13, 2016 14:22
-
-
Save claudius108/97354c5cbddd2118cbc4a959b91867f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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