use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.
the class RecordValidationDialog method showErrorDialog.
private void showErrorDialog(final String title, final Consumer<RecordValidationDialog> successAction, final Consumer<RecordValidationDialog> cancelAction) {
Invoke.later(() -> {
final String layerPath = this.layer.getPath();
final Window window = SwingUtil.getActiveWindow();
final JDialog dialog = new JDialog(window, "Error " + title + " for " + layerPath, ModalityType.APPLICATION_MODAL);
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
dialog.setLayout(new BorderLayout());
final ToolBar toolBar = new ToolBar();
toolBar.addButtonTitleIcon("default", "Cancel " + title, "table_cancel", () -> {
dialog.setVisible(false);
cancelAction.accept(this);
});
toolBar.addButtonTitleIcon("default", "Save valid records", "table_save", () -> {
dialog.setVisible(false);
validateRecords(this.invalidRecords, true);
successAction.accept(this);
});
final TablePanel invalidRecordsTablePanel = newInvalidRecordsTablePanel();
final JLabel message = new JLabel("<html><b style=\"color:red\">Edit the invalid fields (red background) for the invalid records.</b><br />" + " Valid records will have a green background when edited.</html>");
message.setBorder(BorderFactory.createTitledBorder(layerPath));
final BasePanel panel = new //
BasePanel(//
new VerticalLayout(), //
toolBar, //
message, //
invalidRecordsTablePanel);
panel.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 6));
if (!this.validRecords.isEmpty()) {
final TablePanel validRecordsTablePanel = newValidRecordsTablePanel();
panel.add(validRecordsTablePanel);
}
dialog.add(panel, BorderLayout.NORTH);
final Rectangle screenBounds = SwingUtil.getScreenBounds();
dialog.pack();
dialog.setSize(screenBounds.width - 50, dialog.getPreferredSize().height);
SwingUtil.setLocationCentre(screenBounds, dialog);
dialog.setVisible(true);
SwingUtil.dispose(dialog);
});
}
use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.
the class BackgroundTaskTableModel method addNewTabPanel.
public static int addNewTabPanel(final TabbedPane tabs) {
final TablePanel panel = newPanel();
final BackgroundTaskTableModel tableModel = panel.getTableModel();
final BackgroundTaskTabLabel tabLabel = new BackgroundTaskTabLabel(tabs, tableModel);
final int tabIndex = tabs.getTabCount();
tabs.addTab(null, BackgroundTaskTabLabel.STATIC, panel);
tabs.setTabComponentAt(tabIndex, tabLabel);
tabs.setSelectedIndex(tabIndex);
return tabIndex;
}
use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.
the class Log4jTableModel method addNewTabPane.
public static void addNewTabPane(final TabbedPane tabs) {
final TablePanel panel = newPanel();
final Log4jTableModel tableModel = panel.getTableModel();
final int tabIndex = tabs.getTabCount();
tabs.addTab(null, Icons.getIcon("error"), panel);
final Log4jTabLabel tabLabel = new Log4jTabLabel(tabs, tableModel);
tabs.setTabComponentAt(tabIndex, tabLabel);
tabs.setSelectedIndex(tabIndex);
}
use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.
the class LayerRecordForm method addTabFields.
protected void addTabFields() {
final TablePanel tablePanel = LayerRecordTableModel.newTablePanel(this);
this.fieldsTableModel = tablePanel.getTableModel();
addTab("Fields", tablePanel);
}
use of com.revolsys.swing.table.TablePanel 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;
}
Aggregations