Search in sources :

Example 1 with ImportDataSetHandler

use of org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler 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)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 ImportDataSetHandler (org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler)1 IDataEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry)1 IFilteredDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet)1 FilteredRowDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet)1 RowEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry)1 Point (org.eclipse.swt.graphics.Point)1