1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 334566 - [multicore][Pin&Clone] Add support for icon overlay in the debug view

This commit is contained in:
Patrick Chuong 2011-02-15 21:12:12 +00:00
parent 878d101d18
commit 480ee167c8
41 changed files with 858 additions and 110 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

View file

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*******************************************************************************/
package org.eclipse.cdt.ui;
@ -184,6 +185,29 @@ public class CDTSharedImages {
public static final String IMG_OVR_SETTING = "icons/ovr16/setting_nav.gif"; //$NON-NLS-1$
public static final String IMG_OVR_INACTIVE = "icons/ovr16/inactive_co.gif"; //$NON-NLS-1$
// Pin & Clone
public static final String IMG_THREAD_SUSPENDED_R_PINNED = "icons/obj16/threads_obj_r.gif"; //$NON-NLS-1$
public static final String IMG_THREAD_SUSPENDED_G_PINNED = "icons/obj16/threads_obj_g.gif"; //$NON-NLS-1$
public static final String IMG_THREAD_SUSPENDED_B_PINNED = "icons/obj16/threads_obj_b.gif"; //$NON-NLS-1$
public static final String IMG_THREAD_RUNNING_R_PINNED = "icons/obj16/thread_obj_r.gif"; //$NON-NLS-1$
public static final String IMG_THREAD_RUNNING_G_PINNED = "icons/obj16/thread_obj_g.gif"; //$NON-NLS-1$
public static final String IMG_THREAD_RUNNING_B_PINNED = "icons/obj16/thread_obj_b.gif"; //$NON-NLS-1$
public static final String IMG_CONTAINER_SUSPENDED_R_PINNED = "icons/obj16/debugts_obj_r.gif"; //$NON-NLS-1$
public static final String IMG_CONTAINER_SUSPENDED_G_PINNED = "icons/obj16/debugts_obj_g.gif"; //$NON-NLS-1$
public static final String IMG_CONTAINER_SUSPENDED_B_PINNED = "icons/obj16/debugts_obj_b.gif"; //$NON-NLS-1$
public static final String IMG_CONTAINER_RUNNING_R_PINNED = "icons/obj16/debugt_obj_r.gif"; //$NON-NLS-1$
public static final String IMG_CONTAINER_RUNNING_G_PINNED = "icons/obj16/debugt_obj_g.gif"; //$NON-NLS-1$
public static final String IMG_CONTAINER_RUNNING_B_PINNED = "icons/obj16/debugt_obj_b.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_PIN_ACTION = "icons/obj16/toolbar_pinned.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_PIN_ACTION_R = "icons/obj16/toolbar_pinned_r.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_PIN_ACTION_G = "icons/obj16/toolbar_pinned_g.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_PIN_ACTION_B = "icons/obj16/toolbar_pinned_b.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_PIN_ACTION_MULTI = "icons/obj16/toolbar_pinned_multi.gif"; //$NON-NLS-1$
/**
* The method finds URL of the image corresponding to the key which could be project-relative path
* of the image in org.eclipse.cdt.ui plugin or a (previously registered) string representation of URL

View file

@ -20,6 +20,7 @@ Export-Package:
org.eclipse.cdt.debug.internal.ui.editors;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.elements.adapters;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.launch;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.pinclone;x-friends:="org.eclipse.cdt.dsf.gdb.ui",
org.eclipse.cdt.debug.internal.ui.preferences;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.propertypages;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.sourcelookup;x-friends:="org.eclipse.cdt.dsf.ui",

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

View file

@ -1049,7 +1049,7 @@
targetID="org.eclipse.debug.ui.ExpressionView">
<action
class="org.eclipse.cdt.debug.internal.ui.actions.PinDebugContextActionDelegate"
icon="icons/elcl16/pin.gif"
icon="icons/elcl16/toolbar_pinned.gif"
id="org.eclipse.pinclone.expression.pinDebugContext"
label="%PinView.name "
style="toggle"
@ -1069,7 +1069,7 @@
targetID="org.eclipse.debug.ui.VariableView">
<action
class="org.eclipse.cdt.debug.internal.ui.actions.PinDebugContextActionDelegate"
icon="icons/elcl16/pin.gif"
icon="icons/elcl16/toolbar_pinned.gif"
id="org.eclipse.pinclone.variable.pinDebugContext"
label="%PinView.name "
style="toggle"
@ -1089,7 +1089,7 @@
targetID="org.eclipse.debug.ui.RegisterView">
<action
class="org.eclipse.cdt.debug.internal.ui.actions.PinDebugContextActionDelegate"
icon="icons/elcl16/pin.gif"
icon="icons/elcl16/toolbar_pinned.gif"
id="org.eclipse.pinclone.register.pinDebugContext"
label="%PinView.name "
style="toggle"

View file

@ -7,23 +7,27 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*****************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.cdt.debug.internal.ui.pinclone.DebugContextPinProvider;
import org.eclipse.cdt.debug.internal.ui.pinclone.DebugEventFilterService;
import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils;
import org.eclipse.cdt.debug.ui.IPinProvider;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinHandleLabelProvider;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextService;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IActionDelegate2;
@ -40,12 +44,13 @@ import org.eclipse.ui.PlatformUI;
* Pin the selected debug context for the view.
*/
public class PinDebugContextActionDelegate implements IViewActionDelegate, IActionDelegate2, IDebugContextListener {
IViewPart fPart;
IAction fAction;
IPartListener2 fPartListener;
DebugContextPinProvider fProvider;
private IViewPart fPart;
private IAction fAction;
private IPartListener2 fPartListener;
private DebugContextPinProvider fProvider;
public PinDebugContextActionDelegate() {}
public PinDebugContextActionDelegate() {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
@ -61,13 +66,13 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
if (action.isChecked()) {
fProvider = DebugEventFilterService.getInstance().addDebugEventFilter(fPart, getActiveDebugContext());
if (fProvider != null) {
// TODO: set image descriptor
updatePinContextColor(fProvider);
updatePinContextLabel(fProvider);
}
} else {
fProvider = null;
DebugEventFilterService.getInstance().removeDebugEventFilter(fPart);
// TODO: remove image descriptor
updatePinContextColor(fProvider);
updatePinContextLabel(fProvider);
}
}
@ -152,8 +157,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
if (provider != null) {
Set<String> labels = new HashSet<String>();
Set<IPinElementHandle> handles = provider.getPinHandles();
for (IPinElementHandle handle : handles) {
for (IPinElementHandle handle : provider.getPinHandles()) {
String tmp = getLabel(handle);
if (tmp != null && tmp.trim().length() != 0)
labels.add(tmp);
@ -162,7 +166,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
for (String label : labels) {
if (label != null) {
if (description.length() > 0) {
description += "," + label; //$NON-NLS-1$
description += ", " + label; //$NON-NLS-1$
} else {
description = label;
}
@ -176,16 +180,77 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
private String getLabel(IPinElementHandle handle) {
String label = ""; //$NON-NLS-1$
if (handle instanceof IAdaptable) {
IPinHandleLabelProvider provider =
(IPinHandleLabelProvider) ((IAdaptable) handle).getAdapter(IPinHandleLabelProvider.class);
if (provider != null)
label = provider.getLabel();
}
if (handle != null)
label = handle.getLabel();
return label;
}
private boolean useMultiPinImage(Set<IPinElementHandle> handles) {
if (handles.size() <= 1) return false;
int overlayColor = IPinElementColorDescriptor.UNDEFINED;
ImageDescriptor imageDesc = null;
for (IPinElementHandle handle : handles) {
IPinElementColorDescriptor colorDesc = handle.getPinElementColorDescriptor();
if (colorDesc != null) {
ImageDescriptor descImageDesc = colorDesc.getToolbarIconDescriptor();
if (imageDesc != null && !imageDesc.equals(descImageDesc))
return true;
imageDesc = descImageDesc;
int descOverlayColor = colorDesc.getOverlayColor();
if (overlayColor != IPinElementColorDescriptor.UNDEFINED && descOverlayColor != overlayColor)
return true;
overlayColor = descOverlayColor;
}
}
return false;
}
private void updatePinContextColor(DebugContextPinProvider provider) {
ImageDescriptor imageDesc = null;
if (provider != null) {
Set<IPinElementHandle> handles = provider.getPinHandles();
// if handles have different toolbar icon descriptor or different pin color, than use a
// multi-pin toolbar icon
if (useMultiPinImage(handles))
imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_MULTI);
if (imageDesc == null) {
Iterator<IPinElementHandle> itr = handles.iterator();
if (itr.hasNext()) {
IPinElementHandle handle = itr.next();
IPinElementColorDescriptor desc = handle.getPinElementColorDescriptor();
if (desc != null)
imageDesc = desc.getToolbarIconDescriptor();
if (imageDesc == null && desc != null) {
int overlayColor = desc.getOverlayColor() % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT;
switch (overlayColor) {
case IPinProvider.IPinElementColorDescriptor.GREEN:
imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_G);
break;
case IPinProvider.IPinElementColorDescriptor.RED:
imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_R);
break;
case IPinProvider.IPinElementColorDescriptor.BLUE:
imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_B);
break;
}
}
}
}
}
if (imageDesc == null)
imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION);
fAction.setImageDescriptor(imageDesc);
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
*/

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*****************************************************************/
package org.eclipse.cdt.debug.internal.ui.pinclone;
@ -93,20 +94,7 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem
* @return true if the pinned handles are pinned to the debug context
*/
public boolean isPinnedTo(Object debugContext) {
IPinProvider pinProvider = null;
if (debugContext instanceof IAdaptable) {
pinProvider = (IPinProvider) ((IAdaptable)debugContext).getAdapter(IPinProvider.class);
}
for (IPinElementHandle handle : fPinHandles) {
if (pinProvider != null && pinProvider.isPinnedTo(debugContext, handle)) {
return true;
} else if (handle.getDebugContext().equals(debugContext)) {
return true;
}
}
return false;
return PinCloneUtils.isPinnedTo(fPinHandles, debugContext);
}
/**
@ -131,7 +119,7 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem
handles.add(handle);
fPinProvider.put(handle, pinProvider);
} else
handles.add(new PinElementHandle(element, null));
handles.add(new PinElementHandle(element, null, PinCloneUtils.getDefaultPinElementColorDescriptor()));
}
}

View file

@ -7,15 +7,20 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*****************************************************************/
package org.eclipse.cdt.debug.internal.ui.pinclone;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Set;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.IPinProvider;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IViewPart;
@ -29,6 +34,29 @@ import org.eclipse.ui.part.WorkbenchPart;
public class PinCloneUtils {
public static String PIN_CLONE_VIEW_TAG = "PIN_CLONE_VIEW_"; //$NON-NLS-1$
private static final DefaultPinElementColorDescriptor DEFAULT_PIN_ELEMENT_COLOR_DESCRIPTOR = new DefaultPinElementColorDescriptor();
/**
* Default pin element color descriptor.
*/
private static class DefaultPinElementColorDescriptor implements IPinElementColorDescriptor {
public int getOverlayColor() {
return GREEN;
}
public ImageDescriptor getToolbarIconDescriptor() {
return null;
}
}
/**
* Returns the default pin element color descriptor.
*
* @return the color descriptor
*/
public static IPinElementColorDescriptor getDefaultPinElementColorDescriptor() {
return DEFAULT_PIN_ELEMENT_COLOR_DESCRIPTOR;
}
/**
* Encodes cloned part secondary id.
*
@ -42,10 +70,12 @@ public class PinCloneUtils {
/**
* Decodes cloned part secondary id.
*
* @param secondaryId the part's secondary id.
* @return a decoded part secondary id.
* @param secondaryId the part's secondary id
* @return a decoded part secondary id
*/
public static String decodeClonedPartSecondaryId(String secondaryId) {
if (secondaryId == null)
return ""; //$NON-NLS-1$
return secondaryId.replaceFirst(PIN_CLONE_VIEW_TAG, ""); //$NON-NLS-1$
}
@ -168,4 +198,64 @@ public class PinCloneUtils {
return pinnable;
}
/**
* Returns the pin element color descriptor for the set of handles. If there are multiple pinned handles,
* then return the default element color descriptor.
*
* @param handles the pinned debug handles
* @param debugContext the debug context to compare with against the handles
* @return the element color descriptor, can be <code>null</code>;
*/
public static IPinElementColorDescriptor getPinElementColorDescriptor(Set<IPinElementHandle> handles, Object debugContext) {
int color = IPinElementColorDescriptor.UNDEFINED;
IPinElementColorDescriptor colorDesc = null;
for (IPinElementHandle handle : handles) {
if (debugContext instanceof IAdaptable) {
IPinProvider pinProvider = (IPinProvider) ((IAdaptable) debugContext).getAdapter(IPinProvider.class);
if (pinProvider != null) {
if (pinProvider.isPinnedTo(debugContext, handle)) {
colorDesc = handle.getPinElementColorDescriptor();
if (colorDesc != null) {
int overlayColor = colorDesc.getOverlayColor();
if (color == IPinElementColorDescriptor.UNDEFINED) color = overlayColor;
if (color != overlayColor) {
colorDesc = null;
break;
}
}
}
}
}
}
if (colorDesc == null)
colorDesc = getDefaultPinElementColorDescriptor();
return colorDesc;
}
/**
* Returns whether the debug context is pinned to any one of these handles.
*
* @param handles the handles
* @param debugContext the debug context
* @return true if pinned to any one of these handles
*/
public static boolean isPinnedTo(Set<IPinElementHandle> handles, Object debugContext) {
for (IPinElementHandle handle : handles) {
if (debugContext instanceof IAdaptable) {
IPinProvider pinProvider = (IPinProvider) ((IAdaptable) debugContext).getAdapter(IPinProvider.class);
if (pinProvider != null) {
if (pinProvider.isPinnedTo(debugContext, handle)) {
return true;
}
}
}
}
return false;
}
}

View file

@ -7,9 +7,11 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*****************************************************************/
package org.eclipse.cdt.debug.ui;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPart;
/**
@ -29,17 +31,49 @@ import org.eclipse.ui.IWorkbenchPart;
*/
public interface IPinProvider {
/**
* An interface that provides label for the pinned handle. Handle that
* wish to provide custom label should implement this interface.
* Pin element color descriptor.
*/
public interface IPinHandleLabelProvider {
public interface IPinElementColorDescriptor {
/**
* Returns the label the label will be used to display
* in the pinned view's descriptor.
*
* @return the handle label
* Default number of color count.
*/
String getLabel();
final int DEFAULT_COLOR_COUNT = 3;
/**
* An undefined color
*/
int UNDEFINED = -1;
/**
* Green color (Default)
*/
int GREEN = 0;
/**
* Red color
*/
int RED = 1;
/**
* Blue color
*/
int BLUE = 2;
/**
* Returns the overlay pin color. The overlay pin will be used to decorate the debug view for element that
* is pinned to a view.
*
* @return one of the overlay color
*/
int getOverlayColor();
/**
* Returns the toolbar pin action image description to use when the view is pinned, can be <code>null</code>.
* If <code>null</code>, than the default image description will be use.
*
* @return the icon descriptor
*/
ImageDescriptor getToolbarIconDescriptor();
}
/**
@ -52,6 +86,21 @@ public interface IPinProvider {
* @return the debug context
*/
Object getDebugContext();
/**
* Returns the label the label will be used to display
* in the pinned view's descriptor.
*
* @return the handle label
*/
String getLabel();
/**
* Returns color descriptor for this element.
*
* @return the color descriptor, can be <code>null</code>
*/
IPinElementColorDescriptor getPinElementColorDescriptor();
}
/**

View file

@ -7,11 +7,12 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*****************************************************************/
package org.eclipse.cdt.debug.ui;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinHandleLabelProvider;
import org.eclipse.core.runtime.PlatformObject;
/**
@ -19,23 +20,34 @@ import org.eclipse.core.runtime.PlatformObject;
*
* @since 7.1
*/
public class PinElementHandle extends PlatformObject implements IPinHandleLabelProvider, IPinElementHandle {
private final Object fDebugContext;
private final String fLabel;
public class PinElementHandle extends PlatformObject implements IPinElementHandle {
private Object fDebugContext;
private String fLabel;
private IPinElementColorDescriptor fColorDescriptor;
public PinElementHandle(Object debugContext, String label) {
public PinElementHandle(Object debugContext, String label, IPinElementColorDescriptor colorDescriptor) {
fDebugContext = debugContext;
fLabel = label;
fColorDescriptor = colorDescriptor;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle#getDebugContext()
*/
public Object getDebugContext() {
public synchronized Object getDebugContext() {
return fDebugContext;
}
/**
* Sets the debug context.
*
* @param debugContext the new debug context
*/
public synchronized void setDebugContext(Object debugContext) {
fDebugContext = debugContext;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IPinProvider.IHandleLabelProvider#getLabel()
@ -44,6 +56,14 @@ public class PinElementHandle extends PlatformObject implements IPinHandleLabelP
return fLabel;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle#getPinElementColorDescriptor()
*/
public IPinElementColorDescriptor getPinElementColorDescriptor() {
return fColorDescriptor;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/

View file

@ -8,6 +8,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
* Navid Mehregani (TI) - Bug 289526 - Migrate the Restart feature to the new one, as supported by the platform
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui;
@ -172,7 +173,7 @@ public class GdbAdapterFactory
fSaveTraceDataTarget = new GdbSaveTraceDataCommand(session);
fSelectNextRecordTarget = new GdbSelectNextTraceRecordCommand(session);
fSelectPrevRecordTarget = new GdbSelectPrevTraceRecordCommand(session);
fPinProvider = new GdbPinProvider();
fPinProvider = new GdbPinProvider(session);
session.registerModelAdapter(ISteppingModeTarget.class, fSteppingModeTarget);
session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand);
@ -285,6 +286,7 @@ public class GdbAdapterFactory
fSaveTraceDataTarget.dispose();
fSelectNextRecordTarget.dispose();
fSelectPrevRecordTarget.dispose();
fPinProvider.dispose();
}
}

View file

@ -0,0 +1,83 @@
/*****************************************************************
* Copyright (c) 2011 Texas Instruments 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:
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*****************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor;
/**
* This class tracks the color for the pinned context.
*/
class GdbPinColorTracker {
private class Pair {
Integer refCount;
String context;
Pair(String context, Integer refCount) {
this.context = context;
this.refCount = refCount;
}
}
private static List<Pair> gsColorBuckets = Collections.synchronizedList( new ArrayList<Pair>() );
/**
* The static instance.
*/
static GdbPinColorTracker INSTANCE = new GdbPinColorTracker();
/**
* Singleton object - make constructor private.
*/
private GdbPinColorTracker() {}
int addRef(String context) {
if (context == null) return IPinElementColorDescriptor.UNDEFINED;
// look in the buckets and see if it is already exist
for (int i = 0; i < gsColorBuckets.size(); ++i) {
Pair pair = gsColorBuckets.get(i);
if (pair.context.equals(context) && pair.refCount > 0) {
pair.refCount++;
return i % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT;
}
}
// if not exist in the buckets, then add to the bucket collection
int size = gsColorBuckets.size();
int index = size;
for (int i = 0; i < size; ++i) {
Pair pair = gsColorBuckets.get(i);
if (pair.refCount <= 0) {
index = i;
gsColorBuckets.remove(index);
break;
}
}
gsColorBuckets.add(index, new Pair(context, 1));
return (index) % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT;
}
void removeRef(String context) {
if (context == null) return;
for (int i = 0; i < gsColorBuckets.size(); ++i) {
Pair pair = gsColorBuckets.get(i);
if (pair.context.equals(context)) {
pair.refCount--;
return;
}
}
}
}

View file

@ -7,14 +7,20 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*****************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import org.eclipse.cdt.debug.ui.IPinProvider;
import org.eclipse.cdt.debug.ui.PinElementHandle;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateInDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.Query;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
@ -22,58 +28,124 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.StateChangedEvent;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPart;
/**
* GDB pin provider implementation.
*/
public class GdbPinProvider implements IPinProvider {
private static class GdbPinElementColorDescriptor implements IPinElementColorDescriptor {
int fColor = GREEN;
private IMIExecutionDMContext getExecutionDmc(IDMContext dmc) {
return DMContexts.getAncestorOfType(dmc, IMIExecutionDMContext.class);
GdbPinElementColorDescriptor(int color) {
fColor = color;
}
public int getOverlayColor() {
return fColor;
}
public ImageDescriptor getToolbarIconDescriptor() {
return null;
}
}
private IProcessDMContext getProcessDmc(IDMContext dmc) {
/**
* A set of pinned element handles.
*/
static private Set<IPinElementHandle> gsPinnedHandles = Collections.synchronizedSet(new HashSet<IPinElementHandle>());
/**
* Dsf session.
*/
private final DsfSession fSession;
/**
* Constructor.
*
* @param session
*/
public GdbPinProvider(DsfSession session) {
fSession = session;
session.getExecutor().execute(new Runnable() {
public void run() {
fSession.addServiceEventListener(GdbPinProvider.this, null);
}
});
}
/**
* Dispose all resources.
*/
public void dispose() {
try {
fSession.getExecutor().execute(new Runnable() {
public void run() {
fSession.removeServiceEventListener(GdbPinProvider.this);
}
});
} catch (RejectedExecutionException e) {
// Session already gone.
}
}
/**
* Returns the pinned element handles.
*
* @return the element handles.
*/
public static Set<IPinElementHandle> getPinnedHandles() {
return gsPinnedHandles;
}
private static IMIExecutionDMContext getExecutionDmc(IDMContext dmc) {
return DMContexts.getAncestorOfType(dmc, IMIExecutionDMContext.class);
}
private static IProcessDMContext getProcessDmc(IDMContext dmc) {
return DMContexts.getAncestorOfType(dmc, IProcessDMContext.class);
}
private IThreadDMData getData(final IThreadDMContext threadDmc) {
if (threadDmc == null)
if (threadDmc == null || !fSession.isActive())
return null;
IThreadDMData data = null;
final DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId());
try {
String sessionId = threadDmc.getSessionId();
DsfSession session = DsfSession.getSession(sessionId);
final DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), sessionId);
try {
if (tracker != null) {
Query<IThreadDMData> query = new Query<IThreadDMData>() {
@Override
protected void execute(DataRequestMonitor<IThreadDMData> rm) {
protected void execute(final DataRequestMonitor<IThreadDMData> rm) {
final IProcesses processes = tracker.getService(IProcesses.class);
if (processes != null) {
processes.getExecutionData(threadDmc, rm);
} else {
rm.setData(null);
rm.done();
}
}
};
session.getExecutor().execute(query);
data = query.get(1, TimeUnit.SECONDS);
}
ImmediateInDsfExecutor immediateExecutor = new ImmediateInDsfExecutor(fSession.getExecutor());
immediateExecutor.execute(query);
data = query.get(2, TimeUnit.SECONDS); // timeout in 2 seconds, in case the call to execute got stuck
} catch (Exception e) {
GdbUIPlugin.log(e);
} finally {
if (tracker != null)
tracker.dispose();
}
} catch (Exception e) {
}
return data;
}
@ -122,19 +194,38 @@ public class GdbPinProvider implements IPinProvider {
public IPinElementHandle pin(IWorkbenchPart part, Object debugContext) {
Object pinContext = debugContext;
String label = ""; //$NON-NLS-1$
String sessionId = ""; //$NON-NLS-1$
IDMContext dmc = null;
if (debugContext instanceof IAdaptable) {
IDMContext dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class);
dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class);
sessionId = dmc.getSessionId() + "."; //$NON-NLS-1$
if (dmc != null) {
IMIExecutionDMContext execDmc = getExecutionDmc(dmc);
IProcessDMContext processDmc = getProcessDmc(dmc);
label = getCombinedLabels(processDmc, execDmc);
if (execDmc != null)
// set the pin context to a thread if it exist
if (execDmc != null) {
dmc = execDmc;
pinContext = execDmc;
// otherwise, set it to the DM context
} else {
pinContext = dmc;
}
}
return new PinElementHandle(pinContext, label);
}
IPinElementColorDescriptor colorDesc =
new GdbPinElementColorDescriptor(GdbPinColorTracker.INSTANCE.addRef(sessionId + label));
PinElementHandle handle = new PinElementHandle(pinContext, label, colorDesc);
gsPinnedHandles.add(handle);
dispatchChangedEvent(dmc);
return handle;
}
/*
@ -142,7 +233,17 @@ public class GdbPinProvider implements IPinProvider {
* @see org.eclipse.cdt.debug.ui.IPinProvider#unpin(org.eclipse.ui.IWorkbenchPart, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle)
*/
public void unpin(IWorkbenchPart part, IPinElementHandle handle) {
// do nothing for now.
// remove the handle from the cache
gsPinnedHandles.remove(handle);
// dispatch the event to update the handle DM context
Object debugContext = handle.getDebugContext();
if (debugContext instanceof IAdaptable) {
IDMContext dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class);
GdbPinColorTracker.INSTANCE.removeRef(dmc.getSessionId() + handle.getLabel());
dispatchChangedEvent(dmc);
}
}
/*
@ -150,19 +251,82 @@ public class GdbPinProvider implements IPinProvider {
* @see org.eclipse.cdt.debug.ui.IPinProvider#isPinnedTo(java.lang.Object, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle)
*/
public boolean isPinnedTo(Object debugContext, IPinElementHandle handle) {
if (debugContext instanceof IAdaptable) {
Object handleDebugContext = handle.getDebugContext();
if (debugContext instanceof IAdaptable && handleDebugContext instanceof IAdaptable) {
IDMContext dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class);
if (dmc != null) {
IDMContext hDmc = (IDMContext) ((IAdaptable) handleDebugContext).getAdapter(IDMContext.class);
if (dmc != null && hDmc != null) {
if (dmc.getSessionId().equals(hDmc.getSessionId())) {
IMIExecutionDMContext execDmc = getExecutionDmc(dmc);
IProcessDMContext processDmc = getProcessDmc(dmc);
if (execDmc != null && processDmc != null ) {
String label = getCombinedLabels(processDmc, execDmc);
if (handle instanceof IPinHandleLabelProvider)
return label.equals( ((IPinHandleLabelProvider)handle).getLabel() );
return label.equals(handle.getLabel());
}
}
}
return false;
}
/**
* Dispatch the change event for the given DM context.
*
* @param dmc the DM context
*/
private void dispatchChangedEvent(IDMContext dmc) {
if (dmc == null)
return;
try {
DsfSession session = DsfSession.getSession(dmc.getSessionId());
if (session != null && session.isActive())
session.dispatchEvent(new StateChangedEvent(dmc), null);
} catch (RejectedExecutionException e) {
// Session already gone.
}
}
/**
* Handle start event and re-attach the DM context to the pinned handles. The DM context
* is used for dispatching event to update the element label.
*/
@DsfServiceEventHandler
public void handleEvent(final IStartedDMEvent event) {
final IDMContext eventDmc = event.getDMContext();
final IMIExecutionDMContext eventExecDmc = getExecutionDmc(eventDmc);
final IProcessDMContext eventProcessDmc = getProcessDmc(eventDmc);
if (eventProcessDmc != null) {
for (final IPinElementHandle h : gsPinnedHandles) {
new Job("Updating pin handler debug context") { //$NON-NLS-1$
{setPriority(INTERACTIVE);}
@Override
protected IStatus run(IProgressMonitor monitor) {
// only attach to the same pin handle if the session is not active
PinElementHandle handle = ((PinElementHandle)h);
Object handleDebugContext = handle.getDebugContext();
if (handleDebugContext instanceof IAdaptable) {
IDMContext handleDmc = (IDMContext) ((IAdaptable) handleDebugContext).getAdapter(IDMContext.class);
if (handleDmc != null) {
DsfSession session = DsfSession.getSession(handleDmc.getSessionId());
if (session == null || !session.isActive()) {
String handleLabel = handle.getLabel();
String label = getCombinedLabels(eventProcessDmc, eventExecDmc);
if (label.equals(handleLabel)) {
IDMContext newDmc = eventExecDmc != null ? eventExecDmc : eventDmc;
handle.setDebugContext(newDmc);
dispatchChangedEvent(newDmc);
}
}
}
}
return Status.OK_STATUS;
}
}.schedule();
}
}
}
}

View file

@ -8,13 +8,17 @@
* Contributors:
* Ericsson - Initial API and implementation
* Wind River Systems - Factored out AbstractContainerVMNode
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
@ -29,6 +33,7 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommand
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractContainerVMNode;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.cdt.dsf.service.DsfSession;
@ -44,6 +49,7 @@ import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMDelegatingPropertiesUpdate;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
@ -86,15 +92,109 @@ public class ContainerVMNode extends AbstractContainerVMNode
IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN,
IGdbLaunchVMConstants.PROP_CORES_ID }),
new LabelText(MessagesForGdbLaunchVM.ContainerVMNode_No_columns__Error__label, new String[0]),
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_SUSPENDED)) {
/* RUNNING CONTAINER - RED PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_R_PINNED)) {
{ setPropertyNames(new String[] {
ILaunchVMConstants.PROP_IS_SUSPENDED,
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED);
Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (prop != null && pin_prop != null && pin_color_prop != null) ?
!prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false;
};
},
/* RUNNING CONTAINER - GREEN PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_G_PINNED)) {
{ setPropertyNames(new String[] {
ILaunchVMConstants.PROP_IS_SUSPENDED,
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED);
Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (prop != null && pin_prop != null && pin_color_prop != null) ?
!prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false;
};
},
/* RUNNING CONTAINER - BLUE PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_B_PINNED)) {
{ setPropertyNames(new String[] {
ILaunchVMConstants.PROP_IS_SUSPENDED,
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED);
Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (prop != null && pin_prop != null && pin_color_prop != null) ?
!prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false;
};
},
/* RUNNING CONTAINER - NO PIN */
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET)) {
{ setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); }
@Override
public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
return Boolean.TRUE.equals(properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED));
return Boolean.FALSE.equals(properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED));
};
},
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET)),
/* SUSPENDED CONTAINER - RED PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_R_PINNED)) {
{ setPropertyNames(new String[] {
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (pin_prop != null && pin_color_prop != null) ?
pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false;
};
},
/* SUSPENDED CONTAINER - GREEN PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_G_PINNED)) {
{ setPropertyNames(new String[] {
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (pin_prop != null && pin_color_prop != null) ?
pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false;
};
},
/* SUSPENDED CONTAINER - BLUE PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_B_PINNED)) {
{ setPropertyNames(new String[] {
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (pin_prop != null && pin_color_prop != null) ?
pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false;
};
},
/* SUSPENDED CONTAINER - NO PIN */
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_SUSPENDED)),
}));
return provider;
@ -140,6 +240,14 @@ public class ContainerVMNode extends AbstractContainerVMNode
parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm);
count++;
// set pin properties
IDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IDMContext.class);
IPinElementColorDescriptor colorDesc = PinCloneUtils.getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), dmc);
updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR,
colorDesc != null ? colorDesc.getOverlayColor() : null);
updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), dmc));
if (update.getProperties().contains(PROP_NAME) ||
update.getProperties().contains(ILaunchVMConstants.PROP_ID) ||
update.getProperties().contains(IGdbLaunchVMConstants.PROP_CORES_ID))

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch;
@ -29,4 +30,13 @@ public interface IGdbLaunchVMConstants {
*/
public static final String PROP_CORES_ID_KNOWN = "cores_id_known"; //$NON-NLS-1$
/**
* The context is pinned. Value <code>true</code> or <code>false</code>.
*/
public static final String PROP_PINNED_CONTEXT = "pinned_context"; //$NON-NLS-1$
/**
* The pin color. One of the <code>IPinElementColorDescriptor</code> color value.
*/
public static final String PROP_PIN_COLOR = "pin_color"; //$NON-NLS-1$
}

View file

@ -8,9 +8,14 @@
* Contributors:
* Wind River Systems - initial API and implementation
* Ericsson - Modified for multi threaded functionality
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch;
import java.util.Map;
import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
@ -20,6 +25,7 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractThreadVMNode;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
@ -35,6 +41,7 @@ import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMDelegatingPropertiesUpdate;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
@ -83,6 +90,55 @@ public class ThreadVMNode extends AbstractThreadVMNode
ExecutionContextLabelText.PROP_STATE_CHANGE_DETAILS_KNOWN,
ILaunchVMConstants.PROP_STATE_CHANGE_DETAILS}),
new LabelText(MessagesForGdbLaunchVM.ThreadVMNode_No_columns__Error__label, new String[0]),
/* RUNNING THREAD - RED PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_R_PINNED)) {
{ setPropertyNames(new String[] {
ILaunchVMConstants.PROP_IS_SUSPENDED,
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED);
Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (prop != null && pin_prop != null && pin_color_prop != null) ?
!prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false;
};
},
/* RUNNING THREAD - GREEN PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_G_PINNED)) {
{ setPropertyNames(new String[] {
ILaunchVMConstants.PROP_IS_SUSPENDED,
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED);
Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (prop != null && pin_prop != null && pin_color_prop != null) ?
!prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false;
};
},
/* RUNNING THREAD - BLUE PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_B_PINNED)) {
{ setPropertyNames(new String[] {
ILaunchVMConstants.PROP_IS_SUSPENDED,
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED);
Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (prop != null && pin_prop != null && pin_color_prop != null) ?
!prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false;
};
},
/* RUNNING THREAD - NO PIN */
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING)) {
{ setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); }
@ -93,6 +149,49 @@ public class ThreadVMNode extends AbstractThreadVMNode
return (prop != null) ? !prop.booleanValue() : false;
};
},
/* SUSPENDED THREAD - RED PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_R_PINNED)) {
{ setPropertyNames(new String[] {
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (pin_prop != null && pin_color_prop != null) ?
pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false;
};
},
/* SUSPENDED THREAD - GREEN PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_G_PINNED)) {
{ setPropertyNames(new String[] {
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (pin_prop != null && pin_color_prop != null) ?
pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false;
};
},
/* SUSPENDED THREAD - BLUE PIN */
new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_B_PINNED)) {
{ setPropertyNames(new String[] {
IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
IGdbLaunchVMConstants.PROP_PIN_COLOR }); }
@Override
public boolean isEnabled(IStatus status, Map<String, Object> properties) {
Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT);
Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR);
return (pin_prop != null && pin_color_prop != null) ?
pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false;
};
},
/* SUSPENDED THREAD - NO PIN */
new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED)),
}));
return provider;
@ -118,6 +217,13 @@ public class ThreadVMNode extends AbstractThreadVMNode
update.getViewerInput(), update.getElementPath(), IMIExecutionDMContext.class);
if (execDmc != null) {
update.setProperty(ILaunchVMConstants.PROP_ID, Integer.toString(execDmc.getThreadId()));
// set pin properties
IPinElementColorDescriptor colorDesc = PinCloneUtils.getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), execDmc);
updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR,
colorDesc != null ? colorDesc.getOverlayColor() : null);
updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT,
PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), execDmc));
}
if (update.getProperties().contains(PROP_NAME) ||

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

View file

@ -68,7 +68,7 @@
targetID="org.eclipse.cdt.dsf.debug.ui.disassembly.view">
<action
class="org.eclipse.cdt.debug.internal.ui.actions.PinDebugContextActionDelegate"
icon="icons/pin.gif"
icon="icons/toolbar_pinned.gif"
id="org.eclipse.pinclone.disassembly.pinDebugContext"
label="%PinView.name "
style="toggle"

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.ui.viewmodel.launch;
@ -294,6 +295,8 @@ public abstract class AbstractContainerVMNode extends AbstractDMVMNode
}
} else if (e instanceof ModelProxyInstalledEvent || e instanceof DataModelInitializedEvent) {
return IModelDelta.SELECT | IModelDelta.EXPAND;
} else if (e instanceof StateChangedEvent) {
return IModelDelta.STATE;
}
return IModelDelta.NO_CHANGE;
}
@ -376,6 +379,10 @@ public abstract class AbstractContainerVMNode extends AbstractDMVMNode
}
});
return;
} else if (e instanceof StateChangedEvent) {
// If there is a state change needed on the container, update the container
if (dmc instanceof IContainerDMContext)
parentDelta.addNode(createVMContext(dmc), IModelDelta.STATE);
}
requestMonitor.done();

View file

@ -8,6 +8,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
* Ericsson - Modified for multi threaded functionality
* Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.ui.viewmodel.launch;
@ -350,6 +351,8 @@ public abstract class AbstractThreadVMNode extends AbstractDMVMNode
return IModelDelta.CONTENT;
} else if (e instanceof ModelProxyInstalledEvent || e instanceof DataModelInitializedEvent) {
return IModelDelta.SELECT | IModelDelta.EXPAND;
} else if (e instanceof StateChangedEvent) {
return IModelDelta.STATE;
}
return IModelDelta.NO_CHANGE;
}
@ -408,8 +411,10 @@ public abstract class AbstractThreadVMNode extends AbstractDMVMNode
rm.done();
}
});
} else if (e instanceof StateChangedEvent) {
parentDelta.addNode(createVMContext(dmc), IModelDelta.STATE);
rm.done();
} else {
rm.done();
}
}

View file

@ -0,0 +1,26 @@
/*****************************************************************
* Copyright (c) 2011 Texas Instruments 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:
* Patrick Chuong (Texas Instruments) - initial API and implementation
*****************************************************************/
package org.eclipse.cdt.dsf.debug.ui.viewmodel.launch;
import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
/**
* A generic UI state changed event.
*
* @since 2.2
*/
public class StateChangedEvent extends AbstractDMEvent<IDMContext> {
public StateChangedEvent(IDMContext context) {
super(context);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

View file

@ -44,7 +44,7 @@
targetID="org.eclipse.cdt.debug.ui.memory.memorybrowser.MemoryBrowser">
<action
class="org.eclipse.cdt.debug.internal.ui.actions.PinDebugContextActionDelegate"
icon="icons/pin.gif"
icon="icons/toolbar_pinned.gif"
id="org.eclipse.pinclone.memoryBrowser.pinDebugContext"
label="%PinView.name "
style="toggle"