Skip to content

Commit e5a7ca2

Browse files
bugfix: the same Azure node shows in all submodules for a multi-module project.
1 parent c64f9b9 commit e5a7ca2

File tree

1 file changed

+8
-4
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-facet/src/main/java/com/microsoft/azure/toolkit/intellij/facet/projectexplorer

1 file changed

+8
-4
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-facet/src/main/java/com/microsoft/azure/toolkit/intellij/facet/projectexplorer/AzureFacetTreeStructureProvider.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@
3838
import java.awt.event.MouseEvent;
3939
import java.awt.event.MouseListener;
4040
import java.util.*;
41+
import java.util.concurrent.ConcurrentHashMap;
4142
import java.util.stream.Collectors;
4243

4344
import static com.intellij.ui.AnimatedIcon.ANIMATION_IN_RENDERER_ALLOWED;
4445

4546
@Slf4j
4647
public final class AzureFacetTreeStructureProvider implements TreeStructureProvider {
4748
private final Project myProject;
48-
private AzureFacetRootNode azureNode;
49+
private final Map<Module, AzureFacetRootNode> azureNodes = new ConcurrentHashMap<>();
4950

5051
public AzureFacetTreeStructureProvider(Project project) {
5152
myProject = project;
@@ -76,9 +77,12 @@ public Collection<AbstractTreeNode<?>> modify(@Nonnull AbstractTreeNode<?> paren
7677
.findAny().orElse(null);
7778
final List<AbstractTreeNode<?>> nodes = new LinkedList<>(children);
7879
nodes.removeIf(n -> Objects.equals(n, dotAzureDir));
79-
this.azureNode = Optional.ofNullable(this.azureNode).orElseGet(() -> new AzureFacetRootNode(azureModule, settings));
80-
Disposer.register(ProjectView.getInstance(this.myProject).getCurrentProjectViewPane(), this.azureNode);
81-
nodes.add(this.azureNode);
80+
final AzureFacetRootNode azureNode = this.azureNodes.computeIfAbsent(azureModule.getModule(), m -> {
81+
final AzureFacetRootNode node = new AzureFacetRootNode(azureModule, settings);
82+
Disposer.register(ProjectView.getInstance(this.myProject).getCurrentProjectViewPane(), node);
83+
return node;
84+
});
85+
nodes.add(azureNode);
8286
return nodes;
8387
} else {
8488
children.removeIf(c -> c instanceof AzureFacetRootNode);

0 commit comments

Comments
 (0)