use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordLayerListSelectionModel method removeSelectionInterval.
@Override
public void removeSelectionInterval(final int index0, final int index1) {
final List<LayerRecord> records = getRecords(index0, index1);
final AbstractRecordLayer layer = this.model.getLayer();
layer.unSelectRecords(records);
super.removeSelectionInterval(index0, index1);
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordValidationDialog method addInvalidRecords.
protected void addInvalidRecords(final List<LayerRecord> records, final boolean withErrors) {
for (int i = 0; i < this.invalidRecords.size(); i++) {
final Map<String, String> errors = this.invalidRecordErrors.get(i);
final boolean hasErrors = !errors.isEmpty();
if (hasErrors == withErrors) {
final LayerRecord record = this.invalidRecords.get(i);
records.add(record);
}
}
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class ModifiedFieldPredicate method isHighlighted.
@Override
public boolean isHighlighted(final Component renderer, final ComponentAdapter adapter) {
String toolTip = null;
boolean highlighted = false;
try {
final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
final Record record = this.model.getRecord(rowIndex);
if (record instanceof LayerRecord) {
final LayerRecord layerRecord = (LayerRecord) record;
final AbstractRecordLayer layer = layerRecord.getLayer();
if (layer.isDeleted(layerRecord)) {
highlighted = false;
} else {
final int columnIndex = adapter.convertColumnIndexToModel(adapter.column);
final String fieldName = this.model.getColumnFieldName(columnIndex);
highlighted = layerRecord.isModified(fieldName);
if (highlighted) {
final RecordDefinition recordDefinition = layerRecord.getRecordDefinition();
final Object originalValue = layerRecord.getOriginalValue(fieldName);
final CodeTable codeTable = recordDefinition.getCodeTableByFieldName(fieldName);
String text;
if (originalValue == null) {
text = "-";
} else if (codeTable == null) {
text = DataTypes.toString(originalValue);
} else {
text = codeTable.getValue(Identifier.newIdentifier(originalValue));
if (text == null) {
text = "-";
}
}
toolTip = text;
}
if (columnIndex < this.model.getColumnFieldsOffset()) {
highlighted = false;
}
}
}
} catch (final IndexOutOfBoundsException e) {
highlighted = false;
}
final JComponent component = (JComponent) renderer;
if (toolTip != null && toolTip.length() > 100) {
toolTip = toolTip.substring(0, 100) + "...";
}
component.setToolTipText(toolTip);
return highlighted;
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class ScaleMultipleRenderer method renderRecords.
@Override
protected // NOTE: Needed for multiple styles
void renderRecords(final Viewport2D viewport, final Cancellable cancellable, final AbstractRecordLayer layer, final List<LayerRecord> records) {
final BoundingBox visibleArea = viewport.getBoundingBox();
final AbstractRecordLayerRenderer renderer = getRenderer(viewport);
if (renderer != null) {
for (final LayerRecord record : cancellable.cancellable(records)) {
if (isVisible(record)) {
try {
renderer.renderRecord(viewport, visibleArea, layer, record);
} catch (final TopologyException e) {
}
}
}
}
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordStoreLayerTest method testModifiyRecordSaveChanges.
@Test
public void testModifiyRecordSaveChanges() {
final LayerRecord testRecord = testNewRecord();
this.layer.saveChanges();
assertRecordCounts(0, 1, 0, 0);
testRecord.setValue("NAME", CHANGED_NAME);
assertRecordState(testRecord, RecordState.MODIFIED);
assertRecordCounts(0, 1, 1, 0);
final List<LayerRecord> records1 = assertGetRecords(1);
assertRecordAtIndex(1, records1, 0, testRecord, IdentifierProxyLayerRecord.class);
// Save the record and verify that it's modified
this.layer.saveChanges();
assertRecordCounts(0, 1, 0, 0);
final List<LayerRecord> records2 = assertGetRecords(1);
final LayerRecord actualRecord = assertRecordAtIndex(1, records2, 0, testRecord, IdentifierProxyLayerRecord.class);
assertRecordState(testRecord, RecordState.PERSISTED);
assertRecordState(actualRecord, RecordState.PERSISTED);
assertRecordValue(testRecord, "NAME", CHANGED_NAME);
assertRecordValue(actualRecord, "NAME", CHANGED_NAME);
}
Aggregations