use of com.intellij.openapi.actionSystem.ActionPopupMenu in project intellij-community by JetBrains.
the class SimpleTree method invokeContextMenu.
protected void invokeContextMenu(final MouseEvent e) {
SwingUtilities.invokeLater(() -> {
final ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(myPlace, myPopupGroup);
menu.getComponent().show(e.getComponent(), e.getPoint().x, e.getPoint().y);
});
}
use of com.intellij.openapi.actionSystem.ActionPopupMenu in project intellij-community by JetBrains.
the class PopupHandler method installFollowingSelectionTreePopup.
public static MouseListener installFollowingSelectionTreePopup(final JTree tree, @NotNull final ActionGroup group, final String place, final ActionManager actionManager) {
if (ApplicationManager.getApplication() == null)
return new MouseAdapter() {
};
PopupHandler handler = new PopupHandler() {
public void invokePopup(Component comp, int x, int y) {
if (tree.getPathForLocation(x, y) != null && Arrays.binarySearch(tree.getSelectionRows(), tree.getRowForLocation(x, y)) > -1) {
//do not show popup menu on rows other than selection
final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group);
popupMenu.getComponent().show(comp, x, y);
}
}
};
tree.addMouseListener(handler);
return handler;
}
use of com.intellij.openapi.actionSystem.ActionPopupMenu in project azure-tools-for-java by Microsoft.
the class Tree method installPopupMenu.
public static void installPopupMenu(JTree tree) {
final MouseAdapter popupHandler = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
final TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
if (path == null) {
return;
}
final Object node = path.getLastPathComponent();
if (node instanceof TreeNode) {
if (SwingUtilities.isLeftMouseButton(e)) {
if (((TreeNode<?>) node).inner.hasChildren() && ((TreeNode<?>) node).loaded == null) {
((TreeNode<?>) node).refreshChildren();
tree.expandPath(path);
}
} else if (SwingUtilities.isRightMouseButton(e) || e.isPopupTrigger()) {
final ActionGroup actions = ((TreeNode<?>) node).inner.actions();
if (Objects.nonNull(actions)) {
final ActionManager am = ActionManager.getInstance();
final ActionPopupMenu menu = am.createActionPopupMenu("azure.component.tree", toIntellijActionGroup(actions));
menu.setTargetComponent(tree);
menu.getComponent().show(tree, e.getX(), e.getY());
}
}
}
}
private com.intellij.openapi.actionSystem.ActionGroup toIntellijActionGroup(ActionGroup actions) {
final ActionManager am = ActionManager.getInstance();
if (actions instanceof ActionGroup.Proxy) {
final String id = ((ActionGroup.Proxy) actions).id();
if (Objects.nonNull(id)) {
return (com.intellij.openapi.actionSystem.ActionGroup) am.getAction(id);
}
}
return new IntellijAzureActionManager.ActionGroupWrapper(actions);
}
};
tree.addMouseListener(popupHandler);
}
use of com.intellij.openapi.actionSystem.ActionPopupMenu in project intellij-community by JetBrains.
the class EditorActionUtil method showEditorPopup.
private static void showEditorPopup(final EditorMouseEvent event, @NotNull final ActionGroup group) {
if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) {
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group);
MouseEvent e = event.getMouseEvent();
final Component c = e.getComponent();
if (c != null && c.isShowing()) {
popupMenu.getComponent().show(c, e.getX(), e.getY());
}
e.consume();
}
}
use of com.intellij.openapi.actionSystem.ActionPopupMenu in project intellij-community by JetBrains.
the class PopupHandler method installPopupHandler.
public static MouseListener installPopupHandler(JComponent component, @NotNull final ActionGroup group, final String place, final ActionManager actionManager) {
if (ApplicationManager.getApplication() == null)
return new MouseAdapter() {
};
PopupHandler popupHandler = new PopupHandler() {
public void invokePopup(Component comp, int x, int y) {
final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group);
popupMenu.getComponent().show(comp, x, y);
}
};
component.addMouseListener(popupHandler);
return popupHandler;
}
Aggregations