Search in sources :

Example 21 with ActionManager

use of com.intellij.openapi.actionSystem.ActionManager in project azure-tools-for-java by Microsoft.

the class AzureActionsListener method appFrameCreated.

@Override
public void appFrameCreated(@NotNull List<String> commandLineArgs) {
    DefaultLoader.setPluginComponent(this);
    DefaultLoader.setUiHelper(new UIHelperImpl());
    DefaultLoader.setIdeHelper(new IDEHelperImpl());
    AzureTaskManager.register(new IntellijAzureTaskManager());
    AzureRxTaskManager.register();
    AzureMessager.setDefaultMessager(new IntellijAzureMessager());
    IntellijAzureActionManager.register();
    Node.setNode2Actions(NodeActionsMap.NODE_ACTIONS);
    SchedulerProviderFactory.getInstance().init(new AppSchedulerProvider());
    MvpUIHelperFactory.getInstance().init(new MvpUIHelperImpl());
    HDInsightLoader.setHHDInsightHelper(new HDInsightHelperImpl());
    AzureStoreManager.register(new DefaultMachineStore(PluginHelper.getTemplateFile("azure.json")), IntellijStore.getInstance(), IntelliJSecureStore.getInstance());
    try {
        loadPluginSettings();
    } catch (IOException e) {
        PluginUtil.displayErrorDialogAndLog("Error", "An error occurred while attempting to load settings", e);
    }
    AzureInitializer.initialize();
    if (!AzurePlugin.IS_ANDROID_STUDIO) {
        // enable spark serverless node subscribe actions
        ServiceManager.setServiceProvider(CosmosSparkClusterOpsCtrl.class, new CosmosSparkClusterOpsCtrl(CosmosSparkClusterOps.getInstance()));
        ServiceManager.setServiceProvider(TrustStrategy.class, IdeaTrustStrategy.INSTANCE);
        initAuthManage();
        ActionManager am = ActionManager.getInstance();
        DefaultActionGroup toolbarGroup = (DefaultActionGroup) am.getAction(IdeActions.GROUP_MAIN_TOOLBAR);
        toolbarGroup.addAll((DefaultActionGroup) am.getAction("AzureToolbarGroup"));
        DefaultActionGroup popupGroup = (DefaultActionGroup) am.getAction(IdeActions.GROUP_PROJECT_VIEW_POPUP);
        popupGroup.add(am.getAction("AzurePopupGroup"));
    }
    try {
        PlatformDependent.isAndroid();
    } catch (Throwable ignored) {
        DefaultLoader.getUIHelper().showError("A problem with your Android Support plugin setup is preventing the" + " Azure Toolkit from functioning correctly (Retrofit2 and RxJava failed to initialize)" + ".\nTo fix this issue, try disabling the Android Support plugin or installing the " + "Android SDK", "Azure Toolkit for IntelliJ");
    // DefaultLoader.getUIHelper().showException("Android Support Error: isAndroid() throws " + ignored
    // .getMessage(), ignored, "Error Android", true, false);
    }
}
Also used : CosmosSparkClusterOpsCtrl(com.microsoft.azure.cosmosspark.CosmosSparkClusterOpsCtrl) IntellijAzureMessager(com.microsoft.azure.toolkit.intellij.common.messager.IntellijAzureMessager) AppSchedulerProvider(com.microsoft.azuretools.core.mvp.ui.base.AppSchedulerProvider) MvpUIHelperImpl(com.microsoft.intellij.helpers.MvpUIHelperImpl) IOException(java.io.IOException) IDEHelperImpl(com.microsoft.intellij.helpers.IDEHelperImpl) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) IntellijAzureActionManager(com.microsoft.azure.toolkit.intellij.common.action.IntellijAzureActionManager) ActionManager(com.intellij.openapi.actionSystem.ActionManager) HDInsightHelperImpl(com.microsoft.azure.hdinsight.common.HDInsightHelperImpl) UIHelperImpl(com.microsoft.intellij.helpers.UIHelperImpl) MvpUIHelperImpl(com.microsoft.intellij.helpers.MvpUIHelperImpl) DefaultMachineStore(com.microsoft.azure.toolkit.ide.common.store.DefaultMachineStore) IntellijAzureTaskManager(com.microsoft.azure.toolkit.intellij.common.task.IntellijAzureTaskManager)

Example 22 with ActionManager

use of com.intellij.openapi.actionSystem.ActionManager 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 23 with ActionManager

use of com.intellij.openapi.actionSystem.ActionManager in project ideavim by JetBrains.

the class ChangeGroup method runEnterAction.

private void runEnterAction(Editor editor, @NotNull DataContext context) {
    CommandState state = CommandState.getInstance(editor);
    if (state.getMode() != CommandState.Mode.REPEAT) {
        final ActionManager actionManager = ActionManager.getInstance();
        final AnAction action = actionManager.getAction("EditorEnter");
        if (action != null) {
            strokes.add(action);
            KeyHandler.executeAction(action, context);
        }
    }
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 24 with ActionManager

use of com.intellij.openapi.actionSystem.ActionManager in project android by JetBrains.

the class TreeGridTest method setUp.

@Before
public void setUp() {
    myDisposable = Disposer.newDisposable();
    Application application = mock(Application.class);
    DataManager dataManager = mock(DataManager.class);
    DataContext dataContext = mock(DataContext.class);
    ActionManager actionManager = mock(ActionManager.class);
    ApplicationManager.setApplication(application, myDisposable);
    when(application.getAnyModalityState()).thenReturn(ModalityState.NON_MODAL);
    when(application.getComponent(eq(DataManager.class))).thenReturn(dataManager);
    when(dataManager.getDataContext(any(Component.class))).thenReturn(dataContext);
    when(application.getComponent(eq(ActionManager.class))).thenReturn(actionManager);
    myGrid = new TreeGrid<>();
    myGrid.setSize(140, 800);
    myGrid.setModel(createTree());
    myGrid.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    myGrid.setFixedCellWidth(40);
    myGrid.setFixedCellHeight(40);
    myGrid.doLayout();
    BufferedImage image = UIUtil.createImage(1000, 1000, TYPE_INT_ARGB);
    myGrid.paint(image.getGraphics());
    List<JList<String>> lists = myGrid.getLists();
    myGroup1 = lists.get(0);
    myGroup2 = lists.get(1);
    myGroup3 = lists.get(2);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) DataContext(com.intellij.openapi.actionSystem.DataContext) DataManager(com.intellij.ide.DataManager) Application(com.intellij.openapi.application.Application) BufferedImage(java.awt.image.BufferedImage) Before(org.junit.Before)

Example 25 with ActionManager

use of com.intellij.openapi.actionSystem.ActionManager in project android by JetBrains.

the class NlActionsToolbar method createToolbarComponent.

private JComponent createToolbarComponent() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
    // Create a layout where there are three toolbars:
    // +----------------------------------------------------------------------------+
    // | Normal toolbar, minus dynamic actions                                      |
    // +---------------------------------------------+------------------------------+
    // | Dynamic layout actions                      | Zoom actions and file status |
    // +---------------------------------------------+------------------------------+
    ConfigurationHolder context = new NlEditorPanel.NlConfigurationHolder(mySurface);
    ActionGroup configGroup = createConfigActions(context, mySurface);
    ActionManager actionManager = ActionManager.getInstance();
    myActionToolbar = actionManager.createActionToolbar("NlConfigToolbar", configGroup, true);
    myActionToolbar.getComponent().setName("NlConfigToolbar");
    myActionToolbar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY);
    JComponent actionToolbarComponent = myActionToolbar.getComponent();
    actionToolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
    panel.add(actionToolbarComponent, BorderLayout.NORTH);
    final ActionToolbar layoutToolBar = actionManager.createActionToolbar("NlLayoutToolbar", myDynamicGroup, true);
    layoutToolBar.getComponent().setName("NlLayoutToolbar");
    layoutToolBar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY);
    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(layoutToolBar.getComponent(), BorderLayout.WEST);
    JPanel combined = new JPanel(new BorderLayout());
    ActionToolbar zoomToolBar = actionManager.createActionToolbar("NlRhsToolbar", getRhsActions(mySurface), true);
    combined.add(zoomToolBar.getComponent(), BorderLayout.WEST);
    bottom.add(combined, BorderLayout.EAST);
    panel.add(bottom, BorderLayout.SOUTH);
    mySurface.addListener(this);
    updateViewActions();
    return panel;
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ActionToolbar(com.intellij.openapi.actionSystem.ActionToolbar)

Aggregations

ActionManager (com.intellij.openapi.actionSystem.ActionManager)43 AnAction (com.intellij.openapi.actionSystem.AnAction)27 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)15 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)4 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)4 MouseEvent (java.awt.event.MouseEvent)4 Keymap (com.intellij.openapi.keymap.Keymap)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ActionPopupMenu (com.intellij.openapi.actionSystem.ActionPopupMenu)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 ActionManagerImpl (com.intellij.openapi.actionSystem.impl.ActionManagerImpl)2 Application (com.intellij.openapi.application.Application)2 ToolWindow (com.intellij.openapi.wm.ToolWindow)2 IntellijAzureActionManager (com.microsoft.azure.toolkit.intellij.common.action.IntellijAzureActionManager)2 File (java.io.File)2 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)1 CloudDebugHelpAction (com.google.cloud.tools.intellij.debugger.actions.CloudDebugHelpAction)1 DataManager (com.intellij.ide.DataManager)1