Skip to content

Commit c0ca9e9

Browse files
Merge pull request #6647 from microsoft/miller/fix-bugs
fix miscellaneous bugs
2 parents 1b2e283 + 776607d commit c0ca9e9

File tree

6 files changed

+36
-28
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij
    • azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/appservice
    • azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/component
    • azure-intellij-plugin-springcloud/src/main/java/com/microsoft/azure/toolkit/intellij/springcloud/component
  • Utils/azure-toolkit-ide-libs

6 files changed

+36
-28
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoAdvancedPanel.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.microsoft.azure.toolkit.lib.resource.ResourceGroupConfig;
3131
import com.microsoft.azuretools.utils.WebAppUtils;
3232
import org.apache.commons.compress.utils.FileNameUtils;
33-
import org.apache.commons.lang3.ObjectUtils;
3433
import org.apache.commons.lang3.StringUtils;
3534

3635
import javax.swing.*;
@@ -97,8 +96,11 @@ public T getValue() {
9796
config.setRuntime(runtime);
9897
config.setRegion(region);
9998
final AppServicePlanConfig planConfig = AppServicePlanConfig.fromResource(servicePlan);
100-
planConfig.setResourceGroupName(StringUtils.firstNonBlank(planConfig.getResourceGroupName(), config.getResourceGroupName()));
101-
planConfig.setRegion(ObjectUtils.firstNonNull(planConfig.getRegion(), config.getRegion()));
99+
if (Objects.nonNull(planConfig) && servicePlan.isDraftForCreating()) {
100+
planConfig.setResourceGroupName(config.getResourceGroupName());
101+
planConfig.setRegion(region);
102+
planConfig.setOs(Objects.requireNonNull(runtime).getOperatingSystem());
103+
}
102104
config.setServicePlan(planConfig);
103105
if (Objects.nonNull(artifact)) {
104106
final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.project);

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

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,33 @@ public IView.Label getInlineActionView() {
126126

127127
@Override
128128
public void refreshView() {
129-
if (this.getParent() != null) {
130-
((DefaultTreeModel) this.tree.getModel()).nodeChanged(this);
129+
synchronized (this.tree) {
130+
final DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel();
131+
if (Objects.nonNull(this.getParent()) && Objects.nonNull(model)) {
132+
model.nodeChanged(this);
133+
}
134+
}
135+
}
136+
137+
private void refreshChildrenView() {
138+
synchronized (this.tree) {
139+
final DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel();
140+
if (Objects.nonNull(this.getParent()) && Objects.nonNull(model)) {
141+
model.nodeStructureChanged(this);
142+
}
131143
}
132144
}
133145

134146
@Override
135147
public synchronized void refreshChildren(boolean... incremental) {
136148
if (this.getAllowsChildren() && BooleanUtils.isNotFalse(this.loaded)) {
137149
final DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel();
138-
if (incremental.length > 0 && incremental[0]) {
150+
if (incremental.length > 0 && incremental[0] && Objects.nonNull(model)) {
139151
model.insertNodeInto(new LoadingNode(), this, 0);
140152
} else {
141153
this.removeAllChildren();
142154
this.add(new LoadingNode());
143-
if (Objects.nonNull(this.getParent())) {
144-
((DefaultTreeModel) this.tree.getModel()).nodeStructureChanged(this);
145-
}
155+
this.refreshChildrenView();
146156
}
147157
this.loaded = null;
148158
this.loadChildren(incremental);
@@ -169,9 +179,7 @@ private synchronized void setChildren(List<Node<?>> children) {
169179
this.removeAllChildren();
170180
children.stream().map(c -> new TreeNode<>(c, this.tree)).forEach(this::add);
171181
this.loaded = true;
172-
if (Objects.nonNull(this.getParent())) {
173-
((DefaultTreeModel) this.tree.getModel()).nodeStructureChanged(this);
174-
}
182+
this.refreshChildrenView();
175183
}
176184

177185
private synchronized void updateChildren(List<Node<?>> children) {
@@ -195,22 +203,20 @@ private synchronized void updateChildren(List<Node<?>> children) {
195203
}
196204
}
197205
this.remove(0);
198-
if (Objects.nonNull(this.getParent())) {
199-
((DefaultTreeModel) this.tree.getModel()).nodeStructureChanged(this);
200-
}
206+
this.refreshChildrenView();
201207
Optional.ofNullable(toSelect).ifPresent(p -> TreeUtil.selectPath(this.tree, p, false));
202208
this.loaded = true;
203209
}
204210

205-
public synchronized void clearChildren() {
206-
this.removeAllChildren();
207-
this.loaded = null;
208-
if (this.getAllowsChildren()) {
209-
this.add(new LoadingNode());
210-
this.tree.collapsePath(new TreePath(this.getPath()));
211-
}
212-
if (Objects.nonNull(this.getParent())) {
213-
((DefaultTreeModel) this.tree.getModel()).nodeStructureChanged(this);
211+
public void clearChildren() {
212+
synchronized (this.tree) {
213+
this.removeAllChildren();
214+
this.loaded = null;
215+
if (this.getAllowsChildren()) {
216+
this.add(new LoadingNode());
217+
this.tree.collapsePath(new TreePath(this.getPath()));
218+
}
219+
this.refreshChildrenView();
214220
}
215221
}
216222

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-springcloud/src/main/java/com/microsoft/azure/toolkit/intellij/springcloud/component/SpringCloudAppComboBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected List<? extends SpringCloudApp> loadItems() throws Exception {
7272
@Override
7373
protected ExtendableTextComponent.Extension getExtension() {
7474
return ExtendableTextComponent.Extension.create(
75-
AllIcons.General.Add, "Create Azure Spring app", this::showAppCreationPopup);
75+
AllIcons.General.Add, "Create Azure Spring App", this::showAppCreationPopup);
7676
}
7777

7878
private void showAppCreationPopup() {

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/java/com/microsoft/azure/toolkit/ide/common/favorite/Favorites.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public synchronized void pin(@Nonnull AbstractAzResource<?, ?, ?> resource) {
174174
}
175175
final FavoriteDraft draft = this.create(resource.getId(), null);
176176
draft.setResource(resource);
177-
draft.commit();
177+
draft.createIfNotExist();
178178
}
179179

180180
public void unpin(@Nonnull String resourceId) {

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/resources/bundles/com/microsoft/azure/toolkit/message.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ azure.mysql.create.task.title=Creating Azure Database for MySQL...
2323
azure.mysql.link.connection.title=Connecting to Azure Database for MySQL ({0})...
2424

2525
#################### Azure Spring Apps #######################
26-
springcloud.app.create.title=Create Azure Spring app
26+
springcloud.app.create.title=Create Azure Spring App
2727
springcloud.app.create.tooltip=Create Azure Spring app instance.
2828
springcloud.app.name.validate.empty=The name is required.
2929
springcloud.app.name.validate.exist=App with name({0}) already exists.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void registerActions(AzureActionManager am) {
3939
final Consumer<SpringCloudApp> openPublicUrl = s -> am.getAction(ResourceCommonActionsContributor.OPEN_URL).handle(s.getApplicationUrl());
4040
final ActionView.Builder openPublicUrlView = new ActionView.Builder("Access Public Endpoint", AzureIcons.Action.BROWSER.getIconPath())
4141
.title(s -> Optional.ofNullable(s).map(r -> description("springcloud.open_public_url.app", ((SpringCloudApp) r).name())).orElse(null))
42-
.enabled(s -> s instanceof SpringCloudApp && ((SpringCloudApp) s).isPublicEndpointEnabled());
42+
.enabled(s -> s instanceof SpringCloudApp && ((SpringCloudApp) s).getFormalStatus().isConnected() && ((SpringCloudApp) s).isPublicEndpointEnabled());
4343
final Action<SpringCloudApp> openPublicUrlAction = new Action<>(OPEN_PUBLIC_URL, openPublicUrl, openPublicUrlView);
4444
openPublicUrlAction.setShortcuts("control alt P");
4545
am.registerAction(OPEN_PUBLIC_URL, openPublicUrlAction);

0 commit comments

Comments
 (0)