Search in sources :

Example 1 with AzureString

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

the class SignInCommandHandler method loginDeviceCodeSingle.

private static Single<DeviceCodeAccount> loginDeviceCodeSingle() {
    final AzureString title = AzureOperationBundle.title("account.sign_in");
    final AzureTask<DeviceCodeAccount> deviceCodeTask = new AzureTask<>(null, title, true, () -> {
        final AzureAccount az = Azure.az(AzureAccount.class);
        return (DeviceCodeAccount) checkCanceled(null, az.loginAsync(AuthType.DEVICE_CODE, true), () -> {
            throw Lombok.sneakyThrow(new InterruptedException("user cancel"));
        });
    });
    return AzureTaskManager.getInstance().runInBackgroundAsObservable(deviceCodeTask).toSingle();
}
Also used : DeviceCodeAccount(com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 2 with AzureString

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

the class AzureSignInAction method loginDeviceCodeSingle.

private static Single<DeviceCodeAccount> loginDeviceCodeSingle() {
    final AzureString title = AzureOperationBundle.title("account.sign_in");
    final AzureTask<DeviceCodeAccount> deviceCodeTask = new AzureTask<>(null, title, true, () -> {
        final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
        indicator.setIndeterminate(true);
        final AzureAccount az = Azure.az(AzureAccount.class);
        return (DeviceCodeAccount) checkCanceled(indicator, az.loginAsync(AuthType.DEVICE_CODE, true), () -> {
            throw Lombok.sneakyThrow(new InterruptedException("user cancel"));
        });
    });
    return AzureTaskManager.getInstance().runInBackgroundAsObservable(deviceCodeTask).toSingle();
}
Also used : DeviceCodeAccount(com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 3 with AzureString

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

the class CreateBlobContainerForm method doOKAction.

@Override
protected void doOKAction() {
    final String name = nameTextField.getText();
    // Field outerFiele = onCreate.getClass().getDeclaredField("this$0");
    final AzureString title = AzureOperationBundle.title("blob.create", name);
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        EventUtil.executeWithLog(STORAGE, CREATE_BLOB_CONTAINER, (operation) -> {
            ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
            List<BlobContainer> blobs = StorageClientSDKManager.getManager().getBlobContainers(connectionString);
            for (BlobContainer blobContainer : blobs) {
                if (blobContainer.getName().equals(name)) {
                    AzureTaskManager.getInstance().runLater(() -> {
                        DefaultLoader.getUIHelper().showError("A blob container with the specified name already exists.", "Azure Explorer");
                    });
                    return;
                }
            }
            BlobContainer blobContainer = new BlobContainer(name, "", /*storageAccount.getBlobsUri() + name*/
            "", Calendar.getInstance(), "");
            StorageClientSDKManager.getManager().createBlobContainer(connectionString, blobContainer);
            if (onCreate != null) {
                AzureTaskManager.getInstance().runLater(onCreate);
            }
        }, (e) -> {
            String msg = "An error occurred while attempting to create blob container." + "\n" + String.format(message("webappExpMsg"), e.getMessage());
            PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e);
        });
    }));
    sendTelemetry(OK_EXIT_CODE);
    this.close(DialogWrapper.OK_EXIT_CODE, true);
}
Also used : ProgressManager(com.intellij.openapi.progress.ProgressManager) AzureBundle.message(com.microsoft.intellij.ui.messages.AzureBundle.message) StorageClientSDKManager(com.microsoft.tooling.msservices.helpers.azure.sdk.StorageClientSDKManager) PluginUtil(com.microsoft.intellij.util.PluginUtil) AzureOperationBundle(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureDialogWrapper(com.microsoft.intellij.ui.components.AzureDialogWrapper) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) Calendar(java.util.Calendar) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) STORAGE(com.microsoft.azuretools.telemetry.TelemetryConstants.STORAGE) Project(com.intellij.openapi.project.Project) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) CREATE_BLOB_CONTAINER(com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_BLOB_CONTAINER) LinkListener(com.microsoft.intellij.helpers.LinkListener) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) ValidationInfo(com.intellij.openapi.ui.ValidationInfo) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) javax.swing(javax.swing) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) List(java.util.List) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 4 with AzureString

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

the class CreateWebAppAction method deploy.

@AzureOperation(name = "webapp.deploy_artifact", params = { "webapp.name()" }, type = AzureOperation.Type.ACTION)
private void deploy(final IWebApp webapp, final Path application, final Project project) {
    final AzureString title = title("webapp.deploy_artifact", webapp.name());
    final AzureTask<Void> task = new AzureTask<>(null, title, false, () -> {
        ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
        final RunProcessHandler processHandler = new RunProcessHandler();
        processHandler.addDefaultListener();
        final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
        processHandler.startNotify();
        consoleView.attachToProcess(processHandler);
        AzureWebAppMvpModel.getInstance().deployArtifactsToWebApp(webapp, application.toFile(), true, processHandler);
    });
    AzureTaskManager.getInstance().runInModalAsObservable(task).single().subscribe((none) -> {
        this.notifyDeploymentSuccess(webapp);
    });
// let root exception handler to show the error.
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) RunProcessHandler(com.microsoft.intellij.RunProcessHandler) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 5 with AzureString

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

the class SelectImageStep method fillImages.

private void fillImages() {
    disableNext();
    final AzureString title = AzureOperationBundle.title("vm|image.list");
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        progressIndicator.setIndeterminate(true);
        VirtualMachineSku sku = (VirtualMachineSku) skuComboBox.getSelectedItem();
        if (sku != null) {
            RxJavaUtils.unsubscribeSubscription(fillImagesSubscription);
            clearSelection(imageLabelList);
            fillImagesSubscription = Observable.fromCallable(() -> sku.images().list()).subscribeOn(Schedulers.io()).subscribe(imageList -> DefaultLoader.getIdeHelper().invokeLater(() -> imageLabelList.setListData(imageList.toArray())), error -> {
                String msg = String.format(ERROR_MESSAGE_LIST_IMAGES, String.format(message("webappExpMsg"), error.getMessage()));
                handleError(msg, error);
            });
        }
    }));
}
Also used : VirtualMachineSku(com.microsoft.azure.management.compute.VirtualMachineSku) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) 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