示例#1
0
  private void setVariables(Field.BeanTableField beanTableField) {
    List<ThreddsMetadata.Variables> variableLists = dataset.getLocalMetadata().getVariables();
    if ((variableLists != null) && (variableLists.size() > 0)) {
      ThreddsMetadata.Variables vars = variableLists.get(0);
      beanTableField.setValue(vars.getVariableList());
      setMode(beanTableField, 0);
      return;
    }

    variableLists = dataset.getLocalMetadataInheritable().getVariables();
    if ((variableLists != null) && (variableLists.size() > 0)) {
      ThreddsMetadata.Variables vars = variableLists.get(0);
      beanTableField.setValue(vars.getVariableList());
      setMode(beanTableField, 1);
      return;
    }

    variableLists = dataset.getVariables();
    if ((variableLists != null) && (variableLists.size() > 0)) {
      ThreddsMetadata.Variables vars = variableLists.get(0);
      beanTableField.setValue(vars.getVariableList());
      setMode(beanTableField, vars.getVariableList().size() == 0 ? 1 : 2);
      return;
    }

    // clear out the table
    beanTableField.setValue(new ArrayList());
  }
示例#2
0
  private void extractVariables() {
    if (leafDataset == null) leafDataset = findLeafDataset(dataset);
    if (leafDataset == null) return;

    ThreddsMetadata.Variables vars;
    try {
      vars = MetadataExtractor.extractVariables(leafDataset);
    } catch (IOException e) {
      return;
    }

    if (vars != null) {
      ThreddsMetadata tm = dataset.getLocalMetadataInheritable();
      List<ThreddsMetadata.Variables> varsList = tm.getVariables();
      boolean replaced = false;
      for (int i = 0; i < varsList.size(); i++) {
        ThreddsMetadata.Variables vs = varsList.get(i);
        if (vs.getVocabulary().equals(vars.getVocabulary())) {
          varsList.set(i, vars); // replace
          replaced = true;
          break;
        }
      }
      if (!replaced) tm.addVariables(vars);

      variablesFld.setValue(vars.getVariableList());
      setMode(variablesFld, 1);
    }
  }
示例#3
0
 private void setBeanList(Field.BeanTableField beanTableField, String name, PersistentBean bean) {
   List value = (List) bean.getObject("localMetadata." + name); // local, non inheritable
   if ((value != null) && (value.size() > 0)) {
     beanTableField.setValue(value);
     setMode(beanTableField, 0);
   } else {
     value = (List) bean.getObject("localMetadataInheritable." + name); // local, inheritable
     if ((value != null) && (value.size() > 0)) {
       beanTableField.setValue(value);
       setMode(beanTableField, 1);
     } else {
       value = (List) bean.getObject(name); // inherited
       beanTableField.setValue(value);
       setMode(beanTableField, (value == null || value.size() == 0) ? 1 : 2);
     }
   }
 }
示例#4
0
  private void storeBeanList(
      Field.BeanTableField beanTableField, String name, PersistentBean bean) {
    if (bean == null) return;

    List newValue = (List) beanTableField.getValue();

    // if it matches whats already stored (inherited or not), dont need to store it
    List oldValue = (List) bean.getObject(name);
    if (newValue.equals(oldValue)) return;

    // otherwise store it
    if (isInheritable(beanTableField)) bean.putObject("localMetadataInheritable." + name, newValue);
    else bean.putObject("localMetadata." + name, newValue);
  }
示例#5
0
  private JPanel makeVariablesPanel() {
    variablesFld =
        new Field.BeanTableField(
            VARIABLES, "Variables", null, ThreddsMetadata.Variable.class, null, null);

    extractVButton = makeButton("Extract Variables");
    extractVButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            extractVariables();
          }
        });

    JPanel buttPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    buttPanel.add(extractVButton);

    JPanel vPanel = new JPanel(new BorderLayout());
    vPanel.add(buttPanel, BorderLayout.NORTH);
    vPanel.add(variablesFld.getEditComponent(), BorderLayout.CENTER);
    return vPanel;
  }
示例#6
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");

    ArrayList<Field.BeanTableField> tables = new ArrayList<>();

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

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

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

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

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

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

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

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

    for (Field.BeanTableField table : tables) addPopups(table);

    metadataPP.finish(false);

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

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