How to get all Presentation object associated with a AnAction?

Is there a way to do that?

I am trying to wrap the Run/Debug action. The contextual editor menu has a contextual RunClass/DebugClass that modify their Presentation text based on the caret position. As much as possible I do not want to re-implement the same behavior.
Unfortunately these actions somehow are getting their presentation upfront because after replacing these actions with my own wrapped actions, my own action Presentation text never changes again and stays "Run" or "Debug" instead of "Run " or "Debug ]]>"

Without this the API seems incomplete since it allows to listen to change in the Presentation (add/remove/firePropertyChangeListener) but doesn't give a way to access it outside of the implementing action update/actionPerformed methods. The things that RunClass does need to be available through the openapi.

Thanks in advance

Jacques

2 comments
Comment actions Permalink

You are getting presentation to update each time AnAction.update()
method is invoked. Instance of AnAction has many presentations (one
presentation per place and per UI control), so it's event not possible
to say how many presentations it has (they are created dynamically).
Jacques, could you please provide the code sample how you wrap Run/Debug
action, perhaps problem is there.

With best regards,
Vladimir Kondratyev
_____________________
JetBrains

Jacques Morel wrote:

Is there a way to do that?

I am trying to wrap the Run/Debug action. The contextual editor menu has a contextual RunClass/DebugClass that modify their Presentation text based on the caret position. As much as possible I do not want to re-implement the same behavior.
Unfortunately these actions somehow are getting their presentation upfront because after replacing these actions with my own wrapped actions, my own action Presentation text never changes again and stays "Run" or "Debug" instead of "Run <class>" or "Debug <class>"

Without this the API seems incomplete since it allows to listen to change in the Presentation (add/remove/firePropertyChangeListener) but doesn't give a way to access it outside of the implementing action update/actionPerformed methods. The things that RunClass does need to be available through the openapi.

Thanks in advance

Jacques


0
Comment actions Permalink

I must have been a long night ;)
I was just being plain stupid.
I was calling super.update instead of myWrappedAction.update().

Duh!

Thanks for your help anyway. You were very helpful ;)

Jacques

0

Please sign in to leave a comment.