initial commit in accordance with CQ 3784
diff --git a/plugins/org.eclipse.objectteams.otdt/.classpath b/plugins/org.eclipse.objectteams.otdt/.classpath
new file mode 100644
index 0000000..304e861
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.objectteams.otdt/.cvsignore b/plugins/org.eclipse.objectteams.otdt/.cvsignore
new file mode 100644
index 0000000..7eeea25
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/.cvsignore
@@ -0,0 +1,4 @@
+bin
+temp.folder
+build.xml
+otdt.jar
diff --git a/plugins/org.eclipse.objectteams.otdt/.project b/plugins/org.eclipse.objectteams.otdt/.project
new file mode 100644
index 0000000..a40a654
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.objectteams.otdt</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.objectteams.otdt/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.objectteams.otdt/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..10d8eb0
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Fri Mar 09 01:42:55 CET 2007
+eclipse.preferences.version=1
+encoding//src/org/objectteams/otdt/core/ext/OTCoreExtMessages.properties=8859_1
diff --git a/plugins/org.eclipse.objectteams.otdt/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.objectteams.otdt/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..5bacb66
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Tue Sep 18 18:10:56 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.objectteams.otdt/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.otdt/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ad3f620
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Object Teams Development Tooling
+Bundle-SymbolicName: org.eclipse.objectteams.otdt;singleton:=true
+Bundle-Version: 1.4.0.qualifier
+Bundle-Activator: org.eclipse.objectteams.otdt.core.ext.OTDTPlugin
+Bundle-Vendor: The TOPPrax consortium
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core;bundle-version="[3.5.1.v_OTDT_r140,4.0.0)",
+ org.eclipse.jdt.launching,
+ org.eclipse.debug.core,
+ org.eclipse.objectteams.otequinox.branding
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: otdtcoreext.jar
+Export-Package: org.eclipse.objectteams.otdt.core.ext
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.objectteams.otdt/META-INF/p2.inf b/plugins/org.eclipse.objectteams.otdt/META-INF/p2.inf
new file mode 100644
index 0000000..e0bbd41
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/META-INF/p2.inf
@@ -0,0 +1,12 @@
+instructions.install = \
+ removeProgramArg(programArg:-showsplash); \
+ removeProgramArg(programArg:org.eclipse.platform); \
+ addProgramArg(programArg:-showsplash); \
+ addProgramArg(programArg:org.eclipse.objectteams.otdt); \
+ setProgramProperty(propName:osgi.splashPath,propValue:platform\:/base/plugins/org.eclipse.objectteams.otdt);
+instructions.uninstall = \
+ removeProgramArg(programArg:-showsplash); \
+ removeProgramArg(programArg:org.eclipse.objectteams.otdt); \
+ addProgramArg(programArg:-showsplash); \
+ addProgramArg(programArg:org.eclipse.platform); \
+ setProgramProperty(propName:osgi.splashPath,propValue:platform\:/base/plugins/org.eclipse.platform);
diff --git a/plugins/org.eclipse.objectteams.otdt/OT-Icon_32x32.png b/plugins/org.eclipse.objectteams.otdt/OT-Icon_32x32.png
new file mode 100644
index 0000000..1614869
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/OT-Icon_32x32.png
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt/OTDT_32x32.png b/plugins/org.eclipse.objectteams.otdt/OTDT_32x32.png
new file mode 100644
index 0000000..5d09b7e
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/OTDT_32x32.png
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt/OTlogo.gif b/plugins/org.eclipse.objectteams.otdt/OTlogo.gif
new file mode 100644
index 0000000..be3bc29
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/OTlogo.gif
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt/about.html b/plugins/org.eclipse.objectteams.otdt/about.html
new file mode 100644
index 0000000..47048bd
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>Feb 3, 2010</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt/about.ini b/plugins/org.eclipse.objectteams.otdt/about.ini
new file mode 100644
index 0000000..970677f
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/about.ini
@@ -0,0 +1,12 @@
+aboutText=Object Teams Development Tooling\n\
+\n\
+OTDT Version: 1.4.0 Milestone 2\n\
+\n\
+Based on Eclipse version 3.6.0 M4\n\
+\n\
+(c) Copyright The TOPPrax consortium, 2005, 2009\n\
+Visit http://www.objectteams.org
+
+featureImage=OTDT_32x32.png
+
+# welcomePage=$nl$/welcome.xml
diff --git a/plugins/org.eclipse.objectteams.otdt/build.properties b/plugins/org.eclipse.objectteams.otdt/build.properties
new file mode 100644
index 0000000..026e501
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/build.properties
@@ -0,0 +1,14 @@
+bin.includes = plugin.xml,\
+ OTDT_32x32.png,\
+ about.ini,\
+ META-INF/,\
+ lib/,\
+ otdtcoreext.jar,\
+ plugin.properties,\
+ splash.bmp
+src.includes = build.properties,\
+ .classpath,\
+ .project
+jars.compile.order = otdtcoreext.jar
+output.otdtcoreext.jar = bin/
+source.otdtcoreext.jar = src/
diff --git a/plugins/org.eclipse.objectteams.otdt/lib/otre_min.jar b/plugins/org.eclipse.objectteams.otdt/lib/otre_min.jar
new file mode 100644
index 0000000..fc4bd11
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/lib/otre_min.jar
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt/plugin.properties b/plugins/org.eclipse.objectteams.otdt/plugin.properties
new file mode 100644
index 0000000..a0c9178
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/plugin.properties
@@ -0,0 +1,2 @@
+otNatureName=Object Teams
+otjBuilderName=OT/J Builder
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt/plugin.xml b/plugins/org.eclipse.objectteams.otdt/plugin.xml
new file mode 100644
index 0000000..4c37444
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/plugin.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+
+
+<plugin>
+ <!-- Note that the nature and builder definitions appear here mainly
+ because they should have an ID starting with org.eclipse.objectteams.otdt,
+ rather than org.eclipse.jdt, allthough they are defined in jdt.core -->
+
+ <!-- objectteams project nature -->
+ <extension
+ point="org.eclipse.core.resources.natures"
+ id="OTJavaNature"
+ name="%otNatureName">
+ <runtime>
+ <run class="org.eclipse.objectteams.otdt.core.ext.OTJavaNature">
+ </run>
+ </runtime>
+ <builder
+ id="org.eclipse.objectteams.otdt.builder.OTJBuilder">
+ </builder>
+ <!-- run and configure our nature AFTER the java-nature has been configured -->
+ <requires-nature
+ id="org.eclipse.jdt.core.javanature">
+ </requires-nature>
+ </extension>
+
+ <!-- OT/J Builder: -->
+ <extension
+ point="org.eclipse.core.resources.builders"
+ id="builder.OTJBuilder"
+ name="%otjBuilderName">
+ <builder hasNature="true">
+ <run class="org.eclipse.objectteams.otdt.internal.core.builder.OTJBuilder">
+ </run>
+ </builder>
+ </extension>
+
+ <extension point="org.eclipse.jdt.core.classpathVariableInitializer">
+ <classpathVariableInitializer
+ variable="OTDT_INSTALLDIR"
+ class="org.eclipse.objectteams.otdt.core.ext.OTVariableInitializer"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.jdt.core.classpathContainerInitializer"
+ id="org.eclipse.objectteams.otdt.otreContainerInitializer">
+ <classpathContainerInitializer
+ id="OTRE"
+ class="org.eclipse.objectteams.otdt.core.ext.OTREContainerInitializer"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.jdt.core.classpathVariableInitializer">
+ <classpathVariableInitializer
+ variable="OTRUNTIME_INSTALLDIR"
+ class="org.eclipse.objectteams.otdt.core.ext.OTRuntimeVariableInitializer">
+ </classpathVariableInitializer>
+ </extension>
+
+ <extension point="org.eclipse.jdt.launching.classpathProviders">
+ <classpathProvider
+ id="org.eclipse.objectteams.otdt.OTRuntimeClasspathProvider"
+ class="org.eclipse.objectteams.otdt.core.ext.OTRuntimeClasspathProvider">
+ </classpathProvider>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.objectteams.otdt/splash.bmp b/plugins/org.eclipse.objectteams.otdt/splash.bmp
new file mode 100644
index 0000000..4bbee55
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/splash.bmp
Binary files differ
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.java
new file mode 100644
index 0000000..9e5ef14
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.java
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 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: OTCoreExtMessages.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.core.ext;
+
+import org.eclipse.osgi.util.NLS;
+
+public class OTCoreExtMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.core.ext.OTCoreExtMessages"; //$NON-NLS-1$
+
+ public static String OTREContainer__Description;
+
+ public static String OTREContainer_otre_not_found;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, OTCoreExtMessages.class);
+ }
+
+ private OTCoreExtMessages() {
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.properties b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.properties
new file mode 100644
index 0000000..6a81b37
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.properties
@@ -0,0 +1,2 @@
+OTREContainer__Description=Object Teams Runtime Environment
+OTREContainer_otre_not_found=Cannot setup Object Teams ClassPath -- maybe otre.jar not found?
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
new file mode 100644
index 0000000..36dcf9a
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
@@ -0,0 +1,155 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 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: OTDTPlugin.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.core.ext;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.objectteams.otdt.core.exceptions.ExceptionHandler;
+
+
+/**
+ * The main plugin class to be used in the desktop.
+ *
+ * @author jwloka
+ */
+public class OTDTPlugin extends Plugin
+{
+ public static final String PLUGIN_ID = JavaCore.OTDT_PLUGIN_ID;
+
+ public static final String OTDT_INSTALLDIR = "OTDT_INSTALLDIR"; //$NON-NLS-1$
+
+ // === IDs for configurable options for the compiler : ===
+ public static final String OT_COMPILER_BASE_CALL =
+ PLUGIN_ID + ".compiler.problem.basecall"; //$NON-NLS-1$
+ public static final String OT_COMPILER_UNSAFE_ROLE_INSTANTIATION =
+ PLUGIN_ID + ".compiler.problem.unsafe_role_instantiation"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_EFFECTLESS_FIELDACCESS =
+ PLUGIN_ID + ".compiler.problem.effectless_fieldaccess"; //$NON-NLS-1$
+ public static final String OT_COMPILER_FRAGILE_CALLIN =
+ PLUGIN_ID + ".compiler.problem.fragile_callin"; //$NON-NLS-1$
+ public static final String OT_COMPILER_UNUSED_PARAMMAP =
+ PLUGIN_ID + ".compiler.problem.unused_parammap"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_POTENTIAL_AMBIGUOUS_PLAYEDBY =
+ PLUGIN_ID + ".compiler.problem.potential_ambiguous_playedby"; //$NON-NLS-1$
+ public static final String OT_COMPILER_ABSTRACT_POTENTIAL_RELEVANT_ROLE =
+ PLUGIN_ID + ".compiler.problem.abstract_potential_relevant_role"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_DECAPSULATION =
+ PLUGIN_ID + ".compiler.problem.decapsulation"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_BINDING_CONVENTIONS =
+ PLUGIN_ID + ".compiler.problem.binding_conventions"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_INFERRED_CALLOUT =
+ PLUGIN_ID + ".compiler.problem.inferred_callout"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_INCOMPLETE_BUILD =
+ PLUGIN_ID + ".compiler.problem.incomplete_build"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_WEAVE_INTO_SYSTEM_CLASS =
+ PLUGIN_ID + ".compiler.problem.weave_into_system_class"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_OVERRIDE_FINAL_ROLE =
+ PLUGIN_ID + ".compiler.problem.override_final_role"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_EXCEPTION_IN_GUARD =
+ PLUGIN_ID + ".compiler.problem.exception_in_guard"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_AMBIGUOUS_LOWERING =
+ PLUGIN_ID + ".compiler.problem.ambiguous_lowering"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_ADAPTING_DEPRECATED =
+ PLUGIN_ID + ".compiler.problem.adapting_deprecated"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_SCOPED_KEYWORDS =
+ PLUGIN_ID + ".compiler.option.scoped_keywords"; //$NON-NLS-1$
+
+ public static final String OT_COMPILER_DEPRECATED_PATH_SYNTAX =
+ PLUGIN_ID + ".compiler.problem.deprecated_path_syntax"; //$NON-NLS-1$;
+
+
+ public static String OTRUNTIME_INSTALLDIR = "OTRUNTIME_INSTALLDIR"; //$NON-NLS-1$
+
+ private static OTDTPlugin _singleton = null;
+
+
+ public OTDTPlugin()
+ {
+ super();
+ _singleton = this;
+ }
+
+ public static OTDTPlugin getDefault()
+ {
+ return _singleton;
+ }
+
+ public static String[] createProjectNatures(IProjectDescription prjDesc)
+ {
+ String[] natures = prjDesc.getNatureIds();
+ String[] result = new String[natures.length + 1];
+
+ System.arraycopy(natures, 0, result, 0, natures.length);
+
+ result[natures.length] = JavaCore.OTJ_NATURE_ID;
+
+ return result;
+ }
+
+ public static ICommand[] createProjectBuildCommands(IProjectDescription project)
+ {
+ return new ICommand[] { createProjectBuildCommand(project) };
+ }
+
+ public static ICommand createProjectBuildCommand(IProjectDescription project)
+ {
+ ICommand otBuildCmd = project.newCommand();
+ otBuildCmd.setBuilderName(JavaCore.OTJ_BUILDER_ID);
+ return otBuildCmd;
+ }
+
+ public static ExceptionHandler getExceptionHandler()
+ {
+ return new ExceptionHandler(PLUGIN_ID);
+ }
+
+ public static Status createErrorStatus(String message, Throwable exception)
+ {
+ return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, exception);
+ }
+
+ /**
+ * Take relativeFileName relative to OTRUNTIME_INSTALLDIR and make an absolute path from that.
+ * The returned string is enclosed in double-quotes so it is safe to have blanks within.
+ */
+ public static String calculateAbsoluteRuntimePath(String relativeFileName)
+ {
+ Path path = new Path(OTDTPlugin.OTRUNTIME_INSTALLDIR + relativeFileName);
+ return "\""+JavaCore.getResolvedVariablePath( path ).toOSString()+'"'; //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTJavaNature.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTJavaNature.java
new file mode 100644
index 0000000..42d7520
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTJavaNature.java
@@ -0,0 +1,172 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 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: OTJavaNature.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.core.ext;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.ExternalJavaProject;
+
+
+/**
+ * @author jwloka
+ * @version $Id: OTJavaNature.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+@SuppressWarnings("restriction")
+public class OTJavaNature implements IProjectNature
+{
+ private IProject _prj;
+
+ public void configure() throws CoreException
+ {
+ IProjectDescription projectDescription = _prj.getDescription();
+ ICommand command = projectDescription.newCommand();
+ command.setBuilderName(JavaCore.OTJ_BUILDER_ID);
+
+ ICommand[] buildCommands = projectDescription.getBuildSpec();
+ ICommand[] newBuildCommands;
+
+ if (contains(buildCommands, JavaCore.OTJ_BUILDER_ID))
+ {
+ return; // safety, do nothing
+ }
+
+ if (contains(buildCommands, JavaCore.BUILDER_ID))
+ {
+ newBuildCommands =
+ replace(buildCommands, JavaCore.BUILDER_ID, command);
+ }
+ else
+ {
+ newBuildCommands = insert(buildCommands, command);
+ }
+
+ projectDescription.setBuildSpec(newBuildCommands);
+ _prj.setDescription(projectDescription, null);
+ }
+
+ public void deconfigure() throws CoreException
+ {
+ IProjectDescription description = _prj.getDescription();
+ ICommand[] buildCommands = description.getBuildSpec();
+ ICommand command = description.newCommand();
+ command.setBuilderName(JavaCore.BUILDER_ID);
+
+ ICommand[] newBuildCommands;
+
+ if (contains(buildCommands, JavaCore.OTJ_BUILDER_ID))
+ {
+ newBuildCommands =
+ replace(buildCommands, JavaCore.OTJ_BUILDER_ID, command);
+ }
+ else
+ {
+ newBuildCommands =
+ remove(buildCommands, JavaCore.OTJ_BUILDER_ID);
+ }
+
+ description.setBuildSpec(newBuildCommands);
+ _prj.setDescription(description, null);
+ }
+
+ public IProject getProject()
+ {
+ return _prj;
+ }
+
+ public void setProject(IProject value)
+ {
+ _prj = value;
+ }
+
+ public static boolean hasOTJavaNature(IProject project) {
+ try {
+ return project.hasNature(JavaCore.OTJ_NATURE_ID);
+ } catch (CoreException e) {
+ if (ExternalJavaProject.EXTERNAL_PROJECT_NAME.equals(project.getName())) // see JavaProject
+ return true;
+ }
+ return false;
+ }
+
+ private boolean contains(ICommand[] commands, String builderId)
+ {
+ for (int i = 0; i < commands.length; i++)
+ {
+ if (commands[i].getBuilderName().equals(builderId))
+ return true;
+ }
+
+ return false;
+ }
+
+ private ICommand[] replace(
+ ICommand[] sourceCommands, String oldBuilderId, ICommand newCommand)
+ {
+ ICommand[] newCommands = new ICommand[sourceCommands.length];
+
+ for (int i = 0; i < sourceCommands.length; i++)
+ {
+ if (sourceCommands[i].getBuilderName().equals(oldBuilderId))
+ {
+ newCommands[i] = newCommand;
+ }
+ else
+ {
+ newCommands[i] = sourceCommands[i];
+ }
+ }
+
+ return newCommands;
+ }
+
+ private ICommand[] insert(ICommand[] sourceCommands, ICommand command)
+ {
+ ICommand[] newCommands = new ICommand[sourceCommands.length + 1];
+ newCommands[0] = command;
+
+ for (int i = 0; i < sourceCommands.length; i++)
+ {
+ newCommands[i + 1] = sourceCommands[i];
+ }
+
+ return newCommands;
+ }
+
+ private ICommand[] remove(ICommand[] sourceCommands, String builderId)
+ {
+ ICommand[] newCommands = new ICommand[sourceCommands.length - 1];
+ int newCommandIndex = 0;
+
+ for (int i = 0; i < sourceCommands.length; i++)
+ {
+ if (!sourceCommands[i].getBuilderName().equals(builderId))
+ {
+ newCommands[newCommandIndex++] = sourceCommands[i];
+ }
+ }
+
+ return newCommands;
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
new file mode 100644
index 0000000..921b82b
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
@@ -0,0 +1,151 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 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: OTREContainer.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.core.ext;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * @author gis
+ */
+public class OTREContainer implements IClasspathContainer
+{
+ public static final String OTRE_CONTAINER_NAME = "OTRE"; //$NON-NLS-1$
+ public static final String OTRE_JAR_FILENAME = "otre.jar"; //$NON-NLS-1$
+ public static final String OTRE_MIN_JAR_FILENAME = "otre_min.jar"; //$NON-NLS-1$
+
+ public static final IPath OTRE_CONTAINER_PATH = new Path(OTRE_CONTAINER_NAME);
+ public static final String OTRE_JAR_PATH = OTDTPlugin.OTDT_INSTALLDIR + "/lib/" + OTRE_JAR_FILENAME; //$NON-NLS-1$
+ public static final String OTRE_MIN_JAR_PATH = OTDTPlugin.OTDT_INSTALLDIR + "/lib/" + OTRE_MIN_JAR_FILENAME; //$NON-NLS-1$
+
+ private IClasspathEntry[] _cpEntries;
+
+ public IClasspathEntry[] getClasspathEntries()
+ {
+ if (_cpEntries == null)
+ {
+ _cpEntries = new IClasspathEntry[1];
+ IPath fullPath = new Path(OTRE_JAR_PATH);
+ IClasspathEntry varOTREEntry = JavaCore.newVariableEntry(fullPath, fullPath, fullPath, true);
+ _cpEntries[0] = JavaCore.getResolvedClasspathEntry(varOTREEntry);
+ }
+
+ return _cpEntries;
+ }
+
+ public String getDescription()
+ {
+ return OTCoreExtMessages.OTREContainer__Description;
+ }
+
+ public int getKind()
+ {
+ return IClasspathContainer.K_APPLICATION;
+ }
+
+ public IPath getPath()
+ {
+ return OTRE_CONTAINER_PATH;
+ }
+
+ /**
+ * Adds the ObjectTeams classes to the given JavaProject's classpath,
+ * and ensures the Java compliance is >= 1.5
+ */
+ public static void initializeOTJProject(IProject project) throws CoreException
+ {
+ if (project == null)
+ {
+ return;
+ }
+
+ if (project.hasNature(JavaCore.NATURE_ID))
+ {
+ IJavaProject javaPrj = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
+ IClasspathEntry[] classpath = javaPrj.getRawClasspath();
+
+ if (!isOTREAlreadyInClasspath(classpath))
+ {
+ addOTREToClasspath(javaPrj, classpath);
+ }
+ String javaVersion = javaPrj.getOption(JavaCore.COMPILER_COMPLIANCE, true);
+ if (javaVersion.compareTo(JavaCore.VERSION_1_5)<0) {
+ javaPrj.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+ javaPrj.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+ javaPrj.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
+ javaPrj.setOption(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
+ javaPrj.setOption(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
+ javaPrj.setOption(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
+ }
+ }
+ }
+
+ private static boolean isOTREAlreadyInClasspath(IClasspathEntry[] classpath)
+ {
+ for (int idx = 0; classpath != null && idx < classpath.length; idx++)
+ {
+ IClasspathEntry entry = classpath[idx];
+ if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().equals(OTRE_CONTAINER_PATH))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Add the object teams foundation classes to the classpath.
+ */
+ private static void addOTREToClasspath(IJavaProject javaPrj, IClasspathEntry[] classpath)
+ throws JavaModelException, CoreException
+ {
+ IClasspathEntry[] newClasspath = new IClasspathEntry[classpath.length + 1];
+
+ System.arraycopy( classpath, 0, newClasspath, 0, classpath.length );
+
+ newClasspath[classpath.length] = JavaCore.newContainerEntry(OTRE_CONTAINER_PATH, false);
+
+ if (newClasspath[classpath.length] != null)
+ {
+ javaPrj.setRawClasspath( newClasspath, null );
+ }
+ else
+ {
+ Status reason = new Status(
+ IStatus.ERROR,
+ OTDTPlugin.PLUGIN_ID,
+ IStatus.OK,
+ OTCoreExtMessages.OTREContainer_otre_not_found, null);
+
+ throw new CoreException( reason );
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java
new file mode 100644
index 0000000..61689ac
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java
@@ -0,0 +1,60 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 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: OTREContainerInitializer.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.core.ext;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ * This class creates the OTREContainer. Installed from plugin.xml as an extension.
+ *
+ * @author gis
+ */
+public class OTREContainerInitializer extends ClasspathContainerInitializer
+{
+
+ public OTREContainerInitializer()
+ {
+ super();
+ }
+
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException
+ {
+ if (containerPath == null || containerPath.isEmpty() || !containerPath.segment(0).equals(OTREContainer.OTRE_CONTAINER_NAME))
+ return;
+
+ JavaCore.setClasspathContainer(
+ containerPath,
+ new IJavaProject[] { project },
+ new IClasspathContainer[] { createOTREContainer() },
+ null);
+ }
+
+ private IClasspathContainer createOTREContainer()
+ {
+ return new OTREContainer();
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTRuntimeClasspathProvider.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTRuntimeClasspathProvider.java
new file mode 100644
index 0000000..e90bfe4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTRuntimeClasspathProvider.java
@@ -0,0 +1,123 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTRuntimeClasspathProvider.java 21932 2009-07-30 16:53:44Z 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.core.ext;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.StandardClasspathProvider;
+
+
+/**
+ * @author gis
+ * @version $Id: OTRuntimeClasspathProvider.java 21932 2009-07-30 16:53:44Z stephan $
+ */
+public class OTRuntimeClasspathProvider extends StandardClasspathProvider
+{
+ public static final String PROVIDER_ID = "org.eclipse.objectteams.otdt.OTRuntimeClasspathProvider"; //$NON-NLS-1$
+
+ public static IPath BCEL_JAR = getVariablePath("/lib/BCEL.jar"); //$NON-NLS-1$
+
+ public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException
+ {
+ // add BCEL, JMangler-core and JMangler-start (classpath / bootclasspath)
+ IRuntimeClasspathEntry[] origEntries = super.computeUnresolvedClasspath(configuration);
+
+ int oldLength = origEntries.length;
+ IRuntimeClasspathEntry[] otRuntimeEntries = computePathsToAdd(origEntries);
+ IRuntimeClasspathEntry[] result = new IRuntimeClasspathEntry[oldLength + otRuntimeEntries.length];
+ System.arraycopy(origEntries, 0, result, 0, oldLength);
+
+ // add the missing OT runtime paths to the result
+ for (int i = 0; i < otRuntimeEntries.length; i++)
+ {
+ result[oldLength + i] = otRuntimeEntries[i];
+ }
+
+// IJavaProject project = JavaRuntime.getJavaProject(configuration);
+// if (project == null) {
+// // no project - use JRE's libraries by default
+
+ return result;
+ }
+
+ private static IRuntimeClasspathEntry[] computePathsToAdd( IRuntimeClasspathEntry[] origEntries )
+ {
+ boolean hasBCEL = false;
+ boolean hasJManglerCore = false;
+ boolean hasJManglerStart = false;
+
+ for (int i = 0; i < origEntries.length; i++)
+ {
+ IRuntimeClasspathEntry entry = origEntries[i];
+ if (BCEL_JAR.equals(entry.getPath()))
+ hasBCEL = true;
+ }
+
+ List<IRuntimeClasspathEntry> result = new LinkedList<IRuntimeClasspathEntry>();
+ IRuntimeClasspathEntry entry;
+
+//TODO (carp): make these class paths variable classpaths and compute the absolute path later
+// Also fix getVariablePath() then.
+ if (!hasBCEL)
+ {
+ entry = JavaRuntime.newArchiveRuntimeClasspathEntry(BCEL_JAR);
+ entry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
+ result.add(entry);
+ }
+
+ if (!hasJManglerCore)
+ {
+ throw new RuntimeException("JMangler is no longer supported");
+ }
+
+ if (!hasJManglerStart)
+ {
+ throw new RuntimeException("JMangler is no longer supported");
+ }
+
+ return result.toArray(new IRuntimeClasspathEntry[result.size()]);
+ }
+
+ private static IPath getVariablePath(String filename)
+ {
+ Path path = new Path(OTDTPlugin.OTRUNTIME_INSTALLDIR + filename);
+ //return path;
+ return JavaCore.getResolvedVariablePath(path);
+ }
+
+ public IRuntimeClasspathEntry[] resolveClasspath(
+ IRuntimeClasspathEntry[] entries,
+ ILaunchConfiguration configuration)
+ throws CoreException
+ {
+ IRuntimeClasspathEntry[] result = super.resolveClasspath(entries, configuration);
+ return result;
+ }
+
+}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTRuntimeVariableInitializer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTRuntimeVariableInitializer.java
new file mode 100644
index 0000000..c81ca43
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTRuntimeVariableInitializer.java
@@ -0,0 +1,39 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTRuntimeVariableInitializer.java 23419 2010-02-03 20:43:26Z 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.core.ext;
+
+import org.eclipse.jdt.core.ClasspathVariableInitializer;
+
+/**
+ * FIXME(SH): try if this VARIABLE can be removed altogether.
+ * @author gis
+ * @version $Id: OTRuntimeVariableInitializer.java 23419 2010-02-03 20:43:26Z stephan $
+ */
+public class OTRuntimeVariableInitializer extends ClasspathVariableInitializer
+{
+ public void initialize(String variable)
+ {
+ if (OTDTPlugin.OTRUNTIME_INSTALLDIR.equals(variable))
+ {
+ OTVariableInitializer.setPluginInstallationPathVariable(OTDTPlugin.getDefault(), variable);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java
new file mode 100644
index 0000000..e7d07da
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java
@@ -0,0 +1,74 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2003, 2007 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: OTVariableInitializer.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.core.ext;
+
+import java.io.File;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jdt.core.ClasspathVariableInitializer;
+import org.eclipse.jdt.core.JavaCore;
+
+
+/**
+ * ClassPathVariableInitializer to initialize the OTRE_INSTALL variable.
+ *
+ * @author gis
+ * @version $Id: OTVariableInitializer.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+public class OTVariableInitializer extends ClasspathVariableInitializer
+{
+ public OTVariableInitializer()
+ {
+ super();
+ }
+
+ public void initialize(String variable)
+ {
+ if (OTDTPlugin.OTDT_INSTALLDIR.equals(variable))
+ {
+ setPluginInstallationPathVariable(OTDTPlugin.getDefault(), variable);
+ }
+ }
+
+ public static void setPluginInstallationPathVariable(Plugin relativePlugin, String variable)
+ {
+ try
+ {
+ URL installDirectory = relativePlugin.getBundle().getEntry("/"); //$NON-NLS-1$
+
+ // On Windows, the next line leads to something like "/C:/Programme/Eclipse/plugins/my.plugin
+ // If we simply make an org.eclipse.core.runtime.Path out of it, the leading '/' makes the
+ // parsing fail (device, e.g. 'C:' is not detected). We must use java.io.File to parse it
+ // properly.
+ String path = FileLocator.toFileURL(installDirectory).getPath();
+ String fixedPath = new File(path).getPath();
+ JavaCore.setClasspathVariable(variable, new Path(fixedPath), new NullProgressMonitor());
+ }
+ catch (Exception ex)
+ {
+ OTDTPlugin.getExceptionHandler().logException(ex);
+ }
+ }
+}