Search in sources :

Example 71 with LayerRecord

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);
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 72 with LayerRecord

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);
        }
    }
}
Also used : LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 73 with LayerRecord

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;
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) JComponent(javax.swing.JComponent) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 74 with LayerRecord

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) {
                }
            }
        }
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) TopologyException(com.revolsys.geometry.model.TopologyException)

Example 75 with LayerRecord

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);
}
Also used : NewProxyLayerRecord(com.revolsys.swing.map.layer.record.NewProxyLayerRecord) IdentifierProxyLayerRecord(com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Test(org.junit.Test)

Aggregations

LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)79 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)34 Geometry (com.revolsys.geometry.model.Geometry)15 IdentifierProxyLayerRecord (com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord)15 NewProxyLayerRecord (com.revolsys.swing.map.layer.record.NewProxyLayerRecord)15 BoundingBox (com.revolsys.geometry.model.BoundingBox)11 Record (com.revolsys.record.Record)11 ArrayList (java.util.ArrayList)11 List (java.util.List)10 Test (org.junit.Test)10 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 Point (com.revolsys.geometry.model.Point)6 Condition (com.revolsys.record.query.Condition)4 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 RecordRowTable (com.revolsys.swing.table.record.RecordRowTable)4 LineString (com.revolsys.geometry.model.LineString)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)3 Layer (com.revolsys.swing.map.layer.Layer)3