Search in sources :

Example 1 with ISubscriptionSelectionListener

use of com.microsoft.azuretools.authmanage.ISubscriptionSelectionListener in project azure-tools-for-java by Microsoft.

the class AzureModule method addSubscriptionSelectionListener.

private void addSubscriptionSelectionListener() {
    try {
        AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
        // not signed in
        if (azureManager == null) {
            return;
        }
        azureManager.getSubscriptionManager().addListener(new ISubscriptionSelectionListener() {

            @Override
            public void update(boolean isRefresh) {
                if (!isRefresh) {
                    handleSubscriptionChange();
                }
            }
        });
    } catch (Exception ex) {
        DefaultLoader.getUIHelper().logError(ex.getMessage(), ex);
    }
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) ISubscriptionSelectionListener(com.microsoft.azuretools.authmanage.ISubscriptionSelectionListener) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 2 with ISubscriptionSelectionListener

use of com.microsoft.azuretools.authmanage.ISubscriptionSelectionListener in project azure-tools-for-java by Microsoft.

the class BlobExplorerFileEditor method addSubscriptionSelectionListener.

private void addSubscriptionSelectionListener() {
    try {
        AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
        // not signed in
        if (azureManager == null) {
            return;
        }
        azureManager.getSubscriptionManager().addListener(new ISubscriptionSelectionListener() {

            @Override
            public void update(boolean isSignedOut) {
                if (isSignedOut) {
                    Object openedFile = DefaultLoader.getUIHelper().getOpenedFile(project, storageAccount, blobContainer);
                    if (openedFile != null) {
                        DefaultLoader.getIdeHelper().closeFile(project, openedFile);
                    }
                }
            }
        });
    } catch (Exception ex) {
        DefaultLoader.getUIHelper().logError(ex.getMessage(), ex);
    }
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) ISubscriptionSelectionListener(com.microsoft.azuretools.authmanage.ISubscriptionSelectionListener) SocketTimeoutException(java.net.SocketTimeoutException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Aggregations

ISubscriptionSelectionListener (com.microsoft.azuretools.authmanage.ISubscriptionSelectionListener)2 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)2 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)2 SocketTimeoutException (java.net.SocketTimeoutException)1