Skip to content

Commit 7d2663f

Browse files
Merge pull request #7136 from microsoft/hotfix-dbtools
no default server is selected when open datasource dialog from dataso…
2 parents caf33c2 + e1de7fa commit 7d2663f

File tree

2 files changed

+11
-5
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij
    • azure-intellij-plugin-database/src/main/java/com/microsoft/azure/toolkit/intellij/database/dbtools
    • azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/feedback

2 files changed

+11
-5
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-database/src/main/java/com/microsoft/azure/toolkit/intellij/database/dbtools/DatabaseServerParamEditor.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ public class DatabaseServerParamEditor extends ParamEditorBase<DatabaseServerPar
8383
public DatabaseServerParamEditor(@Nonnull Class<? extends IDatabaseServer<?>> clazz, @Nonnull String label, @Nonnull DataInterchange interchange) {
8484
super(new SqlDbServerComboBox(clazz), interchange, FieldSize.LARGE, label);
8585
this.clazz = clazz;
86-
this.jdbcUrl = Optional.ofNullable(interchange.getDataSource().getUrl()).filter(StringUtils::isNotBlank).map(JdbcUrl::from).orElse(null);
86+
final LocalDataSource dataSource = getDataSourceConfigurable().getDataSource();
87+
this.jdbcUrl = Optional.ofNullable(dataSource.getUrl()).filter(StringUtils::isNotBlank).map(JdbcUrl::from).orElse(null);
8788
final SqlDbServerComboBox combox = this.getEditorComponent();
8889
combox.addValueChangedListener(this::setServer);
8990
interchange.addPersistentProperty(KEY_DB_SERVER_ID);
90-
final boolean isModifying = StringUtils.isNotBlank(interchange.getDataSource().getUsername());
91+
final boolean isModifying = StringUtils.isNotBlank(dataSource.getUsername());
9192
if (isModifying && Objects.nonNull(this.jdbcUrl)) {
9293
final JdbcUrl url = this.jdbcUrl;
9394
combox.setValue(new AzureComboBox.ItemReference<>(i -> i.getJdbcUrl().getServerHost().equals(url.getServerHost())));
@@ -171,9 +172,11 @@ private void createServerInIde(InputEvent e) {
171172
}
172173

173174
private void onPropertiesChanged(String propertyName, Object newValue) {
174-
if (!this.updating && Objects.nonNull(this.jdbcUrl) && StringUtils.isNotEmpty((String) newValue)) {
175-
if (StringUtils.equals(propertyName, "host") && !Objects.equals(this.jdbcUrl.getServerHost(), newValue)) {
176-
this.getEditorComponent().setValue((IDatabaseServer<?>) null);
175+
if (!this.updating && StringUtils.isNotEmpty((String) newValue) && StringUtils.equals(propertyName, "host")) {
176+
final SqlDbServerComboBox combox = this.getEditorComponent();
177+
final IDatabaseServer<?> server = combox.getValue();
178+
if (Objects.nonNull(server) && !Objects.equals(server.getJdbcUrl().getServerHost(), newValue)) {
179+
combox.setValue((IDatabaseServer<?>) null);
177180
this.setServer(null);
178181
}
179182
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ public static synchronized void popup(@Nullable Project project) {
210210
popDaysLater(3);
211211

212212
final JFrame frame = ((JFrame) IdeUtils.getWindow(project));
213+
if (RatePopup.balloon.isDisposed()) {
214+
return;
215+
}
213216
RatePopup.balloon.show(new PositionTracker<>(frame.getRootPane()) {
214217
@Override
215218
public RelativePoint recalculateLocation(@NotNull Balloon balloon) {

0 commit comments

Comments
 (0)