From a86e6485f4c18be728fcc37dbf1b4d6dbfcf312b Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Fri, 11 Sep 2009 22:07:03 +0000 Subject: [PATCH] [270675] - [update policy][variables] In manual update model changing the active number for the view causes the view data to appear stale. --- .../register/RegisterVMProvider.java | 6 +- .../update/BreakpointHitUpdatePolicy.java | 5 +- .../update/DebugManualUpdatePolicy.java | 82 +++++++++++++++++++ .../variable/VariableVMProvider.java | 6 +- .../update/AbstractCachingVMProvider.java | 19 ++++- .../update/IElementUpdateTester.java | 5 +- .../update/IElementUpdateTesterExtension.java | 36 ++++++++ .../ui/viewmodel/update/IVMUpdatePolicy.java | 11 ++- 8 files changed, 157 insertions(+), 13 deletions(-) create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/DebugManualUpdatePolicy.java create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTesterExtension.java diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/register/RegisterVMProvider.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/register/RegisterVMProvider.java index 7f269ccc221..c74235d500e 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/register/RegisterVMProvider.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/register/RegisterVMProvider.java @@ -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() }; } /* diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/BreakpointHitUpdatePolicy.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/BreakpointHitUpdatePolicy.java index 0729c16a7d3..be0102b1b20 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/BreakpointHitUpdatePolicy.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/BreakpointHitUpdatePolicy.java @@ -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$ diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/DebugManualUpdatePolicy.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/DebugManualUpdatePolicy.java new file mode 100644 index 00000000000..107d4519119 --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/update/DebugManualUpdatePolicy.java @@ -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 ACTIVE_NUMBER_FORMAT_PROPERTIES = new ArrayList(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 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); + } +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMProvider.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMProvider.java index 46b4d36909f..7632346055f 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMProvider.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMProvider.java @@ -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 diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/AbstractCachingVMProvider.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/AbstractCachingVMProvider.java index fa5675aed25..7e8b2838c76 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/AbstractCachingVMProvider.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/AbstractCachingVMProvider.java @@ -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 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 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) { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTester.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTester.java index 18658964061..ce1594e5e95 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTester.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTester.java @@ -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); diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTesterExtension.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTesterExtension.java new file mode 100644 index 00000000000..14b0826daea --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IElementUpdateTesterExtension.java @@ -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 true if the given cache entry is already dirty + * @return Collection of properties which should be flushed, or + * null if none. + */ + Collection getPropertiesToFlush(Object viewerInput, TreePath path, boolean isDirty); +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IVMUpdatePolicy.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IVMUpdatePolicy.java index 3088371c9a7..925029b47a3 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IVMUpdatePolicy.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/viewmodel/update/IVMUpdatePolicy.java @@ -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.