Search in sources :

Example 1 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class LayerRecordForm method actionAddOk.

protected void actionAddOk() {
    final AbstractRecordLayer layer = getLayer();
    final LayerRecord record = getRecord();
    layer.saveChanges(record);
    layer.setSelectedRecords(record);
    layer.showRecordsTable(RecordLayerTableModel.MODE_RECORDS_SELECTED);
    closeWindow();
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 2 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class LayerRecordForm method copyGeometry.

public void copyGeometry() {
    final LayerRecord record = getRecord();
    final AbstractRecordLayer layer = getLayer();
    if (layer != null) {
        if (record != null) {
            layer.copyRecordGeometry(record);
        }
    }
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 3 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class LayerRecordForm method revertChanges.

public void revertChanges() {
    final LayerRecord record = getRecord();
    if (record != null) {
        record.revertChanges();
        setValues(record);
    }
}
Also used : LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 4 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class LayerRecordForm method propertyChange.

@Override
public void propertyChange(final PropertyChangeEvent event) {
    final String propertyName = event.getPropertyName();
    final AbstractRecordLayer layer = getLayer();
    if (layer != null) {
        final LayerRecord record = getRecord();
        if (record != null) {
            final RecordState state = record.getState();
            if (!state.equals(RecordState.DELETED)) {
                final Object source = event.getSource();
                if (this.geometryCoordinatesPanel != null && source == this.geometryCoordinatesPanel.getTable().getModel()) {
                    if (propertyName.equals("geometry")) {
                        record.setGeometryValue((Geometry) event.getNewValue());
                    }
                } else if (source == layer) {
                    if (AbstractRecordLayer.RECORDS_CHANGED.equals(propertyName)) {
                        setRecord(record);
                    } else if (AbstractRecordLayer.RECORDS_DELETED.equals(propertyName)) {
                        @SuppressWarnings("unchecked") final List<Record> deletedRecords = (List<Record>) event.getNewValue();
                        if (layer.isDeleted(record) || record.contains(deletedRecords)) {
                            final Window window = SwingUtilities.getWindowAncestor(this);
                            SwingUtil.setVisible(window, false);
                            setRecord(record);
                            return;
                        }
                    } else if (AbstractRecordLayer.RECORD_UPDATED.equals(propertyName)) {
                        if (record.isDeleted()) {
                            final Window window = SwingUtilities.getWindowAncestor(this);
                            SwingUtil.setVisible(window, false);
                            setRecord(record);
                        }
                    } else if ("editable".equals(propertyName)) {
                        setEditable(layer.isEditable());
                    }
                } else if (source instanceof Field) {
                    final Field field = (Field) source;
                    final String fieldName = field.getFieldName();
                    final Object fieldValue = field.getFieldValue();
                    final Object recordValue = this.record.getValue(fieldName);
                    if (!DataType.equal(recordValue, fieldValue)) {
                        boolean equal = false;
                        if (fieldValue instanceof String) {
                            final String string = (String) fieldValue;
                            if (!Property.hasValue(string) && recordValue == null) {
                                equal = true;
                            }
                        }
                        if (!equal && layer.isEditable() && (state == RecordState.NEW && layer.isCanAddRecords() || layer.isCanEditRecords())) {
                            record.setValueByPath(fieldName, fieldValue);
                        }
                    }
                } else {
                    if (isSame(source)) {
                        if (getRecordDefinition().getIdFieldNames().contains(propertyName)) {
                            Invoke.later(() -> {
                                final String title = getTitle(record);
                                final BaseDialog dialog = (BaseDialog) SwingUtil.getWindowAncestor(this);
                                if (dialog != null) {
                                    dialog.setTitle(title);
                                }
                            });
                        }
                        if (record.isDeleted()) {
                            final Window window = SwingUtilities.getWindowAncestor(this);
                            SwingUtil.setVisible(window, false);
                        } else if (Record.EVENT_RECORD_CHANGED.equals(propertyName)) {
                            setValues(record);
                            return;
                        }
                        final Object value = event.getNewValue();
                        final RecordDefinition recordDefinition = getRecordDefinition();
                        if ("qaMessagesUpdated".equals(propertyName)) {
                            updateErrors();
                        } else if (recordDefinition.hasField(propertyName)) {
                            setFieldValue(propertyName, value, isFieldValidationEnabled());
                        }
                        fireButtonPropertyChanges();
                        repaint();
                    }
                }
            }
        }
    }
}
Also used : Window(java.awt.Window) BaseDialog(com.revolsys.swing.component.BaseDialog) RecordState(com.revolsys.record.RecordState) RecordDefinition(com.revolsys.record.schema.RecordDefinition) NumberTextField(com.revolsys.swing.field.NumberTextField) Field(com.revolsys.swing.field.Field) ObjectLabelField(com.revolsys.swing.field.ObjectLabelField) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Record(com.revolsys.record.Record) List(java.util.List) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 5 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class LayerRecordForm method actionAddCancel.

protected void actionAddCancel() {
    final AbstractRecordLayer layer = getLayer();
    final LayerRecord record = getRecord();
    setRecord(null);
    layer.deleteRecordAndSaveChanges(record);
    this.cancelled = true;
    closeWindow();
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

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