Skip to content

Commit e7ca310

Browse files
Merge pull request #6799 from microsoft/fix-endgame-202207
Resolve issues in july endgame
2 parents 3036edd + bf8e8da commit e7ca310

4 files changed

Lines changed: 32 additions & 15 deletions

File tree

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-guidance/src/main/java/com/microsoft/azure/toolkit/ide/guidance/GuidanceViewManager.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ public void openCourseView(@Nonnull final Project project, @Nonnull final Course
3535
AzureTaskManager.getInstance().runLater(() -> {
3636
assert toolWindow != null;
3737
toolWindow.setAvailable(true);
38-
final GuidanceView guidanceView = GuidanceViewFactory.getGuidanceView(project);
39-
if (Objects.nonNull(guidanceView)) {
40-
final Course course = new Course(courseConfig, project);
41-
guidanceView.showCourseView(course);
42-
}
43-
toolWindow.activate(null);
38+
toolWindow.activate(() -> {
39+
final GuidanceView guidanceView = GuidanceViewFactory.getGuidanceView(project);
40+
if (Objects.nonNull(guidanceView)) {
41+
final Course course = new Course(courseConfig, project);
42+
guidanceView.showCourseView(course);
43+
}
44+
});
4445
});
4546
}
4647

@@ -49,12 +50,13 @@ public void showCoursesView(@Nonnull final Project project) {
4950
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(GuidanceViewManager.TOOL_WINDOW_ID);
5051
AzureTaskManager.getInstance().runLater(() -> {
5152
assert toolWindow != null;
52-
toolWindow.setAvailable(true);
53-
final GuidanceView guidanceView = GuidanceViewFactory.getGuidanceView(project);
54-
if (Objects.nonNull(guidanceView)) {
55-
guidanceView.showCoursesView();
56-
}
57-
toolWindow.activate(null);
53+
toolWindow.activate(() -> {
54+
toolWindow.setAvailable(true);
55+
final GuidanceView guidanceView = GuidanceViewFactory.getGuidanceView(project);
56+
if (Objects.nonNull(guidanceView)) {
57+
guidanceView.showCoursesView();
58+
}
59+
});
5860
});
5961
}
6062

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ private void refreshChildrenView() {
150150
@Override
151151
@AzureOperation(name = "common.load_children.node", params = "this.getLabel()", type = AzureOperation.Type.ACTION)
152152
public synchronized void refreshChildren(boolean... incremental) {
153+
Optional.ofNullable(this.inner).ifPresent(ignore -> this.setAllowsChildren(inner.hasChildren()));
153154
if (this.getAllowsChildren() && BooleanUtils.isNotFalse(this.loaded)) {
154155
final DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel();
155156
if (incremental.length > 0 && incremental[0] && Objects.nonNull(model)) {
@@ -161,6 +162,9 @@ public synchronized void refreshChildren(boolean... incremental) {
161162
}
162163
this.loaded = null;
163164
this.loadChildren(incremental);
165+
} else if (!this.getAllowsChildren()) {
166+
this.removeAllChildren();
167+
this.refreshChildrenView();
164168
}
165169
}
166170

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-appservice-lib/src/main/java/com/microsoft/azure/toolkit/ide/appservice/file/AppServiceFileActionsContributor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void registerGroups(AzureActionManager am) {
4646

4747
@Override
4848
public void registerActions(AzureActionManager am) {
49-
final Consumer<AppServiceFile> refresh = file -> AzureEventBus.emit("resource.refresh.resource", file);
49+
final Consumer<AppServiceFile> refresh = file -> AzureEventBus.emit("resource.refreshed.resource", file);
5050
final ActionView.Builder refreshView = new ActionView.Builder("Refresh", AzureIcons.Action.REFRESH.getIconPath())
5151
.title(s -> Optional.ofNullable(s).map(r -> description("resource.refresh.resource", ((AppServiceFile) r).getName())).orElse(null))
5252
.enabled(s -> s instanceof AppServiceFile);

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-appservice-lib/src/main/java/com/microsoft/azure/toolkit/ide/appservice/file/AppServiceFileNode.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public AppServiceFileNode(@Nonnull AppServiceFile data) {
6868

6969
@Override
7070
public boolean hasChildren() {
71-
return file.getType() == AppServiceFile.Type.DIRECTORY;
71+
return file.getType() == AppServiceFile.Type.DIRECTORY && appService.getFormalStatus().isRunning();
7272
}
7373

7474
@Override
@@ -87,6 +87,7 @@ static class AppServiceFileLabelView implements NodeView {
8787
@Getter
8888
private final AppServiceFile file;
8989
private final AzureEventBus.EventListener listener;
90+
private final AzureEventBus.EventListener appStatusListener;
9091

9192
@Nullable
9293
@Setter
@@ -96,14 +97,23 @@ static class AppServiceFileLabelView implements NodeView {
9697
public AppServiceFileLabelView(@Nonnull AppServiceFile file) {
9798
this.file = file;
9899
this.listener = new AzureEventBus.EventListener(this::onEvent);
100+
this.appStatusListener= new AzureEventBus.EventListener(this::onAppStatusChanged);
99101
AzureEventBus.on("resource.refreshed.resource", listener);
102+
AzureEventBus.on("resource.status_changed.resource", appStatusListener);
100103
this.refreshView();
101104
}
102105

106+
private void onAppStatusChanged(AzureEvent event) {
107+
final Object source = event.getSource();
108+
if ((source instanceof AppServiceAppBase && StringUtils.equalsIgnoreCase(((AppServiceAppBase<?, ?, ?>) source).getId(), this.file.getApp().getId()))) {
109+
AzureTaskManager.getInstance().runLater(this::refreshChildren);
110+
}
111+
}
112+
103113
private void onEvent(AzureEvent event) {
104114
final String type = event.getType();
105115
final Object source = event.getSource();
106-
if (source instanceof AppServiceFile && StringUtils.equalsIgnoreCase(((AppServiceFile) source).getFullName(), this.file.getFullName())) {
116+
if ((source instanceof AppServiceFile && StringUtils.equalsIgnoreCase(((AppServiceFile) source).getFullName(), this.file.getFullName()))) {
107117
AzureTaskManager.getInstance().runLater(this::refreshChildren);
108118
}
109119
}
@@ -140,6 +150,7 @@ private static String formatDateTime(@Nullable final String dateTime) {
140150
@Override
141151
public void dispose() {
142152
AzureEventBus.off("resource.refreshed.resource", listener);
153+
AzureEventBus.off("resource.status_changed.resource", appStatusListener);
143154
this.refresher = null;
144155
}
145156
}

0 commit comments

Comments
 (0)