customize the Cross reference(Xref) oxygen dialog

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

customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

Hello Team , we have a requirement where for the frameworks ,we need to customize the Cross reference(Xref) oxygen dialog so that the browse for local file drop down will have one more option to browse our own application, how do we need to implement the same?
could you please guide us here?
image.png
image.png (23.9 KiB) Viewed 1879 times
Thanks,
vishwa
Radu
Posts: 9048
Joined: Fri Jul 09, 2004 5:18 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by Radu »

Hi,

You would need to implement a Workspace Access Java Plugin extension for Oxygen:
https://www.oxygenxml.com/doc/versions/ ... lugin.html
and there is a special API to contribute custom Browse actions to all of Oxygen's dialogs:
https://www.oxygenxml.com/doc/versions/ ... v2_dgk_54b

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

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

Thanks Radu.

is this same can be done inside customframework.jar?

we have some other custom dialogs inside framework jar , so we are thinking of the all custom dialogs can go inside this.
Thanks,
vishwa
Radu
Posts: 9048
Joined: Fri Jul 09, 2004 5:18 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by Radu »

Hi,

The API which adds custom browse actions for a dialog was intended to be used from an Oxygen plugin:
https://www.oxygenxml.com/InstData/Edit ... mizer.html
And it adds the custom browse action to all Oxygen dialogs, for example also to the "Insert image" dialog.
The difference between a plugin and a framework is highlighted here:
https://www.oxygenxml.com/doc/versions/ ... guide.html

I guess from a framework's Java code you could try to do something like:

Code: Select all

ro.sync.exml.workspace.api.PluginWorkspaceProvider.getPluginWorkspace().addInputURLChooserCustomizer(..);
before the insert cross references dialog is shown.

Other than that the "Cross Reference (xref)" dialog cannot be customized in other way and we also do not provide the Java source code for it. So another option might be for you to create your own dialog to insert cross references.
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

Thanks Radu.

what does this mean "before the insert cross references dialog is shown."

usually we add the actions to the "farmework_name.framework" file right?
Thanks,
vishwa
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

here we have tried like the below inside our custom framework jar

Code: Select all

public class InsertCrossReferenceOperation extends ro.sync.ecss.extensions.dita.link.InsertXrefOperation {
    public void doOperation(AuthorAccess authorAccess, ArgumentsMap argumentsMap) throws IllegalArgumentException, AuthorOperationException {
        super.doOperationInternal(authorAccess, argumentsMap, true);


        Window[] windows = JDialog.getWindows();
        for (int i = windows.length - 1; i >= 0; i--) {
            Window w = windows[i];
            if (w instanceof JDialog) {
                JDialog dialog = (JDialog) w;
                if (dialog.isVisible() && "Cross reference (xref)".equals(dialog.getTitle())) {
                     //setting our own custom title
                    dialog.setTitle("Insert Cross-Reference");
                    break;
                }
            }
        }

         PluginWorkspaceProvider.getPluginWorkspace().addInputURLChooserCustomizer
                (new InputURLChooserCustomizer() {
                    public void customizeBrowseActions
                            (List<Action> existingBrowseActions, final InputURLChooser chooser) {
                        //IMPORTANT, you also need to set a custom icon on the action
                        //for situations when its text is not used for display.
                        Action browseCMS = new AbstractAction("here our own dropdown") {

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                try {

                                    //here calling our own java call method to select some topic
                                    //downloaded to local and that local path

                                   

                                    String localPath = xxxx.getLocalFilePath();

                                    localPath = "file:" + localPath;

                                    System.out.println(localPath);

                                    URL urlSelected = new URL(localPath);


                                    chooser.urlChosen(urlSelected);

                                } catch (MalformedURLException ex) {
                                    throw new RuntimeException(ex);
                                }
                            }


                        };
                        existingBrowseActions.add(browseCMS);
                    }
                });
Here the custom title part works fine

but it is not adding the AbstractAction("here our own dropdown") to any dialog?

please suggest us here.
Thanks,
vishwa
Radu
Posts: 9048
Joined: Fri Jul 09, 2004 5:18 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by Radu »

Hi,
How about if you call "PluginWorkspaceProvider.getPluginWorkspace().addInputURLChooserCustomizer" before calling "super.doOperationInternal(authorAccess, argumentsMap, true);"?
It should contribute a custom action in the "Browse" drop down actions list.
Also you should try to call "PluginWorkspaceProvider.getPluginWorkspace().addInputURLChooserCustomizer" only once, not every time the end user invokes the action.

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

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

Thanks Radu , it's worked for me :D
Thanks,
vishwa
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

Sorry Radu , one last question with this thread ,

how do we can show the wait cursor for custom action in the "Browse" drop down , until my browse action running and getting something?

tried like the below but no effect
public void doOperation(AuthorAccess authorAccess, ArgumentsMap argumentsMap) throws IllegalArgumentException, AuthorOperationException {
JFrame oxygenFrame = (JFrame) authorAccess.getWorkspaceAccess().getParentFrame();
oxygenFrame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Thanks,
vishwa
Radu
Posts: 9048
Joined: Fri Jul 09, 2004 5:18 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by Radu »

Hi,

If you set the busy cursor on the main Oxygen frame, it only gets shown when you hover the mouse over the frame.
But in your case you have that modal dialog "Cross reference (xref)" which shows up so you would need to set the cursor on the dialog's Window.

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

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

here after our action performed

we are able to load the "Location" text field with our local windows path
chooser.urlChosen(urlSelected);

we wanted the xref should be inserted with keyref instead href

is that possible with the key text field with the our unique key?

in that case how to load the "Key" text field
image.png
image.png (33.61 KiB) Viewed 1625 times

Code: Select all

public class InsertCrossReferenceOperation extends ro.sync.ecss.extensions.dita.link.InsertXrefOperation {
    public void doOperation(AuthorAccess authorAccess, ArgumentsMap argumentsMap) throws IllegalArgumentException, AuthorOperationException {
        super.doOperationInternal(authorAccess, argumentsMap, true);


        Window[] windows = JDialog.getWindows();
        for (int i = windows.length - 1; i >= 0; i--) {
            Window w = windows[i];
            if (w instanceof JDialog) {
                JDialog dialog = (JDialog) w;
                if (dialog.isVisible() && "Cross reference (xref)".equals(dialog.getTitle())) {
                     //setting our own custom title
                    dialog.setTitle("Insert Cross-Reference");
                    break;
                }
            }
        }

         PluginWorkspaceProvider.getPluginWorkspace().addInputURLChooserCustomizer
                (new InputURLChooserCustomizer() {
                    public void customizeBrowseActions
                            (List<Action> existingBrowseActions, final InputURLChooser chooser) {
                        //IMPORTANT, you also need to set a custom icon on the action
                        //for situations when its text is not used for display.
                        Action browseCMS = new AbstractAction("here our own dropdown") {

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                try {

                                    //here calling our own java call method to select some topic
                                    //downloaded to local and that local path

                                   

                                    String localPath = xxxx.getLocalFilePath();

                                    localPath = "file:" + localPath;

                                    System.out.println(localPath);

                                    URL urlSelected = new URL(localPath);


                                    chooser.urlChosen(urlSelected);

                                } catch (MalformedURLException ex) {
                                    throw new RuntimeException(ex);
                                }
                            }


                        };
                        existingBrowseActions.add(browseCMS);
                    }
                });
Thanks,
vishwa
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

as shown here from the link https://www.oxygenxml.com/doc/versions/ ... nking.html

the "Key" text field is not populating in our case?
image.png
image.png (37.77 KiB) Viewed 1620 times
Thanks,
vishwa
Radu
Posts: 9048
Joined: Fri Jul 09, 2004 5:18 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by Radu »

Hi,

Indeed the dialog has both a "Location" where you pick the target topic usually for direct references using "href" and a "Key" textfield where you can pick a key for indirect references. If you pick a Location and the DITA Map used by Oxygen to gather keys has a key already defined for that location, Oxygen should present the value of the key in the "Key" text field.
So have you defined in the DITA Map a key for that particular topic reference?
Oxygen gathers its keys from the main DITA Map referenced in the "DITA Maps Manager" view in the "Context" combo box.

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

Re: customize the Cross reference(Xref) oxygen dialog

Post by vishwavaranasi »

Thanks Radu , Yes , as soon as we are downloading the topic ref(xref) we are getting from our own application after browse .. we are adding that key to DITAMAP dynamically in the same operation of browse , but the problem is the "Key" text field is not presenting any value because the newly added key is only picking up when we reload the DITA MAP referenced in the "DITA Maps Manager"
Thanks,
vishwa
Radu
Posts: 9048
Joined: Fri Jul 09, 2004 5:18 pm

Re: customize the Cross reference(Xref) oxygen dialog

Post by Radu »

Hi,

I agree, Oxygen does not know that you have modified a certain DITA Map on disk so it does not refresh the keys that it gathers from the DITA Map.
I do not have a good workaround for this.
What value does the "Context:" combo box from the DITA Maps manager view have on your side? Is it set to "<Current map>"?
This code should instruct Oxygen to refresh the keys that it gathers from the context root map:

Code: Select all

    Object oldContextMap = PluginWorkspaceProvider.getPluginWorkspace().getGlobalObjectProperty(APIAccessibleOptionTags.KEYS_CONTEXT_MAP);
    PluginWorkspaceProvider.getPluginWorkspace().setGlobalObjectProperty(APIAccessibleOptionTags.KEYS_CONTEXT_MAP, "");
    PluginWorkspaceProvider.getPluginWorkspace().setGlobalObjectProperty(APIAccessibleOptionTags.KEYS_CONTEXT_MAP, oldContextMap);
but from what I looked in the code the "Cross Reference (xref)" dialog which is already opened when you want the keys to be refreshed will not re-compute the keys that it presents in the "Keys" combo box unless it's closed and then re-opened.
I think that if you want this you would probably need to re-implement using Java Swing components your own dialog to insert xrefs with keyrefs.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply