use of com.microsoft.intellij.actions.SelectSubscriptionsAction in project azure-tools-for-java by Microsoft.
the class ServerExplorerToolWindowFactory method addToolbarItems.
private void addToolbarItems(ToolWindow toolWindow, final Project project, final AzureModule azureModule) {
if (toolWindow instanceof ToolWindowEx) {
ToolWindowEx toolWindowEx = (ToolWindowEx) toolWindow;
try {
Runnable forceRefreshTitleActions = () -> {
ApplicationManager.getApplication().invokeLater(() -> {
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();
final String iconPath = isDarkTheme ? RefreshableNode.REFRESH_ICON_DARK : RefreshableNode.REFRESH_ICON_LIGHT;
e.getPresentation().setIcon(UIHelperImpl.loadIcon(iconPath));
}
}, new AzureSignInAction(), new SelectSubscriptionsAction());
} catch (Exception e) {
AzurePlugin.log(e.getMessage(), e);
}
});
};
AuthMethodManager.getInstance().addSignInEventListener(forceRefreshTitleActions);
AuthMethodManager.getInstance().addSignOutEventListener(forceRefreshTitleActions);
// Remove the sign in/out listener when project close
ProjectManager.getInstance().addProjectManagerListener(project, new ProjectManagerListener() {
@Override
public void projectClosing(@NotNull Project project) {
AuthMethodManager.getInstance().removeSignInEventListener(forceRefreshTitleActions);
AuthMethodManager.getInstance().removeSignOutEventListener(forceRefreshTitleActions);
}
});
forceRefreshTitleActions.run();
} catch (Exception e) {
AzurePlugin.log(e.getMessage(), e);
}
}
}
Aggregations