Search in sources :

Example 1 with AzureActionManager

use of com.microsoft.azure.toolkit.lib.common.action.AzureActionManager in project azure-tools-for-java by Microsoft.

the class SpringCloudExplorerContributor method getModuleNode.

@Override
public Node<?> getModuleNode() {
    final AzureActionManager am = AzureActionManager.getInstance();
    final IAzureMessager messager = AzureMessager.getDefaultMessager();
    final AzureSpringCloud service = az(AzureSpringCloud.class);
    return new Node<>(service).view(new AzureServiceLabelView<>(service, "Spring Cloud", ICON)).actions(SpringCloudActionsContributor.SERVICE_ACTIONS).addChildren(AzureSpringCloud::clusters, (cluster, ascNode) -> new Node<>(cluster).view(new AzureResourceLabelView<>(cluster)).actions(SpringCloudActionsContributor.CLUSTER_ACTIONS).addChildren(SpringCloudCluster::apps, (app, clusterNode) -> new Node<>(app).view(new AzureResourceLabelView<>(app)).actions(SpringCloudActionsContributor.APP_ACTIONS)));
}
Also used : IExplorerContributor(com.microsoft.azure.toolkit.ide.common.IExplorerContributor) AzureResourceLabelView(com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView) AzureServiceLabelView(com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView) SpringCloudCluster(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster) Azure.az(com.microsoft.azure.toolkit.lib.Azure.az) IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureMessager(com.microsoft.azure.toolkit.lib.common.messager.AzureMessager) AzureSpringCloud(com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud) Node(com.microsoft.azure.toolkit.ide.common.component.Node) IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) Node(com.microsoft.azure.toolkit.ide.common.component.Node) AzureResourceLabelView(com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureSpringCloud(com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud)

Example 2 with AzureActionManager

use of com.microsoft.azure.toolkit.lib.common.action.AzureActionManager in project azure-tools-for-java by Microsoft.

the class StorageExplorerContributor method getModuleNode.

@Override
public Node<?> getModuleNode() {
    final AzureActionManager am = AzureActionManager.getInstance();
    final IAzureMessager messager = AzureMessager.getDefaultMessager();
    final AzureStorageAccount service = az(AzureStorageAccount.class);
    return new Node<>(service).view(new AzureServiceLabelView<>(service, NAME, ICON)).actions(StorageActionsContributor.SERVICE_ACTIONS).addChildren(AzureStorageAccount::list, (account, storageNode) -> new Node<>(account).view(new AzureResourceLabelView<>(account)).actions(StorageActionsContributor.ACCOUNT_ACTIONS));
}
Also used : IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)

Example 3 with AzureActionManager

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

use of com.microsoft.azure.toolkit.lib.common.action.AzureActionManager in project azure-tools-for-java by Microsoft.

the class IntellijStorageActionsContributor method registerHandlers.

@Override
public void registerHandlers(AzureActionManager am) {
    final BiPredicate<Object, AnActionEvent> condition = (r, e) -> r instanceof AzureStorageAccount;
    final BiConsumer<Object, AnActionEvent> handler = (c, e) -> CreateStorageAccountAction.createStorageAccount((e.getProject()));
    am.registerHandler(ResourceCommonActionsContributor.CREATE, condition, handler);
    am.<IAzureResource<?>, AnActionEvent>registerHandler(ResourceCommonActionsContributor.CONNECT, (r, e) -> r instanceof StorageAccount, (r, e) -> AzureTaskManager.getInstance().runLater(() -> {
        final ConnectorDialog dialog = new ConnectorDialog(e.getProject());
        dialog.setResource(new AzureServiceResource<>(((StorageAccount) r), StorageAccountResourceDefinition.INSTANCE));
        dialog.show();
    }));
}
Also used : AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureServiceResource(com.microsoft.azure.toolkit.intellij.connector.AzureServiceResource) CreateStorageAccountAction(com.microsoft.azure.toolkit.intellij.storage.creation.CreateStorageAccountAction) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) StorageAccountResourceDefinition(com.microsoft.azure.toolkit.intellij.storage.connection.StorageAccountResourceDefinition) BiPredicate(java.util.function.BiPredicate) IActionsContributor(com.microsoft.azure.toolkit.ide.common.IActionsContributor) ResourceCommonActionsContributor(com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) BiConsumer(java.util.function.BiConsumer) ConnectorDialog(com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog) IAzureResource(com.microsoft.azure.toolkit.lib.common.entity.IAzureResource) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) ConnectorDialog(com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) AzureServiceResource(com.microsoft.azure.toolkit.intellij.connector.AzureServiceResource) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) IAzureResource(com.microsoft.azure.toolkit.lib.common.entity.IAzureResource)

Example 5 with AzureActionManager

use of com.microsoft.azure.toolkit.lib.common.action.AzureActionManager in project azure-tools-for-java by Microsoft.

the class AzureSdkEnforcer method warnDeprecatedLibs.

@AzureOperation(name = "sdk|deprecated_libs.warn", type = AzureOperation.Type.ACTION)
private static void warnDeprecatedLibs(@AzureTelemetry.Property List<? extends AzureJavaSdkEntity> deprecatedLibs) {
    final String message = buildMessage(deprecatedLibs);
    final AzureActionManager am = AzureActionManager.getInstance();
    final Action<?> referenceBook = am.getAction(Action.Id.of(OpenReferenceBookAction.ID));
    final Action<?> neverShowAgain = am.getAction(Action.Id.of(IntellijNeverShowAgainAction.ID));
    AzureMessager.getMessager().warning(message, "Deprecated Azure SDK libraries Detected", referenceBook, neverShowAgain);
}
Also used : AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

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