Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-06-05 03:17:15 -0400
committerUwe Stieber2013-06-05 03:17:15 -0400
commita13cb6fdddc13a8ca1f42a4ec8f092baa891d8e0 (patch)
tree7d7e78b53c1ee5ac5339bbce240cda1808b1a11d
parent2e41449b85607ac874a0360f73c095b30eaf94f6 (diff)
downloadorg.eclipse.tcf-a13cb6fdddc13a8ca1f42a4ec8f092baa891d8e0.tar.gz
org.eclipse.tcf-a13cb6fdddc13a8ca1f42a4ec8f092baa891d8e0.tar.xz
org.eclipse.tcf-a13cb6fdddc13a8ca1f42a4ec8f092baa891d8e0.zip
Target Explorer: Provide busy indicator while refreshing the process list
-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.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java32
2 files changed, 51 insertions, 7 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 0737a3de4..2e04f5cbb 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
@@ -89,6 +89,21 @@ public class RuntimeModelRefreshService extends AbstractModelService<IRuntimeMod
return;
}
+ final IAsyncRefreshableCtx refreshable = (IAsyncRefreshableCtx)model.getAdapter(IAsyncRefreshableCtx.class);
+ final AtomicBoolean resetPendingNode = new AtomicBoolean(false);
+ if (refreshable != null && refreshable.getQueryState(QueryType.CHILD_LIST) != QueryState.IN_PROGRESS) {
+ resetPendingNode.set(true);
+ // Mark the refresh as in progress
+ refreshable.setQueryState(QueryType.CHILD_LIST, QueryState.IN_PROGRESS);
+ // Create a new pending operation node and associate it with the refreshable
+ PendingOperationModelNode pendingNode = new PendingOperationNode();
+ pendingNode.setParent(model);
+ refreshable.setPendingOperationNode(pendingNode);
+ // Trigger a refresh of the view content.
+ ChangeEvent event = new ChangeEvent(model, IContainerModelNode.NOTIFY_CHANGED, null, null);
+ EventManager.getInstance().fireEvent(event);
+ }
+
// Get the list of old children (update node instances where possible)
final List<IProcessContextNode> oldChildren = model.getChildren(IProcessContextNode.class);
@@ -111,6 +126,17 @@ public class RuntimeModelRefreshService extends AbstractModelService<IRuntimeMod
for (IProcessContextNode oldChild : oldChildren) model.getService(IModelUpdateService.class).remove(oldChild);
}
+ if (refreshable != null && resetPendingNode.get()) {
+ resetPendingNode.set(false);
+ // Mark the refresh as done
+ refreshable.setQueryState(QueryType.CHILD_LIST, QueryState.DONE);
+ // Reset the pending operation node
+ refreshable.setPendingOperationNode(null);
+ // Trigger a refresh of the view content.
+ ChangeEvent event = new ChangeEvent(model, IContainerModelNode.NOTIFY_CHANGED, null, null);
+ EventManager.getInstance().fireEvent(event);
+ }
+
// Invoke the callback
if (callback != null) callback.done(this, Status.OK_STATUS);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java
index 25f7c37ee..ae3619c8c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2013 Wind River Systems, Inc. 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
@@ -15,7 +15,11 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.core.async.AsyncCallbackCollector;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel;
@@ -27,6 +31,7 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.UIElement;
@@ -44,15 +49,28 @@ public class RefreshProcessListHandler extends AbstractHandler implements IEleme
IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event);
final IPeerModel peer = (IPeerModel) editorInput.getAdapter(IPeerModel.class);
if (peer != null) {
- Runnable runnable = new Runnable() {
+ BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), new Runnable() {
@Override
public void run() {
- IModel model = ModelManager.getRuntimeModel(peer);
- Assert.isNotNull(model);
- model.getService(IModelRefreshService.class).refresh(null);
+ final AsyncCallbackCollector collector = new AsyncCallbackCollector();
+ final ICallback callback = new AsyncCallbackCollector.SimpleCollectorCallback(collector);
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ IModel model = ModelManager.getRuntimeModel(peer);
+ Assert.isNotNull(model);
+ model.getService(IModelRefreshService.class).refresh(callback);
+ }
+ };
+ Protocol.invokeLater(runnable);
+
+ collector.initDone();
+
+ ExecutorsUtil.waitAndExecute(0, collector.getConditionTester());
}
- };
- Protocol.invokeLater(runnable);
+ });
+
}
return null;
}

Back to the top