1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-14 11:45:38 +02:00

'Auto-Refresh' and 'Refresh' actions for registers view.

This commit is contained in:
Mikhail Khodjaiants 2003-03-31 23:00:29 +00:00
parent f0b4f5668f
commit 35222002bd
7 changed files with 65 additions and 24 deletions

View file

@ -1,3 +1,12 @@
2003-03-31 Mikhail Khodjaiants
'Auto-Refresh' and 'Refresh' actions for registers view.
* ICDebugHelpContextIds.java
* RefreshAction.java
* ICDebugPreferenceConstants.java
* RegistersViewPreferencePage.java
* RegistersView.java
* RegistersViewContentProvider.java
2003-03-28 Mikhail Khodjaiants 2003-03-28 Mikhail Khodjaiants
Added the default format section for variables, registers and expressions Added the default format section for variables, registers and expressions
to the debugger preference page. to the debugger preference page.

View file

@ -33,6 +33,8 @@ public interface ICDebugHelpContextIds
public static final String REFRESH_SHARED_LIBRARIES_ACTION = PREFIX + "refresh_shared_libraries_action_context"; //$NON-NLS-1$ public static final String REFRESH_SHARED_LIBRARIES_ACTION = PREFIX + "refresh_shared_libraries_action_context"; //$NON-NLS-1$
public static final String AUTO_REFRESH_SHARED_LIBRARIES_ACTION = PREFIX + "auto_refresh_shared_libraries_action_context"; //$NON-NLS-1$ public static final String AUTO_REFRESH_SHARED_LIBRARIES_ACTION = PREFIX + "auto_refresh_shared_libraries_action_context"; //$NON-NLS-1$
public static final String LOAD_SYMBOLS_FOR_ALL = PREFIX + "load_symbols_for_all_action_context"; //$NON-NLS-1$ public static final String LOAD_SYMBOLS_FOR_ALL = PREFIX + "load_symbols_for_all_action_context"; //$NON-NLS-1$
public static final String REFRESH_REGISTERS_ACTION = PREFIX + "refresh_registers_action_context"; //$NON-NLS-1$
public static final String AUTO_REFRESH_REGISTERS_ACTION = PREFIX + "auto_refresh_registers_action_context"; //$NON-NLS-1$
// Views // Views
public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$ public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$

View file

@ -64,7 +64,7 @@ public class RefreshAction extends Action implements IUpdate
} }
catch( DebugException e ) catch( DebugException e )
{ {
CDebugUIPlugin.errorDialog( "Unable to refresh shared libraries.", e.getStatus() ); CDebugUIPlugin.errorDialog( "Unable to refresh.", e.getStatus() );
} }
} }
} }

View file

@ -117,4 +117,11 @@ public interface ICDebugPreferenceConstants
* <code>true</code> the 'Auto-Refresh' option will be checked. * <code>true</code> the 'Auto-Refresh' option will be checked.
*/ */
public static final String PREF_SHARED_LIBRARIES_AUTO_REFRESH = ICDebugUIConstants.PLUGIN_ID + "SharedLibraries.auto_refresh"; //$NON-NLS-1$ public static final String PREF_SHARED_LIBRARIES_AUTO_REFRESH = ICDebugUIConstants.PLUGIN_ID + "SharedLibraries.auto_refresh"; //$NON-NLS-1$
/**
* Boolean preference controlling whether the registers view will be
* refreshed every time when the execution of program stops. When
* <code>true</code> the 'Auto-Refresh' option will be checked.
*/
public static final String PREF_REGISTERS_AUTO_REFRESH = ICDebugUIConstants.PLUGIN_ID + "Registers.auto_refresh"; //$NON-NLS-1$
} }

View file

@ -56,11 +56,11 @@ public class RegistersViewPreferencePage extends FieldEditorPreferencePage
*/ */
protected void createFieldEditors() protected void createFieldEditors()
{ {
addField( new ColorFieldEditor( ICDebugPreferenceConstants.CHANGED_REGISTER_RGB, "&Changed register value color:", getFieldEditorParent() ) ); addField( new ColorFieldEditor( ICDebugPreferenceConstants.CHANGED_REGISTER_RGB, "&Changed register value color:", getFieldEditorParent() ) );
createSpacer( getFieldEditorParent(), 1 ); createSpacer( getFieldEditorParent(), 1 );
addField( new BooleanFieldEditor( IDebugUIConstants.PREF_SHOW_TYPE_NAMES, "Show type &names by default", SWT.NONE, getFieldEditorParent() ) ); addField( new BooleanFieldEditor( IDebugUIConstants.PREF_SHOW_TYPE_NAMES, "Show type &names by default", SWT.NONE, getFieldEditorParent() ) );
createSpacer( getFieldEditorParent(), 1 );
addField( new BooleanFieldEditor( ICDebugPreferenceConstants.PREF_REGISTERS_AUTO_REFRESH, "Auto-Refresh by default", getFieldEditorParent() ) );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -73,10 +73,10 @@ public class RegistersViewPreferencePage extends FieldEditorPreferencePage
public static void initDefaults( IPreferenceStore store ) public static void initDefaults( IPreferenceStore store )
{ {
store.setDefault( IDebugUIConstants.PREF_SHOW_TYPE_NAMES, false ); store.setDefault( IDebugUIConstants.PREF_SHOW_TYPE_NAMES, false );
PreferenceConverter.setDefault( store, PreferenceConverter.setDefault( store,
ICDebugPreferenceConstants.CHANGED_REGISTER_RGB, ICDebugPreferenceConstants.CHANGED_REGISTER_RGB,
new RGB( 255, 0, 0 ) ); new RGB( 255, 0, 0 ) );
store.setDefault( ICDebugPreferenceConstants.PREF_REGISTERS_AUTO_REFRESH, true );
} }
protected void createSpacer( Composite composite, int columnSpan ) protected void createSpacer( Composite composite, int columnSpan )

View file

@ -6,8 +6,12 @@
package org.eclipse.cdt.debug.internal.ui.views.registers; package org.eclipse.cdt.debug.internal.ui.views.registers;
import org.eclipse.cdt.debug.core.ICRegisterManager;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds; import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.actions.AutoRefreshAction;
import org.eclipse.cdt.debug.internal.ui.actions.ChangeRegisterValueAction; import org.eclipse.cdt.debug.internal.ui.actions.ChangeRegisterValueAction;
import org.eclipse.cdt.debug.internal.ui.actions.RefreshAction;
import org.eclipse.cdt.debug.internal.ui.actions.ShowRegisterTypesAction; import org.eclipse.cdt.debug.internal.ui.actions.ShowRegisterTypesAction;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants; import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler; import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
@ -36,6 +40,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.help.WorkbenchHelp;
/** /**
* *
@ -91,6 +96,25 @@ public class RegistersView extends AbstractDebugEventHandlerView
setAction( "ChangeRegisterValue", action ); //$NON-NLS-1$ setAction( "ChangeRegisterValue", action ); //$NON-NLS-1$
setAction( DOUBLE_CLICK_ACTION, action ); setAction( DOUBLE_CLICK_ACTION, action );
action = new AutoRefreshAction( getViewer(), "Auto-Refresh" );
CDebugImages.setLocalImageDescriptors( action, CDebugImages.IMG_LCL_AUTO_REFRESH );
action.setDescription( "Automatically Refresh Registers View" );
action.setToolTipText( "Auto-Refresh" );
WorkbenchHelp.setHelp( action, ICDebugHelpContextIds.AUTO_REFRESH_REGISTERS_ACTION );
action.setEnabled( false );
action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_REGISTERS_AUTO_REFRESH ) );
setAction( "AutoRefresh", action ); //$NON-NLS-1$
add( (AutoRefreshAction)action );
action = new RefreshAction( getViewer(), "Refresh" );
CDebugImages.setLocalImageDescriptors( action, CDebugImages.IMG_LCL_REFRESH );
action.setDescription( "Refresh Registers View" );
action.setToolTipText( "Refresh" );
WorkbenchHelp.setHelp( action, ICDebugHelpContextIds.REFRESH_REGISTERS_ACTION );
action.setEnabled( false );
setAction( "Refresh", action ); //$NON-NLS-1$
add( (RefreshAction)action );
// set initial content here, as viewer has to be set // set initial content here, as viewer has to be set
setInitialContent(); setInitialContent();
} }
@ -116,6 +140,9 @@ public class RegistersView extends AbstractDebugEventHandlerView
menu.add( getAction( "ShowTypeNames" ) ); //$NON-NLS-1$ menu.add( getAction( "ShowTypeNames" ) ); //$NON-NLS-1$
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
menu.appendToGroup( ICDebugUIConstants.REFRESH_GROUP, getAction( "AutoRefresh" ) ); //$NON-NLS-1$
menu.appendToGroup( ICDebugUIConstants.REFRESH_GROUP, getAction( "Refresh" ) ); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -124,6 +151,11 @@ public class RegistersView extends AbstractDebugEventHandlerView
protected void configureToolBar( IToolBarManager tbm ) protected void configureToolBar( IToolBarManager tbm )
{ {
tbm.add( new Separator( this.getClass().getName() ) ); tbm.add( new Separator( this.getClass().getName() ) );
tbm.add( new Separator( ICDebugUIConstants.REFRESH_GROUP ) );
tbm.add( getAction( "AutoRefresh" ) ); //$NON-NLS-1$
tbm.add( getAction( "Refresh" ) ); //$NON-NLS-1$
tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) ); tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
tbm.add( getAction( "ShowTypeNames" ) ); //$NON-NLS-1$ tbm.add( getAction( "ShowTypeNames" ) ); //$NON-NLS-1$
} }
@ -206,14 +238,10 @@ public class RegistersView extends AbstractDebugEventHandlerView
protected void setViewerInput( IStructuredSelection ssel ) protected void setViewerInput( IStructuredSelection ssel )
{ {
IStackFrame frame = null; ICRegisterManager rm = null;
if ( ssel.size() == 1 ) if ( ssel.size() == 1 && ssel.getFirstElement() instanceof IStackFrame )
{ {
Object input = ssel.getFirstElement(); rm = (ICRegisterManager)((IStackFrame)ssel.getFirstElement()).getDebugTarget().getAdapter( ICRegisterManager.class );
if ( input instanceof IStackFrame )
{
frame = (IStackFrame)input;
}
} }
if ( getViewer() == null ) if ( getViewer() == null )
@ -222,25 +250,19 @@ public class RegistersView extends AbstractDebugEventHandlerView
} }
Object current = getViewer().getInput(); Object current = getViewer().getInput();
if ( current == null && frame == null ) if ( current == null && rm == null )
{ {
return; return;
} }
if ( current != null && current.equals( frame ) ) if ( current != null && current.equals( rm ) )
{
return;
}
if ( current != null && frame != null &&
current instanceof IStackFrame &&
((IStackFrame)current).getDebugTarget().equals( frame.getDebugTarget() ) )
{ {
return; return;
} }
showViewer(); showViewer();
getViewer().setInput( frame ); getViewer().setInput( rm );
updateObjects();
} }
/** /**

View file

@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.internal.ui.views.registers;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.cdt.debug.core.ICRegisterManager;
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler; import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
@ -55,9 +56,9 @@ public class RegistersViewContentProvider implements ITreeContentProvider
Object[] children= null; Object[] children= null;
try try
{ {
if ( parent instanceof IStackFrame ) if ( parent instanceof ICRegisterManager )
{ {
children = ((IStackFrame)parent).getRegisterGroups(); children = ((ICRegisterManager)parent).getRegisterGroups();
} }
else if ( parent instanceof IRegisterGroup ) else if ( parent instanceof IRegisterGroup )
{ {