private void write(StyledLayerDescriptor version) {
    if (layer != null && layer.getStyle() != null) {
      final MutableStyle style = layer.getStyle();
      final JFileChooser chooser = new JFileChooser();
      final int result = chooser.showSaveDialog(this);

      if (result == JFileChooser.APPROVE_OPTION) {
        XMLUtilities tool = new XMLUtilities();
        try {
          tool.writeStyle(chooser.getSelectedFile(), style, version);
        } catch (JAXBException ex) {
          Exceptions.printStackTrace(ex);
        }
      }
    }
  }
    /** {@inheritDoc } */
    @Override
    public MapLayer createLayer(Map<String, String> parameters) {
      load();

      final String coverageName = parameters.get(COVERAGENAME_PROP);

      try {
        final LayerCoverageReader coverageReader = database.createGridCoverageReader(coverageName);
        final MapLayer layer =
            MapBuilder.createCoverageLayer(
                coverageReader, RandomStyleFactory.createRasterStyle(), coverageName);

        final GISLayerSource source =
            new GISLayerSource(getInfo().getID(), parameters, CoverageSQLSource.this);
        layer.setUserPropertie(GISLayerSource.KEY_LAYER_INFO, source);

        return layer;
      } catch (CoverageStoreException ex) {
        Exceptions.printStackTrace(ex);
        return null;
      }
    }