Page 1 of 1

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

Posted: Tue Sep 12, 2023 4:03 pm
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

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

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

Posted: Wed Sep 13, 2023 8:22 am
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