Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-04-01 20:28:43 +0000
committerStephan Herrmann2010-04-01 20:28:43 +0000
commit0166441eb03b6d768965ba684b66ddd76550f740 (patch)
treeefa7995deba0ec83b64d8cbd613a955ea0beba17 /plugins/org.eclipse.objectteams.otdt.debug.adaptor
parent7b7062f3b12bba7ef33116efb94da1f54e069625 (diff)
downloadorg.eclipse.objectteams-0166441eb03b6d768965ba684b66ddd76550f740.tar.gz
org.eclipse.objectteams-0166441eb03b6d768965ba684b66ddd76550f740.tar.xz
org.eclipse.objectteams-0166441eb03b6d768965ba684b66ddd76550f740.zip
initial commit in accordance with CQ 3784
Diffstat (limited to 'plugins/org.eclipse.objectteams.otdt.debug.adaptor')
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/.classpath8
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/.project29
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/.settings/org.eclipse.jdt.core.prefs28
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/META-INF/MANIFEST.MF28
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/build.properties6
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.properties8
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.xml206
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/DebugMessages.java35
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/LaunchUtils.java58
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/OTDebugAdaptorPlugin.java39
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PreferenceInitializer.java38
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptor.java325
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptorActivator.java110
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/RetargettableActionAdaptor.java41
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/SourceLookupAdaptor.java118
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/VariablesViewAdaptor.java131
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/actions/ShowOTInternalVariablesAction.java64
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/debugMessages.properties5
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor.java105
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor2.java35
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor3.java35
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTDebugUILaunchingAdaptor.java136
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java209
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JUnitLaunchingAdaptor.java37
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/LaunchConfigurationInitializer.java81
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTLaunchConfigurationTab.java216
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTREBlock.java126
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/PDELaunchingAdaptor.java254
-rw-r--r--plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/TeamConfig.java453
29 files changed, 2964 insertions, 0 deletions
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.classpath b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.classpath
new file mode 100644
index 000000000..987380a81
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="OTRE"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.project b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.project
new file mode 100644
index 000000000..1dececd55
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.project
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.objectteams.otdt.debug.adaptor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.objectteams.otdt.builder.OTJBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.objectteams.otdt.OTJavaNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..5fbade38e
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,28 @@
+#Sat Oct 03 22:14:54 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.objectteams.otdt.compiler.option.joinpoint_queries=disabled
+org.objectteams.otdt.compiler.option.scoped_keywords=enabled
+org.objectteams.otdt.compiler.problem.abstract_potential_relevant_role=warning
+org.objectteams.otdt.compiler.problem.adapting_deprecated=error
+org.objectteams.otdt.compiler.problem.ambiguous_lowering=warning
+org.objectteams.otdt.compiler.problem.basecall=warning
+org.objectteams.otdt.compiler.problem.binding_conventions=error
+org.objectteams.otdt.compiler.problem.decapsulation=warning
+org.objectteams.otdt.compiler.problem.deprecated_path_syntax=warning
+org.objectteams.otdt.compiler.problem.exception_in_guard=error
+org.objectteams.otdt.compiler.problem.fragile_callin=warning
+org.objectteams.otdt.compiler.problem.inferred_callout=warning
+org.objectteams.otdt.compiler.problem.override_final_role=error
+org.objectteams.otdt.compiler.problem.potential_ambiguous_playedby=warning
+org.objectteams.otdt.compiler.problem.unsafe_role_instantiation=warning
+org.objectteams.otdt.compiler.problem.weave_into_system_class=warning
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..199ef5ff1
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: DebugAdaptor Plug-in
+Bundle-SymbolicName: org.eclipse.objectteams.otdt.debug.adaptor;singleton:=true
+Bundle-Version: 1.4.0.qualifier
+Bundle-Vendor: objectteams.org
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.objectteams.otequinox,
+ org.eclipse.core.runtime,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.debug.ui,
+ org.eclipse.jdt.debug,
+ org.eclipse.jdt.debug.ui,
+ org.eclipse.objectteams.otdt.debug.ui,
+ org.eclipse.jface,
+ org.eclipse.ui,
+ org.eclipse.pde.ui,
+ org.eclipse.jdt.launching,
+ org.eclipse.jdt.junit,
+ org.eclipse.objectteams.otdt,
+ org.eclipse.objectteams.otdt.debug,
+ org.eclipse.objectteams.otdt.ui,
+ org.eclipse.ui.editors,
+ org.eclipse.jface.text
+Bundle-Activator: org.eclipse.objectteams.otdt.internal.debug.adaptor.OTDebugAdaptorPlugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/build.properties b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/build.properties
new file mode 100644
index 000000000..0dc34f783
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.properties b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.properties
new file mode 100644
index 000000000..29c17aa17
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.properties
@@ -0,0 +1,8 @@
+OtGeneratedCodeColorDescription.label=OT/J generated code
+OtGeneratedCodeColorDescription.description=The color by which the debug view marks stack frames that do not correspond to source code\n(generated by compiler or runtime-environment)
+OtSpecialCodeColorDescription.label=OT/J special source code
+OtSpecialCodeColorDescription.description=The color by which the debug view highlights special OT/J source code\n(method bindings, guard predicates etc.)
+
+showOTInternalAction.label=Show &OT/J Internal Variables
+showOTInternalAction.tooltip=Show internal variables which the OT/J compiler and weaver have generated.
+VariablesViewJavaSubmenu.label=&Java
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.xml b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.xml
new file mode 100644
index 000000000..b7f076b91
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/plugin.xml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.objectteams.otequinox.aspectBindings">
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.debug.ui">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.VariablesViewAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.DebugUIDialogAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.PresentationAdaptorActivator"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.jdt.debug.ui">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.PresentationAdaptorActivator"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.JDTDebugUILaunchingAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="NONE"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.DebugUIDialogAdaptor2"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif"
+ superclass="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.DebugUIDialogAdaptor">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.RetargettableActionAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.jdt.debug">
+ </basePlugin>
+ <team
+ activation="NONE"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.PresentationAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.SourceLookupAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.pde.ui">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.SourceLookupAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.PDELaunchingAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.debug.core">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.LaunchConfigurationInitializer"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.jdt.launching">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.JDTLaunchingAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.jdt.junit.core">
+ </basePlugin>
+ <team
+ activation="NONE"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.JUnitLaunchingAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif"
+ superclass="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.JDTLaunchingAdaptor">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.jdt.junit">
+ </basePlugin>
+ <team
+ activation="NONE"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.DebugUIDialogAdaptor3"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif"
+ superclass="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.DebugUIDialogAdaptor2">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.jdt.ui">
+ </basePlugin>
+ <team
+ activation="NONE"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.PresentationAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ <aspectBinding
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
+ <basePlugin
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
+ id="org.eclipse.pde.launching">
+ </basePlugin>
+ <team
+ activation="ALL_THREADS"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.launching.PDELaunchingAdaptor"
+ icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
+ </team>
+ </aspectBinding>
+ </extension>
+ <extension
+ point="org.eclipse.ui.viewActions">
+ <viewContribution
+ targetID="org.eclipse.debug.ui.VariableView"
+ id="org.eclipse.objectteams.otdt.internal.debug.adaptor.VariableViewActions">
+ <action
+ style="toggle"
+ id="org.eclipse.objectteams.otdt.internal.debug.adaptor.variableViewActions.ShowOTInternal"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.actions.ShowOTInternalVariablesAction"
+ helpContextId="show_otinternal_action_context"
+ label="%showOTInternalAction.label"
+ menubarPath="org.eclipse.jdt.debug.ui.VariableView.javaSubmenu/javaPart"
+ tooltip="%showOTInternalAction.tooltip">
+ </action>
+ </viewContribution>
+ <viewContribution
+ targetID="org.eclipse.objectteams.otdt.debug.ui.views.team"
+ id="org.eclipse.objectteams.otdt.internal.debug.adaptor.VariableViewActions">
+ <action
+ style="toggle"
+ id="org.eclipse.objectteams.otdt.internal.debug.adaptor.variableViewActions.ShowOTInternal"
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.actions.ShowOTInternalVariablesAction"
+ helpContextId="show_otinternal_action_context"
+ label="%showOTInternalAction.label"
+ menubarPath="org.eclipse.jdt.debug.ui.VariableView.javaSubmenu/javaPart"
+ tooltip="%showOTInternalAction.tooltip">
+ </action>
+ <menu
+ id="org.eclipse.jdt.debug.ui.VariableView.javaSubmenu"
+ label="%VariablesViewJavaSubmenu.label"
+ path="javaActions">
+ <groupMarker name="org.eclipse.jdt.debug.ui.javaPart"/>
+ </menu>
+ </viewContribution>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.objectteams.otdt.internal.debug.adaptor.PreferenceInitializer">
+ </initializer>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/DebugMessages.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/DebugMessages.java
new file mode 100644
index 000000000..388aa05f9
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/DebugMessages.java
@@ -0,0 +1,35 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: DebugMessages.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import org.eclipse.osgi.util.NLS;
+
+public class DebugMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.internal.debug.adaptor.debugMessages"; //$NON-NLS-1$
+ public static String OTLaunching_loading_failed_msg;
+ public static String OTLaunching_OTRE_checkbox_label;
+ public static String OTLaunching_OTRE_group_title;
+ public static String OTLaunching_OTEquinox_checkbox_label;
+ public static String OTLaunching_no_OTJ_project_found;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, DebugMessages.class);
+ }
+
+ private DebugMessages() {
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/LaunchUtils.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/LaunchUtils.java
new file mode 100644
index 000000000..66f2b35b1
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/LaunchUtils.java
@@ -0,0 +1,58 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: LaunchUtils.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+
+/**
+ * Simple queries relating to launches/launch-configs.
+ * @author stephan
+ * @since 1.2.1
+ */
+public class LaunchUtils {
+
+ /** Does elem belong to an OT launch? */
+ static boolean isOTLaunch(Object elem) {
+ try {
+ if (!(elem instanceof IDebugElement))
+ return false;
+ ILaunchConfiguration launchConfiguration = ((IDebugElement)elem).getLaunch().getLaunchConfiguration();
+ return launchConfiguration.getAttribute(OTDebugPlugin.OT_LAUNCH, false);
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /** Does projectName denote an OT/J-enabled project? */
+ public static boolean isOTJProject(String projectName) {
+ if (projectName != null && projectName.length() > 0) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (project != null && project.exists())
+ try {
+ return project.hasNature(JavaCore.OTJ_NATURE_ID);
+ } catch (CoreException e) { /* ignore */ }
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/OTDebugAdaptorPlugin.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/OTDebugAdaptorPlugin.java
new file mode 100644
index 000000000..8adc4fd10
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/OTDebugAdaptorPlugin.java
@@ -0,0 +1,39 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: OTDebugAdaptorPlugin.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/** This Activator enables the debug adaptor to manage preferences of its own.
+ *
+ * @author stephan
+ * @since 1.2.0
+ */
+public class OTDebugAdaptorPlugin extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.eclipse.objectteams.otdt.internal.debug.adaptor"; //$NON-NLS-1$
+
+ private static OTDebugAdaptorPlugin instance;
+
+ public OTDebugAdaptorPlugin() {
+ instance = this;
+ }
+
+ public static AbstractUIPlugin getDefault() {
+ return instance;
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PreferenceInitializer.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PreferenceInitializer.java
new file mode 100644
index 000000000..a7dec9a2f
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PreferenceInitializer.java
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: PreferenceInitializer.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * Provide defaults for this plugin's preferences.
+ *
+ * @author stephan
+ * @since 1.2.0
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public static final String PREF_SHOW_OTINTERNAL_VARIABLES = OTDebugAdaptorPlugin.PLUGIN_ID+".show_otinternal_variables"; //$NON-NLS-1$
+
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = OTDebugAdaptorPlugin.getDefault().getPreferenceStore();
+ store.setDefault(PreferenceInitializer.PREF_SHOW_OTINTERNAL_VARIABLES, false);
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptor.java
new file mode 100644
index 000000000..26b3687a2
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptor.java
@@ -0,0 +1,325 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2007 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: PresentationAdaptor.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.ISourceReference;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.Member;
+import org.eclipse.jdt.internal.debug.ui.DebugUIMessages;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.debug.ui.internal.preferences.OTDebugPreferences;
+
+import base org.eclipse.jdt.internal.debug.core.model.JDIReferenceType;
+import base org.eclipse.jdt.internal.debug.core.model.JDIStackFrame;
+import base org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+
+/**
+ * Adapt the String representation of stack frames in the debug view.
+ *
+ * @author stephan
+ * @since 1.1.7
+ */
+@SuppressWarnings("restriction")
+public team class PresentationAdaptor
+{
+ enum MethodKind {
+ PLAIN, INITIAL, CHAIN, ORIG, TEAM_WRAPPER, BASE_CALL, LIFT, WHEN, BASE_WHEN, FIELD_ACCESS
+ }
+
+ @SuppressWarnings("nls")
+ public static final String[] enhancementTypes = {
+ "org.objectteams.Team[]", "int[]", "int", "int", "int", "java.lang.Object[]"
+ };
+
+ // while working for some clients we have an editor that we can use for adapted source lookup:
+ private ThreadLocal<JavaEditor> javaEditor = new ThreadLocal<JavaEditor>();
+
+
+ private static PresentationAdaptor instance;
+ public static PresentationAdaptor getInstance() {
+ if (instance == null)
+ instance= new PresentationAdaptor();
+ return instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected class OTJStackFrame playedBy JDIStackFrame
+ {
+ // === imports: ===
+ boolean isStatic() -> boolean isStatic();
+ int modifiers() -> com.sun.jdi.Method getUnderlyingMethod()
+ with { result <- result.modifiers() }
+
+ // store analyzed method kind between calls:
+ protected MethodKind kind= MethodKind.PLAIN;
+
+ // == currently unused: ==
+ boolean isRole;
+ boolean isTeam;
+
+ protected boolean isPurelyGenerated() {
+ switch(this.kind) {
+ case LIFT:
+ case INITIAL:
+ case CHAIN:
+ return true;
+ }
+ return false;
+ }
+ protected boolean isOTSpecialSrc() {
+ switch(this.kind) {
+ case TEAM_WRAPPER:
+ case BASE_CALL:
+ case WHEN:
+ case BASE_WHEN:
+ case FIELD_ACCESS:
+ return true;
+ }
+ return false;
+ }
+
+ getTypeName <- replace getReceivingTypeName, getDeclaringTypeName;
+ callin String getTypeName() throws DebugException {
+ return analyzeType(base.getTypeName());
+ }
+
+ String analyzeType(String typeName) {
+// this.isRole= typeName.contains("__OT__");
+// this.isTeam= (modifiers() & 0x8000) != 0;
+// if (this.isRole)
+ return typeName.replaceAll("__OT__", ""); //$NON-NLS-1$ //$NON-NLS-2$
+// return typeName;
+ }
+
+ String getMethodName() <- replace String getMethodName();
+ @SuppressWarnings("nls")
+ callin String getMethodName() throws DebugException {
+ String result= base.getMethodName();
+ String[] segments= analyzeMethod(result);
+ if (segments != null) {
+ switch (this.kind) {
+ // INITIAL is not yet analyzed
+ case ORIG:
+ return segments[1];
+ case CHAIN:
+ return "{{Dispatch callins for "+segments[1]+"}}";
+ case TEAM_WRAPPER:
+ return "["+segments[1]+"."+segments[2]+"<-"+segments[3]+"]";
+ case LIFT:
+ return "{{Lift to "+segments[2]+"}}";
+ case BASE_CALL:
+ return "base."+segments[1];
+ case WHEN:
+ return "[when]";
+ case BASE_WHEN:
+ return "[base when]";
+ case FIELD_ACCESS:
+ return "[access to field "+segments[3]+"]";
+ }
+ }
+ return result;
+ }
+
+ /** Analyze the method name and store the kind.
+ * @param methodName
+ * @return an array of segments split at '$'.
+ */
+ @SuppressWarnings("nls")
+ String[] analyzeMethod(String methodName)
+ {
+ if (methodName != null && methodName.startsWith("_OT$"))
+ {
+ String[] segments= methodName.split("[$]");
+
+ switch (segments.length) {
+ case 2:
+ if (segments[1].equals("when"))
+ this.kind= MethodKind.WHEN;
+ else if (segments[1].equals("base_when"))
+ this.kind= MethodKind.BASE_WHEN;
+ break;
+ case 3:
+ if (segments[2].equals("orig")) // _OT$bm$orig
+ this.kind= MethodKind.ORIG;
+ else if (segments[2].equals("chain")) // _OT$bm$chain
+ this.kind= MethodKind.CHAIN;
+ else if (segments[1].equals("liftTo")) // _OT$liftTo$R
+ this.kind= MethodKind.LIFT;
+ else if (segments[2].equals("base")) // _OT$rm$base
+ this.kind= MethodKind.BASE_CALL;
+ break;
+ case 4:
+ if (segments[1].equals("_fieldget_")
+ ||segments[1].equals("_fieldset_"))
+ this.kind = MethodKind.FIELD_ACCESS;
+ else
+ // further analysis needed?
+ this.kind= MethodKind.TEAM_WRAPPER; // _OT$R$rm$bm
+ }
+ return segments;
+ }
+ return null;
+ }
+
+ getArgumentTypeNames <- replace getArgumentTypeNames;
+ @SuppressWarnings("rawtypes")
+ callin List getArgumentTypeNames() throws DebugException {
+ return stripGeneratedParams(base.getArgumentTypeNames());
+ }
+
+ int getLineNumber() <- replace int getLineNumber();
+ callin int getLineNumber() throws DebugException {
+ int result= base.getLineNumber();
+ if (result >= ISMAPConstants.STEP_INTO_LINENUMBER) {
+ if (this.kind == MethodKind.PLAIN) // re-classify, if linenumber was the only unusual property
+ this.kind = MethodKind.INITIAL;
+ return -1;
+ }
+ if (this.kind == MethodKind.CHAIN) {
+ JavaEditor editor = PresentationAdaptor.this.javaEditor.get();
+ if (editor != null) {
+ try {
+ return editor.getStartLineOfEnclosingElement(result-1)+1; // map between 0/1 based counting.
+ } catch (BadLocationException e) {
+ OTDebugAdaptorPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, OTDebugAdaptorPlugin.PLUGIN_ID, "Failed to retrieve line number", e));
+ }
+ }
+ }
+ return result;
+ }
+
+ // -- helpers --
+ private List<String> stripGeneratedParams(List<String> typeNames)
+ throws DebugException
+ {
+ switch (this.kind) {
+ case TEAM_WRAPPER:
+ if (!isStatic())
+ typeNames= typeNames.subList(1, typeNames.size()); // remove role arg
+ break;
+ case BASE_WHEN:
+ typeNames= typeNames.subList(2, typeNames.size()); // remove 2 synth args: dummy,Team
+ break;
+ }
+ // may need to strip multiple sets of enhance-args:
+ List<String> stripped= stripEnhancementParams(typeNames);
+ while (stripped != typeNames) {
+ typeNames= stripped;
+ stripped= stripEnhancementParams(typeNames);
+ }
+ // go into details: strip __OT__ prefix of individual types
+ for (int i=0; i<stripped.size(); i++)
+ stripped.set(i, analyzeType(stripped.get(i)));
+ return stripped;
+ }
+ private List<String> stripEnhancementParams(List<String> typeNames) {
+ if (typeNames != null && typeNames.size() >= 6) {
+ for (int i = 0; i < enhancementTypes.length; i++) {
+ if (!enhancementTypes[i].equals(typeNames.get(i)))
+ return typeNames;
+ }
+ return typeNames.subList(6, typeNames.size());
+ }
+ return typeNames;
+ }
+ }
+ /** While assembling the display string (ie., while this team is active)
+ * pretend the "OTJ" stratum is "Java", in order to enable Java name assembly.
+ */
+ protected class ReferenceType playedBy JDIReferenceType
+ {
+ String getDefaultStratum() <- replace String getDefaultStratum();
+ callin String getDefaultStratum() throws DebugException {
+ String stratum= base.getDefaultStratum();
+ if (stratum.equals("OTJ")) //$NON-NLS-1$
+ return "Java"; // this is where we lie ;-) //$NON-NLS-1$
+ return stratum;
+ }
+ }
+
+ /** Gateway to java editors for requesting line numbers using info from the java model. */
+ protected class JavaEditor playedBy JavaEditor
+ {
+ @SuppressWarnings("decapsulation")
+ IJavaElement getElementAt(int offset) -> IJavaElement getElementAt(int offset);
+ IDocumentProvider getDocumentProvider() -> IDocumentProvider getDocumentProvider();
+ IEditorInput getEditorInput() -> IEditorInput getEditorInput();
+
+ protected int getStartLineOfEnclosingElement(int line) throws BadLocationException
+ {
+ IDocument doc = getDocumentProvider().getDocument(getEditorInput());
+ IJavaElement element = getElementAt(doc.getLineOffset(line));
+ if (!(element instanceof ISourceReference))
+ throw new BadLocationException("Element is not an ISourceReference: "+element);
+ try {
+ ISourceRange range = (element instanceof Member)
+ ? ((Member) element).getNameRange()
+ : ((ISourceReference) element).getSourceRange();
+
+ return doc.getLineOfOffset(range.getOffset());
+ } catch (JavaModelException e) {
+ throw new BadLocationException(e.getMessage());
+ }
+ }
+ }
+
+ /** Answer the symbolic name of the color that should be used for displaying
+ * the given stackframe.
+ * @param element stackframe
+ * @return symbolic color name or null.
+ */
+ public String getFrameColorName(JDIStackFrame as OTJStackFrame element) {
+ if (element.isPurelyGenerated())
+ return OTDebugPreferences.OT_GENERATED_CODE_COLOR;
+ if (element.isOTSpecialSrc())
+ return OTDebugPreferences.OT_SPECIAL_CODE_COLOR;
+ return null;
+ }
+
+ /**
+ * When this team is activated in a JavaEditor-aware-context, remember the java editor.
+ * @param javaEditor new java editor to be remembered, may be null (= reset).
+ * @return previously remembered editor, may be null.
+ */
+ public org.eclipse.jdt.internal.ui.javaeditor.JavaEditor setTextEditor(JavaEditor as JavaEditor javaEditor)
+ {
+ JavaEditor previous = this.javaEditor.get();
+ this.javaEditor.set(javaEditor);
+ return previous;
+ }
+
+ /** Final embellishment of a label after everything has been analyzed. */
+ public String postProcess(JDIStackFrame as OTJStackFrame stackFrame, String labelText)
+ {
+ if (stackFrame.kind == MethodKind.INITIAL) // this we didn't know when creating the label text
+ return labelText.replace(DebugUIMessages.JDIModelPresentation_line__76+' '+DebugUIMessages.JDIModelPresentation_not_available,
+ "[about to enter]");
+
+ return labelText;
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptorActivator.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptorActivator.java
new file mode 100644
index 000000000..65f52689b
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/PresentationAdaptorActivator.java
@@ -0,0 +1,110 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2007 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: PresentationAdaptorActivator.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jface.text.source.Annotation;
+
+import base org.eclipse.debug.internal.ui.InstructionPointerManager;
+import base org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility;
+import base org.eclipse.jdt.internal.debug.ui.JDIModelPresentation;
+
+/**
+ * This team watches over a method from JDTModelPresentation
+ * to enable adaptation of String representations by PresentationAdaptor,
+ * given that the current launch is some OT/J launch.
+ *
+ * @author stephan
+ * @since 1.1.7
+ */
+@SuppressWarnings("restriction")
+public team class PresentationAdaptorActivator
+{
+ /** Generalized role for different editor-based contexts. */
+ protected class EditorBasedAdaptation
+ {
+ /**
+ * When the current editor is a java editor make it available to the
+ * to-be-activated {@link PresentationAdaptor}.
+ * @param textEditor
+ */
+ callin void adaptedRun(ITextEditor textEditor)
+ when (textEditor instanceof JavaEditor)
+ {
+ PresentationAdaptor adaptor = PresentationAdaptor.getInstance();
+ JavaEditor previous = adaptor.setTextEditor((JavaEditor)textEditor);
+ try {
+ within(adaptor)
+ base.adaptedRun(textEditor);
+ } finally {
+ adaptor.setTextEditor(previous);
+ }
+ }
+ }
+ /** Let the {@link PresentationAdaptor} adapt positioning of the editor. */
+ protected class EditorPositioningAdaptor extends EditorBasedAdaptation playedBy SourceLookupFacility
+ {
+ @SuppressWarnings("decapsulation")
+ void adaptedRun(ITextEditor editor)
+ <- replace void positionEditor(ITextEditor editor, IStackFrame frame)
+ base when (LaunchUtils.isOTLaunch(frame));
+ }
+ /** Let the {@link PresentationAdaptor} adapt positioning of "current instruction" annotations. */
+ protected class AnnotationAdaptor extends EditorBasedAdaptation playedBy InstructionPointerManager
+ {
+ void adaptedRun(ITextEditor textEditor)
+ <- replace void addAnnotation(ITextEditor textEditor, IStackFrame frame, Annotation annotation)
+ base when (LaunchUtils.isOTLaunch(frame));
+ }
+ /** Let the {@link PresentationAdaptor} adapt composing labels for the debug view. */
+ protected class ModelPresentation playedBy JDIModelPresentation
+ {
+ String getStackFrameText(IStackFrame frame) <- replace String getStackFrameText(IStackFrame frame)
+ base when (LaunchUtils.isOTLaunch(frame));
+ callin String getStackFrameText(IStackFrame stackFrame)
+ throws DebugException
+ {
+ // while constructing the text for a stack frame use the PresentationAdaptor:
+ PresentationAdaptor adaptor = PresentationAdaptor.getInstance();
+ String result;
+ within (adaptor)
+ result = base.getStackFrameText(stackFrame);
+ if (stackFrame instanceof JDIStackFrame)
+ result = adaptor.postProcess((JDIStackFrame)stackFrame, result);
+ return result;
+ }
+
+ Color getForeground(Object element) <- replace Color getForeground(Object element)
+ base when (LaunchUtils.isOTLaunch(element));
+ @SuppressWarnings("basecall")
+ callin Color getForeground(Object element) {
+ if (element instanceof JDIStackFrame) {
+ PresentationAdaptor adaptor = PresentationAdaptor.getInstance();
+ String colorName= adaptor.getFrameColorName((JDIStackFrame)element);
+ if (colorName != null)
+ return OTDebugUIPlugin.getPreferenceColor(colorName);
+ }
+ return base.getForeground(element);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/RetargettableActionAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/RetargettableActionAdaptor.java
new file mode 100644
index 000000000..485ab582c
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/RetargettableActionAdaptor.java
@@ -0,0 +1,41 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2009 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: RetargettableActionAdaptor.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.objectteams.otdt.debug.ui.internal.actions.OTToggleBreakpointAdapter;
+
+import base org.eclipse.jdt.internal.debug.ui.actions.RetargettableActionAdapterFactory;
+
+/**
+ * This team replaces the former OTRetargettableActionAdapterFactory class.
+ *
+ * @author mosconi
+ */
+@SuppressWarnings("restriction")
+public team class RetargettableActionAdaptor {
+ protected class RetargettableActionAdapterFactory playedBy RetargettableActionAdapterFactory {
+ @SuppressWarnings({ "basecall", "rawtypes" })
+ callin Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType == IToggleBreakpointsTarget.class) {
+ return new OTToggleBreakpointAdapter();
+ }
+ return base.getAdapter(adaptableObject, adapterType);
+ }
+ getAdapter <- replace getAdapter;
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/SourceLookupAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/SourceLookupAdaptor.java
new file mode 100644
index 000000000..661bd75c5
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/SourceLookupAdaptor.java
@@ -0,0 +1,118 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: RoFiBreakpointTests.java 18812 2008-07-27 18:01:43Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+
+import base org.eclipse.jdt.internal.debug.core.JavaDebugUtils;
+//import base org.eclipse.pde.internal.ui.launcher.PDESourceLookupQuery;
+
+/**
+ * This team makes the PDE source lookup aware of role files.
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+@SuppressWarnings("restriction")
+public team class SourceLookupAdaptor {
+
+ // field stored in the team, because intercepted base method generateSourceName() has static context.
+ Object currentElement;
+
+// /**
+// * This role is needed because its base class over-eagerly discards
+// * the names of inner classes when looking for the source file.
+// */
+// protected class PDESourceLookupQuery playedBy PDESourceLookupQuery {
+//
+// @SuppressWarnings("decapsulation")
+// Object getFElement() -> get Object fElement;
+//
+// keepElement <- before run;
+// void keepElement() {
+// currentElement = getFElement();
+// }
+//
+// @SuppressWarnings("decapsulation")
+// String generateSourceName(String qualifiedTypeName) <- replace String generateSourceName(String qualifiedTypeName);
+//
+// @SuppressWarnings("basecall")
+// static callin String generateSourceName(String qualifiedTypeName) {
+// try {
+// return JavaDebugUtils.getSourceName(currentElement);
+// } catch (CoreException e) {
+// OTDebugAdaptorPlugin.getDefault().getLog().log(new Status(Status.ERROR, OTDebugAdaptorPlugin.PLUGIN_ID, "Source lookup failed", e));
+// return base.generateSourceName(qualifiedTypeName);
+// }
+// }
+// }
+
+ protected class JavaDebugUtils playedBy JavaDebugUtils
+ {
+ String getSourceName(Object object) -> String getSourceName(Object object);
+
+ // FIXME(SH): workaround, problem with overload between callin and inferred callout
+ IType resolveType(String qualifiedName, IJavaElement javaElement)
+ -> IType resolveType(String qualifiedName, IJavaElement javaElement);
+
+ IType resolveType(IJavaType type) <- replace IType resolveType(IJavaType type);
+
+ @SuppressWarnings({ "basecall", "inferredcallout" })
+ static callin IType resolveType(IJavaType type) throws CoreException {
+ // copied from base method:
+ IJavaElement element = resolveJavaElement(type, type.getLaunch());
+ if (element != null ) {
+ IType result = resolveType(type.getName(), element);
+ // start OT-adaptation: check result:
+ if (result != null && result.exists())
+ return result;
+ // the given compilation unit doesn't have a type `type.getName()`
+ try {
+ ICompilationUnit resolvedCU = (ICompilationUnit) element;
+ String typeName = type.getName();
+ int lastDollar = typeName.lastIndexOf('$');
+ if (lastDollar != -1) {
+ // find a type that is (a) superclass of `type` and (b) contained in `resolvedCU`
+ String enclosingName = typeName.substring(0, lastDollar);
+ IJavaProject javaProject = resolvedCU.getJavaProject();
+ IType enclosingType = javaProject.findType(enclosingName);
+ while (enclosingType != null) {
+ if (resolvedCU.equals(enclosingType.getAncestor(IJavaElement.COMPILATION_UNIT))) {
+ // got the enclosing team, now find the corresponding role:
+ String roleName = typeName.substring(lastDollar+1);
+ if (roleName.startsWith(IOTConstants.OT_DELIM))
+ roleName = roleName.substring(IOTConstants.OT_DELIM_LEN);
+ return enclosingType.getType(roleName);
+ }
+ String[][] superclassName = enclosingType.resolveType((enclosingType.getSuperclassName()));
+ enclosingType = javaProject.findType(superclassName[0][0], superclassName[0][1]);
+ }
+ }
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/VariablesViewAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/VariablesViewAdaptor.java
new file mode 100644
index 000000000..082aee752
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/VariablesViewAdaptor.java
@@ -0,0 +1,131 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2007, 2008 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: VariablesViewAdaptor.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jdt.debug.core.IJavaFieldVariable;
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+import org.eclipse.objectteams.otdt.debug.ui.OTDebugUIPlugin;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.actions.ShowOTInternalVariablesAction;
+
+import base org.eclipse.debug.internal.ui.model.elements.StackFrameContentProvider;
+import base org.eclipse.debug.internal.ui.model.elements.VariableContentProvider;
+
+/**
+ * Implements variables filtering for VariablesView and TeamView.
+ * <ul>
+ * <li>TeamView always filters statics.</li>
+ * <li>Conditionally filter internal OT/J variables (starting with _OT$);
+ * This filter is controlled by view specific preferences.</li>
+ * </ul>
+ *
+ * @author stephan
+ * @since 1.1.6
+ */
+@SuppressWarnings("restriction")
+public team class VariablesViewAdaptor
+{
+ /** Adapt the content provider for root elements of the variables view. */
+ protected class StackFrameContentProvider playedBy StackFrameContentProvider {
+
+ Object[] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor)
+ <- replace Object[] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor);
+
+ callin Object[] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor)
+ throws CoreException
+ {
+ Object[] rawChildren = base.getAllChildren(parent, context, monitor);
+
+ if (!context.getId().equals(IDebugUIConstants.ID_VARIABLE_VIEW))
+ return rawChildren;
+
+ // is filtering needed?
+ if (ShowOTInternalVariablesAction.includeOTInternal(context))
+ return rawChildren;
+
+ // at this point always filter internals, but toplevel never has statics to filter:
+ return filterChildren(rawChildren, true/*OTInternals*/, false/*statics*/);
+ }
+
+ }
+
+ /** Adapt the content provider for non-toplevel elements. */
+ protected class ContentProvider playedBy VariableContentProvider
+ {
+ Object[] getValueChildren(IDebugElement parent, IValue value, IPresentationContext context)
+ <- replace Object[] getValueChildren(IDebugElement parent, IValue value, IPresentationContext context);
+
+ callin Object[] getValueChildren(IDebugElement parent, IValue value, IPresentationContext context)
+ throws CoreException
+ {
+ Object[] rawChildren = base.getValueChildren(parent, value, context);
+
+ // is filtering needed?
+ boolean filterOTInternals = ! ShowOTInternalVariablesAction.includeOTInternal(context);
+
+ // TeamView constantly filters statics:
+ boolean filterStatics = context.getId().equals(OTDebugUIPlugin.TEAM_VIEW_ID);
+
+ if (filterOTInternals || filterStatics)
+ return filterChildren(rawChildren, filterOTInternals, filterStatics);
+
+ return rawChildren;
+ }
+
+ }
+
+ /**
+ * Filter from rawChildren ot-internal variables and/or static fields.
+ */
+ static Object[] filterChildren(Object[] rawChildren, boolean filterOTInternals, boolean filterStatics) {
+ List<Object> visible = new ArrayList<Object>();
+
+ for (int i= 0; i<rawChildren.length; i++)
+ if (!isFiltered((IVariable)rawChildren[i], filterOTInternals, filterStatics))
+ visible.add(rawChildren[i]);
+
+ // has filtering taken place?
+ if (visible.size() == rawChildren.length)
+ return rawChildren;
+ return visible.toArray(new Object[visible.size()]);
+ }
+ // helper checking conditions for above method:
+ static boolean isFiltered(IVariable var, boolean filterOTInternals, boolean filterStatics) {
+ try {
+ if (filterOTInternals && var.getName().startsWith(IOTConstants.OT_DOLLAR))
+ return true;
+ if (filterStatics && var instanceof IJavaFieldVariable)
+ if (((IJavaFieldVariable)var).isStatic())
+ return true;
+ } catch (DebugException e) {
+ return true; // cannot display any way.
+ }
+ return false;
+ }
+
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/actions/ShowOTInternalVariablesAction.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/actions/ShowOTInternalVariablesAction.java
new file mode 100644
index 000000000..f0643d62e
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/actions/ShowOTInternalVariablesAction.java
@@ -0,0 +1,64 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: ShowOTInternalVariablesAction.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.actions;
+
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jdt.internal.debug.ui.actions.ToggleBooleanPreferenceAction;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.OTDebugAdaptorPlugin;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.PreferenceInitializer;
+
+/**
+ * Toggle action for filtering OT-Internal variables (starting with "_OT$").
+ * This action can be used by different views (currently: TeamView and VariablesView).
+ *
+ * @author stephan
+ * @since 1.2.0
+ */
+@SuppressWarnings("restriction")
+public class ShowOTInternalVariablesAction extends ToggleBooleanPreferenceAction {
+
+ public ShowOTInternalVariablesAction() {
+ super();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.actions.ViewFilterAction#getPreferenceKey()
+ */
+ protected String getPreferenceKey() {
+ return PreferenceInitializer.PREF_SHOW_OTINTERNAL_VARIABLES;
+ }
+
+ protected IPreferenceStore getPreferenceStore() {
+ return OTDebugAdaptorPlugin.getDefault().getPreferenceStore();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.actions.ToggleBooleanPreferenceAction#getViewKey()
+ */
+ protected String getViewKey() {
+ return getCompositeKey();
+ }
+
+ public static boolean includeOTInternal(IPresentationContext context){
+ IPreferenceStore store = OTDebugAdaptorPlugin.getDefault().getPreferenceStore();
+ String key = context.getId() + "." + PreferenceInitializer.PREF_SHOW_OTINTERNAL_VARIABLES; //$NON-NLS-1$
+ return store.getBoolean(key);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/debugMessages.properties b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/debugMessages.properties
new file mode 100644
index 000000000..fe10c2c72
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/debugMessages.properties
@@ -0,0 +1,5 @@
+OTLaunching_loading_failed_msg=Unable to read from launch configuration
+OTLaunching_OTRE_checkbox_label=Enable OTRE
+OTLaunching_OTEquinox_checkbox_label=Enable OT/Equinox
+OTLaunching_OTRE_group_title=Object Teams Runtime
+OTLaunching_no_OTJ_project_found=No OT/J plug-in project found, debug functionality not fully available.
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor.java
new file mode 100644
index 000000000..e551404c2
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor.java
@@ -0,0 +1,105 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: DebugUIDialogAdaptor.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.pde.internal.ui.IPDEUIConstants;
+
+import base org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import base org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer;
+import base org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
+
+/**
+ * This team conditionally adds the "Team Activation" tab to the launch configuration dialog.
+ * Only the most specific subteam is activated.
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+@SuppressWarnings("restriction")
+public team class DebugUIDialogAdaptor {
+
+
+ protected class LaunchConfigurationTabGroup playedBy AbstractLaunchConfigurationTabGroup {
+
+ boolean isOTJlaunch = false;
+
+ /** Catch the dialog to find out if the current launch is ot-enabled. */
+ void checkProject(LaunchConfigurationsDialog dialog)
+ <- before void createTabs(ILaunchConfigurationDialog dialog, String mode)
+ with { dialog <- (LaunchConfigurationsDialog)dialog }
+ void checkProject(LaunchConfigurationsDialog dialog) {
+ isOTJlaunch = dialog != null && dialog.isOTJlaunch();
+ }
+
+ /** Intercept installation of the tabs, as to conditionally insert our tab. */
+ void setTabs(ILaunchConfigurationTab[] tabs) <- replace void setTabs(ILaunchConfigurationTab[] tabs)
+ when(this.isOTJlaunch && tabs != null);
+ callin void setTabs(ILaunchConfigurationTab[] tabs) {
+ int len = tabs.length;
+ int insertPos = tabs.length;
+ for(int i=0; i<len; i++) {
+ if (tabs[i] instanceof AbstractLaunchConfigurationTab) {
+ AbstractLaunchConfigurationTab launchConfigurationTab = (AbstractLaunchConfigurationTab)tabs[i];
+ if ("org.eclipse.jdt.debug.ui.javaArgumentsTab".equals(launchConfigurationTab.getId())) { //$NON-NLS-1$
+ insertPos = i+1;
+ break;
+ }
+ } else if (tabs[i] instanceof OTLaunchConfigurationTab) {
+ base.setTabs(tabs); // already present, don't insert again (for legacy launches).
+ return;
+ }
+ }
+ ILaunchConfigurationTab[] newTabs = new ILaunchConfigurationTab[len+1];
+ for (int i=0,j=0; j<=len; j++)
+ if (j != insertPos)
+ newTabs[j] = tabs[i++];
+ newTabs[insertPos] = new OTLaunchConfigurationTab();
+ base.setTabs(newTabs);
+ }
+ }
+ /** Gate to base-level information, here: whether current launch is ot-enabled. */
+ protected class LaunchConfigurationsDialog playedBy LaunchConfigurationsDialog
+ {
+ @SuppressWarnings("decapsulation")
+ LaunchConfigurationTabGroupViewer getTabViewer() -> LaunchConfigurationTabGroupViewer getTabViewer();
+
+ protected boolean isOTJlaunch() {
+ LaunchConfigurationTabGroupViewer viewer = getTabViewer();
+ if (viewer == null) return false;
+ ILaunchConfigurationWorkingCopy workingCopy = viewer.getWorkingCopy();
+ if (workingCopy == null) return false;
+ try {
+ return workingCopy.getAttribute(OTDebugPlugin.OT_LAUNCH, false)
+ && workingCopy.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, (String)null) == null;
+ } catch (CoreException e) {
+ return false;
+ }
+ }
+ }
+ /** Only exposing one inaccessible method. */
+ protected class LaunchConfigurationTabGroupViewer playedBy LaunchConfigurationTabGroupViewer {
+ @SuppressWarnings("decapsulation")
+ ILaunchConfigurationWorkingCopy getWorkingCopy() -> ILaunchConfigurationWorkingCopy getWorkingCopy();
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor2.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor2.java
new file mode 100644
index 000000000..23c50e214
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor2.java
@@ -0,0 +1,35 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: DebugUIDialogAdaptor2.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import base org.eclipse.jdt.internal.debug.ui.launcher.LocalJavaApplicationTabGroup;
+
+/**
+ * Apply adaptations of the super team to a class from org.eclipse.jdt.debug.ui.
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+@SuppressWarnings("restriction")
+public team class DebugUIDialogAdaptor2 extends DebugUIDialogAdaptor {
+ protected class JDTTabGroup
+ extends LaunchConfigurationTabGroup
+ playedBy LocalJavaApplicationTabGroup
+ {
+ // empty role, just advise OT/Equinox to weave into one more base class. See Trac #145
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor3.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor3.java
new file mode 100644
index 000000000..81d475a26
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/DebugUIDialogAdaptor3.java
@@ -0,0 +1,35 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: DebugUIDialogAdaptor3.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import base org.eclipse.jdt.internal.junit.launcher.JUnitTabGroup;
+
+/**
+ * Apply adaptations of the super team to a class from org.eclipse.jdt.junit
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+@SuppressWarnings("restriction")
+public team class DebugUIDialogAdaptor3 extends DebugUIDialogAdaptor2 {
+ protected class JUnitTabGroup
+ extends LaunchConfigurationTabGroup
+ playedBy JUnitTabGroup
+ {
+ // empty, just advise OT/Equinox to weave into one more base class. See Trac #145
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTDebugUILaunchingAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTDebugUILaunchingAdaptor.java
new file mode 100644
index 000000000..a7fbbf822
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTDebugUILaunchingAdaptor.java
@@ -0,0 +1,136 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: JDTDebugUILaunchingAdaptor.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.internal.debug.ui.jres.JREsComboBlock;
+import org.eclipse.objectteams.otdt.debug.IOTLaunchConstants;
+import org.eclipse.objectteams.otdt.ui.OTDTUIPlugin;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+import base org.eclipse.jdt.debug.ui.launchConfigurations.JavaConnectTab;
+import base org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
+
+/**
+ * This team adds a new section to the JRE tab containing
+ * <ul>
+ * <li>a checkbox "Enable OTRE"
+ * <li>a checkbox "Use JPLIS (experimental)"
+ * </ul>
+ * If this box is enabled, launching will happen in OT/J mode, which is
+ * managed by the {@link JDTLaunchingAdaptor}.
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+@SuppressWarnings("restriction")
+public team class JDTDebugUILaunchingAdaptor {
+
+ /**
+ * Adds the "use JPLIS" option to an OTREBlock, and also connects the OTREBlock to its base.
+ */
+ protected class JavaJRETab extends OTREBlock playedBy JavaJRETab {
+
+ Button _jplisToggleButton;
+ boolean _useJPLIS = true;
+
+ // === Imports (callout) : ===
+ @SuppressWarnings("decapsulation")
+ Control getJREControl() -> get JREsComboBlock fJREBlock
+ with { result <- fJREBlock.getControl() }
+
+ @SuppressWarnings("decapsulation")
+ Button createCheckButton(Composite arg0, String arg1) -> Button createCheckButton(Composite arg0, String arg1);
+
+ @SuppressWarnings("decapsulation")
+ void setDirty(boolean dirty) -> void setDirty(boolean dirty);
+
+ @SuppressWarnings("decapsulation")
+ void updateLaunchConfigurationDialog() -> void updateLaunchConfigurationDialog();
+
+ // build the GUI:
+ Group createOTRESection(Composite parent) <- after void createControl(Composite parent);
+ public Group createOTRESection(Composite parent) {
+ Composite enclosingComposite = (Composite) this.getJREControl();
+ Group group = super.createOTRESection(enclosingComposite, true/*useSWTFactory*/);
+ this._jplisToggleButton = createCheckButton(group, OTDTUIPlugin.getResourceString("OTJavaMainTab.jplis_checkbox_label")); //$NON-NLS-1$
+ this._jplisToggleButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ JavaJRETab.this._useJPLIS = JavaJRETab.this._jplisToggleButton.getSelection();
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+ });
+ return group;
+ }
+
+ // read stored value:
+ void initializeFrom(ILaunchConfiguration config) <- after void initializeFrom(ILaunchConfiguration config);
+
+ protected void tryInitializeFrom(ILaunchConfiguration config, boolean hasOTJProject) throws CoreException {
+ super.tryInitializeFrom(config, hasOTJProject);
+ this._jplisToggleButton.setEnabled(hasOTJProject);
+ this._useJPLIS = config.getAttribute(IOTLaunchConstants.ATTR_USE_JPLIS, this._useJPLIS);
+ this._jplisToggleButton.setSelection(this._useJPLIS);
+ }
+
+ // apply value change:
+ void performApply(ILaunchConfigurationWorkingCopy config)
+ <- after void performApply(ILaunchConfigurationWorkingCopy config);
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ super.performApply(config);
+ config.setAttribute(IOTLaunchConstants.ATTR_USE_JPLIS, this._useJPLIS);
+ }
+ }
+
+ /** Add an OTRE block to the "Connect" tab for remote debugging. */
+ @SuppressWarnings("decapsulation")
+ protected class JavaConnectTab extends OTREBlock playedBy JavaConnectTab {
+
+ Control getControl() -> Control getControl();
+
+ void createVerticalSpacer(Composite comp, int colSpan) -> void createVerticalSpacer(Composite comp, int colSpan);
+
+ Button createCheckButton(Composite parent, String label) -> Button createCheckButton(Composite parent, String label);
+
+ void setDirty(boolean dirty) -> void setDirty(boolean dirty);
+
+ void updateLaunchConfigurationDialog() -> void updateLaunchConfigurationDialog();
+
+ // build the GUI:
+ Group createOTRESection(Composite parent) <- after void createControl(Composite parent);
+ public Group createOTRESection(Composite parent) {
+ Composite enclosingComposite = (Composite) this.getControl();
+ createVerticalSpacer(enclosingComposite, 10);
+ Group group = super.createOTRESection(enclosingComposite, true/*useSWTFactory*/);
+ return group;
+ }
+
+ // hook the trigger for passing the ot-launch attribute:
+ void performApply(ILaunchConfigurationWorkingCopy config)
+ <- after void performApply(ILaunchConfigurationWorkingCopy config);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
new file mode 100644
index 000000000..397e51431
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JDTLaunchingAdaptor.java
@@ -0,0 +1,209 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: JDTLaunchingAdaptor.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+import org.eclipse.objectteams.otdt.core.ext.OTRuntimeClasspathProvider;
+import org.eclipse.objectteams.otdt.debug.IOTLaunchConstants;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.debug.OTVMRunnerAdaptor;
+import org.eclipse.objectteams.otdt.debug.TeamBreakpointInstaller;
+import org.eclipse.pde.internal.ui.IPDEUIConstants;
+
+import base org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
+import base org.eclipse.jdt.launching.StandardClasspathProvider;
+
+/**
+ * This team observes java launches and potentially modifies them for OT/J capabilities.
+ * <ul>
+ * <li>Add BCEL and JMangler to the classpath (role {@link ClasspathExtender})
+ * <li>Maintain an OTVMRunnerAdaptor for adapting vm- and program args (role {@link JDTLaunchingAdaptor.AbstractJavaLaunchConfigurationDelegate}).
+ * </ul>
+ * Role {@link JDTLaunchingAdaptor.JavaLaunchDelegate} only binds the above behavior into Java launches.
+ * See {@link JUnitLaunchingAdaptor.JUnitLaunchConfigurationDelegate} for equal binding to JUnit launches.
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+@SuppressWarnings("restriction")
+public team class JDTLaunchingAdaptor {
+
+ /**
+ * This role extends the classpath with BCEL and JMangler paths if OT/J is enabled for the launch.
+ */
+ protected class ClasspathExtender playedBy StandardClasspathProvider {
+
+ IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration config)
+ <- replace IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration config);
+
+ callin IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration config) throws CoreException
+ {
+ IRuntimeClasspathEntry[] origEntries = base.computeUnresolvedClasspath(config);
+
+ boolean useJMangler = isNormalOTJLaunch(config);
+ if (!useJMangler && !isJPLISOTJLaunch(config))
+ return origEntries;
+
+ // add BCEL, JMangler-core and JMangler-start (classpath / bootclasspath)
+ int oldLength = origEntries.length;
+ IRuntimeClasspathEntry[] otRuntimeEntries = computePathsToAdd(origEntries, useJMangler);
+
+ // merge results:
+ IRuntimeClasspathEntry[] result = new IRuntimeClasspathEntry[oldLength + otRuntimeEntries.length];
+ System.arraycopy(origEntries, 0, result, 0, oldLength);
+ System.arraycopy(otRuntimeEntries, 0, result, oldLength, otRuntimeEntries.length);
+ return result;
+ }
+
+ static IRuntimeClasspathEntry[] computePathsToAdd( IRuntimeClasspathEntry[] origEntries, boolean useJMangler )
+ {
+ boolean hasBCEL = false;
+ boolean hasJManglerCore = false;
+ boolean hasJManglerStart = false;
+ boolean hasOTRE_min = false;
+
+ for (int i = 0; i < origEntries.length; i++)
+ {
+ IRuntimeClasspathEntry entry = origEntries[i];
+ if (OTRuntimeClasspathProvider.BCEL_JAR.equals(entry.getPath()))
+ hasBCEL = true;
+ else if (OTREContainer.OTRE_JAR_PATH.equals(entry.getPath().toString()))
+ hasOTRE_min = true;
+ }
+
+ List<IRuntimeClasspathEntry> result = new LinkedList<IRuntimeClasspathEntry>();
+ IRuntimeClasspathEntry entry;
+
+ if (!hasBCEL) {
+ entry = JavaRuntime.newArchiveRuntimeClasspathEntry(OTRuntimeClasspathProvider.BCEL_JAR);
+ entry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
+ result.add(entry);
+ }
+
+ if (!hasJManglerCore && useJMangler) {
+ throw new RuntimeException("JMangler is no longer supported");
+ }
+
+ if (!hasJManglerStart && useJMangler) {
+ throw new RuntimeException("JMangler is no longer supported");
+ }
+
+ if (!hasOTRE_min && !useJMangler) {
+ entry = JavaRuntime.newArchiveRuntimeClasspathEntry(JavaCore.getResolvedVariablePath(new Path(OTREContainer.OTRE_MIN_JAR_PATH)));
+ entry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
+ result.add(entry);
+ }
+
+ return result.toArray(new IRuntimeClasspathEntry[result.size()]);
+ }
+
+ }
+
+ /**
+ * This role performs the adaptations of vmargs and program args (including main class name).
+ */
+ protected class AbstractJavaLaunchConfigurationDelegate playedBy AbstractJavaLaunchConfigurationDelegate
+ {
+ IJavaProject getJavaProject(ILaunchConfiguration arg0) -> IJavaProject getJavaProject(ILaunchConfiguration arg0);
+
+ OTVMRunnerAdaptor fAdaptor;
+ boolean useJMangler = false;
+ String fOriginalMain;
+
+ // --- Initiate adaptations: (this callin actually applies to sub-base-classes)
+ void prepareLaunch(ILaunchConfiguration config, String mode, ILaunch launch)
+ <- before void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor);
+ void prepareLaunch(ILaunchConfiguration config, String mode, ILaunch launch) throws CoreException
+ {
+ this.fOriginalMain = null; // reset potential left over from previous launching
+ this.useJMangler = isNormalOTJLaunch(config);
+ if (!this.useJMangler && !isJPLISOTJLaunch(config)) {
+ this.fAdaptor = null;
+ return;
+ }
+ this.fAdaptor = new OTVMRunnerAdaptor();
+ this.fAdaptor.setAdaptationArgs(config, mode, launch);
+ // install OT-breakpoints
+ if (ILaunchManager.DEBUG_MODE.equals(mode))
+ TeamBreakpointInstaller.installTeamBreakpoints(getJavaProject(config));
+ }
+
+ // --- Main Type Name: ---
+ String verifyMainTypeName(ILaunchConfiguration config)
+ <- replace String verifyMainTypeName(ILaunchConfiguration config)
+ when (this.useJMangler);
+
+ callin String verifyMainTypeName(ILaunchConfiguration config) throws CoreException {
+ throw new RuntimeException("JMangler is no longer supported");
+ }
+
+ // --- VM Arguments: ---
+ String getVMArguments(ILaunchConfiguration configuration)
+ <- replace String getVMArguments(ILaunchConfiguration configuration)
+ when (this.fAdaptor != null);
+
+
+ callin String getVMArguments(ILaunchConfiguration config) throws CoreException {
+ String vmArgs = base.getVMArguments(config);
+ return this.fAdaptor.adaptVMArgumentString(vmArgs);
+ }
+
+ // --- Program Arguments: ---
+ String getProgramArguments(ILaunchConfiguration config)
+ <- replace String getProgramArguments(ILaunchConfiguration config)
+ when (this.fOriginalMain != null);
+
+ callin String getProgramArguments(ILaunchConfiguration config) throws CoreException {
+ String programArguments = base.getProgramArguments(config);
+ return this.fOriginalMain + ' ' + programArguments;
+ }
+ }
+
+ static boolean isNormalOTJLaunch(ILaunchConfiguration config) {
+ try {
+ return config.getAttribute(OTDebugPlugin.OT_LAUNCH, false) // OT/J ?
+ && !config.getAttribute(IOTLaunchConstants.ATTR_USE_JPLIS, false) // not JPLIS ?
+ && (config.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, (String)null) == null); // not PDE ?
+ } catch (CoreException e) {
+ return false; // don't apply adaptations to bogus config
+ }
+ }
+
+ static boolean isJPLISOTJLaunch(ILaunchConfiguration config) {
+ try {
+ return config.getAttribute(OTDebugPlugin.OT_LAUNCH, false) // OT/J ?
+ && config.getAttribute(IOTLaunchConstants.ATTR_USE_JPLIS, false) // JPLIS ?
+ && (config.getAttribute(IPDEUIConstants.LAUNCHER_PDE_VERSION, (String)null) == null); // not PDE ?
+ } catch (CoreException e) {
+ return false; // don't apply adaptations to bogus config
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JUnitLaunchingAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JUnitLaunchingAdaptor.java
new file mode 100644
index 000000000..1c5b3ef98
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/JUnitLaunchingAdaptor.java
@@ -0,0 +1,37 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: JUnitLaunchingAdaptor.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import base org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate;
+
+/**
+ * This team hooks the adaptation of its super team into JUnit launches.
+ * Note, that only an instance of this sub-team is activated a boot-time.
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+public team class JUnitLaunchingAdaptor extends JDTLaunchingAdaptor {
+
+ protected class JUnitLaunchConfigurationDelegate
+ extends AbstractJavaLaunchConfigurationDelegate
+ playedBy JUnitLaunchConfigurationDelegate
+ {
+ // empty: this role only helps OT/Equinox so that it will weave into an overriding method.
+ // all adaptations are defined in the super role.
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/LaunchConfigurationInitializer.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/LaunchConfigurationInitializer.java
new file mode 100644
index 000000000..8ca229aba
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/LaunchConfigurationInitializer.java
@@ -0,0 +1,81 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: LaunchConfigurationInitializer.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.LaunchUtils;
+
+import base org.eclipse.debug.internal.core.LaunchConfigurationType;
+import base org.eclipse.debug.internal.core.LaunchConfigurationWorkingCopy;
+
+/**
+ * This team observes creation of launch configurations and initializes the
+ * org.eclipse.objectteams.launch attribute accordingly.
+ *
+ * @author stephan
+ * @since 1.2.1
+ */
+@SuppressWarnings("restriction")
+public team class LaunchConfigurationInitializer {
+
+ /**
+ * Observe creation of new instances.
+ */
+ protected class LaunchConfigurationType playedBy LaunchConfigurationType {
+
+ void acceptInstance(LaunchConfigWC inst)
+ <- after ILaunchConfigurationWorkingCopy newInstance(IContainer container, String name)
+ with { inst <- (LaunchConfigurationWorkingCopy)result }
+
+ void acceptInstance(LaunchConfigWC inst) {
+ // nop, just lifting. Role will take over.
+ }
+ }
+
+ /**
+ * While an instance is still new (= role exists) wait for the project name to be set.
+ */
+ protected class LaunchConfigWC playedBy LaunchConfigurationWorkingCopy
+ base when (LaunchConfigurationInitializer.this.hasRole(base, LaunchConfigWC.class))
+ {
+ // callout interface:
+ boolean getAttribute(String key, boolean dflt) -> boolean getAttribute(String key, boolean dflt);
+ void setAttribute(String key, boolean val) -> void setAttribute(String key, boolean val);
+
+ void setAttribute(String key, String value) <- after void setAttribute(String key, String value);
+ void setAttribute(String key, String value) {
+ if (key.equals(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME)) {
+ try {
+ if ( LaunchUtils.isOTJProject(value)
+ && !getAttribute(OTDebugPlugin.OT_LAUNCH, false))
+ {
+ setAttribute(OTDebugPlugin.OT_LAUNCH, true);
+ }
+ } catch (CoreException e) {
+ OTDebugPlugin.getExceptionHandler().logException("Error getting a launch configuration attribute", e); //$NON-NLS-1$
+ }
+ // this role has served its purpose - unregister now:
+ LaunchConfigurationInitializer.this.unregisterRole(this, LaunchConfigWC.class);
+ }
+ return;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTLaunchConfigurationTab.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTLaunchConfigurationTab.java
new file mode 100644
index 000000000..bc85d8cfd
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTLaunchConfigurationTab.java
@@ -0,0 +1,216 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2009 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTLaunchConfigurationTab.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.objectteams.otdt.core.IOTType;
+import org.eclipse.objectteams.otdt.core.OTModelManager;
+import org.eclipse.objectteams.otdt.debug.IOTLaunchConstants;
+import org.eclipse.objectteams.otdt.ui.ImageConstants;
+import org.eclipse.objectteams.otdt.ui.ImageManager;
+import org.eclipse.objectteams.otdt.ui.OTDTUIPlugin;
+
+/**
+ * This class provides the "Team Activation" tab to the launch dialog.
+ *
+ * @author gis
+ * @version $Id: OTLaunchConfigurationTab.java 23456 2010-02-04 20:44:45Z stephan $
+ */
+public class OTLaunchConfigurationTab extends AbstractLaunchConfigurationTab implements ILaunchConfigurationTab
+{
+ private List<IType> _teamModel = new ArrayList<IType>();
+
+ private TeamConfig _teamConfig;
+ private IProject _project = null;
+
+ public void createControl(Composite parent)
+ {
+ _teamConfig = new TeamConfig(parent, SWT.NONE, this);
+ setControl(_teamConfig);
+ setMessage(OTDTUIPlugin.getResourceString("TeamConfig.cannot_instantiate_message")); //$NON-NLS-1$
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration)
+ {
+ // nothing to do -- empty defaults
+ }
+
+ public void initializeFrom(ILaunchConfiguration configuration)
+ {
+ _teamModel.clear();
+
+ List teamHandles = new LinkedList();
+ boolean teamsActive = true;
+ try {
+ teamHandles = configuration.getAttribute(IOTLaunchConstants.ATTR_TEAMCONFIG_LIST, teamHandles);
+ teamsActive = configuration.getAttribute(IOTLaunchConstants.ATTR_TEAMCONFIG_ACTIVE, true);
+ } catch (CoreException ce) {
+ OTDTUIPlugin.getExceptionHandler().logCoreException("Cannot read team configuration", ce); //$NON-NLS-1$
+ }
+
+ _teamConfig.clearTeamList();
+ List<String> badTeams = new LinkedList<String>();
+ for (Iterator iter = teamHandles.iterator(); iter.hasNext();) {
+ String teamHandle = (String) iter.next();
+ IType type = (IType) JavaCore.create(teamHandle);
+ if (type != null)
+ {
+ if (type.exists())
+ {
+ IOTType otType = OTModelManager.getOTElement(type);
+ if (otType != null)
+ {
+ _teamModel.add(otType);
+ continue;
+ }
+ }
+ badTeams.add(type.getFullyQualifiedName());
+ }
+ else
+ badTeams.add(teamHandle);
+ }
+
+ reportBadTeams(badTeams);
+
+ _teamConfig.setActive(teamsActive);
+ _teamConfig.setTeamInput(_teamModel);
+ _teamConfig.checkEnablement();
+
+ String projectName = getProjectFromConfig(configuration);
+ if (projectName.length() != 0)
+ _project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ else
+ _project = null;
+ }
+
+ private void reportBadTeams(List<String> badTeams)
+ {
+ // TODO (carp): ideally, we need some sort of listener that notices renaming and deleting of classes
+ // so that the launch configuration can be updated.
+ if (!badTeams.isEmpty())
+ {
+ StringBuffer message = new StringBuffer(OTDTUIPlugin.getResourceString("TeamConfig.not_found_message")); //$NON-NLS-1$
+ for (Iterator<String> iter = badTeams.iterator(); iter.hasNext();)
+ {
+ String badTeam = iter.next();
+ message.append(badTeam + '\n');
+ }
+ setModified(); // otherwise, the bad configuration will be kept!
+ setErrorMessage(message.toString()); // this should actually be a warning, not an error
+ }
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy configuration)
+ {
+ removeUnavailableTeamsErrorMessage(); // not really
+
+ List<String> teamHandles = getTeamModelAsHandles();
+
+ configuration.setAttribute(IOTLaunchConstants.ATTR_TEAMCONFIG_LIST, teamHandles);
+ configuration.setAttribute(IOTLaunchConstants.ATTR_TEAMCONFIG_ACTIVE, _teamConfig.isActive());
+ }
+
+ private void removeUnavailableTeamsErrorMessage()
+ {
+ // well, actually this removes any error message of this tab, but this is our
+ // only one, so far (and actually should be a warning instead of an error)
+ setErrorMessage(null);
+ getLaunchConfigurationDialog().updateMessage();
+ }
+
+ public String getName()
+ {
+ return OTDTUIPlugin.getResourceString("TeamConfig.tab_title"); //$NON-NLS-1$
+ }
+
+ public Image getImage()
+ {
+ return ImageManager.getSharedInstance().get(ImageConstants.TEAM_IMG);
+ }
+
+ /**
+ *
+ */
+ public void setModified()
+ {
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+
+ private String getProjectFromConfig(ILaunchConfiguration config)
+ {
+ String projectName= ""; //$NON-NLS-1$
+ try {
+ projectName= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
+ } catch (CoreException ce) {
+ OTDTUIPlugin.getExceptionHandler().logCoreException("Unable to retrieve _project from launch configuration", ce); //$NON-NLS-1$
+ }
+ return projectName;
+ }
+
+ public IProject getProject() {
+ return _project;
+ }
+
+ public List<IType> getTeamModel()
+ {
+ return _teamModel;
+ }
+
+ /**
+ * Converts the List<IOTType> _teamModel to a new List<String>, consisting of all
+ * ITypes' HandleIdentifiers.
+ * @return the new list
+ */
+ private List<String> getTeamModelAsHandles()
+ {
+ List<String> teamHandles = new LinkedList<String>();
+ for (Iterator<IType> iter = _teamModel.iterator(); iter.hasNext();)
+ {
+ IType type = iter.next();
+ teamHandles.add(type.getHandleIdentifier());
+ }
+ return teamHandles;
+ }
+
+ public IRunnableContext getRunnableContext()
+ {
+ return getLaunchConfigurationDialog();
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTREBlock.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTREBlock.java
new file mode 100644
index 000000000..45655c69d
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/OTREBlock.java
@@ -0,0 +1,126 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: OTREBlock.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.debug.ui.SWTFactory;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.DebugMessages;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.OTDebugAdaptorPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * Common addition for all launches, Java App or OSGi.
+ * Adds the "Object Teams Runtime" section.
+ *
+ * Applied via subclasses (roles).
+ *
+ * @author stephan
+ * @since 1.2.2
+ */
+@SuppressWarnings("restriction")
+public abstract class OTREBlock
+{
+ protected String enableCheckboxLabel = DebugMessages.OTLaunching_OTRE_checkbox_label; // overidable default
+
+ Button _otreToggleButton;
+ boolean _useOTRE;
+
+ public abstract Button createCheckButton(Composite group, String resourceString);
+ public abstract void setDirty(boolean dirty);
+ public abstract void updateLaunchConfigurationDialog();
+
+ // create the "Object Teams Runtime" section:
+ public Group createOTRESection(Composite parent, boolean useSWTFactory) {
+ Group group;
+ if (useSWTFactory) {
+ group = SWTFactory.createGroup(parent, DebugMessages.OTLaunching_OTRE_group_title+':', 1, 1, GridData.FILL_HORIZONTAL);
+ } else {
+ group = new Group(parent, SWT.NONE);
+ group.setText(DebugMessages.OTLaunching_OTRE_group_title);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ this._otreToggleButton = createCheckButton(group, this.enableCheckboxLabel);
+ this._otreToggleButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e) {
+ OTREBlock.this._useOTRE = OTREBlock.this._otreToggleButton.getSelection();
+ setDirty(true);
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ return group;
+ }
+
+ // read values from 'config':
+ public void initializeFrom(ILaunchConfiguration config) {
+ try {
+ tryInitializeFrom(config, hasOTJProject(config));
+ }
+ catch (CoreException ex) {
+ OTDebugAdaptorPlugin.getDefault().getLog().log(
+ new Status(Status.ERROR,
+ OTDebugAdaptorPlugin.PLUGIN_ID,
+ DebugMessages.OTLaunching_loading_failed_msg,
+ ex));
+ }
+ }
+ protected void tryInitializeFrom(ILaunchConfiguration config, boolean hasOTJProject) throws CoreException {
+ this._otreToggleButton.setEnabled(hasOTJProject);
+ this._useOTRE = config.getAttribute(OTDebugPlugin.OT_LAUNCH, this._useOTRE);
+ this._otreToggleButton.setSelection(this._useOTRE);
+ }
+
+ boolean hasOTJProject(ILaunchConfiguration config) {
+ try {
+ String projectName = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
+ if (projectName != null) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (project != null && project.hasNature(JavaCore.OTJ_NATURE_ID))
+ return true;
+ }
+ } catch (CoreException e) {
+ // problems with either config or project, obviously not a sound OT-launch
+ }
+ return false;
+ }
+
+ // apply the value from the checkbox:
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ if (this._otreToggleButton != null)
+ config.setAttribute(OTDebugPlugin.OT_LAUNCH, this._useOTRE);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/PDELaunchingAdaptor.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/PDELaunchingAdaptor.java
new file mode 100644
index 000000000..b651668a0
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/PDELaunchingAdaptor.java
@@ -0,0 +1,254 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: PDELaunchingAdaptor.java 23461 2010-02-04 22:10:39Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.util.Util;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.debug.TeamBreakpointInstaller;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.DebugMessages;
+import org.eclipse.objectteams.otdt.internal.debug.adaptor.OTDebugAdaptorPlugin;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+import base org.eclipse.pde.internal.ui.launcher.JREBlock;
+import base org.eclipse.pde.ui.launcher.AbstractLauncherTab;
+import base org.eclipse.pde.launching.AbstractPDELaunchConfiguration;
+import base org.eclipse.pde.launching.JUnitLaunchConfigurationDelegate;
+
+/**
+ * This team adapts all Eclipse and OSGi launches (Launcher) and launch configurations (JREBlock and LauncherTab).
+ *
+ * @author stephan
+ * @since 1.2.2
+ */
+@SuppressWarnings("restriction")
+public team class PDELaunchingAdaptor {
+
+ /** Mediating between LauncherTab and JREBlock: */
+ LauncherTab currentTab = null;
+
+ static final String OSGI_EXTENSIONS = "-Dosgi.framework.extensions=org.eclipse.objectteams.otequinox.hook"; //$NON-NLS-1$
+ static final String HOOK_CONFIGURATOR = "-Dosgi.hook.configurators.include=org.eclipse.objectteams.otequinox.hook.HookConfigurator";//$NON-NLS-1$
+ static final String CLASSLOADER_LOCKING = "-Dosgi.classloader.lock=classname"; //$NON-NLS-1$
+ static final String ENABLE_OTEQUINOX = "-Dot.equinox=1"; //$NON-NLS-1$ // this also causes the WORKAROUND_REPOSITORY flag being set to true in OTRE.
+ static final String DISABLE_OTEQUINOX = "-Dot.equinox=false"; //$NON-NLS-1$ // prevents TransformerHook installation and start of TransformerPlugin
+ static final String OT_DEBUG_VMARG = "-Dot.debug"; //$NON-NLS-1$
+ static final String[] OT_VM_ARGS = { OSGI_EXTENSIONS, HOOK_CONFIGURATOR, CLASSLOADER_LOCKING, ENABLE_OTEQUINOX };
+ static final String[] OT_VM_DEBUG_ARGS = { OSGI_EXTENSIONS, HOOK_CONFIGURATOR, CLASSLOADER_LOCKING, ENABLE_OTEQUINOX, OT_DEBUG_VMARG };
+ static final String[] VM_ARGS = { CLASSLOADER_LOCKING, DISABLE_OTEQUINOX };
+ static final String[] VM_DEBUG_ARGS = { CLASSLOADER_LOCKING, DISABLE_OTEQUINOX, OT_DEBUG_VMARG };
+
+ /**
+ * Extend pre-built vm arguments with OT/Equinox specifics (depending on run/debug mode).
+ */
+ static String[] extendVMArguments(String[] args, String mode) {
+ String[] otArgs = OT_VM_ARGS;
+ if (mode != null && mode.equals(ILaunchManager.DEBUG_MODE))
+ otArgs = OT_VM_DEBUG_ARGS;
+
+ if (args == null || args.length == 0)
+ return otArgs;
+
+ String[] combinedArgs = new String[args.length + otArgs.length];
+ System.arraycopy(args, 0, combinedArgs, 0, args.length);
+ System.arraycopy(otArgs, 0, combinedArgs, args.length, otArgs.length);
+ return combinedArgs;
+ }
+ static String[] addDisableOTEquinoxArgument(String[] args) {
+ String[] combinedArgs = new String[args.length + 1];
+ System.arraycopy(args, 0, combinedArgs, 0, args.length);
+ combinedArgs[args.length] = DISABLE_OTEQUINOX;
+ return combinedArgs;
+ }
+ /* alternate version for single string signature. */
+ static String extendVMArguments(String args, String mode) {
+ String otArgs;
+ if (mode != null && mode.equals(ILaunchManager.DEBUG_MODE))
+ otArgs = Util.concatWith(OT_VM_DEBUG_ARGS, ' ');
+ else
+ otArgs = Util.concatWith(OT_VM_ARGS, ' ');
+
+ if (args == null || args.length() == 0)
+ return otArgs;
+
+ return args+' '+otArgs;
+ }
+
+ /**
+ * Installs breakpoints needed for the TeamMonitor into org.objectteams.Team.
+ * Needs to find a project with OTJavaNature to do this.
+ */
+ static void installOOTBreakpoints(IProject[] projects) throws CoreException
+ {
+ if (projects != null)
+ for (IProject project : projects)
+ // find org.objectteams.Team in any OT/J Project:
+ if (project.getNature(JavaCore.OTJ_NATURE_ID) != null) {
+ TeamBreakpointInstaller.installTeamBreakpoints(JavaCore.create(project));
+ return; // good, done.
+ }
+ logException(null, Status.WARNING, DebugMessages.OTLaunching_no_OTJ_project_found);
+ }
+
+ static void logException(CoreException ex, int level, String msg) {
+ OTDebugPlugin.getDefault().getLog().log(
+ new Status(level, OTDebugAdaptorPlugin.PLUGIN_ID, 0, msg, ex));
+ }
+
+ // helper needed to protect a guard from exception:
+ static boolean isOTLaunch (ILaunchConfiguration configuration) {
+ try {
+ return configuration.getAttribute(OTDebugPlugin.OT_LAUNCH, false);
+ } catch (CoreException ce) {
+ return false;
+ }
+ }
+
+ /** Generalizes over normal pde launches and JUnit plugin launches. */
+ abstract protected class AbstractLauncher
+ {
+ abstract IProject[] getProjectsForProblemSearch(ILaunchConfiguration config, String mode)
+ throws CoreException;
+
+ String mode;
+
+ void prepareLaunch(ILaunchConfiguration configuration, String mode)
+ {
+ this.mode = mode;
+ if (isOTLaunch(configuration) && ILaunchManager.DEBUG_MODE.equals(mode))
+ try {
+ PDELaunchingAdaptor.installOOTBreakpoints(getProjectsForProblemSearch(configuration, mode));
+ } catch (CoreException ex) {
+ logException(ex, Status.WARNING, DebugMessages.OTLaunching_no_OTJ_project_found);
+ }
+ }
+ }
+
+ /**
+ * This role adapts any pde-launch where the OT/Equinox flag is set to true:
+ * <ul>
+ * <li>add OT-specific arguments to the vm args (extendVMArguments)</li>
+ * <li>install the breakpoints needed by the TeamMonitor (prepareLaunch)</li>
+ * </ul>
+ */
+ protected class Launcher extends AbstractLauncher playedBy AbstractPDELaunchConfiguration
+ {
+ @SuppressWarnings("decapsulation")
+ getProjectsForProblemSearch -> getProjectsForProblemSearch;
+
+ // Extend VM arguments:
+ String[] extendVMArguments(ILaunchConfiguration config) <- replace String[] getVMArguments(ILaunchConfiguration config);
+ callin String[] extendVMArguments(ILaunchConfiguration config) throws CoreException
+ {
+ String[] args = base.extendVMArguments(config);
+ if (isOTLaunch(config))
+ return PDELaunchingAdaptor.extendVMArguments(args, this.mode);
+ else
+ return PDELaunchingAdaptor.addDisableOTEquinoxArgument(args);
+ }
+
+ // install breakpoints and record launch mode (run/debug):
+ prepareLaunch <- before launch;
+ }
+
+ /** Unfortunately JUnit launches are slightly different (and not related by inheritance) */
+ protected class JUnitLauncher extends AbstractLauncher playedBy JUnitLaunchConfigurationDelegate
+ {
+ @SuppressWarnings("decapsulation")
+ getProjectsForProblemSearch -> getProjectsForProblemSearch;
+
+ // Extend VM arguments:
+ String extendVMArgument(ILaunchConfiguration config) <- replace String getVMArguments(ILaunchConfiguration config);
+ callin String extendVMArgument(ILaunchConfiguration config) throws CoreException
+ {
+ String result = base.extendVMArgument(config);
+ if (isOTLaunch(config))
+ return PDELaunchingAdaptor.extendVMArguments(result, this.mode);
+ else
+ return result+' '+DISABLE_OTEQUINOX;
+ }
+
+ // install breakpoints and record launch mode (run/debug):
+ prepareLaunch <- before launch;
+ }
+
+ /**
+ * UI: This role allows us to insert our "Object Teams Runtime" block just after the JREBlock.
+ */
+ protected class JREBlock playedBy JREBlock {
+ // build the GUI:
+ void appendOTOption(Composite parent) <- after void createControl(Composite parent)
+ base when (PDELaunchingAdaptor.this.currentTab != null); // only within the LauncherTab#launcherTabCFlow() (see below)
+
+ void appendOTOption(Composite parent) {
+ PDELaunchingAdaptor.this.currentTab.createOTRESection(parent, false/*useSWTFactory*/);
+ }
+ }
+
+ /**
+ * This role manages the UI-part of this team:
+ * <ul>
+ * <li>insert a new group after the JREBlock.</li>
+ * <li>read (initializeFrom) and apply (performApply) the new flag.</li></ul>
+ */
+ protected class LauncherTab extends OTREBlock playedBy AbstractLauncherTab {
+
+ LauncherTab(AbstractLauncherTab b) {
+ // different label than default:
+ this.enableCheckboxLabel = DebugMessages.OTLaunching_OTEquinox_checkbox_label;
+ }
+
+ // callout interface:
+ @SuppressWarnings("decapsulation")
+ Button createCheckButton(Composite parent, String label) -> Button createCheckButton(Composite parent, String label);
+
+ @SuppressWarnings("decapsulation")
+ void setDirty(boolean dirty) -> void setDirty(boolean dirty);
+
+ void updateLaunchConfigurationDialog() -> void updateLaunchConfigurationDialog();
+
+ // CFlow to let the JREBlock trigger building the GUI:
+ launcherTabCFlow <- replace createControl;
+ callin void launcherTabCFlow(Composite parent) {
+ try {
+ PDELaunchingAdaptor.this.currentTab = this;
+ base.launcherTabCFlow(parent);
+ } finally {
+ PDELaunchingAdaptor.this.currentTab = null;
+ }
+ }
+
+ // connect triggers to inherited methods:
+ void initializeFrom(ILaunchConfiguration config) <- after void initializeFrom(ILaunchConfiguration config)
+ when (this._otreToggleButton != null); // i.e.: is this the tab containing the JREBlock?
+
+ @Override
+ boolean hasOTJProject(ILaunchConfiguration config) {
+ return true; // assume we might have an OT project - even without scanning through all projects; always want to enable our options
+ }
+
+ void performApply(ILaunchConfigurationWorkingCopy config)
+ <- after void performApply(ILaunchConfigurationWorkingCopy config);
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/TeamConfig.java b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/TeamConfig.java
new file mode 100644
index 000000000..41b7c951d
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug.adaptor/src/org/eclipse/objectteams/otdt/internal/debug/adaptor/launching/TeamConfig.java
@@ -0,0 +1,453 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2005, 2009 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: TeamConfig.java 23456 2010-02-04 20:44:45Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.internal.debug.adaptor.launching;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.Flags;
+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.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.jdt.ui.JavaElementLabels;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.objectteams.otdt.core.IOTType;
+import org.eclipse.objectteams.otdt.core.OTModelManager;
+import org.eclipse.objectteams.otdt.ui.OTDTUIPlugin;
+import org.eclipse.objectteams.otdt.ui.dialogs.ISearchFilter;
+import org.eclipse.objectteams.otdt.ui.dialogs.TeamSelectionDialog;
+
+/**
+ * Configuration data for the "Team Activation" tab.
+ *
+ * Created on 02.02.2005
+ * @author gis
+ */
+@SuppressWarnings("restriction")
+public class TeamConfig extends Composite
+{
+
+ private Button _downButton;
+ private Button _upButton;
+ private Button _removeButton;
+ private Button _addButton;
+ private OTLaunchConfigurationTab _otLaunchConfigTab;
+ private TableViewer _teamList;
+ private Button _activeCheckButton;
+
+ public TeamConfig(Composite parent, int style, OTLaunchConfigurationTab otlcTab)
+ {
+ super(parent, style);
+ _otLaunchConfigTab = otlcTab;
+
+ GridLayout grid = new GridLayout();
+ grid.numColumns = 1;
+ grid.marginWidth = 3;
+ setLayout(grid);
+
+ _activeCheckButton = new Button(this, SWT.CHECK);
+ _activeCheckButton.setText(OTDTUIPlugin.getResourceString("TeamConfig.activate_checkbox_description")); //$NON-NLS-1$
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
+ _activeCheckButton.setLayoutData(data);
+ _activeCheckButton.setFont(this.getFont());
+ _activeCheckButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ boolean active = isActive();
+ _teamList.getControl().setEnabled(active);
+ _otLaunchConfigTab.setModified();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ Composite mainCompo = new Composite(this, SWT.NULL);
+ mainCompo.setLayout(new FormLayout());
+ data = new GridData(GridData.FILL_BOTH);
+ mainCompo.setLayoutData(data);
+
+ _teamList = new TableViewer(mainCompo, SWT.BORDER|SWT.H_SCROLL|SWT.V_SCROLL);
+ AppearanceAwareLabelProvider labelProvider = new AppearanceAwareLabelProvider();
+ labelProvider.setTextFlags(JavaElementLabels.T_POST_QUALIFIED);
+ _teamList.setLabelProvider(labelProvider);
+
+ _teamList.setContentProvider(new IStructuredContentProvider() {
+ @SuppressWarnings("unchecked") // cast to generic list not supported
+ public Object[] getElements(Object inputElement)
+ {
+ if (inputElement instanceof List)
+ {
+ List<IType> list = (List<IType>) inputElement;
+ return list.toArray(new IType[list.size()]);
+ }
+ return null;
+ }
+
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+
+ _teamList.addPostSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+ checkEnablement();
+ }
+ });
+
+ final FormData formData = new FormData();
+ formData.right = new FormAttachment(100, -162);
+ formData.bottom = new FormAttachment(100, -5);
+ formData.top = new FormAttachment(0, 5);
+ formData.left = new FormAttachment(0, 2);
+ Control teamListControl = _teamList.getControl();
+ teamListControl.setLayoutData(formData);
+
+ final Composite composite_1 = new Composite(mainCompo, SWT.NONE);
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ composite_1.setLayout(gridLayout);
+ final FormData formData_1 = new FormData();
+ formData_1.left = new FormAttachment(teamListControl, 5, SWT.RIGHT);
+ formData_1.bottom = new FormAttachment(teamListControl, 0, SWT.BOTTOM);
+ formData_1.right = new FormAttachment(100, -5);
+ formData_1.top = new FormAttachment(teamListControl, 0, SWT.TOP);
+ composite_1.setLayoutData(formData_1);
+ _addButton = new Button(composite_1, SWT.NONE);
+ final GridData gridData = new GridData(GridData.FILL_HORIZONTAL| GridData.VERTICAL_ALIGN_BEGINNING);
+ _addButton.setLayoutData(gridData);
+ _addButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ askAddTeam();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ _addButton.setText(OTDTUIPlugin.getResourceString("TeamConfig.add_team_button_label")); //$NON-NLS-1$
+
+ _removeButton = new Button(composite_1, SWT.NONE);
+ final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL| GridData.VERTICAL_ALIGN_BEGINNING);
+ _removeButton.setLayoutData(gridData_1);
+ _removeButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ removeSelected();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ _removeButton.setText(OTDTUIPlugin.getResourceString("TeamConfig.remove_team_button_label")); //$NON-NLS-1$
+
+ _upButton = new Button(composite_1, SWT.NONE);
+ final GridData gridData_2 = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ gridData_2.horizontalSpan = 2;
+ _upButton.setLayoutData(gridData_2);
+ _upButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ moveSelectedUp();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ _upButton.setText(OTDTUIPlugin.getResourceString("TeamConfig.team_up_button_label")); //$NON-NLS-1$
+
+ _downButton = new Button(composite_1, SWT.NONE);
+ final GridData gridData_3 = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ _downButton.setLayoutData(gridData_3);
+ _downButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ moveSelectedDown();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ _downButton.setText(OTDTUIPlugin.getResourceString("TeamConfig.team_down_button_label")); //$NON-NLS-1$
+
+ }
+
+ public void dispose()
+ {
+ super.dispose();
+ }
+
+ protected void checkSubclass()
+ {
+ super.checkSubclass();
+ }
+
+// private class WidgetListener implements ModifyListener {
+// public void modifyText(ModifyEvent e) {
+// _otLaunchConfigTab.setModified();
+// }
+// public void widgetDefaultSelected(SelectionEvent e) {
+// }
+// }
+// private WidgetListener fListener = new WidgetListener();
+
+
+ private void addTeam(IType chosenTeam)
+ {
+ if (chosenTeam != null)
+ {
+ IType teamType = chosenTeam;
+ if (!(chosenTeam instanceof IOTType))
+ teamType = OTModelManager.getOTElement(chosenTeam);
+
+ if (teamType != null)
+ {
+ // TODO (carp): perform further checks (e.g. must have public default constructor)
+ _otLaunchConfigTab.getTeamModel().add(teamType);
+ _otLaunchConfigTab.setModified();
+ checkEnablement();
+ _teamList.refresh();
+ }
+ else
+ {
+ MessageDialog.openError(
+ getShell(),
+ OTDTUIPlugin.getResourceString("TeamConfig.error_adding_team_title"), //$NON-NLS-1$
+ MessageFormat.format(
+ OTDTUIPlugin.getResourceString("TeamConfig.error_adding_team_message"), new Object[] { chosenTeam.getFullyQualifiedName() })); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public void clearTeamList() {
+ _otLaunchConfigTab.getTeamModel().clear();
+ checkEnablement();
+ _teamList.refresh();
+ }
+
+ public boolean isActive() {
+ return _activeCheckButton.getSelection();
+ }
+
+ public void setActive(boolean active) {
+ _activeCheckButton.setSelection(active);
+ _teamList.getControl().setEnabled(active);
+ }
+
+ private IType chooseTeamFromClasspath(IProject project) {
+ if (project == null || !project.exists())
+ return null;
+
+ IJavaProject java_project = JavaCore.create(project);
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{ java_project});
+
+ TeamSelectionDialog dialog = new TeamSelectionDialog(
+ TeamConfig.this.getShell(),
+ _otLaunchConfigTab.getRunnableContext(),
+ scope);
+
+ dialog.setTitle(OTDTUIPlugin.getResourceString("TeamConfig.choose_team_dialog_title")); //$NON-NLS-1$
+ dialog.setMessage(OTDTUIPlugin.getResourceString("TeamConfig.choose_team_dialog_description")); //$NON-NLS-1$
+ dialog.setFilter("*"); //$NON-NLS-1$
+ dialog.addSearchFilter(new ISearchFilter() {
+ public IOTType[] filterTypes(IOTType[] types)
+ {
+ List teamModel = _otLaunchConfigTab.getTeamModel();
+ List<IOTType> result = new ArrayList<IOTType>(types.length);
+ for (int i = 0; i < types.length; i++)
+ {
+ IOTType type = types[i];
+ // hide abstract teams and those already in the list
+ if (!Flags.isAbstract(type.getFlags()) && !teamModel.contains(type))
+ result.add(type);
+ }
+
+ return result.toArray(new IOTType[result.size()]);
+ }
+ });
+
+
+ if (dialog.open() == Window.OK) {
+ IType selectedType = (IType) dialog.getFirstResult();
+ return selectedType;
+ }
+
+ return null;
+ }
+
+ private void removeSelected()
+ {
+ IStructuredSelection selection = (IStructuredSelection)_teamList.getSelection();
+ for (Iterator iterator = selection.iterator(); iterator.hasNext();)
+ {
+ IType selectedType = (IType) iterator.next();
+ _otLaunchConfigTab.getTeamModel().remove(selectedType);
+ }
+ _otLaunchConfigTab.setModified();
+ checkEnablement();
+ _teamList.refresh();
+ }
+
+ private void askAddTeam()
+ {
+ IProject project = _otLaunchConfigTab.getProject();
+ if (project == null)
+ {
+ MessageDialog.openInformation(getShell(), OTDTUIPlugin.getResourceString("TeamConfig.project_not_set_title"), OTDTUIPlugin.getResourceString("TeamConfig.project_not_set_message")); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // TODO: check if the selected team has a default constructor, otherwise give an error message.
+ IType chosenTeam = chooseTeamFromClasspath(project);
+ if (chosenTeam != null)
+ {
+ addTeam(chosenTeam);
+ }
+ }
+
+ private void moveSelectedUp()
+ {
+ List<IType> teamModel = _otLaunchConfigTab.getTeamModel();
+
+ final int currentIndex = getTeamSelectionIndex();
+ if (currentIndex > 0) {
+ IType currentTeam = teamModel.get(currentIndex);
+ IType aboveTeam = teamModel.get(currentIndex - 1);
+ teamModel.set(currentIndex - 1, currentTeam);
+ teamModel.set(currentIndex, aboveTeam);
+ _teamList.refresh();
+ _otLaunchConfigTab.setModified();
+
+ checkMoveEnablement();
+ }
+ }
+
+ private void moveSelectedDown()
+ {
+ List<IType> teamModel = _otLaunchConfigTab.getTeamModel();
+
+ final int currentIndex = getTeamSelectionIndex();
+ if (currentIndex < _otLaunchConfigTab.getTeamModel().size() - 1) {
+ IType currentTeam = teamModel.get(currentIndex);
+ IType belowTeam = teamModel.get(currentIndex + 1);
+ teamModel.set(currentIndex + 1, currentTeam);
+ teamModel.set(currentIndex, belowTeam);
+ _teamList.refresh();
+ _otLaunchConfigTab.setModified();
+
+ checkMoveEnablement();
+ }
+ }
+
+
+ void checkEnablement()
+ {
+ checkMoveEnablement();
+ checkActiveEnablement();
+
+ if (_teamList.getSelection().isEmpty())
+ {
+ _removeButton.setEnabled(false);
+ }
+ else
+ {
+ _removeButton.setEnabled(true);
+ }
+ }
+
+ private void checkActiveEnablement()
+ {
+ boolean enable = !_otLaunchConfigTab.getTeamModel().isEmpty();
+ _activeCheckButton.setEnabled(enable);
+ }
+
+ private void checkMoveEnablement()
+ {
+ final int index = getTeamSelectionIndex();
+
+ if (index == -1)
+ {
+ _upButton.setEnabled(false);
+ _downButton.setEnabled(false);
+ return;
+ }
+
+ final int count = _otLaunchConfigTab.getTeamModel().size();
+ boolean canMove = count >= 2;
+
+ if (index == 0)
+ {
+ _upButton.setEnabled(false);
+ _downButton.setEnabled(canMove);
+ }
+ else if (index == count - 1)
+ {
+ _downButton.setEnabled(false);
+ _upButton.setEnabled(canMove);
+ }
+ else
+ {
+ _upButton.setEnabled(canMove);
+ _downButton.setEnabled(canMove);
+ }
+ }
+
+ private int getTeamIndex(Object element)
+ {
+ return _otLaunchConfigTab.getTeamModel().indexOf(element);
+ }
+
+ private int getTeamSelectionIndex()
+ {
+ IStructuredSelection selection = (IStructuredSelection) _teamList.getSelection();
+ if (selection == null || selection.isEmpty())
+ return -1;
+
+ return getTeamIndex(selection.getFirstElement());
+ }
+
+ public void setTeamInput(List teamModel)
+ {
+ _teamList.setInput(teamModel);
+ }
+}

Back to the top