SchemaManagerFilter.filterAttributeValues(...) element text

Oxygen general issues.
adamretter
Posts: 3
Joined: Fri May 28, 2010 7:59 pm
Location: London, UK
Contact:

SchemaManagerFilter.filterAttributeValues(...) element text

Post 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.
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

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

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply