|
11 | 11 | import com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView; |
12 | 12 | import com.microsoft.azure.toolkit.ide.common.component.Node; |
13 | 13 | import com.microsoft.azure.toolkit.ide.common.icon.AzureIcons; |
| 14 | +import com.microsoft.azure.toolkit.lib.AzService; |
14 | 15 | import com.microsoft.azure.toolkit.lib.Azure; |
| 16 | +import com.microsoft.azure.toolkit.lib.common.event.AzureEvent; |
| 17 | +import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager; |
15 | 18 | import com.microsoft.azure.toolkit.lib.cosmos.AzureCosmosService; |
16 | 19 | import com.microsoft.azure.toolkit.lib.cosmos.CosmosDBAccount; |
17 | 20 | import com.microsoft.azure.toolkit.lib.cosmos.cassandra.CassandraCosmosDBAccount; |
@@ -58,7 +61,7 @@ public Node<?> createNode(@NotNull Object data, @Nullable Node<?> parent, @NotNu |
58 | 61 | final AzureCosmosService service = ((AzureCosmosService) data); |
59 | 62 | final Function<AzureCosmosService, List<CosmosDBAccount>> listFunction = acs -> acs.list().stream().flatMap(m -> m.databaseAccounts().list().stream()) |
60 | 63 | .collect(Collectors.toList()); |
61 | | - return new Node<>(service).view(new AzureServiceLabelView<>(service, NAME, ICON)) |
| 64 | + return new Node<>(service).view(new AzureCosmosServiceLabelView(service, NAME, ICON)) |
62 | 65 | .actions(CosmosActionsContributor.SERVICE_ACTIONS) |
63 | 66 | .addChildren(listFunction, (account, serviceNode) -> this.createNode(account, serviceNode, manager)); |
64 | 67 | } else if (data instanceof SqlCosmosDBAccount) { |
@@ -132,6 +135,22 @@ public Node<?> createNode(@NotNull Object data, @Nullable Node<?> parent, @NotNu |
132 | 135 | return null; |
133 | 136 | } |
134 | 137 |
|
| 138 | + static class AzureCosmosServiceLabelView extends AzureServiceLabelView<AzureCosmosService> { |
| 139 | + |
| 140 | + public AzureCosmosServiceLabelView(@NotNull AzureCosmosService service, String label, String iconPath) { |
| 141 | + super(service, label, iconPath); |
| 142 | + } |
| 143 | + |
| 144 | + @Override |
| 145 | + public void onEvent(AzureEvent event) { |
| 146 | + final Object source = event.getSource(); |
| 147 | + final AzureTaskManager tm = AzureTaskManager.getInstance(); |
| 148 | + if (source instanceof AzService && source.equals(this.getService())) { |
| 149 | + tm.runLater(this::refreshChildren); |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + |
135 | 154 | static class CosmosDBAccountLabelView<T extends CosmosDBAccount> extends AzureResourceLabelView<T> { |
136 | 155 |
|
137 | 156 | public CosmosDBAccountLabelView(@NotNull T resource) { |
|
0 commit comments