From 6062f7a939b24a2bd99dbaa77935bb4a43266c39 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 14 Jul 2008 19:23:29 +0000 Subject: [PATCH] Bug 240525 clean up MIListThreadGroups to use the context properly. Since this class is new, we don't need to worry about an API change. --- .../command/commands/MIListThreadGroups.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIListThreadGroups.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIListThreadGroups.java index c56b1bbd01f..b16b495be8d 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIListThreadGroups.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIListThreadGroups.java @@ -12,7 +12,9 @@ package org.eclipse.dd.mi.service.command.commands; import java.util.ArrayList; +import org.eclipse.dd.dsf.datamodel.DMContexts; import org.eclipse.dd.dsf.datamodel.IDMContext; +import org.eclipse.dd.mi.service.IMIExecutionGroupDMContext; import org.eclipse.dd.mi.service.command.output.MIListThreadGroupsInfo; import org.eclipse.dd.mi.service.command.output.MIOutput; @@ -49,15 +51,7 @@ public class MIListThreadGroups extends MICommand { this(ctx, false); } - public MIListThreadGroups(IDMContext ctx, String threadGroupId) { - this(ctx, threadGroupId, false); - } - public MIListThreadGroups(IDMContext ctx, boolean listAll) { - this(ctx, "", listAll); //$NON-NLS-1$ - } - - public MIListThreadGroups(IDMContext ctx, String threadGroupId, boolean listAll) { super(ctx, "-list-thread-groups"); //$NON-NLS-1$ final ArrayList arguments = new ArrayList(); @@ -65,8 +59,12 @@ public class MIListThreadGroups extends MICommand { arguments.add("--available"); //$NON-NLS-1$ } - if (threadGroupId != null && threadGroupId.length() > 0) { - arguments.add(threadGroupId); + // If the context is a child of thread-group, use the thread-group name + // to list its children; if it is not, then we don't use any name to get + // the list of all thread-groups + IMIExecutionGroupDMContext threadGroup = DMContexts.getAncestorOfType(ctx, IMIExecutionGroupDMContext.class); + if (threadGroup != null) { + arguments.add(threadGroup.getGroupId()); } if (!arguments.isEmpty()) { @@ -78,5 +76,4 @@ public class MIListThreadGroups extends MICommand { public MIListThreadGroupsInfo getResult(MIOutput out) { return new MIListThreadGroupsInfo(out); } - }