Feature removal request! - GenerateSerialVersionUID & GenerateToString

Both the GenerateSerialVersionUID and GenerateToString plugins unnecessarily
add themselves to the Code top-level menu.

IMHO this goes against the style proposed by JetBrains. Having them on the
Generate popupmenu is sufficient.


14 comments

Is this the general opinion from the community? If so I would remove it in a future release (toString)

/Claus

0

Claus Ibsen wrote:

Is this the general opinion from the community? If so I would remove it in a future release (toString)


Arn't these both just plugins thou? If so - just uninstall them!

0

A potential downside to my suggestion is that currently it is possible to
assign a keyboard shortcut to invoke the plugin - I don't think that would
be possible if the top-level menu item were removed. But then, who has keys
assigned for this?

Colin


0

Arn't these both just plugins thou? If so - just uninstall them!


Yes, they are 'just plugins'. Very useful ones!


0

Afair you can fix it by removing the menu association in the plugin.xml in the META-INF folder of the .jar file.

These xml lines should be removed

        
        
            
            
            
        ]]>


/Claus, the author of toString()

0

Same goes for the GenerateSerialVersionUID plugin. I haven't seen enough
complaints to remove it at this point and I use it enough that I like being
able to have a keymap for it.

"Claus Ibsen" <cib_rejse@yahoo.dk> wrote in message
news:2918045.1079865524959.JavaMail.itn@is.intellij.net...

Is this the general opinion from the community? If so I would remove it in

a future release (toString)
>

/Claus



0

Okay I will leave it for folks to have keymaps.

People who does not want it to be in the menu's must manually change the plugin.xml file as documented above.

/Claus

0

v2.12 just released has a feature to disable it from the menus.

- New feature to disable action from code and editor popup menus in settings. To enable again requires restart of IDEA (currently)


/Claus

0

This is the toString() plugin

0

Could you highlight how you did this so I can add this option to
GenerateSerialVersionUID?

"Claus Ibsen" <cib_rejse@yahoo.dk> wrote in message
news:5740701.1080854750915.JavaMail.itn@is.intellij.net...

v2.12 just released has a feature to disable it from the menus.

>

- New feature to disable action from code and editor popup menus in

settings. To enable again requires restart of IDEA (currently)
>
>

/Claus



0

Sadly the wiki does not work at the moment so I can not upload the source code.

I am at work now and does not have the source.

But I was inspired by this plugin:
http://www.intellij.org/twiki/bin/view/Main/RemoveEditorPopupMenuActions

But you still have some messle with removing the menu's immediatly (not to require a restart).

I will paste the source code when I get home, if not drop me an email.

/Claus

0
     * The group must be of a DefaultActionGroup instance, if not this method returns false.
     *
     * @param actionId   group id of the action to remove.
     * @param menuId     id of the menu that contains the action. See ActionManager.xml in the IDEA openapi folder.
     * @return true if the action was remove, false if not (action could not be found)
     */
    public boolean removeActionFromMenu(String actionId, String menuId) {
        ActionManager am = ActionManager.getInstance();
        AnAction group = am.getAction(menuId);

        // must be default action group
        if (group instanceof DefaultActionGroup) {
            DefaultActionGroup defGroup = (DefaultActionGroup) group;

            // loop children (actions) and remove the matching id
            AnAction[] actions = defGroup.getChildren(null);
            for (int i = 0; i < actions.length; i++) {
                AnAction action = actions+;
                String id = am.getId(action);

                // if match id then remove action from menu
                if (actionId.equals(id)) {
                    defGroup.remove(action);
                    return true;
                }
            }

        }

        // action to remove not found
        return false;
    }]]>



And my code removing the action from the menu



You can check the ActionManager.xml in the openapi doc for list of menunames.

/Claus

0

And to add the menu back use the following code

     * The group must be of a DefaultActionGroup instance, if not this method returns false.
     *
     * @param actionId   group id of the action to add.
     * @param menuId     id of the menu the action should be added to. See ActionManager.xml in the IDEA openapi folder.
     * @param anchorId   id of the action to position relative to.  See ActionManager.xml in the IDEA openapi folder.
     * @param afterAnchor  true if the action should be added after the anchorId, false if before.
     * @return true if the action was added, false if not.
     */
    public boolean addActionToMenu(String actionId, String menuId, String anchorId, boolean afterAnchor) {
        ActionManager am = ActionManager.getInstance();
        AnAction group = am.getAction(menuId);

        // must be default action group
        if (group instanceof DefaultActionGroup) {
            DefaultActionGroup defGroup = (DefaultActionGroup) group;

            // loop children (actions) and remove the matching id
            AnAction[] actions = defGroup.getChildren(null);
            for (int i = 0; i < actions.length; i++) {
                AnAction action = actions+;
                String id = am.getId(action);

                // if match id then add action to menu
                if (anchorId.equals(id)) {
                    AnAction actionToAdd = am.getAction(actionId); // find the action to add
                    defGroup.add(actionToAdd, new Constraints( afterAnchor == true ? Anchor.AFTER : Anchor.BEFORE, anchorId));
                    return true;
                }

            }

        }

        // action to add next to not found
        return false;
    }]]>



psi.addActionToMenu("Actions.ActionsPlugin.GenerateToStringGroup", "EditorPopupMenu", "Generate", true);
psi.addActionToMenu("Actions.ActionsPlugin.GenerateToStringGroup", "CodeMenu", "Generate", true);



/Claus

0

Please sign in to leave a comment.