Oxygen Author Component (Applet) text mode: elements highlig
Posted: Mon Mar 10, 2014 3:45 pm
Hi, Oxygen guys!
As you may know, we are using Oxygen web Component in our Ditaworks Cloud application as a main topic editor. We are implementing a conditional processing feature now and we need to highlight a tagged content as a part of this functionality. In the Author mode there are no questions and all are done, but in the text component we faced with problems:
1. How to get a current selected element? In the Author mode we used next:
2. How to get a current selected attribute value? Author:
3. How to add attribute and set/change an attribute value? Author example:
4. XML elements highlighting in ext mode? Author example:
We tried next:
but we don't know how to get a (p0, p1, p) coordinates? And in general, how to build an object model of the XML in the text mode?
Thank you!
As you may know, we are using Oxygen web Component in our Ditaworks Cloud application as a main topic editor. We are implementing a conditional processing feature now and we need to highlight a tagged content as a part of this functionality. In the Author mode there are no questions and all are done, but in the text component we faced with problems:
1. How to get a current selected element? In the Author mode we used next:
Code: Select all
int currentOffset = authorAccess.getEditorAccess().getCaretOffset();
AuthorNode node = authorAccess.getDocumentController().getNodeAtOffset(currentOffset);
Code: Select all
AuthorElement element = (AuthorElement) node;
AttrValue attrValue = element.getAttribute(tagName);
Code: Select all
authorAccess.getDocumentController().beginCompoundEdit();
// insert tag attribute
authorAccess.getDocumentController().removeAttribute(tag.getName(), element);
authorAccess.getDocumentController().setAttribute(tag.getName(),
new AttrValue(ConditionalProcessingUtils.getTagValue(conditionalValues)),element);
authorAccess.getDocumentController().insertXMLFragment("", currentOffset);
authorAccess.getDocumentController().endCompoundEdit();
Code: Select all
ColorHighlightPainter painter = new ColorHighlightPainter();
ColorRGB mergeColor = ColorGenerator.mergeHexColors(tagColors);
Color color = new Color(mergeColor.red, mergeColor.green, mergeColor.blue);
painter.setBgColor(color); authorAccess.getDocumentController().beginCompoundEdit();
authorAccess.getEditorAccess().getHighlighter().addHighlight(element.getStartOffset(), element.getEndOffset(), painter, new AuthorConditionalProcessingHighlight(element)); authorAccess.getDocumentController().endCompoundEdit();
Code: Select all
WSTextEditorPage currentPage = (WSTextEditorPage)editorComponent.getWSEditorAccess().getCurrentPage();
Object textComponent = currentPage.getTextComponent();
if (textComponent instanceof JTextArea) {
JTextArea textArea = (JTextArea) textComponent;
Highlighter highlighther = textArea.getHighlighter();
highlighther.addHighlight(p0, p1, p)
}
Thank you!