Have problems adding action group to welcome screen
Hi.
I'm trying to add an action group to tools menu and to welcome screen.
I'm adding this group as POPUP
]]>
On tools menu this work just fine. I can see the menu as a popup menu.
On the welcome screen, I can see my entry, but when I pressed on it the popup menu does not appear.
I can see in debugger that 'public void update(AnActionEvent anactionevent)' is called.
Can you help me with this.
Thanks
Boaz
Please sign in to leave a comment.
Hello Boaz,
The Welcome screen currently has no special support for popup action groups.
To show a popup from the Welcome screen, you'll need to create it by yourself
using the JBPopupFactory API.
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thanks Dmitry.
I can do that. The problem is that com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen has no public method which i can add my action ?
Regards
Boaz
Hello Boaz,
You're registering the action correctly. You'll need to create a separate
class for the Welcome Screen version of the action, and to show the popup
from its actionPerformed() method.
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Hi Dmitry.
Thanks, now it works.
I have bad time trying to display the popup.
First i tried the naive way:
InputEvent inputEvent = e.getInputEvent();
Component component = inputEvent.getComponent();
listpopup.showUnderneathOf(component);
But inputEvent is null.
So i wrote this, but i hardly can believe is should be so complicated:
Component component2 = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
PointerInfo pi = MouseInfo.getPointerInfo();
Point absolute = pi.getLocation();
Point compCoords = component2.getLocationOnScreen();
Point point = new Point(absolute.x - compCoords.x,
absolute.y - compCoords.y);
SwingUtilities.convertPointToScreen(point, component2.getParent());
listpopup.showInScreenCoordinates(component2.getParent(), point);*
Thanks a lot for your support.
To whom is interested, the complete code:
@Override
public void actionPerformed(AnActionEvent e) {
CreateRecentlyProjectsGroup myGroup = (CreateRecentlyProjectsGroup)ActionManager.getInstance()
.getAction("wfplugins.wftools.project_creator.CreateRecentlyProjectsGroup");
DataContext datacontext = e.getDataContext();
JBPopupFactory popupFactory = JBPopupFactory.getInstance();
ListPopup listpopup =
popupFactory.createActionGroupPopup(null, myGroup, datacontext, ActionSelectionAid.NUMBERING, false);
InputEvent inputEvent = e.getInputEvent();
if (inputEvent != null) {
Component component = inputEvent.getComponent();
listpopup.showUnderneathOf(component);
} else {
Component component2 = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
PointerInfo pi = MouseInfo.getPointerInfo();
Point absolute = pi.getLocation();
Point compCoords = component2.getLocationOnScreen();
Point point = new Point(absolute.x - compCoords.x,
absolute.y - compCoords.y);
SwingUtilities.convertPointToScreen(point, component2.getParent());
listpopup.showInScreenCoordinates(component2.getParent(), point);
}
}
Regards
Boaz