prettyPrint with oXygen settings

Post here questions and problems related to oXygen frameworks/document types.
msklvsk
Posts: 9

prettyPrint with oXygen settings

Fri May 13, 2016 10:07 pm

Documentation states that pluginWorkspaceAccess.getXMLUtilAccess().prettyPrint() will print with oXygen settings, however for me it doesn't. Particularly, it line-breaks elements which have no whitespace in between, while Format and Indent action behaves as expected. I tried null and "http://www.tei-c.org/Lite/DTD/teixlite.dtd" as systemId parameter. How can I simulate Format and Indent action? And more generally, what is the proper way to programmatically invoke oXygen's action?
Radu
Posts: 5380

Re: prettyPrint with oXygen settings

Mon May 16, 2016 11:02 am

Hi,

There indeed seems to be a difference between the API and the "Format and Indent" action. The "Format and indent" action also looks at the schema (RNG or DTD) referenced by the XML while the API method ignores it. I will add an issue to see if we can fix this on our side.
But you seem to want to actually call the toolbar action on the current opened file contents. Do you use a workspace access plugin extension? For example if you want to format and indent the file on open you could use some code like:

Code: Select all

      @Override
      public void applicationStarted(final StandalonePluginWorkspace pluginWorkspaceAccess) {
        pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener(){
          public void editorOpened(URL editorLocation) {
            WSEditor editor = pluginWorkspaceAccess.getEditorAccess(editorLocation, PluginWorkspace.MAIN_EDITING_AREA);
           WSEditorPage edPage = editor.getCurrentPage();
           if(edPage instanceof WSXMLTextEditorPage){
             WSXMLTextEditorPage tp = (WSXMLTextEditorPage)edPage;
             Object formatAndIndentAction = tp.getActionsProvider().getTextActions().get("Source/Pretty_print_tooltip");
             tp.getActionsProvider().invokeAction(formatAndIndentAction);
           }
          }
        }, PluginWorkspace.MAIN_EDITING_AREA);
      }


Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
msklvsk
Posts: 9

Re: prettyPrint with oXygen settings

Mon May 16, 2016 1:01 pm

Hi Radu!

Yes, I am using workspace access plugin extension.
Invoking actions in your snippet's way works, but now the question is where can I get actions' ID strings, like that "Source/Pretty_print_tooltip"?
Radu
Posts: 5380

Re: prettyPrint with oXygen settings

Mon May 16, 2016 1:10 pm

Hi,

We do not have particular documentation for each action ID but you can use System.err to print to console the entire map tp.getActionsProvider().getTextActions(). If you start Oxygen using the command line startup script you should see in the console messages from your plugins.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
msklvsk
Posts: 9

Re: prettyPrint with oXygen settings

Mon May 16, 2016 3:33 pm

Oh, I see, It's just a Map. Thanks, it works.

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 2 guests