Search in sources :

Example 6 with TablePanel

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);
    });
}
Also used : Window(java.awt.Window) BasePanel(com.revolsys.swing.component.BasePanel) BorderLayout(java.awt.BorderLayout) ToolBar(com.revolsys.swing.toolbar.ToolBar) Rectangle(java.awt.Rectangle) JLabel(javax.swing.JLabel) VerticalLayout(org.jdesktop.swingx.VerticalLayout) JDialog(javax.swing.JDialog) TablePanel(com.revolsys.swing.table.TablePanel)

Example 7 with TablePanel

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;
}
Also used : TablePanel(com.revolsys.swing.table.TablePanel)

Example 8 with TablePanel

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);
}
Also used : TablePanel(com.revolsys.swing.table.TablePanel)

Example 9 with TablePanel

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);
}
Also used : TablePanel(com.revolsys.swing.table.TablePanel)

Example 10 with 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;
}
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)

Aggregations

TablePanel (com.revolsys.swing.table.TablePanel)13 RecordRowTable (com.revolsys.swing.table.record.RecordRowTable)5 RecordListTableModel (com.revolsys.swing.table.record.model.RecordListTableModel)4 BaseJTable (com.revolsys.swing.table.BaseJTable)3 Record (com.revolsys.record.Record)2 RecordDefinition (com.revolsys.record.schema.RecordDefinition)2 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)2 ColorHighlighter (com.revolsys.swing.table.highlighter.ColorHighlighter)2 ToolBar (com.revolsys.swing.toolbar.ToolBar)2 Dimension (java.awt.Dimension)2 Rectangle (java.awt.Rectangle)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 HighlightPredicate (org.jdesktop.swingx.decorator.HighlightPredicate)2 AndHighlightPredicate (org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate)2 WebColors (com.revolsys.awt.WebColors)1 ObjectPropertyException (com.revolsys.beans.ObjectPropertyException)1 ArrayRecord (com.revolsys.record.ArrayRecord)1 BasePanel (com.revolsys.swing.component.BasePanel)1 LayerRecordForm (com.revolsys.swing.map.form.LayerRecordForm)1