Ejemplo n.º 1
0
  public static void main(String args[]) {
    JFrame frame;
    final DatasetEditor editor = new DatasetEditor();

    frame = new JFrame("Test DatasetEditor");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    JButton save = new JButton("Accept");
    save.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editor.accept();
            editor.store2Dataset();
            try {
              cat.writeXML(System.out, true);
            } catch (IOException e1) {
              e1.printStackTrace();
            }
          }
        });
    JPanel main = new JPanel(new BorderLayout());
    main.add(editor, BorderLayout.CENTER);
    main.add(save, BorderLayout.NORTH);

    frame.getContentPane().add(main);
    frame.pack();
    frame.setLocation(150, 10);
    frame.setVisible(true);

    // LOOK-NOSAVE
    java.net.Authenticator.setDefault(new UrlAuthenticatorDialog(frame));

    // String url = "http://uni10.unidata.ucar.edu:8088/thredds/content/idd/models.xml";
    String url = "http://thredds.ucar.edu/thredds/content/idd/models.xml";
    InvCatalogFactory catFactory = InvCatalogFactory.getDefaultFactory(true);
    cat = catFactory.readXML(url);
    InvDatasetImpl ds = (InvDatasetImpl) cat.findDatasetByID("NCEP/NAM/V");

    editor.setDataset(ds);
  }