Search in sources :

Example 1 with BaseJTable

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

the class Log4jTableModel method newLogTable.

private static BaseJTable newLogTable() {
    final Log4jTableModel model = new Log4jTableModel();
    final BaseJTable table = new BaseJTable(model);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    for (int i = 0; i < model.getColumnCount(); i++) {
        final TableColumnExt column = table.getColumnExt(i);
        if (i == 0) {
            column.setMinWidth(180);
            column.setPreferredWidth(180);
            column.setMaxWidth(180);
        } else if (i == 1) {
            column.setMinWidth(80);
            column.setPreferredWidth(80);
            column.setMaxWidth(80);
        } else if (i == 2) {
            column.setMinWidth(200);
            column.setPreferredWidth(400);
        } else if (i == 3) {
            column.setMinWidth(200);
            column.setPreferredWidth(800);
        }
    }
    table.setSortOrder(0, SortOrder.DESCENDING);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
                int row = table.rowAtPoint(e.getPoint());
                row = table.convertRowIndexToModel(row);
                if (row != -1) {
                    final LoggingEvent loggingEvent = model.getLoggingEvent(row);
                    LoggingEventPanel.showDialog(table, loggingEvent);
                }
            }
        }
    });
    return table;
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent) MouseEvent(java.awt.event.MouseEvent) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) BaseJTable(com.revolsys.swing.table.BaseJTable) MouseAdapter(java.awt.event.MouseAdapter)

Example 2 with BaseJTable

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

the class RecordRowTable method getEventRecord.

public static <V extends Record> V getEventRecord() {
    final BaseJTable eventTable = TablePanel.getEventTable();
    if (eventTable instanceof RecordRowTable) {
        final RecordRowTable table = (RecordRowTable) eventTable;
        if (table != null) {
            final int eventRow = TablePanel.getEventRow();
            if (eventRow != -1) {
                final RecordRowTableModel model = table.getTableModel();
                final V record = model.getRecord(eventRow);
                return record;
            }
        }
    }
    return null;
}
Also used : BaseJTable(com.revolsys.swing.table.BaseJTable) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel)

Example 3 with BaseJTable

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

the class SingleRecordTableModel method newTable.

public static BaseJTable newTable(final Record object, final boolean editable) {
    final SingleRecordTableModel model = new SingleRecordTableModel(object, editable);
    final BaseJTable table = newTable(model);
    final JTableHeader tableHeader = table.getTableHeader();
    tableHeader.setReorderingAllowed(false);
    return table;
}
Also used : BaseJTable(com.revolsys.swing.table.BaseJTable) JTableHeader(javax.swing.table.JTableHeader)

Example 4 with BaseJTable

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

the class LabelCountMapTableModel method newTable.

public BaseJTable newTable() {
    final BaseJTable table = new BaseJTable(this);
    setTable(table);
    final TableColumnModel columnModel = table.getColumnModel();
    for (int columnIndex = 0; columnIndex < getColumnCount(); columnIndex++) {
        final int columnIndex1 = columnIndex;
        final TableColumn column = columnModel.getColumn(columnIndex1);
        setColumnWidth(columnIndex1, column);
    }
    table.setAutoCreateColumnsFromModel(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    final RowSorter<? extends TableModel> rowSorter = table.getRowSorter();
    final SortKey sortKey = new SortKey(0, SortOrder.ASCENDING);
    rowSorter.setSortKeys(Arrays.asList(sortKey));
    table.addHighlighter(new ColorHighlighter((final Component renderer, final ComponentAdapter adapter) -> {
        final int row = adapter.convertRowIndexToModel(adapter.row);
        if (getValueAt(row, 0).equals(LabelCountMapTableModel.this.selectedLabel)) {
            return true;
        }
        return false;
    }, WebColors.ForestGreen, WebColors.Yellow, WebColors.DarkGreen, WebColors.Yellow));
    table.addHighlighter(new ColorHighlighter((final Component renderer, final ComponentAdapter adapter) -> {
        final int column = adapter.convertColumnIndexToModel(adapter.column);
        final int row = adapter.convertRowIndexToModel(adapter.row);
        if (getValueAt(row, 0).equals(LabelCountMapTableModel.this.selectedLabel)) {
            if (getColumnName(column).equals(LabelCountMapTableModel.this.selectedCountName)) {
                return true;
            }
        }
        return false;
    }, WebColors.Yellow, WebColors.DarkGreen, WebColors.Gold, WebColors.DarkGreen));
    return table;
}
Also used : ColorHighlighter(org.jdesktop.swingx.decorator.ColorHighlighter) BaseJTable(com.revolsys.swing.table.BaseJTable) TableColumnModel(javax.swing.table.TableColumnModel) SortKey(javax.swing.RowSorter.SortKey) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn) ComponentAdapter(org.jdesktop.swingx.decorator.ComponentAdapter)

Example 5 with BaseJTable

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

the class LabelCountMapTableModel method addCountColumn.

private void addCountColumn(final CharSequence name) {
    Invoke.later(() -> {
        this.columnCount++;
        final int columnIndex = 1 + this.countNames.indexOf(name);
        fireTableStructureChanged();
        final BaseJTable table = getTable();
        if (table != null) {
            final TableColumn column = new TableColumnExt(columnIndex);
            setColumnWidth(columnIndex, column);
            table.addColumn(column);
        }
    });
}
Also used : TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) BaseJTable(com.revolsys.swing.table.BaseJTable) TableColumn(javax.swing.table.TableColumn)

Aggregations

BaseJTable (com.revolsys.swing.table.BaseJTable)15 TableColumnExt (org.jdesktop.swingx.table.TableColumnExt)5 TablePanel (com.revolsys.swing.table.TablePanel)4 Dimension (java.awt.Dimension)3 TableColumn (javax.swing.table.TableColumn)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)2 JToolBar (javax.swing.JToolBar)2 TableColumnModel (javax.swing.table.TableColumnModel)2 WebColors (com.revolsys.awt.WebColors)1 PropertyChangeSupport (com.revolsys.beans.PropertyChangeSupport)1 NumericComparator (com.revolsys.comparator.NumericComparator)1 SwingUtil (com.revolsys.swing.SwingUtil)1 TabbedPane (com.revolsys.swing.TabbedPane)1 BasePanel (com.revolsys.swing.component.BasePanel)1 LayerRecordForm (com.revolsys.swing.map.form.LayerRecordForm)1 BaseJPopupMenu (com.revolsys.swing.menu.BaseJPopupMenu)1 MenuFactory (com.revolsys.swing.menu.MenuFactory)1 AbstractTableModel (com.revolsys.swing.table.AbstractTableModel)1 ColorHighlighter (com.revolsys.swing.table.highlighter.ColorHighlighter)1 RecordRowTable (com.revolsys.swing.table.record.RecordRowTable)1