Search in sources :

Example 1 with TablePanel

use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.

the class MergedRecordsTableModel method newPanel.

public static TablePanel newPanel(final AbstractRecordLayer layer, final Record mergedObject, final Collection<LayerRecord> objects) {
    final MergedRecordsTableModel model = new MergedRecordsTableModel(layer, mergedObject, objects);
    final RecordRowTable table = new RecordRowTable(model);
    table.setVisibleRowCount(objects.size() + 2);
    MergedValuePredicate.add(table);
    MergedRecordPredicate.add(table);
    MergedNullValuePredicate.add(table);
    table.setSortable(false);
    table.getSelectionModel().addListSelectionListener(model);
    return new TablePanel(table);
}
Also used : RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) TablePanel(com.revolsys.swing.table.TablePanel)

Example 2 with TablePanel

use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.

the class MergeRecordsDialog method setMergedRecord.

public void setMergedRecord(final int i, final Record mergedObject, final Collection<LayerRecord> objects) {
    this.okButton.setEnabled(true);
    final TablePanel tablePanel = MergedRecordsTableModel.newPanel(this.layer, mergedObject, objects);
    final JPanel panel = Panels.titledTransparentVerticalLayout("Merged " + objects.size() + " Records");
    panel.add(tablePanel);
    this.mergedRecordsPanel.add(panel);
}
Also used : JPanel(javax.swing.JPanel) TablePanel(com.revolsys.swing.table.TablePanel)

Example 3 with TablePanel

use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.

the class MergeRecordsDialog method setMergedRecords.

public void setMergedRecords(String errorMessage, final Map<Record, Set<LayerRecord>> mergedRecords) {
    final Set<Record> unMergeableRecords = new HashSet<>(this.mergeableToOiginalRecordMap.keySet());
    unMergeableRecords.removeAll(mergedRecords.keySet());
    if (!mergedRecords.isEmpty()) {
        int i = 0;
        for (final Entry<Record, Set<LayerRecord>> mergedEntry : mergedRecords.entrySet()) {
            final Record mergedObject = mergedEntry.getKey();
            final Set<LayerRecord> originalObjects = mergedEntry.getValue();
            setMergedRecord(i, mergedObject, originalObjects);
            i++;
        }
    }
    if (!unMergeableRecords.isEmpty() || Property.hasValue(errorMessage)) {
        final Set<LayerRecord> records = new LinkedHashSet<>();
        for (final Record record : unMergeableRecords) {
            final LayerRecord originalRecord = this.mergeableToOiginalRecordMap.get(record);
            if (originalRecord != null) {
                records.add(originalRecord);
            }
        }
        final TablePanel tablePanel = RecordListTableModel.newPanel(this.layer, records);
        final RecordListTableModel tableModel = tablePanel.getTableModel();
        tableModel.setEditable(false);
        tablePanel.setPreferredSize(new Dimension(100, 50 + unMergeableRecords.size() * 22));
        final JPanel panel = Panels.titledTransparentBorderLayout(unMergeableRecords.size() + " Un-Mergeable Records");
        if (!Property.hasValue(errorMessage)) {
            errorMessage = "The following records could not be merged and will not be modified.";
        }
        final JLabel unMergeLabel = new JLabel("<html><p style=\"color:red\">" + errorMessage + "</p></html>");
        panel.add(unMergeLabel, BorderLayout.NORTH);
        panel.add(tablePanel, BorderLayout.SOUTH);
        this.mergedRecordsPanel.add(panel);
    }
    SwingUtil.autoAdjustPosition(this);
    setVisible(true);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JPanel(javax.swing.JPanel) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) RecordListTableModel(com.revolsys.swing.table.record.model.RecordListTableModel) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) TablePanel(com.revolsys.swing.table.TablePanel)

Example 4 with TablePanel

use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.

the class RecordLayerErrorsTableModel method newPanel.

public TablePanel newPanel() {
    final RecordRowTable table = new RecordRowTable(this);
    table.setVisibleRowCount(this.getRowCount() + 1);
    table.setSortable(true);
    table.getSelectionModel().addListSelectionListener(this);
    table.resizeColumnsToContent();
    final HighlightPredicate predicate = (renderer, adapter) -> {
        final int columnIndex = adapter.convertColumnIndexToModel(adapter.column);
        return columnIndex == 0;
    };
    table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.Pink, 127), WebColors.FireBrick, WebColors.LightCoral, WebColors.FireBrick));
    table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.Pink, WebColors.FireBrick, WebColors.Crimson, WebColors.White));
    return new TablePanel(table);
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) RecordListTableModel(com.revolsys.swing.table.record.model.RecordListTableModel) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) TablePanel(com.revolsys.swing.table.TablePanel) Collection(java.util.Collection) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) Record(com.revolsys.record.Record) WebColors(com.revolsys.awt.WebColors) List(java.util.List) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ObjectPropertyException(com.revolsys.beans.ObjectPropertyException) SortableTableModel(com.revolsys.swing.table.SortableTableModel) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) TablePanel(com.revolsys.swing.table.TablePanel)

Example 5 with TablePanel

use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.

the class RecordValidationDialog method newValidRecordsTablePanel.

private TablePanel newValidRecordsTablePanel() {
    final RecordDefinition recordDefinition = this.layer.getRecordDefinition();
    final List<String> fieldNames = this.layer.getFieldNames();
    final RecordListTableModel model = new RecordListTableModel(recordDefinition, this.validRecords, fieldNames);
    final RecordRowTable table = new RecordRowTable(model);
    table.setVisibleRowCount(Math.min(10, model.getRowCount() + 1));
    table.setSortable(true);
    table.setEditable(false);
    table.resizeColumnsToContent();
    final TablePanel tablePanel = new TablePanel(table);
    tablePanel.setBorder(BorderFactory.createTitledBorder(table.getRowCount() + " valid records"));
    return tablePanel;
}
Also used : RecordListTableModel(com.revolsys.swing.table.record.model.RecordListTableModel) RecordDefinition(com.revolsys.record.schema.RecordDefinition) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) 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