mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
[270675] - [update policy][variables] In manual update model changing the active number for the view causes the view data to appear stale.
This commit is contained in:
parent
ef4d88a354
commit
a86e6485f4
8 changed files with 157 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2006, 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
|||
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
||||
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.BreakpointHitUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.DebugManualUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
|
@ -33,7 +34,6 @@ import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
|||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IVMUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.ManualUpdatePolicy;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
|
||||
|
@ -114,7 +114,7 @@ public class RegisterVMProvider extends AbstractDMVMProvider
|
|||
*/
|
||||
@Override
|
||||
protected IVMUpdatePolicy[] createUpdateModes() {
|
||||
return new IVMUpdatePolicy[] { new AutomaticUpdatePolicy(), new ManualUpdatePolicy(), new BreakpointHitUpdatePolicy() };
|
||||
return new IVMUpdatePolicy[] { new AutomaticUpdatePolicy(), new DebugManualUpdatePolicy(), new BreakpointHitUpdatePolicy() };
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -13,12 +13,11 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel.update;
|
|||
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IElementUpdateTester;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.ManualUpdatePolicy;
|
||||
|
||||
/**
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BreakpointHitUpdatePolicy extends ManualUpdatePolicy {
|
||||
public class BreakpointHitUpdatePolicy extends DebugManualUpdatePolicy {
|
||||
|
||||
public static String BREAKPOINT_HIT_UPDATE_POLICY_ID = "org.eclipse.cdt.dsf.debug.ui.viewmodel.update.breakpointHitUpdatePolicy"; //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.ui.viewmodel.update;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.IDebugVMConstants;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IElementUpdateTester;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IElementUpdateTesterExtension;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.ManualUpdatePolicy;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
|
||||
/**
|
||||
* Manual update policy with extensions specific for the debugger views. It
|
||||
* properly handles the changes in active number format values in debug view.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DebugManualUpdatePolicy extends ManualUpdatePolicy {
|
||||
|
||||
public static String DEBUG_MANUAL_UPDATE_POLICY_ID = "org.eclipse.cdt.dsf.debug.ui.viewmodel.update.debugManualUpdatePolicy"; //$NON-NLS-1$
|
||||
|
||||
private static final List<String> ACTIVE_NUMBER_FORMAT_PROPERTIES = new ArrayList<String>(1);
|
||||
|
||||
static {
|
||||
ACTIVE_NUMBER_FORMAT_PROPERTIES.add(IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* This specialized element update tester flushes the active number format
|
||||
* property of the elemetn under consideration. The partial property flush
|
||||
* is performed only if the cache entry is not yet dirty.
|
||||
*/
|
||||
private static IElementUpdateTester fgNumberFormatPropertyEventUpdateTester = new IElementUpdateTesterExtension() {
|
||||
|
||||
public int getUpdateFlags(Object viewerInput, TreePath path) {
|
||||
return FLUSH_PARTIAL_PROPERTIES;
|
||||
}
|
||||
|
||||
public Collection<String> getPropertiesToFlush(Object viewerInput, TreePath path, boolean isDirty) {
|
||||
if (!isDirty) {
|
||||
return ACTIVE_NUMBER_FORMAT_PROPERTIES;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean includes(IElementUpdateTester tester) {
|
||||
return tester.equals(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Manual (refresh = false) update tester for an event that did not originate from the data model"; //$NON-NLS-1$
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return DEBUG_MANUAL_UPDATE_POLICY_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementUpdateTester getElementUpdateTester(Object event) {
|
||||
if ((event instanceof PropertyChangeEvent &&
|
||||
((PropertyChangeEvent)event).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE))
|
||||
{
|
||||
return fgNumberFormatPropertyEventUpdateTester;
|
||||
}
|
||||
return super.getElementUpdateTester(event);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
|||
import org.eclipse.cdt.dsf.debug.ui.DsfDebugUITools;
|
||||
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.BreakpointHitUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.update.DebugManualUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
|
@ -29,7 +30,6 @@ import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
|||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IVMUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.ManualUpdatePolicy;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
|
@ -106,7 +106,7 @@ public class VariableVMProvider extends AbstractDMVMProvider
|
|||
|
||||
@Override
|
||||
protected IVMUpdatePolicy[] createUpdateModes() {
|
||||
return new IVMUpdatePolicy[] { new AutomaticUpdatePolicy(), new ManualUpdatePolicy(), new BreakpointHitUpdatePolicy() };
|
||||
return new IVMUpdatePolicy[] { new AutomaticUpdatePolicy(), new DebugManualUpdatePolicy(), new BreakpointHitUpdatePolicy() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.dsf.ui.viewmodel.update;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -274,6 +275,14 @@ public class AbstractCachingVMProvider extends AbstractVMProvider
|
|||
return 0;
|
||||
}
|
||||
|
||||
Collection<String> getPropertiesToFlush(ElementDataKey key, boolean isDirty) {
|
||||
if (fRootElement.equals(key.fRootElement) && fElementTester instanceof IElementUpdateTesterExtension) {
|
||||
return ((IElementUpdateTesterExtension)fElementTester).
|
||||
getPropertiesToFlush(key.fViewerInput, key.fPath, isDirty);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fElementTester.toString() + " " + fRootElement.toString(); //$NON-NLS-1$
|
||||
|
@ -702,7 +711,8 @@ public class AbstractCachingVMProvider extends AbstractVMProvider
|
|||
}
|
||||
else if (entry instanceof ElementDataEntry) {
|
||||
ElementDataEntry elementDataEntry = (ElementDataEntry)entry;
|
||||
int updateFlags = flushKey.getUpdateFlags((ElementDataKey)elementDataEntry.fKey);
|
||||
ElementDataKey elementDataKey = (ElementDataKey)elementDataEntry.fKey;
|
||||
int updateFlags = flushKey.getUpdateFlags(elementDataKey);
|
||||
if ((updateFlags & IVMUpdatePolicy.FLUSH) != 0) {
|
||||
if ((updateFlags & IVMUpdatePolicy.ARCHIVE) == IVMUpdatePolicy.ARCHIVE) {
|
||||
// We are saving current data for change history, check if the data is valid.
|
||||
|
@ -735,6 +745,11 @@ public class AbstractCachingVMProvider extends AbstractVMProvider
|
|||
elementDataEntry.fChildren = null;
|
||||
elementDataEntry.fAllChildrenKnown = false;
|
||||
elementDataEntry.fDirty = false;
|
||||
} else if ((updateFlags & IVMUpdatePolicy.FLUSH_PARTIAL_PROPERTIES) != 0) {
|
||||
Collection<String> propertiesToFlush = flushKey.getPropertiesToFlush(elementDataKey, elementDataEntry.fDirty);
|
||||
if (propertiesToFlush != null && elementDataEntry.fProperties != null) {
|
||||
elementDataEntry.fProperties.keySet().removeAll(propertiesToFlush);
|
||||
}
|
||||
} else if ((updateFlags & IVMUpdatePolicy.DIRTY) != 0) {
|
||||
elementDataEntry.fDirty = true;
|
||||
if (elementDataEntry.fProperties != null) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -25,6 +25,9 @@ public interface IElementUpdateTester {
|
|||
/**
|
||||
* Returns the flags indicating what updates should be performed on the
|
||||
* cache entry of the given element.
|
||||
*
|
||||
* @param viewerInput The input to the viewer for the given cache entry.
|
||||
* @param path The viewer tree path for the given cache entry.
|
||||
*/
|
||||
public int getUpdateFlags(Object viewerInput, TreePath path);
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.ui.viewmodel.update;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
|
||||
/**
|
||||
* Element update tester extension which allows an update policy to selectively
|
||||
* flush properties of elements. This can be useful if the update tester's event
|
||||
* only affects a certain aspect of the element's presentation.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface IElementUpdateTesterExtension extends IElementUpdateTester {
|
||||
|
||||
/**
|
||||
* Returns the properties that should be flushed for the element.
|
||||
*
|
||||
* @param viewerInput The input to the viewer for the given cache entry.
|
||||
* @param path The viewer tree path for the given cache entry.
|
||||
* @param isDirty <code>true</code> if the given cache entry is already dirty
|
||||
* @return Collection of properties which should be flushed, or
|
||||
* <code>null</code> if none.
|
||||
*/
|
||||
Collection<String> getPropertiesToFlush(Object viewerInput, TreePath path, boolean isDirty);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -40,6 +40,15 @@ public interface IVMUpdatePolicy {
|
|||
* target data.
|
||||
*/
|
||||
public static int DIRTY = 0x4;
|
||||
|
||||
/**
|
||||
* Flag indicating that the cache should flush only selected properties of
|
||||
* an element. The list of properties to clear can be accessed using
|
||||
* {@link IElementUpdateTesterExtension#getPropertiesToFlush(Object, org.eclipse.jface.viewers.TreePath, boolean)}.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public static int FLUSH_PARTIAL_PROPERTIES = 0x8;
|
||||
|
||||
/**
|
||||
* Returns unique ID of this update policy.
|
||||
|
|
Loading…
Add table
Reference in a new issue