Edit online

Save a New Document with a Predefined File Name Pattern

Use Case

You want Oxygen XML Editor to automatically generate a file name comprising a UUID plus file extension using the SDK.

Solution

This could be done implementing a plugin for Oxygen XML Editor using the Plugins SDK.

There is a type of plugin called Workspace Access that can be used to add a listener to be notified before an opened editor is saved. The implemented plugin would intercept the save events when a newly created document is untitled and display an alternative chooser dialog box, then save the topic with the proper name.

The Java code would look like this:
  private static class CustomEdListener extends WSEditorListener{
    private final WSEditor editor;
    private final StandalonePluginWorkspace
        pluginWorkspaceAccess;
    private boolean saving = false;
    public CustomEdListener
(StandalonePluginWorkspace pluginWorkspaceAccess, WSEditor editor) {
            this.pluginWorkspaceAccess = pluginWorkspaceAccess;
            this.editor = editor;
    }
    @Override
    public boolean editorAboutToBeSavedVeto(int operationType) {
      if(! saving &&
        editor.getEditorLocation().toString().contains("Untitled")) {
        File chosenDir = pluginWorkspaceAccess.chooseDirectory();
        if(chosenDir != null) {
          final File chosenFile = 
new File(chosenDir, UUID.randomUUID().toString() + ".dita");         
        SwingUtilities.invokeLater(new Runnable() {
            @Override     
              public void run() {
              try {               
                saving = true;
                editor.saveAs(new URL(chosenFile.toURI().toASCIIString()));
              } catch (MalformedURLException e) {
                e.printStackTrace();
              } finally {
                saving = false;           
              }
            }
          });
        }
       
        //Reject the original save request.
        return false;
      }
      return true;
    }
  }
  
    @Override
    public void applicationStarted
(final StandalonePluginWorkspace pluginWorkspaceAccess) {   
    pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
      @Override
      public void editorOpened(URL editorLocation) {
        final WSEditor editor = pluginWorkspaceAccess.getEditorAccess
(editorLocation, PluginWorkspace.MAIN_EDITING_AREA);
      if(editor != 
null && editor.getEditorLocation().toString().contains("Untitled")) {
         
        //Untitled editor
 editor.addEditorListener(new CustomEdListener(pluginWorkspaceAccess, editor));
        }
      }
     },
  PluginWorkspace.MAIN_EDITING_AREA);
................................................