Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-02-25 21:13:30 +0000
committerSami Wagiaalla2014-03-10 17:55:00 +0000
commit463780565c2a2039c003c205ca7f02cff6bf10f3 (patch)
tree63d11ca8ec9f963667693480718c190a3dd1a60d /systemtap
parent0c8b7cb005665dbb6c63a3788042d0f2a66dce20 (diff)
downloadorg.eclipse.linuxtools-463780565c2a2039c003c205ca7f02cff6bf10f3.tar.gz
org.eclipse.linuxtools-463780565c2a2039c003c205ca7f02cff6bf10f3.tar.xz
org.eclipse.linuxtools-463780565c2a2039c003c205ca7f02cff6bf10f3.zip
Systemtap: Fixes to Graph(ing) preferences.
-Allow changes made to SystemTap->Graphing(->Graph) preferences to be applied immediately, instead of only on graph sets created after having made changes. -Provide functionality to the "X/Y Series Ticks" options, which had no effect previously. Rename them to better indicate their purpose. -DataGrids now properly jump to the newest entry (when the option is enabled), instead of getting stuck at the top of the table. -Remove "Max Data Items" from Graph preferences, as it is a duplicate of the option shown in Data Table preferences. Change-Id: I5364c6cf4feca5d8a9711d47729a38dc46d378d0 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/22585 Reviewed-by: Sami Wagiaalla <swagiaal@redhat.com> IP-Clean: Sami Wagiaalla <swagiaal@redhat.com> Tested-by: Sami Wagiaalla <swagiaal@redhat.com>
Diffstat (limited to 'systemtap')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/AbstractChartWithAxisBuilder.java31
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/localization.properties14
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphPreferencePage.java6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphingPreferenceConstants.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/PreferenceInitializer.java13
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/GraphDisplaySet.java23
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/charts/AbstractChartBuilder.java44
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/datadisplay/DataGrid.java66
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/views/GraphSelectorEditor.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/dataset/DataSetFactory.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/UpdateManager.java22
11 files changed, 168 insertions, 61 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/AbstractChartWithAxisBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/AbstractChartWithAxisBuilder.java
index 1d5066eaf2..44d1d7604a 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/AbstractChartWithAxisBuilder.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/AbstractChartWithAxisBuilder.java
@@ -11,8 +11,7 @@
package org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.linuxtools.internal.systemtap.graphing.ui.GraphingUIPlugin;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.listeners.ChartWithAxisMouseMoveListener;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.preferences.GraphingPreferenceConstants;
import org.eclipse.linuxtools.systemtap.graphing.core.adapters.IAdapter;
@@ -68,20 +67,44 @@ public abstract class AbstractChartWithAxisBuilder extends AbstractChartBuilder
*/
protected String xTitle = null;
protected boolean xLineGrid, yLineGrid;
+ /**
+ * @since 3.0
+ */
+ protected int xSeriesTicks, ySeriesTicks;
/**
* Create a chart series for that chart.
*/
protected abstract ISeries createChartISeries(int i);
+ @Override
+ protected void updateProperties(PropertyChangeEvent event) {
+ super.updateProperties(event);
+ String eventName = event.getProperty();
+ if (eventName.equals(GraphingPreferenceConstants.P_SHOW_X_GRID_LINES)) {
+ xLineGrid = store.getBoolean(GraphingPreferenceConstants.P_SHOW_X_GRID_LINES);
+ buildXAxis();
+ } else if (eventName.equals(GraphingPreferenceConstants.P_SHOW_Y_GRID_LINES)) {
+ yLineGrid = store.getBoolean(GraphingPreferenceConstants.P_SHOW_Y_GRID_LINES);
+ buildYAxis();
+ } else if (eventName.equals(GraphingPreferenceConstants.P_X_SERIES_TICKS)) {
+ xSeriesTicks = store.getInt(GraphingPreferenceConstants.P_X_SERIES_TICKS);
+ buildXAxis();
+ } else if (eventName.equals(GraphingPreferenceConstants.P_Y_SERIES_TICKS)) {
+ ySeriesTicks = store.getInt(GraphingPreferenceConstants.P_Y_SERIES_TICKS);
+ buildYAxis();
+ }
+ }
+
/**
* Constructor.
*/
public AbstractChartWithAxisBuilder(IAdapter adapter, Composite parent, int style, String title) {
super(adapter, parent, style, title);
- IPreferenceStore store = GraphingUIPlugin.getDefault().getPreferenceStore();
xLineGrid = store.getBoolean(GraphingPreferenceConstants.P_SHOW_X_GRID_LINES);
yLineGrid = store.getBoolean(GraphingPreferenceConstants.P_SHOW_Y_GRID_LINES);
+ xSeriesTicks = store.getInt(GraphingPreferenceConstants.P_X_SERIES_TICKS);
+ ySeriesTicks = store.getInt(GraphingPreferenceConstants.P_Y_SERIES_TICKS);
}
@Override
@@ -133,6 +156,7 @@ public abstract class AbstractChartWithAxisBuilder extends AbstractChartBuilder
xAxis.getGrid().setStyle(LineStyle.NONE);
}
xAxis.getTick().setForeground(BLACK);
+ xAxis.getTick().setTickMarkStepHint(xSeriesTicks);
ITitle xTitle = xAxis.getTitle();
xTitle.setForeground(BLACK);
@@ -157,6 +181,7 @@ public abstract class AbstractChartWithAxisBuilder extends AbstractChartBuilder
yAxis.getGrid().setStyle(LineStyle.NONE);
}
yAxis.getTick().setForeground(BLACK);
+ yAxis.getTick().setTickMarkStepHint(ySeriesTicks);
}
/**
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/localization.properties
index dabec5a092..e6df8e69e3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/localization.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/localization.properties
@@ -18,16 +18,16 @@ AGraph.SeriesAxis=series axis
#Preferences
GraphPreferencePage.GraphDisplayPreferences=Basic preferences for graph display.
-GraphPreferencePage.ShowXGridLines=&Show X grid lines:
-GraphPreferencePage.ShowYGridLines=&Show Y grid lines:
+GraphPreferencePage.ShowXGridLines=&Show X grid lines
+GraphPreferencePage.ShowYGridLines=&Show Y grid lines
GraphPreferencePage.MaxDataItems=&Max data items:
GraphPreferencePage.ViewableDataItems=&Viewable data items:
-GraphPreferencePage.XSeriesTicks=&X series ticks:
-GraphPreferencePage.YSeriesTicks=&Y series ticks:
+GraphPreferencePage.XSeriesTicks=&X series tick step size (px):
+GraphPreferencePage.YSeriesTicks=&Y series tick step size (px):
DataTablePreferencePage.GraphDisplayPreferences=Basic preferences for graph display.
-DataTablePreferencePage.JumpNewestEntry=&Jump to newest entry:
-DataTablePreferencePage.AutoResizeColumns=&Auto resize columns:
+DataTablePreferencePage.JumpNewestEntry=&Jump to newest entry
+DataTablePreferencePage.AutoResizeColumns=&Auto resize columns
DataTablePreferencePage.MaxDataItems=&Max data items:
#Wigets
@@ -180,4 +180,4 @@ GraphingPreferencePage.RefreshDelay=&Refresh delay (ms):
GraphDisplaySet.DataView=Data View
GraphDisplaySet.CreateGraph=Create Graph
-GraphDisplaySet.GraphTabTitle={0} - {1} \ No newline at end of file
+GraphDisplaySet.GraphTabTitle={0} - {1}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphPreferencePage.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphPreferencePage.java
index eb88b1cc5a..e9269200f1 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphPreferencePage.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphPreferencePage.java
@@ -42,12 +42,6 @@ public class GraphPreferencePage extends FieldEditorPreferencePage implements IW
addField(
new IntegerFieldEditor(
- GraphingPreferenceConstants.P_MAX_DATA_ITEMS,
- Localization.getString("GraphPreferencePage.MaxDataItems"), //$NON-NLS-1$
- getFieldEditorParent()));
-
- addField(
- new IntegerFieldEditor(
GraphingPreferenceConstants.P_VIEWABLE_DATA_ITEMS,
Localization.getString("GraphPreferencePage.ViewableDataItems"), //$NON-NLS-1$
getFieldEditorParent()));
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphingPreferenceConstants.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphingPreferenceConstants.java
index 0c49e75417..8b28286923 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphingPreferenceConstants.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/GraphingPreferenceConstants.java
@@ -18,11 +18,11 @@ public class GraphingPreferenceConstants {
//graphing.datatable
public static final String P_JUMP_NEW_TABLE_ENTRY = "JumpNewTableEntry"; //$NON-NLS-1$
public static final String P_AUTO_RESIZE = "AutoResizeColumns"; //$NON-NLS-1$
+ public static final String P_MAX_DATA_ITEMS = "MaxDataItems"; //$NON-NLS-1$
//graphing.graph
public static final String P_SHOW_X_GRID_LINES = "ShowXGridLines"; //$NON-NLS-1$
public static final String P_SHOW_Y_GRID_LINES = "ShowYGridLines"; //$NON-NLS-1$
- public static final String P_MAX_DATA_ITEMS = "MaxDataItems"; //$NON-NLS-1$
public static final String P_VIEWABLE_DATA_ITEMS = "ViewableDataItems"; //$NON-NLS-1$
public static final String P_X_SERIES_TICKS = "XSeriesTicks"; //$NON-NLS-1$
public static final String P_Y_SERIES_TICKS = "YSeriesTicks"; //$NON-NLS-1$
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/PreferenceInitializer.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/PreferenceInitializer.java
index faefea760e..f9fd1fca9e 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/PreferenceInitializer.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/preferences/PreferenceInitializer.java
@@ -25,13 +25,16 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
//graphing
store.setDefault(GraphingPreferenceConstants.P_GRAPH_UPDATE_DELAY, 1000);
- store.setDefault(GraphingPreferenceConstants.P_SHOW_X_GRID_LINES, true);
- store.setDefault(GraphingPreferenceConstants.P_SHOW_Y_GRID_LINES, true);
+ //data table
store.setDefault(GraphingPreferenceConstants.P_AUTO_RESIZE, true);
store.setDefault(GraphingPreferenceConstants.P_JUMP_NEW_TABLE_ENTRY, false);
- store.setDefault(GraphingPreferenceConstants.P_VIEWABLE_DATA_ITEMS, 100);
store.setDefault(GraphingPreferenceConstants.P_MAX_DATA_ITEMS, 250);
- store.setDefault(GraphingPreferenceConstants.P_X_SERIES_TICKS, 10);
- store.setDefault(GraphingPreferenceConstants.P_Y_SERIES_TICKS, 4);
+
+ //graph
+ store.setDefault(GraphingPreferenceConstants.P_SHOW_X_GRID_LINES, true);
+ store.setDefault(GraphingPreferenceConstants.P_SHOW_Y_GRID_LINES, true);
+ store.setDefault(GraphingPreferenceConstants.P_VIEWABLE_DATA_ITEMS, 100);
+ store.setDefault(GraphingPreferenceConstants.P_X_SERIES_TICKS, 64);
+ store.setDefault(GraphingPreferenceConstants.P_Y_SERIES_TICKS, 64);
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/GraphDisplaySet.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/GraphDisplaySet.java
index 96c09c39ba..ed49fe9a76 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/GraphDisplaySet.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/GraphDisplaySet.java
@@ -15,6 +15,8 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.GraphingUIPlugin;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.Localization;
@@ -57,14 +59,27 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
*/
public class GraphDisplaySet {
+ private IPropertyChangeListener propertyChangeListener;
+ private IPreferenceStore p;
+
public GraphDisplaySet(Composite parent, IDataSet data) {
- IPreferenceStore p = GraphingUIPlugin.getDefault().getPreferenceStore();
+ p = GraphingUIPlugin.getDefault().getPreferenceStore();
int delay = p.getInt(GraphingPreferenceConstants.P_GRAPH_UPDATE_DELAY);
dataSet = data;
updater = new UpdateManager(delay);
createPartControl(parent);
+ propertyChangeListener = new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (updater.isRunning() && event.getProperty().equals(GraphingPreferenceConstants.P_GRAPH_UPDATE_DELAY)) {
+ updater.restart((int) event.getNewValue());
+ }
+ }
+ };
+ p.addPropertyChangeListener(propertyChangeListener);
+
builders = new ArrayList<>();
tabListeners = new ArrayList<>();
}
@@ -171,6 +186,9 @@ public class GraphDisplaySet {
}
updater = null;
+ p.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+
dataSet = null;
if(null != folder && !folder.isDisposed()) {
folder.removeSelectionListener(listener);
@@ -179,6 +197,9 @@ public class GraphDisplaySet {
}
listener = null;
+ for (AbstractChartBuilder builder : builders) {
+ builder.dispose();
+ }
builders.clear();
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/charts/AbstractChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/charts/AbstractChartBuilder.java
index 45d9cc2ea2..95bc2a9070 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/charts/AbstractChartBuilder.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/charts/AbstractChartBuilder.java
@@ -17,6 +17,8 @@ import java.util.LinkedHashSet;
import java.util.Set;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.GraphingUIPlugin;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.listeners.ChartMouseMoveListener;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.preferences.GraphingPreferenceConstants;
@@ -101,17 +103,53 @@ public abstract class AbstractChartBuilder extends Composite implements IUpdateL
public abstract void updateDataSet();
/**
- * Constructs one chart builder and associate it to one data set.
+ * A reference to the SystemTap Graphing preference store.
+ * @since 3.0
+ */
+ protected IPreferenceStore store;
+ /**
+ * Updates the chart with properties read from user-set preferences. It is called automatically
+ * whenever a change is made to SystemTap Graphing preferences.
+ * @param event The update event containing details on the preference that was changed.
+ * @since 3.0
*/
+ protected void updateProperties(PropertyChangeEvent event) {
+ if (event.getProperty().equals(GraphingPreferenceConstants.P_VIEWABLE_DATA_ITEMS)
+ || event.getProperty().equals(GraphingPreferenceConstants.P_MAX_DATA_ITEMS)) {
+ maxItems = Math.min(store.getInt(GraphingPreferenceConstants.P_VIEWABLE_DATA_ITEMS),
+ store.getInt(GraphingPreferenceConstants.P_MAX_DATA_ITEMS));
+ updateDataSet();
+ }
+ }
+ private IPropertyChangeListener propertyChangeListener;
+ /**
+ * Constructs one chart builder and associate it to one data set.
+ */
public AbstractChartBuilder(IAdapter adapter, Composite parent, int style, String title) {
super(parent, style);
this.adapter = adapter;
this.title = title;
this.setLayout(new FillLayout());
- IPreferenceStore store = GraphingUIPlugin.getDefault().getPreferenceStore();
+
+ store = GraphingUIPlugin.getDefault().getPreferenceStore();
maxItems = Math.min(store.getInt(GraphingPreferenceConstants.P_VIEWABLE_DATA_ITEMS),
- store.getInt(GraphingPreferenceConstants.P_MAX_DATA_ITEMS));
+ store.getInt(GraphingPreferenceConstants.P_MAX_DATA_ITEMS));
+
+ propertyChangeListener = new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ updateProperties(event);
+ }
+ };
+ store.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ @Override
+ public void dispose() {
+ store.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ super.dispose();
}
/**
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/datadisplay/DataGrid.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/datadisplay/DataGrid.java
index b92eabc500..6bbaea6124 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/datadisplay/DataGrid.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/datadisplay/DataGrid.java
@@ -14,6 +14,8 @@ package org.eclipse.linuxtools.systemtap.graphing.ui.datadisplay;
import java.text.MessageFormat;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.linuxtools.internal.systemtap.graphing.ui.GraphingUIPlugin;
@@ -60,8 +62,17 @@ public class DataGrid implements IUpdateListener {
: DataSetFactory.createFilteredDataSet(dataSet);
this.style = style;
clickLocation = new Point(-1, -1);
- removedItems = 0;
createPartControl(composite);
+
+ propertyChangeListener = new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(GraphingPreferenceConstants.P_MAX_DATA_ITEMS)) {
+ handleUpdateEvent();
+ }
+ }
+ };
+ prefs.addPropertyChangeListener(propertyChangeListener);
}
public void setLayoutData(Object data) {
@@ -106,9 +117,6 @@ public class DataGrid implements IUpdateListener {
handleUpdateEvent();
}
- private MenuItem removeFiltersMenuItem;
- private MenuItem formatMenuItem;
-
public Menu initMenus() {
Menu menu = new Menu(table.getShell(), SWT.POP_UP);
menu.addMenuListener(new MainMenuListener());
@@ -296,17 +304,15 @@ public class DataGrid implements IUpdateListener {
return;
}
TableItem item;
- int startLocation, endLocation = filteredDataSet.getRowCount();
- boolean rowsAdded = endLocation != table.getItemCount();
-
- if(FULL_UPDATE == (style & FULL_UPDATE)) {
- //Remove extra items so save memory.
- removedItems += table.getItemCount();
- table.removeAll();
- startLocation = 0;
- } else {
- startLocation = table.getItemCount()+removedItems;
- }
+ int startLocation;
+ int endLocation = filteredDataSet.getRowCount();
+ int maxItems = prefs.getInt(GraphingPreferenceConstants.P_MAX_DATA_ITEMS);
+ int oldSelection = table.getSelectionIndex();
+
+ //Remove old items to refresh table, and only read in as many items as will fit.
+ //Note that a full refresh is necessary in order for filtered data to appear correctly.
+ table.removeAll();
+ startLocation = Math.max(endLocation-maxItems, 0);
//Add all the new items to the table
Object[] os;
@@ -323,14 +329,9 @@ public class DataGrid implements IUpdateListener {
}
}
}
-
- if(FULL_UPDATE != (style & FULL_UPDATE)) {
- //Remove extra items so save memory.
- if(table.getItemCount() > prefs.getInt(GraphingPreferenceConstants.P_MAX_DATA_ITEMS)) {
- int items = table.getItemCount()-prefs.getInt(GraphingPreferenceConstants.P_MAX_DATA_ITEMS);
- table.remove(0, items-1);
- removedItems += items;
- }
+ //Re-select the old table selection, if there was one
+ if (oldSelection != -1) {
+ table.select(oldSelection);
}
//Resize the columns
@@ -342,10 +343,17 @@ public class DataGrid implements IUpdateListener {
cols[i].pack();
}
}
- //Use if we want to set focus to newly added item
+
+ //Use if we want to set focus to newly added item.
+ //Run async so the table can be fully constructed before jumping to an entry.
if(prefs.getBoolean(GraphingPreferenceConstants.P_JUMP_NEW_TABLE_ENTRY)
- && table.getItemCount() > 1 && rowsAdded) {
- table.select(table.getItemCount()-1);
+ && table.getItemCount() > 0) {
+ table.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ table.showItem(table.getItem(table.getItemCount()-1));
+ }
+ });
}
formatMenuItem.setEnabled(table.getItemCount() > 0);
}
@@ -358,6 +366,8 @@ public class DataGrid implements IUpdateListener {
table = null;
clickLocation = null;
columnFormat = null;
+ prefs.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
}
protected IDataSet dataSet;
@@ -371,6 +381,10 @@ public class DataGrid implements IUpdateListener {
protected Menu filterMenu;
protected int style;
+ private MenuItem removeFiltersMenuItem;
+ private MenuItem formatMenuItem;
+ private IPropertyChangeListener propertyChangeListener;
+
public static final int NONE = 0;
public static final int FULL_UPDATE = 1;
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/views/GraphSelectorEditor.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/views/GraphSelectorEditor.java
index 5fe4ed1928..a821699397 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/views/GraphSelectorEditor.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/views/GraphSelectorEditor.java
@@ -218,10 +218,6 @@ public class GraphSelectorEditor extends EditorPart {
*/
@Override
public void dispose() {
- for (GraphDisplaySet displaySet : displaySets) {
- displaySet.dispose();
- }
-
super.dispose();
if(null != scriptFolder && !scriptFolder.isDisposed()) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/dataset/DataSetFactory.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/dataset/DataSetFactory.java
index a69fea5805..d5055946b9 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/dataset/DataSetFactory.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/dataset/DataSetFactory.java
@@ -49,7 +49,9 @@ public final class DataSetFactory {
}
public static DataGrid getDataGrid(Composite composite, IDataSet set) {
- if(set instanceof RowDataSet || set instanceof TableDataSet) {
+ if(set instanceof RowDataSet) {
+ return new DataGrid(composite, set, DataGrid.NONE);
+ } else if(set instanceof TableDataSet) {
return new DataGrid(composite, set, DataGrid.FULL_UPDATE);
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/UpdateManager.java b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/UpdateManager.java
index cb6fa9aa09..8b3336f9f2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/UpdateManager.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/UpdateManager.java
@@ -24,6 +24,16 @@ public class UpdateManager {
updateListeners = new ArrayList<>();
stopped = false;
disposed = false;
+ restart(delay);
+ }
+
+ /**
+ * @since 2.2
+ */
+ public void restart(int delay) {
+ if (timer != null) {
+ timer.cancel();
+ }
timer = new Timer("Update Manager", true); //$NON-NLS-1$
timer.scheduleAtFixedRate(new Notify(), delay, delay);
}
@@ -36,19 +46,22 @@ public class UpdateManager {
stopped = true;
timer.cancel();
synchronized (updateListeners) {
- for(int i=0; i<updateListeners.size(); i++)
+ for(int i=0; i<updateListeners.size(); i++) {
removeUpdateListener(updateListeners.get(i));
+ }
}
}
}
public void addUpdateListener(IUpdateListener l) {
- if(!updateListeners.contains(l))
+ if(!updateListeners.contains(l)) {
updateListeners.add(l);
+ }
}
public void removeUpdateListener(IUpdateListener l) {
- if(updateListeners.contains(l))
+ if(updateListeners.contains(l)) {
updateListeners.remove(l);
+ }
}
public boolean isRunning() {
@@ -72,8 +85,9 @@ public class UpdateManager {
public void run() {
if(!stopped) {
synchronized (updateListeners) {
- for(int i = 0; i < updateListeners.size(); i++)
+ for(int i = 0; i < updateListeners.size(); i++) {
(updateListeners.get(i)).handleUpdateEvent();
+ }
}
}
}

Back to the top