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);
});
}));
}
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);
}
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;
}
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
}
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));
}
Aggregations