From 853d98c8dd8482b3f60ba15e36ea0e634dfd69f3 Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Thu, 20 Sep 2007 17:46:29 +0000 Subject: RESOLVED - bug 201296: add support for XL C/C++ v9.0 https://bugs.eclipse.org/bugs/show_bug.cgi?id=201296 --- .../.settings/org.eclipse.jdt.core.prefs | 22 + .../META-INF/MANIFEST.MF | 10 +- .../plugin.properties | 34 +- .../plugin.xml | 651 +++++++++++++++++---- .../ui/HiddenOptionApplicabilityCalculator.java | 57 -- .../cdt/managedbuilder/xlc/ui/Messages.java | 36 ++ .../xlc/ui/XLCProjectMacroSupplier.java | 116 ++++ .../cdt/managedbuilder/xlc/ui/XLCUIPlugin.java | 85 +++ .../cdt/managedbuilder/xlc/ui/XlcUIPlugin.java | 84 --- .../cdt/managedbuilder/xlc/ui/messages.properties | 22 + .../xlc/ui/preferences/PreferenceConstants.java | 26 + .../xlc/ui/preferences/PreferenceInitializer.java | 35 ++ .../ui/preferences/XLCompilerPreferencePage.java | 68 +++ .../HiddenOptionApplicabilityCalculator.java | 57 ++ .../xlc/ui/properties/XLCompilerPropertyPage.java | 163 ++++++ .../ui/properties/XLCv8ApplicabiltyCalculator.java | 116 ++++ .../properties/XLCv9ApplicabilityCalculator.java | 119 ++++ .../xlc/ui/wizards/XLCSettingsWizardPage.java | 300 ++++++++++ .../xlc/ui/wizards/XLCSettingsWizardRunnable.java | 73 +++ 19 files changed, 1808 insertions(+), 266 deletions(-) create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs delete mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/HiddenOptionApplicabilityCalculator.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/Messages.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCUIPlugin.java delete mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XlcUIPlugin.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/messages.properties create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceConstants.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceInitializer.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/XLCompilerPreferencePage.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/HiddenOptionApplicabilityCalculator.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCompilerPropertyPage.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv8ApplicabiltyCalculator.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv9ApplicabilityCalculator.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardPage.java create mode 100644 xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardRunnable.java diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..d0ca27be35e --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,22 @@ +#/******************************************************************************* +# * Copyright (c) 2007 IBM Corporation and others. +# * All rights reserved. This program and the accompanying materials +# * are made available under the terms of the Eclipse Public License v1.0 +# * which accompanies this distribution, and is available at +# * http://www.eclipse.org/legal/epl-v10.html +# * +# * Contributors: +# * IBM Corporation - initial API and implementation +# *******************************************************************************/ +#Thu Sep 20 11:01:49 EDT 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +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=warning +org.eclipse.jdt.core.compiler.source=1.4 diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF index 1ba4bd9d1c1..5d376a977f6 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF @@ -2,13 +2,17 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.xlc.ui; singleton := true -Bundle-Version: 4.0.0.qualifier -Bundle-Activator: org.eclipse.cdt.managedbuilder.xlc.ui.XlcUIPlugin +Bundle-Version: 4.0.1.qualifier +Bundle-Activator: org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.cdt.managedbuilder.core, - org.eclipse.cdt.core + org.eclipse.cdt.core, + org.eclipse.core.resources, + org.eclipse.cdt.managedbuilder.ui, + org.eclipse.cdt.ui, + org.eclipse.ui.ide Eclipse-LazyStart: true Export-Package: org.eclipse.cdt.managedbuilder.xlc.ui Bundle-Vendor: %providerName diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.properties b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.properties index 5b9604515cc..09ad04e0ea1 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.properties +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.properties @@ -1,14 +1,14 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -pluginName = XL C/C++ Managed Build Plugin +#/******************************************************************************* +# * Copyright (c) 2006, 2007 IBM Corporation and others. +# * All rights reserved. This program and the accompanying materials +# * are made available under the terms of the Eclipse Public License v1.0 +# * which accompanies this distribution, and is available at +# * http://www.eclipse.org/legal/epl-v10.html +# * +# * Contributors: +# * IBM Corporation - initial API and implementation +# *******************************************************************************/ +pluginName = XL C/C++ Managed Build UI Plugin providerName = Eclipse.org #Build model names @@ -55,6 +55,7 @@ OptionCategory.Optimize=Optimization OptionCategory.Comp = Compatibility OptionCategory.Misc=Miscellaneous OptionCategory.Assembler=Assembler Options +OptionCategory.General=General # generic names used by multiple options @@ -119,6 +120,7 @@ Option.Trace=Preview the steps for compilation(-#) Option.bmaxdata=Maximum size of the area shared by the static data ans the heap (-bmaxdata=) Option.c=Pass the source files through compiler component only(-c) Option.PreprocOnly=Preprocess the source files and create an output preprocessed source file (-E) +Option.PreprocRemoveComments=Remove comments from preprocessed output (-C!) Option.M=Create an output file that contains targets for the make command (-M) Option.ma=Substitute inline code for calls to alloca (-ma) Option.o=Specify an output location for the files created by the compiler (-o) @@ -211,6 +213,7 @@ Option.optimization.arch.ppcgr = PowerPC Option.optimization.arch.ppc64gr = PowerPC® 64-bit with graphics instructions Option.optimization.arch.ppc64grsq = PowerPC® 64-bit with graphics and square root instructions Option.optimization.arch.ppc64v = PowerPC® 64-bit with AltiVec +Option.optimization.tune = Specify the processor architecture to tune code for (-qtune=) Option.optimization.assert = Assert program behaviours (-qassert=) Option.optimization.Cache = Specify the cache configuration (-qcache=option1:option2:...:optionN) Option.compact = Avoid transformations that lead to code expansion (-qcompact) @@ -304,7 +307,10 @@ Option.rndflt = Control compile-time rounding mode of floating point expressions Option.rndflt.nearest = Nearest Option.rndflt.minusinf = Minus infinity Option.rndflt.plusinf = Plus infinity -Option.rndflt.zero = Zero +Option.rndflt.zero = Zero +Option.dfp = Decimal floating-point support for types and literals +Option.dfp.enabled = Enabled (-qdfp) +Option.dfp.disabled = Disabled (-qnodfp) # Compiler Customization options Option.B = Determine substitute program path name (-B) @@ -349,10 +355,12 @@ Option.xref = Produce a cross reference listing of identifiers (-qxref) Option.xref.noxref = Do not report identifiers in the program (-qnoxref) Option.xref.fullxref = Report all the identifiers in the program (-qxref = full) Option.xref.xref = Report only those identifiers which are used (-qxref) -Option.warnfourcharconsts = Enable warning of four-character constants in source +Option.warnfourcharconsts = Enable warning of four-character constants in source +Option.report = Produce listing files that show how sections of code have been optimized (-qreport) # Error Checking and Debugging Option.g = Generate debugging information (-g) +Option.optdebug = Enable debugging of optimized code (-qoptdebug) Option.DebugLevel=Debug Level Option.Debug.Min=Minimal (-g1) Option.Debug.Def=Default (-g) diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.xml b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.xml index a1b4663e79c..c30e87e7e91 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.xml +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/plugin.xml @@ -13,7 +13,7 @@ + name="%TargetName.xlc.exe" + projectMacroSupplier="org.eclipse.cdt.managedbuilder.xlc.ui.XLCProjectMacroSupplier"> @@ -522,7 +523,7 @@ id="cdt.managedbuild.target.xlc.platform.exe.release" name="%PlatformName.Rel" binaryParser="org.eclipse.cdt.core.XCOFF32" - osList="aix" + osList="all" archList="all"> + name="%TargetName.xlc.so" + projectMacroSupplier="org.eclipse.cdt.managedbuilder.xlc.ui.XLCProjectMacroSupplier"> + name="%TargetName.xlc.lib" + projectMacroSupplier="org.eclipse.cdt.managedbuilder.xlc.ui.XLCProjectMacroSupplier"> @@ -915,7 +918,7 @@ name="%Option.qcomplexgccincl" category="xlc.c.compiler.category.Input" command="-qcomplexgccincl" - id="xlc.c.compiler.option.include.qcomplexgccincl" + id="xlc.c.compiler.option.input.qcomplexgccincl" valueType="includePath" browseType="directory"> @@ -925,7 +928,7 @@ name="%Option.Mbcs" category="xlc.c.compiler.category.Input" command="-qmbcs" - id="xlc.c.compiler.option.misc.mbcs" + id="xlc.c.compiler.option.input.mbcs" valueType="boolean"> @@ -934,7 +937,7 @@ name="%Option.Digraph" category="xlc.c.compiler.category.Input" command="-qdigraph" - id="xlc.c.compiler.option.misc.digraph" + id="xlc.c.compiler.option.input.digraph" valueType="boolean"> @@ -943,7 +946,7 @@ name="%Option.Dollar" category="xlc.c.compiler.category.Input" command="-qdollar" - id="xlc.c.compiler.option.misc.dollar" + id="xlc.c.compiler.option.input.dollar" valueType="boolean"> @@ -952,7 +955,7 @@ name="%Option.Incdirfirst" category="xlc.c.compiler.category.Input" command="-qidirfirst" - id="xlc.c.compiler.option.include.dirfirst" + id="xlc.c.compiler.option.input.dirfirst" valueType="boolean"> @@ -1000,7 +1003,7 @@ @@ -1076,7 +1079,7 @@ name="%Option.Macpstr" category="xlc.c.compiler.category.Input" command="-qmacpstr" - id="xlc.c.compiler.option.misc.macpstr" + id="xlc.c.compiler.option.input.macpstr" valueType="boolean"> @@ -1118,7 +1121,7 @@ @@ -1147,7 +1150,7 @@ name="%Option.Trigraph" category="xlc.c.compiler.category.Input" command="-qtrigraph" - id="xlc.c.compiler.option.misc.trigraph" + id="xlc.c.compiler.option.input.trigraph" valueType="boolean"> @@ -1180,7 +1183,7 @@ valueType="string"> @@ -1210,7 +1213,7 @@ name="%Option.P" category="xlc.c.compiler.category.output" command="-P" - id="xlc.c.compiler.option.preprocessor.P" + id="xlc.c.compiler.option.output.P" valueType="boolean"> @@ -1219,7 +1222,7 @@ name="%Option.Assem" category="xlc.c.compiler.category.output" command="-S" - id="xlc.c.compiler.option.misc.assem" + id="xlc.c.compiler.option.output.assem" valueType="boolean"> @@ -1236,7 +1239,7 @@ name="%Option.64" category="xlc.c.compiler.category.output" command="-q64" - id="xlc.c.compiler.option.misc.64" + id="xlc.c.compiler.option.output.64" valueType="boolean"> @@ -1299,21 +1302,21 @@ defaultValue="false" name="%Option.Bitfields" category="xlc.c.compiler.category.output" - id="xlc.c.compiler.option.signedness.bitfields" + id="xlc.c.compiler.option.output.bitfields" valueType="enumerated"> @@ -1322,20 +1325,20 @@ defaultValue="false" name="%Option.Chars" category="xlc.c.compiler.category.output" - id="xlc.c.compiler.option.signedness.chars" + id="xlc.c.compiler.option.output.chars" valueType="enumerated"> @@ -1344,84 +1347,84 @@ name="%Option.enablevmx" category="xlc.c.compiler.category.output" command="-qenablevmx" - id="xlc.c.compiler.option.objectcode.enablevmx" + id="xlc.c.compiler.option.output.enablevmx" valueType="boolean"> @@ -1429,7 +1432,7 @@ category="xlc.c.compiler.category.output" command="-qfuncset" defaultValue="false" - id="xlc.c.compiler.option.objectcode.funcset" + id="xlc.c.compiler.option.output.funcset" name="%Option.funcset" valueType="boolean"> @@ -1437,7 +1440,7 @@ category="xlc.c.compiler.category.output" command="-qppline" defaultValue="false" - id="xlc.c.compiler.option.objectcode.ppline" + id="xlc.c.compiler.option.output.ppline" name="%Option.ppline" valueType="boolean"> @@ -1445,7 +1448,7 @@ category="xlc.c.compiler.category.output" command="-qnoro" defaultValue="false" - id="xlc.c.compiler.option.objectcode.noro" + id="xlc.c.compiler.option.output.noro" name="%Option.noro" valueType="boolean"> @@ -1453,7 +1456,7 @@ category="xlc.c.compiler.category.output" command="-qnoroconst" defaultValue="false" - id="xlc.c.compiler.option.objectcode.noroconst" + id="xlc.c.compiler.option.output.noroconst" name="%Option.noroconst" valueType="boolean"> @@ -1461,7 +1464,7 @@ category="xlc.c.compiler.category.output" command="-qroptr" defaultValue="false" - id="xlc.c.compiler.option.objectcode.roptr" + id="xlc.c.compiler.option.output.roptr" name="%Option.roptr" valueType="boolean"> @@ -1469,7 +1472,7 @@ category="xlc.c.compiler.category.output" command="-qsaveopt" defaultValue="false" - id="xlc.c.compiler.option.objectcode.saveopt" + id="xlc.c.compiler.option.output.saveopt" name="%Option.saveopt" valueType="boolean"> @@ -1477,7 +1480,7 @@ category="xlc.c.compiler.category.output" command="-qstaticinline" defaultValue="false" - id="xlc.c.compiler.option.objectcode.staticinline" + id="xlc.c.compiler.option.output.staticinline" name="%Option.staticinline" valueType="boolean"> @@ -1485,7 +1488,7 @@ category="xlc.c.compiler.category.output" command="-qstatsym" defaultValue="false" - id="xlc.c.compiler.option.objectcode.statsym" + id="xlc.c.compiler.option.output.statsym" name="%Option.statsym" valueType="boolean"> @@ -1493,7 +1496,7 @@ category="xlc.c.compiler.category.output" command="-qthreaded" defaultValue="false" - id="xlc.c.compiler.option.objectcode.threaded" + id="xlc.c.compiler.option.output.threaded" name="%Option.threaded" valueType="boolean"> @@ -1501,7 +1504,7 @@ category="xlc.c.compiler.category.output" command="-qvrsave" defaultValue="false" - id="xlc.c.compiler.option.objectcode.vrsave" + id="xlc.c.compiler.option.output.vrsave" name="%Option.vrsave" valueType="boolean"> @@ -1509,7 +1512,7 @@ category="xlc.c.compiler.category.output" command="-qweaksymbol" defaultValue="false" - id="xlc.c.compiler.option.objectcode.weaksymbol" + id="xlc.c.compiler.option.output.weaksymbol" name="%Option.weaksymbol" valueType="boolean"> @@ -1517,7 +1520,7 @@ category="xlc.c.compiler.category.output" command="-qxcall" defaultValue="false" - id="xlc.c.compiler.option.objectcode.xcall" + id="xlc.c.compiler.option.output.xcall" name="%Option.xcall" valueType="boolean"> @@ -1569,55 +1572,27 @@ valueType="enumerated" > - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/HiddenOptionApplicabilityCalculator.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/HiddenOptionApplicabilityCalculator.java deleted file mode 100644 index a0c159d6c48..00000000000 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/HiddenOptionApplicabilityCalculator.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.managedbuilder.xlc.ui; - -import org.eclipse.cdt.managedbuilder.core.IBuildObject; -import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; -import org.eclipse.cdt.managedbuilder.core.IOption; -import org.eclipse.cdt.managedbuilder.core.IOptionApplicability; - -/** - This class decides whether the make shared object - option is visible,enabled or used in command line or not */ - -public class HiddenOptionApplicabilityCalculator implements - IOptionApplicability { - - /** - * This function decides if the option for which this class - * is option applicability calculator is enabled or not. - */ - public boolean isOptionEnabled(IBuildObject configuration, - IHoldsOptions holder, IOption option) { - return false; - } - - /** - * This function decides if the option for which this class - * is option applicability calculator is used in command line - * or not. - */ - - public boolean isOptionUsedInCommandLine(IBuildObject configuration, - IHoldsOptions holder, IOption option) { - return true; - } - - /** - * This function decides if the option for which this class - * is option applicability calculator is visible or not. - */ - - public boolean isOptionVisible(IBuildObject configuration, - IHoldsOptions holder, IOption option) { - - return false; - } - -} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/Messages.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/Messages.java new file mode 100644 index 00000000000..61bf3e2db07 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/Messages.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.xlc.ui; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.xlc.ui.messages"; //$NON-NLS-1$ + public static String XLCompilerPreferencePage_0; + public static String XLCompilerPreferencePage_1; + public static String XLCompilerPreferencePage_2; + public static String XLCompilerPropertyPage_0; + public static String XLCompilerPropertyPage_1; + public static String XLCSettingsWizardPage_0; + public static String XLCSettingsWizardPage_1; + public static String XLCSettingsWizardPage_2; + public static String XLCSettingsWizardPage_3; + public static String XLCSettingsWizardPage_4; + public static String XLCSettingsWizardPage_5; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java new file mode 100644 index 00000000000..80db6253dd7 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.xlc.ui; + +import org.eclipse.cdt.core.cdtvariables.ICdtVariable; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro; +import org.eclipse.cdt.managedbuilder.macros.IBuildMacro; +import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; +import org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier; +import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * @author crecoskie + * + */ +public class XLCProjectMacroSupplier implements IProjectBuildMacroSupplier { + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier#getMacro(java.lang.String, org.eclipse.cdt.managedbuilder.core.IManagedProject, org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider) + */ + public IBuildMacro getMacro(String macroName, IManagedProject project, + IBuildMacroProvider provider) { + + if(macroName.equals(PreferenceConstants.P_XL_COMPILER_ROOT)) { + String compilerPath = null; + + // figure out compiler path from properties and preferences + + // search for property first + IProject theProject = (IProject) project.getOwner(); + try { + compilerPath = theProject.getPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XL_COMPILER_ROOT)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(compilerPath == null) { + // use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + compilerPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT); + } + + BuildMacro macro = new BuildMacro(macroName, ICdtVariable.VALUE_PATH_DIR, + compilerPath); + + return macro; + } + + else + return provider.getMacro(macroName, IBuildMacroProvider.CONTEXT_PROJECT, project, true); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier#getMacros(org.eclipse.cdt.managedbuilder.core.IManagedProject, org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider) + */ + public IBuildMacro[] getMacros(IManagedProject project, + IBuildMacroProvider provider) { + + String macroName = PreferenceConstants.P_XL_COMPILER_ROOT; + + String compilerPath = null; + + // figure out compiler path from properties and preferences + + // search for property first + IProject theProject = (IProject) project.getOwner(); + try { + compilerPath = theProject.getPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XL_COMPILER_ROOT)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(compilerPath == null) { + // use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + compilerPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT); + } + + BuildMacro macro = new BuildMacro(macroName, ICdtVariable.VALUE_PATH_DIR, + compilerPath); + + // our array consists of our macro, plus all the macros from our parent + IBuildMacro[] parentMacros = provider.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, project, true); + + int numMacros = parentMacros.length + 1; // +1 for our macro + + IBuildMacro[] macros = new IBuildMacro[numMacros]; + + macros[0] = macro; + + for(int k = 1; k < macros.length; k++) { + macros[k] = parentMacros[k-1]; + } + + return macros; + + } + +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCUIPlugin.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCUIPlugin.java new file mode 100644 index 00000000000..76ab0a8704b --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCUIPlugin.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2006 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.xlc.ui; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import java.util.*; + +/** + * The main plugin class to be used in the desktop. + */ +public class XLCUIPlugin extends AbstractUIPlugin { + //The shared instance. + private static XLCUIPlugin plugin; + //Resource bundle. + private ResourceBundle resourceBundle; + + /** + * The constructor. + */ + public XLCUIPlugin() { + super(); + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + resourceBundle = null; + } + + /** + * Returns the shared instance. + */ + public static XLCUIPlugin getDefault() { + return plugin; + } + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + */ + public static String getResourceString(String key) { + ResourceBundle bundle = XLCUIPlugin.getDefault().getResourceBundle(); + try { + return (bundle != null) ? bundle.getString(key) : key; + } catch (MissingResourceException e) { + return key; + } + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() { + try { + if (resourceBundle == null) + resourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.managedbuilder.gnu.ui.XlcUIPluginResources"); //$NON-NLS-1$ + } catch (MissingResourceException x) { + resourceBundle = null; + } + return resourceBundle; + } + +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XlcUIPlugin.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XlcUIPlugin.java deleted file mode 100644 index 40ae8e94834..00000000000 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XlcUIPlugin.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.managedbuilder.xlc.ui; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; -import java.util.*; - -/** - * The main plugin class to be used in the desktop. - */ -public class XlcUIPlugin extends Plugin { - //The shared instance. - private static XlcUIPlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; - - /** - * The constructor. - */ - public XlcUIPlugin() { - super(); - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - resourceBundle = null; - } - - /** - * Returns the shared instance. - */ - public static XlcUIPlugin getDefault() { - return plugin; - } - - /** - * Returns the string from the plugin's resource bundle, - * or 'key' if not found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = XlcUIPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - try { - if (resourceBundle == null) - resourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.managedbuilder.gnu.ui.XlcUIPluginResources"); //$NON-NLS-1$ - } catch (MissingResourceException x) { - resourceBundle = null; - } - return resourceBundle; - } - -} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/messages.properties b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/messages.properties new file mode 100644 index 00000000000..d2412b9d65e --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/messages.properties @@ -0,0 +1,22 @@ +#/******************************************************************************* +# * Copyright (c) 2007 IBM Corporation and others. +# * All rights reserved. This program and the accompanying materials +# * are made available under the terms of the Eclipse Public License v1.0 +# * which accompanies this distribution, and is available at +# * http://www.eclipse.org/legal/epl-v10.html +# * +# * Contributors: +# * IBM Corporation - initial API and implementation +# *******************************************************************************/ + +XLCompilerPreferencePage_0=XL C/C++ Compiler Preferences +XLCompilerPreferencePage_1=Compiler Root Path: +XLCompilerPreferencePage_2=Compiler Version: +XLCompilerPropertyPage_0=Compiler Root Path: +XLCompilerPropertyPage_1=Compiler Version: +XLCSettingsWizardPage_0=XL C/C++ Settings +XLCSettingsWizardPage_1=Compiler Root Path: +XLCSettingsWizardPage_2=Browse... +XLCSettingsWizardPage_3=Compiler Version: +XLCSettingsWizardPage_4=Please select the path to your compiler, and the version of the compiler that you are using. +XLCSettingsWizardPage_5=XL Compiler Settings diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceConstants.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceConstants.java new file mode 100644 index 00000000000..a9ac3654a93 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceConstants.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.xlc.ui.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_XL_COMPILER_ROOT = "XL_compilerRoot"; //$NON-NLS-1$ + + public static final String P_XLC_COMPILER_VERSION = "XLC_compilerVersion"; //$NON-NLS-1$ + + public static final String P_XL_COMPILER_VERSION_8_NAME = "v8.0"; //$NON-NLS-1$ + public static final String P_XL_COMPILER_VERSION_9_NAME = "v9.0"; //$NON-NLS-1$ + +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceInitializer.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceInitializer.java new file mode 100644 index 00000000000..dd719712809 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/PreferenceInitializer.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.xlc.ui.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = XLCUIPlugin.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.P_XL_COMPILER_ROOT, "/opt/ibmcmp"); //$NON-NLS-1$ + store.setDefault(PreferenceConstants.P_XLC_COMPILER_VERSION, PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME); + } + +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/XLCompilerPreferencePage.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/XLCompilerPreferencePage.java new file mode 100644 index 00000000000..ef4b4ea6699 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/preferences/XLCompilerPreferencePage.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.xlc.ui.preferences; + +import org.eclipse.jface.preference.*; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.cdt.managedbuilder.xlc.ui.Messages; +import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

+ * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class XLCompilerPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + public XLCompilerPreferencePage() { + super(FLAT); + setPreferenceStore(XLCUIPlugin.getDefault().getPreferenceStore()); + setDescription(Messages.XLCompilerPreferencePage_0); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField(new DirectoryFieldEditor(PreferenceConstants.P_XL_COMPILER_ROOT, + Messages.XLCompilerPreferencePage_1, getFieldEditorParent())); + + String[][] versionEntries = {{PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME, "v8.0"}, //$NON-NLS-1$ + {PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME, "v9.0"}}; //$NON-NLS-1$ + + addField(new ComboFieldEditor(PreferenceConstants.P_XLC_COMPILER_VERSION, + Messages.XLCompilerPreferencePage_2, versionEntries, getFieldEditorParent())); + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + +} \ No newline at end of file diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/HiddenOptionApplicabilityCalculator.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/HiddenOptionApplicabilityCalculator.java new file mode 100644 index 00000000000..02da2ad7940 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/HiddenOptionApplicabilityCalculator.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.xlc.ui.properties; + +import org.eclipse.cdt.managedbuilder.core.IBuildObject; +import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; +import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.core.IOptionApplicability; + +/** + This class decides whether the make shared object + option is visible,enabled or used in command line or not */ + +public class HiddenOptionApplicabilityCalculator implements + IOptionApplicability { + + /** + * This function decides if the option for which this class + * is option applicability calculator is enabled or not. + */ + public boolean isOptionEnabled(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return false; + } + + /** + * This function decides if the option for which this class + * is option applicability calculator is used in command line + * or not. + */ + + public boolean isOptionUsedInCommandLine(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return true; + } + + /** + * This function decides if the option for which this class + * is option applicability calculator is visible or not. + */ + + public boolean isOptionVisible(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + + return false; + } + +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCompilerPropertyPage.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCompilerPropertyPage.java new file mode 100644 index 00000000000..71ade735e23 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCompilerPropertyPage.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.xlc.ui.properties; + +import org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionComboFieldEditor; +import org.eclipse.cdt.managedbuilder.xlc.ui.Messages; +import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin; +import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbenchPropertyPage; + +public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage { + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + */ + protected void createFieldEditors() { + + Composite parent = getFieldEditorParent(); + + fPathEditor = new DirectoryFieldEditor(PreferenceConstants.P_XL_COMPILER_ROOT, + Messages.XLCompilerPropertyPage_0, parent); + addField(fPathEditor); + + IProject project = ((IResource) getElement()).getProject(); + + String currentPath = null; + + try { + currentPath = project.getPersistentProperty(new QualifiedName("", //$NON-NLS-1$ + PreferenceConstants.P_XL_COMPILER_ROOT)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(currentPath == null) { + // if the property isn't set, then use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + currentPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT); + } + + fPathEditor.setStringValue(currentPath); + + String[] versionEntries = {PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME, + PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME}; + + Composite versionParent = getFieldEditorParent(); + + fVersionEditor = new BuildOptionComboFieldEditor(PreferenceConstants.P_XLC_COMPILER_VERSION, + Messages.XLCompilerPropertyPage_1, null, versionEntries, null, versionParent); + + addField(fVersionEditor); + + String currentVersion = null; + try { + currentVersion = project.getPersistentProperty(new QualifiedName("", //$NON-NLS-1$ + PreferenceConstants.P_XLC_COMPILER_VERSION)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(currentVersion == null) { + // if the property isn't set, then use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION); + } + + Combo versionCombo = fVersionEditor.getComboControl(versionParent); + versionCombo.setText(currentVersion); + + } + + private DirectoryFieldEditor fPathEditor; + + private BuildOptionComboFieldEditor fVersionEditor; + + //private Composite parent; + + + /** + * Constructor for SamplePropertyPage. + */ + public XLCompilerPropertyPage() { + super(FieldEditorPreferencePage.FLAT); + } + + + protected void performDefaults() { + // default to whatever is set on the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + String currentPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT); + String currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION); + + fPathEditor.setStringValue(currentPath); + + fVersionEditor.getComboControl(getFieldEditorParent()).setText(currentVersion); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk() + */ + public boolean performOk() { + // store the value in the owner text field + try { + IProject project = ((IResource) getElement()).getProject(); + + project.setPersistentProperty(new QualifiedName("", //$NON-NLS-1$ + PreferenceConstants.P_XL_COMPILER_ROOT), fPathEditor + .getStringValue()); + + project.setPersistentProperty(new QualifiedName("", //$NON-NLS-1$ + PreferenceConstants.P_XLC_COMPILER_VERSION), fVersionEditor + .getSelection()); + } catch (CoreException e) { + return false; + } + return true; + } + + /** + * The element. + */ + private IAdaptable element; + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement() + */ + public IAdaptable getElement() { + return element; + } + + /** + * Sets the element that owns properties shown on this page. + * + * @param element + * the element + */ + public void setElement(IAdaptable element) { + this.element = element; + } + +} \ No newline at end of file diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv8ApplicabiltyCalculator.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv8ApplicabiltyCalculator.java new file mode 100644 index 00000000000..000af9e110d --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv8ApplicabiltyCalculator.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.xlc.ui.properties; + +import org.eclipse.cdt.managedbuilder.core.IBuildObject; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IFolderInfo; +import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.core.IOptionApplicability; +import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin; +import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * @author crecoskie + * + */ +public class XLCv8ApplicabiltyCalculator implements IOptionApplicability { + + private boolean isVersion8(IBuildObject configuration) { + // first we check the preference for this project, if it exists + if(configuration instanceof IConfiguration) { + IConfiguration config = (IConfiguration) configuration; + IManagedProject managedProject = config.getManagedProject(); + + IProject project = (IProject) managedProject.getOwner(); + + String currentVersion = null; + try { + currentVersion = project.getPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XLC_COMPILER_VERSION)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(currentVersion == null) { + // if the property isn't set, then use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION); + } + + if(currentVersion.equals(PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME)) + return true; + } + + if(configuration instanceof IFolderInfo) { + IFolderInfo folderInfo = (IFolderInfo) configuration; + + IConfiguration config = folderInfo.getParent(); + + IManagedProject managedProject = config.getManagedProject(); + + IProject project = (IProject) managedProject.getOwner(); + + String currentVersion = null; + try { + currentVersion = project.getPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XLC_COMPILER_VERSION)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(currentVersion == null) { + // if the property isn't set, then use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION); + } + + if(currentVersion.equals(PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME)) + return true; + + } + + return false; + + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionEnabled(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption) + */ + public boolean isOptionEnabled(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return isVersion8(configuration); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionUsedInCommandLine(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption) + */ + public boolean isOptionUsedInCommandLine(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return isVersion8(configuration); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionVisible(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption) + */ + public boolean isOptionVisible(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return isVersion8(configuration); + } +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv9ApplicabilityCalculator.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv9ApplicabilityCalculator.java new file mode 100644 index 00000000000..9d713dd5ed8 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/properties/XLCv9ApplicabilityCalculator.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.xlc.ui.properties; + +import org.eclipse.cdt.managedbuilder.core.IBuildObject; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IFolderInfo; +import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.core.IOptionApplicability; +import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin; +import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * @author crecoskie + * + * This applicability calculator hides/shows options that are specific to the XL compilers, v9.0 + * + */ +public class XLCv9ApplicabilityCalculator implements IOptionApplicability { + + private boolean isVersion9(IBuildObject configuration) { + // first we check the preference for this project, if it exists + if(configuration instanceof IConfiguration) { + IConfiguration config = (IConfiguration) configuration; + IManagedProject managedProject = config.getManagedProject(); + + IProject project = (IProject) managedProject.getOwner(); + + String currentVersion = null; + try { + currentVersion = project.getPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XLC_COMPILER_VERSION)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(currentVersion == null) { + // if the property isn't set, then use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION); + } + + if(currentVersion.equals(PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME)) + return true; + } + + if(configuration instanceof IFolderInfo) { + IFolderInfo folderInfo = (IFolderInfo) configuration; + + IConfiguration config = folderInfo.getParent(); + + IManagedProject managedProject = config.getManagedProject(); + + IProject project = (IProject) managedProject.getOwner(); + + String currentVersion = null; + try { + currentVersion = project.getPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XLC_COMPILER_VERSION)); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(currentVersion == null) { + // if the property isn't set, then use the workbench preference + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION); + } + + if(currentVersion.equals(PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME)) + return true; + + } + + return false; + + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionEnabled(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption) + */ + public boolean isOptionEnabled(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return isVersion9(configuration); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionUsedInCommandLine(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption) + */ + public boolean isOptionUsedInCommandLine(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return isVersion9(configuration); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionVisible(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption) + */ + public boolean isOptionVisible(IBuildObject configuration, + IHoldsOptions holder, IOption option) { + return isVersion9(configuration); + } + +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardPage.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardPage.java new file mode 100644 index 00000000000..45e7b080ac5 --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardPage.java @@ -0,0 +1,300 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.xlc.ui.wizards; + +import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage; +import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; +import org.eclipse.cdt.managedbuilder.xlc.ui.Messages; +import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin; +import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; + +/** + * @author crecoskie + * + */ +public class XLCSettingsWizardPage extends MBSCustomPage { + + public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.xlc.ui.XlcSettingsWizardPage"; //$NON-NLS-1$ + + private final class BrowseButtonSelectionListener implements + SelectionListener { + private final Composite composite; + + private BrowseButtonSelectionListener(Composite composite) { + this.composite = composite; + } + + public void widgetDefaultSelected(SelectionEvent e) { + // meaningless for a button... do nothing + + } + + public void widgetSelected(SelectionEvent e) { + // open a browse dialog + DirectoryDialog dirDialog = new DirectoryDialog(composite.getShell(), SWT.APPLICATION_MODAL); + String browsedDirectory = dirDialog.open(); + fDirTextBox.setText(browsedDirectory); + + } + } + + private boolean fVisited = false; + + private Composite fComposite = null; + + private Text fDirTextBox; + + private Combo fVersionCombo; + + /** + * @param pageID + */ + public XLCSettingsWizardPage(String pageID) { + super(pageID); + } + + /** + * + */ + public XLCSettingsWizardPage() { + super(PAGE_ID); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage#isCustomPageComplete() + */ + protected boolean isCustomPageComplete() { + // Don't allow the user to finish without visiting the page. + return fVisited; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.IWizardPage#getName() + */ + public String getName() { + String name = Messages.XLCSettingsWizardPage_0; + return name; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + // create a new composite + fComposite = new Composite(parent, SWT.NONE); + fComposite.setBounds(parent.getBounds()); + GridLayout layout = new GridLayout(3, false); + fComposite.setLayout(layout); + fComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + + + // set the layout data for the first column, which contains labels + GridData labelGridData = new GridData(); + + + // create the first label + Label label1 = new Label(fComposite, SWT.NONE); + label1.setText(Messages.XLCSettingsWizardPage_1); + labelGridData.widthHint = 120; + label1.setLayoutData(labelGridData); + label1.setVisible(true); + + // create the text box for the path + GridData dirBoxGridData = new GridData(); + dirBoxGridData.grabExcessHorizontalSpace = true; + dirBoxGridData.horizontalAlignment = SWT.FILL; + fDirTextBox = new Text(fComposite, SWT.SINGLE | SWT.BORDER); + fDirTextBox.setLayoutData(dirBoxGridData); + fDirTextBox.setVisible(true); + + // set the default compiler location based on preferences + IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); + String compilerPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT); + fDirTextBox.setText(compilerPath); + + // update the page manager with the setting + MBSCustomPageManager.addPageProperty(PAGE_ID, PreferenceConstants.P_XL_COMPILER_ROOT, fDirTextBox.getText()); + + fDirTextBox.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + // update the page manager with the setting + MBSCustomPageManager.addPageProperty(PAGE_ID, PreferenceConstants.P_XL_COMPILER_ROOT, fDirTextBox.getText()); + + } + + }); + + // create the browse button + String selectedPath = null; + GridData buttonData = new GridData(); + buttonData.horizontalAlignment = SWT.RIGHT; + Button browseButton = new Button(fComposite, SWT.PUSH); + browseButton.setAlignment(SWT.CENTER); + browseButton.setText(Messages.XLCSettingsWizardPage_2); + browseButton.addSelectionListener(new BrowseButtonSelectionListener(fComposite) + ); + + browseButton.setVisible(true); + + // create the second label + Label label2 = new Label(fComposite, SWT.NONE); + label2.setText(Messages.XLCSettingsWizardPage_3); + label2.setLayoutData(labelGridData); + + label2.setVisible(true); + + // create the version dropdown + GridData comboData = new GridData(); + comboData.horizontalSpan = 2; + comboData.grabExcessHorizontalSpace = true; + comboData.horizontalAlignment = SWT.FILL; + + fVersionCombo = new Combo(fComposite, SWT.READ_ONLY); + fVersionCombo.setLayoutData(comboData); + + // populate the combo + fVersionCombo.add(PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME); + fVersionCombo.add(PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME); + + // set the default based on the workbench preference + String compilerVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION); + fVersionCombo.setText(compilerVersion); + + // update the page manager with the setting + MBSCustomPageManager.addPageProperty(PAGE_ID, PreferenceConstants.P_XLC_COMPILER_VERSION, fVersionCombo.getText()); + + fVersionCombo.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + // update the page manager with the setting + MBSCustomPageManager.addPageProperty(PAGE_ID, PreferenceConstants.P_XLC_COMPILER_VERSION, fVersionCombo.getText()); + + } + + }); + + fVersionCombo.setVisible(true); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#dispose() + */ + public void dispose() { + fComposite.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#getControl() + */ + public Control getControl() { + return fComposite; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#getDescription() + */ + public String getDescription() { + return Messages.XLCSettingsWizardPage_4; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage() + */ + public String getErrorMessage() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#getImage() + */ + public Image getImage() { + return wizard.getDefaultPageImage(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#getMessage() + */ + public String getMessage() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#getTitle() + */ + public String getTitle() { + return Messages.XLCSettingsWizardPage_5; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#performHelp() + */ + public void performHelp() { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#setDescription(java.lang.String) + */ + public void setDescription(String description) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) + */ + public void setImageDescriptor(ImageDescriptor image) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#setTitle(java.lang.String) + */ + public void setTitle(String title) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean) + */ + public void setVisible(boolean visible) { + fComposite.setVisible(visible); + if (visible) { + fVisited = true; + } + + } + +} diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardRunnable.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardRunnable.java new file mode 100644 index 00000000000..1f4bdad73fd --- /dev/null +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/wizards/XLCSettingsWizardRunnable.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.xlc.ui.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard; +import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; +import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.wizard.IWizardPage; + +/** + * @author crecoskie + * + */ +public class XLCSettingsWizardRunnable implements IRunnableWithProgress { + + /** + * + */ + public XLCSettingsWizardRunnable() { + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) + */ + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + // take the data from the page manager, and set the project properties with it + String compilerPath = MBSCustomPageManager.getPageProperty(XLCSettingsWizardPage.PAGE_ID, PreferenceConstants.P_XL_COMPILER_ROOT).toString(); + String compilerVersion = MBSCustomPageManager.getPageProperty(XLCSettingsWizardPage.PAGE_ID, PreferenceConstants.P_XLC_COMPILER_VERSION).toString(); + + // get a handle to the wizard + IWizardPage[] pages = MBSCustomPageManager.getPages(); + + if(pages != null && pages.length > 0) { + + CDTCommonProjectWizard wizard = (CDTCommonProjectWizard) pages[0].getWizard(); + + IProject project = wizard.getLastProject(); + + try { + project.setPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XL_COMPILER_ROOT), compilerPath); + + project.setPersistentProperty(new QualifiedName("", + PreferenceConstants.P_XLC_COMPILER_VERSION), compilerVersion); + + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + } + +} -- cgit v1.2.3