Ejemplo n.º 1
0
  /**
   * Generate a user interface from the given xml document (derived from the given path). The xml
   * can be a thredds query capability, any verion of a thredds catalog or an IDV menus xml file.
   *
   * @param doc the xml document
   * @param xmlRoot The root of the xml document to create a display for.
   * @param path The url path we got the xml from.
   */
  protected void makeUi(Document doc, Element xmlRoot, String path) {
    this.document = doc;
    setHaveData(false);
    if (xmlRoot == null) {
      return;
    }
    setSelected(path);
    XmlHandler handler = null;
    String tagName = XmlUtil.getLocalName(xmlRoot);

    if (tagName.equals(WmsUtil.TAG_WMS1) || tagName.equals(WmsUtil.TAG_WMS2)) {
      handler = new WmsHandler(this, xmlRoot, path);
    } else if (tagName.equals(TAG_ERROR)) {
      final String error = XmlUtil.getAttribute(xmlRoot, "label", "Error");
      LogUtil.userErrorMessage("Error: " + error);
      return;
    } else if (tagName.equals(CatalogUtil.TAG_CATALOG)) {
      handler = new ThreddsHandler(this, xmlRoot, path);
    } else if (tagName.equals("menus")) {
      handler = new MenuHandler(this, xmlRoot, path);
    } else {
      throw new IllegalArgumentException(
          "Unknown xml:"
              + ((xmlContents.length() > 100) ? xmlContents.substring(0, 100) : xmlContents)
              + " ...");
    }

    JComponent contents = handler.getContents();
    contents.setPreferredSize(new Dimension(200, 250));
    addToContents(contents);
    addToHistory(handler);
    updateStatus();
  }
Ejemplo n.º 2
0
 /**
  * Remove the currently display gui and insert the given one.
  *
  * @param comp The new gui.
  */
 private void addToContents(JComponent comp) {
   handlerHolder.removeAll();
   comp.setPreferredSize(new Dimension(200, 300));
   handlerHolder.add(comp, BorderLayout.CENTER);
   if (myContents != null) {
     myContents.invalidate();
     myContents.validate();
     myContents.repaint();
   }
 }