mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +02:00
[274414] Use a Job to prevent locking the UI
This commit is contained in:
parent
4a63d165b2
commit
ec8730ff11
1 changed files with 77 additions and 49 deletions
|
@ -49,6 +49,7 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.IStatusHandler;
|
import org.eclipse.debug.core.IStatusHandler;
|
||||||
|
|
||||||
|
@ -306,57 +307,84 @@ public class FinalLaunchSequence extends Sequence {
|
||||||
* Specify the core file to be debugged if we are launching such a debug session.
|
* Specify the core file to be debugged if we are launching such a debug session.
|
||||||
*/
|
*/
|
||||||
new Step() {
|
new Step() {
|
||||||
private String promptForCoreFilePath() throws CoreException {
|
// Need a job because prompter.handleStatus will block
|
||||||
IStatus promptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200/*STATUS_HANDLER_PROMPT*/, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
class PromptForCoreJob extends Job {
|
||||||
IStatus filePrompt = new Status(IStatus.INFO, "org.eclipse.cdt.dsf.gdb.ui", 1001, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
DataRequestMonitor<String> fRequestMonitor;
|
||||||
// consult a status handler
|
|
||||||
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
|
|
||||||
if (prompter != null) {
|
|
||||||
Object result = prompter.handleStatus(filePrompt, null);
|
|
||||||
if (result instanceof String) {
|
|
||||||
return (String)result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
|
||||||
if (fSessionType == SessionType.CORE) {
|
|
||||||
Exception exception = null;
|
|
||||||
String coreFile;
|
|
||||||
try {
|
|
||||||
coreFile = fLaunch.getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, ""); //$NON-NLS-1$
|
|
||||||
|
|
||||||
if (coreFile != null) {
|
public PromptForCoreJob(String name, DataRequestMonitor<String> rm) {
|
||||||
if (coreFile.length() == 0) {
|
super(name);
|
||||||
coreFile = promptForCoreFilePath();
|
fRequestMonitor = rm;
|
||||||
if (coreFile == null || coreFile.length()== 0) {
|
}
|
||||||
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get core file path", exception)); //$NON-NLS-1$
|
|
||||||
requestMonitor.done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new MITargetSelectCore(fCommandControl.getContext(), coreFile),
|
|
||||||
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) {
|
|
||||||
@Override
|
|
||||||
protected void handleSuccess() {
|
|
||||||
requestMonitor.done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
exception = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get core file path", exception)); //$NON-NLS-1$
|
@Override
|
||||||
requestMonitor.done();
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
} else {
|
final IStatus promptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200/*STATUS_HANDLER_PROMPT*/, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
requestMonitor.done();
|
final IStatus filePrompt = new Status(IStatus.INFO, "org.eclipse.cdt.dsf.gdb.ui", 1001, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
}
|
// consult a status handler
|
||||||
}},
|
final IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
|
||||||
|
|
||||||
|
final Status NO_CORE_STATUS = new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1,
|
||||||
|
LaunchMessages.getString("LocalCDILaunchDelegate.6"), //$NON-NLS-1$
|
||||||
|
null);
|
||||||
|
|
||||||
|
if (prompter == null) {
|
||||||
|
fRequestMonitor.setStatus(NO_CORE_STATUS);
|
||||||
|
fRequestMonitor.done();
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object result = prompter.handleStatus(filePrompt, null);
|
||||||
|
if (result instanceof String) {
|
||||||
|
fRequestMonitor.setData((String)result);
|
||||||
|
} else {
|
||||||
|
fRequestMonitor.setStatus(NO_CORE_STATUS);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
fRequestMonitor.setStatus(NO_CORE_STATUS);
|
||||||
|
}
|
||||||
|
fRequestMonitor.done();
|
||||||
|
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@Override
|
||||||
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
|
if (fSessionType == SessionType.CORE) {
|
||||||
|
try {
|
||||||
|
String coreFile = fLaunch.getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, ""); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (coreFile.length() == 0) {
|
||||||
|
new PromptForCoreJob(
|
||||||
|
"Prompt for core file", //$NON-NLS-1$
|
||||||
|
new DataRequestMonitor<String>(getExecutor(), requestMonitor) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
String newCoreFile = getData();
|
||||||
|
if (newCoreFile == null || newCoreFile.length()== 0) {
|
||||||
|
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get core file path", null)); //$NON-NLS-1$
|
||||||
|
requestMonitor.done();
|
||||||
|
} else {
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new MITargetSelectCore(fCommandControl.getContext(), newCoreFile),
|
||||||
|
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).schedule();
|
||||||
|
} else {
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new MITargetSelectCore(fCommandControl.getContext(), coreFile),
|
||||||
|
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor));
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get core file path", e)); //$NON-NLS-1$
|
||||||
|
requestMonitor.done();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
requestMonitor.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
/*
|
/*
|
||||||
* If remote debugging, connect to target.
|
* If remote debugging, connect to target.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue