Java 类javax.swing.event.RowSorterEvent 实例源码

项目:swingx    文件:RowSorterWrapper.java   
/**
 * Creates and returns a RowSorterListener which re-fires received
 * events.
 * 
 * @return
 */
protected RowSorterListener getRowSorterListener() {
    if (rowSorterListener == null) {
        RowSorterListener listener = new RowSorterListener() {

            @Override
            public void sorterChanged(RowSorterEvent e) {
                if (RowSorterEvent.Type.SORT_ORDER_CHANGED == e.getType()) {
                    fireSortOrderChanged();
                } else if (RowSorterEvent.Type.SORTED == e.getType()) {
                    fireRowSorterChanged(null);                }
            }
        };
        rowSorterListener = listener;
    }
    return rowSorterListener;
}
项目:swingx    文件:ListSortUI.java   
/**
 * Called after notification from RowSorter.
 * 
 * @param e RowSorter event of type SORTED.
 */
protected void sortedChanged(RowSorterEvent e) {
    sorterChanged = true;
    if (!ignoreSortChange) {
        prepareForChange(e);
        processChange(null);
        // PENDING Jw: this is fix of 1161-swingx - not updated after setting 
        // rowFilter
        // potentially costly? but how to distinguish a mere sort from a 
        // filterchanged? (only the latter requires a revalidate)
        // first fix had only revalidate/repaint but was not 
        // good enough, see #1261-swingx - no items visible
        // after setting rowFilter
        // need to invalidate the cell size cache which might be needed
        // even after plain sorting as the indi-sizes are now at different
        // positions
        list.invalidateCellSizeCache();
    }
}
项目:swingx    文件:ListSortUI.java   
private int convertRowIndexToModel(RowSorterEvent e, int viewIndex) {
    // JW: the event is null if the selection is cached in prepareChange
    // after model notification. Then the conversion from the 
    // sorter is still valid as the prepare is called before 
    // notifying the sorter.
    if (e != null) {
        if (e.getPreviousRowCount() == 0) {
            return viewIndex;
        }
        // range checking handled by RowSorterEvent
        return e.convertPreviousRowIndexToModel(viewIndex);
    }
    // Make sure the viewIndex is valid
    if (viewIndex < 0 || viewIndex >= sorter.getViewRowCount()) {
        return -1;
    }
    return sorter.convertRowIndexToModel(viewIndex);
}
项目:swingx    文件:JTableIssues.java   
/**
 * 
 */
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));
}
项目:minimal-j    文件:SwingTable.java   
@Override
    public void sorterChanged(RowSorterEvent e) {
        if (e.getType() == Type.SORT_ORDER_CHANGED) {
@SuppressWarnings("unchecked")
List<? extends SortKey> sortKeys = e.getSource().getSortKeys();
            Object[] keys = new Object[sortKeys.size()];
            boolean[] directions = new boolean[sortKeys.size()];
            int index = 0;
            for (SortKey s : sortKeys) {
                keys[index] = SwingTable.this.keys[s.getColumn()];
                directions[index] = s.getSortOrder() == SortOrder.ASCENDING;
                index++;
            }
            if (list instanceof Sortable) {
                ((Sortable) list).sort(keys, directions);
            }
            setOffset(0);
        }
    }
项目:BfROpenLab    文件:MyDBTable.java   
@Override
public void sorterChanged(final RowSorterEvent e) {
    if (e == null || e.getType() == RowSorterEvent.Type.SORT_ORDER_CHANGED) {
        if (this.getTable().getCellEditor() != null) {
            this.getTable().getCellEditor().stopCellEditing();
        }           
    }
    if (e == null || e.getType() == RowSorterEvent.Type.SORTED) {
        //System.out.println("SORTED");
        /*
        if (this.getSelectedRow() >= 0) {
            System.out.println(this.getTable().convertRowIndexToModel(this.getSelectedRow()) + "\t" +
                    this.getTable().convertRowIndexToView(this.getSelectedRow()) + "\t" + this.getSelectedRow());
        }
        */
        if (myDBPanel1 != null) {
            //myDBPanel1.handleSuchfeldChange(null, false); // handleSuchfeldChange hier oben stehen lassen??? Oder lieber runter?? doFilter = false, weil sonst StackOverflow!
            syncTableRowHeights();
            int selID = this.getSelectedID();
            this.setSelectedID(selID, true);
            myDBPanel1.handleSuchfeldChange(null, false); // doFilter = false, weil sonst StackOverflow!
        }       
    }
}
项目:BfROpenLab    文件:TableInputPanel.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    if (inputTable.isEditing()) {
        inputTable.getCellEditor().stopCellEditing();
    }

    if (e.getSource() == table.getRowSorter()) {
        int idColumn = UI.findColumn(table, TracingColumns.ID);

        for (int row = 0; row < table.getRowCount(); row++) {
            String id = (String) table.getValueAt(row, idColumn);

            inputTable.setValueAt(values.get(id), row, 0);
        }
    }
}
项目:wandora    文件:SimpleTable.java   
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));
}
项目:Lightstreamer-example-StockList-client-java    文件:StockView.java   
@Override
public synchronized void sorterChanged(RowSorterEvent e) {
    //the sort listener waits for changes on the sorted columns
    //if the first sort key is the stock_name or the open_price column
    //(that are fields that never change) it disable the dynamic sort
    if (e.getType().equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) {
        List<RowSorter.SortKey> keys = e.getSource().getSortKeys();
        if(!keys.isEmpty()) {
            int y = keys.get(0).getColumn();
            if (y != 0 && y != 11) {
                enableDynamicSort(true);
            } else {
                enableDynamicSort(false);
            }
        }
    } 
}
项目:incubator-netbeans    文件:KeymapPanel.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    String aid = selectedActionId;
    int colIndex = getSelectedColumn();
    super.sorterChanged(e);
    restoreSelection(aid, colIndex);
}
项目:j2se_for_android    文件:RowSorter.java   
void fireRowSorterChanged(RowSorterEvent event) {
    Object[] listeners = listenerList.getListenerList();
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == RowSorterListener.class) {
            ((RowSorterListener) listeners[i + 1]).sorterChanged(event);
        }
    }
}
项目:LS-jsampler    文件:AbstractInstrumentsDbTable.java   
/**
 * Creates a new instance of <code>AbstractInstrumentsDbTable</code>
 */
public AbstractInstrumentsDbTable(InstrumentsDbTableModel model, String tablePrefix) {
    super(model);
    setView(CC.getViewConfig().getInstrumentsDbTableView());

    this.tablePrefix = tablePrefix;
    loadColumnsVisibleState();
    loadColumnWidths();

    setAutoResizeMode(AUTO_RESIZE_OFF);

    rowSorter = new InstrumentsDbTableRowSorter(getModel());
    setRowSorter(rowSorter);

    loadSortOrder();

    RowSorterListener l = new RowSorterListener() {
        public void
        sorterChanged(RowSorterEvent e) {
            if(e.getType() != SORT_ORDER_CHANGED) return;
            rowSorterChanged();
        }
    };

    getRowSorter().addRowSorterListener(l);

    putClientProperty("JTable.autoStartsEdit", false);

    nameEditor = new DefaultCellEditor(tfEditor);
    nameEditor.setClickCountToStart(5);

    if( getModel().getShowDummyColumn()) {
        TableColumn dummy;
        dummy = getColumnModel().getColumn(getModel().getDummyColumnIndex());
        dummy.setPreferredWidth(10);
    }
}
项目:swingx    文件:JXTable.java   
/**
 * Hack around core issue 6791934: sets the sorter changed flag if appropriate.
 * Called after processing the event.
 * @param e the sorter event received from the sorter
 */
protected void postprocessSorterChanged(RowSorterEvent e) {
    filteredRowCountChanged = false;
    if (forceRevalidate && e.getType() == RowSorterEvent.Type.SORTED) {
        filteredRowCountChanged = e.getPreviousRowCount() != getRowCount();
    }
}
项目:swingx    文件:ListSortUI.java   
/**
 * Converts the selection to model coordinates.  This is used when
 * the model changes or the sorter changes.
 */
private int[] convertSelectionToModel(RowSorterEvent e) {
    int[] selection = list.getSelectedIndices();
    for (int i = selection.length - 1; i >= 0; i--) {
        selection[i] = convertRowIndexToModel(e, selection[i]);
    }
    return selection;
}
项目:swingx    文件:ListSortUI.java   
/**
 * Creates and returns a RowSorterListener. This implementation
 * calls sortedChanged if the event is of type SORTED.
 * 
 * @return rowSorterListener to install on sorter.
 */
protected RowSorterListener createRowSorterListener() {
    RowSorterListener l = new RowSorterListener() {

        @Override
        public void sorterChanged(RowSorterEvent e) {
            if (e.getType() == RowSorterEvent.Type.SORTED) {
                sortedChanged(e);
            }
        }

    };
    return l;
}
项目:mzmine2    文件:PeakListTable.java   
/**
    * 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);
   }
项目:oStorybook    文件:FixedColumnScrollPane.java   
@SuppressWarnings("unchecked")
@Override
public void sorterChanged(RowSorterEvent e) {
    RowSorter<TableModel> rowSorter = e.getSource();
    if (e.getSource() == scrollableTable.getRowSorter()) {
        fixedTable.setRowSorter(rowSorter);
    } else if (e.getSource() == fixedTable.getRowSorter()) {
        scrollableTable.setRowSorter(rowSorter);
    }
}
项目:SE-410-Project    文件:FixedColumnScrollPane.java   
@SuppressWarnings("unchecked")
@Override
public void sorterChanged(RowSorterEvent e) {
    RowSorter<TableModel> rowSorter = e.getSource();
    if (e.getSource() == scrollableTable.getRowSorter()) {
        fixedTable.setRowSorter(rowSorter);
    } else if (e.getSource() == fixedTable.getRowSorter()) {
        scrollableTable.setRowSorter(rowSorter);
    }
}
项目:platypus-js    文件:GridTable.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    if (gridContainer != null) {
        gridContainer.try2CancelAnyEditing();
    }
    super.sorterChanged(e);
}
项目:cn1    文件:RowSorter.java   
protected void fireSortOrderChanged() {
    RowSorterEvent event = new RowSorterEvent(this);

    RowSorterListener[] listenerArray = (RowSorterListener[]) listeners.toArray();
    for (int i=0; i<listenerArray.length; i++) {
        listenerArray[i].sorterChanged(event);
    }        
}
项目:cn1    文件:RowSorter.java   
protected void fireRowSorterChanged(int[] lastRowIndexToModel) {
    RowSorterEvent event = new RowSorterEvent(this, RowSorterEvent.Type.SORTED, lastRowIndexToModel);

    RowSorterListener[] listenerArray = (RowSorterListener[]) listeners.toArray();
    for (int i=0; i<listenerArray.length; i++) {
        listenerArray[i].sorterChanged(event);
    }   
}
项目:breakout    文件:AnnotatingRowSorterCursorController.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    if (e.getSource() instanceof AnnotatingRowSorter) {
        AnnotatingRowSorter<?, ?> sorter = (org.andork.swing.AnnotatingRowSorter<?, ?>) e.getSource();
        if (sorter.isSortingInBackground()) {
            busySorters.add(sorter);
        } else {
            busySorters.remove(sorter);
        }

        target.setCursor(busySorters.isEmpty() ? null : Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }
}
项目:breakout    文件:BetterJTable.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    ignoreViewSelectionChanges = true;
    try {
        super.sorterChanged(e);
    } finally {
        ignoreViewSelectionChanges = false;
    }
    updateViewSelectionModel(e);
}
项目:BfROpenLab    文件:EditablePropertiesDialog.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    if (inputTable.isEditing()) {
        inputTable.getCellEditor().stopCellEditing();
    }

    applyValues();
}
项目:jdal    文件:PageableTable.java   
/** 
 * 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();
    }
}
项目:incubator-netbeans    文件:JXTableRowHeader.java   
@Override
public void sorterChanged(RowSorterEvent rse) {
    tableDataChanged();
}
项目:j2se_for_android    文件:JTable.java   
public void sorterChanged(RowSorterEvent e) {
    AndroidClassUtil.callEmptyMethod();
}
项目:j2se_for_android    文件:RowSorter.java   
protected void fireSortOrderChanged() {
    fireRowSorterChanged(new RowSorterEvent(this));
}
项目:j2se_for_android    文件:RowSorter.java   
protected void fireRowSorterChanged(int[] lastRowIndexToModel) {
    fireRowSorterChanged(new RowSorterEvent(this,
            RowSorterEvent.Type.SORTED, lastRowIndexToModel));
}
项目:swingx    文件:JXTable.java   
/**
 * Overridden to hack around core bug 
 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6791934
 * 
 */
@Override
public void sorterChanged(RowSorterEvent e) {
    super.sorterChanged(e);
    postprocessSorterChanged(e);
}
项目:swingx    文件:ListSortUI.java   
private void cacheModelSelection(RowSorterEvent sortEvent) {
    lastModelSelection = convertSelectionToModel(sortEvent);
    modelLeadIndex = convertRowIndexToModel(sortEvent,
                getViewSelectionModel().getLeadSelectionIndex());
}
项目:swingx    文件:JTableIssues.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    super.sorterChanged(e);
    maybeRepaintOnSorterChanged(e);
}
项目:dita-semia-resolver    文件:AdvancedKeyrefDialog.java   
private void createTablePanel(JPanel tablePanel) {

    tablePanel.setLayout(new GridBagLayout());

    keyTable                = new JTable(keyDefTableModel);
    JScrollPane scrollPane  = new JScrollPane(keyTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    enableSorting(keyTable);
    keyTable.getTableHeader().setReorderingAllowed(false); 
    keyTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    keyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    keyTable.getColumnModel().getColumn(0).setPreferredWidth(25);
    keyTable.getColumnModel().getColumn(0).setMaxWidth(30);
    keyTable.getColumnModel().getColumn(0).setResizable(false);
    keyTable.getColumnModel().getColumn(1).setPreferredWidth(150);
    keyTable.getColumnModel().getColumn(2).setPreferredWidth(150);
    keyTable.getColumnModel().getColumn(3).setPreferredWidth(150);
    keyTable.getColumnModel().getColumn(4).setPreferredWidth(150);

    GridBagConstraints localConstr  = new GridBagConstraints();
    localConstr.insets              = new Insets(2, 2, 2, 2);
    localConstr.anchor              = GridBagConstraints.WEST;
    localConstr.fill                = GridBagConstraints.BOTH;
    localConstr.gridx               = 0;
    localConstr.gridy               = 0;
    localConstr.weightx             = 1;
       localConstr.weighty          = 1;

       DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
       centerRenderer.setHorizontalAlignment(JLabel.CENTER);
       keyTable.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);

    tablePanel.add(scrollPane, localConstr);


    sorter  = new TableRowSorter<>(keyDefTableModel);
    sorter.toggleSortOrder(0);
    sorter.toggleSortOrder(0); // initial sorting be priority descending
    sorter.addRowSorterListener(new RowSorterListener() {
           @Override
           public void sorterChanged (RowSorterEvent e) {
               if (e.getType () == RowSorterEvent.Type.SORTED) {
                   int selection = keyTable.getSelectedRow();
                if (selection >= 0) {
                    boxAction = false;
                    reloadBoxItems();
                    updateComboBoxes();
                    boxAction = true;
                    keyTable.setRowSelectionInterval(selection, selection);
                    Rectangle selectRect = keyTable.getCellRect(selection, 0, true);
                    selectRect.height = (keyTable.getParent().getHeight() / 2);
                    keyTable.scrollRectToVisible(selectRect);
                } else {
                    if (keyTable.getRowCount() > 0) {
                        keyTable.changeSelection(0, 0, false, false);
                        boxAction = false;
                        reloadBoxItems();
                        updateComboBoxes();
                        boxAction = true;
                    }
                }
               }
           }
       });
    keyTable.setRowSorter(sorter);


}
项目:JBroTable    文件:JBroTable.java   
@Override
public void sorterChanged( RowSorterEvent e ) {
  if ( getTableHeader() != null && getTableHeader().getUI() != null )
    getTableHeader().getUI().clearCellImagesCache();
  super.sorterChanged( e );
}
项目:platypus-js    文件:SorterListener.java   
public void sorterChanged(RowSorterEvent e) {
    header.repaint();
}
项目:platypus-js    文件:InsettedRowSorter.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    fireRowSorterChanged(null);
}
项目:platypus-js    文件:ConstrainedRowSorter.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    fireRowSorterChanged(null);
}
项目:breakout    文件:AnnotatingJTableJumpBarModel.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    fireContentsChanged(0, table.getRowCount());
}
项目:breakout    文件:BetterJTable.java   
protected void updateViewSelectionModel(RowSorterEvent e) {
    if (e.getType() == Type.SORTED) {
        rebuildViewSelectionModel();
    }
}
项目:wandora    文件:SimpleTable.java   
@Override
public void sorterChanged(RowSorterEvent e) {
    super.sorterChanged(e);
    maybeRepaintOnSorterChanged(e);
}