Search in sources :

Example 6 with LayerRecord

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

the class LayerRecordForm method deleteRecord.

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

Example 7 with LayerRecord

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

the class LayerRecordForm method addToolBar.

protected ToolBar addToolBar(final AbstractRecordLayer layer) {
    this.toolBar = new ToolBar();
    add(this.toolBar, BorderLayout.NORTH);
    final RecordDefinition recordDefinition = getRecordDefinition();
    final FieldDefinition geometryField = recordDefinition.getGeometryField();
    final boolean hasGeometry = geometryField != null;
    final EnableCheck editable = new ObjectPropertyEnableCheck(this, "editable");
    if (layer != null) {
        final MenuFactory menuFactory = MenuFactory.findMenu(layer);
        if (menuFactory != null) {
            this.toolBar.addButtonTitleIcon("menu", "Layer Menu", "menu", () -> menuFactory.showMenu(layer, this, 10, 10));
        }
    }
    final EnableCheck deletableEnableCheck = editable.and(new ObjectPropertyEnableCheck(this, "deletable"));
    this.toolBar.addButton("record", "Delete Record", "table_row_delete", deletableEnableCheck, this::deleteRecord);
    // Cut, Copy Paste
    this.toolBar.addButton("dnd", "Copy Record", "page_copy", (EnableCheck) null, this::dataTransferCopy);
    if (hasGeometry) {
        this.toolBar.addButton("dnd", "Copy Geometry", "geometry_copy", (EnableCheck) null, this::copyGeometry);
    }
    this.toolBar.addButton("dnd", "Paste Record", "paste_plain", editable, this::dataTransferPaste);
    if (hasGeometry) {
        this.toolBar.addButton("dnd", "Paste Geometry", "geometry_paste", editable, this::pasteGeometry);
    }
    final EnableCheck canUndo = new ObjectPropertyEnableCheck(this.undoManager, "canUndo");
    final EnableCheck canRedo = new ObjectPropertyEnableCheck(this.undoManager, "canRedo");
    final EnableCheck modifiedOrDeleted = new ObjectPropertyEnableCheck(this, "modifiedOrDeleted");
    this.toolBar.addButton("changes", "Revert Record", "arrow_revert", modifiedOrDeleted, this::revertChanges);
    this.toolBar.addButton("changes", "Revert Empty Fields", "field_empty_revert", new ObjectPropertyEnableCheck(this, "hasModifiedEmptyFields"), this::revertEmptyFields);
    this.toolBar.addButton("changes", "Undo", "arrow_undo", canUndo, this.undoManager::undo);
    this.toolBar.addButton("changes", "Redo", "arrow_redo", canRedo, this.undoManager::redo);
    if (hasGeometry) {
        this.toolBar.addButtonTitleIcon("zoom", "Zoom to Record", "magnifier_zoom_selected", () -> {
            final LayerRecord record = getRecord();
            layer.zoomToRecord(record);
        });
        this.toolBar.addButtonTitleIcon("zoom", "Pan to Record", "pan_selected", () -> {
            final LayerRecord record = getRecord();
            final MapPanel mapPanel = layer.getMapPanel();
            if (mapPanel != null) {
                mapPanel.panToRecord(record);
            }
        });
    }
    // Geometry manipulation
    if (hasGeometry) {
        final DataType geometryDataType = geometryField.getDataType();
        if (geometryDataType == DataTypes.LINE_STRING || geometryDataType == DataTypes.MULTI_LINE_STRING) {
            if (DirectionalFields.getProperty(recordDefinition).hasDirectionalFields()) {
                this.toolBar.addButton("geometry", FLIP_RECORD_NAME, FLIP_RECORD_ICON, editable, this::flipRecordOrientation);
                this.toolBar.addButton("geometry", FLIP_LINE_ORIENTATION_NAME, FLIP_LINE_ORIENTATION_ICON, editable, this::flipLineOrientation);
                this.toolBar.addButton("geometry", FLIP_FIELDS_NAME, FLIP_FIELDS_ICON, editable, this::flipFields);
            } else {
                this.toolBar.addButton("geometry", "Flip Line Orientation", "flip_line", editable, this::flipLineOrientation);
            }
        }
    }
    return this.toolBar;
}
Also used : ObjectPropertyEnableCheck(com.revolsys.swing.action.enablecheck.ObjectPropertyEnableCheck) MapPanel(com.revolsys.swing.map.MapPanel) MenuFactory(com.revolsys.swing.menu.MenuFactory) FieldDefinition(com.revolsys.record.schema.FieldDefinition) ToolBar(com.revolsys.swing.toolbar.ToolBar) DataType(com.revolsys.datatype.DataType) EnableCheck(com.revolsys.swing.action.enablecheck.EnableCheck) ObjectPropertyEnableCheck(com.revolsys.swing.action.enablecheck.ObjectPropertyEnableCheck) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 8 with LayerRecord

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

the class RecordLayerTable method addModifiedRecordHighlighter.

@Override
protected void addModifiedRecordHighlighter() {
    final RecordLayerTableModel model = getModel();
    final HighlightPredicate predicate = (renderer, adapter) -> {
        try {
            final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
            final LayerRecord record = model.getRecord(rowIndex);
            final AbstractRecordLayer layer = model.getLayer();
            return layer.isModified(record);
        } catch (final Throwable e) {
            return false;
        }
    };
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.LimeGreen, 127), WebColors.Black, WebColors.newAlpha(WebColors.DarkGreen, 191), Color.WHITE));
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.LimeGreen, WebColors.Black, WebColors.DarkGreen, Color.WHITE));
}
Also used : RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) Color(java.awt.Color) ListSelectionModel(javax.swing.ListSelectionModel) DataFlavor(java.awt.datatransfer.DataFlavor) TextAttribute(java.awt.font.TextAttribute) SwingUtil(com.revolsys.swing.SwingUtil) Transferable(java.awt.datatransfer.Transferable) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) RowFilter(javax.swing.RowFilter) JTableHeader(javax.swing.table.JTableHeader) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) EventObject(java.util.EventObject) RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) WebColors(com.revolsys.awt.WebColors) ClipboardUtil(com.revolsys.swing.dnd.ClipboardUtil) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) RowSorter(javax.swing.RowSorter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) TableModel(javax.swing.table.TableModel) JComponent(javax.swing.JComponent) ChangeEvent(javax.swing.event.ChangeEvent) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) TableColumnModelExtListener(org.jdesktop.swingx.event.TableColumnModelExtListener) TableModelEvent(javax.swing.event.TableModelEvent) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) FontHighlighter(org.jdesktop.swingx.decorator.FontHighlighter) TablePanel(com.revolsys.swing.table.TablePanel) Font(java.awt.Font) TableColumn(javax.swing.table.TableColumn) TableColumnModelExt(org.jdesktop.swingx.table.TableColumnModelExt) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) Geometry(com.revolsys.geometry.model.Geometry) RecordTableCellEditor(com.revolsys.swing.table.record.editor.RecordTableCellEditor) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate)

Example 9 with LayerRecord

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

the class RecordLayerTable method editCellAt.

@Override
public boolean editCellAt(final int row, final int column, final EventObject e) {
    final LayerRecord record = getRecord(row);
    LayerRecordMenu.setEventRecord(record);
    return super.editCellAt(row, column, e);
}
Also used : LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 10 with LayerRecord

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

the class RecordLayerTable method addNewRecordHighlighter.

@Override
protected void addNewRecordHighlighter() {
    final RecordLayerTableModel model = getModel();
    final HighlightPredicate predicate = (renderer, adapter) -> {
        try {
            final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
            final LayerRecord record = model.getRecord(rowIndex);
            final AbstractRecordLayer layer = model.getLayer();
            return layer.isNew(record);
        } catch (final Throwable e) {
            return false;
        }
    };
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.LightSkyBlue, 127), WebColors.Black, WebColors.newAlpha(WebColors.RoyalBlue, 191), Color.WHITE));
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.LightSkyBlue, WebColors.Black, WebColors.RoyalBlue, Color.WHITE));
}
Also used : RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) Color(java.awt.Color) ListSelectionModel(javax.swing.ListSelectionModel) DataFlavor(java.awt.datatransfer.DataFlavor) TextAttribute(java.awt.font.TextAttribute) SwingUtil(com.revolsys.swing.SwingUtil) Transferable(java.awt.datatransfer.Transferable) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) RowFilter(javax.swing.RowFilter) JTableHeader(javax.swing.table.JTableHeader) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) EventObject(java.util.EventObject) RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) WebColors(com.revolsys.awt.WebColors) ClipboardUtil(com.revolsys.swing.dnd.ClipboardUtil) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) RowSorter(javax.swing.RowSorter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) TableModel(javax.swing.table.TableModel) JComponent(javax.swing.JComponent) ChangeEvent(javax.swing.event.ChangeEvent) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) TableColumnModelExtListener(org.jdesktop.swingx.event.TableColumnModelExtListener) TableModelEvent(javax.swing.event.TableModelEvent) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) FontHighlighter(org.jdesktop.swingx.decorator.FontHighlighter) TablePanel(com.revolsys.swing.table.TablePanel) Font(java.awt.Font) TableColumn(javax.swing.table.TableColumn) TableColumnModelExt(org.jdesktop.swingx.table.TableColumnModelExt) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) Geometry(com.revolsys.geometry.model.Geometry) RecordTableCellEditor(com.revolsys.swing.table.record.editor.RecordTableCellEditor) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate)

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