StylesFilter issue when reopening document

Post here questions and problems related to oXygen frameworks/document types.
Posts: 116
Joined: Wed Jun 17, 2015 12:46 pm

StylesFilter issue when reopening document

Post by Johann » Thu Jun 14, 2018 3:06 pm


I am using oxygen SDK and I have a problem with the StylesFilter class.
The goal is to add programmatically a combobox at a particular node. I want to do this programmatically because the labels and the values of this combobx are not fixed.
For this purpose, I added this kind of code in MyStylesFilter :

Code: Select all

            if (AuthorNode.NODE_TYPE_ELEMENT == authorNode.getType() && ("myElement".equals(authorNode.getName()))) {
Map<String, Object> formControlArgs = new HashMap<>();
formControlArgs.put(InplaceEditorArgumentKeys.PROPERTY_EDIT_QUALIFIED, "@myAttribute");
formControlArgs.put(InplaceEditorArgumentKeys.PROPERTY_VALUES, "value1,vale2,value3");
formControlArgs.put(InplaceEditorArgumentKeys.PROPERTY_LABELS, "label1,label2,label3");

formControlArgs.put(InplaceEditorArgumentKeys.PROPERTY_EDITABLE, "false");
StaticContent[] mixedContent = new StaticContent[]{new EditorContent(formControlArgs)};
styles.setProperty(Styles.KEY_MIXED_CONTENT, mixedContent);
return styles;
When I launch my application and open the document, I see the combobox perfectly.
But, if I close the document and re-open the same document, the combobox does not appear.
If I press F5, the combobox re-appears.
In the same way, if the combobox is not visible, if I collapse and expand the block in which the combobox is located, the combobox re-appears.

It's like the page didn't want to render...

Can you help me on this ?



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

Re: StylesFilter issue when reopening document

Post by alex_jitianu » Mon Jun 18, 2018 3:41 pm

Hi Johann,

Does it work better if you put it on a BEFORE?

Code: Select all

if(authorNode.getType() == AuthorNode.NODE_TYPE_PSEUDO_ELEMENT 
&& "before".equals(authorNode.getName())) {
authorNode = authorNode.getParent();
if ("myElement".equals(authorNode.getName())) {
By the way, the value of PROPERTY_EDIT_QUALIFIED should be the attribute name (no @) is the attribute is from no-namespace.

Code: Select all

 formControlArgs.put(InplaceEditorArgumentKeys.PROPERTY_EDIT_QUALIFIED, "myAttribute");
If the attribute is from a namespace, then it should be {namespace.uri}attributeLocalName .

Unfortunately I didn't managed to reproduce such a behavior myself. Here is how I tried:
1. I've created the sample SDK project
2. Inside oxygen-sample-framework, I've added your sample code inside simple.documentation.framework.extensions.SDFStylesFilter
3. I've built the project (mvn install) and unzipped the resulting artifact inside bundle-framework/oxygen-frameworks directory
4. I've built the bundle-framework project (mvn install)
5. Finally, inside the project oxygen-sample-swing-component I've run the main class com.oxygenxml.sdksamples.AuthorComponentSample

I've opened an XML document like the one below (is the sort of document on which the sample framework matches on):

Code: Select all

<myElement myAttribute="value1"/>
I've reproduced the steps you've described (open another file, open the sample file again) but in my case the form control is always presented.

Best regards,

Post Reply