Search in sources :

Example 6 with StringHolder

use of maspack.util.StringHolder in project artisynth_core by artisynth.

the class ComponentPropertyField method setValueFromDisplay.

protected void setValueFromDisplay() {
    if (myAlwaysParseText || !myLastText.equals(myTextField.getText()) || (myPropertySelector != null && !((String) (myPropertySelector.getValue())).equals(myLastPropName))) {
        StringHolder errMsg = new StringHolder();
        // we explicitly call fireValueCheckListeners instead of
        // checkValue since textToValue may itself throw an error
        // and we want to handle that in the same way
        BooleanHolder corrected = new BooleanHolder();
        Object value = textToValue(getText(), corrected, null);
        if (value != Property.IllegalValue) {
            value = validateValue(value, errMsg);
        }
        if (value == Property.IllegalValue) {
            focusListenerMasked = true;
            JOptionPane.showMessageDialog(this, errMsg.value, "Error", JOptionPane.ERROR_MESSAGE);
            focusListenerMasked = false;
            myTextField.setText(myLastText);
            updateDisplay();
            myLastEntryAccepted = false;
            return;
        }
        updateValue(value);
        updateDisplay();
    } else {
        setReverseTextBackground(false);
    }
    myLastEntryAccepted = true;
}
Also used : StringHolder(maspack.util.StringHolder) BooleanHolder(maspack.util.BooleanHolder)

Aggregations

StringHolder (maspack.util.StringHolder)6 ValueChangeEvent (maspack.widgets.ValueChangeEvent)3 ValueCheckListener (maspack.widgets.ValueCheckListener)3 BooleanSelector (maspack.widgets.BooleanSelector)2 DoubleField (maspack.widgets.DoubleField)2 PropertyField (artisynth.core.gui.widgets.PropertyField)1 WayPoint (artisynth.core.probes.WayPoint)1 Container (java.awt.Container)1 BoxLayout (javax.swing.BoxLayout)1 JSeparator (javax.swing.JSeparator)1 DistanceGrid (maspack.geometry.DistanceGrid)1 BooleanHolder (maspack.util.BooleanHolder)1 DoubleInterval (maspack.util.DoubleInterval)1 ColorSelector (maspack.widgets.ColorSelector)1 DoubleIntervalField (maspack.widgets.DoubleIntervalField)1 IntegerField (maspack.widgets.IntegerField)1 LabeledComponentPanel (maspack.widgets.LabeledComponentPanel)1 OptionPanel (maspack.widgets.OptionPanel)1 PropertyDialog (maspack.widgets.PropertyDialog)1 PropertyPanel (maspack.widgets.PropertyPanel)1