1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 235426

Make the FinalLaunchSequence class easily replaceable for someone that wants to extend the launch
This commit is contained in:
Marc Khouzam 2008-06-03 18:33:34 +00:00
parent 152ee1c3f1
commit 33ac8da64e
3 changed files with 15 additions and 10 deletions

View file

@ -18,7 +18,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.dd.gdb.internal.provisional.launching.FinalLaunchSequence;
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages; import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin; import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.debug.core.IStatusHandler; import org.eclipse.debug.core.IStatusHandler;
@ -39,7 +38,7 @@ public class ProcessPrompter implements IStatusHandler {
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
* java.lang.Object) * java.lang.Object)
*/ */
public Object handleStatus(IStatus status, Object source) throws CoreException { public Object handleStatus(IStatus status, Object processList) throws CoreException {
Shell shell = GdbUIPlugin.getShell(); Shell shell = GdbUIPlugin.getShell();
if (shell == null) { if (shell == null) {
IStatus error = new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(), IStatus error = new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(),
@ -48,8 +47,7 @@ public class ProcessPrompter implements IStatusHandler {
throw new CoreException(error); throw new CoreException(error);
} }
// Get the process list from the FinalLaunchSequence IProcessInfo[] plist = (IProcessInfo[])processList;
IProcessInfo[] plist = ((FinalLaunchSequence)source).getProcessList();
if (plist == null) { if (plist == null) {
MessageDialog.openError( MessageDialog.openError(
shell, shell,

View file

@ -272,7 +272,7 @@ public class FinalLaunchSequence extends Sequence {
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
try { try {
Object result = prompter.handleStatus(processPromptStatus, FinalLaunchSequence.this); Object result = prompter.handleStatus(processPromptStatus, fProcessList);
if (result instanceof Integer) { if (result instanceof Integer) {
rm.setData((Integer)result); rm.setData((Integer)result);
} else { } else {
@ -389,8 +389,5 @@ public class FinalLaunchSequence extends Sequence {
public Step[] getSteps() { public Step[] getSteps() {
return fSteps; return fSteps;
} }
public IProcessInfo[] getProcessList() { return fProcessList; }
} }

View file

@ -37,6 +37,8 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
import org.eclipse.dd.dsf.concurrent.Sequence;
import org.eclipse.dd.dsf.concurrent.ThreadSafe; import org.eclipse.dd.dsf.concurrent.ThreadSafe;
import org.eclipse.dd.dsf.debug.sourcelookup.DsfSourceLookupDirector; import org.eclipse.dd.dsf.debug.sourcelookup.DsfSourceLookupDirector;
import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.DsfSession;
@ -131,8 +133,8 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate
launch.addInferiorProcess(exePath.lastSegment()); launch.addInferiorProcess(exePath.lastSegment());
// Create and invoke the final launch sequence to setup GDB // Create and invoke the final launch sequence to setup GDB
final FinalLaunchSequence finalLaunchSequence = final Sequence finalLaunchSequence =
new FinalLaunchSequence(launch.getSession().getExecutor(), launch, sessionType, attach); getFinalLaunchSequence(launch.getSession().getExecutor(), launch, sessionType, attach);
launch.getSession().getExecutor().execute(finalLaunchSequence); launch.getSession().getExecutor().execute(finalLaunchSequence);
try { try {
finalLaunchSequence.get(); finalLaunchSequence.get();
@ -143,6 +145,14 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate
} }
} }
/*
* This method can be overridden by subclasses to allow to change the final launch sequence without
* having to change the entire GdbLaunchDelegate
*/
protected Sequence getFinalLaunchSequence(DsfExecutor executor, GdbLaunch launch, SessionType type, boolean attach) {
return new FinalLaunchSequence(executor, launch, type, attach);
}
private SessionType getSessionType(ILaunchConfiguration config) { private SessionType getSessionType(ILaunchConfiguration config) {
try { try {
String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ); String debugMode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );