Search in sources :

Example 1 with StorageAccount

use of com.microsoft.azure.toolkit.lib.storage.service.StorageAccount in project azure-tools-for-java by Microsoft.

the class SettingsStep method retrieveStorageAccounts.

private void retrieveStorageAccounts() {
    AzureTaskManager.getInstance().runInBackground("Loading storage accounts...", new Runnable() {

        @Override
        public void run() {
            if (storageAccounts == null) {
                List<StorageAccount> accounts = Azure.az(AzureStorageAccount.class).subscription(wizard.getSubscription().getId()).list();
                storageAccounts = new TreeMap<String, StorageAccount>();
                for (StorageAccount storageAccount : accounts) {
                    storageAccounts.put(storageAccount.name(), storageAccount);
                }
            }
            fillStorage(null);
        }
    });
    storageComboBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (CREATE_NEW.equals(storageComboBox.getText())) {
                showNewStorageForm();
            } else if (storageComboBox.getData(storageComboBox.getText()) != null) {
                StorageAccount storageAccount = (StorageAccount) storageComboBox.getData(storageComboBox.getText());
                wizard.setStorageAccount(storageAccount);
            }
        }
    });
    if (storageAccounts == null) {
        DefaultLoader.getIdeHelper().invokeAndWait(new Runnable() {

            @Override
            public void run() {
                storageComboBox.setItems(new String[] { CREATE_NEW, LOADING });
            }
        });
    }
}
Also used : AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap)

Example 2 with StorageAccount

use of com.microsoft.azure.toolkit.lib.storage.service.StorageAccount in project azure-tools-for-java by Microsoft.

the class IntellijStorageActionsContributor method registerHandlers.

@Override
public void registerHandlers(AzureActionManager am) {
    final BiPredicate<Object, AnActionEvent> condition = (r, e) -> r instanceof AzureStorageAccount;
    final BiConsumer<Object, AnActionEvent> handler = (c, e) -> CreateStorageAccountAction.createStorageAccount((e.getProject()));
    am.registerHandler(ResourceCommonActionsContributor.CREATE, condition, handler);
    am.<IAzureResource<?>, AnActionEvent>registerHandler(ResourceCommonActionsContributor.CONNECT, (r, e) -> r instanceof StorageAccount, (r, e) -> AzureTaskManager.getInstance().runLater(() -> {
        final ConnectorDialog dialog = new ConnectorDialog(e.getProject());
        dialog.setResource(new AzureServiceResource<>(((StorageAccount) r), StorageAccountResourceDefinition.INSTANCE));
        dialog.show();
    }));
}
Also used : AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureServiceResource(com.microsoft.azure.toolkit.intellij.connector.AzureServiceResource) CreateStorageAccountAction(com.microsoft.azure.toolkit.intellij.storage.creation.CreateStorageAccountAction) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) StorageAccountResourceDefinition(com.microsoft.azure.toolkit.intellij.storage.connection.StorageAccountResourceDefinition) BiPredicate(java.util.function.BiPredicate) IActionsContributor(com.microsoft.azure.toolkit.ide.common.IActionsContributor) ResourceCommonActionsContributor(com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) BiConsumer(java.util.function.BiConsumer) ConnectorDialog(com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog) IAzureResource(com.microsoft.azure.toolkit.lib.common.entity.IAzureResource) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) ConnectorDialog(com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) AzureServiceResource(com.microsoft.azure.toolkit.intellij.connector.AzureServiceResource) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) IAzureResource(com.microsoft.azure.toolkit.lib.common.entity.IAzureResource)

Example 3 with StorageAccount

use of com.microsoft.azure.toolkit.lib.storage.service.StorageAccount in project azure-tools-for-java by Microsoft.

the class SettingsStep method retrieveStorageAccounts.

private void retrieveStorageAccounts() {
    final AzureString title = AzureOperationBundle.title("vm.list_storage_accounts");
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        progressIndicator.setIndeterminate(true);
        if (storageAccounts == null) {
            List<StorageAccount> accounts = Azure.az(AzureStorageAccount.class).subscription(model.getSubscription().getId()).list();
            storageAccounts = new TreeMap<>();
            for (StorageAccount storageAccount : accounts) {
                storageAccounts.put(storageAccount.name(), storageAccount);
            }
        }
        refreshStorageAccounts(null);
    }));
    if (storageAccounts == null) {
        final DefaultComboBoxModel loadingSAModel = new DefaultComboBoxModel(new String[] { CREATE_NEW, "<Loading...>" }) {

            @Override
            public void setSelectedItem(Object o) {
                if (CREATE_NEW.equals(o)) {
                    showNewStorageForm();
                } else {
                    super.setSelectedItem(o);
                }
            }
        };
        loadingSAModel.setSelectedItem(null);
        AzureTaskManager.getInstance().runAndWait(() -> storageComboBox.setModel(loadingSAModel), AzureTask.Modality.ANY);
    }
}
Also used : AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Aggregations

AzureStorageAccount (com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount)3 StorageAccount (com.microsoft.azure.toolkit.lib.storage.service.StorageAccount)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 IActionsContributor (com.microsoft.azure.toolkit.ide.common.IActionsContributor)1 ResourceCommonActionsContributor (com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor)1 AzureServiceResource (com.microsoft.azure.toolkit.intellij.connector.AzureServiceResource)1 ConnectorDialog (com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog)1 StorageAccountResourceDefinition (com.microsoft.azure.toolkit.intellij.storage.connection.StorageAccountResourceDefinition)1 CreateStorageAccountAction (com.microsoft.azure.toolkit.intellij.storage.creation.CreateStorageAccountAction)1 AzureActionManager (com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 IAzureResource (com.microsoft.azure.toolkit.lib.common.entity.IAzureResource)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 BiConsumer (java.util.function.BiConsumer)1 BiPredicate (java.util.function.BiPredicate)1