use of com.microsoft.azure.toolkit.lib.common.action.Action in project azure-tools-for-java by Microsoft.
the class CreateWebAppAction method openDialog.
@AzureOperation(name = "webapp.open_creation_dialog", type = AzureOperation.Type.ACTION)
private void openDialog(final Project project, @Nullable final WebAppConfig data) {
final WebAppCreationDialog dialog = new WebAppCreationDialog(project);
if (Objects.nonNull(data)) {
dialog.setData(data);
}
dialog.setOkActionListener((config) -> {
dialog.close();
this.createWebApp(config).subscribe(webapp -> {
final Path artifact = config.getApplication();
if (Objects.nonNull(artifact) && artifact.toFile().exists()) {
AzureTaskManager.getInstance().runLater("deploy", () -> deploy(webapp, artifact, project));
}
}, (error) -> {
final String title = String.format("Reopen dialog \"%s\"", dialog.getTitle());
final Consumer<Object> act = t -> AzureTaskManager.getInstance().runLater("open dialog", () -> this.openDialog(project, config));
final Action<?> action = new Action<>(act, new ActionView.Builder(title));
AzureMessager.getMessager().error(error, null, action);
});
});
dialog.show();
}
use of com.microsoft.azure.toolkit.lib.common.action.Action in project azure-tools-for-java by Microsoft.
the class CreateFunctionAppAction method openDialog.
@AzureOperation(name = "function.open_creation_dialog", type = AzureOperation.Type.ACTION)
private void openDialog(final Project project, @Nullable final FunctionAppConfig data) {
final FunctionAppCreationDialog dialog = new FunctionAppCreationDialog(project);
if (Objects.nonNull(data)) {
dialog.setData(data);
}
dialog.setOkActionListener((config) -> {
dialog.close();
this.createFunctionApp(config).subscribe(functionApp -> {
}, (error) -> {
final String title = String.format("Reopen dialog \"%s\"", dialog.getTitle());
final Consumer<Object> act = t -> AzureTaskManager.getInstance().runLater("open dialog", () -> this.openDialog(project, config));
final Action<?> action = new Action<>(act, new ActionView.Builder(title));
AzureMessager.getMessager().error(error, null, action);
});
});
dialog.show();
}
use of com.microsoft.azure.toolkit.lib.common.action.Action in project azure-tools-for-java by Microsoft.
the class SpringCloudActionsContributor method registerActions.
@Override
public void registerActions(AzureActionManager am) {
final AzureTaskManager tm = AzureTaskManager.getInstance();
final Consumer<SpringCloudApp> openPublicUrl = s -> am.getAction(ResourceCommonActionsContributor.OPEN_URL).handle(s.publicUrl());
final ActionView.Builder openPublicUrlView = new ActionView.Builder("Access Public Endpoint", "/icons/action/browser.svg").title(s -> Optional.ofNullable(s).map(r -> title("springcloud|app.open_public_url", ((SpringCloudApp) r).name())).orElse(null)).enabled(s -> s instanceof SpringCloudApp && ((SpringCloudApp) s).entity().isPublic());
am.registerAction(OPEN_PUBLIC_URL, new Action<>(openPublicUrl, openPublicUrlView));
final Consumer<SpringCloudApp> openTestUrl = s -> am.getAction(ResourceCommonActionsContributor.OPEN_URL).handle(s.testUrl());
final ActionView.Builder openTestUrlView = new ActionView.Builder("Access Test Endpoint", "/icons/action/browser.svg").title(s -> Optional.ofNullable(s).map(r -> title("springcloud|app.open_test_url", ((SpringCloudApp) r).name())).orElse(null)).enabled(s -> s instanceof SpringCloudApp);
am.registerAction(OPEN_TEST_URL, new Action<>(openTestUrl, openTestUrlView));
final ActionView.Builder streamLogView = new ActionView.Builder("Streaming Log", "/icons/action/log.svg").title(s -> Optional.ofNullable(s).map(r -> title("springcloud|app.stream_log", ((SpringCloudApp) r).name())).orElse(null)).enabled(s -> s instanceof SpringCloudApp);
am.registerAction(STREAM_LOG, new Action<>(streamLogView));
}
use of com.microsoft.azure.toolkit.lib.common.action.Action in project azure-tools-for-java by Microsoft.
the class WhatsNewAction method doShow.
private static void doShow(String content, DefaultArtifactVersion version, boolean manually, @Nonnull Project project) {
final FileEditorManager manager = FileEditorManager.getInstance(project);
final VirtualFile file = Arrays.stream(manager.getOpenFiles()).filter(f -> StringUtils.equals(f.getUserData(CONTENT_KEY), CONTENT_PATH)).findFirst().orElse(createVirtualFile(content));
AzureTaskManager.getInstance().runAndWait(() -> {
if (project.isDisposed()) {
return;
}
file.putUserData(TextEditorWithPreview.DEFAULT_LAYOUT_FOR_FILE, TextEditorWithPreview.Layout.SHOW_PREVIEW);
final FileEditor[] editors = manager.openFile(file, true, true);
if (editors.length < 1) {
if (manually) {
BrowserUtil.browse(WHATSNEW_URL);
} else {
final String message = String.format("Azure Toolkit for Java is updated to <b><u>%s</u></b>", version.toString());
final String title = "Azure Toolkit for Java Updated";
final AzureActionManager am = AzureActionManager.getInstance();
final Action<?> changelog = new Action<>((n) -> am.getAction(OPEN_URL).handle(WHATSNEW_URL), new ActionView.Builder("What's New"));
AzureMessager.getMessager().info(message, title, changelog);
}
}
});
}
Aggregations