Page 1 of 1

SchemaManagerFilter.filterAttributeValues(...) element text

Posted: Fri May 28, 2010 8:06 pm
by adamretter
I have created an implementation of SchemaManagerFilter and am specifically interested in the filterAttributeValues method for suggesting attribute values for content completion.

I have created a basic filter and have it installed into a Document Type in oXygen and its working well. However I would now like to make my suggestions based on the existing text content of the element.

How can I get the text of the element that the attribute is attached to? I can get the element, but cannot see how to get the text!

I am using -

ContextElement element = context.getParentElement();

But how can I retrieve the text of that element?

Thanks Adam.

Re: SchemaManagerFilter.filterAttributeValues(...) element text

Posted: Mon May 31, 2010 12:04 pm
by Radu
Hi Adam,

The context passed to the WhatAttributesCanGoHereContext object which comes on the filterAttributeValues only contains a path of XML elements in which the last element is the current one. So you cannot obtain the text of the current element from this context.
If you want to implement this only for the Text page:
You have to get access to the JTextArea in which the user is editing.
You can do this by something like:
KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()

Then looking at the caret position in the JTextArea maybe you can search in it for the text after the first >.

Regards,
Radu