Search in sources :

Example 1 with LayerRecordForm

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

the class FormAllFieldsErrorPredicate method isHighlighted.

@Override
public boolean isHighlighted(final Component renderer, final ComponentAdapter adapter) {
    try {
        final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
        final String fieldName = this.model.getColumnFieldName(rowIndex);
        if (fieldName != null) {
            final LayerRecordForm form = this.form.get();
            if (!form.isFieldValid(fieldName)) {
                final JComponent jcomponent = (JComponent) renderer;
                form.setFieldInvalidToolTip(fieldName, jcomponent);
                return true;
            }
        }
    } catch (final IndexOutOfBoundsException e) {
    }
    return false;
}
Also used : LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) JComponent(javax.swing.JComponent)

Example 2 with LayerRecordForm

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

the class AbstractRecordLayer method removeForms.

protected void removeForms(final Iterable<? extends LayerRecord> records) {
    final List<LayerRecordForm> forms = new ArrayList<>();
    final List<Window> windows = new ArrayList<>();
    synchronized (this.formRecords) {
        for (final LayerRecord record : records) {
            final LayerRecord proxiedRecord = getRecordProxied(record);
            final int index = proxiedRecord.indexOf(this.formRecords);
            if (index == -1) {
            } else {
                removeRecordFromCache(this.cacheIdForm, proxiedRecord);
                this.formRecords.remove(index);
                final Component component = this.formComponents.remove(index);
                if (component instanceof LayerRecordForm) {
                    final LayerRecordForm form = (LayerRecordForm) component;
                    forms.add(form);
                }
                final Window window = this.formWindows.remove(index);
                if (window != null) {
                    windows.add(window);
                }
            }
        }
    }
    if (!forms.isEmpty() && !windows.isEmpty()) {
        Invoke.later(() -> {
            for (final LayerRecordForm form : forms) {
                form.destroy();
            }
            for (final Window window : windows) {
                SwingUtil.dispose(window);
            }
        });
    }
}
Also used : Window(java.awt.Window) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) ArrayList(java.util.ArrayList) Component(java.awt.Component) JComponent(javax.swing.JComponent) Point(com.revolsys.geometry.model.Point)

Example 3 with LayerRecordForm

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

the class AbstractRecordLayer method showForm.

public void showForm(final LayerRecord record, final String fieldName) {
    Invoke.later(() -> {
        if (record != null && !record.isDeleted()) {
            final LayerRecord proxiedRecord = getRecordProxied(record);
            final int index;
            Window window;
            synchronized (this.formRecords) {
                index = proxiedRecord.indexOf(this.formRecords);
                if (index == -1) {
                    window = null;
                } else {
                    window = this.formWindows.get(index);
                }
            }
            Component form = null;
            if (window == null) {
                form = newForm(record);
                if (form != null) {
                    final String title = LayerRecordForm.getTitle(record);
                    final Window parent = SwingUtil.getActiveWindow();
                    window = new BaseDialog(parent, title);
                    window.add(form);
                    window.pack();
                    if (form instanceof LayerRecordForm) {
                        final LayerRecordForm recordForm = (LayerRecordForm) form;
                        window.addWindowListener(recordForm);
                        if (record.getState() != RecordState.NEW) {
                            if (!isCanEditRecords()) {
                                recordForm.setEditable(false);
                            }
                        }
                    }
                    SwingUtil.autoAdjustPosition(window);
                    synchronized (this.formRecords) {
                        if (proxiedRecord.isDeleted()) {
                            window.dispose();
                            return;
                        } else {
                            this.formRecords.add(proxiedRecord);
                            this.formComponents.add(form);
                            this.formWindows.add(window);
                        }
                    }
                    window.addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosed(final WindowEvent e) {
                            removeForm(record);
                        }

                        @Override
                        public void windowClosing(final WindowEvent e) {
                            removeForm(record);
                        }
                    });
                    SwingUtil.setVisible(window, true);
                    window.requestFocus();
                    if (proxiedRecord.isDeleted()) {
                        window.setVisible(false);
                    }
                }
            } else {
                SwingUtil.setVisible(window, true);
                window.requestFocus();
                final Component component = window.getComponent(0);
                if (component instanceof JScrollPane) {
                    final JScrollPane scrollPane = (JScrollPane) component;
                    form = scrollPane.getComponent(0);
                }
            }
            if (form instanceof LayerRecordForm) {
                final LayerRecordForm recordForm = (LayerRecordForm) form;
                recordForm.setFieldFocussed(fieldName);
            }
        }
    });
}
Also used : Window(java.awt.Window) JScrollPane(javax.swing.JScrollPane) BaseDialog(com.revolsys.swing.component.BaseDialog) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) LineString(com.revolsys.geometry.model.LineString) Component(java.awt.Component) JComponent(javax.swing.JComponent) Point(com.revolsys.geometry.model.Point)

Example 4 with LayerRecordForm

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

the class FormAllFieldsModifiedPredicate method isHighlighted.

@Override
public boolean isHighlighted(final Component renderer, final ComponentAdapter adapter) {
    try {
        final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
        final String fieldName = this.model.getColumnFieldName(rowIndex);
        if (fieldName != null) {
            final LayerRecordForm form = this.form.get();
            if (form.isFieldValid(fieldName)) {
                if (form.hasOriginalValue(fieldName)) {
                    Object fieldValue = form.getFieldValue(fieldName);
                    if (fieldValue instanceof SingleIdentifier) {
                        final SingleIdentifier singleIdentifier = (SingleIdentifier) fieldValue;
                        fieldValue = singleIdentifier.getValue(0);
                    }
                    final Object originalValue = form.getOriginalValue(fieldName);
                    boolean equal = DataType.equal(originalValue, fieldValue);
                    if (!equal) {
                        if (originalValue == null) {
                            if (fieldValue instanceof String) {
                                final String string = (String) fieldValue;
                                if (!Property.hasValue(string)) {
                                    equal = true;
                                }
                            }
                        }
                    }
                    return !equal;
                }
            }
        }
    } catch (final IndexOutOfBoundsException e) {
    }
    return false;
}
Also used : LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) SingleIdentifier(com.revolsys.identifier.SingleIdentifier)

Example 5 with LayerRecordForm

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

the class GeometryCoordinatesTableModel method setGeometry.

public void setGeometry(final Geometry geometry) {
    final LayerRecordForm form = this.geometryCoordinatesPanel.getForm();
    final LayerRecord record = form.getRecord();
    final Geometry oldGeometry = record.getGeometry();
    if (oldGeometry != geometry) {
        final AbstractRecordLayer layer = record.getLayer();
        final String geometryFieldName = record.getGeometryFieldName();
        final UndoableEdit setGeometryUndo = layer.newSetFieldUndo(record, geometryFieldName, oldGeometry, geometry);
        final UndoManager undoManager = form.getUndoManager();
        undoManager.addEdit(setGeometryUndo);
    }
    if (this.geometry != geometry) {
        this.geometry = geometry;
        if (geometry == null) {
            this.geometryFactory = GeometryFactory.DEFAULT_3D;
            this.vertexIndexMap = Collections.emptyMap();
            this.vertexIndices = Collections.emptyList();
        } else {
            this.geometryFactory = geometry.getGeometryFactory();
            this.vertexIndexMap = getIndexOfVertices(geometry);
            this.vertexIndices = new ArrayList<>(this.vertexIndexMap.keySet());
        }
        this.axisCount = this.geometryFactory.getAxisCount();
        this.axisNames = new ArrayList<>();
        if (geometry.isGeometryCollection()) {
            this.axisNames.add("P");
        }
        if (geometry instanceof Polygonal) {
            this.axisNames.add("R");
        }
        this.vertexIndexColumn = this.axisNames.size();
        this.axisNames.add("#");
        this.segmentIndexColumn = this.axisNames.size();
        this.axisNames.add("S #");
        this.numIndexItems = this.axisNames.size();
        this.axisNames.add("X");
        this.axisNames.add("Y");
        if (this.axisCount > 2) {
            this.axisNames.add("Z");
        }
        if (this.axisCount > 3) {
            this.axisNames.add("M");
        }
        this.columnCount = this.axisNames.size();
        fireTableStructureChanged();
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) UndoManager(com.revolsys.swing.undo.UndoManager) UndoableEdit(javax.swing.undo.UndoableEdit) Polygonal(com.revolsys.geometry.model.Polygonal) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

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