use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class Node method openResourcesInPortal.
@AzureOperation(name = "common.open_portal", params = { "nameFromResourceId(resourceId)" }, type = AzureOperation.Type.ACTION)
public void openResourcesInPortal(String subscriptionId, String resourceId) {
final AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
final String portalUrl = azureManager.getPortalUrl();
Subscription subscription = Azure.az(AzureAccount.class).account().getSubscription(subscriptionId);
final String url = portalUrl + REST_SEGMENT_JOB_MANAGEMENT_TENANTID + subscription.getTenantId() + REST_SEGMENT_JOB_MANAGEMENT_RESOURCE + resourceId;
DefaultLoader.getIdeHelper().openLinkInBrowser(url);
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class IDEHelperImpl method openAppServiceFile.
@AzureOperation(name = "appservice|file.open", params = { "target.getName()" }, type = AzureOperation.Type.SERVICE)
@SneakyThrows
public void openAppServiceFile(AppServiceFile target, Object context) {
final IAppService appService = target.getApp();
final FileEditorManager fileEditorManager = FileEditorManager.getInstance((Project) context);
final VirtualFile virtualFile = getOrCreateVirtualFile(target, fileEditorManager);
final OutputStream output = virtualFile.getOutputStream(null);
final AzureString title = AzureOperationBundle.title("appservice|file.open", virtualFile.getName());
final AzureTask<Void> task = new AzureTask<>(null, title, false, () -> {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.setIndeterminate(true);
indicator.setText2("Checking file existence");
final AppServiceFile file = appService.getFileByPath(target.getPath());
if (file == null) {
final String failureFileDeleted = String.format("Target file (%s) has been deleted", target.getName());
UIUtil.invokeLaterIfNeeded(() -> Messages.showWarningDialog(failureFileDeleted, "Open File"));
return;
}
indicator.setText2("Loading file content");
final String failure = String.format("Can not open file (%s). Try downloading it first and open it manually.", virtualFile.getName());
appService.getFileContent(file.getPath()).doOnComplete(() -> AzureTaskManager.getInstance().runLater(() -> {
final Consumer<String> contentSaver = content -> saveFileToAzure(target, content, fileEditorManager.getProject());
if (!openFileInEditor(contentSaver, virtualFile, fileEditorManager)) {
Messages.showWarningDialog(failure, "Open File");
}
}, AzureTask.Modality.NONE)).doAfterTerminate(() -> IOUtils.closeQuietly(output, null)).subscribe(bytes -> {
try {
if (bytes != null) {
output.write(bytes.array(), 0, bytes.limit());
}
} catch (final IOException e) {
final String error = "failed to load data into editor";
final String action = "try later or downloading it first";
throw new AzureToolkitRuntimeException(error, e, action);
}
}, IDEHelperImpl::onRxException);
});
AzureTaskManager.getInstance().runInModal(task);
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class WhatsNewAction method actionPerformed.
@Override
@AzureOperation(name = "common.load_whatsnew", type = AzureOperation.Type.ACTION)
public void actionPerformed(@Nonnull final AnActionEvent event) {
final boolean manually = !"AzurePluginStartupActivity".equals(event.getPlace());
final String content = getWhatsNewContent();
final DefaultArtifactVersion currentVersion = getVersion(content);
final DefaultArtifactVersion lastVersion = getLastVersion();
if (manually || compare(currentVersion, lastVersion)) {
saveVersion(currentVersion);
doShow(content, currentVersion, manually, Objects.requireNonNull(event.getProject()));
}
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AzureExplorerOpenAction method onActionPerformed.
@Override
@AzureOperation(name = "common|explorer.open", type = AzureOperation.Type.ACTION)
public boolean onActionPerformed(@NotNull AnActionEvent event, @Nullable Operation operation) {
Project project = DataKeys.PROJECT.getData(event.getDataContext());
ToolWindowManager.getInstance(project).getToolWindow(ServerExplorerToolWindowFactory.EXPLORER_WINDOW).activate(null);
return true;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class WebAppService method createWebApp.
@AzureOperation(name = "webapp.create_detail", params = { "config.getName()" }, type = AzureOperation.Type.SERVICE)
public IWebApp createWebApp(final WebAppConfig config) {
final WebAppSettingModel settings = convertConfig2Settings(config);
settings.setCreatingNew(true);
final Map<String, String> properties = settings.getTelemetryProperties(null);
final Operation operation = TelemetryManager.createOperation(WEBAPP, CREATE_WEBAPP);
try {
operation.start();
operation.trackProperties(properties);
return AzureWebAppMvpModel.getInstance().createWebAppFromSettingModel(settings);
} catch (final RuntimeException e) {
EventUtil.logError(operation, ErrorType.userError, e, properties, null);
throw e;
} finally {
operation.complete();
}
}
Aggregations