Plugin - JavaScript Demo Works?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
jlpoole
Posts: 23
Joined: Sun Jan 15, 2017 3:15 pm
Location: Salem, Oregon

Plugin - JavaScript Demo Works?

Post by jlpoole »

I'm recreating the example plugin at https://www.oxygenxml.com/doc/versions/ ... in-js.html

I copied the content from the examples into two files, plugin.xml, and msAcess.js, and placed the files in my Oxygen plugins folder.

I launched Oxygen from a DOS console (so I might see any System.out.println or error output), selected the example flowers.ditamap and then looked for the "Run notepad" in two windows. I did not see any output in my DOS console indicating that the plugin had loaded, nor was I able to see the menu item, "Run notepad", that should have added.

What do I need to do to have the plugins activated?

My version of Oxygen:
Image

Showing the files in the plugins directory:
Image

Depicting the right click pop-up menu in the ditamap views:
Image
Image
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: Plugin - JavaScript Demo Works?

Post by Radu »

Hi,

In the Oxygen "plugins" folder you should create another folder called for example something like "myPlugin" in which the plugin.xml and all other resources are located.
Here's a github project which contains various workspace access plugin samples, maybe it will help you see other examples as well:

https://github.com/oxygenxml/wsaccess-j ... le-plugins

Oh, and we will update our documentation to explain more properly the need for a plugin-specific folder inside the plugins folder.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
jlpoole
Posts: 23
Joined: Sun Jan 15, 2017 3:15 pm
Location: Salem, Oregon

Re: Plugin - JavaScript Demo Works?

Post by jlpoole »

Thank you, your instructions worked.

I created a subfolder "radu", to wit: C:\Program Files\Oxygen XML Editor 18\plugins\radu, and moved the two files plugin.xml and msAcess.js, into the "radu" folder and then launched Oxygen from the command line. The "run notepad" now displays in the right-click pop-up menu.

Here's session output:

Code: Select all

C:\Program Files\Oxygen XML Editor 18>oxygen.bat
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Application started ro.sync.exml.workspace.b.c.k@e62319f
0 WARN [ main ] ro.sync.exml.project.c - Could not load the last project file.java.io.IOException: No scenario in specified file.

running file:/C:/Users/jlpoole/Documents/OxygenXMLEditor/samples/dita/flowers/flowers.ditamap
5253 WARN [ AuthorExtensionBuilder ] ro.sync.ecss.extensions.g - Actions update state took too long, checkOffset 29 in file:/C:/Users/jlpoole/Documents/OxygenXM
amap
RIGHT CLICKro.sync.ecss.component.ui.f.b.t[,0,0,0x0,invalid,layout=javax.swing.plaf.basic.DefaultMenuLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.pla
mumSize=,minimumSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPopupEnabled=true,margin=,paintBorder=true]
Computed absolute reference file:/C:/Users/jlpoole/Documents/OxygenXMLEditor/samples/dita/flowers/topics/flowers/snowdrop.dita
Application closing ro.sync.exml.workspace.b.c.k@e62319f

C:\Program Files\Oxygen XML Editor 18>
This issue is now resolved. Thank you.
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: Plugin - JavaScript Demo Works?

Post by Radu »

Hi John,

Great. Once you have a stable plugin and want to share it with others, the procedure is this one:

https://www.oxygenxml.com/doc/versions/ ... ddons.html

because most people might not have admin privileges to create folders in the Windows program files area.
Or you can instruct users to install Oxygen in a place (user home for example) with full read/write access allowed to all applications.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
steelejc15425
Posts: 4
Joined: Wed Aug 24, 2022 9:34 pm

Re: Plugin - JavaScript Demo Works?

Post by steelejc15425 »

I saw this line in the thread earlier:

"I launched Oxygen from a DOS console (so I might see any System.out.println or error output)."

Is launching from a DOS console the best way to see output from javascript?
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: Plugin - JavaScript Demo Works?

Post by Radu »

Hi,
Yes, if your Javascript based plugin for the Oxygen desktop application uses System.err and System.out to display debug messages or if it throws an exception at some point, if you start Oxygen using the executable script (oxygen.bat on Windows, oxygen.sh on Mac/Linux) you might be able to see more details in the command prompt window.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
AmandaJansen
Posts: 1
Joined: Sun Jul 30, 2023 2:46 pm

Re: Plugin - JavaScript Demo Works?

Post by AmandaJansen »

Thanks, my issue has been fixed.
steelejc15425
Posts: 4
Joined: Wed Aug 24, 2022 9:34 pm

Re: Plugin - JavaScript Demo Works?

Post by steelejc15425 »

I was going to try to modify this sample plugin. The goal would be to edit absoluteRef so that instead of pointing to a path like c:\en-US\calculations\normal.dita I could open c:\de-DE\calculations\normal.dita.

I thought that opening a file would be as simple as swapping out:
Packages.java.lang.Runtime.getRuntime().exec("notepad.exe "
+ pluginWorkspaceAccess.getUtilAccess().locateFile(absoluteRef));

For something like:
Packages.ro.sync.exml.workspace.api.Workspace.open(absoluteRef);

But this results in an error:
Exception in thread "AWT-EventQueue-0" org.mozilla.javascript.EcmaError: TypeError: Cannot find function printStackTrace in object InternalError: Java class "ro.sync.exml.workspace.api.Workspace" has no public instance field or method named "open".

I assume this is a novice problem. Do you see what I've done wrong?
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: Plugin - JavaScript Demo Works?

Post by Radu »

Hi,

The method you are trying to invoke:
https://www.oxygenxml.com/InstData/Edit ... a.net.URL-
is not a static Java method, it's a method which belongs to an object.
So I think you should use instead:

Code: Select all

pluginWorkspaceAccess.open(absoluteRef);
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
steelejc15425
Posts: 4
Joined: Wed Aug 24, 2022 9:34 pm

Re: Plugin - JavaScript Demo Works?

Post by steelejc15425 »

That's exactly right!
(I thought I had tried it already, but my notes reveal that I accidentally started pluginWorkspaceAccess with a capital P.)
Post Reply