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;
}
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);
}
});
}
}
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);
}
}
});
}
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;
}
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();
}
}
Aggregations