mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Use IModelDelta.NO_CHANGE instead of 0
This commit is contained in:
parent
bd8442bf2f
commit
8db497abb6
1 changed files with 43 additions and 29 deletions
|
@ -75,7 +75,7 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
|
||||||
IRootVMNode rootNode = getVMProvider().getRootVMNode();
|
IRootVMNode rootNode = getVMProvider().getRootVMNode();
|
||||||
return rootNode != null &&
|
return rootNode != null &&
|
||||||
rootNode.isDeltaEvent(getRootElement(), event) &&
|
rootNode.isDeltaEvent(getRootElement(), event) &&
|
||||||
getDeltaFlags(rootNode, null, event) != 0;
|
getDeltaFlags(rootNode, null, event) != IModelDelta.NO_CHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,36 +252,51 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
|
||||||
*/
|
*/
|
||||||
public boolean isDisposed() {
|
public boolean isDisposed() {
|
||||||
return fDisposed;
|
return fDisposed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively calls the VM nodes in the hierarchy of the given node
|
* Recursively calls the VM nodes in the hierarchy of the given node to
|
||||||
* to calculate the delta flags that are
|
* determine how elements of those types may be (or are) affected by
|
||||||
* <p/>
|
* [event], the answer being a collection of IModelDelta flags.
|
||||||
* Note: If a child node has a <code>IModelDelta.CONTENT</code> delta
|
*
|
||||||
* flag, it means that this flag will be added to this node's element.
|
* Optimization 1: If the first-level child node does not have
|
||||||
* To allow for optimization change the child's <code>IModelDelta.CONTENT</code>
|
* <code>IModelDelta.CONTENT</code> but one of its descendants does, then
|
||||||
* flag into a <code>IModelDelta.STATE</code> flag.
|
* for optimization reasons we return <code>IModelDelta.STATE</code>
|
||||||
*
|
* instead.
|
||||||
* @param node
|
*
|
||||||
* @param event
|
* Optimization 2: If the parent delta contains
|
||||||
* @return
|
* <code>IModelDelta.CONTENT</code>, we do not need to specify it for its
|
||||||
*/
|
* children. This can shorten delta processing considerably.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* the IVMNode whose delta flags (and those of its descendants)
|
||||||
|
* are being queried
|
||||||
|
* @param parentDelta
|
||||||
|
* the base portion of the delta the caller is trying to
|
||||||
|
* construct; this delta node is specifically the deepest node in
|
||||||
|
* that chain (i.e., has no children, but may have ancestors)
|
||||||
|
* @param event
|
||||||
|
* the event the caller is trying to produce a delta for
|
||||||
|
* @return the collective set of IModelDelta flags that reflect how [node]
|
||||||
|
* and its descendants may be (or are) affected by [event]
|
||||||
|
*/
|
||||||
protected int getDeltaFlags(IVMNode node, ModelDelta parentDelta, Object event) {
|
protected int getDeltaFlags(IVMNode node, ModelDelta parentDelta, Object event) {
|
||||||
int flags = node.getDeltaFlags(event);
|
int flags = node.getDeltaFlags(event);
|
||||||
for (IVMNode childNode : getVMProvider().getChildVMNodes(node)) {
|
for (IVMNode childNode : getVMProvider().getChildVMNodes(node)) {
|
||||||
if (!childNode.equals(node)) {
|
if (!childNode.equals(node)) {
|
||||||
int childNodeDeltaFlags = getDeltaFlags(childNode, parentDelta, event);
|
int childNodeDeltaFlags = getDeltaFlags(childNode, parentDelta, event);
|
||||||
|
|
||||||
|
// optimization 1; see above
|
||||||
if ((childNodeDeltaFlags & IModelDelta.CONTENT) != 0) {
|
if ((childNodeDeltaFlags & IModelDelta.CONTENT) != 0) {
|
||||||
childNodeDeltaFlags &= ~IModelDelta.CONTENT;
|
childNodeDeltaFlags &= ~IModelDelta.CONTENT;
|
||||||
childNodeDeltaFlags |= IModelDelta.STATE;
|
childNodeDeltaFlags |= IModelDelta.STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags |= childNodeDeltaFlags;
|
flags |= childNodeDeltaFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Optimization: If the parent delta contains the "content" flag, we do
|
|
||||||
// not need to add it to the child. This can shorten delta processing
|
// optimization 2; see above
|
||||||
// considerably so check for it.
|
|
||||||
while (parentDelta != null) {
|
while (parentDelta != null) {
|
||||||
if ( (parentDelta.getFlags() & IModelDelta.CONTENT) != 0 ) {
|
if ( (parentDelta.getFlags() & IModelDelta.CONTENT) != 0 ) {
|
||||||
flags = flags & ~IModelDelta.CONTENT & ~IModelDelta.STATE;
|
flags = flags & ~IModelDelta.CONTENT & ~IModelDelta.STATE;
|
||||||
|
@ -305,13 +320,13 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
|
||||||
new DataRequestMonitor<VMDelta>(getVMProvider().getExecutor(), rm) {
|
new DataRequestMonitor<VMDelta>(getVMProvider().getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
// Find the root delta for the whole view to use when firing the delta.
|
// The resulting delta will have parents if our
|
||||||
// Note: the view root is going to be different than the model root
|
// VMProvider is registered to populate only a sub-tree
|
||||||
// in case when the view model provider is registered to populate only
|
// of the viewer. Get the root node of the chain--i.e.,
|
||||||
// a sub-tree of a view.
|
// the delta for the root element of the entire viewer.
|
||||||
final IModelDelta viewRootDelta = getRootDelta(getData());
|
final IModelDelta viewRootDelta = getRootDelta(getData());
|
||||||
|
|
||||||
// Find the child nodes that have deltas for the given event.
|
// Find the child nodes that (may) have deltas for the given event.
|
||||||
final Map<IVMNode,Integer> childNodesWithDeltaFlags = getChildNodesWithDeltaFlags(rootNode, getData(), event);
|
final Map<IVMNode,Integer> childNodesWithDeltaFlags = getChildNodesWithDeltaFlags(rootNode, getData(), event);
|
||||||
|
|
||||||
// If no child nodes have deltas we can stop here.
|
// If no child nodes have deltas we can stop here.
|
||||||
|
@ -689,12 +704,11 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method that returns the child nodes which return
|
* Convenience method that returns what each of the child nodes returns from
|
||||||
* <code>true</code> to the <code>hasDeltaFlags()</code> test for the given
|
* {@link #getDeltaFlags(IVMNode, ModelDelta, Object)}.
|
||||||
* event.
|
*/
|
||||||
*/
|
|
||||||
protected Map<IVMNode, Integer> getChildNodesWithDeltaFlags(IVMNode node, ModelDelta parentDelta, Object e) {
|
protected Map<IVMNode, Integer> getChildNodesWithDeltaFlags(IVMNode node, ModelDelta parentDelta, Object e) {
|
||||||
Map<IVMNode, Integer> nodes = new HashMap<IVMNode, Integer>();
|
Map<IVMNode, Integer> nodes = new HashMap<IVMNode, Integer>();
|
||||||
for (final IVMNode childNode : getVMProvider().getChildVMNodes(node)) {
|
for (final IVMNode childNode : getVMProvider().getChildVMNodes(node)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue