Search in sources :

Example 1 with CREATE_BLOB_CONTAINER

use of com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_BLOB_CONTAINER 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)

Aggregations

ProgressManager (com.intellij.openapi.progress.ProgressManager)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 ValidationInfo (com.intellij.openapi.ui.ValidationInfo)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 AzureOperationBundle (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)1 CREATE_BLOB_CONTAINER (com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_BLOB_CONTAINER)1 STORAGE (com.microsoft.azuretools.telemetry.TelemetryConstants.STORAGE)1 EventUtil (com.microsoft.azuretools.telemetrywrapper.EventUtil)1 LinkListener (com.microsoft.intellij.helpers.LinkListener)1 AzureDialogWrapper (com.microsoft.intellij.ui.components.AzureDialogWrapper)1 AzureBundle.message (com.microsoft.intellij.ui.messages.AzureBundle.message)1 PluginUtil (com.microsoft.intellij.util.PluginUtil)1 DefaultLoader (com.microsoft.tooling.msservices.components.DefaultLoader)1 StorageClientSDKManager (com.microsoft.tooling.msservices.helpers.azure.sdk.StorageClientSDKManager)1 BlobContainer (com.microsoft.tooling.msservices.model.storage.BlobContainer)1 Calendar (java.util.Calendar)1 List (java.util.List)1