Way to hook on the selection user makes on the right click menu ??

Hi.

I have added an option in ProjectPopUp menu , say SamplePopUp with popup =
true property set..
This pop-up menu has sub pop-up menus . I have added their entries in
plugin.xml

I have a class SamplePopUpClass that extends the DefaultActionGroup and
overrides the update method.
When I right click on a file in project view, this update method gets called
three times, twice on right of the file and once when I go to the
SamplePopUp menu option.

I am doing the processing of enabling and disabling the sub-menu options of
SamplePopUp in the update method of SamplePopUpClass. Since this update is
getting called three times for every right click the overhead while
processing is more.

Our processing logic needs to create a file for the selected resource in the
project view. This file is referred by every sub-menu option in SamplePopUp.
Since update gets called three time, three files are getting created for
every right click.

I want to get rid of the first two duplicated files getting created when I
do right click. For this I need to hook when the third update gets called or
when the mouse/keyboard selection is on SamplePopUp option. I have tried all
the api's in Presentation, AnActionEvent, ActionManager but couldn't get an
handle to it.
There is an api getInputEvent in Presentation class, but this returns null.

Is there way to hook on the selection user makes on the right click menu?
Are there any listeners that I can implement to do this?

Any help in this regard would be really great.

~Priya


3 comments

Hello Priya,

P> Our processing logic needs to create a file for the selected resource
P> in the project view. This file is referred by every sub-menu option
P> in SamplePopUp. Since update gets called three time, three files are
P> getting created for every right click.

Please consider changing your logic so that any actual processing (files
creation and so on) is done in the actionPerformed() method, not the update()
method. The update() method for an action may be called many times by IDEA,
and there is no way to determine which of the calls is the "last" one.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Hello,

We cannot change the imlementation because we want to enable/disable the
sub-menu options depending upon some check.
This check requires the creation of the temporary file. We want to handle
the on-over event (i.e when SamplePopUp is selected by the user using
mouse/keyboard)

The logic for actual command is implemented in actionPerformed. And logic of
enable/disable is implemented in update method.

We cannot club these two together as we want to enable/disable menu options
on mouse over and not on click. Is there any way to get the selection on
mouse over (i.e when user selects SamplePopUp)

To reduce the complexity of implementation, we would like to have some
method which will return the current selection. If this not available right
now, can we plan to have it in near future?

~Priya


"Dmitry Jemerov (JetBrains)" <yole@jetbrains.com> wrote in message
news:83ca25fd266d118c808ef528e3640@news.intellij.net...

Hello Priya,

>

P> Our processing logic needs to create a file for the selected resource
P> in the project view. This file is referred by every sub-menu option
P> in SamplePopUp. Since update gets called three time, three files are
P> getting created for every right click.

>

Please consider changing your logic so that any actual processing (files
creation and so on) is done in the actionPerformed() method, not the

update()

method. The update() method for an action may be called many times by

IDEA,

and there is no way to determine which of the calls is the "last" one.

>

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"

>
>


0

Hello Priya,

There is no way to hook the on-over event, and we do not plan to provide one.

P> We cannot change the imlementation because we want to enable/disable
P> the
P> sub-menu options depending upon some check.
P> This check requires the creation of the temporary file. We want to
P> handle
P> the on-over event (i.e when SamplePopUp is selected by the user using
P> mouse/keyboard)
P> The logic for actual command is implemented in actionPerformed. And
P> logic of enable/disable is implemented in update method.
P>
P> We cannot club these two together as we want to enable/disable menu
P> options on mouse over and not on click. Is there any way to get the
P> selection on mouse over (i.e when user selects SamplePopUp)
P>
P> To reduce the complexity of implementation, we would like to have
P> some method which will return the current selection. If this not
P> available right now, can we plan to have it in near future?
P>
P> ~Priya
P>
P> "Dmitry Jemerov (JetBrains)" <yole@jetbrains.com> wrote in message
P> news:83ca25fd266d118c808ef528e3640@news.intellij.net...
P>
>> Hello Priya,
>>
>> P> Our processing logic needs to create a file for the selected
>> resource P> in the project view. This file is referred by every
>> sub-menu option P> in SamplePopUp. Since update gets called three
>> time, three files are P> getting created for every right click.
>>
>> Please consider changing your logic so that any actual processing
>> (files creation and so on) is done in the actionPerformed() method,
>> not the
>>
P> update()
P>
>> method. The update() method for an action may be called many times by
>>
P> IDEA,
P>
>> and there is no way to determine which of the calls is the "last"
>> one.
>>
>> --
>> Dmitry Jemerov
>> Software Developer
>> JetBrains, Inc.
>> http://www.jetbrains.com
>> "Develop with pleasure!"
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Please sign in to leave a comment.