
Hi Anthony, Thanks for the feedback. So about number (2):
(1) This approach may be problematic for big documents, as the whole document is stored in a string.
You are right, we considered the Untitled documents to be quite small at the beginning (usually created from file templates). If such issue arises in the future we could consider adding another method which gives a Reader for the newly created content. For example the Author page usually needs 10-15 times the size of a file on disk in order to display it so if the content is very large the out of memory would most probably occur in that area.
(2) The created document is not marked as modified. Untitled documents are not marked as modified and thus they can be closed without saving their content. But even if they are not marked as modified they can be saved with the final file name. This works exactly as using the File menu->New action in Oxygen. But of course you can mark it as modified if it better fits your purpose.
There are at least two ways of addressing the first of these points. One approach is to create a small blank document that is then overridden using the WSEditod's realoadContent(Reader). Here, the question I had was: what is the minimal XML document that can be overridden (and get the right document type association - e.g. DITA)? It might be that oXygen could automatically create such a document from the first two arguments of the createNewEditor method.
You can set any content to the new document like "<root/>" and then reload it with the real content. The document type should be detected automatically when Oxygen senses the changes. But the switch to the Author page will not be automatically performed. My suggestion is to use the method which delivers the entire content as a string.
A second approach could be to replace the third argument of the createNewEditor method with a java.io.Reader argument, such as is used when reloading a document into an existing WSEditor (editor.reloadContent(reader)).
We always mark our API as experimental but try to maintain backward compatibility the best we can. The solution would be adding in the API another method: URL createNewEditor(String extension, String contentType, Reader content) We'll consider this for a future version. But the already existing method will remain. Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 3/3/2011 6:11 PM, Michael Anthony Smith wrote:
I have now made use of four of the experimental oXygen plugin workspace API options (on a Mac running OS X - Snow Leopard) :
(1) getOptionsStorage - This has a straightforaward interface, which worked as expected. (2) createNewEditor - This was slightly more awkward to use in our plugin's context (more details below). (3) getEntityResolver - Works as expected (thanks). (4) getURIResolver - Appears to works as expected (but currently, not tested).
I have managed to get the 'createNewEditor' API call to create a fresh document that is considered to be modified, using the following code:
Writer writer = new StringWriter(); ... // Write to the string. ... URL url= workspace.createNewEditor("xml", "text/xml", writer.toString()); WSEditor ed=workspace.getEditorAccess(url, StandalonePluginWorkspace.MAIN_EDITING_AREA); ed.setModified(true);
Observations:
(1) This approach may be problematic for big documents, as the whole document is stored in a string. (2) The created document is not marked as modified.
There are at least two ways of addressing the first of these points. One approach is to create a small blank document that is then overridden using the WSEditod's realoadContent(Reader). Here, the question I had was: what is the minimal XML document that can be overridden (and get the right document type association - e.g. DITA)? It might be that oXygen could automatically create such a document from the first two arguments of the createNewEditor method.
A second approach could be to replace the third argument of the createNewEditor method with a java.io.Reader argument, such as is used when reloading a document into an existing WSEditor (editor.reloadContent(reader)).
Overall, I am pleased with these experimental enhancements.
Regards, Anthony.
-- -- ------------------------------------------------------------------------- Michael Anthony Smith, DeltaXML Ltd "Change control for XML" T: +44 1684 578751 E:anthony.smith@deltaxml.com http://www.deltaxml.com Registered in England 02528681 Reg. Office: Monsell House, WR8 0QN, UK
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user