use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class ModeAllPaged method getRecordsForCache.
@Override
protected List<LayerRecord> getRecordsForCache() {
final AbstractRecordLayer layer = getLayer();
final List<LayerRecord> records = layer.getRecordsNew();
final Condition filter = getFilter();
if (!filter.isEmpty()) {
Predicates.retain(records, filter);
for (final LayerRecord modifiedRecord : layer.getRecordsModified()) {
if (filterTestModified(filter, modifiedRecord)) {
records.add(modifiedRecord);
}
}
}
final RecordLayerTableModel model = getTableModel();
final Comparator<Record> comparator = model.getOrderByComparatorIdentifier();
if (comparator != null) {
records.sort(comparator);
}
return records;
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class ModeAllPaged method getRecordPagePersisted.
protected LayerRecord getRecordPagePersisted(final int pageNumber, final int recordIndex) {
synchronized (this) {
final List<LayerRecord> page = this.pageCache.get(pageNumber);
if (page == null) {
boolean load = false;
synchronized (this.loadingPageNumbers) {
if (!this.loadingPageNumbers.contains(pageNumber)) {
this.loadingPageNumbers.add(pageNumber);
load = true;
}
}
if (load) {
final long refreshIndex = getRefreshIndex();
Invoke.background("loadPage" + getTypeName(), 2, "Loading records " + getTypeName(), //
() -> loadPage(pageNumber), (records) -> {
setRecords(refreshIndex, pageNumber, records);
});
}
} else {
if (recordIndex < page.size()) {
final LayerRecord record = page.get(recordIndex);
return record;
}
}
}
return null;
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordStoreLayerTest method testModifiyRecordCancelChanges.
@Test
public void testModifiyRecordCancelChanges() {
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.cancelChanges();
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", DEFAULT_NAME);
assertRecordValue(actualRecord, "NAME", DEFAULT_NAME);
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordStoreLayerTest method testNewRecordChangeValues.
@Test
public void testNewRecordChangeValues() {
final LayerRecord testRecord = testNewRecord();
testRecord.setValue("NAME", CHANGED_NAME);
final List<LayerRecord> records2 = assertGetRecords(1);
final LayerRecord actualRecord = assertRecordAtIndex(1, records2, 0, testRecord);
assertRecordCounts(1, 0, 0, 0);
assertRecordState(testRecord, RecordState.NEW);
assertRecordState(actualRecord, RecordState.NEW);
Assert.assertTrue("Has Changes", this.layer.isHasChanges());
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordStoreLayerTest method assertRecordAtIndex.
public LayerRecord assertRecordAtIndex(final int count, final List<LayerRecord> records, final int index, final LayerRecord expectedRecord) {
Assert.assertEquals("queryCount", count, records.size());
final LayerRecord actualRecord = records.get(index);
final boolean same1 = expectedRecord.isSame(actualRecord);
Assert.assertTrue("record same", same1);
final boolean same2 = actualRecord.isSame(expectedRecord);
Assert.assertTrue("record same", same2);
return actualRecord;
}
Aggregations