use of org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData in project linuxtools by eclipse.
the class SystemTapScriptGraphOptionsTab method findBadGraphs.
/**
* Marks all graphs belonging to the indicated regular expression that have an
* error (missing column data, invalid graphID), or unmarks graphs that don't.
* @param regex The index of the regular expression to check for invalid graphs.
* @return An appropriate error message if an invalid graph is found, or if the
* selected regular expression parses nothing.
*/
private String findBadGraphs(int regex) {
boolean foundBadID = false;
boolean foundRemoved = false;
int numberOfColumns = columnNamesList.get(regex).size();
for (GraphData gd : graphsDataList.get(regex)) {
boolean singleBadID = false;
boolean singleRemoved = false;
if (GraphFactory.getGraphName(gd.graphID) == null) {
singleBadID = true;
} else {
if (gd.xSeries >= numberOfColumns) {
singleRemoved = true;
}
for (int s = 0; s < gd.ySeries.length && !singleRemoved; s++) {
if (gd.ySeries[s] >= numberOfColumns) {
singleRemoved = true;
}
}
}
if (singleRemoved || singleBadID) {
if (!badGraphs.contains(gd)) {
badGraphs.add(gd);
setUpGraphTableItem(findGraphTableItem(gd), null, true);
}
} else if (badGraphs.contains(gd)) {
badGraphs.remove(gd);
setUpGraphTableItem(findGraphTableItem(gd), null, false);
}
foundBadID |= singleBadID;
foundRemoved |= singleRemoved;
}
if (numberOfColumns == 0) {
return Messages.SystemTapScriptGraphOptionsTab_noGroups;
}
if (foundBadID) {
return Messages.SystemTapScriptGraphOptionsTab_badGraphID;
}
if (foundRemoved) {
return Messages.SystemTapScriptGraphOptionsTab_deletedGraphData;
}
return null;
}
use of org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData 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);
}
}
use of org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData in project linuxtools by eclipse.
the class TestCreateSystemtapScript method testGraphErrors.
@Test
public void testGraphErrors() {
SWTBotShell shell = prepareScript("missingColumns.stp", null);
SWTBotButton runButton = bot.button("Run");
SWTBotButton addButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton);
SWTBotButton editButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_EditGraphButton);
SWTBotButton dupButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_DuplicateGraphButton);
SWTBotButton remButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButton);
String graphID = "org.eclipse.linuxtools.systemtap.graphing.ui.charts.scatterchartbuilder";
// As soon as the Graphing tab is entered, no regular expression exists & nothing can be run.
SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
assertEquals("", combo.getText());
assertFalse(runButton.isEnabled());
assertFalse(addButton.isEnabled());
combo.setText("(1)(2)");
assertEquals("(1)(2)", combo.getText());
assertTrue(runButton.isEnabled());
assertTrue(addButton.isEnabled());
setupGraphWithTests("Graph", false);
assertTrue(runButton.isEnabled());
// Removing groups from the regex disables graphs that rely on those groups.
combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
combo.setText("(1)");
assertFalse(runButton.isEnabled());
combo.setText("(1)(2)(3)");
assertTrue(runButton.isEnabled());
final SWTBotTable table = bot.table();
table.select(0);
dupButton.click();
assertEquals(2, table.rowCount());
assertTrue(runButton.isEnabled());
combo.setText("(1)");
assertFalse(runButton.isEnabled());
for (int i = 0, n = table.rowCount(); i < n; i++) {
String itemTitle = table.getTableItem(i).getText();
assertTrue("Graph " + i + " should be invalid, but it's not: " + itemTitle, table.getTableItem(i).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph));
}
setupGraphGeneral("Safe", 1, graphID, true, false);
assertFalse(table.getTableItem(2).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph));
combo.setText("(1)(2)(3)");
assertTrue(runButton.isEnabled());
setupGraphGeneral("Unsafe", 3, graphID, true, false);
assertTrue(runButton.isEnabled());
combo.setText("(1)(2)");
assertFalse(runButton.isEnabled());
for (int i = 0, n = table.rowCount(); i < n; i++) {
String itemTitle = table.getTableItem(i).getText();
assertTrue("Graph " + i + " has incorrect validity: " + itemTitle, !itemTitle.contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph) || itemTitle.contains("Unsafe"));
}
table.select(3);
dupButton.click();
remButton.click();
assertTrue(!runButton.isEnabled());
table.select(3);
editButton.click();
SWTBotShell graphShell = bot.shell("Edit Graph").activate();
SWTBotButton finishButton = bot.button("Finish");
assertTrue(!finishButton.isEnabled());
bot.comboBox("<Deleted>").setSelection("NA");
finishButton.click();
bot.waitUntil(Conditions.shellCloses(graphShell));
shell.setFocus();
assertTrue(runButton.isEnabled());
// Perform tests when graphs have an invalid graphID.
UIThreadRunnable.syncExec(() -> {
GraphData gd = (GraphData) table.getTableItem(0).widget.getData();
gd.graphID = "invalidID";
table.getTableItem(0).widget.setData(gd);
});
// Just to refresh the dialog
combo.setText(combo.getText().concat(" "));
assertFalse(runButton.isEnabled());
assertTrue(table.getTableItem(0).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraphID));
table.select(0);
dupButton.click();
remButton.click();
assertFalse(runButton.isEnabled());
assertTrue(table.getTableItem(table.rowCount() - 1).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraphID));
table.select(table.rowCount() - 1);
editButton.click();
graphShell = bot.shell("Edit Graph").activate();
finishButton = bot.button("Finish");
assertFalse(finishButton.isEnabled());
bot.radio(0).click();
finishButton.click();
bot.waitUntil(Conditions.shellCloses(graphShell));
shell.setFocus();
assertTrue(runButton.isEnabled());
// Removing all invalid graphs should restore validity.
combo.setText("(1)");
assertFalse(runButton.isEnabled());
for (int i = table.rowCount() - 1; i >= 0; i--) {
if (table.getTableItem(i).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph)) {
table.select(i);
remButton.click();
}
}
assertTrue(runButton.isEnabled());
while (table.rowCount() > 0) {
table.select(0);
remButton.click();
}
bot.button("Apply").click();
}
use of org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData 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);
}
use of org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData in project linuxtools by eclipse.
the class SystemTapScriptGraphOptionsTab method createGraphCreateArea.
private void createGraphCreateArea(Composite comp) {
comp.setLayout(new GridLayout(2, false));
graphsTable = new Table(comp, SWT.SINGLE | SWT.BORDER);
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
graphsTable.setLayoutData(layoutData);
// Button to add another graph
Composite buttonComposite = new Composite(comp, SWT.NONE);
buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
buttonComposite.setLayout(gridLayout);
// Button to add a new graph
addGraphButton = new Button(buttonComposite, SWT.PUSH);
addGraphButton.setText(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton);
addGraphButton.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_AddGraphButtonToolTip);
addGraphButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Button to copy an existing graph
duplicateGraphButton = new Button(buttonComposite, SWT.PUSH);
duplicateGraphButton.setText(Messages.SystemTapScriptGraphOptionsTab_DuplicateGraphButton);
duplicateGraphButton.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_DuplicateGraphButtonToolTip);
duplicateGraphButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Button to edit an existing graph
editGraphButton = new Button(buttonComposite, SWT.PUSH);
editGraphButton.setText(Messages.SystemTapScriptGraphOptionsTab_EditGraphButton);
editGraphButton.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_EditGraphButtonToolTip);
editGraphButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Button to remove the selected graph/filter
removeGraphButton = new Button(buttonComposite, SWT.PUSH);
removeGraphButton.setText(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButton);
removeGraphButton.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButtonToolTip);
removeGraphButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Action to notify the buttons when to enable/disable themselves based
// on list selection
graphsTable.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
selectedTableItem = (TableItem) e.item;
setSelectionControlsEnabled(true);
}));
// Brings up a new dialog box when user clicks the add button. Allows
// selecting a new graph to display.
addGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
SelectGraphAndSeriesWizard wizard = new SelectGraphAndSeriesWizard(getCurrentDataset(), null);
IWorkbench workbench = PlatformUI.getWorkbench();
wizard.init(workbench, null);
WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard);
dialog.create();
dialog.open();
GraphData gd = wizard.getGraphData();
if (gd != null) {
TableItem item = new TableItem(graphsTable, SWT.NONE);
graphsData.add(gd);
setUpGraphTableItem(item, gd, false);
updateLaunchConfigurationDialog();
}
}));
// Adds a new entry to the list of graphs that is a copy of the one selected.
duplicateGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
GraphData gd = ((GraphData) selectedTableItem.getData()).getCopy();
TableItem item = new TableItem(graphsTable, SWT.NONE);
graphsData.add(gd);
if (badGraphs.contains(selectedTableItem.getData())) {
badGraphs.add(gd);
setUpGraphTableItem(item, gd, true);
} else {
setUpGraphTableItem(item, gd, false);
}
updateLaunchConfigurationDialog();
}));
// When button is clicked, brings up same wizard as the one for adding
// a graph. Data in the wizard is filled out to match the properties
// of the selected graph.
editGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
SelectGraphAndSeriesWizard wizard = new SelectGraphAndSeriesWizard(getCurrentDataset(), (GraphData) selectedTableItem.getData());
IWorkbench workbench = PlatformUI.getWorkbench();
wizard.init(workbench, null);
WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard);
dialog.create();
dialog.open();
GraphData gd = wizard.getGraphData();
if (gd == null) {
return;
}
GraphData old_gd = (GraphData) selectedTableItem.getData();
if (!gd.isCopyOf(old_gd)) {
badGraphs.remove(old_gd);
setUpGraphTableItem(selectedTableItem, gd, false);
graphsData.set(graphsTable.indexOf(selectedTableItem), gd);
checkErrors(selectedRegex);
updateLaunchConfigurationDialog();
}
}));
// Removes the selected graph/filter from the table
removeGraphButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
GraphData gd = (GraphData) selectedTableItem.getData();
graphsData.remove(gd);
badGraphs.remove(gd);
selectedTableItem.dispose();
setSelectionControlsEnabled(false);
checkErrors(selectedRegex);
updateLaunchConfigurationDialog();
}));
}
Aggregations