Search in sources :

Example 66 with AbstractRecordLayer

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

the class EditRecordGeometryOverlay method setGeometry.

protected UndoableEdit setGeometry(final CloseLocation location, final Geometry newGeometry) {
    if (isOverlayAction(ACTION_ADD_GEOMETRY) || isOverlayAction(ACTION_ADD_GEOMETRY_EDIT_VERTICES)) {
        if (DataTypes.GEOMETRY.equals(newGeometry, this.addGeometryEditor)) {
            return null;
        } else {
            // TODO
            return null;
        }
    } else {
        final LayerRecord record = location.getRecord();
        final String geometryFieldName = record.getGeometryFieldName();
        final Geometry oldValue = record.getGeometry();
        if (newGeometry == oldValue || newGeometry != null && newGeometry.equalsExact(oldValue)) {
            return null;
        } else {
            final AbstractRecordLayer layer = location.getLayer();
            return layer.newSetFieldUndo(record, geometryFieldName, oldValue, newGeometry);
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LineString(com.revolsys.geometry.model.LineString)

Example 67 with AbstractRecordLayer

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

the class RecordLayerListSelectionModel method addSelectionInterval.

@Override
public void addSelectionInterval(final int index0, final int index1) {
    final List<LayerRecord> records = getRecords(index0, index1);
    final AbstractRecordLayer layer = this.model.getLayer();
    layer.addSelectedRecords(records);
    super.addSelectionInterval(index0, index1);
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 68 with AbstractRecordLayer

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

the class RecordLayerListSelectionModel method isSelectedIndex.

@Override
public boolean isSelectedIndex(final int index) {
    final int rowIndex = convertRowIndexToModel(index);
    final LayerRecord record = this.model.getRecord(rowIndex);
    if (record != null) {
        final AbstractRecordLayer layer = this.model.getLayer();
        final boolean selected = layer.isSelected(record);
        return selected;
    }
    return false;
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 69 with AbstractRecordLayer

use of com.revolsys.swing.map.layer.record.AbstractRecordLayer 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 70 with AbstractRecordLayer

use of com.revolsys.swing.map.layer.record.AbstractRecordLayer 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)

Aggregations

AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)71 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)35 Geometry (com.revolsys.geometry.model.Geometry)9 ArrayList (java.util.ArrayList)8 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)7 Layer (com.revolsys.swing.map.layer.Layer)7 List (java.util.List)7 Record (com.revolsys.record.Record)6 Condition (com.revolsys.record.query.Condition)6 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)6 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 Color (java.awt.Color)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Point (com.revolsys.geometry.model.Point)3 Field (com.revolsys.swing.field.Field)3 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)3 WebColors (com.revolsys.awt.WebColors)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)2 Identifier (com.revolsys.identifier.Identifier)2 FieldDefinition (com.revolsys.record.schema.FieldDefinition)2