Detecting new file
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 42
- Joined: Mon Aug 18, 2014 11:50 pm
Detecting new file
Is it possible to detect when a file was just created from a template?
I supposes for unsaved files the title would always be Untitled# and I can use isNewDocument(). But what about documents just created from a template using the DITA Map > insert > New Topic ?
What I am trying to do is always enable track changes, except for when the file has just been created from a template. I suppose I could put some flag or PI in all the template files that get striped off when the file is about to be saved but that seems kind of tweak.
I supposes for unsaved files the title would always be Untitled# and I can use isNewDocument(). But what about documents just created from a template using the DITA Map > insert > New Topic ?
What I am trying to do is always enable track changes, except for when the file has just been created from a template. I suppose I could put some flag or PI in all the template files that get striped off when the file is about to be saved but that seems kind of tweak.
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Detecting new file
Hi,
But why make this difference between new files and existing files?
One possibility I would see for this would be to add a listener to the DITA Map Editor manager to see when a new DITA Map is opened. Then on the opened DITA Map use the API ro.sync.exml.workspace.api.editor.page.ditamap.WSDITAMapEditorPage.setPopUpMenuCustomizer(DITAMapPopupMenuCustomizer) to set a popup menu customizer which replaces the Append Child->New topic action with your own action which sets a flag, then calls the default action and then resets it.
You would look at that flag when a new topic is opened to see if it was triggered from that action.
Regards,
Radu
Right.I supposes for unsaved files the title would always be Untitled# and I can use isNewDocument().
Indeed for such cases the isNewDocument() API returns false because the file was already created and saved on disk before being opened.But what about documents just created from a template using the DITA Map > insert > New Topic ?
So when somebody uses DITA Map > insert > New Topic to insert a topic you would like the newly created and opened topic to have track changes off? Then if the user closes and reopens it you would toggle track changes on it?What I am trying to do is always enable track changes, except for when the file has just been created from a template. I suppose I could put some flag or PI in all the template files that get striped off when the file is about to be saved but that seems kind of tweak.
But why make this difference between new files and existing files?
One possibility I would see for this would be to add a listener to the DITA Map Editor manager to see when a new DITA Map is opened. Then on the opened DITA Map use the API ro.sync.exml.workspace.api.editor.page.ditamap.WSDITAMapEditorPage.setPopUpMenuCustomizer(DITAMapPopupMenuCustomizer) to set a popup menu customizer which replaces the Append Child->New topic action with your own action which sets a flag, then calls the default action and then resets it.
You would look at that flag when a new topic is opened to see if it was triggered from that action.
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: Detecting new file
Because in our current environment, editors know if a file is new or not based on the version history or if there are no tracked changes, then the entire file content is new and needs to be reviewed. Its kinda silly for the entire document to be marked up with inserts. I was able to accomplish what I we need with a PI and the following code in editorOpened():But why make this difference between new files and existing files?
Code: Select all
AuthorNode an = topNodes.get(0);
if(an.getType() == AuthorNode.NODE_TYPE_PI && an.getTextContent().equals("New Document")) {
if(revCtrlr.isTrackingChanges())
revCtrlr.toggleTrackChanges();
ctrl.deleteNode(an);
}
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