mini refresh on set/remove pseudoclass?
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 14
- Joined: Thu Sep 24, 2020 8:20 pm
mini refresh on set/remove pseudoclass?
Hi,
I have a class that shows/hides tags based on whether or not a pseudoclass is applied to the root.
...
private static final String PSEUDOCLASS = "show-all-data";
...
doOperation...
AuthorElement root = adc.getAuthorDocumentNode().getRootElement();
boolean dataShown = root.hasPseudoClass(PSEUDOCLASS);
Show/hide is done via element.setPseudoClass(PSEUDOCLASS) and element.removePseudoClass(PSEUDOCLASS).
The issue is that these tags do not show/hide unless I do a full page refresh via authorAccess.getEditorAccess().refresh().
Is there a way to refresh at the element level or refresh only on the inserted fragment or am I missing a method that redraws just psuedoclasses?
I have a class that shows/hides tags based on whether or not a pseudoclass is applied to the root.
...
private static final String PSEUDOCLASS = "show-all-data";
...
doOperation...
AuthorElement root = adc.getAuthorDocumentNode().getRootElement();
boolean dataShown = root.hasPseudoClass(PSEUDOCLASS);
Show/hide is done via element.setPseudoClass(PSEUDOCLASS) and element.removePseudoClass(PSEUDOCLASS).
The issue is that these tags do not show/hide unless I do a full page refresh via authorAccess.getEditorAccess().refresh().
Is there a way to refresh at the element level or refresh only on the inserted fragment or am I missing a method that redraws just psuedoclasses?
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: mini refresh on set/remove pseudoclass?
Hi,
You should toggle the pseudo class using the AuthorDocumentController API:
because it also takes care of triggering the appropriate listeners which update the UI.
Regards,
Radu
You should toggle the pseudo class using the AuthorDocumentController API:
Code: Select all
adc.setPseudoClass(String, AuthorElement)
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 14
- Joined: Thu Sep 24, 2020 8:20 pm
Re: mini refresh on set/remove pseudoclass?
Thanks -- this worked.
The note on WSAuthorEditorPageBase -> refresh(AuthorNode authorNode), "Note: This should be called on the AWT thread because it will generate a layout event," can I assume that adc.setPseudoClass(String, AuthorElement) does that?
The note on WSAuthorEditorPageBase -> refresh(AuthorNode authorNode), "Note: This should be called on the AWT thread because it will generate a layout event," can I assume that adc.setPseudoClass(String, AuthorElement) does that?
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: mini refresh on set/remove pseudoclass?
Hi,
Most of our API is not thread safe. So if you have started a separate thread and want to use our API you can do something like:
Regards,
Radu
Most of our API is not thread safe. So if you have started a separate thread and want to use our API you can do something like:
Code: Select all
Runnable runnable = new Runnable() {
@Override
public void run() {
//Work with API here.
}
};
if(! SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeAndWait(runnable);
} else {
runnable.run();
}
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 14
- Joined: Thu Sep 24, 2020 8:20 pm
Re: mini refresh on set/remove pseudoclass?
The client has asked us to enable this macro in a read-only context. However, it takes up to 10 times as long for this operation to complete when the document is read-only.
Can you think of a reason why it would take so much longer in this context?
Would placing this on a separate thread prevent oXygen from essentially freezing while the operation is running?
Can you think of a reason why it would take so much longer in this context?
Would placing this on a separate thread prevent oXygen from essentially freezing while the operation is running?
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: mini refresh on set/remove pseudoclass?
Hi,
I do not know exactly what your customization does. Do you call refresh on the entire document or on a certain node? Is it a large document or a node which contains lost of content? Do you call it a number of times?
Or do you call the API to set a pseudo attribute? Do you call it on many elements which have lots of content?
It is quite possible these refresh operations would take lots of time if called on large sections of a document or if called lots of time.
Regards,
Radu
I do not know exactly what your customization does. Do you call refresh on the entire document or on a certain node? Is it a large document or a node which contains lost of content? Do you call it a number of times?
Or do you call the API to set a pseudo attribute? Do you call it on many elements which have lots of content?
It is quite possible these refresh operations would take lots of time if called on large sections of a document or if called lots of time.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 14
- Joined: Thu Sep 24, 2020 8:20 pm
Re: mini refresh on set/remove pseudoclass?
The macro was updated awhile back to only refresh on a node-by-node basis instead of the whole document.I do not know exactly what your customization does. Do you call refresh on the entire document or on a certain node? Is it a large document or a node which contains lost of content? Do you call it a number of times?
Or do you call the API to set a pseudo attribute? Do you call it on many elements which have lots of content?
It is quite possible these refresh operations would take lots of time if called on large sections of a document or if called lots of time.
The client did some more rigorous testing and found that the times were actually pretty similar between read-only vs. non-read-only. The 10x figure was simply because the last document they tested had over 1700 elements being hidden/shown at once. I think my question is actually a non-issue.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: mini refresh on set/remove pseudoclass?
Hi,
Ok, I'm not sure how to help further, sometimes when you have lots of nodes in the document it might become faster to refresh an entire document than to refresh each node individually.
Regards,
Radu
Ok, I'm not sure how to help further, sometimes when you have lots of nodes in the document it might become faster to refresh an entire document than to refresh each node individually.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service