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