javax.swing.event.RowSorterEvent Java Examples

The following examples show how to use javax.swing.event.RowSorterEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleTable.java    From wandora with GNU General Public License v3.0 6 votes vote down vote up
private void maybeRepaintOnSorterChanged(RowSorterEvent e) {
    if (beforeSort == null) return;
    if ((e == null) || (e.getType() != RowSorterEvent.Type.SORTED)) return;
    UpdateHandler afterSort = new UpdateHandler(beforeSort);
    if (afterSort.allHidden(beforeSort)) {
        return;
    } else if (afterSort.complex(beforeSort)) {
        repaint();
        return;
    }
    int firstRow = afterSort.getFirstCombined(beforeSort);
    int lastRow = afterSort.getLastCombined(beforeSort);
    Rectangle first = getCellRect(firstRow, 0, false);
    first.width = getWidth();
    Rectangle last = getCellRect(lastRow, 0, false);
    repaint(first.union(last));
}
 
Example #2
Source File: PeakListTable.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * When user sorts the table, we have to cancel current combobox for identity selection.
 * Unfortunately, this doesn't happen automatically.
 */
@Override
public void sorterChanged(RowSorterEvent e) {
  if (currentEditor != null) {
    currentEditor.stopCellEditing();
  }
  super.sorterChanged(e);
}
 
Example #3
Source File: KeymapPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void sorterChanged(RowSorterEvent e) {
    String aid = selectedActionId;
    int colIndex = getSelectedColumn();
    super.sorterChanged(e);
    restoreSelection(aid, colIndex);
}
 
Example #4
Source File: PeakListTable.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * When user sorts the table, we have to cancel current combobox for identity selection.
 * Unfortunately, this doesn't happen automatically.
 */
public void sorterChanged(RowSorterEvent e) {
  if (currentEditor != null) {
    currentEditor.stopCellEditing();
  }
  super.sorterChanged(e);
}
 
Example #5
Source File: PageableTable.java    From jdal with Apache License 2.0 5 votes vote down vote up
/** 
 * Handle sort changes in model sorter. 
 * Query PageableDataSource for new page with the sort changes
 * @see javax.swing.event.RowSorterListener#sorterChanged(javax.swing.event.RowSorterEvent)
 */
public void sorterChanged(RowSorterEvent e) {
	if (sorter.getSortKeys().size() > 0 && 
			tableModel.isPropertyColumn(sorter.getSortKeys().get(0).getColumn())) {
		// set first page
		configurePage();
		page.firstPage();
	}
}
 
Example #6
Source File: JXTableRowHeader.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void sorterChanged(RowSorterEvent rse) {
    tableDataChanged();
}
 
Example #7
Source File: LogTable.java    From LoggerPlusPlus with GNU Affero General Public License v3.0 4 votes vote down vote up
LogTable(LogTableController controller)
{
    super(controller.getLogTableModel(), controller.getLogTableColumnModel());
    this.controller = controller;
    this.preferences = controller.getPreferences();

    this.setTableHeader(controller.getTableHeader()); // This was used to create tool tips
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // to have horizontal scroll bar
    this.setRowHeight(20); // As we are not using Burp customised UI, we have to define the row height to make it more pretty
    this.setDefaultRenderer(Boolean.class, new BooleanRenderer()); //Fix grey checkbox background
    ((JComponent) this.getDefaultRenderer(Boolean.class)).setOpaque(true); // to remove the white background of the checkboxes!

    this.sorter = new TableRowSorter<>(this.getModel());
    this.sorter.setMaxSortKeys(1);
    this.sorter.setSortsOnUpdates(true);
    this.setRowSorter(this.sorter);

    this.sorter.addRowSorterListener(rowSorterEvent -> {
        if(rowSorterEvent.getType() != RowSorterEvent.Type.SORT_ORDER_CHANGED) return;
        List<? extends RowSorter.SortKey> sortKeys = LogTable.this.sorter.getSortKeys();
        if(sortKeys == null || sortKeys.size() == 0){
            this.preferences.setSetting(Globals.PREF_SORT_ORDER, null);
            this.preferences.setSetting(Globals.PREF_SORT_COLUMN, null);
        }else {
            RowSorter.SortKey sortKey = sortKeys.get(0);
            this.preferences.setSetting(Globals.PREF_SORT_ORDER, sortKey.getSortOrder());
            this.preferences.setSetting(Globals.PREF_SORT_COLUMN, sortKey.getColumn());
        }
    });

    Integer sortColumn = this.preferences.getSetting(Globals.PREF_SORT_COLUMN);
    SortOrder sortOrder = this.preferences.getSetting(Globals.PREF_SORT_ORDER);
    if(sortColumn >= 0 && sortOrder != SortOrder.UNSORTED){
        try {
            this.sorter.setSortKeys(Collections.singletonList(new RowSorter.SortKey(sortColumn, sortOrder)));
        }catch (IllegalArgumentException exception){
            //If we can't set the sort key because its invalid, just ignore it.
        }
    }

    this.getSelectionModel().addListSelectionListener(e -> {
        if(e.getValueIsAdjusting()) return;
        RequestViewerController requestViewerController = LogTable.this.controller.getLogViewController().getRequestViewerController();
        int selectedRow = getSelectedRow();
        if(selectedRow == -1){
            requestViewerController.setDisplayedEntity(null);
        }else {
            // Use a relative instead of an absolute index (This prevents an issue when a filter is set)
            LogEntry logEntry = getModel().getData().get(convertRowIndexToModel(selectedRow));
            if (logEntry.requestResponse != null) {
                requestViewerController.setDisplayedEntity(logEntry.requestResponse);
            }
        }
    });

    this.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    registerListeners();
}
 
Example #8
Source File: SimpleTable.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void sorterChanged(RowSorterEvent e) {
    super.sorterChanged(e);
    maybeRepaintOnSorterChanged(e);
}