Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2009-03-10 23:47:17 +0000
committerPawel Piech2009-03-10 23:47:17 +0000
commit081d4ed5ac7382b0ab4f700cde1d1ae71b7f4a81 (patch)
tree97c2f11b2afc932f71afd6fcd2eabf7de66b8daa /dsf/org.eclipse.cdt.examples.dsf.pda.ui
parent445fc4b23af55090739c2d228bea55a7ffd67416 (diff)
downloadorg.eclipse.cdt-081d4ed5ac7382b0ab4f700cde1d1ae71b7f4a81.tar.gz
org.eclipse.cdt-081d4ed5ac7382b0ab4f700cde1d1ae71b7f4a81.tar.xz
org.eclipse.cdt-081d4ed5ac7382b0ab4f700cde1d1ae71b7f4a81.zip
[225650] - [view model] Convert debug views' view model implementation to use IElementPropertyProvider.
Diffstat (limited to 'dsf/org.eclipse.cdt.examples.dsf.pda.ui')
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java80
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java81
2 files changed, 33 insertions, 128 deletions
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java
index 043f4bc9f08..7b4ba3c7a1a 100644
--- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java
@@ -11,24 +11,22 @@
*******************************************************************************/
package org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.launch;
+import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
-import org.eclipse.cdt.dsf.debug.service.IRunControl;
-import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData;
-import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractThreadVMNode;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants;
import org.eclipse.cdt.dsf.service.DsfSession;
-import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
-import org.eclipse.cdt.examples.dsf.pda.service.PDARunControl;
+import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate;
import org.eclipse.cdt.examples.dsf.pda.service.PDAThreadDMContext;
+import org.eclipse.cdt.examples.dsf.pda.ui.PDAUIPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.ui.IMemento;
@@ -50,68 +48,16 @@ public class PDAThreadsVMNode extends AbstractThreadVMNode
}
@Override
- protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
- for (final ILabelUpdate update : updates) {
- final PDARunControl runControl = getServicesTracker().getService(PDARunControl.class);
- if ( runControl == null ) {
- handleFailedUpdate(update);
- continue;
- }
-
- final PDAThreadDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), PDAThreadDMContext.class);
-
- String imageKey = null;
- if (getServicesTracker().getService(IRunControl.class).isSuspended(dmc)) {
- imageKey = IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
+ protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) {
+ for (int i = 0; i < updates.length; i++) {
+ final PDAThreadDMContext dmc = findDmcInPath(updates[i].getViewerInput(), updates[i].getElementPath(), PDAThreadDMContext.class);
+ if (dmc != null) {
+ updates[i].setProperty(ILaunchVMConstants.PROP_ID, Integer.toString(dmc.getID()));
} else {
- imageKey = IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
+ updates[i].setStatus(new Status(IStatus.ERROR, PDAUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "Invalid context", null)); //$NON-NLS-1$
}
- update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
-
- // Find the Reason for the State
- getDMVMProvider().getModelData(
- this, update, runControl, dmc,
- new ViewerDataRequestMonitor<IExecutionDMData>(getSession().getExecutor(), update) {
- @Override
- public void handleCompleted(){
- if (!isSuccess()) {
- update.setLabel("<unavailable>", 0);
- update.done();
- return;
- }
-
- // We're in a new dispatch cycle, and we have to check whether the
- // service reference is still valid.
- final PDARunControl runControl = getServicesTracker().getService(PDARunControl.class);
- if ( runControl == null ) {
- handleFailedUpdate(update);
- return;
- }
-
- final StateChangeReason reason = getData().getStateChangeReason();
-
- // Create Labels of type Thread[GDBthreadId]RealThreadID/Name (State: Reason)
- // Thread[1] 3457 (Suspended:BREAKPOINT)
- final StringBuilder builder = new StringBuilder();
- builder.append("Thread ");
- builder.append(dmc.getID());
- if(getServicesTracker().getService(IRunControl.class).isSuspended(dmc))
- builder.append(" (Suspended");
- else
- builder.append(" (Running");
- // Reason will be null before ContainerSuspendEvent is fired
- if(reason != null) {
- builder.append(" : ");
- builder.append(reason);
- }
- builder.append(")");
- update.setLabel(builder.toString(), 0);
- update.done();
- }
- },
- getExecutor());
-
}
+ super.updatePropertiesInSessionThread(updates);
}
private String produceThreadElementName(String viewName, PDAThreadDMContext execCtx) {
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java
index 62b57922fa3..415215349e8 100644
--- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java
@@ -13,17 +13,24 @@
package org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.launch;
+import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractContainerVMNode;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
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.properties.IPropertiesUpdate;
import org.eclipse.cdt.examples.dsf.pda.service.PDACommandControl;
+import org.eclipse.cdt.examples.dsf.pda.service.PDAThreadDMContext;
import org.eclipse.cdt.examples.dsf.pda.service.PDAVirtualMachineDMContext;
+import org.eclipse.cdt.examples.dsf.pda.ui.PDAUIPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
@@ -70,70 +77,22 @@ public class PDAVirtualMachineVMNode extends AbstractContainerVMNode
update.done();
}
-
@Override
- protected void updateLabelInSessionThread(final ILabelUpdate update) {
- // Get a reference to the run control service.
- final IRunControl runControl = getServicesTracker().getService(IRunControl.class);
- if (runControl == null) {
- handleFailedUpdate(update);
- return;
- }
-
- // Find the PDA program context.
- final PDAVirtualMachineDMContext programCtx =
- findDmcInPath(update.getViewerInput(), update.getElementPath(), PDAVirtualMachineDMContext.class);
-
- // Call service to get current program state
- final boolean isSuspended = runControl.isSuspended(programCtx);
-
- // Set the program icon based on the running state of the program.
- String imageKey = null;
- if (isSuspended) {
- imageKey = IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
- } else {
- imageKey = IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
+ protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) {
+ for (int i = 0; i < updates.length; i++) {
+ // Find the PDA program context.
+ final PDAVirtualMachineDMContext dmc =
+ findDmcInPath(updates[i].getViewerInput(), updates[i].getElementPath(), PDAVirtualMachineDMContext.class);
+ if (dmc != null) {
+ updates[i].setProperty(PROP_NAME, "PDA");
+ updates[i].setProperty(ILaunchVMConstants.PROP_ID, dmc.getProgram());
+ } else {
+ updates[i].setStatus(new Status(IStatus.ERROR, PDAUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "Invalid context", null)); //$NON-NLS-1$
+ }
}
- update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
-
- // Retrieve the last state change reason
- getDMVMProvider().getModelData(
- this, update, runControl, programCtx,
- new ViewerDataRequestMonitor<IExecutionDMData>(ImmediateExecutor.getInstance(), update)
- {
- @Override
- public void handleCompleted(){
- // If the request failed, fail the udpate.
- if (!isSuccess()) {
- handleFailedUpdate(update);
- return;
- }
-
- // Compose the thread name string.
- final StringBuilder builder = new StringBuilder();
-
- builder.append("PDA [");
- builder.append(programCtx.getProgram());
- builder.append("]");
-
- if(isSuspended) {
- builder.append(" (Suspended");
- } else {
- builder.append(" (Running");
- }
- // Reason will be null before ContainerSuspendEvent is fired
- if(getData().getStateChangeReason() != null) {
- builder.append(" : ");
- builder.append(getData().getStateChangeReason());
- }
- builder.append(")");
- update.setLabel(builder.toString(), 0);
- update.done();
- }
- },
- getExecutor());
+ super.updatePropertiesInSessionThread(updates);
}
-
+
private String produceProgramElementName( String viewName , PDAVirtualMachineDMContext execCtx ) {
return "PDA." + execCtx.getProgram(); //$NON-NLS-1$
}

Back to the top