Some of the Actions are not triggered/delivered to my plugin code

Hello,

I have a simple plugin which listens to some of the "Actions" (e.g : EditorActions), my plugin code never gets triggered on any of the actions in the Editor. I am little surprised that, is it something to do with configuration of my project or am I doing anything wrong.

Here is my project code ...

plugin.xml
-------------------

      <action id="ade.checkout" text="ade.checkout">
          <keyboard-shortcut keymap="$default" first-keystroke="ENTER"/>
      </action>
      <action id="editor.copy" text="editor.copy"
              description="editor copy action">
          <add-to-group group-id="EditorActions" anchor="last"/>
      </action>


Checkout.java
----------------------
    public void actionPerformed(AnActionEvent e) {
        // TODO: insert action logic here
        System.out.println("Key Pressed");

        System.out.println(e.getInputEvent().getSource());


     }

EditorCopy.java
------------------------
    public void actionPerformed(AnActionEvent e) {
        // TODO: insert action logic here
        System.out.println(e.getInputEvent().getSource());
        System.out.println("editor copy kicked in");
    }


1. EditorCopy.actionPerformed() would not be triggered in any of the editor actions.

2. Checkout.actionPerformed() would be triggered only when the file is selected in "Project" navigator and ENTER key is pressed. Keyboard actions works only when specified item is selected in "Project" navigator?

I really appreciate your help in identifying why EditorActions never gets trigger my plugin code.

Thanks,
Sunil.
5 comments
Comment actions Permalink

What exactly are you trying to accomplish? We already have actions for Copy and Enter, and registering your own implementations in the way you're doing is not a correct way to intercept them.

0
Comment actions Permalink

Thanks for your response.

I just want to capture  EditorActions either before / after original action assigned to these events are performed.
My code would make the read only into editable and after every save copies a version of file into backup dir.

My questions are still unanswered.

1. Why don't my code gets called for editor actions?
2. Key board events are working only when a file in highlighted in project navigator, why not when cursor is in file?

Scope for generated events is limited by any chance?

Thanks,
Sunil.

0
Comment actions Permalink

I'm not answering your questions because you don't need to know the answers to them in order to implement your features. To make a read-only file editable when the user tries to edit it, you need to implement the WritingAccessProvider interface and to register your implementation as the corresponding extension point. The feature for creating a backup file seems completely unnecessary to me, because the built-in local history feature does the same thing in a more efficient way, but if you want to implement it anyway, you can do so for example by implementing a VirtualFileListener and watching for changes in files under the project directory.

0
Comment actions Permalink

Thanks for your pointers to "WritingAccessProvider" and "VirtualFileListener"

If such things about Actions are completely internal, I feel its better to remove those items from plugin development area.

Pretty sure that IDE must be doing all the things internally which I wanted to do. But that does not help me what I want to do.

0
Comment actions Permalink

No, they are not completely internal. Your action that you have assigned to the Enter key does not work because we have another action that is assigned to the same keyboard shortcut, and when there are multiple actions that are assigned to the same keyboard shortcut and enabled in the same context, only the first one is triggered. For your "editor.copy" action, there is absolutely no reason why it would be triggered at all - it does not have any keyboard shortcut and it is not added to any menu or toolbar.

0

Please sign in to leave a comment.