Skip to content

Commit c0df4c6

Browse files
Merge pull request #6085 from microsoft/sdkbook/1894061
#1894061: maven repo link is not correct on sdk deprecation notification when there are multiple replaces.
2 parents 5a715eb + d8af52d commit c0df4c6

File tree

7 files changed

+505
-445
lines changed

7 files changed

+505
-445
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import javax.annotation.Nonnull;
1414
import javax.annotation.Nullable;
15+
import java.util.Objects;
1516

1617
public class AzureIntegerInput extends BaseAzureTextInput<Integer> {
1718

@@ -39,8 +40,12 @@ public void setValue(final Integer val) {
3940

4041
@Nonnull
4142
public AzureValidationInfo doValidate(Integer value) {
42-
if (value < minValue || value > maxValue) {
43+
if (Objects.nonNull(minValue) && Objects.nonNull(maxValue) && (value < minValue || value > maxValue)) {
4344
return AzureValidationInfo.error(String.format("Value should be in range [%d, %d]", minValue, maxValue), this);
45+
} else if (Objects.nonNull(minValue) && value < minValue) {
46+
return AzureValidationInfo.error(String.format("Value should be >= %d", minValue), this);
47+
} else if (Objects.nonNull(maxValue) && value > maxValue) {
48+
return AzureValidationInfo.error(String.format("Value should be <= %d", maxValue), this);
4449
} else {
4550
return AzureValidationInfo.success(this);
4651
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
package com.microsoft.azure.toolkit.intellij.common;
77

8-
import javax.annotation.Nullable;
8+
import javax.annotation.Nonnull;
99
import javax.swing.*;
1010

1111
public class AzureTextInput extends BaseAzureTextInput<String> {
1212
public AzureTextInput() {
13-
this(null);
13+
super();
1414
}
1515

16-
public AzureTextInput(@Nullable JTextField comp) {
16+
public AzureTextInput(@Nonnull JTextField comp) {
1717
super(comp);
1818
}
1919

PluginsAndFeatures/azure-toolkit-for-intellij/azure-sdk-reference-book/src/main/java/com/microsoft/azure/toolkit/intellij/azuresdk/enforcer/AzureSdkEnforcer.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.commons.lang3.StringUtils;
2424

2525
import javax.annotation.Nonnull;
26+
import java.util.Arrays;
2627
import java.util.List;
2728
import java.util.Map;
2829
import java.util.Set;
@@ -62,12 +63,15 @@ private static void warnDeprecatedLibs(@AzureTelemetry.Property List<? extends A
6263
private static String buildMessage(@Nonnull List<? extends AzureJavaSdkEntity> libs) {
6364
final String liPackages = libs.stream().map(l -> {
6465
if (StringUtils.isNotBlank(l.getReplace())) {
65-
final String replacePackage = l.getReplace().trim();
66+
final String[] replacePackages = l.getReplace().trim().split(",");
67+
final String replaces = Arrays.stream(replacePackages)
68+
.map(p -> String.format("<a href='%s'>%s</a>", getMavenArtifactUrl(p.trim()), p.trim()))
69+
.collect(Collectors.joining(", "));
6670
return String.format("<li>%s" +
67-
" <ul style='margin-top:0;margin-bottom:0;padding:0'>" +
68-
" <li>Replaced by: <a href='%s'>%s</a></li>" +
69-
" </ul>" +
70-
"</li>", l.getPackageName(), getMavenArtifactUrl(replacePackage), replacePackage);
71+
" <ul style='margin-top:0;margin-bottom:0;padding:0'>" +
72+
" <li>Replaced by: %s</li>" +
73+
" </ul>" +
74+
"</li>", l.getPackageName(), replaces);
7175
} else {
7276
return String.format("<li>%s</li>", l.getPackageName());
7377
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-sdk-reference-book/src/main/java/com/microsoft/azure/toolkit/intellij/azuresdk/referencebook/AzureSdkReferenceBookPanel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package com.microsoft.azure.toolkit.intellij.azuresdk.referencebook;
77

88
import com.intellij.ui.components.JBScrollPane;
9+
import com.microsoft.azure.toolkit.lib.common.bundle.AzureString;
10+
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
911
import lombok.Getter;
1012

1113
import javax.swing.*;
@@ -22,7 +24,7 @@ public class AzureSdkReferenceBookPanel {
2224
public AzureSdkReferenceBookPanel() {
2325
this.contentPanel.setPreferredSize(new Dimension(840, 600));
2426
this.initListeners();
25-
this.servicesTreePanel.refresh();
27+
AzureTaskManager.getInstance().runInBackground(AzureString.fromString("loading Azure SDK data"), () -> this.servicesTreePanel.refresh());
2628
}
2729

2830
private void initListeners() {

PluginsAndFeatures/azure-toolkit-for-intellij/azure-sdk-reference-book/src/main/java/com/microsoft/azure/toolkit/intellij/azuresdk/referencebook/AzureSdkTreePanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ private void filter(final String text) {
104104

105105
public void refresh(boolean... force) {
106106
try {
107-
if(ArrayUtils.isNotEmpty(force) && force[0]){
107+
if (ArrayUtils.isNotEmpty(force) && force[0]) {
108108
AzureSdkLibraryService.refresh();
109109
}
110110
this.services = AzureSdkLibraryService.loadAzureSdkServices();
111111
this.categories = AzureSdkCategoryService.loadAzureSDKCategories();
112112
this.fillDescriptionFromCategoryIfMissing(this.categories, this.services);
113113
this.filter.debounce();
114-
Optional.ofNullable(this.lastNodePath).ifPresent(p -> TreeUtil.selectPath(this.tree, p));
114+
AzureTaskManager.getInstance().runLater(() -> Optional.ofNullable(this.lastNodePath).ifPresent(p -> TreeUtil.selectPath(this.tree, p)));
115115
} catch (final IOException e) {
116116
//TODO: messager.warning(...)
117117
e.printStackTrace();

0 commit comments

Comments
 (0)