1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Restoring the session manager.

This commit is contained in:
Mikhail Khodjaiants 2005-04-21 20:10:06 +00:00
parent 082b3963e9
commit a2b86fef61
3 changed files with 39 additions and 37 deletions

View file

@ -1,6 +1,7 @@
2005-04-21 Mikhail Khodjaiants
Restoring the session manager.
* CDebugCorePlugin.java
* SessionManager.java
2005-04-21 Mikhail Khodjaiants
Cleanup. Removed the session manager from the CDebugCorePlugin class.

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.internal.core.DebugConfiguration;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.core.ListenerList;
import org.eclipse.cdt.debug.internal.core.SessionManager;
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CommonSourceLookupDirector;
@ -66,6 +67,8 @@ public class CDebugCorePlugin extends Plugin {
*/
private CommonSourceLookupDirector fCommonSourceLookupDirector;
private SessionManager fSessionManager = null;
/**
* The constructor.
*/
@ -189,6 +192,16 @@ public class CDebugCorePlugin extends Plugin {
}
}
protected SessionManager getSessionManager() {
return fSessionManager;
}
protected void setSessionManager( SessionManager sm ) {
if ( fSessionManager != null )
fSessionManager.dispose();
fSessionManager = sm;
}
public void saveCommonSourceLocations( ICSourceLocation[] locations ) {
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_SOURCE_LOCATIONS, SourceUtils.getCommonSourceLocationsMemento( locations ) );
}
@ -241,12 +254,14 @@ public class CDebugCorePlugin extends Plugin {
initializeCommonSourceLookupDirector();
createBreakpointListenersList();
resetBreakpointsInstallCount();
setSessionManager( new SessionManager() );
}
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop( BundleContext context ) throws Exception {
setSessionManager( null );
disposeBreakpointListenersList();
resetBreakpointsInstallCount();
disposeCommonSourceLookupDirector();

View file

@ -8,7 +8,6 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@ -22,71 +21,58 @@ import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugTarget;
/**
* Default implementation of the session manager.
* Terminates session when the last target is terminated;
*
* @since Apr 28, 2003
* Default implementation of the session manager. Terminates the session when the last target is terminated;
*/
public class SessionManager implements IDebugEventSetListener
{
public SessionManager()
{
public class SessionManager implements IDebugEventSetListener {
public SessionManager() {
DebugPlugin.getDefault().addDebugEventListener( this );
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter( Class adapter )
{
public Object getAdapter( Class adapter ) {
if ( SessionManager.class.equals( adapter ) )
return this;
return null;
}
public void dispose()
{
public void dispose() {
DebugPlugin.getDefault().removeDebugEventListener( this );
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
*/
public void handleDebugEvents( DebugEvent[] events )
{
for ( int i = 0; i < events.length; i++ )
{
public void handleDebugEvents( DebugEvent[] events ) {
for( int i = 0; i < events.length; i++ ) {
DebugEvent event = events[i];
if ( event.getKind() == DebugEvent.TERMINATE )
{
if ( event.getKind() == DebugEvent.TERMINATE ) {
Object element = event.getSource();
if ( element instanceof IDebugTarget && ((IDebugTarget)element).getAdapter( ICDITarget.class ) != null )
{
if ( element instanceof IDebugTarget && ((IDebugTarget)element).getAdapter( ICDITarget.class ) != null ) {
handleTerminateEvent( ((IDebugTarget)element).getLaunch(), ((ICDITarget)((IDebugTarget)element).getAdapter( ICDITarget.class )).getSession() );
}
}
}
}
private void handleTerminateEvent( ILaunch launch, ICDISession session )
{
private void handleTerminateEvent( ILaunch launch, ICDISession session ) {
IDebugTarget[] targets = launch.getDebugTargets();
boolean terminate = true;
for ( int i = 0; i < targets.length; ++i )
{
if ( targets[i].getAdapter( ICDITarget.class ) != null &&
session.equals( ((ICDITarget)targets[i].getAdapter( ICDITarget.class )).getSession() ) &&
!targets[i].isTerminated() && !targets[i].isDisconnected() )
for( int i = 0; i < targets.length; ++i ) {
if ( targets[i].getAdapter( ICDITarget.class ) != null && session.equals( ((ICDITarget)targets[i].getAdapter( ICDITarget.class )).getSession() ) && !targets[i].isTerminated() && !targets[i].isDisconnected() )
terminate = false;
}
if ( terminate )
{
try
{
}
if ( terminate ) {
try {
session.terminate();
}
catch( CDIException e )
{
catch( CDIException e ) {
CDebugCorePlugin.log( e );
}
}