Skip to content

Commit e10e7b3

Browse files
Merge branch 'endgame-june' into endgame-june.next
2 parents 8361439 + 14e8159 commit e10e7b3

File tree

10 files changed

+34
-46
lines changed

10 files changed

+34
-46
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
1919
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskContext;
2020
import lombok.Getter;
21-
import lombok.RequiredArgsConstructor;
2221
import lombok.Setter;
22+
import lombok.extern.java.Log;
2323
import org.apache.commons.lang3.ObjectUtils;
2424
import org.apache.commons.lang3.StringUtils;
2525
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -35,12 +35,13 @@
3535
import java.util.Map;
3636
import java.util.Objects;
3737
import java.util.Optional;
38+
import java.util.logging.Level;
3839
import java.util.regex.Matcher;
3940
import java.util.regex.Pattern;
4041
import java.util.stream.Collectors;
4142

4243
@Setter
43-
@RequiredArgsConstructor
44+
@Log
4445
public class IntellijAzureMessage implements IAzureMessage {
4546
static final Pattern URL_PATTERN = Pattern.compile("\\s+(https?|ftp)://(www\\d?|[a-zA-Z0-9]+)?.[a-zA-Z0-9-]+(:|.)([a-zA-Z0-9.]+|(\\d+)?)([/?:].*)?");
4647
static final String DEFAULT_MESSAGE_TITLE = "Azure";
@@ -59,6 +60,13 @@ public class IntellijAzureMessage implements IAzureMessage {
5960
@Getter
6061
private final IAzureMessage original;
6162

63+
public IntellijAzureMessage(@Nonnull IAzureMessage original) {
64+
this.original = original;
65+
if (original.getPayload() instanceof Throwable) {
66+
log.log(Level.WARNING, "caught error in IntellijAzureMessager", ((Throwable) original.getPayload()));
67+
}
68+
}
69+
6270
public IntellijAzureMessage(@Nonnull Type type, @Nonnull String message) {
6371
this(new SimpleMessage(type, message));
6472
}
@@ -143,7 +151,7 @@ public Boolean getBackgrounded() {
143151
private static String getCause(@Nonnull Throwable throwable) {
144152
final Throwable root = getRecognizableCause(throwable);
145153
if (Objects.isNull(root)) {
146-
return null;
154+
return ExceptionUtils.getRootCause(throwable).toString();
147155
}
148156
String cause = null;
149157
if (root instanceof ManagementException) {
@@ -163,7 +171,7 @@ private static Throwable getRecognizableCause(@Nonnull Throwable throwable) {
163171
continue;
164172
}
165173
final String rootClassName = t.getClass().getName();
166-
if (rootClassName.startsWith("com.microsoft.azure") || rootClassName.startsWith("com.azure")) {
174+
if (rootClassName.startsWith("com.microsoft") || rootClassName.startsWith("com.azure")) {
167175
return t;
168176
}
169177
}

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ private void loadData(final Map<String, List<AzureSdkCategoryEntity>> categoryTo
131131
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) this.model.getRoot();
132132
root.removeAllChildren();
133133
final Map<String, AzureSdkServiceEntity> serviceMap = services.stream().collect(Collectors.toMap(e -> getServiceKeyByName(e.getName()), e -> e));
134-
final List<String> categories = categoryToServiceMap.keySet().stream().sorted().collect(Collectors.toList());
134+
final List<String> categories = categoryToServiceMap.keySet().stream().filter(StringUtils::isNotBlank).sorted(
135+
(s1, s2) -> StringUtils.contains(s1, "Others") ? 1 : StringUtils.contains(s2, "Others") ? -1 : s1.compareTo(s2)).collect(Collectors.toList());
135136
for (final String category : categories) {
136137
// no feature found for current category
137138
if (CollectionUtils.isEmpty(categoryToServiceMap.get(category)) ||
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
sqlserver.create=create Azure Database for SQL Server({0}) in subscription({1})
2-
sqlserver|database.list.server|subscription=list all Azure SQL Server database schemas in server({0}) of subscription({1})
3-
sqlserver|region.list.supported=list Azure SQL Server-supported regions
4-
sqlserver|version.list.supported=list Azure SQL Server-supported versions
5-
sqlserver.update_password=update password of SQL Server instance
6-
sqlserver.connect_server=connect to Azure SQL Server({0})
7-
sqlserver.delete=delete SQL Server({0})
8-
sqlserver.open_portal=open configuration page of SQL Server({0}) in portal
9-
sqlserver.show_properties=show properties of SQL Server({0})
1+
sqlserver|server.create=create SQL Server({0}) in subscription({1})
2+
sqlserver|server.delete=delete SQL Server({0})
3+
sqlserver|server.open_portal=open configuration page of SQL Server({0}) in portal
4+
sqlserver|server.show_properties=show properties of SQL Server({0})
5+
sqlserver|server.open_by_database_tools=open SQL Server({0}) by Database Tools plugin.
6+
sqlserver|server.database_load|subscription=list all SQL Server databases in server({0}) of subscription({1})

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/properties/SpringCloudAppPanel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ private void setApp(@Nonnull SpringCloudApp app) {
173173
private void updateForm() {
174174
assert Objects.nonNull(app): "app is not specified";
175175
final String testUrl = app.entity().getTestUrl();
176-
this.txtTestEndpoint.setHyperlinkText(testUrl.length() > 60 ? testUrl.substring(0, 60) + "..." : testUrl);
176+
if (testUrl != null) {
177+
this.txtTestEndpoint.setHyperlinkText(testUrl.length() > 60 ? testUrl.substring(0, 60) + "..." : testUrl);
178+
}
177179
this.txtTestEndpoint.setHyperlinkTarget(testUrl);
178180

179181
final SpringCloudSku sku = app.getCluster().entity().getSku();

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/sqlserver/OpenSqlServerByToolsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected String getOperationName(NodeActionEvent event) {
6060
return ActionConstants.parse(ActionConstants.SqlServer.CONNECT_TO_SERVER).getOperationName();
6161
}
6262

63-
@AzureOperation(name = "sqlserver.connect_server", params = {"this.node.getServer().entity().getName()"}, type = AzureOperation.Type.ACTION)
63+
@AzureOperation(name = "sqlserver|server.open_by_database_tools", params = {"this.node.getServer().entity().getName()"}, type = AzureOperation.Type.ACTION)
6464
private void doActionPerformed(boolean isLoggedIn, Project project) {
6565
try {
6666
if (!isLoggedIn ||

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/sqlserver/common/SqlServerDatabaseComboBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected String getItemText(Object item) {
4444

4545
@Override
4646
@AzureOperation(
47-
name = "sqlserver|database.list.server|subscription",
47+
name = "sqlserver|server.database_load|subscription",
4848
params = {"this.server.name()", "this.subscription.subscriptionId()"},
4949
type = AzureOperation.Type.SERVICE
5050
)

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/sqlserver/task/CreateSqlServerTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public CreateSqlServerTask(SqlServerConfig config) {
3434
}
3535

3636
@AzureOperation(
37-
name = "sqlserver.create",
37+
name = "sqlserver|server.create",
3838
params = {
3939
"config.getServerName()",
4040
"config.getSubscription().displayName()"

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/ui/SignInWindow.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import com.intellij.openapi.application.ApplicationManager;
99
import com.intellij.openapi.diagnostic.Logger;
10-
import com.intellij.openapi.progress.ProcessCanceledException;
1110
import com.intellij.openapi.progress.ProgressIndicator;
1211
import com.intellij.openapi.progress.ProgressManager;
1312
import com.intellij.openapi.project.Project;
@@ -38,7 +37,6 @@
3837
import org.apache.commons.lang3.StringUtils;
3938
import org.jdesktop.swingx.JXHyperlink;
4039
import org.jetbrains.annotations.Nullable;
41-
import reactor.core.Disposable;
4240
import reactor.core.publisher.Flux;
4341
import reactor.core.publisher.Mono;
4442
import reactor.core.scheduler.Schedulers;
@@ -197,27 +195,9 @@ private AuthMethodDetails doServicePrincipalLogin() {
197195
}
198196

199197
private static AuthMethodDetails checkCanceled(ProgressIndicator indicator, Mono<? extends AuthMethodDetails> mono) {
200-
CompletableFuture<? extends AuthMethodDetails> future = mono.toFuture();
201-
Disposable disposable = Flux.interval(Duration.ofSeconds(1)).map(ts -> {
202-
if (indicator != null) {
203-
indicator.checkCanceled();
204-
}
205-
return 1;
206-
}).onErrorResume(e -> {
207-
if (e instanceof ProcessCanceledException) {
208-
future.cancel(true);
209-
}
210-
return Mono.empty();
211-
}).subscribeOn(Schedulers.boundedElastic()).subscribe();
212-
try {
213-
return future.get();
214-
} catch (CancellationException e) {
215-
return null;
216-
} catch (Throwable e) {
217-
throw new AzureToolkitRuntimeException("Cannot login due to error: " + e.getMessage(), e);
218-
} finally {
219-
disposable.dispose();
220-
}
198+
final Mono<AuthMethodDetails> cancelMono = Flux.interval(Duration.ofSeconds(1)).map(ignore -> indicator.isCanceled())
199+
.any(cancel -> cancel).map(ignore -> new AuthMethodDetails()).subscribeOn(Schedulers.boundedElastic());
200+
return Mono.firstWithSignal(cancelMono, mono.subscribeOn(Schedulers.boundedElastic())).block();
221201
}
222202

223203
@Override
@@ -328,7 +308,7 @@ private synchronized AuthMethodDetails doDeviceLogin() {
328308
ErrorWindow.show(project, ex.getMessage(), SIGN_IN_ERROR);
329309
}
330310
}
331-
return null;
311+
return new AuthMethodDetails();
332312
}
333313

334314
private static AuthMethodDetails fromAccountEntity(AccountEntity entity) {

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/springcloud/SpringCloudNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public SpringCloudNode(AzureRefreshableNode parent, SpringCloudCluster cluster)
4242

4343
public void onAppCreatedOrRemoved(SpringCloudApp app) {
4444
if (this.cluster.name().equals(app.getCluster().name())) {
45-
refreshItems();
45+
this.load(true);
4646
}
4747
}
4848

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/sqlserver/SqlServerNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ public List<NodeAction> getNodeActions() {
6666
return super.getNodeActions();
6767
}
6868

69-
@AzureOperation(name = "sqlserver.delete", params = {"this.server.entity().getName()"}, type = AzureOperation.Type.ACTION)
69+
@AzureOperation(name = "sqlserver|server.delete", params = {"this.server.entity().getName()"}, type = AzureOperation.Type.ACTION)
7070
private void delete() {
7171
this.serverState = SERVER_UPDATING;
7272
this.getParent().removeNode(this.subscriptionId, this.getId(), SqlServerNode.this);
7373
}
7474

75-
@AzureOperation(name = "sqlserver.open_portal", params = {"this.server.entity().getName()"}, type = AzureOperation.Type.ACTION)
75+
@AzureOperation(name = "sqlserver|server.open_portal", params = {"this.server.entity().getName()"}, type = AzureOperation.Type.ACTION)
7676
private void openInPortal() {
7777
this.openResourcesInPortal(this.subscriptionId, this.server.entity().getId());
7878
}
7979

80-
@AzureOperation(name = "sqlserver.show_properties", params = {"this.server.entity().getName()"}, type = AzureOperation.Type.ACTION)
80+
@AzureOperation(name = "sqlserver|server.show_properties", params = {"this.server.entity().getName()"}, type = AzureOperation.Type.ACTION)
8181
private void showProperties() {
8282
DefaultLoader.getUIHelper().openSqlServerPropertyView(SqlServerNode.this);
8383
}

0 commit comments

Comments
 (0)