private void exportReferenceSystems() {
    try {
      setSettings();

      if (config.getProject().getDatabase().getReferenceSystems().isEmpty()) {
        LOG.error("There are no user-defined reference systems to be exported.");
        return;
      }

      topFrame.clearConsole();
      topFrame.setStatusText(Language.I18N.getString("main.status.database.srs.export.label"));

      String fileName = fileText.getText().trim();
      if (fileName.length() == 0) {
        LOG.error("Please specify the export file for the reference systems.");
        topFrame.errorMessage(
            Language.I18N.getString("common.dialog.error.io.title"),
            Language.I18N.getString("pref.db.srs.error.write.msg"));
        return;
      }

      if ((!fileName.contains("."))) {
        fileName += ".xml";
        fileText.setText(fileName);
      }

      File file = new File(fileName);
      LOG.info("Writing reference systems to file '" + file.getAbsolutePath() + "'.");

      DatabaseSrsList refSys = new DatabaseSrsList();
      for (DatabaseSrs tmp : config.getProject().getDatabase().getReferenceSystems()) {
        DatabaseSrs copy = new DatabaseSrs(tmp);
        copy.setId(null);
        refSys.addItem(copy);

        LOG.info(
            "Writing reference system '"
                + tmp.getDescription()
                + "' (SRID: "
                + tmp.getSrid()
                + ").");
      }

      ConfigUtil.marshal(refSys, file, getJAXBContext());
      LOG.info("Reference systems successfully written to file '" + file.getAbsolutePath() + "'.");
    } catch (JAXBException jaxb) {
      String msg = jaxb.getMessage();
      if (msg == null && jaxb.getLinkedException() != null)
        msg = jaxb.getLinkedException().getMessage();

      LOG.error("Failed to write file: " + msg);
      topFrame.errorMessage(
          Language.I18N.getString("common.dialog.error.io.title"),
          MessageFormat.format(Language.I18N.getString("common.dialog.file.write.error"), msg));
    } finally {
      topFrame.setStatusText(Language.I18N.getString("main.status.ready.label"));
    }
  }
  private void importReferenceSystems(boolean replace) {
    try {
      topFrame.clearConsole();
      topFrame.setStatusText(Language.I18N.getString("main.status.database.srs.import.label"));

      File file = new File(fileText.getText().trim());
      String msg = "";

      if (replace) msg += "Replacing reference systems with those from file '";
      else msg += "Adding reference systems from file '";

      LOG.info(msg + file.getAbsolutePath() + "'.");

      if (!file.exists() || !file.isFile() || !file.canRead()) {
        LOG.error("Failed to open reference system file.");
        topFrame.errorMessage(
            Language.I18N.getString("common.dialog.error.io.title"),
            MessageFormat.format(
                Language.I18N.getString("common.dialog.file.read.error"),
                Language.I18N.getString("pref.db.srs.error.read.msg")));
        return;
      }

      Object object = ConfigUtil.unmarshal(file, getJAXBContext());
      if (object instanceof DatabaseSrsList) {
        DatabaseSrsList refSyss = (DatabaseSrsList) object;
        if (replace) config.getProject().getDatabase().getReferenceSystems().clear();

        if (dbPool.isConnected())
          LOG.info("Checking whether reference systems are supported by database profile.");

        for (DatabaseSrs refSys : refSyss.getItems()) {
          msg =
              "Adding reference system '"
                  + refSys.getDescription()
                  + "' (SRID: "
                  + refSys.getSrid()
                  + ").";

          if (dbPool.isConnected()) {
            try {
              dbPool.getActiveDatabaseAdapter().getUtil().getSrsInfo(refSys);
              if (!refSys.isSupported()) msg += " (NOT supported)";
              else msg += " (supported)";

            } catch (SQLException sqlEx) {
              LOG.error("Error while checking user-defined SRSs: " + sqlEx.getMessage().trim());
            }
          }

          config.getProject().getDatabase().getReferenceSystems().add(refSys);
          LOG.info(msg);
        }

        updateSrsComboBoxes(true);
        displaySelectedValues();

        LOG.info(
            "Reference systems successfully imported from file '" + file.getAbsolutePath() + "'.");
      } else
        LOG.error(
            "Could not find reference system definitions in file '"
                + file.getAbsolutePath()
                + "'.");

    } catch (JAXBException jaxb) {
      String msg = jaxb.getMessage();
      if (msg == null && jaxb.getLinkedException() != null)
        msg = jaxb.getLinkedException().getMessage();

      LOG.error("Failed to parse file: " + msg);
      topFrame.errorMessage(
          Language.I18N.getString("common.dialog.error.io.title"),
          MessageFormat.format(Language.I18N.getString("common.dialog.file.read.error"), msg));
    } catch (IOException e) {
      String msg = e.getMessage();
      LOG.error("Failed to access file: " + msg);
      topFrame.errorMessage(
          Language.I18N.getString("common.dialog.error.io.title"),
          MessageFormat.format(Language.I18N.getString("common.dialog.file.read.error"), msg));
    } finally {
      topFrame.setStatusText(Language.I18N.getString("main.status.ready.label"));
    }
  }