diff options
Diffstat (limited to 'systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java')
-rw-r--r-- | systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TreeTapsetParser.java | 50 |
1 files changed, 42 insertions, 8 deletions
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 2009bd6762..e3b5f2ebe1 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 @@ -13,6 +13,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.core.runtime.Status; +import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin; import org.eclipse.linuxtools.systemtap.structures.TreeNode; /** @@ -21,6 +23,9 @@ import org.eclipse.linuxtools.systemtap.structures.TreeNode; */ public abstract class TreeTapsetParser extends TapsetParser { + protected TreeNode tree = null; + private TreeNode forcedTree = null; + protected TreeTapsetParser(String jobTitle) { super(jobTitle); } @@ -30,24 +35,53 @@ public abstract class TreeTapsetParser extends TapsetParser { * actions during the run; a call to super.run() is necessary. */ @Override - protected IStatus run(IProgressMonitor monitor) { - resetTree(); - return null; + protected final synchronized IStatus run(IProgressMonitor monitor) { + if (forcedTree != null) { + tree = forcedTree; + forcedTree = null; + return new Status(IStatus.OK, IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$ + } else { + tree = new TreeNode(null, false); + return runAction(monitor); + } + } + + protected IStatus runAction(IProgressMonitor monitor) { + return new Status(!monitor.isCanceled() ? IStatus.OK : IStatus.CANCEL, + IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$ } /** * @return The tree that this parser constructs. */ - abstract TreeNode getTree(); + public final synchronized TreeNode getTree() { + return tree; + } /** - * Clears & resets the tree that this parser constructs. + * Forcefully set this parser's tree, and subsequently fire update events + * that normally get called when a parse operation completes. + * @param tree The tree to put into this parser. */ - abstract protected void resetTree(); + final synchronized void setTree(TreeNode tree) { + String errorMessage = isValidTree(tree); + if (errorMessage != null) { + throw new IllegalArgumentException(errorMessage); + } + cancel(); + forcedTree = tree; + schedule(); + } /** - * Clean up everything from the last parse run. + * 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. */ - abstract void dispose(); + protected String isValidTree(TreeNode tree) { + return null; + } } |