Reuse Content default reference type

Oxygen general issues.
FrankDLT
Posts: 17
Joined: Tue Jul 12, 2022 10:17 pm

Reuse Content default reference type

Post by FrankDLT »

Hello and Good day
I have been developing a plugin that modifies the usage of the Reuse Content Windows in oxygen, and I'm facing 2 different problems.
The first one is that the windows has a reference type that's set to keydef by default, and while it can be manually changed to conkeyref I was wondering if there is a way to alter it so the conkeydef its selected by default.
The other one its that my team added a custom Browse option in the Reuse Content Window along side the default one like Browse for local, remote, archived, etc file, however this option appears only sometimes and other times appears to be missing, the plugin has its document type association priority set to the highest to ensure that this change shows up, but as stated it only does it on occasion, could there be an option that blocking the changes of the plugin?

Default Window:
image.png
image.png (89.99 KiB) Viewed 764 times
Desired Option:
image.png
image.png (97.06 KiB) Viewed 764 times
Thanks and Regards,
Frank
Attachments
image.png
image.png (19.81 KiB) Viewed 764 times
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Reuse Content default reference type

Post by Radu »

Hi,

Please see some remarks below:
The first one is that the windows has a reference type that's set to keydef by default, and while it can be manually changed to conkeyref I was wondering if there is a way to alter it so the conkeydef its selected by default.
You mean the "Reference type" combo box has two values "keyref/conkeyref", right? From what I tested, the selected value in the combo usually changes automatically when you select a key in the "Key" drop down. For example if you select a key which points to a DITA topic (like in the example above) without defining any keywords on it, it should automatically change to "conkeyref".

Code: Select all

<topicref href="topics/target.dita" keys="test"/>
Other than that we do not have special API to control completely the dialog. Being a Java Swing-based dialog once you get access to it, you can navigate its hierarchy of Swing components and hack your way through it, find the combo box, change its selected value maybe. Other than that, maybe you can build your own Java Swing based dialog for reusing and avoid using our dialog completely. This would give you 100% control over the wanted behaviors.
The other one its that my team added a custom Browse option in the Reuse Content Window along side the default one like Browse for local, remote, archived, etc file, however this option appears only sometimes and other times appears to be missing, the plugin has its document type association priority set to the highest to ensure that this change shows up, but as stated it only does it on occasion, could there be an option that blocking the changes of the plugin?
Plugins do not have document type association priorities, from what I remember from previous discussions on our forum you do not have a plugin, you have a framework, the difference is explained here:
https://www.oxygenxml.com/doc/versions/ ... guide.html
The API to add new "Browse" actions to all of Oxygen's URL choosers was intended to be used from a Workspace Access plugin extension, it's a common customizations for developers who want to integrate Oxygen with a remote Content Management System:
https://www.oxygenxml.com/doc/versions/ ... lugin.html
But from what I remember from previous discussions, you are using the API from a framework configuration, from a custom java-based Author Operation implemented in a framework customization. Can you give me again some Java source code showing how you are doing this?


Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
FrankDLT
Posts: 17
Joined: Tue Jul 12, 2022 10:17 pm

Re: Reuse Content default reference type

Post by FrankDLT »

Hello Radu

Yes you are correct, sorry for the incorrect term, we are indeed using a framework to modify these things, and this is the piece of code that add the custom button to the reuse windows:

Code: Select all

public void doOperation(AuthorAccess authorAccess, ArgumentsMap argumentsMap) throws IllegalArgumentException, AuthorOperationException {

        PluginWorkspaceProvider.getPluginWorkspace().addInputURLChooserCustomizer
                (new InputURLChooserCustomizer() {

                    public void customizeBrowseActions
                            (List<Action> existingBrowseActions, final InputURLChooser chooser) {

                        Action browseCMS = new AbstractAction("Action Name" ,new ImageIcon(getClass().getResource("/image.png"))) {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                try {

                                    javax.swing.JFrame parentFrame = (JFrame) PluginWorkspaceProvider.getPluginWorkspace().getParentFrame();
                                    parentFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));


                                    AuthorBridgeDTO authordto = getAuthoringBridgeRepository(); //Place holder name for the actual function

                                    String localPath = authordto.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);
                    }
                });
        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())) {
                    dialog.setTitle("Insert Cross-Reference");
                    break;
                }
            }
        }
        javax.swing.JFrame parentFrame = (JFrame) PluginWorkspaceProvider.getPluginWorkspace().getParentFrame();
        parentFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    }
This should add the button to these types of windows, including the reuse content, insert cross reference, etc. At least that's the behavior we expect, but while it appears to add the button in the RC Window, sometimes it fails to show up.

Thanks and Regards,
Frank
Last edited by FrankDLT on Thu May 04, 2023 5:56 pm, edited 1 time in total.
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Reuse Content default reference type

Post by Radu »

Hi Frank,

Sorry for the delay, I probably accidentally deleted the notification email and forgot to reply on the thread.
Most of the Java Swing-based dialogs that Oxygen presents are singletons, they have a static instance and are only created once, then the instance is reused.
So if for example someone were to call the old "Reuse Content" operation from Oxygen before calling your new operation, the dialog instance is created before your operation gets called and will no longer take into account the newly added "InputURLChooserCustomizer"'s added by your operation.
This is the only explanation I can think of right now.
In a way this is why the "addInputURLChooserCustomizer" API was intended to be called from a plugin which gets instantiated very early when the application is staring up.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
FrankDLT
Posts: 17
Joined: Tue Jul 12, 2022 10:17 pm

Re: Reuse Content default reference type

Post by FrankDLT »

Hello Radu, G'Day

No worries, I appreciate all the help!
As an update, I was able to make the button appear correctly by making a custom operation that extends the ro.sync.ecss.extensions.dita.conref.InsertConrefOperation class and adding to it the custom button, it is now correctly showing the button and using the information that its being fed to it.

Now the only thing that presents a complication for my team is the fact that once selected, the file will be inserted as a <title conref=> tag, but we need the reference to be a conkeyref instead of a conref, but I cant seem to find the code that actually sets that part of the insert.
By any chance, would you know in where is the final tag built to be inserted?

Thanks and Regards,
Frank
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Reuse Content default reference type

Post by Radu »

Hi Frank,

The dialog has a radio button choice "Location/Key". If you select the "Key" radio button choice and pick the target key, then the dialog will insert a conkeyref.

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