mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Clean-up assumptions in AbstractDMVMLayoutNode about the DMC type in VMC held in viewer (bug 192019).
This commit is contained in:
parent
a132e82188
commit
c124ed7f92
3 changed files with 35 additions and 6 deletions
|
@ -267,8 +267,8 @@ public class RegisterLayoutNode extends AbstractExpressionLayoutNode<IRegisterDM
|
||||||
@Override
|
@Override
|
||||||
protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
|
protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
|
||||||
for (final ILabelUpdate update : updates) {
|
for (final ILabelUpdate update : updates) {
|
||||||
|
|
||||||
final IRegisterDMContext dmc = findDmcInPath(update.getElementPath(), IRegisters.IRegisterDMContext.class);
|
final IRegisterDMContext dmc = findDmcInPath(update.getElementPath(), IRegisters.IRegisterDMContext.class);
|
||||||
|
if (!checkDmc(dmc, update) || !checkService(null, dmc.getServiceFilter(), update)) return;
|
||||||
|
|
||||||
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
||||||
dmc,
|
dmc,
|
||||||
|
|
|
@ -338,6 +338,12 @@ abstract public class AbstractVMLayoutNode implements IVMLayoutNode {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience method that completes update object in case of an error.
|
||||||
|
* Different types of update need to have some data configured to exhibit
|
||||||
|
* desired behavior in the viewer.
|
||||||
|
* @param update Update to handle.
|
||||||
|
*/
|
||||||
protected void handleFailedUpdate(IViewerUpdate update) {
|
protected void handleFailedUpdate(IViewerUpdate update) {
|
||||||
if (update instanceof IHasChildrenUpdate) {
|
if (update instanceof IHasChildrenUpdate) {
|
||||||
((IHasChildrenUpdate)update).setHasChilren(false);
|
((IHasChildrenUpdate)update).setHasChilren(false);
|
||||||
|
|
|
@ -169,6 +169,31 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method that checks whether the given dmc context is null. If it is null, an
|
||||||
|
* appropriate error message is set in the update.
|
||||||
|
* @param dmc Data Model Context (DMC) to check.
|
||||||
|
* @param update Update to handle in case the DMC is null.
|
||||||
|
* @return true if the DMC is NOT null, indicating that it's OK to proceed.
|
||||||
|
*/
|
||||||
|
protected boolean checkDmc(IDMContext<?> dmc, IViewerUpdate update) {
|
||||||
|
if (dmc == null) {
|
||||||
|
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INVALID_STATE,
|
||||||
|
"No valid context found.", null)); //$NON-NLS-1$
|
||||||
|
handleFailedUpdate(update);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience method that checks whether a given service exists. If the service does not
|
||||||
|
* exist, the update is filled in with the appropriate error message.
|
||||||
|
* @param serviceClass Service class to find.
|
||||||
|
* @param filter Service filter to use in addition to the service class name.
|
||||||
|
* @param update Update object to fill in.
|
||||||
|
* @return true if service IS found, indicating that it's OK to proceed.
|
||||||
|
*/
|
||||||
protected boolean checkService(Class<? extends IDsfService> serviceClass, String filter, IViewerUpdate update) {
|
protected boolean checkService(Class<? extends IDsfService> serviceClass, String filter, IViewerUpdate update) {
|
||||||
if (getServicesTracker().getService(serviceClass, filter) == null) {
|
if (getServicesTracker().getService(serviceClass, filter) == null) {
|
||||||
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INVALID_STATE,
|
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INVALID_STATE,
|
||||||
|
@ -291,12 +316,10 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
||||||
*/
|
*/
|
||||||
protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
|
protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
|
||||||
for (final ILabelUpdate update : updates) {
|
for (final ILabelUpdate update : updates) {
|
||||||
final DMVMContext vmc = (DMVMContext)update.getElement();
|
|
||||||
if (!checkService(null, vmc.getDMC().getServiceFilter(), update)) return;
|
|
||||||
|
|
||||||
final IDMContext<V> dmc = findDmcInPath(update.getElementPath(), fDMCClassType);
|
final IDMContext<V> dmc = findDmcInPath(update.getElementPath(), fDMCClassType);
|
||||||
|
if (!checkDmc(dmc, update) || !checkService(null, dmc.getServiceFilter(), update)) return;
|
||||||
|
|
||||||
((IDMService)getServicesTracker().getService(null, vmc.getDMC().getServiceFilter())).getModelData(
|
((IDMService)getServicesTracker().getService(null, dmc.getServiceFilter())).getModelData(
|
||||||
dmc,
|
dmc,
|
||||||
new DataRequestMonitor<V>(getSession().getExecutor(), null) {
|
new DataRequestMonitor<V>(getSession().getExecutor(), null) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -395,7 +418,7 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
|
||||||
|
|
||||||
if (dmc != null) {
|
if (dmc != null) {
|
||||||
// Create the VM context based on the DM context from the DM event.
|
// Create the VM context based on the DM context from the DM event.
|
||||||
final IVMContext vmc = new DMVMContext(DMContexts.getAncestorOfType(event.getDMContext(), fDMCClassType));
|
final IVMContext vmc = createVMContext(DMContexts.getAncestorOfType(event.getDMContext(), fDMCClassType));
|
||||||
|
|
||||||
final Map<IVMLayoutNode,Integer> childNodeDeltas = getChildNodesWithDeltaFlags(event);
|
final Map<IVMLayoutNode,Integer> childNodeDeltas = getChildNodesWithDeltaFlags(event);
|
||||||
if (childNodeDeltas.size() == 0) {
|
if (childNodeDeltas.size() == 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue