mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Preserving the registers tree structure during the debug session.
This commit is contained in:
parent
90aaf1dfaa
commit
928199b44e
4 changed files with 120 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-04-08 Mikhail Khodjaiants
|
||||
Preserving the registers tree structure during the debug session.
|
||||
* ViewerState.java: new
|
||||
* RegistersView.java
|
||||
* RegistersViewEventHandler.java
|
||||
|
||||
2003-04-07 Mikhail Khodjaiants
|
||||
No dialog if switch to frame failed.
|
||||
* CDebugUIPlugin.java
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2003 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.views;
|
||||
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
|
||||
/**
|
||||
* Memento of the expanded and selected items in a tree
|
||||
* viewer for.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ViewerState {
|
||||
|
||||
private Object[] fExpandedElements = null;
|
||||
private ISelection fSelection = null;
|
||||
|
||||
/**
|
||||
* Constructs a memento for the given viewer.
|
||||
*/
|
||||
public ViewerState(TreeViewer viewer) {
|
||||
saveState(viewer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current state of the given viewer into
|
||||
* this memento.
|
||||
*
|
||||
* @param viewer viewer of which to save the state
|
||||
*/
|
||||
public void saveState(TreeViewer viewer) {
|
||||
fExpandedElements = viewer.getExpandedElements();
|
||||
fSelection = viewer.getSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the state of the given viewer to this mementos
|
||||
* saved state.
|
||||
*
|
||||
* @param viewer viewer to which state is restored
|
||||
*/
|
||||
public void restoreState(TreeViewer viewer) {
|
||||
if (fExpandedElements != null) {
|
||||
viewer.setExpandedElements(fExpandedElements);
|
||||
}
|
||||
if (fSelection != null) {
|
||||
viewer.setSelection(fSelection);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
package org.eclipse.cdt.debug.internal.ui.views.registers;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICRegisterManager;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||
|
@ -17,6 +19,7 @@ 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.AbstractDebugEventHandlerView;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.ViewerState;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
@ -60,6 +63,14 @@ public class RegistersView extends AbstractDebugEventHandlerView
|
|||
|
||||
protected static final String VARIABLES_SELECT_ALL_ACTION = SELECT_ALL_ACTION + ".Registers"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* A map of register managers to <code>ViewerState</code>s.
|
||||
* Used to restore the expanded state of the registers view on
|
||||
* re-selection of the register manager. The cache is cleared on
|
||||
* a frame by frame basis when a thread/target is terminated.
|
||||
*/
|
||||
private HashMap fExpandedRegisters = new HashMap( 10 );
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
|
||||
*/
|
||||
|
@ -262,8 +273,26 @@ public class RegistersView extends AbstractDebugEventHandlerView
|
|||
return;
|
||||
}
|
||||
|
||||
if ( current != null )
|
||||
{
|
||||
// save state
|
||||
ViewerState state = new ViewerState( getRegistersViewer() );
|
||||
fExpandedRegisters.put( current, state );
|
||||
}
|
||||
|
||||
showViewer();
|
||||
getViewer().setInput( rm );
|
||||
|
||||
// restore state
|
||||
if ( rm != null )
|
||||
{
|
||||
ViewerState state = (ViewerState)fExpandedRegisters.get( rm );
|
||||
if ( state != null )
|
||||
{
|
||||
state.restoreState( getRegistersViewer() );
|
||||
}
|
||||
}
|
||||
|
||||
updateObjects();
|
||||
}
|
||||
|
||||
|
@ -279,4 +308,14 @@ public class RegistersView extends AbstractDebugEventHandlerView
|
|||
setViewerInput( (IStructuredSelection)selection );
|
||||
}
|
||||
}
|
||||
|
||||
protected RegistersViewer getRegistersViewer()
|
||||
{
|
||||
return (RegistersViewer)getViewer();
|
||||
}
|
||||
|
||||
protected void clearExpandedRegisters( ICRegisterManager rm )
|
||||
{
|
||||
fExpandedRegisters.remove( rm );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.registers;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICRegisterManager;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
import org.eclipse.debug.core.model.IVariable;
|
||||
import org.eclipse.debug.ui.AbstractDebugView;
|
||||
|
||||
|
@ -38,6 +40,13 @@ public class RegistersViewEventHandler extends AbstractDebugEventHandler
|
|||
DebugEvent event = events[i];
|
||||
switch( event.getKind() )
|
||||
{
|
||||
case DebugEvent.TERMINATE :
|
||||
if ( event.getSource() instanceof IDebugTarget &&
|
||||
((IDebugTarget)event.getSource()).getAdapter( ICRegisterManager.class ) != null )
|
||||
{
|
||||
getRegistersView().clearExpandedRegisters( (ICRegisterManager)(((IDebugTarget)event.getSource()).getAdapter( ICRegisterManager.class )) );
|
||||
}
|
||||
break;
|
||||
case DebugEvent.SUSPEND :
|
||||
if ( event.getDetail() != DebugEvent.EVALUATION_IMPLICIT )
|
||||
{
|
||||
|
@ -64,6 +73,11 @@ public class RegistersViewEventHandler extends AbstractDebugEventHandler
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected RegistersView getRegistersView()
|
||||
{
|
||||
return (RegistersView)getView();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue