Search in sources :

Example 1 with RowEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry in project linuxtools by eclipse.

the class TestCreateSystemtapScript method createAndViewDummyData.

private static void createAndViewDummyData(String[] titles, Object[] data) {
    if (data.length % titles.length != 0) {
        throw new IllegalArgumentException("data.length must be a multiple of titles.length.");
    }
    final int numRows = data.length / titles.length;
    IFilteredDataSet dataset = new FilteredRowDataSet(titles);
    for (int i = 0; i < numRows; i++) {
        IDataEntry dataEntry = new RowEntry();
        Object[] values = new Object[titles.length];
        for (int v = 0; v < titles.length; v++) {
            values[v] = data[titles.length * i + v];
        }
        dataEntry.putRow(0, values);
        dataset.setData(dataEntry);
    }
    final File dataFile;
    try {
        dataFile = File.createTempFile("testSet", ".set");
        dataFile.deleteOnExit();
        if (!dataset.writeToFile(dataFile)) {
            throw new IOException();
        }
    } catch (IOException e) {
        fail("Could not create dummy data set.");
        return;
    }
    UIThreadRunnable.syncExec(() -> {
        new ImportDataSetHandler().execute(dataFile.getPath());
    });
    String editorName = dataFile.getName().concat(" Graphs");
    bot.waitUntil(new EditorIsActive(editorName));
}
Also used : ImportDataSetHandler(org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler) IOException(java.io.IOException) Point(org.eclipse.swt.graphics.Point) IFilteredDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet) FilteredRowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet) IDataEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry) RowEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry) File(java.io.File)

Example 2 with RowEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry in project linuxtools by eclipse.

the class FilteredRowDataSetTest method setUp.

@Before
public void setUp() {
    data = new RowDataSet(new String[] { "a", "b", "c" });
    fdata = new FilteredRowDataSet(data);
    new FilteredRowDataSet(data.getTitles());
    entry0 = new RowEntry();
    entry0.putRow(0, new String[] { "1", "2", "3" });
    data.setData(entry0);
    RowEntry entry = new RowEntry();
    entry.putRow(0, new String[] { "4", "5", "6" });
    data.setData(entry);
}
Also used : RowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowDataSet) FilteredRowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet) FilteredRowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet) RowEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry) Before(org.junit.Before)

Example 3 with RowEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry in project linuxtools by eclipse.

the class FilteredRowDataSetTest method testAppend.

// Overwrite methods to insure data is removed from the original DataSet
@Test
public void testAppend() {
    assertEquals(2, data.getEntryCount());
    RowEntry entry = new RowEntry();
    entry.putRow(0, new String[] { "1", "2", "3" });
    fdata.append(entry);
    assertEquals(3, data.getEntryCount());
}
Also used : RowEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry) Test(org.junit.Test)

Example 4 with RowEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry in project linuxtools by eclipse.

the class FilteredRowDataSetTest method testRemove.

@Test
public void testRemove() {
    assertFalse(fdata.remove(null));
    assertFalse(fdata.remove(new RowEntry()));
    assertFalse(fdata.remove(-1));
    assertFalse(fdata.remove(10));
    assertEquals(2, fdata.getEntryCount());
    IDataEntry entry = data.getEntry(0);
    assertTrue(fdata.remove(entry));
    assertEquals(1, fdata.getEntryCount());
    assertFalse(fdata.remove(entry));
    assertTrue(fdata.remove(0));
}
Also used : IDataEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry) RowEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry) Test(org.junit.Test)

Example 5 with RowEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry in project linuxtools by eclipse.

the class FilteredRowDataSetTest method testClearFilters.

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

Aggregations

RowEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry)16 Test (org.junit.Test)11 IDataEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry)3 RowDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowDataSet)3 RangeFilter (org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter)3 SortFilter (org.eclipse.linuxtools.systemtap.graphing.core.filters.SortFilter)3 Before (org.junit.Before)3 FilteredRowDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet)2 File (java.io.File)1 IOException (java.io.IOException)1 ImportDataSetHandler (org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler)1 IFilteredDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet)1 TableEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.TableEntry)1 Point (org.eclipse.swt.graphics.Point)1