Search in sources :

Example 26 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString 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 27 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString 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)

Example 28 with AzureString

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

the class RefreshableNode method load.

public ListenableFuture<List<Node>> load(boolean forceRefresh) {
    initialized = true;
    final RefreshableNode node = this;
    final SettableFuture<List<Node>> future = SettableFuture.create();
    final AzureString title = AzureOperationBundle.title("common|node.load_content", node.getName());
    AzureTaskManager.getInstance().runInBackground(new AzureTask<>(getProject(), title, false, new Runnable() {

        @Override
        public void run() {
            if (!loading) {
                final String nodeName = node.getName();
                DefaultLoader.getIdeHelper().invokeLater(() -> updateName(nodeName + " (Refreshing...)", null));
                Futures.addCallback(future, new FutureCallback<List<Node>>() {

                    @Override
                    public void onSuccess(List<Node> nodes) {
                        DefaultLoader.getIdeHelper().invokeLater(() -> {
                            if (node.getName().endsWith("(Refreshing...)")) {
                                updateName(nodeName, null);
                            }
                            updateNodeNameAfterLoading();
                            expandNodeAfterLoading();
                        });
                    }

                    @Override
                    public void onFailure(Throwable throwable) {
                        DefaultLoader.getIdeHelper().invokeLater(() -> {
                            updateName(nodeName, throwable);
                            updateNodeNameAfterLoading();
                            expandNodeAfterLoading();
                        });
                    }
                }, MoreExecutors.directExecutor());
                node.refreshItems(future, forceRefresh);
            }
        }

        private void updateName(String name, final Throwable throwable) {
            node.setName(name);
            if (throwable != null) {
                AzureMessager.getMessager().error(throwable);
            }
        }
    }));
    return future;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 29 with AzureString

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

the class FunctionNode method loadActions.

@Override
protected void loadActions() {
    addAction("Trigger Function", new WrappedTelemetryNodeActionListener(FUNCTION, TRIGGER_FUNCTION, new NodeActionListener() {

        @Override
        @AzureOperation(name = "function|trigger.start", type = AzureOperation.Type.ACTION)
        protected void actionPerformed(NodeActionEvent e) {
            final AzureString title = AzureOperationBundle.title("function|trigger.start");
            AzureTaskManager.getInstance().runInBackground(new AzureTask<>(getProject(), title, false, () -> trigger()));
        }
    }));
// todo: find whether there is sdk to enable/disable trigger
}
Also used : WrappedTelemetryNodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener) WrappedTelemetryNodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 30 with AzureString

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

the class AppServiceFileNode method onNodeDblClicked.

@Override
public void onNodeDblClicked(Object context) {
    if (this.file.getType() == AppServiceFile.Type.DIRECTORY) {
        return;
    } else if (this.file.getSize() > SIZE_20MB) {
        DefaultLoader.getUIHelper().showError("File is too large, please download it first", "File is Too Large");
        return;
    }
    final Runnable runnable = () -> open(context);
    final AzureString title = AzureOperationBundle.title("appservice|file.get_content", file.getName(), file.getApp().name());
    AzureTaskManager.getInstance().runInBackground(new AzureTask(this.getProject(), title, false, runnable));
}
Also used : 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