Skip to content

Commit

Permalink
#16696 save connection settings even if reconnect refused (#16699)
Browse files Browse the repository at this point in the history
  • Loading branch information
E1izabeth committed Jun 3, 2022
1 parent d45e272 commit dc371f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,6 @@ private FilterInfo(Class<?> type, String title) {
}
}

@Nullable
protected Boolean isConnectionReadOnly() {
return this.readOnlyConnection == null? null : this.readOnlyConnection.getSelection();
}

@Nullable
protected List<DBPDataSourcePermission> getAccessRestrictions() {
return this.accessRestrictions;
}

protected boolean wasActivated() {
return this.activated;
Expand Down Expand Up @@ -602,9 +593,8 @@ public void saveSettings(DBPDataSourceContainer dataSource) {
}
dsDescriptor.setNavigatorSettings(this.navigatorSettings);

// it should be changed with connection settings and saved only on reconnect when connection is active
// dsDescriptor.setConnectionReadOnly(this.readOnlyConnection.getSelection());
// dsDescriptor.setModifyPermissions(this.accessRestrictions);
dsDescriptor.setConnectionReadOnly(this.readOnlyConnection.getSelection());
dsDescriptor.setModifyPermissions(this.accessRestrictions);

for (FilterInfo filterInfo : filters) {
if (filterInfo.filter != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void dispose() {

public abstract ConnectionPageSettings getPageSettings();

protected abstract void saveSettings(DataSourceDescriptor dataSource, boolean isSaveConnectionSettings);
protected abstract void saveSettings(DataSourceDescriptor dataSource);

@NotNull
public DataSourceDescriptor getActiveDataSource() {
Expand Down Expand Up @@ -142,7 +142,7 @@ public void testConnection() {
DataSourceDescriptor dataSource = getPageSettings().getActiveDataSource();
DataSourceDescriptor testDataSource = new DataSourceDescriptor(dataSource, dataSource.getRegistry());

saveSettings(testDataSource, true);
saveSettings(testDataSource);
testDataSource.setTemporary(true);

// Generate new ID to avoid session conflicts in QM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public IWizardPage getPage(String name) {
public boolean performFinish() {
DataSourceDescriptor dsCopy = new DataSourceDescriptor(originalDataSource, originalDataSource.getRegistry());
DataSourceDescriptor dsChanged = new DataSourceDescriptor(dataSource, dataSource.getRegistry());
saveSettings(dsChanged, true);
saveSettings(dsChanged);

if (dsCopy.equalSettings(dsChanged)) {
// No changes
Expand Down Expand Up @@ -241,7 +241,7 @@ public boolean performFinish() {
}

// Save
saveSettings(originalDataSource, saveConnectionSettings);
saveSettings(originalDataSource);
originalDataSource.getRegistry().updateDataSource(originalDataSource);


Expand Down Expand Up @@ -290,19 +290,9 @@ public void init(IWorkbench workbench, IStructuredSelection selection) {
}

@Override
protected void saveSettings(DataSourceDescriptor dataSource, boolean isSaveConnectionSettings) {
if (isPageActive(pageSettings) && isSaveConnectionSettings) {
protected void saveSettings(DataSourceDescriptor dataSource) {
if (isPageActive(pageSettings)) {
pageSettings.saveSettings(dataSource);
if (pageGeneral.wasActivated()) {
Boolean isReadOnlyConnection = pageGeneral.isConnectionReadOnly();
if (isReadOnlyConnection != null) {
dataSource.setConnectionReadOnly(isReadOnlyConnection);
}
List<DBPDataSourcePermission> accessRestrictions = pageGeneral.getAccessRestrictions();
if (accessRestrictions != null) {
dataSource.setModifyPermissions(accessRestrictions);
}
}
}
pageGeneral.saveSettings(dataSource);
pageInit.saveSettings(dataSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public boolean performFinish()
DataSourceDescriptor dataSourceNew = new DataSourceDescriptor(
dataSourceRegistry, dataSourceTpl.getId(), driver, dataSourceTpl.getConnectionConfiguration());
dataSourceNew.copyFrom(dataSourceTpl);
saveSettings(dataSourceNew, true);
saveSettings(dataSourceNew);
dataSourceRegistry.addDataSource(dataSourceNew);
return true;
}
Expand All @@ -217,7 +217,7 @@ public void init(IWorkbench workbench, IStructuredSelection selection)
}

@Override
protected void saveSettings(DataSourceDescriptor dataSource, boolean isSaveConnectionSettings) {
protected void saveSettings(DataSourceDescriptor dataSource) {
ConnectionPageSettings pageSettings = getPageSettings(dataSource.getDriver());
if (pageSettings != null) {
pageSettings.saveSettings(dataSource);
Expand Down

0 comments on commit dc371f4

Please sign in to comment.