From a2b86fef61de5156bd0be125f1bfe1b02d8ca7f8 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Thu, 21 Apr 2005 20:10:06 +0000 Subject: [PATCH] Restoring the session manager. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 1 + .../cdt/debug/core/CDebugCorePlugin.java | 15 +++++ .../debug/internal/core/SessionManager.java | 60 +++++++------------ 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 337241753fa..8b75e55a4e8 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -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. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index 6bc7c819867..892da337a59 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -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(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/SessionManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/SessionManager.java index 0333382fc64..5252aa57054 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/SessionManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/SessionManager.java @@ -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 ); } }