Skip to content

Commit 6ea4951

Browse files
Merge branch 'develop' into develop.next
2 parents 43b2a74 + 0638b9a commit 6ea4951

File tree

197 files changed

+4378
-771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+4378
-771
lines changed

PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.appservice/src/com/microsoft/azure/toolkit/eclipse/function/launch/deploy/AzureFunctionDeployLaunchDelegate.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
2121
import org.eclipse.jdt.core.IJavaProject;
2222

23-
import com.google.gson.JsonObject;
2423
import com.microsoft.azure.toolkit.eclipse.common.launch.AzureLongDurationTaskRunnerWithConsole;
2524
import com.microsoft.azure.toolkit.eclipse.common.launch.LaunchConfigurationUtils;
2625
import com.microsoft.azure.toolkit.eclipse.function.core.EclipseFunctionProject;
2726
import com.microsoft.azure.toolkit.eclipse.function.launch.model.FunctionDeployConfiguration;
2827
import com.microsoft.azure.toolkit.eclipse.function.utils.FunctionUtils;
2928
import com.microsoft.azure.toolkit.ide.appservice.function.FunctionAppConfig;
30-
import com.microsoft.azure.toolkit.ide.appservice.util.JsonUtils;
3129
import com.microsoft.azure.toolkit.lib.appservice.function.FunctionAppBase;
3230
import com.microsoft.azure.toolkit.lib.appservice.function.core.AzureFunctionPackager;
3331
import com.microsoft.azure.toolkit.lib.appservice.task.CreateOrUpdateFunctionAppTask;
@@ -36,6 +34,7 @@
3634
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
3735
import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager;
3836
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
37+
import com.microsoft.azure.toolkit.lib.common.utils.JsonUtils;
3938
import com.microsoft.azuretools.core.utils.MavenUtils;
4039

4140
import javax.annotation.Nonnull;
@@ -102,13 +101,10 @@ private static void updateAppSettings(@Nonnull final File localSettings, @Nonnul
102101
}
103102

104103
private static Map<String, String> getAppSettingsFromLocalSettingsJson(@Nonnull final File target) {
105-
final Map<String, String> result = new HashMap<>();
106-
final JsonObject jsonObject = JsonUtils.readJsonFile(target);
104+
final Map<String, Object> jsonObject = JsonUtils.readFromJsonFile(target, HashMap.class);
107105
if (jsonObject == null) {
108106
return new HashMap<>();
109107
}
110-
final JsonObject valueObject = jsonObject.getAsJsonObject(LOCAL_SETTINGS_VALUES);
111-
valueObject.entrySet().stream().forEach(entry -> result.put(entry.getKey(), entry.getValue().getAsString()));
112-
return result;
108+
return (Map<String, String>) jsonObject.get(LOCAL_SETTINGS_VALUES);
113109
}
114110
}

PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.core/src/com/microsoft/azuretools/core/ui/login/ServicePrincipalLoginDialog.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import com.microsoft.azure.toolkit.lib.common.form.AzureFormInput;
1414
import com.microsoft.azure.toolkit.lib.common.form.AzureValidationInfo;
1515
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
16-
import com.microsoft.azuretools.utils.JsonUtils;
16+
import com.microsoft.azure.toolkit.lib.common.utils.JsonUtils;
17+
1718
import org.apache.commons.lang3.StringUtils;
1819
import org.eclipse.swt.SWT;
1920
import org.eclipse.swt.events.SelectionAdapter;
@@ -255,7 +256,7 @@ private void updateToJsonEditor() {
255256
}
256257
map.put("appId", newData.getClient());
257258
map.put("tenant", newData.getTenant());
258-
String text = JsonUtils.getGson().toJson(map);
259+
String text = JsonUtils.toJson(map);
259260
this.txtJson.setText(text);
260261
} finally {
261262
intermediateState.set(false);

PluginsAndFeatures/azure-toolkit-for-intellij/.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-applicationinsights/src/main/java/com/microsoft/azure/toolkit/intellij/applicationinsights/connection/ApplicationInsightsResourcePanel.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package com.microsoft.azure.toolkit.intellij.applicationinsights.connection;
77

88
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
9-
import com.microsoft.azure.toolkit.intellij.common.AzureComboBoxSimple;
109
import com.microsoft.azure.toolkit.intellij.common.AzureFormJPanel;
1110
import com.microsoft.azure.toolkit.intellij.common.component.SubscriptionComboBox;
1211
import com.microsoft.azure.toolkit.intellij.connector.Resource;
@@ -23,7 +22,6 @@
2322
import java.awt.event.ItemEvent;
2423
import java.util.Arrays;
2524
import java.util.Collections;
26-
import java.util.Comparator;
2725
import java.util.List;
2826
import java.util.Optional;
2927
import java.util.function.Supplier;
@@ -43,7 +41,7 @@ private void init() {
4341
this.insightComboBox.trackValidation();
4442
this.subscriptionComboBox.addItemListener(e -> {
4543
if (e.getStateChange() == ItemEvent.SELECTED) {
46-
this.insightComboBox.refreshItems();
44+
this.insightComboBox.reloadItems();
4745
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
4846
this.insightComboBox.clear();
4947
}
@@ -86,11 +84,20 @@ protected void createUIComponents() {
8684
.map(id -> Azure.az(AzureApplicationInsights.class).applicationInsights(id).list()
8785
.stream().sorted((first, second) -> StringUtils.compare(first.getName(), second.getName())).collect(Collectors.toList()))
8886
.orElse(Collections.emptyList());
89-
this.insightComboBox = new AzureComboBoxSimple<>(loader) {
87+
this.insightComboBox = new AzureComboBox<>(loader) {
9088
@Override
9189
protected String getItemText(Object item) {
9290
return Optional.ofNullable(item).map(i -> ((ApplicationInsight) i).getName()).orElse(StringUtils.EMPTY);
9391
}
92+
93+
@Override
94+
protected void refreshItems() {
95+
Optional.ofNullable(ApplicationInsightsResourcePanel.this.subscriptionComboBox)
96+
.map(AzureComboBox::getValue)
97+
.map(Subscription::getId)
98+
.ifPresent(id -> Azure.az(AzureApplicationInsights.class).applicationInsights(id).refresh());
99+
super.refreshItems();
100+
}
94101
};
95102
}
96103

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
package com.microsoft.azure.toolkit.intellij.legacy.appservice;
77

88
import com.intellij.icons.AllIcons;
9+
import com.intellij.openapi.keymap.KeymapUtil;
910
import com.intellij.openapi.project.Project;
1011
import com.intellij.ui.SimpleListCellRenderer;
11-
import com.intellij.ui.components.fields.ExtendableTextComponent;
12+
import com.intellij.ui.components.fields.ExtendableTextComponent.Extension;
1213
import com.microsoft.azure.toolkit.ide.appservice.model.AppServiceConfig;
1314
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
1415
import com.microsoft.azure.toolkit.lib.appservice.AppServiceAppBase;
@@ -21,10 +22,11 @@
2122
import com.microsoft.azure.toolkit.lib.resource.ResourceGroupConfig;
2223
import lombok.Setter;
2324
import org.apache.commons.lang3.StringUtils;
24-
import rx.Subscription;
2525

2626
import javax.annotation.Nonnull;
2727
import javax.swing.*;
28+
import java.awt.event.InputEvent;
29+
import java.awt.event.KeyEvent;
2830
import java.util.List;
2931
import java.util.Objects;
3032
import java.util.Optional;
@@ -33,7 +35,6 @@
3335
public abstract class AppServiceComboBox<T extends AppServiceConfig> extends AzureComboBox<T> {
3436

3537
protected Project project;
36-
protected Subscription subscription;
3738

3839
@Setter
3940
protected T configModel;
@@ -49,7 +50,7 @@ public AppServiceComboBox(final Project project) {
4950
protected List<? extends T> loadItems() throws Exception {
5051
final List<T> items = loadAppServiceModels();
5152
final boolean isConfigResourceCreated = !isDraftResource(configModel) ||
52-
items.stream().anyMatch(item -> AppServiceConfig.isSameApp(item, configModel));
53+
items.stream().anyMatch(item -> AppServiceConfig.isSameApp(item, configModel));
5354
if (isConfigResourceCreated) {
5455
this.configModel = null;
5556
} else {
@@ -86,8 +87,14 @@ public T getValue() {
8687

8788
@Nonnull
8889
@Override
89-
protected ExtendableTextComponent.Extension getExtension() {
90-
return ExtendableTextComponent.Extension.create(AllIcons.General.Add, "Create", this::createResource);
90+
protected List<Extension> getExtensions() {
91+
final List<Extension> extensions = super.getExtensions();
92+
final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.ALT_DOWN_MASK);
93+
final String tooltip = String.format("Create (%s)", KeymapUtil.getKeystrokeText(keyStroke));
94+
final Extension addEx = Extension.create(AllIcons.General.Add, tooltip, this::createResource);
95+
this.registerShortcut(keyStroke, addEx);
96+
extensions.add(addEx);
97+
return extensions;
9198
}
9299

93100
@Override
@@ -108,7 +115,7 @@ public static class AppComboBoxRender extends SimpleListCellRenderer<AppServiceC
108115
public void customize(JList<? extends AppServiceConfig> list, AppServiceConfig app, int index, boolean isSelected, boolean cellHasFocus) {
109116
if (app != null) {
110117
final boolean isJavaApp = Optional.ofNullable(app.getRuntime()).map(Runtime::getJavaVersion)
111-
.map(javaVersion -> !Objects.equals(javaVersion, JavaVersion.OFF)).orElse(false);
118+
.map(javaVersion -> !Objects.equals(javaVersion, JavaVersion.OFF)).orElse(false);
112119
setEnabled(isJavaApp);
113120
setFocusable(isJavaApp);
114121

@@ -123,12 +130,12 @@ public void customize(JList<? extends AppServiceConfig> list, AppServiceConfig a
123130

124131
private String getAppServiceLabel(AppServiceConfig appServiceModel) {
125132
final String appServiceName = isDraftResource(appServiceModel) ?
126-
String.format("(New) %s", appServiceModel.getName()) : appServiceModel.getName();
133+
String.format("(New) %s", appServiceModel.getName()) : appServiceModel.getName();
127134
final String runtime = appServiceModel.getRuntime() == null ?
128135
"Loading:" : WebAppService.getInstance().getRuntimeDisplayName(appServiceModel.getRuntime());
129136
final String resourceGroup = Optional.ofNullable(appServiceModel.getResourceGroupName()).orElse(StringUtils.EMPTY);
130137
return String.format("<html><div>%s</div></div><small>Runtime: %s | Resource Group: %s</small></html>",
131-
appServiceName, runtime, resourceGroup);
138+
appServiceName, runtime, resourceGroup);
132139
}
133140
}
134141

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private void onServicePlanChanged(final ItemEvent e) {
239239
private void createUIComponents() {
240240
// TODO: place custom component creation code here
241241
this.selectorApplication = new AzureArtifactComboBox(project, true);
242-
this.selectorApplication.refreshItems();
242+
this.selectorApplication.reloadItems();
243243
}
244244

245245
public void setValidPricingTier(List<PricingTier> pricingTier, PricingTier defaultPricingTier) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
package com.microsoft.azure.toolkit.intellij.legacy.appservice;
77

8+
import com.intellij.ui.components.fields.ExtendableTextComponent;
89
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
910
import com.microsoft.azure.toolkit.lib.appservice.model.LogLevel;
1011

1112
import javax.annotation.Nonnull;
1213
import java.util.Arrays;
14+
import java.util.Collections;
1315
import java.util.List;
1416

1517
public class LogLevelComboBox extends AzureComboBox<LogLevel> {
@@ -24,4 +26,10 @@ protected List<? extends LogLevel> loadItems() throws Exception {
2426
protected String getItemText(Object item) {
2527
return item instanceof LogLevel ? ((LogLevel) item).getValue() : super.getItemText(item);
2628
}
29+
30+
@Nonnull
31+
@Override
32+
protected List<ExtendableTextComponent.Extension> getExtensions() {
33+
return Collections.emptyList();
34+
}
2735
}

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,27 @@
66
package com.microsoft.azure.toolkit.intellij.legacy.appservice;
77

88
import com.intellij.icons.AllIcons;
9-
import com.intellij.ui.components.fields.ExtendableTextComponent;
109
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
1110
import com.microsoft.azure.toolkit.lib.appservice.AppServiceAppBase;
12-
import com.microsoft.azure.toolkit.lib.legacy.appservice.jfr.FlightRecorderManager;
1311
import com.microsoft.azure.toolkit.lib.appservice.model.ProcessInfo;
1412
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
13+
import com.microsoft.azure.toolkit.lib.legacy.appservice.jfr.FlightRecorderManager;
1514
import lombok.Getter;
1615
import lombok.Setter;
1716
import org.apache.commons.lang3.StringUtils;
18-
import org.jetbrains.annotations.NotNull;
19-
import org.jetbrains.annotations.Nullable;
2017

18+
import javax.annotation.Nonnull;
2119
import javax.swing.*;
2220
import java.util.Collections;
2321
import java.util.List;
2422
import java.util.Objects;
2523

26-
import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message;
27-
2824
public class ProcessComboBox extends AzureComboBox<ProcessInfo> {
2925
@Setter
3026
@Getter
3127
private AppServiceAppBase<?, ?, ?> appService;
3228

33-
@NotNull
29+
@Nonnull
3430
@Override
3531
@AzureOperation(
3632
name = "appservice.list_flight_recorders.app",
@@ -44,19 +40,12 @@ protected List<ProcessInfo> loadItems() throws Exception {
4440
return FlightRecorderManager.getFlightRecorderStarter(appService).listProcess();
4541
}
4642

47-
@Nullable
48-
@Override
49-
protected ExtendableTextComponent.Extension getExtension() {
50-
return ExtendableTextComponent.Extension.create(
51-
AllIcons.Actions.Refresh, message("common.refresh"), this::refreshItems);
52-
}
53-
5443
protected String getItemText(Object item) {
5544
if (item == null) {
5645
return StringUtils.EMPTY;
5746
}
5847
if (item instanceof ProcessInfo) {
59-
ProcessInfo processInfo = (ProcessInfo) item;
48+
final ProcessInfo processInfo = (ProcessInfo) item;
6049
return String.format("[%d] %s", processInfo.getId(), StringUtils.abbreviate(processInfo.getName(), 50));
6150
}
6251
return item.toString();

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

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
package com.microsoft.azure.toolkit.intellij.legacy.appservice.insights;
66

77
import com.intellij.icons.AllIcons;
8-
import com.intellij.ui.components.fields.ExtendableTextComponent;
8+
import com.intellij.openapi.keymap.KeymapUtil;
9+
import com.intellij.ui.components.fields.ExtendableTextComponent.Extension;
910
import com.microsoft.azure.toolkit.ide.appservice.model.ApplicationInsightsConfig;
1011
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
1112
import com.microsoft.azure.toolkit.intellij.legacy.function.runner.component.CreateApplicationInsightsDialog;
@@ -16,10 +17,13 @@
1617
import org.apache.commons.collections.ListUtils;
1718

1819
import javax.annotation.Nonnull;
19-
import javax.annotation.Nullable;
20+
import javax.swing.*;
21+
import java.awt.event.InputEvent;
22+
import java.awt.event.KeyEvent;
2023
import java.util.Collections;
2124
import java.util.List;
2225
import java.util.Objects;
26+
import java.util.Optional;
2327
import java.util.stream.Collectors;
2428

2529
import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message;
@@ -37,7 +41,7 @@ public void setSubscription(Subscription subscription) {
3741
this.clear();
3842
return;
3943
}
40-
this.refreshItems();
44+
this.reloadItems();
4145
}
4246

4347
@Override
@@ -55,22 +59,33 @@ public void setValue(final ApplicationInsightsConfig insightsConfig) {
5559
params = {"this.subscription.getId()"},
5660
type = AzureOperation.Type.SERVICE
5761
)
58-
protected List<? extends ApplicationInsightsConfig> loadItems() throws Exception {
62+
protected List<? extends ApplicationInsightsConfig> loadItems() {
5963
final List<ApplicationInsightsConfig> newItems =
60-
getItems().stream().filter(ApplicationInsightsConfig::isNewCreate).collect(Collectors.toList());
64+
getItems().stream().filter(ApplicationInsightsConfig::isNewCreate).collect(Collectors.toList());
6165
final List<ApplicationInsightsConfig> existingItems =
62-
subscription == null ? Collections.emptyList() :
63-
Azure.az(AzureApplicationInsights.class).applicationInsights(subscription.getId()).list().stream()
64-
.map(instance -> new ApplicationInsightsConfig(instance.getName(), instance.getInstrumentationKey()))
65-
.collect(Collectors.toList());
66+
subscription == null ? Collections.emptyList() :
67+
Azure.az(AzureApplicationInsights.class).applicationInsights(subscription.getId()).list().stream()
68+
.map(instance -> new ApplicationInsightsConfig(instance.getName(), instance.getInstrumentationKey()))
69+
.collect(Collectors.toList());
6670
return ListUtils.union(newItems, existingItems);
6771
}
6872

69-
@Nullable
7073
@Override
71-
protected ExtendableTextComponent.Extension getExtension() {
72-
return ExtendableTextComponent.Extension.create(
73-
AllIcons.General.Add, message("appService.insights.create.tooltip"), this::onCreateApplicationInsights);
74+
protected void refreshItems() {
75+
Optional.ofNullable(subscription).ifPresent(s -> Azure.az(AzureApplicationInsights.class).applicationInsights(subscription.getId()).refresh());
76+
super.refreshItems();
77+
}
78+
79+
@Nonnull
80+
@Override
81+
protected List<Extension> getExtensions() {
82+
final List<Extension> extensions = super.getExtensions();
83+
final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.ALT_DOWN_MASK);
84+
final String tooltip = String.format("%s (%s)", message("appService.insights.create.tooltip"), KeymapUtil.getKeystrokeText(keyStroke));
85+
final Extension addEx = Extension.create(AllIcons.General.Add, tooltip, this::onCreateApplicationInsights);
86+
this.registerShortcut(keyStroke, addEx);
87+
extensions.add(addEx);
88+
return extensions;
7489
}
7590

7691
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public List<AzureFormInput<?>> getInputs() {
8080
private void createUIComponents() {
8181
this.processComboBox1 = new ProcessComboBox();
8282
this.processComboBox1.setAppService(this.appService);
83-
this.processComboBox1.refreshItems();
83+
this.processComboBox1.reloadItems();
8484
this.durationPanel = new DurationPanel(1, MAX_DURATION_SECONDS, DEFAULT_DURATION_SECONDS);
8585
}
8686
}

0 commit comments

Comments
 (0)