Search in sources :

Example 1 with FilteredRowDataSet

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet 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 FilteredRowDataSet

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet 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 FilteredRowDataSet

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

the class ImportDataSetHandler method execute.

/**
 * Import a data set from the specified path.
 * @param path The path of the data set to import.
 */
public void execute(String path) {
    IFilteredDataSet dataset = null;
    File file = new File(path);
    try (InputStreamReader fr = new InputStreamReader(new FileInputStream(file), Charset.defaultCharset());
        BufferedReader br = new BufferedReader(fr)) {
        String id = br.readLine();
        // $NON-NLS-1$
        String[] titles = br.readLine().split(", ");
        if (id == null && titles == null) {
            throw new IOException();
        } else if (id.equals(RowDataSet.ID)) {
            dataset = new FilteredRowDataSet(titles);
        } else if (id.equals(TableDataSet.ID)) {
            dataset = new FilteredTableDataSet(titles);
        } else {
            throw new IOException();
        }
        dataset.readFromFile(file);
        String title = path.substring(path.lastIndexOf('/') + 1);
        IWorkbenchPage p = PlatformUI.getWorkbench().showPerspective(IDEPerspective.ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
        GraphSelectorEditor ivp = (GraphSelectorEditor) p.openEditor(new GraphSelectorEditorInput(title), GraphSelectorEditor.ID);
        ivp.createScriptSets(path, Arrays.asList(title), Arrays.asList(dataset));
    } catch (FileNotFoundException fnfe) {
        ExceptionErrorDialog.openError(Messages.ImportDataSetAction_FileNotFound, fnfe);
    } catch (IOException ioe) {
        ExceptionErrorDialog.openError(Messages.ImportDataSetAction_FileInvalid, ioe);
    } catch (WorkbenchException we) {
        ExceptionErrorDialog.openError(Messages.RunScriptChartHandler_couldNotSwitchToGraphicPerspective, we);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) GraphSelectorEditor(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) WorkbenchException(org.eclipse.ui.WorkbenchException) IFilteredDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet) FileInputStream(java.io.FileInputStream) FilteredRowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet) GraphSelectorEditorInput(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditorInput) BufferedReader(java.io.BufferedReader) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) FilteredTableDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.FilteredTableDataSet) File(java.io.File)

Aggregations

FilteredRowDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet)3 File (java.io.File)2 IOException (java.io.IOException)2 IFilteredDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet)2 RowEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 ImportDataSetHandler (org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler)1 IDataEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry)1 RowDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowDataSet)1 FilteredTableDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.FilteredTableDataSet)1 GraphSelectorEditor (org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor)1 GraphSelectorEditorInput (org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditorInput)1 Point (org.eclipse.swt.graphics.Point)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 WorkbenchException (org.eclipse.ui.WorkbenchException)1 Before (org.junit.Before)1