use of org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.SelectGraphAndSeriesWizard 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