mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
Added expression service (bug# 159696)
Fixed updating the launch state upon startup and shutdown.
This commit is contained in:
parent
6c6f7978db
commit
750c30a128
3 changed files with 93 additions and 30 deletions
|
@ -38,6 +38,17 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
|||
public class StandardLaunchRootLayoutNode extends AbstractVMRootLayoutNode
|
||||
implements IVMRootLayoutNode
|
||||
{
|
||||
public static class LaunchesEvent {
|
||||
public enum Type { ADDED, REMOVED, CHANGED, TERMINATED };
|
||||
public final ILaunch[] fLaunches;
|
||||
public final Type fType;
|
||||
|
||||
public LaunchesEvent(ILaunch[] launches, Type type) {
|
||||
fLaunches = launches;
|
||||
fType = type;
|
||||
}
|
||||
}
|
||||
|
||||
final private ILaunch fLaunch;
|
||||
|
||||
public StandardLaunchRootLayoutNode(AbstractVMProvider provider, ILaunch launch) {
|
||||
|
@ -60,7 +71,21 @@ public class StandardLaunchRootLayoutNode extends AbstractVMRootLayoutNode
|
|||
return IModelDelta.NO_CHANGE;
|
||||
}
|
||||
}
|
||||
return super.getDeltaFlags(e);
|
||||
int flags = 0;
|
||||
if (e instanceof LaunchesEvent) {
|
||||
LaunchesEvent le = (LaunchesEvent)e;
|
||||
for (ILaunch launch : le.fLaunches) {
|
||||
if (fLaunch == launch) {
|
||||
if (le.fType == LaunchesEvent.Type.CHANGED) {
|
||||
flags = IModelDelta.STATE | IModelDelta.CONTENT;
|
||||
} else if (le.fType == LaunchesEvent.Type.TERMINATED) {
|
||||
flags = IModelDelta.STATE | IModelDelta.CONTENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flags | super.getDeltaFlags(e);
|
||||
}
|
||||
|
||||
public void createDelta(Object event, final GetDataDone<IModelDelta> done) {
|
||||
|
@ -74,19 +99,37 @@ public class StandardLaunchRootLayoutNode extends AbstractVMRootLayoutNode
|
|||
final VMDelta viewRootDelta = new VMDelta(manager, 0, IModelDelta.NO_CHANGE, launchList.size());
|
||||
final VMDelta rootDelta = viewRootDelta.addNode(getRootObject(), launchList.indexOf(fLaunch), IModelDelta.NO_CHANGE);
|
||||
|
||||
final Map<IVMLayoutNode,Integer> childNodeDeltas = getChildNodesWithDeltas(event);
|
||||
assert childNodeDeltas.size() != 0 : "Caller should make sure that there are deltas for given event."; //$NON-NLS-1$
|
||||
|
||||
callChildNodesToBuildDelta(
|
||||
childNodeDeltas, rootDelta, event,
|
||||
new Done() {
|
||||
public void run() {
|
||||
if (isDisposed()) return;
|
||||
if (propagateError(getExecutor(), done, "Failed to create delta.")); //$NON-NLS-1$
|
||||
done.setData(viewRootDelta);
|
||||
getExecutor().execute(done);
|
||||
// Generate delta for launch node.
|
||||
if (event instanceof LaunchesEvent) {
|
||||
LaunchesEvent le = (LaunchesEvent)event;
|
||||
for (ILaunch launch : le.fLaunches) {
|
||||
if (fLaunch == launch) {
|
||||
if (le.fType == LaunchesEvent.Type.CHANGED) {
|
||||
rootDelta.addFlags(IModelDelta.STATE | IModelDelta.CONTENT);
|
||||
} else if (le.fType == LaunchesEvent.Type.TERMINATED) {
|
||||
rootDelta.addFlags(IModelDelta.STATE | IModelDelta.CONTENT);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Call the child nodes to generate their delta.
|
||||
final Map<IVMLayoutNode,Integer> childNodeDeltas = getChildNodesWithDeltas(event);
|
||||
if (childNodeDeltas.size() != 0) {
|
||||
callChildNodesToBuildDelta(
|
||||
childNodeDeltas, rootDelta, event,
|
||||
new Done() {
|
||||
public void run() {
|
||||
if (isDisposed()) return;
|
||||
if (propagateError(getExecutor(), done, "Failed to create delta.")); //$NON-NLS-1$
|
||||
done.setData(viewRootDelta);
|
||||
getExecutor().execute(done);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
done.setData(viewRootDelta);
|
||||
getExecutor().execute(done);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getRootObject() {
|
||||
|
|
|
@ -53,6 +53,10 @@ public class StandardProcessLayoutNode extends AbstractVMLayoutNode {
|
|||
|
||||
public IVMLayoutNode getLayoutNode() { return StandardProcessLayoutNode.this; }
|
||||
@SuppressWarnings("unchecked") public Object getAdapter(Class adapter) {
|
||||
Object vmcAdapter = super.getAdapter(adapter);
|
||||
if (vmcAdapter != null) {
|
||||
return vmcAdapter;
|
||||
}
|
||||
return fProcess.getAdapter(adapter);
|
||||
}
|
||||
public String toString() { return "IProcess " + fProcess.toString(); } //$NON-NLS-1$
|
||||
|
@ -67,7 +71,9 @@ public class StandardProcessLayoutNode extends AbstractVMLayoutNode {
|
|||
public boolean isTerminated() { return fProcess.isTerminated(); }
|
||||
public void terminate() throws DebugException { fProcess.terminate(); }
|
||||
|
||||
public boolean equals(Object other) { return fProcess.equals(other); }
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof VMC && fProcess.equals(((VMC)other).fProcess);
|
||||
}
|
||||
public int hashCode() { return fProcess.hashCode(); }
|
||||
}
|
||||
|
||||
|
|
|
@ -175,10 +175,16 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
|||
}
|
||||
|
||||
public void updateHasElements(final IHasChildrenUpdate[] updates) {
|
||||
getSession().getExecutor().execute(new DsfRunnable() {
|
||||
public void run() {
|
||||
updateHasElementsInSessionThread(updates);
|
||||
}});
|
||||
try {
|
||||
getSession().getExecutor().execute(new DsfRunnable() {
|
||||
public void run() {
|
||||
updateHasElementsInSessionThread(updates);
|
||||
}});
|
||||
} catch (RejectedExecutionException e) {
|
||||
for (IHasChildrenUpdate update : updates) {
|
||||
handleFailedUpdate(update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateHasElementsInSessionThread(IHasChildrenUpdate[] updates) {
|
||||
|
@ -206,12 +212,16 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
|||
public void updateElementCount(final IChildrenCountUpdate update) {
|
||||
if (!checkUpdate(update)) return;
|
||||
|
||||
getSession().getExecutor().execute(new DsfRunnable() {
|
||||
public void run() {
|
||||
// After every dispatch, must check if update still valid.
|
||||
if (!checkUpdate(update)) return;
|
||||
updateElementCountInSessionThread(update);
|
||||
}});
|
||||
try {
|
||||
getSession().getExecutor().execute(new DsfRunnable() {
|
||||
public void run() {
|
||||
// After every dispatch, must check if update still valid.
|
||||
if (!checkUpdate(update)) return;
|
||||
updateElementCountInSessionThread(update);
|
||||
}});
|
||||
} catch (RejectedExecutionException e) {
|
||||
handleFailedUpdate(update);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateElementCountInSessionThread(final IChildrenCountUpdate update) {
|
||||
|
@ -235,12 +245,16 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
|||
public void updateElements(final IChildrenUpdate update) {
|
||||
if (!checkUpdate(update)) return;
|
||||
|
||||
getSession().getExecutor().execute(new DsfRunnable() {
|
||||
public void run() {
|
||||
// After every dispatch, must check if update still valid.
|
||||
if (!checkUpdate(update)) return;
|
||||
updateElementsInSessionThread(update);
|
||||
}});
|
||||
try {
|
||||
getSession().getExecutor().execute(new DsfRunnable() {
|
||||
public void run() {
|
||||
// After every dispatch, must check if update still valid.
|
||||
if (!checkUpdate(update)) return;
|
||||
updateElementsInSessionThread(update);
|
||||
}});
|
||||
} catch (RejectedExecutionException e) {
|
||||
handleFailedUpdate(update);
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected void updateElementsInSessionThread(IChildrenUpdate update);
|
||||
|
|
Loading…
Add table
Reference in a new issue