Search in sources :

Example 6 with AzureActionManager

use of com.microsoft.azure.toolkit.lib.common.action.AzureActionManager 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

AzureActionManager (com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)6 IActionsContributor (com.microsoft.azure.toolkit.ide.common.IActionsContributor)2 ResourceCommonActionsContributor (com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor)2 Action (com.microsoft.azure.toolkit.lib.common.action.Action)2 ActionView (com.microsoft.azure.toolkit.lib.common.action.ActionView)2 IAzureMessager (com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager)2 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)2 AzureStorageAccount (com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount)2 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 IExplorerContributor (com.microsoft.azure.toolkit.ide.common.IExplorerContributor)1 AzureResourceLabelView (com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView)1 AzureServiceLabelView (com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView)1 Node (com.microsoft.azure.toolkit.ide.common.component.Node)1 AzureServiceResource (com.microsoft.azure.toolkit.intellij.connector.AzureServiceResource)1 ConnectorDialog (com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog)1