Ejemplo n.º 1
0
 /** Reload the current xml and update the display. */
 public void doUpdateInner() {
   String selected = urlBox.getSelectedItem().toString().trim();
   // Only save off the list on a successful load
   if (selected.length() == 0) {
     if (handlers.size() > 0) {
       goBack();
     } else {
       makeBlankTree();
     }
     return;
   }
   if (makeUiFromPath(selected)) {
     urlListHandler.saveState(urlBox);
   }
 }
Ejemplo n.º 2
0
 /**
  * Handle any Gui actions.
  *
  * @param ae The <code>ActionEvent</code>.
  */
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (cmd.equals(CMD_BROWSE)) {
     String filename = FileManager.getReadFile(FILTER_XML);
     if (filename == null) {
       return;
     }
     urlBox.setSelectedItem(filename);
   } else if (cmd.equals(GuiUtils.CMD_OK)) {
     doLoad();
   } else {
     // Here, the base class ChooserPanel will check if this command
     // is the load or cancel command.
     super.actionPerformed(ae);
   }
 }
Ejemplo n.º 3
0
 /**
  * Set the catalog list combobox to the given xmlPath.
  *
  * @param xmlPath The xmlPath to show in the combo box.
  */
 private void setSelected(String xmlPath) {
   okToDoUrlListEvents = false;
   urlBox.setSelectedItem(xmlPath);
   okToDoUrlListEvents = true;
 }
Ejemplo n.º 4
0
  /**
   * Create and return the Gui contents.
   *
   * @return The gui contents.
   */
  protected JComponent doMakeContents() {
    //        dataSelector = new DataSelector(getIdv(), new Dimension(400, 200),
    //                                        true);

    // Get the list of catalogs but remove the old catalog.xml entry
    urlListHandler = getPreferenceList(PREF_CATALOGLIST);
    final XmlChooser xmlChooser = this;
    ActionListener catListListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if (!okToDoUrlListEvents) {
              return;
            }
            xmlChooser.actionPerformed(ae);
          }
        };
    urlBox = urlListHandler.createComboBox(GuiUtils.CMD_UPDATE, catListListener, true);

    GuiUtils.setPreferredWidth(urlBox, 200);

    // top panel
    JButton browseButton = new JButton("Select File...");
    browseButton.setToolTipText("Choose a catalog from disk");
    browseButton.setActionCommand(CMD_BROWSE);
    browseButton.addActionListener(this);

    GuiUtils.setHFill();
    JPanel catListPanel =
        GuiUtils.doLayout(new Component[] {urlBox}, 1, GuiUtils.WT_Y, GuiUtils.WT_N);

    backBtn =
        GuiUtils.getImageButton(GuiUtils.getImageIcon("/auxdata/ui/icons/Left16.gif", getClass()));
    backBtn.setToolTipText("View previous selection");
    GuiUtils.makeMouseOverBorder(backBtn);
    backBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            goBack();
          }
        });

    fwdBtn =
        GuiUtils.getImageButton(GuiUtils.getImageIcon("/auxdata/ui/icons/Right16.gif", getClass()));
    GuiUtils.makeMouseOverBorder(fwdBtn);
    fwdBtn.setToolTipText("View next selection");
    fwdBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            goForward();
          }
        });

    checkButtons();
    JComponent bottomButtons = getDefaultButtons();
    handlerHolder = new JPanel();
    handlerHolder.setLayout(new BorderLayout());
    //        JPanel tmp = new JPanel();
    //        tmp.setPreferredSize(new Dimension(200,500));
    //        handlerHolder.add(tmp, BorderLayout.CENTER);

    if (getIdv().getArgsManager().getInitCatalogs().size() > 0) {
      initialUrlPath = (String) getIdv().getArgsManager().getInitCatalogs().get(0);
      urlBox.setSelectedItem(initialUrlPath);
    } else {
      if ((initialUrlPath != null) && (initialUrlPath.length() > 0)) {
        makeUiFromPath(initialUrlPath);
      } else {
        makeBlankTree();
      }
    }
    JPanel navButtons = GuiUtils.hbox(backBtn, fwdBtn);

    GuiUtils.tmpInsets = GRID_INSETS;
    JPanel catPanel =
        GuiUtils.doLayout(
            new Component[] {new JLabel("Catalogs:"), catListPanel, browseButton},
            3,
            GuiUtils.WT_NYN,
            GuiUtils.WT_N);
    JPanel topPanel = GuiUtils.leftCenter(navButtons, catPanel);
    myContents = GuiUtils.topCenterBottom(topPanel, handlerHolder, bottomButtons);
    //        myContents = GuiUtils.topCenter(getStatusComponent(), myContents);
    return myContents;
  }
Ejemplo n.º 5
0
 /**
  * _more_
  *
  * @param definingObject _more_
  * @param dataType _more_
  * @param properties _more_
  * @return _more_
  */
 protected boolean makeDataSource(Object definingObject, String dataType, Hashtable properties) {
   properties.put(PROP_CHOOSER_URL, urlBox.getSelectedItem());
   return super.makeDataSource(definingObject, dataType, properties);
 }
Ejemplo n.º 6
0
 /**
  * _more_
  *
  * @param properties _more_
  */
 public void initSubProperties(Hashtable properties) {
   properties.put(PROP_CHOOSERCLASSNAME, getClass().getName());
   properties.put(PROP_CHOOSER_URL, urlBox.getSelectedItem());
 }
Ejemplo n.º 7
0
    /**
     * Edit row
     *
     * @param paramInfo param info
     * @param removeOnCancel Should remove param info if user presses cancel_
     * @return ok
     */
    public boolean editRow(ParamInfo paramInfo, boolean removeOnCancel) {

      List comps = new ArrayList();
      ParamField nameFld = new ParamField(null, true);
      nameFld.setText(paramInfo.getName());
      JPanel topPanel = GuiUtils.hbox(GuiUtils.lLabel("Parameter:  "), nameFld);
      topPanel = GuiUtils.inset(topPanel, 5);

      comps.add(GuiUtils.inset(new JLabel("Defined"), new Insets(5, 0, 0, 0)));
      comps.add(GuiUtils.filler());
      comps.add(GuiUtils.filler());

      final JLabel ctPreviewLbl = new JLabel("");
      final JLabel ctLbl = new JLabel("");
      if (paramInfo.hasColorTableName()) {
        ctLbl.setText(paramInfo.getColorTableName());
        ColorTable ct =
            getIdv().getColorTableManager().getColorTable(paramInfo.getColorTableName());
        if (ct != null) {
          ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
        } else {
          ctPreviewLbl.setIcon(null);
        }
      }
      String cbxLabel = "";
      final ArrayList menus = new ArrayList();
      getIdv()
          .getColorTableManager()
          .makeColorTableMenu(
              new ObjectListener(null) {
                public void actionPerformed(ActionEvent ae, Object data) {
                  ctLbl.setText(data.toString());
                  ColorTable ct = getIdv().getColorTableManager().getColorTable(ctLbl.getText());
                  if (ct != null) {
                    ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
                  } else {
                    ctPreviewLbl.setIcon(null);
                  }
                }
              },
              menus);

      JCheckBox ctUseCbx = new JCheckBox(cbxLabel, paramInfo.hasColorTableName());
      final JButton ctPopup = new JButton("Change");
      ctPopup.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              GuiUtils.showPopupMenu(menus, ctPopup);
            }
          });
      addEditComponents(
          comps,
          "Color Table:",
          ctUseCbx,
          GuiUtils.hbox(ctPopup, GuiUtils.vbox(ctLbl, ctPreviewLbl), 5));

      JCheckBox rangeUseCbx = new JCheckBox(cbxLabel, paramInfo.hasRange());
      JTextField minFld = new JTextField("" + paramInfo.getMin(), 4);
      JTextField maxFld = new JTextField("" + paramInfo.getMax(), 4);
      JPanel rangePanel = GuiUtils.hbox(minFld, maxFld, 5);
      addEditComponents(comps, "Range:", rangeUseCbx, rangePanel);

      JCheckBox unitUseCbx = new JCheckBox(cbxLabel, paramInfo.hasDisplayUnit());
      String unitLabel = "";
      Unit unit = null;
      if (paramInfo.hasDisplayUnit()) {
        unit = paramInfo.getDisplayUnit();
      }

      JComboBox unitFld = getIdv().getDisplayConventions().makeUnitBox(unit, null);
      //            JTextField unitFld = new JTextField(unitLabel, 15);
      addEditComponents(comps, "Unit:", unitUseCbx, unitFld);

      ContourInfo ci = paramInfo.getContourInfo();
      JCheckBox contourUseCbx = new JCheckBox(cbxLabel, ci != null);
      if (ci == null) {
        ci = new ContourInfo();
      }
      ContourInfoDialog contDialog =
          new ContourInfoDialog("Edit Contour Defaults", false, null, false);
      contDialog.setState(ci);
      addEditComponents(comps, "Contour:", contourUseCbx, contDialog.getContents());

      GuiUtils.tmpInsets = new Insets(5, 5, 5, 5);
      JComponent contents = GuiUtils.doLayout(comps, 3, GuiUtils.WT_NNY, GuiUtils.WT_N);

      contents = GuiUtils.topCenter(topPanel, contents);
      contents = GuiUtils.inset(contents, 5);
      while (true) {
        if (!GuiUtils.showOkCancelDialog(null, "Parameter Defaults", contents, null)) {
          if (removeOnCancel) {
            myParamInfos.remove(paramInfo);
            tableChanged();
          }
          return false;
        }
        String what = "";
        try {
          if (contourUseCbx.isSelected()) {
            what = "setting contour defaults";
            contDialog.doApply();
            ci.set(contDialog.getInfo());
            paramInfo.setContourInfo(ci);
          } else {
            paramInfo.clearContourInfo();
          }
          if (unitUseCbx.isSelected()) {
            what = "setting display unit";
            Object selected = unitFld.getSelectedItem();
            String unitName = TwoFacedObject.getIdString(selected);
            if ((unitName == null) || unitName.trim().equals("")) {
              paramInfo.setDisplayUnit(null);
            } else {
              paramInfo.setDisplayUnit(ucar.visad.Util.parseUnit(unitName));
            }
          } else {
            paramInfo.setDisplayUnit(null);
          }

          if (ctUseCbx.isSelected()) {
            paramInfo.setColorTableName(ctLbl.getText());
          } else {
            paramInfo.clearColorTableName();
          }

          if (rangeUseCbx.isSelected()) {
            what = "setting range";
            paramInfo.setRange(
                new Range(Misc.parseNumber(minFld.getText()), Misc.parseNumber(maxFld.getText())));
          } else {
            paramInfo.clearRange();
          }

          paramInfo.setName(nameFld.getText().trim());
          break;
        } catch (Exception exc) {
          errorMsg("An error occurred " + what + "\n " + exc.getMessage());
          //              exc.printStackTrace();
        }
      }
      repaint();
      saveData();
      return true;
    }