예제 #1
0
  public void modifyText(ModifyEvent e) {
    if (_internalModify) return;

    try {
      String text = _text.getText();
      double value;
      if (text.length() == 0) {
        value = new Double(0); // $NON-NLS-1$
      } else {
        value = new Double(text);
      }
      _preferences.setDoublePreference(_index, value);
    } catch (NumberFormatException x) {
      // $JL-EXC$ do nothing, reset after the conversion anyway
      updateControl();
    }
  }
예제 #2
0
 /**
  * Updates control according to value in the IPrintPreferences. If it is the first update with an
  * empty textfield, the preference value is set. If it is not the first time an empty text field
  * occurs, nothing happens avoiding the confusing behaviour of updating to 0.00 when the user
  * deletes all characters for preparing new input.
  */
 public void updateControl() {
   _internalModify = true;
   double newValue = _preferences.getDoublePreference(_index);
   try {
     if (_text.getText().length() != 0) {
       double oldValue = Double.valueOf(_text.getText()).doubleValue();
       if (newValue != oldValue) _text.setText(Double.toString(newValue));
     } else {
       if (_initialUpdate) {
         _text.setText(Double.toString(newValue));
       }
     }
   } catch (NumberFormatException e) {
     // $JL-EXC$
     _text.setText(Double.toString(newValue));
   } finally {
     _internalModify = false;
   }
   _initialUpdate = false;
 }