Search in sources :

Example 1 with ChartEditorInput

use of org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput in project linuxtools by eclipse.

the class ChartExportTest method testChartExportPNG.

@Test
public void testChartExportPNG() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDefaults");
    IEditorInput input = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
    assertTrue("input must be ChartEditorInput", input instanceof ChartEditorInput);
    Composite control = ((ChartEditorInput) input).getChart().getChartControl();
    if (control.getSize().x == 0 || control.getSize().y == 0) {
        // Manually resize the composite to non-zero width/height so it can be saved
        control.setSize(10, 10);
    }
    SaveChartAction saveChartAction = (SaveChartAction) getToolbarAction(MassifViewPart.SAVE_CHART_ACTION);
    assertNotNull(saveChartAction);
    for (IPath path : paths) {
        saveAsPath(saveChartAction, path);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) SaveChartAction(org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction) Composite(org.eclipse.swt.widgets.Composite) IPath(org.eclipse.core.runtime.IPath) ChartEditorInput(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput) IEditorInput(org.eclipse.ui.IEditorInput) Test(org.junit.Test)

Example 2 with ChartEditorInput

use of org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput in project linuxtools by eclipse.

the class ChartTests method byteScalingHelper.

private void byteScalingHelper(int ix, long times, long bytes, String testName) throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, // $NON-NLS-1$
    String.valueOf(bytes) + " " + String.valueOf(times));
    wc.setAttribute(MassifLaunchConstants.ATTR_MASSIF_TIMEUNIT, MassifLaunchConstants.TIME_B);
    config = wc.doSave();
    doLaunch(config, testName);
    IAction chartAction = getChartAction();
    assertNotNull(chartAction);
    chartAction.run();
    IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    assertTrue(part.getEditorInput() instanceof ChartEditorInput);
    ChartEditorInput input = (ChartEditorInput) part.getEditorInput();
    HeapChart chart = input.getChart();
    assertEquals(HeapChart.getByteUnits()[ix], chart.getXUnits());
}
Also used : HeapChart(org.eclipse.linuxtools.internal.valgrind.massif.charting.HeapChart) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IAction(org.eclipse.jface.action.IAction) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IEditorPart(org.eclipse.ui.IEditorPart) ChartEditorInput(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput)

Example 3 with ChartEditorInput

use of org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput in project linuxtools by eclipse.

the class MassifViewPart method createChart.

private void createChart(MassifSnapshot[] snapshots) {
    // $NON-NLS-1$//$NON-NLS-2$
    String title = chartName + " [PID: " + pid + "]";
    HeapChart chart = new HeapChart(snapshots, title);
    String name = getInputName(title);
    ChartEditorInput input = new ChartEditorInput(chart, this, name, pid);
    chartInputs.add(input);
    // open the editor
    displayChart(input);
}
Also used : HeapChart(org.eclipse.linuxtools.internal.valgrind.massif.charting.HeapChart) ChartEditorInput(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput)

Example 4 with ChartEditorInput

use of org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput in project linuxtools by eclipse.

the class MassifViewPart method getToolbarActions.

@Override
public IAction[] getToolbarActions() {
    pidAction = new MassifPidMenuAction(this);
    pidAction.setId(PID_ACTION);
    Action chartAction = new Action(// $NON-NLS-1$
    Messages.getString("MassifViewPart.Display_Heap_Allocation"), // $NON-NLS-1$
    IAction.AS_PUSH_BUTTON) {

        @Override
        public void run() {
            ChartEditorInput input = getChartInput(pid);
            if (input != null) {
                displayChart(input);
            }
        }
    };
    chartAction.setId(CHART_ACTION);
    chartAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID, // $NON-NLS-1$
    "icons/linecharticon.gif"));
    chartAction.setToolTipText(Messages.getString(// $NON-NLS-1$
    "MassifViewPart.Display_Heap_Allocation"));
    saveChartAction = new SaveChartAction();
    saveChartAction.setId(SAVE_CHART_ACTION);
    treeAction = new Action(// $NON-NLS-1$
    Messages.getString("MassifViewPart.Show_Heap_Tree"), // $NON-NLS-1$
    IAction.AS_CHECK_BOX) {

        @Override
        public void run() {
            if (isChecked()) {
                stackLayout.topControl = treeViewer.getViewer().getControl();
                top.layout();
            } else {
                stackLayout.topControl = viewer.getControl();
                top.layout();
            }
        }
    };
    treeAction.setId(TREE_ACTION);
    treeAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID, // $NON-NLS-1$
    "icons/call_hierarchy.gif"));
    treeAction.setToolTipText(Messages.getString(// $NON-NLS-1$
    "MassifViewPart.Show_Heap_Tree"));
    return new IAction[] { pidAction, chartAction, saveChartAction, treeAction };
}
Also used : IAction(org.eclipse.jface.action.IAction) SaveChartAction(org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction) Action(org.eclipse.jface.action.Action) SaveChartAction(org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction) IAction(org.eclipse.jface.action.IAction) ChartEditorInput(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput)

Example 5 with ChartEditorInput

use of org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput in project linuxtools by eclipse.

the class ChartTests method testChartCallback.

@Test
public void testChartCallback() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testChartCallback");
    IAction chartAction = getChartAction();
    assertNotNull(chartAction);
    chartAction.run();
    IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    assertTrue(part instanceof ChartEditor);
    Chart control = ((ChartEditor) part).getControl();
    ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().getSeries(// $NON-NLS-1$
    Messages.getString("HeapChart.Total_Heap"));
    Point p1 = lsTotal.getPixelCoordinates(4);
    HeapChart heapChart = ((ChartEditorInput) ((ChartEditor) part).getEditorInput()).getChart();
    int x = control.getAxisSet().getXAxis(0).getPixelCoordinate(heapChart.time[4]);
    int y = control.getAxisSet().getYAxis(0).getPixelCoordinate(heapChart.dataTotal[4]);
    assertEquals(x, p1.x);
    assertEquals(y, p1.y);
}
Also used : HeapChart(org.eclipse.linuxtools.internal.valgrind.massif.charting.HeapChart) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ChartEditor(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditor) IAction(org.eclipse.jface.action.IAction) ILineSeries(org.swtchart.ILineSeries) IEditorPart(org.eclipse.ui.IEditorPart) Point(org.eclipse.swt.graphics.Point) ChartEditorInput(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput) Chart(org.swtchart.Chart) HeapChart(org.eclipse.linuxtools.internal.valgrind.massif.charting.HeapChart) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Aggregations

ChartEditorInput (org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)3 IAction (org.eclipse.jface.action.IAction)3 HeapChart (org.eclipse.linuxtools.internal.valgrind.massif.charting.HeapChart)3 SaveChartAction (org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction)2 IEditorPart (org.eclipse.ui.IEditorPart)2 Test (org.junit.Test)2 IPath (org.eclipse.core.runtime.IPath)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 Action (org.eclipse.jface.action.Action)1 ChartEditor (org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditor)1 Point (org.eclipse.swt.graphics.Point)1 Composite (org.eclipse.swt.widgets.Composite)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 IEditorInput (org.eclipse.ui.IEditorInput)1 Chart (org.swtchart.Chart)1 ILineSeries (org.swtchart.ILineSeries)1