Search in sources :

Example 1 with ActionGroup

use of com.microsoft.azure.toolkit.lib.common.action.ActionGroup 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);
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) ActionManager(com.intellij.openapi.actionSystem.ActionManager) IntellijAzureActionManager(com.microsoft.azure.toolkit.intellij.common.action.IntellijAzureActionManager) TreePath(javax.swing.tree.TreePath) ActionGroup(com.microsoft.azure.toolkit.lib.common.action.ActionGroup) MutableTreeNode(javax.swing.tree.MutableTreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionPopupMenu(com.intellij.openapi.actionSystem.ActionPopupMenu)

Example 2 with ActionGroup

use of com.microsoft.azure.toolkit.lib.common.action.ActionGroup in project azure-tools-for-java by Microsoft.

the class ResourceConnectionActionsContributor method registerGroups.

@Override
public void registerGroups(AzureActionManager am) {
    final ActionGroup moduleActions = new ActionGroup(ADD_CONNECTION);
    am.registerGroup(MODULE_ACTIONS, moduleActions);
    final ActionGroup connectionActions = new ActionGroup("", EDIT_CONNECTION, REMOVE_CONNECTION);
    am.registerGroup(CONNECTION_ACTIONS, connectionActions);
}
Also used : ActionGroup(com.microsoft.azure.toolkit.lib.common.action.ActionGroup)

Example 3 with ActionGroup

use of com.microsoft.azure.toolkit.lib.common.action.ActionGroup in project azure-tools-for-java by Microsoft.

the class VirtualMachineActionsContributor method registerGroups.

@Override
public void registerGroups(AzureActionManager am) {
    final ActionGroup serviceActionGroup = new ActionGroup(ResourceCommonActionsContributor.SERVICE_REFRESH, ResourceCommonActionsContributor.CREATE);
    am.registerGroup(SERVICE_ACTIONS, serviceActionGroup);
    final ActionGroup accountActionGroup = new ActionGroup(ResourceCommonActionsContributor.REFRESH, ResourceCommonActionsContributor.OPEN_PORTAL_URL, "---", ResourceCommonActionsContributor.START, ResourceCommonActionsContributor.STOP, ResourceCommonActionsContributor.RESTART, ResourceCommonActionsContributor.DELETE);
    am.registerGroup(VM_ACTIONS, accountActionGroup);
}
Also used : ActionGroup(com.microsoft.azure.toolkit.lib.common.action.ActionGroup)

Example 4 with ActionGroup

use of com.microsoft.azure.toolkit.lib.common.action.ActionGroup in project azure-tools-for-java by Microsoft.

the class SpringCloudActionsContributor method registerGroups.

@Override
public void registerGroups(AzureActionManager am) {
    final ActionGroup serviceActionGroup = new ActionGroup(ResourceCommonActionsContributor.SERVICE_REFRESH);
    am.registerGroup(SERVICE_ACTIONS, serviceActionGroup);
    final ActionGroup clusterActionGroup = new ActionGroup(ResourceCommonActionsContributor.OPEN_PORTAL_URL, ResourceCommonActionsContributor.CREATE, ResourceCommonActionsContributor.REFRESH);
    am.registerGroup(CLUSTER_ACTIONS, clusterActionGroup);
    final ActionGroup appActionGroup = new ActionGroup(ResourceCommonActionsContributor.OPEN_PORTAL_URL, SpringCloudActionsContributor.OPEN_PUBLIC_URL, SpringCloudActionsContributor.OPEN_TEST_URL, "---", ResourceCommonActionsContributor.START, ResourceCommonActionsContributor.STOP, ResourceCommonActionsContributor.RESTART, ResourceCommonActionsContributor.DELETE, "---", ResourceCommonActionsContributor.DEPLOY, "---", ResourceCommonActionsContributor.SHOW_PROPERTIES, ResourceCommonActionsContributor.REFRESH, "---", SpringCloudActionsContributor.STREAM_LOG);
    am.registerGroup(APP_ACTIONS, appActionGroup);
}
Also used : ActionGroup(com.microsoft.azure.toolkit.lib.common.action.ActionGroup)

Example 5 with ActionGroup

use of com.microsoft.azure.toolkit.lib.common.action.ActionGroup in project azure-tools-for-java by Microsoft.

the class StorageActionsContributor method registerGroups.

@Override
public void registerGroups(AzureActionManager am) {
    final ActionGroup serviceActionGroup = new ActionGroup(ResourceCommonActionsContributor.SERVICE_REFRESH, ResourceCommonActionsContributor.CREATE);
    am.registerGroup(SERVICE_ACTIONS, serviceActionGroup);
    final ActionGroup accountActionGroup = new ActionGroup(ResourceCommonActionsContributor.OPEN_PORTAL_URL, StorageActionsContributor.OPEN_STORAGE_EXPLORER, "---", ResourceCommonActionsContributor.CONNECT, "---", ResourceCommonActionsContributor.DELETE);
    am.registerGroup(ACCOUNT_ACTIONS, accountActionGroup);
}
Also used : ActionGroup(com.microsoft.azure.toolkit.lib.common.action.ActionGroup)

Aggregations

ActionGroup (com.microsoft.azure.toolkit.lib.common.action.ActionGroup)5 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 ActionPopupMenu (com.intellij.openapi.actionSystem.ActionPopupMenu)1 IntellijAzureActionManager (com.microsoft.azure.toolkit.intellij.common.action.IntellijAzureActionManager)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 MutableTreeNode (javax.swing.tree.MutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1