Search in sources :

Example 1 with AbstractChartBuilder

use of org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder in project linuxtools by eclipse.

the class GraphDisplaySet method addGraph.

public void addGraph(final GraphData gd) {
    CTabItem item = new CTabItem(folder, SWT.CLOSE);
    item.setText(// $NON-NLS-1$
    MessageFormat.format(// $NON-NLS-1$
    Localization.getString("GraphDisplaySet.GraphTabTitle"), gd.title, GraphFactory.getGraphName(gd.graphID)));
    final GraphComposite gc = new GraphComposite(folder, SWT.FILL, gd, dataSet);
    gc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    gc.addCheckOption(Messages.GraphCompositeTitle, SelectionListener.widgetSelectedAdapter(e -> {
        gc.setTitleVisible(((Button) e.getSource()).getSelection());
    }));
    gc.addCheckOption(Messages.GraphCompositeLegend, SelectionListener.widgetSelectedAdapter(e -> {
        gc.setLegendVisible(((Button) e.getSource()).getSelection());
    }));
    folder.setSelection(item);
    AbstractChartBuilder g = gc.getCanvas();
    item.setControl(gc);
    if (null != g) {
        if (null != updater) {
            updater.addUpdateListener(g);
        }
        builders.add(g);
    }
}
Also used : Messages(org.eclipse.linuxtools.systemtap.graphing.ui.widgets.Messages) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) Localization(org.eclipse.linuxtools.internal.systemtap.graphing.ui.Localization) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) GraphComposite(org.eclipse.linuxtools.systemtap.graphing.ui.widgets.GraphComposite) GraphFactory(org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.GraphFactory) DataSetFactory(org.eclipse.linuxtools.systemtap.graphing.ui.wizards.dataset.DataSetFactory) Composite(org.eclipse.swt.widgets.Composite) GraphData(org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData) AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) GridData(org.eclipse.swt.layout.GridData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Button(org.eclipse.swt.widgets.Button) DataGrid(org.eclipse.linuxtools.systemtap.graphing.ui.datadisplay.DataGrid) CTabFolder(org.eclipse.swt.custom.CTabFolder) FormLayout(org.eclipse.swt.layout.FormLayout) PlatformUI(org.eclipse.ui.PlatformUI) FormData(org.eclipse.swt.layout.FormData) IDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSet) CTabFolder2Adapter(org.eclipse.swt.custom.CTabFolder2Adapter) GraphingPreferenceConstants(org.eclipse.linuxtools.internal.systemtap.graphing.ui.preferences.GraphingPreferenceConstants) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectGraphAndSeriesWizard(org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.SelectGraphAndSeriesWizard) IFilteredDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet) CTabItem(org.eclipse.swt.custom.CTabItem) List(java.util.List) UpdateManager(org.eclipse.linuxtools.systemtap.structures.UpdateManager) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SWT(org.eclipse.swt.SWT) IWorkbench(org.eclipse.ui.IWorkbench) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GraphingUIPlugin(org.eclipse.linuxtools.internal.systemtap.graphing.ui.GraphingUIPlugin) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) GraphComposite(org.eclipse.linuxtools.systemtap.graphing.ui.widgets.GraphComposite) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 2 with AbstractChartBuilder

use of org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder in project linuxtools by eclipse.

the class GraphDisplaySet method dispose.

/**
 * Removes all internal references in this class.  Nothing should make any references
 * to anything in this class after calling the dispose method.
 */
public void dispose() {
    if (null != updater && updater.isRunning()) {
        updater.dispose();
    }
    updater = null;
    p.removePropertyChangeListener(propertyChangeListener);
    propertyChangeListener = null;
    dataSet = null;
    if (null != folder && !folder.isDisposed()) {
        folder.removeSelectionListener(listener);
        folder.dispose();
        folder = null;
    }
    listener = null;
    for (AbstractChartBuilder builder : builders) {
        builder.dispose();
    }
    builders.clear();
}
Also used : AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder)

Example 3 with AbstractChartBuilder

use of org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testLabelledGraphScript.

@Test
public void testLabelledGraphScript() {
    final int numItems = 13;
    final int numNumberItems = 4;
    final int numCategories = 3;
    createAndViewDummyData(new String[] { "Fruit", "Number", "Freshness", "Tastiness" }, new Object[] { "Apples", 2, 14, 16, 1, 1, 2, 3, "Bananas (2)", 10, 10, 10, "Cherries", 10, 20, 30, 2, 2, 4, 6, "Apples", 12, 5, 16, "Bananas", 0, 1, 0, 3, 3, 6, 9, "Dates", 12, 5, 16, "Bananas", 2, 1, 2, 4, 4, 8, 12, "Apples", 12, 5, 16, "Bananas (2)", 3, 1, 3 });
    SWTBotEditor graphEditor = bot.activeEditor();
    // Add bar, pie, and line graphs that use the same column data.
    String title = "Fruit Info";
    setupGraphGeneral(title, 4, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.barchartbuilder", false, true);
    setupGraphGeneral(title, 4, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.piechartbuilder", false, true);
    setupGraphGeneral(title, 4, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.linechartbuilder", false, true);
    // Confirm that the bar & pie charts display the String categories, but the line chart ignores them.
    String titleBar = title + " - Bar Graph";
    String titlePie = title + " - Pie Chart";
    String titleLine = title + " - Line Graph";
    graphEditor.bot().cTabItem(titleLine).activate();
    Matcher<AbstractChartBuilder> matcher = widgetOfType(AbstractChartBuilder.class);
    AbstractChartBuilder cb = bot.widget(matcher);
    assertEquals(numNumberItems, cb.getChart().getSeriesSet().getSeries()[0].getXSeries().length);
    graphEditor.bot().cTabItem(titlePie).activate();
    cb = bot.widget(matcher);
    assertEquals(numItems, cb.getChart().getSeriesSet().getSeries().length);
    graphEditor.bot().cTabItem(titleBar).activate();
    cb = bot.widget(matcher);
    assertEquals(numItems, cb.getChart().getSeriesSet().getSeries()[0].getXSeries().length);
    // Test graph scaling & scrolling
    // Bar Chart
    discreteXControlTests(cb, numItems);
    continuousControlTests(cb, false);
    graphEditor.bot().cTabItem(titlePie).activate();
    cb = bot.widget(matcher);
    discreteXControlTests(cb, numCategories);
    graphEditor.bot().cTabItem(titleLine).activate();
    cb = bot.widget(matcher);
    continuousControlTests(cb, true);
    continuousControlTests(cb, false);
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 4 with AbstractChartBuilder

use of org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testGraphTooltips.

@Test
@Ignore
public void testGraphTooltips() {
    createAndViewDummyData(new String[] { "Column 1" }, new Integer[] { 1, 2, 3, 4, 5 });
    // Add bar, pie, and line graphs that use the same column data.
    String title = "Info";
    setupGraphGeneral(title, 1, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.linechartbuilder", true, true);
    setupGraphGeneral(title, 1, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.barchartbuilder", true, true);
    // Perform mouse hover tests on graphs.
    bot.activeEditor().bot().cTabItem(title.concat(" - Bar Graph")).activate();
    final Matcher<AbstractChartBuilder> matcher = widgetOfType(AbstractChartBuilder.class);
    AbstractChartBuilder cb = bot.widget(matcher);
    String tooltipFormat = "{0}: {1}";
    checkTooltipAtDataPoint(cb, 0, MessageFormat.format(tooltipFormat, "Column 1", "1"), true);
    bot.activeEditor().bot().cTabItem(title.concat(" - Line Graph")).activate();
    cb = bot.widget(matcher);
    tooltipFormat = "Series: {0}\nx: {1}\ny: {2}";
    String lineChartTooltip = MessageFormat.format(tooltipFormat, "Column 1", "2", "2");
    checkTooltipAtDataPoint(cb, 1, lineChartTooltip, true);
    // The tooltip should disappear when a point moves away from the mouse, without need for mouse movement.
    cb.setScale(0.2);
    checkTooltipAtDataPoint(cb, -1, lineChartTooltip, false);
}
Also used : AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with AbstractChartBuilder

use of org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testGraphContents.

@Test
public void testGraphContents() {
    final String valA1 = "A1";
    final String valB1 = "B1";
    createAndViewDummyData(new String[] { valA1, valB1 }, new Integer[] { 0, 0, 1, 2, 2, 4, 3, 6, 4, 8, 5, 10, 6, 12, 7, 14, 8, 16, 9, 18 });
    SWTBotEditor graphEditorA = bot.activeEditor();
    final String valA2 = "A2";
    final String valB2 = "B2";
    createAndViewDummyData(new String[] { valA2, valB2 }, new Integer[] { 2, 0, 5, 1, 7, 2, 10, 3 });
    SWTBotEditor graphEditorB = bot.activeEditor();
    // Add graphs.
    setupGraphWithTests("Others", true);
    String graphTitle2 = "Others - Scatter Graph";
    graphEditorA.show();
    setupGraphWithTests("Values", true);
    String graphTitle1 = "Values - Scatter Graph";
    // Test table & graph contents.
    graphEditorA.bot().cTabItem("Data View").activate();
    SWTBotTable dataTable = bot.table();
    List<String> colNames = dataTable.columns();
    assertEquals(3, colNames.size());
    assertEquals(valA1, colNames.get(1));
    assertEquals(valB1, colNames.get(2));
    assertEquals("2", dataTable.cell(2, 1));
    assertEquals("4", dataTable.cell(2, 2));
    graphEditorA.bot().cTabItem(graphTitle1).activate();
    Matcher<AbstractChartBuilder> matcher = widgetOfType(AbstractChartBuilder.class);
    AbstractChartBuilder cb = bot.widget(matcher);
    ISeries[] series = cb.getChart().getSeriesSet().getSeries();
    assertEquals(2, series.length);
    assertEquals(10, series[0].getXSeries().length);
    assertEquals(10, series[1].getXSeries().length);
    assertEquals(2, (int) series[0].getYSeries()[2]);
    assertEquals(4, (int) series[1].getYSeries()[2]);
    graphEditorB.show();
    graphEditorB.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    colNames = dataTable.columns();
    assertEquals(3, colNames.size());
    assertEquals(valA2, colNames.get(1));
    assertEquals(valB2, colNames.get(2));
    assertEquals("7", dataTable.cell(2, 1));
    assertEquals("2", dataTable.cell(2, 2));
    graphEditorB.bot().cTabItem(graphTitle2).activate();
    cb = bot.widget(matcher);
    series = cb.getChart().getSeriesSet().getSeries();
    assertEquals(2, series.length);
    assertEquals(4, series[0].getXSeries().length);
    assertEquals(4, series[1].getXSeries().length);
    assertEquals(7, (int) series[0].getYSeries()[2]);
    assertEquals(2, (int) series[1].getYSeries()[2]);
    // Test filters on the data table & graphs.
    graphEditorA.show();
    graphEditorA.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    new SWTBotMenu(ContextMenuHelper.contextMenu(dataTable, "Add filter...")).click();
    SWTBotShell shell = bot.shell("Create Filter");
    shell.setFocus();
    // Match Filter - Remove a matching
    bot.button("Match Filter").click();
    bot.button("Next >").click();
    bot.text().setText("2");
    deselectDefaultSelection(0);
    bot.radio(1).click();
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    bot.waitUntil(new TableHasUpdated(graphEditorA.bot().table(), 9, true));
    assertEquals("3", dataTable.cell(2, 1));
    assertEquals("6", dataTable.cell(2, 2));
    // Filters should be applied to graphs as well as data tables.
    graphEditorA.bot().cTabItem(graphTitle1).activate();
    cb = bot.widget(matcher);
    series = cb.getChart().getSeriesSet().getSeries();
    bot.waitUntil(new ChartHasUpdated(cb.getChart(), 9));
    assertEquals(3, (int) series[0].getYSeries()[2]);
    assertEquals(6, (int) series[1].getYSeries()[2]);
    // Each graph set should have its own filters.
    graphEditorB.show();
    graphEditorB.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    assertEquals(4, dataTable.rowCount());
    assertEquals("2", dataTable.cell(0, 1));
    // Test removing a filter.
    graphEditorA.show();
    graphEditorA.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    new SWTBotMenu(ContextMenuHelper.contextMenu(dataTable, "Remove filter...", "Match Filter: \"" + valA1 + "\" removing \"2\"")).click();
    bot.waitUntil(new TableHasUpdated(graphEditorA.bot().table(), 10, true));
    assertEquals("2", dataTable.cell(2, 1));
    assertEquals("4", dataTable.cell(2, 2));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ISeries(org.swtchart.ISeries) Test(org.junit.Test)

Aggregations

AbstractChartBuilder (org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder)5 Test (org.junit.Test)3 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)2 MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 GraphingUIPlugin (org.eclipse.linuxtools.internal.systemtap.graphing.ui.GraphingUIPlugin)1 Localization (org.eclipse.linuxtools.internal.systemtap.graphing.ui.Localization)1 GraphingPreferenceConstants (org.eclipse.linuxtools.internal.systemtap.graphing.ui.preferences.GraphingPreferenceConstants)1 IDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSet)1 IFilteredDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet)1 GraphData (org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData)1 DataGrid (org.eclipse.linuxtools.systemtap.graphing.ui.datadisplay.DataGrid)1 GraphComposite (org.eclipse.linuxtools.systemtap.graphing.ui.widgets.GraphComposite)1 Messages (org.eclipse.linuxtools.systemtap.graphing.ui.widgets.Messages)1 DataSetFactory (org.eclipse.linuxtools.systemtap.graphing.ui.wizards.dataset.DataSetFactory)1 GraphFactory (org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.GraphFactory)1