use of com.microsoft.azure.toolkit.lib.common.task.AzureTask in project azure-tools-for-java by Microsoft.
the class SignInCommandHandler method loginDeviceCodeSingle.
private static Single<DeviceCodeAccount> loginDeviceCodeSingle() {
final AzureString title = AzureOperationBundle.title("account.sign_in");
final AzureTask<DeviceCodeAccount> deviceCodeTask = new AzureTask<>(null, title, true, () -> {
final AzureAccount az = Azure.az(AzureAccount.class);
return (DeviceCodeAccount) checkCanceled(null, az.loginAsync(AuthType.DEVICE_CODE, true), () -> {
throw Lombok.sneakyThrow(new InterruptedException("user cancel"));
});
});
return AzureTaskManager.getInstance().runInBackgroundAsObservable(deviceCodeTask).toSingle();
}
use of com.microsoft.azure.toolkit.lib.common.task.AzureTask in project azure-tools-for-java by Microsoft.
the class AzureSignInAction method loginDeviceCodeSingle.
private static Single<DeviceCodeAccount> loginDeviceCodeSingle() {
final AzureString title = AzureOperationBundle.title("account.sign_in");
final AzureTask<DeviceCodeAccount> deviceCodeTask = new AzureTask<>(null, title, true, () -> {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.setIndeterminate(true);
final AzureAccount az = Azure.az(AzureAccount.class);
return (DeviceCodeAccount) checkCanceled(indicator, az.loginAsync(AuthType.DEVICE_CODE, true), () -> {
throw Lombok.sneakyThrow(new InterruptedException("user cancel"));
});
});
return AzureTaskManager.getInstance().runInBackgroundAsObservable(deviceCodeTask).toSingle();
}
use of com.microsoft.azure.toolkit.lib.common.task.AzureTask 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);
}
use of com.microsoft.azure.toolkit.lib.common.task.AzureTask in project azure-tools-for-java by Microsoft.
the class CreateWebAppAction method deploy.
@AzureOperation(name = "webapp.deploy_artifact", params = { "webapp.name()" }, type = AzureOperation.Type.ACTION)
private void deploy(final IWebApp webapp, final Path application, final Project project) {
final AzureString title = title("webapp.deploy_artifact", webapp.name());
final AzureTask<Void> task = new AzureTask<>(null, title, false, () -> {
ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
final RunProcessHandler processHandler = new RunProcessHandler();
processHandler.addDefaultListener();
final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
processHandler.startNotify();
consoleView.attachToProcess(processHandler);
AzureWebAppMvpModel.getInstance().deployArtifactsToWebApp(webapp, application.toFile(), true, processHandler);
});
AzureTaskManager.getInstance().runInModalAsObservable(task).single().subscribe((none) -> {
this.notifyDeploymentSuccess(webapp);
});
// let root exception handler to show the error.
}
use of com.microsoft.azure.toolkit.lib.common.task.AzureTask in project azure-tools-for-java by Microsoft.
the class SelectImageStep method fillImages.
private void fillImages() {
disableNext();
final AzureString title = AzureOperationBundle.title("vm|image.list");
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
progressIndicator.setIndeterminate(true);
VirtualMachineSku sku = (VirtualMachineSku) skuComboBox.getSelectedItem();
if (sku != null) {
RxJavaUtils.unsubscribeSubscription(fillImagesSubscription);
clearSelection(imageLabelList);
fillImagesSubscription = Observable.fromCallable(() -> sku.images().list()).subscribeOn(Schedulers.io()).subscribe(imageList -> DefaultLoader.getIdeHelper().invokeLater(() -> imageLabelList.setListData(imageList.toArray())), error -> {
String msg = String.format(ERROR_MESSAGE_LIST_IMAGES, String.format(message("webappExpMsg"), error.getMessage()));
handleError(msg, error);
});
}
}));
}
Aggregations