Example usage for javax.swing RowFilter regexFilter

List of usage examples for javax.swing RowFilter regexFilter

Introduction

In this page you can find the example usage for javax.swing RowFilter regexFilter.

Prototype

public static <M, I> RowFilter<M, I> regexFilter(String regex, int... indices) 

Source Link

Document

Returns a RowFilter that uses a regular expression to determine which entries to include.

Usage

From source file:dmh.kuebiko.view.NoteTable.java

/**
 * Apply a filter to the table's, hiding all rows that don't match.
 * @param filterString The string to use as a filter.
 *//*  ww w .  j  a v  a2s  .c o  m*/
void filter(String filterString) {
    // Short-circuit if we're clearing the filter.
    if (StringUtils.isBlank(filterString)) {
        sorter.setRowFilter(null);
        return;
    }

    final RowFilter<NoteTableModel, Integer> rowFilter;
    try {
        rowFilter = RowFilter.regexFilter(String.format(".*?%s.*", Pattern.quote(filterString)),
                Column.TITLE.ordinal());
    } catch (PatternSyntaxException e) {
        throw new IllegalArgumentException("Invalid filter string", e);
    }
    sorter.setRowFilter(rowFilter);
}

From source file:components.TableFilterDemo.java

/** 
 * Update the row filter regular expression from the expression in
 * the text box.//from w  w w .  j  av  a2  s.c  om
 */
private void newFilter() {
    RowFilter<MyTableModel, Object> rf = null;
    //If current expression doesn't parse, don't update.
    try {
        rf = RowFilter.regexFilter(filterText.getText(), 0);
    } catch (java.util.regex.PatternSyntaxException e) {
        return;
    }
    sorter.setRowFilter(rf);
}

From source file:TableFilterDemo.java

/**
 * Update the row filter regular expression from the expression in the text
 * box./*from   w  w  w .jav a2s.c  om*/
 */
private void newFilter() {
    RowFilter<MyTableModel, Object> rf = null;
    // If current expression doesn't parse, don't update.
    try {
        rf = RowFilter.regexFilter(filterText.getText(), 0);
    } catch (java.util.regex.PatternSyntaxException e) {
        return;
    }
    sorter.setRowFilter(rf);
}

From source file:edu.harvard.mcz.imagecapture.SpecimenBrowser.java

private void newFilter() {
    RowFilter<SpecimenListTableModel, Object> rf = null;
    //If current expression doesn't parse, don't update.
    try {/* w  ww.  j  a  v a  2s .c  o m*/
        RowFilter<SpecimenListTableModel, Object> rf_family = null;
        RowFilter<SpecimenListTableModel, Object> rf_barcode = null;
        RowFilter<SpecimenListTableModel, Object> rf_drawer = null;
        RowFilter<SpecimenListTableModel, Object> rf_workflow = null;
        rf_family = RowFilter.regexFilter(jTextFieldFamily.getText(), SpecimenListTableModel.COL_FAMILY);
        rf_barcode = RowFilter.regexFilter(jTextField.getText(), SpecimenListTableModel.COL_BARCODE);
        rf_drawer = RowFilter.regexFilter(jTextFieldDrawerNumber.getText(), SpecimenListTableModel.COL_DRAWER);
        rf_workflow = RowFilter.regexFilter(jComboBox.getSelectedItem().toString(),
                SpecimenListTableModel.COL_WORKFLOW);
        ArrayList<RowFilter<SpecimenListTableModel, Object>> i = new ArrayList<RowFilter<SpecimenListTableModel, Object>>();
        i.add(rf_family);
        i.add(rf_barcode);
        i.add(rf_drawer);
        i.add(rf_workflow);
        rf = RowFilter.andFilter((Iterable<RowFilter<SpecimenListTableModel, Object>>) i);
    } catch (java.util.regex.PatternSyntaxException e) {
        return;
    }
    sorter.setRowFilter(rf);
}

From source file:net.sf.dvstar.transmission.TransmissionView.java

/**
 * Update the row filter regular expression from the expression in
 * the text box./*from   w w w  . ja va  2  s .  co  m*/
 */
private void setTorrentListFilter() {
    RowFilter<TorrentsTableModel, Object> rowFilter = null;
    java.util.List<RowFilter<TorrentsTableModel, Object>> filters = new ArrayList<RowFilter<TorrentsTableModel, Object>>();
    //If current expression doesn't parse, don't update.
    try {
        rowFilter = RowFilter.regexFilter(tfFindItem.getText(), 1);
        filters.add(rowFilter);
    } catch (java.util.regex.PatternSyntaxException ex) {
        return;
    }

    // use combo box filter by status
    if (cbFilterStatus.getSelectedIndex() > 0) {

        /*
        0 All
        1 Download TR_STATUS_DOWNLOAD
        2 Stopped  TR_STATUS_STOPPED
        3 Seed     TR_STATUS_SEED
        4 Check    TR_STATUS_CHECK || TR_STATUS_CHECK_WAIT
        5 Error
         */

        String filter = "";
        switch (cbFilterStatus.getSelectedIndex()) {
        case 1:
            filter = "" + TRS_STATUS_DOWNLOAD;
            break;
        case 2:
            filter = "" + TRS_STATUS_PAUSED;
            break;
        case 3:
            filter = "" + TRS_STATUS_SEED;
            break;
        case 4:
            filter = "" + TRS_STATUS_CHECK;
            break;
        case 5:
            break;
        }

        rowFilter = RowFilter.regexFilter(filter, 4);
        filters.add(rowFilter);

    }

    TableRowSorter sorter = (TableRowSorter) tblTorrentList.getRowSorter();
    RowFilter mrowFilter = RowFilter.andFilter(filters);
    if (sorter != null) {

        /**
         * @todo change is possible old selection to new
         */
        //selectedTorrentRows = null;
        lockValueChanged = true;
        sorter.setRowFilter(mrowFilter);
        lockValueChanged = false;
        int rcs = tblTorrentList.getRowSorter().getViewRowCount();
        int rca = tblTorrentList.getRowSorter().getModelRowCount();
        lbFindInfo.setText(String.format("%d of %d", rcs, rca));
        lbFindInfo.invalidate();
    }
}

From source file:com.sciaps.view.SpectrumShotPanel.java

private void filterTable() {
    try {/*from  w  w w.  ja  v  a 2  s  .  co  m*/
        RowFilter<ShotListTableModel, Object> rowFilter = RowFilter
                .regexFilter("(?i)" + txtFilterText_.getText(), 1);
        sorter_.setRowFilter(rowFilter);
    } catch (java.util.regex.PatternSyntaxException ex) {
        logger_.error(ex.getMessage());
    }
}

From source file:org.trzcinka.intellitrac.view.toolwindow.tickets.tickets_list.TicketsListForm.java

/**
 * Update the row filter regular expression from the expression in
 * the text box./*from w  ww .  j a v  a 2 s.  c  o m*/
 */
private void newFilter() {
    RowFilter<TicketsListModel, Object> rf;
    //If current expression doesn't parse, don't update.
    try {
        rf = RowFilter.regexFilter(filterStringTextField.getText(), filterColumnsComboBox.getSelectedIndex());
    } catch (java.util.regex.PatternSyntaxException e) {
        return;
    }
    sorter.setRowFilter(rf);
}

From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.simulation.SimulationTopComponent.java

private void updateFilter() {
    filters.clear();/*ww w .ja  v a 2 s .c o m*/

    if (!StringUtils.isEmpty(txtName.getText())) {
        try {
            nameFilter = RowFilter.regexFilter(txtName.getText(), 1);
            filters.add(nameFilter);
        } catch (java.util.regex.PatternSyntaxException e) {
            return;
        }
    }

    if (!StringUtils.isEmpty(txtSource.getText())) {
        try {
            sourceFilter = RowFilter.regexFilter(txtSource.getText(), 2);
            filters.add(sourceFilter);
        } catch (java.util.regex.PatternSyntaxException e) {
            return;
        }
    }

    if (!StringUtils.isEmpty(txtDest.getText())) {
        try {
            destinationFilter = RowFilter.regexFilter(txtDest.getText(), 3);
            filters.add(destinationFilter);
        } catch (java.util.regex.PatternSyntaxException e) {
            return;
        }
    }

    compoundRowFilter = RowFilter.andFilter(filters); //it is also possible to use OR filter: RowFilter.orFilter

    sorterSimRules.setRowFilter(compoundRowFilter);
    jXTable1.setRowSorter(sorterSimRules);
}

From source file:sms.Form1Exams.java

/**
 * Creates new form Form1Exams//w ww  .  j a v a 2  s  .  c  o m
 */
public Form1Exams() {

    this.table = new JTable(this.model);
    this.sid = new JTextField();
    final TableRowSorter<TableModel> rowSorter = new TableRowSorter(this.table.getModel());
    this.table.setRowSorter(rowSorter);
    sid.getDocument().addDocumentListener(new DocumentListener() {
        public void insertUpdate(DocumentEvent e) {
            String text = Form1Exams.this.sid.getText();
            if (text.trim().length() == 0) {
                rowSorter.setRowFilter(null);
            } else {
                rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text, new int[0]));
            }
        }

        public void removeUpdate(DocumentEvent e) {
            String text = Form1Exams.this.sid.getText();
            if (text.trim().length() == 0) {
                rowSorter.setRowFilter(null);
            } else {
                rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text, new int[0]));
            }
        }

        public void changedUpdate(DocumentEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });

    initComponents();
    setSubjectsModel();
    setExamsModel();
    actionPerformed();
    // findUsers();
    //action and statechanged listner for term radio buttons 

    //title();
}