Add 'disabled' items to the popup menu for DITA Maps Manager

Post here questions and problems related to oXygen frameworks/document types.
abhik
Posts: 17
Joined: Tue Sep 05, 2023 12:14 am

Add 'disabled' items to the popup menu for DITA Maps Manager

Post by abhik »

Hi Team,

I am extending default popup menu behaviour for DITA Maps Manager using DITAMapPopupMenuCustomizer.
I want to add few item to the existing popup menu and enable/disable these items as per the requirements.

When I disable the item, it is not displayed in popup menu.
It is working fine for enabled items but I want to display disabled items too.
Please check the screenshot and my customizePopUpMenu() function.

Code: Select all

    public void customizePopUpMenu(Object popUp, AuthorDocumentController ditaMapDocumentController) {

        javax.swing.JMenuItem itemMenuEnabled = new javax.swing.JMenuItem("Enabled Menu item");
        javax.swing.JMenuItem itemMenuDisabled = new javax.swing.JMenuItem("Disabled Menu item");
        itemMenuDisabled.setEnabled(false);

        javax.swing.JMenu extendedMenu = new javax.swing.JMenu("Extended Menu");
        javax.swing.JMenuItem itemSubmenuEnabled = new javax.swing.JMenuItem("Enabled Submenu item");
        javax.swing.JMenuItem itemSubmenuDisabled = new javax.swing.JMenuItem("Disabled Submenu item");
        itemSubmenuDisabled.setEnabled(false);
        extendedMenu.add(itemSubmenuEnabled);
        extendedMenu.add(itemSubmenuDisabled);

        javax.swing.JPopupMenu jpm = (javax.swing.JPopupMenu) popUp;
        jpm.addSeparator();
        jpm.add(itemMenuEnabled);
        jpm.add(itemMenuDisabled);
        jpm.add(extendedMenu);
    }
popup_menu_screenshot.png
popup_menu_screenshot.png (208.78 KiB) Viewed 401 times

I have tried similar implementation with MenusAndToolbarsContributorCustomizer by overriding customizeDITAMapPopUpMenu() function, but disabled items are not visible.

Please suggest solution to append the 'disabled' item to the popup menu of DITA Maps Manager.

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

Re: Add 'disabled' items to the popup menu for DITA Maps Manager

Post by Radu »

Hi,
For the Oxygen contextual menus we follow a best UI practice of hiding completely the actions which are disabled as the end user cannot use them anyway and they add to the list of available contextual menu actions.
You do not have a way to override this behavior via our APIs. If you want those actions to appear you can always make them enabled and maybe show a message dialog if the action is called in an inappropriate context.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply