diff options
author | Sami Wagiaalla | 2013-04-23 17:36:20 +0000 |
---|---|---|
committer | Camilo Bernal | 2013-05-06 15:32:40 +0000 |
commit | 7f91d0652e289d291dcaca097edf39a228851509 (patch) | |
tree | 03e7bc869182fb67e7f1f22b9ef1d13b9c984501 | |
parent | 422b6cf957fd88d06579659243c76a69514d9455 (diff) | |
download | org.eclipse.linuxtools-7f91d0652e289d291dcaca097edf39a228851509.tar.gz org.eclipse.linuxtools-7f91d0652e289d291dcaca097edf39a228851509.tar.xz org.eclipse.linuxtools-7f91d0652e289d291dcaca097edf39a228851509.zip |
Allow creation of graphs in launch configuration.
- Add an area in the "Graphing" configuration tab to add graphs.
- change the API of the graphing view to allow pre-launch
addition of graphs.
Change-Id: I6900fbe3a6e55dd4dfcf19ac77de77687153aca9
Reviewed-on: https://git.eclipse.org/r/12458
Reviewed-by: Camilo Bernal <cabernal@redhat.com>
IP-Clean: Camilo Bernal <cabernal@redhat.com>
Tested-by: Camilo Bernal <cabernal@redhat.com>
12 files changed, 249 insertions, 38 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java index 3a76e00878..00dbcea13e 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java @@ -20,7 +20,7 @@ import org.osgi.framework.BundleContext; */ public class GraphingAPIUIPlugin extends AbstractUIPlugin { - public static final String PLUGIN_ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui"; //$NON-NLS-1$ + public static final String PLUGIN_ID = "org.eclipse.linuxtools.systemtap.graphingapi.ui"; //$NON-NLS-1$ //The shared instance. private static GraphingAPIUIPlugin plugin; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/GraphFactory.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/GraphFactory.java index ce94cdca3d..c8d80096b3 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/GraphFactory.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/GraphFactory.java @@ -32,7 +32,6 @@ import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.GraphComposite; import org.eclipse.swt.graphics.Image; - public final class GraphFactory { private static final String[] graphNames = new String[] { Localization.getString("GraphFactory.ScatterGraph"), //$NON-NLS-1$ @@ -76,8 +75,9 @@ public final class GraphFactory { ids.add(PieChartBuilder.ID); } if(data instanceof IBlockDataSet) { - if(!ids.contains(BarChartBuilder.ID)) + if(!ids.contains(BarChartBuilder.ID)) { ids.add(BarChartBuilder.ID); + } ids.add(PieChartBuilder.ID); } @@ -87,28 +87,32 @@ public final class GraphFactory { public static String getGraphName(String id) { int index = getIndex(id); - if(index >= 0) + if(index >= 0) { return graphNames[index]; + } return null; } public static String getGraphDescription(String id) { int index = getIndex(id); - if(index >= 0) + if(index >= 0) { return graphDescriptions[index]; + } return null; } public static Image getGraphImage(String id) { int index = getIndex(id); - if(index >= 0) + if(index >= 0) { return graphImages[index]; + } return null; } public static boolean isMultiGraph(String id) { - if(id.equals(PieChart.ID)) + if(id.equals(PieChart.ID)) { return false; + } return true; } @@ -116,8 +120,9 @@ public final class GraphFactory { switch(getIndex(graphID)) { case 0: case 1: - if(data instanceof IBlockDataSet) //Has to be IHistoricalDataSet + if(data instanceof IBlockDataSet) { return true; + } default: return false; } @@ -126,8 +131,9 @@ public final class GraphFactory { public static boolean isKeyOptional(String graphID, IDataSet data) { switch(getIndex(graphID)) { case 2: - if(data instanceof IBlockDataSet) //Has to be IHistoricalDataSet + if(data instanceof IBlockDataSet) { return true; + } default: return false; } @@ -168,9 +174,11 @@ public final class GraphFactory { private static int getIndex(String id) { - for(int i=0; i<graphIDs.length; i++) - if(id.equals(graphIDs[i])) + for(int i=0; i<graphIDs.length; i++) { + if(id.equals(graphIDs[i])) { return i; + } + } return -1; } } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/ExportDataSetAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/ExportDataSetAction.java index 46f5ff0188..173b0ffc62 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/ExportDataSetAction.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/ExportDataSetAction.java @@ -17,9 +17,9 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.linuxtools.internal.systemtap.ui.graphing.Localization; -import org.eclipse.linuxtools.internal.systemtap.ui.graphing.structures.GraphDisplaySet; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet; import org.eclipse.linuxtools.systemtap.structures.listeners.ITabListener; +import org.eclipse.linuxtools.systemtap.ui.graphing.GraphDisplaySet; import org.eclipse.linuxtools.systemtap.ui.graphing.views.GraphSelectorView; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.FileDialog; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java index 6fa36f4d77..a0b3ccaafb 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java @@ -16,10 +16,10 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.linuxtools.internal.systemtap.ui.graphing.Localization; -import org.eclipse.linuxtools.internal.systemtap.ui.graphing.structures.GraphDisplaySet; import org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.AbstractChartBuilder; import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.ExceptionErrorDialog; import org.eclipse.linuxtools.systemtap.structures.listeners.ITabListener; +import org.eclipse.linuxtools.systemtap.ui.graphing.GraphDisplaySet; import org.eclipse.linuxtools.systemtap.ui.graphing.views.GraphSelectorView; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/structures/GraphDisplaySet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/GraphDisplaySet.java index fc6eabba9e..127d863d36 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/structures/GraphDisplaySet.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/GraphDisplaySet.java @@ -9,7 +9,7 @@ * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse *******************************************************************************/ -package org.eclipse.linuxtools.internal.systemtap.ui.graphing.structures; +package org.eclipse.linuxtools.systemtap.ui.graphing; import java.util.ArrayList; @@ -51,6 +51,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; * This class is used to contain all of the graphing components that can * be displayed as individual tabs in a single location. * @author Ryan Morse + * @since 2.0 */ public class GraphDisplaySet { @@ -178,7 +179,7 @@ public class GraphDisplaySet { /** * This class handles switching between tabs and creating new graphs. * When the user selects the first tab a new dialog is displayed for - * them to slect what they want to display for the new graph. + * them to select what they want to display for the new graph. */ public class ButtonClickListener extends SelectionAdapter { @Override @@ -197,21 +198,7 @@ public class GraphDisplaySet { GraphData gd = wizard.getGraphData(); if(null != gd) { - CTabItem item = new CTabItem(folder, SWT.CLOSE); - item.setText(GraphFactory.getGraphName(gd.graphID)); - GraphComposite gc = new GraphComposite(folder, SWT.FILL, gd, dataSet); - gc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - folder.setSelection(item); - - AbstractChartBuilder g = gc.getCanvas(); - item.setControl(gc); - - if(null != g) { - if(null != updater) { - updater.addUpdateListener(g); - } - builders.add(g); - } + addGraph(gd); } wizard.dispose(); fireTabOpenEvent(); @@ -243,6 +230,24 @@ public class GraphDisplaySet { } } + public void addGraph(GraphData gd) { + CTabItem item = new CTabItem(folder, SWT.CLOSE); + item.setText(GraphFactory.getGraphName(gd.graphID)); + GraphComposite gc = new GraphComposite(folder, SWT.FILL, gd, dataSet); + gc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + folder.setSelection(item); + + AbstractChartBuilder g = gc.getCanvas(); + item.setControl(gc); + + if(null != g) { + if(null != updater) { + updater.addUpdateListener(g); + } + builders.add(g); + } + } + private int lastSelectedTab; private IDataSet dataSet; private CTabFolder folder; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/views/GraphSelectorView.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/views/GraphSelectorView.java index 99cec8aad8..7e5a79471c 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/views/GraphSelectorView.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/views/GraphSelectorView.java @@ -13,9 +13,9 @@ package org.eclipse.linuxtools.systemtap.ui.graphing.views; import java.util.ArrayList; -import org.eclipse.linuxtools.internal.systemtap.ui.graphing.structures.GraphDisplaySet; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet; import org.eclipse.linuxtools.systemtap.structures.listeners.ITabListener; +import org.eclipse.linuxtools.systemtap.ui.graphing.GraphDisplaySet; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabFolder2Adapter; @@ -162,7 +162,7 @@ public class GraphSelectorView extends ViewPart { /** * Removes all internal references in this class. Nothing should make any references - * to anyting in this class after calling the dispose method. + * to anything in this class after calling the dispose method. */ @Override public void dispose() { diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/META-INF/MANIFEST.MF b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/META-INF/MANIFEST.MF index 928e35e4ce..beba908888 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/META-INF/MANIFEST.MF +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/META-INF/MANIFEST.MF @@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.linuxtools.profiling.launch;bundle-version="0.11.0", org.eclipse.ui.ide, org.eclipse.debug.ui;bundle-version="3.8.0", - org.eclipse.core.expressions;bundle-version="3.4.400" + org.eclipse.core.expressions;bundle-version="3.4.400", + org.eclipse.linuxtools.systemtap.graphingapi.ui Bundle-ActivationPolicy: lazy Import-Package: com.jcraft.jsch;version="0.1.46", org.eclipse.cdt.core.model, @@ -27,8 +28,12 @@ Import-Package: com.jcraft.jsch;version="0.1.46", org.eclipse.linuxtools.man.parser, org.eclipse.linuxtools.systemtap.graphingapi.core.datasets, org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.row, + org.eclipse.linuxtools.systemtap.graphingapi.core.filters, + org.eclipse.linuxtools.systemtap.graphingapi.core.structures, org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets, org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.dataset, + org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.filter, + org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.graph, org.eclipse.linuxtools.systemtap.structures, org.eclipse.linuxtools.systemtap.structures.listeners, org.eclipse.linuxtools.systemtap.ui.graphing, diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptChartHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptChartHandler.java index bee8fabd92..7d470f315f 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptChartHandler.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/RunScriptChartHandler.java @@ -11,8 +11,11 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.actions; +import java.util.LinkedList; + import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSetParser; +import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.GraphData; import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.ExceptionErrorDialog; import org.eclipse.linuxtools.systemtap.ui.consolelog.ChartStreamDaemon2; import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.ScriptConsole; @@ -20,7 +23,6 @@ import org.eclipse.linuxtools.systemtap.ui.graphing.GraphingPerspective; import org.eclipse.linuxtools.systemtap.ui.graphing.views.GraphSelectorView; import org.eclipse.linuxtools.systemtap.ui.ide.actions.Messages; import org.eclipse.linuxtools.systemtap.ui.ide.actions.RunScriptHandler; -import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.WorkbenchException; @@ -34,11 +36,13 @@ public class RunScriptChartHandler extends RunScriptHandler { private IDataSet dataSet; private IDataSetParser parser; + private LinkedList<GraphData> graphs; - public RunScriptChartHandler(IDataSetParser parser, IDataSet dataSet) { + public RunScriptChartHandler(IDataSetParser parser, IDataSet dataSet, LinkedList<GraphData> graphs) { super(); this.parser = parser; this.dataSet = dataSet; + this.graphs = graphs; } @Override @@ -46,9 +50,13 @@ public class RunScriptChartHandler extends RunScriptHandler { console.getCommand().addInputStreamListener(new ChartStreamDaemon2(console, dataSet, parser)); try { IWorkbenchPage p = PlatformUI.getWorkbench().showPerspective(GraphingPerspective.ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); - IViewPart ivp = p.showView(GraphSelectorView.ID); + GraphSelectorView ivp = (GraphSelectorView)p.showView(GraphSelectorView.ID); String name = console.getName(); - ((GraphSelectorView)ivp).createScriptSet(name.substring(name.lastIndexOf('/')+1), dataSet); + ivp.createScriptSet(name.substring(name.lastIndexOf('/')+1), dataSet); + + for (GraphData graph : graphs) { + ivp.getActiveDisplaySet().addGraph(graph); + } } catch(WorkbenchException we) { ExceptionErrorDialog.openError(Messages.RunScriptChartAction_couldNotSwitchToGraphicPerspective, we); } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java index a2b8bc3f82..1f7ca2cc43 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java @@ -31,6 +31,11 @@ public class Messages extends NLS { public static String SystemTapScriptGraphOptionsTab_6; public static String SystemTapScriptGraphOptionsTab_7; + public static String SystemTapScriptGraphOptionsTab_AddGraphButton; + public static String SystemTapScriptGraphOptionsTab_AddGraphButtonToolTip; + public static String SystemTapScriptGraphOptionsTab_graphsTitle; + public static String SystemTapScriptGraphOptionsTab_RemoveGraphButtonLabel; + public static String SystemTapScriptLaunchConfigurationTab_0; public static String SystemTapScriptLaunchConfigurationTab_1; public static String SystemTapScriptLaunchConfigurationTab_2; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java index 4b321fa76f..088ab83d15 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java @@ -12,22 +12,28 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher; import java.util.ArrayList; +import java.util.LinkedList; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSetParser; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.row.RowDataSet; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.row.RowParser; +import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.GraphData; import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.ExceptionErrorDialog; import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.dataset.DataSetFactory; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.graph.GraphFactory; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.graph.SelectGraphWizard; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; @@ -39,7 +45,11 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Spinner; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; public class SystemTapScriptGraphOptionsTab extends @@ -49,6 +59,14 @@ public class SystemTapScriptGraphOptionsTab extends static final String NUMBER_OF_COLUMNS = "numberOfColumns"; //$NON-NLS-1$ static final String REGEX_BOX = "regexBox_"; //$NON-NLS-1$ + private static final String NUMBER_OF_GRAPHS = "numberOfGraphs"; //$NON-NLS-1$ + private static final String GRAPH_TITLE = "graphTitle"; //$NON-NLS-1$ + private static final String GRAPH_KEY = "graphKey"; //$NON-NLS-1$ + private static final String GRAPH_X_SERIES = "graphXSeries"; //$NON-NLS-1$ + private static final String GRAPH_ID = "graphID"; //$NON-NLS-1$ + private static final String GRAPH_Y_SERIES_LENGTH = "graphYSeriesLength"; //$NON-NLS-1$ + private static final String GRAPH_Y_SERIES = "graphYSeries"; //$NON-NLS-1$ + private ModifyListener regExListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { @@ -69,6 +87,11 @@ public class SystemTapScriptGraphOptionsTab extends private Group outputParsingGroup; private Button runWithChartCheckButton; + private Table graphsTable; + private Button addGraphButton, removeGraphButton; + private TableItem selectedTableItem; + private Group graphsGroup; + public static IDataSetParser createDatasetParser(ILaunchConfiguration configuration) { int n; try { @@ -111,6 +134,30 @@ public class SystemTapScriptGraphOptionsTab extends return null; } + public static LinkedList<GraphData> createGraphsFromConfiguration (ILaunchConfiguration configuration) throws CoreException { + LinkedList<GraphData> graphs = new LinkedList<GraphData>(); + int n = configuration.getAttribute(NUMBER_OF_GRAPHS, 0); + for (int i = 0; i < n; i++) { + GraphData graphData = new GraphData(); + graphData.title = configuration.getAttribute (GRAPH_TITLE + i, ""); //$NON-NLS-1$ + + graphData.key = configuration.getAttribute(GRAPH_KEY + i, ""); //$NON-NLS-1$ + graphData.xSeries = configuration.getAttribute(GRAPH_X_SERIES + i, 0); + graphData.graphID = configuration.getAttribute(GRAPH_ID + i, ""); //$NON-NLS-1$ + + int ySeriesLength = configuration.getAttribute(GRAPH_Y_SERIES_LENGTH, 0); + int[] ySeries = new int[ySeriesLength]; + for (int j = 0; j < ySeriesLength; j++) { + ySeries[j] = configuration.getAttribute(GRAPH_Y_SERIES + i + "_" + j, 0); //$NON-NLS-1$ + } + graphData.ySeries = ySeries; + + graphs.add(graphData); + } + + return graphs; + } + @Override public void createControl(Composite parent) { GridLayout layout = new GridLayout(); @@ -140,6 +187,11 @@ public class SystemTapScriptGraphOptionsTab extends outputParsingGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); this.createColumnSelector(outputParsingGroup); + this.graphsGroup = new Group(top, SWT.SHADOW_ETCHED_IN); + graphsGroup.setText(Messages.SystemTapScriptGraphOptionsTab_graphsTitle); + graphsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + createGraphCreateArea(graphsGroup); + setGraphingEnabled(false); runWithChartCheckButton.setSelection(false); } @@ -167,6 +219,7 @@ public class SystemTapScriptGraphOptionsTab extends public void modifyText(ModifyEvent e) { refreshRegexRows(); refreshRegEx(); + updateLaunchConfigurationDialog(); } }); @@ -213,6 +266,95 @@ public class SystemTapScriptGraphOptionsTab extends refreshRegexRows(); } + private IDataSet getDataset() { + int n = this.numberOfColumnsSpinner.getSelection(); + ArrayList<String> labels = new ArrayList<String>(n); + Control[] regExTexts = textFieldsComposite.getChildren(); + + for (int i = 0; i < (n * COLUMNS); i++) { + if (i % COLUMNS == 0) { + String text = ((Text)regExTexts[i]).getText(); + labels.add(text); + } + } + return DataSetFactory.createDataSet(RowDataSet.ID, labels.toArray(new String[] {})); + } + + private void createGraphCreateArea(Composite comp){ + GridLayout twoColumnsLayout = new GridLayout(); + comp.setLayout(twoColumnsLayout); + twoColumnsLayout.numColumns = 2; + + 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); + 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 remove the selected graph/filter + removeGraphButton = new Button(buttonComposite, SWT.PUSH); + removeGraphButton.setText("Remove"); //$NON-NLS-1$ + removeGraphButton.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButtonLabel); + removeGraphButton.setEnabled(false); + 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(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + selectedTableItem = (TableItem) e.item; + removeGraphButton.setEnabled(true); + } + }); + + // Brings up a new dialog box when user clicks the add button. Allows + // selecting a new graph to display. + addGraphButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + SelectGraphWizard wizard = new SelectGraphWizard(getDataset()); + 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 (null != gd) { + TableItem item = new TableItem(graphsTable, SWT.NONE); + item.setText(GraphFactory.getGraphName(gd.graphID) + ":" //$NON-NLS-1$ + + gd.title); + item.setData(gd); + updateLaunchConfigurationDialog(); + } + } + }); + + // Removes the selected graph/filter from the table + removeGraphButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + selectedTableItem.dispose(); + removeGraphButton.setEnabled(false); + updateLaunchConfigurationDialog(); + } + }); + } + private void refreshRegexRows() { int numberOfColumns = numberOfColumnsSpinner.getSelection(); int currentNumberOfColumns = textFieldsComposite.getChildren().length/3; @@ -281,6 +423,7 @@ public class SystemTapScriptGraphOptionsTab extends public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(RUN_WITH_CHART, false); configuration.setAttribute(NUMBER_OF_COLUMNS, 3); + configuration.setAttribute(NUMBER_OF_GRAPHS, 0); } @Override @@ -299,6 +442,17 @@ public class SystemTapScriptGraphOptionsTab extends ((Text)textBoxes[i]).setText(text); } } + + // Add graphs + graphsTable.removeAll(); + LinkedList<GraphData> graphs = createGraphsFromConfiguration(configuration); + for (GraphData graphData : graphs) { + TableItem item = new TableItem(graphsTable, SWT.NONE); + item.setText(GraphFactory.getGraphName(graphData.graphID) + ":" //$NON-NLS-1$ + + graphData.title); + item.setData(graphData); + } + } catch (CoreException e) { ExceptionErrorDialog.openError(Messages.SystemTapScriptGraphOptionsTab_5, e); } @@ -315,6 +469,23 @@ public class SystemTapScriptGraphOptionsTab extends String text = ((Text)textBoxes[i]).getText(); configuration.setAttribute(REGEX_BOX+i, text); } + + // Save graphs. + TableItem[] list = this.graphsTable.getItems(); + configuration.setAttribute(NUMBER_OF_GRAPHS, list.length); + for (int i = 0; i < list.length; i++) { + GraphData graphData = (GraphData)list[i].getData(); + configuration.setAttribute(GRAPH_TITLE + i, graphData.title); + + configuration.setAttribute(GRAPH_KEY + i, graphData.key); + configuration.setAttribute(GRAPH_X_SERIES + i, graphData.xSeries); + configuration.setAttribute(GRAPH_ID + i, graphData.graphID); + + configuration.setAttribute(GRAPH_Y_SERIES_LENGTH, graphData.ySeries.length); + for (int j = 0; j < graphData.ySeries.length; j++) { + configuration.setAttribute(GRAPH_Y_SERIES + i + "_" + j, graphData.ySeries[j]); //$NON-NLS-1$ + } + } } @Override @@ -352,6 +523,7 @@ public class SystemTapScriptGraphOptionsTab extends private void setGraphingEnabled(boolean enabled){ this.setControlEnabled(outputParsingGroup, enabled); + this.setControlEnabled(graphsGroup, enabled); updateLaunchConfigurationDialog(); } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java index 8428b0c065..2a1d05ee4d 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java @@ -11,6 +11,8 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher; +import java.util.LinkedList; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; @@ -22,6 +24,7 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.RunScriptChartHa import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet; import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSetParser; +import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.GraphData; import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin; import org.eclipse.linuxtools.systemtap.ui.consolelog.preferences.ConsoleLogPreferenceConstants; import org.eclipse.linuxtools.systemtap.ui.ide.actions.RunScriptHandler; @@ -43,7 +46,8 @@ public class SystemTapScriptLaunchConfigurationDelegate implements if (runWithChart){ IDataSet dataSet = SystemTapScriptGraphOptionsTab.createDataset(configuration); IDataSetParser parser = SystemTapScriptGraphOptionsTab.createDatasetParser(configuration); - action = new RunScriptChartHandler(parser, dataSet); + LinkedList<GraphData> graphs = SystemTapScriptGraphOptionsTab.createGraphsFromConfiguration(configuration); + action = new RunScriptChartHandler(parser, dataSet, graphs); }else{ action = new RunScriptHandler(); } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties index 9cf8ab0295..de5d853e2d 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties @@ -24,6 +24,10 @@ SystemTapScriptGraphOptionsTab_6=You must specify a title, Regular expression an SystemTapScriptGraphOptionsTab_7=Graphing SystemTapScriptGraphOptionsTab_0=Unable to initialize launch configuration tab +SystemTapScriptGraphOptionsTab_AddGraphButton=Add... +SystemTapScriptGraphOptionsTab_AddGraphButtonToolTip=Add a new graph +SystemTapScriptGraphOptionsTab_graphsTitle=Graphs: +SystemTapScriptGraphOptionsTab_RemoveGraphButtonLabel=Remove the selected graph SystemTapScriptLaunchConfigurationTab_0=Systemtap Script: SystemTapScriptLaunchConfigurationTab_1=Browse... SystemTapScriptLaunchConfigurationTab_2=Execute script as current user. |