plugin to read the templates from our installed frameworks location

Post here questions and problems related to oXygen frameworks/document types.
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

Hello Team , Would you please help here.
our custom plugin and custom frameworks will be installed as add-on.
and we wanted our plugin to read the templates from our installed frameworks location. see here how oxygen is reading and displaying for "choose a file template" dialog
image.png
image.png (76.48 KiB) Viewed 836 times
we wanted to read the templates list from our custom DITA and DITAMP frameworks location in the plugin as like how oxygen is reading above.
would you please let me know how can we achieve the same?
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hi,
I assume you have defined your custom template directories in your DITA custom framework extensions.
https://blog.oxygenxml.com/topics/autho ... lates.html
Oxygen already has a "File->New" dialog, do you want to replicate this effort and create your own File->New dialog?

We have an API which could be used from a workspace access plugin extension:
ro.sync.exml.workspace.api.WorkspaceUtilities.getTemplateManager()
https://www.oxygenxml.com/InstData/Edit ... eManager()

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

Re: plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

Thanks Radu ,
yes our custom dita and ditamap installed via addons , installed here
\AppData\Roaming\com.oxygenxml\extensions\v24.0\frameworks\https_oxygen_addons.host1.abc.com_updateSite.xml\my-dita-framework
the folders inside the my-dita-framework folder , here
image.png
image.png (14.7 KiB) Viewed 809 times
Sure , We will try using the API getTemplateManager

Code: Select all

Oxygen already has a "File->New" dialog, do you want to replicate this effort and create your own File->New dialog?
Yes Radu , we wanted to have our own dialog , reading our templates and allow the user to create the dita file based on the selected template.
my next question was like , can we also achieve this from the oxygen plugin?

Thanks,
vishwa
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hi,
I usually advise people against re-implementing our existing functionality. With enough effort anything can be done, an Oxygen workspace access plugin can access also the main toolbar, maybe remove the existing "New" action, add your own action to create a new file. The same for accessing the main menu and removing the "File->New" action from there. Then you can work on a custom Swing dialog to present new file templates to users.
About accessing from a plugin resources from a framework, we also have this API:

Code: Select all

ro.sync.exml.workspace.api.util.UtilAccess.expandEditorVariables("${framework(DITA Extension)}", null) 
so if for example your framework's name is "DITA Extension", expanding the "${framework(DITA Extension)}"" editor variable should give you the folder path to it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

Re: plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

Sure Radu , we will evaluate as per your suggestion.
my frameworks named as "my-dita-framework" installed via addons
and installed at this place

Code: Select all

\AppData\Roaming\com.oxygenxml\extensions\v24.0\frameworks\xxxxxx.com_updateSite.xml\my-dita-framework
and i was trying the below from my pluginExtension class of

Code: Select all

public void applicationStarted(StandalonePluginWorkspace oxygenWorkspace) ()
method as below

Code: Select all

String pathToDitaTemplatesFolder = oxygenWorkspace.getUtilAccess().expandEditorVariables("${framework(my-dita-framework)}", null);
it is not printing anything
expandEditorVariables will only work from the OxygenInstllation directory?
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hi,

In your case "my-dita-framework" is the name of your framework directory.
The name of your framework is the name which appears in the Oxygen Preferences->"Document Type Association" page in the "Document type" column.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

Re: plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

Radu , in continuation with the the above question , our requirement is to create the file form the selected template

Code: Select all

StandalonePluginWorkspace OXYGEN_WORKSPACE = (StandalonePluginWorkspace) PluginWorkspaceProvider.getPluginWorkspace();

String pathToDitaTemplatesFolder =OXYGEN_WORKSPACE.getUtilAccess().expandEditorVariables("${framework(my-dita-framework)}", null);

pathToDitaTemplatesFolder=pathToDitaTemplatesFolder+"\\templates\\Common Topics\\Concept.xml"

from one of  our own dialog , reading our templates path (\\templates\\Common Topics\\Concept.xml) and trying to create the concept file based on the selected template.

and am trying like as below

try {	OXYGEN_WORKSPACE.open(OXYGEN_WORKSPACE.createNewEditor("xml", "text/xml", <not sure what to fill here???);
	} catch (MalformedURLException e) {
		e.printStackTrace();
	}
and our template file has custom editor variable 		
<concept id="${customUUID}" xml:lang="en-US">
      ---------------------
	  -----------------------
</concept>		
am trying this createNewEditor since am reading that is same like File - > new
so would you please help me to create the file form the selected template
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hi,

I do not understand clearly what the problem is. Did you call the API? Does it not work?
You can look at our Javadoc API to know more about what each method does:

https://www.oxygenxml.com/InstData/Edit ... ng.String)

As for your custom editor variable, you can probably expand it yourself before calling our API which opens an untitled XML document.
About your use of file path separators like this:

"\\templates\\Common Topics\\Concept.xml"

they do not work on Linux or Mac, ideally even if your plugin is only for Windows Oxygen users, you should use the "/" separator for paths which works in Java both for Windows and Mac/Linux.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

Re: plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

let me rephrase my question

for the API
createNewEditor​(java.lang.String extension, java.lang.String contentType, java.lang.String content)
what is the content?
meanwhile i tried creating a sting like the below

Code: Select all

String myconcept_content="<?xml version="1.0" encoding="UTF-8"?>
<!-- Template: Concept -->
<!DOCTYPE concept PUBLIC "-//xxx//DTD xxx DITA Concept//EN" "xxxx.dtd"[]>
<concept id="${customUUID}" xml:lang="en-US">
    <title>&lt;Enter Concept Title Here&gt;</title>
   
    <shortdesc>(Required) &lt;Enter a short description here.&gt;</shortdesc>
    
    <prolog>
        <metadata>
            <othermeta name="template" content="Concept"/>
        </metadata>
    </prolog>
    <conbody>
      
    </conbody>
</concept>";
and used that as
createNewEditor("xml", "text/xml", myconcept_content)

it is created and opened the file in oxygen but the customUUID is not resolved
image.png
image.png (29.15 KiB) Viewed 447 times
the string i have created String myconcept_content is not a good approach , or i might be doing wrong here , please help me here.
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hi,
I confirm that Oxygen will not auto expand editor variables when using this API to create a new document.
Did you add in Oxygen the support to expand the "customUUID" using the "UtilAccess.addCustomEditorVariablesResolver(EditorVariablesResolver)" API?
If so you can use "ro.sync.exml.workspace.api.util.UtilAccess.expandEditorVariables(String, URL)" API to expand the editor variables yourself before passing the content to Oxygen's API.
https://www.oxygenxml.com/InstData/Edit ... ccess.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

Re: plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

Hi Radu,
yes we do the below inside
applicationStarted() method of CustomWorkspaceAccessPluginExtension implements WorkspaceAccessPluginExtension
oxygenWorkspace.getUtilAccess().addCustomEditorVariablesResolver(customEditorVariablesResolver);
when we do regular flow from oxygen
File - New , and then select template , that is resolving fine.
as you mentioned
ro.sync.exml.workspace.api.util.UtilAccess.expandEditorVariables(String, URL)
i have to try this.

and also please confirm me for the API
createNewEditor​(java.lang.String extension, java.lang.String contentType, java.lang.String content)
the String content what am passing is correct? is there any better approach?
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hi,
Yes, you seem to be properly passing the API parameters, the first one being the extension "xml" in your case, the second the content type "text/xml" and the third the content to load in the untitled file.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

Re: plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

one more question here Radu.
our template content to load in the untitled file has the customUUID varable as below.
<concept id="${customUUID}" xml:lang="en-US">

so here when i before calling the createNewEditor​(java.lang.String extension, java.lang.String contentType, java.lang.String content)
do i need to to expand the customUUID varable using o.sync.exml.workspace.api.util.UtilAccess.expandEditorVariables(String, URL)
and then replace that in my template content to load and then call
createNewEditor​(java.lang.String extension, java.lang.String contentType, java.lang.String content)?
or is something this can be achieved in some other way?
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hi,
You understood my suggestion precisely.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 160
Joined: Fri Feb 28, 2020 4:02 pm

Re: plugin to read the templates from our installed frameworks location

Post by vishwavaranasi »

Thanks a ton Radu :)
your inputs worked for me to implement the feature of create new file from our custom dialogs. :D
Thanks,
vishwa
Radu
Posts: 9246
Joined: Fri Jul 09, 2004 5:18 pm

Re: plugin to read the templates from our installed frameworks location

Post by Radu »

Hello,
Great, I'm glad this worked for you!
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply