Search in sources :

Example 1 with NOTIFY_UPDATE_DEPLOYMENT_FAIL

use of com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_FAIL in project azure-tools-for-java by Microsoft.

the class ResourceTemplateView method updateDeployment.

private void updateDeployment() {
    String oldTemplate = this.originTemplate;
    String oldParameters = this.originParameters;
    final AzureString title = AzureOperationBundle.title("arm|deployment.update", node.getDeployment().name());
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        EventUtil.executeWithLog(ARM, UPDATE_DEPLOYMENT_SHORTCUT, (operation -> {
            ResourceTemplateView.this.originTemplate = getTemplate();
            ResourceTemplateView.this.originParameters = getParameters();
            node.getDeployment().update().withTemplate(ResourceTemplateView.this.originTemplate).withParameters(ResourceTemplateView.this.originParameters).withMode(DeploymentMode.INCREMENTAL).apply();
            UIUtils.showNotification(project, NOTIFY_UPDATE_DEPLOYMENT_SUCCESS, MessageType.INFO);
        }), (e) -> {
            // Fall back the origin value when update fail.
            ResourceTemplateView.this.originTemplate = oldTemplate;
            ResourceTemplateView.this.originParameters = oldParameters;
            UIUtils.showNotification(project, NOTIFY_UPDATE_DEPLOYMENT_FAIL + ", " + e.getMessage(), MessageType.ERROR);
        });
    }));
}
Also used : MessageType(com.intellij.openapi.ui.MessageType) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiAwareTextEditorProvider(com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider) AzureOperationBundle(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) DeploymentMode(com.microsoft.azure.management.resources.DeploymentMode) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) NOTIFY_UPDATE_DEPLOYMENT_FAIL(com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_FAIL) NOTIFY_UPDATE_DEPLOYMENT_SUCCESS(com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_SUCCESS) Project(com.intellij.openapi.project.Project) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) DeploymentNode(com.microsoft.tooling.msservices.serviceexplorer.azure.arm.deployments.DeploymentNode) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileEditorManagerListener(com.intellij.openapi.fileEditor.FileEditorManagerListener) UIUtils(com.microsoft.intellij.ui.util.UIUtils) BaseEditor(com.microsoft.azure.toolkit.intellij.common.BaseEditor) UPDATE_DEPLOYMENT_SHORTCUT(com.microsoft.azuretools.telemetry.TelemetryConstants.UPDATE_DEPLOYMENT_SHORTCUT) PsiAwareTextEditorImpl(com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl) FileEditor(com.intellij.openapi.fileEditor.FileEditor) ARM(com.microsoft.azuretools.telemetry.TelemetryConstants.ARM) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) NotNull(org.jetbrains.annotations.NotNull) ARMLanguage(com.microsoft.intellij.language.arm.ARMLanguage) Utils(com.microsoft.azuretools.azurecommons.util.Utils) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) javax.swing(javax.swing) 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 NOTIFY_UPDATE_DEPLOYMENT_FAIL

use of com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_FAIL in project azure-tools-for-java by Microsoft.

the class UpdateDeploymentForm method doOKAction.

@Override
protected void doOKAction() {
    String deploymentName = deploymentNode.getDeployment().name();
    final AzureString title = AzureOperationBundle.title("arm|deployment.update", deploymentName);
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        EventUtil.executeWithLog(TelemetryConstants.ARM, TelemetryConstants.UPDATE_DEPLOYMENT, (operation -> {
            Deployment.Update update = deploymentNode.getDeployment().update();
            String templatePath = templateTextField.getText();
            update = update.withTemplate(IOUtils.toString(new FileReader(templatePath)));
            String parametersPath = parametersTextField.getText();
            if (!StringUtils.isEmpty(parametersPath)) {
                String parameters = IOUtils.toString(new FileReader(parametersPath));
                update = update.withParameters(DeploymentUtils.parseParameters(parameters));
            }
            update.withMode(DeploymentMode.INCREMENTAL).apply();
            UIUtils.showNotification(statusBar, NOTIFY_UPDATE_DEPLOYMENT_SUCCESS, MessageType.INFO);
        }), (e) -> {
            UIUtils.showNotification(statusBar, NOTIFY_UPDATE_DEPLOYMENT_FAIL + ", " + e.getMessage(), MessageType.ERROR);
        });
    }));
    close(OK_EXIT_CODE, true);
}
Also used : FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) StringUtils(org.apache.commons.lang.StringUtils) MessageType(com.intellij.openapi.ui.MessageType) AzureOperationBundle(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) DeploymentMode(com.microsoft.azure.management.resources.DeploymentMode) NOTIFY_UPDATE_DEPLOYMENT_FAIL(com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_FAIL) StatusBar(com.intellij.openapi.wm.StatusBar) Map(java.util.Map) NOTIFY_UPDATE_DEPLOYMENT_SUCCESS(com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_SUCCESS) Project(com.intellij.openapi.project.Project) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) DeploymentNode(com.microsoft.tooling.msservices.serviceexplorer.azure.arm.deployments.DeploymentNode) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) Deployment(com.microsoft.azure.management.resources.Deployment) UIUtils(com.microsoft.intellij.ui.util.UIUtils) WindowManager(com.intellij.openapi.wm.WindowManager) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) Nullable(org.jetbrains.annotations.Nullable) Azure.az(com.microsoft.azure.toolkit.lib.Azure.az) List(java.util.List) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) FileReader(java.io.FileReader) BROWSE_TEMPLATE_SAMPLES(com.microsoft.azuretools.telemetry.TelemetryConstants.BROWSE_TEMPLATE_SAMPLES) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) javax.swing(javax.swing) Deployment(com.microsoft.azure.management.resources.Deployment) FileReader(java.io.FileReader) 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

Project (com.intellij.openapi.project.Project)2 MessageType (com.intellij.openapi.ui.MessageType)2 DeploymentMode (com.microsoft.azure.management.resources.DeploymentMode)2 NOTIFY_UPDATE_DEPLOYMENT_FAIL (com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_FAIL)2 NOTIFY_UPDATE_DEPLOYMENT_SUCCESS (com.microsoft.azure.toolkit.intellij.arm.action.UpdateDeploymentAction.NOTIFY_UPDATE_DEPLOYMENT_SUCCESS)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 AzureOperationBundle (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle)2 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)2 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)2 EventUtil (com.microsoft.azuretools.telemetrywrapper.EventUtil)2 UIUtils (com.microsoft.intellij.ui.util.UIUtils)2 DeploymentNode (com.microsoft.tooling.msservices.serviceexplorer.azure.arm.deployments.DeploymentNode)2 javax.swing (javax.swing)2 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 FileEditorManagerListener (com.intellij.openapi.fileEditor.FileEditorManagerListener)1 PsiAwareTextEditorImpl (com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl)1 PsiAwareTextEditorProvider (com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider)1 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)1