use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class CreateStorageAccountAction method create.
@AzureOperation(name = "storage|account.create", params = { "config.getName()" }, type = AzureOperation.Type.ACTION)
public static void create(final StorageAccountConfig config) {
final AzureString title = AzureOperationBundle.title("storage|account.create", config.getName());
AzureTaskManager.getInstance().runInBackground(title, () -> createStorageAccount(config));
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class CreateFunctionAppAction method createFunctionApp.
@AzureOperation(name = "function.create_detail", params = { "config.getName()" }, type = AzureOperation.Type.ACTION)
private Single<IFunctionApp> createFunctionApp(final FunctionAppConfig config) {
final AzureString title = title("function.create_detail", config.getName());
final IntellijAzureMessager actionMessenger = new IntellijAzureMessager() {
@Override
public boolean show(IAzureMessage raw) {
if (raw.getType() != IAzureMessage.Type.INFO) {
return super.show(raw);
}
return false;
}
};
final AzureTask<IFunctionApp> task = new AzureTask<>(null, title, false, () -> {
final Operation operation = TelemetryManager.createOperation(TelemetryConstants.FUNCTION, TelemetryConstants.CREATE_FUNCTION_APP);
operation.trackProperties(config.getTelemetryProperties());
try {
AzureMessager.getContext().setMessager(actionMessenger);
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.setIndeterminate(true);
return functionAppService.createFunctionApp(config);
} finally {
operation.trackProperties(AzureTelemetry.getActionContext().getProperties());
operation.complete();
}
});
return AzureTaskManager.getInstance().runInModalAsObservable(task).toSingle().doOnSuccess(app -> {
AzureMessager.getMessager().success(message("function.create.success.message", app.name()), message("function.create.success.title"));
this.refreshAzureExplorer(app);
});
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class FunctionDeploymentState method listFunctions.
// todo: Move to toolkit lib as shared task
private List<FunctionEntity> listFunctions(final IFunctionApp functionApp) {
final int[] count = { 0 };
final IAzureMessager azureMessager = AzureMessager.getMessager();
return Mono.fromCallable(() -> {
final AzureString message = count[0]++ == 0 ? AzureString.fromString(SYNCING_TRIGGERS) : AzureString.format(SYNCING_TRIGGERS_WITH_RETRY, count[0], LIST_TRIGGERS_MAX_RETRY);
azureMessager.info(message);
return Optional.ofNullable(functionApp.listFunctions(true)).filter(CollectionUtils::isNotEmpty).orElseThrow(() -> new AzureToolkitRuntimeException(NO_TRIGGERS_FOUNDED));
}).subscribeOn(Schedulers.boundedElastic()).retryWhen(Retry.fixedDelay(LIST_TRIGGERS_MAX_RETRY - 1, Duration.ofSeconds(LIST_TRIGGERS_RETRY_PERIOD_IN_SECONDS))).block();
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class OpenStorageExplorerAction method openStorageBrowser.
public static void openStorageBrowser(StorageAccount account) {
final AzureString title = AzureString.format("storage|account.open_storage_explorer", account.name());
AzureTaskManager.getInstance().runInBackground(new AzureTask<>(title, () -> {
final String url = account.portalUrl() + "/storageExplorer";
AzureActionManager.getInstance().getAction(ResourceCommonActionsContributor.OPEN_URL).handle(url);
}));
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class AddDependencyAction method onActionPerformed.
@Override
public boolean onActionPerformed(@NotNull AnActionEvent event, @Nullable Operation operation) {
final Module module = event.getData(LangDataKeys.MODULE);
final Project project = module.getProject();
final MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
final MavenProject mavenProject = projectsManager.findProject(module);
if (mavenProject == null) {
PluginUtil.showErrorNotificationProject(project, "Error", String.format("Project '%s' is not a maven project.", project.getName()));
return true;
}
final AzureString title = AzureOperationBundle.title("springcloud.update_dependency", project.getName());
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, true, () -> {
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
progressIndicator.setText("Syncing maven project " + project.getName());
final SettableFuture<Boolean> isDirty = SettableFuture.create();
AzureTaskManager.getInstance().runAndWait(() -> {
ProjectNotificationAware notificationAware = ProjectNotificationAware.getInstance(project);
isDirty.set(notificationAware.isNotificationVisible());
if (notificationAware.isNotificationVisible()) {
ExternalSystemProjectTracker projectTracker = ExternalSystemProjectTracker.getInstance(project);
projectTracker.scheduleProjectRefresh();
}
});
try {
if (isDirty.get().booleanValue()) {
projectsManager.forceUpdateProjects(Collections.singletonList(mavenProject)).get();
}
} catch (InterruptedException | ExecutionException e) {
PluginUtil.showErrorNotification("Error", "Failed to update project due to error: " + e.getMessage());
return;
}
try {
progressIndicator.setText("Check existing dependencies");
final String evaluateEffectivePom = MavenUtils.evaluateEffectivePom(project, mavenProject);
ProgressManager.checkCanceled();
if (StringUtils.isEmpty(evaluateEffectivePom)) {
PluginUtil.showErrorNotificationProject(project, "Error", "Failed to evaluate effective pom.");
return;
}
final String springBootVer = getMavenLibraryVersion(mavenProject, SPRING_BOOT_GROUP_ID, "spring-boot-autoconfigure");
if (StringUtils.isEmpty(springBootVer)) {
throw new AzureExecutionException(String.format("Module %s is not a spring-boot application.", module.getName()));
}
progressIndicator.setText("Get latest versions ...");
SpringCloudDependencyManager dependencyManager = new SpringCloudDependencyManager(evaluateEffectivePom);
Map<String, DependencyArtifact> versionMaps = dependencyManager.getDependencyVersions();
Map<String, DependencyArtifact> managerDependencyVersionsMaps = dependencyManager.getDependencyManagementVersions();
// given the spring-cloud-commons is greater or equal to 2.2.5.RELEASE, we should not add spring-cloud-starter-azure-spring-cloud-client
// because the code is already merged into spring repo: https://github.com/spring-cloud/spring-cloud-commons/pull/803
boolean noAzureSpringCloudClientDependency = shouldNotAddAzureSpringCloudClientDependency(versionMaps) || shouldNotAddAzureSpringCloudClientDependency(managerDependencyVersionsMaps);
ProgressManager.checkCanceled();
final List<DependencyArtifact> versionChanges = calculateVersionChanges(springBootVer, noAzureSpringCloudClientDependency, versionMaps);
if (versionChanges.isEmpty()) {
PluginUtil.showInfoNotificationProject(project, "Your project is update-to-date.", "No updates are needed.");
return;
}
progressIndicator.setText("Applying versions ...");
final File pomFile = new File(mavenProject.getFile().getCanonicalPath());
ProgressManager.checkCanceled();
if (applyVersionChanges(dependencyManager, pomFile, springBootVer, managerDependencyVersionsMaps, versionChanges)) {
noticeUserVersionChanges(project, pomFile, versionChanges);
} else {
PluginUtil.showInfoNotificationProject(project, "Your project is update-to-date.", "No updates are needed.");
}
} catch (DocumentException | IOException | AzureExecutionException | MavenProcessCanceledException e) {
PluginUtil.showErrorNotification("Error", "Failed to update Azure Spring Cloud dependencies due to error: " + e.getMessage());
}
}));
return false;
}
Aggregations