Search in sources :

Example 1 with STORAGE

use of com.microsoft.azuretools.telemetry.TelemetryConstants.STORAGE 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 2 with STORAGE

use of com.microsoft.azuretools.telemetry.TelemetryConstants.STORAGE in project azure-tools-for-java by Microsoft.

the class CreateArmStorageAccountAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    SignInCommandHandler.requireSignedIn(PluginUtil.getParentShell(), () -> {
        CreateArmStorageAccountForm createStorageAccountForm = new CreateArmStorageAccountForm(PluginUtil.getParentShell(), null, null);
        createStorageAccountForm.setOnCreate(() -> {
            AzureTaskManager.getInstance().runInBackground("Creating storage account " + createStorageAccountForm.getStorageAccount().getName() + "...", new Runnable() {

                @Override
                public void run() {
                    EventUtil.executeWithLog(STORAGE, CREATE_STORAGE_ACCOUNT, (operation) -> {
                        createStorageAccount(createStorageAccountForm.getStorageAccount());
                        storageModule.load(false);
                    }, (e) -> AzureTaskManager.getInstance().runLater(() -> PluginUtil.displayErrorDialog(PluginUtil.getParentShell(), Messages.err, "An error occurred while creating the storage account: " + e.getMessage())));
                }
            });
        });
        createStorageAccountForm.open();
    });
}
Also used : NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) Azure(com.microsoft.azure.toolkit.lib.Azure) Messages(com.microsoft.azuretools.core.utils.Messages) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) Name(com.microsoft.tooling.msservices.helpers.Name) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) StorageAccountConfig(com.microsoft.azure.toolkit.lib.storage.model.StorageAccountConfig) CREATE_STORAGE_ACCOUNT(com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_STORAGE_ACCOUNT) SignInCommandHandler(com.microsoft.azuretools.core.handlers.SignInCommandHandler) AzureTelemetry(com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetry) Draft(com.microsoft.azuretools.azureexplorer.forms.common.Draft) CreateArmStorageAccountForm(com.microsoft.azuretools.azureexplorer.forms.CreateArmStorageAccountForm) StorageModule(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.StorageModule) PluginUtil(com.microsoft.azuretools.core.utils.PluginUtil) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) STORAGE(com.microsoft.azuretools.telemetry.TelemetryConstants.STORAGE) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) CreateArmStorageAccountForm(com.microsoft.azuretools.azureexplorer.forms.CreateArmStorageAccountForm)

Aggregations

AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)2 STORAGE (com.microsoft.azuretools.telemetry.TelemetryConstants.STORAGE)2 EventUtil (com.microsoft.azuretools.telemetrywrapper.EventUtil)2 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 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)1 AzureOperationBundle (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 AzureTelemetry (com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetry)1 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)1 StorageAccountConfig (com.microsoft.azure.toolkit.lib.storage.model.StorageAccountConfig)1 AzureStorageAccount (com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount)1 StorageAccount (com.microsoft.azure.toolkit.lib.storage.service.StorageAccount)1 CreateArmStorageAccountForm (com.microsoft.azuretools.azureexplorer.forms.CreateArmStorageAccountForm)1 Draft (com.microsoft.azuretools.azureexplorer.forms.common.Draft)1 SignInCommandHandler (com.microsoft.azuretools.core.handlers.SignInCommandHandler)1