From f0c0e2418a4070b51c2b9ea7c3ae373c46665536 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Mon, 18 Nov 2002 23:05:58 +0000 Subject: [PATCH] Fixes for the 'Add Global Variables' action's bugs. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 6 +++++ .../ui/actions/AddGlobalsActionDelegate.java | 25 +++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 81c17177fe1..5a2da2e0789 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,9 @@ +2002-11-18 Mikhail Khodjaiants + Fixes for the 'Add Global Variables' action's bugs. + The action disabled after 'Remove All'. + Error message after adding a valid expression. + * AddGlobalsActionDelegate.java + 2002-11-15 Mikhail Khodjaiants Added presentation for dummy stack frames. * CDTDebugModelPresentation.java diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddGlobalsActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddGlobalsActionDelegate.java index 87e1d5c7fb8..f3cee867a6a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddGlobalsActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddGlobalsActionDelegate.java @@ -23,7 +23,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.Display; @@ -113,7 +112,15 @@ public class AddGlobalsActionDelegate implements IViewActionDelegate, { if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) { - update( getAction(), selection ); + if ( selection instanceof IStructuredSelection ) + { + setSelection( (IStructuredSelection)selection ); + } + else + { + setSelection( null ); + } + update( getAction() ); } } @@ -133,6 +140,7 @@ public class AddGlobalsActionDelegate implements IViewActionDelegate, try { doAction( selection.getFirstElement() ); + setStatus( null ); } catch( DebugException e ) { @@ -162,22 +170,19 @@ public class AddGlobalsActionDelegate implements IViewActionDelegate, setAction( action ); if ( getView() != null ) { - update( action, selection ); + update( action ); } } - protected void update( IAction action, ISelection s ) + protected void update( IAction action ) { - if ( action != null && s instanceof IStructuredSelection ) + if ( action != null ) { - IStructuredSelection ss = (IStructuredSelection)s; - action.setEnabled( getEnableStateForSelection( ss ) ); - setSelection( ss ); + action.setEnabled( getEnableStateForSelection( getSelection() ) ); } else { action.setEnabled( false ); - setSelection( StructuredSelection.EMPTY ); } } @@ -261,7 +266,7 @@ public class AddGlobalsActionDelegate implements IViewActionDelegate, protected boolean getEnableStateForSelection( IStructuredSelection selection ) { - if ( selection.size() != 1 ) + if ( selection == null || selection.size() != 1 ) { return false; }