showStatusMessage
Oxygen general issues.
-
- Posts: 96
- Joined: Mon May 09, 2011 11:54 am
showStatusMessage
Hi,
I try to use showStatusMessage in a for loop in a custom oxygen plugin to display the status while replacing some elements in the document. It should show the progress, e.g. "x of y nodes replaced" but the status appear only after the plugin is finished. How can I push a 'live' message to the oxygen status bar?
Thanks,
Patrick
I try to use showStatusMessage in a for loop in a custom oxygen plugin to display the status while replacing some elements in the document. It should show the progress, e.g. "x of y nodes replaced" but the status appear only after the plugin is finished. How can I push a 'live' message to the oxygen status bar?
Thanks,
Patrick
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: showStatusMessage
Hello Patrick,
This is the usual behavior of swing applications.
An AuthorOperation is executed on the Java AWT thread.
As long as the AWT thread is busy (performing the operation's code) repaint is not done in the entire application as the repaint should also be made by the AWT thread.
What you could try to do would be to start a thread which performs the operation's code.
But be careful to invoke all the code which interacts with our internal model on the AWT thread using javax.swing.SwingUtilities.invokeAndWait(Runnable) because the Author model is not thread safe.
So your code could look a little like this:
In this way the AWT thread would be freed at times and might be able to show the status change.
Regards,
Radu
This is the usual behavior of swing applications.
An AuthorOperation is executed on the Java AWT thread.
As long as the AWT thread is busy (performing the operation's code) repaint is not done in the entire application as the repaint should also be made by the AWT thread.
What you could try to do would be to start a thread which performs the operation's code.
But be careful to invoke all the code which interacts with our internal model on the AWT thread using javax.swing.SwingUtilities.invokeAndWait(Runnable) because the Author model is not thread safe.
So your code could look a little like this:
Code: Select all
/**
* @see ro.sync.ecss.extensions.api.AuthorOperation#doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
*/
@Override
public void doOperation(final AuthorAccess authorAccess, ArgumentsMap args)
throws IllegalArgumentException, AuthorOperationException {
new Thread("modifying thread"){
public void run() {
for (int i = 0; i < 100; i++) {
authorAccess.getWorkspaceAccess().showStatusMessage("THE STATUS " + i);
//And modify some nodes
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
authorAccess.getDocumentController().setAttribute("test", new AttrValue("val"), element);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}.start();
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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