mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implementing the "Display As Array" action.
This commit is contained in:
parent
7c2c85ddb5
commit
1741944fb0
4 changed files with 153 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2003-03-10 Mikhail Khodjaiants
|
||||||
|
Implementing the "Display As Array" action.
|
||||||
|
* plugin.xml
|
||||||
|
* plugin.propeties
|
||||||
|
* CastToArrayActionDelegate.java: new
|
||||||
|
|
||||||
2003-03-09 Mikhail Khodjaiants
|
2003-03-09 Mikhail Khodjaiants
|
||||||
The implementation of the "Cast To Type" and "Restore Default Type" actions.
|
The implementation of the "Cast To Type" and "Restore Default Type" actions.
|
||||||
* plugin.xml
|
* plugin.xml
|
||||||
|
|
|
@ -66,3 +66,5 @@ CastToTypeAction.label=Cast To Type...
|
||||||
CastToTypeAction.tooltip=Cast Varibale To Type
|
CastToTypeAction.tooltip=Cast Varibale To Type
|
||||||
RestoreDefaultTypeAction.label=Restore Default Type
|
RestoreDefaultTypeAction.label=Restore Default Type
|
||||||
RestoreDefaultTypeAction.tooltip=Restore Default Type Of Variable
|
RestoreDefaultTypeAction.tooltip=Restore Default Type Of Variable
|
||||||
|
CastToArrayAction.label=Display As Array...
|
||||||
|
CastToArrayAction.tooltip=Display Variable As Array
|
||||||
|
|
|
@ -816,8 +816,8 @@
|
||||||
id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate">
|
id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate">
|
||||||
<enablement>
|
<enablement>
|
||||||
<pluginState
|
<pluginState
|
||||||
id="org.eclipse.cdt.debug.ui"
|
value="activated"
|
||||||
value="activated">
|
id="org.eclipse.cdt.debug.ui">
|
||||||
</pluginState>
|
</pluginState>
|
||||||
</enablement>
|
</enablement>
|
||||||
</action>
|
</action>
|
||||||
|
@ -837,6 +837,22 @@
|
||||||
</pluginState>
|
</pluginState>
|
||||||
</enablement>
|
</enablement>
|
||||||
</action>
|
</action>
|
||||||
|
<action
|
||||||
|
label="%CastToArrayAction.label"
|
||||||
|
icon="icons/full/clcl16/showasarray_co.gif"
|
||||||
|
helpContextId="cast_to_array_action_context"
|
||||||
|
tooltip="%CastToArrayAction.tooltip"
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"
|
||||||
|
menubarPath="additions"
|
||||||
|
enablesFor="1"
|
||||||
|
id="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate">
|
||||||
|
<enablement>
|
||||||
|
<pluginState
|
||||||
|
id="org.eclipse.cdt.debug.ui"
|
||||||
|
value="activated">
|
||||||
|
</pluginState>
|
||||||
|
</enablement>
|
||||||
|
</action>
|
||||||
</objectContribution>
|
</objectContribution>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICastToArray;
|
||||||
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
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;
|
||||||
|
import org.eclipse.ui.actions.ActionDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since Mar 10, 2003
|
||||||
|
*/
|
||||||
|
public class CastToArrayActionDelegate extends ActionDelegate implements IObjectActionDelegate
|
||||||
|
{
|
||||||
|
private ICastToArray fCastToArray = null;
|
||||||
|
private IStatus fStatus = null;
|
||||||
|
|
||||||
|
public CastToArrayActionDelegate()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
|
||||||
|
*/
|
||||||
|
public void setActivePart( IAction action, IWorkbenchPart targetPart )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||||
|
*/
|
||||||
|
public void run( IAction action )
|
||||||
|
{
|
||||||
|
if ( getCastToArray() == null )
|
||||||
|
return;
|
||||||
|
BusyIndicator.showWhile( Display.getCurrent(),
|
||||||
|
new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
doAction( getCastToArray() );
|
||||||
|
setStatus( null );
|
||||||
|
}
|
||||||
|
catch( DebugException e )
|
||||||
|
{
|
||||||
|
setStatus( e.getStatus() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
if ( getStatus() != null && !getStatus().isOK() )
|
||||||
|
{
|
||||||
|
IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow();
|
||||||
|
if ( window != null )
|
||||||
|
{
|
||||||
|
CDebugUIPlugin.errorDialog( "Unable to display this variable as an array.", getStatus() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CDebugUIPlugin.log( getStatus() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
||||||
|
*/
|
||||||
|
public void selectionChanged( IAction action, ISelection selection )
|
||||||
|
{
|
||||||
|
if ( selection instanceof IStructuredSelection )
|
||||||
|
{
|
||||||
|
Object element = ((IStructuredSelection)selection).getFirstElement();
|
||||||
|
if ( element instanceof ICastToArray )
|
||||||
|
{
|
||||||
|
boolean enabled = ((ICastToArray)element).supportsCastToArray();
|
||||||
|
action.setEnabled( enabled );
|
||||||
|
if ( enabled )
|
||||||
|
{
|
||||||
|
setCastToArray( (ICastToArray)element );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
action.setEnabled( false );
|
||||||
|
setCastToArray( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICastToArray getCastToArray()
|
||||||
|
{
|
||||||
|
return fCastToArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setCastToArray( ICastToArray castToArray )
|
||||||
|
{
|
||||||
|
fCastToArray = castToArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IStatus getStatus()
|
||||||
|
{
|
||||||
|
return fStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus( IStatus status )
|
||||||
|
{
|
||||||
|
fStatus = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doAction( ICastToArray castToArray ) throws DebugException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue