Search in sources :

Example 1 with Action

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();
}
Also used : Path(java.nio.file.Path) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) AzureBundle.message(com.microsoft.intellij.ui.messages.AzureBundle.message) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Single(rx.Single) AzureOperationBundle.title(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title) Project(com.intellij.openapi.project.Project) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) TextConsoleBuilderFactory(com.intellij.execution.filters.TextConsoleBuilderFactory) AzureWebAppMvpModel(com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel) Path(java.nio.file.Path) Notifications(com.intellij.notification.Notifications) ProgressManager(com.intellij.openapi.progress.ProgressManager) WebAppConfig(com.microsoft.azure.toolkit.lib.webapp.WebAppConfig) AzureActionEnum(com.microsoft.tooling.msservices.serviceexplorer.AzureActionEnum) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) WebAppModule(com.microsoft.tooling.msservices.serviceexplorer.azure.webapp.WebAppModule) WebAppCreationDialog(com.microsoft.azure.toolkit.intellij.webapp.WebAppCreationDialog) AzureMessager(com.microsoft.azure.toolkit.lib.common.messager.AzureMessager) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) RunProcessHandler(com.microsoft.intellij.RunProcessHandler) NotificationType(com.intellij.notification.NotificationType) Objects(java.util.Objects) Consumer(java.util.function.Consumer) Notification(com.intellij.notification.Notification) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) WebAppService(com.microsoft.azure.toolkit.lib.webapp.WebAppService) ConsoleView(com.intellij.execution.ui.ConsoleView) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) Action(com.microsoft.azure.toolkit.lib.common.action.Action) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) Action(com.microsoft.azure.toolkit.lib.common.action.Action) WebAppCreationDialog(com.microsoft.azure.toolkit.intellij.webapp.WebAppCreationDialog) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with Action

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();
}
Also used : FunctionAppCreationDialog(com.microsoft.azure.toolkit.intellij.function.FunctionAppCreationDialog) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) AzureBundle.message(com.microsoft.intellij.ui.messages.AzureBundle.message) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) IntellijAzureMessager(com.microsoft.azure.toolkit.intellij.common.messager.IntellijAzureMessager) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Single(rx.Single) AzureOperationBundle.title(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title) Project(com.intellij.openapi.project.Project) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) FunctionAppService(com.microsoft.azure.toolkit.lib.function.FunctionAppService) ProgressManager(com.intellij.openapi.progress.ProgressManager) AzureActionEnum(com.microsoft.tooling.msservices.serviceexplorer.AzureActionEnum) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) AzureMessager(com.microsoft.azure.toolkit.lib.common.messager.AzureMessager) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable) IAzureMessage(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessage) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) Name(com.microsoft.tooling.msservices.helpers.Name) FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig) AzureTelemetry(com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetry) Objects(java.util.Objects) Consumer(java.util.function.Consumer) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) FunctionModule(com.microsoft.tooling.msservices.serviceexplorer.azure.function.FunctionModule) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) Action(com.microsoft.azure.toolkit.lib.common.action.Action) TelemetryManager(com.microsoft.azuretools.telemetrywrapper.TelemetryManager) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) Action(com.microsoft.azure.toolkit.lib.common.action.Action) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) FunctionAppCreationDialog(com.microsoft.azure.toolkit.intellij.function.FunctionAppCreationDialog) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 3 with Action

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));
}
Also used : ActionGroup(com.microsoft.azure.toolkit.lib.common.action.ActionGroup) Consumer(java.util.function.Consumer) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) IActionsContributor(com.microsoft.azure.toolkit.ide.common.IActionsContributor) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) ResourceCommonActionsContributor(com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor) Action(com.microsoft.azure.toolkit.lib.common.action.Action) AzureOperationBundle.title(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title) Optional(java.util.Optional) SpringCloudApp(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) SpringCloudApp(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp)

Example 4 with Action

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);
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) AnAction(com.intellij.openapi.actionSystem.AnAction) Action(com.microsoft.azure.toolkit.lib.common.action.Action) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)

Aggregations

Action (com.microsoft.azure.toolkit.lib.common.action.Action)4 ActionView (com.microsoft.azure.toolkit.lib.common.action.ActionView)4 AzureOperationBundle.title (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title)3 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)3 Consumer (java.util.function.Consumer)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 Project (com.intellij.openapi.project.Project)2 AzureActionManager (com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 AzureMessager (com.microsoft.azure.toolkit.lib.common.messager.AzureMessager)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)2 Nullable (com.microsoft.azuretools.azurecommons.helpers.Nullable)2 AzureUIRefreshCore (com.microsoft.azuretools.utils.AzureUIRefreshCore)2 AzureUIRefreshEvent (com.microsoft.azuretools.utils.AzureUIRefreshEvent)2 AzureSignInAction (com.microsoft.intellij.actions.AzureSignInAction)2 AzureBundle.message (com.microsoft.intellij.ui.messages.AzureBundle.message)2 AzureActionEnum (com.microsoft.tooling.msservices.serviceexplorer.AzureActionEnum)2 NodeActionEvent (com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)2