Exemplo n.º 1
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;
  }
Exemplo n.º 2
0
 public Quiz getQuizFromContents() {
   List<Question> questions = new ArrayList<Question>();
   for (QuestionEditor editor : questionEditorList) {
     questions.add(editor.getQuestionFromContents());
   }
   return new Quiz(titleTxt.getText(), authorTxt.getText(), questions);
 }
  public Controls(EPGSwingEngine swingEngine) {
    _playButton = (JToggleButton) swingEngine.find("PLAY_BUTTON");
    _playButton.addActionListener(this);

    _allNotesOffButton = (JButton) swingEngine.find("ALL_NOTES_OFF_BUTTON");
    _allNotesOffButton.addActionListener(this);

    _tempoSlider = (JSlider) swingEngine.find("TEMPO_SLIDER");
    _tempoSlider.addChangeListener(this);

    _tempoInput = (JFormattedTextField) swingEngine.find("TEMPO_INPUT");
    _tempoInput.setPreferredSize(new Dimension(60, _tempoInput.getPreferredSize().height));
    _tempoInput.addActionListener(this);

    _midiOutBox = (JComboBox) swingEngine.find("MIDI_OUT_BOX");
    _midiOutBox.addActionListener(this);

    _midiCheckBox = (JCheckBox) swingEngine.find("MIDI_CHECKBOX");
    _midiCheckBox.addActionListener(this);

    _oscTextField = (JTextField) swingEngine.find("OSC_TEXTFIELD");
    _oscTextField.addActionListener(this);

    _oscCheckBox = (JCheckBox) swingEngine.find("OSC_CHECKBOX");
    _oscCheckBox.addActionListener(this);
  }
Exemplo n.º 4
0
  public void initialize(Instrument instrument) {
    ExpireTimeSpinnerModel model = new ExpireTimeSpinnerModel(instrument);
    this.setModel(model);

    JFormattedTextField textField = ((DateEditor) this.getEditor()).getTextField();
    textField.setValue(model._value);
    textField.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {}

          public void focusLost(FocusEvent e) {
            ExpireTimeSpinnerModel model = (ExpireTimeSpinnerModel) getModel();
            JFormattedTextField textField = ((DateEditor) getEditor()).getTextField();
            try {
              DateTime newTime = DateTime.fromDate((Date) getValue());
              if (newTime.compareTo(model.getEndTime()) > 0) {
                textField.setValue(model.getEndTime());
              } else if (newTime.compareTo(model.getBeginTime()) < 0) {
                textField.setValue(model.getBeginTime());
              } else if (DeliveryHoliday.instance.isHoliday(newTime)) {
                textField.setValue(model.getNextAvaliableTime(newTime));
              }
            } catch (IllegalArgumentException exception) // the input maybe out of datetime range
            {
              textField.setValue(model.getEndTime());
            }
          }
        });
  }
Exemplo n.º 5
0
 /** @see Editor#refreshItem() */
 @Override
 public void refreshItem() {
   if (isEditorForm) {
     JTextField jtfModel = (JTextField) model;
     JFormattedTextField jftfYear = (JFormattedTextField) year;
     if (item == null) {
       item =
           new Bus(
               Bus.getNextBusID(this),
               jtfModel.getText(),
               jftfYear.getText().replaceAll("[^0-9]", ""));
     } else {
       item.model = jtfModel.getText();
       item.year = jftfYear.getText().replaceAll("[^0-9]", "");
     }
   } else {
     JComboBox<Bus> jcbBus = (JComboBox) model;
     Bus bus = (Bus) jcbBus.getSelectedItem();
     if (item == null) {
       item = bus;
     } else {
       item.id = bus.id;
       item.model = bus.model;
       item.year = bus.year;
     }
   }
 }
Exemplo n.º 6
0
  // This method is called when a cell value is edited by the user.
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int row, int column) {
    // Configure the component with the specified value
    if (!mitMaus) {
      ((JFormattedTextField) component).setText(String.valueOf(value));
      ((JFormattedTextField) component).selectAll();
      ((JFormattedTextField) component).setHorizontalAlignment(SwingConstants.RIGHT);
      ((JFormattedTextField) component).setBackground(Color.YELLOW);

    } else {
      final String xvalue = String.valueOf(value);
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              ((JFormattedTextField) component).setText(String.valueOf(xvalue).replace(".", ","));
              ((JFormattedTextField) component).selectAll();
              ((JFormattedTextField) component).setBackground(Color.YELLOW);
              ((JFormattedTextField) component).setHorizontalAlignment(SwingConstants.RIGHT);
              ((JFormattedTextField) component).setCaretPosition(0);
            }
          });
    }

    // Return the configured component
    //// System.out.println("I've been Called!!");
    return component;
  }
 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);
 }
Exemplo n.º 8
0
  private JPanel createParametersPanel() {
    JPanel parametersPanel = new JPanel();
    parametersPanel.setBorder(BorderFactory.createTitledBorder(dataLayer.getString("PARAMETERS")));

    GridLayout parametersPanelLayout = new GridLayout(0, 3);
    parametersPanelLayout.setHgap(10);
    parametersPanelLayout.setVgap(5);
    parametersPanel.setLayout(parametersPanelLayout);
    //
    // -- DELAY ------------------------------------------------------------
    JLabel delayName = new JLabel(dataLayer.getString("DELAY") + ":");
    delayName.setFont(fontBold);
    parametersPanel.add(delayName);

    // create formatter
    RegexFormatter delayFormatter = new RegexFormatter(Validator.DELAY_PATTERN);
    delayFormatter.setAllowsInvalid(true); // allow to enter invalid value for short time
    delayFormatter.setCommitsOnValidEdit(true); // value is immedeatly published to textField
    delayFormatter.setOverwriteMode(false); // do not overwrite charracters

    jTextFieldDelay = new JFormattedTextField(delayFormatter);
    jTextFieldDelay.setText("" + cable.getDelay());
    jTextFieldDelay.setToolTipText(dataLayer.getString("REQUIRED_FORMAT_IS") + " 1-99");
    // add decorator that paints wrong input icon
    parametersPanel.add(new JLayer<JFormattedTextField>(jTextFieldDelay, layerUI));

    JLabel delayTip = new JLabel("1-99");
    parametersPanel.add(delayTip);

    // --  ------------------------------------------------------------
    return parametersPanel;
  }
Exemplo n.º 9
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();
    }
  }
Exemplo n.º 10
0
  public ToolheadIndexer(Frame parent, final Driver d) {
    super(parent, "Set Toolhead Index", true);
    Container c = getContentPane();
    c.setLayout(new MigLayout("fillx,pack pref pref"));
    c.add(new JLabel(instructions), "wrap,wmax 500px");
    c.add(new JLabel("Tool index:"), "split");
    NumberFormat.getNumberInstance();

    final JFormattedTextField toolIndexField =
        new JFormattedTextField(NumberFormat.getIntegerInstance());
    toolIndexField.setColumns(4);
    toolIndexField.setValue(new Integer(0));
    c.add(toolIndexField);
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
          }
        });
    JButton indexButton = new JButton("Set Index");
    indexButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int value = ((Number) toolIndexField.getValue()).intValue();
            Base.logger.info("Setting toolhead index to " + Integer.toString(value));
            ((MultiTool) d).setConnectedToolIndex(value);
            setVisible(false);
          }
        });
    c.add(indexButton);
    c.add(cancelButton);
    pack();
  }
Exemplo n.º 11
0
  public void focusGained(FocusEvent e) {
    JFormattedTextField field = (JFormattedTextField) e.getComponent();

    // Save the current field value in case the user botches up the edit.
    // This allows us to restore the prior value upon field exit
    saveFocusString = field.getText();
  } // focusGained
Exemplo n.º 12
0
  public void initComponents() {

    setLayout(new GridLayout(18, 0, 15, 5));
    msisdnLable = new JLabel("MSISDN");
    querybtn = new JButton("Query");

    ////// Formatted text //////
    NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.getDefault());
    DecimalFormat decimalFormat = (DecimalFormat) numberFormat;
    decimalFormat.setGroupingUsed(false);
    msisdnTextFeild = new JFormattedTextField(decimalFormat);
    msisdnTextFeild.setColumns(12);
    msisdnTextFeild.setToolTipText("lenght Should be " + "at least 12 like 989209202207");
    ///////////////////////////////

    Border innerBorder = BorderFactory.createTitledBorder("Query Items");
    Border outterBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    setBorder(BorderFactory.createCompoundBorder(innerBorder, outterBorder));

    ///////////////////////////////////////////

    add(msisdnLable);
    add(msisdnTextFeild);
    add(new JLabel(""));
    add(querybtn);
  }
Exemplo n.º 13
0
 private void setState(int newState) {
   String message = null;
   this.state = newState;
   switch (state) {
     case ParameterInputComponent.INPUT_IS_VALID:
       field.setBackground(ParameterInputComponent.BG_VALID);
       message = param.getDescription();
       getParentPanel().setMessage(message, Color.black);
       break;
     case ParameterInputComponent.INPUT_IS_OUT_OF_BOUNDS:
       field.setBackground(ParameterInputComponent.BG_INVALID);
       message =
           "Value for "
               + param.getID()
               + " must be between "
               + param.getMinValue()
               + " and "
               + param.getMaxValue()
               + ".";
       getParentPanel().setMessage(message, Color.red);
       break;
     case ParameterInputComponent.INPUT_IS_INCOMPREHENSIBLE:
       field.setBackground(ParameterInputComponent.BG_INVALID);
       message = "Value for " + param.getID() + " must be a valid integer.";
       getParentPanel().setMessage(message, Color.red);
       break;
     case ParameterInputComponent.INPUT_IS_REQUIRED_AND_EMPTY:
       field.setBackground(ParameterInputComponent.BG_INVALID);
       message = "Parameter " + param.getID() + " is required and " + "can not be empty.";
       getParentPanel().setMessage(message, Color.red);
   }
 }
Exemplo n.º 14
0
  protected JComponent createBeepPanel() {
    JPanel beepPanel = new JPanel();

    final JFormattedTextField beepFreq = new JFormattedTextField(Base.getLocalFormat());
    final JFormattedTextField beepDur = new JFormattedTextField(Base.getLocalFormat());
    final JButton beepButton = new JButton("Beep Beep!");

    beepFreq.setColumns(5);
    beepDur.setColumns(5);

    final int EFFECT_DO_IMMEDATELY = 0; // /
    beepButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Base.logger.severe("running sendBeep");
            machine.runCommand(
                new SendBeep(
                    ((Number) beepFreq.getValue()).intValue(),
                    ((Number) beepDur.getValue()).intValue(),
                    EFFECT_DO_IMMEDATELY));
          }
        });

    beepPanel.add(new JLabel("Frequency"), "split");
    beepPanel.add(beepFreq, "growy");
    beepPanel.add(new JLabel("Duration"), "gap unrel");
    beepPanel.add(beepDur, "growx");
    beepPanel.add(beepButton, "gap unrel");
    return beepPanel;
  }
Exemplo n.º 15
0
 private void setContents(Quiz quiz) {
   removeAllContent();
   titleTxt.setText(quiz.getTitle());
   authorTxt.setText(quiz.getAuthor());
   for (Question question : quiz.getQuestionList()) {
     addQuestion(question);
   }
 }
Exemplo n.º 16
0
 @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;
 }
 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);
 }
Exemplo n.º 18
0
 protected void load() {
   nameField.setText(data.name);
   costField.setValue(data.cost);
   colorBox.setSelectedItem(data.color);
   charField.setValue(data.text);
   weightField.setValue(data.weight);
   spellBox.setSelectedItem(data.spell);
 }
Exemplo n.º 19
0
 protected final String getValueString() {
   if (inputField.isEditValid())
     try {
       inputField.commitEdit();
     } catch (Exception e) {
     }
   return inputField.getText();
 }
Exemplo n.º 20
0
  public Ingresso salvaIngresso() {

    Ingresso i = new Ingresso();
    i.setLimiteIngresso(Integer.parseInt(txtQtdIngresso.getText()));
    i.setPrecoSemana(Double.parseDouble(txtSemana.getText().replaceAll(",", ".")));
    i.setPrecoFimDeSemana(Double.parseDouble(txtFds.getText().replaceAll(",", ".")));

    return i;
  }
Exemplo n.º 21
0
 // Override to invoke setValue on the formatted text field.
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   JFormattedTextField ftf1 =
       (JFormattedTextField)
           super.getTableCellEditorComponent(table, value, isSelected, row, column);
   ftf1.setValue(new Float(value.toString()));
   return ftf1;
 }
Exemplo n.º 22
0
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   JFormattedTextField ftf = (JFormattedTextField) getComponent();
   ftf.setFormatterFactory(null);
   ftf.setValue(value);
   ftf.setFormatterFactory(formatterFactory);
   return super.getTableCellEditorComponent(table, value, isSelected, row, column);
 }
Exemplo n.º 23
0
 public NumberSpinner(int value, int min, int max, int step) {
   super(new SpinnerNumberModel(value, min, max, step));
   JSpinner.NumberEditor editor = new JSpinner.NumberEditor(this, "0");
   this.setEditor(editor);
   JFormattedTextField textField = ((JSpinner.NumberEditor) this.getEditor()).getTextField();
   textField.setEditable(true);
   DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory();
   NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter();
   formatter.setAllowsInvalid(false);
 }
Exemplo n.º 24
0
  private void bloqueiaDesbloqueiaCampos(boolean opcao) {

    jTextFieldRazaoSocial.setEditable(opcao);
    jTextFieldFantasia.setEditable(opcao);
    jTextFieldFormatCnpj.setEditable(opcao);
    jTextFieldTelefone.setEditable(opcao);
    jTextFieldEndereco.setEditable(opcao);
    jTextFieldNumero.setEditable(opcao);
    jTextFieldQuantQuartos.setEditable(opcao);
  }
Exemplo n.º 25
0
  /** Updates the text field when the main data model is updated. */
  public void stateChanged(ChangeEvent e) {
    int min = sliderModel.getMinimum();
    int max = sliderModel.getMaximum();
    double value = sliderModel.getDoubleValue();
    NumberFormatter formatter = (NumberFormatter) textField.getFormatter();

    formatter.setMinimum(new Double(min));
    formatter.setMaximum(new Double(max));
    textField.setValue(new Double(value));
  }
Exemplo n.º 26
0
 public void readValues() {
   portTextField.setValue(getPortFromOptionsFile());
   memoryTextField.setValue(getMemoryLimitFromOptionsFile());
   contextPathComboBox.setSelectedItem(getContextPathFromOptionsFile());
   int httpsPort = getHttpsPortFromOptionsFile();
   boolean httpsEnabled = httpsPort != 0;
   httpsPortTextField.setValue(httpsEnabled ? httpsPort : 443);
   httpsPortTextField.setEnabled(httpsEnabled);
   httpsPortCheckBox.setSelected(httpsEnabled);
 }
Exemplo n.º 27
0
  public settings() {

    setUpFormats();
    setPreferredSize(new Dimension(100, 80));
    setBackground(Color.DARK_GRAY);
    ;
    setVisible(true);

    Font font = new Font("Verdana", Font.BOLD, 14);
    angleTag.setFont(font);
    depthTag.setFont(font);
    angleTag.setForeground(Color.white);
    depthTag.setForeground(Color.white);

    angleData = new JFormattedTextField(angleFormat);
    angleData.setValue(new Double(angleRange));
    angleData.setColumns(3);

    depthData = new JFormattedTextField(depthFormat);
    depthData.setValue(new Double(depthRange));
    depthData.setColumns(3);

    alter = new JButton("redraw");
    alter.addActionListener(new buttonListener());

    angleTag.setLabelFor(angleData);
    depthTag.setLabelFor(depthData);

    JPanel labelPanel = new JPanel(new GridLayout(0, 1));
    labelPanel.add(angleTag);
    labelPanel.add(depthTag);
    labelPanel.setBackground(Color.DARK_GRAY);

    JPanel dataPanel = new JPanel(new GridLayout(0, 1));
    dataPanel.add(angleData);
    dataPanel.add(depthData);
    dataPanel.setBackground(Color.DARK_GRAY);

    JPanel buttonPanel = new JPanel(new GridLayout(0, 1));
    buttonPanel.add(alter);
    dataPanel.setBackground(Color.DARK_GRAY);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    add(labelPanel, BorderLayout.CENTER);
    add(dataPanel, BorderLayout.LINE_END);
    add(buttonPanel, BorderLayout.EAST);

    printthing();

    setVisible(true);
    // depthTag.setFont(font);
    // depthTag.setForeground(Color.white);
    // add(depthTag);

  }
  @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());
  }
Exemplo n.º 29
0
 /** @see Editor#areFieldsFilledOut() */
 @Override
 public boolean areFieldsFilledOut() {
   if (isEditorForm) {
     JTextField jtfModel = (JTextField) model;
     JFormattedTextField jftfYear = (JFormattedTextField) year;
     return (!jtfModel.getText().isEmpty()
         && !jftfYear.getText().replaceAll("[^0-9]", "").isEmpty());
   } else {
     return ((JComboBox) model).getSelectedIndex() != -1;
   }
 }
Exemplo n.º 30
0
  private void limpaCampos() {

    txtEvento.setText("");
    txtDataInicio.setText("");
    txtDataFim.setText("");
    txtHorario.setText("");
    rdbtnNao.setSelected(true);
    txtQtdIngresso.setText("");
    txtSemana.setValue(null);
    txtFds.setValue(null);
  }