Need to add context menu on selection in a ToolWindow

Hi,

I am developing a plugin in which I have my custom ToolWindow which displays some search

result on an action. This ToolWindow has a JTable in it.This JTable is populated which the

search results.

I also have a Pop up menu in the project view which has few options.These options are

registered as actions under a ProjectViewPopupMenu group in the plugin.xml

I want to display this the same pop-up when user selects some row(s) from the JTable in my

ToolWindow.

What I understand is to create a new group in plugin.xml and add references to existing actions in that group, but to show these items in the context menu of a ToolWindow is there any group id which I can use?

Also to display these options on the JTable component, I need to use JPopUpMenu which takes

JComponent objects to fill up the menu.

Can someone suggest me how I can solve this problem? Thanks in advance


~Yuvraj

1 comment

Hello Yuvraj,

You can use ActionManager.createActionPopupMenu() to create a popup menu
from a group of registered actions. You can then use ActionPopupMenu.getComponent()
to get the regular Swing menu component from it, and use the regular Swing
APIs to show the context menu in your JTable.

g> I am developing a plugin in which I have my custom ToolWindow which
g> displays some search
g>
g> result on an action. This ToolWindow has a JTable in it.This JTable
g> is populated which the
g>
g> search results.
g>
g> I also have a Pop up menu in the project view which has few
g> options.These options are
g>
g> registered as actions under a ProjectViewPopupMenu group in the
g> plugin.xml
g>
g> I want to display this the same pop-up when user selects some row(s)
g> from the JTable in my
g>
g> ToolWindow.
g>
g> What I understand is to create a new group in plugin.xml and add
g> references to existing actions in that group, but to show these items
g> in the context menu of a ToolWindow is there any group id which I can
g> use?
g>
g> Also to display these options on the JTable component, I need to use
g> JPopUpMenu which takes
g>
g> JComponent objects to fill up the menu.
g>
g> Can someone suggest me how I can solve this problem? Thanks in
g> advance

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


0

Please sign in to leave a comment.