@Override public void loadSettings() { super.loadSettings(); // Load values from new connection info DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration(); this.parseSampleURL(site.getDriver()); if (!isCustom) { if (hostText != null) { if (!CommonUtils.isEmpty(connectionInfo.getHostName())) { hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName())); } else { hostText.setText("localhost"); // $NON-NLS-1$ } } if (portText != null) { if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) { portText.setText(String.valueOf(connectionInfo.getHostPort())); } else if (site.getDriver().getDefaultPort() != null) { portText.setText(site.getDriver().getDefaultPort()); } else { portText.setText(""); // $NON-NLS-1$ } } if (serverText != null) { serverText.setText(CommonUtils.notEmpty(connectionInfo.getServerName())); } if (dbText != null) { dbText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName())); } if (pathText != null) { pathText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName())); } } else { hostText.setText(""); // $NON-NLS-1$ portText.setText(""); // $NON-NLS-1$ serverText.setText(""); // $NON-NLS-1$ dbText.setText(""); // $NON-NLS-1$ pathText.setText(""); // $NON-NLS-1$ } if (userNameText != null) { userNameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName())); } if (passwordText != null) { passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword())); } if (urlText != null) { if (connectionInfo.getUrl() != null) { urlText.setText(CommonUtils.notEmpty(connectionInfo.getUrl())); } else { urlText.setText(""); // $NON-NLS-1$ } } activated = true; }
private void createEmbeddedDatabase() { String paramCreate = CommonUtils.toString( site.getDriver().getDriverParameter(GenericConstants.PARAM_CREATE_URL_PARAM)); DataSourceDescriptor dataSource = (DataSourceDescriptor) site.getActiveDataSource(); final DataSourceDescriptor testDataSource = new DataSourceDescriptor( site.getDataSourceRegistry(), dataSource.getId(), dataSource.getDriver(), new DBPConnectionConfiguration(dataSource.getConnectionConfiguration())); saveSettings(testDataSource); DBPConnectionConfiguration cfg = testDataSource.getConnectionConfiguration(); cfg.setUrl(cfg.getUrl() + paramCreate); String databaseName = cfg.getDatabaseName(); testDataSource.setName(databaseName); if (!UIUtils.confirmAction( getShell(), "Create Database", "Are you sure you want to create database '" + databaseName + "'?")) { testDataSource.dispose(); return; } try { site.getRunnableContext() .run( true, true, new DBRRunnableWithProgress() { @Override public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { createEmbeddedDatabase(monitor, testDataSource); } catch (DBException e1) { throw new InvocationTargetException(e1); } } }); MessageDialog.openInformation( getShell(), "Database Create", "Database '" + databaseName + "' created!"); } catch (InvocationTargetException e1) { UIUtils.showErrorDialog( getShell(), "Create database", "Error creating database", e1.getTargetException()); } catch (InterruptedException e1) { // Just ignore } }