diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog
index 32ab0a56956..e0cfb0c9b3c 100644
--- a/debug/org.eclipse.cdt.debug.ui/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog
@@ -1,3 +1,14 @@
+2005-05-20 Mikhail Khodjaiants
+ Bug 94139: User-defined register groups.
+ UI to add/remove user-defined groups.
+ * ICDebugHelpContextIds.java
+ * ActionMessages.properties
+ + AddRegisterGroupActionDelegate.java
+ + RegisterGroupDialog.java
+ + RemoveRegisterGroupActionDelegate.java
+ * plugin.properties
+ * plugin.xml
+
2005-05-09 Mikhail Khodjaiants
Bug 80175: Replace the CDT source lookup by the source lookup provided by Eclipse platform.
Removed unused images.
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index 283ddc3a627..7cd67138e74 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -119,3 +119,8 @@ CollapseAllModulesAction.tooltip=Collapse All
ModulePropertiesAction.label=Properties...
ModulePropertiesAction.tooltip=Open Module Properties Dialog
+
+AddRegisterGroupAction.label=Add Register Group
+AddRegisterGroupAction.tooltip=Add Register Group
+RemoveRegisterGroupAction.label=Remove Register Group
+RemoveRegisterGroupAction.tooltip=Remove Register Group
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 2ce34d30fbb..bd370d068a0 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -650,6 +650,20 @@
class="org.eclipse.cdt.debug.core.model.ICVariable">
+
+
+
+
+
+
+
+
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java
index 4bc6d720ac1..707bdf14f63 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java
@@ -68,4 +68,5 @@ public interface ICDebugHelpContextIds
public static final String SOURCE_PATH_MAP_ENTRY_DIALOG = PREFIX + "source_path_map_entry_dialog_context"; //$NON-NLS-1$
public static final String ADD_SOURCE_CONTAINER_DIALOG = PREFIX + "add_source_container_dialog"; //$NON-NLS-1$
public static final String ADD_DIRECTORY_CONTAINER_DIALOG = PREFIX + "add_directory_container_dialog"; //$NON-NLS-1$
+ public static final String REGISTER_GROUP = PREFIX + "register_group_dialog"; //$NON-NLS-1$
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties
index e26dabb161a..de86cf0c872 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties
@@ -96,6 +96,14 @@ ResumeAtLineAdapter.1=Missing document
ResumeAtLineAdapter.2=Empty editor
ResumeAtLineAdapter.3=Operation is not supported.
ResumeAtLineAdapter.4=Resume At Line failed.
+RegisterGroupDialog.0=New Group
+RegisterGroupDialog.1=Select All
+RegisterGroupDialog.2=Desellect All
+RegisterGroupDialog.3=Group Name:
+RegisterGroupDialog.4=Choose From The List:
+RegisterGroupDialog.5=Register Group
+RegisterGroupDialog.6=Select the group registers
+RegisterGroupDialog.7=The group name field must not be empty.
ToggleDetailPaneAction.0=Vertical View Orientation
ToggleDetailPaneAction.1=Place the Detail Pane Underneath the Main Tree View
ToggleDetailPaneAction.2=Place the Detail Pane Underneath the Main Tree View
@@ -104,3 +112,5 @@ ToggleDetailPaneAction.4=Place the Detail Pane on the Right of the Main Tree Vie
ToggleDetailPaneAction.5=Place the Detail Pane on the Right of the Main Tree View
ToggleDetailPaneAction.6=Hide the Detail Pane so that only the Main Tree View is Visible
ToggleDetailPaneAction.7=Hide the Detail Pane so that only the Main Tree View is Visible
+AddRegisterGroupActionDelegate.0=Error
+AddRegisterGroupActionDelegate.1=Error(s) occurred adding register group.
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddRegisterGroupActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddRegisterGroupActionDelegate.java
new file mode 100644
index 00000000000..4c1922c1c04
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddRegisterGroupActionDelegate.java
@@ -0,0 +1,85 @@
+/**********************************************************************
+ * 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.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.core.model.ICDebugTarget;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+
+/**
+ * A delegate for the "Add register group" action.
+ */
+public class AddRegisterGroupActionDelegate extends AbstractViewActionDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogTitle()
+ */
+ protected String getErrorDialogTitle() {
+ return ActionMessages.getString( "AddRegisterGroupActionDelegate.0" ); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogMessage()
+ */
+ protected String getErrorDialogMessage() {
+ return ActionMessages.getString( "AddRegisterGroupActionDelegate.1" ); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doAction()
+ */
+ protected void doAction() throws DebugException {
+ RegisterGroupDialog dialog = new RegisterGroupDialog( getView().getSite().getShell(), getDebugTarget().getRegisterDescriptors() );
+ if ( dialog.open() == Window.OK ) {
+ getDebugTarget().addUserDefinedRegisterGroup( dialog.getName(), dialog.getDescriptors() );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#update()
+ */
+ protected void update() {
+ IAction action = getAction();
+ if ( action != null ) {
+ ICDebugTarget target = getDebugTarget();
+ action.setEnabled( ( target != null ) ? target.isSuspended() : false );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doHandleDebugEvent(org.eclipse.debug.core.DebugEvent)
+ */
+ protected void doHandleDebugEvent( DebugEvent event ) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#init(org.eclipse.jface.action.IAction)
+ */
+ public void init( IAction action ) {
+ super.init( action );
+ Object element = DebugUITools.getDebugContext();
+ setSelection( (element != null) ? new StructuredSelection( element ) : new StructuredSelection() );
+ update();
+ }
+
+ private ICDebugTarget getDebugTarget() {
+ Object element = getSelection().getFirstElement();
+ if ( element instanceof IDebugElement ) {
+ return (ICDebugTarget)((IDebugElement)element).getDebugTarget().getAdapter( ICDebugTarget.class );
+ }
+ return null;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RegisterGroupDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RegisterGroupDialog.java
new file mode 100644
index 00000000000..ebe5e4543e9
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RegisterGroupDialog.java
@@ -0,0 +1,159 @@
+/**********************************************************************
+ * 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.cdt.debug.internal.ui.actions;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
+import org.eclipse.cdt.debug.internal.ui.CDebugImages;
+import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
+import org.eclipse.cdt.debug.internal.ui.PixelConverter;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.CheckedListDialogField;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.DialogField;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.LayoutUtil;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.Separator;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.StringDialogField;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This dialog is used to add/edit user-defined register groups.
+ */
+public class RegisterGroupDialog extends TitleAreaDialog {
+
+ public class RegisterLabelProvider extends LabelProvider {
+
+ public Image getImage( Object element ) {
+ if ( element instanceof IRegisterDescriptor ) {
+ return CDebugImages.get( CDebugImages.IMG_OBJS_REGISTER );
+ }
+ return super.getImage( element );
+ }
+
+ public String getText( Object element ) {
+ if ( element instanceof IRegisterDescriptor ) {
+ IRegisterDescriptor rd = (IRegisterDescriptor)element;
+ return MessageFormat.format( "{0} - {1}", new String[] { rd.getName(), rd.getGroupName() } ); //$NON-NLS-1$
+ }
+ return super.getText( element );
+ }
+ }
+
+ private StringDialogField fNameField;
+ private CheckedListDialogField fListField;
+ private String fName;
+ private IRegisterDescriptor[] fDescriptors;
+
+ public RegisterGroupDialog( Shell parentShell, IRegisterDescriptor[] allRegisters ) {
+ this( parentShell, ActionMessages.getString( "RegisterGroupDialog.0" ), allRegisters, new IRegisterDescriptor[0] ); //$NON-NLS-1$
+ }
+
+ public RegisterGroupDialog( Shell parentShell, String groupName, IRegisterDescriptor[] allRegisters, IRegisterDescriptor[] groupRegisters ) {
+ super( parentShell );
+ fName = groupName;
+ fDescriptors = groupRegisters;
+ String[] buttonLabels = new String[] { ActionMessages.getString( "RegisterGroupDialog.1" ), ActionMessages.getString( "RegisterGroupDialog.2" ) }; //$NON-NLS-1$ //$NON-NLS-2$
+ fNameField = new StringDialogField();
+ fNameField.setLabelText( ActionMessages.getString( "RegisterGroupDialog.3" ) ); //$NON-NLS-1$
+ fNameField.setTextWithoutUpdate( groupName );
+ fNameField.setDialogFieldListener( new IDialogFieldListener() {
+ public void dialogFieldChanged( DialogField field ) {
+ update();
+ }
+ } );
+ fListField = new CheckedListDialogField( new IListAdapter() {
+
+ public void customButtonPressed( DialogField field, int index ) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void selectionChanged( DialogField field ) {
+ // TODO Auto-generated method stub
+
+ }
+ }, buttonLabels, new RegisterLabelProvider() );
+ fListField.setLabelText( ActionMessages.getString( "RegisterGroupDialog.4" ) ); //$NON-NLS-1$
+ fListField.setCheckAllButtonIndex( 0 );
+ fListField.setUncheckAllButtonIndex( 1 );
+ fListField.setElements( Arrays.asList( allRegisters ) );
+ fListField.setCheckedElements( Arrays.asList( groupRegisters ) );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent ) {
+ getShell().setText( ActionMessages.getString( "RegisterGroupDialog.5" ) ); //$NON-NLS-1$
+ setTitle( ActionMessages.getString( "RegisterGroupDialog.6" ) ); //$NON-NLS-1$
+ // setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_REGISTER_GROUP ) );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.REGISTER_GROUP );
+ Composite composite = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout();
+ layout.numColumns = Math.max( fNameField.getNumberOfControls(), fListField.getNumberOfControls() );
+ layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
+ layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
+ composite.setLayout( layout );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Dialog.applyDialogFont( composite );
+ PixelConverter converter = new PixelConverter( composite );
+ new Separator().doFillIntoGrid( composite, layout.numColumns, converter.convertHeightInCharsToPixels( 1 ) );
+ fNameField.doFillIntoGrid( composite, layout.numColumns );
+ fNameField.getTextControl( null ).selectAll();
+ new Separator().doFillIntoGrid( composite, layout.numColumns, converter.convertHeightInCharsToPixels( 1 ) );
+ fListField.doFillIntoGrid( composite, layout.numColumns + 1 );
+ LayoutUtil.setHorizontalSpan( fListField.getLabelControl( null ), layout.numColumns );
+ LayoutUtil.setHeigthHint( fListField.getListControl( null ), convertWidthInCharsToPixels( 30 ) );
+ LayoutUtil.setHorizontalGrabbing( fListField.getListControl( null ) );
+ setMessage( null );
+ return composite;
+ }
+
+ protected void update() {
+ setErrorMessage( null );
+ String name = fNameField.getText().trim();
+ if ( name.length() == 0 ) {
+ setErrorMessage( ActionMessages.getString( "RegisterGroupDialog.7" ) ); //$NON-NLS-1$
+ }
+ getButton( IDialogConstants.OK_ID ).setEnabled( name.length() > 0 );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ super.okPressed();
+ fName = fNameField.getText().trim();
+ List elements = fListField.getCheckedElements();
+ fDescriptors = (IRegisterDescriptor[])elements.toArray( new IRegisterDescriptor[elements.size()] );
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public IRegisterDescriptor[] getDescriptors() {
+ return fDescriptors;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RemoveRegisterGroupActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RemoveRegisterGroupActionDelegate.java
new file mode 100644
index 00000000000..6a95d358fa8
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RemoveRegisterGroupActionDelegate.java
@@ -0,0 +1,84 @@
+/**********************************************************************
+ * 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.cdt.debug.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import org.eclipse.cdt.debug.core.model.ICDebugTarget;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * The "Remove Register Group" action.
+ */
+public class RemoveRegisterGroupActionDelegate extends ActionDelegate implements IObjectActionDelegate {
+
+ private IRegisterGroup[] fRegisterGroups;
+
+ /**
+ * Constructor for RemoveRegisterGroupActionDelegate.
+ */
+ public RemoveRegisterGroupActionDelegate() {
+ super();
+ setRegisterGroups( new IRegisterGroup[0] );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IAction action, ISelection selection ) {
+ ArrayList list = new ArrayList();
+ if ( selection instanceof IStructuredSelection ) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ Iterator it = ss.iterator();
+ while( it.hasNext() ) {
+ Object o = it.next();
+ if ( o instanceof IRegisterGroup ) {
+ list.add( o );
+ }
+ }
+ }
+ setRegisterGroups( (IRegisterGroup[])list.toArray( new IRegisterGroup[list.size()] ) );
+ }
+
+ protected IRegisterGroup[] getRegisterGroups() {
+ return fRegisterGroups;
+ }
+
+ protected void setRegisterGroups( IRegisterGroup[] registerGroups ) {
+ fRegisterGroups = registerGroups;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run( IAction action ) {
+ IRegisterGroup[] groups = getRegisterGroups();
+ if ( groups.length > 0 ) {
+ IDebugTarget target = groups[0].getDebugTarget();
+ if ( target instanceof ICDebugTarget ) {
+ ((ICDebugTarget)target).removeRegisterGroups( groups );
+ }
+ }
+ }
+}