Beispiel #1
0
    @Override
    public void layerRemoved(LayerCollectionEvent e) {
      HashSet<ILayer> newSelection = new HashSet<ILayer>();
      newSelection.addAll(Arrays.asList(selectedLayers));
      ILayer[] affected = e.getAffected();
      for (final ILayer layer : affected) {
        // Check active
        if (activeLayer == layer) {
          setActiveLayer(null);
        }

        // Check selection
        newSelection.remove(layer);
        layer.removeLayerListenerRecursively(openerListener);
        if (isOpen()) {
          try {
            layer.close();
          } catch (LayerException e1) {
            LOGGER.warn(I18N.tr("Cannot close layer {0}", layer.getName()), e1);
          }
        }
      }

      setSelectedLayers(newSelection.toArray(new ILayer[newSelection.size()]));
      // checkIfHasToResetSRID();
    }
Beispiel #2
0
 @Override
 public void layerAdded(LayerCollectionEvent e) {
   if (isOpen()) {
     for (final ILayer layer : e.getAffected()) {
       try {
         layer.open();
         layer.addLayerListenerRecursively(openerListener);
         // checking & possibly setting SRID
         // checkSRID(layer);
       } catch (LayerException ex) {
         LOGGER.error(I18N.tr("Cannot open layer : {0} ", layer.getName()), ex);
         try {
           layer.getParent().remove(layer);
         } catch (LayerException e1) {
           LOGGER.error(I18N.tr("Cannot remove the layer {0}", layer.getName()), ex);
         }
       }
     }
   }
 }