
Hi Jirka, Oxygen support for creating Java plugins and deploying them in the "OXYGEN_INSTALL_DIR/plugins" directory. In our plugins development kit: http://www.oxygenxml.com/developer.html#Developer_Plugins there is a Workspace Access plugin type sample implementation (ro.sync.sample.plugin.workspace.CustomWorkspaceAccessPluginExtension). Using a Workspace Access plugin you can register a listener to be notified when an editor in Oxygen is selected for example (or when the editor page is switched). Here is one sample Java code approach to what you want, based on registering listeners both in the Author and the Text pages:
@Override public void editorSelected(URL editorLocation) { try { WSEditor editorAccess = pluginWorkspaceAccess.getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA); if(editorAccess != null) { if(EditorPageConstants.PAGE_AUTHOR.equals(editorAccess.getCurrentPageID())){ final WSAuthorEditorPage authorPage = (WSAuthorEditorPage) editorAccess.getCurrentPage(); authorPage.getDocumentController().addAuthorListener(new AuthorListenerAdapter() { /** * @see ro.sync.ecss.extensions.api.AuthorListenerAdapter#contentInserted(ro.sync.ecss.extensions.api.DocumentContentInsertedEvent) */ @Override public void contentInserted(DocumentContentInsertedEvent e) { try { if("-".equals(e.getInsertedText())) { //Look if there is another one to the left Segment seg = new Segment(); authorPage.getDocumentController().getChars(e.getOffset() - 1, 1, seg); if("-".equals(seg.toString())) { //Remove both "-" and insert your own char. authorPage.getDocumentController().delete(e.getOffset() - 1, e.getOffset()); authorPage.getDocumentController().insertText(e.getOffset() - 1, "CUSTOM_REPLACEMENT"); } } } catch(Exception ex) { ex.printStackTrace(); } } }); } else if(EditorPageConstants.PAGE_TEXT.equals(editorAccess.getCurrentPageID())){ final WSTextEditorPage textPage = (WSTextEditorPage) editorAccess.getCurrentPage(); textPage.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { // TODO About the same approach as in the Author page. } public void changedUpdate(DocumentEvent e) { } }); } } } catch(Exception ex) { ex.printStackTrace(); } };
The sample is not complete, you have to remove listeners when another editor is selected and also add them when the editor page changes. Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 5/30/2011 5:30 PM, Jirka Kosek wrote:
Hi,
for one project I need to customize Author View (and Text View if possible as well) to emit en-dash characters when "-" is pressed twice and em-dash when "-" is presed three times.
I was studying SDK but so far I have no idea how to do this. Any clue?
Thanks,
Jirka
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user