Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-debug-dev] Variables and Registers views

Darin,

This is the patch for the Registers view and the corresponding changes. It
is created against the HEAD branch, though I tested it for v20040223.

Thank you,
Mikhail

----- Original Message ----- 
From: "Darin Wright" <Darin_Wright@xxxxxxxxxx>
To: <platform-debug-dev@xxxxxxxxxxx>
Sent: Friday, February 27, 2004 5:45 PM
Subject: Re: [platform-debug-dev] Variables and Registers views


> Sure.
>
> Darin
>
>
>
>
> "Mikhail Khodjaiants" <mikhailk@xxxxxxx>
> Sent by: platform-debug-dev-admin@xxxxxxxxxxx
> 02/27/2004 02:34 PM
> Please respond to
> platform-debug-dev
>
>
> To
> <platform-debug-dev@xxxxxxxxxxx>
> cc
>
> Subject
> Re: [platform-debug-dev] Variables and Registers views
>
>
>
>
>
>
> Unfortunately, the "nice" extension of the "VariablesView" class is not
> possible. The "ViewerState" class assumes that all viewer's elements are
> instances of  "IVaraible" which is not true for the registers view.
> However, replacing "ViewerState" by some abstract class with the abstract
> "encode" and "decode" methods and providing a protected factory method for
> this class will solve the problem.
> Are you interested in these changes?
>
> Thanks,
> Mikhail
> ----- Original Message ----- 
> From: "Darin Wright" <Darin_Wright@xxxxxxxxxx>
> To: <platform-debug-dev@xxxxxxxxxxx>
> Sent: Wednesday, February 25, 2004 3:18 PM
> Subject: Re: [platform-debug-dev] Variables and Registers views
>
>
> > Ideally, you could contribute your registers view to the debug platform.
> > Then it could live in an internal package, taking advantage of the debug
> > view framework. Currently, we do not have cycles to make the views API.
> > Alternatively, you could just subclass our views, knowning that you are
> > vulnerable to breakage.
> >
> > Darin
> >
> >
> >
> >
> > "Mikhail Khodjaiants" <mikhailk@xxxxxxx>
> > Sent by: platform-debug-dev-admin@xxxxxxxxxxx
> > 02/25/2004 01:43 PM
> > Please respond to
> > platform-debug-dev
> >
> >
> > To
> > <platform-debug-dev@xxxxxxxxxxx>
> > cc
> >
> > Subject
> > [platform-debug-dev] Variables and Registers views
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> > I am currently working on the new version of the Registers view for CDT.
> > Functionally the Registers view is identical to the Variables view. The
> > implementation needs some minor changes in the content provider and the
> > event handler. The best way to implement this is to do exactly what has
> > been done for the Expression view - extend the corresponding classes.
> > Unfortunately, this is not an option, the VariablesView class and all
> > related classes are internal. All I can do now is create copies of the
> > internal classes and follow the changes.
> > Are there any suggestions on how to handle the situations like this
> > differently?
> >
> > Thanks,
> > Mikhail Khodjaiants
> > QNX Software Systems
> >
> > _______________________________________________
> > platform-debug-dev mailing list
> > platform-debug-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/platform-debug-dev
> >
>
> _______________________________________________
> platform-debug-dev mailing list
> platform-debug-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-debug-dev
>
>
> _______________________________________________
> platform-debug-dev mailing list
> platform-debug-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-debug-dev
>
Index: plugin.properties
===================================================================
retrieving revision 1.109
diff -u -r1.109 plugin.properties
--- plugin.properties	26 Feb 2004 20:41:36 -0000	1.109
+++ plugin.properties	2 Mar 2004 22:59:19 -0000
@@ -65,6 +65,7 @@
 ProfileHistoryMenuAction.label=Profile Histor&y
 ProfileLastAction.label=Profi&le Last Launched
 ProfileActionSet.label=Profile
+RegistersView.name=Registers
 RelaunchAction.label=Re&launch
 RemoveAction.label=Rem&ove
 RemoveAllAction.label=Remove A&ll
Index: plugin.xml
===================================================================
retrieving revision 1.177
diff -u -r1.177 plugin.xml
--- plugin.xml	26 Feb 2004 20:41:36 -0000	1.177
+++ plugin.xml	2 Mar 2004 22:59:20 -0000
@@ -95,6 +95,13 @@
             class="org.eclipse.debug.internal.ui.views.expression.ExpressionView"
             id="org.eclipse.debug.ui.ExpressionView">
       </view>
+      <view
+            name="%RegistersView.name"
+            icon="icons/full/cview16/register_view.gif"
+            category="org.eclipse.debug.ui"
+            class="org.eclipse.debug.internal.ui.views.registers.RegistersView"
+            id="org.eclipse.debug.ui.RegistersView">
+      </view>
    </extension>
    <extension
          point="org.eclipse.ui.preferencePages">
@@ -644,6 +651,19 @@
                id="org.eclipse.debug.ui.expresssionsView.toolbar.detailPaneWordWrap">
          </action>
       </viewContribution>
+      <viewContribution
+            targetID="org.eclipse.debug.ui.RegistersView"
+            id="org.eclipse.debug.ui.registersView.toolbar">
+         <action
+               label="%DetailPaneWordWrapAction.label"
+               style="toggle"
+               helpContextId="detail_pane_word_wrap_action_context"
+               tooltip="%DetailPaneWordWrapAction.tooltip"
+               class="org.eclipse.debug.internal.ui.views.variables.DetailPaneWordWrapAction"
+               menubarPath="viewActions"
+               id="org.eclipse.debug.ui.variableViewActions.toolbar.detailPaneWordWrap">
+         </action>
+      </viewContribution>
    </extension>
    <extension
          point="org.eclipse.ui.popupMenus">
@@ -1016,6 +1036,29 @@
                class="org.eclipse.debug.internal.ui.actions.SelectAllExpressionsAction"
                menubarPath="expressionGroup"
                id="org.eclipse.debug.ui.actions.SelectAllExpressionsAction">
+         </action>
+      </viewerContribution>
+      <viewerContribution
+            targetID="org.eclipse.debug.ui.RegistersView"
+            id="org.eclipse.debug.ui.registersView.popupMenu">
+<!-- Variable Group -->
+         <action
+               menubarPath="variableGroup"
+               class="org.eclipse.debug.internal.ui.actions.CopyVariablesToClipboardActionDelegate"
+               icon="icons/full/clcl16/copy_edit_co.gif"
+               label="%CopyVariablesToClipboardAction.label"
+               id="org.eclipse.debug.ui.debugview.popupMenu.copyVariablesToClipboard"
+               helpContextId="copy_variables_to_clipboard_action_context">
+            <selection
+                  class="org.eclipse.debug.core.model.IDebugElement">
+            </selection>
+         </action>
+         <action
+               class="org.eclipse.debug.internal.ui.actions.SelectAllVariablesAction"
+               label="%SelectAll.label"
+               menubarPath="variableGroup"
+               helpContextId="select_all_variables_action_context"
+               id="org.eclipse.debug.ui.actions.SelectAllVariablesAction">
          </action>
       </viewerContribution>
    </extension>
Index: ui/org/eclipse/debug/internal/ui/DebugPluginImages.java
===================================================================
retrieving revision 1.53
diff -u -r1.53 DebugPluginImages.java
--- ui/org/eclipse/debug/internal/ui/DebugPluginImages.java	26 Feb 2004 17:16:09 -0000	1.53
+++ ui/org/eclipse/debug/internal/ui/DebugPluginImages.java	2 Mar 2004 22:59:24 -0000
@@ -132,6 +132,8 @@
 		declareRegistryImage(IDebugUIConstants.IMG_OBJS_STACKFRAME, OBJECT + "stckframe_obj.gif"); //$NON-NLS-1$
 		declareRegistryImage(IDebugUIConstants.IMG_OBJS_STACKFRAME_RUNNING, OBJECT + "stckframe_running_obj.gif"); //$NON-NLS-1$
 		declareRegistryImage(IDebugUIConstants.IMG_OBJS_VARIABLE, OBJECT + "genericvariable_obj.gif"); //$NON-NLS-1$
+		declareRegistryImage(IDebugUIConstants.IMG_OBJS_REGISTER, OBJECT + "genericregister_obj.gif"); //$NON-NLS-1$
+		declareRegistryImage(IDebugUIConstants.IMG_OBJS_REGISTER_GROUP, OBJECT + "genericreggroup_obj.gif"); //$NON-NLS-1$
 		declareRegistryImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT, OBJECT + "brkp_obj.gif"); //$NON-NLS-1$
 		declareRegistryImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED, OBJECT + "brkpd_obj.gif"); //$NON-NLS-1$
 		declareRegistryImage(IDebugUIConstants.IMG_OBJS_OS_PROCESS, OBJECT + "osprc_obj.gif"); //$NON-NLS-1$
Index: ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java
===================================================================
retrieving revision 1.28
diff -u -r1.28 DefaultLabelProvider.java
--- ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java	2 Mar 2004 00:27:34 -0000	1.28
+++ ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java	2 Mar 2004 22:59:25 -0000
@@ -28,6 +28,8 @@
 import org.eclipse.debug.core.model.IDisconnect;
 import org.eclipse.debug.core.model.IExpression;
 import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IRegister;
+import org.eclipse.debug.core.model.IRegisterGroup;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.ITerminate;
 import org.eclipse.debug.core.model.IThread;
@@ -71,7 +73,11 @@
 		if (element instanceof IDebugElement) {
 			// Group elements into debug elements and non-debug elements
 			// to reduce the number of instanceof checks performed
-			if (element instanceof IVariable) {
+			if (element instanceof IRegister) {
+				return IDebugUIConstants.IMG_OBJS_REGISTER;
+			} else if (element instanceof IRegisterGroup) {
+				return IDebugUIConstants.IMG_OBJS_REGISTER_GROUP;
+			} else if (element instanceof IVariable) {
 				if (element instanceof IndexedVariablePartition) {
 					return IInternalDebugUIConstants.IMG_OBJS_ARRAY_PARTITION;
 				} else {
@@ -169,6 +175,8 @@
 					label.append((((IDebugTarget)element).getName()));
 				} else if (element instanceof IExpression) {
 					label.append(getExpressionText((IExpression)element));
+				} else if (element instanceof IRegisterGroup) {
+					label.append(getRegisterGroupText((IRegisterGroup)element));
 				} 
 			} else {
 				if (element instanceof IMarker) {
@@ -299,6 +307,16 @@
 			buffer.append(variable.getName());
 			buffer.append(" = "); //$NON-NLS-1$
 			buffer.append(value.getValueString());
+		} catch (DebugException de) {
+			DebugUIPlugin.log(de);
+		}
+		return buffer.toString();
+	}
+	
+	protected String getRegisterGroupText(IRegisterGroup registerGroup) {
+		StringBuffer buffer= new StringBuffer();
+		try {
+			buffer.append(registerGroup.getName());
 		} catch (DebugException de) {
 			DebugUIPlugin.log(de);
 		}
Index: ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
===================================================================
retrieving revision 1.35
diff -u -r1.35 IDebugHelpContextIds.java
--- ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java	26 Feb 2004 17:16:09 -0000	1.35
+++ ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java	2 Mar 2004 22:59:25 -0000
@@ -53,6 +53,7 @@
 	public static final String BREAKPOINT_VIEW = PREFIX + "breakpoint_view_context"; //$NON-NLS-1$
 	public static final String EXPRESSION_VIEW = PREFIX + "expression_view_context"; //$NON-NLS-1$
 	public static final String LAUNCH_CONFIGURATION_VIEW = PREFIX + "launch_configuration_view_context"; //$NON-NLS-1$
+	public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$
 	
 	// Preference pages
 	public static final String DEBUG_PREFERENCE_PAGE = PREFIX + "debug_preference_page_context"; //$NON-NLS-1$
Index: ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java
===================================================================
retrieving revision 1.19
diff -u -r1.19 IDebugPreferenceConstants.java
--- ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java	8 Dec 2003 22:18:06 -0000	1.19
+++ ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java	2 Mar 2004 22:59:27 -0000
@@ -73,6 +73,7 @@
 	 */
 	public static final String VARIABLES_DETAIL_PANE_ORIENTATION = "Variables.detail.orientation"; //$NON-NLS-1$
 	public static final String EXPRESSIONS_DETAIL_PANE_ORIENTATION = "Expressions.detail.orientation"; //$NON-NLS-1$
+	public static final String REGISTERS_DETAIL_PANE_ORIENTATION = "Registers.detail.orientation"; //$NON-NLS-1$
 	public static final String VARIABLES_DETAIL_PANE_RIGHT = "Variables.detail.orientation.right"; //$NON-NLS-1$
 	public static final String VARIABLES_DETAIL_PANE_UNDERNEATH = "Variables.detail.orientation.underneath"; //$NON-NLS-1$
 	public static final String VARIABLES_DETAIL_PANE_HIDDEN = "Variables.detail.orientation.hidden"; //$NON-NLS-1$
Index: ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
===================================================================
retrieving revision 1.72
diff -u -r1.72 VariablesView.java
--- ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java	2 Mar 2004 22:43:38 -0000	1.72
+++ ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java	2 Mar 2004 22:59:29 -0000
@@ -40,6 +40,7 @@
 import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
 import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandler;
 import org.eclipse.debug.internal.ui.views.AbstractDebugEventHandlerView;
+import org.eclipse.debug.internal.ui.views.AbstractViewerState;
 import org.eclipse.debug.internal.ui.views.DebugViewDecoratingLabelProvider;
 import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider;
 import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator;
@@ -278,7 +279,7 @@
 	 * in the variables view when there is no state to go on for the
 	 * current stack frame being displayed.
 	 */
-	private ViewerState fLastState = null;
+	private AbstractViewerState fLastState = null;
 	
 	/**
 	 * Remembers which viewer (tree viewer or details viewer) had focus, so we
@@ -345,7 +346,7 @@
 
 		if (current != null) {
 			// save state
-			fLastState = new ViewerState(getVariablesViewer());
+			fLastState = getViewerState();
 			fSelectionStates.put(current, fLastState);
 		}		
 		
@@ -357,7 +358,7 @@
 		
 		// restore state
 		if (frame != null) {
-			ViewerState state = (ViewerState)fSelectionStates.get(frame);
+			AbstractViewerState state = (AbstractViewerState)fSelectionStates.get(frame);
 			if (state == null) {
 				// attempt to restore selection/expansion based on last frame
 				state = fLastState;
@@ -1345,4 +1346,12 @@
 		}
 	}
 
+	/**
+	 * Returns the memento of the expanded and selected items in the viewer.
+	 * 
+	 * @return the memento of the expanded and selected items in the viewer
+	 */
+	protected AbstractViewerState getViewerState() {
+		return new ViewerState(getVariablesViewer());
+	}
 }
Index: ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java
===================================================================
retrieving revision 1.5
diff -u -r1.5 ViewerState.java
--- ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java	4 Nov 2003 03:57:05 -0000	1.5
+++ ui/org/eclipse/debug/internal/ui/views/variables/ViewerState.java	2 Mar 2004 22:59:29 -0000
@@ -10,16 +10,12 @@
  *******************************************************************************/
 package org.eclipse.debug.internal.ui.views.variables;
 
-
-import java.util.ArrayList;
-import java.util.List;
-
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.views.AbstractViewerState;
 import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.widgets.TreeItem;
 
@@ -28,114 +24,19 @@
  * 
  * @since 2.1
  */
-public class ViewerState {
+public class ViewerState extends AbstractViewerState {
 
-	// paths to expanded variables
-	private List fExpandedElements = null;
-	// paths to selected variables	
-	private IPath[] fSelection = null;
-	
 	/**
 	 * Constructs a memento for the given viewer.
 	 */
 	public ViewerState(TreeViewer viewer) {
-		saveState(viewer);
+		super(viewer);
 	}
 
 	/**
-	 * Saves the current state of the given viewer into
-	 * this memento.
-	 * 
-	 * @param viewer viewer of which to save the state
+	 * @see org.eclipse.debug.internal.ui.views.AbstractViewerState#encodeElement(org.eclipse.swt.widgets.TreeItem)
 	 */
-	public void saveState(TreeViewer viewer) {
-		List expanded = new ArrayList();
-		fExpandedElements = null;
-		TreeItem[] items = viewer.getTree().getItems();
-		try {
-			for (int i = 0; i < items.length; i++) {
-				collectExandedItesm(items[i], expanded);
-			}
-			if (expanded.size() > 0) {
-				fExpandedElements = expanded;
-			}
-		} catch (DebugException e) {
-			fExpandedElements = null;
-		}
-		
-		TreeItem[] selection = viewer.getTree().getSelection();
-		fSelection = new IPath[selection.length];
-		try {
-			for (int i = 0; i < selection.length; i++) {
-				fSelection[i] = encodeVariable(selection[i]);
-			}
-		} catch (DebugException e) {
-			fSelection = null;
-		}
-	}
-	
-	protected void collectExandedItesm(TreeItem item, List expanded) throws DebugException {
-		if (item.getExpanded()) {
-			expanded.add(encodeVariable(item));
-			TreeItem[] items = item.getItems();
-			for (int i = 0; i < items.length; i++) {
-				collectExandedItesm(items[i], expanded);
-			}
-		}
-	}
-	
-	/**
-	 * Restores the state of the given viewer to this mementos
-	 * saved state.
-	 * 
-	 * @param viewer viewer to which state is restored
-	 */
-	public void restoreState(TreeViewer viewer) {
-		if (fExpandedElements != null) {
-			List expansion = new ArrayList(fExpandedElements.size());
-			for (int i = 0; i < fExpandedElements.size(); i++) {
-				IPath path = (IPath) fExpandedElements.get(i);
-				if (path != null) {
-					IVariable var;
-					try {
-						var = decodePath(path, viewer);
-						if (var != null) {
-							expansion.add(var);
-						}
-					} catch (DebugException e) {
-					}
-				}
-			}
-			viewer.setExpandedElements(expansion.toArray());
-		}
-		if (fSelection != null) {
-			List selection = new ArrayList(fSelection.length);
-			for (int i = 0; i < fSelection.length; i++) {
-				IPath path = fSelection[i];
-				IVariable var;
-				try {
-					var = decodePath(path, viewer);
-					if (var != null) {
-						selection.add(var);
-					}
-				} catch (DebugException e) {
-				}
-			}			
-			
-			viewer.setSelection(new StructuredSelection(selection));
-		}
-	}
-	
-	/**
-	 * Constructs a path representing the given variable. The segments in the
-	 * path denote parent variable names, and the last segment is the name of
-	 * the given variable.
-	 *   
-	 * @param item tree item containing the variable to encode
-	 * @return path encoding the given variable
-	 * @throws DebugException if unable to generate a path
-	 */
-	protected IPath encodeVariable(TreeItem item) throws DebugException {
+	protected IPath encodeElement(TreeItem item) throws DebugException {
 		IVariable variable = (IVariable)item.getData();
 		IPath path = new Path(variable.getName());
 		TreeItem parent = item.getParentItem();
@@ -146,17 +47,11 @@
 		}
 		return path;
 	}
-	
+
 	/**
-	 * Returns a variable in the given viewer that corresponds to the given
-	 * path, or <code>null</code> if none.
-	 * 
-	 * @param path encoded variable path
-	 * @param viewer viewer to search for the variable in
-	 * @return variable represented by the path, or <code>null</code> if none
-	 * @throws DebugException if unable to locate a variable
+	 * @see org.eclipse.debug.internal.ui.views.AbstractViewerState#decodePath(org.eclipse.core.runtime.IPath, org.eclipse.jface.viewers.TreeViewer)
 	 */
-	protected IVariable decodePath(IPath path, TreeViewer viewer) throws DebugException {
+	protected Object decodePath(IPath path, TreeViewer viewer) throws DebugException {
 		ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
 		String[] names = path.segments();
 		Object parent = viewer.getInput();
Index: ui/org/eclipse/debug/ui/IDebugUIConstants.java
===================================================================
retrieving revision 1.105
diff -u -r1.105 IDebugUIConstants.java
--- ui/org/eclipse/debug/ui/IDebugUIConstants.java	26 Feb 2004 17:16:09 -0000	1.105
+++ ui/org/eclipse/debug/ui/IDebugUIConstants.java	2 Mar 2004 22:59:30 -0000
@@ -278,6 +278,12 @@
 	public static final String ID_EXPRESSION_VIEW= "org.eclipse.debug.ui.ExpressionView"; //$NON-NLS-1$
 		
 	/**
+	 * Register view identifier (value <code>"org.eclipse.debug.ui.RegisterView"</code>).
+	 * @since 3.0
+	 */
+	public static final String ID_REGISTER_VIEW= "org.eclipse.debug.ui.RegisterView"; //$NON-NLS-1$
+		
+	/**
 	 * Console view identifier (value <code>"org.eclipse.debug.ui.ConsoleView"</code>).
 	 * @deprecated Use org.eclipse.ui.console.IConsoleConstants.ID_CONSOLE_VIEW 
 	 * @since 3.0
@@ -478,6 +484,20 @@
 	 */
 	public static final String IMG_OBJS_VARIABLE= "IMG_OBJS_VARIABLE"; //$NON-NLS-1$
 
+	/**
+	 * Generic identifier of register group image.
+	 * 
+	 * @since 3.0
+	 */
+	public static final String IMG_OBJS_REGISTER_GROUP= "IMG_OBJS_REGISTER_GROUP"; //$NON-NLS-1$
+
+	/**
+	 * Generic register image identifier.
+	 * 
+	 * @since 3.0
+	 */
+	public static final String IMG_OBJS_REGISTER= "IMG_OBJS_REGISTER"; //$NON-NLS-1$
+
 	// views
 	
 	/** 
@@ -692,6 +712,17 @@
 	 * Identifier for a property group in a menu (value <code>"propertyGroup"</code>).
 	 */
 	public static final String PROPERTY_GROUP = "propertyGroup"; //$NON-NLS-1$
+	
+	/** 
+	 * Identifier for an empty group preceding a
+	 * register group in a menu (value <code>"emptyRegisterGroup"</code>).
+	 */
+	public static final String EMPTY_REGISTER_GROUP = "emptyRegisterGroup"; //$NON-NLS-1$
+	
+	/**
+	 * Identifier for a register group in a menu (value <code>"registerGroup"</code>).
+	 */
+	public static final String REGISTER_GROUP = "registerGroup"; //$NON-NLS-1$
 	
 	/**
 	 * Id for the popup menu associated with the variables (tree viewer) part of the VariableView
Index: icons/full/cview16/register_view.gif
===================================================================
RCS file: icons/full/cview16/register_view.gif
diff -N icons/full/cview16/register_view.gif
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ icons/full/cview16/register_view.gif	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a¢€_Ÿ¿_ŸŸÿÿÿÿÿÿ!ù,<XºÜ:0J)Ê 8ë\o_8vb:®)ʾ­E‚i_[N¸³Ùï2Œ'¼Õh#J·éžÐhÔA­Z	;
Index: icons/full/eview16/register_view.gif
===================================================================
RCS file: icons/full/eview16/register_view.gif
diff -N icons/full/eview16/register_view.gif
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ icons/full/eview16/register_view.gif	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a¢ÿÿÿŸŸŸ€€€___ÿÿÿ!ù,;HºÜ*0J9ˆ8ë\oà?"ЕWŠšÖªªçŽ3{m¸]Ê;y¾.øðhºÜ¦3h:ŸO‡tJU$;
Index: icons/full/obj16/genericreggroup_obj.gif
===================================================================
RCS file: icons/full/obj16/genericreggroup_obj.gif
diff -N icons/full/obj16/genericreggroup_obj.gif
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ icons/full/obj16/genericreggroup_obj.gif	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,3 @@
+GIF89aĀ??Ÿ??_?_Ÿ_Ÿ¿?Ÿ¿Ÿ¿¿¿ß¿ŸŸ_¿¿ßߟ_ŸŸßß¿ÿûðÿÿÿ¿¿¿ccc___ÿÿÿ!ù,|àd?15’Ôˆ¤9
+‡!L’£Ho<¿F1KŠÄlÐÛAÈI"X““£A†
+6‰²c¬±%’m!›ºA„@,`¸ßpø¢ý¨Ûïö9ãA|~€{?‰„Šˆ‹??{}?–„“{x?…”¡¢££¦§¨©¦!;
Index: icons/full/obj16/genericregister_obj.gif
===================================================================
RCS file: icons/full/obj16/genericregister_obj.gif
diff -N icons/full/obj16/genericregister_obj.gif
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ icons/full/obj16/genericregister_obj.gif	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a¢€_Ÿ¿_ŸŸÿÿÿÿÿÿ!ù,;XºÜþlÈI©(ƒèÍ÷ÍŽåG®e»ªnüb¦¸žsÖí\£¿M&ós7[	§âu>‚¨t:…X;
Index: ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java
===================================================================
RCS file: ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java
diff -N ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ui/org/eclipse/debug/internal/ui/views/AbstractViewerState.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,144 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved.   This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors: 
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.debug.internal.ui.views;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * The abstract superclass for mementos of the expanded and 
+ * selected items in a tree viewer.
+ */
+public abstract class AbstractViewerState {
+
+	// paths to expanded elements
+	private List fExpandedElements = null;
+	// paths to selected elements
+	private IPath[] fSelection = null;
+	
+	/**
+	 * Constructs a memento for the given viewer.
+	 */
+	public AbstractViewerState(TreeViewer viewer) {
+		saveState(viewer);
+	}
+
+	/**
+	 * Saves the current state of the given viewer into
+	 * this memento.
+	 * 
+	 * @param viewer viewer of which to save the state
+	 */
+	public void saveState(TreeViewer viewer) {
+		List expanded = new ArrayList();
+		fExpandedElements = null;
+		TreeItem[] items = viewer.getTree().getItems();
+		try {
+			for (int i = 0; i < items.length; i++) {
+				collectExandedItems(items[i], expanded);
+			}
+			if (expanded.size() > 0) {
+				fExpandedElements = expanded;
+			}
+		} catch (DebugException e) {
+			fExpandedElements = null;
+		}
+		TreeItem[] selection = viewer.getTree().getSelection();
+		fSelection = new IPath[selection.length];
+		try {
+			for (int i = 0; i < selection.length; i++) {
+				fSelection[i] = encodeElement(selection[i]);
+			}
+		} catch (DebugException e) {
+			fSelection = null;
+		}
+	}
+
+	protected void collectExandedItems(TreeItem item, List expanded)
+			throws DebugException {
+		if (item.getExpanded()) {
+			expanded.add(encodeElement(item));
+			TreeItem[] items = item.getItems();
+			for (int i = 0; i < items.length; i++) {
+				collectExandedItems(items[i], expanded);
+			}
+		}
+	}
+
+	/**
+	 * Constructs a path representing the given tree item. The segments in the
+	 * path denote parent items, and the last segment is the name of
+	 * the given item.
+	 *   
+	 * @param item tree item to encode
+	 * @return path encoding the given item
+	 * @throws DebugException if unable to generate a path
+	 */
+	protected abstract IPath encodeElement(TreeItem item) throws DebugException;
+
+	/**
+	 * Restores the state of the given viewer to this memento's
+	 * saved state.
+	 * 
+	 * @param viewer viewer to which state is restored
+	 */
+	public void restoreState(TreeViewer viewer) {
+		if (fExpandedElements != null) {
+			List expansion = new ArrayList(fExpandedElements.size());
+			for (int i = 0; i < fExpandedElements.size(); i++) {
+				IPath path = (IPath) fExpandedElements.get(i);
+				if (path != null) {
+					Object obj;
+					try {
+						obj = decodePath(path, viewer);
+						if (obj != null) {
+							expansion.add(obj);
+						}
+					} catch (DebugException e) {
+					}
+				}
+			}
+			viewer.setExpandedElements(expansion.toArray());
+		}
+		if (fSelection != null) {
+			List selection = new ArrayList(fSelection.length);
+			for (int i = 0; i < fSelection.length; i++) {
+				IPath path = fSelection[i];
+				Object obj;
+				try {
+					obj = decodePath(path, viewer);
+					if (obj != null) {
+						selection.add(obj);
+					}
+				} catch (DebugException e) {
+				}
+			}
+			viewer.setSelection(new StructuredSelection(selection));
+		}
+	}
+	
+	/**
+	 * Returns an element in the given viewer that corresponds to the given
+	 * path, or <code>null</code> if none.
+	 * 
+	 * @param path encoded element path
+	 * @param viewer viewer to search for the element in
+	 * @return element represented by the path, or <code>null</code> if none
+	 * @throws DebugException if unable to locate a variable
+	 */
+	protected abstract Object decodePath(IPath path, TreeViewer viewer) throws DebugException;
+
+}
Index: ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java
===================================================================
RCS file: ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java
diff -N ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ui/org/eclipse/debug/internal/ui/views/registers/RegistersView.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,73 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved.   This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors: 
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.debug.internal.ui.views.registers;
+
+import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
+import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
+import org.eclipse.debug.internal.ui.views.AbstractViewerState;
+import org.eclipse.debug.internal.ui.views.variables.VariablesView;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.IContentProvider;
+
+/**
+ * Displays registers and their values with a detail area.
+ */
+public class RegistersView extends VariablesView {
+	
+	/**
+	 * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#createContentProvider()
+	 */
+	protected IContentProvider createContentProvider() {
+		RegistersViewContentProvider cp = new RegistersViewContentProvider(this);
+		cp.setExceptionHandler(this);
+		return cp;
+	}
+
+	/**
+	 * @see org.eclipse.debug.ui.AbstractDebugView#getHelpContextId()
+	 */
+	protected String getHelpContextId() {
+		return IDebugHelpContextIds.REGISTERS_VIEW;
+	}
+
+	/**
+	 * @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(org.eclipse.jface.action.IToolBarManager)
+	 */
+	protected void configureToolBar(IToolBarManager tbm) {
+		super.configureToolBar(tbm);
+		tbm.add(new Separator(IDebugUIConstants.EMPTY_REGISTER_GROUP));		
+		tbm.add(new Separator(IDebugUIConstants.REGISTER_GROUP));
+	}
+
+	/**
+	 * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#getDetailPanePreferenceKey()
+	 */
+	protected String getDetailPanePreferenceKey() {
+		return IDebugPreferenceConstants.REGISTERS_DETAIL_PANE_ORIENTATION;
+	}
+
+	/**
+	 * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#getToggleActionLabel()
+	 */
+	protected String getToggleActionLabel() {
+		return RegistersViewMessages.getString("RegistersView.0"); //$NON-NLS-1$
+	}
+
+	/**
+	 * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#getViewerState()
+	 */
+	protected AbstractViewerState getViewerState() {
+		return new RegistersViewerState(getVariablesViewer());
+	}
+}
Index: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewContentProvider.java
===================================================================
RCS file: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewContentProvider.java
diff -N ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewContentProvider.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewContentProvider.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,82 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved.   This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors: 
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.debug.internal.ui.views.registers;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.views.IDebugExceptionHandler;
+import org.eclipse.debug.internal.ui.views.variables.VariablesViewContentProvider;
+import org.eclipse.debug.ui.IDebugView;
+
+/**
+ * Provides contents for the registers view
+ */
+public class RegistersViewContentProvider extends VariablesViewContentProvider {
+
+	public RegistersViewContentProvider(IDebugView view) {
+		super(view);
+	}
+
+	/**
+	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+	 */
+	public Object[] getChildren(Object parent) {
+		Object[] children= null;
+		try {
+			if (parent instanceof IStackFrame) {
+				children = ((IStackFrame)parent).getRegisterGroups();
+			} else if (parent instanceof IRegisterGroup) {
+				children = ((IRegisterGroup)parent).getRegisters();
+			} else if (parent instanceof IVariable) {
+				children = super.getChildren( parent );
+			}
+			if (children != null) {
+				cache(parent, children);
+				return children;
+			}
+		} catch (DebugException de) {
+			if (getExceptionHandler() != null) {
+				getExceptionHandler().handleException(de);
+			} else {
+				DebugUIPlugin.log(de);
+			}
+		}
+		return new Object[0];
+	}
+
+	/**
+	 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+	 */
+	public boolean hasChildren(Object element) {
+		try {
+			if (element instanceof IStackFrame) {
+				return ((IStackFrame)element).hasRegisterGroups();
+			}
+			if (element instanceof IRegisterGroup) {
+				return ((IRegisterGroup)element).hasRegisters();
+			}
+		} catch (DebugException de) {
+			DebugUIPlugin.log(de);
+			return false;
+		}
+		return super.hasChildren(element);
+	}
+
+	/**
+	 * @see org.eclipse.debug.internal.ui.views.variables.VariablesViewContentProvider#setExceptionHandler(org.eclipse.debug.internal.ui.views.IDebugExceptionHandler)
+	 */
+	protected void setExceptionHandler(IDebugExceptionHandler handler) {
+		super.setExceptionHandler(handler);
+	}
+}
Index: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.java
===================================================================
RCS file: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.java
diff -N ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,33 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved.   This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors: 
+ * QNX Software Systems - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.debug.internal.ui.views.registers;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class RegistersViewMessages {
+
+	private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.views.registers.RegistersViewMessages";//$NON-NLS-1$
+	
+	private static final ResourceBundle RESOURCE_BUNDLE = 
+		ResourceBundle.getBundle(BUNDLE_NAME);
+
+	private RegistersViewMessages() {
+	}
+
+	public static String getString(String key) {
+		try {
+			return RESOURCE_BUNDLE.getString(key);
+		} catch (MissingResourceException e) {
+			return '!' + key + '!';
+		}
+	}
+}
Index: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.properties
===================================================================
RCS file: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.properties
diff -N ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.properties
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewMessages.properties	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+RegistersView.0=Registers View Only
Index: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java
===================================================================
RCS file: ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java
diff -N ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ui/org/eclipse/debug/internal/ui/views/registers/RegistersViewerState.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,87 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved.   This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors: 
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.debug.internal.ui.views.registers;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.views.AbstractViewerState;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Memento of the expanded and selected items in a registers viewer.
+ * 
+ */
+public class RegistersViewerState extends AbstractViewerState {
+
+	public RegistersViewerState( TreeViewer viewer ) {
+		super( viewer );
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#encodeElement(org.eclipse.swt.widgets.TreeItem)
+	 */
+	public IPath encodeElement( TreeItem item ) throws DebugException {
+		Object obj = item.getData();
+		String name = ( obj instanceof IRegisterGroup ) ? 
+						((IRegisterGroup)obj).getName() : ((IVariable)obj).getName();
+		IPath path = new Path( name );
+		TreeItem parent = item.getParentItem();
+		while( parent != null ) {
+			obj = parent.getData();
+			name = ( obj instanceof IRegisterGroup ) ? 
+					 ((IRegisterGroup)obj).getName() : ((IVariable)obj).getName();
+			path = new Path( name ).append( path );
+			parent = parent.getParentItem();
+		}
+		return path;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#decodePath(org.eclipse.core.runtime.IPath, org.eclipse.jface.viewers.TreeViewer)
+	 */
+	public Object decodePath( IPath path, TreeViewer viewer ) throws DebugException {
+		ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
+		String[] names = path.segments();
+		Object parent = viewer.getInput();
+		Object element = null;
+		for( int i = 0; i < names.length; i++ ) {
+			element = null;
+			Object[] children = contentProvider.getChildren( parent );
+			String name = names[i];
+			for( int j = 0; j < children.length; j++ ) {
+				if ( children[j] instanceof IRegisterGroup ) {	
+					if ( name.equals( ((IRegisterGroup)children[j]).getName() ) ) {
+						element = children[j];
+						break;
+					}
+				}
+				else if ( children[j] instanceof IVariable ) {	
+					if ( name.equals( ((IVariable)children[j]).getName() ) ) {
+						element = children[j];
+						break;
+					}
+				}
+			}
+			if ( element == null ) {
+				return null;
+			} 
+			else {
+				parent = element;
+			}
+		}
+		return element;
+	}
+}

Back to the top