use of com.revolsys.swing.map.layer.record.AbstractRecordLayer in project com.revolsys.open by revolsys.
the class FieldCalculator method validateExpression.
private void validateExpression() {
boolean valid = true;
final String scriptText = this.expressionField.getText();
if (scriptText.isEmpty()) {
valid = false;
} else {
try {
this.script = this.scriptEngineCompiler.compile(scriptText);
final Bindings bindings = newBindings();
final AbstractRecordLayer layer = getLayer();
final RecordDefinition recordDefinition = layer.getRecordDefinition();
final Record record = new ArrayRecord(recordDefinition);
for (final FieldDefinition field : layer.getFieldDefinitions()) {
bindings.put(field.getName(), null);
}
bindings.put("record", record);
this.script.eval(bindings);
this.errorsField.setText(null);
} catch (final Throwable e) {
String errorMessage = e.getMessage();
if (!Property.hasValue(errorMessage)) {
errorMessage = "null pointer";
}
this.errorsField.setText(errorMessage);
this.errorsField.setCaretPosition(0);
valid = false;
this.script = null;
}
}
setFormValid(valid);
}
use of com.revolsys.swing.map.layer.record.AbstractRecordLayer in project com.revolsys.open by revolsys.
the class AbstractMultipleRenderer method convertToScaleStyle.
public ScaleMultipleRenderer convertToScaleStyle() {
final AbstractRecordLayer layer = getLayer();
final List<AbstractRecordLayerRenderer> renderers = getRenderers();
final AbstractMultipleRenderer parent = (AbstractMultipleRenderer) getParent();
final Map<String, Object> style = toMap();
style.remove("styles");
final ScaleMultipleRenderer newRenderer = new ScaleMultipleRenderer(layer, parent);
newRenderer.setProperties(style);
newRenderer.setRenderers(JavaBeanUtil.clone(renderers));
final String name = getName();
if (name.equals("Filter Style")) {
newRenderer.setName("Scale Style");
} else if (name.equals("Multiple Style")) {
newRenderer.setName("Scale Style");
}
replace(layer, parent, newRenderer);
return newRenderer;
}
use of com.revolsys.swing.map.layer.record.AbstractRecordLayer in project com.revolsys.open by revolsys.
the class AbstractMultipleRenderer method convertToMultipleStyle.
public MultipleRecordRenderer convertToMultipleStyle() {
final AbstractRecordLayer layer = getLayer();
final List<AbstractRecordLayerRenderer> renderers = getRenderers();
final AbstractMultipleRenderer parent = (AbstractMultipleRenderer) getParent();
final Map<String, Object> style = toMap();
style.remove("styles");
final MultipleRecordRenderer newRenderer = new MultipleRecordRenderer(layer, parent);
newRenderer.setProperties(style);
newRenderer.setRenderers(JavaBeanUtil.clone(renderers));
final String name = getName();
if (name.equals("Filter Style")) {
newRenderer.setName("Multiple Style");
} else if (name.equals("Scale Style")) {
newRenderer.setName("Multiple Style");
}
replace(layer, parent, newRenderer);
return newRenderer;
}
use of com.revolsys.swing.map.layer.record.AbstractRecordLayer in project com.revolsys.open by revolsys.
the class ModeAbstractCached method forEachRecord.
@Override
public void forEachRecord(final Query query, final Consumer<? super LayerRecord> action) {
final Condition filter = query.getWhereCondition();
final Map<? extends CharSequence, Boolean> orderBy = query.getOrderBy();
final AbstractRecordLayer layer = getLayer();
final Iterable<LayerRecord> records = new ListByIndexIterator<>(this.records);
layer.forEachRecord(records, filter, orderBy, action);
}
use of com.revolsys.swing.map.layer.record.AbstractRecordLayer in project com.revolsys.open by revolsys.
the class ModeAllPaged method forEachRecord.
@Override
public void forEachRecord(final Query query, final Consumer<? super LayerRecord> action) {
final AbstractRecordLayer layer = getLayer();
layer.forEachRecord(query, action);
}
Aggregations