Ejemplo n.º 1
0
  public boolean setDataset(InvDatasetImpl ds) {
    if (!accept()) return false;

    this.dataset = ds;
    this.leafDataset = null;
    exampleButton.setText("Example Dataset");

    //////////
    PersistentBean persBean = new PersistentBean(ds);

    setEditValue(NAME, persBean, 0);
    setEditValue(ID, persBean, 0);

    setEditValueWithInheritence(AUTHORITY, persBean);
    setEditValueWithInheritence(SERVICE_NAME, persBean);

    setEditValueWithInheritence(FORMAT_TYPE, persBean);
    setEditValueWithInheritence(DATA_TYPE, persBean);

    setEditValue(COLLECTION_TYPE, persBean, 0);
    setEditValue(HARVEST, persBean, 0);

    // gotta find which GeospatialCoverage to use.
    int mode = 0;
    ThreddsMetadata.GeospatialCoverage gc = ds.getLocalMetadata().getGeospatialCoverage();
    if ((gc == null) || gc.isEmpty()) {
      gc = ds.getLocalMetadataInheritable().getGeospatialCoverage();
      mode = 1;
    }
    if ((gc == null) || gc.isEmpty()) {
      gc = ds.getGeospatialCoverage();
      mode = 2; // inherited
    }
    metadataPP.setFieldValue(GC_TYPE, inherit_types.get(mode));
    setGC(gc, mode);

    // gotta find which TimeCoverage to use.
    mode = 0;
    DateRange tc = ds.getLocalMetadata().getTimeCoverage();
    if (tc == null) {
      tc = ds.getLocalMetadataInheritable().getTimeCoverage();
      mode = 1;
    }
    if (tc == null) {
      tc = ds.getTimeCoverage();
      mode = 2; // inherited
    }
    metadataPP.setFieldValue(TC_TYPE, inherit_types.get(mode));
    if (tc != null) dateRangeSelector.setDateRange(tc);
    setTCmode(mode);

    setEditValueWithInheritence(SUMMARY, persBean);
    setEditValueWithInheritence(RIGHTS, persBean);
    setEditValueWithInheritence(HISTORY, persBean);
    setEditValueWithInheritence(PROCESSING, persBean);

    setVariables(variablesFld);
    setBeanList(creatorsFld, CREATORS, persBean);
    setBeanList(publishersFld, PUBLISHERS, persBean);
    setBeanList(projectsFld, PROJECTS, persBean);
    setBeanList(keywordsFld, KEYWORDS, persBean);
    setBeanList(datesFld, DATES, persBean);
    setBeanList(contributorsFld, CONTRIBUTORS, persBean);
    setBeanList(docsFld, DOCUMENTATION, persBean);

    if (ds instanceof InvDatasetScan) {
      dscanPP.setEnabled(true);
      setEditValue(dscanPP, DSCAN_PATH, persBean, 0);
      setEditValue(dscanPP, DSCAN_DIR, persBean, 0);
      // setEditValue( dscanPP, DSCAN_FILTER, persBean, 0);
      setEditValue(dscanPP, DSCAN_ADDSIZE, persBean, 0);
      // setEditValue( dscanPP, DSCAN_ADDLATEST, persBean, 0);
      // setEditValue( dscanPP, DSCAN_TC_MATCH, persBean, 0);
      // setEditValue( dscanPP, DSCAN_TC_SUBS, persBean, 0);
      // setEditValue( dscanPP, DSCAN_TC_DURATOPN, persBean, 0);
    } else dscanPP.setEnabled(false);

    return true;
  }
Ejemplo n.º 2
0
  public void store2Dataset() {
    PersistentBean persBean = new PersistentBean(dataset); // reset the BeanMaps

    setStoreValue(NAME, persBean, false);
    setStoreValue(ID, persBean, false);

    setStoreValue(AUTHORITY, persBean, true);
    setStoreValue(SERVICE_NAME, persBean, true);

    setStoreValue(FORMAT_TYPE, persBean, true);
    setStoreValue(DATA_TYPE, persBean, true);

    setStoreValue(COLLECTION_TYPE, persBean, false);
    setStoreValue(HARVEST, persBean, false);

    String gcType = (String) metadataPP.getFieldValue(GC_TYPE);
    if (!gcType.equals(INHERITED)) {
      ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage();
      storeGC(new PersistentBean(gc));
      if (gcType.equals(LOCAL)) {
        dataset.getLocalMetadata().setGeospatialCoverage(gc);
        dataset.getLocalMetadataInheritable().setGeospatialCoverage(null);

      } else {
        dataset.getLocalMetadata().setGeospatialCoverage(null);
        dataset.getLocalMetadataInheritable().setGeospatialCoverage(gc);
      }
    }

    String tcType = (String) metadataPP.getFieldValue(TC_TYPE);
    if (!tcType.equals(INHERITED)) {
      DateRange dateRange = dateRangeSelector.getDateRange();
      if (tcType.equals(LOCAL)) {
        dataset.getLocalMetadata().setTimeCoverage(dateRange);
        dataset.getLocalMetadataInheritable().setTimeCoverage(null);

      } else {
        dataset.getLocalMetadata().setTimeCoverage(null);
        dataset.getLocalMetadataInheritable().setTimeCoverage(dateRange);
      }
    }

    setStoreValue(SUMMARY, persBean, true);
    setStoreValue(RIGHTS, persBean, true);
    setStoreValue(HISTORY, persBean, true);
    setStoreValue(PROCESSING, persBean, true);

    // storeBeanList( variablesFld, VARIABLES, persBean);
    storeBeanList(creatorsFld, CREATORS, persBean);
    storeBeanList(publishersFld, PUBLISHERS, persBean);
    storeBeanList(projectsFld, PROJECTS, persBean);
    storeBeanList(keywordsFld, KEYWORDS, persBean);
    storeBeanList(datesFld, DATES, persBean);
    storeBeanList(contributorsFld, CONTRIBUTORS, persBean);
    storeBeanList(docsFld, DOCUMENTATION, persBean);

    if (dataset instanceof InvDatasetScan) {
      setStoreValue(dscanPP, DSCAN_PATH, persBean, false);
      setStoreValue(dscanPP, DSCAN_DIR, persBean, false);
      // setStoreValue( dscanPP, DSCAN_FILTER, persBean, false);
      setStoreValue(dscanPP, DSCAN_ADDSIZE, persBean, false);
      // setStoreValue( dscanPP, DSCAN_ADDLATEST, persBean, false);
      // setStoreValue( dscanPP, DSCAN_TC_MATCH, persBean, false);
      // setStoreValue( dscanPP, DSCAN_TC_SUBS, persBean, false);
      // setStoreValue( dscanPP, DSCAN_TC_DURATOPN, persBean, false);
    }

    dataset.finish();
  }
Ejemplo n.º 3
0
  public DatasetEditor() {
    JTabbedPane tabs = new JTabbedPane();

    metadataPP = new PrefPanel("Edit Catalog Dataset", null, null);
    tabs.add("metadata", metadataPP);

    int row = 0;
    metadataPP.addHeading("Basic", row++);

    // row 0
    metadataPP.addTextField(NAME, "Name", "", 0, row++, "8,1");
    // row 1
    metadataPP.addTextField(ID, "ID", "", 0, row, null);
    addPopups(metadataPP.addTextField(AUTHORITY, "Authority", "", 2, row, null));
    addPopups(metadataPP.addTextField(SERVICE_NAME, "Service", "", 4, row, null));

    row++;
    // row 2
    addPopups(
        metadataPP.addEnumComboField(
            FORMAT_TYPE, "Data format", DataFormatType.getAllTypes(), true, 0, row, null));
    addPopups(
        metadataPP.addEnumComboField(
            DATA_TYPE, "Data type", Arrays.asList(FeatureType.values()), true, 2, row, null));
    metadataPP.addEnumComboField(
        COLLECTION_TYPE, "Collection type", CollectionType.getAllTypes(), true, 4, row++, null);

    ////////////
    metadataPP.addHeading("GeoSpatial Coverage", row++);

    // addCheckBoxField("localMetadata.geospatialCoverage.global", "Global", false, 0, row);
    gc_type = metadataPP.addEnumComboField(GC_TYPE, "type", inherit_types, false, 0, row, null);
    gc_type.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            String mode = (String) gc_type.getValue();
            setGCmode(getMode(mode));
          }
        });

    extractGCButton = makeButton("Extract Geospatial");
    extractGCButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            extractGeospatial();
          }
        });
    metadataPP.addComponent(extractGCButton, 2, row, "left, center");

    metadataPP.addCheckBoxField(ZPOSITIVE_UP, "Z positive up", false, 4, row);
    row++;

    /* JPanel geoPanel = new JPanel();
    Field.CheckBox global = new Field.CheckBox( "localMetadata.geospatialCoverage.global", "Global", false, persBean);
    geoPanel.add( new JLabel("Global: "));
    geoPanel.add( global.getEditComponent());
    geoPanel.add( new JButton("Read Dataset"));
    pp.addComponent(geoPanel, 0, row++, "left, center"); */

    // 4 columns in 3 rows
    metadataPP.addDoubleField(LAT_START, "Starting Latitude", 0.0, 5, 0, row, null);
    metadataPP.addDoubleField(LAT_EXTENT, "Size", 0.0, 5, 2, row, null);
    metadataPP.addDoubleField(LAT_RESOLUTION, "Resolution", 0.0, 5, 4, row, null);
    metadataPP.addTextField(LAT_UNITS, "Units", "", 6, row, null);
    metadataPP.addDoubleField(LON_START, "Starting Longitude", 0.0, 5, 0, row + 1, null);
    metadataPP.addDoubleField(LON_EXTENT, "Size", 0.0, 5, 2, row + 1, null);
    metadataPP.addDoubleField(LON_RESOLUTION, "Resolution", 0.0, 5, 4, row + 1, null);
    metadataPP.addTextField(LON_UNITS, "Units", "", 6, row + 1, null);
    metadataPP.addDoubleField(HEIGHT_START, "Starting Height", 0.0, 5, 0, row + 2, null);
    metadataPP.addDoubleField(HEIGHT_EXTENT, "Size", 0.0, 5, 2, row + 2, null);
    metadataPP.addDoubleField(HEIGHT_RESOLUTION, "Resolution", 0.0, 5, 4, row + 2, null);
    metadataPP.addTextField(HEIGHT_UNITS, "Units", "", 6, row + 2, null);
    // addTextField("localMetadata.geospatialCoverage.ZPositive", "Z is Positive", "up", 6, row+3,
    // null);
    row += 3;

    //////
    metadataPP.addHeading("Temporal Coverage", row++);
    tc_type = metadataPP.addEnumComboField(TC_TYPE, "type", inherit_types, false, 0, row++, null);
    tc_type.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            String mode = (String) tc_type.getValue();
            setTCmode(getMode(mode));
          }
        });

    DateRange range = null;
    try {
      range = new DateRange();
    } catch (Exception e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
    dateRangeSelector = new RangeDateSelector("", range, false, false, null, false, false);
    DateField minDateField = dateRangeSelector.getMinDateField();
    DateField maxDateField = dateRangeSelector.getMaxDateField();
    DurationField durationField = dateRangeSelector.getDurationField();
    DurationField resolutionField = dateRangeSelector.getResolutionField();

    metadataPP.addField(minDateField, 0, row, null);
    metadataPP.addField(maxDateField, 2, row, null);
    metadataPP.addField(durationField, 4, row, null);
    metadataPP.addField(resolutionField, 6, row++, null);

    ////
    metadataPP.addHeading("Digital Library Info", row++);
    metadataPP.addCheckBoxField(HARVEST, "Harvest", false, 0, row++);

    addPopups(metadataPP.addTextAreaField(SUMMARY, "Summary", null, 7, 0, row, "3,1"));
    addPopups(metadataPP.addTextAreaField(RIGHTS, "Rights", null, 2, 0, row + 1, "3,1"));

    addPopups(metadataPP.addTextAreaField(HISTORY, "History", null, 7, 4, row, "3,1"));
    addPopups(metadataPP.addTextAreaField(PROCESSING, "Process", null, 2, 4, row + 1, "3,1"));
    row += 2;

    metadataPP.addEmptyRow(row++, 10);

    JTabbedPane tabPane = new JTabbedPane();
    metadataPP.addComponent(tabPane, 0, row++, "8,1");

    tables = new ArrayList();

    tabPane.addTab("Variables", makeVariablesPanel());
    tables.add(variablesFld);

    creatorsFld =
        new Field.BeanTable(CREATORS, "Creators", null, ThreddsMetadata.Source.class, null, null);
    tabPane.addTab("Creators", creatorsFld.getEditComponent());
    tables.add(creatorsFld);

    publishersFld =
        new Field.BeanTable(
            PUBLISHERS, "Publishers", null, ThreddsMetadata.Source.class, null, null);
    tabPane.addTab("Publishers", publishersFld.getEditComponent());
    tables.add(publishersFld);

    projectsFld =
        new Field.BeanTable(PROJECTS, "Projects", null, ThreddsMetadata.Vocab.class, null, null);
    tabPane.addTab("Projects", projectsFld.getEditComponent());
    tables.add(projectsFld);

    keywordsFld =
        new Field.BeanTable(KEYWORDS, "Keywords", null, ThreddsMetadata.Vocab.class, null, null);
    tabPane.addTab("Keywords", keywordsFld.getEditComponent());
    tables.add(keywordsFld);

    datesFld = new Field.BeanTable(DATES, "Dates", null, DateType.class, null, null);
    tabPane.addTab("Dates", datesFld.getEditComponent());
    tables.add(datesFld);

    contributorsFld =
        new Field.BeanTable(
            CONTRIBUTORS, "Contributors", null, ThreddsMetadata.Contributor.class, null, null);
    tabPane.addTab("Contributors", contributorsFld.getEditComponent());
    tables.add(contributorsFld);

    docsFld =
        new Field.BeanTable(
            DOCUMENTATION, "Documentation", null, InvDocumentation.class, null, null);
    tabPane.addTab("Documentation", docsFld.getEditComponent());
    tables.add(docsFld);

    for (int i = 0; i < tables.size(); i++) addPopups((Field.BeanTable) tables.get(i));

    metadataPP.finish(false);

    makeDscanPanel();
    tabs.add("datasetScan", dscanPP);

    setLayout(new BorderLayout());
    add(tabs, BorderLayout.CENTER);
  }