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

项目: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;
}
项目: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    文件: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;
}
项目: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);
    }   
}
项目:j2se_for_android    文件:RowSorter.java   
public void addRowSorterListener(RowSorterListener l) {
    listenerList.add(RowSorterListener.class, l);
}
项目:j2se_for_android    文件:RowSorter.java   
public void removeRowSorterListener(RowSorterListener l) {
    listenerList.remove(RowSorterListener.class, l);
}
项目: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);


}
项目:cn1    文件:RowSorter.java   
public void addRowSorterListener(RowSorterListener l) {
    if (l == null) return;
    listeners.add(l);
}
项目:cn1    文件:RowSorter.java   
public void removeRowSorterListener(RowSorterListener l) {
    if (l == null) return;
    listeners.remove(l);
}
项目:ali-idea-plugin    文件:MultipleItemsDialog.java   
@Override
public void addRowSorterListener(RowSorterListener l) {
    if(!ignoreAddRowSorterListener) {
        super.addRowSorterListener(l);
    }
}
项目:TreeTable    文件:BasicTreeTableUI.java   
@Override
public void addRowSorterListener(RowSorterListener l) {}
项目:TreeTable    文件:BasicTreeTableUI.java   
@Override
public void removeRowSorterListener(RowSorterListener l) {}