Search in sources :

Example 36 with Field

use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.

the class BaseStylePanel method rendererPropertyChange.

protected boolean rendererPropertyChange(final PropertyChangeEvent event) {
    final Object source = event.getSource();
    if (source instanceof Field) {
        final LayerRenderer<?> renderer = getRenderer();
        final Field field = (Field) source;
        final String fieldName = field.getFieldName();
        final Object fieldValue = field.getFieldValue();
        if (fieldName.endsWith("Scale")) {
            long scale = 0;
            if (fieldValue instanceof Number) {
                final Number number = (Number) fieldValue;
                scale = number.longValue();
            }
            if ("minimumScale".equals(fieldName)) {
                if (scale <= 0) {
                    scale = Long.MAX_VALUE;
                }
            } else if ("maximumScale".equals(fieldName)) {
                if (scale == Long.MAX_VALUE) {
                    scale = 0;
                }
            }
            renderer.setProperty(fieldName, scale);
            return true;
        } else if (this.rendererFieldNames.contains(fieldName)) {
            renderer.setProperty(fieldName, fieldValue);
        }
    }
    return false;
}
Also used : LengthMeasureTextField(com.revolsys.swing.field.LengthMeasureTextField) FontChooserField(com.revolsys.swing.field.FontChooserField) MarkerField(com.revolsys.swing.map.component.MarkerField) JTextField(javax.swing.JTextField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) ColorChooserField(com.revolsys.swing.field.ColorChooserField)

Example 37 with Field

use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.

the class MarkerStylePanel method propertyChangeDo.

@Override
public void propertyChangeDo(final PropertyChangeEvent event) {
    final Object source = event.getSource();
    if (source instanceof Field) {
        final Field field = (Field) source;
        final String fieldName = field.getFieldName();
        final Object fieldValue = field.getFieldValue();
        this.markerStyle.setProperty(fieldName, fieldValue);
    } else if (source == this.markerStyle) {
        final String name = event.getPropertyName();
        final Object value = event.getNewValue();
        setFieldValue(name, value);
    }
    for (final Component preview : this.previews.getComponents()) {
        preview.repaint();
    }
}
Also used : Field(com.revolsys.swing.field.Field) Component(java.awt.Component)

Example 38 with Field

use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.

the class GeometryStylePanel method propertyChangeDo.

@Override
public void propertyChangeDo(final PropertyChangeEvent event) {
    final Object source = event.getSource();
    if (source instanceof Field) {
        final Field field = (Field) source;
        final String fieldName = field.getFieldName();
        Object fieldValue = field.getFieldValue();
        if ("lineDashOffset".equals(fieldName) && !Property.hasValue(fieldValue)) {
            fieldValue = 0;
        }
        this.geometryStyle.setProperty(fieldName, fieldValue);
    } else if (source == this.geometryStyle) {
        final String name = event.getPropertyName();
        final Object value = event.getNewValue();
        setFieldValue(name, value);
    }
    for (final Component preview : this.previews.getComponents()) {
        preview.repaint();
    }
}
Also used : Field(com.revolsys.swing.field.Field) Component(java.awt.Component)

Example 39 with Field

use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.

the class Form method setFieldValues.

public void setFieldValues(final Map<String, ? extends Object> values) {
    if (Property.hasValue(values)) {
        Invoke.later(() -> {
            final Map<String, Object> newValues = new HashMap<>();
            final Map<String, Pair<Object, Throwable>> fieldValueErrors = new HashMap<>();
            try (BaseCloseable settingFieldValue = this.settingFieldValue.closeable(true)) {
                for (final Entry<String, ? extends Object> entry : values.entrySet()) {
                    final String fieldName = entry.getKey();
                    Object fieldValue = entry.getValue();
                    final Field field = getField(fieldName);
                    if (field != null) {
                        try {
                            final boolean valueSet = field.setFieldValue(fieldValue);
                            fieldValue = field.getFieldValue();
                            if (!DataType.equal(this.fieldValueByName.put(fieldName, fieldValue), fieldValue) || valueSet) {
                                newValues.put(fieldName, fieldValue);
                            }
                        } catch (final Throwable e) {
                            fieldValueErrors.put(fieldName, new Pair<>(fieldValue, e));
                        }
                    }
                }
            }
            for (final Entry<String, Object> entry : newValues.entrySet()) {
                final String fieldName = entry.getKey();
                final Object fieldValue = entry.getValue();
                fireFieldValueChanged(null, fieldName, fieldValue);
                fireFieldValueChanged(fieldName, fieldName, fieldValue);
            }
            if (!isSettingFieldValue()) {
                if (!fieldValueErrors.isEmpty()) {
                    postSetFieldValuesErrors(fieldValueErrors);
                }
                if (!newValues.isEmpty()) {
                    postSetFieldValues(newValues);
                }
            }
        });
    }
}
Also used : Field(com.revolsys.swing.field.Field) BaseCloseable(com.revolsys.io.BaseCloseable) HashMap(java.util.HashMap) Pair(com.revolsys.util.Pair)

Example 40 with Field

use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.

the class Form method removeNotify.

@Override
public void removeNotify() {
    super.addNotify();
    for (final Entry<String, Field> entry : this.fieldByName.entrySet()) {
        final String fieldName = entry.getKey();
        final Field field = entry.getValue();
        Property.removeListener(field, fieldName, this.propertyChangeSetValue);
    }
}
Also used : Field(com.revolsys.swing.field.Field)

Aggregations

Field (com.revolsys.swing.field.Field)43 NumberTextField (com.revolsys.swing.field.NumberTextField)15 ObjectLabelField (com.revolsys.swing.field.ObjectLabelField)15 Component (java.awt.Component)13 TextField (com.revolsys.swing.field.TextField)12 JComponent (javax.swing.JComponent)9 JTextField (javax.swing.JTextField)8 AbstractRecordQueryField (com.revolsys.swing.field.AbstractRecordQueryField)7 DateField (com.revolsys.swing.field.DateField)7 ColorChooserField (com.revolsys.swing.field.ColorChooserField)5 QueryWhereConditionField (com.revolsys.swing.field.QueryWhereConditionField)5 JXSearchField (org.jdesktop.swingx.JXSearchField)5 Container (java.awt.Container)4 JComboBox (javax.swing.JComboBox)4 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 FontChooserField (com.revolsys.swing.field.FontChooserField)3 LengthMeasureTextField (com.revolsys.swing.field.LengthMeasureTextField)3 MarkerField (com.revolsys.swing.map.component.MarkerField)3 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)3 BaseCloseable (com.revolsys.io.BaseCloseable)2