public void showAtts() {
    if (ds == null) return;
    if (attTable == null) {
      // global attributes
      attTable =
          new BeanTable(AttributeBean.class, (PreferencesExt) prefs.node("AttributeBeans"), false);
      PopupMenu varPopup = new ucar.nc2.ui.widget.PopupMenu(attTable.getJTable(), "Options");
      varPopup.addAction(
          "Show Attribute",
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              AttributeBean bean = (AttributeBean) attTable.getSelectedBean();
              if (bean != null) {
                infoTA.setText(bean.att.toString());
                infoTA.gotoTop();
                infoWindow.show();
              }
            }
          });
      attWindow =
          new IndependentWindow("Global Attributes", BAMutil.getImage("netcdfUI"), attTable);
      attWindow.setBounds(
          (Rectangle) prefs.getBean("AttWindowBounds", new Rectangle(300, 100, 500, 800)));
    }

    List<AttributeBean> attlist = new ArrayList<>();
    for (Attribute att : ds.getGlobalAttributes()) {
      attlist.add(new AttributeBean(att));
    }
    attTable.setBeans(attlist);
    attWindow.show();
  }
Example #2
0
  private void showDeclaration(BeanTableSorted from, boolean isNcml) {
    Variable v = getCurrentVariable(from);
    if (v == null) return;
    infoTA.clear();
    if (isNcml) {
      Formatter out = new Formatter();
      try {
        NCdumpW.writeNcMLVariable(v, out);
      } catch (IOException e) {
        e.printStackTrace();
      }
      infoTA.appendLine(out.toString());

    } else {
      infoTA.appendLine(v.toString());
    }

    if (Debug.isSet("Xdeveloper")) {
      infoTA.appendLine("\n");
      infoTA.appendLine("FULL NAME = " + v.getFullName());
      infoTA.appendLine("\n");
      infoTA.appendLine(v.toStringDebug());
    }
    infoTA.gotoTop();
    infoWindow.setTitle("Variable Info");
    infoWindow.show();
  }
Example #3
0
  private void makeDscanPanel() {
    dscanPP = new PrefPanel("dscan", null);
    int row = 0;
    dscanPP.addCheckBoxField(DSCAN_ADDSIZE, "Add File Size", false, 0, row++);
    // dscanPP.addCheckBoxField(DSCAN_ADDLATEST, "Add Latest", false, 0, row++);
    dscanPP.addTextField(DSCAN_PATH, "Path", "", 0, row++, null);
    dscanPP.addTextField(DSCAN_DIR, "Directory Location", "", 0, row++, null);
    // dscanPP.addTextField(DSCAN_FILTER, "Filter", "", 0, row++, null);

    dscanPP.addEmptyRow(row++, 2);
    dscanPP.addHeading("Time Coverage", row++);

    exampleButton = makeButton("Example filename");
    exampleButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            InvDataset leaf = findLeafDataset(dataset);
            exampleButton.setText((leaf == null) ? "ERR" : leaf.getName());
          }
        });
    dscanPP.addComponent(exampleButton, 0, row, null);

    // dscanPP.addTextField(DSCAN_TC_MATCH, "Dataset Name Match", "", 0, row++, null);
    // dscanPP.addTextField(DSCAN_TC_SUBS, "Substituton Pattern", "$1-$2-$3T$4:00:00", 0, row++,
    // null);
    // dscanPP.addTextField(DSCAN_TC_DURATOPN, "Duration", "", 0, row++, null);

    dscanPP.finish(false);

    IndependentWindow dscanWindow =
        new IndependentWindow("DatasetScan " + "options", BAMutil.getImage("thredds"), dscanPP);
    dscanWindow.setBounds(new Rectangle(150, 50, 700, 300));
  }
 public void save() {
   varTable.saveState(false);
   csTable.saveState(false);
   axisTable.saveState(false);
   prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
   prefs.putInt("splitPos", split.getDividerLocation());
   prefs.putInt("splitPos2", split2.getDividerLocation());
   prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
   if (attWindow != null) prefs.putBeanObject("AttWindowBounds", attWindow.getBounds());
 }
Example #5
0
  public void save() {
    dumpPane.save();
    for (NestedTable nt : nestedTableList) {
      nt.saveState();
    }
    prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
    prefs.putBeanObject("DumpWindowBounds", dumpWindow.getBounds());
    if (attWindow != null) prefs.putBeanObject("AttWindowBounds", attWindow.getBounds());

    prefs.putInt("mainSplit", mainSplit.getDividerLocation());
  }
Example #6
0
  public DatasetViewer(PreferencesExt prefs, FileManager fileChooser) {
    this.prefs = prefs;
    this.fileChooser = fileChooser;

    // create the variable table(s)
    tablePanel = new JPanel(new BorderLayout());
    setNestedTable(0, null);

    // the tree view
    datasetTree = new DatasetTreeView();
    datasetTree.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            setSelected((Variable) e.getNewValue());
          }
        });

    // layout
    mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, datasetTree, tablePanel);
    mainSplit.setDividerLocation(prefs.getInt("mainSplit", 100));

    setLayout(new BorderLayout());
    add(mainSplit, BorderLayout.CENTER);

    // the info window
    infoTA = new TextHistoryPane();
    infoWindow =
        new IndependentWindow("Variable Information", BAMutil.getImage("netcdfUI"), infoTA);
    infoWindow.setBounds(
        (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300)));

    // the data Table
    dataTable = new StructureTable((PreferencesExt) prefs.node("structTable"));
    dataWindow = new IndependentWindow("Data Table", BAMutil.getImage("netcdfUI"), dataTable);
    dataWindow.setBounds(
        (Rectangle) prefs.getBean("dataWindow", new Rectangle(50, 300, 1000, 600)));

    // the ncdump Pane
    dumpPane = new NCdumpPane((PreferencesExt) prefs.node("dumpPane"));
    dumpWindow =
        new IndependentWindow("NCDump Variable Data", BAMutil.getImage("netcdfUI"), dumpPane);
    dumpWindow.setBounds(
        (Rectangle) prefs.getBean("DumpWindowBounds", new Rectangle(300, 300, 300, 200)));
  }
Example #7
0
  private void compareDataset(CompareDialog.Data data) {
    if (data.name == null) return;

    NetcdfFile compareFile = null;
    try {
      compareFile = NetcdfDataset.openFile(data.name, null);

      Formatter f = new Formatter();
      CompareNetcdf2 cn = new CompareNetcdf2(f, data.showCompare, data.showDetails, data.readData);
      if (data.howMuch == CompareDialog.HowMuch.All) cn.compare(ds, compareFile);
      else {
        NestedTable nested = nestedTableList.get(0);
        Variable org = getCurrentVariable(nested.table);
        if (org == null) return;
        Variable ov = compareFile.findVariable(org.getFullNameEscaped());
        if (ov != null) cn.compareVariable(org, ov);
      }

      infoTA.setText(f.toString());
      infoTA.gotoTop();
      infoWindow.setTitle("Compare");
      infoWindow.show();

    } catch (Throwable ioe) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(10000);
      ioe.printStackTrace(new PrintStream(bos));
      infoTA.setText(bos.toString());
      infoTA.gotoTop();
      infoWindow.show();

    } finally {
      if (compareFile != null)
        try {
          compareFile.close();
        } catch (Exception eek) {
        }
    }
  }
Example #8
0
  private void dataTable(BeanTableSorted from) {
    VariableBean vb = (VariableBean) from.getSelectedBean();
    if (vb == null) return;
    Variable v = vb.vs;
    if (v instanceof Structure) {
      try {
        dataTable.setStructure((Structure) v);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else return;

    dataWindow.show();
  }
Example #9
0
  private void dumpData(BeanTableSorted from) {
    Variable v = getCurrentVariable(from);
    if (v == null) return;

    dumpPane.clear();
    String spec;

    try {
      spec = ParsedSectionSpec.makeSectionSpecString(v, null);
      dumpPane.setContext(ds, spec);

    } catch (Exception ex) {
      StringWriter s = new StringWriter();
      ex.printStackTrace(new PrintWriter(s));
      dumpPane.setText(s.toString());
    }

    dumpWindow.show();
  }
Example #10
0
  public CoordSysTable(PreferencesExt prefs, JPanel buttPanel) {
    this.prefs = prefs;

    if (buttPanel != null) {
      AbstractAction attAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              showAtts();
            }
          };
      BAMutil.setActionProperties(attAction, "FontDecr", "global attributes", false, 'A', -1);
      BAMutil.addActionToContainer(buttPanel, attAction);
    }

    varTable =
        new BeanTable(VariableBean.class, (PreferencesExt) prefs.node("VariableBeans"), false);
    varTable.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            VariableBean vb = (VariableBean) varTable.getSelectedBean();
            if (null != vb.firstCoordSys) setSelectedCoordinateSystem(vb.firstCoordSys);
          }
        });

    csTable =
        new BeanTable(
            CoordinateSystemBean.class, (PreferencesExt) prefs.node("CoordinateSystemBean"), false);
    csTable.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            CoordinateSystemBean csb = (CoordinateSystemBean) csTable.getSelectedBean();
            setSelectedCoordinateAxes(csb.coordSys);
          }
        });

    axisTable =
        new BeanTable(AxisBean.class, (PreferencesExt) prefs.node("CoordinateAxisBean"), false);

    ucar.nc2.ui.widget.PopupMenu varPopup = new PopupMenu(varTable.getJTable(), "Options");
    varPopup.addAction(
        "Show Declaration",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            VariableBean vb = (VariableBean) varTable.getSelectedBean();
            Variable v = ds.findVariable(vb.getName());
            if (v == null) return;
            infoTA.clear();
            infoTA.appendLine(v.toString());
            infoTA.appendLine(showMissing(v));
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    varPopup.addAction(
        "Try as Grid",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            VariableBean vb = (VariableBean) varTable.getSelectedBean();
            VariableEnhanced v = (VariableEnhanced) ds.findVariable(vb.getName());
            if (v == null) return;
            infoTA.clear();
            infoTA.appendLine(tryGrid(v));
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    PopupMenu csPopup = new PopupMenu(csTable.getJTable(), "Options");
    csPopup.addAction(
        "Show CoordSys",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            CoordinateSystemBean csb = (CoordinateSystemBean) csTable.getSelectedBean();
            CoordinateSystem coordSys = csb.coordSys;
            infoTA.clear();
            infoTA.appendLine("Coordinate System = " + coordSys.getName());
            for (CoordinateAxis axis : coordSys.getCoordinateAxes()) {
              infoTA.appendLine("  " + axis.getAxisType() + " " + axis.writeCDL(true, false));
            }
            infoTA.appendLine(" Coordinate Transforms");
            for (CoordinateTransform ct : coordSys.getCoordinateTransforms()) {
              infoTA.appendLine("  " + ct.getName() + " type=" + ct.getTransformType());
              for (Parameter p : ct.getParameters()) {
                infoTA.appendLine("    " + p);
              }
              if (ct instanceof ProjectionCT) {
                ProjectionCT pct = (ProjectionCT) ct;
                if (pct.getProjection() != null) {
                  infoTA.appendLine("    impl.class= " + pct.getProjection().getClass().getName());
                  // pct.getProjection();
                }
              }
              if (ct instanceof VerticalCT) {
                VerticalCT vct = (VerticalCT) ct;
                infoTA.appendLine("  VerticalCT= " + vct);
              }
            }
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    PopupMenu axisPopup = new PopupMenu(axisTable.getJTable(), "Options");
    axisPopup.addAction(
        "Show Declaration",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            VariableDS axis = (VariableDS) ds.findVariable(bean.getName());
            if (axis == null) return;
            infoTA.clear();
            infoTA.appendLine(axis.toString());
            infoTA.appendLine(showMissing(axis));
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    axisPopup.addAction(
        "Show Values",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            infoTA.clear();
            showValues(bean.axis);
            infoTA.gotoTop();
            infoWindow.show();
          }
        });
    axisPopup.addAction(
        "Show Value Differences",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            infoTA.clear();
            showValueDiffs(bean.axis);
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    axisPopup.addAction(
        "Show Values as Date",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            AxisBean bean = (AxisBean) axisTable.getSelectedBean();
            if (bean == null) return;
            infoTA.clear();
            showValuesAsDates(bean.axis);
            infoTA.gotoTop();
            infoWindow.show();
          }
        });

    // the info window
    infoTA = new TextHistoryPane();
    infoWindow = new IndependentWindow("Extra Information", BAMutil.getImage("netcdfUI"), infoTA);
    infoWindow.setBounds(
        (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300)));

    split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, varTable, csTable);
    split.setDividerLocation(prefs.getInt("splitPos", 500));

    split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, split, axisTable);
    split2.setDividerLocation(prefs.getInt("splitPos2", 500));

    setLayout(new BorderLayout());
    add(split2, BorderLayout.CENTER);
  }
Example #11
0
 void save() {
   if (infoWindow != null) prefs.putBeanObject(FRAME_SIZE, infoWindow.getBounds());
 }
Example #12
0
    OpPanel(PreferencesExt prefs, boolean isAccess) {
      this.prefs = prefs;
      this.isAccess = isAccess;
      ta = new TextHistoryPane(true);
      infoWindow =
          new IndependentWindow("Details", BAMutil.getImage("netcdfUI"), new JScrollPane(ta));
      Rectangle bounds = (Rectangle) prefs.getBean(FRAME_SIZE, new Rectangle(200, 50, 500, 700));
      infoWindow.setBounds(bounds);

      topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));

      // which server
      serverCB = new JComboBox();
      serverCB.setModel(manage.getServersCB().getModel());
      serverCB.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String server = (String) serverCB.getSelectedItem();
              setServer(server);
            }
          });

      // serverCB.setModel(manage.getServers().getModel());
      topPanel.add(new JLabel("server:"));
      topPanel.add(serverCB);

      // the date selectors
      startDateField = new JTextArea("                    ");
      endDateField = new JTextArea("                    ");

      topPanel.add(new JLabel("Start Date:"));
      topPanel.add(startDateField);
      topPanel.add(new JLabel("End Date:"));
      topPanel.add(endDateField);

      AbstractAction showAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              showLogs();
            }
          };
      BAMutil.setActionProperties(showAction, "Import", "get logs", false, 'G', -1);
      BAMutil.addActionToContainer(topPanel, showAction);

      AbstractAction filterAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              Boolean state = (Boolean) getValue(BAMutil.STATE);
              removeTestReq = state.booleanValue();
            }
          };
      BAMutil.setActionProperties(filterAction, "time", "remove test Requests", true, 'F', -1);
      BAMutil.addActionToContainer(topPanel, filterAction);

      AbstractAction filter2Action =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              Boolean state = (Boolean) getValue(BAMutil.STATE);
              problemsOnly = state.booleanValue();
            }
          };
      BAMutil.setActionProperties(filter2Action, "time", "only show problems", true, 'F', -1);
      BAMutil.addActionToContainer(topPanel, filter2Action);

      AbstractAction infoAction =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              Formatter f = new Formatter();
              showInfo(f);
              ta.setText(f.toString());
              infoWindow.show();
            }
          };
      BAMutil.setActionProperties(
          infoAction, "Information", "info on selected logs", false, 'I', -1);
      BAMutil.addActionToContainer(topPanel, infoAction);

      setLayout(new BorderLayout());
      add(topPanel, BorderLayout.NORTH);
    }
Example #13
0
  public NcmlEditor(JPanel buttPanel, PreferencesExt prefs) {
    this.prefs = prefs;
    fileChooser = new FileManager(null, null, null, (PreferencesExt) prefs.node("FileManager"));

    AbstractAction coordAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            addCoords = (Boolean) getValue(BAMutil.STATE);
            String tooltip = addCoords ? "add Coordinates is ON" : "add Coordinates is OFF";
            coordButt.setToolTipText(tooltip);
          }
        };
    addCoords = prefs.getBoolean("coordState", false);
    String tooltip2 = addCoords ? "add Coordinates is ON" : "add Coordinates is OFF";
    BAMutil.setActionProperties(coordAction, "addCoords", tooltip2, true, 'C', -1);
    coordAction.putValue(BAMutil.STATE, Boolean.valueOf(addCoords));
    coordButt = BAMutil.addActionToContainer(buttPanel, coordAction);

    protoChooser = new ComboBox((PreferencesExt) prefs.node("protoChooser"));
    addProtoChoices();
    buttPanel.add(protoChooser);
    protoChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String ptype = (String) protoChooser.getSelectedItem();
            String proto = protoMap.get(ptype);
            if (proto != null) {
              editor.setText(proto);
            }
          }
        });

    editor = new JEditorPane();

    // Instantiate a XMLEditorKit with wrapping enabled.
    XMLEditorKit kit = new XMLEditorKit(false);

    // Set the wrapping style.
    kit.setWrapStyleWord(true);

    editor.setEditorKit(kit);

    // Set the font style.
    editor.setFont(new Font("Monospaced", Font.PLAIN, 12));

    // Set the tab size
    editor.getDocument().putProperty(PlainDocument.tabSizeAttribute, 2);

    // Enable auto indentation.
    editor.getDocument().putProperty(XMLDocument.AUTO_INDENTATION_ATTRIBUTE, true);

    // Enable tag completion.
    editor.getDocument().putProperty(XMLDocument.TAG_COMPLETION_ATTRIBUTE, true);

    // Initialise the folding
    kit.setFolding(true);

    // Set a style
    kit.setStyle(XMLStyleConstants.ATTRIBUTE_NAME, Color.RED, Font.BOLD);

    // Put the editor in a panel that will force it to resize, when a different view is choosen.
    ScrollableEditorPanel editorPanel = new ScrollableEditorPanel(editor);

    JScrollPane scroller = new JScrollPane(editorPanel);

    // Add the number margin as a Row Header View
    scroller.setRowHeaderView(new LineNumberMargin(editor));

    AbstractAction wrapAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            XMLEditorKit kit = (XMLEditorKit) editor.getEditorKit();
            kit.setLineWrappingEnabled(!kit.isLineWrapping());
            editor.updateUI();
          }
        };
    BAMutil.setActionProperties(wrapAction, "Wrap", "Toggle Wrapping", false, 'W', -1);
    BAMutil.addActionToContainer(buttPanel, wrapAction);

    AbstractAction saveAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            String location = (ds == null) ? ncmlLocation : ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);
            String filename = fileChooser.chooseFilenameToSave(location + ".ncml");
            if (filename == null) return;
            if (doSaveNcml(editor.getText(), filename)) ncmlLocation = filename;
          }
        };
    BAMutil.setActionProperties(saveAction, "Save", "Save NcML", false, 'S', -1);
    BAMutil.addActionToContainer(buttPanel, saveAction);

    AbstractAction netcdfAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (outChooser == null) {
              outChooser = new NetcdfOutputChooser((Frame) null);
              outChooser.addPropertyChangeListener(
                  "OK",
                  new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent evt) {
                      writeNetcdf((NetcdfOutputChooser.Data) evt.getNewValue());
                    }
                  });
            }

            String location = (ds == null) ? ncmlLocation : ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);

            outChooser.setOutputFilename(location);
            outChooser.setVisible(true);
          }
        };
    BAMutil.setActionProperties(netcdfAction, "netcdf", "Write netCDF file", false, 'N', -1);
    BAMutil.addActionToContainer(buttPanel, netcdfAction);

    AbstractAction transAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            doTransform(editor.getText());
          }
        };
    BAMutil.setActionProperties(
        transAction,
        "Import",
        "read textArea through NcMLReader\n write NcML back out via resulting dataset",
        false,
        'T',
        -1);
    BAMutil.addActionToContainer(buttPanel, transAction);

    AbstractButton compareButton = BAMutil.makeButtcon("Select", "Check NcML", false);
    compareButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Formatter f = new Formatter();
            checkNcml(f);

            infoTA.setText(f.toString());
            infoTA.gotoTop();
            infoWindow.show();
          }
        });
    buttPanel.add(compareButton);

    setLayout(new BorderLayout());
    add(scroller, BorderLayout.CENTER);

    // the info window
    infoTA = new TextHistoryPane();
    infoWindow = new IndependentWindow("Extra Information", BAMutil.getImage("netcdfUI"), infoTA);
    infoWindow.setBounds(
        (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300)));
  }
Example #14
0
 public void save() {
   fileChooser.save();
   prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
 }