diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 04146d93c84..108d0a802a4 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,18 @@ +2003-06-20 Mikhail Khodjaiants + Variable bookkeeping (phase 0.1). + The 'Enable' and 'Disable' actions added to the Variables view. + * plugin.properties + * plugin.xml + * icons/full/obj16/vard_aggr.gif: new + * icons/full/obj16/vard_pointer.gif: new + * icons/full/obj16/vard_simple.gif: new + * icons/full/clc16/disabled_co.gif: new + * icons/full/clc16/enabled_co.gif: new + * CDebugImages.java + * CDTDebugModelPresentation.java + * DisableVariablesActionDelegate.java: new + * EnableVariablesActionDelegate.java: new + 2003-06-13 Mikhail Khodjaiants Fix for PR 38788: Ctrl-X, Ctrl-C, Ctrl-V, Ctrl-A, Ctrl-Z and Ctrl-Y keys don't work in the address field of the Memory view. diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/disabled_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/disabled_co.gif new file mode 100644 index 00000000000..e11c4116a50 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/disabled_co.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/enabled_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/enabled_co.gif new file mode 100644 index 00000000000..c256109dc06 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/enabled_co.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_aggr.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_aggr.gif new file mode 100644 index 00000000000..8c494d67678 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_aggr.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_pointer.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_pointer.gif new file mode 100644 index 00000000000..25c010a9ac0 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_pointer.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_simple.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_simple.gif new file mode 100644 index 00000000000..1e16bc0d69f Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_simple.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index a4cb0ce86bf..65f89639525 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -73,3 +73,9 @@ RestoreDefaultTypeAction.label=Restore Default Type RestoreDefaultTypeAction.tooltip=Restore Default Type Of Variable CastToArrayAction.label=Display As Array... CastToArrayAction.tooltip=Display Variable As Array + +EnableVariablesAction.label=Enable +EnableVariablesAction.tooltip=Enable Selected Variables + +DisableVariablesAction.label=Disable +DisableVariablesAction.tooltip=Disable Selected Variables diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 08f7199f63c..0d4419674a5 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -891,6 +891,36 @@ + + + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 6ff8377ab39..5256f6cbccc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -564,6 +564,8 @@ public class CDTDebugModelPresentation extends LabelProvider label.append( ' ' ); } } + if ( !((ICVariable)var).isEnabled() ) + label.append( " " ); label.append( var.getName() ); IValue value = var.getValue(); if ( value instanceof ICValue && value.getValueString() != null ) @@ -870,12 +872,16 @@ public class CDTDebugModelPresentation extends LabelProvider { if ( element instanceof ICVariable ) { - if ( !((ICVariable)element).isEditable() ) - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE ); - else if ( ((ICVariable)element).hasChildren() ) - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_VARIABLE_POINTER ); + ICType type = ((ICVariable)element).getType(); + if ( type != null && ( type.isArray() || type.isStructure() ) ) + return fDebugImageRegistry.get( ( ((ICVariable)element).isEnabled() ) ? + CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE : CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE_DISABLED ); + else if ( type != null && type.isPointer() ) + return fDebugImageRegistry.get( ( ((ICVariable)element).isEnabled() ) ? + CDebugImages.DESC_OBJS_VARIABLE_POINTER : CDebugImages.DESC_OBJS_VARIABLE_POINTER_DISABLED ); else - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_VARIABLE_SIMPLE ); + return fDebugImageRegistry.get( ( ((ICVariable)element).isEnabled() ) ? + CDebugImages.DESC_OBJS_VARIABLE_SIMPLE : CDebugImages.DESC_OBJS_VARIABLE_SIMPLE_DISABLED ); } return null; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index 740a0b22931..7bd6d9c0995 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -70,8 +70,11 @@ public class CDebugImages public static final String IMG_OBJS_WRITE_WATCHPOINT_ENABLED = NAME_PREFIX + "write_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WRITE_WATCHPOINT_DISABLED = NAME_PREFIX + "write_obj_disabled.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_VARIABLE_SIMPLE = NAME_PREFIX + "var_simple.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_SIMPLE_DISABLED = NAME_PREFIX + "vard_simple.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_VARIABLE_AGGREGATE = NAME_PREFIX + "var_aggr.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_AGGREGATE_DISABLED = NAME_PREFIX + "vard_aggr.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_VARIABLE_POINTER = NAME_PREFIX + "var_pointer.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_POINTER_DISABLED = NAME_PREFIX + "vard_pointer.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_VARIABLE_STRING = NAME_PREFIX + "var_string.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_REGISTER_GROUP = NAME_PREFIX + "registergroup_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_REGISTER = NAME_PREFIX + "register_obj.gif"; //$NON-NLS-1$ @@ -127,8 +130,11 @@ public class CDebugImages public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_ENABLED ); public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_DISABLED ); public static final ImageDescriptor DESC_OBJS_VARIABLE_SIMPLE = createManaged( T_OBJ, IMG_OBJS_VARIABLE_SIMPLE ); + public static final ImageDescriptor DESC_OBJS_VARIABLE_SIMPLE_DISABLED = createManaged( T_OBJ, IMG_OBJS_VARIABLE_SIMPLE_DISABLED ); public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE = createManaged( T_OBJ, IMG_OBJS_VARIABLE_AGGREGATE ); + public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE_DISABLED = createManaged( T_OBJ, IMG_OBJS_VARIABLE_AGGREGATE_DISABLED ); public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER = createManaged( T_OBJ, IMG_OBJS_VARIABLE_POINTER ); + public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER_DISABLED = createManaged( T_OBJ, IMG_OBJS_VARIABLE_POINTER_DISABLED ); public static final ImageDescriptor DESC_OBJS_VARIABLE_STRING = createManaged( T_OBJ, IMG_OBJS_VARIABLE_STRING ); public static final ImageDescriptor DESC_OBJS_REGISTER_GROUP = createManaged( T_OBJ, IMG_OBJS_REGISTER_GROUP ); public static final ImageDescriptor DESC_OBJS_REGISTER = createManaged( T_OBJ, IMG_OBJS_REGISTER ); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DisableVariablesActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DisableVariablesActionDelegate.java new file mode 100644 index 00000000000..92ca696511c --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DisableVariablesActionDelegate.java @@ -0,0 +1,23 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.ui.actions; + +/** + * Enter type comment. + * + * @since Jun 19, 2003 + */ +public class DisableVariablesActionDelegate extends EnableVariablesActionDelegate +{ + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.EnableVariablesActionDelegate#isEnableAction() + */ + protected boolean isEnableAction() + { + return false; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/EnableVariablesActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/EnableVariablesActionDelegate.java new file mode 100644 index 00000000000..4b341bf2a5a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/EnableVariablesActionDelegate.java @@ -0,0 +1,166 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.internal.ui.actions; + +import java.util.Iterator; + +import org.eclipse.cdt.debug.core.model.ICVariable; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.debug.core.DebugException; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +/** + * Enter type comment. + * + * @since Jun 19, 2003 + */ +public class EnableVariablesActionDelegate implements IViewActionDelegate +{ + private IViewPart fView; + + private IAction fAction; + + public EnableVariablesActionDelegate() + { + } + + protected IViewPart getView() + { + return fView; + } + + protected void setView( IViewPart view ) + { + fView = view; + } + + protected IAction getAction() + { + return fAction; + } + + protected void setAction( IAction action ) + { + fAction = action; + } + + /** + * This action enables variables. + */ + protected boolean isEnableAction() + { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) + */ + public void init( IViewPart view ) + { + setView(view); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run( IAction action ) + { + IStructuredSelection selection = getSelection(); + final int size = selection.size(); + if ( size == 0 ) + return; + + final Iterator enum = selection.iterator(); + final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, "Enable variable(s) failed.", null ); + Runnable runnable = new Runnable() + { + public void run() + { + while( enum.hasNext() ) + { + ICVariable var = (ICVariable)enum.next(); + try + { + if ( size > 1 ) + { + if ( isEnableAction() ) + var.setEnabled( true ); + else + var.setEnabled( false ); + } + else + var.setEnabled( !var.isEnabled() ); + } + catch( DebugException e ) + { + ms.merge( e.getStatus() ); + } + } + update(); + } + }; + + final Display display = CDebugUIPlugin.getStandardDisplay(); + if ( display.isDisposed() ) + return; + display.asyncExec( runnable ); + + if ( !ms.isOK() ) + { + CDebugUIPlugin.errorDialog( "Exceptions occurred enabling the variable(s).", ms ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged( IAction action, ISelection selection ) + { + setAction( action ); + if ( !( selection instanceof IStructuredSelection ) ) + return; + IStructuredSelection sel = (IStructuredSelection)selection; + Object o = sel.getFirstElement(); + if ( !( o instanceof ICVariable ) ) + return; + + Iterator enum = sel.iterator(); + boolean allEnabled = true; + boolean allDisabled = true; + while( enum.hasNext() ) + { + ICVariable var = (ICVariable)enum.next(); + if ( !var.canEnableDisable() ) + continue; + if ( var.isEnabled() ) + allDisabled = false; + else + allEnabled = false; + } + + if ( isEnableAction() ) + action.setEnabled( !allEnabled ); + else + action.setEnabled( !allDisabled ); + } + + private IStructuredSelection getSelection() + { + return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection(); + } + + protected void update() + { + getView().getViewSite().getSelectionProvider().setSelection( getView().getViewSite().getSelectionProvider().getSelection() ); + } +}