mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
New formating actions for variables, registers, and expressions
This commit is contained in:
parent
d1e1638d2e
commit
7f5f0e1f71
7 changed files with 285 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2002-12-16 Mikhail Khodjaiants
|
||||||
|
New formating actions for variables, registers, and expressions
|
||||||
|
* VariableFormatActionDelegate.java
|
||||||
|
* DecVariableFormatActionDelegate.java
|
||||||
|
* HexVariableFormatActionDelegate.java
|
||||||
|
* NaturalVariableFormatActionDelegate.java
|
||||||
|
* plugin.xml
|
||||||
|
* plugin.properties
|
||||||
|
|
||||||
2002-12-10 Mikhail Khodjaiants
|
2002-12-10 Mikhail Khodjaiants
|
||||||
Added new case in the 'getEditorInput' method of CDTDebugModelPresentation for FileStorage objects.
|
Added new case in the 'getEditorInput' method of CDTDebugModelPresentation for FileStorage objects.
|
||||||
* CDTDebugModelPresentation.java
|
* CDTDebugModelPresentation.java
|
||||||
|
|
|
@ -40,4 +40,9 @@ ShowFullPathsAction.tooltip=Show Full Paths
|
||||||
AddGlobalsAction.label=Add Global Variables...
|
AddGlobalsAction.label=Add Global Variables...
|
||||||
AddGlobalsAction.tooltip=Add Global Variables
|
AddGlobalsAction.tooltip=Add Global Variables
|
||||||
|
|
||||||
|
CVariableFormatMenu.label=Format
|
||||||
|
HexVariableFormatAction.label=Hexadecimal
|
||||||
|
DecVariableFormatAction.label=Decimal
|
||||||
|
NaturalVariableFormatAction.label=Natural
|
||||||
|
|
||||||
CDebugActionGroup.name=C/C++ Debug
|
CDebugActionGroup.name=C/C++ Debug
|
||||||
|
|
|
@ -481,6 +481,42 @@
|
||||||
</enablement>
|
</enablement>
|
||||||
</action>
|
</action>
|
||||||
</viewerContribution>
|
</viewerContribution>
|
||||||
|
<objectContribution
|
||||||
|
objectClass="org.eclipse.cdt.debug.core.model.ICVariable"
|
||||||
|
id="org.eclipse.cdt.debug.ui.CVariableActions">
|
||||||
|
<menu
|
||||||
|
label="%CVariableFormatMenu.label"
|
||||||
|
path="renderGroup"
|
||||||
|
id="org.eclipse.cdt.debug.ui.CVariableFormatMenu">
|
||||||
|
<separator
|
||||||
|
name="formatGroup">
|
||||||
|
</separator>
|
||||||
|
</menu>
|
||||||
|
<action
|
||||||
|
label="%HexVariableFormatAction.label"
|
||||||
|
helpContextId="hexadecimal_variable_format_action_context"
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.actions.HexVariableFormatActionDelegate"
|
||||||
|
menubarPath="org.eclipse.cdt.debug.ui.CVariableFormatMenu/formatGroup"
|
||||||
|
enablesFor="1"
|
||||||
|
id="org.eclipse.cdt.debug.internal.ui.actions.HexVariableFormatActionDelegate">
|
||||||
|
</action>
|
||||||
|
<action
|
||||||
|
label="%DecVariableFormatAction.label"
|
||||||
|
helpContextId="decimal_variable_format_action_context"
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.actions.DecVariableFormatActionDelegate"
|
||||||
|
menubarPath="org.eclipse.cdt.debug.ui.CVariableFormatMenu/formatGroup"
|
||||||
|
enablesFor="1"
|
||||||
|
id="org.eclipse.cdt.debug.internal.ui.actions.DecVariableFormatActionDelegate">
|
||||||
|
</action>
|
||||||
|
<action
|
||||||
|
label="%NaturalVariableFormatAction.label"
|
||||||
|
helpContextId="naturall_variable_format_action_context"
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.actions.NaturalVariableFormatActionDelegate"
|
||||||
|
menubarPath="org.eclipse.cdt.debug.ui.CVariableFormatMenu/formatGroup"
|
||||||
|
enablesFor="1"
|
||||||
|
id="org.eclipse.cdt.debug.internal.ui.actions.NaturalVariableFormatActionDelegate">
|
||||||
|
</action>
|
||||||
|
</objectContribution>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.viewActions">
|
point="org.eclipse.ui.viewActions">
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since Dec 16, 2002
|
||||||
|
*/
|
||||||
|
public class DecVariableFormatActionDelegate extends VariableFormatActionDelegate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for DecVariableFormatActionDelegate.
|
||||||
|
* @param format
|
||||||
|
*/
|
||||||
|
public DecVariableFormatActionDelegate()
|
||||||
|
{
|
||||||
|
super( ICDIFormat.DECIMAL );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since Dec 16, 2002
|
||||||
|
*/
|
||||||
|
public class HexVariableFormatActionDelegate extends VariableFormatActionDelegate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor for HexVariableFormatActionDelegate.
|
||||||
|
* @param format
|
||||||
|
*/
|
||||||
|
public HexVariableFormatActionDelegate()
|
||||||
|
{
|
||||||
|
super( ICDIFormat.HEXADECIMAL );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since Dec 16, 2002
|
||||||
|
*/
|
||||||
|
public class NaturalVariableFormatActionDelegate extends VariableFormatActionDelegate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor for NaturalVariableFormatActionDelegate.
|
||||||
|
* @param format
|
||||||
|
*/
|
||||||
|
public NaturalVariableFormatActionDelegate()
|
||||||
|
{
|
||||||
|
super( ICDIFormat.NATURAL );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICValue;
|
||||||
|
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.debug.core.model.IValue;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.swt.custom.BusyIndicator;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since Dec 16, 2002
|
||||||
|
*/
|
||||||
|
public class VariableFormatActionDelegate implements IObjectActionDelegate
|
||||||
|
{
|
||||||
|
private int fFormat = ICDIFormat.DECIMAL;
|
||||||
|
private ICVariable fVariable = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for VariableFormatActionDelegate.
|
||||||
|
*/
|
||||||
|
public VariableFormatActionDelegate( int format )
|
||||||
|
{
|
||||||
|
fFormat = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
|
||||||
|
*/
|
||||||
|
public void setActivePart( IAction action, IWorkbenchPart targetPart )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.ui.IActionDelegate#run(IAction)
|
||||||
|
*/
|
||||||
|
public void run( IAction action )
|
||||||
|
{
|
||||||
|
if ( getVariable() != null )
|
||||||
|
{
|
||||||
|
final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(),
|
||||||
|
DebugException.REQUEST_FAILED, "", null );
|
||||||
|
BusyIndicator.showWhile( Display.getCurrent(),
|
||||||
|
new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
doAction( getVariable() );
|
||||||
|
}
|
||||||
|
catch( DebugException e )
|
||||||
|
{
|
||||||
|
ms.merge( e.getStatus() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
if ( !ms.isOK() )
|
||||||
|
{
|
||||||
|
IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow();
|
||||||
|
if ( window != null )
|
||||||
|
{
|
||||||
|
CDebugUIPlugin.errorDialog( "Unable to set format of variable.", ms );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CDebugUIPlugin.log( ms );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
|
||||||
|
*/
|
||||||
|
public void selectionChanged( IAction action, ISelection selection )
|
||||||
|
{
|
||||||
|
if ( selection instanceof IStructuredSelection )
|
||||||
|
{
|
||||||
|
Object element = ((IStructuredSelection)selection).getFirstElement();
|
||||||
|
if ( element instanceof ICVariable )
|
||||||
|
{
|
||||||
|
boolean enabled = enablesFor( (ICVariable)element );
|
||||||
|
action.setEnabled( enabled );
|
||||||
|
if ( enabled )
|
||||||
|
{
|
||||||
|
action.setChecked( ( ((ICVariable)element).getFormat() == fFormat ) );
|
||||||
|
setVariable( (ICVariable)element );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
action.setChecked( false );
|
||||||
|
action.setEnabled( false );
|
||||||
|
setVariable( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean enablesFor( ICVariable var )
|
||||||
|
{
|
||||||
|
boolean enabled = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IValue value = var.getValue();
|
||||||
|
if ( value != null && value instanceof ICValue )
|
||||||
|
{
|
||||||
|
switch( ((ICValue)value).getType() )
|
||||||
|
{
|
||||||
|
case ICValue.TYPE_ARRAY:
|
||||||
|
case ICValue.TYPE_SIMPLE:
|
||||||
|
case ICValue.TYPE_POINTER:
|
||||||
|
enabled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( DebugException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setVariable( ICVariable var )
|
||||||
|
{
|
||||||
|
fVariable = var;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICVariable getVariable()
|
||||||
|
{
|
||||||
|
return fVariable;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doAction( ICVariable var ) throws DebugException
|
||||||
|
{
|
||||||
|
var.setFormat( fFormat );
|
||||||
|
var.refresh();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue