protected String refreshListSelection(String layerName) {
    try {

      Collection collection = geopistaEditor.getSelection();
      if (collection.iterator().hasNext()) {
        GeopistaFeature feature = (GeopistaFeature) collection.iterator().next();
        if (feature == null) {
          logger.error("feature: " + feature);
          return null;
        }

        if (layerName != null && feature.getLayer() != null) {
          if (!layerName.equals(feature.getLayer().getName())) return null;
        }
        // String id = checkNull(feature.getAttribute(0));
        String id = checkNull(feature.getSystemId());
        logger.info("id: -" + id + "-");
        return id;
      }
    } catch (Exception ex) {

      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      logger.error("Exception: " + sw.toString());
      return null;
    }
    return null;
  }
  /**
   * @param context
   * @throws IOException
   */
  private void saveTrafficRegulationInformation(PlugInContext context, TaskMonitor monitor)
      throws IOException {

    String netName = "";
    if (getSelectedLayer().getSystemId().startsWith("Arcos-")) {
      String[] a = getSelectedLayer().getSystemId().split("-");
      netName = a[1];
      System.out.println(a.length);
      for (int i = 2; i < a.length; i++) {
        netName = netName + "-" + a[i];
      }
    } else {
      netName = getSelectedLayer().getSystemId();
    }

    ArrayList<GeopistaFeature> listaFeatures = this.getSelectedsArrayListStreetFeature();
    ArrayList<Integer> listaEdgeIds = this.getSelectedsArrayListEdgesIds();

    for (int i = 0; i < listaFeatures.size(); i++) {

      monitor.report("Modificando Direccion tramo " + i + " de " + listaEdgeIds.size());

      Edge selectedEdge = searchEdgeByIdAndNetworkName(context, netName, listaEdgeIds.get(i));

      if (selectedEdge instanceof LocalGISStreetDynamicEdge) {
        // Se actualiza el StreetEdge
        ((LocalGISStreetDynamicEdge) selectedEdge).setTrafficRegulation(getTrafficRegualtion());

        RouteArrowLineStyle line =
            new RouteArrowLineStyle.BiDirect(
                (Viewport) context.getLayerViewPanel().getViewport(),
                (Graphics2D) ((LayerViewPanel) context.getLayerViewPanel()).getGraphics());
        if (this.getSelectedLayer().getStyle(RouteArrowLineStyle.class) != null) {
          getSelectedLayer().removeStyle(getSelectedLayer().getStyle(RouteArrowLineStyle.class));
        }
        getSelectedLayer().addStyle(line);

        GeopistaFeature feat = listaFeatures.get(i);

        if (feat != null) {
          // se actualiza el valor de la feature
          feat.setAttribute(
              I18N.get(
                  "regulacionTrafico",
                  "routeengine.trafficregulation.trafficregulationattributename"),
              getTrafficRegualtion().toString());
          //					this.paintBidirectTrafiicRegulation(getTrafficRegualtion());

          if (feat.getSchema().hasAttribute("pintadaRegulacionTrafico")
              && feat.getAttribute("pintadaRegulacionTrafico") != null
              && feat.getAttribute("pintadaRegulacionTrafico") instanceof Integer) {
            try {
              feat.setAttribute("pintadaRegulacionTrafico", 1);
            } catch (Exception e) {
            }
          }
        }

        context.getLayerViewPanel().repaint();
      }
      NetworkManager nManager = NetworkModuleUtilWorkbench.getNetworkManager(context);
      Network actualNetwork = nManager.getNetwork(netName);

      // intentamos insercion en la base de datos de la velocidad de la v�a
      Category categoryLayer = context.getLayerManager().getCategory(getSelectedLayer());
      if (!categoryLayer.getName().equals("")) {
        if (actualNetwork.getGraph() instanceof DynamicGraph
            && ((DynamicGraph) actualNetwork.getGraph()).getMemoryManager()
                instanceof SpatialAllInMemoryExternalSourceMemoryManager) {
          RouteConnectionFactory routeConnection = new GeopistaRouteConnectionFactoryImpl();
          LocalGISNetworkDAO lnDAO = new LocalGISNetworkDAO();
          Connection connection = null;
          try {
            connection = routeConnection.getConnection();
            lnDAO.updateStreetData(netName, (LocalGISStreetDynamicEdge) selectedEdge, connection);
          } catch (SQLException e) {
            e.printStackTrace();
          } catch (Exception e) {
            e.printStackTrace();
          } finally {
            ConnectionUtilities.closeConnection(connection);
          }
        }
      }
    }
  }
  public static Geometry obtenerGeometriaParcela(String dxf, WorkbenchContext context) {

    Geometry geometryParcela = null;

    GeopistaLoadDxfQueryChooser dxfLoad =
        new GeopistaLoadDxfQueryChooser(Dxf.class, "GEOPISTA dxf", extensions(Dxf.class), context);

    InputStream fileDXF = ImportarUtils_LCGIII.parseStringToIS(dxf);

    try {
      Assert.isTrue(!dxfLoad.getDataSourceQueries(fileDXF).isEmpty());
    } catch (AssertionFailedException e) {
      throw new AssertionFailedException(I18N.get("FileEmpty"));
    }

    fileDXF = ImportarUtils_LCGIII.parseStringToIS(dxf);

    boolean exceptionsEncountered = false;
    for (Iterator i = dxfLoad.getDataSourceQueries(fileDXF).iterator(); i.hasNext(); ) {
      DataSourceQuery dataSourceQuery = (DataSourceQuery) i.next();

      ArrayList exceptions = new ArrayList();
      Assert.isTrue(dataSourceQuery.getDataSource().isReadable());

      Connection connection = dataSourceQuery.getDataSource().getConnection();
      try {
        FeatureCollection dataset =
            dataSourceQuery
                .getDataSource()
                .installCoordinateSystem(
                    connection.executeQuery(dataSourceQuery.getQuery(), exceptions, null), null);
        if (dataset != null) {

          String layerName = dataSourceQuery.toString();
          Geometry geometriaInicial = null;
          GeopistaFeature featureInicial = null;

          if (layerName.startsWith("PG-LP")) {
            // Obtener el borde con las features de la capa
            ArrayList lstFeatures = new ArrayList();
            for (Iterator features = dataset.getFeatures().iterator(); features.hasNext(); ) {
              GeopistaFeature feature = (GeopistaFeature) features.next();
              lstFeatures.add(feature);
            }
            ArrayList coordenadas = new ArrayList();

            if (lstFeatures != null && lstFeatures.size() > 0) {

              featureInicial = (GeopistaFeature) lstFeatures.iterator().next();
              lstFeatures.remove(featureInicial);
              geometriaInicial = featureInicial.getGeometry();
              for (int indice = 0; indice < geometriaInicial.getCoordinates().length; indice++)
                coordenadas.add(geometriaInicial.getCoordinates()[indice]);

              if (geometriaInicial instanceof LineString) {

                Point puntoFinal = ((LineString) geometriaInicial).getEndPoint();
                GeopistaFeature feature = null;
                Geometry geometria = null;
                int indice;

                while (lstFeatures.size() > 0) {
                  boolean encontrado = false;
                  Iterator features = lstFeatures.iterator();
                  while (features.hasNext() && !encontrado) {

                    feature = (GeopistaFeature) features.next();
                    geometria = feature.getGeometry();
                    if (geometria instanceof LineString) {

                      if (puntoFinal.distance(((LineString) geometria).getStartPoint()) == 0) {

                        for (indice = 1; indice < geometria.getCoordinates().length; indice++)
                          coordenadas.add(geometria.getCoordinates()[indice]);
                        puntoFinal = ((LineString) geometria).getEndPoint();
                        encontrado = true;

                      } else if (puntoFinal.distance(((LineString) geometria).getEndPoint()) == 0) {
                        for (indice = geometria.getCoordinates().length - 2; indice >= 0; indice--)
                          coordenadas.add(geometria.getCoordinates()[indice]);

                        puntoFinal = ((LineString) geometria).getStartPoint();
                        encontrado = true;
                      }
                    }
                  }
                  if (encontrado) {
                    lstFeatures.remove(feature);
                  }
                }
                Coordinate[] coordenadasParcela = new Coordinate[coordenadas.size()];
                indice = 0;
                for (Iterator coordenada = coordenadas.iterator(); coordenada.hasNext(); ) {
                  coordenadasParcela[indice] = (Coordinate) coordenada.next();
                  indice++;
                }

                if (coordenadasParcela[0].equals3D(
                    coordenadasParcela[coordenadasParcela.length - 1])) {
                  LinearRing lineaParcela =
                      geometriaInicial.getFactory().createLinearRing(coordenadasParcela);
                  Polygon poligonoParcela = null;
                  poligonoParcela = geometriaInicial.getFactory().createPolygon(lineaParcela, null);
                  geometryParcela = poligonoParcela;
                }
              }
            }
          }
        }
      } finally {
        connection.close();
      }
      if (!exceptions.isEmpty()) {
        if (!exceptionsEncountered) {
          context.getIWorkbench().getFrame().getOutputFrame().createNewDocument();
          exceptionsEncountered = true;
        }
        reportExceptions(exceptions, dataSourceQuery, context);
      }
    }
    if (exceptionsEncountered) {
      context
          .getIWorkbench()
          .getGuiComponent()
          .warnUser("Problems were encountered. See Output Window for details.");
    }

    return geometryParcela;
  }