Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2015-01-27 03:55:14 +0000
committerAlexander Kurtakov2015-02-04 12:12:29 +0000
commita9b1446426b640054fc4e27681f1e233aa8bddf7 (patch)
treea3514f556365eeab9f01c7974687a0bb66c8e8a7
parent1c076c65b0f2c51399326b1be75279766f32a441 (diff)
downloadorg.eclipse.linuxtools-a9b1446426b640054fc4e27681f1e233aa8bddf7.tar.gz
org.eclipse.linuxtools-a9b1446426b640054fc4e27681f1e233aa8bddf7.tar.xz
org.eclipse.linuxtools-a9b1446426b640054fc4e27681f1e233aa8bddf7.zip
Systemtap: Remove race conditions in TapsetLibrary updates.
Remove several race conditions between tapset updates and TapsetBrowser UI, as well as remove some null pointer accesses. Clean code where necessary and move the TapsetParsers to their own package. Change-Id: I0c06e6878a6d976e0db50eadfe84adc60c238014 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/40936 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java8
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties1
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java22
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java7
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java96
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeSettings.java14
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties7
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbeNodeData.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/FunctionParser.java (renamed from systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/FunctionParser.java)3
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/ProbeParser.java (renamed from systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ProbeParser.java)11
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/SharedParser.java (renamed from systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/SharedParser.java)7
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/TapsetParser.java (renamed from systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java)20
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/TreeTapsetParser.java (renamed from systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java)80
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/BrowserView.java3
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/FunctionBrowserView.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/ProbeAliasBrowserView.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/TapsetBrowserView.java42
20 files changed, 171 insertions, 166 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java
index bc42627cca..ce671fce41 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java
@@ -124,7 +124,6 @@ public class STPCompletionProcessorTest {
int offset = TEST_STP_SCRIPT.indexOf("//marker1");
STPCompletionProcessor completionProcessor = new STPCompletionProcessor();
- completionProcessor.waitForInitialization();
ICompletionProposal[] proposals = completionProcessor
.computeCompletionProposals(testDocument,
offset);
@@ -188,7 +187,6 @@ public class STPCompletionProcessorTest {
offset += prefix.length() - 1;
STPCompletionProcessor completionProcessor = new STPCompletionProcessor();
- completionProcessor.waitForInitialization();
ICompletionProposal[] proposals = completionProcessor
.computeCompletionProposals(testDocument,
offset);
@@ -245,7 +243,6 @@ public class STPCompletionProcessorTest {
offset += prefix.length();
STPCompletionProcessor completionProcessor = new STPCompletionProcessor();
- completionProcessor.waitForInitialization();
ICompletionProposal[] proposals = completionProcessor
.computeCompletionProposals(testDocument,
@@ -265,7 +262,6 @@ public class STPCompletionProcessorTest {
offset += prefix.length() - 1;
STPCompletionProcessor completionProcessor = new STPCompletionProcessor();
- completionProcessor.waitForInitialization();
ICompletionProposal[] proposals = completionProcessor
.computeCompletionProposals(testDocument,
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
index 80ef43c8a8..ce748bfbfc 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
@@ -375,10 +375,6 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
return Pattern.matches("\\W", Character.toString(c)); //$NON-NLS-1$
}
- public void waitForInitialization() {
- this.stpMetadataSingleton.waitForInitialization();
- }
-
@Override
public IContextInformation[] computeContextInformation(ITextViewer viewer,
int offset) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
index 8ba4a70b7c..8c3c7bc5ec 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
@@ -44,10 +44,6 @@ public final class STPMetadataSingleton {
return instance;
}
- public void waitForInitialization() {
- TapsetLibrary.waitForInitialization();
- }
-
public TreeNode[] getFunctionCompletions(String prefix) {
TreeNode node = TapsetLibrary.getFunctions();
return getMatchingChildren(node, prefix);
@@ -58,10 +54,6 @@ public final class STPMetadataSingleton {
String groupName = extractProbeGroupName(prefix);
for (TreeNode node : TapsetLibrary.getProbeCategoryNodes()) {
- if (node == null) {
- continue;
- }
-
TreeNode groupNode = node.getChildByName(groupName);
if (groupNode != null) {
node = groupNode;
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 25bc454047..05284d800c 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
@@ -67,6 +67,7 @@ KernelBrowserView.KernelSourceDirNotFound=Kernel Source Directory not found
KernelBrowserView.CouldNotInitializeTree=Could not initialize kernel source tree
BrowserView.Loading=Loading...
+BrowserView.TryRefresh=Refresh to update contents.
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/ManpageCacher.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
index d95115a9aa..12510b9d9c 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
@@ -12,6 +12,7 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
import java.util.HashMap;
+import java.util.Iterator;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
@@ -34,7 +35,19 @@ public class ManpageCacher {
}
public static synchronized void clear() {
- pages.clear();
+ clear(TapsetItemType.values());
+ }
+
+ public static synchronized void clear(TapsetItemType ...types) {
+ Iterator<String> keys = pages.keySet().iterator();
+ while (keys.hasNext()) {
+ for (TapsetItemType type : types) {
+ if (keys.next().startsWith(type.toString())) {
+ keys.remove();
+ break;
+ }
+ }
+ }
}
/**
@@ -108,10 +121,11 @@ public class ManpageCacher {
}
private static String createFullElement(TapsetItemType prefix, String ...elements) {
- String fullElement = prefix.toString();
+ StringBuilder fullElement = new StringBuilder();
+ fullElement.append(prefix.toString());
for (String element : elements) {
- fullElement += SPLITTER + element;
+ fullElement.append(SPLITTER + element);
}
- return fullElement;
+ return fullElement.toString();
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
index 3ec958ee0f..21cd75dc71 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
@@ -23,10 +23,9 @@ public class Messages extends NLS {
public static String ProbeParser_errorInitializingStaticProbes;
public static String ProbeParser_staticProbes;
public static String ProbeParser_aliasProbes;
- public static String ProbeParser_illegalArgMessage;
- public static String TapsetParser_CannotRunStapMessage;
- public static String TapsetParser_CannotRunRemoteStapMessage;
- public static String TapsetParser_ErrorRunningSystemtap;
+ public static String TapsetParser_ErrorCannotRunStap;
+ public static String TapsetParser_ErrorCannotRunRemoteStap;
+ public static String TapsetParser_ErrorInvalidTapsetTree;
public static String TapsetParser_RemoteCredentialErrorTitle;
public static String TapsetParser_RemoteCredentialErrorMessage;
static {
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 e3a96c7b83..3df7a9df11 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
@@ -16,8 +16,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.runtime.IStatus;
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;
@@ -27,6 +27,9 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
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.internal.systemtap.ui.ide.structures.tparsers.FunctionParser;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers.ProbeParser;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers.SharedParser;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.swt.widgets.Display;
@@ -40,8 +43,6 @@ import org.eclipse.ui.PlatformUI;
* @author Ryan Morse
*/
public final class TapsetLibrary {
- private static TreeNode functionTree = null;
- private static TreeNode probeTree = null;
private static FunctionParser functionParser = FunctionParser.getInstance();
private static ProbeParser probeParser = ProbeParser.getInstance();
@@ -49,15 +50,15 @@ public final class TapsetLibrary {
private static boolean initialized = false;
public static TreeNode getProbes() {
- return probeTree;
+ return probeParser.getTree();
}
public static TreeNode getStaticProbes() {
- return probeTree == null ? null : probeTree.getChildByName(Messages.ProbeParser_staticProbes);
+ return getProbes().getChildByName(Messages.ProbeParser_staticProbes);
}
public static TreeNode getProbeAliases() {
- return probeTree == null ? null : probeTree.getChildByName(Messages.ProbeParser_aliasProbes);
+ return getProbes().getChildByName(Messages.ProbeParser_aliasProbes);
}
public static TreeNode[] getProbeCategoryNodes() {
@@ -65,7 +66,7 @@ public final class TapsetLibrary {
}
public static TreeNode getFunctions() {
- return functionTree;
+ return functionParser.getTree();
}
/**
@@ -105,9 +106,9 @@ public final class TapsetLibrary {
// When turning off stored trees, reload the tapset contents directly.
TreeSettings.deleteTrees();
runStapParser();
- } else {
- // When turning on stored trees, store the current trees (if possible).
- TreeSettings.setTrees(functionTree, probeTree);
+ } else if (isReady()) {
+ // When turning on stored trees, store the current trees immediately.
+ TreeSettings.setTrees(getFunctions(), getProbes());
}
}
}
@@ -123,26 +124,28 @@ public final class TapsetLibrary {
private static JobChangeAdapter parseCompletionListener = new JobChangeAdapter() {
@Override
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 (event.getResult().isOK()) {
+ if (isReady() && IDEPlugin.getDefault().getPreferenceStore().
+ getBoolean(IDEPreferenceConstants.P_STORED_TREE)) {
+ TreeSettings.setTrees(getFunctions(), getProbes());
+ }
- if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_STORED_TREE)) {
- TreeSettings.setTrees(functionTree, probeTree);
- }
- synchronized (parser) {
- parser.notifyAll();
+ if (event.getJob() instanceof ProbeParser) {
+ ManpageCacher.clear(TapsetItemType.PROBE, TapsetItemType.PROBEVAR);
+ } else {
+ ManpageCacher.clear(TapsetItemType.FUNCTION);
+ }
}
}
};
+ private static boolean isReady() {
+ IStatus probeResult = probeParser.getLatestResult();
+ IStatus funcResult = functionParser.getLatestResult();
+ return probeResult != null && funcResult != null
+ && probeResult.isOK() && funcResult.isOK();
+ }
+
/**
* This method will trigger the appropriate parsing jobs
* to get the information directly from the files.
@@ -150,9 +153,7 @@ public final class TapsetLibrary {
*/
public static void runStapParser() {
stop();
- clearTrees();
SharedParser.getInstance().clearTapsetContents();
- ManpageCacher.clear();
functionParser.schedule();
probeParser.schedule();
}
@@ -173,20 +174,8 @@ public final class TapsetLibrary {
functionParser.runUpdate(additionArray, deletionArray);
}
- private static void clearTrees() {
- if (functionTree != null) {
- functionTree.dispose();
- functionTree = null;
- }
- if (probeTree != null) {
- probeTree.dispose();
- probeTree = null;
- }
- }
-
/**
- * This method will get all of the tree information from
- * the TreeSettings xml file.
+ * This method will get all of the tree information from the TreeSettings xml file.
*/
public static void readTreeFile() {
functionParser.setTree(TreeSettings.getFunctionTree());
@@ -304,35 +293,8 @@ public final class TapsetLibrary {
}
/**
- * Blocks the current thread until the parser has finished
- * parsing probes and functions.
- * @since 2.0
- */
- public static void waitForInitialization() {
- while (functionParser.getState() != Job.NONE) {
- try {
- synchronized (functionParser) {
- functionParser.wait(5000);
- }
- } catch (InterruptedException e) {
- break;
- }
- }
- while (probeParser.getState() != Job.NONE) {
- try {
- synchronized (probeParser) {
- probeParser.wait(5000);
- }
- } catch (InterruptedException e) {
- break;
- }
- }
- }
-
- /**
* This method will stop all running tapset parsers, and will block
* the calling thread until they have terminated.
- * @since 1.2
*/
public static void stop() {
functionParser.cancel();
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeSettings.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeSettings.java
index 55d5561521..43a3595865 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeSettings.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeSettings.java
@@ -86,7 +86,9 @@ public final class TreeSettings {
* @return <code>true</code> if the caching is successful.
*/
public static synchronized boolean setTrees(TreeNode functions, TreeNode probes) {
- if (functions == null || probes == null || !isTreeFileAvailable()) {
+ if (functions == null || probes == null
+ || functions == cachedFunctions || probes == cachedProbes
+ || !isTreeFileAvailable()) {
return false;
}
@@ -134,14 +136,8 @@ public final class TreeSettings {
}
private static void clearCachedTrees() {
- if (cachedFunctions != null) {
- cachedFunctions.dispose();
- cachedFunctions = null;
- }
- if (cachedProbes != null) {
- cachedProbes.dispose();
- cachedProbes = null;
- }
+ cachedFunctions = null;
+ cachedProbes = null;
}
/**
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
index 171e087383..59ac0e99e3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
@@ -15,9 +15,8 @@ ProbeParser_name=Probe Parser
ProbeParser_errorInitializingStaticProbes=Could not initialize static probe list
ProbeParser_staticProbes=Static Probes
ProbeParser_aliasProbes=Probe Aliases
-ProbeParser_illegalArgMessage=The first-level children of this tree must be two nodes named "Static Probes" and "Probe Alias" respectively.
-TapsetParser_CannotRunStapMessage=Cannot run SystemTap. Make sure SystemTap is installed.
-TapsetParser_CannotRunRemoteStapMessage=Cannot run SystemTap on the remote host {0}@{1}. Make sure SystemTap is installed on the remote machine.
-TapsetParser_ErrorRunningSystemtap=Error Running SystemTap
+TapsetParser_ErrorCannotRunStap=Cannot run SystemTap. Make sure SystemTap is installed.
+TapsetParser_ErrorCannotRunRemoteStap=Cannot run SystemTap on the remote host {0}@{1}. Make sure SystemTap is installed on the remote machine.
+TapsetParser_ErrorInvalidTapsetTree=The cache of tapset trees is corrupt. Try refreshing either the Probe Alias view or the Function view.
TapsetParser_RemoteCredentialErrorTitle=Remote Login Error
TapsetParser_RemoteCredentialErrorMessage=Unable to login to the remote host for loading tapset contents. Edit the login credentials now?
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java
index 49e68a504d..069e66c9ce 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.FunctionParser;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers.FunctionParser;
/**
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbeNodeData.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbeNodeData.java
index 7f8a20a6b7..d1b05382fd 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbeNodeData.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbeNodeData.java
@@ -13,7 +13,7 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata;
import java.text.MessageFormat;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.ProbeParser;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers.ProbeParser;
public class ProbeNodeData implements ISearchableNode {
static final String ID = "ProbeNodeData"; //$NON-NLS-1$
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/tparsers/FunctionParser.java
index 22bfadc33f..00f6218f15 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/tparsers/FunctionParser.java
@@ -9,7 +9,7 @@
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
*******************************************************************************/
-package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers;
import java.text.MessageFormat;
import java.util.Scanner;
@@ -19,6 +19,7 @@ import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.CommentRemover;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.Messages;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData;
import org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode;
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/tparsers/ProbeParser.java
index 6e48682de0..0fc35ae0bb 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/tparsers/ProbeParser.java
@@ -9,7 +9,7 @@
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
*******************************************************************************/
-package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.Messages;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData;
import org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode;
@@ -60,10 +61,10 @@ public final class ProbeParser extends TreeTapsetParser {
* be two nodes respectively named "Static Probes" and "Probe Alias".
*/
@Override
- protected String isValidTree(TreeNode tree) {
- return tree.getChildByName(Messages.ProbeParser_staticProbes) != null
- && tree.getChildByName(Messages.ProbeParser_aliasProbes) != null
- ? null : Messages.ProbeParser_illegalArgMessage;
+ protected boolean isValidTree(TreeNode tree) {
+ return super.isValidTree(tree) &&
+ tree.getChildByName(Messages.ProbeParser_staticProbes) != null
+ && tree.getChildByName(Messages.ProbeParser_aliasProbes) != null;
}
/**
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/SharedParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/SharedParser.java
index b59cb3ac68..af249412f2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/SharedParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/SharedParser.java
@@ -9,13 +9,14 @@
* Red Hat - initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.Messages;
/**
* A helper class for performing tapset-loading operations,
@@ -82,7 +83,7 @@ public final class SharedParser extends TapsetParser {
* Clear the cached tapset contents, so that the next call to {@link #getTapsetContents()}
* will be guaranteed to use a new call of stap to gather up-to-date tapset contents.
*/
- synchronized void clearTapsetContents() {
+ public synchronized void clearTapsetContents() {
tapsetContents = null;
}
@@ -102,7 +103,7 @@ public final class SharedParser extends TapsetParser {
protected IStatus run(IProgressMonitor monitor) {
return createStatus(verifyRunResult(runAction()));
}
-
+
private String runAction() {
String contents = runStap(STAP_OPTIONS, STAP_DUMMYPROBE, false);
if (verifyRunResult(contents) == IStatus.OK) {
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/tparsers/TapsetParser.java
index e2307a1598..f0727afef6 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/tparsers/TapsetParser.java
@@ -9,7 +9,7 @@
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
*******************************************************************************/
-package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers;
import java.io.File;
import java.io.IOException;
@@ -25,6 +25,7 @@ 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.internal.systemtap.ui.ide.structures.Messages;
import org.eclipse.linuxtools.systemtap.structures.runnable.StringStreamGobbler;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.linuxtools.systemtap.ui.consolelog.preferences.ConsoleLogPreferenceConstants;
@@ -67,25 +68,34 @@ public abstract class TapsetParser extends Job {
}
/**
- * Generates a {@link Status} with the provided severity.
+ * Generates a {@link Status} with the provided severity,
+ * and given an appropriate error message.
*/
protected IStatus createStatus(int severity) {
String message;
+ IPreferenceStore ps = IDEPlugin.getDefault().getPreferenceStore();
switch (severity) {
case IStatus.ERROR:
- if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES)) {
+ if (ps.getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES)) {
IPreferenceStore p = ConsoleLogPlugin.getDefault().getPreferenceStore();
message = MessageFormat.format(
- Messages.TapsetParser_CannotRunRemoteStapMessage,
+ Messages.TapsetParser_ErrorCannotRunRemoteStap,
p.getString(ConsoleLogPreferenceConstants.SCP_USER),
p.getString(ConsoleLogPreferenceConstants.HOST_NAME));
} else {
- message = Messages.TapsetParser_CannotRunStapMessage;
+ message = Messages.TapsetParser_ErrorCannotRunStap;
}
break;
default:
message = ""; //$NON-NLS-1$
}
+ return createStatus(severity, message);
+ }
+
+ /**
+ * Generates a {@link Status} with the provided severity and message.
+ */
+ protected IStatus createStatus(int severity, String message) {
return new Status(severity, IDEPlugin.PLUGIN_ID, message);
}
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/tparsers/TreeTapsetParser.java
index c339b964dd..7e2e1449c1 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/tparsers/TreeTapsetParser.java
@@ -9,10 +9,13 @@
* Red Hat - initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.Messages;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
/**
@@ -32,7 +35,9 @@ public abstract class TreeTapsetParser extends TapsetParser {
}
}
- protected TreeNode tree = null;
+ private final Object lock = new Object();
+
+ protected TreeNode tree = new TreeNode(null, false);
private TreeNode forcedTree = null;
private TapsetChanges tapsetChanges = null;
@@ -41,22 +46,60 @@ public abstract class TreeTapsetParser extends TapsetParser {
}
/**
+ * Adds a listener to this job and returns this job's latest result, which will
+ * not be pre-empted by another job completing. Clients should call this instead of
+ * {@link #addJobChangeListener(IJobChangeListener)} only when knowing the previous
+ * job result is required for synchronization purposes (such as UI updating).
+ * @param listener the listener to be added.
+ * @return The result of {@link #getLatestResult()}.
+ * @see #addJobChangeListener(IJobChangeListener)
+ * @see #getLatestResult()
+ */
+ public IStatus safelyAddJobChangeListener(IJobChangeListener listener) {
+ synchronized (lock) {
+ super.addJobChangeListener(listener);
+ return getLatestResult();
+ }
+ }
+
+ /**
+ * Gets the result of the last job that was started, rather than the last job
+ * that was finished. This should only be used when a {@link IJobChangeListener}
+ * is already registered with this job, so true job completion can be caught.
+ * @return The result of this job's last run, or null if this job has either
+ * never finished running or is currently running.
+ * @see #getResult()
+ */
+ public IStatus getLatestResult() {
+ synchronized (lock) {
+ return getState() != Job.RUNNING ? getResult() : null;
+ }
+ }
+
+ /**
* 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 final synchronized IStatus run(IProgressMonitor monitor) {
+ IStatus result;
if (forcedTree != null) {
- tapsetChanges = null;
- tree = forcedTree;
+ if (isValidTree(forcedTree)) {
+ tree = forcedTree;
+ result = createStatus(IStatus.OK);
+ } else {
+ result = createStatus(IStatus.ERROR, Messages.TapsetParser_ErrorInvalidTapsetTree);
+ }
forcedTree = null;
- return createStatus(IStatus.OK);
+ } else if (tapsetChanges != null) {
+ result = performUpdate(monitor);
+ } else {
+ tree = new TreeNode(null, false);
+ result = createStatus(runAction(monitor));
}
- if (tapsetChanges != null) {
- return performUpdate(monitor);
+ synchronized (lock) {
+ return result;
}
- tree = new TreeNode(null, false);
- return createStatus(runAction(monitor));
}
/**
@@ -67,7 +110,7 @@ public abstract class TreeTapsetParser extends TapsetParser {
protected abstract int runAction(IProgressMonitor monitor);
/**
- * After adding / removing tapsets, scheduled the job that
+ * After adding / removing tapsets, schedule the job that
* loads in / discards the tapsets that were added / removed.
* @param additions The list of added tapset directories.
* @param deletions The list of removed tapset directories.
@@ -123,9 +166,9 @@ public abstract class TreeTapsetParser extends TapsetParser {
protected abstract int addTapsets(String tapsetContents, String[] additions, IProgressMonitor monitor);
/**
- * @return The tree that this parser constructs.
+ * @return The tree that this parser constructs. Guaranteed not be null.
*/
- public final synchronized TreeNode getTree() {
+ public final TreeNode getTree() {
return tree;
}
@@ -134,11 +177,7 @@ public abstract class TreeTapsetParser extends TapsetParser {
* that normally get called when a parse operation completes.
* @param tree The tree to put into this parser.
*/
- final synchronized void setTree(TreeNode tree) {
- String errorMessage = isValidTree(tree);
- if (errorMessage != null) {
- throw new IllegalArgumentException(errorMessage);
- }
+ public final void setTree(TreeNode tree) {
cancel();
forcedTree = tree;
schedule();
@@ -148,11 +187,10 @@ public abstract class TreeTapsetParser extends TapsetParser {
* Check if the provided tree a valid tree for this parser.
* Called internally by {@link #setTree(TreeNode)}.
* @param tree The tree to check for validity.
- * @return <code>null</code> if the tree is valid; otherwise,
- * an error message signifying why the tree is invalid.
+ * @return <code>true</code> if the tree is valid, <code>false</code> otherwise.
*/
- protected String isValidTree(TreeNode tree) {
- return null;
+ protected boolean isValidTree(TreeNode tree) {
+ return tree != null;
}
}
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 046fbf0138..fab6bf6993 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
@@ -106,7 +106,8 @@ public abstract class BrowserView extends ViewPart {
@Override
public Image getImage(Object obj) {
TreeNode treeObj = (TreeNode) obj;
- if (treeObj.toString().equals(Localization.getString("BrowserView.Loading"))) { //$NON-NLS-1$
+ if (treeObj.toString().equals(Localization.getString("BrowserView.Loading")) //$NON-NLS-1$
+ || treeObj.toString().equals(Localization.getString("BrowserView.TryRefresh"))) { //$NON-NLS-1$
return null;
}
return getEntryImage(treeObj);
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 67d30c91b0..2a8ace954d 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
@@ -13,9 +13,9 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.views;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.FunctionBrowserAction;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.FunctionParser;
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.internal.systemtap.ui.ide.structures.tparsers.FunctionParser;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.swt.graphics.Image;
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 b32d0b62f4..c0eb90d791 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
@@ -15,10 +15,10 @@ import java.util.List;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.ProbeAliasAction;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.ProbeParser;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetLibrary;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers.ProbeParser;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
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
index 6fed41f592..c084934144 100644
--- 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
@@ -15,8 +15,10 @@ 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.Localization;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetLibrary;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetParser;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers.TapsetParser;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.tparsers.TreeTapsetParser;
import org.eclipse.swt.widgets.Composite;
/**
@@ -28,20 +30,21 @@ public abstract class TapsetBrowserView extends BrowserView {
/**
* The parser that the contents of this view rely on.
*/
- private final TapsetParser parser;
+ private final TreeTapsetParser parser;
+ private final Object lock = new Object();
protected JobChangeAdapter viewUpdater = new JobChangeAdapter() {
@Override
public void aboutToRun(IJobChangeEvent event) {
- synchronized (TapsetBrowserView.this) {
+ synchronized (lock) {
displayLoadingMessage();
}
}
@Override
public void done(IJobChangeEvent event) {
- synchronized (TapsetBrowserView.this) {
+ synchronized (lock) {
if (event.getResult().isOK()) {
displayContents();
} else {
@@ -54,10 +57,10 @@ public abstract class TapsetBrowserView extends BrowserView {
/**
* Creates a new {@link BrowserView} for displaying tapset contents, which will
- * be provided by an externally-run {@link TapsetParser}.
+ * be provided by an externally-run {@link TreeTapsetParser}.
* @param job The parser used to obtain the tapset contents this view will display.
*/
- public TapsetBrowserView(TapsetParser parser) {
+ public TapsetBrowserView(TreeTapsetParser parser) {
Assert.isNotNull(parser);
this.parser = parser;
}
@@ -65,25 +68,20 @@ public abstract class TapsetBrowserView extends BrowserView {
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
- parser.addJobChangeListener(viewUpdater);
- updateContents();
makeActions();
- }
- /**
- * Updates the contents of this view without using the job listener.
- * Use this when the result of the parser may be missed by the listener.
- */
- private synchronized void updateContents() {
- IStatus result = parser.getResult();
- if (result != null) {
- if (result.isOK()) {
- displayContents();
+ // Add listener and display initial contents based on the state of the last parser job.
+ synchronized (lock) {
+ IStatus result = parser.safelyAddJobChangeListener(viewUpdater);
+ if (result != null) {
+ if (result.isOK()) {
+ displayContents();
+ } else {
+ displayCancelContents();
+ }
} else {
- displayCancelContents();
+ displayLoadingMessage();
}
- } else {
- displayLoadingMessage();
}
}
@@ -108,7 +106,7 @@ public abstract class TapsetBrowserView extends BrowserView {
* Automatically called whenever a parse job fails; should not be called by clients.
*/
protected void displayCancelContents() {
- setViewerInput(null);
+ displayMessage(Localization.getString("BrowserView.TryRefresh")); //$NON-NLS-1$
setRefreshable(true);
}

Back to the top