Search in sources :

Example 6 with LayerRecordForm

use of com.revolsys.swing.map.form.LayerRecordForm in project com.revolsys.open by revolsys.

the class LayerRecordTableModel method newTablePanel.

public TablePanel newTablePanel() {
    final LayerRecordForm form = this.form.get();
    final BaseJTable table = AbstractSingleRecordTableModel.newTable(this);
    FormAllFieldsModifiedPredicate.add(form, table);
    FormAllFieldsErrorPredicate.add(form, table);
    final TableColumnModel columnModel = table.getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount(); i++) {
        final TableColumn column = columnModel.getColumn(i);
        if (i == 2) {
            final TableCellEditor cellEditor = column.getCellEditor();
            cellEditor.addCellEditorListener(form);
        }
    }
    final TablePanel tablePanel = new TablePanel(table);
    final ToolBar toolBar = tablePanel.getToolBar();
    toolBar.addComponent("default", this.fieldNamesSetNamesField);
    toolBar.addButtonTitleIcon("default", "Edit Field Sets", "fields_filter_edit", () -> {
        final String fieldNamesSetName = FieldNamesSetPanel.showDialog(this.layer);
        if (Property.hasValue(fieldNamesSetName)) {
            this.fieldNamesSetNamesField.setFieldValue(fieldNamesSetName);
        }
    });
    int maxHeight = 500;
    for (final GraphicsDevice device : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
        final GraphicsConfiguration graphicsConfiguration = device.getDefaultConfiguration();
        final Rectangle bounds = graphicsConfiguration.getBounds();
        maxHeight = Math.min(bounds.height, maxHeight);
    }
    final int preferredHeight = Math.min(maxHeight, (this.getRowCount() + 1) * 20 + 45);
    tablePanel.setMinimumSize(new Dimension(100, preferredHeight));
    tablePanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, maxHeight));
    tablePanel.setPreferredSize(new Dimension(800, preferredHeight));
    return tablePanel;
}
Also used : LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) Rectangle(java.awt.Rectangle) TableColumnModel(javax.swing.table.TableColumnModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) GraphicsConfiguration(java.awt.GraphicsConfiguration) GraphicsDevice(java.awt.GraphicsDevice) BaseJTable(com.revolsys.swing.table.BaseJTable) ToolBar(com.revolsys.swing.toolbar.ToolBar) TableCellEditor(javax.swing.table.TableCellEditor) TablePanel(com.revolsys.swing.table.TablePanel)

Example 7 with LayerRecordForm

use of com.revolsys.swing.map.form.LayerRecordForm in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method showAddForm.

public LayerRecord showAddForm(final Map<String, Object> values) {
    if (isCanAddRecords()) {
        final LayerRecord newRecord = newLayerRecord(values);
        final LayerRecordForm form = newForm(newRecord);
        if (form == null) {
            return null;
        } else {
            try {
                form.setAddRecord(newRecord);
                if (form.showAddDialog()) {
                    return form.getAddRecord();
                } else {
                    return null;
                }
            } finally {
                form.setAddRecord(null);
            }
        }
    } else {
        final Window window = SwingUtil.getActiveWindow();
        JOptionPane.showMessageDialog(window, "Adding records is not enabled for the " + getPath() + " layer. If possible make the layer editable", "Cannot Add Record", JOptionPane.ERROR_MESSAGE);
        return null;
    }
}
Also used : Window(java.awt.Window) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm)

Example 8 with LayerRecordForm

use of com.revolsys.swing.map.form.LayerRecordForm in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method delete.

@Override
public void delete() {
    super.delete();
    for (final Window window : this.formWindows) {
        SwingUtil.dispose(window);
    }
    for (final Component form : this.formComponents) {
        if (form != null) {
            if (form instanceof LayerRecordForm) {
                final LayerRecordForm recordForm = (LayerRecordForm) form;
                Invoke.later(recordForm::destroy);
            }
        }
    }
    this.fieldNamesSetNames.clear();
    this.fieldNamesSets.clear();
    this.formRecords.clear();
    this.formComponents.clear();
    this.formWindows.clear();
    this.index = new LayerRecordQuadTree(getGeometryFactory());
    this.recordsByCacheId.clear();
    this.selectedRecordsIndex = null;
}
Also used : Window(java.awt.Window) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Aggregations

LayerRecordForm (com.revolsys.swing.map.form.LayerRecordForm)8 Window (java.awt.Window)4 JComponent (javax.swing.JComponent)4 Component (java.awt.Component)3 Point (com.revolsys.geometry.model.Point)2 Geometry (com.revolsys.geometry.model.Geometry)1 LineString (com.revolsys.geometry.model.LineString)1 Polygonal (com.revolsys.geometry.model.Polygonal)1 SingleIdentifier (com.revolsys.identifier.SingleIdentifier)1 BaseDialog (com.revolsys.swing.component.BaseDialog)1 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)1 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)1 BaseJTable (com.revolsys.swing.table.BaseJTable)1 TablePanel (com.revolsys.swing.table.TablePanel)1 ToolBar (com.revolsys.swing.toolbar.ToolBar)1 UndoManager (com.revolsys.swing.undo.UndoManager)1 Dimension (java.awt.Dimension)1 GraphicsConfiguration (java.awt.GraphicsConfiguration)1 GraphicsDevice (java.awt.GraphicsDevice)1 Rectangle (java.awt.Rectangle)1