From 109d948e1f12e5a06185ac419a3957e91a4f842b Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 20 Jun 2003 21:23:23 +0000 Subject: [PATCH] Variable bookkeeping (phase 0.1). --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 15 ++ .../icons/full/clcl16/disabled_co.gif | Bin 0 -> 885 bytes .../icons/full/clcl16/enabled_co.gif | Bin 0 -> 897 bytes .../icons/full/obj16/vard_aggr.gif | Bin 0 -> 146 bytes .../icons/full/obj16/vard_pointer.gif | Bin 0 -> 130 bytes .../icons/full/obj16/vard_simple.gif | Bin 0 -> 131 bytes .../plugin.properties | 6 + debug/org.eclipse.cdt.debug.ui/plugin.xml | 30 ++++ .../ui/CDTDebugModelPresentation.java | 16 +- .../cdt/debug/internal/ui/CDebugImages.java | 6 + .../DisableVariablesActionDelegate.java | 23 +++ .../EnableVariablesActionDelegate.java | 166 ++++++++++++++++++ 12 files changed, 257 insertions(+), 5 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/disabled_co.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/enabled_co.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_aggr.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_pointer.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/vard_simple.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DisableVariablesActionDelegate.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/EnableVariablesActionDelegate.java 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 0000000000000000000000000000000000000000..e11c4116a50ba9e8d21b34dc33243c05e64650d6 GIT binary patch literal 885 zcmZ?wbhEHb6krfw_|CvEe}4V`{qyhN-@o79e!ji^{rU6%|Nr06&`@7rA0HnNWHXF{ z(GVEEA)o{D8YnL?a6~cia>#gWSm40IDWnxM<3qy%76v7+ITC>foEaF6vhK|In8eV` zY%SIBLolU*S=Dov%S@rg2PaF}inT}<$L@o%VI8Bv}+~)Fg(qo3ne6f@EXd0{gPO^}H^@Ouf?dUuK bM>m}VTUG{7;1ctg>lK>C)DpqW#9$2oDa$~J literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..8c494d676787966f5e5a66b9181f81a0c0c67f22 GIT binary patch literal 146 zcmZ?wbhEHb6krfw_{_lY|NsBrzkmPy`SZw;Bd=e-{`m1@b93|O&!4}4|NiICpMwVv zzJLFo0SPGnWMKqxbwC8j3}zO4ffJsq_gdUOS{)v(q;{fE!>vNZr9001&@Rn6TaIw^ oNIQ9VOQjZ`xGKiJN&jvTadvT03wP&R{#J2 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..25c010a9ac0a461962191143caa54dff3c8f8a61 GIT binary patch literal 130 zcmZ?wbhEHb6krfw_{_lY|Nnn)Z|}UkJVQgn)vH%;+O$bsT|GZP|K!P&3=9ktCr$(^ z=;`V4_4SR9k1s4NRQ$=p2$W#Z0TCcGm|64%PI#`~Yw@~vex0APVbXRTFD3=|NK5a_ eDxHq2Lxay~89tac+lAo{i^Yj0MLT;K7_0$l0x!A% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1e16bc0d69facc91d34814613c5c79da5ec752ce GIT binary patch literal 131 zcmZ?wbhEHb6krfw_{_lY|NsBjuU~)s__4XU`Sa(`-@kwV^XJdOg9qQgf6ssoDE?$& z1c~c_2#^`fECvE6JXi0vh(1znKU-0X)ltUTgTt{quH)b?&73U + + + + + + + + + + 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() ); + } +}