Author Options: GUI for person-search

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Pagina_SL
Posts: 7
Joined: Tue Jan 30, 2024 1:03 pm

Author Options: GUI for person-search

Post by Pagina_SL »

Hello, I am completely new to working with Oxygen and I need to write an Author Option in an XML-File with JavaScript. With the option, I want to customize the person search from ediarum. I want to build a GUI window that looks like the one in the image below:

1. It needs a field for user-input which can be typed but at the same time, this field shall keep track on which part of text has been selected by the user.
2. If any change in this field occurs, a method (which I still have to write) shall be fired which extracts matching person-entries from a Personen.xml file and prints all matches in a window below the search-field.
3. The matches in the window shall be clickable and on click, the selection shall be tagged like <persName key="woa_AE0DFAF3-A2B1-4806-BACB-96F4945801E5">Agathon</persName> (the value of key comes from Personen.xml and extracting it will be part of the method I still need to write).
Screenshot (11).png
Screenshot (11).png (102 KiB) Viewed 458 times
In the documentation, I found this package here (https://www.oxygenxml.com/InstData/Edit ... mmary.html) but I could not figure out how to work with the methods listed there. Since I am actually quite stuck, I have not much code to provide so far, it is only the one given below and I would highly appreciate some help to get me started. Thank you very much in advance!

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<a:authorAction id="personsearchwindow" 
  xmlns:a="http://www.oxygenxml.com/ns/author/external-action"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.oxygenxml.com/ns/author/external-action http://www.oxygenxml.com/ns/author/external-action/authorAction.xsd">
  <a:name>Personensuchfenster</a:name>
  <a:description>Personensuchfenster</a:description>
  <a:operations>
    <a:operation id="JSOperation">
      <a:arguments>
        <a:argument name="script"><![CDATA[function doOperation(){ 

    documentController = authorAccess.getDocumentController();
    workspaceAccess = authorAccess.getWorkspaceAccess();
    
    }]]>
        </a:argument>
      </a:arguments>
    </a:operation>
  </a:operations>
  <a:enabledInReadOnlyContext>false</a:enabledInReadOnlyContext>
</a:authorAction>
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Author Options: GUI for person-search

Post by Radu »

Hi,

Are you implementing the framework extension for the Oxygen desktop on-premise XML Author/Editor or for the Oxygen WebAuthor in-web-browser editor?
I will assume it's for the Oxygen desktop/on premise installation.
I see in your screenshot you already seem to have such a dialog, or is it just a mockup?

Oxygen desktop is a Java swing based application so in general complex dialogs like the ones you want to create would need to be implemented in Java Swing. So my suggestion to you would be to create a new Java project (in your IDE of choice, Eclipse or IntelliJ Idea for example) which creates a new custom Author operation implemented in Java, operation which can use our AuthorAccess API to obtain the selection and to perform changes on the selected content, implementing that dialog in Java Swing:
https://www.oxygenxml.com/doc/versions/ ... HowTo.html
There is indeed this possibility to call a JSOperation with custom Javascript code. The Javascript code gets translated by Oxygen to Java method calls using the Rhyno Javascript to Java interpreter. You can also create Java Swing components in the Javascript code like:
https://github.com/oxygenxml/javascript ... XMLFrag.js
but the Javascript code gets quite complex and hard to debug and understand, so I would suggest going with a pure Java AuthorOperation implementation.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Pagina_SL
Posts: 7
Joined: Tue Jan 30, 2024 1:03 pm

Re: Author Options: GUI for person-search

Post by Pagina_SL »

Thank you very much, I will try it with Java. Are there any examples available how such a .java file has to look like?
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Author Options: GUI for person-search

Post by Radu »

Hi,
Once you follow the instructions I gave you and install our SDK, the SDK should have sample AuthorOperation custom implementation.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Pagina_SL
Posts: 7
Joined: Tue Jan 30, 2024 1:03 pm

Re: Author Options: GUI for person-search

Post by Pagina_SL »

I am currently trying to download the Oxygen SDK but somehow I got caught in a circular loop. I have created an account (via Google) and have followed all steps starting from https://www.oxygenxml.com/oxygen_sdk.html
Screenshot (12).png
Screenshot (12).png (91.16 KiB) Viewed 394 times
When I click on Save, I get to
Screenshot (13).png
Screenshot (13).png (54.77 KiB) Viewed 394 times
and from there I get to https://www.oxygenxml.com/oxygen_sdk.html and when I click on Download, the whole loop starts again. Could you please explain what went wrong and how I can install it?
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Author Options: GUI for person-search

Post by Radu »

Hi,
Sorry about that, we have a problem with our web site. My colleagues are still working on it I'm afraid, maybe you can try tomorrow.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Author Options: GUI for person-search

Post by Radu »

Hi,
My colleagues repaired the problem and things should properly work again if you log in to our SDK page.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Pagina_SL
Posts: 7
Joined: Tue Jan 30, 2024 1:03 pm

Re: Author Options: GUI for person-search

Post by Pagina_SL »

Just one question out of interest: Would it be possible to do this without having to set up a large Java-Project and to write the Java-Code for the GUI directly to a single XML Author Option file or would I then get issues with Swing and other imports?
If this would work, could you please provide me some examples how to embed the Java code into the XML?

Thank you very much in advance!

Radu wrote: Tue Feb 06, 2024 9:23 am Hi,

Are you implementing the framework extension for the Oxygen desktop on-premise XML Author/Editor or for the Oxygen WebAuthor in-web-browser editor?
I will assume it's for the Oxygen desktop/on premise installation.
I see in your screenshot you already seem to have such a dialog, or is it just a mockup?

Oxygen desktop is a Java swing based application so in general complex dialogs like the ones you want to create would need to be implemented in Java Swing. So my suggestion to you would be to create a new Java project (in your IDE of choice, Eclipse or IntelliJ Idea for example) which creates a new custom Author operation implemented in Java, operation which can use our AuthorAccess API to obtain the selection and to perform changes on the selected content, implementing that dialog in Java Swing:
https://www.oxygenxml.com/doc/versions/ ... HowTo.html
There is indeed this possibility to call a JSOperation with custom Javascript code. The Javascript code gets translated by Oxygen to Java method calls using the Rhyno Javascript to Java interpreter. You can also create Java Swing components in the Javascript code like:
https://github.com/oxygenxml/javascript ... XMLFrag.js
but the Javascript code gets quite complex and hard to debug and understand, so I would suggest going with a pure Java AuthorOperation implementation.

Regards,
Radu
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Author Options: GUI for person-search

Post by Radu »

Hi,
Using Javascript directly in the action's definition works to implement basically anything you could implement with a Java based operation, even by creating and showing Java Swing specific dialogs:
https://github.com/oxygenxml/javascript ... XMLFrag.js
So it's your choice, but the code gets quite hard to write, creating Swing components, creating a layout manager, adding components to a dialog. It can be done with Javacript but you do not have the help of a compiler to signal mistakes so I would usually suggest using Java-based custom operations if your operation is quite complex and shows a user's interface.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply