Search in sources :

Example 1 with AzureTaskManager

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

the class AzureResourceLabelView method onEvent.

public void onEvent(AzureEvent<Object> event) {
    final String type = event.getType();
    final Object source = event.getSource();
    if (source instanceof IAzureBaseResource && ((IAzureBaseResource<?, ?>) source).id().equals(this.resource.id())) {
        final AzureTaskManager tm = AzureTaskManager.getInstance();
        if ("common|resource.refresh".equals(type)) {
            if (((AzureOperationEvent) event).getStage() == AzureOperationEvent.Stage.AFTER) {
                tm.runLater(this::refreshChildren);
            }
        } else if ("common|resource.status_changed".equals(type)) {
            tm.runLater(this::refreshView);
        }
    }
}
Also used : IAzureBaseResource(com.microsoft.azure.toolkit.lib.common.entity.IAzureBaseResource) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)

Example 2 with AzureTaskManager

use of com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager 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)

Aggregations

AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)2 IActionsContributor (com.microsoft.azure.toolkit.ide.common.IActionsContributor)1 ResourceCommonActionsContributor (com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor)1 Action (com.microsoft.azure.toolkit.lib.common.action.Action)1 ActionGroup (com.microsoft.azure.toolkit.lib.common.action.ActionGroup)1 ActionView (com.microsoft.azure.toolkit.lib.common.action.ActionView)1 AzureActionManager (com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)1 IAzureBaseResource (com.microsoft.azure.toolkit.lib.common.entity.IAzureBaseResource)1 AzureOperationBundle.title (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title)1 SpringCloudApp (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1