initial commit in accordance with CQ 3784
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/.classpath b/plugins/org.eclipse.objectteams.otdt.debug/.classpath
new file mode 100644
index 0000000..304e861
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/.cvsignore b/plugins/org.eclipse.objectteams.otdt.debug/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/.project b/plugins/org.eclipse.objectteams.otdt.debug/.project
new file mode 100644
index 0000000..0cca0d4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.objectteams.otdt.debug</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.objectteams.otdt.debug/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..6305aca
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,57 @@
+#Tue Sep 18 18:19:36 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.otdt.debug/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..37af2cb
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OTDebug Plug-in
+Bundle-SymbolicName: org.eclipse.objectteams.otdt.debug;singleton:=true
+Bundle-Version: 1.4.0.qualifier
+Bundle-Activator: org.eclipse.objectteams.otdt.debug.OTDebugPlugin
+Bundle-Vendor: Fraunhofer FIRST
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.debug.core,
+ org.eclipse.jdt.debug,
+ org.eclipse.jdt.launching,
+ org.eclipse.jdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.objectteams.otdt
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.objectteams.otdt.debug,
+ org.eclipse.objectteams.otdt.debug.core.breakpoints,
+ org.eclipse.objectteams.otdt.debug.internal
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/build.properties b/plugins/org.eclipse.objectteams.otdt.debug/build.properties
new file mode 100644
index 0000000..0c93900
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+               META-INF/,\
+               .
+src.includes = .project,\
+               .classpath,\
+               build.properties
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/scripts/genIOOTBreakPoints.launch b/plugins/org.eclipse.objectteams.otdt.debug/scripts/genIOOTBreakPoints.launch
new file mode 100644
index 0000000..814e921
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/scripts/genIOOTBreakPoints.launch
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/org.eclipse.objectteams.otdt.debug&quot; type=&quot;4&quot;/&gt;&#10;&lt;/resources&gt;}"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.objectteams.otdt.debug/scripts/genIOOTBreakPoints.sh}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="${project_loc:OTRE}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/org.eclipse.objectteams.otdt.debug}"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/scripts/genIOOTBreakPoints.sh b/plugins/org.eclipse.objectteams.otdt.debug/scripts/genIOOTBreakPoints.sh
new file mode 100644
index 0000000..0b700bd
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/scripts/genIOOTBreakPoints.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# This script is inteded to be invoked from within eclipse 
+# using the launch configuration genIOOTBreakPoints.launch
+# in the same directory.
+# Prerequisite: 
+# You must have the project OTRE within the same workspace.
+#
+# author: stephan@cs.tu-berlin.de
+
+
+# Let's identify ourselves:
+CWD=`pwd`
+PROG=`echo $0 | sed "s|${CWD}/||"`
+
+HEADER="/**********************************************************************
+ * This file is part of \"Object Teams Development Tooling\"-Software
+ * 
+ * Copyright 2006, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * \$Id\$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.core.breakpoints;
+
+/** 
+ *  Do not edit: This interface is auto-generated from org/objectteams/Team.java 
+ *  using ${PROG}
+ *
+ *  Purpose: make specific line numbers of Team.java available for the debugger.
+ */
+public interface IOOTBreakPoints 
+{"
+
+
+# INPUT:
+OTRE=$1
+if [ ! -d ${OTRE} ]; then
+	echo "Project root of OTRE not found at ${OTRE}".
+	echo "Perhaps you don't have project OTRE in your workspace?"
+	exit
+fi
+TEAM=${OTRE}/src/org/objectteams/Team.java
+if [ ! -f ${TEAM} ]; then
+	echo "Team.java not found at ${TEAM}."
+	exit
+fi
+
+# OUTPUT:
+OUT=src/org/objectteams/otdt/debug/core/breakpoints/IOOTBreakPoints.java
+
+if [ "$2" != "RUN" ]
+then
+    # fetch stdin from Team.java, write to IOOTBreakPoints.java and restart:
+    $0 $1 RUN 0<"$TEAM" | tee $OUT
+    echo ">>>> Please refresh the source folder. <<<<"
+    exit
+else
+
+	echo "${HEADER}"
+    i=0
+    while read 
+    do
+        i=`expr $i + 1`
+        l=`echo "$REPLY" | sed -e "s/^.*[$]Debug(\(.*\))/\1/"`
+        if [ "$REPLY" != "$l" ]
+        then
+            echo "  int LINE_$l = $i;"
+        fi
+    done
+	echo "}"
+fi
+
+
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTDTDebugPreferenceConstants.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTDTDebugPreferenceConstants.java
new file mode 100644
index 0000000..59cfc62
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTDTDebugPreferenceConstants.java
@@ -0,0 +1,33 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;

+

+public interface IOTDTDebugPreferenceConstants

+{

+

+	/**

+	 * The sort mode for teams in Teamview

+	 */

+	public static final String TEAMS_BY_NAME = "Teams.by.name"; //$NON-NLS-1$

+	public static final String TEAMS_BY_INSTANTIATION = "Teams.by.instantiation"; //$NON-NLS-1$

+	public static final String TEAMS_BY_ACTIVATION_TIME = "Teams.by.activationtime"; //$NON-NLS-1$

+	public static final String TEAMS_BY_ACTIVATION_ORDER = "Teams.by.activationorder"; //$NON-NLS-1$

+}

diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTDebugEventListener.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTDebugEventListener.java
new file mode 100644
index 0000000..6b912ce
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTDebugEventListener.java
@@ -0,0 +1,34 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: IOTDebugEventListener.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;
+
+import org.eclipse.debug.core.ILaunch;
+
+/**
+ * @author gis
+ */
+public interface IOTDebugEventListener
+{
+    public void launched(ILaunch launch);
+    public void teamInstantiated(TeamInstance newTeam);
+    public void teamDisposed(int idx);
+    public void activationStateChanged(TeamInstance teamInstance);
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTLaunchConstants.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTLaunchConstants.java
new file mode 100644
index 0000000..26cbed3
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/IOTLaunchConstants.java
@@ -0,0 +1,43 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: IOTLaunchConstants.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;
+
+
+/**
+ * @author resix
+ */
+public interface IOTLaunchConstants {
+	public static final String uniquePrefix = "org.eclipse.objectteams.otdt.debug"; //$NON-NLS-1$
+	/**
+	 * Launch configuration attribute key. The value is a list of team names
+	 * to be woven and activated automatically in this objectteams launch configuration.
+	 */
+	public static final String ATTR_TEAMCONFIG_LIST = uniquePrefix + ".TEAMCONFIG_ATTR"; //$NON-NLS-1$
+	
+	/**
+	 * Launch configuration attribute key. The value states, if the teams in the objectteams 
+	 * launch configuration will be actually used while launching.
+	 */
+	public static final String ATTR_TEAMCONFIG_ACTIVE = uniquePrefix + ".TEAMCONFIG_ACTIVE_ATTR"; //$NON-NLS-1$
+
+	public static final String ATTR_USE_JPLIS = uniquePrefix + ".USE_JPLIS"; //$NON-NLS-1$
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTDebugElementsContainer.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTDebugElementsContainer.java
new file mode 100644
index 0000000..7a75e4c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTDebugElementsContainer.java
@@ -0,0 +1,228 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTDebugElementsContainer.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.eclipse.core.internal.runtime.AdapterManager;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+import org.eclipse.jdt.internal.debug.core.model.JDIThisVariable;
+import org.eclipse.objectteams.otdt.debug.internal.util.TeamActivationOrderComparator;
+import org.eclipse.objectteams.otdt.debug.internal.util.TeamActivationTimeComparator;
+import org.eclipse.objectteams.otdt.debug.internal.util.TeamInstantiantionComparator;
+import org.eclipse.objectteams.otdt.debug.internal.util.TeamNameComparator;
+
+/**
+ * One instance of this class exists per launch (ensured by OTDebugElementsContainerFactory).
+ * At each point in time, each OTDebugElementsContainer also refers to a specific "context" - 
+ * either of:
+ * <ul>
+ * <li> ILaunch </li>
+ * <li> IThread </li>
+ * <li> IStackFrame </li>
+ * </ul>
+ * Depending on the context of the Container a current thread can be requested (IThread/IStackFrame).
+ * 
+ * A list of known team instances is maintained, which is always sorted according to the 
+ * current sorting mode.
+ * 
+ * @author ike
+ * $Id: OTDebugElementsContainer.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+public class OTDebugElementsContainer implements IAdaptable
+{
+    private ArrayList<TeamInstance> _teamInstances = new ArrayList<TeamInstance>();
+    private IDebugElement _context;
+	private String _sortMode;
+
+	/** @category lifecycle */
+	public Object getAdapter(Class adapter)
+	{
+		return AdapterManager.getDefault().getAdapter(this, adapter);
+	}
+	
+	/** @category lifecycle */
+	public IDebugElement getContext()
+	{
+		return _context;
+	}
+
+	/**
+	 * @category lifecycle 
+	 * 
+	 * @param context
+	 * @return true if the context actually changed (refresh needed).
+	 */
+	public boolean setContext(IDebugElement context)
+	{
+		if (this._context == context)
+			return false;
+		_context = context;
+		return true; 
+	}
+	
+	/** @category lifecycle */
+	public void dispose()
+	{
+		_teamInstances.clear();
+	}
+	
+	/** @throws DebugException 
+	 * @category modification */
+    public TeamInstance addTeamInstance(JDIThisVariable teamVariable) 
+    		throws DebugException
+    {
+    	TeamInstance teamInstance = getTeamInstance(teamVariable);
+    	if (teamInstance== null)
+        {
+        	teamInstance = new TeamInstance(teamVariable);
+        	_teamInstances.add(teamInstance);
+    		sortTeamInstances();
+        }
+        
+        return teamInstance;
+    }
+    
+    /** @category modification */
+    public int removeTeamInstance(IJavaVariable teamVariable)
+    {
+    	for (int i=0; i<this._teamInstances.size(); i++)
+    	{
+    		if(this._teamInstances.get(i).equals(teamVariable))
+    		{
+    			_teamInstances.remove(i);
+    			return i;
+    		}
+		}
+    	return -1;
+    }
+    
+    /** @category modification */
+	public void setSortMode(String sortMode)
+	{
+		String oldSortMode= _sortMode;
+		_sortMode = sortMode;
+		if (sortMode != null && !sortMode.equals(oldSortMode))
+			sortTeamInstances();
+	}
+
+	/** @category modification */
+	private void sortTeamInstances()
+	{
+		if (_sortMode == null)
+			return;
+		if(_sortMode.equals(IOTDTDebugPreferenceConstants.TEAMS_BY_ACTIVATION_TIME))
+		{
+			Collections.sort(_teamInstances, new TeamActivationTimeComparator());
+		}
+		if(_sortMode.equals(IOTDTDebugPreferenceConstants.TEAMS_BY_ACTIVATION_ORDER))
+		{
+			Collections.sort(_teamInstances, new TeamActivationOrderComparator());
+		}
+		if(_sortMode.equals(IOTDTDebugPreferenceConstants.TEAMS_BY_INSTANTIATION))
+		{
+			Collections.sort(_teamInstances, new TeamInstantiantionComparator());
+		}
+		if(_sortMode.equals(IOTDTDebugPreferenceConstants.TEAMS_BY_NAME))
+		{
+			Collections.sort(_teamInstances, new TeamNameComparator());
+		}
+	}
+
+	/** @category query */
+	public boolean hasTeamInstances()
+	{
+		return !_teamInstances.isEmpty();
+	}
+
+	/** @category query */
+	public int getChildCount() {
+		return _teamInstances.size();
+	}
+
+	/** @category query */
+    public TeamInstance getTeamInstance(IJavaVariable teamVariable)
+    {
+    	for (Iterator iter = _teamInstances.iterator(); iter.hasNext();)
+    	{
+			TeamInstance teamInstance = (TeamInstance) iter.next();
+    		if(teamInstance.equals(teamVariable))
+    			return teamInstance;
+    	}
+		return null;
+    }
+    
+    /** @category query */
+    public int getIndexOfTeamInstance(TeamInstance teamInstance) {
+    	for (int i = 0; i < this._teamInstances.size(); i++)
+			if (this._teamInstances.get(i).equals(teamInstance))
+				return i;
+
+    	return -1;
+    }
+
+    /** @category query */
+    public ArrayList<TeamInstance> getTeamInstances()
+    {
+		return _teamInstances;
+    }
+
+    /** 
+     * @category query
+     * 
+     * If the current context is either an IJavaThread or an IStackFrame,
+     * return the (corresponding) thread.
+     */
+	public IJavaThread getContextThread() {
+		if (this._context instanceof IJavaThread)
+			return (IJavaThread) this._context;
+		if (this._context instanceof IStackFrame) 
+			return (IJavaThread)((IStackFrame) this._context).getThread();
+		return null; // no specific thread selected
+	}
+
+	/** 
+	 * @category query
+	 * 
+	 * If the current context has a thread, ask whether it is suspended,
+	 * otherwise ask whether some thread is suspended (by using canResume()).
+	 */
+	public boolean isSuspended() {
+		IJavaThread contextThread = getContextThread();
+		if (contextThread != null && contextThread.isSuspended())
+			return true;
+		IDebugTarget target= null;
+		if (this._context instanceof IDebugTarget)
+			target = (IDebugTarget) this._context;
+		else
+			target= this._context.getDebugTarget();
+		return target.canResume();
+	}
+
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTDebugPlugin.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTDebugPlugin.java
new file mode 100644
index 0000000..5a76d1d
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTDebugPlugin.java
@@ -0,0 +1,370 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTDebugPlugin.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
+import org.eclipse.objectteams.otdt.core.exceptions.ExceptionHandler;
+import org.eclipse.objectteams.otdt.debug.internal.Logger;
+import org.eclipse.objectteams.otdt.debug.internal.OTDebugElementsContainerFactory;
+import org.eclipse.objectteams.otdt.debug.internal.RoleBreakpointListener;
+import org.eclipse.objectteams.otdt.debug.internal.StepFromLinenumberGenerator;
+import org.eclipse.objectteams.otdt.debug.internal.TeamBreakpointListener;
+import org.eclipse.objectteams.otdt.debug.internal.TempFileManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class OTDebugPlugin extends Plugin 
+{
+	public static final String PLUGIN_ID = "org.eclipse.objectteams.otdt.debug"; //$NON-NLS-1$
+	public static final String OT_LAUNCH = "org.eclipse.objectteams.launch"; //$NON-NLS-1$
+	/**
+	 * @deprecated reference to a removed launch configuration type.
+	 */
+    public static final String OT_LAUNCH_CONFIGURATION_TYPE = "org.objectteams.otdt.debug.LaunchConfigurationType"; //$NON-NLS-1$
+    
+    private OTDebugElementsContainerFactory _containerFactory;
+
+    class OTDebugLaunchManager implements ILaunchesListener2
+	{
+        private Vector<ILaunch> _otLaunches;
+        
+		public OTDebugLaunchManager()
+		{
+			ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
+			
+			if (launches != null)
+			{
+				_otLaunches = new Vector<ILaunch>();
+				for (int i = 0; i < launches.length; i++) 
+				{
+                    if (isOTDebugLaunch(launches[i]))
+                        _otLaunches.add(launches[i]);
+				}
+				checkOTLaunches(_otLaunches.size());
+			}
+		}
+		
+		public void terminateOTLaunches()
+		{
+		    // operate on a copy of _otLaunches to prevent concurrent modification
+		    ILaunch[] launches = new ILaunch[_otLaunches.size()];
+		    _otLaunches.copyInto(launches);
+		    
+		    for (int i = 0; i < launches.length; i++)
+            {
+                try {
+	                launches[i].terminate();
+                }
+                catch (DebugException ex) { // only log
+                    OTDebugPlugin.getExceptionHandler().logCoreException("Unable to terminate launch on bundle shutdown", ex); //$NON-NLS-1$
+                }
+            }
+		}
+		
+		public int getOTLaunchesCount() 
+		{
+			return _otLaunches.size();
+		}
+
+		private boolean isOTDebugLaunch(ILaunch launch)
+		{
+			try 
+			{
+				if (ILaunchManager.DEBUG_MODE.equals(launch.getLaunchMode())) { 
+					String isOTLaunch = launch.getAttribute(OT_LAUNCH);
+					if (isOTLaunch != null && isOTLaunch.equals("true")) //$NON-NLS-1$
+						return true;
+					if (launch.getLaunchConfiguration() != null) 
+						return launch.getLaunchConfiguration().getAttribute(OT_LAUNCH, false);
+				}
+			}
+			catch (CoreException ex)
+			{}
+			return false;
+		}
+
+        public void launchesAdded(ILaunch[] launches)
+        {
+            for (int idx = 0; idx < launches.length; idx++)
+            {
+                ILaunch launch = launches[idx];
+                if (isOTDebugLaunch(launch) && !_otLaunches.contains(launch))
+                {
+                    _otLaunches.add(launch);
+                    checkOTLaunches(_otLaunches.size());
+                }
+            }
+        }
+        
+        public void launchesTerminated(ILaunch[] launches)
+        {
+            forgetOTLaunches(launches);
+        }
+        
+        private void forgetOTLaunches(ILaunch[] launches)
+        {
+            for (int idx = 0; idx < launches.length; idx++)
+            {
+                ILaunch launch = launches[idx];
+                if (isOTDebugLaunch(launch) && _otLaunches.contains(launch))
+                {
+                    _otLaunches.remove(launch);
+                    checkOTLaunches(_otLaunches.size());
+                    otLaunchFinished(launch);
+                }
+            }
+            assert(_otLaunches.size() >= 0);
+        }
+
+        //we're not interested in this
+        public void launchesRemoved(ILaunch[] launches){}
+        public void launchesChanged(ILaunch[] launches){}
+	}
+	
+	private void otLaunchFinished(ILaunch launch)
+    {
+	    if (_tempFileManager != null) // we're really cautious today
+	        _tempFileManager.deleteTempFile(launch);
+    }
+	
+    //The shared instance.
+	private static OTDebugPlugin plugin;
+	//Resource bundle.
+	private ResourceBundle resourceBundle;
+	
+	private OTDebugLaunchManager _otLaunchManager;
+	private TeamBreakpointListener _otTeamBreakpointListener;
+	private RoleBreakpointListener _otRoleBreakpointListener;
+    private IOTDebugEventListener[] _listeners = new IOTDebugEventListener[0];
+    private TempFileManager _tempFileManager;
+    private StepFromLinenumberGenerator _stepGenerator;
+    private String _callinSteppingConfig = null;
+    
+	public OTDebugPlugin() 
+	{
+		super();
+		plugin = this;
+		try {
+			resourceBundle = ResourceBundle.getBundle("org.eclipse.objectteams.otdt.debug.OTDebugPluginResources"); //$NON-NLS-1$
+		} catch (MissingResourceException x) {
+			resourceBundle = null;
+		}
+	}
+	
+	public void setCallinSteppingConfig(String config) {
+		this._callinSteppingConfig = config;
+	}
+	public String getCallinSteppingConfig() {
+		return this._callinSteppingConfig;
+	}
+
+	public static Status createErrorStatus(String message)
+	{
+	    return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, null);
+	}
+	
+	public static Status createErrorStatus(String message, Throwable exception)
+	{
+	    return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, exception);
+	}
+	
+	/**
+	 * This method is called upon plug-in activation
+	 */
+	public void start(BundleContext context) throws Exception 
+	{
+		super.start(context);
+
+		_otLaunchManager = new OTDebugLaunchManager();
+		DebugPlugin.getDefault().getLaunchManager().addLaunchListener(_otLaunchManager);
+	}
+
+	/**
+	 * This method is called when the plug-in is stopped
+	 */
+	public void stop(BundleContext context) throws Exception 
+	{
+		// when this plugin is stopped, terminate any running OT launches
+	    unregisterOTDebugSupport();
+	    _otLaunchManager.terminateOTLaunches();
+		
+		DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(_otLaunchManager);
+		_otLaunchManager = null;
+		if (_tempFileManager != null)
+		{
+			_tempFileManager.deleteAll();
+			_tempFileManager = null;
+		}
+		
+		super.stop(context);
+	}
+
+    /**
+	 * Returns the shared instance.
+	 */
+	public static OTDebugPlugin getDefault() {
+		return plugin;
+	}
+
+	/**
+	 * Returns the string from the plugin's resource bundle,
+	 * or 'key' if not found.
+	 */
+	public static String getResourceString(String key) {
+		ResourceBundle bundle = OTDebugPlugin.getDefault().getResourceBundle();
+		try {
+			return (bundle != null) ? bundle.getString(key) : key;
+		} catch (MissingResourceException e) {
+			return key;
+		}
+	}
+
+	/**
+	 * Returns the plugin's resource bundle,
+	 */
+	public ResourceBundle getResourceBundle() {
+		return resourceBundle;
+	}
+
+	public static ExceptionHandler getExceptionHandler()
+	{
+		return new ExceptionHandler(PLUGIN_ID);
+	}
+
+	public TempFileManager getTempFileManager()
+    {
+	    if (_tempFileManager == null)
+	        _tempFileManager = new TempFileManager();
+	    
+        return _tempFileManager;
+    }
+
+	public IOTDebugEventListener[] getOTDebugEventListeners()
+    {
+        return _listeners;
+    }
+
+	public void addOTDebugEventListener(IOTDebugEventListener listener)
+	{
+	    int newLength = _listeners.length + 1;
+	    IOTDebugEventListener[] newListeners = new IOTDebugEventListener[newLength];
+	    System.arraycopy(_listeners, 0, newListeners, 0, _listeners.length);
+	    newListeners[_listeners.length] = listener;
+	    _listeners = newListeners;
+	}
+	
+	public void removeOTDebugEventListener(IOTDebugEventListener listener)
+	{
+	    int occurrences = 0;
+	    for (int i = 0; i < _listeners.length; i++)
+        {
+            if (listener.equals(_listeners[i]))
+                occurrences++;
+        }
+
+	    if (occurrences > 0)
+	    {
+		    int newLength = _listeners.length - occurrences;
+		    IOTDebugEventListener[] newListeners = new IOTDebugEventListener[newLength];
+
+		    int insertionIndex = 0;
+		    for (int i = 0; i < _listeners.length; i++)
+	        {
+	            if (!listener.equals(_listeners[i]))
+	                newListeners[insertionIndex++] = _listeners[i];
+	        }
+
+	        _listeners = newListeners;
+	    }
+	}
+	
+	public void checkOTLaunches(int otLaunchCount)
+	{
+		// Note: the order seems to be undefined! After finishing a launch, we do not 
+		// immediately get the launchRemoved event. We may first get another launchAdded 
+		// and then the previous launchRemoved. So we can't rely on the counter being 
+		// 0 or 1 here.
+		if (otLaunchCount <= 0)
+		{
+			unregisterOTDebugSupport();
+		}
+		else if (_otTeamBreakpointListener == null)
+			registerOTDebugSupport();
+	}
+
+	private void registerOTDebugSupport() 
+	{
+		assert(_otTeamBreakpointListener == null);
+		
+		 _containerFactory= new OTDebugElementsContainerFactory();
+		Platform.getAdapterManager().registerAdapters(_containerFactory, ILaunch.class);
+		
+		_otTeamBreakpointListener = TeamBreakpointListener.getInstance();
+		_otRoleBreakpointListener = RoleBreakpointListener.getInstance();
+		_stepGenerator = StepFromLinenumberGenerator.getInstance();
+
+		DebugPlugin.getDefault().addDebugEventFilter(_stepGenerator);
+		JDIDebugPlugin.getDefault().addJavaBreakpointListener(_otTeamBreakpointListener);
+		JDIDebugPlugin.getDefault().addJavaBreakpointListener(_otRoleBreakpointListener);
+	}
+
+	private void unregisterOTDebugSupport() 
+	{
+		if (_otTeamBreakpointListener != null)
+		{
+			DebugPlugin.getDefault().removeDebugEventFilter(_stepGenerator);
+			JDIDebugPlugin.getDefault().removeJavaBreakpointListener(_otTeamBreakpointListener);
+			JDIDebugPlugin.getDefault().removeJavaBreakpointListener(_otRoleBreakpointListener);
+			try
+            {
+                TeamBreakpointInstaller.uninstallTeamBreakpoints();
+            }
+            catch (CoreException e)
+            {
+                Logger.log(0,"OTDebugPlugin.unregisterOTDebugSupport()","ERROR unable to remove Breakpoints"); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+            _otTeamBreakpointListener.dispose();
+            _otTeamBreakpointListener = null;
+
+            _otRoleBreakpointListener.dispose();
+            _otRoleBreakpointListener = null;
+		}
+        if (_containerFactory != null)
+           	_containerFactory.dispose();
+        _containerFactory= null;
+	}
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTLaunchConfigMigrationDelegate.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTLaunchConfigMigrationDelegate.java
new file mode 100644
index 0000000..b289ec7
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTLaunchConfigMigrationDelegate.java
@@ -0,0 +1,89 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTLaunchConfigMigrationDelegate.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;
+
+import java.util.HashMap;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.internal.core.LaunchConfiguration;
+import org.eclipse.debug.internal.core.LaunchConfigurationInfo;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+
+/**
+ * This class migrates old OT-launches (Java App, OT/Equinox FW, OTEclipse App) into regular
+ * Eclipse launches, but marked as OTlaunch, thereby enabling the OTRE, OT/Equinox, resp.
+ * 
+ * @author stephan
+ * @since 1.2.2
+ */
+public class OTLaunchConfigMigrationDelegate implements ILaunchConfigurationMigrationDelegate {
+
+	final static HashMap<String,String> oldToNew = new HashMap<String, String>();
+	static {
+		oldToNew.put(OTDebugPlugin.OT_LAUNCH_CONFIGURATION_TYPE, 	IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
+		// 'referencing' constants from downstream plug-ins (old, removed launch configuration types)
+		oldToNew.put("org.objectteams.otdt.pde.ui.OTEquinoxLaunchConfigurationType", 		  "org.eclipse.pde.ui.EquinoxLauncher");  //$NON-NLS-1$ //$NON-NLS-2$
+		oldToNew.put("org.objectteams.otdt.pde.ui.EclipseApplicationLaunchConfigurationType", "org.eclipse.pde.ui.RuntimeWorkbench"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	
+	@SuppressWarnings("nls")
+	public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
+		String candidateType = candidate.getType().getIdentifier();
+		return   candidateType.startsWith("org.objectteams.otdt")
+			  && oldToNew.containsKey(candidateType);
+	}
+
+	public void migrate(final ILaunchConfiguration candidate) throws CoreException {
+		final String newId = oldToNew.get(candidate.getType().getIdentifier());
+		if (newId == null) return;
+		ILaunchConfiguration wrapper = new LaunchConfiguration(candidate.getMemento()) {
+			@Override
+			protected LaunchConfigurationInfo getInfo() throws CoreException {
+				return new LaunchConfigurationInfo() {
+					@Override
+					protected ILaunchConfigurationType getType() {
+						// revert to plain Eclipse launch type:
+						return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(newId);
+					}
+					@SuppressWarnings("unchecked")
+					@Override
+					protected TreeMap getAttributes() {
+						try {
+							TreeMap orig = (TreeMap) candidate.getWorkingCopy().getAttributes();
+							// but ensure it is marked as an OT-launch:
+							orig.put(OTDebugPlugin.OT_LAUNCH, Boolean.TRUE);
+							return orig;
+						} catch (CoreException e) { /* silent. */ }
+						return new TreeMap(); // must not return null
+					}
+				};
+			}
+		};
+		wrapper.getWorkingCopy().doSave();
+	}
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTVMRunnerAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTVMRunnerAdaptor.java
new file mode 100644
index 0000000..cc48eb6
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/OTVMRunnerAdaptor.java
@@ -0,0 +1,258 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+import org.eclipse.objectteams.otdt.debug.internal.TempFileManager;
+
+
+/**
+ * @author gis
+ * @version $Id: OTLaunchConfigurationDelegate.java 11843 2006-05-09 10:36:01Z carp $
+ */
+@SuppressWarnings("nls")
+public class OTVMRunnerAdaptor
+{
+	private static final String OT_DEBUG_VMARG = "-Dot.debug";
+	private static final String OT_DEBUG_CALLIN_STEPPING_VMARG = "-Dot.debug.callin.stepping";
+	private static final String OT_TEAMCONFIG_VMARG = "-Dot.teamconfig";
+	private static List<String> JPLIS_VMARGS;
+	static {
+		JPLIS_VMARGS = new ArrayList<String>();
+		JPLIS_VMARGS.add("-Dot.otdt");
+		JPLIS_VMARGS.add("-javaagent:" + OTDTPlugin.calculateAbsoluteRuntimePath("/lib/otre_agent.jar"));
+	}
+
+	final static private boolean _useJPLIS = true;
+	private ILaunchConfiguration _launchConfig;
+	private String _mode;
+	private ILaunch _launch;
+
+	public void setAdaptationArgs(ILaunchConfiguration configuration, String mode, ILaunch launch) throws CoreException
+	{
+		_launchConfig = configuration;
+		_mode = mode;
+		_launch = launch;
+	}
+	
+	public boolean usesJPLIS() {
+		return _useJPLIS;
+	}
+	
+	public VMRunnerConfiguration adapt(VMRunnerConfiguration vmRunnerConfig) throws CoreException
+	{
+		adaptVMArgs(vmRunnerConfig);
+		
+		return vmRunnerConfig;
+	}
+
+	protected void cloneRunner(VMRunnerConfiguration vmRunnerConfig, VMRunnerConfiguration newConfig)
+	{
+		// Only main type and class path have to be set in the constructor already
+    	newConfig.setBootClassPath(vmRunnerConfig.getBootClassPath());
+    	newConfig.setEnvironment(vmRunnerConfig.getEnvironment());
+    	newConfig.setProgramArguments(vmRunnerConfig.getProgramArguments());
+    	newConfig.setResumeOnStartup(vmRunnerConfig.isResumeOnStartup());
+    	newConfig.setVMArguments(vmRunnerConfig.getVMArguments());
+    	newConfig.setVMSpecificAttributesMap(vmRunnerConfig.getVMSpecificAttributesMap());
+    	newConfig.setWorkingDirectory(vmRunnerConfig.getWorkingDirectory());
+	}
+
+	protected void adaptVMArgs(VMRunnerConfiguration newConfig) throws CoreException
+    {
+	    List<String> otVMArgs = getOTVMArgs();
+	    String teamConfigArg = generateTeamConfigArgument(_launch, _launchConfig);
+	    if (teamConfigArg != null)
+	    	otVMArgs.add(teamConfigArg);
+	    if (ILaunchManager.DEBUG_MODE.equals(_mode)) 
+	    {
+	    	otVMArgs.add(OT_DEBUG_VMARG);
+	    	
+	    	String callinSteppingVMArg = getCallinSteppingVMArg();
+	    	if (callinSteppingVMArg != null)
+	    		otVMArgs.add(callinSteppingVMArg);
+	    }
+
+	    String[] vmArgs = newConfig.getVMArguments();
+	    if (vmArgs.length > 0)
+	    {
+	    	for (int i = 0; i < vmArgs.length; i++)
+				otVMArgs.add(vmArgs[i]);
+	    }
+	    
+	    String[] newArgs = new String[otVMArgs.size()];
+	    
+	    // new launches need to enclose file paths in quotes (cmdline is one string parsed by ArgumentParser),
+	    // which are removed here (cmdline is array of strings):
+	    for (int i = 0; i<newArgs.length; i++) {
+	    	newArgs[i] = otVMArgs.get(i).replaceAll("\"", "");
+	    }
+	    newConfig.setVMArguments(newArgs);
+    }
+	
+	/**
+	 * API version: given a list of vm arguments add ot-specific vm arguments.
+	 * 
+	 * @param vmArguments list to be augmented.
+	 * @throws CoreException
+	 */
+	public void adaptVMArguments(List vmArguments) throws CoreException 
+	{
+	    vmArguments.addAll(getOTVMArgs());
+	    String teamConfigArg = generateTeamConfigArgument(_launch, _launchConfig);
+	    if (teamConfigArg != null)
+	    	vmArguments.add(teamConfigArg);
+	    if (ILaunchManager.DEBUG_MODE.equals(_mode))
+	    	vmArguments.add(OT_DEBUG_VMARG);
+	}
+
+	public String adaptVMArgumentString(String vmArguments) throws CoreException 
+	{
+		String sep = " ";
+	    StringBuffer result = new StringBuffer(vmArguments);
+	    
+	    if (_useJPLIS)
+			for (String arg : JPLIS_VMARGS)
+				result.append(sep).append(arg);
+	    
+	    String callinSteppingVMArg = getCallinSteppingVMArg();
+	    if (callinSteppingVMArg != null)
+	    	result.append(sep).append(callinSteppingVMArg);
+	    
+	    String teamConfigArg = generateTeamConfigArgument(_launch, _launchConfig);
+	    if (teamConfigArg != null)
+	    	result.append(sep).append(teamConfigArg);
+	    if (ILaunchManager.DEBUG_MODE.equals(_mode))
+	    	result.append(sep).append(OT_DEBUG_VMARG);
+	    
+	    return result.toString();
+	}
+
+	private String getCallinSteppingVMArg() {
+		String value = OTDebugPlugin.getDefault().getCallinSteppingConfig();
+		if (value == null) return null;
+		return OT_DEBUG_CALLIN_STEPPING_VMARG+'='+value;
+	}
+
+	protected List<String> getOTVMArgs()
+	{
+        return new ArrayList<String>(JPLIS_VMARGS);
+	}
+	
+    /**
+	 * Teams to activate are read from ILaunchConfiguration configuration.
+	 * The list of team names are written to temporary file.
+	 * The commandline par -Dot.teamconfig=filename is returned and can
+	 * be added to the vmArgs variable. 
+     * @param launch
+	 * @param configuration	The launch configuration object.
+	 * @return 
+	 */
+	private String generateTeamConfigArgument(ILaunch launch, ILaunchConfiguration configuration) throws CoreException
+	{
+		List<String> teamList = getTeamConfigList(configuration);
+		if (teamList.isEmpty())
+			return null;
+
+		// write the teams into a temporary file:
+        File teamFile = createTeamConfigFile(launch, teamList);
+        
+		return OT_TEAMCONFIG_VMARG+"=\"" + teamFile.getAbsolutePath()+'"';
+	}
+
+	private File createTeamConfigFile(ILaunch launch, List<String> teamList) throws CoreException
+    {
+        try {
+            TempFileManager manager = OTDebugPlugin.getDefault().getTempFileManager();
+            File tempFile = manager.createTempFile(launch, ".otteamconfig", ".conf");
+
+		    PrintStream printStream = new PrintStream(new FileOutputStream(tempFile));
+        	for (Iterator<String> iter = teamList.iterator(); iter.hasNext();) {
+        		String element = iter.next();
+				printStream.println(element);
+			}
+        	printStream.close();
+        	return tempFile;
+        } catch (Exception e) {
+            IStatus status = OTDebugPlugin.createErrorStatus("Error writing static teams configuration", e);
+        	throw new CoreException(status);
+        }
+    }
+
+    /**
+	 * Returns the list of teams which will be woven into the launched application 
+	 * specified by the given launch configuration, as a list of strings. 
+	 * The returned list is empty if no teams are are specified or if the teams
+	 * are deactivated in the configuratio tab.
+	 * 
+	 * @param configuration
+	 *            launch configuration
+	 * @return the list of teams from the team configuration specified by the given launch
+	 *         configuration, possibly an empty list
+	 * @exception CoreException
+	 *                if unable to retrieve the attribute
+	 */
+	private List<String> getTeamConfigList(ILaunchConfiguration configuration)
+			throws CoreException 
+	{
+		boolean teamsActive = configuration.getAttribute(IOTLaunchConstants.ATTR_TEAMCONFIG_ACTIVE, true);
+		if (!teamsActive)
+			return new LinkedList<String>();
+		
+		List teamHandles = configuration.getAttribute(IOTLaunchConstants.ATTR_TEAMCONFIG_LIST, new LinkedList());	
+		List<String> teamNames = new LinkedList<String>();
+		List<String> badHandles = new LinkedList<String>();
+		
+		for (Iterator iter = teamHandles.iterator(); iter.hasNext();)
+        {
+            String teamHandle = (String) iter.next();
+            IType teamType = (IType) JavaCore.create(teamHandle);
+            if (teamType != null && teamType.exists())
+                teamNames.add(teamType.getFullyQualifiedName());
+            else
+                badHandles.add(teamHandle);
+        }
+		
+		if (!badHandles.isEmpty())
+		{
+		    IStatus status = OTDebugPlugin.createErrorStatus("Cannot determine types: " + badHandles.toString());
+		    throw new CoreException(status);
+		}
+		
+    	return teamNames;
+    }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamBreakpointInstaller.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamBreakpointInstaller.java
new file mode 100644
index 0000000..aab2961
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamBreakpointInstaller.java
@@ -0,0 +1,117 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;

+

+import java.util.Hashtable;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;

+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IBreakpoint;

+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.jdt.core.IJavaProject;

+import org.eclipse.jdt.core.IType;

+import org.eclipse.jdt.core.JavaModelException;

+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;

+import org.eclipse.objectteams.otdt.debug.core.breakpoints.OOTBreakpoints;
+

+public class TeamBreakpointInstaller

+{

+    private static Hashtable<String, IBreakpoint> OT_BREAKPOINTS = new Hashtable<String, IBreakpoint>(5);

+    public static boolean OOT_BREAKPOINTS_ENABLED = true; 

+    static {

+    	String prop = System.getProperty("ot.oot.breakpoints"); //$NON-NLS-1$

+    	if ("DISABLE".equals(prop))                             //$NON-NLS-1$

+    		OOT_BREAKPOINTS_ENABLED = false;

+    }

+

+    public static void installTeamBreakpoints(IJavaProject project) throws CoreException

+    {

+    	if (!OOT_BREAKPOINTS_ENABLED)

+    		return;

+        
+        DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
+        	// since we want to avoid using the breakpoint manager (thus hiding synthetic breakpoints from the UI),
+        	// we have to track creation of the debug target in order to manually install our breakpoints into the target:
+			public void handleDebugEvents(DebugEvent[] events) {
+				boolean done = false;
+				if (OT_BREAKPOINTS.size() == 0) {
+					done = true;
+				} else {
+					for (DebugEvent event : events) {
+						if (event.getKind() == DebugEvent.CREATE) {
+							if (event.getSource() instanceof IJavaDebugTarget) {
+								IDebugTarget debugTarget = ((IJavaDebugTarget) event.getSource()).getDebugTarget();
+								for (IBreakpoint bp : OT_BREAKPOINTS.values())
+									debugTarget.breakpointAdded(bp);
+								done = true;
+								break;
+							}
+						}
+					}
+				}
+				if (done)
+					DebugPlugin.getDefault().removeDebugEventListener(this);					
+			}
+		});

+        try

+        {

+            IType oot = project.findType(new String(IOTConstants.STR_ORG_OBJECTTEAMS_TEAM));

+            if (oot != null)

+            {            	

+                // Breakpoints in class org.objectteams.Team:

+                // bp on ctor, finalize()-, activate()-, deactivate(), -methods

+            	if(!OT_BREAKPOINTS.containsKey(OOTBreakpoints.ATTR_OT_BREAKPOINT_CTOR))

+            		OT_BREAKPOINTS.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_CTOR, OOTBreakpoints.createOOTConstructorBreakpoint(oot));

+            	

+            	if(!OT_BREAKPOINTS.containsKey(OOTBreakpoints.ATTR_OT_BREAKPOINT_FINALIZE))

+            		OT_BREAKPOINTS.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_FINALIZE, OOTBreakpoints.createOOTFinalizeBreakpoint(oot));

+          		

+            	if(!OT_BREAKPOINTS.containsKey(OOTBreakpoints.ATTR_OT_BREAKPOINT_ACT))

+            		OT_BREAKPOINTS.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_ACT, OOTBreakpoints.createOOTActivateBreakpoint(oot));

+            		

+       			if(!OT_BREAKPOINTS.containsKey(OOTBreakpoints.ATTR_OT_BREAKPOINT_DEACT))

+       				OT_BREAKPOINTS.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_DEACT, OOTBreakpoints.createOOTDeactivateBreakpoint(oot));

+                

+            	if(!OT_BREAKPOINTS.containsKey(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_ACT))

+            		OT_BREAKPOINTS.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_ACT, OOTBreakpoints.createOOTImplicitActivateBreakpoint(oot));

+            		

+       			if(!OT_BREAKPOINTS.containsKey(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_DEACT))

+       				OT_BREAKPOINTS.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_DEACT, OOTBreakpoints.createOOTImplicitDeactivateBreakpoint(oot));

+            }

+        }

+        catch (JavaModelException ex)

+        {

+            throw new CoreException(new Status(IStatus.WARNING, OTDebugPlugin.PLUGIN_ID, IStatus.OK, "Cannot set breakpoints for team-activation tracking", ex)); //$NON-NLS-1$

+        }

+    }

+

+    public static void uninstallTeamBreakpoints() throws CoreException

+    {

+    	if (!OOT_BREAKPOINTS_ENABLED)

+    		return;

+        OT_BREAKPOINTS.clear();

+    }
+}

diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamInstance.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamInstance.java
new file mode 100644
index 0000000..a8707c7
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamInstance.java
@@ -0,0 +1,192 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: TeamInstance.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.internal.runtime.AdapterManager;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
+import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;
+import org.eclipse.jdt.internal.debug.core.model.JDIThisVariable;
+import org.eclipse.jdt.internal.debug.core.model.JDIThread;
+
+import com.sun.jdi.ThreadReference;
+
+/**
+ * @author ike
+ */
+//TODO(ike): what about launches and thread termination->notify and update _activethreads
+public class TeamInstance extends JDIThisVariable implements IAdaptable
+{
+	public static final int IS_INACTIVE = 0;
+	public static final int IS_IMPLICITACTIVE = 1;
+	public static final int IS_ACTIVE = 2;
+
+    private List<TeamThread> _activethreads;
+    private List<TeamThread> _deactivethreads;
+    private List<TeamThread> _implicitActivethreads;
+    private int _activationState; // TODO(SH): use for caching
+    private TeamThread _globalThread;;
+    private long _creationTime;
+    private long _activationTime;
+    
+    public TeamInstance(JDIThisVariable var) throws DebugException
+    {
+    	super((JDIDebugTarget)var.getDebugTarget(),
+    		 ((JDIObjectValue)var.getValue()).getUnderlyingObject());
+    	_activethreads = new ArrayList<TeamThread>();
+    	_deactivethreads = new ArrayList<TeamThread>();
+    	_implicitActivethreads = new ArrayList<TeamThread>();
+    	_globalThread = new TeamThread(-1, 0);
+    	_creationTime = System.currentTimeMillis();
+    	_activationTime = 0;
+    }
+    
+    public long getCreationTime()
+    {
+    	return _creationTime;
+    }
+    
+    public long getActivationTime()
+    {
+    	return _activationTime;
+    }
+
+    public void setImplicitActiveForThreadID(long threadID)
+    {
+    	TeamThread teamThread = new TeamThread(threadID, System.currentTimeMillis());
+    	_implicitActivethreads.add(teamThread);
+    }
+    
+    public void setImplicitInactiveForThreadID(long threadID)
+    {
+    	TeamThread teamThread = new TeamThread(threadID, 0);
+    	_implicitActivethreads.remove(teamThread);
+    }
+
+    public void setActiveForThreadID(long threadID)
+    {
+    	TeamThread teamThread = new TeamThread(threadID, System.currentTimeMillis());
+    	_activethreads.add(teamThread);
+    	_deactivethreads.remove(teamThread);
+    }
+    
+    public void setInactiveForThreadID(long threadID)
+    {
+    	TeamThread teamThread = new TeamThread(threadID, System.currentTimeMillis());
+    	_activethreads.remove(teamThread);
+    	_deactivethreads.add(teamThread);
+    }
+
+    public List getThreads()
+    {
+    	return _activethreads;
+    }
+
+	public Object getAdapter(Class adapter)
+	{
+		return AdapterManager.getDefault().getAdapter(this, adapter);
+	}
+	
+	public int getActivationState(IDebugElement debugElement)
+	{
+		IThread thread= null;
+		if (debugElement instanceof IStackFrame) {
+			IStackFrame stackFrame= (IStackFrame)debugElement;
+			thread= stackFrame.getThread();
+		} else if (debugElement instanceof IThread) {
+			thread = (IThread)debugElement;
+		} if (thread != null)
+			return getActivationState(thread);
+		return globalActivationState();
+	}
+
+	private int getActivationState(IThread thread)
+	{
+		if(isActiveFor(thread))
+			return TeamInstance.IS_ACTIVE;
+		else
+			if(isImplicitActiveFor(thread))
+				return TeamInstance.IS_IMPLICITACTIVE;
+			else
+				return TeamInstance.IS_INACTIVE;
+	}
+	
+	public boolean isActiveFor(IThread thread)
+	{
+		boolean isActive= false;
+		ThreadReference threadRef= null;
+		if (thread != null) {
+			threadRef= ((JDIThread)thread).getUnderlyingThread();
+			TeamThread teamThread = new TeamThread(threadRef.uniqueID(), 0);
+			isActive = _activethreads.contains(teamThread);
+			if (isActive) {
+				setActivationTime(_activethreads.get(_activethreads.indexOf(teamThread)).time);
+				return true;
+			}
+			if (_deactivethreads.contains(teamThread))
+				return false;
+		}
+
+		//team is perhaps global active 
+		if(!isActive)
+			isActive = (_activethreads.contains(_globalThread));
+
+		return isActive;
+	}
+
+	private  int globalActivationState() {
+		if (_activethreads.contains(_globalThread))
+			return IS_ACTIVE;
+		return IS_INACTIVE;
+	}
+	
+	private void setActivationTime(long time)
+	{
+		_activationTime = time;
+	}
+
+	public boolean isImplicitActiveFor(IThread thread)
+	{
+		ThreadReference threadRef = ((JDIThread)thread).getUnderlyingThread();
+		long threadID = threadRef.uniqueID();
+		TeamThread teamThread= new TeamThread(threadID, 0);
+		boolean isImplicitActive = _implicitActivethreads.contains(teamThread);
+		
+		if(isImplicitActive)
+		{
+			setActivationTime(_implicitActivethreads.get(_implicitActivethreads.indexOf(teamThread)).time);
+		}
+		
+		return isImplicitActive;
+	}
+	
+	public void setGlobalThreadID(long globalThreadID)
+	{
+		_globalThread.threadID = globalThreadID;
+	}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamThread.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamThread.java
new file mode 100644
index 0000000..48856bf
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/TeamThread.java
@@ -0,0 +1,48 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug;

+

+public class TeamThread

+{

+	public long threadID = 0;

+	public long time = 0;

+

+	public TeamThread(long threadID, long time)

+	{

+		this.threadID = threadID;

+		this.time = time;

+	}

+	

+	@Override

+	public boolean equals(Object obj)

+	{

+		if (obj instanceof TeamThread)

+			return (threadID == ((TeamThread)obj).threadID);

+			

+		return super.equals(obj);

+	}

+	

+	@Override

+	public String toString()

+	{

+		return "threadID="+threadID+",time="+time;  //$NON-NLS-1$ //$NON-NLS-2$

+	}

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/IOOTBreakPoints.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/IOOTBreakPoints.java
new file mode 100644
index 0000000..7eb40ce
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/IOOTBreakPoints.java
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2006, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: IOOTBreakPoints.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.core.breakpoints;
+
+/** 
+ *  Do not edit: This interface is auto-generated from org/objectteams/Team.java 
+ *  using scripts/genIOOTBreakPoints.sh
+ *
+ *  Purpose: make specific line numbers of Team.java available for the debugger.
+ */
+public interface IOOTBreakPoints 
+{
+  int LINE_TeamConstructor = 60;
+  int LINE_ConfinedGetTeam = 91;
+  int LINE_ActivateMethod		 = 162;
+  int LINE_DeactivateMethod = 196;
+  int LINE_ImplicitActivateMethod = 243;
+  int LINE_ImplicitDeactivateMethod = 278;
+  int LINE_FinalizeMethod = 489;
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/OOTBreakpoints.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/OOTBreakpoints.java
new file mode 100644
index 0000000..586d3a3
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/OOTBreakpoints.java
@@ -0,0 +1,213 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OOTBreakpoints.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.core.breakpoints;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.debug.core.IJavaBreakpoint;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+
+import static org.eclipse.objectteams.otdt.debug.core.breakpoints.IOOTBreakPoints.*;
+
+/**
+ * @author ike
+ *
+ * This class provides methods to create OOT-specific (org.objectteams.Team) breakpoints
+ *
+ * $Id: OOTBreakpoints.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+@SuppressWarnings("nls")
+public class OOTBreakpoints
+{
+	public static final String FIELD_THIS = "this";
+	public static final String LOCAL_THREAD_ACT_DEACT = "thread";
+	public static final String LOCAL_THREAD_IMPLICIT_ACT_DEACT = "currentThread";
+	public static final String FIELD_ALL_THREADS = "ALL_THREADS";
+	
+	public static final String ATTR_OT_BREAKPOINT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint";
+	public static final String ATTR_OT_BREAKPOINT_CTOR     = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.Constructor";
+	public static final String ATTR_OT_BREAKPOINT_FINALIZE = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.FinalizeMethod";
+	public static final String ATTR_OT_BREAKPOINT_ACT   = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.ActivateMethod";
+	public static final String ATTR_OT_BREAKPOINT_DEACT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.DeactivateMethod";
+	public static final String ATTR_OT_BREAKPOINT_IMPLICIT_ACT   = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.ImplicitActivateMethod";
+	public static final String ATTR_OT_BREAKPOINT_IMPLICIT_DEACT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.ImplicitDeactivateMethod";
+
+	
+	//associated with "public Team() {}"
+    public static int getTeamConstructorLineNumber()
+    {
+        return LINE_TeamConstructor;
+    }
+
+    //associated with "doRegistration();"
+    public static int getActivateMethodLineNumber()
+    {
+        return LINE_ActivateMethod;
+    }
+    
+    //associated with "_OT$lazyGlobalActiveFlag = false;"
+    public static int getDeactivateMethodLineNumber()
+    {
+        return LINE_DeactivateMethod;
+    }
+    
+    //associated with "implicitActivationsPerThread.set(Integer.valueOf(implActCount + 1 ));"
+    public static int getImplicitActivateMethodLineNumber()
+    {
+        return LINE_ImplicitActivateMethod;
+    }
+
+    //implicitActivationsPerThread.set(Integer.valueOf(implActCount - 1));
+    public static int getImplicitDeactivateMethodLineNumber()
+    {
+        return LINE_ImplicitDeactivateMethod;
+    }
+    
+    // implicit "return;"
+    public static int getFinalizeMethodLineNumber() {
+		return LINE_FinalizeMethod;
+	}
+
+    public static Map<String, Boolean> getBreakpointAttributes()
+    {
+        Map<String, Boolean> attrs = new HashMap<String, Boolean>();
+        attrs.put(OOTBreakpoints.ATTR_OT_BREAKPOINT, Boolean.TRUE);
+        return attrs;
+    }
+
+    public static IBreakpoint createOOTConstructorBreakpoint(IType oot) 
+    		throws CoreException
+    {
+		Map<String, Boolean> constructorAttributes = getBreakpointAttributes();
+		constructorAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_CTOR, Boolean.TRUE);
+         return createOOTBreakpoint(oot, getTeamConstructorLineNumber(), constructorAttributes);
+    }
+    
+    public static IBreakpoint createOOTFinalizeBreakpoint(IType oot)
+    		throws CoreException
+    {
+    	Map<String, Boolean> finalizeMethodAttributes = getBreakpointAttributes();
+    	finalizeMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_FINALIZE, Boolean.TRUE);
+    	return createOOTMethodBreakpoint(oot, getFinalizeMethodLineNumber(), finalizeMethodAttributes);    	
+    }
+        
+    public static IBreakpoint createOOTActivateBreakpoint(IType oot)throws CoreException
+    {
+		Map<String, Boolean> activateMethodAttributes = getBreakpointAttributes();
+		activateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_ACT, Boolean.TRUE);
+    	return createOOTBreakpoint(oot, getActivateMethodLineNumber(), activateMethodAttributes);
+    }
+
+    public static IBreakpoint createOOTDeactivateBreakpoint(IType oot) throws CoreException
+	{
+		Map<String, Boolean> deactivateMethodAttributes = getBreakpointAttributes();
+		deactivateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_DEACT, Boolean.TRUE);
+		return createOOTBreakpoint(oot, getDeactivateMethodLineNumber(), deactivateMethodAttributes);
+	}
+    
+    public static IBreakpoint createOOTImplicitActivateBreakpoint(IType oot)throws CoreException
+    {
+		Map<String, Boolean> implicitActivateMethodAttributes = getBreakpointAttributes();
+		implicitActivateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_ACT, Boolean.TRUE);
+    	return createOOTBreakpoint(oot, getImplicitActivateMethodLineNumber(), implicitActivateMethodAttributes);
+    }
+
+    public static IBreakpoint createOOTImplicitDeactivateBreakpoint(IType oot)throws CoreException
+    {
+		Map<String, Boolean> implicitDeactivateMethodAttributes = getBreakpointAttributes();
+		implicitDeactivateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_DEACT, Boolean.TRUE);
+    	return createOOTBreakpoint(oot, getImplicitDeactivateMethodLineNumber(), implicitDeactivateMethodAttributes);
+    }
+	public static IBreakpoint createOOTBreakpoint(IType oot, int linenumber, Map attributes) 
+			throws CoreException
+	{
+		IResource teamResource = oot.getJavaProject().getResource();
+		IJavaBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(
+				teamResource,
+				oot.getFullyQualifiedName(),
+				linenumber,
+				-1, -1, 0,
+				false /*register*/,
+				attributes);
+		breakpoint.setPersisted(false);
+		
+		return breakpoint;
+	}
+    
+	public static IBreakpoint createOOTMethodBreakpoint(IType oot, int linenumber, Map attributes)
+			throws CoreException
+	{
+		IResource teamResource = oot.getJavaProject().getResource();
+		IJavaBreakpoint breakpoint = JDIDebugModel.createMethodBreakpoint(
+				teamResource, 
+				oot.getFullyQualifiedName(), 
+				"finalize", 
+				"()V",
+				true /*entry*/, false /*exit*/, false /*native*/,
+				linenumber, 
+				-1, -1, 0, 
+				false /*register*/, 
+				attributes);
+		breakpoint.setPersisted(false);
+		return breakpoint;
+	}
+	
+	public static final boolean isOOTBreakpoint(IBreakpoint breakpoint) throws CoreException
+    {
+        return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT) != null;
+    }
+
+    public static final boolean isOOTConstructorBreakpoint(IBreakpoint breakpoint) throws CoreException
+    {
+        return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_CTOR) != null;
+    }
+    
+    public static final boolean isOOTFinalizeBreakpoint(IBreakpoint breakpoint) throws CoreException
+    {
+    	return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_FINALIZE) != null;
+    }
+    
+    public static final boolean isOOTActiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+    {
+        return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_ACT) != null;
+    }
+    
+    public static final boolean isOOTDeactiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+    {
+        return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_DEACT) != null;
+    }
+    
+    public static final boolean isOOTImplicitActiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+    {
+        return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_ACT) != null;
+    }
+    
+    public static final boolean isOOTImplicitDeactiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+    {
+        return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_DEACT) != null;
+    }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/OTJavaWatchpoint.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/OTJavaWatchpoint.java
new file mode 100644
index 0000000..abf5f88
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/core/breakpoints/OTJavaWatchpoint.java
@@ -0,0 +1,143 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTJavaWatchpoint.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.core.breakpoints;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+import org.eclipse.jdt.internal.debug.core.breakpoints.JavaWatchpoint;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
+import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;
+import org.eclipse.jdt.internal.debug.core.model.JDIThread;
+
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.Value;
+import com.sun.jdi.event.Event;
+import com.sun.jdi.event.ModificationWatchpointEvent;
+
+/**
+ * FIXME(SH): THIS CLASS IS NOT USED.
+ * 
+ * @author ike
+ * 
+ * This class is for dealing with the Modification Watchpoint and getting the modified value.
+ * 
+ * $Id: OTJavaWatchpoint.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+public class OTJavaWatchpoint extends JavaWatchpoint
+{
+    private Hashtable _threadToObjectRefTable;
+// unused    private String _searchField;
+    
+    public OTJavaWatchpoint(IResource resource, String typeName, String fieldName, int lineNumber, int charStart, int charEnd, int hitCount, boolean register, Map attributes, String searchString) throws DebugException
+    {
+        super(resource, typeName, fieldName, lineNumber, charStart, charEnd, hitCount, register, attributes);
+        
+        _threadToObjectRefTable = new Hashtable();
+// unused        _searchField = searchString;
+    }
+    
+    /** Overrides the JavaWatchpoint.handleBreakpointEvent() method to handle
+     *  the ModificationWatchpointEvent and to store the value, which
+     *  will be set.
+     */
+    @Override
+    public boolean handleBreakpointEvent(Event event, JDIThread thread, boolean suspendVote) 
+    {
+        if (event instanceof ModificationWatchpointEvent)
+        {
+            ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent)event;
+            Value currentValue = modEvent.valueCurrent();
+            Value valueToBe = modEvent.valueToBe();
+            ObjectReference objectRef = modEvent.object();
+            
+            Hashtable objectRefs;
+            if (!_threadToObjectRefTable.containsKey(thread))
+            {
+                objectRefs = new Hashtable();
+            }
+            else
+            {
+                objectRefs = (Hashtable)_threadToObjectRefTable.get(thread);
+            }
+            
+            Value [] values;
+            if (!objectRefs.containsKey(objectRef))
+            {
+                values = new Value[2];
+                
+            }
+            else
+            {
+                values = (Value [])objectRefs.get(objectRef);
+            }
+            
+            values[0] = currentValue;
+            values[1] = valueToBe;
+            objectRefs.put(objectRef, values);
+            
+            _threadToObjectRefTable.put(thread, objectRefs);
+        }
+        return super.handleBreakpointEvent(event, thread, suspendVote);
+    }
+    
+    public Value getValueToBe(IJavaThread thread, IJavaVariable variable) throws DebugException
+    {
+        Value [] values = getValues(thread, variable);
+        
+        if (values != null && values.length >=2)
+            return values[1];
+        else
+            return null;
+    }
+    
+    public Value getCurrentValue(IJavaThread thread, IJavaVariable variable) throws DebugException
+    {
+        Value [] values = getValues(thread, variable);
+        
+        if (values != null && values.length >=2)
+            return values[0];
+        else
+            return null;
+    }
+    
+    private Value[] getValues(IJavaThread thread, IJavaVariable variable) throws DebugException
+    {
+        Hashtable objRefTable = (Hashtable) _threadToObjectRefTable.get(thread);
+        
+        for (Iterator iter = objRefTable.keySet().iterator(); iter.hasNext();)
+        {
+            Value objRef = (ObjectReference) iter.next();
+            JDIObjectValue value = (JDIObjectValue)variable.getValue();
+
+            if (value.getUnderlyingObject().equals(objRef))
+            {
+                return (Value [])objRefTable.get(objRef);
+            }
+        }
+        return null;
+    }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/Logger.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/Logger.java
new file mode 100644
index 0000000..e471989
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/Logger.java
@@ -0,0 +1,57 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: Logger.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal;
+
+
+@SuppressWarnings("nls")
+public class Logger
+{
+ 
+    public static boolean ON = true;
+    
+	public static void log(int level, String caller, String message)
+    {
+        switch (level) {
+        case 0:
+            
+            printLog("# ",caller, message);
+            break;
+
+        case 1:
+            
+            printLog("## ",caller, message);
+            break;
+        case 2:
+            
+            printLog("## ",caller, message);
+            break;
+            
+        default:
+            break;
+        }
+    }
+    
+    private static void printLog(String prefix, String caller, String message)
+    {
+        if (ON)
+            System.out.println(prefix + caller + " -> " +message);    
+    }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/OTDebugElementsContainerFactory.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/OTDebugElementsContainerFactory.java
new file mode 100644
index 0000000..106b212
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/OTDebugElementsContainerFactory.java
@@ -0,0 +1,81 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTDebugElementsContainerFactory.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+
+/**
+ * @author ike
+ *
+ * $Id: OTDebugElementsContainerFactory.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+public class OTDebugElementsContainerFactory implements IAdapterFactory, ILaunchesListener2 {
+    
+    private HashMap<Object, OTDebugElementsContainer> _launchToDebugModel = new HashMap<Object, OTDebugElementsContainer>();
+    
+    public OTDebugElementsContainerFactory()
+    {
+        DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
+    }
+
+    public Object getAdapter(Object adaptableObject, Class adapterType)
+    {
+        if (!_launchToDebugModel.containsKey(adaptableObject))
+        {
+            if (OTDebugElementsContainer.class.equals(adapterType))
+            {
+                _launchToDebugModel.put(adaptableObject, new OTDebugElementsContainer());
+            }
+        }
+        
+        return _launchToDebugModel.get(adaptableObject);
+    }
+    
+    public Class[] getAdapterList()
+    {
+        return new Class [] { OTDebugElementsContainer.class };
+    }
+
+    //TODO(ike): check, why there are sometimes 2 launches
+    public void launchesTerminated(ILaunch[] launches)
+    {
+        for (int idx = 0; idx < launches.length; idx++)
+        {
+            _launchToDebugModel.remove(launches[idx]);   
+        }
+    }
+    
+    public void launchesRemoved(ILaunch[] launches) {}
+    public void launchesAdded(ILaunch[] launches) {}
+    public void launchesChanged(ILaunch[] launches) {}
+    
+    public void dispose()
+    {
+        DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
+        _launchToDebugModel.clear();
+    }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/RoleBreakpointListener.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/RoleBreakpointListener.java
new file mode 100644
index 0000000..e47df9a
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/RoleBreakpointListener.java
@@ -0,0 +1,84 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jdt.core.dom.Message;
+import org.eclipse.jdt.debug.core.IJavaBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaBreakpointListener;
+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+
+/**
+ * The purpose of this listener is to prevent that attempts are made
+ * to install a breakpoint of a role into the enclosing team or a 
+ * sibling role. In Java, all inner classes reside in the file of
+ * the same outermost enclosing type. This is not true for roles.
+ * 
+ * @author stephan
+ * @since 1.1.4
+ */
+public class RoleBreakpointListener implements IJavaBreakpointListener 
+{
+	private static RoleBreakpointListener _singleton= null;
+	public static RoleBreakpointListener getInstance() {
+		if(_singleton == null)
+			_singleton = new RoleBreakpointListener();
+		return _singleton;
+	}
+
+	public void addingBreakpoint(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}
+	public void breakpointHasCompilationErrors(IJavaLineBreakpoint breakpoint, Message[] errors) {}
+	public void breakpointHasRuntimeException(IJavaLineBreakpoint breakpoint, DebugException exception) {}
+	public void breakpointInstalled(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}
+	public void breakpointRemoved(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}
+	
+	public int breakpointHit(IJavaThread thread, IJavaBreakpoint breakpoint) {
+		return IJavaBreakpointListener.DONT_CARE;
+	}
+
+	public int installingBreakpoint(IJavaDebugTarget target, IJavaBreakpoint breakpoint, IJavaType type)
+	{
+		try {
+			String typeName = type.getName();
+			String breakpointTypeName = breakpoint.getTypeName();
+			if (   typeName.contains(IOTConstants.OT_DELIM)
+				|| breakpointTypeName.contains(IOTConstants.OT_DELIM)) 
+			{
+				if (!breakpointTypeName.equals(typeName))
+					// for roles we need to be stricter than for regular inner classes:
+					// don't try to install a role breakpoint into any other type 
+					return IJavaBreakpointListener.DONT_INSTALL;
+			}
+		} catch (Exception e) {
+			// could not retrieve name, don't interfere with current action.
+		}
+		return IJavaBreakpointListener.DONT_CARE;
+	}
+
+	public void dispose()
+	{
+		_singleton = null;
+	}
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/StepFromLinenumberGenerator.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/StepFromLinenumberGenerator.java
new file mode 100644
index 0000000..71fa483
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/StepFromLinenumberGenerator.java
@@ -0,0 +1,196 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal;

+

+import org.eclipse.debug.core.DebugEvent;

+import org.eclipse.debug.core.DebugException;

+import org.eclipse.debug.core.DebugPlugin;

+import org.eclipse.debug.core.IDebugEventFilter;

+import org.eclipse.debug.core.model.IStackFrame;

+import org.eclipse.jdt.debug.core.IJavaDebugTarget;

+import org.eclipse.jdt.internal.debug.core.model.JDIThread;

+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+

+/**

+ * @author ike

+ *  

+ */

+public class StepFromLinenumberGenerator implements IDebugEventFilter, ISMAPConstants

+{

+    private static StepFromLinenumberGenerator _stepGenerator;

+    

+    public static StepFromLinenumberGenerator getInstance()

+    {

+        if (_stepGenerator == null)

+        {

+            _stepGenerator = new StepFromLinenumberGenerator();

+        }

+        

+        return _stepGenerator;

+    }

+    

+    public DebugEvent[] filterDebugEvents(DebugEvent[] events)

+    {

+        for (int index = 0; index < events.length; index++)

+        {

+            DebugEvent event = events[index];

+            

+            JDIThread thread = getThreadFromEvent(event);

+            

+            if (thread == null)

+            {

+                return events;

+            }

+                

+            try

+            {

+                IStackFrame topStackframe = getStackFrame(thread);

+                                

+                if (isResumeEvent(event) || (topStackframe == null))

+                {

+                    return events;

+                }

+                

+                //every time a STEP_OVER_LINENUMBER is detected, step over it

+                if (isStepOverElement(topStackframe) && isSuspendEvent(event))

+                {

+                    generateStepOver(thread);

+                    return filterEvent(events, index);

+                }

+                

+                //every time a STEP_INTO_LINENUMBER is detected step into it

+                if (isStepIntoElement(topStackframe) && isSuspendEvent(event))

+                {

+                    generateStepInto(thread);

+                    return filterEvent(events, index);

+                }

+                

+            }

+            catch (DebugException e)

+            {

+                //TODO(ike): handle exception

+                e.printStackTrace();

+                return events;

+            }

+        }

+        

+        return events;

+    }

+

+    private boolean isResumeEvent(DebugEvent event)

+    {

+        return (event.getKind() == DebugEvent.RESUME);

+    }

+

+    private boolean isSuspendEvent(DebugEvent event)

+    {

+        return (event.getKind() == DebugEvent.SUSPEND);

+    }

+

+    private boolean isStepOverElement(IStackFrame topStackframe) throws DebugException

+    {

+        if (topStackframe.getLineNumber() == STEP_OVER_LINENUMBER)

+            return true;

+        

+        return false;

+    }

+

+    private boolean isStepIntoElement(IStackFrame topStackframe) throws DebugException

+    {

+        if (topStackframe.getLineNumber() == STEP_INTO_LINENUMBER)

+            return true;

+        

+        return false;

+    }

+    

+    private IStackFrame getStackFrame(JDIThread thread) throws DebugException 

+    {

+        if (thread.hasStackFrames())

+        {

+            return thread.getTopStackFrame();

+        }

+        return null;

+    }

+    

+    private JDIThread getThreadFromEvent(DebugEvent event)

+    {

+        if (event.getSource() instanceof JDIThread)

+        {

+            return (JDIThread) event.getSource();

+        }

+        

+        return null;

+    }

+    

+    

+    /** Filter event with given index.

+     */

+    private DebugEvent[] filterEvent(DebugEvent[] events, int index)

+    {

+        DebugEvent[] filtered = new DebugEvent[events.length - 1];

+        if (filtered.length > 0)

+        {

+            int j = 0;

+            for (int idx = 0; idx < events.length; idx++)

+            {

+                if (idx != index)

+                {

+                    filtered[j] = events[idx];

+                    j++;

+                }

+            }

+        }

+        return filtered;

+    }

+    

+    /** Generates and performs a single stepInto in the given thread.

+     */

+    private void generateStepInto(JDIThread thread)

+    {

+        IJavaDebugTarget debugTarget = (IJavaDebugTarget) thread.getDebugTarget();

+        

+        try

+        {

+            thread.stepInto();

+        }

+        catch (DebugException e)

+        {

+            DebugPlugin.getDefault().fireDebugEventSet( new DebugEvent[] { new DebugEvent(debugTarget, DebugEvent.CHANGE) });

+        }

+    }

+    

+    

+    /** Generates and performs a single stepOver in the given thread.

+     */

+    private void generateStepOver(JDIThread thread)

+    {

+        IJavaDebugTarget debugTarget = (IJavaDebugTarget) thread.getDebugTarget();

+        

+        try

+        {

+            thread.stepOver();

+        }

+        catch (DebugException e)

+        {

+            DebugPlugin.getDefault().fireDebugEventSet( new DebugEvent[] { new DebugEvent(debugTarget, DebugEvent.CHANGE) });

+        }

+    }

+}

diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/TeamBreakpointListener.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/TeamBreakpointListener.java
new file mode 100644
index 0000000..dbb2e62
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/TeamBreakpointListener.java
@@ -0,0 +1,196 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal;

+

+import org.eclipse.debug.core.DebugException;

+import org.eclipse.debug.core.ILaunch;

+import org.eclipse.debug.core.model.IValue;

+import org.eclipse.jdt.core.dom.Message;

+import org.eclipse.jdt.debug.core.IJavaBreakpoint;

+import org.eclipse.jdt.debug.core.IJavaBreakpointListener;

+import org.eclipse.jdt.debug.core.IJavaDebugTarget;

+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;

+import org.eclipse.jdt.debug.core.IJavaThread;

+import org.eclipse.jdt.debug.core.IJavaType;

+import org.eclipse.jdt.debug.core.IJavaVariable;

+import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;

+import org.eclipse.jdt.internal.debug.core.model.JDIThisVariable;

+import org.eclipse.jdt.internal.debug.core.model.JDIThread;

+import org.eclipse.objectteams.otdt.debug.IOTDebugEventListener;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+import org.eclipse.objectteams.otdt.debug.core.breakpoints.OOTBreakpoints;
+

+public class TeamBreakpointListener implements IJavaBreakpointListener

+{

+	private static TeamBreakpointListener _singleton;

+

+	public static TeamBreakpointListener getInstance()

+	{

+		if(_singleton == null)

+			_singleton = new TeamBreakpointListener();

+		

+		return _singleton;

+	}

+	

+	public int breakpointHit(IJavaThread thread, IJavaBreakpoint breakpoint)

+	{

+	    OTDebugElementsContainer otDebugElementsContainer = getDebugElementsContainer(thread.getLaunch());

+	    if (otDebugElementsContainer == null)

+	    	return DONT_CARE; // something's broken for OT, don't interfere the debugger

+

+	    // without a marker it can't be a valid OOT breakpoint

+	    if (!breakpoint.getMarker().exists())

+	    	return DONT_CARE;

+

+		try

+		{

+			if (OOTBreakpoints.isOOTConstructorBreakpoint(breakpoint))

+			{

+			  // A team is being instantiated!

+              JDIThisVariable teamVariable = (JDIThisVariable) thread.findVariable(OOTBreakpoints.FIELD_THIS);

+              if (otDebugElementsContainer.getTeamInstance(teamVariable) == null) {

+	              TeamInstance newTeam= otDebugElementsContainer.addTeamInstance(teamVariable);

+	              notifyTeamInstantiation(otDebugElementsContainer, newTeam);

+              }

+              return IJavaBreakpointListener.DONT_SUSPEND;

+			}

+			

+			if (OOTBreakpoints.isOOTFinalizeBreakpoint(breakpoint))

+			{

+			  // A team is being disposed!

+              IJavaVariable teamVariable = thread.findVariable(OOTBreakpoints.FIELD_THIS);

+              int idx= otDebugElementsContainer.removeTeamInstance(teamVariable);

+              if (idx != -1)

+            	  notifyTeamFinalize(otDebugElementsContainer, idx);

+              return IJavaBreakpointListener.DONT_SUSPEND;

+			}

+			

+			if (OOTBreakpoints.isOOTActiveMethodBreakpoint(breakpoint))

+			{

+				IJavaVariable teamVariable = thread.findVariable(OOTBreakpoints.FIELD_THIS);

+				TeamInstance teamInstance = otDebugElementsContainer.getTeamInstance(teamVariable);

+

+				IJavaVariable teamActiveThread = thread.findVariable(OOTBreakpoints.LOCAL_THREAD_ACT_DEACT);

+				IValue threadValue = teamActiveThread.getValue();

+				long threadID = ((JDIObjectValue)threadValue).getUniqueId();

+				teamInstance.setActiveForThreadID(threadID);

+				

+				IJavaVariable teamGlobalThread = thread.findVariable(OOTBreakpoints.FIELD_ALL_THREADS);

+				IValue globalThreadValue = teamGlobalThread.getValue();

+				long globalThreadID = ((JDIObjectValue)globalThreadValue).getUniqueId();

+				teamInstance.setGlobalThreadID(globalThreadID);

+				

+				notifyActivationState(teamInstance);

+				return IJavaBreakpointListener.DONT_SUSPEND;

+			}

+

+			if (OOTBreakpoints.isOOTDeactiveMethodBreakpoint(breakpoint))

+			{

+				IJavaVariable teamVariable = thread.findVariable(OOTBreakpoints.FIELD_THIS);

+				TeamInstance teamInstance = otDebugElementsContainer.getTeamInstance(teamVariable);

+				

+				IJavaVariable teamDeactiveThread= thread.findVariable(OOTBreakpoints.LOCAL_THREAD_ACT_DEACT);

+				IValue threadValue = teamDeactiveThread.getValue();

+				long threadID = ((JDIObjectValue)threadValue).getUniqueId();

+				teamInstance.setInactiveForThreadID(new Long(threadID));

+				

+				notifyActivationState(teamInstance);

+				return IJavaBreakpointListener.DONT_SUSPEND;

+			}

+			

+			if (OOTBreakpoints.isOOTImplicitActiveMethodBreakpoint(breakpoint))

+			{

+				IJavaVariable teamVariable = thread.findVariable(OOTBreakpoints.FIELD_THIS);

+				TeamInstance teamInstance = otDebugElementsContainer.getTeamInstance(teamVariable);

+				

+				// don't use fragile access to local variable 

+				// but directly use the current thread:

+				long threadID= ((JDIThread)thread).getUnderlyingThread().uniqueID();

+				teamInstance.setImplicitActiveForThreadID(threadID);

+				

+				notifyActivationState(teamInstance);

+				return IJavaBreakpointListener.DONT_SUSPEND;

+			}

+

+			if (OOTBreakpoints.isOOTImplicitDeactiveMethodBreakpoint(breakpoint))

+			{

+				IJavaVariable teamVariable = thread.findVariable(OOTBreakpoints.FIELD_THIS);

+				TeamInstance teamInstance = otDebugElementsContainer.getTeamInstance(teamVariable);

+				

+				// don't use fragile access to local variable 

+				// but directly use the current thread:

+				long threadID = ((JDIThread)thread).getUnderlyingThread().uniqueID();

+				teamInstance.setImplicitInactiveForThreadID(threadID);

+				

+				notifyActivationState(teamInstance);

+				return IJavaBreakpointListener.DONT_SUSPEND;

+			}

+		}

+		catch (Exception ex)

+		{

+	 		OTDebugPlugin.getExceptionHandler().logException("Teammonitor can't read infos from debugTarget anymore. Disconnected?", ex); //$NON-NLS-1$

+			//if something fails, let the debugger go on

+			return IJavaBreakpointListener.DONT_SUSPEND;

+		}

+

+      return IJavaBreakpointListener.DONT_CARE;

+	}

+	

+    protected OTDebugElementsContainer getDebugElementsContainer(ILaunch launch)

+    {

+        return (OTDebugElementsContainer) launch.getAdapter(OTDebugElementsContainer.class);

+    }

+

+    private void notifyTeamInstantiation(OTDebugElementsContainer container, TeamInstance newTeam)

+    {

+        for (IOTDebugEventListener listener : OTDebugPlugin.getDefault().getOTDebugEventListeners())

+            listener.teamInstantiated(newTeam);

+    }

+

+    private void notifyTeamFinalize(OTDebugElementsContainer container, int idx)

+    {

+        for (IOTDebugEventListener listener : OTDebugPlugin.getDefault().getOTDebugEventListeners())

+            listener.teamDisposed(idx);

+    }

+    

+    private void notifyActivationState(TeamInstance teamInstance)

+    {

+        for (IOTDebugEventListener listener : OTDebugPlugin.getDefault().getOTDebugEventListeners())

+            listener.activationStateChanged(teamInstance);

+    }

+    

+	public void addingBreakpoint(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}

+	public void breakpointHasCompilationErrors(IJavaLineBreakpoint breakpoint, Message[] errors) {}

+	public void breakpointHasRuntimeException(IJavaLineBreakpoint breakpoint, DebugException exception) {}

+	public void breakpointInstalled(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}

+	public void breakpointRemoved(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}

+	public int installingBreakpoint(IJavaDebugTarget target, IJavaBreakpoint breakpoint, IJavaType type)

+	{

+		return IJavaBreakpointListener.DONT_CARE;

+	}

+

+	public void dispose()

+	{

+		_singleton = null;

+	}

+}

diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/TempFileManager.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/TempFileManager.java
new file mode 100644
index 0000000..278732c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/TempFileManager.java
@@ -0,0 +1,83 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: TempFileManager.java 23427 2010-02-03 22:23:59Z stephan $
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author gis
+ */
+public class TempFileManager
+{
+    private Map _tempFiles = new HashMap();
+
+    /**
+     * If you created a temporary file yourself and want TempFileManager to manage the
+     * deletion, use this method to register the file with the given key. 
+     * Call deleteTempFile with the same key to delete it.
+     */
+    public void registerTempFile(Object key, File file)
+    {
+        synchronized(_tempFiles) {
+            _tempFiles.put(key, file);
+        }
+    }
+    
+    /**
+     * Creates a temporary file via java.io.File.createTempFile and registers it for later
+     * deletion via the given key. Call deleteTempFile with the same key to delete it.
+     * @throws IOException
+     */
+    public File createTempFile(Object key, String prefix, String suffix) throws IOException
+    {
+        File tempFile = File.createTempFile(prefix, suffix);
+        tempFile.deleteOnExit();
+        synchronized(_tempFiles) {
+            _tempFiles.put(key, tempFile);
+        }
+        
+        return tempFile;
+    }
+
+    public void deleteTempFile(Object key)
+    {
+        synchronized(_tempFiles) {
+            File file = (File) _tempFiles.get(key);
+            if (file != null)
+                file.delete();
+        }
+    }
+
+    public void deleteAll()
+    {
+        synchronized(_tempFiles) {
+            for (Iterator iter = _tempFiles.values().iterator(); iter.hasNext();)
+            {
+                File file = (File) iter.next();
+                file.delete();
+            }
+        }
+    }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamActivationOrderComparator.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamActivationOrderComparator.java
new file mode 100644
index 0000000..016f8ef
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamActivationOrderComparator.java
@@ -0,0 +1,45 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal.util;

+

+import java.util.Comparator;

+

+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+

+public class TeamActivationOrderComparator implements Comparator

+{

+	public int compare(Object o1, Object o2)

+	{

+		TeamInstance team1 = (TeamInstance)o1;

+		TeamInstance team2 = (TeamInstance)o2;

+		

+		if (team1.getActivationTime() > team2.getActivationTime())

+			return -1;

+

+		if (team1.getActivationTime() == team2.getActivationTime())

+			return 0;

+

+		if (team1.getActivationTime() < team2.getActivationTime())

+			return 1;

+

+		return 0;

+	}

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamActivationTimeComparator.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamActivationTimeComparator.java
new file mode 100644
index 0000000..975b1a4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamActivationTimeComparator.java
@@ -0,0 +1,45 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal.util;

+

+import java.util.Comparator;

+

+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+

+public class TeamActivationTimeComparator implements Comparator

+{

+	public int compare(Object o1, Object o2)

+	{

+		TeamInstance team1 = (TeamInstance)o1;

+		TeamInstance team2 = (TeamInstance)o2;

+		

+		if (team1.getActivationTime() < team2.getActivationTime())

+			return -1;

+

+		if (team1.getActivationTime() == team2.getActivationTime())

+			return 0;

+

+		if (team1.getActivationTime() > team2.getActivationTime())

+			return 1;

+

+		return 0;

+	}

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamInstantiantionComparator.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamInstantiantionComparator.java
new file mode 100644
index 0000000..0298567
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamInstantiantionComparator.java
@@ -0,0 +1,45 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal.util;

+

+import java.util.Comparator;

+

+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+

+public class TeamInstantiantionComparator implements Comparator

+{

+	public int compare(Object o1, Object o2)

+	{

+		TeamInstance team1 = (TeamInstance)o1;

+		TeamInstance team2 = (TeamInstance)o2;

+		

+		if (team1.getCreationTime() < team2.getCreationTime())

+			return -1;

+

+		if (team1.getCreationTime() == team2.getCreationTime())

+			return 0;

+

+		if (team1.getCreationTime() > team2.getCreationTime())

+			return 1;

+

+		return 0;

+	}

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamNameComparator.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamNameComparator.java
new file mode 100644
index 0000000..52f509e
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/util/TeamNameComparator.java
@@ -0,0 +1,49 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ * 
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ * 
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ * 
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.internal.util;

+

+import java.util.Comparator;

+

+import org.eclipse.debug.core.DebugException;

+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+

+public class TeamNameComparator implements Comparator

+{

+	public int compare(Object o1, Object o2)

+	{

+		TeamInstance team1 = (TeamInstance)o1;

+		TeamInstance team2 = (TeamInstance)o2;

+		

+		int order = 0;

+		try

+		{

+			String teamName1 = team1.getReferenceTypeName();

+			String teamName2 = team2.getReferenceTypeName();

+			order = teamName1.compareTo(teamName2);

+		}

+		catch (DebugException e)

+		{

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		return order;

+	}

+}
\ No newline at end of file