Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-06-11 15:33:39 +0000
committerAlexander Kurtakov2014-07-17 17:45:30 +0000
commit551c6f297f6e77087ddcb5d599a236275f4118ba (patch)
tree74148996c55cd6e9c28c75460f0727e7eca19376
parent038db7ee329abce27d372696de2cee161811ee82 (diff)
downloadorg.eclipse.linuxtools-551c6f297f6e77087ddcb5d599a236275f4118ba.tar.gz
org.eclipse.linuxtools-551c6f297f6e77087ddcb5d599a236275f4118ba.tar.xz
org.eclipse.linuxtools-551c6f297f6e77087ddcb5d599a236275f4118ba.zip
Systemtap: Refreshable/improved BrowserViews.
Provide a "refresh" control on BrowserViews (Function, Probe Alias, and Kernel Browsers), and indicate when the contents of the views are loading. Also clear the browser contents when a refresh operation begins. Change-Id: I6faadbbdae6fb9e311f74811bbd9fd157911d159 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/29001 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/icons/actions/refresh_tab.gifbin0 -> 213 bytes
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml22
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/FunctionParser.java26
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ProbeParser.java58
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java44
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java62
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java17
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/BrowserView.java64
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/FunctionBrowserView.java37
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/KernelBrowserView.java50
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/ProbeAliasBrowserView.java37
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/RefreshHandler.java56
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/TapsetBrowserView.java102
15 files changed, 341 insertions, 238 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/icons/actions/refresh_tab.gif b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/icons/actions/refresh_tab.gif
new file mode 100644
index 0000000000..3ec515bda8
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/icons/actions/refresh_tab.gif
Binary files differ
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
index 96cb75d3d9..65f83c26bb 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
@@ -45,6 +45,8 @@ command.dataExport.name=SystemTap: Export Data Set
command.dataExport.desc=Export graph contents to an external file
command.dataImport.name=SystemTap: Import Data Set
command.dataImport.desc=Import previously-saved graph contents
+command.refreshView.name=Refresh
+command.refreshView.desc=Refresh the contents of this view
toolbar.actions.name=SystemTap Actions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
index 38066a094c..724ef281d1 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
@@ -44,16 +44,31 @@
<menuContribution
locationURI="toolbar:org.eclipse.linuxtools.internal.systemtap.ui.ide.views.FunctionBrowserView">
<command commandId="org.eclipse.ui.navigate.collapseAll"/>
+ <command
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.refreshView"
+ icon="icons/actions/refresh_tab.gif"
+ label="%command.refreshView.name"
+ tooltip="%command.refreshView.name"/>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.linuxtools.internal.systemtap.ui.ide.views.KernelBrowserView">
<command commandId="org.eclipse.ui.navigate.collapseAll"/>
+ <command
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.refreshView"
+ icon="icons/actions/refresh_tab.gif"
+ label="%command.refreshView.name"
+ tooltip="%command.refreshView.name"/>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.linuxtools.internal.systemtap.ui.ide.views.ProbeAliasBrowserView">
<command commandId="org.eclipse.ui.navigate.collapseAll"/>
+ <command
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.refreshView"
+ icon="icons/actions/refresh_tab.gif"
+ label="%command.refreshView.name"
+ tooltip="%command.refreshView.name"/>
</menuContribution>
<menuContribution
@@ -312,6 +327,13 @@
categoryId="org.eclipse.linuxtools.systemtap.ui.ide.category.tapset"
id="org.eclipse.linuxtools.systemtap.ui.ide.definitionMenu">
</command>
+ <command
+ name="%command.refreshView.name"
+ description="%command.refreshView.desc"
+ categoryId="org.eclipse.linuxtools.systemtap.ui.ide.category.tapset"
+ id="org.eclipse.linuxtools.systemtap.ui.ide.refreshView"
+ defaultHandler="org.eclipse.linuxtools.internal.systemtap.ui.ide.views.RefreshHandler">
+ </command>
<category
name="%category.cfiles.name"
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
index 6465c3921c..76784fb0ae 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
@@ -65,5 +65,7 @@ KernelBrowserView.KernelSourceDirNotFound=Kernel Source Directory not found
KernelBrowserView.CouldNotInitializeTree=Could not initialize kernel source tree
+BrowserView.Loading=Loading...
+
ToggleComment_error_title=Comment/Uncomment
ToggleComment_error_message=An error occurred while commenting/uncommenting.
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/FunctionParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/FunctionParser.java
index 27ca954f35..65cd8b67c1 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/FunctionParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/FunctionParser.java
@@ -68,33 +68,39 @@ public final class FunctionParser extends TreeTapsetParser {
}
@Override
+ protected void resetTree() {
+ functions = new TreeNode(null, false);
+ }
+
+ @Override
public void dispose() {
functions.dispose();
}
+ /**
+ * Runs stap to collect all available tapset functions.
+ */
@Override
protected IStatus run(IProgressMonitor monitor) {
- boolean cancelled = runPass2Functions();
+ super.run(monitor);
+ boolean canceled = !addFunctions(monitor);
functions.sortTree();
- fireUpdateEvent(); //Inform listeners that everything is done
- return new Status(!cancelled ? IStatus.OK : IStatus.CANCEL, IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
+ return new Status(!canceled ? IStatus.OK : IStatus.CANCEL,
+ IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
}
/**
* This method is used to build up the list of functions that were found
- * during the first pass of stap. Stap is invoked by: $stap -v -p1 -e
- * 'probe begin{}' and parsing the output.
+ * during the first pass of stap.
*
* FunctionTree organized as:
* Root->Functions->Parameters
*
- * @return <code>false</code> if a cancellation prevented all probes from being added;
+ * @return <code>false</code> if a cancelation prevented all functions from being added;
* <code>true</code> otherwise.
*/
- private boolean runPass2Functions() {
+ private boolean addFunctions(IProgressMonitor monitor) {
String tapsetContents = SharedParser.getInstance().getTapsetContents();
- // Create a new function tree each time, so as to not add duplicates
- functions = new TreeNode(null, false);
if (tapsetContents == null) {
// Functions are only drawn from the tapset dump, so exit if it's empty.
return true;
@@ -105,7 +111,7 @@ public final class FunctionParser extends TreeTapsetParser {
SharedParser sparser = SharedParser.getInstance();
while (st.hasNextLine()) {
- if (isCancelRequested()) {
+ if (monitor.isCanceled()) {
return false;
}
String tok = st.nextLine();
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ProbeParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ProbeParser.java
index d02cd2e601..ad7ce447f3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ProbeParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ProbeParser.java
@@ -68,22 +68,25 @@ public final class ProbeParser extends TreeTapsetParser {
aliases.dispose();
}
+ /**
+ * Runs stap to collect all available tapset probes.
+ * ProbeTree organized as:
+ * Root->Named Groups->ProbePoints->Variables
+ */
@Override
protected IStatus run(IProgressMonitor monitor) {
- // Create a new function tree each time, so as to not add duplicates.
- reset();
-
- addStaticProbes();
- if (isCancelRequested()) {
- return new Status(IStatus.CANCEL, IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
+ super.run(monitor);
+ boolean canceled = !addStaticProbes(monitor);
+ if (!canceled) {
+ canceled = !addProbeAliases(monitor);
}
- addProbeAliases();
constructRootTree();
- fireUpdateEvent(); //Inform listeners that everything is done
- return new Status(!isCancelRequested() ? IStatus.OK : IStatus.CANCEL, IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
+ return new Status(!monitor.isCanceled() ? IStatus.OK : IStatus.CANCEL,
+ IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$
}
- private void reset() {
+ @Override
+ protected void resetTree() {
probes = new TreeNode(null, false);
statics = new TreeNode(Messages.ProbeParser_staticProbes, false);
aliases = new TreeNode(Messages.ProbeParser_aliasProbes, false);
@@ -96,46 +99,49 @@ public final class ProbeParser extends TreeTapsetParser {
probes.add(aliases);
}
- private void addStaticProbes() {
+ /**
+ * Runs stap to obtain a log of all static probes, and populate the probe tree with them.
+ *
+ * @return <code>false</code> if a cancelation prevented all probes from being added;
+ * <code>true</code> otherwise.
+ */
+ private boolean addStaticProbes(IProgressMonitor monitor) {
String probeDump = runStap(new String[]{"--dump-probe-types"}, null, false); //$NON-NLS-1$
if (probeDump == null) {
- return;
+ return true;
}
TreeNode group = null;
try (Scanner st = new Scanner(probeDump)) {
while (st.hasNextLine()) {
- if (isCancelRequested()) {
- return;
+ if (monitor.isCanceled()) {
+ return false;
}
String tokenString = st.nextLine();
String probeName = (new StringTokenizer(tokenString)).nextToken();
group = addOrFindProbeGroup(extractProbeGroupName(probeName), group, statics);
group.add(makeStaticProbeNode(probeName));
}
- return;
+ return true;
}
}
/**
- * Parses the output generated from running stap -L. Pulls out all functions
- * and probe aliases from the provided string. Populates the probe tree.
- *
- * ProbeTree organized as:
- * Root->Named Groups->ProbePoints->Variables
+ * Runs stap to obtain a log of all probe aliases & their variables,
+ * and populate the probe tree with them.
*
- * @return <code>false</code> if a cancellation prevented all probes from being added;
+ * @return <code>false</code> if a cancelation prevented all probes from being added;
* <code>true</code> otherwise.
*/
- private void addProbeAliases() {
+ private boolean addProbeAliases(IProgressMonitor monitor) {
String probeDump = runStap(new String[]{"-L"}, "**", false); //$NON-NLS-1$ //$NON-NLS-2$
if (probeDump == null) {
- return;
+ return true;
}
TreeNode group = null;
try (Scanner st = new Scanner(probeDump)) {
while (st.hasNextLine()) {
- if (isCancelRequested()) {
- return;
+ if (monitor.isCanceled()) {
+ return false;
}
String tokenString = st.nextLine();
// If the token starts with '_' or '__' it is a private probe so
@@ -155,7 +161,7 @@ public final class ProbeParser extends TreeTapsetParser {
addAllVarNodesToProbeNode(probeTokenizer, probeNode);
}
}
- return;
+ return true;
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
index c93605e8c2..a1958993e7 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
@@ -13,7 +13,9 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
import java.io.File;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -23,7 +25,6 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.PreferenceConstants;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
-import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -44,9 +45,6 @@ public final class TapsetLibrary {
private static FunctionParser functionParser = FunctionParser.getInstance();
private static ProbeParser probeParser = ProbeParser.getInstance();
- private static final IUpdateListener functionCompletionListener = new ParseCompletionListener(functionParser);
- private static final IUpdateListener probeCompletionListener = new ParseCompletionListener(probeParser);
-
private static boolean initialized = false;
public static TreeNode getProbes() {
@@ -80,8 +78,8 @@ public final class TapsetLibrary {
preferenceStore.addPropertyChangeListener(propertyChangeListener);
ConsoleLogPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(credentialChangeListener);
- functionParser.addListener(functionCompletionListener);
- probeParser.addListener(probeCompletionListener);
+ functionParser.addJobChangeListener(parseCompletionListener);
+ probeParser.addJobChangeListener(parseCompletionListener);
if (preferenceStore.getBoolean(IDEPreferenceConstants.P_STORED_TREE)
&& isTreeFileCurrent()) {
@@ -120,37 +118,35 @@ public final class TapsetLibrary {
}
};
- private static class ParseCompletionListener implements IUpdateListener {
- TreeTapsetParser parser;
- public ParseCompletionListener(TreeTapsetParser parser) {
- this.parser = parser;
- }
-
+ private static JobChangeAdapter parseCompletionListener = new JobChangeAdapter() {
@Override
- public void handleUpdateEvent() {
- if (!parser.isCancelRequested()) {
- if (parser.equals(functionParser)) {
- functionTree = parser.getTree();
- } else {
- probeTree = parser.getTree();
- }
+ public void done(IJobChangeEvent event) {
+ super.done(event);
+ if (!event.getResult().isOK()) {
+ return;
+ }
+ TreeTapsetParser parser = (TreeTapsetParser) event.getJob();
+ if (parser.equals(functionParser)) {
+ functionTree = parser.getTree();
+ } else {
+ probeTree = parser.getTree();
+ }
- if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_STORED_TREE)) {
- TreeSettings.setTrees(functionTree, probeTree);
- }
+ if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_STORED_TREE)) {
+ TreeSettings.setTrees(functionTree, probeTree);
}
synchronized (parser) {
parser.notifyAll();
}
}
- }
+ };
/**
* This method will trigger the appropriate parsing jobs
* to get the information directly from the files.
* If the jobs are already in progess, they will be restarted.
*/
- private static void runStapParser() {
+ public static void runStapParser() {
stop();
clearTrees();
SharedParser.getInstance().clearTapsetContents();
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
index b25dcbf081..52ffe37f49 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
@@ -14,11 +14,8 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
import java.io.File;
import java.io.IOException;
import java.net.ConnectException;
-import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -26,7 +23,6 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.StringOutputStream;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.EnvironmentVariablesPreferencePage;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
-import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener;
import org.eclipse.linuxtools.systemtap.structures.process.SystemtapProcessFactory;
import org.eclipse.linuxtools.systemtap.structures.runnable.StringStreamGobbler;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
@@ -59,74 +55,16 @@ public abstract class TapsetParser extends Job {
private static AtomicBoolean displayingError = new AtomicBoolean(false);
private static AtomicBoolean displayingCredentialDialog = new AtomicBoolean(false);
- private ArrayList<IUpdateListener> listeners = new ArrayList<>();
- private boolean cancelRequested = false;
- public boolean isCancelRequested() {
- return cancelRequested;
- }
-
protected TapsetParser(String jobTitle) {
super(jobTitle);
- addJobChangeListener(new IJobChangeListener() {
- @Override
- public void sleeping(IJobChangeEvent event) {
- }
- @Override
- public void scheduled(IJobChangeEvent event) {
- }
- @Override
- public void running(IJobChangeEvent event) {
- }
- @Override
- public void done(IJobChangeEvent event) {
- cancelRequested = false;
- }
- @Override
- public void awake(IJobChangeEvent event) {
- }
- @Override
- public void aboutToRun(IJobChangeEvent event) {
- }
- });
}
@Override
protected void canceling() {
- cancelRequested = true;
getThread().interrupt();
}
/**
- * Register a new listener with this parser.
- * @param listener The listener that will receive an update event when this
- * parser has completed its operation.
- */
- public void addListener(IUpdateListener listener) {
- if (listener != null) {
- listeners.add(listener);
- }
- }
-
- /**
- * Unregister the listener with this parser.
- * @param listener The listener that no longer wants to recieve update events.
- */
- public void removeListener(IUpdateListener listener) {
- if (listener != null) {
- listeners.remove(listener);
- }
- }
-
- /**
- * This method will fire an updateEvent to all listeners.
- */
- protected void fireUpdateEvent() {
- for (IUpdateListener listener : listeners) {
- listener.handleUpdateEvent();
- }
- }
-
- /**
* Runs stap with the given options and returns the output generated,
* or <code>null</code> if the case of an error.
* @param options String[] of any optional parameters to pass to stap
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java
index e0b0ebd806..2009bd6762 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java
@@ -11,6 +11,8 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
/**
@@ -24,11 +26,26 @@ public abstract class TreeTapsetParser extends TapsetParser {
}
/**
+ * Prepares the parser for a run. Clients must override this method to perform
+ * actions during the run; a call to super.run() is necessary.
+ */
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ resetTree();
+ return null;
+ }
+
+ /**
* @return The tree that this parser constructs.
*/
abstract TreeNode getTree();
/**
+ * Clears & resets the tree that this parser constructs.
+ */
+ abstract protected void resetTree();
+
+ /**
* Clean up everything from the last parse run.
*/
abstract void dispose();
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/BrowserView.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/BrowserView.java
index acedd5bfe2..a7c46314cf 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/BrowserView.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/BrowserView.java
@@ -17,9 +17,9 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.BrowserViewAction;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
-import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
@@ -45,14 +45,10 @@ import org.eclipse.ui.part.ViewPart;
*/
public abstract class BrowserView extends ViewPart {
protected TreeViewer viewer;
- protected TreeNode tree;
protected BrowserViewAction doubleClickAction;
private CollapseAllHandler collapseHandler;
-
- public BrowserView() {
- super();
- }
+ private RefreshHandler refreshHandler;
/**
* Provides an interface for the TreeViewer to interact with the internal TreeNode data structure.
@@ -109,23 +105,34 @@ public abstract class BrowserView extends ViewPart {
@Override
public Image getImage(Object obj) {
- return getEntryImage((TreeNode) obj);
+ TreeNode treeObj = (TreeNode) obj;
+ if (treeObj.toString().equals(Localization.getString("BrowserView.Loading"))) { //$NON-NLS-1$
+ return null;
+ }
+ return getEntryImage(treeObj);
}
}
@Override
public void createPartControl(Composite parent) {
- parent.getShell().setCursor(parent.getShell().getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
PatternFilter filter = new PatternFilter();
FilteredTree filteredTree = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
viewer = filteredTree.getViewer();
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
+
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
collapseHandler = new CollapseAllHandler(getViewer());
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, collapseHandler);
+ refreshHandler = new RefreshHandler(this);
+ handlerService.activateHandler(RefreshHandler.COMMAND_ID, refreshHandler);
}
+ /**
+ * Wires up all of the actions for this browser, such as double and right click handlers.
+ */
+ abstract void makeActions();
+
protected void registerContextMenu(String menuName) {
Control control = this.viewer.getControl();
MenuManager manager = new MenuManager(menuName);
@@ -154,6 +161,10 @@ public abstract class BrowserView extends ViewPart {
collapseHandler.dispose();
collapseHandler = null;
}
+ if (refreshHandler != null) {
+ refreshHandler.dispose();
+ refreshHandler = null;
+ }
if (viewer != null) {
if (doubleClickAction != null) {
viewer.removeDoubleClickListener(doubleClickAction);
@@ -168,17 +179,30 @@ public abstract class BrowserView extends ViewPart {
abstract void refresh();
- protected IUpdateListener viewUpdater = new IUpdateListener() {
- @Override
- public void handleUpdateEvent() {
- if (viewer != null) {
- viewer.getControl().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- refresh();
- }
- });
- }
+ protected void displayLoadingMessage() {
+ displayMessage(Localization.getString("BrowserView.Loading")); //$NON-NLS-1$
+ }
+
+ protected void displayMessage(String message) {
+ TreeNode tree = new TreeNode(null, false);
+ tree.add(new TreeNode(message, false));
+ setViewerInput(tree);
+ }
+
+ protected void setViewerInput(final Object input) {
+ if (viewer != null) {
+ viewer.getControl().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ viewer.setInput(input);
+ }
+ });
}
- };
+ }
+
+ protected void setRefreshable(boolean state) {
+ if (refreshHandler != null) {
+ refreshHandler.setActive(state);
+ }
+ }
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/FunctionBrowserView.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/FunctionBrowserView.java
index e6c646b38d..67d30c91b0 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/FunctionBrowserView.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/FunctionBrowserView.java
@@ -18,7 +18,6 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetLibrary
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ISingleTypedNode;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
@@ -28,18 +27,11 @@ import org.eclipse.swt.widgets.Composite;
* @author Ryan Morse
* @author Henry Hughes
*/
-public class FunctionBrowserView extends BrowserView {
+public class FunctionBrowserView extends TapsetBrowserView {
public static final String ID = "org.eclipse.linuxtools.internal.systemtap.ui.ide.views.FunctionBrowserView"; //$NON-NLS-1$
- /**
- * Creates the UI on the given <code>Composite</code>
- */
- @Override
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
- FunctionParser.getInstance().addListener(viewUpdater);
- refresh();
- makeActions();
+ public FunctionBrowserView() {
+ super(FunctionParser.getInstance());
}
@Override
@@ -59,30 +51,17 @@ public class FunctionBrowserView extends BrowserView {
}
}
- /**
- * Refreshes the list of functions in the viewer.
- */
@Override
- public void refresh() {
- tree = TapsetLibrary.getFunctions();
- if (tree != null) {
- viewer.setInput(tree);
- }
+ protected void displayContents() {
+ setViewerInput(TapsetLibrary.getFunctions());
+ setRefreshable(true);
}
- /**
- * Wires up all of the actions for this browser, such as double and right click handlers.
- */
- private void makeActions() {
+ @Override
+ protected void makeActions() {
doubleClickAction = new FunctionBrowserAction(getSite().getWorkbenchWindow(), this);
viewer.addDoubleClickListener(doubleClickAction);
registerContextMenu("functionPopup"); //$NON-NLS-1$
}
- @Override
- public void dispose() {
- super.dispose();
- FunctionParser.getInstance().removeListener(viewUpdater);
- }
-
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/KernelBrowserView.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/KernelBrowserView.java
index 12be1d8025..ef0072f322 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/KernelBrowserView.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/KernelBrowserView.java
@@ -38,7 +38,6 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.UIJob;
/**
* The Kernel Source Browser module for the SystemTap GUI. This browser provides a list of kernel source
@@ -79,31 +78,10 @@ public class KernelBrowserView extends BrowserView {
kst.buildKernelTree(kernelSource, excluded);
}
if (monitor.isCanceled()) {
+ setViewerInput(null);
return Status.CANCEL_STATUS;
}
- UpdateKernelBrowserJob job = new UpdateKernelBrowserJob(kst);
- job.schedule();
- monitor.done();
- return Status.OK_STATUS;
- }
- }
-
- private class UpdateKernelBrowserJob extends UIJob {
- KernelSourceTree kst;
- public UpdateKernelBrowserJob(KernelSourceTree kst) {
- super(Localization.getString("KernelBrowserView.UpdateKernelBrowser")); //$NON-NLS-1$
- this.kst = kst;
- }
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- monitor.beginTask(Localization.getString("KernelBrowserView.UpdateKernelBrowser"), 100); //$NON-NLS-1$
- if (kst == null) {
- return Status.OK_STATUS;
- }
- tree = kst.getTree();
- viewer.setInput(tree);
- kst.dispose();
+ setViewerInput(kst.getTree());
monitor.done();
return Status.OK_STATUS;
}
@@ -119,10 +97,8 @@ public class KernelBrowserView extends BrowserView {
makeActions();
}
- /**
- * Wires up all of the actions for this browser, such as double and right click handlers.
- */
- private void makeActions() {
+ @Override
+ protected void makeActions() {
doubleClickAction = new KernelSourceAction(getSite().getWorkbenchWindow(), this);
viewer.addDoubleClickListener(doubleClickAction);
IDEPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
@@ -130,6 +106,10 @@ public class KernelBrowserView extends BrowserView {
@Override
protected Image getEntryImage(TreeNode treeObj) {
+ if (treeObj.toString().equals(
+ Localization.getString("KernelBrowserView.NoKernelSourceFound"))) { //$NON-NLS-1$
+ return null;
+ }
if (treeObj.toString().lastIndexOf('.') != -1) {
String item = treeObj.getData().toString();
if (item.endsWith(".c")) { //$NON-NLS-1$
@@ -150,10 +130,11 @@ public class KernelBrowserView extends BrowserView {
*/
@Override
public void refresh() {
+ displayLoadingMessage();
IPreferenceStore p = IDEPlugin.getDefault().getPreferenceStore();
String kernelSource = p.getString(IDEPreferenceConstants.P_KERNEL_SOURCE);
if (kernelSource == null || kernelSource.length() < 1) {
- showBrowserErrorMessage(Localization.getString("KernelBrowserView.NoKernelSourceFound")); //$NON-NLS-1$
+ displayMessage(Localization.getString("KernelBrowserView.NoKernelSourceFound")); //$NON-NLS-1$
return;
}
@@ -177,13 +158,12 @@ public class KernelBrowserView extends BrowserView {
error = true;
}
if (error) {
- showBrowserErrorMessage(Localization.getString("KernelBrowserView.KernelSourceDirNotFound")); //$NON-NLS-1$
+ displayMessage(Localization.getString("KernelBrowserView.KernelSourceDirNotFound")); //$NON-NLS-1$
return;
}
}
KernelRefreshJob refreshJob = new KernelRefreshJob(remote, kernelLocationURI, proxy, kernelSource);
- refreshJob.setUser(true);
refreshJob.setPriority(Job.SHORT);
refreshJob.schedule();
}
@@ -206,12 +186,6 @@ public class KernelBrowserView extends BrowserView {
return true;
}
- private void showBrowserErrorMessage(String message) {
- tree = new TreeNode("", "", false); //$NON-NLS-1$ //$NON-NLS-2$
- tree.add(new TreeNode("", message, false)); //$NON-NLS-1$
- viewer.setInput(tree);
- }
-
/**
* A <code>IPropertyChangeListener</code> that detects changes to the Kernel Source location
* and runs the <code>updateKernelSourceTree</code> method.
@@ -222,7 +196,7 @@ public class KernelBrowserView extends BrowserView {
if (event.getProperty().equals(IDEPreferenceConstants.P_KERNEL_SOURCE) ||
event.getProperty().equals(IDEPreferenceConstants.P_REMOTE_LOCAL_KERNEL_SOURCE) ||
event.getProperty().equals(IDEPreferenceConstants.P_EXCLUDED_KERNEL_SOURCE)) {
- viewUpdater.handleUpdateEvent();
+ refresh();
}
}
};
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/ProbeAliasBrowserView.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/ProbeAliasBrowserView.java
index 47f06df11c..b32d0b62f4 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/ProbeAliasBrowserView.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/ProbeAliasBrowserView.java
@@ -21,7 +21,6 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.Prob
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -33,18 +32,11 @@ import org.eclipse.ui.PlatformUI;
* @author Henry Hughes
* @author Ryan Morse
*/
-public class ProbeAliasBrowserView extends BrowserView {
+public class ProbeAliasBrowserView extends TapsetBrowserView {
public static final String ID = "org.eclipse.linuxtools.internal.systemtap.ui.ide.views.ProbeAliasBrowserView"; //$NON-NLS-1$
- /**
- * Creates the UI on the given <code>Composite</code>
- */
- @Override
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
- ProbeParser.getInstance().addListener(viewUpdater);
- refresh();
- makeActions();
+ public ProbeAliasBrowserView() {
+ super(ProbeParser.getInstance());
}
@Override
@@ -75,30 +67,17 @@ public class ProbeAliasBrowserView extends BrowserView {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
}
- /**
- * Refreshes the list of probe aliases in the viewer.
- */
@Override
- public void refresh() {
- tree = TapsetLibrary.getProbes();
- if (tree != null) {
- viewer.setInput(tree);
- }
+ protected void displayContents() {
+ setViewerInput(TapsetLibrary.getProbes());
+ setRefreshable(true);
}
- /**
- * Wires up all of the actions for this browser, such as double and right click handlers.
- */
- private void makeActions() {
+ @Override
+ protected void makeActions() {
doubleClickAction = new ProbeAliasAction(getSite().getWorkbenchWindow(), this);
viewer.addDoubleClickListener(doubleClickAction);
registerContextMenu("probePopup"); //$NON-NLS-1$
}
- @Override
- public void dispose() {
- super.dispose();
- ProbeParser.getInstance().removeListener(viewUpdater);
- }
-
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/RefreshHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/RefreshHandler.java
new file mode 100644
index 0000000000..4204471dd4
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/RefreshHandler.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.views;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.Assert;
+
+public class RefreshHandler extends AbstractHandler {
+ public static final String COMMAND_ID = "org.eclipse.linuxtools.systemtap.ui.ide.refreshView"; //$NON-NLS-1$
+ private BrowserView view;
+ private boolean active = true;
+
+ public RefreshHandler(final BrowserView view) {
+ Assert.isNotNull(view);
+ this.view = view;
+ }
+
+ /**
+ * Use this method to enable/disable the handler. Simpler than working with
+ * the standard ways to control toolbar button enablement.
+ * @param state
+ */
+ public void setActive(boolean state) {
+ active = state;
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) {
+ if (active) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ view.refresh();
+ }
+ }).start();
+ }
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ view = null;
+ }
+
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/TapsetBrowserView.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/TapsetBrowserView.java
new file mode 100644
index 0000000000..53003ddafe
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/TapsetBrowserView.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.views;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetLibrary;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetParser;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A base class for a {@link BrowserView} for displaying tapset information, which
+ * relies on the results of an externally-run {@link TapsetParser}. Contents are
+ * kept up-to-date with the status of the parser.
+ */
+public abstract class TapsetBrowserView extends BrowserView {
+ /**
+ * The parser that the contents of this view rely on.
+ */
+ private final TapsetParser parser;
+
+ protected JobChangeAdapter viewUpdater = new JobChangeAdapter() {
+
+ @Override
+ public void aboutToRun(IJobChangeEvent event) {
+ displayLoadingMessage();
+ }
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (event.getResult().isOK()) {
+ displayContents();
+ } else {
+ setViewerInput(null);
+ setRefreshable(true);
+ }
+ }
+
+ };
+
+ /**
+ * Create a new {@link BrowserView} for displaying tapset contents, which will
+ * be provided by an externally-run {@link TapsetParser}.
+ * @param job The parser used to obtain the tapset contents this view will display.
+ */
+ public TapsetBrowserView(TapsetParser parser) {
+ Assert.isNotNull(parser);
+ this.parser = parser;
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+
+ IStatus result = parser.getResult();
+ if (result != null && result.isOK()) {
+ displayContents();
+ } else {
+ displayLoadingMessage();
+ }
+
+ parser.addJobChangeListener(viewUpdater);
+ makeActions();
+ }
+
+ @Override
+ protected void displayLoadingMessage() {
+ super.displayLoadingMessage();
+ setRefreshable(false);
+ }
+
+ /**
+ * Populates the view with its contents obtained by the most recent run of {@link #parser}.
+ */
+ abstract protected void displayContents();
+
+ /**
+ * Rerun the tapset parser to refresh the list of both probes and functions.
+ */
+ @Override
+ protected void refresh() {
+ TapsetLibrary.runStapParser();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ parser.removeJobChangeListener(viewUpdater);
+ }
+
+}

Back to the top