Search in sources :

Example 1 with SelectSubscriptionsAction

use of com.microsoft.azuretools.ijidea.actions.SelectSubscriptionsAction in project azure-tools-for-java by Microsoft.

the class ServerExplorerToolWindowFactory method addToolbarItems.

private void addToolbarItems(ToolWindow toolWindow, final AzureModule azureModule) {
    if (toolWindow instanceof ToolWindowEx) {
        ToolWindowEx toolWindowEx = (ToolWindowEx) toolWindow;
        try {
            Runnable forceRefreshTitleActions = () -> {
                try {
                    toolWindowEx.setTitleActions(new AnAction("Refresh", "Refresh Azure Nodes List", null) {

                        @Override
                        public void actionPerformed(AnActionEvent event) {
                            azureModule.load(true);
                        }

                        @Override
                        public void update(AnActionEvent e) {
                            boolean isDarkTheme = DefaultLoader.getUIHelper().isDarkTheme();
                            e.getPresentation().setIcon(UIHelperImpl.loadIcon(isDarkTheme ? RefreshableNode.REFRESH_ICON_DARK : RefreshableNode.REFRESH_ICON_LIGHT));
                        }
                    }, new AzureSignInAction(), new SelectSubscriptionsAction());
                } catch (Exception e) {
                    AzurePlugin.log(e.getMessage(), e);
                }
            };
            AuthMethodManager.getInstance().addSignInEventListener(forceRefreshTitleActions);
            AuthMethodManager.getInstance().addSignOutEventListener(forceRefreshTitleActions);
            forceRefreshTitleActions.run();
        } catch (Exception e) {
            AzurePlugin.log(e.getMessage(), e);
        }
    }
}
Also used : ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) AzureSignInAction(com.microsoft.azuretools.ijidea.actions.AzureSignInAction) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) SelectSubscriptionsAction(com.microsoft.azuretools.ijidea.actions.SelectSubscriptionsAction) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ToolWindowEx (com.intellij.openapi.wm.ex.ToolWindowEx)1 AzureSignInAction (com.microsoft.azuretools.ijidea.actions.AzureSignInAction)1 SelectSubscriptionsAction (com.microsoft.azuretools.ijidea.actions.SelectSubscriptionsAction)1