Search in sources :

Example 1 with SelectGraphAndSeriesWizard

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();
    }));
}
Also used : RowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowDataSet) Image(org.eclipse.swt.graphics.Image) CoreException(org.eclipse.core.runtime.CoreException) Table(org.eclipse.swt.widgets.Table) Stack(java.util.Stack) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ExceptionErrorDialog(org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog) Matcher(java.util.regex.Matcher) ILaunchConfigurationTab(org.eclipse.debug.ui.ILaunchConfigurationTab) GraphFactory(org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.GraphFactory) IDEPlugin(org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin) DataSetFactory(org.eclipse.linuxtools.systemtap.graphing.ui.wizards.dataset.DataSetFactory) IPath(org.eclipse.core.runtime.IPath) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) Composite(org.eclipse.swt.widgets.Composite) GraphData(org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData) AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) GridData(org.eclipse.swt.layout.GridData) LinkedList(java.util.LinkedList) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) PatternSyntaxException(java.util.regex.PatternSyntaxException) IDataSetParser(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSetParser) Combo(org.eclipse.swt.widgets.Combo) Button(org.eclipse.swt.widgets.Button) PlatformUI(org.eclipse.ui.PlatformUI) IDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSet) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Group(org.eclipse.swt.widgets.Group) SelectGraphAndSeriesWizard(org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.SelectGraphAndSeriesWizard) IFilteredDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet) List(java.util.List) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) Entry(java.util.Map.Entry) IWorkbench(org.eclipse.ui.IWorkbench) Pattern(java.util.regex.Pattern) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) LineParser(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.LineParser) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkbench(org.eclipse.ui.IWorkbench) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) SelectGraphAndSeriesWizard(org.eclipse.linuxtools.systemtap.graphing.ui.wizards.graph.SelectGraphAndSeriesWizard) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) WizardDialog(org.eclipse.jface.wizard.WizardDialog) GraphData(org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData)

Aggregations

MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Stack (java.util.Stack)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 AbstractLaunchConfigurationTab (org.eclipse.debug.ui.AbstractLaunchConfigurationTab)1 ILaunchConfigurationTab (org.eclipse.debug.ui.ILaunchConfigurationTab)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 IDEPlugin (org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin)1 IDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSet)1 IDataSetParser (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSetParser)1