Ejemplo n.º 1
0
  @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;
  }