1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Changes in the 'Automatically Load Symbols' action because of the removal of the

This commit is contained in:
Mikhail Khodjaiants 2003-02-13 00:16:37 +00:00
parent ed1c2b769e
commit 1e011191d0
3 changed files with 61 additions and 63 deletions

View file

@ -1,3 +1,9 @@
2003-02-12 Mikhail Khodjaiants
Changes in the 'Automatically Load Symbols' action because of the removal of the
'setAutoSolib' method from ICDISharedLibraryManager.
* SetAutoSolibActionDelegate.java
* plugin.xml
2003-02-11 Mikhail Khodjaiants 2003-02-11 Mikhail Khodjaiants
The 'Automatically Load Symbols' action is added to the 'Shared Libraries' view. The 'Automatically Load Symbols' action is added to the 'Shared Libraries' view.
* SetAutoSolibActionDelegate.java: new * SetAutoSolibActionDelegate.java: new

View file

@ -61,11 +61,11 @@
icon="icons/full/elcl16/auto_solib_co.gif" icon="icons/full/elcl16/auto_solib_co.gif"
helpContextId="set_auto_solib_action_context" helpContextId="set_auto_solib_action_context"
label="%SetAutoSolibAction.label" label="%SetAutoSolibAction.label"
menubarPath="sharedLibrariesGroup" menubarPath="additions"
tooltip="%SetAutoSolibAction.tooltip"> tooltip="%SetAutoSolibAction.tooltip">
<enablement> <enablement>
<pluginState <pluginState
value="activated" value="installed"
id="org.eclipse.cdt.debug.ui"> id="org.eclipse.cdt.debug.ui">
</pluginState> </pluginState>
</enablement> </enablement>

View file

@ -5,15 +5,21 @@
*/ */
package org.eclipse.cdt.debug.mi.internal.ui.actions; package org.eclipse.cdt.debug.mi.internal.ui.actions;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.mi.core.MIPlugin;
import org.eclipse.cdt.debug.mi.core.cdi.Session;
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IPartListener; import org.eclipse.ui.IPartListener;
@ -34,7 +40,6 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
{ {
private IViewPart fView = null; private IViewPart fView = null;
private IAction fAction; private IAction fAction;
private IStructuredSelection fSelection;
private IStatus fStatus = null; private IStatus fStatus = null;
/** /**
@ -42,6 +47,7 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
*/ */
public SetAutoSolibActionDelegate() public SetAutoSolibActionDelegate()
{ {
super();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -61,14 +67,6 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
{ {
if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) )
{ {
if ( selection instanceof IStructuredSelection )
{
setSelection( (IStructuredSelection)selection );
}
else
{
setSelection( null );
}
update( getAction() ); update( getAction() );
} }
} }
@ -78,9 +76,6 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
*/ */
public void run( IAction action ) public void run( IAction action )
{ {
final IStructuredSelection selection = getSelection();
if ( selection != null && selection.size() != 1 )
return;
BusyIndicator.showWhile( Display.getCurrent(), BusyIndicator.showWhile( Display.getCurrent(),
new Runnable() new Runnable()
{ {
@ -88,7 +83,7 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
{ {
try try
{ {
doAction( selection.getFirstElement() ); doAction( DebugUITools.getDebugContext() );
setStatus( null ); setStatus( null );
} }
catch( DebugException e ) catch( DebugException e )
@ -109,6 +104,7 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
CDebugUIPlugin.log( getStatus() ); CDebugUIPlugin.log( getStatus() );
} }
} }
update( action );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -127,8 +123,9 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
{ {
if ( action != null ) if ( action != null )
{ {
action.setEnabled( getEnableStateForSelection( getSelection() ) ); IAdaptable element = DebugUITools.getDebugContext();
action.setChecked( getCheckStateForSelection( getSelection() ) ); action.setEnabled( getEnableStateForSelection( element ) );
action.setChecked( getCheckStateForSelection( element ) );
} }
} }
@ -191,16 +188,6 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
return fAction; return fAction;
} }
private void setSelection( IStructuredSelection selection )
{
fSelection = selection;
}
private IStructuredSelection getSelection()
{
return fSelection;
}
protected void dispose() protected void dispose()
{ {
if ( getView() != null ) if ( getView() != null )
@ -210,34 +197,27 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
} }
} }
protected boolean getCheckStateForSelection( IStructuredSelection selection ) protected boolean getCheckStateForSelection( IAdaptable element )
{ {
if ( selection == null || selection.size() != 1 ) SharedLibraryManager slm = getSharedLibraryManager( element );
if ( slm != null )
{ {
return false; try
} {
Object element = selection.getFirstElement(); return slm.isAutoLoadSymbols();
if ( element instanceof IDebugElement ) }
{ catch( CDIException e )
ICSharedLibraryManager slm = (ICSharedLibraryManager)((IDebugElement)element).getDebugTarget().getAdapter( ICSharedLibraryManager.class );
if ( slm != null )
{ {
return slm.getAutoLoadSymbols();
} }
} }
return false; return false;
} }
protected boolean getEnableStateForSelection( IStructuredSelection selection ) protected boolean getEnableStateForSelection( IAdaptable element )
{ {
if ( selection == null || selection.size() != 1 )
{
return false;
}
Object element = selection.getFirstElement();
return ( element instanceof IDebugElement && return ( element instanceof IDebugElement &&
((IDebugElement)element).getDebugTarget().isSuspended() && ((IDebugElement)element).getDebugTarget().isSuspended() &&
((IDebugElement)element).getDebugTarget().getAdapter( ICSharedLibraryManager.class ) != null ); getSharedLibraryManager( element ) != null );
} }
protected String getStatusMessage() protected String getStatusMessage()
@ -263,25 +243,37 @@ public class SetAutoSolibActionDelegate implements IViewActionDelegate,
return fStatus; return fStatus;
} }
protected void doAction( Object element ) throws DebugException protected void doAction( IAdaptable element ) throws DebugException
{ {
if ( getView() == null ) if ( getView() == null )
return; return;
if ( element instanceof IDebugElement ) SharedLibraryManager slm = getSharedLibraryManager( element );
if ( slm != null && getAction() != null )
{ {
ICSharedLibraryManager slm = (ICSharedLibraryManager)((IDebugElement)element).getDebugTarget().getAdapter( ICSharedLibraryManager.class ); try
if ( slm != null && getAction() != null )
{ {
try slm.setAutoLoadSymbols( getAction().isChecked() );
{ }
slm.setAutoLoadSymbols( getAction().isChecked() ); catch( CDIException e )
} {
catch( DebugException e ) getAction().setChecked( !getAction().isChecked() );
{ throw new DebugException( new Status( IStatus.ERROR,
getAction().setChecked( slm.getAutoLoadSymbols() ); MIPlugin.getUniqueIdentifier(),
throw e; DebugException.TARGET_REQUEST_FAILED,
} e.toString(),
null ) );
} }
} }
} }
private SharedLibraryManager getSharedLibraryManager( IAdaptable element )
{
if ( element != null )
{
ICDISession session = (ICDISession)element.getAdapter( ICDISession.class );
if ( session instanceof Session && ((Session)session).getSharedLibraryManager() instanceof SharedLibraryManager )
return (SharedLibraryManager)((Session)session).getSharedLibraryManager();
}
return null;
}
} }