Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetHandler.java53
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetMenu.java10
2 files changed, 26 insertions, 37 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetHandler.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetHandler.java
index 7a411f6f8..1f431c9ac 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetHandler.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetHandler.java
@@ -19,35 +19,12 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.tcf.internal.debug.ui.model.TCFNode;
import org.eclipse.tcf.internal.debug.ui.model.TCFNodeExecContext;
-import org.eclipse.tcf.internal.debug.ui.preferences.TCFPreferences;
import org.eclipse.tcf.services.IContextReset;
import org.eclipse.tcf.util.TCFDataCache;
import org.eclipse.tcf.util.TCFTask;
public class ResetHandler extends AbstractHandler {
- private String getDefaultResetType(final TCFNodeExecContext exec) {
- return new TCFTask<String>(exec.getChannel()) {
- @Override
- public void run() {
- TCFDataCache<Collection<Map<String, Object>>> cache = exec.getResetCapabilities();
- if (!cache.validate(this)) {
- return;
- }
- Collection<Map<String, Object>> caps = cache.getData();
- if (caps == null || caps.isEmpty()) {
- done(null);
- }
- else {
- @SuppressWarnings("unchecked")
- Map<String, Object>[] items = caps.toArray(new Map[caps.size()]);
- String type = items[0].get(IContextReset.CAPABILITY_TYPE).toString();
- done(type);
- }
- }
- }.getE();
- }
-
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = DebugUITools.getDebugContextForEvent(event);
@@ -55,16 +32,32 @@ public class ResetHandler extends AbstractHandler {
IStructuredSelection ssel = (IStructuredSelection)selection;
Object obj = ssel.getFirstElement();
if (obj instanceof TCFNode) {
+ final String param_type = event.getParameter("org.eclipse.tcf.debug.ui.commands.reset.param.type");
TCFNode node = (TCFNode)obj;
while (node != null) {
if (node instanceof TCFNodeExecContext) {
- TCFNodeExecContext exec = (TCFNodeExecContext)node;
- String type = event.getParameter("org.eclipse.tcf.debug.ui.commands.reset.param.type");
- if (type == null) type = getDefaultResetType(exec);
- boolean suspend = exec.getModel().getSuspendAfterReset();
- Map<String, Object> params = new HashMap<String, Object>();
- if (suspend) params.put(IContextReset.PARAM_SUSPEND, true);
- exec.reset(type, params);
+ final TCFNodeExecContext exec = (TCFNodeExecContext)node;
+ new TCFTask<Boolean>() {
+ @Override
+ public void run() {
+ String type = param_type;
+ if (type == null) {
+ TCFDataCache<Collection<Map<String, Object>>> cache = exec.getResetCapabilities();
+ if (!cache.validate(this)) return;
+ Collection<Map<String, Object>> caps = cache.getData();
+ if (caps != null && !caps.isEmpty()) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object>[] items = caps.toArray(new Map[caps.size()]);
+ type = items[0].get(IContextReset.CAPABILITY_TYPE).toString();
+ }
+ }
+ boolean suspend = exec.getModel().getSuspendAfterReset();
+ Map<String, Object> params = new HashMap<String, Object>();
+ if (suspend) params.put(IContextReset.PARAM_SUSPEND, true);
+ exec.reset(type, params);
+ done(true);
+ }
+ }.getE();
break;
}
node = node.getParent();
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetMenu.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetMenu.java
index fef57c404..43cdd46cf 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetMenu.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ResetMenu.java
@@ -79,18 +79,14 @@ public class ResetMenu extends CompoundContributionItem implements IWorkbenchCon
@Override
public void run() {
TCFDataCache<Collection<Map<String, Object>>> cache = exec.getResetCapabilities();
- if (!cache.validate(this)) {
- return;
- }
- Collection<Map<String, Object>> capabilities = cache.getData();
- done(capabilities);
+ if (!cache.validate(this)) return;
+ done(cache.getData());
}
}.getE();
items = new IContributionItem[capabilities.size()];
int i = 0;
for (Map<String, Object> c : capabilities) {
- items[i] = makeContributionItem(exec, c);
- ++i;
+ items[i++] = makeContributionItem(exec, c);
}
break;
}

Back to the top