Skip to content

Commit 3eb71f0

Browse files
Merge pull request #6267 from microsoft/bugfix-1894623
#1894623: [Test] The children nodes are out of order in new `Tree` based nodes(Azure Explorer, Resource Connection Explorer)
2 parents 60f49f4 + c58d7d6 commit 3eb71f0

File tree

7 files changed

+73
-11
lines changed

7 files changed

+73
-11
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/component/Tree.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import javax.swing.tree.TreeSelectionModel;
4040
import java.awt.event.MouseAdapter;
4141
import java.awt.event.MouseEvent;
42-
import java.util.Comparator;
4342
import java.util.List;
4443
import java.util.Objects;
4544
import java.util.stream.Stream;
@@ -169,9 +168,7 @@ protected synchronized void loadChildren() {
169168
tm.runOnPooledThread(() -> {
170169
try {
171170
final List<Node<?>> children = this.inner.getChildren();
172-
tm.runLater(() -> setChildren(children.stream()
173-
.sorted(Comparator.comparing(o -> o.view().getLabel()))
174-
.map(c -> new TreeNode<>(c, this.tree))));
171+
tm.runLater(() -> setChildren(children.stream().map(c -> new TreeNode<>(c, this.tree))));
175172
} catch (final Exception e) {
176173
this.setChildren(Stream.empty());
177174
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/intellij/ui/SignInWindow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private void checkAccountAvailability() {
101101
Mono.just(az).subscribeOn(Schedulers.boundedElastic())
102102
.flatMap(a -> a.checkAvailable().onErrorResume(e -> Mono.just(false)))
103103
.doFinally((s) -> {
104-
cliBtn.setText("Azure CLI");
104+
cliBtn.setText(cliBtn.isEnabled() ? "Azure CLI" : "Azure CLI (Not logged in)");
105105
cliDesc.setIcon(null);
106106
oauthBtn.setSelected(cliBtn.isSelected() && !cliBtn.isEnabled());
107107
updateSelection();

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-database-lib/src/main/java/com/microsoft/azure/toolkit/ide/database/postgre/PostgreSqlExplorerContributor.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
import com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView;
1010
import com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView;
1111
import com.microsoft.azure.toolkit.ide.common.component.Node;
12+
import com.microsoft.azure.toolkit.lib.common.entity.IAzureResource;
1213
import com.microsoft.azure.toolkit.lib.postgre.AzurePostgreSql;
14+
import com.microsoft.azure.toolkit.lib.postgre.PostgreSqlServer;
15+
16+
import javax.annotation.Nonnull;
17+
import java.util.Comparator;
18+
import java.util.List;
19+
import java.util.stream.Collectors;
1320

1421
import static com.microsoft.azure.toolkit.lib.Azure.az;
1522

@@ -22,8 +29,13 @@ public Node<?> getModuleNode() {
2229
final AzurePostgreSql service = az(AzurePostgreSql.class);
2330
return new Node<>(service).view(new AzureServiceLabelView<>(service, NAME, ICON))
2431
.actions(PostgreSqlActionsContributor.SERVICE_ACTIONS)
25-
.addChildren(AzurePostgreSql::list, (postgre, serviceNode) -> new Node<>(postgre)
32+
.addChildren(this::listPostgreServers, (postgre, serviceNode) -> new Node<>(postgre)
2633
.view(new AzureResourceLabelView<>(postgre))
2734
.actions(PostgreSqlActionsContributor.POSTGRE_ACTIONS));
2835
}
36+
37+
@Nonnull
38+
private List<PostgreSqlServer> listPostgreServers(AzurePostgreSql s) {
39+
return s.list().stream().sorted(Comparator.comparing(IAzureResource::name)).collect(Collectors.toList());
40+
}
2941
}

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-redis-lib/src/main/java/com/microsoft/azure/toolkit/ide/redis/RedisExplorerContributor.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
import com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView;
1111
import com.microsoft.azure.toolkit.ide.common.component.Node;
1212
import com.microsoft.azure.toolkit.lib.common.action.AzureActionManager;
13+
import com.microsoft.azure.toolkit.lib.common.entity.IAzureResource;
1314
import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager;
1415
import com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager;
1516
import com.microsoft.azure.toolkit.redis.AzureRedis;
17+
import com.microsoft.azure.toolkit.redis.RedisCache;
18+
19+
import javax.annotation.Nonnull;
20+
import java.util.Comparator;
21+
import java.util.List;
22+
import java.util.stream.Collectors;
1623

1724
import static com.microsoft.azure.toolkit.lib.Azure.az;
1825

@@ -28,8 +35,13 @@ public Node<?> getModuleNode() {
2835
final AzureRedis service = az(AzureRedis.class);
2936
return new Node<>(service).view(new AzureServiceLabelView<>(service, NAME, ICON))
3037
.actions(RedisActionsContributor.SERVICE_ACTIONS)
31-
.addChildren(AzureRedis::list, (redis, serviceNode) -> new Node<>(redis)
38+
.addChildren(this::listRedisCache, (redis, serviceNode) -> new Node<>(redis)
3239
.view(new AzureResourceLabelView<>(redis))
3340
.actions(RedisActionsContributor.REDIS_ACTIONS));
3441
}
42+
43+
@Nonnull
44+
private List<RedisCache> listRedisCache(AzureRedis s) {
45+
return s.list().stream().sorted(Comparator.comparing(IAzureResource::name)).collect(Collectors.toList());
46+
}
3547
}

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-springcloud-lib/src/main/java/com/microsoft/azure/toolkit/ide/springcloud/SpringCloudExplorerContributor.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@
1010
import com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView;
1111
import com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView;
1212
import com.microsoft.azure.toolkit.ide.common.component.Node;
13+
import com.microsoft.azure.toolkit.lib.common.entity.IAzureResource;
1314
import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager;
1415
import com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager;
1516
import com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud;
17+
import com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp;
1618
import com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster;
1719

20+
import javax.annotation.Nonnull;
21+
import java.util.Comparator;
22+
import java.util.List;
23+
import java.util.stream.Collectors;
24+
1825
import static com.microsoft.azure.toolkit.lib.Azure.az;
1926

2027
public class SpringCloudExplorerContributor implements IExplorerContributor {
@@ -30,11 +37,21 @@ public Node<?> getModuleNode() {
3037
final AzureSpringCloud service = az(AzureSpringCloud.class);
3138
return new Node<>(service).view(new AzureServiceLabelView<>(service, "Spring Cloud", ICON))
3239
.actions(SpringCloudActionsContributor.SERVICE_ACTIONS)
33-
.addChildren(AzureSpringCloud::clusters, (cluster, ascNode) -> new Node<>(cluster)
40+
.addChildren(this::listClusters, (cluster, ascNode) -> new Node<>(cluster)
3441
.view(new AzureResourceLabelView<>(cluster))
3542
.actions(SpringCloudActionsContributor.CLUSTER_ACTIONS)
36-
.addChildren(SpringCloudCluster::apps, (app, clusterNode) -> new Node<>(app)
43+
.addChildren(this::listApps, (app, clusterNode) -> new Node<>(app)
3744
.view(new AzureResourceLabelView<>(app))
3845
.actions(SpringCloudActionsContributor.APP_ACTIONS)));
3946
}
47+
48+
@Nonnull
49+
private List<SpringCloudApp> listApps(SpringCloudCluster c) {
50+
return c.apps().stream().sorted(Comparator.comparing(IAzureResource::name)).collect(Collectors.toList());
51+
}
52+
53+
@Nonnull
54+
private List<SpringCloudCluster> listClusters(AzureSpringCloud s) {
55+
return s.clusters().stream().sorted(Comparator.comparing(IAzureResource::name)).collect(Collectors.toList());
56+
}
4057
}

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-storage-lib/src/main/java/com/microsoft/azure/toolkit/ide/storage/StorageExplorerContributor.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
import com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView;
1111
import com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView;
1212
import com.microsoft.azure.toolkit.ide.common.component.Node;
13+
import com.microsoft.azure.toolkit.lib.common.entity.IAzureResource;
1314
import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager;
1415
import com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager;
1516
import com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount;
17+
import com.microsoft.azure.toolkit.lib.storage.service.StorageAccount;
18+
19+
import javax.annotation.Nonnull;
20+
import java.util.Comparator;
21+
import java.util.List;
22+
import java.util.stream.Collectors;
1623

1724
import static com.microsoft.azure.toolkit.lib.Azure.az;
1825

@@ -28,8 +35,13 @@ public Node<?> getModuleNode() {
2835
final AzureStorageAccount service = az(AzureStorageAccount.class);
2936
return new Node<>(service).view(new AzureServiceLabelView<>(service, NAME, ICON))
3037
.actions(StorageActionsContributor.SERVICE_ACTIONS)
31-
.addChildren(AzureStorageAccount::list, (account, storageNode) -> new Node<>(account)
38+
.addChildren(this::listStorageAccounts, (account, storageNode) -> new Node<>(account)
3239
.view(new AzureResourceLabelView<>(account))
3340
.actions(StorageActionsContributor.ACCOUNT_ACTIONS));
3441
}
42+
43+
@Nonnull
44+
private List<StorageAccount> listStorageAccounts(AzureStorageAccount s) {
45+
return s.list().stream().sorted(Comparator.comparing(IAzureResource::name)).collect(Collectors.toList());
46+
}
3547
}

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-vm-lib/src/main/java/com/microsoft/azure/toolkit/ide/vm/VirtualMachineExplorerContributor.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
import com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView;
1111
import com.microsoft.azure.toolkit.ide.common.component.Node;
1212
import com.microsoft.azure.toolkit.lib.Azure;
13+
import com.microsoft.azure.toolkit.lib.compute.AbstractAzureResource;
1314
import com.microsoft.azure.toolkit.lib.compute.vm.AzureVirtualMachine;
15+
import com.microsoft.azure.toolkit.lib.compute.vm.VirtualMachine;
16+
17+
import javax.annotation.Nonnull;
18+
import java.util.Comparator;
19+
import java.util.List;
20+
import java.util.stream.Collectors;
1421

1522
public class VirtualMachineExplorerContributor implements IExplorerContributor {
1623
private static final String NAME = "Virtual Machines";
@@ -21,8 +28,13 @@ public Node<?> getModuleNode() {
2128
final AzureVirtualMachine service = Azure.az(AzureVirtualMachine.class);
2229
return new Node<>(service).view(new AzureServiceLabelView<>(service, NAME, ICON))
2330
.actions(VirtualMachineActionsContributor.SERVICE_ACTIONS)
24-
.addChildren(AzureVirtualMachine::list, (vm, vmNode) -> new Node<>(vm)
31+
.addChildren(this::listVirtualMachines, (vm, vmNode) -> new Node<>(vm)
2532
.view(new AzureResourceLabelView<>(vm))
2633
.actions(VirtualMachineActionsContributor.VM_ACTIONS));
2734
}
35+
36+
@Nonnull
37+
private List<VirtualMachine> listVirtualMachines(AzureVirtualMachine s) {
38+
return s.list().stream().sorted(Comparator.comparing(AbstractAzureResource::name)).collect(Collectors.toList());
39+
}
2840
}

0 commit comments

Comments
 (0)