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;
}
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();
}
}
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();
}
}
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);
}
}
});
}
}
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);
}
}
Aggregations