summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2013-06-19 10:16:48 (EDT)
committer Jeff Johnston2013-10-31 16:17:42 (EDT)
commit7b8671a7e761e79c502daeab0babea9bfc1f0021 (patch)
treeb41eabfc3b64d258933b4095d18bb7742b0b2d72
parent5ff1d9d48ac1536ed343e7a4c949c6f6d0a430f5 (diff)
downloadorg.eclipse.linuxtools-7b8671a7e761e79c502daeab0babea9bfc1f0021.zip
org.eclipse.linuxtools-7b8671a7e761e79c502daeab0babea9bfc1f0021.tar.gz
org.eclipse.linuxtools-7b8671a7e761e79c502daeab0babea9bfc1f0021.tar.bz2
Systemtap: Prevent running scripts if existing graphs are missing required columns.refs/changes/13/16613/10
In Run Configurations->Graphing, deleting a parsing column that a created graph relies on now counts as an error in a Run Configuration, and UI notifies users of such an error when it is present. A regular expression without any parenthesized groups also now counts as an error, and graphs can't be added unless at least one such group exists. Change-Id: Ibe6d11fad66c8b60ea40cd4faccb7cdf7749d18a Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/16613 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> IP-Clean: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties3
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java93
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java93
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java95
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties2
6 files changed, 253 insertions, 35 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties
index eaa5548..6c85b85 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties
@@ -140,10 +140,11 @@ SelectGraphAndSeriesWizardPage.Graph=Graph Type:
SelectGraphAndSeriesWizardPage.Title=Title:
SelectGraphAndSeriesWizardPage.XSeries=X Series:
SelectGraphAndSeriesWizardPage.RowID=Row ID
-SelectGraphAndSeriesWizardPage.YSeries=Y Series
+SelectGraphAndSeriesWizardPage.YSeries=Y Series
SelectGraphAndSeriesWizardPage.TitleNotSet=Title not set
SelectGraphAndSeriesWizardPage.KeyFilter=Key filter:
SelectGraphAndSeriesWizardPage.KeyNotSet=Key not set
SelectGraphAndSeriesWizardPage.NA=NA
+SelectGraphAndSeriesWizardPage.Deleted=<Deleted>
SelectGraphAndSeriesWizardPage.UseHistoricalData=Use historical data?
SelectGraphAndSeriesWizardPage.SeriesNotSelected=Series not selected, or share the same selection
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java
index 696aa60..b88745e 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java
@@ -96,20 +96,14 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen
@Override
public void modifyText(ModifyEvent e) {
getWizard().getContainer().updateButtons();
- if(txtTitle.getText().length() == 0) {
- setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.TitleNotSet")); //$NON-NLS-1$
- setMessage(null);
- } else {
- setErrorMessage(null);
- setMessage(""); //$NON-NLS-1$
- }
+ checkErrors();
}
});
//Add the data series widgets
String[] labels = model.getSeries();
- cboYItems = new Combo[labels.length];
+ cboYItems = new Combo[!edit ? labels.length : Math.max(labels.length, model.getYSeries().length)];
lblYItems = new Label[cboYItems.length];
Label lblXItem = new Label(cmpGraphOptsSeries, SWT.NONE);
@@ -141,17 +135,38 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen
cboYItems[j].add(labels[i]);
}
- cboXItem.select(edit ? model.getXSeries() + 1 : 0);
+ int selected;
boolean cvisible = edit;
- if (edit) {
- cboYItems[0].select(model.getYSeries()[0]);
+ if (!edit) {
+ cboXItem.select(0);
+ } else {
+ selected = model.getXSeries();
+ if (selected < labels.length){
+ cboXItem.select(selected + 1);
+ } else {
+ cboXItem.setText(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted")); //$NON-NLS-1$
+ }
+ selected = model.getYSeries()[0];
+ if (selected < labels.length) {
+ cboYItems[0].select(selected);
+ } else {
+ cboYItems[0].setText(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted")); //$NON-NLS-1$
+ }
}
for(int i=1; i<cboYItems.length; i++) {
- int index = edit && model.getYSeries().length > i ? model.getYSeries()[i] + 1 : 0;
- cboYItems[i].select(index);
+ if (!edit || model.getYSeries().length <= i) {
+ cboYItems[i].select(selected = 0);
+ } else {
+ selected = model.getYSeries()[i];
+ if (selected < labels.length){
+ cboYItems[i].select(selected + 1);
+ } else {
+ cboYItems[i].setText(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted")); //$NON-NLS-1$
+ }
+ }
cboYItems[i].setVisible(cvisible);
lblYItems[i].setVisible(cvisible);
- cvisible = (index > 0);
+ cvisible = (selected > 0);
}
//Select one of the graph types by default, rather than blank choice
@@ -164,6 +179,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen
}
setControl(comp);
+ checkErrors();
}
@Override
@@ -209,14 +225,15 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen
model.setXSeries(cboXItem.getSelectionIndex()-1);
int i, count;
- for(i=1, count=1; i<cboYItems.length; i++)
- if(0 != cboYItems[i].getSelectionIndex())
- count++;
+ for(i=1, count=1; i<cboYItems.length && 0 != cboYItems[i].getSelectionIndex(); i++) {
+ count++;
+ }
int[] ySeries = new int[count];
ySeries[0] = cboYItems[0].getSelectionIndex();
- for(i=1; i<count; i++)
+ for(i=1; i<count; i++) {
ySeries[i] = cboYItems[i].getSelectionIndex()-1;
+ }
model.setYSeries(ySeries);
return true;
}
@@ -229,12 +246,21 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen
* @return True if there is no conflict, false otherwise.
*/
private boolean isSeriesUnique() {
- if("".equals(txtTitle.getText().trim())) //$NON-NLS-1$
+ if("".equals(txtTitle.getText().trim())) { //$NON-NLS-1$
return false;
- if(null != txtKey && txtKey.isEnabled() && txtKey.getText().length() <= 0)
+ }
+ if(null != txtKey && txtKey.isEnabled() && txtKey.getText().length() <= 0) {
return false;
+ }
+
+ if (cboXItem.getText().contentEquals(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted"))) { //$NON-NLS-1$
+ return false;
+ }
for(int j,i=0; i<cboYItems.length; i++) {
+ if (cboYItems[i].getText().contentEquals(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted"))) { //$NON-NLS-1$
+ return false;
+ }
if(cboYItems[i].isVisible()) {
for(j=i+1; j<cboYItems.length; j++) {
if(cboYItems[j].isVisible()) {
@@ -324,22 +350,25 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen
}
}
- if(!isSeriesUnique()) {
- setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.SeriesNotSelected")); //$NON-NLS-1$
- setMessage(null);
- } else {
- setErrorMessage(null);
- setMessage(""); //$NON-NLS-1$
- }
- if(txtTitle.getText().length() == 0) {
- setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.TitleNotSet")); //$NON-NLS-1$
- setMessage(null);
- }
-
+ checkErrors();
getWizard().getContainer().updateButtons();
}
}
+ private void checkErrors(){
+ if(!isSeriesUnique()) {
+ setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.SeriesNotSelected")); //$NON-NLS-1$
+ setMessage(null);
+ } else {
+ setErrorMessage(null);
+ setMessage(""); //$NON-NLS-1$
+ }
+ if(txtTitle.getText().length() == 0) {
+ setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.TitleNotSet")); //$NON-NLS-1$
+ setMessage(null);
+ }
+ }
+
private Button[] btnGraphs;
private SelectGraphAndSeriesWizard wizard;
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
index 4d45070..854e1b9 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
@@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.MenuItem;
@@ -28,6 +29,8 @@ import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
@@ -230,6 +233,96 @@ public class TestCreateSystemtapScript {
}
}
+ @Test
+ public void testMissingColumns(){
+ String scriptName = "missingColumns.stp";
+ createScript(bot, scriptName);
+
+ // Focus on project explorer view.
+ bot.viewByTitle("Project Explorer").setFocus();
+ bot.activeShell();
+ SWTBotTree treeBot = bot.tree();
+ treeBot.setFocus();
+ SWTBotTreeItem node = treeBot.expandNode((SYSTEMTAP_PROJECT_NAME));
+ bot.waitUntil(new NodeAvaiable(node, scriptName));
+
+ treeBot.expandNode(SYSTEMTAP_PROJECT_NAME).expand().select(scriptName);
+
+ MenuItem menu = ContextMenuHelper.contextMenu(treeBot, "Run As", "Run Configurations...");
+ click(menu);
+
+ SWTBotShell shell = bot.shell("Run Configurations");
+ shell.setFocus();
+
+ SWTBotTree runConfigurationsTree = bot.tree();
+ runConfigurationsTree.select("SystemTap").contextMenu("New").click();
+
+ // Select the "Graphing" tab.
+ SWTBotCTabItem tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_7);
+ tab.activate();
+
+ // Enable output graphing.
+ bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_2).click();
+
+ // As soon as the Graphing tab is entered, no regular expression exists & nothing can be run.
+ SWTBotText text = bot.textWithLabel("Regular Expression:");
+ assertEquals("", text.getText());
+ assertTrue(!bot.button("Run").isEnabled());
+ assertTrue(!bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).isEnabled());
+ text.setText("(1)(2)");
+ assertEquals("(1)(2)", text.getText());
+ assertTrue(bot.button("Run").isEnabled());
+ assertTrue(bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).isEnabled());
+
+ text = bot.text("", 1);
+ text.setText("Val 1");
+ assertEquals("Val 1", text.getText());
+ text = bot.text("", 1);
+ text.setText("Val 2");
+ assertEquals("Val 2", text.getText());
+
+ bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).click();
+ setupGraph("Graph");
+
+ shell.setFocus();
+ assertTrue(bot.button("Run").isEnabled());
+
+ // Removing groups from the regex disables graphs that rely on those groups.
+ text = bot.textWithLabel("Regular Expression:");
+ text.setText("(1)");
+ assertTrue(!bot.button("Run").isEnabled());
+ text.setText("(1)(2)(3)");
+ assertTrue(bot.button("Run").isEnabled());
+
+ shell.setFocus();
+ bot.button("Apply").click();
+ bot.button("Close").click();
+ bot.waitUntil(new ShellIsClosed(shell));
+ }
+
+ private void setupGraph(String title) {
+ SWTBotShell shell = bot.shell("Create Graph");
+ shell.setFocus();
+
+ SWTBotText text = bot.textWithLabel("Title:");
+ text.setText(title);
+ assertEquals(title, text.getText());
+
+ SWTBotCombo combo_x = bot.comboBoxWithLabel("X Series:");
+ assertEquals(3, combo_x.itemCount()); // X Series includes "Row ID" as a selection
+ SWTBotCombo combo_y0 = bot.comboBoxWithLabel("Y Series 0:");
+ assertEquals(2, combo_y0.itemCount()); // Y Series 0 only includes series entries
+ combo_y0.setSelection(0);
+ SWTBotCombo combo_y1 = bot.comboBoxWithLabel("Y Series 1:");
+ assertEquals(3, combo_y1.itemCount()); // Y Series (i>0) has extra "NA" option as first entry
+ combo_y1.setSelection(1);
+ assertTrue(!bot.button("Finish").isEnabled()); // Don't allow duplicate selections
+ combo_y1.setSelection(2);
+ bot.button("Finish").click();
+
+ bot.waitUntil(new ShellIsClosed(shell));
+ }
+
public static void click(final MenuItem menuItem) {
final Event event = new Event();
event.time = (int) System.currentTimeMillis();
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 49f663e..32d8934 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
@@ -30,6 +30,8 @@ public class Messages extends NLS {
public static String SystemTapScriptGraphOptionsTab_5;
public static String SystemTapScriptGraphOptionsTab_6;
public static String SystemTapScriptGraphOptionsTab_7;
+ public static String SystemTapScriptGraphOptionsTab_8;
+ public static String SystemTapScriptGraphOptionsTab_9;
public static String SystemTapScriptGraphOptionsTab_AddGraphButton;
public static String SystemTapScriptGraphOptionsTab_AddGraphButtonToolTip;
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 668af49..bc4542f 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
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher;
import java.util.ArrayList;
import java.util.LinkedList;
+import java.util.List;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -62,6 +63,8 @@ public class SystemTapScriptGraphOptionsTab extends
static final String RUN_WITH_CHART = "runWithChart"; //$NON-NLS-1$
static final String NUMBER_OF_COLUMNS = "numberOfColumns"; //$NON-NLS-1$
static final String REGEX_BOX = "regexBox_"; //$NON-NLS-1$
+ static final String NUMBER_OF_EXTRAS = "numberOfExtras"; //$NON-NLS-1$
+ static final String EXTRA_BOX = "extraBox_"; //$NON-NLS-1$
static final String REGULARE_EXPRESSION = "regularExpression"; //$NON-NLS-1$
static final String SAMPLE_OUTPUT = "sampleOutput"; //$NON-NLS-1$
@@ -106,6 +109,9 @@ public class SystemTapScriptGraphOptionsTab extends
private boolean graphingEnabled = true;
private String regexErrorMessage;
private Stack<String> cachedNames = new Stack<String>();
+ private List<TableItem> badGraphs = new LinkedList<TableItem>();
+ private int oldNumColumns;
+ private int oldNumExtras;
public static IDataSetParser createDatasetParser(ILaunchConfiguration configuration) {
try {
@@ -356,6 +362,10 @@ public class SystemTapScriptGraphOptionsTab extends
item.setText(GraphFactory.getGraphName(gd.graphID) + ":" //$NON-NLS-1$
+ gd.title);
item.setData(gd);
+ if (badGraphs.contains(selectedTableItem)) {
+ badGraphs.add(item);
+ markGraphTableItem(item, true);
+ }
updateLaunchConfigurationDialog();
}
});
@@ -381,6 +391,9 @@ public class SystemTapScriptGraphOptionsTab extends
selectedTableItem.setText(GraphFactory.getGraphName(gd.graphID) + ":" //$NON-NLS-1$
+ gd.title);
selectedTableItem.setData(gd);
+ if (badGraphs.contains(selectedTableItem)){
+ findBadGraphs(selectedTableItem);
+ }
updateLaunchConfigurationDialog();
}
}
@@ -390,6 +403,7 @@ public class SystemTapScriptGraphOptionsTab extends
removeGraphButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
+ badGraphs.remove(selectedTableItem);
selectedTableItem.dispose();
setSelectionControlsEnabled(false);
updateLaunchConfigurationDialog();
@@ -449,6 +463,7 @@ public class SystemTapScriptGraphOptionsTab extends
label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
this.numberOfVisibleColumns++;
+ findBadGraphs();
textFieldsComposite.layout();
textFieldsComposite.pack();
@@ -462,11 +477,53 @@ public class SystemTapScriptGraphOptionsTab extends
children[i-1].dispose();
this.numberOfVisibleColumns--;
+ findBadGraphs();
textFieldsComposite.layout();
textFieldsComposite.pack();
}
+ private void findBadGraphs(){
+ findBadGraphs(null);
+ }
+
+ private void findBadGraphs(TableItem itemToCheck){
+ TableItem[] items = {itemToCheck};
+ if (itemToCheck == null) {
+ items = graphsTable.getItems();
+ }
+ if (items.length == 0){
+ badGraphs.clear();
+ return;
+ }
+ for (TableItem item : items){
+ GraphData gd = (GraphData) item.getData();
+ boolean removed = false;
+ if (gd.xSeries >= this.numberOfVisibleColumns){
+ removed = true;
+ }
+ for (int s = 0; s < gd.ySeries.length && !removed; s++){
+ if (gd.ySeries[s] >= this.numberOfVisibleColumns){
+ removed = true;
+ }
+ }
+
+ if (removed){
+ if (!badGraphs.contains(item)){
+ badGraphs.add(item);
+ markGraphTableItem(item, true);
+ }
+ }else if (badGraphs.contains(item)){
+ badGraphs.remove(item);
+ markGraphTableItem(item, false);
+ }
+ }
+ }
+
+ private void markGraphTableItem(TableItem item, boolean bad){
+ item.setForeground(item.getDisplay().getSystemColor(bad ? SWT.COLOR_RED : SWT.COLOR_BLACK));
+ }
+
public boolean canFlipToNextPage() {
return false;
}
@@ -491,24 +548,33 @@ public class SystemTapScriptGraphOptionsTab extends
regularExpressionText.setText(configuration.getAttribute(REGULARE_EXPRESSION, "")); //$NON-NLS-1$
sampleOutputText.setText(configuration.getAttribute(SAMPLE_OUTPUT, "")); //$NON-NLS-1$
- int n = configuration.getAttribute(NUMBER_OF_COLUMNS, 0);
+ oldNumColumns = configuration.getAttribute(NUMBER_OF_COLUMNS, 0);
Control[] textBoxes = this.textFieldsComposite.getChildren();
- for (int i = 0; i < n && i*2 < textBoxes.length; i++) {
+ for (int i = 0; i < oldNumColumns && i*2 < textBoxes.length; i++) {
String text = configuration.getAttribute(REGEX_BOX+i, (String)null);
if (text != null) {
((Text)textBoxes[i*2]).setText(text);
}
}
+ cachedNames.clear();
+ oldNumExtras = configuration.getAttribute(NUMBER_OF_EXTRAS, 0);
+ for (int i = oldNumExtras-1; i >= 0; i--) {
+ cachedNames.push(configuration.getAttribute(EXTRA_BOX+i, "")); //$NON-NLS-1$
+ }
+
// Add graphs
graphsTable.removeAll();
+ badGraphs.clear();
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.setForeground(item.getDisplay().getSystemColor(SWT.COLOR_BLACK));
item.setData(graphData);
+ findBadGraphs(item);
}
} catch (CoreException e) {
@@ -531,6 +597,21 @@ public class SystemTapScriptGraphOptionsTab extends
String text = ((Text)textBoxes[i*2]).getText();
configuration.setAttribute(REGEX_BOX+i, text);
}
+ //clear what's unused
+ for (int i = numberOfColumns; i < oldNumColumns; i++) {
+ configuration.setAttribute(REGEX_BOX+i, (String) null);
+ }
+ oldNumColumns = numberOfColumns;
+
+ int numberOfExtras = (badGraphs.size() == 0) ? 0 : cachedNames.size();
+ configuration.setAttribute(NUMBER_OF_EXTRAS, numberOfExtras);
+ for (int i = 0; i < numberOfExtras; i++) {
+ configuration.setAttribute(EXTRA_BOX+i, cachedNames.get(i));
+ }
+ for (int i = numberOfExtras; i < oldNumExtras; i++) {
+ configuration.setAttribute(EXTRA_BOX+i, (String) null);
+ }
+ oldNumExtras = numberOfExtras;
// Save graphs.
TableItem[] list = this.graphsTable.getItems();
@@ -548,6 +629,8 @@ public class SystemTapScriptGraphOptionsTab extends
configuration.setAttribute(GRAPH_Y_SERIES + i + "_" + j, graphData.ySeries[j]); //$NON-NLS-1$
}
}
+
+ addGraphButton.setEnabled(numberOfColumns > 0);
}
@Override
@@ -563,6 +646,14 @@ public class SystemTapScriptGraphOptionsTab extends
setErrorMessage(regexErrorMessage);
return false;
}
+ if (this.numberOfVisibleColumns == 0){
+ setErrorMessage(Messages.SystemTapScriptGraphOptionsTab_9);
+ return false;
+ }
+ if (badGraphs.size() > 0){
+ setErrorMessage(Messages.SystemTapScriptGraphOptionsTab_8);
+ return false;
+ }
return true;
}
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 8d5b08c..54baeb2 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
@@ -22,6 +22,8 @@ SystemTapScriptGraphOptionsTab_4=Output Parsing:
SystemTapScriptGraphOptionsTab_5=Unable to initialize launch configuration tab
SystemTapScriptGraphOptionsTab_6=Cannot parse an empty string: remove '()'
SystemTapScriptGraphOptionsTab_7=Graphing
+SystemTapScriptGraphOptionsTab_8=Some of the created graphs rely on column data that has been deleted. Either re-add the columns or edit the affected graphs.
+SystemTapScriptGraphOptionsTab_9=Please designate the output to graph from the parsed regular expression. Do so by placing parentheses () around what you want to graph.
SystemTapScriptGraphOptionsTab_0=Unable to initialize launch configuration tab
SystemTapScriptGraphOptionsTab_AddGraphButton=Add...