diff options
author | Uwe Stieber | 2014-02-05 16:44:03 +0000 |
---|---|---|
committer | Uwe Stieber | 2014-02-05 16:44:03 +0000 |
commit | b0e9b7937e0cafe7c8e30cfcfe64ced895178b85 (patch) | |
tree | a1546d16131b936b659bf061f4cb0582cb07e11c | |
parent | f4cf80651787c6393d18658dd81b5827b21e537b (diff) | |
download | org.eclipse.tcf-b0e9b7937e0cafe7c8e30cfcfe64ced895178b85.tar.gz org.eclipse.tcf-b0e9b7937e0cafe7c8e30cfcfe64ced895178b85.tar.xz org.eclipse.tcf-b0e9b7937e0cafe7c8e30cfcfe64ced895178b85.zip |
Target Explorer: Fix process monitor toolbar refresh button has no effect for process hierarchies with more than 1 level
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelRefreshService.java | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelRefreshService.java index 0d2f92698..460c5eee4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelRefreshService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelRefreshService.java @@ -207,8 +207,51 @@ public class RuntimeModelRefreshService extends AbstractModelService<IRuntimeMod if (status.isOK()) { // Process the new child list and merge it with the model model.getService(IRuntimeModelUpdateService.class).updateChildren(model, container); - // Invoke the callbacks - invokeCallbacks(model, RuntimeModelRefreshService.this, status); + + // Walk the tree on check the children at level 2 to determine if there are + // nodes which got expanded by the user and must be refreshed therefore too. + final List<IProcessContextNode> children = new ArrayList<IProcessContextNode>(); + // Get the first level children from the model + List<IProcessContextNode> candidates = model.getChildren(IProcessContextNode.class); + for (IProcessContextNode candidate : candidates) { + // If the child list got not queried for the candidate, skip it + IAsyncRefreshableCtx refreshable = (IAsyncRefreshableCtx)candidate.getAdapter(IAsyncRefreshableCtx.class); + Assert.isNotNull(refreshable); + if (refreshable.getQueryState(QueryType.CHILD_LIST) != QueryState.DONE) continue; + // Get the second level children and find those candidates where + // the child list query is marked done. Add those candidates to + // the list of children to refresh too. + List<IProcessContextNode> candidates2 = candidate.getChildren(IProcessContextNode.class); + for (IProcessContextNode candidate2 : candidates2) { + // Get the asynchronous refreshable for the candidate + refreshable = (IAsyncRefreshableCtx)candidate2.getAdapter(IAsyncRefreshableCtx.class); + Assert.isNotNull(refreshable); + if (refreshable.getQueryState(QueryType.CHILD_LIST) != QueryState.DONE) continue; + // This child needs an additional refresh + children.add(candidate2); + } + } + + // Run the auto-refresh logic for all children we have found + final ICallback callback = new Callback() { + @Override + protected void internalDone(Object caller, IStatus status) { + // Invoke the callbacks + invokeCallbacks(model, RuntimeModelRefreshService.this, status); + } + }; + + // Create the callback collector to fire once all refresh operations are completed + final AsyncCallbackCollector collector = new AsyncCallbackCollector(callback, new CallbackInvocationDelegate()); + + // Get the first level of children and check if they are need to be refreshed + if (children.size() > 0) { + // Initiate the refresh of the children + doAutoRefresh(model, children.toArray(new IProcessContextNode[children.size()]), 0, collector); + } + + // Mark the collector initialization done + collector.initDone(); } else { // Invoke the callbacks invokeCallbacks(model, RuntimeModelRefreshService.this, status); @@ -316,6 +359,9 @@ public class RuntimeModelRefreshService extends AbstractModelService<IRuntimeMod return; } + // Determine if there is already a model refresh running. + // A model refresh can be initiated via refresh(...) or autoRefresh(...). + // Create the callback collector to fire once all refresh operations are completed final AsyncCallbackCollector collector = new AsyncCallbackCollector(callback, new CallbackInvocationDelegate()); @@ -452,7 +498,7 @@ public class RuntimeModelRefreshService extends AbstractModelService<IRuntimeMod // Get the context id of the child String id = child.getStringProperty(IProcessContextNodeProperties.PROPERTY_ID); if (id == null) continue; - + // Find the real child node IProcessContextNode realChild = null; for (IProcessContextNode candidate : oldChildren) { |