public void commit() {
   OnboardParameters.PIDParameters pp = new OnboardParameters.PIDParameters();
   pp.p = ((Number) pField.getValue()).floatValue();
   pp.i = ((Number) iField.getValue()).floatValue();
   pp.d = ((Number) dField.getValue()).floatValue();
   target.setPIDParameters(which, pp, toolIndex);
 }
  /** Validates the options of the fields inputted. */
  private void validateFields() {
    errorDisplay.removeAllErrors();
    Calendar cal = new GregorianCalendar();
    cal.setTime(Calendar.getInstance().getTime());
    cal.add(Calendar.DAY_OF_YEAR, -1);
    Iteration forName = IterationModel.getInstance().getIteration(boxName.getText().trim());
    if (boxName.getText().trim().length() == 0) {
      errorDisplay.displayError(EMPTY_NAME_ERROR);
    } else if (forName != null && forName != displayIteration) {
      errorDisplay.displayError(INVALID_NAME_ERROR);
    }

    if (endDateBox.getText().trim().length() == 0 || endDateBox.getText().trim().length() == 0) {
      errorDisplay.displayError(DATES_REQ);
    } else if (((Date) startDateBox.getValue()).after((Date) endDateBox.getValue())) {
      errorDisplay.displayError(START_AFTER_END_ERROR);
    } else if (((Date) startDateBox.getValue()).before(cal.getTime())) {
      errorDisplay.displayError(PAST_ERROR);
    } else {
      Iteration conflicting =
          IterationModel.getInstance()
              .getConflictingIteration(
                  (Date) startDateBox.getValue(), (Date) endDateBox.getValue());
      if (conflicting != null && conflicting != displayIteration) {
        errorDisplay.displayError(
            OVERLAPPING_ERROR + " Overlaps with " + conflicting.getName() + ".");
      }
    }

    buttonAdd.setEnabled(!errorDisplay.hasErrors());
  }
Beispiel #3
0
  @Override
  public Object getValue() {
    try {
      field.commitEdit();
    } catch (ParseException e) {
      logger.error(e.getMessage(), e);
      Utils.showError(e);
      e.printStackTrace();
    }

    if (value instanceof Number) {
      NumberConverter nc =
          new NumberConverter(true, field.getValue()) {

            @Override
            protected Class<?> getDefaultType() {
              return value.getClass();
            }
          };

      return value.getClass().cast(nc.convert(value.getClass(), field.getValue()));
    } else {
      return field.getValue();
    }
  }
 public void commit() {
   OnboardParameters.BackoffParameters bp = new OnboardParameters.BackoffParameters();
   bp.forwardMs = ((Number) forwardMsField.getValue()).intValue();
   bp.reverseMs = ((Number) reverseMsField.getValue()).intValue();
   bp.stopMs = ((Number) stopMsField.getValue()).intValue();
   bp.triggerMs = ((Number) triggerMsField.getValue()).intValue();
   target.setBackoffParameters(bp, toolIndex);
 }
 @Override
 public AbstractFormatter getFormatter(JFormattedTextField tf) {
   Double dx = 0.0;
   if (tf.getValue() != null && tf.getValue() instanceof Double)
     dx = Math.abs((Double) tf.getValue());
   if (dx != 0 && (dx > 1000000.0 || dx < 0.001)) return scientific;
   else return decimal;
 }
Beispiel #6
0
  public ToneMapper getSelectedToneMapper() {
    final ButtonModel model = toneMappingChoice.getSelection();
    final double maxLum = ((Number) maxLumValue.getValue()).doubleValue();
    if (model == wardTRButton.getModel()) {
      return new ImageUtil.WardTM(maxLum == 0 ? null : maxLum);
    } else if (model == reinhardTRButton.getModel()) {
      return new ImageUtil.ReinhardTM(
          ((Number) midpointValue.getValue()).doubleValue(), maxLum == 0 ? null : maxLum);
    }

    return ImageUtil.clampTM;
  }
  /** Called when a field's "value" property changes. */
  public void propertyChange(PropertyChangeEvent e) {
    Object source = e.getSource();
    if (source == amountField) {
      amount = ((Number) amountField.getValue()).doubleValue();
    } else if (source == rateField) {
      rate = ((Number) rateField.getValue()).doubleValue();
    } else if (source == numPeriodsField) {
      numPeriods = ((Number) numPeriodsField.getValue()).intValue();
    }

    double payment = computePayment(amount, rate, numPeriods);
    paymentField.setValue(new Double(payment));
  }
  @Override
  public void setSettings() {
    ThreadPoolConfig threadPool =
        config.getProject().getExporter().getSystem().getThreadPool().getDefaultPool();
    GmlIdLookupServerConfig geometry =
        config.getProject().getExporter().getSystem().getGmlIdLookupServer().getGeometry();
    GmlIdLookupServerConfig feature =
        config.getProject().getExporter().getSystem().getGmlIdLookupServer().getFeature();

    int minThreads = ((Number) expResMinThreadsText.getValue()).intValue();
    int maxThreads = ((Number) expResMaxThreadsText.getValue()).intValue();

    if (minThreads > maxThreads) {
      minThreads = maxThreads;
      expResMinThreadsText.setValue(minThreads);
    }

    threadPool.setMinThreads(minThreads);
    threadPool.setMaxThreads(maxThreads);

    geometry.setCacheSize(((Number) expResGeomCacheText.getValue()).intValue());
    feature.setCacheSize(((Number) expResFeatCacheText.getValue()).intValue());
    geometry.setPageFactor(((Number) expResGeomDrainText.getValue()).floatValue() / 100);
    feature.setPageFactor(((Number) expResFeatDrainText.getValue()).floatValue() / 100);
    geometry.setPartitions(((Number) expResGeomPartText.getValue()).intValue());
    feature.setPartitions(((Number) expResFeatPartText.getValue()).intValue());
  }
  @Override
  public boolean isModified() {
    ThreadPoolConfig threadPool =
        config.getProject().getExporter().getSystem().getThreadPool().getDefaultPool();
    GmlIdLookupServerConfig geometry =
        config.getProject().getExporter().getSystem().getGmlIdLookupServer().getGeometry();
    GmlIdLookupServerConfig feature =
        config.getProject().getExporter().getSystem().getGmlIdLookupServer().getFeature();

    try {
      expResMinThreadsText.commitEdit();
    } catch (ParseException e) {
    }
    try {
      expResMaxThreadsText.commitEdit();
    } catch (ParseException e) {
    }
    try {
      expResGeomCacheText.commitEdit();
    } catch (ParseException e) {
    }
    try {
      expResGeomDrainText.commitEdit();
    } catch (ParseException e) {
    }
    try {
      expResGeomPartText.commitEdit();
    } catch (ParseException e) {
    }
    try {
      expResFeatCacheText.commitEdit();
    } catch (ParseException e) {
    }
    try {
      expResFeatDrainText.commitEdit();
    } catch (ParseException e) {
    }
    try {
      expResFeatPartText.commitEdit();
    } catch (ParseException e) {
    }

    if (((Number) expResMinThreadsText.getValue()).intValue() != threadPool.getMinThreads())
      return true;
    if (((Number) expResMaxThreadsText.getValue()).intValue() != threadPool.getMaxThreads())
      return true;
    if (((Number) expResGeomCacheText.getValue()).intValue() != geometry.getCacheSize())
      return true;
    if (((Number) expResGeomDrainText.getValue()).intValue()
        != (int) (geometry.getPageFactor() * 100)) return true;
    if (((Number) expResGeomPartText.getValue()).intValue() != geometry.getPartitions())
      return true;
    if (((Number) expResFeatCacheText.getValue()).intValue() != feature.getCacheSize()) return true;
    if (((Number) expResFeatDrainText.getValue()).intValue()
        != (int) (feature.getPageFactor() * 100)) return true;
    if (((Number) expResFeatPartText.getValue()).intValue() != feature.getPartitions()) return true;

    return false;
  }
Beispiel #10
0
 @Override
 public void applyOptions() {
   options.getOption(OptionsEnum.dim).set(((Integer) dimensionsSpinner.getValue()).intValue());
   options
       .getOption(OptionsEnum.iter)
       .set(Integer.parseInt(this.numOfIterationsSpinner.getValue().toString()));
   options.getOption(OptionsEnum.autoStopIterating).set(autoStopIteratingCheckBox.isSelected());
   options.getOption(OptionsEnum.initLayout).set(initialLayoutTextField.getText());
   options.attrExponent = (Float) attractionExponentTextField.getValue();
   options.repuExponent = (Float) repulsionExponentTextField.getValue();
   options.gravitation = ((Number) gravitationTextField.getValue()).floatValue();
   options.vertRepu = (repulsionTypeTextField.getSelectedIndex() == 1);
   options.noWeight = !weightedCheckbox.isSelected();
   options.getOption(OptionsEnum.scalePos).set((Float) scaleTextField.getValue());
   options.getOption(OptionsEnum.anim).set(animationCheckBox.isSelected());
 }
Beispiel #11
0
  /**
   * Lets the user know that the text they entered is bad. Returns true if the user elects to revert
   * to the last good value. Otherwise, returns false, indicating that the user wants to continue
   * editing.
   */
  protected boolean userSaysRevert() {
    Toolkit.getDefaultToolkit().beep();
    ftf.selectAll();
    Object[] options = {"Editar", "Revertir"};
    String mensaje = "El valor debe ser ";
    if (minimum != null && maximum != null)
      mensaje += "mayor a " + minimum + " y menor a " + maximum;
    else {
      if (minimum != null) mensaje += "mayor a " + minimum;
      if (maximum != null) mensaje += "menor a " + maximum;
    }
    int answer =
        JOptionPane.showOptionDialog(
            SwingUtilities.getWindowAncestor(ftf),
            mensaje + ".\n" + "¿Deseas editar el número " + "o revertir los cambios?",
            "Valor ingresado no válido",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.ERROR_MESSAGE,
            null,
            options,
            options[1]);

    if (answer == 1) { // Revert!
      ftf.setValue(ftf.getValue());
      return true;
    }
    return false;
  }
Beispiel #12
0
    @Override
    public void doApply() {
      super.doApply();
      parametros.put("FECHA_INI", fechaInicial.getDate());
      parametros.put("FECHA_FIN", fechaFinal.getDate());
      String suc = String.valueOf(getSucursal());
      if (todasLasSucursales.isSelected()) suc = "%";

      if (suc.equals("6")) {
        parametros.put("EXI_SUCURSAL", " and X.SUCURSAL_ID  in(6,11)");
      } else if (suc.equals("9")) {
        parametros.put("EXI_SUCURSAL", " and X.SUCURSAL_ID  in(9,14)");
      } else {
        parametros.put("EXI_SUCURSAL", " and X.SUCURSAL_ID LIKE " + "\'" + suc + "\'");
      }

      parametros.put("SUCURSAL", suc);
      parametros.put("LINEA", getLinea());
      int order = getOrden();
      parametros.put("ORDEN", String.valueOf(order));
      parametros.put("FORMA", getForma());
      parametros.put("MESES", getMeses());
      parametros.put("FILTRO", getParam(filtrosBox).value);
      parametros.put("FILTRADO", getParam(filtrosBox).name);
      parametros.put("MESESF", (Double) mesesF.getValue());
      parametros.put("DELINEA", getParam(filtro2Box).value);
    }
  /** Updates the display iteration */
  private void updateIteration() {
    String name = boxName.getText();
    displayIteration.setName(name);
    displayIteration.setDateInterval((Date) startDateBox.getValue(), (Date) endDateBox.getValue());

    if (vm == ViewMode.CREATING) {
      int id = IterationModel.getInstance().getNextID();
      displayIteration.setId(id);
      IterationModel.getInstance().addIteration(displayIteration);

    } else {
      UpdateIterationController.getInstance().updateIteration(displayIteration);
    }

    forceRemove = true;

    ViewEventController.getInstance().removeTab(IterationPanel.this);
  }
Beispiel #14
0
 /**
  * Moves piezo and slice together. Specify the factor by which the step size is multiplied by
  * (e.g. +/- 1).
  *
  * @param factor
  */
 private void stepPiezoAndGalvo(double factor) {
   try {
     double piezoPos = positions_.getUpdatedPosition(piezoImagingDeviceKey_);
     piezoPos += (factor * (Double) piezoDeltaField_.getValue());
     positions_.setPosition(piezoImagingDeviceKey_, piezoPos, true);
     double galvoPos = computeGalvoFromPiezo(piezoPos);
     positions_.setPosition(micromirrorDeviceKey_, Directions.Y, galvoPos, true);
   } catch (Exception ex) {
     MyDialogUtils.showError(ex);
   }
 }
Beispiel #15
0
  public ProblemDescriptors getParameters() {
    if (Utils.isEmpty(problemSizeEdit.getText())
        || Utils.isEmpty(stockLengthEdit.getText())
        || Utils.isEmpty(orderLengthLowerBoundEdit.getText())
        || Utils.isEmpty(orderLengthUpperBoundEdit.getText())
        || Utils.isEmpty(averageDemandEdit.getText())) {
      return null;
    }

    int problemSize = ((Number) problemSizeEdit.getValue()).intValue();
    int stockLength = ((Number) stockLengthEdit.getValue()).intValue();
    double orderLengthLowerBound = ((Number) orderLengthLowerBoundEdit.getValue()).doubleValue();
    double orderLengthUpperBound = ((Number) orderLengthUpperBoundEdit.getValue()).doubleValue();
    int averageDemand = ((Number) averageDemandEdit.getValue()).intValue();

    ProblemDescriptors descriptors =
        new ProblemDescriptors(
            problemSize, stockLength, orderLengthLowerBound, orderLengthUpperBound, averageDemand);

    return descriptors;
  }
Beispiel #16
0
 private int getPort() throws SettingsException {
   int port;
   try {
     port = ((Number) portTextField.getValue()).intValue();
     if (port < 1 || port > 65535) {
       throw new Exception();
     }
   } catch (Exception x) {
     throw new SettingsException("Please specify a valid port number.", x);
   }
   return port;
 }
Beispiel #17
0
 private int getMemoryLimit() throws SettingsException {
   int memoryLimit;
   try {
     memoryLimit = ((Number) memoryTextField.getValue()).intValue();
     if (memoryLimit < 5) {
       throw new Exception();
     }
   } catch (Exception x) {
     throw new SettingsException("Please specify a valid memory limit.", x);
   }
   return memoryLimit;
 }
Beispiel #18
0
 /** Performs "1-point" calibration updating the offset but not the slope. */
 private void updateCalibrationOffset() {
   try {
     double rate = (Double) rateField_.getValue();
     // bypass cached positions in positions_ in case they aren't current
     double currentScanner = positions_.getUpdatedPosition(micromirrorDeviceKey_, Directions.Y);
     double currentPiezo = positions_.getUpdatedPosition(piezoImagingDeviceKey_);
     double newOffset = currentPiezo - rate * currentScanner;
     offsetField_.setValue((Double) newOffset);
   } catch (Exception ex) {
     MyDialogUtils.showError(ex);
   }
 }
  protected void readSizeFromTextField() {

    int size = ((Number) sizetf.getValue()).intValue();
    if (size == getParticlePicker().getSize()) return;

    if (!getParticlePicker().isValidSize(ParticlePickerJFrame.this, size)) {

      int prevsize = getParticlePicker().getSize();
      sizetf.setText(Integer.toString(prevsize));
      return;
    }
    updateSize(size);
  }
  /**
   * Verify that a {@link javax.swing.JFormattedTextField} contains a positive integer.
   *
   * @param jc The {@link javax.swing.JFormattedTextField} with input to verify.
   * @return <code>true</code> if the {@link javax.swing.JFormattedTextField} contains a positive
   *     integer, <code>false</code> otherwise.
   */
  @Override
  public boolean verify(JComponent jc) {
    if (jc instanceof JFormattedTextField) {
      JFormattedTextField numberTextField = (JFormattedTextField) jc;

      if (this.notEmpty.verify(jc) && numberTextField.isEditValid()) {
        int cardNumber = ((Number) numberTextField.getValue()).intValue();
        return cardNumber > 0;
      }
    }

    return false;
  }
  /**
   * Checks whether anything changed and updates buttons as needed.
   *
   * @return boolean
   */
  private boolean checkForChanges() {
    boolean nameChanged = false;
    boolean startChanged = false;
    boolean endChanged = false;
    if (vm == ViewMode.CREATING) {

      nameChanged = !boxName.getText().trim().equals("");
      startChanged = !startDateBox.getText().equals("");
      endChanged = !endDateBox.getText().equals("");
    } else {
      nameChanged = !boxName.getText().equals(displayIteration.getName());
      Date startDate = (Date) startDateBox.getValue();
      Date endDate = (Date) endDateBox.getValue();

      startChanged = !startDate.equals(displayIteration.getStart().getDate());
      endChanged = !endDate.equals(displayIteration.getEnd().getDate());
    }

    boolean anythingChanged = nameChanged || startChanged || endChanged;
    buttonAdd.setEnabled(buttonAdd.isEnabled() && anythingChanged);
    buttonUndoChanges.setEnabled(anythingChanged);
    return anythingChanged;
  }
  @Override
  public boolean isModified() {
    DatabaseSrs refSys = srsComboBox.getSelectedItem();

    try {
      sridText.commitEdit();
    } catch (ParseException e) {
    }
    if (((Number) sridText.getValue()).intValue() != refSys.getSrid()) return true;

    if (!gmlSrsNameText.getText().equals(refSys.getGMLSrsName())) return true;
    if (!descriptionText.getText().equals(refSys.getDescription())) return true;

    return false;
  }
  @Override
  protected boolean updateModel() {
    Tax tax = (Tax) getBean();

    String name = tfName.getText();
    if (POSUtil.isBlankOrNull(name)) {
      MessageDialog.showError(com.floreantpos.POSConstants.NAME_REQUIRED);
      return false;
    }

    tax.setName(name);
    tax.setRate(new Double(tfRate.getValue().toString()).doubleValue());

    return true;
  }
Beispiel #24
0
 protected void save() {
   data.name = nameField.getText();
   try {
     costField.commitEdit();
     data.cost = ((Long) costField.getValue()).intValue();
   } catch (ParseException e) {
     data.cost = 0;
   }
   data.color = colorBox.getSelectedItem().toString();
   data.text = charField.getText();
   data.weight = Float.parseFloat(weightField.getText());
   if (spellBox.getSelectedItem() != null) {
     data.spell = spellBox.getSelectedItem().toString();
   }
   data.setPath(Editor.getStore().getActive().get("id"));
 }
Beispiel #25
0
  private int getHttpsPort() throws SettingsException {
    if (!httpsPortCheckBox.isSelected()) {
      return 0;
    }

    int port;
    try {
      port = ((Number) httpsPortTextField.getValue()).intValue();
      if (port < 1 || port > 65535) {
        throw new Exception();
      }
    } catch (Exception x) {
      throw new SettingsException("Please specify a valid https port number.", x);
    }
    return port;
  }
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == anul) {
      dispose();
    }

    if (source == save) {

      Date now;
      GregorianCalendar cal = new GregorianCalendar();
      now = (Date) jdate.getValue();
      cal.setTime(now);
      if (cal.compareTo(interviewer.getRelieveDay()) >= 0) {
        interviewer.setOutOfWorkTime(interviewer.getRelieveDay(), cal);
        int y1 = interviewer.getRelieveDay().get(Calendar.YEAR); // .toString();
        int m1 = interviewer.getRelieveDay().get(Calendar.MONTH);
        int d1 = interviewer.getRelieveDay().get(Calendar.DAY_OF_MONTH);
        int y2 = cal.get(Calendar.YEAR);
        int m2 = cal.get(Calendar.MONTH);
        int d2 = cal.get(Calendar.DAY_OF_MONTH);
        String s =
            Integer.toString(d1)
                + "."
                + Integer.toString(m1 + 1)
                + "."
                + Integer.toString(y1)
                + " - "
                + Integer.toString(d2)
                + "."
                + Integer.toString(m2 + 1)
                + "."
                + Integer.toString(y2);
        interviewer.setRelieveDay(null);
        JOptionPane.showMessageDialog(this, "Przywrócono ankietera");
        active.setText("Ankieter jest aktywny");
        listModel.addElement(s);
        // JList newJlist = new JList(getTimeOutWork(interviewer));
        // workOutTime = newJlist;
        // SwingUtilities.updateComponentTreeUI(this);
        // System.out.println("dzien zwolnienia ankietera "+ interviewer.getRelieveDay().getTime());
        dispose();
      } else {
        JOptionPane.showMessageDialog(this, "Data nieprawid³owa");
      }
    }
  }
Beispiel #27
0
  /** Metodo com a acaoo do botao OK. */
  private void ok() {
    boolean valido = true;
    EcfPagamento pag = new EcfPagamento();

    try {
      // recupera a barra
      String barra;
      if (txtBarra.getText().equals("") || txtBarra.getText().length() < 30) {
        throw new Exception();
      } else {
        barra = txtBarra.getText();
      }
      pag.setEcfPagamentoNsu(barra);
      // recupera o valor
      Double valor = Double.valueOf(txtValor.getValue().toString());
      if (valor == 0.00 || valor.compareTo(total) > 0) {
        throw new Exception();
      }
      pag.setEcfPagamentoValor(valor);
      // recupera o vencimento
      Date vencimento = Util.formataData(txtVencimento.getText(), "dd/MM/yyyy");
      if (vencimento == null) {
        throw new Exception();
      }
      pag.setEcfPagamentoData(vencimento);
      // seta os demais valores do pagamento
      pag.setEcfPagamentoGnf(0);
      pag.setEcfPagamentoValor(valor);
      pag.setEcfPagamentoNsu(barra);
      pag.setEcfPagamentoEstorno('N');
      pag.setEcfVenda(Caixa.getInstancia().getVenda());
    } catch (Exception ex) {
      valido = false;
    }

    // se valido procegue o processo
    if (valido) {
      setVisible(false);
      async.sucesso(pag);
    } else {
      JOptionPane.showMessageDialog(
          null,
          "Deve-se informar todos os dados, ou dados errados!",
          "Cheque",
          JOptionPane.INFORMATION_MESSAGE);
    }
  }
 @Override
 public boolean stopCellEditing() {
   JFormattedTextField ftf = (JFormattedTextField) getComponent();
   if (ftf.isEditValid()) {
     try {
       ftf.commitEdit();
     } catch (java.text.ParseException exc) {
       // nothing to do
     }
   } else {
     if (!askEditOrRevert(ftf, null)) {
       return false;
     } else {
       ftf.setValue(ftf.getValue());
     }
   }
   return super.stopCellEditing();
 }
Beispiel #29
0
 public void fieldChange2() {
   Double value = (Double) textField2.getValue();
   log.debug("Changed isoFact to: " + value);
   if (value.isInfinite() || value.isNaN()) {
     value = 0.0;
   }
   Setting.getElement("/bat/isotope/calc/bg/error").setText(value.toString());
   for (int i = 0; i < data.corrList.size(); i++) {
     data.corrList.get(i).isoErr = value;
   }
   data.calcAll();
   //		makeReg();
   //	    dataSet = Func.getXY(data.get(dataType),null,x,y,x_multi,y_multi);
   //		chart.getXYPlot().setDataset(0,dataSet);
   log.debug(
       "Isobar correction factor error set to: "
           + value
           + "-"
           + Setting.getDouble("/bat/isotope/calc/bg/error"));
 }
Beispiel #30
0
 // Override to ensure that the value remains an Float.
 @Override
 public Object getCellEditorValue() {
   JFormattedTextField ftf1 = (JFormattedTextField) getComponent();
   Object o = ftf1.getValue();
   if (o instanceof Float) {
     return o;
   } else if (o instanceof Number) {
     return new Float(((Number) o).intValue());
   } else {
     if (DEBUG) {
       System.out.println("getCellEditorValue: o isn't a Number");
     }
     try {
       return floatFormat.parseObject(o.toString());
     } catch (ParseException exc) {
       System.err.println("getCellEditorValue: can't parse o: " + o);
       return null;
     }
   }
 }