Search in sources :

Example 46 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.

the class SelectImageStep method fillSkus.

private void fillSkus() {
    disableNext();
    if (offerComboBox.getItemCount() > 0) {
        final VirtualMachineOffer offer = (VirtualMachineOffer) offerComboBox.getSelectedItem();
        final AzureString title = AzureOperationBundle.title("vm|sku.list", offer.name());
        AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
            final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
            progressIndicator.setIndeterminate(true);
            RxJavaUtils.unsubscribeSubscription(fillSkuSubscription);
            clearSelection(skuComboBox, imageLabelList);
            fillSkuSubscription = Observable.fromCallable(() -> offer.skus().list()).subscribeOn(Schedulers.io()).subscribe(skuList -> DefaultLoader.getIdeHelper().invokeLater(() -> {
                skuComboBox.setModel(new DefaultComboBoxModel(skuList.toArray()));
                fillImages();
            }), error -> {
                String msg = String.format(ERROR_MESSAGE_FILL_SKUS, String.format(message("webappExpMsg"), error.getMessage()));
                handleError(msg, error);
            });
        }));
    } else {
        skuComboBox.removeAllItems();
        imageLabelList.setListData(new Object[] {});
    }
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) VirtualMachineOffer(com.microsoft.azure.management.compute.VirtualMachineOffer) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Aggregations

AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)46 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)36 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)21 Project (com.intellij.openapi.project.Project)7 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)6 List (java.util.List)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 AzureOperationBundle (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle)5 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)5 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)5 EventUtil (com.microsoft.azuretools.telemetrywrapper.EventUtil)4 BlobFile (com.microsoft.tooling.msservices.model.storage.BlobFile)4 IOException (java.io.IOException)4 MessageType (com.intellij.openapi.ui.MessageType)3 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)3 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)3 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)3 File (java.io.File)3 javax.swing (javax.swing)3 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)2