[dsf-gdb] service which requires multiple commands [message #1726878] |
Thu, 17 March 2016 08:41 |
florent Vion Messages: 2 Registered: March 2016 |
Junior Member |
|
|
Hi,
I develop plugins installed on a CDT Eclipse to manage my own debug session.
I am based on the dsf plugin example (org.eclipse.cdt.examples.dsf.gdb).
I create a service via a service factory which implements several commands (each command needs to be executed in a chain).
My service is called via a button and thus via an handler.
For the time being, in order to execute commands one after the others, in my handler I call the next command in the "handleCompleted" method of the previous one. Like this:
MyHandler.java
public class MyHandler implements IMyHandler {
...
@Override
public boolean execute(final IDebugCommandRequest request) {
...
executeCommandA(context, request);
...
}
// execute the first command of my service
private void executeCommandA(final Optional<ICommandControlDMContext> context,
final IDebugCommandRequest request) {
fExecutor.execute(new DsfRunnable() {
@Override
public void run() {
...
myService.doCommandA(context.get(), new DataRequestMonitor<Boolean>(fExecutor, null) {
@Override
protected void handleCompleted() {
if (isSuccess()) {
...
executeCommandB(context, request);
}
request.done();
}
});
}
}
}
// execute the second command of my service
private void executeCommandB(final Optional<ICommandControlDMContext> context,
final IDebugCommandRequest request) {
fExecutor.execute(new DsfRunnable() {
@Override
public void run() {
...
myService.doCommandB(context.get(), new DataRequestMonitor<String>(fExecutor, null) {
@Override
protected void handleCompleted() {
if (isSuccess()) {
...
executeCommandC(context, request);
}
request.done();
}
});
}
}
}
...
Each "doCommandX" of my service executes the associated command line via a MIInterpreterExecConsole.
Even if it works, I strongly suspect that I am not using the proper process to manage my commands. Am I right?
And I think I should use the class Sequence (org.eclipse.cdt.dsf.concurrent) but I'm not sure to truly understand how it works.
Cheers
Flo
|
|
|
Powered by
FUDForum. Page generated in 0.03442 seconds