Set prolog revised date on save?
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 42
- Joined: Mon Aug 18, 2014 11:50 pm
Set prolog revised date on save?
Is it possible to get Oxygen to update the revised date on a DITA document when it's saved? I tried updating the attribute during a editorAboutToBeSavedVeto(), EditorListener event, but it throws a java.lang.Error: Fire should be on the AWT thread. error.
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Set prolog revised date on save?
Hi,
The save action is called on a thread in order not to block the entire application if the content will be saved on a remote server for example.
All modifications to the internal Author editing mode model must be done on the AWT thread so you should call:
Regards,
Radu
The save action is called on a thread in order not to block the entire application if the content will be saved on a remote server for example.
All modifications to the internal Author editing mode model must be done on the AWT thread so you should call:
Code: Select all
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
//YOUR CODE HERE
}
});
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 42
- Joined: Mon Aug 18, 2014 11:50 pm
Re: Set prolog revised date on save?
Ah,, exactly what I needed, thank you so much. I see that now in the the FAQ of the Developer Guide, should have looked harder first. Looks like I need it both ways though, since closing the application or closing the file seems to trigger the save action on the AWT thread.
Looks like I might need to find another way though, the editorAboutToBeSavedVeto event triggers before the save-"Yes, No, Cancel" dialog comes up. So if a user presses No or cancel the editor was not actually about to be saved. Humm... I guess I will try the AuthorListener and update the revised date when any change occurs to the document. Or is there a way to recorder the WSEditorListener so my listener is only called after a yes confirm Save on editor close?
Code: Select all
if(! SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
//CODE;
}
});
} else
//CODE;
Looks like I might need to find another way though, the editorAboutToBeSavedVeto event triggers before the save-"Yes, No, Cancel" dialog comes up. So if a user presses No or cancel the editor was not actually about to be saved. Humm... I guess I will try the AuthorListener and update the revised date when any change occurs to the document. Or is there a way to recorder the WSEditorListener so my listener is only called after a yes confirm Save on editor close?
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Set prolog revised date on save?
Hi,
and call it with a Runnable which contains your code.
But it probably does not matter much for your particular situation, you can modify the document and set the revised date even if the user eventually rejects the save on close operation.
The AuthorListener is called quite often (for each small modification) and I would not see it a good place from where to make changes in the XML content.
Regards,
Radu
Exactly, you can probably create an utility method like:Looks like I need it both ways though, since closing the application or closing the file seems to trigger the save action on the AWT thread.
Code: Select all
/**
* Invokes a runnable synchronously on the AWT thread. The current thread
* may be AWT or not. Returns after the runnable is run.
*
* @param runnable The runnable to be run.
*/
public static void invokeSynchronously(final Runnable runnable) {
if (SwingUtilities.isEventDispatchThread()) {
runnable.run();
} else {
try {
SwingUtilities.invokeAndWait(runnable);
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Yes, the API is called before the dialog is shown. We considered this callback is a good way for the developer to reject the save operation completely (by returning "false") and thus there will be situations when the Save dialog shown by Oxygen can be prohibited to appear.Looks like I might need to find another way though, the editorAboutToBeSavedVeto event triggers before the save-"Yes, No, Cancel" dialog comes up. So if a user presses No or cancel the editor was not actually about to be saved. Humm... I guess I will try the AuthorListener and update the revised date when any change occurs to the document. Or is there a way to recorder the WSEditorListener so my listener is only called after a yes confirm Save on editor close?
But it probably does not matter much for your particular situation, you can modify the document and set the revised date even if the user eventually rejects the save on close operation.
The AuthorListener is called quite often (for each small modification) and I would not see it a good place from where to make changes in the XML content.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 42
- Joined: Mon Aug 18, 2014 11:50 pm
Re: Set prolog revised date on save?
Thanks for the reply, that makes sense now that you explain it. Yeah I figured the AuthorListener would be called often. If I did that, I would have had an if(!setOnce) or something so it only sets it once.
Return to “DITA (Editing and Publishing DITA Content)”
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