1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for PR 39101: No hilight when changing the value of register.

This commit is contained in:
Mikhail Khodjaiants 2003-06-30 02:59:10 +00:00
parent bc44d5b65f
commit 269cca164e
3 changed files with 82 additions and 69 deletions

View file

@ -1,3 +1,8 @@
2003-06-29 Mikhail Khodjaiants
Fix for PR 39101: No hilight when changing the value of register.
* RegistersView.java
* RegistersViewer.java
2003-06-26 Mikhail Khodjaiants
New icon for shared libraries with loaded symbols.
* icons/full/ovr16/symbols_ovr.gif: new

View file

@ -23,6 +23,7 @@ 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;
import org.eclipse.debug.core.model.IRegister;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugModelPresentation;
@ -33,12 +34,17 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchActionConstants;
@ -56,6 +62,76 @@ public class RegistersView extends AbstractDebugEventHandlerView
IPropertyChangeListener,
IDebugExceptionHandler
{
/**
* A label provider that delegates to a debug model
* presentation and adds coloring to registers to
* reflect their changed state
*/
class VariablesViewLabelProvider implements ILabelProvider, IColorProvider
{
private IDebugModelPresentation fPresentation;
public VariablesViewLabelProvider( IDebugModelPresentation presentation )
{
fPresentation = presentation;
}
public IDebugModelPresentation getPresentation()
{
return fPresentation;
}
public Image getImage( Object element )
{
return fPresentation.getImage( element );
}
public String getText( Object element )
{
return fPresentation.getText( element );
}
public void addListener( ILabelProviderListener listener )
{
fPresentation.addListener( listener );
}
public void dispose()
{
fPresentation.dispose();
}
public boolean isLabelProperty( Object element, String property )
{
return fPresentation.isLabelProperty( element, property );
}
public void removeListener( ILabelProviderListener listener )
{
fPresentation.removeListener( listener );
}
public Color getForeground( Object element )
{
if ( element instanceof IRegister )
{
IRegister register = (IRegister)element;
try
{
if ( register.hasValueChanged() )
{
return CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.CHANGED_REGISTER_RGB );
}
}
catch( DebugException e )
{
CDebugUIPlugin.log( e );
}
}
return null;
}
public Color getBackground( Object element )
{
return null;
}
}
/**
* The model presentation used as the label provider for the tree viewer.
*/
@ -81,7 +157,7 @@ public class RegistersView extends AbstractDebugEventHandlerView
// add tree viewer
final TreeViewer vv = new RegistersViewer( parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL );
vv.setContentProvider( createContentProvider() );
vv.setLabelProvider( getModelPresentation() );
vv.setLabelProvider( new VariablesViewLabelProvider( getModelPresentation() ) );
vv.setUseHashlookup( true );
setAction( SELECT_ALL_ACTION, getAction( VARIABLES_SELECT_ALL_ACTION ) );
getViewSite().getActionBars().updateActionBars();

View file

@ -5,17 +5,10 @@
*/
package org.eclipse.cdt.debug.internal.ui.views.registers;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
/**
@ -60,33 +53,10 @@ public class RegistersViewer extends TreeViewer
super( tree );
}
/**
* Refresh the view, and then do another pass to
* update the foreground color for values that have changed
* since the last refresh. Values that have not
* changed are drawn with the default system foreground color.
* If the viewer has no selection, ensure that new items
* are visible.
*
* @see Viewer#refresh()
*/
public void refresh()
{
getControl().setRedraw( false );
super.refresh();
Item[] children = getChildren( getControl() );
if ( children != null )
{
Color c = CDebugUIPlugin.getPreferenceColor( ICDebugPreferenceConstants.CHANGED_REGISTER_RGB );
for( int i = 0; i < children.length; i++ )
{
updateColor( (TreeItem)children[i], c );
}
}
getControl().setRedraw( true );
if ( getSelection().isEmpty() && getNewItem() != null )
{
if ( !getNewItem().isDisposed() )
@ -99,44 +69,6 @@ public class RegistersViewer extends TreeViewer
//expandToLevel( 2 );
}
/**
* Updates the color of the given item as well
* as all of its children. If the item corresponds
* to a variable that has changed in value,
* it is rendered with the <code>CHANGED_VARIABLE_RGB</code>
* generated foreground color, otherwise the default system
* color is used.
*
* @param item tree item
*/
protected void updateColor( TreeItem item, Color c )
{
if ( item.getData() instanceof IVariable )
{
IVariable var = (IVariable)item.getData();
try
{
if ( var.hasValueChanged() )
{
item.setForeground( c );
}
else
{
item.setForeground( null );
}
}
catch( DebugException e )
{
DebugUIPlugin.log( e );
}
}
TreeItem[] children = item.getItems();
for( int i = 0; i < children.length; i++ )
{
updateColor( children[i], c );
}
}
/**
* @see AbstractTreeViewer#newItem(Widget, int, int)
*/