mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Restoring the session manager.
This commit is contained in:
parent
082b3963e9
commit
a2b86fef61
3 changed files with 39 additions and 37 deletions
|
@ -1,6 +1,7 @@
|
||||||
2005-04-21 Mikhail Khodjaiants
|
2005-04-21 Mikhail Khodjaiants
|
||||||
Restoring the session manager.
|
Restoring the session manager.
|
||||||
* CDebugCorePlugin.java
|
* CDebugCorePlugin.java
|
||||||
|
* SessionManager.java
|
||||||
|
|
||||||
2005-04-21 Mikhail Khodjaiants
|
2005-04-21 Mikhail Khodjaiants
|
||||||
Cleanup. Removed the session manager from the CDebugCorePlugin class.
|
Cleanup. Removed the session manager from the CDebugCorePlugin class.
|
||||||
|
|
|
@ -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.DebugConfiguration;
|
||||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
||||||
import org.eclipse.cdt.debug.internal.core.ListenerList;
|
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.breakpoints.CBreakpoint;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CommonSourceLookupDirector;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CommonSourceLookupDirector;
|
||||||
|
@ -66,6 +67,8 @@ public class CDebugCorePlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
private CommonSourceLookupDirector fCommonSourceLookupDirector;
|
private CommonSourceLookupDirector fCommonSourceLookupDirector;
|
||||||
|
|
||||||
|
private SessionManager fSessionManager = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* 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 ) {
|
public void saveCommonSourceLocations( ICSourceLocation[] locations ) {
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_SOURCE_LOCATIONS, SourceUtils.getCommonSourceLocationsMemento( locations ) );
|
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_SOURCE_LOCATIONS, SourceUtils.getCommonSourceLocationsMemento( locations ) );
|
||||||
}
|
}
|
||||||
|
@ -241,12 +254,14 @@ public class CDebugCorePlugin extends Plugin {
|
||||||
initializeCommonSourceLookupDirector();
|
initializeCommonSourceLookupDirector();
|
||||||
createBreakpointListenersList();
|
createBreakpointListenersList();
|
||||||
resetBreakpointsInstallCount();
|
resetBreakpointsInstallCount();
|
||||||
|
setSessionManager( new SessionManager() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
public void stop( BundleContext context ) throws Exception {
|
public void stop( BundleContext context ) throws Exception {
|
||||||
|
setSessionManager( null );
|
||||||
disposeBreakpointListenersList();
|
disposeBreakpointListenersList();
|
||||||
resetBreakpointsInstallCount();
|
resetBreakpointsInstallCount();
|
||||||
disposeCommonSourceLookupDirector();
|
disposeCommonSourceLookupDirector();
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.internal.core;
|
package org.eclipse.cdt.debug.internal.core;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
|
@ -22,71 +21,58 @@ import org.eclipse.debug.core.ILaunch;
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of the session manager.
|
* Default implementation of the session manager. Terminates the session when the last target is terminated;
|
||||||
* Terminates session when the last target is terminated;
|
|
||||||
*
|
|
||||||
* @since Apr 28, 2003
|
|
||||||
*/
|
*/
|
||||||
public class SessionManager implements IDebugEventSetListener
|
public class SessionManager implements IDebugEventSetListener {
|
||||||
{
|
|
||||||
public SessionManager()
|
public SessionManager() {
|
||||||
{
|
|
||||||
DebugPlugin.getDefault().addDebugEventListener( this );
|
DebugPlugin.getDefault().addDebugEventListener( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
* @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 ) )
|
if ( SessionManager.class.equals( adapter ) )
|
||||||
return this;
|
return this;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose() {
|
||||||
{
|
|
||||||
DebugPlugin.getDefault().removeDebugEventListener( this );
|
DebugPlugin.getDefault().removeDebugEventListener( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
|
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
|
||||||
*/
|
*/
|
||||||
public void handleDebugEvents( DebugEvent[] events )
|
public void handleDebugEvents( DebugEvent[] events ) {
|
||||||
{
|
for( int i = 0; i < events.length; i++ ) {
|
||||||
for ( int i = 0; i < events.length; i++ )
|
|
||||||
{
|
|
||||||
DebugEvent event = events[i];
|
DebugEvent event = events[i];
|
||||||
if ( event.getKind() == DebugEvent.TERMINATE )
|
if ( event.getKind() == DebugEvent.TERMINATE ) {
|
||||||
{
|
|
||||||
Object element = event.getSource();
|
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() );
|
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();
|
IDebugTarget[] targets = launch.getDebugTargets();
|
||||||
boolean terminate = true;
|
boolean terminate = true;
|
||||||
for ( int i = 0; i < targets.length; ++i )
|
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() )
|
||||||
if ( targets[i].getAdapter( ICDITarget.class ) != null &&
|
|
||||||
session.equals( ((ICDITarget)targets[i].getAdapter( ICDITarget.class )).getSession() ) &&
|
|
||||||
!targets[i].isTerminated() && !targets[i].isDisconnected() )
|
|
||||||
terminate = false;
|
terminate = false;
|
||||||
}
|
}
|
||||||
if ( terminate )
|
if ( terminate ) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
session.terminate();
|
session.terminate();
|
||||||
}
|
}
|
||||||
catch( CDIException e )
|
catch( CDIException e ) {
|
||||||
{
|
|
||||||
CDebugCorePlugin.log( e );
|
CDebugCorePlugin.log( e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue