Пример #1
0
  protected void copy(EditorConfiguration src, EditorConfiguration dst) {
    dst.title = src.title;
    dst.mimeType = src.mimeType;
    Enumeration styleNames = src.styleContext.getStyleNames();
    if (src.styleContext == dst.styleContext) dst.styleContext = new StyleContext();
    while (styleNames.hasMoreElements()) {
      String sname = (String) styleNames.nextElement();
      Style style = src.styleContext.getStyle(sname);

      Style newStyle = dst.styleContext.addStyle(sname, null);
      newStyle.addAttributes(style.copyAttributes());
    }

    styleNames = dst.styleContext.getStyleNames();
    while (styleNames.hasMoreElements()) {
      String sname = (String) styleNames.nextElement();
      Style style = src.styleContext.getStyle(sname);
      AttributeSet resolveParent = style.getResolveParent();
      Style parent = (Style) resolveParent;

      if (parent != null) {
        dst.styleContext
            .getStyle(sname)
            .setResolveParent(dst.styleContext.getStyle(parent.getName()));
      }
    }
  }
    @Override
    public void sourceAdded(SourceEvent e) {
      String name = e.getName();
      SourceManager sm = dsf.getSourceManager();
      if (e.isWellKnownName()
          && !sm.getSource(name).isSystemTableSource()
          && !layerMap.containsKey(name)) {
        try {
          Layer layer = new Layer();
          layer.setName(name);
          layer.setTitle(name);

          // Setting the bounding box data
          DataSource ds = dsf.getDataSource(name);
          ds.open();
          Envelope env = ds.getFullExtent();
          CoordinateReferenceSystem crs = ds.getCRS();
          ds.close();
          BoundingBox bBox = getBoundingBox(env, crs);
          if (bBox == null) {
            return;
          }
          layer.getCRS().add(bBox.getCRS());
          layer.getBoundingBox().add(bBox);
          layer.setEXGeographicBoundingBox(getGeographicBoundingBox(env, bBox.getCRS()));
          layer.setQueryable(true);
          if (layerStyles.containsKey(name)) {
            String[] lStyles = layerStyles.get(name);
            for (int i = 0; i < lStyles.length; i++) {
              Style style = new Style();
              String styleName = lStyles[i];
              style.setName(styleName);
              style.setTitle(styleName);
              layer.getStyle().add(style);
            }
          }
          layerMap.put(name, layer);
        } catch (NoSuchTableException ex) {
        } catch (DataSourceCreationException ex) {
        } catch (DriverException ex) {
        }
      }
    }