Search in sources :

Example 1 with GraphSelectorEditor

use of org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor in project linuxtools by eclipse.

the class SaveGraphImageHandler method getActiveGraph.

private AbstractChartBuilder getActiveGraph() {
    GraphSelectorEditor graphEditor = getActiveGraphEditor();
    if (graphEditor == null) {
        return null;
    }
    GraphDisplaySet gds = graphEditor.getActiveDisplaySet();
    return gds == null ? null : gds.getActiveGraph();
}
Also used : GraphSelectorEditor(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor) GraphDisplaySet(org.eclipse.linuxtools.systemtap.graphing.ui.GraphDisplaySet)

Example 2 with GraphSelectorEditor

use of org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor in project linuxtools by eclipse.

the class ExportDataSetHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    GraphSelectorEditor editor = getActiveGraphEditor(event);
    if (editor == null) {
        return null;
    }
    FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);
    dialog.setOverwrite(true);
    dialog.setFilterExtensions(new String[] { Messages.DataSetFileExtension });
    dialog.setText(MessageFormat.format(Messages.ExportDataSetAction_DialogTitle, editor.getActiveTitle()));
    // $NON-NLS-1$ //$NON-NLS-2$
    dialog.setFileName(editor.getActiveTitle().replaceAll(" ", ""));
    String path = dialog.open();
    if (path != null) {
        editor.getActiveDisplaySet().getDataSet().writeToFile(new File(path));
    }
    return null;
}
Also used : GraphSelectorEditor(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Example 3 with GraphSelectorEditor

use of org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor 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)

Example 4 with GraphSelectorEditor

use of org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor in project linuxtools by eclipse.

the class RunScriptChartHandler method scriptConsoleInitialized.

@Override
protected void scriptConsoleInitialized(ScriptConsole console) {
    int n = parsers.size();
    for (int i = 0; i < n; i++) {
        console.getCommand().addInputStreamListener(new ChartStreamDaemon(dataSets.get(i), parsers.get(i)));
    }
    try {
        String name = console.getName();
        String title = name.substring(name.lastIndexOf('/') + 1);
        IWorkbenchPage p = PlatformUI.getWorkbench().showPerspective(IDEPerspective.ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
        GraphSelectorEditor ivp = (GraphSelectorEditor) p.openEditor(new GraphSelectorEditorInput(title), GraphSelectorEditor.ID);
        String scriptName = console.getName();
        ivp.createScriptSets(scriptName, names, dataSets);
        for (int i = 0; i < n; i++) {
            for (GraphData graph : graphs.get(i)) {
                ivp.getDisplaySet(i).addGraph(graph);
            }
        }
    } catch (WorkbenchException we) {
        ExceptionErrorDialog.openError(Messages.RunScriptChartHandler_couldNotSwitchToGraphicPerspective, we);
    }
    super.scriptConsoleInitialized(console);
}
Also used : GraphSelectorEditorInput(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditorInput) ChartStreamDaemon(org.eclipse.linuxtools.systemtap.graphing.core.structures.ChartStreamDaemon) GraphSelectorEditor(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WorkbenchException(org.eclipse.ui.WorkbenchException) GraphData(org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData)

Aggregations

GraphSelectorEditor (org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor)4 File (java.io.File)2 GraphSelectorEditorInput (org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditorInput)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 WorkbenchException (org.eclipse.ui.WorkbenchException)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 IFilteredDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet)1 FilteredRowDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet)1 FilteredTableDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.FilteredTableDataSet)1 ChartStreamDaemon (org.eclipse.linuxtools.systemtap.graphing.core.structures.ChartStreamDaemon)1 GraphData (org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData)1 GraphDisplaySet (org.eclipse.linuxtools.systemtap.graphing.ui.GraphDisplaySet)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1