Bug 481065 - Preference UI for weaving scheme
diff --git a/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/CompilerConfigurationBlock.java b/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/CompilerConfigurationBlock.java
index 68726b6..b25cf36 100644
--- a/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/CompilerConfigurationBlock.java
+++ b/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/CompilerConfigurationBlock.java
@@ -31,6 +31,7 @@
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.layout.PixelConverter;
 import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+import org.eclipse.objectteams.otdt.core.ext.WeavingScheme;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
@@ -109,6 +110,8 @@
 	private static final Key PREF_PB_EFFECTLESS_FIELD_ACCESS = getJDTCoreKey(OTDTPlugin.OT_COMPILER_EFFECTLESS_FIELD_ACCESS);
 	private static final Key PREF_PB_UNUSED_PARAMMAP = getJDTCoreKey(OTDTPlugin.OT_COMPILER_UNUSED_PARAMMAP);
 
+	private static final Key PREF_WEAVING_SCHEME = getJDTCoreKey(OTDTPlugin.OT_COMPILER_WEAVING_SCHEME);
+
 	// values
 	private static final String ERROR= JavaCore.ERROR;
 	private static final String WARNING= JavaCore.WARNING;
@@ -150,6 +153,7 @@
 				PREF_PB_OVERRIDE_FINAL_ROLE,
 				PREF_PB_EXCEPTION_IN_GUARD,
 				PREF_PB_AMBIGUOUS_LOWERING,
+				PREF_WEAVING_SCHEME
 			};
 	}
 	
@@ -194,6 +198,23 @@
 	
 
 	private Composite createCompilerPreferenceTabContent(Composite folder) {
+
+		int indentStep=  fPixelConverter.convertWidthInCharsToPixels(1);
+
+		int nColumns= 3;
+		
+		Composite topComposite = new Composite(folder, SWT.NONE);
+		topComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+		GridLayout topLayout= new GridLayout(nColumns, false);
+		topLayout.marginHeight = fPixelConverter.convertHeightInCharsToPixels(1) / 2;
+		topComposite.setLayout(topLayout);
+
+		addComboBox(topComposite, OTPreferencesMessages.OTCompilerConfigurationBlock_weaving_label, PREF_WEAVING_SCHEME, 
+				new String[] { WeavingScheme.OTRE.toString(), WeavingScheme.OTDRE.toString() }, 
+				new String[] { OTPreferencesMessages.OTCompilerConfigurationBlock_weaving_otre_label,
+								OTPreferencesMessages.OTCompilerConfigurationBlock_weaving_otdre_label },
+				indentStep*2);
+
 		String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
 		
 		String[] errorWarningIgnoreLabels= new String[] {
@@ -209,16 +230,12 @@
 		fFilteredPrefTree= new FilteredPreferenceTree(this, folder, OTPreferencesMessages.OTCompilerConfigurationBlock_common_description);
 		final ScrolledPageContent sc1= fFilteredPrefTree.getScrolledPageContent();
 
-		int nColumns= 3;
-		
 		Composite composite= sc1.getBody();
 		GridLayout layout= new GridLayout(nColumns, false);
 		layout.marginHeight= 0;
 		layout.marginWidth= 0;
 		composite.setLayout(layout);
 
-		int indentStep=  fPixelConverter.convertWidthInCharsToPixels(1);
-
 		int defaultIndent= indentStep * 0;
 //		int extraIndent= indentStep * 3;
 		String label;
diff --git a/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.java b/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.java
index 4ad9982..d88bb80 100644
--- a/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.java
+++ b/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.java
@@ -1,7 +1,7 @@
 /**********************************************************************
  * This file is part of "Object Teams Development Tooling"-Software
  * 
- * Copyright 2005, 2011 Fraunhofer Gesellschaft, Munich, Germany,
+ * Copyright 2005, 2015 Fraunhofer Gesellschaft, Munich, Germany,
  * for its Fraunhofer Institute for Computer Architecture and Software
  * Technology (FIRST), Berlin, Germany and Technical University Berlin,
  * Germany, and others.
@@ -10,7 +10,6 @@
  * 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: OTPreferencesMessages.java 23435 2010-02-04 00:14:38Z stephan $
  * 
  * Please visit http://www.eclipse.org/objectteams for updates and contact.
  * 
@@ -29,7 +28,6 @@
  * Created on Sep 11, 2005
  * 
  * @author stephan
- * @version $Id: OTPreferencesMessages.java 23435 2010-02-04 00:14:38Z stephan $
  */
 public class OTPreferencesMessages {
 
@@ -48,6 +46,9 @@
 
 	public static String OTCompilerPreferencePage_title;
 
+	public static String OTCompilerConfigurationBlock_weaving_label;
+	public static String OTCompilerConfigurationBlock_weaving_otre_label;
+	public static String OTCompilerConfigurationBlock_weaving_otdre_label;
 	
 	public static String OTCompilerConfigurationBlock_common_description;
 	public static String OTCompilerProblemConfiguration_otjld_ref_description;
diff --git a/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.properties b/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.properties
index 3c36554..fdb5711 100644
--- a/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.properties
+++ b/plugins/org.eclipse.objectteams.otdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/preferences/OTPreferencesMessages.properties
@@ -12,6 +12,10 @@
 
 OTCompilerPreferencePage_title=OT/J Compiler
 
+OTCompilerConfigurationBlock_weaving_label=Weaving Scheme
+OTCompilerConfigurationBlock_weaving_otdre_label=Dynamic (OTDRE)
+OTCompilerConfigurationBlock_weaving_otre_label=Traditional (OTRE)
+
 OTCompilerConfigurationBlock_common_description=&Select the severity level for the following optional OT/J compiler problems:
 OTCompilerProblemConfiguration_otjld_ref_description=(numbers refer to paragraphs in the OTJLD)
 
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
index cfd53a8..0f2603b 100644
--- 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
@@ -228,6 +228,16 @@
 	 * @category CompilerOptionID
 	 */
 	public static final String OT_COMPILER_PURE_JAVA = PLUGIN_ID + ".compiler.option.pure_java";
+
+	/**
+	 * Compiler option ID: For which weaving scheme should code be compiled?
+	 * <dl>
+	 * <dt>Possible values:</dt><dd><code>{ "OTRE", "OTDRE" }</code></dd>
+	 * <dt>Default:</dt><dd><code>"OTRE"</code></dd>
+	 * </dl>
+	 * @category CompilerOptionID
+	 */
+	public static final String OT_COMPILER_WEAVING_SCHEME = PLUGIN_ID + ".compiler.option.weaving_scheme";
 	
     private static OTDTPlugin _singleton = null;