Example #1
0
 /**
  * Make a combo box to select vertical separation of wind barbs, in m
  *
  * @return component for vertical interval selection
  */
 protected JComponent doMakeVerticalIntervalComponent() {
   JComboBox intervalBox =
       GuiUtils.createValueBox(
           this,
           CMD_INTERVAL,
           (int) verticalIntervalValue,
           Misc.createIntervalList(250, 1000, 250),
           true);
   return GuiUtils.label("  Vertical interval (m): ", GuiUtils.wrap(intervalBox));
 }
  /**
   * Returns the data-specific widget for controlling the data-specific aspects of the display.
   *
   * @return The data-specific control-component.
   * @throws RemoteException _more_
   * @throws VisADException _more_
   */
  Component getSpecificWidget() throws VisADException, RemoteException {

    stationMenue = new JComboBox(stationIds);

    // TODO: Check this
    if ((selectedStationIndex >= 0) && (selectedStationIndex < stationIds.length)) {
      stationMenue.setSelectedIndex(selectedStationIndex);
      setStation(selectedStationIndex);
    } else {
      setStation(0);
    }
    stationMenue.setToolTipText("Soundings");

    stationMenue.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            try {
              //                    System.err.println("station menu changed");
              //                    setStation(stationMenue.getSelectedIndex());
              updateHeaderLabel();
            } catch (Exception ex) {
              logException(ex);
            }
          }
        });

    stationMenue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (ignoreStationMenuEvent) {
              return;
            }
            Misc.run(
                new Runnable() {
                  public void run() {
                    try {
                      setStation(stationMenue.getSelectedIndex());
                      Misc.runInABit(
                          250,
                          new Runnable() {
                            public void run() {
                              stationMenue.requestFocus();
                            }
                          });
                      updateHeaderLabel();
                    } catch (Exception ex) {
                      logException(ex);
                    }
                  }
                });
          }
        });

    return GuiUtils.top(GuiUtils.inset(GuiUtils.label("Soundings: ", stationMenue), 8));
  }
Example #3
0
 /**
  * Popup a unit selection gui. This will also save off persistently any new unit names typed in.
  *
  * @param unit The current unit
  * @param defaultUnit The default unit to return if the user chooses "Default"
  * @return The new unit or null on a cancel or an error
  */
 public Unit selectUnit(Unit unit, Unit defaultUnit) {
   JComboBox ufld = makeUnitBox(unit, defaultUnit);
   Component panel = GuiUtils.label(" New unit:  ", ufld);
   if (!GuiUtils.showOkCancelDialog(
       null, "Change unit", GuiUtils.inset(panel, 5), null, Misc.newList(ufld))) {
     return null;
   }
   Object selected = ufld.getSelectedItem();
   String unitName = TwoFacedObject.getIdString(selected);
   if (unitName == null) {
     return defaultUnit;
   }
   try {
     Unit newUnit = Util.parseUnit(unitName);
     if (!(selected instanceof TwoFacedObject)) {
       selected = new TwoFacedObject(selected.toString(), newUnit);
     }
     addToUnitList(selected);
     return newUnit;
   } catch (Exception exc) {
     LogUtil.userMessage("Error parsing unit:" + unitName + "\n" + exc);
   }
   return null;
 }