initial commit in accordance with CQ 3784
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/OTDebugImages.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/OTDebugImages.java
new file mode 100644
index 0000000..a04871e
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/OTDebugImages.java
@@ -0,0 +1,86 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDebugImages.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui;
+
+import java.net.URL;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.osgi.framework.Bundle;
+
+
+/**
+ * @author ike
+ *
+ * $Id: OTDebugImages.java 23432 2010-02-03 23:13:42Z stephan $
+ */
+
+@SuppressWarnings("nls")
+public class OTDebugImages
+{
+ public static final String TEAM_ACTIVATED = "icons/team_act.gif";
+ public static final String TEAM_IMPLICIT_ACTIVATED = "icons/team_act_implicit.gif";
+ public static final String TEAM_INACTIVATED = "icons/team_inact.gif";
+ public static final String SORT_TEAMS_BY_ACTIVATION_TIME = "icons/sort_by_activationtime.gif";
+ public static final String SORT_TEAMS_BY_ACTIVATION_ORDER = "icons/sort_by_activation.gif";
+ public static final String SORT_TEAMS_BY_NAME = "icons/sort_by_name.gif";
+ public static final String SORT_TEAMS_BY_INSTANTIATION = "icons/sort_by_instantiation.gif";
+ public static final String UPDATE_TEAM_VIEW_ACTION = "icons/refresh.gif";
+
+
+ public static void register()
+ {
+ checkBundleState();
+
+ OTDebugUIPlugin plugin = OTDebugUIPlugin.getDefault();
+ Bundle bundle = plugin.getBundle();
+ ImageRegistry registry = plugin.getImageRegistry();
+
+ register(TEAM_ACTIVATED, bundle, registry);
+ register(TEAM_IMPLICIT_ACTIVATED, bundle, registry);
+ register(TEAM_INACTIVATED, bundle, registry);
+ register(SORT_TEAMS_BY_ACTIVATION_TIME, bundle, registry);
+ register(SORT_TEAMS_BY_ACTIVATION_ORDER, bundle, registry);
+ register(SORT_TEAMS_BY_NAME, bundle, registry);
+ register(SORT_TEAMS_BY_INSTANTIATION, bundle, registry);
+ register(UPDATE_TEAM_VIEW_ACTION, bundle, registry);
+ }
+
+ public static ImageDescriptor get(String image)
+ {
+ checkBundleState();
+ return OTDebugUIPlugin.getDefault().getImageRegistry().getDescriptor(image);
+ }
+
+ static void register(String icon, Bundle bundle, ImageRegistry registry)
+ {
+ URL imageURL = bundle.getEntry(icon);
+ ImageDescriptor desc = ImageDescriptor.createFromURL(imageURL);
+ registry.put(icon, desc);
+ }
+
+ private static void checkBundleState()
+ {
+ if (OTDebugUIPlugin.getDefault().getBundle().getState() != Bundle.ACTIVE)
+ throw new IllegalStateException("Bundle not active: " + OTDebugUIPlugin.getDefault().getBundle().getBundleId());
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/OTDebugUIPlugin.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/OTDebugUIPlugin.java
new file mode 100644
index 0000000..83fad25
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/OTDebugUIPlugin.java
@@ -0,0 +1,157 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDebugUIPlugin.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.internal.ui.ColorManager;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.objectteams.otdt.core.exceptions.ExceptionHandler;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+import org.eclipse.objectteams.otdt.debug.ui.internal.CopyInheritanceBreakpointManager;
+import org.eclipse.objectteams.otdt.debug.ui.internal.OTDebugElementAdapterFactory;
+import org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class OTDebugUIPlugin extends AbstractUIPlugin
+{
+ // preference constants
+ public static final String PLUGIN_ID = "org.eclipse.objectteams.otdt.debug.ui"; //$NON-NLS-1$
+ public static final String TEAM_DETAIL_PANE_ORIENTATION = "ot.teamview.detail.orientation"; //$NON-NLS-1$
+
+ // this id is also used in plugin.xml:
+ public static final String TEAM_VIEW_ID = "org.eclipse.objectteams.otdt.debug.ui.views.team"; //$NON-NLS-1$
+
+
+ private static final String PREFIX = PLUGIN_ID + "."; //$NON-NLS-1$
+ public static final String HELP_TEAM_VIEW = PREFIX + "team_view_context"; //$NON-NLS-1$
+
+ //The shared instance.
+ private static OTDebugUIPlugin plugin;
+ //Resource bundle.
+ private ResourceBundle resourceBundle;
+ private CopyInheritanceBreakpointManager _copyInheritanceBPManager;
+
+ // TODO: use JDIDebugUIPlugin to contribute to the UI
+
+ /**
+ * The constructor.
+ */
+ public OTDebugUIPlugin()
+ {
+ super();
+ plugin = this;
+ try {
+ resourceBundle = ResourceBundle.getBundle("org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPluginResources"); //$NON-NLS-1$
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
+ }
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ OTDebugPreferences.propagateFilterFlag(getPreferenceStore());
+
+ // this breakpoint manager listens to two kinds of changes:
+ _copyInheritanceBPManager = new CopyInheritanceBreakpointManager();
+ JDIDebugModel.addJavaBreakpointListener(_copyInheritanceBPManager);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(_copyInheritanceBPManager, IResourceChangeEvent.POST_CHANGE);
+
+ IAdapterManager manager= Platform.getAdapterManager();
+ OTDebugElementAdapterFactory propertiesFactory = new OTDebugElementAdapterFactory();
+ manager.registerAdapters(propertiesFactory, OTDebugElementsContainer.class);
+ manager.registerAdapters(propertiesFactory, TeamInstance.class);
+
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ JDIDebugModel.removeJavaBreakpointListener(_copyInheritanceBPManager);
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static OTDebugUIPlugin 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 = OTDebugUIPlugin.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;
+ }
+
+ /**
+ * Returns the a color based on the type of output.
+ * Valid types:
+ * <li>OT_GENERATED_CODE_COLOR</li>
+ * <li>CONSOLE_SYS_ERR_RGB</li>
+ */
+ public static Color getPreferenceColor(String type) {
+ return ColorManager.getDefault().getColor(PreferenceConverter.getColor(getDefault().getPreferenceStore(), type));
+ }
+
+
+ public static ExceptionHandler getExceptionHandler()
+ {
+ return new ExceptionHandler(PLUGIN_ID);
+ }
+
+ protected void initializeImageRegistry(ImageRegistry reg)
+ {
+ super.initializeImageRegistry(reg);
+ OTDebugImages.register();
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/BreakpointMessages.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/BreakpointMessages.java
new file mode 100644
index 0000000..864cb2e
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/BreakpointMessages.java
@@ -0,0 +1,36 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: BreakpointMessages.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class BreakpointMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.debug.ui.internal.BreakpointMessages"; //$NON-NLS-1$
+ public static String CopyInheritanceBreakpointManager_find_tsub_types_task;
+ public static String CopyInheritanceBreakpointManager_toggle_enablement_job;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, BreakpointMessages.class);
+ }
+
+ private BreakpointMessages() {
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/BreakpointMessages.properties b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/BreakpointMessages.properties
new file mode 100644
index 0000000..976c95f
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/BreakpointMessages.properties
@@ -0,0 +1,2 @@
+CopyInheritanceBreakpointManager_find_tsub_types_task=Finding tsub-types...
+CopyInheritanceBreakpointManager_toggle_enablement_job=Toggle copied breakpoint enablement
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/CopyInheritanceBreakpointManager.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/CopyInheritanceBreakpointManager.java
new file mode 100644
index 0000000..fbcebcf
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/CopyInheritanceBreakpointManager.java
@@ -0,0 +1,426 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: CopyInheritanceBreakpointManager.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+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.IJavaInterfaceType;
+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.JDIDebugModel;
+import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.objectteams.otdt.core.IOTType;
+import org.eclipse.objectteams.otdt.core.IOTTypeHierarchy;
+import org.eclipse.objectteams.otdt.core.IRoleType;
+import org.eclipse.objectteams.otdt.core.OTModelManager;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+
+/**
+ * This class deals with the problem that a breakpoint in role-method won't have an effect
+ * in tsub-classes. This is due to the fact, that methods are inherited through CopyInheritance,
+ * that is, their byte-code is copied to the tsub-class.
+ *
+ * This class sort of performs copy-inheritance for breakpoints. I.e. whenever a breakpoint
+ * is installed for a role-method, it will be installed in the copied methods of all tsub-classes
+ * as well.
+ *
+ * When uninstalling a breakpoint for a target, the copies are removed from that target,
+ * and completely removed if no longer installed in any targets.
+ *
+ * Mapping of line numbers is handled by a JavaStratumLineBreakpoint for stratum "OTJ".
+ *
+ * @author gis, stephan
+ */
+public class CopyInheritanceBreakpointManager implements IJavaBreakpointListener, IResourceChangeListener
+{
+ private static final Object OT_BREAKPOINT_COPY = "OT_BREAKPOINT_COPY"; //$NON-NLS-1$
+
+ private static final String ROLE_CLASS_SEPARATOR = "$__OT__"; //$NON-NLS-1$
+
+ /** keep our own mapping from original breakpoints to copies (the breakpoint manager only knows installed breakpoints). */
+ private Map<IMarker, List<IJavaBreakpoint>> copiedBreakpoints = new HashMap<IMarker, List<IJavaBreakpoint>>();
+
+ public CopyInheritanceBreakpointManager()
+ {
+ super();
+ }
+
+ public void addingBreakpoint(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}
+ public void breakpointInstalled(IJavaDebugTarget target, IJavaBreakpoint breakpoint) {}
+ public void breakpointHasRuntimeException(IJavaLineBreakpoint breakpoint, DebugException exception) {}
+ public void breakpointHasCompilationErrors(IJavaLineBreakpoint breakpoint, Message[] errors) {}
+ public int breakpointHit(IJavaThread thread, IJavaBreakpoint breakpoint)
+ {
+ return IJavaBreakpointListener.DONT_CARE;
+ }
+
+ /**
+ * The debugger signals that a breakpoint is being installed into the VM.
+ * Check if we need to add copies into tsub roles.
+ */
+ public int installingBreakpoint(IJavaDebugTarget target, IJavaBreakpoint breakpoint, IJavaType type)
+ {
+ try {
+ if (isBreakpointCopy(breakpoint))
+ return IJavaBreakpointListener.INSTALL; // yes please! (no further copying needed)
+
+ if (!(type instanceof IJavaInterfaceType))
+ return IJavaBreakpointListener.DONT_CARE; // only use ifc part, (tsuper-) class may not be loaded
+
+ if (breakpoint instanceof IJavaLineBreakpoint)
+ addTSubBreakpointsFor(type, (IJavaLineBreakpoint) breakpoint, target);
+ }
+ catch (CoreException ex)
+ {
+ OTDebugUIPlugin.getExceptionHandler().logCoreException("Problem with breakpoint handling", ex); //$NON-NLS-1$
+ }
+
+ return IJavaBreakpointListener.DONT_CARE;
+ }
+
+ private boolean isBreakpointCopy(IJavaBreakpoint breakpoint) throws CoreException
+ {
+ IMarker marker = breakpoint.getMarker();
+ if (marker == null)
+ return false;
+
+ Map properties = marker.getAttributes();
+ return properties.containsKey(OT_BREAKPOINT_COPY);
+ }
+
+ private void addTSubBreakpointsFor(IJavaType triggerType, IJavaLineBreakpoint breakpoint, IJavaDebugTarget target)
+ throws CoreException
+ {
+ IMarker marker = breakpoint.getMarker();
+ IType type = BreakpointUtils.getType(breakpoint);
+
+ // only act when triggered by the class of the breakpoint (which must be a role):
+ IOTType otType = OTModelManager.getOTElement(type);
+ if (otType == null)
+ return;
+ if (!otType.getFullyQualifiedName('$').equals(triggerType.getName()))
+ return;
+
+ // check whether copies have already been created:
+ List<IJavaBreakpoint> existingCopies = this.copiedBreakpoints.get(marker);
+ if (existingCopies != null) {
+ // tsub breakpoints are already created, only add them to this target:
+ for (IJavaBreakpoint existingCopy : existingCopies)
+ target.breakpointAdded(existingCopy);
+ return;
+ }
+
+ // find tsub roles to install into:
+ IType[] tsubClasses = new TSubClassComputer((IRoleType) otType).getSubClasses();
+ if (tsubClasses == null || tsubClasses.length == 0)
+ return;
+
+ // perform:
+ String fileName = type.getCompilationUnit().getElementName();
+ List<IJavaBreakpoint> newBreakpoints = new ArrayList<IJavaBreakpoint>(tsubClasses.length);
+ for (IType tsubClass : tsubClasses) {
+ IJavaLineBreakpoint newBreakpoint = propagateBreakpoint(breakpoint, fileName, tsubClass, target);
+ if (newBreakpoint != null)
+ newBreakpoints.add(newBreakpoint);
+ }
+
+ this.copiedBreakpoints.put(marker, newBreakpoints);
+
+ }
+
+ /**
+ * Propagate the given breakpoint to one tsub role.
+ *
+ * @param breakpoint breakpoint to copy
+ * @param fileName name of the source file that implements the given line
+ * @param destType the tsub role into which to install
+ * @param target the debug target into which the breakpoint should be installed
+ * @return a new breakpoint or null
+ * @throws CoreException when accessing the existing breakpoint fails or the marker for the new breakpoint could not be created
+ */
+ private IJavaLineBreakpoint propagateBreakpoint(IJavaLineBreakpoint breakpoint, String fileName, IType destType, IJavaDebugTarget target)
+ throws CoreException
+ {
+ if (destType == null)
+ {
+ OTDebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,
+ OTDebugUIPlugin.PLUGIN_ID,
+ "CopyInheritanceBreakpointManager.propagateBreakpoint(): tsub type is null")); //$NON-NLS-1$
+ return null;
+ }
+
+ Exception ex = null;
+ int sourceLineNumber = -1;
+ try {
+ sourceLineNumber = breakpoint.getLineNumber();
+ } catch (CoreException ce) {
+ ex = ce;
+ }
+ if (sourceLineNumber == -1 || ex != null)
+ {
+ OTDebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,
+ OTDebugUIPlugin.PLUGIN_ID,
+ "CopyInheritanceBreakpointManager.propagateBreakpoint(): source line number not found", //$NON-NLS-1$
+ ex));
+ return null;
+ }
+
+ return duplicateBreakpoint(breakpoint, fileName, destType, sourceLineNumber, target);
+ }
+
+ /**
+ * Duplicate the given breakpoint for the given tsub-role.
+ *
+ * @param breakpoint breakpoint to copy
+ * @param fileName name of the source file that implements the given line
+ * @param destType the tsub role into which to install
+ * @param sourceLineNumber line number within fileName
+ * @param target the debug target into which the breakpoint should be installed
+ * @return a new breakpoint, never null;
+ * @throws CoreException when accessing the existing breakpoint fails or the marker for the new breakpoint could not be created
+ */
+ private IJavaLineBreakpoint duplicateBreakpoint(IJavaLineBreakpoint breakpoint, String fileName, IType destType, int sourceLineNumber, IJavaDebugTarget target)
+ throws CoreException
+ {
+ // FIXME: other breakpoint types, exception, properties (null)
+ Map properties = getBreakpointProperties(breakpoint);
+ Boolean origEnabled = (Boolean) properties.get(IBreakpoint.ENABLED);
+ String destName = getClassPartName(destType);
+ // Note: by marking the breakpoint as unregistered, we prevent it from showing up in the breakpoints view.
+ // Conversely this means that we can not rely on the breakpoint manager but must maintain our own registry (copiedBreakpoints)
+ IJavaLineBreakpoint newBreakpoint = JDIDebugModel.createStratumBreakpoint(
+ breakpoint.getMarker().getResource(),
+ ISMAPConstants.OTJ_STRATUM_NAME,
+ fileName,
+ null, //sourcePath,
+ destName, // classNamePattern
+ sourceLineNumber,
+ -1, -1, // charStart, charEnd
+ breakpoint.getHitCount(),
+ false,
+ properties);
+ // restore one attribute that is hardcoded in JavaStratumLineBreakpoint.<init>:
+ if (!origEnabled)
+ try {
+ newBreakpoint.getMarker().setAttribute(IBreakpoint.ENABLED, Boolean.FALSE);
+ } catch (CoreException ex) {
+ OTDebugUIPlugin.getExceptionHandler().logCoreException("Unable to disable breakpoint", ex); //$NON-NLS-1$
+ }
+ target.getDebugTarget().breakpointAdded(newBreakpoint);
+
+ return newBreakpoint;
+ }
+
+ /**
+ * If type is a role return the name of its class-part,
+ * and ensure all enclosing role-teams are given by their class-part, too.
+ */
+ String getClassPartName(IType type) {
+ IType enclosing = type.getDeclaringType();
+ try {
+ if ( enclosing != null
+ && Flags.isTeam(enclosing.getFlags()))
+ return getClassPartName(enclosing)+ROLE_CLASS_SEPARATOR+type.getElementName();
+ } catch (JavaModelException e) {
+ // fall through
+ }
+ return type.getFullyQualifiedName();
+ }
+
+ /** Initialize breakpoint properties from `breakpoint' and add a few values specific to copies. */
+ private Map getBreakpointProperties(IJavaLineBreakpoint breakpoint)
+ {
+ Map properties = new HashMap(13);
+ try {
+ properties.putAll(breakpoint.getMarker().getAttributes());
+ } catch (CoreException e) {
+ // couldn't read marker attributes
+ }
+ properties.put(IBreakpoint.PERSISTED, Boolean.FALSE);
+ properties.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); // hide from the ruler
+ properties.put(OT_BREAKPOINT_COPY, Boolean.TRUE);
+
+ return properties;
+ }
+
+ /**
+ * A breakpoint has been removed from a target. Do the same for copies of this breakpoint.
+ *
+ * @param target the debug target from which the breakpoint has been removed
+ * @param breakpoint the breakpoint (potential tsuper).
+ */
+ public void breakpointRemoved(IJavaDebugTarget target, IJavaBreakpoint breakpoint)
+ {
+ IMarker marker = breakpoint.getMarker();
+ if (marker == null || !marker.exists())
+ return;
+
+ // retrieve breakpoint and disable it:
+ List<IJavaBreakpoint> copies = this.copiedBreakpoints.get(marker);
+ if (copies == null)
+ return;
+
+ List<IJavaBreakpoint> remainingCopies = new ArrayList<IJavaBreakpoint>(copies.size());
+ for (IJavaBreakpoint copy : copies) {
+ target.getDebugTarget().breakpointRemoved(copy, null);
+ try {
+ if (copy.isInstalled())
+ remainingCopies.add(copy);
+ else
+ copy.delete();
+ } catch (CoreException ex) {
+ OTDebugUIPlugin.getExceptionHandler().logCoreException("Unable to query copied breakpoint", ex); //$NON-NLS-1$
+ }
+ }
+ // cleanup if no more copies are active:
+ if (remainingCopies.size() == 0)
+ this.copiedBreakpoints.remove(marker);
+ // cleanup if fewer copies are active:
+ else if (remainingCopies.size() != copies.size())
+ this.copiedBreakpoints.put(marker, remainingCopies);
+ }
+
+ private class TSubClassComputer implements IRunnableWithProgress
+ {
+ private IOTTypeHierarchy _hierarchy;
+ private IRoleType _roleType;
+ private IType[] _subClasses;
+
+ public TSubClassComputer(IRoleType otType)
+ {
+ _roleType = otType;
+ }
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException
+ {
+ monitor.beginTask(BreakpointMessages.CopyInheritanceBreakpointManager_find_tsub_types_task, 1);
+ IProgressMonitor mon = new SubProgressMonitor(monitor, 1);
+ try
+ {
+ _hierarchy = _roleType.newOTTypeHierarchy(mon);
+ _hierarchy.setPhantomMode(true);
+ _subClasses = _hierarchy.getAllTSubtypes((IType)_roleType);
+
+ }
+ catch (JavaModelException ex)
+ {
+ throw new InvocationTargetException(ex);
+ }
+ finally
+ {
+ mon.done();
+ }
+ }
+
+ /**
+ * @return null or the computed tsub classes
+ */
+ public IType[] getSubClasses()
+ {
+ try
+ {
+// PlatformUI.getWorkbench().getProgressService().busyCursorWhile(this);
+ run(new NullProgressMonitor());
+ }
+ catch (InvocationTargetException ex)
+ {
+ if (ex.getCause() instanceof CoreException)
+ OTDebugUIPlugin.getExceptionHandler().logCoreException("Error creating type hiearchy", (CoreException) ex.getCause()); //$NON-NLS-1$
+ else
+ OTDebugUIPlugin.getExceptionHandler().logException("Error creating type hiearchy", ex); //$NON-NLS-1$
+ }
+ catch (InterruptedException ex)
+ {
+ OTDebugUIPlugin.getExceptionHandler().logException("Error creating type hiearchy", ex); //$NON-NLS-1$
+ }
+
+ return _subClasses;
+ }
+ }
+
+ /**
+ * Watch for changes of the ENABLED attribute of breakpoint markers.
+ *
+ * @param event the change event.
+ */
+ public void resourceChanged(IResourceChangeEvent event)
+ {
+ IMarkerDelta[] markerDeltas = event.findMarkerDeltas(IBreakpoint.BREAKPOINT_MARKER, true);
+ if (markerDeltas == null)
+ return;
+ for (IMarkerDelta markerDelta : markerDeltas) {
+ if (markerDelta.getKind() == IResourceDelta.CHANGED) {
+ IMarker marker = markerDelta.getMarker();
+ final Boolean oldEnabled = markerDelta.getAttribute(IBreakpoint.ENABLED, Boolean.FALSE);
+ final Boolean newEnabled = marker.getAttribute(IBreakpoint.ENABLED, Boolean.FALSE);
+ if (!oldEnabled.equals(newEnabled)) {
+ // we have a change wrt enablement
+ List<IJavaBreakpoint> breakpoints = this.copiedBreakpoints.get(marker);
+ if (breakpoints != null) {
+ for (final IJavaBreakpoint copy : breakpoints) {
+ Job job = new Job(BreakpointMessages.CopyInheritanceBreakpointManager_toggle_enablement_job) {
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ copy.setEnabled(newEnabled);
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return new Status(IStatus.ERROR, OTDebugUIPlugin.PLUGIN_ID, "Error toggling copied breakpoint enablement", e); //$NON-NLS-1$
+ }
+ }
+ };
+ job.setRule(event.getResource());
+ job.schedule();
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/OTDebugElementAdapterFactory.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/OTDebugElementAdapterFactory.java
new file mode 100644
index 0000000..2e3c4be
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/OTDebugElementAdapterFactory.java
@@ -0,0 +1,94 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDebugElementAdapterFactory.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+import org.eclipse.objectteams.otdt.debug.ui.internal.model.OTDebugElementsContainerContentProvider;
+import org.eclipse.objectteams.otdt.debug.ui.internal.model.OTDebugElementsContainerLabelProvider;
+import org.eclipse.objectteams.otdt.debug.ui.internal.model.OTDefaultModelProxyFactory;
+import org.eclipse.objectteams.otdt.debug.ui.internal.model.OTVariableColumnFactoryAdapter;
+import org.eclipse.objectteams.otdt.debug.ui.internal.model.TeamInstanceContentProvider;
+import org.eclipse.objectteams.otdt.debug.ui.internal.model.TeamInstanceLabelProvider;
+
+/**
+ * This factory installs our content/label providers into the TeamView
+ */
+public class OTDebugElementAdapterFactory implements IAdapterFactory
+{
+
+ private static IModelProxyFactory fgModelProxyFactoryAdapter= new OTDefaultModelProxyFactory();
+ private static IColumnPresentationFactory fgVariableColumnFactory = new OTVariableColumnFactoryAdapter();
+
+ private static IElementLabelProvider _LPElementContainer= new OTDebugElementsContainerLabelProvider();
+ private static IElementLabelProvider _LPTeamInstance= new TeamInstanceLabelProvider();
+
+ private static IElementContentProvider _CPElementContainer= new OTDebugElementsContainerContentProvider();
+ private static IElementContentProvider _CPTeamInstance= new TeamInstanceContentProvider();
+
+
+ public Object getAdapter(Object adaptableObject, Class adapterType)
+ {
+ if (adapterType.equals(IElementContentProvider.class))
+ {
+ if(adaptableObject instanceof OTDebugElementsContainer)
+ return _CPElementContainer;
+
+ if(adaptableObject instanceof TeamInstance)
+ return _CPTeamInstance;
+ }
+
+ if (adapterType.equals(IElementLabelProvider.class))
+ {
+ if(adaptableObject instanceof OTDebugElementsContainer)
+ return _LPElementContainer;
+
+ if(adaptableObject instanceof TeamInstance)
+ return _LPTeamInstance;
+ }
+ if (adapterType.equals(IModelProxyFactory.class)) {
+ if (adaptableObject instanceof OTDebugElementsContainer)
+ return fgModelProxyFactoryAdapter;
+ }
+
+ if (adapterType.equals(IColumnPresentationFactory.class)) {
+ if (adaptableObject instanceof OTDebugElementsContainer) {
+ return fgVariableColumnFactory;
+ }
+ }
+
+ return null;
+ }
+
+ public Class[] getAdapterList()
+ {
+ return new Class[]{IElementContentProvider.class,
+ IElementLabelProvider.class,
+ IModelProxyFactory.class,
+ IColumnPresentationFactory.class};
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ActionMessages.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ActionMessages.java
new file mode 100644
index 0000000..51ba74a
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ActionMessages.java
@@ -0,0 +1,41 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: ActionMessages.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ActionMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.debug.ui.internal.actions.ActionMessages"; //$NON-NLS-1$
+ public static String ChangeTeamActivationAction_activate_label;
+ public static String ChangeTeamActivationAction_activate_description;
+ public static String ChangeTeamActivationAction_deactivate_label;
+ public static String ChangeTeamActivationAction_deactivate_description;
+ public static String ChangeTeamActivationAction_error_title;
+ public static String ChangeTeamActivationAction_error_exception;
+ public static String ChangeTeamActivationAction_error_no_thread_suspended;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
+ }
+
+ private ActionMessages() {
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ActionMessages.properties b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ActionMessages.properties
new file mode 100644
index 0000000..ad558f3
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ActionMessages.properties
@@ -0,0 +1,7 @@
+ChangeTeamActivationAction_activate_label=Activate Team
+ChangeTeamActivationAction_activate_description=Activate this team for the selected thread
+ChangeTeamActivationAction_deactivate_label=Deactivate Team
+ChangeTeamActivationAction_deactivate_description=Deactivate this team for the selected thread
+ChangeTeamActivationAction_error_title=Debug operation failed
+ChangeTeamActivationAction_error_no_thread_suspended=Unable to change team activation:\n\nNo thread is suspended to perform this operation.
+ChangeTeamActivationAction_error_exception=Unable to change team activation.
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ChangeTeamActivationAction.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ChangeTeamActivationAction.java
new file mode 100644
index 0000000..b5ec97c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/ChangeTeamActivationAction.java
@@ -0,0 +1,176 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: ChangeTeamActivationAction.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
+import org.eclipse.jdt.debug.core.IJavaFieldVariable;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugImages;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+import org.eclipse.objectteams.otdt.debug.ui.views.TeamView;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.SelectionProviderAction;
+
+public class ChangeTeamActivationAction extends SelectionProviderAction {
+
+ // selectors of methods to invoke:
+ private static final String DEACTIVATE = "deactivate"; //$NON-NLS-1$
+ private static final String ACTIVATE = "activate"; //$NON-NLS-1$
+ // signatures of (de)activate() methods:
+ private static final String SIGNATURE = "()V"; //$NON-NLS-1$
+ private static final String SIGNATURE_THREAD_ARG = "(Ljava/lang/Thread;)V"; //$NON-NLS-1$
+ // for constant org.objectteams.Team.ALL_THREADS:
+ private static final String ALL_THREADS = "ALL_THREADS"; //$NON-NLS-1$
+
+ protected IVariable fVariable;
+ private TeamView fView;
+ String selector;
+ private boolean isActivate;
+
+ /**
+ * Creates a new ChangeTeamActivationAction for the given variables view
+ * @param view the variables view in which this action will appear
+ */
+ public ChangeTeamActivationAction(TeamView view, boolean isActivate) {
+ super(view.getViewer(), isActivate
+ ? ActionMessages.ChangeTeamActivationAction_activate_label
+ : ActionMessages.ChangeTeamActivationAction_deactivate_label);
+ this.selector= isActivate ? ACTIVATE : DEACTIVATE;
+ this.isActivate= isActivate;
+ this.setEnabled(false);
+
+ if (isActivate) {
+ setDescription(ActionMessages.ChangeTeamActivationAction_activate_description);
+ setImageDescriptor(OTDebugImages.get(OTDebugImages.TEAM_ACTIVATED));
+ } else {
+ setDescription(ActionMessages.ChangeTeamActivationAction_deactivate_description);
+ setImageDescriptor(OTDebugImages.get(OTDebugImages.TEAM_INACTIVATED));
+ }
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(
+ this,
+ IDebugHelpContextIds.CHANGE_VALUE_ACTION);
+ fView= view;
+ }
+
+ protected void doActionPerformed(Object element)
+ {
+ if (! (element instanceof TeamInstance))
+ return;
+ TeamInstance teamInstance= (TeamInstance)element;
+ try {
+ IValue value= teamInstance.getValue();
+ if (value instanceof IJavaObject) {
+ IJavaObject teamObject= (IJavaObject) value;
+ String methodSignature = SIGNATURE; // default
+ IJavaValue[] args= null; // default
+ IJavaThread thread= fView.getSelectedThread();
+ if (thread == null) {
+ // no thread selected means: (de)activate for all threads.
+ methodSignature= SIGNATURE_THREAD_ARG;
+
+ // create argument ALL_THREADS
+ IJavaFieldVariable field= teamObject.getField(ALL_THREADS, true);
+ args= new IJavaValue[]{(IJavaValue) field.getValue()};
+
+ // search for a suspended thread:
+ IDebugTarget target= teamObject.getDebugTarget();
+ for (IThread tThread: target.getThreads()) {
+ if (tThread.isSuspended()) {
+ thread= (IJavaThread)tThread;
+ break;
+ }
+ }
+ if (thread == null) {
+ String cause= ActionMessages.ChangeTeamActivationAction_error_no_thread_suspended;
+ DebugUIPlugin.errorDialog(fView.getViewSite().getShell(),
+ ActionMessages.ChangeTeamActivationAction_error_title,
+ cause,
+ new Status(Status.ERROR, OTDebugUIPlugin.PLUGIN_ID, cause));
+ return;
+ }
+ }
+ teamObject.sendMessage(this.selector, methodSignature, args, thread, false);
+ Viewer viewer = fView.getViewer();
+ viewer.setSelection(viewer.getSelection()); // refresh action enablement
+ }
+ } catch (DebugException de) {
+ DebugUIPlugin.errorDialog(fView.getViewSite().getShell(),
+ ActionMessages.ChangeTeamActivationAction_error_title,
+ ActionMessages.ChangeTeamActivationAction_error_exception,
+ de);
+ }
+ }
+
+ /**
+ * Updates the enabled state of this action based
+ * on the selection
+ */
+ protected void update(IStructuredSelection sel) {
+ if (sel.size() > 1) {
+ setEnabled(false); // can only activate one team at a time.
+ return;
+ }
+ Iterator iter= sel.iterator();
+ if (iter.hasNext()) {
+ Object object= iter.next();
+ if (object instanceof TeamInstance) {
+ TeamInstance instance= (TeamInstance)object;
+ if ( instance.isActiveFor(fView.getSelectedThread())
+ != isActivate)
+ {
+ setEnabled(true);
+ return;
+ }
+ }
+ }
+ setEnabled(false); // no team instance selected
+ }
+
+ /**
+ * @see IAction#run()
+ */
+ public void run() {
+ Iterator iterator= getStructuredSelection().iterator();
+ doActionPerformed(iterator.next());
+ }
+
+ /**
+ * @see SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void selectionChanged(IStructuredSelection sel) {
+ update(sel);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTBreakpointLocationVerifierJob.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTBreakpointLocationVerifierJob.java
new file mode 100644
index 0000000..d27cadc
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTBreakpointLocationVerifierJob.java
@@ -0,0 +1,306 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * 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: OTBreakpointLocationVerifierJob.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Fraunhofer FIRST - extended API and implementation
+ * Technical University Berlin - extended API and implementation
+ *******************************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.actions;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.internal.debug.ui.actions.ActionMessages;
+import org.eclipse.jdt.internal.debug.core.breakpoints.ValidBreakpointLocationLocator;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.IEditorStatusLine;
+
+/**
+ * Job used to verify the position of a breakpoint
+ * copied from BreakpointLocationVerifierJob
+ * $Id: OTBreakpointLocationVerifierJob.java 23432 2010-02-03 23:13:42Z stephan $
+ */
+//{OT_COPY_PASTE: class copied from org.eclipse.jdt.internal.debug.ui.actions.BreakpointLocationVerifierJob
+// modified just to instantiate OTValidBreakpointLocationLocator in favor of ValidBreakpointLocationLocator
+public class OTBreakpointLocationVerifierJob extends Job {
+
+ /**
+ * The document which contains the code source.
+ */
+ private IDocument fDocument;
+
+ /**
+ * The temporary breakpoint that has been set. Can be <code>null</code> if the callee was not able
+ * to check if a breakpoint was already set at this position.
+ */
+ private IJavaLineBreakpoint fBreakpoint;
+
+ /**
+ * The number of the line where the breakpoint has been requested.
+ */
+ private int fLineNumber;
+
+ /**
+ * The qualified type name of the class where the temporary breakpoint as been set.
+ * Can be <code>null</code> if fBreakpoint is null.
+ */
+ private String fTypeName;
+
+ /**
+ * The type in which should be set the breakpoint.
+ */
+ private IType fType;
+
+ /**
+ * Indicate if the search for a valid location should be limited to a line
+ * or expanded to field and method declaration.
+ */
+ private boolean fBestMatch;
+
+ /**
+ * The resource in which should be set the breakpoint.
+ */
+ private IResource fResource;
+
+ /**
+ * The current IEditorPart
+ */
+ private IEditorPart fEditorPart;
+
+ /**
+ * The status line to use to display errors
+ */
+ private IEditorStatusLine fStatusLine;
+
+ public OTBreakpointLocationVerifierJob(IDocument document, IJavaLineBreakpoint breakpoint, int lineNumber, boolean bestMatch, String typeName, IType type, IResource resource, IEditorPart editorPart) {
+ super(ActionMessages.BreakpointLocationVerifierJob_breakpoint_location);
+ fDocument= document;
+ fBreakpoint= breakpoint;
+ fLineNumber= lineNumber;
+ fBestMatch= bestMatch;
+ fTypeName= typeName;
+ fType= type;
+ fResource= resource;
+ fEditorPart= editorPart;
+ fStatusLine= (IEditorStatusLine) editorPart.getAdapter(IEditorStatusLine.class);
+ setSystem(true);
+ }
+
+ public IStatus run(IProgressMonitor monitor) {
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ char[] source = fDocument.get().toCharArray();
+ parser.setSource(source);
+ IJavaElement javaElement = JavaCore.create(fResource);
+ IJavaProject project= null;
+ if (javaElement != null) {
+ Map options=JavaCore.getDefaultOptions();
+ project= javaElement.getJavaProject();
+ String compilerCompliance = JavaCore.VERSION_1_5;
+ String compilerSource = JavaCore.VERSION_1_5;
+ if (project != null) {
+ compilerCompliance = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
+ compilerSource = project.getOption(JavaCore.COMPILER_SOURCE, true);
+ }
+ options.put(JavaCore.COMPILER_COMPLIANCE, compilerCompliance);
+ options.put(JavaCore.COMPILER_SOURCE, compilerSource);
+ parser.setCompilerOptions(options);
+ }
+ CompilationUnit compilationUnit= (CompilationUnit)parser.createAST(null);
+//{ObjectTeams: replace ValidBreakpointLocationLocator with own OTValidBreakpointLocationLocator
+ OTValidBreakpointLocationLocator locator= new OTValidBreakpointLocationLocator(compilationUnit, fLineNumber, false, fBestMatch);
+//ike}
+ compilationUnit.accept(locator);
+ if (locator.isBindingsRequired()) {
+ if (javaElement != null) {
+ // try again with bindings if required and available
+ String unitName = null;
+ if (fType == null) {
+ String name = fResource.getName();
+ if (JavaCore.isJavaLikeFileName(name)) {
+ unitName = name;
+ }
+ } else {
+ if (fType.isBinary()) {
+ String className= fType.getClassFile().getElementName();
+ int nameLength= className.indexOf('$');
+ if (nameLength < 0) {
+ nameLength= className.indexOf('.');
+ }
+ unitName= className.substring(0, nameLength) + ".java"; //$NON-NLS-1$
+ } else {
+ unitName= fType.getCompilationUnit().getElementName();
+ }
+ }
+ if (unitName != null) {
+ parser = ASTParser.newParser(AST.JLS3);
+ parser.setSource(source);
+ parser.setProject(project);
+ parser.setUnitName(unitName);
+ parser.setResolveBindings(true);
+ compilationUnit= (CompilationUnit)parser.createAST(null);
+//{ObjectTeams: replace ValidBreakpointLocationLocator with own OTValidBreakpointLocationLocator
+ locator= new OTValidBreakpointLocationLocator(compilationUnit, fLineNumber, true, fBestMatch);
+//ike}
+ compilationUnit.accept(locator);
+ }
+ }
+ }
+ int lineNumber= locator.getLineLocation();
+ String typeName= locator.getFullyQualifiedTypeName();
+
+ try {
+ switch (locator.getLocationType()) {
+ case ValidBreakpointLocationLocator.LOCATION_LINE:
+ return manageLineBreakpoint(typeName, lineNumber);
+ case ValidBreakpointLocationLocator.LOCATION_METHOD:
+ if (fBreakpoint != null) {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(fBreakpoint, true);
+ }
+//{ObjectTeams use OTToggleBreakpointAdapter
+ new OTToggleBreakpointAdapter().toggleMethodBreakpoints(fEditorPart, new TextSelection(locator.getMemberOffset(), 0));
+//carp}
+ break;
+ case ValidBreakpointLocationLocator.LOCATION_FIELD:
+ if (fBreakpoint != null) {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(fBreakpoint, true);
+ }
+//{ObjectTeams use OTToggleBreakpointAdapter
+ new OTToggleBreakpointAdapter().toggleWatchpoints(fEditorPart, new TextSelection(locator.getMemberOffset(), 0));
+//carp}
+ break;
+ default:
+ // cannot find a valid location
+ report(ActionMessages.BreakpointLocationVerifierJob_not_valid_location);
+ if (fBreakpoint != null) {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(fBreakpoint, true);
+ }
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, ActionMessages.BreakpointLocationVerifierJob_not_valid_location, null);
+ }
+ } catch (CoreException e) {
+ JDIDebugUIPlugin.log(e);
+ }
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.OK, ActionMessages.BreakpointLocationVerifierJob_breakpoint_set, null);
+
+ }
+
+ /**
+ * Determines the placement of the line breakpoint, and ensures that duplicates are not created
+ * and that notification is sent in the event of collisions
+ * @param typeName the fully qualified name of the type to add the line breakpoint to
+ * @param lineNumber the number we wish to put the breakpoint on
+ * @return the status of the line breakpoint placement
+ */
+ public IStatus manageLineBreakpoint(String typeName, int lineNumber) {
+ try {
+ boolean differentLineNumber= lineNumber != fLineNumber;
+ IJavaLineBreakpoint breakpoint= JDIDebugModel.lineBreakpointExists(fResource, typeName, lineNumber);
+ boolean breakpointExist= breakpoint != null;
+ if (fBreakpoint == null) {
+ if (breakpointExist) {
+ if (differentLineNumber) {
+ // There is already a breakpoint on the valid line.
+ report(MessageFormat.format(ActionMessages.BreakpointLocationVerifierJob_0, new String[]{Integer.toString(lineNumber)}));
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, ActionMessages.BreakpointLocationVerifierJob_not_valid_location, null);
+ }
+ // There is already a breakpoint on the valid line, but it's also the requested line.
+ // Removing the existing breakpoint.
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(breakpoint, true);
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.OK, ActionMessages.BreakpointLocationVerifierJob_breakpointRemoved, null);
+ }
+ createNewBreakpoint(lineNumber, typeName);
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.OK, ActionMessages.BreakpointLocationVerifierJob_breakpoint_set, null);
+ }
+ if (differentLineNumber) {
+ if (breakpointExist) {
+ // there is already a breakpoint on the valid line.
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(fBreakpoint, true);
+ report(MessageFormat.format(ActionMessages.BreakpointLocationVerifierJob_0, new String[]{Integer.toString(lineNumber)}));
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, ActionMessages.BreakpointLocationVerifierJob_not_valid_location, null);
+ }
+ replaceBreakpoint(lineNumber, typeName);
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.WARNING, ActionMessages.BreakpointLocationVerifierJob_breakpointMovedToValidPosition, null);
+ }
+ if (!typeName.equals(fTypeName)) {
+ replaceBreakpoint(lineNumber, typeName);
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.WARNING, ActionMessages.BreakpointLocationVerifierJob_breakpointSetToRightType, null);
+ }
+ } catch (CoreException e) {
+ JDIDebugUIPlugin.log(e);
+ }
+ return new Status(IStatus.OK, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.OK, ActionMessages.BreakpointLocationVerifierJob_breakpoint_set, null);
+ }
+
+ /**
+ * Remove the temporary breakpoint and create a new breakpoint at the right position.
+ */
+ private void replaceBreakpoint(int lineNumber, String typeName) throws CoreException {
+ createNewBreakpoint(lineNumber, typeName);
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(fBreakpoint, true);
+ }
+
+ /**
+ * Create a new breakpoint at the right position.
+ */
+ private void createNewBreakpoint(int lineNumber, String typeName) throws CoreException {
+ Map newAttributes = new HashMap(10);
+ if (fType != null) {
+ try {
+ IRegion line= fDocument.getLineInformation(lineNumber - 1);
+ int start= line.getOffset();
+ int end= start + line.getLength() - 1;
+ BreakpointUtils.addJavaBreakpointAttributesWithMemberDetails(newAttributes, fType, start, end);
+ } catch (BadLocationException ble) {
+ JDIDebugUIPlugin.log(ble);
+ }
+ }
+ JDIDebugModel.createLineBreakpoint(fResource, typeName, lineNumber, -1, -1, 0, true, newAttributes);
+ }
+
+ /**
+ * Reports any status to the current active workbench shell
+ * @param message the message to display
+ */
+ protected void report(final String message) {
+ JDIDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (fStatusLine != null) {
+ fStatusLine.setMessage(true, message, null);
+ }
+ if (message != null && JDIDebugUIPlugin.getActiveWorkbenchShell() != null) {
+ Display.getCurrent().beep();
+ }
+ }
+ });
+ }
+}
+//ike}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTToggleBreakpointAdapter.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTToggleBreakpointAdapter.java
new file mode 100644
index 0000000..bba4f4f
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTToggleBreakpointAdapter.java
@@ -0,0 +1,1243 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * 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: OTToggleBreakpointAdapter.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Fraunhofer FIRST - extended API and implementation
+ * Technical University Berlin - extended API and implementation
+ *******************************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.actions;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageDeclaration;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeParameter;
+import org.eclipse.jdt.core.ITypeRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.debug.core.IJavaBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaClassPrepareBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaFieldVariable;
+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaMethodBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.jdt.debug.core.IJavaWatchpoint;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+import org.eclipse.jdt.internal.debug.core.JavaDebugUtils;
+import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
+import org.eclipse.jdt.internal.debug.ui.DebugWorkingCopyManager;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.internal.debug.ui.actions.ActionDelegateHelper;
+import org.eclipse.jdt.internal.debug.ui.actions.ActionMessages;
+import org.eclipse.jdt.ui.IWorkingCopyManager;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.IEditorStatusLine;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.objectteams.otdt.core.IOTJavaElement;
+import org.eclipse.objectteams.otdt.core.IOTType;
+import org.eclipse.objectteams.otdt.core.OTModelManager;
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+
+/**
+ * @author ike
+ * Toggles a line breakpoint in a OTJava editor.
+ *
+ * @since 3.0
+ */
+//{OT_COPY_PASTE: class copied from org.eclipse.jdt.internal.debug.ui.actions.ToggleBreakpointAdapter
+// to instantiate OTBreakpointLocationVerifierJob in favor of BreakpointLocationVerifierJob
+// and to access a protected method of ValidBreakpointLocationLocator
+public class OTToggleBreakpointAdapter implements IToggleBreakpointsTargetExtension {
+
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ */
+ public OTToggleBreakpointAdapter() {
+ // initialize helper in UI thread
+ ActionDelegateHelper.getDefault();
+ }
+
+ /**
+ * Convenience method for printing messages to the status line
+ * @param message the message to be displayed
+ * @param part the currently active workbench part
+ */
+ protected void report(final String message, final IWorkbenchPart part) {
+ JDIDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IEditorStatusLine statusLine = (IEditorStatusLine) part.getAdapter(IEditorStatusLine.class);
+ if (statusLine != null) {
+ if (message != null) {
+ statusLine.setMessage(true, message, null);
+ } else {
+ statusLine.setMessage(true, null, null);
+ }
+ }
+ if (message != null && JDIDebugUIPlugin.getActiveWorkbenchShell() != null) {
+ JDIDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep();
+ }
+ }
+ });
+ }
+
+ /**
+ * Returns the <code>IType</code> for the given selection
+ * @param selection the current text selection
+ * @return the <code>IType</code> for the text selection or <code>null</code>
+ */
+ protected IType getType(ITextSelection selection) {
+ IMember member = ActionDelegateHelper.getDefault().getCurrentMember(selection);
+ IType type = null;
+ if (member instanceof IType) {
+ type = (IType) member;
+ } else if (member != null) {
+ type = member.getDeclaringType();
+ }
+ // bug 52385: we don't want local and anonymous types from compilation
+ // unit,
+ // we are getting 'not-always-correct' names for them.
+ try {
+ while (type != null && !type.isBinary() && type.isLocal()) {
+ type = type.getDeclaringType();
+ }
+ } catch (JavaModelException e) {
+ JDIDebugUIPlugin.log(e);
+ }
+ return type;
+ }
+
+ /**
+ * Returns the IType associated with the <code>IJavaElement</code> passed in
+ * @param element the <code>IJavaElement</code> to get the type from
+ * @return the corresponding <code>IType</code> for the <code>IJavaElement</code>, or <code>null</code> if there is not one.
+ * @since 3.3
+ */
+ protected IType getType(IJavaElement element) {
+ switch(element.getElementType()) {
+ case IJavaElement.FIELD: {
+ return ((IField)element).getDeclaringType();
+ }
+ case IJavaElement.METHOD: {
+ return ((IMethod)element).getDeclaringType();
+ }
+ case IJavaElement.TYPE: {
+ return (IType)element;
+ }
+ default: {
+ return null;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ toggleLineBreakpoints(part, selection, false);
+ }
+
+ /**
+ * Toggles a line breakpoint.
+ * @param part the currently active workbench part
+ * @param selection the current selection
+ * @param bestMatch if we should make a best match or not
+ */
+ public void toggleLineBreakpoints(final IWorkbenchPart part, final ISelection selection, final boolean bestMatch) {
+ Job job = new Job("Toggle Line Breakpoint") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ ITextEditor editor = getTextEditor(part);
+ if (editor != null && selection instanceof ITextSelection) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ try {
+ report(null, part);
+ ISelection sel = selection;
+ if(!(selection instanceof IStructuredSelection)) {
+ sel = translateToMembers(part, selection);
+ }
+ if(isInterface(sel, part)) {
+ report(ActionMessages.ToggleBreakpointAdapter_6, part);
+ return Status.OK_STATUS;
+ }
+ if(sel instanceof IStructuredSelection) {
+ IMember member = (IMember) ((IStructuredSelection)sel).getFirstElement();
+ IType type = null;
+//{ObjectTeams: also handle IOTJavaElement.{ROLE,TEAM}:
+/* orig:
+ if(member.getElementType() == IJavaElement.TYPE) {
+ :giro */
+ if(member instanceof IType) {
+// SH}
+ type = (IType) member;
+ }
+ else {
+ type = member.getDeclaringType();
+ }
+ String tname = createQualifiedTypeName(type);
+ IResource resource = BreakpointUtils.getBreakpointResource(type);
+ int lnumber = ((ITextSelection) selection).getStartLine() + 1;
+ IJavaLineBreakpoint existingBreakpoint = JDIDebugModel.lineBreakpointExists(resource, tname, lnumber);
+ if (existingBreakpoint != null) {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(existingBreakpoint, true);
+ return Status.OK_STATUS;
+ }
+ Map attributes = new HashMap(10);
+ IDocumentProvider documentProvider = editor.getDocumentProvider();
+ if (documentProvider == null) {
+ return Status.CANCEL_STATUS;
+ }
+ IDocument document = documentProvider.getDocument(editor.getEditorInput());
+ try {
+ IRegion line = document.getLineInformation(lnumber - 1);
+ int start = line.getOffset();
+ int end = start + line.getLength() - 1;
+ BreakpointUtils.addJavaBreakpointAttributesWithMemberDetails(attributes, type, start, end);
+ }
+ catch (BadLocationException ble) {JDIDebugUIPlugin.log(ble);}
+ IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(resource, tname, lnumber, -1, -1, 0, true, attributes);
+//{ObjectTeams: replace BreakpointLocationVerifierJob with own OTBreakpointLocationVerifierJob
+ new OTBreakpointLocationVerifierJob(document, breakpoint, lnumber, bestMatch, tname, type, resource, editor).schedule();
+// ike}
+ }
+ else {
+ report(ActionMessages.ToggleBreakpointAdapter_3, part);
+ return Status.OK_STATUS;
+ }
+ }
+ catch (CoreException ce) {return ce.getStatus();}
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(IWorkbenchPart,
+ * ISelection)
+ */
+ public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) {
+ if (isRemote(part, selection)) {
+ return false;
+ }
+ return selection instanceof ITextSelection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleMethodBreakpoints(final IWorkbenchPart part, final ISelection finalSelection) {
+ Job job = new Job("Toggle Method Breakpoints") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ try {
+ report(null, part);
+ ISelection selection = finalSelection;
+ if(!(selection instanceof IStructuredSelection)) {
+ selection = translateToMembers(part, selection);
+ }
+ if(isInterface(selection, part)) {
+ report(ActionMessages.ToggleBreakpointAdapter_7, part);
+ return Status.OK_STATUS;
+ }
+ if (selection instanceof IStructuredSelection) {
+ IMethod[] members = getMethods((IStructuredSelection) selection);
+ if (members.length == 0) {
+ report(ActionMessages.ToggleBreakpointAdapter_9, part);
+ return Status.OK_STATUS;
+ }
+ IJavaBreakpoint breakpoint = null;
+ ISourceRange range = null;
+ Map attributes = null;
+ IType type = null;
+ String signature = null;
+ String mname = null;
+ for (int i = 0, length = members.length; i < length; i++) {
+ breakpoint = getMethodBreakpoint(members[i]);
+ if (breakpoint == null) {
+ int start = -1;
+ int end = -1;
+ range = members[i].getNameRange();
+ if (range != null) {
+ start = range.getOffset();
+ end = start + range.getLength();
+ }
+ attributes = new HashMap(10);
+ BreakpointUtils.addJavaBreakpointAttributes(attributes, members[i]);
+ type = members[i].getDeclaringType();
+ signature = members[i].getSignature();
+ mname = members[i].getElementName();
+ if (members[i].isConstructor()) {
+ mname = "<init>"; //$NON-NLS-1$
+ if (type.isEnum()) {
+ signature = "(Ljava.lang.String;I" + signature.substring(1); //$NON-NLS-1$
+ }
+ }
+ if (!type.isBinary()) {
+ signature = resolveMethodSignature(members[i]);
+ if (signature == null) {
+ report(ActionMessages.ManageMethodBreakpointActionDelegate_methodNonAvailable, part);
+ return Status.OK_STATUS;
+ }
+ }
+ JDIDebugModel.createMethodBreakpoint(BreakpointUtils.getBreakpointResource(members[i]), createQualifiedTypeName(type), mname, signature, true, false, false, -1, start, end, 0, true, attributes);
+ } else {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(breakpoint, true);
+ }
+ }
+ }
+ else {
+ report(ActionMessages.ToggleBreakpointAdapter_4, part);
+ return Status.OK_STATUS;
+ }
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ /**
+ * Toggles a class load breakpoint
+ * @param part the part
+ * @param selection the current selection
+ * @since 3.3
+ */
+ public void toggleClassBreakpoints(final IWorkbenchPart part, final ISelection selection) {
+ Job job = new Job("Toggle Class Load Breakpoints") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ try {
+ report(null, part);
+ ISelection sel = selection;
+ if(!(selection instanceof IStructuredSelection)) {
+ sel = translateToMembers(part, selection);
+ }
+ if(isInterface(sel, part)) {
+ report(ActionMessages.ToggleBreakpointAdapter_1, part);
+ return Status.OK_STATUS;
+ }
+ if(sel instanceof IStructuredSelection) {
+ IMember member = (IMember)((IStructuredSelection)sel).getFirstElement();
+ IType type = (IType) member;
+ IBreakpoint existing = getClassLoadBreakpoint(type);
+ if (existing != null) {
+ existing.delete();
+ }
+ else {
+ HashMap map = new HashMap(10);
+ BreakpointUtils.addJavaBreakpointAttributes(map, type);
+ ISourceRange range= type.getNameRange();
+ int start = -1;
+ int end = -1;
+ if (range != null) {
+ start = range.getOffset();
+ end = start + range.getLength();
+ }
+ JDIDebugModel.createClassPrepareBreakpoint(BreakpointUtils.getBreakpointResource(member), createQualifiedTypeName(type), IJavaClassPrepareBreakpoint.TYPE_CLASS, start, end, true, map);
+ }
+ }
+ else {
+ report(ActionMessages.ToggleBreakpointAdapter_0, part);
+ return Status.OK_STATUS;
+ }
+ }
+ catch (CoreException e) {
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ /**
+ * Returns the class load breakpoint for the specified type or null if none found
+ * @param type the type to search for a class load breakpoint for
+ * @return the existing class load breakpoint, or null if none
+ * @throws CoreException
+ * @since 3.3
+ */
+ protected IBreakpoint getClassLoadBreakpoint(IType type) throws CoreException {
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(JDIDebugModel.getPluginIdentifier());
+ IBreakpoint existing = null;
+ IJavaBreakpoint breakpoint = null;
+ for (int i = 0; i < breakpoints.length; i++) {
+ breakpoint = (IJavaBreakpoint) breakpoints[i];
+ if (breakpoint instanceof IJavaClassPrepareBreakpoint && createQualifiedTypeName(type).equals(breakpoint.getTypeName())) {
+ existing = breakpoint;
+ break;
+ }
+ }
+ return existing;
+ }
+
+ /**
+ * Returns the package qualified name, while accounting for the fact that a source file might
+ * not have a project
+ * @param type the type to ensure the package qualified name is created for
+ * @return the package qualified name
+ * @since 3.3
+ */
+//{ObjectTeams: made API for RoFiBreakpointTests (was private non-static):
+ public static String createQualifiedTypeName(IType type) {
+// SH}
+ String tname = pruneAnonymous(type);
+ try {
+ String packName = null;
+ if (type.isBinary()) {
+ packName = type.getPackageFragment().getElementName();
+ } else {
+ IPackageDeclaration[] pd = type.getCompilationUnit().getPackageDeclarations();
+ if(pd.length > 0) {
+ packName = pd[0].getElementName();
+ }
+ }
+ if(packName != null && !packName.equals(EMPTY_STRING)) {
+//{ObjectTeams: package of a role must be a team package:
+ if (tname.startsWith(IOTConstants.OT_DELIM))
+ tname = packName+'$'+tname;
+ else
+// SH}
+ tname = packName+"."+tname; //$NON-NLS-1$
+ }
+ }
+ catch (JavaModelException e) {}
+ return tname;
+ }
+
+ /**
+ * Prunes out all naming occurrences of anonymous inner types, since these types have no names
+ * and cannot be derived visiting an AST (no positive type name matching while visiting ASTs)
+ * @param type
+ * @return the compiled type name from the given {@link IType} with all occurrences of anonymous inner types removed
+ * @since 3.4
+ */
+ private static String pruneAnonymous(IType type) {
+ StringBuffer buffer = new StringBuffer();
+ IJavaElement parent = type;
+ while(parent != null) {
+ if(parent.getElementType() == IJavaElement.TYPE){
+ IType atype = (IType) parent;
+ try {
+ if(!atype.isAnonymous()) {
+ if(buffer.length() > 0) {
+ buffer.insert(0, '$');
+ }
+//{ObjectTeams: use prefixed role type if appropriate:
+// cf. OTValidBreakpointLocationLocator.computeTypeName()
+/* orig:
+ buffer.insert(0, atype.getElementName());
+ :giro */
+ buffer.insert(0, getSimpleTypeName(atype));
+// SH}
+ }
+ }
+ catch(JavaModelException jme) {}
+ }
+ parent = parent.getParent();
+ }
+ return buffer.toString();
+ }
+
+//{ObjectTeams: new util:
+ /** Make sure each role type is prefixed with __OT__. */
+ private static String getSimpleTypeName(IType type) {
+ String name= type.getElementName();
+ if (name.startsWith(IOTConstants.OT_DELIM))
+ return name; // already prefixed
+
+ boolean isRole= false;
+ if (type.getElementType() == IOTJavaElement.ROLE)
+ isRole= true;
+ else if (OTModelManager.hasOTElementFor(type)) {
+ IOTType otType= OTModelManager.getOTElement(type);
+ isRole= otType.isRole();
+ }
+ if (isRole)
+ return IOTConstants.OT_DELIM + name;
+ return name;
+ }
+// SH}
+
+ /**
+ * gets the <code>IJavaElement</code> from the editor input
+ * @param input the current editor input
+ * @return the corresponding <code>IJavaElement</code>
+ * @since 3.3
+ */
+ private IJavaElement getJavaElement(IEditorInput input) {
+ IJavaElement je = JavaUI.getEditorInputJavaElement(input);
+ if(je != null) {
+ return je;
+ }
+ //try to get from the working copy manager
+ return DebugWorkingCopyManager.getWorkingCopy(input, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) {
+ if (isRemote(part, selection)) {
+ return false;
+ }
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ return getMethods(ss).length > 0;
+ }
+ return (selection instanceof ITextSelection) && isMethod((ITextSelection) selection, part);
+ }
+
+ /**
+ * Returns whether the given part/selection is remote (viewing a repository)
+ *
+ * @param part
+ * @param selection
+ * @return
+ */
+ protected boolean isRemote(IWorkbenchPart part, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ Object element = ss.getFirstElement();
+ if(element instanceof IMember) {
+ IMember member = (IMember) element;
+ return !member.getJavaProject().getProject().exists();
+ }
+ }
+ ITextEditor editor = getTextEditor(part);
+ if (editor != null) {
+ IEditorInput input = editor.getEditorInput();
+ Object adapter = Platform.getAdapterManager().getAdapter(input, "org.eclipse.team.core.history.IFileRevision"); //$NON-NLS-1$
+ return adapter != null;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the text editor associated with the given part or <code>null</code>
+ * if none. In case of a multi-page editor, this method should be used to retrieve
+ * the correct editor to perform the breakpoint operation on.
+ *
+ * @param part workbench part
+ * @return text editor part or <code>null</code>
+ */
+ protected ITextEditor getTextEditor(IWorkbenchPart part) {
+ if (part instanceof ITextEditor) {
+ return (ITextEditor) part;
+ }
+ return (ITextEditor) part.getAdapter(ITextEditor.class);
+ }
+
+ /**
+ * Returns the methods from the selection, or an empty array
+ * @param selection the selection to get the methods from
+ * @return an array of the methods from the selection or an empty array
+ */
+ protected IMethod[] getMethods(IStructuredSelection selection) {
+ if (selection.isEmpty()) {
+ return new IMethod[0];
+ }
+ List methods = new ArrayList(selection.size());
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object thing = iterator.next();
+ try {
+ if (thing instanceof IMethod) {
+ IMethod method = (IMethod) thing;
+ if (!Flags.isAbstract(method.getFlags())) {
+ methods.add(method);
+ }
+ }
+ }
+ catch (JavaModelException e) {}
+ }
+ return (IMethod[]) methods.toArray(new IMethod[methods.size()]);
+ }
+
+ /**
+ * Returns if the text selection is a valid method or not
+ * @param selection the text selection
+ * @param part the associated workbench part
+ * @return true if the selection is a valid method, false otherwise
+ */
+ private boolean isMethod(ITextSelection selection, IWorkbenchPart part) {
+ ITextEditor editor = getTextEditor(part);
+ if(editor != null) {
+ IJavaElement element = getJavaElement(editor.getEditorInput());
+ if(element != null) {
+ try {
+ if(element instanceof ICompilationUnit) {
+ element = ((ICompilationUnit) element).getElementAt(selection.getOffset());
+ }
+ else if(element instanceof IClassFile) {
+ element = ((IClassFile) element).getElementAt(selection.getOffset());
+ }
+ return element != null && element.getElementType() == IJavaElement.METHOD;
+ }
+ catch (JavaModelException e) {return false;}
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns a list of <code>IField</code> and <code>IJavaFieldVariable</code> in the given selection.
+ * When an <code>IField</code> can be resolved for an <code>IJavaFieldVariable</code>, it is
+ * returned in favour of the variable.
+ *
+ * @param selection
+ * @return list of <code>IField</code> and <code>IJavaFieldVariable</code>, possibly empty
+ * @throws CoreException
+ */
+ protected List getFields(IStructuredSelection selection) throws CoreException {
+ if (selection.isEmpty()) {
+ return Collections.EMPTY_LIST;
+ }
+ List fields = new ArrayList(selection.size());
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object thing = iterator.next();
+ if (thing instanceof IField) {
+ fields.add(thing);
+ } else if (thing instanceof IJavaFieldVariable) {
+ IField field = getField((IJavaFieldVariable) thing);
+ if (field == null) {
+ fields.add(thing);
+ } else {
+ fields.add(field);
+ }
+ }
+ }
+ return fields;
+ }
+
+ /**
+ * Returns if the structured selection is itself or is part of an interface
+ * @param selection the current selection
+ * @return true if the selection is part of an interface, false otherwise
+ * @since 3.2
+ */
+ private boolean isInterface(ISelection selection, IWorkbenchPart part) {
+ try {
+ ISelection sel = selection;
+ if(!(sel instanceof IStructuredSelection)) {
+ sel = translateToMembers(part, selection);
+ }
+ if(sel instanceof IStructuredSelection) {
+ Object obj = ((IStructuredSelection)sel).getFirstElement();
+ if(obj instanceof IMember) {
+ IMember member = (IMember) ((IStructuredSelection)sel).getFirstElement();
+ if(member.getElementType() == IJavaElement.TYPE) {
+ return ((IType)member).isInterface();
+ }
+ return member.getDeclaringType().isInterface();
+ }
+ else if(obj instanceof IJavaFieldVariable) {
+ IJavaFieldVariable var = (IJavaFieldVariable) obj;
+ IType type = JavaDebugUtils.resolveType(var.getDeclaringType());
+ return type != null && type.isInterface();
+ }
+ }
+ }
+ catch (CoreException e1) {}
+ return false;
+ }
+
+ /**
+ * Returns if the text selection is a field selection or not
+ * @param selection the text selection
+ * @param part the associated workbench part
+ * @return true if the text selection is a valid field for a watchpoint, false otherwise
+ * @since 3.3
+ */
+ private boolean isField(ITextSelection selection, IWorkbenchPart part) {
+ ITextEditor editor = getTextEditor(part);
+ if(editor != null) {
+ IJavaElement element = getJavaElement(editor.getEditorInput());
+ if(element != null) {
+ try {
+ if(element instanceof ICompilationUnit) {
+ element = ((ICompilationUnit) element).getElementAt(selection.getOffset());
+ }
+ else if(element instanceof IClassFile) {
+ element = ((IClassFile) element).getElementAt(selection.getOffset());
+ }
+ return element != null && element.getElementType() == IJavaElement.FIELD;
+ }
+ catch (JavaModelException e) {return false;}
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Determines if the selection is a field or not
+ * @param selection the current selection
+ * @return true if the selection is a field false otherwise
+ */
+ private boolean isFields(IStructuredSelection selection) {
+ if (!selection.isEmpty()) {
+ try {
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object thing = iterator.next();
+ if (thing instanceof IField) {
+ int flags = ((IField)thing).getFlags();
+ return !Flags.isFinal(flags) & !(Flags.isFinal(flags) & Flags.isStatic(flags));
+ }
+ else if(thing instanceof IJavaFieldVariable) {
+ IJavaFieldVariable fv = (IJavaFieldVariable)thing;
+ return !fv.isFinal() & !(fv.isFinal() & fv.isStatic());
+ }
+ }
+ }
+ catch(JavaModelException e) {return false;}
+ catch(DebugException de) {return false;}
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleWatchpoints(final IWorkbenchPart part, final ISelection finalSelection) {
+ Job job = new Job("Toggle Watchpoints") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ try {
+ report(null, part);
+ ISelection selection = finalSelection;
+ if(!(selection instanceof IStructuredSelection)) {
+ selection = translateToMembers(part, finalSelection);
+ }
+ if(isInterface(selection, part)) {
+ report(ActionMessages.ToggleBreakpointAdapter_5, part);
+ return Status.OK_STATUS;
+ }
+ boolean allowed = false;
+ if (selection instanceof IStructuredSelection) {
+ List fields = getFields((IStructuredSelection) selection);
+ if (fields.isEmpty()) {
+ report(ActionMessages.ToggleBreakpointAdapter_10, part);
+ return Status.OK_STATUS;
+ }
+ Iterator theFields = fields.iterator();
+ IField javaField = null;
+ IResource resource = null;
+ String typeName = null;
+ String fieldName = null;
+ Object element = null;
+ Map attributes = null;
+ IJavaBreakpoint breakpoint = null;
+ while (theFields.hasNext()) {
+ element = theFields.next();
+ if (element instanceof IField) {
+ javaField = (IField) element;
+ IType type = javaField.getDeclaringType();
+ typeName = createQualifiedTypeName(type);
+ fieldName = javaField.getElementName();
+ int f = javaField.getFlags();
+ boolean fin = Flags.isFinal(f);
+ allowed = !(fin) & !(Flags.isStatic(f) & fin);
+ } else if (element instanceof IJavaFieldVariable) {
+ IJavaFieldVariable var = (IJavaFieldVariable) element;
+ typeName = var.getDeclaringType().getName();
+ fieldName = var.getName();
+ boolean fin = var.isFinal();
+ allowed = !(fin) & !(var.isStatic() & fin);
+ }
+ breakpoint = getWatchpoint(typeName, fieldName);
+ if (breakpoint == null) {
+ if(!allowed) {
+ toggleLineBreakpoints(part, finalSelection);
+ return Status.OK_STATUS;
+ }
+ int start = -1;
+ int end = -1;
+ attributes = new HashMap(10);
+ if (javaField == null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot();
+ } else {
+ IType type = javaField.getDeclaringType();
+ ISourceRange range = javaField.getNameRange();
+ if (range != null) {
+ start = range.getOffset();
+ end = start + range.getLength();
+ }
+ BreakpointUtils.addJavaBreakpointAttributes(attributes, javaField);
+ resource = BreakpointUtils.getBreakpointResource(type);
+ }
+ JDIDebugModel.createWatchpoint(resource, typeName, fieldName, -1, start, end, 0, true, attributes);
+ } else {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(breakpoint, true);
+ }
+ }
+ }
+ else {
+ report(ActionMessages.ToggleBreakpointAdapter_2, part);
+ return Status.OK_STATUS;
+ }
+ } catch (CoreException e) {return e.getStatus();}
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ /**
+ * Returns any existing watchpoint for the given field, or <code>null</code> if none.
+ *
+ * @param typeName fully qualified type name on which watchpoint may exist
+ * @param fieldName field name
+ * @return any existing watchpoint for the given field, or <code>null</code> if none
+ * @throws CoreException
+ */
+ private IJavaWatchpoint getWatchpoint(String typeName, String fieldName) throws CoreException {
+ IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
+ IBreakpoint[] breakpoints = breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier());
+ for (int i = 0; i < breakpoints.length; i++) {
+ IBreakpoint breakpoint = breakpoints[i];
+ if (breakpoint instanceof IJavaWatchpoint) {
+ IJavaWatchpoint watchpoint = (IJavaWatchpoint) breakpoint;
+ if (typeName.equals(watchpoint.getTypeName()) && fieldName.equals(watchpoint.getFieldName())) {
+ return watchpoint;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the resolved signature of the given method
+ * @param method method to resolve
+ * @return the resolved method signature or <code>null</code> if none
+ * @throws JavaModelException
+ * @since 3.4
+ */
+ public static String resolveMethodSignature(IMethod method) throws JavaModelException {
+ String signature = method.getSignature();
+ String[] parameterTypes = Signature.getParameterTypes(signature);
+ int length = parameterTypes.length;
+ String[] resolvedParameterTypes = new String[length];
+ for (int i = 0; i < length; i++) {
+ resolvedParameterTypes[i] = resolveTypeSignature(method, parameterTypes[i]);
+ if (resolvedParameterTypes[i] == null) {
+ return null;
+ }
+ }
+ String resolvedReturnType = resolveTypeSignature(method, Signature.getReturnType(signature));
+ if (resolvedReturnType == null) {
+ return null;
+ }
+ return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType);
+ }
+
+ /**
+ * Returns the resolved type signature for the given signature in the given
+ * method, or <code>null</code> if unable to resolve.
+ *
+ * @param method method containing the type signature
+ * @param typeSignature the type signature to resolve
+ * @return the resolved type signature
+ * @throws JavaModelException
+ */
+ private static String resolveTypeSignature(IMethod method, String typeSignature) throws JavaModelException {
+ int count = Signature.getArrayCount(typeSignature);
+ String elementTypeSignature = Signature.getElementType(typeSignature);
+ if (elementTypeSignature.length() == 1) {
+ // no need to resolve primitive types
+ return typeSignature;
+ }
+ String elementTypeName = Signature.toString(elementTypeSignature);
+ IType type = method.getDeclaringType();
+ String[][] resolvedElementTypeNames = type.resolveType(elementTypeName);
+ if (resolvedElementTypeNames == null || resolvedElementTypeNames.length != 1) {
+ // check if type parameter
+ ITypeParameter typeParameter = method.getTypeParameter(elementTypeName);
+ if (!typeParameter.exists()) {
+ typeParameter = type.getTypeParameter(elementTypeName);
+ }
+ if (typeParameter.exists()) {
+ String[] bounds = typeParameter.getBounds();
+ if (bounds.length == 0) {
+ return "Ljava/lang/Object;"; //$NON-NLS-1$
+ } else {
+ String bound = Signature.createTypeSignature(bounds[0], false);
+ return resolveTypeSignature(method, bound);
+ }
+ }
+ // the type name cannot be resolved
+ return null;
+ }
+
+ String[] types = resolvedElementTypeNames[0];
+ types[1] = types[1].replace('.', '$');
+
+ String resolvedElementTypeName = Signature.toQualifiedName(types);
+ String resolvedElementTypeSignature = EMPTY_STRING;
+ if(types[0].equals(EMPTY_STRING)) {
+ resolvedElementTypeName = resolvedElementTypeName.substring(1);
+ resolvedElementTypeSignature = Signature.createTypeSignature(resolvedElementTypeName, true);
+ }
+ else {
+ resolvedElementTypeSignature = Signature.createTypeSignature(resolvedElementTypeName, true).replace('.', '/');
+ }
+
+ return Signature.createArraySignature(resolvedElementTypeSignature, count);
+ }
+
+ /**
+ * Returns the resource associated with the specified editor part
+ * @param editor the currently active editor part
+ * @return the corresponding <code>IResource</code> from the editor part
+ */
+ protected static IResource getResource(IEditorPart editor) {
+ IEditorInput editorInput = editor.getEditorInput();
+ IResource resource = (IResource) editorInput.getAdapter(IFile.class);
+ if (resource == null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot();
+ }
+ return resource;
+ }
+
+ /**
+ * Returns a handle to the specified method or <code>null</code> if none.
+ *
+ * @param editorPart
+ * the editor containing the method
+ * @param typeName
+ * @param methodName
+ * @param signature
+ * @return handle or <code>null</code>
+ */
+ protected IMethod getMethodHandle(IEditorPart editorPart, String typeName, String methodName, String signature) throws CoreException {
+ IJavaElement element = (IJavaElement) editorPart.getEditorInput().getAdapter(IJavaElement.class);
+ IType type = null;
+ if (element instanceof ICompilationUnit) {
+ IType[] types = ((ICompilationUnit) element).getAllTypes();
+ for (int i = 0; i < types.length; i++) {
+ if (types[i].getFullyQualifiedName().equals(typeName)) {
+ type = types[i];
+ break;
+ }
+ }
+ } else if (element instanceof IClassFile) {
+ type = ((IClassFile) element).getType();
+ }
+ if (type != null) {
+ String[] sigs = Signature.getParameterTypes(signature);
+ return type.getMethod(methodName, sigs);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the <code>IJavaBreakpoint</code> from the specified <code>IMember</code>
+ * @param element the element to get the breakpoint from
+ * @return the current breakpoint from the element or <code>null</code>
+ */
+ protected IJavaBreakpoint getMethodBreakpoint(IMember element) {
+ IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
+ IBreakpoint[] breakpoints = breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier());
+ if (element instanceof IMethod) {
+ IMethod method = (IMethod) element;
+ for (int i = 0; i < breakpoints.length; i++) {
+ IBreakpoint breakpoint = breakpoints[i];
+ if (breakpoint instanceof IJavaMethodBreakpoint) {
+ IJavaMethodBreakpoint methodBreakpoint = (IJavaMethodBreakpoint) breakpoint;
+ IMember container = null;
+ try {
+ container = BreakpointUtils.getMember(methodBreakpoint);
+ } catch (CoreException e) {
+ JDIDebugUIPlugin.log(e);
+ return null;
+ }
+ if (container == null) {
+ try {
+ if (method.getDeclaringType().getFullyQualifiedName().equals(methodBreakpoint.getTypeName()) &&
+ method.getElementName().equals(methodBreakpoint.getMethodName()) &&
+ methodBreakpoint.getMethodSignature().equals(resolveMethodSignature(method))) {
+ return methodBreakpoint;
+ }
+ } catch (CoreException e) {
+ JDIDebugUIPlugin.log(e);
+ }
+ } else {
+ if (container instanceof IMethod) {
+ if (method.getDeclaringType().getFullyQualifiedName().equals(container.getDeclaringType().getFullyQualifiedName())) {
+ if (method.isSimilar((IMethod) container)) {
+ return methodBreakpoint;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the compilation unit from the editor
+ * @param editor the editor to get the compilation unit from
+ * @return the compilation unit or <code>null</code>
+ */
+ protected CompilationUnit parseCompilationUnit(ITextEditor editor) {
+ ITypeRoot root = getTypeRoot(editor.getEditorInput());
+ if(root != null) {
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ parser.setSource(root);
+ return (CompilationUnit) parser.createAST(null);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
+ if (isRemote(part, selection)) {
+ return false;
+ }
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ return isFields(ss);
+ }
+ return (selection instanceof ITextSelection) && isField((ITextSelection) selection, part);
+ }
+
+ /**
+ * Returns a selection of the member in the given text selection, or the
+ * original selection if none.
+ *
+ * @param part
+ * @param selection
+ * @return a structured selection of the member in the given text selection,
+ * or the original selection if none
+ * @exception CoreException
+ * if an exception occurs
+ */
+ protected ISelection translateToMembers(IWorkbenchPart part, ISelection selection) throws CoreException {
+ ITextEditor textEditor = getTextEditor(part);
+ if (textEditor != null && selection instanceof ITextSelection) {
+ ITextSelection textSelection = (ITextSelection) selection;
+ IEditorInput editorInput = textEditor.getEditorInput();
+ IDocumentProvider documentProvider = textEditor.getDocumentProvider();
+ if (documentProvider == null) {
+ throw new CoreException(Status.CANCEL_STATUS);
+ }
+ IDocument document = documentProvider.getDocument(editorInput);
+ int offset = textSelection.getOffset();
+ if (document != null) {
+ try {
+ IRegion region = document.getLineInformationOfOffset(offset);
+ int end = region.getOffset() + region.getLength();
+ while (Character.isWhitespace(document.getChar(offset)) && offset < end) {
+ offset++;
+ }
+ } catch (BadLocationException e) {}
+ }
+ IMember m = null;
+ ITypeRoot root = getTypeRoot(editorInput);
+ if(root instanceof ICompilationUnit) {
+ ICompilationUnit unit = (ICompilationUnit) root;
+ synchronized (unit) {
+ unit.reconcile(ICompilationUnit.NO_AST , false, null, null);
+ }
+ }
+ if(root != null){
+ IJavaElement e = root.getElementAt(offset);
+ if (e instanceof IMember) {
+ m = (IMember) e;
+ }
+ }
+ if (m != null) {
+ return new StructuredSelection(m);
+ }
+ }
+ return selection;
+ }
+
+ /**
+ * Returns the {@link ITypeRoot} for the given {@link IEditorInput}
+ * @param input
+ * @return the type root or <code>null</code> if one cannot be derived
+ * @since 3.4
+ */
+ private ITypeRoot getTypeRoot(IEditorInput input) {
+ ITypeRoot root = (ITypeRoot) input.getAdapter(IClassFile.class);
+ if(root == null) {
+ IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
+ root = manager.getWorkingCopy(input);
+ }
+ if(root == null) {
+ root = DebugWorkingCopyManager.getWorkingCopy(input, false);
+ }
+ return root;
+ }
+
+ /**
+ * Return the associated IField (Java model) for the given
+ * IJavaFieldVariable (JDI model)
+ */
+ private IField getField(IJavaFieldVariable variable) throws CoreException {
+ String varName = null;
+ try {
+ varName = variable.getName();
+ } catch (DebugException x) {
+ JDIDebugUIPlugin.log(x);
+ return null;
+ }
+ IField field;
+ IJavaType declaringType = variable.getDeclaringType();
+ IType type = JavaDebugUtils.resolveType(declaringType);
+ if (type != null) {
+ field = type.getField(varName);
+ if (field.exists()) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#toggleBreakpoints(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ ISelection sel = translateToMembers(part, selection);
+ if(sel instanceof IStructuredSelection) {
+ IMember member = (IMember) ((IStructuredSelection)sel).getFirstElement();
+ int mtype = member.getElementType();
+ if(mtype == IJavaElement.FIELD || mtype == IJavaElement.METHOD) {
+ // remove line breakpoint if present first
+ if (selection instanceof ITextSelection) {
+ ITextSelection ts = (ITextSelection) selection;
+ IType declaringType = member.getDeclaringType();
+ IResource resource = BreakpointUtils.getBreakpointResource(declaringType);
+ IJavaLineBreakpoint breakpoint = JDIDebugModel.lineBreakpointExists(resource, createQualifiedTypeName(declaringType), ts.getStartLine() + 1);
+ if (breakpoint != null) {
+ breakpoint.delete();
+ return;
+ }
+ CompilationUnit unit = parseCompilationUnit(getTextEditor(part));
+//ObjectTeams: (visibility) OTValidBreakpointLocationLocator instead of ValidBreakpointLocationLocator
+ OTValidBreakpointLocationLocator loc = new OTValidBreakpointLocationLocator(unit, ts.getStartLine()+1, true, true);
+ unit.accept(loc);
+ if(loc.getLocationType() == OTValidBreakpointLocationLocator.LOCATION_METHOD) {
+ toggleMethodBreakpoints(part, sel);
+ }
+ else if(loc.getLocationType() == OTValidBreakpointLocationLocator.LOCATION_FIELD) {
+ toggleWatchpoints(part, ts);
+ }
+ else if(loc.getLocationType() == OTValidBreakpointLocationLocator.LOCATION_LINE) {
+ toggleLineBreakpoints(part, ts);
+ }
+// carp}
+ }
+ }
+ else if(member.getElementType() == IJavaElement.TYPE) {
+ toggleClassBreakpoints(part, sel);
+ }
+ else {
+ //fall back to old behavior, always create a line breakpoint
+ toggleLineBreakpoints(part, selection, true);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#canToggleBreakpoints(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) {
+ if (isRemote(part, selection)) {
+ return false;
+ }
+ return canToggleLineBreakpoints(part, selection);
+ }
+}
+
+//ike}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTValidBreakpointLocationLocator.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTValidBreakpointLocationLocator.java
new file mode 100644
index 0000000..dc88fc7
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/OTValidBreakpointLocationLocator.java
@@ -0,0 +1,1153 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * 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: OTValidBreakpointLocationLocator.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Fraunhofer FIRST - extended API and implementation
+ * Technical University Berlin - extended API and implementation
+ *******************************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.*;
+import org.eclipse.jdt.core.dom.PrefixExpression.Operator;
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+
+/**
+ * Compute a valid location where to put a breakpoint from an JDOM CompilationUnit.
+ * The result is the first valid location with a line number greater or equals than the given position.
+ *
+ * The Visitor visits now also OT-nodes like Callout-/CallinMappingDeclaration and decides wheather a breakpoint
+ * is allowed in this node or not.
+*
+ * @author ike
+ * $Id: OTValidBreakpointLocationLocator.java 23432 2010-02-03 23:13:42Z stephan $
+ */
+//{OT_COPY_PASTE from org.eclipse.jdt.internal.debug.ui.action.ValidBreakpointLocationLocator
+// due to private visibility of visit(ASTNode, boolean) (added visitor-methods can't call it)
+// -> could easily be ported to OT, together with OTBreakpointLocationVerifierJob
+public class OTValidBreakpointLocationLocator extends ASTVisitor {
+
+ public static final int LOCATION_NOT_FOUND= 0;
+ public static final int LOCATION_LINE= 1;
+ public static final int LOCATION_METHOD= 2;
+ public static final int LOCATION_FIELD= 3;
+
+ private CompilationUnit fCompilationUnit;
+ private int fLineNumber;
+ private boolean fBindingsResolved;
+ private boolean fNeedBindings = false;
+ private boolean fBestMatch;
+
+ private int fLocationType;
+ private boolean fLocationFound;
+ private String fTypeName;
+ private int fLineLocation;
+ private int fMemberOffset;
+ private List fLabels;
+
+ /**
+ * @param compilationUnit the JDOM CompilationUnit of the source code.
+ * @param lineNumber the line number in the source code where to put the breakpoint.
+ * @param bestMatch if <code>true</code> look for the best match, otherwise look only for a valid line
+ */
+ public OTValidBreakpointLocationLocator(CompilationUnit compilationUnit, int lineNumber, boolean bindingsResolved, boolean bestMatch) {
+ fCompilationUnit= compilationUnit;
+ fLineNumber= lineNumber;
+ fBindingsResolved= bindingsResolved;
+ fBestMatch= bestMatch;
+ fLocationFound= false;
+ }
+
+ /**
+ * Returns whether binding information would be helpful in validating a breakpoint
+ * location. If this locator makes a pass of the tree and determines that binding
+ * information would be helpful but was not available, this method returns
+ * <code>true</code>.
+ *
+ * @return whether binding information would be helpful in validating a breakpoint location
+ */
+ public boolean isBindingsRequired() {
+ return fNeedBindings;
+ }
+
+ /**
+ * Return the type of the valid location found
+ * @return one of LOCATION_NOT_FOUND, LOCATION_LINE, LOCATION_METHOD or LOCATION_FIELD
+ */
+ public int getLocationType() {
+ return fLocationType;
+ }
+
+ /**
+ * Return of the type where the valid location is.
+ */
+ public String getFullyQualifiedTypeName() {
+ return fTypeName;
+ }
+
+ /**
+ * Return the line number of the computed valid location, if the location type is LOCATION_LINE.
+ */
+ public int getLineLocation() {
+ if (fLocationType == LOCATION_LINE) {
+ return fLineLocation;
+ }
+ return -1;
+ }
+
+ /**
+ * Return the offset of the member which is the valid location,
+ * if the location type is LOCATION_METHOD or LOCATION_FIELD.
+ */
+ public int getMemberOffset() {
+ return fMemberOffset;
+ }
+
+ /**
+ * Compute the name of the type which contains this node.
+ * Result will be the name of the type or the inner type which contains this node, but not of the local or anonymous type.
+ */
+ static protected String computeTypeName(ASTNode node) {
+//{ObjectTeams: several modifications to cope with role classes (inline and role file):
+
+ // type part:
+ String typeName = null;
+ while (!(node instanceof CompilationUnit)) {
+ if (node instanceof AbstractTypeDeclaration) {
+ String identifier= ((AbstractTypeDeclaration)node).getName().getIdentifier();
+ if (typeName == null) {
+ typeName= identifier;
+ if ( node instanceof RoleTypeDeclaration
+ && !typeName.startsWith(IOTConstants.OT_DELIM))
+ typeName= IOTConstants.OT_DELIM+typeName;
+ } else {
+ typeName= identifier + '$' + typeName;
+ }
+ } else {
+ typeName= null;
+ }
+ node= node.getParent();
+ }
+
+ // package part (may be team package):
+ PackageDeclaration packageDecl= ((CompilationUnit)node).getPackage();
+ char sep= '.'; // for regular toplevel types
+ if (typeName.startsWith(IOTConstants.OT_DELIM))
+ sep= '$'; // for role files
+ String packageIdentifier= ""; //$NON-NLS-1$
+ if (packageDecl != null) {
+ Name packageName= packageDecl.getName();
+ while (packageName.isQualifiedName()) {
+ QualifiedName qualifiedName= (QualifiedName) packageName;
+ packageIdentifier= qualifiedName.getName().getIdentifier() + sep + packageIdentifier;
+ sep= '.';
+ packageName= qualifiedName.getQualifier();
+ }
+ packageIdentifier= ((SimpleName)packageName).getIdentifier() + sep + packageIdentifier;
+ }
+
+ return packageIdentifier + typeName;
+// SH}
+ }
+
+ /**
+ * Return <code>true</code> if this node children may contain a valid location
+ * for the breakpoint.
+ * @param node the node.
+ * @param isCode true indicated that the first line of the given node always
+ * contains some executable code, even if split in multiple lines.
+ */
+ private boolean visit(ASTNode node, boolean isCode) {
+ // if we already found a correct location
+ // no need to check the element inside.
+ if (fLocationFound) {
+ return false;
+ }
+ int startPosition= node.getStartPosition();
+ int endLine= lineNumber(startPosition + node.getLength() - 1);
+ // if the position is not in this part of the code
+ // no need to check the element inside.
+ if (endLine < fLineNumber) {
+ return false;
+ }
+ // if the first line of this node always represents some executable code and the
+ // breakpoint is requested on this line or on a previous line, this is a valid
+ // location
+ int startLine = lineNumber(startPosition);
+ if (isCode && (fLineNumber <= startLine)) {
+ fLineLocation= startLine;
+ fLocationFound= true;
+ fLocationType= LOCATION_LINE;
+ fTypeName= computeTypeName(node);
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isReplacedByConstantValue(Expression node) {
+ switch (node.getNodeType()) {
+ // litterals are constant
+ case ASTNode.BOOLEAN_LITERAL:
+ case ASTNode.CHARACTER_LITERAL:
+ case ASTNode.NUMBER_LITERAL:
+ case ASTNode.STRING_LITERAL:
+ return true;
+ case ASTNode.SIMPLE_NAME:
+ case ASTNode.QUALIFIED_NAME:
+ return isReplacedByConstantValue((Name)node);
+ case ASTNode.FIELD_ACCESS:
+ return isReplacedByConstantValue((FieldAccess)node);
+ case ASTNode.SUPER_FIELD_ACCESS:
+ return isReplacedByConstantValue((SuperFieldAccess)node);
+ case ASTNode.INFIX_EXPRESSION:
+ return isReplacedByConstantValue((InfixExpression)node);
+ case ASTNode.PREFIX_EXPRESSION:
+ return isReplacedByConstantValue((PrefixExpression)node);
+ case ASTNode.CAST_EXPRESSION:
+ return isReplacedByConstantValue(((CastExpression)node).getExpression());
+ default:
+ return false;
+ }
+ }
+
+ private boolean isReplacedByConstantValue(InfixExpression node) {
+ // if all operands are constant value, the expression is replaced by a constant value
+ if (!(isReplacedByConstantValue(node.getLeftOperand()) && isReplacedByConstantValue(node.getRightOperand()))) {
+ return false;
+ }
+ if (node.hasExtendedOperands()) {
+ for (Iterator iter = node.extendedOperands().iterator(); iter.hasNext(); ) {
+ if (!isReplacedByConstantValue((Expression) iter.next())) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean isReplacedByConstantValue(PrefixExpression node) {
+ // for '-', '+', '~' and '!', if the operand is a constant value,
+ // the expression is replaced by a constant value
+ Operator operator = node.getOperator();
+ if (operator != PrefixExpression.Operator.INCREMENT && operator != PrefixExpression.Operator.DECREMENT) {
+ return isReplacedByConstantValue(node.getOperand());
+ }
+ return false;
+ }
+
+ private boolean isReplacedByConstantValue(Name node) {
+ if (!fBindingsResolved) {
+ fNeedBindings = true;
+ return false;
+ }
+ // if node is a variable with a constant value (static final field)
+ IBinding binding= node.resolveBinding();
+ if (binding != null && binding.getKind() == IBinding.VARIABLE) {
+ return ((IVariableBinding)binding).getConstantValue() != null;
+ }
+ return false;
+ }
+
+ private boolean isReplacedByConstantValue(FieldAccess node) {
+ if (!fBindingsResolved) {
+ fNeedBindings = true;
+ return false;
+ }
+ // if the node is 'this.<field>', and the field is static final
+ Expression expression= node.getExpression();
+ IVariableBinding binding= node.resolveFieldBinding();
+ if (binding != null && expression.getNodeType() == ASTNode.THIS_EXPRESSION) {
+ return binding.getConstantValue() != null;
+ }
+ return false;
+ }
+
+ private boolean isReplacedByConstantValue(SuperFieldAccess node) {
+ if (!fBindingsResolved) {
+ fNeedBindings = true;
+ return false;
+ }
+ // if the field is static final
+ IVariableBinding binding= node.resolveFieldBinding();
+ if (binding != null) {
+ return binding.getConstantValue() != null;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration)
+ */
+ public boolean visit(AnnotationTypeDeclaration node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration)
+ */
+ public boolean visit(AnnotationTypeMemberDeclaration node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.AnonymousClassDeclaration)
+ */
+ public boolean visit(AnonymousClassDeclaration node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayAccess)
+ */
+ public boolean visit(ArrayAccess node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayCreation)
+ */
+ public boolean visit(ArrayCreation node) {
+ return visit(node, node.getInitializer() == null);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayInitializer)
+ */
+ public boolean visit(ArrayInitializer node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayType)
+ */
+ public boolean visit(ArrayType node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.AssertStatement)
+ */
+ public boolean visit(AssertStatement node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.Assignment)
+ */
+ public boolean visit(Assignment node) {
+ if (visit(node, false)) {
+ // if the left hand side represent a local variable, or a static field
+ // and the breakpoint was requested on a line before the line where
+ // starts the assigment, set the location to be the first executable
+ // instruction of the right hand side, as it will be the first part of
+ // this assigment to be executed
+ Expression leftHandSide= node.getLeftHandSide();
+ if (leftHandSide instanceof Name) {
+ int startLine = lineNumber(node.getStartPosition());
+ if (fLineNumber < startLine) {
+ if (fBindingsResolved) {
+ IVariableBinding binding= (IVariableBinding)((Name)leftHandSide).resolveBinding();
+ if (binding != null && (!binding.isField() || Modifier.isStatic(binding.getModifiers()))) {
+ node.getRightHandSide().accept(this);
+ }
+ } else {
+ fNeedBindings = true;
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.Block)
+ */
+ public boolean visit(Block node) {
+ if (visit(node, false)) {
+ if (node.statements().isEmpty() && node.getParent().getNodeType() == ASTNode.METHOD_DECLARATION) {
+ // in case of an empty method, set the breakpoint on the last line of the empty block.
+ fLineLocation= lineNumber(node.getStartPosition() + node.getLength() - 1);
+ fLocationFound= true;
+ fLocationType= LOCATION_LINE;
+ fTypeName= computeTypeName(node);
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.BlockComment)
+ */
+ public boolean visit(BlockComment node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.BooleanLiteral)
+ */
+ public boolean visit(BooleanLiteral node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.BreakStatement)
+ */
+ public boolean visit(BreakStatement node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CastExpression)
+ */
+ public boolean visit(CastExpression node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CatchClause)
+ */
+ public boolean visit(CatchClause node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CharacterLiteral)
+ */
+ public boolean visit(CharacterLiteral node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ClassInstanceCreation)
+ */
+ public boolean visit(ClassInstanceCreation node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ public boolean visit(CompilationUnit node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ConditionalExpression)
+ */
+ public boolean visit(ConditionalExpression node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ConstructorInvocation)
+ */
+ public boolean visit(ConstructorInvocation node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ContinueStatement)
+ */
+ public boolean visit(ContinueStatement node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.DoStatement)
+ */
+ public boolean visit(DoStatement node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.EmptyStatement)
+ */
+ public boolean visit(EmptyStatement node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.EnhancedForStatement)
+ */
+ public boolean visit(EnhancedForStatement node) {
+ if (visit(node, false)) {
+ node.getExpression().accept(this);
+ node.getBody().accept(this);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.EnumConstantDeclaration)
+ */
+ public boolean visit(EnumConstantDeclaration node) {
+ if (visit(node, false)) {
+ List arguments= node.arguments();
+ for (Iterator iter= arguments.iterator(); iter.hasNext();) {
+ ((Expression)iter.next()).accept(this);
+ }
+ AnonymousClassDeclaration decl= node.getAnonymousClassDeclaration();
+ if (decl != null) {
+ decl.accept(this);
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.EnumDeclaration)
+ */
+ public boolean visit(EnumDeclaration node) {
+ if (visit(node, false)) {
+ List enumConstants= node.enumConstants();
+ for (Iterator iter = enumConstants.iterator(); iter.hasNext();) {
+ ((EnumConstantDeclaration) iter.next()).accept(this);
+ }
+ List bodyDeclaration= node.bodyDeclarations();
+ for (Iterator iter= bodyDeclaration.iterator(); iter.hasNext();) {
+ ((BodyDeclaration)iter.next()).accept(this);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ExpressionStatement)
+ */
+ public boolean visit(ExpressionStatement node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.FieldAccess)
+ */
+ public boolean visit(FieldAccess node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.FieldDeclaration)
+ */
+ public boolean visit(FieldDeclaration node) {
+ if (visit(node, false)) {
+ if (fBestMatch) {
+ // check if the line contains a single field declaration.
+ List fragments = node.fragments();
+ if (fragments.size() == 1) {
+ int offset= ((VariableDeclarationFragment)fragments.get(0)).getName().getStartPosition();
+ // check if the breakpoint is to be set on the line which contains the name of the field
+ if (lineNumber(offset) == fLineNumber) {
+ fMemberOffset= offset;
+ fLocationType= LOCATION_FIELD;
+ fLocationFound= true;
+ return false;
+ }
+ }
+ }
+ // visit only the variable declaration fragments, no the variable names.
+ List fragments= node.fragments();
+ for (Iterator iter= fragments.iterator(); iter.hasNext();) {
+ ((VariableDeclarationFragment)iter.next()).accept(this);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ForStatement)
+ */
+ public boolean visit(ForStatement node) {
+ // in case on a "for(;;)", the breakpoint can be set on the first token of the node.
+ return visit(node, node.initializers().isEmpty() && node.getExpression() == null && node.updaters().isEmpty());
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.IfStatement)
+ */
+ public boolean visit(IfStatement node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ImportDeclaration)
+ */
+ public boolean visit(ImportDeclaration node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.InfixExpression)
+ */
+ public boolean visit(InfixExpression node) {
+ // if the breakpoint is to be set on a constant operand, the breakpoint needs to be
+ // set on the first constant operand after the previous non-constant operand
+ // (or the beginning of the expression, if there is no non-constant operand before).
+ // ex: foo() + // previous non-constant operand
+ // 1 + // breakpoint set here
+ // 2 // breakpoint asked to be set here
+ if (visit(node, false)) {
+ Expression leftOperand= node.getLeftOperand();
+ Expression firstConstant= null;
+ if (visit(leftOperand, false)) {
+ leftOperand.accept(this);
+ return false;
+ }
+ if (isReplacedByConstantValue(leftOperand)) {
+ firstConstant= leftOperand;
+ }
+ Expression rightOperand= node.getRightOperand();
+ if (visit(rightOperand, false)) {
+ if (firstConstant == null || !isReplacedByConstantValue(rightOperand)) {
+ rightOperand.accept(this);
+ return false;
+ }
+ } else {
+ if (isReplacedByConstantValue(rightOperand)) {
+ if (firstConstant == null) {
+ firstConstant= rightOperand;
+ }
+ } else {
+ firstConstant= null;
+ }
+ List extendedOperands= node.extendedOperands();
+ for (Iterator iter= extendedOperands.iterator(); iter.hasNext();) {
+ Expression operand= (Expression) iter.next();
+ if (visit(operand, false)) {
+ if (firstConstant == null || !isReplacedByConstantValue(operand)) {
+ operand.accept(this);
+ return false;
+ }
+ break;
+ }
+ if (isReplacedByConstantValue(operand)) {
+ if (firstConstant == null) {
+ firstConstant= operand;
+ }
+ } else {
+ firstConstant= null;
+ }
+
+ }
+ }
+ fLineLocation= lineNumber(firstConstant.getStartPosition());
+ fLocationFound= true;
+ fLocationType= LOCATION_LINE;
+ fTypeName= computeTypeName(firstConstant);
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.Initializer)
+ */
+ public boolean visit(Initializer node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.InstanceofExpression)
+ */
+ public boolean visit(InstanceofExpression node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.Javadoc)
+ */
+ public boolean visit(Javadoc node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.LabeledStatement)
+ */
+ public boolean visit(LabeledStatement node) {
+ nestLabel(node.getLabel().getFullyQualifiedName());
+ return visit(node, false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.LabeledStatement)
+ */
+ public void endVisit(LabeledStatement node) {
+ popLabel();
+ super.endVisit(node);
+ }
+
+ private String getLabel() {
+ if (fLabels == null || fLabels.isEmpty()) {
+ return null;
+ }
+ return (String) fLabels.get(fLabels.size() - 1);
+ }
+
+ private void nestLabel(String label) {
+ if (fLabels == null) {
+ fLabels = new ArrayList();
+ }
+ fLabels.add(label);
+ }
+
+ private void popLabel() {
+ if (fLabels == null || fLabels.isEmpty()) {
+ return;
+ }
+ fLabels.remove(fLabels.size() - 1);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.LineComment)
+ */
+ public boolean visit(LineComment node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MarkerAnnotation)
+ */
+ public boolean visit(MarkerAnnotation node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MemberRef)
+ */
+ public boolean visit(MemberRef node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MemberValuePair)
+ */
+ public boolean visit(MemberValuePair node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MethodDeclaration)
+ */
+ public boolean visit(MethodDeclaration node) {
+ if (visit(node, false)) {
+ if (fBestMatch) {
+ // check if we are on the line which contains the method name
+ int nameOffset= node.getName().getStartPosition();
+ if (lineNumber(nameOffset) == fLineNumber) {
+ fMemberOffset= nameOffset;
+ fLocationType= LOCATION_METHOD;
+ fLocationFound= true;
+ return false;
+ }
+ }
+ // visit only the body
+ Block body = node.getBody();
+ if (body != null) { // body is null for abstract methods
+ body.accept(this);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MethodInvocation)
+ */
+ public boolean visit(MethodInvocation node) {
+ return visit(node, true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MethodRef)
+ */
+ public boolean visit(MethodRef node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MethodRefParameter)
+ */
+ public boolean visit(MethodRefParameter node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.Modifier)
+ */
+ public boolean visit(Modifier node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.NormalAnnotation)
+ */
+ public boolean visit(NormalAnnotation node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.NullLiteral)
+ */
+ public boolean visit(NullLiteral node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.NumberLiteral)
+ */
+ public boolean visit(NumberLiteral node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.PackageDeclaration)
+ */
+ public boolean visit(PackageDeclaration node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ParameterizedType)
+ */
+ public boolean visit(ParameterizedType node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ParenthesizedExpression)
+ */
+ public boolean visit(ParenthesizedExpression node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.PostfixExpression)
+ */
+ public boolean visit(PostfixExpression node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.PrefixExpression)
+ */
+ public boolean visit(PrefixExpression node) {
+ if (visit(node, false)) {
+ if (isReplacedByConstantValue(node)) {
+ fLineLocation= lineNumber(node.getStartPosition());
+ fLocationFound= true;
+ fLocationType= LOCATION_LINE;
+ fTypeName= computeTypeName(node);
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.PrimitiveType)
+ */
+ public boolean visit(PrimitiveType node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.QualifiedName)
+ */
+ public boolean visit(QualifiedName node) {
+ visit(node, true);
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.QualifiedType)
+ */
+ public boolean visit(QualifiedType node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ReturnStatement)
+ */
+ public boolean visit(ReturnStatement node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SimpleName)
+ */
+ public boolean visit(SimpleName node) {
+ // the name is only code if its not the current label (if any)
+ return visit(node, !node.getFullyQualifiedName().equals(getLabel()));
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SimpleType)
+ */
+ public boolean visit(SimpleType node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SingleMemberAnnotation)
+ */
+ public boolean visit(SingleMemberAnnotation node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SingleVariableDeclaration)
+ */
+ public boolean visit(SingleVariableDeclaration node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.StringLiteral)
+ */
+ public boolean visit(StringLiteral node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperConstructorInvocation)
+ */
+ public boolean visit(SuperConstructorInvocation node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperFieldAccess)
+ */
+ public boolean visit(SuperFieldAccess node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperMethodInvocation)
+ */
+ public boolean visit(SuperMethodInvocation node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SwitchCase)
+ */
+ public boolean visit(SwitchCase node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SwitchStatement)
+ */
+ public boolean visit(SwitchStatement node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SynchronizedStatement)
+ */
+ public boolean visit(SynchronizedStatement node) {
+ return visit(node, false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TagElement)
+ */
+ public boolean visit(TagElement node) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TextElement)
+ */
+ public boolean visit(TextElement node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ThisExpression)
+ */
+ public boolean visit(ThisExpression node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ThrowStatement)
+ */
+ public boolean visit(ThrowStatement node) {
+ return visit(node, true);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TryStatement)
+ */
+ public boolean visit(TryStatement node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TypeDeclaration)
+ */
+ public boolean visit(TypeDeclaration node) {
+ if (visit(node, false)) {
+ // visit only the elements of the type declaration
+ List bodyDeclaration= node.bodyDeclarations();
+ for (Iterator iter= bodyDeclaration.iterator(); iter.hasNext();) {
+ ((BodyDeclaration)iter.next()).accept(this);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TypeDeclarationStatement)
+ */
+ public boolean visit(TypeDeclarationStatement node) {
+ return visit(node, false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TypeParameter)
+ */
+ public boolean visit(TypeParameter node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TypeLiteral)
+ */
+ public boolean visit(TypeLiteral node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.VariableDeclarationExpression)
+ */
+ public boolean visit(VariableDeclarationExpression node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.VariableDeclarationFragment)
+ */
+ public boolean visit(VariableDeclarationFragment node) {
+ Expression initializer = node.getInitializer();
+ if (visit(node, false) && initializer != null) {
+ int startLine = lineNumber(node.getName().getStartPosition());
+
+ if (fLineNumber == startLine) {
+ fLineLocation= startLine;
+ fLocationFound= true;
+ fLocationType= LOCATION_LINE;
+ fTypeName= computeTypeName(node);
+ return false;
+ }
+ initializer.accept(this);
+ }
+ return false;
+ }
+
+ private int lineNumber(int offset) {
+ int lineNumber = fCompilationUnit.getLineNumber(offset);
+ return lineNumber < 1 ? 1 : lineNumber;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.WildcardType)
+ */
+ public boolean visit(WildcardType node) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.VariableDeclarationStatement)
+ */
+ public boolean visit(VariableDeclarationStatement node) {
+ return visit(node, false);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.WhileStatement)
+ */
+ public boolean visit(WhileStatement node) {
+ return visit(node, false);
+ }
+
+//{ObjectTeams: visit also ot-specific nodes or skip some
+
+ public boolean visit(GuardPredicateDeclaration node) {
+ // visit only the expression (don't want a method-entry breakpoint but stop directly at the expression).
+ ASTNode expression = node.getExpression();
+ expression.accept(this);
+ return false;
+ }
+
+ public boolean visit(CallinMappingDeclaration node)
+ {
+ return visit(node, false);
+ }
+
+ public boolean visit(CalloutMappingDeclaration node)
+ {
+ return visit(node, false);
+ }
+
+ public boolean visit(FieldAccessSpec node)
+ {
+ return visit(node, false);
+ }
+
+ public boolean visit(LiftingType node)
+ {
+ return false;
+ }
+
+ public boolean visit(TypeAnchor node)
+ {
+ return false;
+ }
+
+ public boolean visit(MethodSpec node)
+ {
+ return visit(node, false);
+ }
+
+ public boolean visit(ParameterMapping node)
+ {
+ return false;
+ }
+
+ public boolean visit(RoleTypeDeclaration node)
+ {
+ if (visit(node, false)) {
+ // guards first: appear before body declarations:
+ GuardPredicateDeclaration guard = node.getGuardPredicate();
+ if (guard != null)
+ guard.accept(this);
+ // visit only the elements of the type declaration
+ List bodyDeclaration= node.bodyDeclarations();
+ for (Iterator iter= bodyDeclaration.iterator(); iter.hasNext();) {
+ ((BodyDeclaration)iter.next()).accept(this);
+ }
+ }
+ return false;
+ }
+
+ public boolean visit(WithinStatement node)
+ {
+ return visit(node, false);
+ }
+//ike}
+}
+//ike}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/SortTeamAction.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/SortTeamAction.java
new file mode 100644
index 0000000..f91a469
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/SortTeamAction.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 and 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: SortTeamAction.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.objectteams.otdt.debug.IOTDTDebugPreferenceConstants;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugImages;
+import org.eclipse.objectteams.otdt.debug.ui.views.TeamView;
+import org.eclipse.objectteams.otdt.debug.ui.views.TeamViewMessages;
+
+/**
+ * @author ike
+ * This Action sorts the teams in TeamMonitor.
+ *
+ * $Id: SortTeamAction.java 23432 2010-02-03 23:13:42Z stephan $
+ */
+public class SortTeamAction extends Action
+{
+ private TeamView _teamView;
+ private String _sortMode;
+
+ public SortTeamAction(TeamView teamView, String sortMode)
+ {
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+
+ if (sortMode == IOTDTDebugPreferenceConstants.TEAMS_BY_ACTIVATION_TIME)
+ {
+ setText(TeamViewMessages.SortTeamByActivation_0);
+ setImageDescriptor(OTDebugImages.get(OTDebugImages.SORT_TEAMS_BY_ACTIVATION_TIME));
+ }
+
+ if (sortMode == IOTDTDebugPreferenceConstants.TEAMS_BY_ACTIVATION_ORDER)
+ {
+ setText(TeamViewMessages.SortTeamByActivation_1);
+ setImageDescriptor(OTDebugImages.get(OTDebugImages.SORT_TEAMS_BY_ACTIVATION_ORDER));
+ }
+
+ if (sortMode == IOTDTDebugPreferenceConstants.TEAMS_BY_INSTANTIATION)
+ {
+ setText(TeamViewMessages.SortTeamByInstantiation_0);
+ setImageDescriptor(OTDebugImages.get(OTDebugImages.SORT_TEAMS_BY_INSTANTIATION));
+ }
+
+ if (sortMode == IOTDTDebugPreferenceConstants.TEAMS_BY_NAME)
+ {
+ setText(TeamViewMessages.SortTeamByName_0);
+ setImageDescriptor(OTDebugImages.get(OTDebugImages.SORT_TEAMS_BY_NAME));
+ }
+
+ _teamView = teamView;
+ _sortMode = sortMode;
+ setChecked(sortMode == _teamView.getDefaultSortMode());
+ }
+
+ public void run()
+ {
+ if (isChecked())
+ {
+ _teamView.setSortMode(getSortMode());
+ OTDebugElementsContainer container = (OTDebugElementsContainer)_teamView.getViewer().getInput();
+ container.setSortMode(getSortMode());
+ _teamView.getViewer().setInput(container);
+ }
+ }
+
+ private String getSortMode()
+ {
+ return _sortMode;
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/UpdateTeamViewAction.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/UpdateTeamViewAction.java
new file mode 100644
index 0000000..0eb143c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/actions/UpdateTeamViewAction.java
@@ -0,0 +1,51 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: UpdateTeamViewAction.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugImages;
+import org.eclipse.objectteams.otdt.debug.ui.views.TeamView;
+
+public class UpdateTeamViewAction extends Action
+{
+ private TeamView _teamView;
+
+ public UpdateTeamViewAction(TeamView teamView)
+ {
+ super("", AS_CHECK_BOX);
+ setToolTipText("Permanently update Team Monitor");
+ setDescription("Shows teams and their activation state while the application is running.");
+ setImageDescriptor(OTDebugImages.get(OTDebugImages.UPDATE_TEAM_VIEW_ACTION));
+ _teamView = teamView;
+ }
+
+ @Override
+ public void run()
+ {
+ _teamView.setUpdatePermanently(isChecked());
+ OTDebugElementsContainer container = (OTDebugElementsContainer)_teamView.getViewer().getInput();
+ if(isChecked())
+ {
+ _teamView.getViewer().setInput(container);
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDebugElementsContainerContentProvider.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDebugElementsContainerContentProvider.java
new file mode 100644
index 0000000..827ca92
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDebugElementsContainerContentProvider.java
@@ -0,0 +1,78 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDebugElementsContainerContentProvider.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+
+/**
+ * Provide top level nodes for the TeamView:
+ * + team instances from an OTDebugElementsContainer
+ *
+ * @author stephan
+ * @since 1.1.2
+ */
+public class OTDebugElementsContainerContentProvider extends ElementContentProvider
+{
+
+ @Override
+ protected int getChildCount(Object element,
+ IPresentationContext context,
+ IViewerUpdate monitor)
+ throws CoreException
+ {
+ OTDebugElementsContainer container = (OTDebugElementsContainer) element;
+ return container.getChildCount();
+ }
+
+ @Override
+ protected Object[] getChildren(Object parent,
+ int index,
+ int length,
+ IPresentationContext context,
+ IViewerUpdate monitor)
+ throws CoreException
+ {
+ OTDebugElementsContainer container = (OTDebugElementsContainer) parent;
+ if(container.hasTeamInstances())
+ {
+ ArrayList<TeamInstance> teamInstances = container.getTeamInstances();
+ Object[] result= new Object[length];
+ for (int i=0; i<length; i++)
+ result[i]= teamInstances.get(index+i);
+ return result;
+ }
+ return null;
+
+ }
+
+ @Override
+ protected boolean supportsContextId(String id) {
+ return id.equals(OTDebugUIPlugin.TEAM_VIEW_ID);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDebugElementsContainerLabelProvider.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDebugElementsContainerLabelProvider.java
new file mode 100644
index 0000000..c9b63ed
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDebugElementsContainerLabelProvider.java
@@ -0,0 +1,40 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDebugElementsContainerLabelProvider.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.model;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jface.viewers.TreePath;
+
+/** Label for the root node of the TeamView (which does not have a label). */
+public class OTDebugElementsContainerLabelProvider extends ElementLabelProvider {
+
+ @Override
+ protected String getLabel(TreePath elementPath,
+ IPresentationContext presentationContext,
+ String columnId)
+ throws CoreException
+ {
+ return "never-seen-OTDebugLabel"; //$NON-NLS-1$
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDefaultModelProxyFactory.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDefaultModelProxyFactory.java
new file mode 100644
index 0000000..9e825ab
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDefaultModelProxyFactory.java
@@ -0,0 +1,48 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDefaultModelProxyFactory.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.model;
+
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.update.DefaultModelProxyFactory;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+
+/**
+ * Install OTDefaultVariableViewModelProxy.
+ *
+ * @author stephan
+ * @since 1.1.2
+ */
+public class OTDefaultModelProxyFactory extends DefaultModelProxyFactory
+{
+ @Override
+ public IModelProxy createModelProxy(Object element, IPresentationContext context)
+ {
+ String id= context.getId();
+ if (OTDebugUIPlugin.TEAM_VIEW_ID.equals(id)) {
+ if (element instanceof OTDebugElementsContainer)
+ return new OTDefaultVariableViewModelProxy((OTDebugElementsContainer)element);
+ }
+ return super.createModelProxy(element, context);
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDefaultVariableViewModelProxy.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDefaultVariableViewModelProxy.java
new file mode 100644
index 0000000..04584b4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTDefaultVariableViewModelProxy.java
@@ -0,0 +1,90 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDefaultVariableViewModelProxy.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.model;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
+import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
+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;
+
+/**
+ * This class mediates between the model and its view:
+ *
+ * + Receive triggers from TeamBreakpointListener (via IOTDebugEventListener)
+ * + Create and fire ModelDelta events (received by TreeModelContentProvider)
+ *
+ * Installation:
+ * + TreeModelContentProvider.inputChanged()->installModelProxy()
+ * -> makes TreeModelContentProvider an fListener (modelChangedListener) of this
+ *
+ *
+ * @author stephan
+ * @since 1.1.2
+ */
+public class OTDefaultVariableViewModelProxy
+ extends AbstractModelProxy
+ implements IOTDebugEventListener
+{
+
+ private OTDebugElementsContainer container;
+
+ public OTDefaultVariableViewModelProxy(OTDebugElementsContainer debugElementsContainer) {
+ super();
+ this.container= debugElementsContainer;
+ OTDebugPlugin.getDefault().addOTDebugEventListener(this);
+ }
+
+ public void launched(ILaunch launch) {
+ // TODO Auto-generated method stub
+ }
+
+ public void teamInstantiated(TeamInstance newTeam)
+ {
+ int idx= container.getIndexOfTeamInstance(newTeam);
+ ModelDelta delta= new ModelDelta(container, IModelDelta.NO_CHANGE);
+ delta.addNode(newTeam, idx, IModelDelta.INSERTED);
+ fireModelChanged(delta);
+ }
+
+ public void teamDisposed(int idx) {
+ ModelDelta delta= new ModelDelta(container, IModelDelta.NO_CHANGE);
+ delta.addNode(null, idx, IModelDelta.REMOVED);
+ fireModelChanged(delta);
+ }
+
+ public void activationStateChanged(TeamInstance teamInstance)
+ {
+ int idx= container.getIndexOfTeamInstance(teamInstance);
+ ModelDelta delta= new ModelDelta(container, IModelDelta.NO_CHANGE);
+ delta.addNode(teamInstance, idx, IModelDelta.STATE);
+ fireModelChanged(delta);
+ }
+
+ @Override
+ public synchronized void dispose() {
+ super.dispose();
+ OTDebugPlugin.getDefault().removeOTDebugEventListener(this);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTVariableColumnFactoryAdapter.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTVariableColumnFactoryAdapter.java
new file mode 100644
index 0000000..bca3f62
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/OTVariableColumnFactoryAdapter.java
@@ -0,0 +1,64 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTVariableColumnFactoryAdapter.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.model;
+
+import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+
+/**
+ * Factory for default variable column presentation.
+ * (from VariableColumnFactoryAdaptor (since 3.2))
+ *
+ * @since 1.1.2
+ */
+public class OTVariableColumnFactoryAdapter implements IColumnPresentationFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.provisional.IColumnPresenetationFactoryAdapter#createColumnPresentation(org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.Object)
+ */
+ public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {
+ String id = context.getId();
+ if (OTDebugUIPlugin.TEAM_VIEW_ID.equals(id)) {
+ if (element instanceof OTDebugElementsContainer) {
+ return new VariableColumnPresentation();
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.provisional.IColumnPresenetationFactoryAdapter#getColumnPresentationId(org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.Object)
+ */
+ public String getColumnPresentationId(IPresentationContext context, Object element) {
+ String id = context.getId();
+ if (OTDebugUIPlugin.TEAM_VIEW_ID.equals(id)) {
+ if (element instanceof OTDebugElementsContainer) {
+ return VariableColumnPresentation.DEFAULT_VARIABLE_COLUMN_PRESENTATION;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/TeamInstanceContentProvider.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/TeamInstanceContentProvider.java
new file mode 100644
index 0000000..3892b29
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/TeamInstanceContentProvider.java
@@ -0,0 +1,41 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: TeamInstanceContentProvider.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.model;
+
+import org.eclipse.debug.internal.ui.model.elements.VariableContentProvider;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+
+/**
+ * Content provider for the fields of a team instance.
+ * Sole purpose compared to its superclass: make it applicable to the TeamView, too.
+ *
+ * Note, that filtering takes place within the debug.adaptor.VariablesViewAdaptor.
+ *
+ * @author stephan
+ * @since 1.1.2
+ */
+public class TeamInstanceContentProvider extends VariableContentProvider
+{
+ @Override
+ protected boolean supportsContextId(String id) {
+ return id.equals(OTDebugUIPlugin.TEAM_VIEW_ID);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/TeamInstanceLabelProvider.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/TeamInstanceLabelProvider.java
new file mode 100644
index 0000000..befa3b3
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/model/TeamInstanceLabelProvider.java
@@ -0,0 +1,99 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: TeamInstanceLabelProvider.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.model;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation;
+import org.eclipse.debug.internal.ui.model.elements.VariableLabelProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.TeamInstance;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugImages;
+
+/**
+ * Labels (text/image) for team instances in the TeamView.
+ *
+ * @author stephan
+ * @since 1.1.2
+ */
+public class TeamInstanceLabelProvider extends VariableLabelProvider
+{
+ @Override
+ protected String getLabel(TreePath elementPath, IPresentationContext context, String columnId)
+ throws CoreException
+ {
+//{ObjecgtTeams: new implementation, re-using only getColumnText():
+ Object element = elementPath.getLastSegment();
+ if (element instanceof TeamInstance) {
+ IVariable variable= (IVariable) element;
+ if (isNameColumn(columnId))
+ return variable.getReferenceTypeName();
+ else
+ return getColumnText(variable, variable.getValue(), context, columnId);
+ }
+ return "<unknown element>"; //$NON-NLS-1$ // should never be seen
+// SH}
+ }
+ @Override
+ protected ImageDescriptor getImageDescriptor(
+ TreePath elementPath, IPresentationContext presentationContext, String columnId)
+ throws CoreException
+ {
+ // completely new implementation for the OTDT:
+ if (isNameColumn(columnId)) {
+ TeamInstance teamInstance = (TeamInstance) elementPath.getLastSegment();
+ OTDebugElementsContainer _otDebugElementsContainer = (OTDebugElementsContainer) teamInstance.getLaunch().getAdapter(OTDebugElementsContainer.class);
+
+ if (_otDebugElementsContainer != null && _otDebugElementsContainer.getTeamInstance(teamInstance) != null)
+ {
+ int activationState = teamInstance.getActivationState(_otDebugElementsContainer.getContext());
+ return getImageForState(activationState);
+ }
+
+ //DefaultImage for Teams is inactive-Image
+ return getImageForState(0);
+ }
+ return null;
+ }
+
+ private boolean isNameColumn(String columnId) {
+ return columnId == null
+ || VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals(columnId);
+ }
+
+ private ImageDescriptor getImageForState(int activationState)
+ {
+ switch (activationState)
+ {
+ case TeamInstance.IS_INACTIVE:
+ return OTDebugImages.get(OTDebugImages.TEAM_INACTIVATED);
+ case TeamInstance.IS_IMPLICITACTIVE:
+ return OTDebugImages.get(OTDebugImages.TEAM_IMPLICIT_ACTIVATED);
+ case TeamInstance.IS_ACTIVE:
+ return OTDebugImages.get(OTDebugImages.TEAM_ACTIVATED);
+ default:
+ return OTDebugImages.get(OTDebugImages.TEAM_INACTIVATED);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencePage.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencePage.java
new file mode 100644
index 0000000..654d6fe
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencePage.java
@@ -0,0 +1,214 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDebugPreferencePage.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.preferences;
+
+import static org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences.CALLIN_STEPPING_TOKENS;
+import static org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences.DEBUG_CALLIN_STEPPING;
+import static org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences.DEBUG_FILTERS_ENABLED_BOOL;
+import static org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences.OT_GENERATED_CODE_COLOR;
+import static org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences.OT_SPECIAL_CODE_COLOR;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.debug.internal.ui.SWTFactory;
+import org.eclipse.debug.internal.ui.preferences.BooleanFieldEditor2;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.ColorFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.preference.PreferenceNode;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+import org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.internal.Workbench;
+
+/**
+ * @author gis, stephan
+ */
+public class OTDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
+{
+ private static final String JAVA_STEP_FILTER_PREFERENCE_PAGE = "org.eclipse.jdt.debug.ui.JavaStepFilterPreferencePage"; //$NON-NLS-1$
+
+ protected boolean _debugFiltersEnabled;
+
+ private Composite _parentComposite;
+ private ColorFieldEditor fGeneratedCodeColorFieldEditor;
+ private ColorFieldEditor fSpecialCodeColorFieldEditor;
+ private BooleanFieldEditor2 fDebugFilter;
+ /** sync with {@link OTDebugPreferences#CALLIN_STEPPING_TOKENS}: */
+ private String[] callinLabels = {OTDebugPreferencesMessages.OTDebugPreferencePage_callin_step_role_label,
+ OTDebugPreferencesMessages.OTDebugPreferencePage_callin_step_recurse_label,
+ OTDebugPreferencesMessages.OTDebugPreferencePage_callin_step_base_label};
+
+ public OTDebugPreferencePage()
+ {
+ super(GRID);
+ setTitle(OTDebugPreferencesMessages.OTDebugPreferencePage_title);
+ }
+
+ public void createControl(Composite parent)
+ {
+ super.createControl(parent);
+ _parentComposite = parent;
+ }
+
+ protected IPreferenceStore doGetPreferenceStore()
+ {
+ return OTDebugUIPlugin.getDefault().getPreferenceStore();
+ }
+
+ protected void createFieldEditors()
+ {
+ // container group:
+ Composite groupAll= new Composite(getFieldEditorParent(), SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth= 0;
+ layout.verticalSpacing= convertVerticalDLUsToPixels(10);
+ layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ groupAll.setLayout(layout);
+
+ // block 1 group: stack frame filtering:
+ Group group = new Group(groupAll, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setText(OTDebugPreferencesMessages.OTDebugPreferencePage_enable_filter_title);
+
+ fDebugFilter = new BooleanFieldEditor2(DEBUG_FILTERS_ENABLED_BOOL,
+ OTDebugPreferencesMessages.OTDebugPreferencePage_enableFilter_label,
+ SWT.NONE, group);
+ addField(fDebugFilter);
+ fDebugFilter.getChangeControl(groupAll).addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) { }
+ public void widgetSelected(SelectionEvent e) {
+ setDebugFiltersEnabled(fDebugFilter.getBooleanValue());
+ }
+ });
+
+ // block 2 group: stack frame coloring:
+ group = new Group(groupAll, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setText(OTDebugPreferencesMessages.OTDebugPreferencePage_stackFrameColoringGroup_label);
+
+ Composite spacer = SWTFactory.createComposite(group, 2, 1, GridData.FILL_HORIZONTAL);
+ fGeneratedCodeColorFieldEditor = new ColorFieldEditor(OT_GENERATED_CODE_COLOR,
+ OTDebugPreferencesMessages.OTDebugPreferencePage_colorGeneratedCode_label,
+ spacer);
+ fGeneratedCodeColorFieldEditor.fillIntoGrid(spacer, 2);
+ addField(fGeneratedCodeColorFieldEditor);
+
+ fSpecialCodeColorFieldEditor = new ColorFieldEditor(OT_SPECIAL_CODE_COLOR,
+ OTDebugPreferencesMessages.OTDebugPreferencePage_colorSpecialCode_label,
+ spacer);
+ fSpecialCodeColorFieldEditor.fillIntoGrid(spacer, 2);
+ addField(fSpecialCodeColorFieldEditor);
+
+ // block 3 group: callin dispatch visualization:
+ group = new Group(groupAll, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setText(OTDebugPreferencesMessages.OTDebugPreferencePage_callin_stepping_title);
+
+ for (int i=0; i<CALLIN_STEPPING_TOKENS.length; i++) {
+ final String token = CALLIN_STEPPING_TOKENS[i];
+ final BooleanFieldEditor2 editor = new BooleanFieldEditor2(DEBUG_CALLIN_STEPPING+token,
+ this.callinLabels[i],
+ SWT.NONE, group);
+ addField(editor);
+ editor.getChangeControl(group).addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) { }
+ public void widgetSelected(SelectionEvent e) {
+ OTDebugPreferences.setCallinStepping(token, editor.getBooleanValue());
+ }
+ });
+ }
+ Label description= new Label(group, SWT.LEFT | SWT.WRAP);
+ Font font = description.getFont();
+ FontData[] data = font.getFontData();
+ data[0].setStyle(SWT.ITALIC);
+ description.setFont(new Font(font.getDevice(), data[0]));
+ description.setText(OTDebugPreferencesMessages.OTDebugPreferencePage_callin_stepping_hint);
+ description.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false, 0, 1));
+
+ }
+
+ protected void performDefaults()
+ {
+ OTDebugPreferences.propagateFilterFlag(getPreferenceStore());
+ super.performDefaults();
+ }
+
+ /////////////// HACK synchronizing with JDT Debug step filter configuration
+
+ private void setDebugFiltersEnabled(boolean enable)
+ {
+ if (_debugFiltersEnabled == enable)
+ return;
+
+ _debugFiltersEnabled = enable;
+
+ OTDebugPreferences.setUseOTStepFilters(enable);
+ updateStepFilteringPrefPage();
+ }
+
+ private void updateStepFilteringPrefPage()
+ {
+ List prefs = Workbench.getInstance().getPreferenceManager().getElements(PreferenceManager.PRE_ORDER);
+ for (Iterator iter = prefs.iterator(); iter.hasNext();)
+ {
+ PreferenceNode node = (PreferenceNode) iter.next();
+ if(node.getId().indexOf(JAVA_STEP_FILTER_PREFERENCE_PAGE) != -1)
+ {
+ forcePreferencePageRecreation(node);
+ }
+ }
+ }
+
+ private void forcePreferencePageRecreation(PreferenceNode node)
+ {
+ IPreferencePage oldPage = node.getPage();
+ if (oldPage != null)
+ {
+ node.setPage(null);
+ node.createPage();
+ node.getPage().createControl(_parentComposite);
+
+ oldPage.dispose();
+ }
+ }
+
+ public void init(IWorkbench workbench) { }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferences.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferences.java
new file mode 100644
index 0000000..542a34b
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferences.java
@@ -0,0 +1,160 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: OTDebugPreferences.java 23435 2010-02-04 00:14:38Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.debug.internal.core.StepFilterManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.internal.debug.ui.JavaDebugOptionsManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * @author gis
+ */
+public class OTDebugPreferences extends AbstractPreferenceInitializer {
+
+ // preference keys:
+ public final static String OT_GENERATED_CODE_COLOR = "org.eclipse.objectteams.otdt.debug.ui.OtGeneratedCodeColor"; //$NON-NLS-1$
+ public final static String OT_SPECIAL_CODE_COLOR = "org.eclipse.objectteams.otdt.debug.ui.OtSpecialCodeColor"; //$NON-NLS-1$
+ public static final String DEBUG_FILTERS_ENABLED_BOOL = "prefs.ot.debugfilters.enabled"; //$NON-NLS-1$
+
+ // key is the first constant plugs one of the tokens:
+ public static final String DEBUG_CALLIN_STEPPING = "org.eclipse.objectteams.otdt.debug.ui.OtCallinStepping."; // need to append token //$NON-NLS-1$
+ public static final String[] CALLIN_STEPPING_TOKENS = {"role", "recurse", "orig"}; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ // special value:
+ public static final String CALLIN_STEPPING_NONE = "none"; //$NON-NLS-1$
+
+ public static final String[] STEP_FILTER_PACKAGES =
+ {
+ "de.fub.bytecode.*", //$NON-NLS-1$
+ "gnu.regexp.*", //$NON-NLS-1$
+ "org.eclipse.objectteams.otre", //$NON-NLS-1$
+ "org.eclipse.objectteams.otre.jplis", //$NON-NLS-1$
+ "org.eclipse.objectteams.otre.util" //$NON-NLS-1$
+ };
+
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore prefs = OTDebugUIPlugin.getDefault().getPreferenceStore();
+
+ PreferenceConverter.setDefault(prefs, OTDebugPreferences.OT_GENERATED_CODE_COLOR, new RGB(182, 182, 209));
+ PreferenceConverter.setDefault(prefs, OTDebugPreferences.OT_SPECIAL_CODE_COLOR, new RGB(24, 152, 16));
+
+ prefs.setDefault(OTDebugPreferences.DEBUG_FILTERS_ENABLED_BOOL, true);
+
+ for (String token : CALLIN_STEPPING_TOKENS)
+ prefs.setDefault(OTDebugPreferences.DEBUG_CALLIN_STEPPING+token, true);
+ }
+
+ public static void propagateFilterFlag(IPreferenceStore prefs)
+ {
+ setUseOTStepFilters(prefs.getBoolean(DEBUG_FILTERS_ENABLED_BOOL));
+ }
+
+ public static void setUseOTStepFilters(boolean enable)
+ {
+ IPreferenceStore jdiDebugStore = JDIDebugUIPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore debugUIStore = DebugUIPlugin.getDefault().getPreferenceStore();
+
+ String stepFilterPackages = jdiDebugStore.getString(IJDIPreferencesConstants.PREF_ACTIVE_FILTERS_LIST);
+ String newStepFilterPackages;
+ if (enable)
+ {
+ newStepFilterPackages = addOTStepFilters(stepFilterPackages);
+ }
+ else
+ {
+ newStepFilterPackages = removeOTStepFilters(stepFilterPackages);
+ }
+
+ debugUIStore.setValue(StepFilterManager.PREF_USE_STEP_FILTERS, enable);
+ jdiDebugStore.setValue(IJDIPreferencesConstants.PREF_ACTIVE_FILTERS_LIST, newStepFilterPackages);
+ jdiDebugStore.setValue(IJDIPreferencesConstants.PREF_FILTER_SYNTHETICS, enable);
+ }
+
+ private static String addOTStepFilters(String values)
+ {
+ List result = new ArrayList();
+ String[] origEntries = JavaDebugOptionsManager.parseList(values);
+ for (int i = 0; i < origEntries.length; i++)
+ result.add(origEntries[i]);
+
+ String[] entriesToAdd = OTDebugPreferences.STEP_FILTER_PACKAGES;
+
+ for (int i = 0; i < entriesToAdd.length; i++)
+ {
+ String entryToAdd = entriesToAdd[i];
+ if (!result.contains(entryToAdd))
+ result.add(entryToAdd);
+ }
+
+ return JavaDebugOptionsManager.serializeList((String[])result.toArray(new String[result.size()]));
+ }
+
+ private static String removeOTStepFilters(String values)
+ {
+ String[] entriesToRemove = OTDebugPreferences.STEP_FILTER_PACKAGES;
+ Arrays.sort(entriesToRemove);
+ String[] orig = JavaDebugOptionsManager.parseList(values);
+ List result = new ArrayList(entriesToRemove.length);
+
+ for (int i = 0; i < orig.length; i++)
+ {
+ String origValue = orig[i];
+ if (Arrays.binarySearch(entriesToRemove, origValue) < 0)
+ result.add(origValue);
+ }
+
+ return JavaDebugOptionsManager.serializeList((String[])result.toArray(new String[result.size()]));
+ }
+ /** Propagate callin stepping configuration down to the org.eclipse.objectteams.otdt.debug plugin. */
+ public static void setCallinStepping(String token, boolean value) {
+ IPreferenceStore prefs = OTDebugUIPlugin.getDefault().getPreferenceStore();
+ prefs.setValue(DEBUG_CALLIN_STEPPING+token, value);
+ OTDebugPlugin.getDefault().setCallinSteppingConfig(getCallinSteppingString());
+ }
+
+ public static String getCallinSteppingString() {
+ IPreferenceStore prefs = OTDebugUIPlugin.getDefault().getPreferenceStore();
+ String callinStepping = null;
+ for (String token : CALLIN_STEPPING_TOKENS) {
+ if (prefs.getBoolean(DEBUG_CALLIN_STEPPING+token)) {
+ if (callinStepping == null)
+ callinStepping = token;
+ else
+ callinStepping = callinStepping + ',' +token;
+ }
+ }
+ if (callinStepping == null)
+ callinStepping = CALLIN_STEPPING_NONE;
+ return callinStepping;
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencesMessages.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencesMessages.java
new file mode 100644
index 0000000..69530f0
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencesMessages.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 and 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: OTDebugPreferencesMessages.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.internal.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public class OTDebugPreferencesMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferencesMessages"; //$NON-NLS-1$
+ public static String OTDebugPreferencePage_title;
+ public static String OTDebugPreferencePage_enable_filter_title;
+ public static String OTDebugPreferencePage_enableFilter_label;
+ public static String OTDebugPreferencePage_stackFrameColoringGroup_label;
+ public static String OTDebugPreferencePage_colorGeneratedCode_label;
+ public static String OTDebugPreferencePage_colorSpecialCode_label;
+ public static String OTDebugPreferencePage_callin_stepping_title;
+ public static String OTDebugPreferencePage_callin_step_base_label;
+ public static String OTDebugPreferencePage_callin_step_recurse_label;
+ public static String OTDebugPreferencePage_callin_step_role_label;
+ public static String OTDebugPreferencePage_callin_stepping_hint;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, OTDebugPreferencesMessages.class);
+ }
+
+ private OTDebugPreferencesMessages() {
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencesMessages.properties b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencesMessages.properties
new file mode 100644
index 0000000..fa738c5
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/internal/preferences/OTDebugPreferencesMessages.properties
@@ -0,0 +1,11 @@
+OTDebugPreferencePage_title=Debug
+OTDebugPreferencePage_enable_filter_title=Stack frame filtering
+OTDebugPreferencePage_enableFilter_label=Hide stack frames of the Object Teams Runtime Environment
+OTDebugPreferencePage_stackFrameColoringGroup_label=Displaying OT/J-specific stack frames
+OTDebugPreferencePage_colorGeneratedCode_label=generated code
+OTDebugPreferencePage_colorSpecialCode_label=special OT/J code (method bindings etc.)
+OTDebugPreferencePage_callin_stepping_title=Visualization of callin dispatch
+OTDebugPreferencePage_callin_step_base_label=Show pending dispatch to original base method
+OTDebugPreferencePage_callin_step_recurse_label=Show pending recursive dispatch
+OTDebugPreferencePage_callin_step_role_label=Show pending dispatch to callin binding
+OTDebugPreferencePage_callin_stepping_hint=Unchecked steps will be skipped, the debugger will automatically step into the next action.
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamView.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamView.java
new file mode 100644
index 0000000..22c95a4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamView.java
@@ -0,0 +1,286 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: TeamView.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ * IBM Corporation - copies of individual methods from super class.
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.views;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
+import org.eclipse.debug.internal.ui.views.variables.VariablesView;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.objectteams.otdt.debug.IOTDTDebugPreferenceConstants;
+import org.eclipse.objectteams.otdt.debug.OTDebugElementsContainer;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+import org.eclipse.objectteams.otdt.debug.ui.internal.actions.ChangeTeamActivationAction;
+import org.eclipse.objectteams.otdt.debug.ui.internal.actions.SortTeamAction;
+import org.eclipse.objectteams.otdt.debug.ui.internal.actions.UpdateTeamViewAction;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IActionBars;
+
+/**
+ * The TeamView aka "Team Monitor" for observing instantiation
+ * and (de)activation of teams.
+ *
+ * This class was originally developed against Eclipse <= 3.2.
+ * For changes in VariablesView see
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=153500
+ *
+ * @author gis
+ *
+ * $Id: TeamView.java 23432 2010-02-03 23:13:42Z stephan $
+ */
+public class TeamView extends VariablesView implements ILaunchesListener2
+{
+ private static final String ACTION_ACTIVATE_TEAM = "ActivateTeam"; //$NON-NLS-1$
+ private static final String ACTION_DEACTIVATE_TEAM = "DeactivateTeam"; //$NON-NLS-1$
+ private static final String ACTION_UPDATE_TEAMVIEW = "action.update.teamview"; //$NON-NLS-1$
+ private String _sortMode;
+ private boolean _updatePermantently = false;
+
+ private static boolean DEBUG= false;
+
+ public TeamView()
+ {
+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
+ _sortMode = getDefaultSortMode();
+ }
+
+ @Override
+ protected String getPresentationContextId() {
+ return OTDebugUIPlugin.TEAM_VIEW_ID;
+ }
+
+ public String getDefaultSortMode()
+ {
+ return IOTDTDebugPreferenceConstants.TEAMS_BY_ACTIVATION_ORDER;
+ }
+
+ @Override // COPY_AND_PASTE from super, edited:
+ public void contextActivated(ISelection selection)
+ {
+ if (DEBUG) System.out.println("TV: contextActivated: "+selection); //$NON-NLS-1$
+
+ if (!isAvailable() || !isVisible()) {
+ return;
+ }
+
+ if (selection instanceof IStructuredSelection) {
+//ObjectTeams: if there are multiselected DebugElements - show nothing
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ if(structuredSelection.size() == 1)
+ // orig:
+ setViewerInput(structuredSelection.getFirstElement());
+ // :giro
+ else
+ setViewerInput(null);
+// carp+SH}
+ }
+ showViewer();
+
+ updateAction(VARIABLES_FIND_ELEMENT_ACTION);
+ updateAction(FIND_ACTION);
+ }
+
+ @Override // COPY_AND_PASTE from super, edited:
+ protected void setViewerInput(Object context)
+ {
+ if (DEBUG) System.out.println("TV: setViewerInput: "+context); //$NON-NLS-1$
+
+//{ObjectTeams
+ if(!isSuspended(context) && !_updatePermantently)
+ return;
+// SH}
+
+ if (context == null) {
+ // Clear the detail pane
+//{ObjectTeams: workaround invisible field fDetailPane:
+ /* orig:
+ fDetailPane.display(null);
+ :giro */
+ refreshDetailPaneContents();
+// SH}
+ }
+
+ Object current= getViewer().getInput();
+
+ if (current == null && context == null) {
+ return;
+ }
+
+//{ObjectTeams:
+ boolean hasContextChanged= false;
+ if ((context instanceof IStackFrame) || (context instanceof IThread) || (context instanceof IDebugTarget))
+ {
+ ILaunch launch = ((IDebugElement)context).getLaunch();
+ OTDebugElementsContainer newInput = (OTDebugElementsContainer) launch.getAdapter(OTDebugElementsContainer.class);
+ if (newInput != null) { // null for non-OT launches!
+ hasContextChanged= newInput.setContext((IDebugElement)context);
+ newInput.setSortMode(_sortMode);
+ context= newInput;
+ }
+ }
+// SH}
+ // OT: first condition added:
+ if (!hasContextChanged && current != null && current.equals(context)) {
+ return;
+ }
+
+ showViewer();
+ getViewer().setInput(context);
+ }
+
+ private boolean isSuspended(Object context)
+ {
+ if (context instanceof OTDebugElementsContainer)
+ return ((OTDebugElementsContainer)context).isSuspended();
+ return true;
+ }
+
+ public IJavaThread getSelectedThread() {
+ Object input= getViewer().getInput();
+ if (input instanceof OTDebugElementsContainer)
+ return ((OTDebugElementsContainer)input).getContextThread();
+ return null; // no input!
+ }
+
+ @Override
+ public void modelChanged(IModelDelta delta, IModelProxy proxy) {
+ throw new RuntimeException("TeamView.modelChanged() should not be called"); //$NON-NLS-1$
+ }
+
+ public void launchesTerminated(ILaunch[] launches)
+ {
+ //clear TeamView
+ ;
+ }
+
+ public void launchesRemoved(ILaunch[] launches) {}
+ public void launchesAdded(ILaunch[] launches) {}
+ public void launchesChanged(ILaunch[] launches) {}
+
+ public void dispose()
+ {
+ DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
+ */
+ public Viewer createViewer(Composite parent)
+ {
+ TreeModelViewer variablesViewer = (TreeModelViewer) super.createViewer(parent);
+ variablesViewer.removeModelChangedListener(this); // only register the proxy.
+ return variablesViewer;
+ }
+
+ protected void createActions()
+ {
+ super.createActions();
+ IActionBars actionBars = getViewSite().getActionBars();
+ IMenuManager viewMenu = actionBars.getMenuManager();
+ createSortActions(viewMenu);
+ // button:
+ setAction(ACTION_UPDATE_TEAMVIEW, new UpdateTeamViewAction(this));
+
+ setAction(ACTION_ACTIVATE_TEAM, new ChangeTeamActivationAction(this, true));
+ setAction(ACTION_DEACTIVATE_TEAM, new ChangeTeamActivationAction(this, false));
+ }
+
+ private void createSortActions(IMenuManager viewMenu)
+ {
+ final SortTeamAction sortAction1 = new SortTeamAction(this, IOTDTDebugPreferenceConstants.TEAMS_BY_ACTIVATION_ORDER);
+ final SortTeamAction sortAction2 = new SortTeamAction(this, IOTDTDebugPreferenceConstants.TEAMS_BY_ACTIVATION_TIME);
+ final SortTeamAction sortAction3 = new SortTeamAction(this, IOTDTDebugPreferenceConstants.TEAMS_BY_INSTANTIATION);
+ final SortTeamAction sortAction4 = new SortTeamAction(this, IOTDTDebugPreferenceConstants.TEAMS_BY_NAME);
+
+ final MenuManager layoutSubMenu = new MenuManager(TeamViewMessages.TeamView_0);
+ layoutSubMenu.setRemoveAllWhenShown(true);
+ layoutSubMenu.add(sortAction1);
+ layoutSubMenu.add(sortAction2);
+ layoutSubMenu.add(sortAction3);
+ layoutSubMenu.add(sortAction4);
+ viewMenu.add(layoutSubMenu);
+ viewMenu.add(new Separator());
+
+ layoutSubMenu.addMenuListener(new IMenuListener()
+ {
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ layoutSubMenu.add(sortAction1);
+ layoutSubMenu.add(sortAction2);
+ layoutSubMenu.add(sortAction3);
+ layoutSubMenu.add(sortAction4);
+ }
+ });
+ }
+
+ @Override
+ protected void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+ menu.add(getAction(ACTION_ACTIVATE_TEAM));
+ menu.add(getAction(ACTION_DEACTIVATE_TEAM));
+ }
+
+ protected String getToggleActionLabel()
+ {
+ return TeamViewMessages.TeamView_1;
+ }
+
+ public void setSortMode(String sortMode)
+ {
+ _sortMode = sortMode;
+ }
+
+ protected void configureToolBar(IToolBarManager tbm)
+ {
+ super.configureToolBar(tbm);
+ tbm.add(new Separator(IDebugUIConstants.EMPTY_REGISTER_GROUP));
+ tbm.add(new Separator(IDebugUIConstants.REGISTER_GROUP));
+ tbm.add(getAction(ACTION_UPDATE_TEAMVIEW));
+ }
+
+ public void setUpdatePermanently(boolean updatePermanently)
+ {
+ _updatePermantently = updatePermanently;
+
+ //by default clear viewer
+ if(!updatePermanently)
+ setViewerInput(null);
+
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamViewMessages.java b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamViewMessages.java
new file mode 100644
index 0000000..4332777
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamViewMessages.java
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and 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: TeamViewMessages.java 23432 2010-02-03 23:13:42Z stephan $
+ *
+ * Please visit http://www.objectteams.org for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.ui.views;
+
+import org.eclipse.osgi.util.NLS;
+
+public class TeamViewMessages extends NLS
+{
+ private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.debug.ui.views.TeamViewMessages"; //$NON-NLS-1$
+
+ public static String SortTeamByName_0;
+
+ public static String SortTeamByActivation_0;
+
+ public static String SortTeamByActivation_1;
+
+ public static String SortTeamByInstantiation_0;
+
+ public static String SortTeamDescription_0;
+
+ public static String TeamView_0;
+
+ public static String TeamView_1;
+
+ static
+ {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, TeamViewMessages.class);
+ }
+
+ private TeamViewMessages()
+ {
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamViewMessages.properties b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamViewMessages.properties
new file mode 100644
index 0000000..4c3538c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.ui/src/org/eclipse/objectteams/otdt/debug/ui/views/TeamViewMessages.properties
@@ -0,0 +1,28 @@
+###############################################################################
+ # This file is part of "Object Teams Development Tooling"-Software
+ #
+ # Copyright 2004, 2005, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ # for its Fraunhofer Institute and 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: AspectBundleRole.java 14430 2006-09-23 12:06:21Z stephan $
+ #
+ # Please visit http://www.objectteams.org for updates and contact.
+ #
+ # Contributors:
+ # Fraunhofer FIRST - Initial API and implementation
+ # Technical University Berlin - Initial API and implementation
+ ###############################################################################
+
+TeamView_0=Sort Teams
+TeamView_1=Team View Only
+SortTeamByName_0=Sort Teams by Name
+SortTeamByActivation_0=Sort Teams by Activation Time
+SortTeamByActivation_1=Sort Teams by Activation Order
+SortTeamByInstantiation_0=Sort Teams by Instantiation Time
+SortTeamDescription_0=By Default Teams are sorted by Activation Order.