Search in sources :

Example 11 with RangeFilter

use of org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter in project linuxtools by eclipse.

the class FilteredTableDataSetTest method testClearFilters.

@Test
public void testClearFilters() {
    TableEntry entry;
    entry = new TableEntry();
    entry.add(new Integer[] { 3, 2, 5 });
    dataSet.append(entry);
    entry = new TableEntry();
    entry.add(new Integer[] { 4, 2, 3 });
    dataSet.append(entry);
    entry = new TableEntry();
    entry.add(new Integer[] { 7, 2, 9 });
    dataSet.append(entry);
    entry = new TableEntry();
    entry.add(new Integer[] { 2, 2, 6 });
    dataSet.append(entry);
    entry = new TableEntry();
    entry.add(new Integer[] { 5, 2, 2 });
    dataSet.append(entry);
    dataSet.addFilter(new RangeFilter(0, 3, 5, RangeFilter.INCLUSIVE | RangeFilter.INSIDE_BOUNDS));
    dataSet.addFilter(new SortFilter(2, SortFilter.ASCENDING));
    assertEquals(2, dataSet.getFilters().length);
    dataSet.clearFilters();
    assertEquals(1, dataSet.getRowCount());
    Object[] row = dataSet.getRow(0);
    assertEquals(5, ((Integer) row[0]).intValue());
    assertEquals(2, ((Integer) row[2]).intValue());
    assertEquals(0, dataSet.getFilters().length);
}
Also used : TableEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.TableEntry) SortFilter(org.eclipse.linuxtools.systemtap.graphing.core.filters.SortFilter) RangeFilter(org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter) Test(org.junit.Test)

Example 12 with RangeFilter

use of org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter in project linuxtools by eclipse.

the class RangeFilterWizardPage method createFilter.

@Override
protected void createFilter() {
    filter = null;
    setErrorMessage(null);
    String highText = txtHigh.getText().trim();
    String lowText = txtLow.getText().trim();
    // Allow inside/outside bounds only if the range is bounded (has upper & lower bounds)
    boolean bounded = highText.length() * lowText.length() != 0;
    radInside.setEnabled(bounded);
    radOutside.setEnabled(bounded);
    if (highText.length() + lowText.length() == 0) {
        // $NON-NLS-1$
        setErrorMessage(Localization.getString("RangeFilterWizardPage.EmptyError"));
        return;
    }
    try {
        Double high = highText.length() > 0 ? Double.parseDouble(txtHigh.getText().trim()) : null;
        Double low = lowText.length() > 0 ? Double.parseDouble(txtLow.getText().trim()) : null;
        if (low != null && high != null && low >= high) {
            // $NON-NLS-1$
            setErrorMessage(Localization.getString("RangeFilterWizardPage.BoundError"));
            return;
        }
        // By default, if range is unbounded, force "inside" bounds to apply.
        int style = (!radInside.isEnabled() || radInside.getSelection() ? RangeFilter.INSIDE_BOUNDS : RangeFilter.OUTSIDE_BOUNDS);
        int selected = cboColumn.getSelectionIndex();
        if (chkInclusive.getSelection()) {
            style |= RangeFilter.INCLUSIVE;
        }
        filter = new RangeFilter(selected, low, high, style);
    } catch (NumberFormatException nfe) {
    }
}
Also used : RangeFilter(org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter)

Aggregations

RangeFilter (org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter)12 Test (org.junit.Test)11 SortFilter (org.eclipse.linuxtools.systemtap.graphing.core.filters.SortFilter)7 RowEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry)3 TableEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.TableEntry)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IDataSetFilter (org.eclipse.linuxtools.systemtap.graphing.core.filters.IDataSetFilter)2