|
24 | 24 | import org.eclipse.swt.layout.GridData; |
25 | 25 | import org.eclipse.swt.layout.GridLayout; |
26 | 26 | import org.eclipse.swt.widgets.*; |
| 27 | +import org.jkiss.dbeaver.ext.hana.model.HANAConstants; |
27 | 28 | import org.jkiss.dbeaver.ext.hana.ui.internal.HANAEdition; |
28 | 29 | import org.jkiss.dbeaver.ext.hana.ui.internal.HANAMessages; |
29 | 30 | import org.jkiss.dbeaver.model.DBPDataSourceContainer; |
@@ -120,7 +121,7 @@ public void createControl(Composite composite) { |
120 | 121 | editionCombo.addSelectionListener(new SelectionAdapter() { |
121 | 122 | @Override public void widgetSelected(SelectionEvent e) { editionUpdated(); site.updateButtons(); } |
122 | 123 | }); |
123 | | - hostText.addModifyListener(e -> site.updateButtons()); |
| 124 | + hostText.addModifyListener(e -> { hostUpdated(); site.updateButtons(); }); |
124 | 125 | portText.addModifyListener(e -> site.updateButtons()); |
125 | 126 | instanceText.addModifyListener(e -> { instanceUpdated(); site.updateButtons(); }); |
126 | 127 | databaseText.addModifyListener(e -> site.updateButtons()); |
@@ -182,7 +183,7 @@ public void loadSettings() { |
182 | 183 | super.loadSettings(); |
183 | 184 | DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration(); |
184 | 185 | edition = HANAEdition.fromName(connectionInfo.getProviderProperty(PROV_PROP_EDITION)); |
185 | | - portValue = CommonUtils.toString(connectionInfo.getHostPort(), site.getDriver().getDefaultPort()); |
| 186 | + portValue = CommonUtils.toString(connectionInfo.getHostPort()/*, site.getDriver().getDefaultPort()*/); |
186 | 187 | instanceValue = CommonUtils.notEmpty(connectionInfo.getProviderProperty(PROV_PROP_INSTANCE_NUMBER)); |
187 | 188 | databaseValue = CommonUtils.notEmpty(getProperty(connectionInfo, PROP_DATABASE_NAME)); |
188 | 189 | if (created) { |
@@ -290,21 +291,34 @@ private void editionUpdated() { |
290 | 291 | } |
291 | 292 | UIUtils.fixReadonlyTextBackground(databaseText); |
292 | 293 |
|
293 | | - toggleControlVisibility(instanceLabel); |
294 | | - toggleControlVisibility(instanceText); |
295 | | - toggleControlVisibility(databaseLabel); |
296 | | - toggleControlVisibility(databaseText); |
| 294 | + boolean visible = edition != HANAEdition.GENERIC && edition != HANAEdition.CLOUD; |
| 295 | + toggleControlVisibility(instanceLabel, visible); |
| 296 | + toggleControlVisibility(instanceText, visible); |
| 297 | + toggleControlVisibility(databaseLabel, visible); |
| 298 | + toggleControlVisibility(databaseText, visible); |
297 | 299 | ((Composite)getControl()).layout(true, true); |
298 | 300 | } |
299 | 301 |
|
300 | | - private void toggleControlVisibility(Control control) { |
301 | | - control.setVisible(edition != HANAEdition.GENERIC); |
| 302 | + private void toggleControlVisibility(Control control, boolean visible) { |
| 303 | + control.setVisible(visible); |
302 | 304 | Object layoutData = control.getLayoutData(); |
303 | 305 | if (layoutData instanceof GridData) { |
304 | | - ((GridData) layoutData).exclude = (edition == HANAEdition.GENERIC); |
| 306 | + ((GridData) layoutData).exclude = !visible; |
305 | 307 | } |
306 | 308 | } |
307 | 309 |
|
| 310 | + private void hostUpdated() { |
| 311 | + if (CommonUtils.isEmpty(hostText.getText())) { |
| 312 | + return; |
| 313 | + } |
| 314 | + String host = hostText.getText().trim(); |
| 315 | + if (edition == HANAEdition.GENERIC && CommonUtils.isEmpty(portText.getText()) && host.endsWith(HANAConstants.HTTPS_PORT_SUFFIX)) { |
| 316 | + hostText.setText(host.substring(0, host.length() - HANAConstants.HTTPS_PORT_SUFFIX.length())); |
| 317 | + editionCombo.select(editionCombo.indexOf(HANAEdition.CLOUD.getTitle())); |
| 318 | + editionUpdated(); |
| 319 | + } |
| 320 | + } |
| 321 | + |
308 | 322 | private void instanceUpdated() { |
309 | 323 | if (CommonUtils.isEmpty(instanceText.getText())) { |
310 | 324 | return; |
|
0 commit comments