Skip to content

Commit d97e829

Browse files
committed
Fix actions are missing in new created cosmos db account node
1 parent 8576288 commit d97e829

File tree

1 file changed

+20
-1
lines changed
  • Utils/azure-toolkit-ide-libs/azure-toolkit-ide-cosmos-lib/src/main/java/com/microsoft/azure/toolkit/ide/cosmos

1 file changed

+20
-1
lines changed

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-cosmos-lib/src/main/java/com/microsoft/azure/toolkit/ide/cosmos/CosmosNodeProvider.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
import com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView;
1212
import com.microsoft.azure.toolkit.ide.common.component.Node;
1313
import com.microsoft.azure.toolkit.ide.common.icon.AzureIcons;
14+
import com.microsoft.azure.toolkit.lib.AzService;
1415
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;
1518
import com.microsoft.azure.toolkit.lib.cosmos.AzureCosmosService;
1619
import com.microsoft.azure.toolkit.lib.cosmos.CosmosDBAccount;
1720
import com.microsoft.azure.toolkit.lib.cosmos.cassandra.CassandraCosmosDBAccount;
@@ -58,7 +61,7 @@ public Node<?> createNode(@NotNull Object data, @Nullable Node<?> parent, @NotNu
5861
final AzureCosmosService service = ((AzureCosmosService) data);
5962
final Function<AzureCosmosService, List<CosmosDBAccount>> listFunction = acs -> acs.list().stream().flatMap(m -> m.databaseAccounts().list().stream())
6063
.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))
6265
.actions(CosmosActionsContributor.SERVICE_ACTIONS)
6366
.addChildren(listFunction, (account, serviceNode) -> this.createNode(account, serviceNode, manager));
6467
} else if (data instanceof SqlCosmosDBAccount) {
@@ -132,6 +135,22 @@ public Node<?> createNode(@NotNull Object data, @Nullable Node<?> parent, @NotNu
132135
return null;
133136
}
134137

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+
135154
static class CosmosDBAccountLabelView<T extends CosmosDBAccount> extends AzureResourceLabelView<T> {
136155

137156
public CosmosDBAccountLabelView(@NotNull T resource) {

0 commit comments

Comments
 (0)