mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 10:25:32 +02:00
Added support of the 'Add Global Variables' action of the Expressions view.
This commit is contained in:
parent
21a42a700d
commit
8ad962852c
9 changed files with 441 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
|||
<classpathentry kind="src" path="/org.eclipse.debug.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.cdt.ui"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.cdt.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
|
||||
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<name>org.eclipse.cdt.debug.ui</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>org.eclipse.cdt.core</project>
|
||||
<project>org.eclipse.cdt.debug.core</project>
|
||||
<project>org.eclipse.cdt.ui</project>
|
||||
<project>org.eclipse.core.boot</project>
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
2002-11-05 Mikhail Khodjaiants
|
||||
Implementation of the "Add Global Variables" action of the Expressions view.
|
||||
Action images:
|
||||
watch_globals.gif (clcl, dlcl, elcl).
|
||||
* AddGlobalsActionDelegate.java: implementation.
|
||||
* plugin.xml: contribution to the Expression view
|
||||
* plugin.xml: added dependency to org.eclipse.cdt.core
|
||||
* .classpath: added dependency to org.eclipse.cdt.core
|
||||
* .project: added dependency to org.eclipse.cdt.core
|
||||
* plugin.properties: action's label and tooltip text
|
||||
|
||||
2002-11-03 Mikhail Khodjaiants
|
||||
Implementation of the "Format/Decimal" and "Format/Unsigned Decimal" actions of the Memory view.
|
||||
* MemoryFormataction.java
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 145 B |
Binary file not shown.
After Width: | Height: | Size: 105 B |
Binary file not shown.
After Width: | Height: | Size: 105 B |
|
@ -37,4 +37,7 @@ RunToLineAction.label=Run To C/C++ &Line
|
|||
ShowFullPathsAction.label=Show Full Paths
|
||||
ShowFullPathsAction.tooltip=Show Full Paths
|
||||
|
||||
AddGlobalsAction.label=Add Global Variables...
|
||||
AddGlobalsAction.tooltip=Add Global Variables
|
||||
|
||||
CDebugActionGroup.name=C/C++ Debug
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<import plugin="org.eclipse.debug.core"/>
|
||||
<import plugin="org.eclipse.cdt.debug.core"/>
|
||||
<import plugin="org.eclipse.cdt.ui"/>
|
||||
<import plugin="org.eclipse.cdt.core"/>
|
||||
</requires>
|
||||
|
||||
|
||||
|
@ -238,12 +239,12 @@
|
|||
</enablement>
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.DebuggerConsoleActionDelegate"
|
||||
enablesFor="1"
|
||||
label="%ShowDebuggerConsoleAction.label"
|
||||
menubarPath="renderGroup"
|
||||
helpContextId="show_debugger_console_action_context"
|
||||
icon="icons/full/clcl16/debugger_console.gif"
|
||||
helpContextId="show_debugger_console_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.DebuggerConsoleActionDelegate"
|
||||
menubarPath="renderGroup"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.DebuggerConsoleActionDelegate">
|
||||
<enablement>
|
||||
<pluginState
|
||||
|
@ -351,6 +352,25 @@
|
|||
</enablement>
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
targetID="org.eclipse.debug.ui.ExpressionView"
|
||||
id="org.eclipse.debug.ui.expressionView.popupMenu">
|
||||
<action
|
||||
label="%AddGlobalsAction.label"
|
||||
icon="icons/full/clcl16/watch_globals.gif"
|
||||
helpContextId="add_globals_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate"
|
||||
menubarPath="expressionGroup"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate">
|
||||
<enablement>
|
||||
<pluginState
|
||||
value="activated"
|
||||
id="org.eclipse.cdt.debug.ui">
|
||||
</pluginState>
|
||||
</enablement>
|
||||
</action>
|
||||
</viewerContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.viewActions">
|
||||
|
@ -420,6 +440,28 @@
|
|||
tooltip="%ShowFullPathsAction.tooltip">
|
||||
</action>
|
||||
</viewContribution>
|
||||
<viewContribution
|
||||
targetID="org.eclipse.debug.ui.ExpressionView"
|
||||
id="org.eclipse.debug.ui.expressionsView.toolbar">
|
||||
<action
|
||||
toolbarPath="expressionGroup"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate"
|
||||
hoverIcon="icons/full/clcl16/watch_globals.gif"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate"
|
||||
disabledIcon="icons/full/dlcl16/watch_globals.gif"
|
||||
enablesFor="1"
|
||||
icon="icons/full/elcl16/watch_globals.gif"
|
||||
helpContextId="add_globals_action_context"
|
||||
label="%AddGlobalsAction.label"
|
||||
tooltip="%AddGlobalsAction.tooltip">
|
||||
<enablement>
|
||||
<pluginState
|
||||
value="activated"
|
||||
id="org.eclipse.cdt.debug.ui">
|
||||
</pluginState>
|
||||
</enablement>
|
||||
</action>
|
||||
</viewContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.editorActions">
|
||||
|
@ -490,6 +532,9 @@
|
|||
<action
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.DebuggerConsoleActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate">
|
||||
</action>
|
||||
</debugActionGroup>
|
||||
</extension>
|
||||
|
||||
|
|
|
@ -0,0 +1,376 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||
import org.eclipse.cdt.debug.core.IExecFileInfo;
|
||||
import org.eclipse.cdt.debug.core.IGlobalVariable;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.IDebugElement;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
import org.eclipse.debug.core.model.IExpression;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.custom.BusyIndicator;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.dialogs.ListSelectionDialog;
|
||||
|
||||
/**
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since: Nov 4, 2002
|
||||
*/
|
||||
public class AddGlobalsActionDelegate implements IViewActionDelegate,
|
||||
ISelectionListener,
|
||||
IPartListener
|
||||
{
|
||||
protected class Global
|
||||
{
|
||||
private String fName;
|
||||
private IPath fPath;
|
||||
|
||||
/**
|
||||
* Constructor for Global.
|
||||
*/
|
||||
public Global( String name, IPath path )
|
||||
{
|
||||
fName = name;
|
||||
fPath = path;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
public IPath getPath()
|
||||
{
|
||||
return fPath;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String path = "";
|
||||
if ( getPath() != null )
|
||||
{
|
||||
path = getPath().toString();
|
||||
int index = path.lastIndexOf( '/' );
|
||||
if ( index != -1 )
|
||||
path = path.substring( index + 1 );
|
||||
}
|
||||
return ( path.length() > 0 ? ( '\'' + path + "\'::" ) : "" ) + getName();
|
||||
}
|
||||
}
|
||||
|
||||
private Global[] fGlobals;
|
||||
private IViewPart fView = null;
|
||||
private IAction fAction;
|
||||
private IStructuredSelection fSelection;
|
||||
private IStatus fStatus = null;
|
||||
|
||||
/**
|
||||
* Constructor for AddGlobalsActionDelegate.
|
||||
*/
|
||||
public AddGlobalsActionDelegate()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
|
||||
*/
|
||||
public void init( IViewPart view )
|
||||
{
|
||||
fView = view;
|
||||
view.getSite().getPage().addPartListener( this );
|
||||
view.getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
|
||||
*/
|
||||
public void selectionChanged( IWorkbenchPart part, ISelection selection )
|
||||
{
|
||||
if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) )
|
||||
{
|
||||
update( getAction(), selection );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#run(IAction)
|
||||
*/
|
||||
public void run( IAction action )
|
||||
{
|
||||
final IStructuredSelection selection = getSelection();
|
||||
if ( selection != null && selection.size() != 1 )
|
||||
return;
|
||||
BusyIndicator.showWhile( Display.getCurrent(),
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
doAction( selection.getFirstElement() );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
setStatus( e.getStatus() );
|
||||
}
|
||||
}
|
||||
} );
|
||||
if ( getStatus() != null && !getStatus().isOK() )
|
||||
{
|
||||
IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow();
|
||||
if ( window != null )
|
||||
{
|
||||
CDebugUIPlugin.errorDialog( getErrorDialogMessage(), getStatus() );
|
||||
}
|
||||
else
|
||||
{
|
||||
CDebugUIPlugin.log( getStatus() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
|
||||
*/
|
||||
public void selectionChanged( IAction action, ISelection selection )
|
||||
{
|
||||
setAction( action );
|
||||
if ( getView() != null )
|
||||
{
|
||||
update( action, selection );
|
||||
}
|
||||
}
|
||||
|
||||
protected void update( IAction action, ISelection s )
|
||||
{
|
||||
if ( action != null && s instanceof IStructuredSelection )
|
||||
{
|
||||
IStructuredSelection ss = (IStructuredSelection)s;
|
||||
action.setEnabled( getEnableStateForSelection( ss ) );
|
||||
setSelection( ss );
|
||||
}
|
||||
else
|
||||
{
|
||||
action.setEnabled( false );
|
||||
setSelection( StructuredSelection.EMPTY );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
|
||||
*/
|
||||
public void partActivated( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
|
||||
*/
|
||||
public void partBroughtToTop( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
|
||||
*/
|
||||
public void partClosed( IWorkbenchPart part )
|
||||
{
|
||||
if ( part.equals( getView() ) )
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
|
||||
*/
|
||||
public void partDeactivated( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
|
||||
*/
|
||||
public void partOpened( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
protected IViewPart getView()
|
||||
{
|
||||
return fView;
|
||||
}
|
||||
|
||||
protected void setView( IViewPart viewPart )
|
||||
{
|
||||
fView = viewPart;
|
||||
}
|
||||
|
||||
protected void setAction( IAction action )
|
||||
{
|
||||
fAction = action;
|
||||
}
|
||||
|
||||
protected IAction getAction()
|
||||
{
|
||||
return fAction;
|
||||
}
|
||||
|
||||
private void setSelection( IStructuredSelection selection )
|
||||
{
|
||||
fSelection = selection;
|
||||
}
|
||||
|
||||
private IStructuredSelection getSelection()
|
||||
{
|
||||
return fSelection;
|
||||
}
|
||||
|
||||
protected void dispose()
|
||||
{
|
||||
if ( getView() != null )
|
||||
{
|
||||
getView().getViewSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
getView().getViewSite().getPage().removePartListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean getEnableStateForSelection( IStructuredSelection selection )
|
||||
{
|
||||
if ( selection.size() != 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Object element = selection.getFirstElement();
|
||||
return ( element != null &&
|
||||
element instanceof IDebugElement &&
|
||||
((IDebugElement)element).getDebugTarget().getAdapter( IExecFileInfo.class ) != null );
|
||||
}
|
||||
|
||||
private ListSelectionDialog createDialog()
|
||||
{
|
||||
return new ListSelectionDialog( getView().getSite().getShell(),
|
||||
fGlobals,
|
||||
new IStructuredContentProvider()
|
||||
{
|
||||
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
|
||||
{
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public Object[] getElements( Object parent )
|
||||
{
|
||||
return getGlobals();
|
||||
}
|
||||
},
|
||||
new LabelProvider()
|
||||
{
|
||||
public String getText( Object element )
|
||||
{
|
||||
if ( element instanceof Global )
|
||||
{
|
||||
String path = "";
|
||||
if ( ((Global)element).getPath() != null )
|
||||
{
|
||||
path = ((Global)element).getPath().toString();
|
||||
int index = path.lastIndexOf( '/' );
|
||||
if ( index != -1 )
|
||||
path = path.substring( index + 1 );
|
||||
}
|
||||
return ( path.length() > 0 ? ( '\'' + path + "\'::" ) : "" ) + ((Global)element).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
},
|
||||
"Select Variables:" );
|
||||
}
|
||||
|
||||
protected Global[] getGlobals()
|
||||
{
|
||||
return fGlobals;
|
||||
}
|
||||
|
||||
protected void doAction( Object element ) throws DebugException
|
||||
{
|
||||
if ( getView() == null )
|
||||
return;
|
||||
if ( element != null && element instanceof IDebugElement )
|
||||
{
|
||||
IExecFileInfo info = (IExecFileInfo)((IDebugElement)element).getDebugTarget().getAdapter( IExecFileInfo.class );
|
||||
if ( info != null )
|
||||
{
|
||||
IGlobalVariable[] globalVars = (IGlobalVariable[])info.getGlobals();
|
||||
fGlobals = new Global[globalVars.length];
|
||||
for ( int i = 0; i < globalVars.length; ++i )
|
||||
{
|
||||
fGlobals[i] = new Global( globalVars[i].getName(), globalVars[i].getPath() );
|
||||
}
|
||||
ListSelectionDialog dlg = createDialog();
|
||||
if ( dlg.open() == Dialog.OK )
|
||||
{
|
||||
Object[] selections = dlg.getResult();
|
||||
for ( int i = 0; i < selections.length; ++i )
|
||||
{
|
||||
createExpression( ((IDebugElement)element).getDebugTarget(), ((Global)selections[i]).toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getStatusMessage()
|
||||
{
|
||||
return "Exceptions occurred attempting to add global variables.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractDebugActionDelegate#getErrorDialogMessage()
|
||||
*/
|
||||
protected String getErrorDialogMessage()
|
||||
{
|
||||
return "Add global variables failed.";
|
||||
}
|
||||
|
||||
protected void setStatus( IStatus status )
|
||||
{
|
||||
fStatus = status;
|
||||
}
|
||||
|
||||
protected IStatus getStatus()
|
||||
{
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
private void createExpression( IDebugTarget target, String text ) throws DebugException
|
||||
{
|
||||
IExpression expression = CDebugModel.createExpression( target, text );
|
||||
DebugPlugin.getDefault().getExpressionManager().addExpression( expression );
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue