Modify Link Action

Posts: 150
Joined: Mon Aug 18, 2014 4:11 pm

Modify Link Action

Post by mu258770 » Wed Jan 07, 2015 1:23 pm

Hi Alex,

We are working in one more functionality as "Modify inserted Link" in oxygen eclipse. What is required is if user select a link and by selecting "Modify Link" option from menu or toolbar, he should get the link in the proper text box and he should be able to edit it. This is similar to "Edit Attributes", but difference is our link is a mixture of many fields.

For eg :- Consider the link is as below,

<xref topicname#sectionname>

Now user selects Modify Link from toolbar (this we have done using framework changes), then we need to get 'topicname' in one field and 'sectionname' in another.

How can we do this. How can we read character from the editor using java code.


Posts: 851
Joined: Wed Nov 16, 2005 11:11 am

Re: Modify Link Action

Post by alex_jitianu » Wed Jan 07, 2015 5:14 pm


I suspect that there is an href attribute there, that contains the topicName#sectionName value, right? You can get it and set it back like this:

Code: Select all

int caretOffset = authorAccess.getEditorAccess().getCaretOffset();
AuthorNode xrefNode = authorAccess.getDocumentController().getNodeAtOffset(caretOffset);
if (xrefNode.getType() == AuthorNode.NODE_TYPE_ELEMENT) {
AuthorElement authorElement = (AuthorElement) xrefNode;

// How to get/set an attribute value
AttrValue attribute = authorElement.getAttribute("href");

String[] topicNameAndSection = attribute.getValue().split("#");
// TODO ......
// To set the value back you must use the controller
authorAccess.getDocumentController().setAttribute("href", new AttrValue("newValue"), authorElement);
You can learn more about the Author document model by reading about the AuthorNode and AuthorElement.

best regards,

Post Reply