Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-02-20 17:23:35 +0000
committerMikhail Sennikovsky2007-02-20 17:23:35 +0000
commit5fdd70a074698a3c0f1b81428320eff63421d833 (patch)
tree0e3aa327e7d4cbe692db732b01a42e6d14f4f075
parent14737740c62a7475ff851548c1dbaaed7fe04ddb (diff)
downloadorg.eclipse.cdt-5fdd70a074698a3c0f1b81428320eff63421d833.tar.gz
org.eclipse.cdt-5fdd70a074698a3c0f1b81428320eff63421d833.tar.xz
org.eclipse.cdt-5fdd70a074698a3c0f1b81428320eff63421d833.zip
New Project Model initial check-in
-rw-r--r--build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF3
-rw-r--r--build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java62
-rw-r--r--build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java412
-rw-r--r--build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF11
-rw-r--r--build/org.eclipse.cdt.make.core/plugin.properties12
-rw-r--r--build/org.eclipse.cdt.make.core/plugin.xml21
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java5
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetListener.java2
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java31
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java340
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java49
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java276
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java60
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeTargetEvent.java2
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java83
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java540
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java343
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java173
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java292
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java244
-rw-r--r--build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF1
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.xml16
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/ErrorParserBlock.java118
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java810
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java16
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java15
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java1
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java5
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java383
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java129
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java846
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java379
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java380
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java29
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java596
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml167
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java29
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java642
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestMacro.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java819
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF11
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/plugin.properties12
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/plugin.xml274
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/schema/ScannerConfigurationDiscoveryProfile.exsd (renamed from build/org.eclipse.cdt.make.core/schema/ScannerConfigurationDiscoveryProfile.exsd)4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd263
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/schema/buildProperties.exsd87
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java)6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java)8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IConfigurationScannerConfigBuilderInfo.java73
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java)15
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java)20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector3.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/InfoContext.java97
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java147
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java)138
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java)2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java)8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java)35
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java)34
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java555
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java)207
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java)6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathInfo.java183
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java)28
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java)19
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java)91
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java)12
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java)10
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java)2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java)6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java)21
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java)85
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java)2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java)4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java)130
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java)55
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java)6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java)55
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java)75
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java)6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java)0
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java)38
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java)518
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java)37
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java)119
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperties.java35
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperty.java18
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyManager.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyType.java19
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyValue.java15
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IPropertyBase.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectProperties.java21
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectPropertiesContainer.java16
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPropertiesRestriction.java26
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java73
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java79
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFileInfo.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFolderInfo.java63
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java44
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ILanguageInfoCalculator.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IModificationStatus.java63
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java36
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceInfo.java107
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java37
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java1216
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java207
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedCProjectNature.java49
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedOptionValueHandler.java7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IBuildEnvironmentVariable.java14
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableProvider.java11
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableSupplier.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java161
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java25
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/FileMacroExplicitSubstitutor.java18
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java150
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java90
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyManager.java226
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyType.java38
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyValue.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/PropertyBase.java46
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BooleanExpressionApplicabilityCalculator.java181
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObjectProperties.java155
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java78
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java1466
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java343
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java1612
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java1863
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConverterInfo.java39
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java1221
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HoldsOptions.java175
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IBuildPropertyChangeListener.java15
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IMatchKeyProvider.java21
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ISettingsChangeListener.java19
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java818
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java284
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java83
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java19
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java306
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java273
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ModificationStatus.java114
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/NotificationManager.java57
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java240
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java49
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java106
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java127
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java9
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java550
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java450
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java113
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SourcePath.java49
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SupportedProperties.java200
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java62
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java1342
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java1079
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java62
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java93
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java132
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEnvironmentContributor.java72
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFileData.java67
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFolderData.java75
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java453
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildTargetPlatformData.java47
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java149
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java357
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java92
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java89
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java346
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ExternalExtensionMacroSupplier.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExternalExtensionMacroSupplier.java)135
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java225
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java291
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AdjustmentContext.java77
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AndExpression.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckBuildPropertyExpression.java108
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckHolderExpression.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckOptionExpression.java66
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckStringExpression.java18
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CompositeExpression.java37
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/FalseExpression.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/IBooleanExpression.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/NotExpression.java7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OptionEnablementExpression.java366
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OrExpression.java8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java54
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/DefaultContextInfo.java101
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvironmentVariableProvider.java495
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/ExternalExtensionEnvironmentSupplier.java184
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/MbsEnvironmentSupplier.java44
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java247
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java272
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java326
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildCdtVariablesSupplierBase.java51
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacro.java71
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroProvider.java406
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroStatus.java211
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildfileMacroSubstitutor.java109
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CdtPathEntryMacroSupplier.java76
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CoreMacrosSupplier.java43
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroContextInfo.java61
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/EnvironmentMacroSupplier.java191
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExplicitFileMacroCollector.java18
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfo.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfoProvider.java16
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java196
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java129
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java44
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java11
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/BuildMacroException.java45
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacro.java64
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroStatus.java60
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroSupplier.java14
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator2.java22
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java6
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java17
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3.java6
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3Commands.java10
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java13
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java1202
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java35
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeBuilderInfo.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java)4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeCommonBuildInfo.java)20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeBuilderUtil.java44
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeScannerInfo.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerInfo.java)2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeScannerProvider.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java)11
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.java58
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.properties55
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/PreferenceInitializer.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java)24
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java102
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml1584
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCProjectPlatformPage.java179
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCustomPageManager.java1641
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestToolchain.java38
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/dlcl16/read_only.gifbin0 -> 851 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/built_in.gifbin0 -> 854 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/discovery.gifbin0 -> 362 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/editable.gifbin0 -> 829 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/read_only.gifbin0 -> 851 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/artifact.gifbin0 -> 177 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/bin_obj.gifbin0 -> 367 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/build_settings.gifbin0 -> 940 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/define_obj.gifbin0 -> 154 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/environment.gifbin0 -> 614 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/error_obj.gifbin0 -> 339 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/filesystem.gifbin0 -> 310 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/fldr_obj.gifbin0 -> 216 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/hfolder_obj.gifbin0 -> 579 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/lib_obj.gifbin0 -> 338 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/opentype.gifbin0 -> 581 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/output_folder_obj.gifbin0 -> 352 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/search_ref_obj.gifbin0 -> 356 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/steps.gifbin0 -> 857 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/workspace.gifbin0 -> 308 bytes
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.properties11
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.xml599
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/schema/CDTWizard.exsd122
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/schema/CNewWizard.exsd119
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/schema/DiscoveryProfileUI.exsd139
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java747
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java347
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java1230
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java322
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java199
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java1294
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java329
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java438
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java76
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/NewEnvVarDialog.java709
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java618
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java954
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java18
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetDialog.java9
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractCBuildPropertyTab.java85
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractDiscoveryPage.java (renamed from build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java)330
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractToolSettingUI.java75
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ArtifactTab.java160
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildOptionComboFieldEditor.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java)4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildOptionSettingsUI.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java)219
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildStepsTab.java374
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildToolSettingUI.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java)229
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuilderSettingsTab.java581
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CBuildLocationOutputTab.java27
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CNewOptionsPage.java41
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java509
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/DiscoveryTab.java385
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/FileListControl.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java)70
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/FileListControlFieldEditor.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java)13
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerFileSCDProfilePage.java39
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerProjectSCDProfilePage.java126
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/IBuildInfoContainer.java31
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/IFileListChangeListener.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/IFileListChangeListener.java)5
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ManagedBuilderUIImages.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIImages.java)19
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ManagedBuilderUIPlugin.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java)6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/Messages.java22
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewBuildConfigurationDialog.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java)278
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewCfgDialog.java432
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewVarDialog.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/NewBuildMacroDialog.java)130
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PageLayout.java63
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PrefPage_NewCDTProject.java39
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolChainEditTab.java228
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListContentProvider.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java)62
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListElement.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java)12
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListLabelProvider.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java)10
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSelectionDialog.java236
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSettingsPrefStore.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPreferenceStore.java)264
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSettingsTab.java644
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/messages.properties65
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/AbstractBuildPropertyPage.java212
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BrowseEntryDialog.java339
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPreferencePage.java269
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java649
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java104
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java677
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java647
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/AbstractCWizard.java57
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CCProjectWizard.java37
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CConfigWizardPage.java317
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTProjectWizard.java29
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CMainWizardPage.java505
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CNewWizard.java93
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java598
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectWizard.java36
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CWizardHandler.java195
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java32
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationLabelProvider.java41
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/DummyHandler.java58
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICNewWizard.java49
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICWizardHandler.java46
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IDEWorkbenchMessages.java31
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IToolChainListListener.java32
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java53
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java107
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/Messages.java31
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java83
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java67
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java137
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java273
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewModelProjectWizard.java318
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdBuildWizard.java32
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdProjectTypeHandler.java84
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/messages.properties36
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF10
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java83
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguageDescriptor.java22
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java84
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java40
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java42
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java40
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java40
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java52
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java39
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java34
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java34
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICBuildSetting.java34
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java61
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java355
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExclusionPatternPathEntry.java17
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExternalSetting.java23
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFolderDescription.java32
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludeFileEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludePathEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java55
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingEntry.java14
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingPathEntry.java17
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryFileEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryPathEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroFileEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICOutputEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICPathEntry.java22
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java143
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICResourceDescription.java27
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingBase.java21
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingContainer.java17
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java48
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingObject.java69
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingsStorage.java52
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java53
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICTargetPlatformSetting.java17
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/WriteAccessException.java20
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java37
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationData.java60
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java64
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CDataObject.java34
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFileData.java27
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFolderData.java38
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java53
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CResourceData.java27
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CTargetPlatformData.java23
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/ICProjectConverter.java22
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java116
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultBuildData.java132
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java303
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java126
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java163
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java214
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultTargetPlatformData.java94
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CResourceDataContainer.java109
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java77
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java81
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CExtensionUtil.java43
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/Comparator.java20
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryNameKey.java39
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java189
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IKindBasedInfo.java19
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerListener.java23
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerVisitor.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java174
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java266
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ListComparator.java122
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfo.java29
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfoElement.java47
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java2231
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java411
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java308
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java31
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java44
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java47
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java3
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java122
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java87
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreChangedOperation.java25
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java134
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java11
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACExclusionFilterEntry.java91
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingEntry.java114
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingPathEntry.java92
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java152
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java69
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java90
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java77
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDataProviderDescriptor.java114
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java708
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java396
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java744
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java150
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java108
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSetting.java183
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingProvider.java146
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java131
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java83
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java194
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java129
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java399
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java111
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectConverterDesciptor.java69
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java384
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java158
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionEvent.java148
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java2630
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CStorage.java172
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java40
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java50
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java128
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedEntriesContainerInitializer.java30
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java28
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java195
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java51
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java188
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionStatus.java33
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/EntriesNamesContainer.java105
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExceptionFactory.java33
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExternalSettingsManager.java1072
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataProxyContainer.java18
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataScope.java19
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDescriptionDelta.java65
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionListener.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICachedData.java15
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IDataProvider.java17
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IExternalSettingsProvider.java22
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalCCfgInfo.java21
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalResourceDescription.java23
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyCache.java42
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyFactory.java18
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyProvider.java42
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/InternalXmlStorageElement.java184
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java74
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java310
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProjectRefInfo.java92
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProviderBasedRcDesHolder.java62
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProxyProvider.java128
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java179
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java149
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java90
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml18
-rw-r--r--core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd87
-rw-r--r--core/org.eclipse.cdt.core/schema/projectConverter.exsd87
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java209
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java3
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionDescriptor.java17
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java88
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableException.java115
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java220
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariable.java80
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java151
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableStatus.java85
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariablesContributor.java19
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvirinmentVariable.java88
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IContributedEnvironment.java35
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentContributor.java17
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java69
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java80
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java257
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java413
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java1164
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java690
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java36
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java10
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java129
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java99
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java495
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java204
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java39
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreVariableSubstitutor.java53
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java139
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EclipseVariablesVariableSupplier.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/EclipseVariablesMacroSupplier.java)49
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EnvironmentVariableSupplier.java182
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/ICoreVariableContextInfo.java39
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariable.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableBuildMacro.java)40
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableMacros.java)194
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java)201
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSustemEnvironmentSupplier.java252
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java140
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java85
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EclipseEnvironmentSupplier.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EclipseEnvironmentSupplier.java)24
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarCollector.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarCollector.java)28
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarDescriptor.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarDescriptor.java)29
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java426
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ICoreEnvironmentVariableSupplier.java39
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/IEnvironmentContextInfo.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/IContextInfo.java)13
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java364
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MacroResolver.java)205
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/ICdtVariableSupplier.java38
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java37
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableSubstitutor.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroSubstitutor.java)21
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableManager.java113
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableStatus.java45
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroSubstitutor.java)164
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvVarOperationProcessor.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarOperationProcessor.java)48
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvironmentCollector.java58
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvVar.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvVar.java)16
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java317
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironmentLoader.java (renamed from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironmentLoader.java)73
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF8
-rw-r--r--core/org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gifbin0 -> 552 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/dlcl16/config-tool.gifbin0 -> 368 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/dlcl16/open_incl.gifbin0 -> 324 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gifbin0 -> 578 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/elcl16/config-tool.gifbin0 -> 368 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/elcl16/open_incl.gifbin0 -> 324 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/obj16/environment.gifbin0 -> 614 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/obj16/filesyst.GIFbin0 -> 310 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/obj16/workspace.GIFbin0 -> 308 bytes
-rw-r--r--core/org.eclipse.cdt.ui/plugin.properties19
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml138
-rw-r--r--core/org.eclipse.cdt.ui/schema/cPropertyTab.exsd221
-rw-r--r--core/org.eclipse.cdt.ui/schema/newCfgDialog.exsd143
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildConfigAction.java)31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigActionBase.java)171
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigContextAction.java)14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigMenuAction.java)16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java190
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java99
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java488
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java443
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java405
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java848
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java63
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java354
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTListComparator.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java48
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java294
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java135
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java441
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java200
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java268
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java233
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java280
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryPathTab.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java40
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java66
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java64
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java141
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java60
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LanguagesTab.java144
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java75
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java288
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManagedBuilderHelpContextIds.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderHelpContextIds.java)4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/MultiLineTextFieldEditor.java)19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java369
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewUIMessages.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIMessages.java)10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_BuildSettings.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ExpPathAndSymb.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Languages.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_PathAndSymb.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ConvertStartup.java)26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ToolChain.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Variables.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties)109
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java193
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java (renamed from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java)185
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SDKsTab.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java135
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java53
665 files changed, 69261 insertions, 27809 deletions
diff --git a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF
index 00becff334b..cbeb1d1cd0d 100644
--- a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.junit,
org.eclipse.cdt.make.core,
org.eclipse.cdt.core,
- org.eclipse.core.resources
+ org.eclipse.core.resources,
+ org.eclipse.cdt.managedbuilder.core
Eclipse-AutoStart: true
Bundle-Vendor: Eclipse.org
diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java
index b16afb8de44..e823b3fc270 100644
--- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java
+++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java
@@ -11,21 +11,13 @@
package org.eclipse.cdt.make.builder.tests;
import java.io.ByteArrayInputStream;
-import java.util.Map;
import junit.framework.TestCase;
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.MakeProjectNature;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
import org.eclipse.cdt.make.core.tests.StandardBuildTestHelper;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -61,33 +53,33 @@ public class ScannerConfigDiscoveryTests extends TestCase {
StandardBuildTestHelper.removeProject("SCDC");
}
- public void testGetCCompilerBuiltins() throws CoreException {
- MakeProjectNature.addNature(fCProject, fMonitor);
- ScannerConfigNature.addScannerConfigNature(fCProject);
-
- PerProjectSICollector.calculateCompilerBuiltins(fCProject);
- IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
- getScannerInformation(fCFile);
- assertNotNull(scInfo);
- String[] includes = scInfo.getIncludePaths();
- assertTrue(includes.length > 0);
- Map symbols = scInfo.getDefinedSymbols();
- assertFalse(symbols.isEmpty());
- }
+// public void testGetCCompilerBuiltins() throws CoreException {
+// MakeProjectNature.addNature(fCProject, fMonitor);
+// ScannerConfigNature.addScannerConfigNature(fCProject);
+//
+// PerProjectSICollector.calculateCompilerBuiltins(fCProject);
+// IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
+// getScannerInformation(fCFile);
+// assertNotNull(scInfo);
+// String[] includes = scInfo.getIncludePaths();
+// assertTrue(includes.length > 0);
+// Map symbols = scInfo.getDefinedSymbols();
+// assertFalse(symbols.isEmpty());
+// }
- public void testGetCCCompilerBuiltins() throws CoreException {
- CCProjectNature.addCCNature(fCProject, fMonitor);
- MakeProjectNature.addNature(fCProject, fMonitor);
- ScannerConfigNature.addScannerConfigNature(fCProject);
-
- PerProjectSICollector.calculateCompilerBuiltins(fCProject);
- IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
- getScannerInformation(fCFile);
- assertNotNull(scInfo);
- String[] includes = scInfo.getIncludePaths();
- assertTrue(includes.length > 0);
- Map symbols = scInfo.getDefinedSymbols();
- assertFalse(symbols.isEmpty());
- }
+// public void testGetCCCompilerBuiltins() throws CoreException {
+// CCProjectNature.addCCNature(fCProject, fMonitor);
+// MakeProjectNature.addNature(fCProject, fMonitor);
+// ScannerConfigNature.addScannerConfigNature(fCProject);
+//
+// PerProjectSICollector.calculateCompilerBuiltins(fCProject);
+// IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
+// getScannerInformation(fCFile);
+// assertNotNull(scInfo);
+// String[] includes = scInfo.getIncludePaths();
+// assertTrue(includes.length > 0);
+// Map symbols = scInfo.getDefinedSymbols();
+// assertFalse(symbols.isEmpty());
+// }
}
diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java
index 367d5b1b73a..fe40525e64e 100644
--- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java
+++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java
@@ -17,10 +17,9 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
-import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
+import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -46,216 +45,217 @@ public class StandardBuildTests extends TestCase {
super(name);
}
+ //TODO: migrate tests to the new functionality
public static Test suite() {
TestSuite suite = new TestSuite(StandardBuildTests.class.getName());
// Add the relevant tests to the suite
- suite.addTest(new StandardBuildTests("testProjectCreation"));
- suite.addTest(new StandardBuildTests("testProjectSettings"));
- suite.addTest(new StandardBuildTests("testProjectConversion"));
- suite.addTest(new StandardBuildTests("testProjectCleanup"));
-
- suite.addTestSuite(ScannerConfigConsoleParserTests.class);
- suite.addTestSuite(ScannerConfigDiscoveryTests.class);
+// suite.addTest(new StandardBuildTests("testProjectCreation"));
+// suite.addTest(new StandardBuildTests("testProjectSettings"));
+// suite.addTest(new StandardBuildTests("testProjectConversion"));
+// suite.addTest(new StandardBuildTests("testProjectCleanup"));
+//
+// suite.addTestSuite(ScannerConfigConsoleParserTests.class);
+// suite.addTestSuite(ScannerConfigDiscoveryTests.class);
return suite;
}
- private void checkDefaultProjectSettings(IProject project) throws Exception {
- assertNotNull(project);
-
- IMakeBuilderInfo defaultInfo = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
-
- IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
- // Check the rest of the project information
- assertEquals(defaultInfo.isDefaultBuildCmd(), builderInfo.isDefaultBuildCmd());
- assertEquals(defaultInfo.isStopOnError(), builderInfo.isStopOnError());
- assertEquals(defaultInfo.getBuildCommand(), builderInfo.getBuildCommand());
- assertEquals(defaultInfo.getBuildArguments(), builderInfo.getBuildArguments());
- assertEquals(defaultInfo.getBuildLocation(), builderInfo.getBuildLocation());
-
- assertEquals(defaultInfo.isAutoBuildEnable(), builderInfo.isAutoBuildEnable());
- assertEquals(defaultInfo.getAutoBuildTarget(), builderInfo.getAutoBuildTarget());
- assertEquals(defaultInfo.isIncrementalBuildEnabled(), builderInfo.isIncrementalBuildEnabled());
- assertEquals(defaultInfo.getIncrementalBuildTarget(), builderInfo.getIncrementalBuildTarget());
- assertEquals(defaultInfo.isFullBuildEnabled(), builderInfo.isFullBuildEnabled());
- assertEquals(defaultInfo.getFullBuildTarget(), builderInfo.getFullBuildTarget());
- assertEquals(defaultInfo.isCleanBuildEnabled(), builderInfo.isCleanBuildEnabled());
- assertEquals(defaultInfo.getCleanBuildTarget(), builderInfo.getCleanBuildTarget());
-
- }
-
- private void checkOverriddenProjectSettings(IProject project) throws Exception {
- assertNotNull(project);
-
- // Check the rest of the project information
- IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
- assertEquals(OFF, builderInfo.isDefaultBuildCmd());
- assertEquals(ON, builderInfo.isStopOnError());
- assertEquals(new Path(OVR_BUILD_COMMAND), builderInfo.getBuildCommand());
- assertEquals(OVR_BUILD_ARGS, builderInfo.getBuildArguments());
- assertEquals(new Path(OVR_BUILD_LOCATION), builderInfo.getBuildLocation());
- }
-
- /**
- * Create a new project named <code>name</code> or return the project in
- * the workspace of the same name if it exists.
- *
- * @param name The name of the project to create or retrieve.
- * @return
- * @throws CoreException
- */
- private IProject createProject(final String name) throws CoreException {
- final Object[] result = new Object[1];
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor monitor) throws CoreException {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IProject project = root.getProject(name);
- if (!project.exists()) {
- project.create(null);
- } else {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- if (!project.isOpen()) {
- project.open(null);
- }
- CCorePlugin.getDefault().convertProjectToC(project, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
- result[0] = project;
- }
- }, null);
- return (IProject)result[0];
- }
-
- /**
- * Remove the <code>IProject</code> with the name specified in the argument from the
- * receiver's workspace.
- *
- * @param name
- */
- private void removeProject(String name) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IProject project = root.getProject(name);
- if (project.exists()) {
- try {
- project.delete(true, false, null);
- } catch (CoreException e) {
- assertTrue(false);
- }
- }
- }
-
- /**
- * Remove all the project information associated with the project used during test.
- */
- public void testProjectCleanup() {
- removeProject(PROJECT_NAME);
- }
-
- public void testProjectConversion() throws Exception {
- // Open the project
- IProject project = null;
- try {
- project = createProject(PROJECT_NAME);
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectConversion failed opening project: " + e.getLocalizedMessage());
- }
- assertNotNull(project);
-
- // Check the settings (they should be the override values)
- checkOverriddenProjectSettings(project);
-
- // Now convert the project
- try {
- CCorePlugin.getDefault().convertProjectFromCtoCC(project, new NullProgressMonitor());
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectConversion failed to convert project: " + e.getLocalizedMessage());
- }
-
- // Close, and Reopen the project
- try {
- project.close(new NullProgressMonitor());
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectConversion failed to close project " + e.getLocalizedMessage());
- }
- try {
- project.open(new NullProgressMonitor());
- } catch (CoreException e) {
- fail ("StandardBuildTest testProjectConversion failed to open project " + e.getLocalizedMessage());
- }
-
- // Make sure it has a CCNature
- try {
- project.hasNature(CCProjectNature.CC_NATURE_ID);
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectConversion failed getting nature: " + e.getLocalizedMessage());
- }
-
- // Nothing should have changed in the settings
- checkOverriddenProjectSettings(project);
- }
-
- /**
- *
- */
- public void testProjectCreation() throws Exception {
- // Create a new project
- IProject project = null;
- try {
- project = createProject(PROJECT_NAME);
- // Convert the new project to a standard make project
- MakeProjectNature.addNature(project, null);
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectCreation failed creating project: " + e.getLocalizedMessage());
- }
- assertNotNull(project);
-
- // Make sure it has a CNature
- try {
- project.hasNature(CProjectNature.C_NATURE_ID);
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
- }
- // Make sure it has a MakeNature
- try {
- project.hasNature(MakeProjectNature.NATURE_ID);
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
- }
- // Check the default settings
- checkDefaultProjectSettings(project);
- }
-
- public void testProjectSettings() throws Exception {
- // Get the project
- IProject project = null;
- try {
- project = createProject(PROJECT_NAME);
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectSettings failed opening project: " + e.getLocalizedMessage());
- }
- assertNotNull(project);
-
- // Use the build info for the rest of the settings
- IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
- builderInfo.setStopOnError(ON);
- builderInfo.setUseDefaultBuildCmd(OFF);
- builderInfo.setBuildCommand(new Path(OVR_BUILD_COMMAND));
- builderInfo.setBuildArguments(OVR_BUILD_ARGS);
- builderInfo.setBuildLocation(new Path(OVR_BUILD_LOCATION));
- try {
- project.close(new NullProgressMonitor());
- } catch (CoreException e) {
- fail("StandardBuildTest testProjectSettings failed to close project " + e.getLocalizedMessage());
- }
- try {
- project.open(new NullProgressMonitor());
- } catch (CoreException e) {
- fail ("StandardBuildTest testProjectSettings failed to open project " + e.getLocalizedMessage());
- }
-
- // Retest
- checkOverriddenProjectSettings(project);
- }
+// private void checkDefaultProjectSettings(IProject project) throws Exception {
+// assertNotNull(project);
+//
+// IMakeBuilderInfo defaultInfo = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
+//
+// IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
+// // Check the rest of the project information
+// assertEquals(defaultInfo.isDefaultBuildCmd(), builderInfo.isDefaultBuildCmd());
+// assertEquals(defaultInfo.isStopOnError(), builderInfo.isStopOnError());
+// assertEquals(defaultInfo.getBuildCommand(), builderInfo.getBuildCommand());
+// assertEquals(defaultInfo.getBuildArguments(), builderInfo.getBuildArguments());
+// assertEquals(defaultInfo.getBuildLocation(), builderInfo.getBuildLocation());
+//
+// assertEquals(defaultInfo.isAutoBuildEnable(), builderInfo.isAutoBuildEnable());
+// assertEquals(defaultInfo.getAutoBuildTarget(), builderInfo.getAutoBuildTarget());
+// assertEquals(defaultInfo.isIncrementalBuildEnabled(), builderInfo.isIncrementalBuildEnabled());
+// assertEquals(defaultInfo.getIncrementalBuildTarget(), builderInfo.getIncrementalBuildTarget());
+// assertEquals(defaultInfo.isFullBuildEnabled(), builderInfo.isFullBuildEnabled());
+// assertEquals(defaultInfo.getFullBuildTarget(), builderInfo.getFullBuildTarget());
+// assertEquals(defaultInfo.isCleanBuildEnabled(), builderInfo.isCleanBuildEnabled());
+// assertEquals(defaultInfo.getCleanBuildTarget(), builderInfo.getCleanBuildTarget());
+//
+// }
+//
+// private void checkOverriddenProjectSettings(IProject project) throws Exception {
+// assertNotNull(project);
+//
+// // Check the rest of the project information
+// IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
+// assertEquals(OFF, builderInfo.isDefaultBuildCmd());
+// assertEquals(ON, builderInfo.isStopOnError());
+// assertEquals(new Path(OVR_BUILD_COMMAND), builderInfo.getBuildCommand());
+// assertEquals(OVR_BUILD_ARGS, builderInfo.getBuildArguments());
+// assertEquals(new Path(OVR_BUILD_LOCATION), builderInfo.getBuildLocation());
+// }
+//
+// /**
+// * Create a new project named <code>name</code> or return the project in
+// * the workspace of the same name if it exists.
+// *
+// * @param name The name of the project to create or retrieve.
+// * @return
+// * @throws CoreException
+// */
+// private IProject createProject(final String name) throws CoreException {
+// final Object[] result = new Object[1];
+// ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+//
+// public void run(IProgressMonitor monitor) throws CoreException {
+// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+// IProject project = root.getProject(name);
+// if (!project.exists()) {
+// project.create(null);
+// } else {
+// project.refreshLocal(IResource.DEPTH_INFINITE, null);
+// }
+//
+// if (!project.isOpen()) {
+// project.open(null);
+// }
+// CCorePlugin.getDefault().convertProjectToC(project, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
+// result[0] = project;
+// }
+// }, null);
+// return (IProject)result[0];
+// }
+//
+// /**
+// * Remove the <code>IProject</code> with the name specified in the argument from the
+// * receiver's workspace.
+// *
+// * @param name
+// */
+// private void removeProject(String name) {
+// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+// IProject project = root.getProject(name);
+// if (project.exists()) {
+// try {
+// project.delete(true, false, null);
+// } catch (CoreException e) {
+// assertTrue(false);
+// }
+// }
+// }
+//
+// /**
+// * Remove all the project information associated with the project used during test.
+// */
+// public void testProjectCleanup() {
+// removeProject(PROJECT_NAME);
+// }
+//
+// public void testProjectConversion() throws Exception {
+// // Open the project
+// IProject project = null;
+// try {
+// project = createProject(PROJECT_NAME);
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectConversion failed opening project: " + e.getLocalizedMessage());
+// }
+// assertNotNull(project);
+//
+// // Check the settings (they should be the override values)
+// checkOverriddenProjectSettings(project);
+//
+// // Now convert the project
+// try {
+// CCorePlugin.getDefault().convertProjectFromCtoCC(project, new NullProgressMonitor());
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectConversion failed to convert project: " + e.getLocalizedMessage());
+// }
+//
+// // Close, and Reopen the project
+// try {
+// project.close(new NullProgressMonitor());
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectConversion failed to close project " + e.getLocalizedMessage());
+// }
+// try {
+// project.open(new NullProgressMonitor());
+// } catch (CoreException e) {
+// fail ("StandardBuildTest testProjectConversion failed to open project " + e.getLocalizedMessage());
+// }
+//
+// // Make sure it has a CCNature
+// try {
+// project.hasNature(CCProjectNature.CC_NATURE_ID);
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectConversion failed getting nature: " + e.getLocalizedMessage());
+// }
+//
+// // Nothing should have changed in the settings
+// checkOverriddenProjectSettings(project);
+// }
+//
+// /**
+// *
+// */
+// public void testProjectCreation() throws Exception {
+// // Create a new project
+// IProject project = null;
+// try {
+// project = createProject(PROJECT_NAME);
+// // Convert the new project to a standard make project
+// MakeProjectNature.addNature(project, null);
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectCreation failed creating project: " + e.getLocalizedMessage());
+// }
+// assertNotNull(project);
+//
+// // Make sure it has a CNature
+// try {
+// project.hasNature(CProjectNature.C_NATURE_ID);
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
+// }
+// // Make sure it has a MakeNature
+// try {
+// project.hasNature(MakeProjectNature.NATURE_ID);
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
+// }
+// // Check the default settings
+// checkDefaultProjectSettings(project);
+// }
+//
+// public void testProjectSettings() throws Exception {
+// // Get the project
+// IProject project = null;
+// try {
+// project = createProject(PROJECT_NAME);
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectSettings failed opening project: " + e.getLocalizedMessage());
+// }
+// assertNotNull(project);
+//
+// // Use the build info for the rest of the settings
+// IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
+// builderInfo.setStopOnError(ON);
+// builderInfo.setUseDefaultBuildCmd(OFF);
+// builderInfo.setBuildCommand(new Path(OVR_BUILD_COMMAND));
+// builderInfo.setBuildArguments(OVR_BUILD_ARGS);
+// builderInfo.setBuildLocation(new Path(OVR_BUILD_LOCATION));
+// try {
+// project.close(new NullProgressMonitor());
+// } catch (CoreException e) {
+// fail("StandardBuildTest testProjectSettings failed to close project " + e.getLocalizedMessage());
+// }
+// try {
+// project.open(new NullProgressMonitor());
+// } catch (CoreException e) {
+// fail ("StandardBuildTest testProjectSettings failed to open project " + e.getLocalizedMessage());
+// }
+//
+// // Retest
+// checkOverriddenProjectSettings(project);
+// }
}
diff --git a/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF
index 052eb8c33d3..fbe0f4a747d 100644
--- a/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF
@@ -9,18 +9,13 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.make.core,
org.eclipse.cdt.make.core.makefile,
org.eclipse.cdt.make.core.makefile.gnu,
- org.eclipse.cdt.make.core.scannerconfig,
org.eclipse.cdt.make.internal.core,
org.eclipse.cdt.make.internal.core.makefile,
org.eclipse.cdt.make.internal.core.makefile.gnu,
- org.eclipse.cdt.make.internal.core.makefile.posix,
- org.eclipse.cdt.make.internal.core.scannerconfig,
- org.eclipse.cdt.make.internal.core.scannerconfig.gnu,
- org.eclipse.cdt.make.internal.core.scannerconfig.jobs,
- org.eclipse.cdt.make.internal.core.scannerconfig.util,
- org.eclipse.cdt.make.internal.core.scannerconfig2
+ org.eclipse.cdt.make.internal.core.makefile.posix
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.cdt.core;bundle-version="[4.0.0,5.0.0)"
+ org.eclipse.cdt.core;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.cdt.managedbuilder.core
Eclipse-LazyStart: true
diff --git a/build/org.eclipse.cdt.make.core/plugin.properties b/build/org.eclipse.cdt.make.core/plugin.properties
index 655cd9036b5..44b3886fea8 100644
--- a/build/org.eclipse.cdt.make.core/plugin.properties
+++ b/build/org.eclipse.cdt.make.core/plugin.properties
@@ -16,16 +16,4 @@ extensionTargetBuilder.name=Target Builder Extension
natureMake.name=CDT Make Nature
builderMake.name=CDT Makefile Builder
-epScannerConfigNature.name=Scanner Configuration Nature
-epScannerConfigBuilder.name=Scanner Configuration Builder
-extensionExternalScannerInfoProvider.name=C/C++ External Scanner Info Provider Extension
-epDefaultExternalScannerInfoProvider.name=Default External Scanner Info Provider
-
-extensionScannerInfoConsoleParser.name=GNU C/C++ Scanner Info Console Parser Extension
-epGCCCommandLineParser.name=GNU C/C++ Scanner Info Parser
-epGCCSpecsParser.name=GNU C/C++ Compiler Specs Parser
-
-extensionGCCPerProjectProfile.name=GNU C/C++ Scanner Info per project profile
-extensionGCCPerFileProfile.name=GNU C/C++ Scanner Info per file profile
-
makefile=Makefile
diff --git a/build/org.eclipse.cdt.make.core/plugin.xml b/build/org.eclipse.cdt.make.core/plugin.xml
index 5f58f276f4d..863bfbb1aae 100644
--- a/build/org.eclipse.cdt.make.core/plugin.xml
+++ b/build/org.eclipse.cdt.make.core/plugin.xml
@@ -30,7 +30,7 @@
id="org.eclipse.cdt.make.core.makeBuilder">
</builder>
</extension>
- <extension
+ <!--extension
id="makeBuilder"
name="%builderMake.name"
point="org.eclipse.core.resources.builders">
@@ -44,7 +44,7 @@
</parameter>
</run>
</builder>
- </extension>
+ </extension-->
<extension
id="make"
name="%makeproject.name"
@@ -54,14 +54,14 @@
natureID="org.eclipse.cdt.make.core.makeNature">
</cproject>
</extension>
- <extension
+ <!--extension
point="org.eclipse.cdt.make.core.MakeTargetBuilder">
<builder
builderID="org.eclipse.cdt.make.core.makeBuilder"
id="org.eclipse.cdt.make.MakeTargetBuilder">
</builder>
- </extension>
- <extension
+ </extension-->
+ <!--extension
id="ScannerConfigNature"
name="%epScannerConfigNature.name"
point="org.eclipse.core.resources.natures">
@@ -87,7 +87,7 @@
class="org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder">
</run>
</builder>
- </extension>
+ </extension-->
<extension
id="DiscoveredScannerInfoProvider"
point="org.eclipse.cdt.core.ScannerInfoProvider">
@@ -159,5 +159,14 @@
file-names="Makefile,makefile,GNUMakefile"
file-extensions="mk"/>
</extension>
+
+ <extension
+ point="org.eclipse.cdt.make.core.MakeTargetBuilder">
+ <builder
+ builderID="org.eclipse.cdt.managedbuilder.core.genmakebuilder"
+ id="org.eclipse.cdt.make.MakeTargetBuilder">
+ </builder>
+ </extension>
+
</plugin>
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java
index 41431fce6a3..57b1b380612 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.make.core;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.newmake.core.IMakeCommonBuildInfo;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -25,6 +27,7 @@ public interface IMakeTarget extends IAdaptable, IMakeCommonBuildInfo {
IProject getProject();
+ IConfiguration getConfiguration();
/**
* @deprecated
*/
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetListener.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetListener.java
index 42c754531c9..b31e7214737 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetListener.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java
index 614a0095bd5..5a675465039 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -10,12 +10,24 @@
*******************************************************************************/
package org.eclipse.cdt.make.core;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
public interface IMakeTargetManager {
+ /**
+ * @param project
+ * @param targetName
+ * @param targetBuilderID
+ * @return
+ * @throws CoreException
+ *
+ */
IMakeTarget createTarget(IProject project, String targetName, String targetBuilderID) throws CoreException;
+
+ IMakeTarget createTarget(IConfiguration cfg, String builderId, String targetBuilderID, String name) throws CoreException;
+
/**
* Adds target to manager.
* @param target
@@ -34,10 +46,25 @@ public interface IMakeTargetManager {
void renameTarget(IMakeTarget target, String name) throws CoreException;
boolean targetExists(IMakeTarget target);
-
+ /**
+ * @param container
+ * @return
+ * @throws CoreException
+ */
IMakeTarget[] getTargets(IContainer container) throws CoreException;
+
+ IMakeTarget[] getTargets(IConfiguration cfg, IContainer container) throws CoreException;
+
+ /**
+ * @param container
+ * @param name
+ * @return
+ * @throws CoreException
+ */
IMakeTarget findTarget(IContainer container, String name) throws CoreException;
+ IMakeTarget findTarget(IConfiguration cfg, IContainer container, String name) throws CoreException;
+
IProject[] getTargetBuilderProjects() throws CoreException;
String getBuilderID(String targetBuilderID);
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
deleted file mode 100644
index 770c77b7ead..00000000000
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.core;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CommandLauncher;
-import org.eclipse.cdt.core.ErrorParserManager;
-import org.eclipse.cdt.core.model.ICModelMarker;
-import org.eclipse.cdt.core.resources.ACBuilder;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
-import org.eclipse.cdt.make.internal.core.StreamMonitor;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceRuleFactory;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-
-public class MakeBuilder extends ACBuilder {
-
- public final static String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeBuilder"; //$NON-NLS-1$
-
- public MakeBuilder() {
- }
-
- /**
- * @see IncrementalProjectBuilder#build
- */
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
- boolean bPerformBuild = true;
- IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(args, MakeBuilder.BUILDER_ID);
- if (!shouldBuild(kind, info)) {
- return new IProject[0];
- }
- if (kind == IncrementalProjectBuilder.AUTO_BUILD) {
- IResourceDelta delta = getDelta(getProject());
- if (delta != null) {
- IResource res = delta.getResource();
- if (res != null) {
- bPerformBuild = res.getProject().equals(getProject());
- }
- } else {
- bPerformBuild = false;
- }
- }
- if (bPerformBuild) {
- boolean isClean = invokeMake(kind, info, monitor);
- if (isClean) {
- forgetLastBuiltState();
- }
- }
- checkCancel(monitor);
- return getProject().getReferencedProjects();
- }
-
-
- protected void clean(IProgressMonitor monitor) throws CoreException {
- final IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(getProject(), BUILDER_ID);
- if (shouldBuild(CLEAN_BUILD, info)) {
- IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
- final ISchedulingRule rule = ruleFactory.modifyRule(getProject());
- Job backgroundJob = new Job("Standard Make Builder"){ //$NON-NLS-1$
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
- try {
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor monitor) {
- invokeMake(CLEAN_BUILD, info, monitor);
- }
- }, rule, IWorkspace.AVOID_UPDATE, monitor);
- } catch (CoreException e) {
- return e.getStatus();
- }
- IStatus returnStatus = Status.OK_STATUS;
- return returnStatus;
- }
-
-
- };
-
- backgroundJob.setRule(rule);
- backgroundJob.schedule();
- }
- }
-
-
-
- protected boolean invokeMake(int kind, IMakeBuilderInfo info, IProgressMonitor monitor) {
- boolean isClean = false;
- IProject currProject = getProject();
-
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(MakeMessages.getString("MakeBuilder.Invoking_Make_Builder") + currProject.getName(), 100); //$NON-NLS-1$
-
- try {
- IPath buildCommand = info.getBuildCommand();
- if (buildCommand != null) {
- IConsole console = CCorePlugin.getDefault().getConsole();
- console.start(currProject);
-
- OutputStream cos = console.getOutputStream();
-
- // remove all markers for this project
- removeAllMarkers(currProject);
-
- IPath workingDirectory = MakeBuilderUtil.getBuildDirectory(currProject, info);
-
- String[] targets = getTargets(kind, info);
- if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget())) //$NON-NLS-1$
- isClean = true;
-
- String errMsg = null;
- CommandLauncher launcher = new CommandLauncher();
- // Print the command for visual interaction.
- launcher.showCommand(true);
-
- // Set the environment
- HashMap envMap = new HashMap();
- if (info.appendEnvironment()) {
- envMap.putAll(launcher.getEnvironment());
- }
- // Add variables from build info
- envMap.putAll(info.getExpandedEnvironment());
- Iterator iter = envMap.entrySet().iterator();
- List strings= new ArrayList(envMap.size());
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- StringBuffer buffer= new StringBuffer((String) entry.getKey());
- buffer.append('=').append((String) entry.getValue());
- strings.add(buffer.toString());
- }
- String[] env = (String[]) strings.toArray(new String[strings.size()]);
- String[] buildArguments = targets;
- if (info.isDefaultBuildCmd()) {
- if (!info.isStopOnError()) {
- buildArguments = new String[targets.length + 1];
- buildArguments[0] = "-k"; //$NON-NLS-1$
- System.arraycopy(targets, 0, buildArguments, 1, targets.length);
- }
- } else {
- String args = info.getBuildArguments();
- if (args != null && !args.equals("")) { //$NON-NLS-1$
- String[] newArgs = makeArray(args);
- buildArguments = new String[targets.length + newArgs.length];
- System.arraycopy(newArgs, 0, buildArguments, 0, newArgs.length);
- System.arraycopy(targets, 0, buildArguments, newArgs.length, targets.length);
- }
- }
-// MakeRecon recon = new MakeRecon(buildCommand, buildArguments, env, workingDirectory, makeMonitor, cos);
-// recon.invokeMakeRecon();
-// cos = recon;
- QualifiedName qName = new QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "progressMonitor"); //$NON-NLS-1$
- Integer last = (Integer)getProject().getSessionProperty(qName);
- if (last == null) {
- last = new Integer(100);
- }
- StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), cos, last.intValue());
- ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectory, this, info.getErrorParsers());
- epm.setOutputStream(streamMon);
- OutputStream stdout = epm.getOutputStream();
- OutputStream stderr = epm.getOutputStream();
- // Sniff console output for scanner info
- ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getMakeBuilderOutputSniffer(
- stdout, stderr, getProject(), workingDirectory, null, this, null);
- OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream());
- OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream());
- Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory);
- if (p != null) {
- try {
- // Close the input of the Process explicitly.
- // We will never write to it.
- p.getOutputStream().close();
- } catch (IOException e) {
- }
- // Before launching give visual cues via the monitor
- monitor.subTask(MakeMessages.getString("MakeBuilder.Invoking_Command") + launcher.getCommandLine()); //$NON-NLS-1$
- if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0))
- != CommandLauncher.OK)
- errMsg = launcher.getErrorMessage();
- monitor.subTask(MakeMessages.getString("MakeBuilder.Updating_project")); //$NON-NLS-1$
-
- try {
- // Do not allow the cancel of the refresh, since the builder is external
- // to Eclipse, files may have been created/modified and we will be out-of-sync.
- // The caveat is for hugue projects, it may take sometimes at every build.
- currProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- }
- } else {
- errMsg = launcher.getErrorMessage();
- }
- getProject().setSessionProperty(qName, !monitor.isCanceled() && !isClean ? new Integer(streamMon.getWorkDone()) : null);
-
- if (errMsg != null) {
- StringBuffer buf = new StringBuffer(buildCommand.toString() + " "); //$NON-NLS-1$
- for (int i = 0; i < buildArguments.length; i++) {
- buf.append(buildArguments[i]);
- buf.append(' ');
- }
-
- String errorDesc = MakeMessages.getFormattedString("MakeBuilder.buildError", buf.toString()); //$NON-NLS-1$
- buf = new StringBuffer(errorDesc);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
- cos.write(buf.toString().getBytes());
- cos.flush();
- }
-
- stdout.close();
- stderr.close();
-
- monitor.subTask(MakeMessages.getString("MakeBuilder.Creating_Markers")); //$NON-NLS-1$
- consoleOut.close();
- consoleErr.close();
- epm.reportProblems();
- cos.close();
- }
- } catch (Exception e) {
- CCorePlugin.log(e);
- } finally {
- monitor.done();
- }
- return (isClean);
- }
-
- /**
- * Check whether the build has been canceled.
- */
- public void checkCancel(IProgressMonitor monitor) {
- if (monitor != null && monitor.isCanceled())
- throw new OperationCanceledException();
- }
-
- protected boolean shouldBuild(int kind, IMakeBuilderInfo info) {
- switch (kind) {
- case IncrementalProjectBuilder.AUTO_BUILD :
- return info.isAutoBuildEnable();
- case IncrementalProjectBuilder.INCREMENTAL_BUILD : // now treated as the same!
- case IncrementalProjectBuilder.FULL_BUILD :
- return info.isFullBuildEnabled() | info.isIncrementalBuildEnabled() ;
- case IncrementalProjectBuilder.CLEAN_BUILD :
- return info.isCleanBuildEnabled();
- }
- return true;
- }
-
- protected String[] getTargets(int kind, IMakeBuilderInfo info) {
- String targets = ""; //$NON-NLS-1$
- switch (kind) {
- case IncrementalProjectBuilder.AUTO_BUILD :
- targets = info.getAutoBuildTarget();
- break;
- case IncrementalProjectBuilder.INCREMENTAL_BUILD : // now treated as the same!
- case IncrementalProjectBuilder.FULL_BUILD :
- targets = info.getIncrementalBuildTarget();
- break;
- case IncrementalProjectBuilder.CLEAN_BUILD :
- targets = info.getCleanBuildTarget();
- break;
- }
- return makeArray(targets);
- }
-
- // Turn the string into an array.
- String[] makeArray(String string) {
- string.trim();
- char[] array = string.toCharArray();
- ArrayList aList = new ArrayList();
- StringBuffer buffer = new StringBuffer();
- boolean inComment = false;
- for (int i = 0; i < array.length; i++) {
- char c = array[i];
- if (array[i] == '"' || array[i] == '\'') {
- if (i > 0 && array[i - 1] == '\\') {
- inComment = false;
- } else {
- inComment = !inComment;
- }
- }
- if (c == ' ' && !inComment) {
- aList.add(buffer.toString());
- buffer = new StringBuffer();
- } else {
- buffer.append(c);
- }
- }
- if (buffer.length() > 0)
- aList.add(buffer.toString());
- return (String[]) aList.toArray(new String[aList.size()]);
- }
-
- private void removeAllMarkers(IProject currProject) throws CoreException {
- IWorkspace workspace = currProject.getWorkspace();
-
- // remove all markers
- IMarker[] markers = currProject.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- if (markers != null) {
- workspace.deleteMarkers(markers);
- }
- }
-}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java
deleted file mode 100644
index a95a8eec695..00000000000
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 QNX Software Systems 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:
- * QNX Software Systems - Initial implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.core;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-public class MakeBuilderUtil {
-
- public static IPath getBuildDirectory(IProject project, IPath subPath, String builderID) {
- IPath rootPath = getBuildDirectory(project, builderID);
- return rootPath.append(subPath);
- }
-
- public static IPath getBuildDirectory(IProject project, String builderID) {
- IMakeBuilderInfo info;
- try {
- info = MakeCorePlugin.createBuildInfo(project, builderID);
- } catch (CoreException e) {
- return project.getLocation();
- }
- return getBuildDirectory(project, info);
- }
-
- public static IPath getBuildDirectory(IProject project, IMakeBuilderInfo info) {
- IPath buildDirectory = info.getBuildLocation();
- if (!buildDirectory.isEmpty()) {
- IResource res = project.getParent().findMember(buildDirectory);
- if (res instanceof IContainer && res.exists()) {
- buildDirectory = res.getLocation();
- }
- } else {
- buildDirectory = project.getLocation();
- }
- return buildDirectory;
- }
-}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java
index fcf67e4387d..6b72eaaf971 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java
@@ -16,34 +16,22 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.cdt.make.core.makefile.IMakefile;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.internal.core.BuildInfoFactory;
import org.eclipse.cdt.make.internal.core.MakeTargetManager;
import org.eclipse.cdt.make.internal.core.makefile.gnu.GNUMakefile;
import org.eclipse.cdt.make.internal.core.makefile.posix.PosixMakefile;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathManager;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigInfoFactory;
-import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
@@ -57,9 +45,9 @@ public class MakeCorePlugin extends Plugin {
public static final String MAKE_PROJECT_ID = MakeCorePlugin.getUniqueIdentifier() + ".make"; //$NON-NLS-1$
public static final String OLD_BUILDER_ID = "org.eclipse.cdt.core.cbuilder"; //$NON-NLS-1$
- public static final String EXTERNAL_SI_PROVIDER_SIMPLE_ID = "ExternalScannerInfoProvider"; //$NON-NLS-1$
- public static final String SI_CONSOLE_PARSER_SIMPLE_ID = "ScannerInfoConsoleParser"; //$NON-NLS-1$
- public static final String DEFAULT_EXTERNAL_SI_PROVIDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".DefaultExternalScannerInfoProvider"; //$NON-NLS-1$
+// public static final String EXTERNAL_SI_PROVIDER_SIMPLE_ID = "ExternalScannerInfoProvider"; //$NON-NLS-1$
+// public static final String SI_CONSOLE_PARSER_SIMPLE_ID = "ScannerInfoConsoleParser"; //$NON-NLS-1$
+// public static final String DEFAULT_EXTERNAL_SI_PROVIDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".DefaultExternalScannerInfoProvider"; //$NON-NLS-1$
public static final String GCC_SPECS_CONSOLE_PARSER_ID = MakeCorePlugin.getUniqueIdentifier() + ".GCCSpecsConsoleParser"; //$NON-NLS-1$
public static final String GCC_SCANNER_INFO_CONSOLE_PARSER_ID = MakeCorePlugin.getUniqueIdentifier() + ".GCCScannerInfoConsoleParser"; //$NON-NLS-1$
@@ -69,7 +57,7 @@ public class MakeCorePlugin extends Plugin {
private MakeTargetManager fTargetManager;
- private DiscoveredPathManager fDiscoveryPathManager;
+// private DiscoveredPathManager fDiscoveryPathManager;
//The shared instance.
private static MakeCorePlugin plugin;
@@ -113,17 +101,17 @@ public class MakeCorePlugin extends Plugin {
return getDefault().getBundle().getSymbolicName();
}
- public static IMakeBuilderInfo createBuildInfo(Preferences prefs, String builderID, boolean useDefaults) {
- return BuildInfoFactory.create(prefs, builderID, useDefaults);
- }
-
- public static IMakeBuilderInfo createBuildInfo(IProject project, String builderID) throws CoreException {
- return BuildInfoFactory.create(project, builderID);
- }
-
- public static IMakeBuilderInfo createBuildInfo(Map args, String builderID) {
- return BuildInfoFactory.create(args, builderID);
- }
+// public static IMakeBuilderInfo createBuildInfo(Preferences prefs, String builderID, boolean useDefaults) {
+// return BuildInfoFactory.create(prefs, builderID, useDefaults);
+// }
+//
+// public static IMakeBuilderInfo createBuildInfo(IProject project, String builderID) throws CoreException {
+// return ManagedBuilderCorePlugin.createBuilders(project, args)Info(project, builderID);
+// }
+//
+// public static IMakeBuilderInfo createBuildInfo(Map args, String builderID) {
+// return BuildInfoFactory.create(args, builderID);
+// }
public IMakeTargetManager getTargetManager() {
if ( fTargetManager == null) {
@@ -186,10 +174,10 @@ public class MakeCorePlugin extends Plugin {
fTargetManager.shutdown();
fTargetManager = null;
}
- if (fDiscoveryPathManager != null) {
- fDiscoveryPathManager.shutdown();
- fDiscoveryPathManager = null;
- }
+// if (fDiscoveryPathManager != null) {
+// fDiscoveryPathManager.shutdown();
+// fDiscoveryPathManager = null;
+// }
savePluginPreferences();
} finally {
super.stop(context);
@@ -200,115 +188,115 @@ public class MakeCorePlugin extends Plugin {
* Following methods create IScannerConfigBuilderInfo
* Delegating requests to ScannerConfigInfoFactory
*/
- public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
- Preferences prefs, String builderID, boolean useDefaults) {
- return ScannerConfigInfoFactory.create(prefs, builderID, useDefaults);
- }
-
- public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
- IProject project, String builderID) throws CoreException {
- return ScannerConfigInfoFactory.create(project, builderID);
- }
-
- public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
- Map args, String builderID) {
- return ScannerConfigInfoFactory.create(args, builderID);
- }
+// public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
+// Preferences prefs, String builderID, boolean useDefaults) {
+// return ScannerConfigInfoFactory.create(prefs, builderID, useDefaults);
+// }
+//
+// public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
+// IProject project, String builderID) throws CoreException {
+// return ScannerConfigInfoFactory.create(project, builderID);
+// }
+//
+// public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
+// Map args, String builderID) {
+// return ScannerConfigInfoFactory.create(args, builderID);
+// }
public static IPath getWorkingDirectory() {
return MakeCorePlugin.getDefault().getStateLocation();
}
- public IDiscoveredPathManager getDiscoveryManager() {
- if ( fDiscoveryPathManager == null) {
- fDiscoveryPathManager = new DiscoveredPathManager();
- fDiscoveryPathManager.startup();
- }
- return fDiscoveryPathManager;
- }
-
- /**
- * @param id - id specifying external scanner info provider
- * @return provider - new instance of an external scanner info provider
- */
- public IExternalScannerInfoProvider getExternalScannerInfoProvider(String id) {
- try {
- IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, EXTERNAL_SI_PROVIDER_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- String tool = extensions[i].getUniqueIdentifier();
- if (tool != null && tool.equals(id)) {
- IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
- IConfigurationElement[] runElement = configElements[j].getChildren("run"); //$NON-NLS-1$
- if (runElement.length > 0) {
- IExternalScannerInfoProvider builder = (IExternalScannerInfoProvider) runElement[0].createExecutableExtension("class"); //$NON-NLS-1$
- return builder;
- }
- }
- }
- }
- }
- }
- catch (CoreException e) {
- log(e);
- }
- return null;
- }
+// public IDiscoveredPathManager getDiscoveryManager() {
+// if ( fDiscoveryPathManager == null) {
+// fDiscoveryPathManager = new DiscoveredPathManager();
+// fDiscoveryPathManager.startup();
+// }
+// return fDiscoveryPathManager;
+// }
- /**
- * @param commandId
- * @return String[] - array of parserIds associated with the commandId or 'all'
- */
- public String[] getScannerInfoConsoleParserIds(String commandId) {
- String[] empty = new String[0];
- if (commandId == null || commandId.length() == 0) {
- commandId = "all"; //$NON-NLS-1$
- }
- IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- List parserIds = new ArrayList(extensions.length);
- for (int i = 0; i < extensions.length; i++) {
- String parserId = extensions[i].getUniqueIdentifier();
- if (parserId != null) {
- IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
- String id = configElements[0].getAttribute("commandId");//$NON-NLS-1$
- if (id != null && (id.equals(commandId) || id.equals("all"))) { //$NON-NLS-1$
- parserIds.add(parserId);
- }
- }
- }
- return (String[])parserIds.toArray(empty);
- }
- return empty;
- }
-
- /**
- * @param parserId
- * @return parser - parser object identified by the parserId
- */
- public IScannerInfoConsoleParser getScannerInfoConsoleParser(String parserId) {
- try {
- IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- String id = extensions[i].getUniqueIdentifier();
- if (id != null && id.equals(parserId)) {
- IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
- IScannerInfoConsoleParser parser = (IScannerInfoConsoleParser)configElements[0].createExecutableExtension("class");//$NON-NLS-1$
- return parser;
- }
- }
- }
- }
- catch (CoreException e) {
- log(e);
- }
- return null;
- }
+// /**
+// * @param id - id specifying external scanner info provider
+// * @return provider - new instance of an external scanner info provider
+// */
+// public IExternalScannerInfoProvider getExternalScannerInfoProvider(String id) {
+// try {
+// IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, EXTERNAL_SI_PROVIDER_SIMPLE_ID);
+// if (extension != null) {
+// IExtension[] extensions = extension.getExtensions();
+// for (int i = 0; i < extensions.length; i++) {
+// String tool = extensions[i].getUniqueIdentifier();
+// if (tool != null && tool.equals(id)) {
+// IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+// for (int j = 0; j < configElements.length; j++) {
+// IConfigurationElement[] runElement = configElements[j].getChildren("run"); //$NON-NLS-1$
+// if (runElement.length > 0) {
+// IExternalScannerInfoProvider builder = (IExternalScannerInfoProvider) runElement[0].createExecutableExtension("class"); //$NON-NLS-1$
+// return builder;
+// }
+// }
+// }
+// }
+// }
+// }
+// catch (CoreException e) {
+// log(e);
+// }
+// return null;
+// }
+//
+// /**
+// * @param commandId
+// * @return String[] - array of parserIds associated with the commandId or 'all'
+// */
+// public String[] getScannerInfoConsoleParserIds(String commandId) {
+// String[] empty = new String[0];
+// if (commandId == null || commandId.length() == 0) {
+// commandId = "all"; //$NON-NLS-1$
+// }
+// IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
+// if (extension != null) {
+// IExtension[] extensions = extension.getExtensions();
+// List parserIds = new ArrayList(extensions.length);
+// for (int i = 0; i < extensions.length; i++) {
+// String parserId = extensions[i].getUniqueIdentifier();
+// if (parserId != null) {
+// IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+// String id = configElements[0].getAttribute("commandId");//$NON-NLS-1$
+// if (id != null && (id.equals(commandId) || id.equals("all"))) { //$NON-NLS-1$
+// parserIds.add(parserId);
+// }
+// }
+// }
+// return (String[])parserIds.toArray(empty);
+// }
+// return empty;
+// }
+//
+// /**
+// * @param parserId
+// * @return parser - parser object identified by the parserId
+// */
+// public IScannerInfoConsoleParser getScannerInfoConsoleParser(String parserId) {
+// try {
+// IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
+// if (extension != null) {
+// IExtension[] extensions = extension.getExtensions();
+// for (int i = 0; i < extensions.length; i++) {
+// String id = extensions[i].getUniqueIdentifier();
+// if (id != null && id.equals(parserId)) {
+// IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+// IScannerInfoConsoleParser parser = (IScannerInfoConsoleParser)configElements[0].createExecutableExtension("class");//$NON-NLS-1$
+// return parser;
+// }
+// }
+// }
+// }
+// catch (CoreException e) {
+// log(e);
+// }
+// return null;
+// }
/* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#startup()
@@ -319,19 +307,19 @@ public class MakeCorePlugin extends Plugin {
//Set debug tracing options
configurePluginDebugOptions();
// Scanner config discovery setup
- GCCScannerConfigUtil.createSpecs();
+// GCCScannerConfigUtil.createSpecs();
}
- private static final String SCANNER_CONFIG = MakeCorePlugin.getUniqueIdentifier() + "/debug/scdiscovery"; //$NON-NLS-1$
+// private static final String SCANNER_CONFIG = MakeCorePlugin.getUniqueIdentifier() + "/debug/scdiscovery"; //$NON-NLS-1$
/**
*
*/
private void configurePluginDebugOptions() {
- if (isDebugging()) {
- String option = Platform.getDebugOption(SCANNER_CONFIG);
- if (option != null) {
- TraceUtil.SCANNER_CONFIG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
- }
- }
+// if (isDebugging()) {
+// String option = Platform.getDebugOption(SCANNER_CONFIG);
+// if (option != null) {
+// TraceUtil.SCANNER_CONFIG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
+// }
+// }
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java
index 0f532ac42aa..fdde361be6b 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java
@@ -119,48 +119,48 @@ public class MakeProjectNature implements IProjectNature {
project.setDescription(description, mon);
}
- public void addBuildSpec() throws CoreException {
- addToBuildSpec(getProject(), MakeBuilder.BUILDER_ID, null);
- }
+// public void addBuildSpec() throws CoreException {
+// addToBuildSpec(getProject(), MakeBuilder.BUILDER_ID, null);
+// }
/**
* @see IProjectNature#configure
*/
public void configure() throws CoreException {
- addBuildSpec();
- IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, false);
- IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(getProject(), MakeBuilder.BUILDER_ID);
- projectInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
- projectInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
-
- projectInfo.setUseDefaultBuildCmd(info.isDefaultBuildCmd());
- projectInfo.setStopOnError(info.isStopOnError());
-
- projectInfo.setAutoBuildEnable(info.isAutoBuildEnable());
- projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "")); //$NON-NLS-1$
-
- projectInfo.setIncrementalBuildEnable(info.isIncrementalBuildEnabled());
- projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, "")); //$NON-NLS-1$
-
- projectInfo.setFullBuildEnable(info.isIncrementalBuildEnabled());
-
- projectInfo.setCleanBuildEnable(info.isCleanBuildEnabled());
- projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "")); //$NON-NLS-1$
-
- projectInfo.setErrorParsers(info.getErrorParsers());
- projectInfo.setAppendEnvironment(info.appendEnvironment());
- projectInfo.setEnvironment(info.getEnvironment());
+// addBuildSpec();
+// IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, false);
+// IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(getProject(), MakeBuilder.BUILDER_ID);
+// projectInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
+// projectInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
+//
+// projectInfo.setUseDefaultBuildCmd(info.isDefaultBuildCmd());
+// projectInfo.setStopOnError(info.isStopOnError());
+//
+// projectInfo.setAutoBuildEnable(info.isAutoBuildEnable());
+// projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "")); //$NON-NLS-1$
+//
+// projectInfo.setIncrementalBuildEnable(info.isIncrementalBuildEnabled());
+// projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, "")); //$NON-NLS-1$
+//
+// projectInfo.setFullBuildEnable(info.isIncrementalBuildEnabled());
+//
+// projectInfo.setCleanBuildEnable(info.isCleanBuildEnabled());
+// projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "")); //$NON-NLS-1$
+//
+// projectInfo.setErrorParsers(info.getErrorParsers());
+// projectInfo.setAppendEnvironment(info.appendEnvironment());
+// projectInfo.setEnvironment(info.getEnvironment());
}
- public void removeBuildSpec() throws CoreException {
- removeFromBuildSpec(getProject(), MakeBuilder.BUILDER_ID, null);
- }
+// public void removeBuildSpec() throws CoreException {
+// removeFromBuildSpec(getProject(), MakeBuilder.BUILDER_ID, null);
+// }
/**
* @see IProjectNature#deconfigure
*/
public void deconfigure() throws CoreException {
- removeBuildSpec();
+// removeBuildSpec();
}
/**
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeTargetEvent.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeTargetEvent.java
index dca4dcf2a51..44c05958f26 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeTargetEvent.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeTargetEvent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
deleted file mode 100644
index 36d60120ce8..00000000000
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import java.util.Map;
-
-import org.eclipse.cdt.core.resources.ACBuilder;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
-import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.SCJobsUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-/**
- * Runs after standard make builder.
- * Consolidates discovered scanner configuration and updates project's scanner configuration.
- *
- * @see IncrementalProjectBuilder
- */
-public class ScannerConfigBuilder extends ACBuilder {
- public final static String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$
-
- public ScannerConfigBuilder() {
- super();
- }
-
- /**
- * @see IncrementalProjectBuilder#build
- */
- protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
- // If auto discovery is disabled, do nothing
-// boolean autodiscoveryEnabled;
- boolean autodiscoveryEnabled2;
- IScannerConfigBuilderInfo2 buildInfo2 = null;
- try {
-// IScannerConfigBuilderInfo buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(getProject(), BUILDER_ID);
-// autodiscoveryEnabled = buildInfo.isAutoDiscoveryEnabled();
-//
-// if (autodiscoveryEnabled) {
-// monitor.beginTask("ScannerConfigBuilder.Invoking_Builder", 100); //$NON-NLS-1$
-// monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
-// getProject().getName());
-// ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(), new SubProgressMonitor(monitor, 100));
-// }
-
- buildInfo2 = ScannerConfigProfileManager.createScannerConfigBuildInfo2(getProject());
- autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
-
- if (autodiscoveryEnabled2) {
- monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$
- monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
- getProject().getName());
-
- // get scanner info from all external providers
- SCJobsUtil.getProviderScannerInfo(getProject(), buildInfo2, new SubProgressMonitor(monitor, 70));
-
- // update and persist scanner configuration
- SCJobsUtil.updateScannerConfiguration(getProject(), buildInfo2, new SubProgressMonitor(monitor, 30));
- }
- }
- catch (CoreException e) {
- // builder not installed or disabled
-// autodiscoveryEnabled = false;
- autodiscoveryEnabled2 = false;
- MakeCorePlugin.log(e);
- }
-
- return getProject().getReferencedProjects();
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
deleted file mode 100644
index d8815b81823..00000000000
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
+++ /dev/null
@@ -1,540 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.ErrorParserManager;
-import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.MakeProjectNature;
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.osgi.service.environment.*;
-
-public class BuildInfoFactory {
-
- private static final String PREFIX = MakeCorePlugin.getUniqueIdentifier();
-
- static final String BUILD_COMMAND = PREFIX + ".buildCommand"; //$NON-NLS-1$
- static final String BUILD_LOCATION = PREFIX + ".buildLocation"; //$NON-NLS-1$
- static final String STOP_ON_ERROR = PREFIX + ".stopOnError"; //$NON-NLS-1$
- static final String USE_DEFAULT_BUILD_CMD = PREFIX + ".useDefaultBuildCmd"; //$NON-NLS-1$
- static final String BUILD_TARGET_AUTO = PREFIX + ".autoBuildTarget"; //$NON-NLS-1$
- static final String BUILD_TARGET_INCREMENTAL = PREFIX + ".incrementalBuildTarget"; //$NON-NLS-1$
- static final String BUILD_TARGET_FULL = PREFIX + ".fullBuildTarget"; //$NON-NLS-1$
- static final String BUILD_TARGET_CLEAN = PREFIX + ".cleanBuildTarget"; //$NON-NLS-1$
- static final String BUILD_FULL_ENABLED = PREFIX + ".enableFullBuild"; //$NON-NLS-1$
- static final String BUILD_CLEAN_ENABLED = PREFIX + ".enableCleanBuild"; //$NON-NLS-1$
- static final String BUILD_INCREMENTAL_ENABLED = PREFIX + ".enabledIncrementalBuild"; //$NON-NLS-1$
- static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild"; //$NON-NLS-1$
- static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments"; //$NON-NLS-1$
- static final String ENVIRONMENT = PREFIX + ".environment"; //$NON-NLS-1$
- static final String BUILD_APPEND_ENVIRONMENT = PREFIX + ".append_environment"; //$NON-NLS-1$
-
- private abstract static class AbstractBuildInfo implements IMakeBuilderInfo {
-
- public void setUseDefaultBuildCmd(boolean on) throws CoreException {
- putString(USE_DEFAULT_BUILD_CMD, new Boolean(on).toString());
- }
-
- public boolean isDefaultBuildCmd() {
- if (getString(USE_DEFAULT_BUILD_CMD) == null) { // if no property
- // then default to
- // true
- return true;
- }
- return getBoolean(USE_DEFAULT_BUILD_CMD);
- }
-
- public String getBuildAttribute(String name, String defaultValue) {
- String value = getString(name);
- if (value == null ) {
- if (IMakeCommonBuildInfo.BUILD_COMMAND.equals(name)) {
- value = getString(BuildInfoFactory.BUILD_COMMAND);
- } else if (IMakeCommonBuildInfo.BUILD_ARGUMENTS.equals(name)) {
- value = getString(BuildInfoFactory.BUILD_ARGUMENTS);
- } else if (IMakeCommonBuildInfo.BUILD_LOCATION.equals(name)) {
- value = getString(BuildInfoFactory.BUILD_LOCATION);
- } else if (IMakeBuilderInfo.BUILD_TARGET_AUTO.equals(name)) {
- value = getString(BuildInfoFactory.BUILD_TARGET_AUTO);
- } else if (IMakeBuilderInfo.BUILD_TARGET_CLEAN.equals(name)) {
- value = getString(BuildInfoFactory.BUILD_TARGET_CLEAN);
- } else if (IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL.equals(name)) {
- value = getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL);
- }
- }
- return value != null ? value : defaultValue != null ? defaultValue : ""; //$NON-NLS-1$
- }
-
- public void setBuildAttribute(String name, String value) throws CoreException {
- putString(name, value);
- }
-
- public Map getExpandedEnvironment() {
- Map env = getEnvironment();
- HashMap envMap = new HashMap(env.entrySet().size());
- Iterator iter = env.entrySet().iterator();
- boolean win32 = Platform.getOS().equals(Constants.OS_WIN32);
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- String key = (String)entry.getKey();
- if (win32) {
- // Win32 vars are case insensitive. Uppercase everything so
- // that (for example) "pAtH" will correctly replace "PATH"
- key = key.toUpperCase();
- }
- String value = (String)entry.getValue();
- // translate any string substitution variables
- String translated = value;
- try {
- translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value, false);
- } catch (CoreException e) {
- }
- envMap.put(key, translated);
- }
- return envMap;
- }
-
- public void setBuildCommand(IPath location) throws CoreException {
- putString(IMakeCommonBuildInfo.BUILD_COMMAND, null);
- putString(BuildInfoFactory.BUILD_COMMAND, location.toString());
- }
-
- public IPath getBuildCommand() {
- if (isDefaultBuildCmd()) {
- String command = getBuildParameter("defaultCommand"); //$NON-NLS-1$
- if (command == null) {
- return new Path("make"); //$NON-NLS-1$
- }
- return new Path(command);
- }
- String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, getString(BuildInfoFactory.BUILD_COMMAND));
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return new Path(result);
- }
-
- protected String getBuildParameter(String name) {
- IExtension extension = Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES,
- ResourcesPlugin.PT_BUILDERS, getBuilderID());
- if (extension == null)
- return null;
- IConfigurationElement[] configs = extension.getConfigurationElements();
- if (configs.length == 0)
- return null;
- // The nature exists, or this builder doesn't specify a nature
- IConfigurationElement[] runElement = configs[0].getChildren("run"); //$NON-NLS-1$
- IConfigurationElement[] paramElement = runElement[0].getChildren("parameter"); //$NON-NLS-1$
- for (int i = 0; i < paramElement.length; i++) {
- if (paramElement[i].getAttribute("name").equals(name)) { //$NON-NLS-1$
- return paramElement[i].getAttribute("value"); //$NON-NLS-1$
- }
- }
- return null;
- }
-
- protected abstract String getBuilderID();
-
- public void setBuildLocation(IPath location) throws CoreException {
- putString(IMakeCommonBuildInfo.BUILD_LOCATION, null);
- putString(BuildInfoFactory.BUILD_LOCATION, location.toString());
- }
-
- public IPath getBuildLocation() {
- String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, getString(BuildInfoFactory.BUILD_LOCATION));
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return new Path(result);
- }
-
- public String getBuildArguments() {
- String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, getString(BuildInfoFactory.BUILD_ARGUMENTS));
- if (result == null) {
- return ""; //$NON-NLS-1$
- }
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return result;
- }
-
- public void setBuildArguments(String args) throws CoreException {
- putString(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null);
- putString(BuildInfoFactory.BUILD_ARGUMENTS, args);
- }
-
- public void setStopOnError(boolean enabled) throws CoreException {
- putString(STOP_ON_ERROR, new Boolean(enabled).toString());
- }
-
- public boolean isStopOnError() {
- return getBoolean(STOP_ON_ERROR);
- }
-
- public void setAutoBuildTarget(String target) throws CoreException {
- putString(IMakeBuilderInfo.BUILD_TARGET_AUTO, null);
- putString(BuildInfoFactory.BUILD_TARGET_AUTO, target);
- }
-
- public String getAutoBuildTarget() {
- String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, getString(BuildInfoFactory.BUILD_TARGET_AUTO));
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return result;
- }
-
- public void setIncrementalBuildTarget(String target) throws CoreException {
- putString(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, null);
- putString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL, target);
- }
-
- public String getIncrementalBuildTarget() {
- String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL,
- getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL));
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return result;
- }
-
- public void setFullBuildTarget(String target) throws CoreException {
-
- }
-
- public String getFullBuildTarget() {
- String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL));
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return result;
- }
-
- public void setCleanBuildTarget(String target) throws CoreException {
- putString(IMakeBuilderInfo.BUILD_TARGET_CLEAN, null);
- putString(BuildInfoFactory.BUILD_TARGET_CLEAN, target);
- }
-
- public String getCleanBuildTarget() {
- String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, getString(BuildInfoFactory.BUILD_TARGET_CLEAN));
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return result;
- }
-
- public void setAutoBuildEnable(boolean enabled) throws CoreException {
- putString(BUILD_AUTO_ENABLED, new Boolean(enabled).toString());
- }
-
- public boolean isAutoBuildEnable() {
- return getBoolean(BUILD_AUTO_ENABLED);
- }
-
- public void setIncrementalBuildEnable(boolean enabled) throws CoreException {
- putString(BUILD_INCREMENTAL_ENABLED, new Boolean(enabled).toString());
- }
-
- public boolean isIncrementalBuildEnabled() {
- return getBoolean(BUILD_INCREMENTAL_ENABLED);
- }
-
- public void setFullBuildEnable(boolean enabled) throws CoreException {
- putString(BUILD_FULL_ENABLED, new Boolean(enabled).toString());
- }
-
- public boolean isFullBuildEnabled() {
- return getBoolean(BUILD_FULL_ENABLED);
- }
-
- public void setCleanBuildEnable(boolean enabled) throws CoreException {
- putString(BUILD_CLEAN_ENABLED, new Boolean(enabled).toString());
- }
-
- public boolean isCleanBuildEnabled() {
- return getBoolean(BUILD_CLEAN_ENABLED);
- }
-
- public String[] getErrorParsers() {
- String parsers = getString(ErrorParserManager.PREF_ERROR_PARSER);
- if (parsers != null && parsers.length() > 0) {
- StringTokenizer tok = new StringTokenizer(parsers, ";"); //$NON-NLS-1$
- List list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- return (String[])list.toArray(new String[list.size()]);
- }
- return new String[0];
- }
-
- public void setErrorParsers(String[] parsers) throws CoreException {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < parsers.length; i++) {
- buf.append(parsers[i]).append(';');
- }
- putString(ErrorParserManager.PREF_ERROR_PARSER, buf.toString());
- }
-
- public Map getEnvironment() {
- return decodeMap(getString(ENVIRONMENT));
- }
-
- public void setEnvironment(Map env) throws CoreException {
- putString(ENVIRONMENT, encodeMap(env));
- }
-
- public boolean appendEnvironment() {
- if (getString(BUILD_APPEND_ENVIRONMENT) != null) {
- return getBoolean(BUILD_APPEND_ENVIRONMENT);
- }
- return true;
- }
-
- public void setAppendEnvironment(boolean append) throws CoreException {
- putString(BUILD_APPEND_ENVIRONMENT, new Boolean(append).toString());
- }
-
- public boolean getBoolean(String property) {
- return Boolean.valueOf(getString(property)).booleanValue();
- }
-
- protected Map decodeMap(String value) {
- Map map = new HashMap();
- if (value != null) {
- StringBuffer envStr = new StringBuffer(value);
- String escapeChars = "|\\"; //$NON-NLS-1$
- char escapeChar = '\\';
- try {
- while (envStr.length() > 0) {
- int ndx = 0;
- while (ndx < envStr.length()) {
- if (escapeChars.indexOf(envStr.charAt(ndx)) != -1) {
- if (envStr.charAt(ndx - 1) == escapeChar) {
- // escaped '|' - remove '\' and continue on.
- envStr.deleteCharAt(ndx - 1);
- if (ndx == envStr.length()) {
- break;
- }
- }
- if (envStr.charAt(ndx) == '|')
- break;
- }
- ndx++;
- }
- StringBuffer line = new StringBuffer(envStr.substring(0, ndx));
- int lndx = 0;
- while (lndx < line.length()) {
- if (line.charAt(lndx) == '=') {
- if (line.charAt(lndx - 1) == escapeChar) {
- // escaped '=' - remove '\' and continue on.
- line.deleteCharAt(lndx - 1);
- } else {
- break;
- }
- }
- lndx++;
- }
- map.put(line.substring(0, lndx), line.substring(lndx + 1));
- envStr.delete(0, ndx + 1);
- }
- } catch (StringIndexOutOfBoundsException e) {
- }
- }
- return map;
- }
-
- protected String encodeMap(Map values) {
- StringBuffer str = new StringBuffer();
- Iterator entries = values.entrySet().iterator();
- while (entries.hasNext()) {
- Entry entry = (Entry)entries.next();
- str.append(escapeChars((String)entry.getKey(), "=|\\", '\\')); //$NON-NLS-1$
- str.append("="); //$NON-NLS-1$
- str.append(escapeChars((String)entry.getValue(), "|\\", '\\')); //$NON-NLS-1$
- str.append("|"); //$NON-NLS-1$
- }
- return str.toString();
- }
-
- protected String escapeChars(String string, String escapeChars, char escapeChar) {
- StringBuffer str = new StringBuffer(string);
- for (int i = 0; i < str.length(); i++) {
- if (escapeChars.indexOf(str.charAt(i)) != -1) {
- str.insert(i, escapeChar);
- i++;
- }
- }
- return str.toString();
- }
-
- protected abstract void putString(String name, String value) throws CoreException;
- protected abstract String getString(String property);
- }
-
- private static class BuildInfoPreference extends AbstractBuildInfo {
-
- private Preferences prefs;
- private String builderID;
- private boolean useDefaults;
-
- BuildInfoPreference(Preferences prefs, String builderID, boolean useDefaults) {
- this.prefs = prefs;
- this.builderID = builderID;
- this.useDefaults = useDefaults;
- }
-
- protected void putString(String name, String value) {
- if (useDefaults) {
- if (value != null) {
- prefs.setDefault(name, value);
- }
- } else {
- if (value == null) {
- prefs.setValue(name, prefs.getDefaultString(name));
- return;
- }
- prefs.setValue(name, value);
- }
- }
-
- protected String getString(String property) {
- if (!prefs.contains(property)) {
- return null;
- }
- if (useDefaults) {
- return prefs.getDefaultString(property);
- }
- return prefs.getString(property);
- }
-
- protected String getBuilderID() {
- return builderID;
- }
- }
-
- private static class BuildInfoProject extends AbstractBuildInfo {
-
- private IProject project;
- private String builderID;
- private Map args;
-
- BuildInfoProject(IProject project, String builderID) throws CoreException {
- this.project = project;
- this.builderID = builderID;
- ICommand builder;
- builder = MakeProjectNature.getBuildSpec(project.getDescription(), builderID);
- if (builder == null) {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("BuildInfoFactory.Missing_Builder") + builderID, null)); //$NON-NLS-1$
- }
- args = builder.getArguments();
- }
-
- protected void putString(String name, String value) throws CoreException {
- String curValue = (String)args.get(name);
- if (curValue != null && curValue.equals(value)) {
- return;
- }
- if (value == null) {
- args.remove(name);
- } else {
- args.put(name, value);
- }
- IProjectDescription description = project.getDescription();
- ICommand builder = MakeProjectNature.getBuildSpec(description, builderID);
- builder.setArguments(args);
- builder.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, isAutoBuildEnable());
- builder.setBuilding(IncrementalProjectBuilder.FULL_BUILD, isFullBuildEnabled());
- builder.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, isIncrementalBuildEnabled());
- builder.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, isCleanBuildEnabled());
- MakeProjectNature.setBuildSpec(description, builder);
- project.setDescription(description, null);
- }
-
- protected String getString(String name) {
- return (String)args.get(name);
- }
-
- protected String getBuilderID() {
- return builderID;
- }
- }
-
- private static class BuildInfoMap extends AbstractBuildInfo {
-
- private Map args;
- private String builderID;
-
- BuildInfoMap(Map args, String builderID) {
- this.args = args;
- this.builderID = builderID;
- }
-
- protected void putString(String name, String value) {
- if (value == null) {
- args.remove(name);
- } else {
- args.put(name, value);
- }
- }
-
- protected String getString(String name) {
- return (String)args.get(name);
- }
-
- protected String getBuilderID() {
- return builderID;
- }
- }
-
- public static IMakeBuilderInfo create(Preferences prefs, String builderID, boolean useDefaults) {
- return new BuildInfoFactory.BuildInfoPreference(prefs, builderID, useDefaults);
- }
-
- public static IMakeBuilderInfo create(IProject project, String builderID) throws CoreException {
- return new BuildInfoFactory.BuildInfoProject(project, builderID);
- }
-
- public static IMakeBuilderInfo create(Map args, String builderID) {
- return new BuildInfoFactory.BuildInfoMap(args, builderID);
- }
-}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
index 689478e3ecc..04361a0ebc8 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -11,14 +11,15 @@
*******************************************************************************/
package org.eclipse.cdt.make.internal.core;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
-import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.make.core.IMakeTarget;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Builder;
+import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
@@ -29,38 +30,154 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.osgi.service.environment.Constants;
public class MakeTarget extends PlatformObject implements IMakeTarget {
- private final static int USE_PROJECT_ENV_SETTING = 3;
+// private final static int USE_PROJECT_ENV_SETTING = 3;
private final MakeTargetManager manager;
private final IProject project;
+// private final IConfiguration configuration;
+ private IBuilder builder;
+
private String name;
- private boolean isDefaultBuildCmd;
- private boolean isStopOnError;
- boolean runAllBuidlers = true;
+// private boolean isDefaultBuildCmd;
+// private boolean isStopOnError;
+ private boolean runAllBuidlers = true;
private String targetBuilderID;
private IContainer container;
- private int appendEnvironment = USE_PROJECT_ENV_SETTING;
- private boolean appendProjectEnvironment = true;
- private Map buildEnvironment = new HashMap();
- private Map targetAttributes = new HashMap();
+// private int appendEnvironment = USE_PROJECT_ENV_SETTING;
+// private boolean appendProjectEnvironment = true;
+// private Map buildEnvironment = new HashMap();
+// private Map targetAttributes = new HashMap();
+
+ private static final String TARGET_ATTR_ID = "targetID"; //$NON-NLS-1$
+ private static final String TARGET_ATTR_PATH = "path"; //$NON-NLS-1$
+ private static final String TARGET_ATTR_NAME = "name"; //$NON-NLS-1$
+ private static final String TARGET_STOP_ON_ERROR = "stopOnError"; //$NON-NLS-1$
+ private static final String TARGET_USE_DEFAULT_CMD = "useDefaultCommand"; //$NON-NLS-1$
+ private static final String TARGET_ARGUMENTS = "buildArguments"; //$NON-NLS-1$
+ private static final String TARGET_COMMAND = "buildCommand"; //$NON-NLS-1$
+ private static final String BAD_TARGET = "buidlTarget"; //$NON-NLS-1$
+ private static final String TARGET = "buildTarget"; //$NON-NLS-1$
+
+ MakeTarget(MakeTarget target, IConfiguration cfg) {
+ manager = target.manager;
+ project = target.project;
+
+ builder = ManagedBuildManager.createCustomBuilder(cfg, target.builder);
+
+ name = target.name;
+ runAllBuidlers = target.runAllBuidlers;
+ targetBuilderID = target.targetBuilderID;
+ container = target.container;
+ }
+
+ MakeTarget(MakeTargetManager manager, IConfiguration cfg, ICStorageElement el) throws CoreException {
+ this.manager = manager;
+ this.project = cfg.getOwner().getProject();
+ ICStorageElement children[] = el.getChildren();
+ IBuilder builder = null;
+
+ String path = el.getAttribute(TARGET_ATTR_PATH);
+ if (path != null && !path.equals("")) { //$NON-NLS-1$
+ container = project.getFolder(path);
+ } else {
+ container = project;
+ }
+
+
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ if(IBuilder.BUILDER_ELEMENT_NAME.equals(child.getName())){
+ builder = new Builder(cfg.getToolChain(), child, null);
+ }
+ }
+
+ if(builder == null){
+ builder = ManagedBuildManager.createCustomBuilder(cfg, cfg.getBuilder());
+ }
+
+ this.builder = builder;
+
+ targetBuilderID = el.getAttribute(TARGET_ATTR_ID);
+ name = el.getAttribute(TARGET_ATTR_NAME);
+
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ String name = child.getName();
+ if(TARGET_STOP_ON_ERROR.equals(name)){
+ String value = child.getValue();
+ if(value != null){
+ builder.setStopOnError(Boolean.valueOf(value).booleanValue());
+ }
+ } else if (TARGET_USE_DEFAULT_CMD.equals(name)){
+ String value = child.getValue();
+ if(value != null){
+ builder.setUseDefaultBuildCmd(Boolean.valueOf(value).booleanValue());
+ }
+ } else if (TARGET_COMMAND.equals(name)){
+ String value = child.getValue();
+ if(value != null){
+ builder.setCommand(value);
+ }
+ } else if (TARGET_ARGUMENTS.equals(name)){
+ String value = child.getValue();
+ if(value != null){
+ builder.setArguments(value);
+ }
+ } else if (BAD_TARGET.equals(name)){
+ String value = child.getValue();
+ if(value != null){
+ builder.setBuildAttribute(IMakeTarget.BUILD_TARGET, value);
+ }
+ } else if (TARGET.equals(name)){
+ String value = child.getValue();
+ if(value != null){
+ builder.setBuildAttribute(IMakeTarget.BUILD_TARGET, value);
+ }
+ }
+ }
+ }
+
+ void serialize(ICStorageElement el){
+
+ if(container != null){
+ el.setAttribute(TARGET_ATTR_PATH, container.getProjectRelativePath().toString());
+ }
+
+ if(targetBuilderID != null)
+ el.setAttribute(TARGET_ATTR_ID, targetBuilderID);
+
+ if(name != null)
+ el.setAttribute(TARGET_ATTR_NAME, name);
- MakeTarget(MakeTargetManager manager, IProject project, String targetBuilderID, String name) throws CoreException {
+ ICStorageElement builderEl = el.createChild(IBuilder.BUILDER_ELEMENT_NAME);
+ ((Builder)builder).serialize(builderEl, false);
+ }
+
+ MakeTarget(MakeTargetManager manager, IConfiguration cfg, String builderId, String targetBuilderID, String name) throws CoreException {
this.manager = manager;
- this.project = project;
+// this.configuration = cfg;
+ this.project = cfg.getOwner().getProject();
this.targetBuilderID = targetBuilderID;
this.name = name;
- IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(project, manager.getBuilderID(targetBuilderID));
- setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
- setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
- isDefaultBuildCmd = info.isDefaultBuildCmd();
- isStopOnError = info.isStopOnError();
+
+ if(builderId != null){
+ builder = ManagedBuildManager.createCustomBuilder(cfg, builderId);
+ } /*else if (targetBuilderID != null){
+ builder = ManagedBuildManager.createBuilderForEclipseBuilder(cfg, manager.getBuilderID(targetBuilderID));
+ } */else {
+ builder = ManagedBuildManager.createCustomBuilder(cfg, cfg.getBuilder());
+ }
+
+// IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(project, manager.getBuilderID(targetBuilderID));
+// setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
+// setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
+// isDefaultBuildCmd = info.isDefaultBuildCmd();
+// isStopOnError = info.isStopOnError();
+ manager.updateTarget(this);
+
}
public IProject getProject() {
@@ -75,9 +192,9 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
this.name = name;
}
- Map getAttributeMap() {
- return targetAttributes;
- }
+// Map getAttributeMap() {
+// return targetAttributes;
+// }
public String getName() {
return name;
@@ -88,25 +205,26 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
public boolean isStopOnError() {
- return isStopOnError;
+ return builder.isStopOnError();
}
public void setStopOnError(boolean stopOnError) throws CoreException {
- isStopOnError = stopOnError;
+ builder.setStopOnError(stopOnError);
manager.updateTarget(this);
}
public boolean isDefaultBuildCmd() {
- return isDefaultBuildCmd;
+ return builder.isDefaultBuildCmd();
}
public void setUseDefaultBuildCmd(boolean useDefault) throws CoreException {
- isDefaultBuildCmd = useDefault;
+ builder.setUseDefaultBuildCmd(useDefault);
manager.updateTarget(this);
}
public IPath getBuildCommand() {
- if (isDefaultBuildCmd()) {
+ return builder.getBuildCommand();
+/* if (isDefaultBuildCmd()) {
IMakeBuilderInfo info;
try {
info = MakeCorePlugin.createBuildInfo(getProject(), manager.getBuilderID(targetBuilderID));
@@ -120,36 +238,43 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
} catch (CoreException e) {
}
return new Path(result);
+*/
}
public void setBuildCommand(IPath command) throws CoreException {
- setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, command.toString());
+ builder.setBuildCommand(command);
+// setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, command.toString());
}
public String getBuildArguments() {
- String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, ""); //$NON-NLS-1$
- try {
- result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
- } catch (CoreException e) {
- }
- return result;
+ return builder.getBuildArguments();
+// String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, ""); //$NON-NLS-1$
+// try {
+// result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+// } catch (CoreException e) {
+// }
+// return result;
}
public void setBuildArguments(String arguments) throws CoreException {
- setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, arguments);
+ builder.setBuildArguments(arguments);
+// setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, arguments);
}
public void setBuildTarget(String target) throws CoreException {
- setBuildAttribute(IMakeTarget.BUILD_TARGET, target);
+// setBuildAttribute(IMakeTarget.BUILD_TARGET, target);
+ builder.setIncrementalBuildTarget(target);
}
public String getBuildTarget() {
- String result = getBuildAttribute(IMakeTarget.BUILD_TARGET, ""); //$NON-NLS-1$
+/* String result = getBuildAttribute(IMakeTarget.BUILD_TARGET, ""); //$NON-NLS-1$
try {
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
} catch (CoreException e) {
}
return result;
+*/
+ return builder.getIncrementalBuildTarget();
}
public void setRunAllBuilders(boolean runAllBuilders) throws CoreException {
@@ -162,13 +287,23 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
public void setBuildAttribute(String name, String value) throws CoreException {
- targetAttributes.put(name, value);
+ if(BUILD_TARGET.equals(name))
+ setBuildTarget(value);
+ else
+ builder.setBuildAttribute(name, value);
manager.updateTarget(this);
}
public String getBuildAttribute(String name, String defaultValue) {
- String value = (String)targetAttributes.get(name);
- return value != null ? value : defaultValue;
+ String value = null;
+ if(BUILD_TARGET.equals(name)){
+ value = getBuildTarget();
+ } else {
+ value = builder.getBuildAttribute(name, defaultValue);
+ }
+ if(value == null)
+ value = defaultValue;
+ return value;
}
public IPath getBuildLocation() {
@@ -180,21 +315,16 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
public String[] getErrorParsers() {
- IMakeBuilderInfo projectInfo;
- try {
- projectInfo = MakeCorePlugin.createBuildInfo(getProject(), manager.getBuilderID(targetBuilderID));
- return projectInfo.getErrorParsers();
- } catch (CoreException e) {
- }
- return new String[0];
+ return builder.getErrorParsers();
}
public void setErrorParsers(String[] parsers) throws CoreException {
- throw new UnsupportedOperationException();
+ builder.setErrorParsers(parsers);
}
public Map getExpandedEnvironment() throws CoreException {
- Map env = null;
+ return builder.getExpandedEnvironment();
+/* Map env = null;
if (appendProjectEnvironment()) {
IMakeBuilderInfo projectInfo;
projectInfo = MakeCorePlugin.createBuildInfo(getProject(), manager.getBuilderID(targetBuilderID));
@@ -223,35 +353,44 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
envMap.put(key, translated);
}
return envMap;
+*/
}
public boolean appendProjectEnvironment() {
- return appendProjectEnvironment;
+ return builder.appendEnvironment();
+// return appendProjectEnvironment;
}
public void setAppendProjectEnvironment(boolean append) {
- appendProjectEnvironment = append;
+ try {
+ builder.setAppendEnvironment(append);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+// appendProjectEnvironment = append;
}
public Map getEnvironment() {
- return buildEnvironment;
+ return builder.getEnvironment();
}
public void setEnvironment(Map env) throws CoreException {
- buildEnvironment = new HashMap(env);
+ builder.setEnvironment(env);
manager.updateTarget(this);
}
- public void setAppendEnvironment(boolean append) throws CoreException {
- appendEnvironment = append ? 1 : 0;
+ public void setAppendEnvironment(boolean append) throws CoreException {
+ builder.setAppendEnvironment(append);
+// appendEnvironment = append ? 1 : 0;
manager.updateTarget(this);
}
public boolean appendEnvironment() {
- return appendEnvironment == USE_PROJECT_ENV_SETTING ? getProjectEnvSetting(): appendEnvironment == 1;
+ return builder.appendEnvironment();
+// return appendEnvironment == USE_PROJECT_ENV_SETTING ? getProjectEnvSetting(): appendEnvironment == 1;
}
- private boolean getProjectEnvSetting() {
+/* private boolean getProjectEnvSetting() {
IMakeBuilderInfo projectInfo;
try {
projectInfo = MakeCorePlugin.createBuildInfo(getProject(), manager.getBuilderID(targetBuilderID));
@@ -260,6 +399,7 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
return false;
}
+*/
public IContainer getContainer() {
return container;
@@ -278,10 +418,33 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
public int hashCode() {
return container.hashCode() * 17 + name != null ? name.hashCode(): 0;
}
-
+
+ public IConfiguration getConfiguration(){
+ return builder.getParent().getParent();
+ }
+/* public IConfiguration getConfiguration() throws CoreException{
+ IConfiguration builderCfg = builder.getParent().getParent();
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration cfg = info.getManagedProject().getConfiguration(builderCfg.getId());
+ if(cfg == null){
+ cfg = info.getDefaultConfiguration();
+ }
+
+ if(cfg != null){
+ if(builderCfg != cfg){
+ ((Builder)builder).setParent(cfg.getToolChain());
+ }
+ return cfg;
+ }
+ throw new CoreException(new Status(
+ IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "builder configuration was removed"));
+ }
+*/
public void build(IProgressMonitor monitor) throws CoreException {
final String builderID = manager.getBuilderID(targetBuilderID);
- final HashMap infoMap = new HashMap();
+/* final HashMap infoMap = new HashMap();
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(infoMap, builderID);
info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
@@ -297,6 +460,14 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(getProject(), builderID);
info.setErrorParsers(projectInfo.getErrorParsers());
+*/
+
+
+ IConfiguration cfg = builder.getParent().getParent();
+ final Map infoMap = BuilderFactory.createBuildArgs(
+ new IConfiguration[]{cfg},
+ builder);
+
IWorkspaceRunnable op = new IWorkspaceRunnable() {
/*
@@ -337,4 +508,46 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
return super.getAdapter(adapter);
}
+
+ public boolean isManagedBuildOn() {
+ return builder.isManagedBuildOn();
+ }
+
+ public void setManagedBuildOn(boolean on) throws CoreException {
+ builder.setManagedBuildOn(on);
+ }
+
+ public boolean supportsBuild(boolean managed) {
+ return builder.supportsBuild(managed);
+ }
+
+ public void setConfiguration(IConfiguration cfg){
+ if(getConfiguration() == cfg)
+ return;
+ builder = ManagedBuildManager.createCustomBuilder(cfg, builder);
+ }
+
+ public int getParallelizationNum() {
+ return builder.getParallelizationNum();
+ }
+
+ public void setParallelizationNum(int num) throws CoreException {
+ builder.setParallelizationNum(num);
+ }
+
+ public boolean supportsParallelBuild() {
+ return builder.supportsParallelBuild();
+ }
+
+ public boolean supportsStopOnError(boolean on) {
+ return builder.supportsStopOnError(on);
+ }
+
+ public boolean isParallelBuildOn() {
+ return builder.isParallelBuildOn();
+ }
+
+ public void setParallelBuildOn(boolean on) throws CoreException {
+ builder.setParallelBuildOn(on);
+ }
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java
index 1ed60d2f148..74741cba978 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -17,11 +17,18 @@ import java.util.Map;
import java.util.Vector;
import java.util.Map.Entry;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetListener;
import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeTargetEvent;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
@@ -40,6 +47,7 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
public class MakeTargetManager implements IMakeTargetManager, IResourceChangeListener {
@@ -48,15 +56,23 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
private static String TARGETS_EXT = "targets"; //$NON-NLS-1$
private ListenerList listeners = new ListenerList();
- Map projectMap = new HashMap();
+// Map projectMap = new HashMap();
private HashMap builderMap;
protected Vector fProjects = new Vector();
+ private final static QualifiedName projectTargetsQualifiedName = new QualifiedName(
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "targetMapQualifiedName"); //$NON-NLS-1$
public MakeTargetManager() {
}
public IMakeTarget createTarget(IProject project, String name, String targetBuilderID) throws CoreException {
- return new MakeTarget(this, project, targetBuilderID, name);
+ IConfiguration cfg = getConfiguration(project);
+ return createTarget(cfg, null, targetBuilderID, name);
+ }
+
+ public IMakeTarget createTarget(IConfiguration cfg, String builderId, String targetBuilderID, String name) throws CoreException {
+ return new MakeTarget(this, cfg, builderId, targetBuilderID, name);
}
public void addTarget(IMakeTarget target) throws CoreException {
@@ -65,12 +81,17 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
public void addTarget(IContainer container, IMakeTarget target) throws CoreException {
if (container instanceof IWorkspaceRoot) {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$
- }
- ProjectTargets projectTargets = (ProjectTargets)projectMap.get(target.getProject());
- if (projectTargets == null) {
- projectTargets = readTargets(target.getProject());
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$
}
+
+// ICConfigurationDescription cfgDescription = getDescription(target);
+// if(cfgDescription == null){
+// throw new CoreException(new Status(IStatus.ERROR,
+// ManagedBuilderCorePlugin.getUniqueIdentifier(),
+// "target refers inexistent configuration"));
+// }
+
+ ProjectTargets projectTargets = getProjectTargets(target);
((MakeTarget) target).setContainer(container == null ? target.getProject() : container);
projectTargets.add((MakeTarget) target);
try {
@@ -82,19 +103,67 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
notifyListeners(new MakeTargetEvent(this, MakeTargetEvent.TARGET_ADD, target));
}
+ private ProjectTargets getProjectTargets(IMakeTarget target) throws CoreException{
+ return getProjectTargets(target, true);
+ }
+
+ private ProjectTargets getProjectTargets(IMakeTarget target, boolean load) throws CoreException{
+ return getProjectTargets(target.getConfiguration(), load);
+ }
+
+ private ProjectTargets getProjectTargets(IConfiguration cfg) throws CoreException{
+ return getProjectTargets(cfg, true);
+ }
+
+ private ProjectTargets getProjectTargets(IConfiguration cfg, boolean load) throws CoreException{
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ if(cfgDes == null){
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "target refers inexistent configuration"));
+ }
+
+ ICProjectDescription des = cfgDes.getProjectDescription();
+
+ ProjectTargets targets = (ProjectTargets)des.getSessionProperty(projectTargetsQualifiedName);//getLoaddedProjectTargets(des);
+ if(targets == null || targets.getProjectDescription() != des){
+ if(load){
+ if(targets == null)
+ targets = readTargets(cfg);
+ else
+ targets = new ProjectTargets(targets, des, cfg);
+ des.setSessionProperty(projectTargetsQualifiedName, targets);
+ } else {
+ targets = null;
+ }
+ }
+ return targets;
+ }
+
+// private ProjectTargets getLoaddedProjectTargets(ICConfigurationDescription des){
+// return (ProjectTargets)des.getSessionProperty(projectTargetsQualifiedName);
+// }
+
+// private void setLoaddedProjectTargets(ICConfigurationDescription des, ProjectTargets targets){
+// des.setSessionProperty(projectTargetsQualifiedName, targets);
+// }
+
public boolean targetExists(IMakeTarget target) {
- ProjectTargets projectTargets = (ProjectTargets)projectMap.get(target.getProject());
- if (projectTargets == null) {
- projectTargets = readTargets(target.getProject());
+ try {
+ ProjectTargets projectTargets = getProjectTargets(target);
+ return projectTargets.contains((MakeTarget) target);
+ } catch (CoreException e) {
}
- return projectTargets.contains((MakeTarget) target);
+ return false;
}
+// private ICConfigurationDescription getDescription(IMakeTarget target){
+// IConfiguration cfg = target.getConfiguration();
+// return ManagedBuildManager.getDescriptionForConfiguration(cfg);
+// }
+
public void removeTarget(IMakeTarget target) throws CoreException {
- ProjectTargets projectTargets = (ProjectTargets)projectMap.get(target.getProject());
- if (projectTargets == null) {
- projectTargets = readTargets(target.getProject());
- }
+ ProjectTargets projectTargets = getProjectTargets(target);
if (projectTargets.remove((MakeTarget) target)) {
try {
writeTargets(projectTargets);
@@ -107,10 +176,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
}
public void renameTarget(IMakeTarget target, String name) throws CoreException {
- ProjectTargets projectTargets = (ProjectTargets)projectMap.get(target.getProject());
- if (projectTargets == null) {
- projectTargets = readTargets(target.getProject());
- }
+ ProjectTargets projectTargets = getProjectTargets(target);
if (!projectTargets.contains((MakeTarget)target)) {
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("MakeTargetManager.target_exists"), null)); //$NON-NLS-1$
}
@@ -119,19 +185,42 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
}
public IMakeTarget[] getTargets(IContainer container) throws CoreException {
- ProjectTargets projectTargets = (ProjectTargets)projectMap.get(container.getProject());
- if (projectTargets == null) {
- projectTargets = readTargets(container.getProject());
+ IConfiguration cfg = getConfiguration(container);
+ return getTargets(cfg, container);
+ }
+
+ private IConfiguration getConfiguration(IResource rc){
+ IProject project = rc.getProject();
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ return info.getDefaultConfiguration();
+ }
+
+ public IMakeTarget[] getTargets(IConfiguration cfg, IContainer container)
+ throws CoreException {
+ ProjectTargets targets = getProjectTargets(cfg);
+ return setConfiguration(cfg, targets.get(container));
+ }
+
+ private IMakeTarget[] setConfiguration(IConfiguration cfg, IMakeTarget targets[]){
+ for(int i = 0; i < targets.length; i++){
+ ((MakeTarget)targets[i]).setConfiguration(cfg);
}
- return projectTargets.get(container);
+ return targets;
}
public IMakeTarget findTarget(IContainer container, String name) throws CoreException {
- ProjectTargets projectTargets = (ProjectTargets)projectMap.get(container.getProject());
- if (projectTargets == null) {
- projectTargets = readTargets(container.getProject());
+ IConfiguration cfg = getConfiguration(container);
+ return findTarget(cfg, container, name);
+ }
+
+ public IMakeTarget findTarget(IConfiguration cfg, IContainer container,
+ String name) throws CoreException {
+ ProjectTargets targets = getProjectTargets(cfg);
+ IMakeTarget target = targets.findTarget(container, name);
+ if(target != null){
+ ((MakeTarget)target).setConfiguration(cfg);
}
- return projectTargets.findTarget(container, name);
+ return target;
}
public IProject[] getTargetBuilderProjects() {
@@ -230,7 +319,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
if (0 != (flags & IResourceDelta.DESCRIPTION)) {
if (fProjects.contains(project) && !hasTargetBuilder(project)) {
fProjects.remove(project);
- projectMap.remove(project);
+ // projectMap.remove(project);
notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project));
} else if (!fProjects.contains(project) && hasTargetBuilder(project)) {
fProjects.add(project);
@@ -240,7 +329,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
if (0 != (flags & IResourceDelta.OPEN)) {
if (!project.isOpen() && fProjects.contains(project)) {
fProjects.remove(project);
- projectMap.remove(project);
+// projectMap.remove(project);
notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project));
} else if (project.isOpen() && hasTargetBuilder(project) && !fProjects.contains(project)) {
fProjects.add(project);
@@ -256,7 +345,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
protected void updateTarget(MakeTarget target) throws CoreException {
if (target.getContainer() != null ) { // target has not been added to manager.
- ProjectTargets projectTargets = (ProjectTargets)projectMap.get(target.getProject());
+ ProjectTargets projectTargets = getProjectTargets(target, false);
if (projectTargets == null || !projectTargets.contains(target)) {
return; // target has not been added to manager.
}
@@ -267,28 +356,38 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
protected void writeTargets(ProjectTargets projectTargets) throws CoreException {
projectTargets.saveTargets();
+ CoreModel.getDefault().setProjectDescription(projectTargets.getProject(), projectTargets.getProjectDescription());
}
- protected ProjectTargets readTargets(IProject project) {
- ProjectTargets projectTargets = new ProjectTargets(this, project);
- projectMap.put(project, projectTargets);
+ protected ProjectTargets readTargets(IConfiguration cfg) throws CoreException {
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ if(cfgDes == null){
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "target refers inexistent configuration"));
+ }
+
+ ICProjectDescription des = cfgDes.getProjectDescription();
+
+ ProjectTargets projectTargets = new ProjectTargets(this, des, cfg);
+// projectMap.put(project, projectTargets);
return projectTargets;
}
protected void deleteTargets(IProject project) {
//Historical: We clean up after all other parts.
IPath targetFilePath =
- MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT);
+ ManagedBuilderCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT);
File targetFile = targetFilePath.toFile();
if (targetFile.exists()) {
targetFile.delete();
}
- projectMap.remove(project);
+// projectMap.remove(project);
}
protected void initializeBuilders() {
builderMap = new HashMap();
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.PLUGIN_ID, MakeTargetManager.TARGET_BUILD_EXT);
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.getUniqueIdentifier(), MakeTargetManager.TARGET_BUILD_EXT);
IExtension[] ext = point.getExtensions();
for (int i = 0; i < ext.length; i++) {
IConfigurationElement[] element = ext[i].getConfigurationElements();
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java
index bd8054d611e..f3a73b05308 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -14,7 +14,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -22,19 +21,16 @@ import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.util.XmlStorageElement;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -43,7 +39,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -54,49 +49,81 @@ public class ProjectTargets {
private static final String BUILD_TARGET_ELEMENT = "buildTargets"; //$NON-NLS-1$
private static final String TARGET_ELEMENT = "target"; //$NON-NLS-1$
- private static final String TARGET_ATTR_ID = "targetID"; //$NON-NLS-1$
- private static final String TARGET_ATTR_PATH = "path"; //$NON-NLS-1$
- private static final String TARGET_ATTR_NAME = "name"; //$NON-NLS-1$
- private static final String TARGET_STOP_ON_ERROR = "stopOnError"; //$NON-NLS-1$
- private static final String TARGET_USE_DEFAULT_CMD = "useDefaultCommand"; //$NON-NLS-1$
- private static final String TARGET_ARGUMENTS = "buildArguments"; //$NON-NLS-1$
- private static final String TARGET_COMMAND = "buildCommand"; //$NON-NLS-1$
- private static final String BAD_TARGET = "buidlTarget"; //$NON-NLS-1$
- private static final String TARGET = "buildTarget"; //$NON-NLS-1$
+
+ private static final String TARGETS_STORAGE_ID = "build.Targets"; //$NON-NLS-1$
private HashMap targetMap = new HashMap();
+// private IConfiguration configuraion;
+ private ICProjectDescription projDes;
+// private IProject project;
+
+ public ProjectTargets(ProjectTargets targets, ICProjectDescription des, IConfiguration cfg) {
+ projDes = des;
+ for(Iterator iter = targets.targetMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ IContainer cr = (IContainer)entry.getKey();
+ List list = (List)entry.getValue();
+
+ List targetsList = new ArrayList(list.size());
+ targetMap.put(cr, targetsList);
+ for(int i = 0; i < list.size(); i++){
+ MakeTarget target = (MakeTarget)list.get(i);
+ MakeTarget cloneTarget = new MakeTarget(target, cfg);
+ targetsList.add(cloneTarget);
+ }
+ }
+ }
- private IProject project;
-
- public ProjectTargets(MakeTargetManager manager, IProject project) {
+ public ProjectTargets(MakeTargetManager manager, ICProjectDescription projDes, IConfiguration cfg) {
boolean writeTargets = false;
File targetFile = null;
- this.project = project;
-
- Document document = translateCDTProjectToDocument();
+// this.project = project;
+ this.projDes = projDes;
+ IProject project = projDes.getProject();
+
+// ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ ICStorageElement el = null;
+
+ try {
+ ICStorageElement rootEl = getStorageElement(projDes, false);
+
+ if(rootEl != null){
+ ICStorageElement children[] = rootEl.getChildren();
+ for(int i = 0; i < children.length; i++){
+ if(BUILD_TARGET_ELEMENT.equals(children[i].getName())){
+ el = children[i];
+ break;
+ }
+ }
+ }
+ } catch (CoreException e1) {
+ }
+// Document document = translateCDTProjectToDocument();
//Historical ... fall back to the workspace and look in previous
// location
- if (document == null || !document.hasChildNodes()) {
- IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(
+ if (el == null) {
+ IPath targetFilePath = ManagedBuilderCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(
TARGETS_EXT);
targetFile = targetFilePath.toFile();
try {
InputStream input = new FileInputStream(targetFile);
- document = translateInputStreamToDocument(input);
+ Document document = translateInputStreamToDocument(input);
+ Element element = document.getDocumentElement();
+ el = new XmlStorageElement(element);
writeTargets = true; // update cdtproject
} catch (FileNotFoundException ex) {
/* Ignore */
}
}
- if (document != null) {
- extractMakeTargetsFromDocument(document, manager);
+ if (el != null) {
+ extractMakeTargetsFromDocument(el, manager, cfg);
if (writeTargets) {
try {
- Document doc = getAsXML();
- translateDocumentToCDTProject(doc);
+ saveTargets();
+// translateDocumentToCDTProject(doc);
} catch (Exception e) {
targetFile = null;
}
@@ -106,7 +133,11 @@ public class ProjectTargets {
}
}
}
-
+
+/* public IConfiguration getConfiguration(){
+ return configuraion;
+ }
+*/
protected String getString(Node target, String tagName) {
Node node = searchNode(target, tagName);
return node != null ? (node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue()) : null;
@@ -177,111 +208,39 @@ public class ProjectTargets {
}
public IProject getProject() {
- return project;
+ return projDes.getProject();
}
- protected Document getAsXML() throws CoreException {
- Document doc;
- try {
- doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- } catch (ParserConfigurationException ex) {
- //This should never happen.
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
- "Error creating new XML storage document", ex)); //$NON-NLS-1$
- }
- Element targetsRootElement = doc.createElement(BUILD_TARGET_ELEMENT);
- doc.appendChild(targetsRootElement);
+ protected void storeTargets(ICStorageElement element) throws CoreException {
Iterator container = targetMap.entrySet().iterator();
while (container.hasNext()) {
List targets = (List) ((Map.Entry) container.next()).getValue();
for (int i = 0; i < targets.size(); i++) {
MakeTarget target = (MakeTarget) targets.get(i);
- targetsRootElement.appendChild(createTargetElement(doc, target));
+ ICStorageElement child = element.createChild(TARGET_ELEMENT);
+ target.serialize(child);
}
}
- return doc;
- }
-
- private Node createTargetElement(Document doc, MakeTarget target) {
- Element targetElem = doc.createElement(TARGET_ELEMENT);
- targetElem.setAttribute(TARGET_ATTR_NAME, target.getName());
- targetElem.setAttribute(TARGET_ATTR_ID, target.getTargetBuilderID());
- targetElem.setAttribute(TARGET_ATTR_PATH, target.getContainer().getProjectRelativePath().toString());
- Element elem = doc.createElement(TARGET_COMMAND);
- targetElem.appendChild(elem);
- elem.appendChild(doc.createTextNode(target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make"))); //$NON-NLS-1$
-
- String targetAttr = target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null);
- if ( targetAttr != null) {
- elem = doc.createElement(TARGET_ARGUMENTS);
- elem.appendChild(doc.createTextNode(targetAttr));
- targetElem.appendChild(elem);
- }
-
- targetAttr = target.getBuildAttribute(IMakeTarget.BUILD_TARGET, null);
- if (targetAttr != null) {
- elem = doc.createElement(TARGET);
- elem.appendChild(doc.createTextNode(targetAttr));
- targetElem.appendChild(elem);
- }
-
- elem = doc.createElement(TARGET_STOP_ON_ERROR);
- elem.appendChild(doc.createTextNode(new Boolean(target.isStopOnError()).toString()));
- targetElem.appendChild(elem);
-
- elem = doc.createElement(TARGET_USE_DEFAULT_CMD);
- elem.appendChild(doc.createTextNode(new Boolean(target.isDefaultBuildCmd()).toString()));
- targetElem.appendChild(elem);
- return targetElem;
}
public void saveTargets() throws CoreException {
- Document doc = getAsXML();
- //Historical method would save the output to the stream specified
- //translateDocumentToOutputStream(doc, output);
- translateDocumentToCDTProject(doc);
+ ICProjectDescription des = projDes.isReadOnly() ?
+ CoreModel.getDefault().getProjectDescription(projDes.getProject())
+ :
+ projDes;
+
+ ICStorageElement rootEl = getStorageElement(des, true);
+ rootEl.clear();
+ ICStorageElement el = rootEl.createChild(BUILD_TARGET_ELEMENT);
+ storeTargets(el);
+
+ CoreModel.getDefault().setProjectDescription(des.getProject(), des);
}
- protected void saveTargets(Document doc, OutputStream output) throws TransformerException {
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer;
- transformer = factory.newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
-
- DOMSource source = new DOMSource(doc);
- StreamResult outputTarget = new StreamResult(output);
- transformer.transform(source, outputTarget);
- }
- /**
- * This output method saves the information into the .cdtproject metadata file.
- *
- * @param doc
- * @throws CoreException
- */
- protected void translateDocumentToCDTProject(Document doc) throws CoreException {
- ICDescriptor descriptor;
- descriptor = CCorePlugin.getDefault().getCProjectDescription(getProject(), true);
-
- Element rootElement = descriptor.getProjectData(MAKE_TARGET_KEY);
-
- //Nuke the children since we are going to write out new ones
- NodeList kids = rootElement.getChildNodes();
- for (int i = 0; i < kids.getLength(); i++) {
- rootElement.removeChild(kids.item(i));
- i--;
- }
-
- //Extract the root of our temporary document
- Node node = doc.getFirstChild();
- if (node.hasChildNodes()) {
- //Create a copy which is a part of the new document
- Node appendNode = rootElement.getOwnerDocument().importNode(node, true);
- //Put the copy into the document in the appropriate location
- rootElement.appendChild(appendNode);
- }
- //Save the results
- descriptor.saveProjectData();
+ private ICStorageElement getStorageElement(ICProjectDescription des, boolean create) throws CoreException{
+// return create || des.containsStorage(TARGETS_STORAGE_ID) ?
+// des.getStorage(TARGETS_STORAGE_ID) : null;
+ return des.getStorage(TARGETS_STORAGE_ID, create);
}
/**
@@ -290,7 +249,7 @@ public class ProjectTargets {
* @param input
* @return
*/
- protected Document translateCDTProjectToDocument() {
+/* protected Document translateCDTProjectToDocument() {
Document document = null;
Element rootElement = null;
try {
@@ -314,7 +273,7 @@ public class ProjectTargets {
}
return document;
}
-
+*/
/**
* This method parses the input stream for the XML document describing the build targets.
*
@@ -336,55 +295,38 @@ public class ProjectTargets {
*
* @param document
*/
- protected void extractMakeTargetsFromDocument(Document document, MakeTargetManager manager) {
- Node node = document.getFirstChild();
- if (node != null && node.getNodeName().equals(BUILD_TARGET_ELEMENT)) {
- NodeList list = node.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- node = list.item(i);
- if (node.getNodeName().equals(TARGET_ELEMENT)) {
- IContainer container = null;
- NamedNodeMap attr = node.getAttributes();
- String path = attr.getNamedItem(TARGET_ATTR_PATH).getNodeValue();
- if (path != null && !path.equals("")) { //$NON-NLS-1$
- container = project.getFolder(path);
- } else {
- container = project;
- }
- try {
- MakeTarget target = new MakeTarget(manager, project, attr.getNamedItem(TARGET_ATTR_ID).getNodeValue(),
- attr.getNamedItem(TARGET_ATTR_NAME).getNodeValue());
- target.setContainer(container);
- String option = getString(node, TARGET_STOP_ON_ERROR);
- if (option != null) {
- target.setStopOnError(Boolean.valueOf(option).booleanValue());
- }
- option = getString(node, TARGET_USE_DEFAULT_CMD);
- if (option != null) {
- target.setUseDefaultBuildCmd(Boolean.valueOf(option).booleanValue());
- }
- option = getString(node, TARGET_COMMAND);
- if (option != null) {
- target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, option);
- }
- option = getString(node, TARGET_ARGUMENTS);
- if (option != null) {
- target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, option);
- }
- option = getString(node, BAD_TARGET);
- if (option != null) {
- target.setBuildAttribute(IMakeTarget.BUILD_TARGET, option);
- }
- option = getString(node, TARGET);
- if (option != null) {
- target.setBuildAttribute(IMakeTarget.BUILD_TARGET, option);
+ protected void extractMakeTargetsFromDocument(ICStorageElement el, MakeTargetManager manager, IConfiguration cfg) {
+// Node node = document.getFirstChild();
+// if (node != null && node.getNodeName().equals(BUILD_TARGET_ELEMENT)) {
+ ICStorageElement list[] = el.getChildren();
+ ICConfigurationDescription cfgDes = projDes.getActiveConfiguration();
+/* IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+ if(cfg == null){
+ ICConfigurationDescription dess[] = projDes.getConfigurations();
+ for(int i = 0; i < dess.length; i++){
+ cfg = ManagedBuildManager.getConfigurationForDescription(dess[i]);
+ if(cfg != null)
+ break;
+ }
+ }
+*/
+ if(cfg != null){
+ for (int i = 0; i < list.length; i++) {
+ ICStorageElement node = list[i];
+ if (node.getName().equals(TARGET_ELEMENT)) {
+ try {
+ MakeTarget target = new MakeTarget(manager, cfg, node);
+ add(target);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
}
- add(target);
- } catch (CoreException e) {
- MakeCorePlugin.log(e);
}
}
}
- }
+// }
+ }
+
+ public ICProjectDescription getProjectDescription(){
+ return projDes;
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
deleted file mode 100644
index de6899c1d22..00000000000
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.PathEntryContainerChanged;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-
-public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceChangeListener {
-
- private Map fDiscoveredMap = new HashMap();
- private List listeners = Collections.synchronizedList(new ArrayList());
-
- private static final int INFO_CHANGED = 1;
- private static final int INFO_REMOVED = 2;
-
- public DiscoveredPathManager() {
-
- }
-
- public void startup() {
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
- }
-
- public void shutdown() {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (event.getSource() instanceof IWorkspace) {
- IResource resource = event.getResource();
-
- switch (event.getType()) {
- case IResourceChangeEvent.POST_CHANGE :
- DiscoveredScannerInfoStore.getInstance().updateScannerConfigStore(event.getDelta());
- break;
- case IResourceChangeEvent.PRE_DELETE :
- case IResourceChangeEvent.PRE_CLOSE :
- if (resource.getType() == IResource.PROJECT) {
- fDiscoveredMap.remove(resource);
- }
- break;
- }
- }
- }
-
- public IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException {
- IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.get(project);
- if (info == null) {
- info = loadPathInfo(project);
- fDiscoveredMap.put(project, info);
- }
- return info;
- }
-
- private IDiscoveredPathInfo loadPathInfo(IProject project) throws CoreException {
- IDiscoveredPathInfo pathInfo = null;
-
- IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
- String profileId = buildInfo.getSelectedProfileId();
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, profileId);
- IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
-
- if (collector instanceof IScannerInfoCollector2) {
- IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
- pathInfo = collector2.createPathInfoObject();
- }
- else {
- pathInfo = new DiscoveredPathInfo(project);
- }
- return pathInfo;
- }
-
- public void removeDiscoveredInfo(IProject project) {
- IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.remove(project);
- if (info != null) {
- fireUpdate(INFO_REMOVED, info);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#updateDiscoveredInfo(org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo, java.util.List)
- */
- public void updateDiscoveredInfo(IDiscoveredPathInfo info, List changedResources) throws CoreException {
- if (fDiscoveredMap.get(info.getProject()) != null) {
- IDiscoveredScannerInfoSerializable serializable = info.getSerializable();
- if (serializable != null) {
- IProject project = info.getProject();
- DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, serializable);
- fireUpdate(INFO_CHANGED, info);
-
-// ICProject cProject = CoreModel.getDefault().create(info.getProject());
-// if (cProject != null) {
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// new DiscoveredPathContainer(info.getProject()), null);
-// }
- IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
- String profileId = buildInfo.getSelectedProfileId();
- ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId).getProfileScope();
- changeDiscoveredContainer(project, profileScope, changedResources);
- }
- else {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#changeDiscoveredContainer(org.eclipse.core.resources.IProject, java.lang.String)
- */
- public void changeDiscoveredContainer(final IProject project, final ScannerConfigScope profileScope, final List changedResources) {
- // order here is of essence
- // 1. clear DiscoveredPathManager's path info cache
- IDiscoveredPathInfo oldInfo = (IDiscoveredPathInfo) fDiscoveredMap.remove(project);
-
- // 2. switch the containers
- try {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- ICProject cProject = CoreModel.getDefault().create(project);
- if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
- CoreModel.setPathEntryContainer(new ICProject[]{cProject},
- new DiscoveredPathContainer(project), null);
- }
- else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
- PerFileDiscoveredPathContainer container = new PerFileDiscoveredPathContainer(project);
- CoreModel.setPathEntryContainer(new ICProject[]{cProject},
- container, null);
- if (changedResources != null) {
- List changeDelta = new ArrayList(changedResources.size());
- for (Iterator i = changedResources.iterator(); i.hasNext(); ) {
- IResource resource = (IResource) i.next();
- IPath path = resource.getFullPath();
- changeDelta.add(new PathEntryContainerChanged(path,
- PathEntryContainerChanged.INCLUDE_CHANGED |
- PathEntryContainerChanged.MACRO_CHANGED)); // both include paths and symbols changed
- }
- CoreModel.pathEntryContainerUpdates(container,
- (PathEntryContainerChanged[]) changeDelta.toArray(new PathEntryContainerChanged[changeDelta.size()]),
- null);
- }
- }
- else {
- MakeCorePlugin.log(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1,
- MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
- }
-
- }
- };
- CoreModel.run(runnable, null);
- }
- catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
-
- // 3. clear the container's path entry cache
- if (oldInfo != null) {
- fireUpdate(INFO_REMOVED, oldInfo);
- }
- }
-
- private void fireUpdate(final int type, final IDiscoveredPathInfo info) {
- Object[] list = listeners.toArray();
- for (int i = 0; i < list.length; i++) {
- final IDiscoveredInfoListener listener = (IDiscoveredInfoListener)list[i];
- if (listener != null) {
- Platform.run(new ISafeRunnable() {
-
- public void handleException(Throwable exception) {
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
- CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
- CCorePlugin.log(status);
- }
-
- public void run() throws Exception {
- switch (type) {
- case INFO_CHANGED :
- listener.infoChanged(info);
- break;
- case INFO_REMOVED :
- listener.infoRemoved(info);
- break;
- }
- }
- });
- }
- }
- }
-
- public void addDiscoveredInfoListener(IDiscoveredInfoListener listener) {
- listeners.add(listener);
- }
-
- public void removeDiscoveredInfoListener(IDiscoveredInfoListener listener) {
- listeners.remove(listener);
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
index eab1be0f42e..ef230e9f5de 100644
--- a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
@@ -30,6 +30,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.cdt.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.cdt.ui;bundle-version="[4.0.0,5.0.0)",
org.eclipse.cdt.make.core;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.cdt.managedbuilder.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional
diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml
index c1f920a0e24..f3f4cc2b21d 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.xml
+++ b/build/org.eclipse.cdt.make.ui/plugin.xml
@@ -5,7 +5,7 @@
<extension-point id="DiscoveryProfilePage" name="%discoveryProfilePage.name" schema="schema/DiscoveryProfilePage.exsd"/>
- <extension
+ <!--extension
point="org.eclipse.ui.newWizards">
<wizard
name="%WizardNewCMakeProject.name"
@@ -32,9 +32,9 @@
<selection
class="org.eclipse.core.resources.IProject">
</selection>
- </wizard>
+ </wizard-->
<!-- For C++ Wizards -->
- <wizard
+ <!--wizard
name="%WizardNewCCMakeProject.name"
icon="icons/etool16/newcc_app.gif"
category="org.eclipse.cdt.ui.newCCWizards"
@@ -60,7 +60,7 @@
class="org.eclipse.core.resources.IProject">
</selection>
</wizard>
- </extension>
+ </extension-->
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
@@ -81,10 +81,10 @@
enablesFor="1"
id="org.eclipse.cdt.make.ui.CViewCreateTargetAction">
</action>
- <filter
+ <!--filter
name="projectNature"
value="org.eclipse.cdt.make.core.makeNature">
- </filter>
+ </filter-->
</objectContribution>
</extension>
<extension
@@ -161,12 +161,12 @@
class="org.eclipse.cdt.make.internal.ui.preferences.MakePreferencePage"
id="org.eclipse.cdt.make.ui.preferences.MakePreferencePage">
</page>
- <page
+ <!--page
name="%PreferenceMakeProject.name"
category="org.eclipse.cdt.make.ui.preferences.MakePreferencePage"
class="org.eclipse.cdt.make.internal.ui.preferences.NewMakeProjectPreferencePage"
id="org.eclipse.cdt.make.ui.preferences.MakeProjectPreferencePage">
- </page>
+ </page-->
<page
name="%PreferenceMakefileEditor.name"
category="org.eclipse.cdt.make.ui.preferences.MakePreferencePage"
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/ErrorParserBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/ErrorParserBlock.java
deleted file mode 100644
index f712cb0d05d..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/ErrorParserBlock.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.ui;
-
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
-import org.eclipse.cdt.make.core.MakeBuilder;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.swt.widgets.Composite;
-
-public class ErrorParserBlock extends AbstractErrorParserBlock {
-
- // make builder enabled
- IMakeBuilderInfo fBuildInfo;
- boolean useBuildInfo = false;
- Preferences fPrefs;
-
- public ErrorParserBlock(Preferences preferences) {
- super();
- fPrefs = preferences;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
-
- if (useBuildInfo == true && fBuildInfo == null) {
- Composite composite = ControlFactory.createComposite(parent, 1);
- setControl(composite);
- ControlFactory.createEmptySpace(composite);
- ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString("ErrorParserBlock.label.missingBuilderInformation")); //$NON-NLS-1$
- return;
- }
- super.createControl(parent);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.dialogs.ErrorParserBlock#getErrorParserIDs(org.eclipse.core.resources.IProject)
- */
- protected String[] getErrorParserIDs(IProject project) {
- if (getContainer().getProject() != null && fBuildInfo == null) {
- try {
- fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), MakeBuilder.BUILDER_ID);
- } catch (CoreException e) {
- }
- }
- if (fBuildInfo != null) {
- return fBuildInfo.getErrorParsers();
- }
- return new String[0];
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.dialogs.ErrorParserBlock#saveErrorParsers(org.eclipse.core.resources.IProject,
- * java.lang.String[])
- */
- public void saveErrorParsers(IProject project, String[] parserIDs) throws CoreException {
- if (getContainer().getProject() != null) {
- try {
- fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), MakeBuilder.BUILDER_ID);
- } catch (CoreException e) {
- }
- }
- if (fBuildInfo != null) {
- fBuildInfo.setErrorParsers(parserIDs);
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock#saveErrorParsers(java.lang.String[])
- */
- protected void saveErrorParsers(String[] parserIDs) throws CoreException {
- fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, MakeBuilder.BUILDER_ID, false);
- fBuildInfo.setErrorParsers(parserIDs);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock#getErrorParserIDs(boolean)
- */
- protected String[] getErrorParserIDs(boolean defaults) {
- fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, MakeBuilder.BUILDER_ID, defaults);
- return fBuildInfo.getErrorParsers();
- }
-
- public void setContainer(ICOptionContainer container) {
- super.setContainer(container);
- if (getContainer().getProject() != null) {
- try {
- fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), MakeBuilder.BUILDER_ID);
- } catch (CoreException e) {
- }
- useBuildInfo = true;
- } else {
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java
deleted file mode 100644
index 3754ff1e8d8..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java
+++ /dev/null
@@ -1,810 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.ui;
-
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.spawner.EnvironmentReader;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
-
-public class MakeEnvironmentBlock extends AbstractCOptionPage {
-
- Preferences fPrefs;
- String fBuilderID;
- IMakeCommonBuildInfo fBuildInfo;
- protected TableViewer environmentTable;
- protected String[] envTableColumnHeaders = {MakeUIPlugin.getResourceString("MakeEnvironmentBlock.0"), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.1")}; //$NON-NLS-1$ //$NON-NLS-2$
- protected ColumnLayoutData[] envTableColumnLayouts = {new ColumnPixelData(150), new ColumnPixelData(250)};
-
- private static final String NAME_LABEL = MakeUIPlugin.getResourceString("MakeEnvironmentBlock.2"); //$NON-NLS-1$
- private static final String VALUE_LABEL = MakeUIPlugin.getResourceString("MakeEnvironmentBlock.3"); //$NON-NLS-1$
-
- protected static final String P_VARIABLE = "variable"; //$NON-NLS-1$
- protected static final String P_VALUE = "value"; //$NON-NLS-1$
- protected static String[] envTableColumnProperties = {P_VARIABLE, P_VALUE};
- protected Button envAddButton;
- protected Button envEditButton;
- protected Button envRemoveButton;
- protected Button appendEnvironment;
- protected Button replaceEnvironment;
- protected Button envSelectButton;
-
- class EnvironmentVariable {
-
- // The name of the environment variable
- private String name;
-
- // The value of the environment variable
- private String value;
-
- EnvironmentVariable(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- /**
- * Returns this variable's name, which serves as the key in the
- * key/value pair this variable represents
- *
- * @return this variable's name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns this variables value.
- *
- * @return this variable's value
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets this variable's value
- *
- * @param value
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return getName();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- boolean equal = false;
- if (obj instanceof EnvironmentVariable) {
- EnvironmentVariable var = (EnvironmentVariable)obj;
- equal = var.getName().equals(name);
- }
- return equal;
- }
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return name.hashCode();
- }
- }
-
- /**
- * Content provider for the environment table
- */
- protected class EnvironmentVariableContentProvider implements IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- EnvironmentVariable[] elements = new EnvironmentVariable[0];
- IMakeCommonBuildInfo info = (IMakeCommonBuildInfo)inputElement;
- Map m = info.getEnvironment();
- if (m != null && !m.isEmpty()) {
- elements = new EnvironmentVariable[m.size()];
- String[] varNames = new String[m.size()];
- m.keySet().toArray(varNames);
- for (int i = 0; i < m.size(); i++) {
- elements[i] = new EnvironmentVariable(varNames[i], (String)m.get(varNames[i]));
- }
- }
- return elements;
- }
- public void dispose() {
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput == null) {
- return;
- }
- if (viewer instanceof TableViewer) {
- TableViewer tableViewer = (TableViewer)viewer;
- if (tableViewer.getTable().isDisposed()) {
- return;
- }
- tableViewer.setSorter(new ViewerSorter() {
-
- public int compare(Viewer iviewer, Object e1, Object e2) {
- if (e1 == null) {
- return -1;
- } else if (e2 == null) {
- return 1;
- } else {
- return ((EnvironmentVariable)e1).getName().compareToIgnoreCase( ((EnvironmentVariable)e2).getName());
- }
- }
- });
- }
- }
- }
-
- /**
- * Label provider for the environment table
- */
- public class EnvironmentVariableLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- public String getColumnText(Object element, int columnIndex) {
- String result = null;
- if (element != null) {
- EnvironmentVariable var = (EnvironmentVariable)element;
- switch (columnIndex) {
- case 0 : // variable
- result = var.getName();
- break;
- case 1 : // value
- result = var.getValue();
- break;
- }
- }
- return result;
- }
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == 0) {
- return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENV_VAR);
- }
- return null;
- }
- }
-
- public MakeEnvironmentBlock(Preferences prefs, String builderID) {
- super(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.4")); //$NON-NLS-1$
- setDescription(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.5")); //$NON-NLS-1$
- fPrefs = prefs;
- fBuilderID = builderID;
- }
-
- public void setContainer(ICOptionContainer container) {
- super.setContainer(container);
- if (getContainer().getProject() != null) {
- try {
- fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
- } catch (CoreException e) {
- }
- } else {
- fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
- }
- }
-
- public void performApply(IProgressMonitor monitor) throws CoreException {
- // Missing builder info
- if (fBuildInfo == null) {
- return;
- }
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- IWorkspace workspace = MakeUIPlugin.getWorkspace();
- // To avoid multi-build
- IWorkspaceRunnable operation = new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(MakeUIPlugin.getResourceString("SettingsBlock.monitor.applyingSettings"), 1); //$NON-NLS-1$
- IMakeCommonBuildInfo info = null;
- if (getContainer().getProject() != null) {
- try {
- info = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
- } catch (CoreException e) {
- // disabled builder... just log it
- MakeCorePlugin.log(e);
- return;
- }
- } else {
- info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
- }
- // Convert the table's items into a Map so that this can be saved in the
- // configuration's attributes.
- TableItem[] items = environmentTable.getTable().getItems();
- Map map = new HashMap(items.length);
- for (int i = 0; i < items.length; i++)
- {
- EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
- map.put(var.getName(), var.getValue());
- }
- info.setEnvironment(map);
- info.setAppendEnvironment(appendEnvironment.getSelection());
- }
- };
- if (getContainer().getProject() != null) {
- workspace.run(operation, monitor);
- } else {
- operation.run(monitor);
- }
- }
-
- /**
- * Updates the environment table for the given launch configuration
- *
- * @param configuration
- */
- protected void updateEnvironment(IMakeCommonBuildInfo info) {
- environmentTable.setInput(info);
- }
-
- public void performDefaults() {
- // Missing builder info
- if (fBuildInfo == null) {
- return;
- }
-
- IMakeCommonBuildInfo info;
- if (getContainer().getProject() != null) {
- info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
- } else {
- info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, true);
- }
- boolean append = info.appendEnvironment();
- if (append) {
- appendEnvironment.setSelection(true);
- replaceEnvironment.setSelection(false);
- } else {
- replaceEnvironment.setSelection(true);
- appendEnvironment.setSelection(false);
- }
- updateEnvironment(info);
- updateAppendReplace();
- }
-
- public void createControl(Composite parent) {
- Composite composite = ControlFactory.createComposite(parent, 1);
- setControl(composite);
-
- MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_BUILDER_SETTINGS);
-
- if (fBuildInfo == null) {
- ControlFactory.createEmptySpace(composite);
- ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString("SettingsBlock.label.missingBuilderInformation")); //$NON-NLS-1$
- return;
- }
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- composite.setLayout(layout);
- composite.setLayoutData(gridData);
- composite.setFont(parent.getFont());
-
- createBuildEnvironmentControls(composite);
- createTableButtons(composite);
- createAppendReplace(composite);
-
- boolean append = fBuildInfo.appendEnvironment();
- if (append) {
- appendEnvironment.setSelection(true);
- replaceEnvironment.setSelection(false);
- } else {
- replaceEnvironment.setSelection(true);
- appendEnvironment.setSelection(false);
- }
- updateEnvironment(fBuildInfo);
- updateAppendReplace();
-
- }
-
- private void createBuildEnvironmentControls(Composite parent) {
- Font font = parent.getFont();
- // Create table composite
- Composite tableComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 1;
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.heightHint = 150;
- tableComposite.setLayout(layout);
- tableComposite.setLayoutData(gridData);
- tableComposite.setFont(font);
- // Create label
- Label label = new Label(tableComposite, SWT.NONE);
- label.setFont(font);
- label.setText(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.6")); //$NON-NLS-1$
- // Create table
- environmentTable = new TableViewer(tableComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
- | SWT.FULL_SELECTION);
- Table table = environmentTable.getTable();
- TableLayout tableLayout = new TableLayout();
- table.setLayout(tableLayout);
- table.setHeaderVisible(true);
- table.setFont(font);
- gridData = new GridData(GridData.FILL_BOTH);
- environmentTable.getControl().setLayoutData(gridData);
- environmentTable.setContentProvider(new EnvironmentVariableContentProvider());
- environmentTable.setLabelProvider(new EnvironmentVariableLabelProvider());
- environmentTable.setColumnProperties(envTableColumnProperties);
- environmentTable.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- handleTableSelectionChanged(event);
- }
- });
- environmentTable.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(DoubleClickEvent event) {
- if (!environmentTable.getSelection().isEmpty()) {
- handleEnvEditButtonSelected();
- }
- }
- });
- // Create columns
- for (int i = 0; i < envTableColumnHeaders.length; i++) {
- tableLayout.addColumnData(envTableColumnLayouts[i]);
- TableColumn tc = new TableColumn(table, SWT.NONE, i);
- tc.setResizable(envTableColumnLayouts[i].resizable);
- tc.setText(envTableColumnHeaders[i]);
- }
- }
-
- /**
- * Responds to a selection changed event in the environment table
- *
- * @param event
- * the selection change event
- */
- protected void handleTableSelectionChanged(SelectionChangedEvent event) {
- int size = ((IStructuredSelection)event.getSelection()).size();
- envEditButton.setEnabled(size == 1);
- envRemoveButton.setEnabled(size > 0);
- }
-
- /**
- * Create some empty space.
- */
- protected void createVerticalSpacer(Composite comp, int colSpan) {
- Label label = new Label(comp, SWT.NONE);
- GridData gd = new GridData();
- gd.horizontalSpan = colSpan;
- label.setLayoutData(gd);
- label.setFont(comp.getFont());
- }
-
- /**
- * Creates the add/edit/remove buttons for the environment table
- *
- * @param parent
- * the composite in which the buttons should be created
- */
- protected void createTableButtons(Composite parent) {
- // Create button composite
- Composite buttonComposite = new Composite(parent, SWT.NONE);
- GridLayout glayout = new GridLayout();
- glayout.marginHeight = 0;
- glayout.marginWidth = 0;
- glayout.numColumns = 1;
- GridData gdata = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
- buttonComposite.setLayout(glayout);
- buttonComposite.setLayoutData(gdata);
- buttonComposite.setFont(parent.getFont());
-
- createVerticalSpacer(buttonComposite, 1);
- // Create buttons
- envAddButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.7"), null); //$NON-NLS-1$
- envAddButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- handleEnvAddButtonSelected();
- }
- });
- envSelectButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.8"), null); //$NON-NLS-1$
- envSelectButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- handleEnvSelectButtonSelected();
- }
- });
- envEditButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.9"), null); //$NON-NLS-1$
- envEditButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- handleEnvEditButtonSelected();
- }
- });
- envEditButton.setEnabled(false);
- envRemoveButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.10"), null); //$NON-NLS-1$
- envRemoveButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- handleEnvRemoveButtonSelected();
- }
- });
- envRemoveButton.setEnabled(false);
- }
-
- /**
- * Adds a new environment variable to the table.
- */
- protected void handleEnvAddButtonSelected() {
- MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.11")); //$NON-NLS-1$
- dialog.addTextField(NAME_LABEL, null, false);
- dialog.addVariablesField(VALUE_LABEL, null, true);
-
- if (dialog.open() != Window.OK) {
- return;
- }
-
- String name = dialog.getStringValue(NAME_LABEL);
- String value = dialog.getStringValue(VALUE_LABEL);
-
- if (name != null && value != null && name.length() > 0 && value.length() > 0) {
- addVariable(new EnvironmentVariable(name.trim(), value.trim()));
- updateAppendReplace();
- }
- }
-
- /**
- * Updates the enablement of the append/replace widgets. The widgets should
- * disable when there are no environment variables specified.
- */
- protected void updateAppendReplace() {
- boolean enable = environmentTable.getTable().getItemCount() > 0;
- appendEnvironment.setEnabled(enable);
- replaceEnvironment.setEnabled(enable);
- }
-
- /**
- * Attempts to add the given variable. Returns whether the variable was
- * added or not (as when the user answers not to overwrite an existing
- * variable).
- *
- * @param variable
- * the variable to add
- * @return whether the variable was added
- */
- protected boolean addVariable(EnvironmentVariable variable) {
- String name = variable.getName();
- TableItem[] items = environmentTable.getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- EnvironmentVariable existingVariable = (EnvironmentVariable)items[i].getData();
- if (existingVariable.getName().equals(name)) {
- boolean overWrite = MessageDialog.openQuestion(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.12"), MessageFormat.format( //$NON-NLS-1$
- MakeUIPlugin.getResourceString("MakeEnvironmentBlock.13"), new String[]{name})); //$NON-NLS-1$
- if (!overWrite) {
- return false;
- }
- environmentTable.remove(existingVariable);
- break;
- }
- }
- environmentTable.add(variable);
- getContainer().updateContainer();
- return true;
- }
-
- /**
- * Gets native environment variable. Creates EnvironmentVariable objects.
- *
- * @return Map of name - EnvironmentVariable pairs based on native
- * environment.
- */
- private Map getNativeEnvironment() {
- Map stringVars = EnvironmentReader.getEnvVars();
- HashMap vars = new HashMap();
- for (Iterator i = stringVars.keySet().iterator(); i.hasNext();) {
- String key = (String)i.next();
- String value = (String)stringVars.get(key);
- vars.put(key, new EnvironmentVariable(key, value));
- }
- return vars;
- }
-
- /**
- * Displays a dialog that allows user to select native environment variables
- * to add to the table.
- */
- protected void handleEnvSelectButtonSelected() {
- // get Environment Variables from the OS
- Map envVariables = getNativeEnvironment();
-
- // get Environment Variables from the table
- TableItem[] items = environmentTable.getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- EnvironmentVariable var = (EnvironmentVariable)items[i].getData();
- envVariables.remove(var.getName());
- }
-
- ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(),
- createSelectionDialogLabelProvider(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.14")); //$NON-NLS-1$
- dialog.setTitle(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.15")); //$NON-NLS-1$
-
- int button = dialog.open();
- if (button == Window.OK) {
- Object[] selected = dialog.getResult();
- for (int i = 0; i < selected.length; i++) {
- environmentTable.add(selected[i]);
- }
- }
-
- updateAppendReplace();
- getContainer().updateContainer();
- }
-
- /**
- * Creates a label provider for the native native environment variable
- * selection dialog.
- *
- * @return A label provider for the native native environment variable
- * selection dialog.
- */
- private ILabelProvider createSelectionDialogLabelProvider() {
- return new ILabelProvider() {
-
- public Image getImage(Object element) {
- return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENVIRONMNET);
- }
- public String getText(Object element) {
- EnvironmentVariable var = (EnvironmentVariable)element;
- return var.getName() + " [" + var.getValue() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- public void addListener(ILabelProviderListener listener) {
- }
- public void dispose() {
- }
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
- public void removeListener(ILabelProviderListener listener) {
- }
- };
- }
-
- /**
- * Creates a content provider for the native native environment variable
- * selection dialog.
- *
- * @return A content provider for the native native environment variable
- * selection dialog.
- */
- private IStructuredContentProvider createSelectionDialogContentProvider() {
- return new IStructuredContentProvider() {
-
- public Object[] getElements(Object inputElement) {
- EnvironmentVariable[] elements = null;
- if (inputElement instanceof Map) {
- Comparator comparator = new Comparator() {
-
- public int compare(Object o1, Object o2) {
- String s1 = (String)o1;
- String s2 = (String)o2;
- return s1.compareTo(s2);
- }
-
- };
- TreeMap envVars = new TreeMap(comparator);
- envVars.putAll((Map)inputElement);
- elements = new EnvironmentVariable[envVars.size()];
- int index = 0;
- for (Iterator iterator = envVars.keySet().iterator(); iterator.hasNext(); index++) {
- Object key = iterator.next();
- elements[index] = (EnvironmentVariable)envVars.get(key);
- }
- }
- return elements;
- }
- public void dispose() {
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- };
- }
- /**
- * Creates an editor for the value of the selected environment variable.
- */
- protected void handleEnvEditButtonSelected() {
- IStructuredSelection sel = (IStructuredSelection)environmentTable.getSelection();
- EnvironmentVariable var = (EnvironmentVariable)sel.getFirstElement();
- if (var == null) {
- return;
- }
- String originalName = var.getName();
- String value = var.getValue();
- MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.16")); //$NON-NLS-1$
- dialog.addTextField(NAME_LABEL, originalName, false);
- dialog.addVariablesField(VALUE_LABEL, value, true);
-
- if (dialog.open() != Window.OK) {
- return;
- }
- String name = dialog.getStringValue(NAME_LABEL);
- value = dialog.getStringValue(VALUE_LABEL);
- if (!originalName.equals(name)) {
- if (addVariable(new EnvironmentVariable(name, value))) {
- environmentTable.remove(var);
- }
- } else {
- var.setValue(value);
- environmentTable.update(var, null);
- getContainer().updateContainer();
- }
- }
-
- /**
- * Removes the selected environment variable from the table.
- */
- protected void handleEnvRemoveButtonSelected() {
- IStructuredSelection sel = (IStructuredSelection)environmentTable.getSelection();
- environmentTable.getControl().setRedraw(false);
- for (Iterator i = sel.iterator(); i.hasNext();) {
- EnvironmentVariable var = (EnvironmentVariable)i.next();
- environmentTable.remove(var);
- }
- environmentTable.getControl().setRedraw(true);
- updateAppendReplace();
- getContainer().updateContainer();
- }
-
- private class NativeEnvironmentDialog extends ListSelectionDialog {
-
- public NativeEnvironmentDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider,
- ILabelProvider labelProvider, String message) {
- super(parentShell, input, contentProvider, labelProvider, message);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- protected IDialogSettings getDialogSettings() {
- IDialogSettings settings = MakeUIPlugin.getDefault().getDialogSettings();
- IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
- if (section == null) {
- section = settings.addNewSection(getDialogSettingsSectionName());
- }
- return section;
- }
-
- /**
- * Returns the name of the section that this dialog stores its settings
- * in
- *
- * @return String
- */
- protected String getDialogSettingsSectionName() {
- return MakeUIPlugin.getPluginId() + ".ENVIRONMENT_TAB.NATIVE_ENVIROMENT_DIALOG"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
- */
- protected Point getInitialLocation(Point initialSize) {
- Point initialLocation = DialogSettingsHelper.getInitialLocation(getDialogSettingsSectionName());
- if (initialLocation != null) {
- return initialLocation;
- }
- return super.getInitialLocation(initialSize);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#getInitialSize()
- */
- protected Point getInitialSize() {
- Point size = super.getInitialSize();
- return DialogSettingsHelper.getInitialSize(getDialogSettingsSectionName(), size);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#close()
- */
- public boolean close() {
- DialogSettingsHelper.persistShellGeometry(getShell(), getDialogSettingsSectionName());
- return super.close();
- }
- }
-
- /**
- * Creates and configures the widgets which allow the user to choose whether
- * the specified environment should be appended to the native environment or
- * if it should completely replace it.
- *
- * @param parent
- * the composite in which the widgets should be created
- */
- protected void createAppendReplace(Composite parent) {
- Composite appendReplaceComposite = new Composite(parent, SWT.NONE);
- GridData gridData = new GridData();
- gridData.horizontalSpan = 2;
- GridLayout layout = new GridLayout();
- appendReplaceComposite.setLayoutData(gridData);
- appendReplaceComposite.setLayout(layout);
- appendReplaceComposite.setFont(parent.getFont());
-
- appendEnvironment = createRadioButton(appendReplaceComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.17")); //$NON-NLS-1$
- appendEnvironment.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- getContainer().updateContainer();
- }
- });
- replaceEnvironment = createRadioButton(appendReplaceComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.18")); //$NON-NLS-1$
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
index ea0305e527e..abea9ee1da7 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
@@ -13,13 +13,8 @@ package org.eclipse.cdt.make.internal.ui;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.cdt.make.core.MakeBuilder;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.properties.MakePropertyPage;
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
-import org.eclipse.cdt.make.ui.dialogs.DiscoveryOptionsBlock;
-import org.eclipse.cdt.make.ui.dialogs.SettingsBlock;
-import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
@@ -39,11 +34,12 @@ public class MakeProjectOptionBlock extends TabFolderOptionBlock {
}
protected void addTabs() {
- addTab(new SettingsBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
- addTab(new MakeEnvironmentBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
- addTab(new ErrorParserBlock(MakeCorePlugin.getDefault().getPluginPreferences()));
- addTab(new BinaryParserBlock());
- addTab(new DiscoveryOptionsBlock());
+
+// addTab(new SettingsBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
+// addTab(new MakeEnvironmentBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
+// addTab(new ErrorParserBlock(MakeCorePlugin.getDefault().getPluginPreferences()));
+// addTab(new BinaryParserBlock());
+// addTab(new DiscoveryOptionsBlock());
}
public void setOptionContainer(ICOptionContainer parent) {
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
index 19fb38ffdd3..8df515c259c 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
@@ -19,6 +19,10 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.makefile.ITargetRule;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
@@ -117,8 +121,17 @@ public class AddBuildTargetAction extends Action {
IFile file = getFile();
if (file == null)
return false;
- if (!MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(file.getProject()))
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(file);
+ if(info == null)
return false;
+ IConfiguration cfg = info.getDefaultConfiguration();
+ if(cfg == null)
+ return false;
+ IBuilder builder = cfg.getBuilder();
+ if(builder == null)
+ return false;
+// if(!builder.isManagedBuildOn())
+// return false;
}
return true;
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java
index 6217f750be0..9b71878e2c9 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java
@@ -15,6 +15,7 @@ import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java
index b719b95bcd5..7061cca0904 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java
@@ -16,14 +16,13 @@ import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
-import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.wizards.UpdateMakeProjectWizard;
+import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -212,7 +211,7 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
MakeProjectNature.addNature(project[i], new SubProgressMonitor(monitor, 1));
// move existing build properties to new
- IMakeBuilderInfo newInfo = MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
+ IMakeBuilderInfo newInfo = null; //TODO: MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
final int LOCATION = 0, FULL_ARGS = 1, INC_ARGS = 2, STOP_ERORR = 3, USE_DEFAULT = 4;
QualifiedName[] qName = new QualifiedName[USE_DEFAULT + 1];
qName[LOCATION] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation"); //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java
deleted file mode 100644
index 772c926aa71..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.internal.ui.preferences.TabFolderLayout;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Fremework for loading profile option pages
- *
- * @author vhirsl
- */
-public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage {
- protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
- private static final String UNSAVEDCHANGES_TITLE = PREFIX + ".unsavedchanges.title"; //$NON-NLS-1$
- private static final String UNSAVEDCHANGES_MESSAGE = PREFIX + ".unsavedchanges.message"; //$NON-NLS-1$
- private static final String UNSAVEDCHANGES_BSAVE = PREFIX + ".unsavedchanges.button.save"; //$NON-NLS-1$
- private static final String UNSAVEDCHANGES_BCANCEL = PREFIX + ".unsavedchanges.button.cancel"; //$NON-NLS-1$
- private static final String ERROR_TITLE = PREFIX + ".error.title"; //$NON-NLS-1$
- private static final String ERROR_MESSAGE = PREFIX + ".error.message"; //$NON-NLS-1$
- private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
- private static final String PROFILE_ID = "profileId"; //$NON-NLS-1$
-
- private Preferences fPrefs;
- private IScannerConfigBuilderInfo2 fBuildInfo;
- private boolean fInitialized = false;
- private String fPersistedProfileId = null;
-
- private Map fProfilePageMap = null;
-
- // Composite parent provided by the block.
- private Composite fCompositeParent;
- private AbstractDiscoveryPage fCurrentPage;
-
- /**
- * @return Returns the project.
- */
- public IProject getProject() {
- return getContainer().getProject();
- }
- /**
- * @return Returns the fPrefs.
- */
- public Preferences getPrefs() {
- return fPrefs;
- }
- /**
- * @return Returns the fBuildInfo.
- */
- public IScannerConfigBuilderInfo2 getBuildInfo() {
- return fBuildInfo;
- }
- /**
- * @return Returns the fInitialized.
- */
- public boolean isInitialized() {
- return fInitialized;
- }
- /**
- * @param initialized The fInitialized to set.
- */
- public void setInitialized(boolean initialized) {
- fInitialized = initialized;
- }
-
- /**
- * @return true - OK to continue
- */
- public boolean checkDialogForChanges() {
- boolean rc = true;
- if (isProfileDifferentThenPersisted()) {
- String title = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_TITLE);
- String message = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_MESSAGE);
- String[] buttonLabels = new String[]{
- MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BSAVE),
- MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BCANCEL),
- };
- MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
- buttonLabels, 0);
- int res = dialog.open();
- if (res == 0) { // OK
- callPerformApply();
- rc = true;
- } else if (res == 1) { // CANCEL
- rc = false;
- }
- }
- return rc;
- }
-
- public boolean isProfileDifferentThenPersisted() {
- return (fPersistedProfileId != null &&
- !fPersistedProfileId.equals(getBuildInfo().getSelectedProfileId()));
- }
-
- public void updatePersistedProfile() {
- fPersistedProfileId = getBuildInfo().getSelectedProfileId();
- }
-
- /**
- * Create a profile page only on request
- *
- * @author vhirsl
- */
- protected static class DiscoveryProfilePageConfiguration {
-
- AbstractDiscoveryPage page;
- IConfigurationElement fElement;
-
- public DiscoveryProfilePageConfiguration(IConfigurationElement element) {
- fElement = element;
- }
-
- public AbstractDiscoveryPage getPage() throws CoreException {
- if (page == null) {
- page = (AbstractDiscoveryPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
- }
- return page;
- }
- public String getName() {
- return fElement.getAttribute("name"); //$NON-NLS-1$
- }
- }
-
- /**
- * @param title
- */
- public AbstractDiscoveryOptionsBlock(String title) {
- super(title);
- initializeProfilePageMap();
- }
-
- /**
- * @param title
- * @param image
- */
- public AbstractDiscoveryOptionsBlock(String title, ImageDescriptor image) {
- super(title, image);
- initializeProfilePageMap();
- }
-
- /**
- *
- */
- private void initializeProfilePageMap() {
- fProfilePageMap = new HashMap(5);
-
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(MakeUIPlugin.getPluginId(), "DiscoveryProfilePage"); //$NON-NLS-1$
- IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
- for (int i = 0; i < infos.length; i++) {
- if (infos[i].getName().equals(PROFILE_PAGE)) { //$NON-NLS-1$
- String id = infos[i].getAttribute(PROFILE_ID); //$NON-NLS-1$
- fProfilePageMap.put(id, new DiscoveryProfilePageConfiguration(infos[i]));
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
- */
- public void setContainer(ICOptionContainer container) {
- super.setContainer(container);
-
- fPrefs = getContainer().getPreferences();
- IProject project = getContainer().getProject();
-
- fInitialized = true;
- if (project != null) {
- try {
- fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
- } catch (CoreException e) {
- // missing builder information (builder disabled or legacy project)
- fInitialized = false;
- fBuildInfo = null;
- }
- } else {
- fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
- }
- if (fBuildInfo != null) {
- fPersistedProfileId = fBuildInfo.getSelectedProfileId();
- }
- }
-
- public void updateContainer() {
- getContainer().updateContainer();
- }
-
- /**
- * @param project
- */
- protected void createBuildInfo() {
- if (getProject() != null) {
- try {
- // get the project properties
- fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(getProject());
- }
- catch (CoreException e) {
- fBuildInfo = null;
- }
- }
- else {
- // get the preferences
- fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
- }
- }
-
- /**
- * Create build info based on preferences
- */
- protected void createDefaultBuildInfo() {
- // Populate with the default values
- if (getProject() != null) {
- // get the preferences
- fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
- } else {
- // get the defaults
- fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, true);
- }
- }
-
- protected Composite getCompositeParent() {
- return fCompositeParent;
- }
-
- protected void setCompositeParent(Composite parent) {
- fCompositeParent = parent;
- fCompositeParent.setLayout(new TabFolderLayout());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- handleDiscoveryProfileChanged();
- }
- }
-
- /**
- * Notification that the user changed the selection of the SCD profile.
- */
- protected void handleDiscoveryProfileChanged() {
- if (getCompositeParent() == null) {
- return;
- }
- String profileId = getCurrentProfileId();
- AbstractDiscoveryPage page = getDiscoveryProfilePage(profileId);
- if (page != null) {
- if (page.getControl() == null) {
- Composite parent = getCompositeParent();
- page.setContainer(this);
- page.createControl(parent);
- parent.layout(true);
- }
- if (fCurrentPage != null) {
- fCurrentPage.setVisible(false);
- }
- page.setVisible(true);
- }
- setCurrentPage(page);
- }
-
- protected AbstractDiscoveryPage getCurrentPage() {
- return fCurrentPage;
- }
-
- protected void setCurrentPage(AbstractDiscoveryPage page) {
- fCurrentPage = page;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.AbstractDiscoveryPage#isValid()
- */
- public boolean isValid() {
- return (getCurrentPage() == null) ? true : getCurrentPage().isValid();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
- */
- public String getErrorMessage() {
- return getCurrentPage().getErrorMessage();
- }
-
- protected AbstractDiscoveryPage getDiscoveryProfilePage(String profileId) {
- DiscoveryProfilePageConfiguration configElement =
- (DiscoveryProfilePageConfiguration) fProfilePageMap.get(profileId);
- if (configElement != null) {
- try {
- return configElement.getPage();
- } catch (CoreException e) {
- }
- }
- return null;
- }
-
- protected String getDiscoveryProfileName(String profileId) {
- DiscoveryProfilePageConfiguration configElement =
- (DiscoveryProfilePageConfiguration) fProfilePageMap.get(profileId);
- if (configElement != null) {
- return configElement.getName();
- }
- return null;
- }
-
- protected String getDiscoveryProfileId(String profileName) {
- for (Iterator I = fProfilePageMap.keySet().iterator(); I.hasNext();) {
- String profileId = (String) I.next();
- String confProfileName = getDiscoveryProfileName(profileId);
- if (profileName.equals(confProfileName)) {
- return profileId;
- }
- }
- return null;
- }
-
- protected List getDiscoveryProfileIdList() {
- return new ArrayList(fProfilePageMap.keySet());
- }
-
- protected abstract String getCurrentProfileId();
-
- /**
- *
- */
- public void callPerformApply() {
- try {
- new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- performApply(monitor);
- }
- catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- });
- } catch (InvocationTargetException e) {
- String title = CPathEntryMessages.getString(ERROR_TITLE); //$NON-NLS-1$
- String message = CPathEntryMessages.getString(ERROR_MESSAGE); //$NON-NLS-1$
- ExceptionHandler.handle(e, getShell(), title, message);
- } catch (InterruptedException e) {
- // cancelled
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java
deleted file mode 100644
index 0f728740896..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.debug.ui.StringVariableSelectionDialog;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Abstract SCD profile page
- *
- * @author vhirsl
- */
-public abstract class AbstractDiscoveryPage extends DialogPage {
- protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
- protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
- private static final String VARIABLES_BUTTON = PREFIX + ".common.variables.button"; //$NON-NLS-1$
-
- protected AbstractDiscoveryOptionsBlock fContainer; // parent
-
- /**
- * @return Returns the fContainer.
- */
- protected AbstractDiscoveryOptionsBlock getContainer() {
- return fContainer;
- }
- /**
- * @param container The fContainer to set.
- */
- protected void setContainer(AbstractDiscoveryOptionsBlock container) {
- fContainer = container;
- }
- /**
- *
- */
- public AbstractDiscoveryPage() {
- super();
- }
-
- /**
- * @param title
- */
- public AbstractDiscoveryPage(String title) {
- super(title);
- }
-
- /**
- * @param title
- * @param image
- */
- public AbstractDiscoveryPage(String title, ImageDescriptor image) {
- super(title, image);
- }
-
- protected Button addVariablesButton(Composite parent, final Text control) {
- Button variablesButton = ControlFactory.createPushButton(parent,
- MakeUIPlugin.getResourceString(VARIABLES_BUTTON));
- ((GridData) variablesButton.getLayoutData()).widthHint =
- SWTUtil.getButtonWidthHint(variablesButton);
-
- variablesButton.addSelectionListener(new SelectionAdapter() {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent arg0) {
- handleVariablesButtonSelected(control);
- }
- });
- return variablesButton;
- }
-
- /**
- * A variable entry button has been pressed for the given text field. Prompt
- * the user for a variable and enter the result in the given field.
- */
- private void handleVariablesButtonSelected(Text textField) {
- String variable = getVariable();
- if (variable != null) {
- textField.append(variable);
- }
- }
-
- /**
- * Prompts the user to choose and configure a variable and returns the
- * resulting string, suitable to be used as an attribute.
- */
- private String getVariable() {
- StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
- dialog.open();
- return dialog.getVariableExpression();
- }
-
- protected abstract boolean isValid();
- protected abstract void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo);
- protected abstract void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo);
-
- public void performApply() {
- IScannerConfigBuilderInfo2 buildInfo = getContainer().getBuildInfo();
-
- populateBuildInfo(buildInfo);
- }
-
- public void performDefaults() {
- IScannerConfigBuilderInfo2 buildInfo = getContainer().getBuildInfo();
-
- restoreFromBuildinfo(buildInfo);
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java
deleted file mode 100644
index 8493ee417d0..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java
+++ /dev/null
@@ -1,846 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.util.PixelConverter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElement;
-import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementLabelProvider;
-import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementSorter;
-import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ActionHandler;
-import org.eclipse.ui.commands.HandlerSubmission;
-import org.eclipse.ui.commands.IWorkbenchCommandSupport;
-import org.eclipse.ui.commands.Priority;
-import org.eclipse.ui.contexts.IWorkbenchContextSupport;
-
-/**
- * A dialog page to manage discovered scanner configuration
- *
- * @author vhirsl
- */
-public class DiscoveredPathContainerPage extends WizardPage implements IPathEntryContainerPage {
- private static final String PREFIX = "DiscoveredScannerConfigurationContainerPage"; //$NON-NLS-1$
-
- private static final String DISC_COMMON_PREFIX = "ManageScannerConfigDialogCommon"; //$NON-NLS-1$
- private static final String UP = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.up.label"; //$NON-NLS-1$
- private static final String DOWN = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.down.label"; //$NON-NLS-1$
- private static final String DISABLE = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.disable.label"; //$NON-NLS-1$
- private static final String ENABLE = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.enable.label"; //$NON-NLS-1$
- private static final String DELETE = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.delete.label"; //$NON-NLS-1$
-
- private static final String CONTAINER_LABEL = PREFIX + ".title"; //$NON-NLS-1$
- private static final String CONTAINER_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
- private static final String CONTAINER_LIST_LABEL = PREFIX + ".list.title"; //$NON-NLS-1$
- private static final String CONTAINER_INITIALIZATION_ERROR = PREFIX +".initialization.error.message"; //$NON-NLS-1$
-
- private final int IDX_UP = 0;
- private final int IDX_DOWN = 1;
- private final int IDX_ENABLE = 2;
- private final int IDX_DISABLE = 3;
-
- private final int IDX_DELETE = 5;
-
- private static final int DISC_UP = 0;
- private static final int DISC_DOWN = 1;
-
- private static final int DO_DISABLE = 0;
- private static final int DO_ENABLE = 1;
-
- private ICProject fCProject;
- private IContainerEntry fPathEntry;
-
- private TreeListDialogField fDiscoveredContainerList;
- private IDiscoveredPathInfo info = null;
- private boolean dirty;
- private List deletedEntries;
-
- private CopyTextAction copyTextAction;
- private HandlerSubmission submission;
-
- public DiscoveredPathContainerPage() {
- super("DiscoveredScannerConfigurationContainerPage"); //$NON-NLS-1$
-
- setTitle(MakeUIPlugin.getResourceString(CONTAINER_LABEL));
- setDescription(MakeUIPlugin.getResourceString(CONTAINER_DESCRIPTION));
- setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
-
- String[] buttonLabels = new String[]{
- /* IDX_UP */ MakeUIPlugin.getResourceString(UP),
- /* IDX_DOWN */ MakeUIPlugin.getResourceString(DOWN),
- /* IDX_ENABLE */MakeUIPlugin.getResourceString(ENABLE),
- /* IDX_DISABLE */MakeUIPlugin.getResourceString(DISABLE),
- null,
- /* IDX_DELETE */MakeUIPlugin.getResourceString(DELETE),
- };
-
- DiscoveredContainerAdapter adapter = new DiscoveredContainerAdapter();
-
- fDiscoveredContainerList = new TreeListDialogField(adapter, buttonLabels, new DiscoveredElementLabelProvider());
- fDiscoveredContainerList.setDialogFieldListener(adapter);
- fDiscoveredContainerList.setLabelText(MakeUIPlugin.getResourceString(CONTAINER_LIST_LABEL)); //$NON-NLS-1$
-
- fDiscoveredContainerList.setTreeExpansionLevel(2);
- fDiscoveredContainerList.setViewerSorter(new DiscoveredElementSorter());
- dirty = false;
- deletedEntries = new ArrayList();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
- */
- public void dispose() {
- deregisterActionHandlers();
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#initialize(org.eclipse.cdt.core.model.ICProject, org.eclipse.cdt.core.model.IPathEntry[])
- */
- public void initialize(ICProject project, IPathEntry[] currentEntries) {
- fCProject = project;
- try {
- info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fCProject.getProject());
- } catch (CoreException e) {
- setErrorMessage(MakeUIPlugin.getResourceString(CONTAINER_INITIALIZATION_ERROR));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#finish()
- */
- public boolean finish() {
- if (!dirty) {
- return true;
- }
- // first process deletes
- if (deletedEntries.size() > 0) {
- IProject project = fCProject.getProject();
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID); // use selected profile for the project
- IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
- if (collector instanceof IScannerInfoCollectorCleaner) {
- IScannerInfoCollectorCleaner collectorUtil = (IScannerInfoCollectorCleaner) collector;
- boolean exitLoop = false;
- for (Iterator i = deletedEntries.iterator(); i.hasNext() && !exitLoop; ) {
- DiscoveredElement elem = (DiscoveredElement) i.next();
- switch (elem.getEntryKind()) {
- case DiscoveredElement.CONTAINER:
- collectorUtil.deleteAll(project);
- exitLoop = true;
- break;
- case DiscoveredElement.PATHS_GROUP:
- collectorUtil.deleteAllPaths(project);
- break;
- case DiscoveredElement.SYMBOLS_GROUP:
- collectorUtil.deleteAllSymbols(project);
- break;
- case DiscoveredElement.INCLUDE_PATH:
- collectorUtil.deletePath(project, elem.getEntry());
- break;
- case DiscoveredElement.SYMBOL_DEFINITION:
- collectorUtil.deleteSymbol(project, elem.getEntry());
- break;
- }
- }
- }
- }
-
- if (info instanceof IPerProjectDiscoveredPathInfo) {
- IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) info;
-
- LinkedHashMap includes = new LinkedHashMap();
- LinkedHashMap symbols = new LinkedHashMap();
-
- DiscoveredElement container = (DiscoveredElement) fDiscoveredContainerList.getElement(0);
- if (container != null && container.getEntryKind() == DiscoveredElement.CONTAINER) {
- Object[] cChildren = container.getChildren();
- if (cChildren != null) {
- for (int i = 0; i < cChildren.length; ++i) {
- DiscoveredElement group = (DiscoveredElement) cChildren[i];
- switch (group.getEntryKind()) {
- case DiscoveredElement.PATHS_GROUP: {
- // get the include paths
- Object[] gChildren = group.getChildren();
- if (gChildren != null) {
- for (int j = 0; j < gChildren.length; ++j) {
- DiscoveredElement include = (DiscoveredElement) gChildren[j];
- includes.put(include.getEntry(), Boolean.valueOf(include.isRemoved()));
- }
- }
- }
- break;
- case DiscoveredElement.SYMBOLS_GROUP: {
- // get the symbol definitions
- Object[] gChildren = group.getChildren();
- if (gChildren != null) {
- for (int j = 0; j < gChildren.length; ++j) {
- DiscoveredElement symbol = (DiscoveredElement) gChildren[j];
- ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol.getEntry(), !symbol.isRemoved());
- }
- }
- }
- break;
- }
- }
- }
- }
- projectPathInfo.setIncludeMap(includes);
- projectPathInfo.setSymbolMap(symbols);
- }
-
- try {
- // update scanner configuration
- List resourceDelta = new ArrayList(1);
- resourceDelta.add(fCProject.getProject());
- MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(info, resourceDelta);
- return true;
- } catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#getContainerEntries()
- */
- public IContainerEntry[] getNewContainers() {
- return new IContainerEntry[] { fPathEntry };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#setSelection(org.eclipse.cdt.core.model.IPathEntry)
- */
- public void setSelection(IContainerEntry containerEntry) {
- if (containerEntry != null) {
- fPathEntry = containerEntry;
- }
- else {
- fPathEntry = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
- }
- if (fPathEntry != null) {
- DiscoveredElement element = populateDiscoveredElements(fPathEntry);
- ArrayList elements = new ArrayList();
- elements.add(element);
- fDiscoveredContainerList.addElements(elements);
- }
- }
-
- /**
- * @param pathEntry
- * @return
- */
- private DiscoveredElement populateDiscoveredElements(IContainerEntry pathEntry) {
- DiscoveredElement container = null;
- try {
- container = DiscoveredElement.createNew(null, fCProject.getProject(), null,
- DiscoveredElement.CONTAINER, false, false);
- IPathEntryContainer peContainer = CoreModel.getPathEntryContainer(pathEntry.getPath(), fCProject);
- if (peContainer != null) {
- container.setEntry(peContainer.getDescription());
- }
- if (info != null) {
- if (info instanceof IPerProjectDiscoveredPathInfo) {
- IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) info;
- // get include paths
- LinkedHashMap paths = projectPathInfo.getIncludeMap();
- for (Iterator i = paths.keySet().iterator(); i.hasNext(); ) {
- String include = (String) i.next();
- Boolean removed = (Boolean) paths.get(include);
- removed = (removed == null) ? Boolean.FALSE : removed;
- DiscoveredElement.createNew(container, fCProject.getProject(), include,
- DiscoveredElement.INCLUDE_PATH, removed.booleanValue(), false);
- }
- // get defined symbols
- LinkedHashMap symbols = projectPathInfo.getSymbolMap();
- for (Iterator i = symbols.keySet().iterator(); i.hasNext(); ) {
- String symbol = (String) i.next();
- SymbolEntry se = (SymbolEntry) symbols.get(symbol);
- for (Iterator j = se.getActiveRaw().iterator(); j.hasNext();) {
- String value = (String) j.next();
- DiscoveredElement.createNew(container, fCProject.getProject(), value,
- DiscoveredElement.SYMBOL_DEFINITION, false, false);
- }
- for (Iterator j = se.getRemovedRaw().iterator(); j.hasNext();) {
- String value = (String) j.next();
- DiscoveredElement.createNew(container, fCProject.getProject(), value,
- DiscoveredElement.SYMBOL_DEFINITION, true, false);
- }
- }
- }
- else if (info instanceof IPerFileDiscoveredPathInfo) {
- IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
- // get include paths
- IPath[] includes = filePathInfo.getIncludePaths();
- for (int i = 0; i < includes.length; i++) {
- String include = includes[i].toPortableString();
- DiscoveredElement.createNew(container, fCProject.getProject(), include,
- DiscoveredElement.INCLUDE_PATH, false, false);
- }
- // get defined symbols
- Map symbols = filePathInfo.getSymbols();
- for (Iterator iter = symbols.keySet().iterator(); iter.hasNext();) {
- String key = (String) iter.next();
- String value = (String) symbols.get(key);
- String symbol = (value != null && value.length() > 0) ? key + "=" + value : key; //$NON-NLS-1$
- DiscoveredElement.createNew(container, fCProject.getProject(), symbol,
- DiscoveredElement.SYMBOL_DEFINITION, false, false);
- }
- // get include files
- IPath[] includeFiles = filePathInfo.getIncludeFiles(fCProject.getPath());
- for (int i = 0; i < includeFiles.length; i++) {
- String includeFile = includeFiles[i].toPortableString();
- DiscoveredElement.createNew(container, fCProject.getProject(), includeFile,
- DiscoveredElement.INCLUDE_FILE, false, false);
- }
- // get macros files
- IPath[] macrosFiles = filePathInfo.getMacroFiles(fCProject.getPath());
- for (int i = 0; i < macrosFiles.length; i++) {
- String macrosFile = macrosFiles[i].toPortableString();
- DiscoveredElement.createNew(container, fCProject.getProject(), macrosFile,
- DiscoveredElement.MACROS_FILE, false, false);
- }
- }
- }
- } catch (CModelException e) {
- MakeUIPlugin.log(e.getStatus());
- }
- return container;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- PixelConverter converter = new PixelConverter(parent);
-
- Composite composite = new Composite(parent, SWT.NONE);
-
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fDiscoveredContainerList}, true);
- LayoutUtil.setHorizontalGrabbing(fDiscoveredContainerList.getTreeControl(null));
-
- int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
- fDiscoveredContainerList.setButtonsMinWidth(buttonBarWidth);
-
- fDiscoveredContainerList.getTreeViewer().addFilter(new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof DiscoveredElement) {
- DiscoveredElement elem = (DiscoveredElement) element;
- switch (elem.getEntryKind()) {
- case DiscoveredElement.PATHS_GROUP:
- case DiscoveredElement.SYMBOLS_GROUP:
- case DiscoveredElement.INCLUDE_FILE_GROUP:
- case DiscoveredElement.MACROS_FILE_GROUP:
- return elem.getChildren().length != 0;
- }
- }
- return true;
- }
- });
-
- setControl(composite);
-
- fDiscoveredContainerList.selectFirstElement();
-
- // Create copy text action
- Shell shell = fDiscoveredContainerList.getTreeViewer().getControl().getShell();
- copyTextAction = new CopyTextAction(shell);
- hookContextMenu();
- registerActionHandler(shell, copyTextAction);
- }
-
- private void hookContextMenu() {
- MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
-// if (copyTextAction.canBeApplied(fDiscoveredContainerList.getSelectedElements())) {
- manager.add(copyTextAction);
-// }
- }
- });
- Menu menu = menuMgr.createContextMenu(fDiscoveredContainerList.getTreeViewer().getControl());
- fDiscoveredContainerList.getTreeViewer().getControl().setMenu(menu);
- }
-
- private void registerActionHandler(Shell shell, IAction action) {
- IWorkbench workbench = PlatformUI.getWorkbench();
-
- IWorkbenchContextSupport contextSupport = workbench.getContextSupport();
- IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
-
- submission = new HandlerSubmission(null, shell, null,
- CopyTextAction.ACTION_ID, new ActionHandler(action), Priority.MEDIUM);
- commandSupport.addHandlerSubmission(submission);
- contextSupport.registerShell(shell, IWorkbenchContextSupport.TYPE_DIALOG);
- }
-
- private void deregisterActionHandlers() {
- IWorkbench workbench = PlatformUI.getWorkbench();
-
- IWorkbenchContextSupport contextSupport = workbench.getContextSupport();
- IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
-
- commandSupport.removeHandlerSubmission(submission);
- contextSupport.unregisterShell(fDiscoveredContainerList.getTreeViewer().getControl().getShell());
- }
-
- /**
- * @author vhirsl
- */
- private class DiscoveredContainerAdapter implements IDialogFieldListener, ITreeListAdapter {
- private final Object[] EMPTY_ARR = new Object[0];
-
- // ---------- IDialogFieldListener --------
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField)
- */
- public void dialogFieldChanged(DialogField field) {
- // TODO Auto-generated method stub
-
- }
-
- // -------- IListAdapter --------
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#customButtonPressed(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, int)
- */
- public void customButtonPressed(TreeListDialogField field, int index) {
- containerPageCustomButtonPressed(field, index);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#selectionChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField)
- */
- public void selectionChanged(TreeListDialogField field) {
- if (copyTextAction != null) {
- copyTextAction.canBeApplied(field.getSelectedElements());
- }
- containerPageSelectionChanged(field);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#doubleClicked(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField)
- */
- public void doubleClicked(TreeListDialogField field) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#keyPressed(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, org.eclipse.swt.events.KeyEvent)
- */
- public void keyPressed(TreeListDialogField field, KeyEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#getChildren(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, java.lang.Object)
- */
- public Object[] getChildren(TreeListDialogField field, Object element) {
- if (element instanceof DiscoveredElement) {
- DiscoveredElement elem = (DiscoveredElement) element;
- return elem.getChildren();
- }
- return EMPTY_ARR;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#getParent(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, java.lang.Object)
- */
- public Object getParent(TreeListDialogField field, Object element) {
- if (element instanceof DiscoveredElement) {
- DiscoveredElement elem = (DiscoveredElement) element;
- return elem.getParent();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#hasChildren(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, java.lang.Object)
- */
- public boolean hasChildren(TreeListDialogField field, Object element) {
- if (element instanceof DiscoveredElement) {
- DiscoveredElement elem = (DiscoveredElement) element;
- return elem.hasChildren();
- }
- return false;
- }
- }
-
- /**
- * @param field
- * @param index
- */
- private void containerPageCustomButtonPressed(TreeListDialogField field, int index) {
- switch (index) {
- case IDX_UP:
- /* move entry up */
- dirty |= moveUp();
- break;
- case IDX_DOWN:
- /* move entry down */
- dirty |= moveDown();
- break;
- case IDX_DISABLE:
- /* remove */
- dirty |= enableDisableEntry(DO_DISABLE);
- break;
- case IDX_ENABLE:
- /* restore */
- dirty |= enableDisableEntry(DO_ENABLE);
- break;
- case IDX_DELETE:
- /* delete */
- dirty |= deleteEntry();
- break;
- }
- if (dirty) {
- fDiscoveredContainerList.refresh();
- fDiscoveredContainerList.setFocus();
- }
- }
-
- private boolean moveUp() {
- boolean rc = false;
- List selElements = fDiscoveredContainerList.getSelectedElements();
- for (Iterator i = selElements.iterator(); i.hasNext(); ) {
- DiscoveredElement elem = (DiscoveredElement) i.next();
- DiscoveredElement parent = elem.getParent();
- Object[] children = parent.getChildren();
- for (int j = 0; j < children.length; ++j) {
- DiscoveredElement child = (DiscoveredElement) children[j];
- if (elem.equals(child)) {
- int prevIndex = j - 1;
- if (prevIndex >= 0) {
- // swap the two
- children[j] = children[prevIndex];
- children[prevIndex] = elem;
- rc = true;
- break;
- }
- }
- }
- parent.setChildren(children);
- }
- fDiscoveredContainerList.postSetSelection(new StructuredSelection(selElements));
- return rc;
- }
-
- private boolean moveDown() {
- boolean rc = false;
- List selElements = fDiscoveredContainerList.getSelectedElements();
- List revSelElements = new ArrayList(selElements);
- Collections.reverse(revSelElements);
- for (Iterator i = revSelElements.iterator(); i.hasNext(); ) {
- DiscoveredElement elem = (DiscoveredElement) i.next();
- DiscoveredElement parent = elem.getParent();
- Object[] children = parent.getChildren();
- for (int j = children.length - 1; j >= 0; --j) {
- DiscoveredElement child = (DiscoveredElement) children[j];
- if (elem.equals(child)) {
- int prevIndex = j + 1;
- if (prevIndex < children.length) {
- // swap the two
- children[j] = children[prevIndex];
- children[prevIndex] = elem;
- rc = true;
- break;
- }
- }
- }
- parent.setChildren(children);
- }
- fDiscoveredContainerList.postSetSelection(new StructuredSelection(selElements));
- return rc;
- }
-
- /**
- * @param action
- * @return
- */
- private boolean enableDisableEntry(int action) {
- boolean rc = false;
- boolean remove = (action == DO_DISABLE);
- List selElements = fDiscoveredContainerList.getSelectedElements();
- for (int i = selElements.size() - 1; i >= 0; --i) {
- DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
- switch (elem.getEntryKind()) {
- case DiscoveredElement.INCLUDE_PATH:
- case DiscoveredElement.SYMBOL_DEFINITION:
- elem.setRemoved(remove);
- rc = true;
- }
- }
- return rc;
- }
-
- private boolean deleteEntry() {
- boolean rc = false;
- List newSelection = new ArrayList();
- List selElements = fDiscoveredContainerList.getSelectedElements();
- boolean skipIncludes = false, skipSymbols = false;
- for (int i = 0; i < selElements.size(); ++i) {
- DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
- if (elem.getEntryKind() == DiscoveredElement.CONTAINER) {
- deletedEntries.add(elem);
-
- Object[] children = elem.getChildren();
- for (int j = 0; j < children.length; j++) {
- if (children[j] instanceof DiscoveredElement) {
- DiscoveredElement child = (DiscoveredElement) children[j];
- child.delete();
- }
- }
- newSelection.add(elem);
- rc = true;
- break;
- }
- DiscoveredElement parent = elem.getParent();
- if (parent != null) {
- Object[] children = parent.getChildren();
- if (elem.delete()) {
- switch (elem.getEntryKind()) {
- case DiscoveredElement.PATHS_GROUP:
- deletedEntries.add(elem);
- skipIncludes = true;
- break;
- case DiscoveredElement.SYMBOLS_GROUP:
- deletedEntries.add(elem);
- skipSymbols = true;
- break;
- case DiscoveredElement.INCLUDE_PATH:
- if (!skipIncludes) {
- deletedEntries.add(elem);
- }
- break;
- case DiscoveredElement.SYMBOL_DEFINITION:
- if (!skipSymbols) {
- deletedEntries.add(elem);
- }
- break;
- }
-
- rc = true;
- // set new selection
- for (int j = 0; j < children.length; ++j) {
- DiscoveredElement child = (DiscoveredElement) children[j];
- if (elem.equals(child)) {
- newSelection.clear();
- if (j + 1 < children.length) {
- newSelection.add(children[j + 1]);
- }
- else if (j - 1 >= 0) {
- newSelection.add(children[j - 1]);
- }
- else {
- newSelection.add(parent);
- }
- break;
- }
- }
- }
- }
- }
- fDiscoveredContainerList.postSetSelection(new StructuredSelection(newSelection));
- return rc;
- }
-
- /**
- * @param field
- */
- private void containerPageSelectionChanged(TreeListDialogField field) {
- List selElements = field.getSelectedElements();
- fDiscoveredContainerList.enableButton(IDX_UP, canMoveUpDown(selElements, DISC_UP));
- fDiscoveredContainerList.enableButton(IDX_DOWN, canMoveUpDown(selElements, DISC_DOWN));
- fDiscoveredContainerList.enableButton(IDX_DISABLE, canRemoveRestore(selElements));
- fDiscoveredContainerList.enableButton(IDX_ENABLE, canRemoveRestore(selElements));
- fDiscoveredContainerList.enableButton(IDX_DELETE, canDelete(selElements));
- }
-
- /**
- * @param selElements
- * @param direction
- * @return
- */
- private boolean canMoveUpDown(List selElements, int direction) {
- if (info instanceof IPerFileDiscoveredPathInfo) {
- return false;
- }
- if (selElements.size() == 0) {
- return false;
- }
- for (int i = 0; i < selElements.size(); i++) {
- DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
- switch (elem.getEntryKind()) {
- case DiscoveredElement.CONTAINER:
- case DiscoveredElement.PATHS_GROUP:
- case DiscoveredElement.SYMBOLS_GROUP:
- case DiscoveredElement.SYMBOL_DEFINITION:
- return false;
- }
- DiscoveredElement parent = elem.getParent();
- DiscoveredElement borderElem = null;
- int borderElementIndex = (direction == DISC_UP) ? 0 : parent.getChildren().length - 1;
- if (parent.getEntryKind() == DiscoveredElement.PATHS_GROUP) {
- borderElem = (DiscoveredElement)(parent.getChildren())[borderElementIndex];
- }
- if (borderElem != null) {
- if (borderElem.equals(elem)) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * @param selElements
- * @return
- */
- private boolean canRemoveRestore(List selElements) {
- if (info instanceof IPerFileDiscoveredPathInfo) {
- return false;
- }
- if (selElements.size() == 0) {
- return false;
- }
- for (int i = 0; i < selElements.size(); i++) {
- DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
- switch (elem.getEntryKind()) {
- case DiscoveredElement.CONTAINER:
- case DiscoveredElement.PATHS_GROUP:
- case DiscoveredElement.SYMBOLS_GROUP:
- return false;
- }
- }
- return true;
- }
-
- /**
- * @param selElements
- * @return
- */
- private boolean canDelete(List selElements) {
- if (info instanceof IPerFileDiscoveredPathInfo) {
- if (selElements.size() > 0 &&
- ((DiscoveredElement) selElements.get(0)).getEntryKind() == DiscoveredElement.CONTAINER) {
- return true;
- }
- return false;
- }
- if (selElements.size() == 0) {
- return false;
- }
- return true;
- }
-
- /**
- * Support for text copy/paste
- *
- * @author vhirsl
- */
- public class CopyTextAction extends Action {
- static final String ACTION_ID = "org.eclipse.ui.edit.copy"; //$NON-NLS-1$
- private Clipboard clipboard;
- private String discoveredEntry = null;
-
- public CopyTextAction(Shell shell) {
- super(MakeUIPlugin.getResourceString("CopyDiscoveredPathAction.title")); //$NON-NLS-1$
- setDescription(MakeUIPlugin.getResourceString("CopyDiscoveredPathAction.description")); //$NON-NLS-1$
- setToolTipText(MakeUIPlugin.getResourceString("CopyDiscoveredPathAction.tooltip")); //$NON-NLS-1$
- setActionDefinitionId(ACTION_ID);
- clipboard = new Clipboard(shell.getDisplay());
- }
-
- /**
- * @param selectedElements
- * @return
- */
- boolean canBeApplied(List selElements) {
- boolean rc = false;
- if (selElements != null && selElements.size() == 1) {
- DiscoveredElement elem = (DiscoveredElement) selElements.get(0);
- switch (elem.getEntryKind()) {
- case DiscoveredElement.INCLUDE_PATH:
- case DiscoveredElement.SYMBOL_DEFINITION:
- discoveredEntry = elem.getEntry();
- rc = true;
- }
- }
- setEnabled(rc);
- return rc;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- if (discoveredEntry != null) {
- // copy to clipboard
- clipboard.setContents(new Object[] {discoveredEntry},
- new Transfer[] {TextTransfer.getInstance()});
- discoveredEntry = null;
- }
- }
- }
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
deleted file mode 100644
index f3c1a404669..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.MakeProjectNature;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.internal.ui.preferences.TabFolderLayout;
-import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-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.Group;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * A dialog to set scanner config discovery options.
- *
- * @author vhirsl
- * @since 3.0
- */
-public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
- private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
-
- private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
- private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
- private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
- private static final String SC_ENABLED_BUTTON = PREFIX + ".scGroup.enabled.button"; //$NON-NLS-1$
- private static final String SC_PROBLEM_REPORTING_ENABLED_BUTTON = PREFIX + ".scGroup.problemReporting.enabled.button"; //$NON-NLS-1$
- private static final String SC_SELECTED_PROFILE_COMBO = PREFIX + ".scGroup.selectedProfile.combo"; //$NON-NLS-1$
- private static final String BO_PROVIDER_GROUP_LABEL = PREFIX + ".boProvider.group.label"; //$NON-NLS-1$
- private static final String SC_APPLY_PROGRESS_MESSAGE = PREFIX + ".apply.progressMessage"; //$NON-NLS-1$
-
- private Button scEnabledButton;
- private Button scProblemReportingEnabledButton;
- private Combo profileComboBox;
- private Composite profileComp;
-
- private boolean needsSCNature = false;
- private boolean fCreatePathContainer = false;
- private boolean isValid = true;
- private boolean persistedProfileChanged = false; // new persisted selected profile different than the old one
-
- /**
- *
- */
- public DiscoveryOptionsBlock() {
- super(MakeUIPlugin.getResourceString(DIALOG_TITLE));
- setDescription(MakeUIPlugin.getResourceString(DIALOG_DESCRIPTION));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
- */
- public void setContainer(ICOptionContainer container) {
- super.setContainer(container);
- if (container.getProject() == null) {
- fCreatePathContainer = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- // Create the composite control for the tab
- int tabColumns = 2;
- Font font = parent.getFont();
- Composite composite = ControlFactory.createComposite(parent, 1);
- ((GridLayout)composite.getLayout()).marginHeight = 0;
- ((GridLayout)composite.getLayout()).marginWidth = 0;
- ((GridLayout)composite.getLayout()).verticalSpacing = 0;
- ((GridData)composite.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
- composite.setFont(font);
- setControl(composite);
-
- MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS);
-
- // create a composite for general scanner config discovery options
- Composite scComp = ControlFactory.createComposite(composite, 1);
- ((GridLayout)scComp.getLayout()).marginHeight = 0;
- ((GridLayout)scComp.getLayout()).marginTop = 5;
- scComp.setFont(font);
-
- // Create a group for scanner config discovery
- if (createScannerConfigControls(scComp, tabColumns)) {
- // create a composite for discovery profile options
- profileComp = new Composite(composite, SWT.NULL);
- // ((GridLayout)profileComp.getLayout()).marginHeight = 5;
- // ((GridLayout)profileComp.getLayout()).marginWidth = 5;
- // ((GridLayout)profileComp.getLayout()).verticalSpacing = 5;
- profileComp.setFont(font);
- profileComp.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
- profileComp.setLayout(new TabFolderLayout());
-
- // Must set the composite parent to super class.
- setCompositeParent(profileComp);
- // fire a change event, to quick start.
- handleDiscoveryProfileChanged();
- // enable controls depending on the state of auto discovery
- enableAllControls();
- }
- parent.layout(true);
- }
-
- private boolean createScannerConfigControls(Composite parent, int numColumns) {
- // Check if it is an old project
- IProject project = getContainer().getProject();
- boolean showMissingBuilder = false;
- try {
- if (project != null && project.hasNature(MakeProjectNature.NATURE_ID)
- && !project.hasNature(ScannerConfigNature.NATURE_ID)) {
- needsSCNature = true; // legacy project
- }
- } catch (CoreException e) {
- showMissingBuilder = true;
- }
-
- if (showMissingBuilder || (!needsSCNature && !isInitialized())) {
- ControlFactory.createEmptySpace(parent);
- ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
- return false;
- }
-
- Group scGroup = ControlFactory.createGroup(parent,
- MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
- scGroup.setFont(parent.getFont());
- ((GridData)scGroup.getLayoutData()).grabExcessHorizontalSpace = true;
- ((GridData)scGroup.getLayoutData()).horizontalSpan = numColumns;
- ((GridData)scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
-
- // Add main SCD checkbox
- scEnabledButton = ControlFactory.createCheckBox(scGroup,
- MakeUIPlugin.getResourceString(SC_ENABLED_BUTTON));
- scEnabledButton.setFont(parent.getFont());
- ((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns;
- ((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
- // VMIR* old projects will have discovery disabled by default
- scEnabledButton.setSelection(needsSCNature ? false : getBuildInfo().isAutoDiscoveryEnabled());
- scEnabledButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- enableAllControls();
- }
- });
- // handleScannerConfigEnable(); Only if true in VMIR*
-
- // Add problem reporting checkbox
- scProblemReportingEnabledButton = ControlFactory.createCheckBox(scGroup,
- MakeUIPlugin.getResourceString(SC_PROBLEM_REPORTING_ENABLED_BUTTON));
- scProblemReportingEnabledButton.setFont(parent.getFont());
- ((GridData)scProblemReportingEnabledButton.getLayoutData()).horizontalSpan = numColumns;
- ((GridData)scProblemReportingEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
- scProblemReportingEnabledButton.setSelection(getBuildInfo().isProblemReportingEnabled());
-
- // Add profile combo box
- Label label = ControlFactory.createLabel(scGroup,
- MakeUIPlugin.getResourceString(SC_SELECTED_PROFILE_COMBO));
- ((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
-
- profileComboBox = new Combo(scGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
- profileComboBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- getBuildInfo().setSelectedProfileId(getCurrentProfileId());
- handleDiscoveryProfileChanged();
- }
- });
- // fill the combobox and set the initial value
- for (Iterator items = getDiscoveryProfileIdList().iterator(); items.hasNext();) {
- String profileId = (String)items.next();
- String pageName = getDiscoveryProfileName(profileId);
- if (pageName != null) {
- profileComboBox.add(pageName);
- if (profileId.equals(getBuildInfo().getSelectedProfileId())) {
- profileComboBox.setText(pageName);
- }
- }
- }
- profileComboBox.setEnabled(scEnabledButton.getSelection());
-
- return true;
- }
-
- /**
- *
- */
- private void enableAllControls() {
- boolean isSCDEnabled = scEnabledButton.getSelection();
- scProblemReportingEnabledButton.setEnabled(isSCDEnabled);
- profileComboBox.setEnabled(isSCDEnabled);
- profileComp.setVisible(isSCDEnabled);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- if (!visible) {
- if (!checkDialogForChanges()) {
- createBuildInfo();
- restoreFromBuildinfo(getBuildInfo());
- enableAllControls();
- handleDiscoveryProfileChanged();
-
- getCurrentPage().performDefaults();
- }
- }
- super.setVisible(visible);
- enableAllControls();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryOptionsBlock#getCurrentProfileId()
- */
- protected String getCurrentProfileId() {
- String selectedProfileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
- String selectedProfileId = getDiscoveryProfileId(selectedProfileName);
- return selectedProfileId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
-
- // init buildInfo
- final IProject project = getContainer().getProject();
- // Create new build info in case of new C++ project wizard
- createBuildInfo();
-
- if (getBuildInfo() != null) {
- populateBuildInfo(getBuildInfo());
- monitor.worked(1);
-
- if (scEnabledButton.getSelection()) {
- getCurrentPage().performApply();
- }
- monitor.worked(1);
-
- if (project != null) {
- configureProject(project, monitor);
- }
- getBuildInfo().save();
- if (isProfileDifferentThenPersisted()) {
- if (project != null) {
- changeDiscoveryContainer(project);
- }
- updatePersistedProfile();
- }
- }
- monitor.done();
- }
-
- private void configureProject(IProject project, IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
-
- if (needsSCNature) {
- ScannerConfigNature.addScannerConfigNature(project);
- needsSCNature = false;
- fCreatePathContainer = true;
- }
- if (fCreatePathContainer) {
- createDiscoveredPathContainer(project, monitor);
- fCreatePathContainer = false;
- }
- }
-
- /**
- * @param project
- * @param monitor
- * @throws CModelException
- */
- private void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) throws CModelException {
- IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
- ICProject cProject = CoreModel.getDefault().create(project);
- if (cProject != null) {
- IPathEntry[] entries = cProject.getRawPathEntries();
- List newEntries = new ArrayList(Arrays.asList(entries));
- if (!newEntries.contains(container)) {
- newEntries.add(container);
- cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), monitor);
- }
- }
- // create a new discovered scanner config store
- MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
- }
-
- /**
- * @param project
- */
- private void changeDiscoveryContainer(IProject project) {
- String profileId = getBuildInfo().getSelectedProfileId();
- ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId).getProfileScope();
- List changedResources = new ArrayList();
-// changedResources.add(project.getFullPath());
- changedResources.add(project);
- MakeCorePlugin.getDefault().getDiscoveryManager().changeDiscoveredContainer(
- project, profileScope, changedResources);
- }
-
- private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
- if (buildInfo != null) {
- buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
- String profileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
- buildInfo.setSelectedProfileId(getDiscoveryProfileId(profileName));
- buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
-
- public void performDefaults() {
- if (!isInitialized() && !needsSCNature) {
- // Missing builder info on a non-legacy project
- return;
- }
- createDefaultBuildInfo();
-
- restoreFromBuildinfo(getBuildInfo());
- enableAllControls();
-
- getCurrentPage().performDefaults();
-
- handleDiscoveryProfileChanged();
- }
-
- private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
- if (buildInfo != null) {
- scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
- String profileId = buildInfo.getSelectedProfileId();
- profileComboBox.setText(getDiscoveryProfileName(profileId));
- scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java
deleted file mode 100644
index 58d565d1975..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
-
-import java.io.File;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.BuildOutputReaderJob;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * SCD per project profile property/preference page
- *
- * @author vhirsl
- */
-public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
- private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
- private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
- private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
- private static final String BO_PROVIDER_OPEN_FILE_DIALOG = PREFIX + ".boProvider.browse.openFileDialog"; //$NON-NLS-1$
- private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
- private static final String SI_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".siProvider.parser.enabled.button"; //$NON-NLS-1$
- private static final String SI_PROVIDER_COMMAND_LABEL = PREFIX + ".siProvider.command.label"; //$NON-NLS-1$
- private static final String SI_PROVIDER_BROWSE_BUTTON = PREFIX + ".siProvider.browse.button"; //$NON-NLS-1$
- private static final String SI_PROVIDER_COMMAND_DIALOG = PREFIX + ".siProvider.browse.runCommandDialog"; //$NON-NLS-1$
- private static final String SI_PROVIDER_COMMAND_ERROR_MESSAGE= PREFIX + ".siProvider.command.errorMessage"; //$NON-NLS-1$
-
- private static final String providerId = "specsFile"; //$NON-NLS-1$
-
- // thread syncronization
- //private static ILock lock = Platform.getJobManager().newLock();
-// private static Object lock = new Object();
- private static Object lock = GCCPerProjectSCDProfilePage.class;
- private Shell shell;
- private static GCCPerProjectSCDProfilePage instance;
- private static boolean loadButtonInitialEnabled = true;
-
- private Button bopEnabledButton;
- private Text bopOpenFileText;
- private Button bopLoadButton;
- private Button sipEnabledButton;
- private Text sipRunCommandText;
-
- private boolean isValid = true;
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite page = ControlFactory.createComposite(parent, 1);
-// ((GridData) page.getLayoutData()).grabExcessVerticalSpace = true;
-// ((GridData) page.getLayoutData()).verticalAlignment = GridData.FILL;
-
- // Add the profile UI contribution.
- Group profileGroup = ControlFactory.createGroup(page,
- MakeUIPlugin.getResourceString(PROFILE_GROUP_LABEL), 3);
-
- GridData gd = (GridData) profileGroup.getLayoutData();
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
-// PixelConverter converter = new PixelConverter(parent);
-// gd.heightHint = converter.convertVerticalDLUsToPixels(DEFAULT_HEIGHT);
- ((GridLayout) profileGroup.getLayout()).makeColumnsEqualWidth = false;
-
- // Add bop enabled checkbox
- bopEnabledButton = ControlFactory.createCheckBox(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_PARSER_ENABLED_BUTTON));
-// bopEnabledButton.setFont(parent.getFont());
- ((GridData)bopEnabledButton.getLayoutData()).horizontalSpan = 3;
- ((GridData)bopEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
- bopEnabledButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- handleModifyOpenFileText();
- }
-
- });
-
- // load label
- Label loadLabel = ControlFactory.createLabel(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
- ((GridData) loadLabel.getLayoutData()).horizontalSpan = 2;
-
- // load button
- bopLoadButton = ControlFactory.createPushButton(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
- ((GridData) bopLoadButton.getLayoutData()).widthHint =
- SWTUtil.getButtonWidthHint(bopLoadButton);
- bopLoadButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- handleBOPLoadFileButtonSelected();
- }
-
- });
- if (getContainer().getProject() == null) { // project properties
- bopLoadButton.setVisible(false);
- }
-
- // text field
- bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
- bopOpenFileText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleModifyOpenFileText();
- }
- });
- bopLoadButton.setEnabled(loadButtonInitialEnabled && handleModifyOpenFileText());
-
- // browse button
- Button browseButton = ControlFactory.createPushButton(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_BROWSE_BUTTON));
- ((GridData) browseButton.getLayoutData()).widthHint =
- SWTUtil.getButtonWidthHint(browseButton);
- browseButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- handleBOPBrowseButtonSelected();
- }
-
- private void handleBOPBrowseButtonSelected() {
- FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
- dialog.setText(MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_FILE_DIALOG)); //$NON-NLS-1$
- String fileName = getBopOpenFileText();
- IPath filterPath;
- if (fileName.length() == 0 && getContainer().getProject() != null) {
- filterPath = getContainer().getProject().getLocation();
- }
- else {
- IPath filePath = new Path(fileName);
- filterPath = filePath.removeLastSegments(1).makeAbsolute();
- }
- dialog.setFilterPath(filterPath.toOSString());
- String res = dialog.open();
- if (res == null) {
- return;
- }
- setBopOpenFileText(res);
- }
- });
-
- // variable button
- addVariablesButton(profileGroup, bopOpenFileText);
-
- ControlFactory.createSeparator(profileGroup, 3);
-
- // si provider enabled checkbox
- sipEnabledButton = ControlFactory.createCheckBox(profileGroup,
- MakeUIPlugin.getResourceString(SI_PROVIDER_PARSER_ENABLED_BUTTON));
-// sipEnabledButton.setFont(parent.getFont());
- ((GridData)sipEnabledButton.getLayoutData()).horizontalSpan = 3;
- ((GridData)sipEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
- sipEnabledButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
-// bopLoadButton.setEnabled(sipEnabledButton.getSelection());
- }
-
- });
-
- // si command label
- Label siCommandLabel = ControlFactory.createLabel(profileGroup,
- MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_LABEL));
- ((GridData) siCommandLabel.getLayoutData()).horizontalSpan = 3;
-
- // text field
- sipRunCommandText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
- //((GridData) sipRunCommandText.getLayoutData()).horizontalSpan = 2;
- sipRunCommandText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleModifyRunCommandText();
- }
- });
-
- // si browse button
- Button siBrowseButton = ControlFactory.createPushButton(profileGroup,
- MakeUIPlugin.getResourceString(SI_PROVIDER_BROWSE_BUTTON));
- ((GridData) siBrowseButton.getLayoutData()).widthHint =
- SWTUtil.getButtonWidthHint(browseButton);
- siBrowseButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent event) {
- handleSIPBrowseButtonSelected();
- }
-
- private void handleSIPBrowseButtonSelected() {
- FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
- dialog.setText(MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_DIALOG)); //$NON-NLS-1$
- String fileName = sipRunCommandText.getText().trim();
- int lastSeparatorIndex = fileName.lastIndexOf(File.separator);
- if (lastSeparatorIndex != -1) {
- dialog.setFilterPath(fileName.substring(0, lastSeparatorIndex));
- }
- String res = dialog.open();
- if (res == null) {
- return;
- }
- sipRunCommandText.setText(res);
- }
- });
-
- setControl(page);
- // set the shell variable; must be after setControl
- //lock.acquire();
- synchronized (lock) {
- shell = getShell();
- instance = this;
- }
- //lock.release();
- initializeValues();
- }
-
- protected boolean handleModifyOpenFileText() {
- String fileName = getBopOpenFileText();
- bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
- fileName.length() > 0 &&
- new File(fileName).exists());
- return bopLoadButton.getEnabled();
- }
-
- protected void handleModifyRunCommandText() {
- String cmd = sipRunCommandText.getText().trim();
- isValid = (cmd.length() > 0) ? true : false;
-
- getContainer().updateContainer();
- }
-
- private String getBopOpenFileText() {
- // from project relative path to absolute path
- String fileName = bopOpenFileText.getText().trim();
- if (fileName.length() > 0) {
- IPath filePath = new Path(fileName);
- if (!filePath.isAbsolute()) {
- if (getContainer().getProject() != null) {
- IPath projectPath = getContainer().getProject().getLocation();
- filePath = projectPath.append(filePath);
- fileName = filePath.toString();
- }
- }
- }
- return fileName;
- }
-
- private void setBopOpenFileText(String fileName) {
- // from absolute path to project relative path
- if (fileName.length() > 0) {
- IPath filePath = new Path(fileName);
- if (filePath.isAbsolute()) {
- if (getContainer().getProject() != null) {
- IPath projectPath = getContainer().getProject().getLocation();
- if (projectPath.isPrefixOf(filePath)) {
- filePath = filePath.removeFirstSegments(projectPath.segmentCount());
- filePath = filePath.setDevice(null);
- fileName = filePath.toString();
- }
- }
- }
- }
- bopOpenFileText.setText(fileName);
- }
-
- private void initializeValues() {
- bopEnabledButton.setSelection(getContainer().getBuildInfo().isBuildOutputParserEnabled());
- setBopOpenFileText(getContainer().getBuildInfo().getBuildOutputFilePath());
- sipEnabledButton.setSelection(getContainer().getBuildInfo().isProviderOutputParserEnabled(providerId));
- sipRunCommandText.setText(getContainer().getBuildInfo().getProviderRunCommand(providerId));
- }
-
- private void handleBOPLoadFileButtonSelected() {
- if (!getContainer().checkDialogForChanges()) return;
- loadButtonInitialEnabled = false;
- bopLoadButton.setEnabled(false);
-
- // populate buildInfo to be used by the reader job
- populateBuildInfo(getContainer().getBuildInfo());
- IProject project = getContainer().getProject();
- Job readerJob = new BuildOutputReaderJob(project, getContainer().getBuildInfo());
- readerJob.setPriority(Job.LONG);
- readerJob.addJobChangeListener(new JobChangeAdapter() {
-
- public void done(IJobChangeEvent event) {
- //lock.acquire();
- synchronized (lock) {
- if (!instance.shell.isDisposed()) {
- instance.shell.getDisplay().asyncExec(new Runnable() {
-
- public void run() {
- if (!instance.shell.isDisposed()) {
- loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
- instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
- }
- else {
- loadButtonInitialEnabled = true;
- }
- }
-
- });
- }
- else {
- loadButtonInitialEnabled = true;
- }
- }
- //lock.release();
- }
-
- });
- readerJob.schedule();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#isValid()
- */
- public boolean isValid() {
- return isValid;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
- */
- public String getErrorMessage() {
- return (isValid) ? null : MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_ERROR_MESSAGE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#populateBuildInfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
- */
- protected void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
- if (buildInfo != null) {
- buildInfo.setBuildOutputFileActionEnabled(true);
- buildInfo.setBuildOutputFilePath(getBopOpenFileText());
- buildInfo.setBuildOutputParserEnabled(bopEnabledButton.getSelection());
-
- buildInfo.setProviderOutputParserEnabled(providerId, sipEnabledButton.getSelection());
- buildInfo.setProviderRunCommand(providerId, sipRunCommandText.getText().trim());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#restoreFromBuildinfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
- */
- protected void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
- if (buildInfo != null) {
- setBopOpenFileText(buildInfo.getBuildOutputFilePath());
- bopEnabledButton.setSelection(buildInfo.isBuildOutputParserEnabled());
-
- sipEnabledButton.setSelection(buildInfo.isProviderOutputParserEnabled(providerId));
- sipRunCommandText.setText(buildInfo.getProviderRunCommand(providerId));
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
index ca8560fa576..cb9f60f540a 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
@@ -10,12 +10,15 @@
*******************************************************************************/
package org.eclipse.cdt.make.ui.dialogs;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MessageLine;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
@@ -68,6 +71,7 @@ public class MakeTargetDialog extends Dialog {
IMakeTargetManager fTargetManager;
IContainer fContainer;
+ IConfiguration fConfiguration;
private IPath buildCommand;
private boolean isDefaultCommand;
@@ -103,19 +107,28 @@ public class MakeTargetDialog extends Dialog {
super(parentShell);
fContainer = container;
fTargetManager = MakeCorePlugin.getDefault().getTargetManager();
+ IBuilder builder = null;
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(fContainer);
+ if(info == null){
+ throw new CoreException(new Status(IStatus.ERROR, MakeUIPlugin.getUniqueIdentifier(), -1,
+ MakeUIPlugin.getResourceString("project {0} does not have build info associated"), null));
+ }
+
+ fConfiguration = info.getDefaultConfiguration();
String[] id = fTargetManager.getTargetBuilders(container.getProject());
if (id.length == 0) {
throw new CoreException(new Status(IStatus.ERROR, MakeUIPlugin.getUniqueIdentifier(), -1,
MakeUIPlugin.getResourceString("MakeTargetDialog.exception.noTargetBuilderOnProject"), null)); //$NON-NLS-1$
}
+
targetBuildID = id[0];
- IMakeBuilderInfo buildInfo = MakeCorePlugin.createBuildInfo(container.getProject(),
- fTargetManager.getBuilderID(targetBuildID));
- isStopOnError = buildInfo.isStopOnError();
- isDefaultCommand = buildInfo.isDefaultBuildCmd();
- buildCommand = buildInfo.getBuildCommand();
- buildArguments = buildInfo.getBuildArguments();
- targetString = buildInfo.getIncrementalBuildTarget();
+// builder = ManagedBuilderCorePlugin.createBuilderForEclipseBuilder(fConfiguration, fTargetManager.getBuilderID(targetBuildID));
+ builder = fConfiguration.getBuilder();
+ isStopOnError = builder.isStopOnError();
+ isDefaultCommand = builder.isDefaultBuildCmd();
+ buildCommand = builder.getBuildCommand();
+ buildArguments = builder.getBuildArguments();
+ targetString = builder.getIncrementalBuildTarget();
}
protected void configureShell(Shell newShell) {
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java
deleted file mode 100644
index 49696a4408d..00000000000
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java
+++ /dev/null
@@ -1,596 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
-
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
-import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
-import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.debug.ui.StringVariableSelectionDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ContainerSelectionDialog;
-
-public class SettingsBlock extends AbstractCOptionPage {
-
- private static final String PREFIX = "SettingsBlock"; //$NON-NLS-1$
- private static final String MAKE_LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String MAKE_MESSAGE = PREFIX + ".message"; //$NON-NLS-1$
-
- private static final String MAKE_SETTING_GROUP = PREFIX + ".makeSetting.group_label"; //$NON-NLS-1$
- private static final String MAKE_SETTING_STOP_ERROR = PREFIX + ".makeSetting.stopOnError"; //$NON-NLS-1$
-
- private static final String MAKE_CMD_GROUP = PREFIX + ".makeCmd.group_label"; //$NON-NLS-1$
- private static final String MAKE_CMD_USE_DEFAULT = PREFIX + ".makeCmd.use_default"; //$NON-NLS-1$
- private static final String MAKE_CMD_LABEL = PREFIX + ".makeCmd.label"; //$NON-NLS-1$
-
- private static final String MAKE_WORKBENCH_BUILD_GROUP = PREFIX + ".makeWorkbench.group_label"; //$NON-NLS-1$
- private static final String MAKE_WORKBENCH_BUILD_TYPE = PREFIX + ".makeWorkbench.type"; //$NON-NLS-1$
- private static final String MAKE_WORKBENCH_BUILD_TARGET = PREFIX + ".makeWorkbench.target"; //$NON-NLS-1$
- private static final String MAKE_WORKBENCH_BUILD_AUTO = PREFIX + ".makeWorkbench.auto"; //$NON-NLS-1$
- private static final String MAKE_WORKBENCH_BUILD_INCR = PREFIX + ".makeWorkbench.incremental"; //$NON-NLS-1$
- private static final String MAKE_WORKBENCH_BUILD_FULL = PREFIX + ".makeWorkbench.full"; //$NON-NLS-1$
- private static final String MAKE_WORKBENCH_BUILD_CLEAN = PREFIX + ".makeWorkbench.clean"; //$NON-NLS-1$
-
- private static final String MAKE_BUILD_DIR_GROUP = PREFIX + ".makeLoc.group_label"; //$NON-NLS-1$
- private static final String MAKE_BUILD_DIR_LABEL = PREFIX + ".makeDir.label"; //$NON-NLS-1$
- private static final String MAKE_BUILD_DIR_BROWSE_FILESYSTEM = PREFIX + ".makeDir.browseFilesystem"; //$NON-NLS-1$
- private static final String MAKE_BUILD_DIR_BROWSE_WORKSPACE = PREFIX + ".makeDir.browseWorkspace"; //$NON-NLS-1$
-
- private static final String MAKE_BUILD_AUTO_TARGET = PREFIX + ".makeWorkbench.autoBuildTarget"; //$NON-NLS-1$
- private static final String MAKE_BUILD_INCREMENTAL_TARGET = PREFIX + ".makeWorkbench.incrementalBuildTarget"; //$NON-NLS-1$
- private static final String MAKE_BUILD_FULL_TARGET = PREFIX + ".makeWorkbench.fullBuildTarget"; //$NON-NLS-1$
- private static final String MAKE_BUILD_CLEAN_TARGET = PREFIX + ".makeWorkbench.cleanTarget"; //$NON-NLS-1$
-
- Button stopOnErrorButton;
- Button defButton;
- Text buildCommand;
- Button argumentVariablesButton;
-
- Text buildLocation;
- Button locationVariablesButton;
-
- Text targetIncr;
- Text targetAuto;
- Text targetClean;
-
- Button incrButton;
- Button autoButton;
- Button cleanButton;
-
- Button incrVariableButton;
- Button autoVariableButton;
- Button cleanVariableButton;
-
- IMakeBuilderInfo fBuildInfo;
- Preferences fPrefs;
- String fBuilderID;
-
- public SettingsBlock(Preferences prefs, String builderID) {
- super(MakeUIPlugin.getResourceString(MAKE_LABEL));
- setDescription(MakeUIPlugin.getResourceString(MAKE_MESSAGE));
- fPrefs = prefs;
- fBuilderID = builderID;
- }
-
- protected void createSettingControls(Composite parent) {
- Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1);
- stopOnErrorButton = new Button(group, SWT.CHECK);
- stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR));
- if (fBuildInfo.isStopOnError()) {
- stopOnErrorButton.setSelection(true);
- }
- stopOnErrorButton.setEnabled(fBuildInfo.isDefaultBuildCmd());
- }
-
- protected void createBuildCmdControls(Composite parent) {
- Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.makeColumnsEqualWidth = false;
- group.setLayout(layout);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT));
- defButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- if (defButton.getSelection() == true) {
- buildCommand.setEnabled(false);
- argumentVariablesButton.setEnabled(false);
- stopOnErrorButton.setEnabled(true);
- getContainer().updateContainer();
- } else {
- buildCommand.setEnabled(true);
- argumentVariablesButton.setEnabled(true);
- stopOnErrorButton.setEnabled(false);
- getContainer().updateContainer();
- }
- }
- });
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- defButton.setLayoutData(gd);
- Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL));
- ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
- ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
- buildCommand = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
-
- ((GridData) (buildCommand.getLayoutData())).horizontalAlignment = GridData.FILL;
- ((GridData) (buildCommand.getLayoutData())).grabExcessHorizontalSpace = true;
- buildCommand.addListener(SWT.Modify, new Listener() {
-
- public void handleEvent(Event e) {
- getContainer().updateContainer();
- }
- });
- if (fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, null) != null) {
- StringBuffer cmd = new StringBuffer(fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "")); //$NON-NLS-1$
- if (!fBuildInfo.isDefaultBuildCmd()) {
- String args = fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, ""); //$NON-NLS-1$
- if (args != null && !args.equals("")) { //$NON-NLS-1$
- cmd.append(" "); //$NON-NLS-1$
- cmd.append(args);
- }
- }
- buildCommand.setText(cmd.toString());
- }
- argumentVariablesButton = addVariablesButton(group, buildCommand);
- if (fBuildInfo.isDefaultBuildCmd()) {
- buildCommand.setEnabled(false);
- argumentVariablesButton.setEnabled(false);
- }
- defButton.setSelection(fBuildInfo.isDefaultBuildCmd());
- }
-
- protected void createWorkBenchBuildControls(Composite parent) {
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- targetAuto.setEnabled(autoButton.getSelection());
- autoVariableButton.setEnabled(autoButton.getSelection());
- targetIncr.setEnabled(incrButton.getSelection());
- incrVariableButton.setEnabled(incrButton.getSelection());
- targetClean.setEnabled(cleanButton.getSelection());
- cleanVariableButton.setEnabled(cleanButton.getSelection());
- getContainer().updateContainer();
- }
-
- };
- Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_GROUP), 1);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.makeColumnsEqualWidth = false;
- group.setLayout(layout);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Label label = new Label(group, SWT.NONE);
- label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TYPE));
- label = new Label(group, SWT.NONE);
- label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TARGET));
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- label.setLayoutData(gd);
- autoButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_AUTO));
- autoButton.addSelectionListener(selectionAdapter);
- autoButton.setSelection(fBuildInfo.isAutoBuildEnable());
- targetAuto = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- targetAuto.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "")); //$NON-NLS-1$
- ((GridData) (targetAuto.getLayoutData())).horizontalAlignment = GridData.FILL;
- ((GridData) (targetAuto.getLayoutData())).grabExcessHorizontalSpace = true;
- addControlAccessibleListener(targetAuto, MakeUIPlugin.getResourceString(MAKE_BUILD_AUTO_TARGET));
- autoVariableButton = addVariablesButton(group, targetAuto);
- String noteTitle = MakeUIPlugin.getResourceString("SettingsBlock.makeWorkbench.note"); //$NON-NLS-1$
- String noteMessage = MakeUIPlugin.getResourceString("SettingsBlock.makeWorkbench.autobuildMessage"); //$NON-NLS-1$
- Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), group, noteTitle, noteMessage);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 3;
- noteControl.setLayoutData(gd);
- incrButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_INCR));
- incrButton.addSelectionListener(selectionAdapter);
- incrButton.setSelection(fBuildInfo.isIncrementalBuildEnabled());
- targetIncr = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- targetIncr.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, "")); //$NON-NLS-1$
- ((GridData) (targetIncr.getLayoutData())).horizontalAlignment = GridData.FILL;
- ((GridData) (targetIncr.getLayoutData())).grabExcessHorizontalSpace = true;
- addControlAccessibleListener(targetIncr, MakeUIPlugin.getResourceString(MAKE_BUILD_INCREMENTAL_TARGET));
- incrVariableButton = addVariablesButton(group, targetIncr);
- cleanButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_CLEAN));
- cleanButton.addSelectionListener(selectionAdapter);
- cleanButton.setSelection(fBuildInfo.isCleanBuildEnabled());
- targetClean = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- targetClean.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "")); //$NON-NLS-1$
- ((GridData) (targetClean.getLayoutData())).horizontalAlignment = GridData.FILL;
- ((GridData) (targetClean.getLayoutData())).grabExcessHorizontalSpace = true;
- addControlAccessibleListener(targetClean, MakeUIPlugin.getResourceString(MAKE_BUILD_CLEAN_TARGET));
- cleanVariableButton = addVariablesButton(group, targetClean);
- selectionAdapter.widgetSelected(null);
- }
-
- private Button addVariablesButton(Composite parent, final Text control) {
- String variablesTitle = MakeUIPlugin.getResourceString("SettingsBlock.variables"); //$NON-NLS-1$
- Button variablesButton = createPushButton(parent, variablesTitle, null);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
- variablesButton.setLayoutData(gd);
- variablesButton.addSelectionListener(new SelectionAdapter() {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent arg0) {
- handleVariablesButtonSelected(control);
- }
- });
- return variablesButton;
- }
-
- protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
- Composite messageComposite = new Composite(composite, SWT.NONE);
- GridLayout messageLayout = new GridLayout();
- messageLayout.numColumns = 2;
- messageLayout.marginWidth = 0;
- messageLayout.marginHeight = 0;
- messageComposite.setLayout(messageLayout);
- messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- messageComposite.setFont(font);
-
- final Label noteLabel = new Label(messageComposite, SWT.BOLD);
- noteLabel.setText(title);
- noteLabel.setFont(JFaceResources.getBannerFont());
- noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-
- final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent event) {
- if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
- noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
- }
- }
- };
- JFaceResources.getFontRegistry().addListener(fontListener);
- noteLabel.addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent event) {
- JFaceResources.getFontRegistry().removeListener(fontListener);
- }
- });
-
- Label messageLabel = new Label(messageComposite, SWT.WRAP);
- messageLabel.setText(message);
- messageLabel.setFont(font);
- return messageComposite;
- }
- public void addControlAccessibleListener(Control control, String controlName) {
- control.getAccessible().addAccessibleListener(new ControlAccessibleListener(controlName));
- }
- private class ControlAccessibleListener extends AccessibleAdapter {
-
- private String controlName;
- ControlAccessibleListener(String name) {
- controlName = name;
- }
- public void getName(AccessibleEvent e) {
- e.result = controlName;
- }
- }
- protected void createBuilderWorkingDirControls(Composite parent) {
- Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_GROUP), 1);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.makeColumnsEqualWidth = false;
- group.setLayout(layout);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_LABEL));
- ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
- ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
- buildLocation = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- ((GridData) (buildLocation.getLayoutData())).horizontalAlignment = GridData.FILL;
- ((GridData) (buildLocation.getLayoutData())).grabExcessHorizontalSpace = true;
- buildLocation.addListener(SWT.Modify, new Listener() {
-
- public void handleEvent(Event e) {
- getContainer().updateContainer();
- }
- });
-
- Composite buttons = ControlFactory.createComposite(group, 4);
- layout = new GridLayout(4, false);
- layout.marginHeight = layout.marginWidth = 0;
- buttons.setLayout(layout);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- buttons.setLayoutData(gd);
-
- Label emptyLabel = ControlFactory.createLabel(buttons, ""); //$NON-NLS-1$
- emptyLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Button browseWorkspace = new Button(buttons, SWT.NONE);
- browseWorkspace.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE_WORKSPACE));
- browseWorkspace.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), getContainer().getProject(), true,
- MakeUIPlugin.getResourceString("SettingsBlock.title.selectLocationToBuildFrom")); //$NON-NLS-1$
- if (dialog.open() == Window.OK) {
- Object[] selection = dialog.getResult();
- if (selection.length > 0) {
- buildLocation.setText( ((IPath)selection[0]).toOSString());
- }
- }
- }
- });
-
- Button browseFilesystem = new Button(buttons, SWT.NONE);
- browseFilesystem.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE_FILESYSTEM));
- browseFilesystem.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
- dialog.setText(MakeUIPlugin.getResourceString("SettingsBlock.title.selectLocationToBuildFrom"));
- dialog.setFilterPath(getContainer().getProject().toString());
- String directory = dialog.open();
- if (directory != null) {
- if (directory.trim().length() > 0) {
- buildLocation.setText(directory);
- }
- }
- }
- });
-
- buildLocation.setText(fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, "")); //$NON-NLS-1$
- locationVariablesButton = addVariablesButton(buttons, buildLocation);
- }
-
- /**
- * A variable entry button has been pressed for the given text field. Prompt
- * the user for a variable and enter the result in the given field.
- */
- private void handleVariablesButtonSelected(Text textField) {
- String variable = getVariable();
- if (variable != null) {
- textField.append(variable);
- }
- }
-
- /**
- * Prompts the user to choose and configure a variable and returns the
- * resulting string, suitable to be used as an attribute.
- */
- private String getVariable() {
- StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
- dialog.open();
- return dialog.getVariableExpression();
- }
- public void createControl(Composite parent) {
- Composite composite = ControlFactory.createComposite(parent, 1);
- setControl(composite);
-
- MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_BUILDER_SETTINGS);
-
- if (fBuildInfo == null) {
- ControlFactory.createEmptySpace(composite);
- ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString("SettingsBlock.label.missingBuilderInformation")); //$NON-NLS-1$
- return;
- }
-
- createBuildCmdControls(composite);
- createSettingControls(composite);
- createWorkBenchBuildControls(composite);
-
- if (getContainer().getProject() != null) {
- createBuilderWorkingDirControls(composite);
- }
- }
-
- public boolean isValid() {
- if (defButton != null && defButton.getSelection() != true) {
- String cmd = getBuildLine();
- if (cmd == null || cmd.length() == 0) {
- return false;
- }
- }
- return true;
- }
-
- public void performApply(IProgressMonitor monitor) throws CoreException {
- // Missing builder info
- if (fBuildInfo == null) {
- return;
- }
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- IWorkspace workspace = MakeUIPlugin.getWorkspace();
- // To avoid multi-build
- IWorkspaceRunnable operation = new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(MakeUIPlugin.getResourceString("SettingsBlock.monitor.applyingSettings"), 1); //$NON-NLS-1$
- IMakeBuilderInfo info = null;
- if (getContainer().getProject() != null) {
- try {
- info = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
- } catch (CoreException e) {
- // disabled builder... just log it
- MakeCorePlugin.log(e);
- return;
- }
- } else {
- info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
- }
- info.setStopOnError(isStopOnError());
- info.setUseDefaultBuildCmd(useDefaultBuildCmd());
- if (!useDefaultBuildCmd()) {
- String bldLine = getBuildLine();
- int start = 0;
- int end = -1;
- if (!bldLine.startsWith("\"")) { //$NON-NLS-1$
- end = bldLine.indexOf(' ');
- } else {
- start = 1;
- end = bldLine.indexOf('"', 1);
- }
- String path;
- if (end == -1) {
- path = bldLine;
- } else {
- path = bldLine.substring(start, end);
- }
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_COMMAND, path);
- String args = ""; //$NON-NLS-1$
- if (end != -1) {
- args = bldLine.substring(end + 1);
- }
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_ARGUMENTS, args);
- }
- info.setAutoBuildEnable(autoButton.getSelection());
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, targetAuto.getText().trim());
- info.setIncrementalBuildEnable(incrButton.getSelection());
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, targetIncr.getText().trim());
- info.setFullBuildEnable(incrButton.getSelection());
- info.setCleanBuildEnable(cleanButton.getSelection());
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, targetClean.getText().trim());
- if (buildLocation != null) {
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_LOCATION, buildLocation.getText().trim());
- }
- }
- };
- if (getContainer().getProject() != null) {
- workspace.run(operation, monitor);
- } else {
- operation.run(monitor);
- }
- }
-
- public void performDefaults() {
- // Missing builder info
- if (fBuildInfo == null) {
- return;
- }
- IMakeBuilderInfo info;
- if (getContainer().getProject() != null) {
- info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
- } else {
- info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, true);
- }
- if (info.isStopOnError())
- stopOnErrorButton.setSelection(true);
- else
- stopOnErrorButton.setSelection(false);
- if (info.getBuildCommand() != null) {
- StringBuffer cmd = new StringBuffer(info.getBuildCommand().toOSString());
- if (!info.isDefaultBuildCmd()) {
- String args = info.getBuildArguments();
- if (args != null && !args.equals("")) { //$NON-NLS-1$
- cmd.append(" "); //$NON-NLS-1$
- cmd.append(args);
- }
- }
- buildCommand.setText(cmd.toString());
- }
- if (info.isDefaultBuildCmd()) {
- buildCommand.setEnabled(false);
- argumentVariablesButton.setEnabled(false);
- stopOnErrorButton.setEnabled(true);
- } else {
- buildCommand.setEnabled(true);
- argumentVariablesButton.setEnabled(true);
- stopOnErrorButton.setEnabled(false);
- }
-
- defButton.setSelection(info.isDefaultBuildCmd());
-
- autoButton.setSelection(info.isAutoBuildEnable());
- autoVariableButton.setEnabled(info.isAutoBuildEnable());
- targetAuto.setEnabled(info.isAutoBuildEnable());
- targetAuto.setText(info.getAutoBuildTarget());
- incrButton.setSelection(info.isIncrementalBuildEnabled());
- incrVariableButton.setEnabled(info.isIncrementalBuildEnabled());
- targetIncr.setText(info.getIncrementalBuildTarget());
- targetIncr.setEnabled(info.isIncrementalBuildEnabled());
- cleanButton.setSelection(info.isCleanBuildEnabled());
- cleanVariableButton.setEnabled(info.isCleanBuildEnabled());
- targetClean.setText(info.getCleanBuildTarget());
- targetClean.setEnabled(info.isCleanBuildEnabled());
- }
-
- boolean isStopOnError() {
- return stopOnErrorButton.getSelection();
- }
-
- boolean useDefaultBuildCmd() {
- return defButton.getSelection();
- }
-
- String getBuildLine() {
- if (buildCommand != null) {
- String cmd = buildCommand.getText();
- if (cmd != null)
- return cmd.trim();
- }
- return null;
- }
-
- public void setContainer(ICOptionContainer container) {
- super.setContainer(container);
- if (getContainer().getProject() != null) {
- try {
- fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
- } catch (CoreException e) {
- }
- } else {
- fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
- }
- }
-
- public String getErrorMessage() {
- if (!useDefaultBuildCmd()) {
- String cmd = getBuildLine();
- if (cmd == null || cmd.length() == 0) {
- return MakeUIPlugin.getResourceString("SettingsBlock.message.mustEnterBuildCommand"); //$NON-NLS-1$
- }
- }
- return null;
- }
-}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java
index 9d3003c21c5..a6f2cabe62d 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java
@@ -86,7 +86,7 @@ public class ConvertToMakeProjectWizardPage extends ConvertProjectWizardPage {
super.convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
MakeProjectNature.addNature(project, new SubProgressMonitor(monitor, 1));
ScannerConfigNature.addScannerConfigNature(project);
- ScannerConfigNature.initializeDiscoveryOptions(project);
+//FIXME ScannerConfigNature.initializeDiscoveryOptions(project);
CCorePlugin.getDefault().mapCProjectOwner(project, projectID, true);
} finally {
monitor.done();
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF
index def01a183fe..912025f95c6 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF
@@ -14,7 +14,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.junit,
org.eclipse.cdt.managedbuilder.core,
org.eclipse.cdt.core,
- org.eclipse.cdt.make.core,
org.eclipse.core.resources,
org.eclipse.ui,
org.eclipse.ui.ide
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index 823ff25fd18..9035b079d55 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -140,7 +140,8 @@
</configuration>
<configuration
name="Root Override Config"
- id="root.override.config">
+ id="root.override.config"
+ isSystem="true">
<toolReference
id="root.tool">
<optionReference
@@ -155,7 +156,8 @@
</configuration>
<configuration
name="Complete Override Config"
- id="complete.override.config">
+ id="complete.override.config"
+ isSystem="true">
<toolReference
id="root.tool">
<optionReference
@@ -358,7 +360,8 @@
</tool>
<configuration
name="Who Cares"
- id="test.forward.parent.config">
+ id="test.forward.parent.config"
+ isSystem="true">
<toolReference
id="test.forward.tool"/>
</configuration>
@@ -377,11 +380,13 @@
outputFlag="-o"
outputs="xy"
command="EP"
- id="error.parsers.tool">
+ id="error.parsers.tool"
+ isSystem="true">
</tool>
<configuration
name="EP Config"
- id="ep.config"/>
+ id="ep.config"
+ isSystem="true"/>
</target>
</extension>
@@ -1205,7 +1210,8 @@
name="Dbg ToolChain"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
osList="solaris,linux,hpux,aix,qnx"
- archList="all">
+ archList="all"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.exe.debug"
name="Dbg Platform"
@@ -1272,7 +1278,8 @@
name="Rel ToolChain"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
osList="solaris,linux,hpux,aix,qnx"
- archList="all">
+ archList="all"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.exe.release"
name="Rel Platform"
@@ -1346,7 +1353,8 @@
name="so Debug ToolChain"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
osList="solaris,linux,hpux,aix,qnx"
- archList="all">
+ archList="all"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.so.debug"
name="so Debug Platform"
@@ -1427,7 +1435,8 @@
name="so Release ToolChain"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
osList="solaris,linux,hpux,aix,qnx"
- archList="all">
+ archList="all"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.so.release"
name="so Release Platform"
@@ -1515,7 +1524,8 @@
name="Dbg TC"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
osList="solaris,linux,hpux,aix,qnx"
- archList="all">
+ archList="all"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.lib.debug"
name="Dbg P"
@@ -1580,7 +1590,8 @@
name="Rel TC"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
osList="solaris,linux,hpux,aix,qnx"
- archList="all">
+ archList="all"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.lib.release"
name="Rel P"
@@ -1648,7 +1659,8 @@
id="cdt.managedbuild.test.java.attrs.config">
<toolChain
id="cdt.managedbuild.test.java.attrs.toolchain"
- name="The Tool-Chain">
+ name="The Tool-Chain"
+ isSystem="true">
<tool
id="cdt.managedbuild.test.java.attrs.tool"
superClass="cdt.managedbuild.tool.testgnu.c.compiler"
@@ -2557,7 +2569,8 @@
name="MBS30ToolChainName.Dbg"
targetTool="cdt.managedbuild.tool.testgnu30.c.linker.exe.debug;cdt.managedbuild.tool.testgnu30.cpp.linker.exe.debug"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.testgnu30.exe.debug">
+ id="cdt.managedbuild.toolchain.testgnu30.exe.debug"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu30.platform.exe.debug"
name="MBS30PlatformName.Dbg"
@@ -2621,7 +2634,8 @@
name="MBS30ToolChainName.Rel"
targetTool="cdt.managedbuild.tool.testgnu30.c.linker.exe.release;cdt.managedbuild.tool.testgnu30.cpp.linker.exe.release"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.testgnu30.exe.release">
+ id="cdt.managedbuild.toolchain.testgnu30.exe.release"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu30.platform.exe.release"
name="MBS30PlatformName.Rel"
@@ -2693,7 +2707,8 @@
name="MBS30ToolChainName.Dbg"
targetTool="cdt.managedbuild.tool.testgnu30.c.linker.so.debug;cdt.managedbuild.tool.testgnu30.cpp.linker.so.debug"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.testgnu30.so.debug">
+ id="cdt.managedbuild.toolchain.testgnu30.so.debug"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu30.platform.so.debug"
name="MBS30PlatformName.Dbg"
@@ -2782,7 +2797,8 @@
name="MBS30ToolChainName.Rel"
targetTool="cdt.managedbuild.tool.testgnu30.c.linker.so.release;cdt.managedbuild.tool.testgnu30.cpp.linker.so.release"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.testgnu30.so.release">
+ id="cdt.managedbuild.toolchain.testgnu30.so.release"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu30.platform.so.release"
name="MBS30PlatformName.Rel"
@@ -2878,7 +2894,8 @@
name="MBS30ToolChainName.Dbg"
targetTool="cdt.managedbuild.tool.testgnu30.archiver.lib.debug"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.testgnu30.lib.debug">
+ id="cdt.managedbuild.toolchain.testgnu30.lib.debug"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu30.platform.lib.debug"
name="MBS30PlatformName.Dbg"
@@ -2939,7 +2956,8 @@
name="MBS30ToolChainName.Rel"
targetTool="cdt.managedbuild.tool.testgnu30.archiver.lib.release"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.testgnu30.lib.release">
+ id="cdt.managedbuild.toolchain.testgnu30.lib.release"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testgnu30.platform.lib.release"
name="MBS30PlatformName.Rel"
@@ -3039,7 +3057,8 @@
name="ToolChainDbg"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
targetTool="foo.bar;cdt.managedbuild.tool30.deploy.x.c.1"
- id="cdt.managedbuild.Testprepost30.gnu.toolchain.exe.debug">
+ id="cdt.managedbuild.Testprepost30.gnu.toolchain.exe.debug"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.Testprepost30.gnu.platform.exe.debug"
name="PlatformDbg"
@@ -3128,7 +3147,8 @@
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
targetTool="test30_1.gnu.so.deploy"
secondaryOutputs="test30_1.gnu.so.cjpeg.output"
- id="test30_1.gnu.so.toolchain">
+ id="test30_1.gnu.so.toolchain"
+ isSystem="true">
<targetPlatform
id="test30_1.gnu.so.platform"
name="Platform for test30_1"
@@ -3273,7 +3293,8 @@
id="test30_sto.dummy.toolchain.parent"
isAbstract="true"
name="test30_sto ToolChain.Parent"
- osList="all">
+ osList="all"
+ isSystem="true">
<optionCategory
id="test30_sto.dummy.category.5"
name="Category.Top.5.NoIcon"/>
@@ -3341,7 +3362,8 @@
id="test30_sto.dummy.toolchain"
isAbstract="false"
name="Toolchain for test30_sto"
- superClass="test30_sto.dummy.toolchain.parent">
+ superClass="test30_sto.dummy.toolchain.parent"
+ isSystem="true">
<targetPlatform
archList="all"
id="test30_sto.dummy.platform"
@@ -3464,7 +3486,8 @@
<toolChain
name="ToolChain for test30_2"
targetTool="test30_2.cat"
- id="test30_2.tar.toolchain">
+ id="test30_2.tar.toolchain"
+ isSystem="true">
<builder
id="test30_2.tar.builder"
name="Builder for test30_2"
@@ -3596,7 +3619,8 @@
isToolChainSupported="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
name="Dbg ToolChain"
osList="solaris,linux,hpux,aix,qnx"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testenv.platform.exe.debug"
name="Dbg Platform"
@@ -3660,7 +3684,8 @@
isToolChainSupported="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
name="Rel ToolChain"
osList="solaris,linux,hpux,aix,qnx"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testenv.platform.exe.release"
name="Rel Platform"
@@ -3708,7 +3733,8 @@
id="cdt.managedbuild.toolchain.testenv.exe.xz"
isToolChainSupported="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
name="Three ToolChain"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testenv.platform.exe.xz"
name="xz Platform">
@@ -3734,7 +3760,8 @@
<toolChain
id="cdt.managedbuild.toolchain.testenv.exe.min"
isToolChainSupported="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
- name="Three ToolChain">
+ name="Three ToolChain"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testenv.platform.exe.min"
name="Rel Platform">
@@ -3765,7 +3792,8 @@
isToolChainSupported="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
name="Dbg ToolChain"
osList="solaris,linux,hpux,aix,qnx"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testenv.platform.exe.five"
name="Dbg Platform"
@@ -3818,7 +3846,8 @@
id="TopTC.toolchain.base"
name="TopLevel Toolchain"
isAbstract="true"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="TopTC.platform"
name="TopTC Platform"
@@ -3834,7 +3863,8 @@
id="TopTC.toolchain.release"
name="TopTC Release Toolchain"
isAbstract="true"
- superClass="TopTC.toolchain.base">
+ superClass="TopTC.toolchain.base"
+ isSystem="true">
<tool
id="TopTC.c.compiler.release"
superClass="cdt.managedbuild.tool.gnu.c.compiler"
@@ -3866,7 +3896,8 @@
id="TopTC.toolchain.debug"
name="TopTC Debug Toolchain"
isAbstract="true"
- superClass="TopTC.toolchain.base">
+ superClass="TopTC.toolchain.base"
+ isSystem="true">
<tool
id="TopTC.c.compiler.debug"
superClass="cdt.managedbuild.tool.gnu.c.compiler"
@@ -3906,7 +3937,8 @@
cleanCommand="rm -rf">
<toolChain
id="TopTC.toolchain.exe.debug"
- superClass="TopTC.toolchain.debug">
+ superClass="TopTC.toolchain.debug"
+ isSystem="true">
<tool
id="TopTC..c.linker.exe.debug"
superClass="cdt.managedbuild.tool.gnu.c.linker"
@@ -3924,7 +3956,8 @@
cleanCommand="rm -rf">
<toolChain
id="TopTC.toolchain.exe.release"
- superClass="TopTC.toolchain.release">
+ superClass="TopTC.toolchain.release"
+ isSystem="true">
<tool
id="TopTC..c.linker.exe.release"
superClass="cdt.managedbuild.tool.gnu.c.linker"
@@ -3958,7 +3991,8 @@
name="Debug IA32 ToolChain"
archList="x86"
osList="linux"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testMultipleVersions.platform.exe.debug"
name="Debug IA32 Platform"
@@ -3997,7 +4031,8 @@
osList="linux"
id="cdt.managedbuild.toolchain.testMultipleVersions.exe.release"
name="Release IA32 ToolChain"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testMultipleVersions.platform.exe.release"
name="Release IA32 Platform"
@@ -4028,7 +4063,8 @@
configurationMacroSupplier="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
id="cdt.managedbuild.toolchain.testMultipleVersions.exe.debug64_2.2.0"
name="Debug IA64 ToolChain"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testMultipleVersions.platform.exe.debug64"
name="Debug IA64 Platform">
@@ -4055,7 +4091,8 @@
id="cdt.managedbuild.toolchain.testMultipleVersions.exe.release64_2.2.0"
versionsSupported="1.2.0,2.0.0,2.1.3"
isToolChainSupported="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
- name="Three ToolChain">
+ name="Three ToolChain"
+ isSystem="true">
<targetPlatform
id="cdt.managedbuild.target.testMultipleVersions.platform.exe.release64"
name="Release IA64 Platform">
@@ -4092,7 +4129,7 @@
id="config.testProjectConverterConvenienceRoutines.exe.debug"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
+ <toolChain isSystem="true"
id="toolchain.testProjectConverterConvenienceRoutines.exe.debug_1.1.0"
name="Debug IA32 ToolChain"
archList="x86"
@@ -4135,7 +4172,7 @@
cleanCommand="rm"
id="org.eclipse.cdt.managedbuilder.core.tests.BDMacroSupportConfiguration"
name="Default">
- <toolChain
+ <toolChain isSystem="true"
id="org.eclipse.cdt.managedbuilder.core.tests.BDMacroSupportToolchain"
isAbstract="false"
name="Build Definition Macro Support Toolchain"
@@ -4260,7 +4297,7 @@
id="test.config_1.0.0"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
+ <toolChain isSystem="true"
id="test.toolChain_1.0.0"
name="Test ToolChain Ver 1.0"
convertToId="test.toolChain_2.0.0"
@@ -4304,7 +4341,7 @@
id="test.config_2.0.0"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
+ <toolChain isSystem="true"
id="test.toolChain_2.0.0"
name="Test ToolChain Ver 2.0"
archList="all">
@@ -4342,7 +4379,7 @@
superClass="cdt.managedbuild.target.gnu.exe"
id="test.target">
<configuration id="test.config" name="Test Configuration">
- <toolChain
+ <toolChain isSystem="true"
id="test.toolchain"
name="Test Toolchain"
convertToId="test.toolchain_1.2.0">
@@ -4372,7 +4409,7 @@
superClass="cdt.managedbuild.target.gnu.exe"
id="test.target_1.2.0">
<configuration id="test.config_1.2.0" name="Test Configuration">
- <toolChain
+ <toolChain isSystem="true"
id="test.toolchain_1.2.0"
name="Test Toolchain 1.2.0">
<builder
@@ -4407,7 +4444,7 @@
id="testProject.config_1.0.0"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
+ <toolChain isSystem="true"
id="testProject.toolChain_1.0.0"
name="Test ToolChain Ver 1.0"
archList="all">
@@ -4448,7 +4485,7 @@
id="testProject.config_2.0.0"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
+ <toolChain isSystem="true"
id="testProject.toolChain_2.0.0"
name="Test ToolChain Ver 2.0"
archList="all">
@@ -4671,7 +4708,7 @@
name="Release"
id="cdt.test.fortran.executable.release"
cleanCommand="rm -rf">
- <toolChain
+ <toolChain isSystem="true"
id="cdt.test.fortran.toolchain.executable.release"
name="ToolChain.Executable.Release"
targetTool="cdt.test.fortran.linkstep.executable.release"
@@ -4715,7 +4752,7 @@
name="Debug"
id="cdt.test.fortran.executable.debug"
cleanCommand="rm -rf">
- <toolChain
+ <toolChain isSystem="true"
id="cdt.test.fortran.toolchain.executable.debug"
name="ToolChain.Executable.Debug"
targetTool="cdt.test.fortran.linkstep.executable.debug"
@@ -4771,7 +4808,7 @@
cleanCommand="rm -rf"
id="cdt.test.assignToOption.debug"
name="Debug">
- <toolChain
+ <toolChain isSystem="true"
id="cdt.test.assignToOption.exeDebugToolchain"
isAbstract="false"
name="AssingToOption Tools"
@@ -4881,7 +4918,7 @@
<configuration
id="cdt.test.dollarValue.one"
name="One">
- <toolChain
+ <toolChain isSystem="true"
id="cdt.test.dollarValue.Toolchain"
isAbstract="false"
name="Tools">
@@ -4958,7 +4995,7 @@
id="cdt.managedbuild.config.enablement.exe.debug"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
+ <toolChain isSystem="true"
archList="all"
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
configurationMacroSupplier="org.eclipse.cdt.managedbuilder.core.tests.TestMacro"
@@ -5956,7 +5993,7 @@
cleanCommand="rm -rf"
id="test1.configuration"
name="Test Configuration 1">
- <toolChain
+ <toolChain isSystem="true"
archList="foo"
id="test1.toolChain1"
isAbstract="false"
@@ -5981,7 +6018,7 @@
cleanCommand="rm -rf"
id="test1.configuration 2"
name="Test Configuration 2">
- <toolChain
+ <toolChain isSystem="true"
archList="foo"
id="test1.toolChain2"
name="Test1 Tool Chain 2"
@@ -6025,7 +6062,7 @@
name="Debug"
cleanCommand="rm"
id="depcalc2.managedbuild.config.gnu.exe.debug">
- <toolChain
+ <toolChain isSystem="true"
id="test.dependency.calculator.2"
name="GCC using DependencyCalculator2"
superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
@@ -6059,7 +6096,7 @@
name="Debug"
cleanCommand="rm"
id="depcalc3.managedbuild.config.gnu.exe.debug">
- <toolChain
+ <toolChain isSystem="true"
id="test.dependency.calculator.3"
name="GCC using DependencyCalculator3"
superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
@@ -6093,7 +6130,7 @@
name="Debug"
cleanCommand="rm"
id="depcalcPreBuild.managedbuild.config.gnu.exe.debug">
- <toolChain
+ <toolChain isSystem="true"
id="test.dependency.calculator.PreBuild"
name="GCC using DependencyCalculatorPreBuild"
superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
@@ -6132,7 +6169,7 @@
id="cdt.managedbuild.config.bdm.exe.debug"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
+ <toolChain isSystem="true"
archList="all"
osList="solaris,linux,hpux,aix,qnx"
name="MBS30ToolChainName.Dbg"
@@ -6243,14 +6280,14 @@
<projectType
id="org.eclipse.cdt.managedbuilder.core.tests.inputTypeOptionMakefileRenderingTest"
isAbstract="false"
- isTest="false"
+ isTest="true"
name="org.eclipse.cdt.managedbuilder.core.tests.inputTypeOptionMakefileRenderingTest"
superClass="cdt.managedbuild.target.gnu30.exe">
<configuration
id="org.eclipse.cdt.managedbuilder.core.tests.inputTypeOptionMakefileRenderingTest"
name="org.eclipse.cdt.managedbuilder.core.tests.inputTypeOptionMakefileRenderingTest"
parent="cdt.managedbuild.config.testgnu30.exe.release">
- <toolChain
+ <toolChain isSystem="true"
id="org.eclipse.cdt.managedbuilder.core.tests.inputTypeOptionMakefileRenderingTest.toolChain"
isAbstract="false"
name="org.eclipse.cdt.managedbuilder.core.tests.inputTypeOptionMakefileRenderingTest.toolChain"
@@ -6313,12 +6350,12 @@
<extension
point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
<managedBuildRevision fileVersion="3.1.0"/>
- <toolChain
+ <toolChain isSystem="true"
id="pathconvertertest.convertingtoolchain"
isAbstract="false"
name="path converting toolchain"
optionPathConverter="org.eclipse.cdt.managedbuilder.core.tests.TestPathConverter1"/>
- <toolChain
+ <toolChain isSystem="true"
id="pathconvertertest.nonconvertingtoolchain"
isAbstract="false"
name="non path converting toolchain"
@@ -6350,7 +6387,7 @@
<configuration
id="pathconvertertest.tcnn.tonn"
name="config toolchain-nn, tool-nn">
- <toolChain
+ <toolChain isSystem="true"
id="pathconvertertest.config.tcnn.tonn.toolchain"
isAbstract="false"
name="toolchain tcnn tonn"
@@ -6375,7 +6412,7 @@
<configuration
id="pathconvertertest.tcny.tonn"
name="config toolchain-ny, tool-nn">
- <toolChain
+ <toolChain isSystem="true"
id="pathconvertertest.config.tcny.tonn.toolchain"
isAbstract="false"
name="toolchain tcny tonn"
@@ -6399,7 +6436,7 @@
<configuration
id="pathconvertertest.tcyy.tonn"
name="config toolchain-yy, tool-nn">
- <toolChain
+ <toolChain isSystem="true"
id="pathconvertertest.config.tcyy.tonn.toolchain"
isAbstract="false"
name="toolchain tcyy tonn"
@@ -6424,7 +6461,7 @@
<configuration
id="pathconvertertest.tcyy.tony"
name="config toolchain-yy, tool-ny">
- <toolChain
+ <toolChain isSystem="true"
id="pathconvertertest.config.tcyy.tony.toolchain"
isAbstract="false"
name="toolchain tcyy tony"
@@ -6449,7 +6486,7 @@
<configuration
id="pathconvertertest.tcyy.toyy"
name="config toolchain-yy, tool-yy">
- <toolChain
+ <toolChain isSystem="true"
id="pathconvertertest.config.tcyy.toyy.toolchain"
isAbstract="false"
name="toolchain tcyy toyy"
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java
index ff2f95db1ef..0395688e7f7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java
@@ -165,6 +165,27 @@ public class ManagedBuildTestHelper {
return file;
}
+ static public IFolder createFolder(IProject project, String name){
+ IFolder folder = project.getFolder(name);
+ if( !folder.exists() ){
+ try {
+ IPath dirPath = folder.getFullPath().removeLastSegments(1).removeFirstSegments(1);
+ if(dirPath.segmentCount() > 0){
+ IFolder rc = project.getFolder(dirPath);
+ if(!rc.exists()){
+ rc.create(true, true, null);
+ }
+ }
+
+// file.create( new ByteArrayInputStream( "#include <stdio.h>\n extern void bar(); \n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }".getBytes() ), false, null );
+ folder.create(true , false, null );
+ } catch (CoreException e) {
+ TestCase.fail(e.getLocalizedMessage());
+ }
+ }
+ return folder;
+ }
+
/**
* Remove the <code>IProject</code> with the name specified in the argument from the
* receiver's workspace.
@@ -296,6 +317,8 @@ public class ManagedBuildTestHelper {
for(int i = 0; i < cfgs.length; i++){
cfgs[i].setArtifactName(newProject.getDefaultArtifactName());
}
+
+ ManagedBuildManager.getBuildInfo(project).setValid(true);
}
};
NullProgressMonitor monitor = new NullProgressMonitor();
@@ -316,7 +339,7 @@ public class ManagedBuildTestHelper {
static public void addManagedBuildNature (IProject project) {
// Create the buildinformation object for the project
IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
- info.setValid(true);
+// info.setValid(true);
// Add the managed build nature
try {
@@ -696,6 +719,10 @@ public class ManagedBuildTestHelper {
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
case IOption.OBJECTS:
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
{
String val[] = (String[])value;
if(rcCfg != null)
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
index 2bb9c8a6abb..6198c942dc6 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
@@ -64,6 +64,7 @@ public class AllManagedBuildTests {
suite.addTest(MultiVersionSupportTests.suite());
suite.addTest(OptionEnablementTests.suite());
suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
+
suite.addTest(BuildDescriptionModelTests.suite());
suite.addTest(PathConverterTest.suite());
//$JUnit-END$
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java
index 9d75960ad0a..41d3d1ea675 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java
@@ -57,6 +57,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
public class BuildDescriptionModelTests extends TestCase {
@@ -1100,10 +1101,12 @@ public class BuildDescriptionModelTests extends TestCase {
//
//FIXME: this is very bad, need to wait until the indexing is completed here
- try {
+/* try {
Thread.sleep(10000);
} catch (InterruptedException e1) {
}
+*/
+ CCorePlugin.getIndexManager().joinIndexer(-1, new NullProgressMonitor());
IBuildDescription des = null;
try {
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java
index 1967e7a5fa2..bc9e9eb2195 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java
@@ -270,7 +270,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
assertEquals(4, configs.length);
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
buildInfo.setDefaultConfiguration(newProject.getConfiguration(configs[0].getId()));
-
+ buildInfo.setValid(true);
// Save, close, reopen
ManagedBuildManager.saveBuildInfo(project, true);
ManagedBuildManager.removeBuildInfo(project);
@@ -551,6 +551,8 @@ public class ManagedBuildCoreTests20 extends TestCase {
defaultConfig.setArtifactName(buildArtifactName);
defaultConfig.setArtifactExtension(newExt);
+ ManagedBuildManager.getBuildInfo(project).setValid(true);
+
// Initialize the path entry container
IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
if (initResult.getCode() != IStatus.OK) {
@@ -1781,6 +1783,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
assertEquals(newProj.getName(), projType.getName());
ManagedBuildManager.setNewProjectVersion(project);
+ ManagedBuildManager.getBuildInfo(project).setValid(true);
// Initialize the path entry container
IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
if (initResult.getCode() != IStatus.OK) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java
index 092dafc2d92..79019c1c14d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java
@@ -10,10 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@@ -21,7 +23,6 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -165,7 +166,7 @@ public class ManagedBuildEnvironmentTests extends TestCase {
assertNotNull(envProvider.getVariable(NAME_CWD, cfg, true, false));
assertNotNull(envProvider.getVariable(NAME_PWD, cfg, true, false));
}
-
+/*
public void testEnvSuppliers() {
doInit();
@@ -203,7 +204,7 @@ public class ManagedBuildEnvironmentTests extends TestCase {
}
}
}
-
+*/
/*
* plugin.xml contents:
<projectType id="cdt.managedbuild.target.testgnu.exe">
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java
index 5b3c2df2033..f0a1e82f4cd 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java
@@ -20,6 +20,7 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@@ -34,10 +35,8 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.UserDefinedMacroSupplier;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
@@ -53,6 +52,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+
public class ManagedBuildMacrosTests extends TestCase {
static IProject proj = null;
static IManagedProject mproj = null;
@@ -112,7 +112,7 @@ public class ManagedBuildMacrosTests extends TestCase {
/**
* testMacroConf()
*/
- public void testMacroConf(){
+/* public void testMacroConf(){
doInit();
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
assertNotNull(ms);
@@ -129,11 +129,11 @@ public class ManagedBuildMacrosTests extends TestCase {
TEST, "NEW_FOR_CFG" }; //$NON-NLS-1$
assertTrue(arrayContains(b, a));
}
-
+*/
/**
* testMacroEEnv()
*/
- public void testMacroEEnv(){
+/* public void testMacroEEnv(){
doInit();
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_ECLIPSEENV, null);
assertNotNull(ms);
@@ -144,11 +144,11 @@ public class ManagedBuildMacrosTests extends TestCase {
// String[] b = {"PATH", "USERNAME"}; //$NON-NLS-1$ //$NON-NLS-2$
// assertTrue(arrayContains(b, a));
}
-
+*/
/**
* testMacroInst()
*/
- public void testMacroInst(){
+/* public void testMacroInst(){
doInit();
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_INSTALLATIONS, null);
assertNotNull(ms);
@@ -160,75 +160,75 @@ public class ManagedBuildMacrosTests extends TestCase {
"EclipseVersion", "HostOsName", "CDTVersion"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue(arrayContains(b, a));
}
-
+*/
/**
* testMacroProj()
*/
- public void testMacroProj(){
- doInit();
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
- assertNotNull(ms);
- assertEquals(ms.length, 4);
- assertTrue(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_PROJECT],
- IBuildMacroProvider.CONTEXT_PROJECT, mproj));
- functionCalled = 0;
- String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, mproj, flag), "Project "); //$NON-NLS-1$
- assertEquals(GET_MANY_PROJECT, functionCalled);
- String[] b = {"ProjDirPath", "ProjName", //$NON-NLS-1$ //$NON-NLS-2$
- TEST, "NEW_FOR_PRJ"}; //$NON-NLS-1$
- assertTrue(arrayContains(b, a));
- }
+// public void testMacroProj(){
+// doInit();
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
+// assertNotNull(ms);
+// assertEquals(ms.length, 4);
+// assertTrue(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_PROJECT],
+// IBuildMacroProvider.CONTEXT_PROJECT, mproj));
+// functionCalled = 0;
+// String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, mproj, flag), "Project "); //$NON-NLS-1$
+// assertEquals(GET_MANY_PROJECT, functionCalled);
+// String[] b = {"ProjDirPath", "ProjName", //$NON-NLS-1$ //$NON-NLS-2$
+// TEST, "NEW_FOR_PRJ"}; //$NON-NLS-1$
+// assertTrue(arrayContains(b, a));
+// }
/**
* testMacroWrks()
*/
- public void testMacroWrks(){
- doInit();
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
- assertNotNull(ms);
- assertEquals(ms.length, 5);
- assertTrue(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_WORKSPACE],
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
- String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag), "Workspace "); //$NON-NLS-1$
- String[] b = {"DirectoryDelimiter", "WorkspaceDirPath", //$NON-NLS-1$ //$NON-NLS-2$
- "PathDelimiter", TEST}; //$NON-NLS-1$
- assertTrue(arrayContains(b, a));
- }
+// public void testMacroWrks(){
+// doInit();
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
+// assertNotNull(ms);
+// assertEquals(ms.length, 5);
+// assertTrue(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_WORKSPACE],
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+// String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag), "Workspace "); //$NON-NLS-1$
+// String[] b = {"DirectoryDelimiter", "WorkspaceDirPath", //$NON-NLS-1$ //$NON-NLS-2$
+// "PathDelimiter", TEST}; //$NON-NLS-1$
+// assertTrue(arrayContains(b, a));
+// }
/**
* testMacroOptn()
*/
- public void testMacroOptS(){
- doInit();
- IToolChain tc = cfgs[0].getToolChain();
- ITool t = cfgs[0].getTools()[0];
- IOption opt = t.getOptionById(OPT_IDS);
- assertNotNull(opt);
-
- // standard check of suppliers # and attempt to add macro (should fail)
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
- assertNotNull(ms);
- assertEquals(ms.length, 1);
- assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_OPTION], IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t)));
-
- // modify value and check that macros is resolved
- try {
- opt = cfgs[0].setOption(t, opt, "222 " + INC_DEF); //$NON-NLS-1$
- String a = mp.resolveValue(opt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
- assertEquals(a, "222 111"); //$NON-NLS-1$
- } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
- catch (BuildException e) { fail(e.getLocalizedMessage()); }
-
- // Create resource configuration
- IResourceConfiguration rc = cfgs[0].createResourceConfiguration(getFile());
- assertNotNull(rc);
- IOption ropt = rc.getTools()[0].getOptionById(OPT_IDS);
- try {
- ropt = rc.setOption(rc.getTools()[0], ropt, "333 " + INC_DEF); //$NON-NLS-1$
- String a = mp.resolveValue(ropt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
- assertEquals(a, "333 111"); //$NON-NLS-1$
- } catch (Exception e) { fail(e.getLocalizedMessage()); }
- }
+// public void testMacroOptS(){
+// doInit();
+// IToolChain tc = cfgs[0].getToolChain();
+// ITool t = cfgs[0].getTools()[0];
+// IOption opt = t.getOptionById(OPT_IDS);
+// assertNotNull(opt);
+//
+// // standard check of suppliers # and attempt to add macro (should fail)
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
+// assertNotNull(ms);
+// assertEquals(ms.length, 1);
+// assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_OPTION], IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t)));
+//
+// // modify value and check that macros is resolved
+// try {
+// opt = cfgs[0].setOption(t, opt, "222 " + INC_DEF); //$NON-NLS-1$
+// String a = mp.resolveValue(opt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
+// assertEquals(a, "222 111"); //$NON-NLS-1$
+// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
+// catch (BuildException e) { fail(e.getLocalizedMessage()); }
+//
+// // Create resource configuration
+// IResourceConfiguration rc = cfgs[0].createResourceConfiguration(getFile());
+// assertNotNull(rc);
+// IOption ropt = rc.getTools()[0].getOptionById(OPT_IDS);
+// try {
+// ropt = rc.setOption(rc.getTools()[0], ropt, "333 " + INC_DEF); //$NON-NLS-1$
+// String a = mp.resolveValue(ropt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
+// assertEquals(a, "333 111"); //$NON-NLS-1$
+// } catch (Exception e) { fail(e.getLocalizedMessage()); }
+// }
public void testMacroOptL(){
@@ -273,124 +273,124 @@ public class ManagedBuildMacrosTests extends TestCase {
/**
* testMacroFile()
*/
- public void testMacroFile(){
- final String EIN = "ein.c"; //$NON-NLS-1$
- final String AUS = "aus.o"; //$NON-NLS-1$
- final String UP2W = "..\\..\\"; //$NON-NLS-1$
- final String UP2U = "../../"; //$NON-NLS-1$
- final String KLMN = "\\k\\l\\m\\n\\o\\p\\"; //$NON-NLS-1$
- final String[] names =
- {"InputFileName", "InputFileExt", "InputFileBaseName", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "InputFileRelPath", "InputDirRelPath", //$NON-NLS-1$ //$NON-NLS-2$
- "OutputFileName", "OutputFileExt", "OutputFileBaseName",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "OutputFileRelPath", "OutputDirRelPath"}; //$NON-NLS-1$ //$NON-NLS-2$
- String[] values0wAbs =
- {"a.f77", "f77", "a", "\\xz\\a.f77", "\\xz\\", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- "b.exe", "exe", "b", "\\tmp\\b.exe", "\\tmp\\"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- final String[] values0wRel =
- {EIN, "c", "ein", UP2W+EIN, UP2W, //$NON-NLS-1$ //$NON-NLS-2$
- AUS, "o", "aus", UP2W+AUS, UP2W}; //$NON-NLS-1$ //$NON-NLS-2$
-
- final String[] values0u =
- {EIN, "c", "ein", UP2U+EIN, UP2U, //$NON-NLS-1$ //$NON-NLS-2$
- AUS, "o", "aus", UP2U+AUS, UP2U}; //$NON-NLS-1$ //$NON-NLS-2$
-
- final String[] values1 =
- {"$(notdir $<)", "$(suffix $(notdir $<))", //$NON-NLS-1$ //$NON-NLS-2$
- "$(basename $(notdir $<))", "$<", "$(dir $<)", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "$(notdir $@)", "$(suffix $(notdir $@))", //$NON-NLS-1$ //$NON-NLS-2$
- "$(basename $(notdir $@))", "$@", "$(dir $@)"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- FileContextData fd = null;
-
- doInit();
- ITool t = cfgs[0].getTools()[0];
- assertNotNull(t);
- IOption opt = t.getOptionById(OPT_IDS);
-
- String dir=null;
- try {
- dir = mp.getMacro("WorkspaceDirPath", IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag).getStringValue(); //$NON-NLS-1$
- } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
- IPath p = (new Path(dir)).addTrailingSeparator();
-
- if (windows) {
- // check behaviour in case of different disks usage
-
- // config #4 has changed BuilderMakeFileGenerator, #0 has standard one
- IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", cfgs[0], false, true); //$NON-NLS-1$
- String dev0 = Path.fromOSString(cwdvar.getValue()).getDevice().toUpperCase();
- String dev1 = (dev0.startsWith("C")) ? "D:" : "C:"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- values0wAbs[3] = dev1 + values0wAbs[3];
- values0wAbs[4] = dev1 + values0wAbs[4];
- values0wAbs[8] = dev1 + values0wAbs[8];
- values0wAbs[9] = dev1 + values0wAbs[9];
-
- fd = new FileContextData(new Path(values0wAbs[3]), new Path(values0wAbs[8]),opt,t);
- for (int i=0; i<names.length; i++)
- try {
- assertEquals(values0wAbs[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
-
- // check that relative path are reported OK
- fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
- for (int i=0; i<names.length; i++)
- try {
- assertEquals(values0wRel[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
-
- //TODO:
- // check paths using changed BuilderMakeFileGenerator in cfg "Five"
-/*
- int index = 4;
- ManagedBuildManager.setDefaultConfiguration(proj, cfgs[index]);
- OptionContextData op = new OptionContextData(cfgs[index].getTools()[0].getOptions()[0], cfgs[index].getToolChain());
- String p0 = dev0 + KLMN;
- fd = new FileContextData(new Path(p0+EIN), new Path(p0+AUS), op);
- assertNotNull(fd);
- //TODO: the same dir, upper dir, lower dir
- try {
- TestMacro.topBuildDir = Path.fromOSString(p0);
- assertEquals(p0+EIN, mp.getMacro(names[3], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- assertEquals(p0, mp.getMacro(names[4], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- assertEquals(p0+AUS, mp.getMacro(names[8], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- assertEquals(p0, mp.getMacro(names[9], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
-// p0 = Path.fromOSString(p0).removeLastSegments(2).addTrailingSeparator().toOSString();
-// p0 = dev0+KLMN+"x\\";
-// TestMacro.topBuildDir = Path.fromOSString(p0);
- assertEquals(p0+EIN, mp.getMacro(names[3], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- assertEquals(p0, mp.getMacro(names[4], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- assertEquals(p0+AUS, mp.getMacro(names[8], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- assertEquals(p0, mp.getMacro(names[9], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
-// */
-
-
- } else {
- // check relative path only
- fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
- for (int i=0; i<names.length; i++)
- try {
- assertEquals(values0u[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
- }
-
- // check supplier's parameters
- assertNotNull(fd);
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_FILE, fd);
- assertNotNull(ms);
- assertEquals(ms.length, 1);
- assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT,
- TST[IBuildMacroProvider.CONTEXT_FILE], IBuildMacroProvider.CONTEXT_FILE, fd));
-
- // For config #3, macros should contain lines specified in plugin.xml
- opt = cfgs[1].getTools()[0].getOptions()[0];
- fd = new FileContextData(p.append(EIN), p.append(AUS),opt,cfgs[1].getTools()[0]);
- for (int i=0; i<names.length; i++)
- try {
- assertEquals(values1[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
- } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
- }
+// public void testMacroFile(){
+// final String EIN = "ein.c"; //$NON-NLS-1$
+// final String AUS = "aus.o"; //$NON-NLS-1$
+// final String UP2W = "..\\..\\"; //$NON-NLS-1$
+// final String UP2U = "../../"; //$NON-NLS-1$
+// final String KLMN = "\\k\\l\\m\\n\\o\\p\\"; //$NON-NLS-1$
+// final String[] names =
+// {"InputFileName", "InputFileExt", "InputFileBaseName", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+// "InputFileRelPath", "InputDirRelPath", //$NON-NLS-1$ //$NON-NLS-2$
+// "OutputFileName", "OutputFileExt", "OutputFileBaseName",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+// "OutputFileRelPath", "OutputDirRelPath"}; //$NON-NLS-1$ //$NON-NLS-2$
+// String[] values0wAbs =
+// {"a.f77", "f77", "a", "\\xz\\a.f77", "\\xz\\", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+// "b.exe", "exe", "b", "\\tmp\\b.exe", "\\tmp\\"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+// final String[] values0wRel =
+// {EIN, "c", "ein", UP2W+EIN, UP2W, //$NON-NLS-1$ //$NON-NLS-2$
+// AUS, "o", "aus", UP2W+AUS, UP2W}; //$NON-NLS-1$ //$NON-NLS-2$
+//
+// final String[] values0u =
+// {EIN, "c", "ein", UP2U+EIN, UP2U, //$NON-NLS-1$ //$NON-NLS-2$
+// AUS, "o", "aus", UP2U+AUS, UP2U}; //$NON-NLS-1$ //$NON-NLS-2$
+//
+// final String[] values1 =
+// {"$(notdir $<)", "$(suffix $(notdir $<))", //$NON-NLS-1$ //$NON-NLS-2$
+// "$(basename $(notdir $<))", "$<", "$(dir $<)", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+// "$(notdir $@)", "$(suffix $(notdir $@))", //$NON-NLS-1$ //$NON-NLS-2$
+// "$(basename $(notdir $@))", "$@", "$(dir $@)"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+//
+// FileContextData fd = null;
+//
+// doInit();
+// ITool t = cfgs[0].getTools()[0];
+// assertNotNull(t);
+// IOption opt = t.getOptionById(OPT_IDS);
+//
+// String dir=null;
+// try {
+// dir = mp.getMacro("WorkspaceDirPath", IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag).getStringValue(); //$NON-NLS-1$
+// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
+// IPath p = (new Path(dir)).addTrailingSeparator();
+//
+// if (windows) {
+// // check behaviour in case of different disks usage
+//
+// // config #4 has changed BuilderMakeFileGenerator, #0 has standard one
+// IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", cfgs[0], false, true); //$NON-NLS-1$
+// String dev0 = Path.fromOSString(cwdvar.getValue()).getDevice().toUpperCase();
+// String dev1 = (dev0.startsWith("C")) ? "D:" : "C:"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+// values0wAbs[3] = dev1 + values0wAbs[3];
+// values0wAbs[4] = dev1 + values0wAbs[4];
+// values0wAbs[8] = dev1 + values0wAbs[8];
+// values0wAbs[9] = dev1 + values0wAbs[9];
+//
+// fd = new FileContextData(new Path(values0wAbs[3]), new Path(values0wAbs[8]),opt,t);
+// for (int i=0; i<names.length; i++)
+// try {
+// assertEquals(values0wAbs[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
+//
+// // check that relative path are reported OK
+// fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
+// for (int i=0; i<names.length; i++)
+// try {
+// assertEquals(values0wRel[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
+//
+//// //TODO:
+//// // check paths using changed BuilderMakeFileGenerator in cfg "Five"
+/////*
+//// int index = 4;
+//// ManagedBuildManager.setDefaultConfiguration(proj, cfgs[index]);
+//// OptionContextData op = new OptionContextData(cfgs[index].getTools()[0].getOptions()[0], cfgs[index].getToolChain());
+//// String p0 = dev0 + KLMN;
+//// fd = new FileContextData(new Path(p0+EIN), new Path(p0+AUS), op);
+//// assertNotNull(fd);
+//// //TODO: the same dir, upper dir, lower dir
+//// try {
+//// TestMacro.topBuildDir = Path.fromOSString(p0);
+//// assertEquals(p0+EIN, mp.getMacro(names[3], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+//// assertEquals(p0, mp.getMacro(names[4], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+//// assertEquals(p0+AUS, mp.getMacro(names[8], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+//// assertEquals(p0, mp.getMacro(names[9], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+////// p0 = Path.fromOSString(p0).removeLastSegments(2).addTrailingSeparator().toOSString();
+////// p0 = dev0+KLMN+"x\\";
+////// TestMacro.topBuildDir = Path.fromOSString(p0);
+//// assertEquals(p0+EIN, mp.getMacro(names[3], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+//// assertEquals(p0, mp.getMacro(names[4], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+//// assertEquals(p0+AUS, mp.getMacro(names[8], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+//// assertEquals(p0, mp.getMacro(names[9], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+//// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
+////// */
+//
+//
+// } else {
+// // check relative path only
+// fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
+// for (int i=0; i<names.length; i++)
+// try {
+// assertEquals(values0u[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
+// }
+//
+// // check supplier's parameters
+// assertNotNull(fd);
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_FILE, fd);
+// assertNotNull(ms);
+// assertEquals(ms.length, 1);
+// assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT,
+// TST[IBuildMacroProvider.CONTEXT_FILE], IBuildMacroProvider.CONTEXT_FILE, fd));
+//
+// // For config #3, macros should contain lines specified in plugin.xml
+// opt = cfgs[1].getTools()[0].getOptions()[0];
+// fd = new FileContextData(p.append(EIN), p.append(AUS),opt,cfgs[1].getTools()[0]);
+// for (int i=0; i<names.length; i++)
+// try {
+// assertEquals(values1[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
+// } catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
+// }
@@ -418,58 +418,58 @@ public class ManagedBuildMacrosTests extends TestCase {
/**
* testMacroResolve()
*/
- public void testMacroResolve(){
- doInit();
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
- assertNotNull(ms);
- String[] lst = {"SCHEISE", "MERDE", "SHIT"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertTrue(addMacro("LST", IBuildMacro.VALUE_TEXT_LIST, lst, //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
- assertTrue(addMacro("ONE", IBuildMacro.VALUE_TEXT, "EIN", //$NON-NLS-1$ //$NON-NLS-2$
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
- //
- assertTrue(addMacro("L1", IBuildMacro.VALUE_TEXT, "nested L1-${L2}-L1", //$NON-NLS-1$ //$NON-NLS-2$
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
- assertTrue(addMacro("L2", IBuildMacro.VALUE_TEXT, "L2-${L3}-L2", //$NON-NLS-1$ //$NON-NLS-2$
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
- assertTrue(addMacro("L3", IBuildMacro.VALUE_TEXT, "L3-${L4}-L3", //$NON-NLS-1$ //$NON-NLS-2$
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
- assertTrue(addMacro("L4", IBuildMacro.VALUE_TEXT, "L4", //$NON-NLS-1$ //$NON-NLS-2$
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
-
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
- assertNotNull(ms);
- assertTrue(addMacro("TWO", IBuildMacro.VALUE_TEXT, "ZWEI", //$NON-NLS-1$ //$NON-NLS-2$
- IBuildMacroProvider.CONTEXT_PROJECT, mproj));
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
- assertNotNull(ms);
- assertTrue(addMacro("three", IBuildMacro.VALUE_TEXT, "DREI", //$NON-NLS-1$ //$NON-NLS-2$
- IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]));
-
-
- // check normal workflow
- try {
- final String pattern = "${ONE} - ${TWO} - ${three} -> ${LST}"; //$NON-NLS-1$
- String a = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
- IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
- String b = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
- IBuildMacroProvider.CONTEXT_PROJECT, mproj);
- String c = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
- String d = mp.resolveValue("${L1}", UNKNOWN, LISTSEP, //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
- String e = mp.resolveValue("${one} - ${Two} - ${THREE} -> ${lst}", UNKNOWN, LISTSEP, //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
-
- assertEquals(a, "EIN - ZWEI - DREI -> SCHEISE|MERDE|SHIT"); //$NON-NLS-1$
- assertEquals(b, "EIN - ZWEI - <HZ> -> SCHEISE|MERDE|SHIT"); //$NON-NLS-1$
- assertEquals(c, "EIN - <HZ> - <HZ> -> SCHEISE|MERDE|SHIT"); //$NON-NLS-1$
- assertEquals(d, "nested L1-L2-L3-L4-L3-L2-L1"); //$NON-NLS-1$
- assertEquals(e, "<HZ> - <HZ> - <HZ> -> <HZ>"); //$NON-NLS-1$
- } catch (BuildMacroException e) {
- fail("Exception while resolving: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
+// public void testMacroResolve(){
+// doInit();
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
+// assertNotNull(ms);
+// String[] lst = {"SCHEISE", "MERDE", "SHIT"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+// assertTrue(addMacro("LST", IBuildMacro.VALUE_TEXT_LIST, lst, //$NON-NLS-1$
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+// assertTrue(addMacro("ONE", IBuildMacro.VALUE_TEXT, "EIN", //$NON-NLS-1$ //$NON-NLS-2$
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+// //
+// assertTrue(addMacro("L1", IBuildMacro.VALUE_TEXT, "nested L1-${L2}-L1", //$NON-NLS-1$ //$NON-NLS-2$
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+// assertTrue(addMacro("L2", IBuildMacro.VALUE_TEXT, "L2-${L3}-L2", //$NON-NLS-1$ //$NON-NLS-2$
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+// assertTrue(addMacro("L3", IBuildMacro.VALUE_TEXT, "L3-${L4}-L3", //$NON-NLS-1$ //$NON-NLS-2$
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+// assertTrue(addMacro("L4", IBuildMacro.VALUE_TEXT, "L4", //$NON-NLS-1$ //$NON-NLS-2$
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+//
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
+// assertNotNull(ms);
+// assertTrue(addMacro("TWO", IBuildMacro.VALUE_TEXT, "ZWEI", //$NON-NLS-1$ //$NON-NLS-2$
+// IBuildMacroProvider.CONTEXT_PROJECT, mproj));
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
+// assertNotNull(ms);
+// assertTrue(addMacro("three", IBuildMacro.VALUE_TEXT, "DREI", //$NON-NLS-1$ //$NON-NLS-2$
+// IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]));
+//
+//
+// // check normal workflow
+// try {
+// final String pattern = "${ONE} - ${TWO} - ${three} -> ${LST}"; //$NON-NLS-1$
+// String a = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
+// IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
+// String b = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
+// IBuildMacroProvider.CONTEXT_PROJECT, mproj);
+// String c = mp.resolveValue(pattern, UNKNOWN, LISTSEP,
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
+// String d = mp.resolveValue("${L1}", UNKNOWN, LISTSEP, //$NON-NLS-1$
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
+// String e = mp.resolveValue("${one} - ${Two} - ${THREE} -> ${lst}", UNKNOWN, LISTSEP, //$NON-NLS-1$
+// IBuildMacroProvider.CONTEXT_CONFIGURATION, cfgs[0]);
+//
+// assertEquals(a, "EIN - ZWEI - DREI -> SCHEISE|MERDE|SHIT"); //$NON-NLS-1$
+// assertEquals(b, "EIN - ZWEI - <HZ> -> SCHEISE|MERDE|SHIT"); //$NON-NLS-1$
+// assertEquals(c, "EIN - <HZ> - <HZ> -> SCHEISE|MERDE|SHIT"); //$NON-NLS-1$
+// assertEquals(d, "nested L1-L2-L3-L4-L3-L2-L1"); //$NON-NLS-1$
+// assertEquals(e, "<HZ> - <HZ> - <HZ> -> <HZ>"); //$NON-NLS-1$
+// } catch (BuildMacroException e) {
+// fail("Exception while resolving: " + e.getLocalizedMessage()); //$NON-NLS-1$
+// }
+// }
/**
* testMacroResolveExceptions()
@@ -499,55 +499,56 @@ public class ManagedBuildMacrosTests extends TestCase {
/**
* testMacroResolveLoop()
*/
- public void testMacroResolveLoop() {
- doInit();
- int ctx = IBuildMacroProvider.CONTEXT_WORKSPACE;
- Object obj = worksp;
- ms = mp.getSuppliers(ctx, obj);
- assertNotNull(ms);
-
- // check state before macros added (should be OK)
- try {
- mp.checkIntegrity(ctx, obj);
- } catch (BuildMacroException e) {
- fail("Macros integrity check is failed"); //$NON-NLS-1$
- }
-
- // create macro which references to undefined macro
- assertTrue(addMacro("B1", IBuildMacro.VALUE_TEXT, "B1-${B2}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
- rmMacro("B2", ctx, obj); // usually it does not exist, but to be sure... //$NON-NLS-1$
-
- // check state after macro added (should be exception)
- try {
- mp.checkIntegrity(ctx, obj);
- fail("Macros misintegrity (ref to undefined) is not detected"); //$NON-NLS-1$
- } catch (BuildMacroException e) {}
-
- // create "dead loop" of nested macros
- assertTrue(addMacro("B2", IBuildMacro.VALUE_TEXT, "B2-${B3}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(addMacro("B3", IBuildMacro.VALUE_TEXT, "B3-${B1}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // check state after macros added (should be exception)
- try {
- mp.checkIntegrity(ctx, obj);
- fail("Macros misintegrity (dead loop) is not detected"); //$NON-NLS-1$
- } catch (BuildMacroException e) {}
-
- // remove "dead loop" of nested macros
- assertTrue(rmMacro("B1", ctx, obj)); //$NON-NLS-1$
- assertTrue(rmMacro("B2", ctx, obj)); //$NON-NLS-1$
- assertTrue(rmMacro("B3", ctx, obj)); //$NON-NLS-1$
-
- // check state after macros removed (should be OK)
- try {
- mp.checkIntegrity(ctx, obj);
- } catch (BuildMacroException e) {
- fail("Macros integrity check is failed " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
+// public void testMacroResolveLoop() {
+// doInit();
+// int ctx = IBuildMacroProvider.CONTEXT_WORKSPACE;
+// Object obj = worksp;
+// ms = mp.getSuppliers(ctx, obj);
+// assertNotNull(ms);
+//
+// // check state before macros added (should be OK)
+// try {
+// mp.checkIntegrity(ctx, obj);
+// } catch (BuildMacroException e) {
+// fail("Macros integrity check is failed"); //$NON-NLS-1$
+// }
+//
+// // create macro which references to undefined macro
+// assertTrue(addMacro("B1", IBuildMacro.VALUE_TEXT, "B1-${B2}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
+// rmMacro("B2", ctx, obj); // usually it does not exist, but to be sure... //$NON-NLS-1$
+//
+// // check state after macro added (should be exception)
+// try {
+// mp.checkIntegrity(ctx, obj);
+// fail("Macros misintegrity (ref to undefined) is not detected"); //$NON-NLS-1$
+// } catch (BuildMacroException e) {}
+//
+// // create "dead loop" of nested macros
+// assertTrue(addMacro("B2", IBuildMacro.VALUE_TEXT, "B2-${B3}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
+// assertTrue(addMacro("B3", IBuildMacro.VALUE_TEXT, "B3-${B1}", ctx, obj)); //$NON-NLS-1$ //$NON-NLS-2$
+//
+// // check state after macros added (should be exception)
+// try {
+// mp.checkIntegrity(ctx, obj);
+// fail("Macros misintegrity (dead loop) is not detected"); //$NON-NLS-1$
+// } catch (BuildMacroException e) {}
+//
+// // remove "dead loop" of nested macros
+// assertTrue(rmMacro("B1", ctx, obj)); //$NON-NLS-1$
+// assertTrue(rmMacro("B2", ctx, obj)); //$NON-NLS-1$
+// assertTrue(rmMacro("B3", ctx, obj)); //$NON-NLS-1$
+//
+// // check state after macros removed (should be OK)
+// try {
+// mp.checkIntegrity(ctx, obj);
+// } catch (BuildMacroException e) {
+// fail("Macros integrity check is failed " + e.getLocalizedMessage()); //$NON-NLS-1$
+// }
+// }
/**
* testMacroResolveMake()
*/
+ /*
public void testMacroResolveMake(){
final String p1 = "USERNAME: "; //$NON-NLS-1$
final String p2 = "${USERNAME} "; //$NON-NLS-1$
@@ -598,6 +599,7 @@ public class ManagedBuildMacrosTests extends TestCase {
fail(e.getLocalizedMessage());
}
}
+ */
/**
* testMacroResolveCase()
@@ -635,39 +637,39 @@ public class ManagedBuildMacrosTests extends TestCase {
* testMacroSave()
*/
- public void testMacroSave(){
- final String TO_SAVE_P = "TO_SAVE_P"; //$NON-NLS-1$
- final String TO_SAVE_W = "TO_SAVE_W"; //$NON-NLS-1$
- doInit();
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
- assertNotNull(ms);
- assertTrue(addMacro(TO_SAVE_P, IBuildMacro.VALUE_TEXT, TO_SAVE_P,
- IBuildMacroProvider.CONTEXT_PROJECT, mproj));
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
- assertNotNull(ms);
- assertTrue(addMacro(TO_SAVE_W, IBuildMacro.VALUE_TEXT, TO_SAVE_W,
- IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
- try {
- // Save the buildinfo, and then remove it, to be complete
- ManagedBuildManager.saveBuildInfo(proj, true);
- ManagedBuildManager.removeBuildInfo(proj);
- proj.close(null);
- proj.open(null);
- } catch (CoreException e) {
- fail("Failed on project close/open: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
- assertNotNull(ms);
- String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, mproj, flag), TO_SAVE_P);
- String[] b1 = {TO_SAVE_P};
- assertTrue(arrayContains(b1, a));
-
- ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
- assertNotNull(ms);
- a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag), TO_SAVE_W);
- String[] b2 = {TO_SAVE_W};
- assertTrue(arrayContains(b2, a));
- }
+// public void testMacroSave(){
+// final String TO_SAVE_P = "TO_SAVE_P"; //$NON-NLS-1$
+// final String TO_SAVE_W = "TO_SAVE_W"; //$NON-NLS-1$
+// doInit();
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
+// assertNotNull(ms);
+// assertTrue(addMacro(TO_SAVE_P, IBuildMacro.VALUE_TEXT, TO_SAVE_P,
+// IBuildMacroProvider.CONTEXT_PROJECT, mproj));
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
+// assertNotNull(ms);
+// assertTrue(addMacro(TO_SAVE_W, IBuildMacro.VALUE_TEXT, TO_SAVE_W,
+// IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
+// try {
+// // Save the buildinfo, and then remove it, to be complete
+// ManagedBuildManager.saveBuildInfo(proj, true);
+// ManagedBuildManager.removeBuildInfo(proj);
+// proj.close(null);
+// proj.open(null);
+// } catch (CoreException e) {
+// fail("Failed on project close/open: " + e.getLocalizedMessage()); //$NON-NLS-1$
+// }
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_PROJECT, mproj);
+// assertNotNull(ms);
+// String[] a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, mproj, flag), TO_SAVE_P);
+// String[] b1 = {TO_SAVE_P};
+// assertTrue(arrayContains(b1, a));
+//
+// ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp);
+// assertNotNull(ms);
+// a = printMacros(mp.getMacros(IBuildMacroProvider.CONTEXT_WORKSPACE, worksp, flag), TO_SAVE_W);
+// String[] b2 = {TO_SAVE_W};
+// assertTrue(arrayContains(b2, a));
+// }
/*
* Below are service methods
@@ -816,7 +818,7 @@ public class ManagedBuildMacrosTests extends TestCase {
* @param obj
* @return
*/
- private boolean addMacro(String name, int type, String value, int context, Object obj) {
+ /*private boolean addMacro(String name, int type, String value, int context, Object obj) {
assertNotNull(ms);
for(int i=0; i<ms.length; i++) {
if (ms[i] instanceof UserDefinedMacroSupplier) {
@@ -824,7 +826,7 @@ public class ManagedBuildMacrosTests extends TestCase {
}
}
return false;
- }
+ }*/
/**
* addMacro
* @param name
@@ -834,7 +836,7 @@ public class ManagedBuildMacrosTests extends TestCase {
* @param obj
* @return
*/
- private boolean addMacro(String name, int type, String[] value, int context, Object obj) {
+/* private boolean addMacro(String name, int type, String[] value, int context, Object obj) {
assertNotNull(ms);
for(int i=0; i<ms.length; i++) {
if (ms[i] instanceof UserDefinedMacroSupplier) {
@@ -842,7 +844,7 @@ public class ManagedBuildMacrosTests extends TestCase {
}
}
return false;
- }
+ }*/
/**
* rmMacro
* @param name - name of macro
@@ -850,7 +852,7 @@ public class ManagedBuildMacrosTests extends TestCase {
* @param obj
* @return
*/
- private boolean rmMacro(String name, int context, Object obj) {
+/* private boolean rmMacro(String name, int context, Object obj) {
assertNotNull(ms);
for(int i=0; i<ms.length; i++) {
if (ms[i] instanceof UserDefinedMacroSupplier) {
@@ -859,7 +861,7 @@ public class ManagedBuildMacrosTests extends TestCase {
}
return false;
}
-
+ */
/*
* addVars() - adds macros for testMacroResolveCase
*/
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestMacro.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestMacro.java
index cf4908ec273..889e0e7008b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestMacro.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestMacro.java
@@ -35,9 +35,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-/**
- *
- */
/**
*
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java
new file mode 100644
index 00000000000..d6f4914e14e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java
@@ -0,0 +1,819 @@
+package org.eclipse.cdt.projectmodel.tests;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.IElementChangedListener;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+public class ProjectModelTests extends TestCase implements IElementChangedListener{
+ private CModelEventChecker fEventChecker;
+
+ public void elementChanged(ElementChangedEvent event) {
+ if(fEventChecker != null)
+ fEventChecker.checkEvent(event);
+ }
+
+ private class CModelEventChecker {
+ private boolean fEventOccured;
+
+ void checkEvent(ElementChangedEvent event){
+ fEventOccured = true;
+ }
+
+ }
+
+ private class CDefaultModelEventChecker extends CModelEventChecker{
+
+ void checkEvent(ElementChangedEvent event) {
+ super.checkEvent(event);
+
+ assertEquals(ElementChangedEvent.POST_CHANGE, event.getType());
+
+ ICElementDelta delta = event.getDelta();
+ System.out.println(delta.toString());
+ }
+
+ }
+
+
+
+ public static Test suite() {
+ return new TestSuite(ProjectModelTests.class);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ fEventChecker = null;
+ CoreModel.getDefault().addElementChangedListener(this);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fEventChecker = null;
+ CoreModel.getDefault().removeElementChangedListener(this);
+ }
+
+ public void testDescription() throws Exception{
+ final String projectName = "test1";
+ IProject project = createProject(projectName);
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescription des = coreModel.getProjectDescription(project);
+ assertNull("detDescription1 returned not null!", des);
+
+ des = coreModel.createProjectDescription(project, true);
+ assertNotNull("createDescription returned null!", des);
+
+ assertNull("detDescription2 returned not null!", coreModel.getProjectDescription(project));
+
+ assertFalse("new des should be not valid", des.isValid());
+
+ assertEquals(0, des.getConfigurations().length);
+
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ IProjectType type = ManagedBuildManager.getProjectType("cdt.managedbuild.target.gnu30.exe");
+ assertNotNull("project type not found", type);
+
+ ManagedProject mProj = new ManagedProject(project, type);
+ info.setManagedProject(mProj);
+
+ IConfiguration cfgs[] = type.getConfigurations();
+
+
+ for(int i = 0; i < cfgs.length; i++){
+ String id = ManagedBuildManager.calculateChildId(cfgs[i].getId(), null);
+ Configuration config = new Configuration(mProj, (Configuration)cfgs[i], id, false, true, false);
+ CConfigurationData data = config.getConfigurationData();
+ assertNotNull("data is null for created configuration", data);
+ ICConfigurationDescription cfgDes = des.createConfiguration("org.eclipse.cdt.managedbuilder.core.configurationDataProvider", data);
+ }
+ coreModel.setProjectDescription(project, des);
+
+ IWorkspace wsp = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = wsp.getRoot();
+ project.delete(false, true, new NullProgressMonitor());
+
+ project = root.getProject(projectName);
+ des = coreModel.getProjectDescription(project);
+ assertNull("project description is not null for removed project", des);
+
+ project = createProject(projectName);
+ des = coreModel.getProjectDescription(project);
+ assertNotNull("project description is null for re-created project", des);
+ assertTrue("des should be valid for re-created project", des.isValid());
+
+ ICConfigurationDescription cfgDess[] = des.getConfigurations();
+
+ assertEquals(2, cfgDess.length);
+
+ ICConfigurationDescription cfgDes = cfgDess[0];
+ ICResourceDescription rcDess[] = cfgDes.getResourceDescriptions();
+ assertEquals(1, rcDess.length);
+ assertEquals(cfgDes.getRootFolderDescription(), rcDess[0]);
+ assertFalse(cfgDes.isModified());
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), true));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path("ds/sd/sdf/"), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), true));
+ assertEquals(null, cfgDes.getResourceDescription(new Path("ds/sd/sdf/"), true));
+
+ ICFileDescription fd_abc = cfgDes.createFileDescription(new Path("a/b/c"), rcDess[0]);
+ assertTrue(cfgDes.isModified());
+
+ ICProjectDescription anotherDes = coreModel.getProjectDescription(project);
+ assertNotNull("project description is null for re-created project", des);
+ assertTrue("des should be valid for re-created project", des.isValid());
+
+ ICConfigurationDescription anotherCfgDess[] = anotherDes.getConfigurations();
+
+ assertEquals(2, anotherCfgDess.length);
+
+ ICConfigurationDescription anotherCfgDes = anotherCfgDess[0];
+ ICResourceDescription anotherRcDess[] = anotherCfgDes.getResourceDescriptions();
+ assertEquals(1, anotherRcDess.length);
+ assertEquals(anotherCfgDes.getRootFolderDescription(), anotherRcDess[0]);
+ assertFalse(anotherCfgDes.isModified());
+
+ CConfigurationData cfgData = cfgDes.getConfigurationData();
+ assertEquals(cfgData, cfgDes.getConfigurationData());
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+ IResourceInfo infos[] = cfg.getResourceInfos();
+ assertEquals(2, infos.length);
+
+ ICFolderDescription rf = cfgDes.getRootFolderDescription();
+ ICResourceDescription nestedFis[] = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE);
+ ICResourceDescription nestedFos[] = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ assertEquals(2, cfgDes.getResourceDescriptions().length);
+ assertEquals(0, nestedFos.length);
+ assertEquals(1, nestedFis.length);
+
+ ICFileDescription fd_asd = cfgDes.createFileDescription(new Path("a/s/d"), cfgDes.getRootFolderDescription());
+ assertEquals(3, cfgDes.getResourceDescriptions().length);
+ nestedFis = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE);
+ nestedFos = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ assertEquals(0, nestedFos.length);
+ assertEquals(2, nestedFis.length);
+
+ cfg.createFileInfo(new Path("z/x/c"));
+ nestedFis = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE);
+ nestedFos = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ assertEquals(0, nestedFos.length);
+ assertEquals(3, nestedFis.length);
+ assertEquals(4, cfgDes.getResourceDescriptions().length);
+
+ cfg.createFileInfo(new Path("q/w/e"));
+ ICFileDescription fd_qwe = (ICFileDescription)cfgDes.getResourceDescription(new Path("q/w/e"), true);
+ assertNotNull(fd_qwe);
+ assertEquals(5, cfgDes.getResourceDescriptions().length);
+ nestedFis = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE);
+ nestedFos = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ assertEquals(0, nestedFos.length);
+ assertEquals(4, nestedFis.length);
+
+ cfgDes.removeResourceDescription(fd_abc);
+ nestedFis = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE);
+ nestedFos = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ assertEquals(0, nestedFos.length);
+ assertEquals(3, nestedFis.length);
+ assertEquals(4, cfgDes.getResourceDescriptions().length);
+
+ cfg.removeResourceInfo(new Path("a/s/d"));
+ assertEquals(3, cfgDes.getResourceDescriptions().length);
+ nestedFis = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE);
+ nestedFos = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ assertEquals(0, nestedFos.length);
+ assertEquals(2, nestedFis.length);
+
+ IFileInfo fi_qwe = (IFileInfo)cfg.getResourceInfo(new Path("q/w/e"), true);
+ assertNotNull(fi_qwe);
+
+ ICFileDescription fid_qwe = (ICFileDescription)cfgDes.getResourceDescription(new Path("q/w/e"), true);
+ assertNotNull(fid_qwe);
+ fi_qwe.setPath(new Path("r/t/y"));
+ assertEquals(fi_qwe, cfg.getResourceInfo(new Path("r/t/y"), true));
+ assertNull(cfgDes.getResourceDescription(new Path("q/w/e"), true));
+ ICFileDescription fid_rty = (ICFileDescription)cfgDes.getResourceDescription(new Path("r/t/y"), true);
+ assertEquals(fid_qwe, fid_rty);
+
+ fid_rty.setPath(new Path("f/g/h"));
+ assertNull(cfg.getResourceInfo(new Path("r/t/y"), true));
+ IFileInfo fi_fgh = (IFileInfo)cfg.getResourceInfo(new Path("f/g/h"), true);
+ assertEquals(fi_qwe, fi_fgh);
+
+ ICFolderDescription fod_fg1 = cfgDes.createFolderDescription(new Path("f/g/1"), cfgDes.getRootFolderDescription());
+
+ ICFolderDescription fod_fg12 = cfgDes.createFolderDescription(new Path("f/g/1/2"), fod_fg1);
+ assertEquals(fod_fg12, fod_fg1.getNestedResourceDescription(new Path("2"), true));
+
+ ICFileDescription fid_fg13 = cfgDes.createFileDescription(new Path("f/g/1/3"), fod_fg1);
+ assertEquals(fid_fg13, fod_fg1.getNestedResourceDescription(new Path("3"), true));
+
+ assertEquals(2, fod_fg1.getNestedResourceDescriptions().length);
+ assertEquals(1, fod_fg1.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE).length);
+ assertEquals(1, fod_fg1.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER).length);
+
+ IFolderInfo fo_fg1 = (IFolderInfo)cfg.getResourceInfo(new Path("f/g/1"), true);
+ assertNotNull(fo_fg1);
+
+ fo_fg1.setPath(new Path("t/y/u"));
+
+ assertEquals(2, fod_fg1.getNestedResourceDescriptions().length);
+ assertEquals(1, fod_fg1.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE).length);
+ assertEquals(1, fod_fg1.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER).length);
+
+ assertEquals(fod_fg12, cfgDes.getResourceDescription(new Path("t/y/u/2"), true));
+ assertEquals(fid_fg13, cfgDes.getResourceDescription(new Path("t/y/u/3"), true));
+
+ ICLanguageSetting settings[] = cfgDes.getRootFolderDescription().getLanguageSettings();
+ for(int i = 0; i < settings.length; i++){
+ ICLanguageSetting setting = settings[i];
+ ICLanguageSettingEntry[] entries = setting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ for(int j = 0; j < entries.length; j++){
+ System.out.println(entries[j].getName());
+ }
+ System.out.println(entries.length);
+ }
+ coreModel.setProjectDescription(project, des);
+
+ project.delete(false, true, new NullProgressMonitor());
+
+ project = root.getProject(projectName);
+ des = coreModel.getProjectDescription(project);
+ assertNull("project description is not null for removed project", des);
+
+ project = createProject(projectName);
+ long time = System.currentTimeMillis();
+ des = coreModel.getProjectDescription(project);
+ time = System.currentTimeMillis() - time;
+ System.out.println("time to load = " + time);
+
+ assertNotNull("project description is null for re-created project", des);
+ assertTrue("des should be valid for re-created project", des.isValid());
+
+ cfgDess = des.getConfigurations();
+ cfgDes = cfgDess[0];
+ rf = cfgDes.getRootFolderDescription();
+ settings = rf.getLanguageSettings();
+ ICLanguageSettingEntry updatedEntries[] = null;
+ for(int i = 0; i < settings.length; i++){
+ ICLanguageSetting setting = settings[i];
+ ICLanguageSettingEntry[] entries = setting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ if(entries.length > 0){
+ ICLanguageSettingEntry updated[] = new ICLanguageSettingEntry[entries.length + 1];
+ System.arraycopy(entries, 0, updated, 1, entries.length);
+ updated[0] = new CIncludePathEntry("a/b/c", 0);
+ setting.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, updated);
+ updatedEntries = setting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ assertEquals(updated.length, updatedEntries.length);
+ for(int k = 0; k < updated.length; k++){
+ assertEquals(updated[i].getValue(), updatedEntries[i].getValue());
+ }
+ }
+ }
+
+ fEventChecker = new CDefaultModelEventChecker();
+ coreModel.setProjectDescription(project, des);
+ fEventChecker = null;
+
+ project.delete(false, true, new NullProgressMonitor());
+
+ project = root.getProject(projectName);
+ des = coreModel.getProjectDescription(project);
+ assertNull("project description is not null for removed project", des);
+
+ project = createProject(projectName);
+ time = System.currentTimeMillis();
+ des = coreModel.getProjectDescription(project);
+ time = System.currentTimeMillis() - time;
+ System.out.println("time to load = " + time);
+
+ assertNotNull("project description is null for re-created project", des);
+ assertTrue("des should be valid for re-created project", des.isValid());
+
+ cfgDess = des.getConfigurations();
+ cfgDes = cfgDess[0];
+ rf = cfgDes.getRootFolderDescription();
+ settings = rf.getLanguageSettings();
+
+ for(int i = 0; i < settings.length; i++){
+ ICLanguageSetting setting = settings[i];
+ ICLanguageSettingEntry[] entries = setting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ if(entries.length > 0){
+// ICLanguageSettingEntry updated[] = new ICLanguageSettingEntry[entries.length + 1];
+// System.arraycopy(entries, 0, updated, 1, entries.length);
+// updated[0] = new CIncludePathEntry("a/b/c", 0);
+// setting.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, updated);
+// updatedEntries = setting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ assertEquals(entries.length, updatedEntries.length);
+ for(int k = 0; k < entries.length; k++){
+ assertEquals(entries[i].getValue(), updatedEntries[i].getValue());
+ }
+ }
+ }
+
+ assertEquals(2, cfgDess.length);
+ nestedFis = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FILE);
+ nestedFos = rf.getNestedResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ assertEquals(2, nestedFos.length);
+ assertEquals(3, nestedFis.length);
+
+ assertEquals(6, cfgDes.getResourceDescriptions().length);
+
+ IFolder folder = ManagedBuildTestHelper.createFolder(project, "a/b");
+ ICFolderDescription base = (ICFolderDescription)cfgDes.getResourceDescription(new Path("a/b"), false);
+ ICFolderDescription abFoDes = cfgDes.createFolderDescription(new Path("a/b"), base);
+ ICLanguageSetting ls = abFoDes.getLanguageSettingForFile("a.c");
+ assertNotNull(ls);
+ List list = ls.getSettingEntriesList(ICLanguageSettingEntry.INCLUDE_PATH);
+ list.add(0, new CIncludePathEntry("zzza/b/c", 0));
+ ls.setSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH, list);
+
+ System.out.println("setting entries for non-root folder..\n");
+ fEventChecker = new CDefaultModelEventChecker();
+ coreModel.setProjectDescription(project, des);
+ fEventChecker = null;
+
+ time = System.currentTimeMillis();
+ des = coreModel.getProjectDescription(project);
+ time = System.currentTimeMillis() - time;
+ System.out.println("time to load = " + time);
+
+ assertNotNull("project description is null for re-created project", des);
+ assertTrue("des should be valid for re-created project", des.isValid());
+
+ cfgDess = des.getConfigurations();
+ cfgDes = cfgDess[0];
+ rf = cfgDes.getRootFolderDescription();
+
+ IFolder f_bc = ManagedBuildTestHelper.createFolder(project, "b/c");
+ base = (ICFolderDescription)cfgDes.getResourceDescription(new Path("b/c"), false);
+ ICFolderDescription bcFoDes = cfgDes.createFolderDescription(new Path("b/c"), base);
+ ls = bcFoDes.getLanguageSettingForFile("a.c");
+ assertNotNull(ls);
+ ICLanguageSetting rLS = rf.getLanguageSettingForFile("a.c");
+ assertNotNull(rLS);
+ List lsList = ls.getSettingEntriesList(ICLanguageSettingEntry.INCLUDE_PATH);
+ List rLSList = rLS.getSettingEntriesList(ICLanguageSettingEntry.INCLUDE_PATH);
+
+ System.out.println("default entries for non-root folder..\n");
+ fEventChecker = new CDefaultModelEventChecker();
+ coreModel.setProjectDescription(project, des);
+ fEventChecker = null;
+
+ project.delete(true, true, new NullProgressMonitor());
+ }
+
+ public void testSourceEntries() throws Exception {
+ final String projectName = "test2";
+ IProject project = createProject(projectName);
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescription des = coreModel.getProjectDescription(project);
+ assertNull("detDescription1 returned not null!", des);
+
+ des = coreModel.createProjectDescription(project, true);
+ assertNotNull("createDescription returned null!", des);
+
+ assertNull("detDescription2 returned not null!", coreModel.getProjectDescription(project));
+
+ assertFalse("new des should be not valid", des.isValid());
+
+ assertEquals(0, des.getConfigurations().length);
+
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ IProjectType type = ManagedBuildManager.getProjectType("cdt.managedbuild.target.gnu30.exe");
+ assertNotNull("project type not found", type);
+
+ ManagedProject mProj = new ManagedProject(project, type);
+ info.setManagedProject(mProj);
+
+ IConfiguration cfgs[] = type.getConfigurations();
+
+
+ for(int i = 0; i < cfgs.length; i++){
+ String id = ManagedBuildManager.calculateChildId(cfgs[i].getId(), null);
+ Configuration config = new Configuration(mProj, (Configuration)cfgs[i], id, false, true);
+ CConfigurationData data = config.getConfigurationData();
+ assertNotNull("data is null for created configuration", data);
+ ICConfigurationDescription cfgDes = des.createConfiguration("org.eclipse.cdt.managedbuilder.core.configurationDataProvider", data);
+ }
+ coreModel.setProjectDescription(project, des);
+
+ IWorkspace wsp = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = wsp.getRoot();
+ project.delete(false, true, new NullProgressMonitor());
+
+ project = root.getProject(projectName);
+ des = coreModel.getProjectDescription(project);
+ assertNull("project description is not null for removed project", des);
+
+ project = createProject(projectName);
+ des = coreModel.getProjectDescription(project);
+ assertNotNull("project description is null for re-created project", des);
+ assertTrue("des should be valid for re-created project", des.isValid());
+
+ ICConfigurationDescription cfgDess[] = des.getConfigurations();
+
+ assertEquals(2, cfgDess.length);
+
+ ICConfigurationDescription cfgDes = cfgDess[0];
+ ICResourceDescription rcDess[] = cfgDes.getResourceDescriptions();
+ assertEquals(1, rcDess.length);
+ assertEquals(cfgDes.getRootFolderDescription(), rcDess[0]);
+ assertFalse(cfgDes.isModified());
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), true));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path("ds/sd/sdf/"), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), true));
+ assertEquals(null, cfgDes.getResourceDescription(new Path("ds/sd/sdf/"), true));
+
+ ICSourceEntry s[] = cfgDes.getSourceEntries();
+ IPath projPath = cfgDes.getProjectDescription().getProject().getFullPath();
+ assertEquals(1, s.length);
+ assertEquals(projPath, s[0].getFullPath());
+ assertEquals(0, s[0].getExclusionPatterns().length);
+
+ IFolder folder = ManagedBuildTestHelper.createFolder(project, "a/b");
+
+ ICSourceEntry updatetSEs[] = new ICSourceEntry[2];
+ updatetSEs[0] = new CSourceEntry(projPath.append("a"), new Path[]{new Path("b")}, ICSourceEntry.VALUE_WORKSPACE_PATH);
+ updatetSEs[1] = s[0];
+
+ cfgDes.setSourceEntries(updatetSEs);
+
+ s = cfgDes.getSourceEntries();
+ updatetSEs[1] = new CSourceEntry(projPath, new Path[]{new Path("a")}, ICSourceEntry.VALUE_WORKSPACE_PATH);
+ checkArrays(updatetSEs, s);
+ //assertTrue(Arrays.equals(updatetSEs, s));
+
+ System.out.println("saving updated source entries..\n");
+ fEventChecker = new CDefaultModelEventChecker();
+ coreModel.setProjectDescription(project, des);
+ fEventChecker = null;
+
+ des = coreModel.getProjectDescription(project);
+ cfgDes = des.getConfigurations()[0];
+ checkArrays(cfgDes.getSourceEntries(), s);
+
+ project.delete(true, true, new NullProgressMonitor());
+ }
+
+ public void testMacroEntries() throws Exception {
+ final String projectName = "test3";
+ IProject project = createProject(projectName);
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescription des = coreModel.getProjectDescription(project);
+ assertNull("detDescription1 returned not null!", des);
+
+ des = coreModel.createProjectDescription(project, true);
+ assertNotNull("createDescription returned null!", des);
+
+ assertNull("detDescription2 returned not null!", coreModel.getProjectDescription(project));
+
+ assertFalse("new des should be not valid", des.isValid());
+
+ assertEquals(0, des.getConfigurations().length);
+
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ IProjectType type = ManagedBuildManager.getProjectType("cdt.managedbuild.target.gnu30.exe");
+ assertNotNull("project type not found", type);
+
+ ManagedProject mProj = new ManagedProject(project, type);
+ info.setManagedProject(mProj);
+
+ IConfiguration cfgs[] = type.getConfigurations();
+
+ for(int i = 0; i < cfgs.length; i++){
+ String id = ManagedBuildManager.calculateChildId(cfgs[i].getId(), null);
+ Configuration config = new Configuration(mProj, (Configuration)cfgs[i], id, false, true);
+ CConfigurationData data = config.getConfigurationData();
+ assertNotNull("data is null for created configuration", data);
+ ICConfigurationDescription cfgDes = des.createConfiguration("org.eclipse.cdt.managedbuilder.core.configurationDataProvider", data);
+ }
+ coreModel.setProjectDescription(project, des);
+
+ des = coreModel.getProjectDescription(project);
+ assertNotNull("project description is null ", des);
+ assertTrue("des should be valid ", des.isValid());
+
+ ICConfigurationDescription cfgDess[] = des.getConfigurations();
+
+ assertEquals(2, cfgDess.length);
+
+ ICConfigurationDescription cfgDes = cfgDess[0];
+ ICResourceDescription rcDess[] = cfgDes.getResourceDescriptions();
+ assertEquals(1, rcDess.length);
+ assertEquals(cfgDes.getRootFolderDescription(), rcDess[0]);
+ assertFalse(cfgDes.isModified());
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), true));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path("ds/sd/sdf/"), false));
+ assertEquals(cfgDes.getRootFolderDescription(), cfgDes.getResourceDescription(new Path(""), true));
+ assertEquals(null, cfgDes.getResourceDescription(new Path("ds/sd/sdf/"), true));
+
+ ICFolderDescription rf = cfgDes.getRootFolderDescription();
+ ICLanguageSetting setting = rf.getLanguageSettingForFile("a.c");
+ ICLanguageSettingEntry entries[] = setting.getSettingEntries(ICLanguageSettingEntry.MACRO);
+
+ for(int i = 0; i < entries.length; i++){
+ System.out.println("name = \"" + entries[i].getName() + "\", value = \"" + entries[i].getValue() + "\"");
+ }
+
+ CMacroEntry entry = new CMacroEntry("a", "b", 0);
+ List list = new ArrayList();
+ list.add(entry);
+ list.addAll(Arrays.asList(entries));
+
+ setting.setSettingEntries(ICLanguageSettingEntry.MACRO, list);
+
+ ICLanguageSettingEntry updatedEntries[] = setting.getSettingEntries(ICLanguageSettingEntry.MACRO);
+ assertEquals(entries.length + 1, updatedEntries.length);
+
+ boolean found = false;
+ for(int i = 0; i < updatedEntries.length; i++){
+ if(updatedEntries[i].getName().equals("a")
+ && updatedEntries[i].getValue().equals("b")){
+ found = true;
+ break;
+ }
+ }
+
+ assertTrue(found);
+ }
+
+ public void testReferences() throws Exception{
+ final String projectName4 = "test4";
+ final String projectName5 = "test5";
+ final String projectName6 = "test6";
+ final String projectName7 = "test7";
+ CoreModel coreModel = CoreModel.getDefault();
+
+ IProject project4 = createProject(projectName4, "cdt.managedbuild.target.gnu30.exe");
+ IProject project5 = createProject(projectName5, "cdt.managedbuild.target.gnu30.exe");
+ IProject project6 = createProject(projectName6, "cdt.managedbuild.target.gnu30.exe");
+ IProject project7 = createProject(projectName7, "cdt.managedbuild.target.gnu30.exe");
+
+ ICProjectDescription des4 = coreModel.getProjectDescription(project4);
+ ICProjectDescription des5 = coreModel.getProjectDescription(project5);
+ ICConfigurationDescription dess[] = des5.getConfigurations();
+ String id1 = dess[0].getId();
+ String id2 = dess[1].getId();
+
+ ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[]{
+ new CMacroEntry("a", "b", 0),
+ new CMacroEntry("c", "d", 0),
+ new CIncludePathEntry("a/b/c", 0),
+ new CIncludePathEntry("d/e/f", 0),
+ };
+ dess[0].createExternalSetting(null, null, null, entries);
+ dess[0].setActive();
+
+ ICExternalSetting extSettings[] = dess[0].getExternalSettings();
+ assertEquals(extSettings.length, 1);
+
+ checkArrays(extSettings[0].getEntries(), entries);
+ List list = new ArrayList(Arrays.asList(entries));
+ list.remove(3);
+ list.remove(2);
+ checkArrays(extSettings[0].getEntries(ICLanguageSettingEntry.MACRO), list.toArray());
+ list = new ArrayList(Arrays.asList(entries));
+ list.remove(0);
+ list.remove(0);
+ checkArrays(extSettings[0].getEntries(ICLanguageSettingEntry.INCLUDE_PATH), list.toArray());
+ coreModel.setProjectDescription(project5, des5);
+
+ extSettings = coreModel.getProjectDescription(project5).getActiveConfiguration().getExternalSettings();
+ assertEquals(extSettings.length, 1);
+
+ checkArrays(extSettings[0].getEntries(), entries);
+ list = new ArrayList(Arrays.asList(entries));
+ list.remove(3);
+ list.remove(2);
+ checkArrays(extSettings[0].getEntries(ICLanguageSettingEntry.MACRO), list.toArray());
+ list = new ArrayList(Arrays.asList(entries));
+ list.remove(0);
+ list.remove(0);
+ checkArrays(extSettings[0].getEntries(ICLanguageSettingEntry.INCLUDE_PATH), list.toArray());
+
+ dess = des4.getConfigurations();
+ ICLanguageSetting ls = dess[0].getRootFolderDescription().getLanguageSettingForFile("a.c");
+ ICLanguageSettingEntry macros[] = ls.getSettingEntries(ICLanguageSettingEntry.MACRO);
+ ICLanguageSettingEntry includes[] = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ assertFalse(arrayContains(entries[0], macros));
+ assertFalse(arrayContains(entries[1], macros));
+ assertFalse(arrayContains(entries[2], includes));
+ assertFalse(arrayContains(entries[3], includes));
+ Map map = new HashMap();
+ map.put(projectName5, "");
+ dess[0].setReferenceInfo(map);
+ ICLanguageSettingEntry updatedMacros[] = ls.getSettingEntries(ICLanguageSettingEntry.MACRO);
+ ICLanguageSettingEntry udatedIncludes[] = ls.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ assertTrue(arrayContains(entries[0], updatedMacros));
+ assertTrue(arrayContains(entries[1], updatedMacros));
+ assertTrue(arrayContains(entries[2], udatedIncludes));
+ assertTrue(arrayContains(entries[3], udatedIncludes));
+
+ }
+
+ public void testActiveCfg() throws Exception{
+ final String projectName = "test8";
+
+ IProject project = createProject(projectName, "cdt.managedbuild.target.gnu30.exe");
+ CoreModel coreModel = CoreModel.getDefault();
+
+ ICProjectDescription des = coreModel.getProjectDescription(project);
+ ICConfigurationDescription cfgs[] = des.getConfigurations();
+ String id1 = cfgs[0].getId();
+ String id2 = cfgs[1].getId();
+
+ cfgs[0].setActive();
+ assertEquals(cfgs[0], des.getActiveConfiguration());
+
+ coreModel.setProjectDescription(project, des);
+
+ des = coreModel.getProjectDescription(project);
+ cfgs = des.getConfigurations();
+ assertEquals(id1, des.getActiveConfiguration().getId());
+
+ ICConfigurationDescription newActive = null;
+ for(int i = 0; i < cfgs.length; i++){
+ if(!cfgs[i].getId().equals(id1)){
+ newActive = cfgs[i];
+ break;
+ }
+ }
+
+ String newActiveId = newActive.getId();
+ newActive.setActive();
+ assertEquals(newActive, des.getActiveConfiguration());
+
+ coreModel.setProjectDescription(project, des);
+
+ des = coreModel.getProjectDescription(project);
+ assertEquals(newActiveId, des.getActiveConfiguration().getId());
+
+
+ }
+
+ private boolean arrayContains(Object el, Object[] a){
+ for(int i = 0; i < a.length; i++){
+ if(el.equals(a[i]))
+ return true;
+ }
+ return false;
+ }
+
+ private void checkArrays(Object[] a1, Object[] a2){
+ if(a1 == null){
+ assertTrue(a2 == null);
+ return;
+ }
+ assertTrue(a2 != null);
+
+ assertEquals(a1.length, a2.length);
+
+ for(int i = 0; i < a1.length; i++){
+ Object o1 = a1[i];
+ boolean found = false;
+ for(int j = 0; j < a2.length; j++){
+ if(o1.equals(a2[j])){
+ found = true;
+ break;
+ }
+ }
+
+ if(!found){
+ fail("a2 array does not contain the \"" + o1 + "\" element");
+ }
+ }
+ }
+
+ static public IProject createProject(String name, String projTypeId) throws CoreException{
+ IProject project = createProject(name);
+
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescription des = coreModel.getProjectDescription(project);
+ assertNull("detDescription1 returned not null!", des);
+
+ des = coreModel.createProjectDescription(project, true);
+ assertNotNull("createDescription returned null!", des);
+
+ assertNull("detDescription2 returned not null!", coreModel.getProjectDescription(project));
+
+ assertFalse("new des should be not valid", des.isValid());
+
+ assertEquals(0, des.getConfigurations().length);
+
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ IProjectType type = ManagedBuildManager.getProjectType(projTypeId);
+ assertNotNull("project type not found", type);
+
+ ManagedProject mProj = new ManagedProject(project, type);
+ info.setManagedProject(mProj);
+
+ IConfiguration cfgs[] = type.getConfigurations();
+
+
+ for(int i = 0; i < cfgs.length; i++){
+ String id = ManagedBuildManager.calculateChildId(cfgs[i].getId(), null);
+ Configuration config = new Configuration(mProj, (Configuration)cfgs[i], id, false, true);
+ CConfigurationData data = config.getConfigurationData();
+ assertNotNull("data is null for created configuration", data);
+ ICConfigurationDescription cfgDes = des.createConfiguration("org.eclipse.cdt.managedbuilder.core.configurationDataProvider", data);
+ }
+
+ coreModel.setProjectDescription(project, des);
+
+ return project;
+ }
+
+ static public IProject createProject(String name) throws CoreException{
+ return createProject(name, (IPath)null);
+ }
+
+ static public IProject createProject(
+ final String name,
+ final IPath location) throws CoreException{
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ final IProject newProjectHandle = root.getProject(name);
+ IProject project = null;
+
+ if (!newProjectHandle.exists()) {
+ IWorkspaceDescription workspaceDesc = workspace.getDescription();
+ workspaceDesc.setAutoBuilding(false);
+ workspace.setDescription(workspaceDesc);
+ IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
+ if(location != null)
+ description.setLocation(location);
+ //description.setLocation(root.getLocation());
+ project = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new NullProgressMonitor());
+ } else {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+ };
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor);
+ project = newProjectHandle;
+ }
+
+ // Open the project if we have to
+ if (!project.isOpen()) {
+ project.open(new NullProgressMonitor());
+ }
+
+ return project;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
index 1db75599eeb..3687155142c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.managedbuilder.buildmodel,
org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.cdt.newmake.core,
org.eclipse.cdt.managedbuilder.envvar,
org.eclipse.cdt.managedbuilder.internal.buildmodel,
org.eclipse.cdt.managedbuilder.internal.core,
@@ -19,11 +20,17 @@ Export-Package: org.eclipse.cdt.managedbuilder.buildmodel,
org.eclipse.cdt.managedbuilder.makegen.gnu,
org.eclipse.cdt.managedbuilder.makegen.internal,
org.eclipse.cdt.managedbuilder.projectconverter,
- org.eclipse.cdt.managedbuilder.scannerconfig
+ org.eclipse.cdt.managedbuilder.scannerconfig,
+ org.eclipse.cdt.managedbuilder.buildproperties,
+ org.eclipse.cdt.make.internal.core.scannerconfig,
+ org.eclipse.cdt.make.internal.core.scannerconfig.gnu,
+ org.eclipse.cdt.make.internal.core.scannerconfig.jobs,
+ org.eclipse.cdt.make.internal.core.scannerconfig.util,
+ org.eclipse.cdt.make.internal.core.scannerconfig2,
+ org.eclipse.cdt.make.core.scannerconfig
Require-Bundle: org.eclipse.cdt.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.cdt.make.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)"
Eclipse-LazyStart: true
diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.properties b/build/org.eclipse.cdt.managedbuilder.core/plugin.properties
index 945ce202354..b3debdcfc0b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.properties
@@ -19,3 +19,15 @@ objectFileName=Object File
executableName=Executable File
staticLibraryName=Static Library
sharedLibraryName=Shared Library
+
+epScannerConfigNature.name=Scanner Configuration Nature
+epScannerConfigBuilder.name=Scanner Configuration Builder
+extensionExternalScannerInfoProvider.name=C/C++ External Scanner Info Provider Extension
+epDefaultExternalScannerInfoProvider.name=Default External Scanner Info Provider
+
+extensionScannerInfoConsoleParser.name=GNU C/C++ Scanner Info Console Parser Extension
+epGCCCommandLineParser.name=GNU C/C++ Scanner Info Parser
+epGCCSpecsParser.name=GNU C/C++ Compiler Specs Parser
+
+extensionGCCPerProjectProfile.name=GNU C/C++ Scanner Info per project profile
+extensionGCCPerFileProfile.name=GNU C/C++ Scanner Info per file profile
diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
index a95ed7e010b..18ed2a7ae5d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
@@ -5,6 +5,9 @@
<extension-point id="ManagedBuildInfo" name="Managed Build Tools 2.0 (Deprecated)" schema="schema/ManagedBuildTools.exsd"/>
<extension-point id="buildDefinitions" name="Managed Build Definitions" schema="schema/buildDefinitions.exsd"/>
<extension-point id="projectConverter" name="Managed Build Project Converter" schema="schema/Converter.exsd"/>
+ <extension-point id="buildProperties" name="Build Properties" schema="schema/buildProperties.exsd"/>
+ <extension-point id="ScannerConfigurationDiscoveryProfile" name="%extensionScannerConfigurationDiscoveryProfile.name" schema="schema/ScannerConfigurationDiscoveryProfile.exsd"/>
+
<!-- =================================================================================== -->
<!-- Extension Point: IScannerInfoProvider for the managed Builder -->
@@ -26,9 +29,13 @@
name="%GeneratedMakefileCBuilder.name"
point="org.eclipse.core.resources.builders">
<builder
- hasNature="true">
- <run
+ hasNature="true"
+ callOnEmptyDelta="true">
+ <!--run
class="org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder">
+ </run-->
+ <run
+ class="org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder">
</run>
</builder>
</extension>
@@ -81,9 +88,39 @@
</scannerInfoProvider>
</extension>
<extension
+ id="GCCManagedMakePerProjectProfileCPP"
+ name="GNU C/C++ managed make per project SCD profile"
+ point="org.eclipse.cdt.managedbuilder.core.ScannerConfigurationDiscoveryProfile">
+ <scannerInfoCollector
+ class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ scope="project"/>
+ <scannerInfoProvider providerId="specsFile">
+ <run
+ arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp"
+ command="g++"
+ class="org.eclipse.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider"/>
+ <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/>
+ </scannerInfoProvider>
+ </extension>
+ <extension
+ id="GCCManagedMakePerProjectProfileC"
+ name="GNU C/C++ managed make per project SCD profile"
+ point="org.eclipse.cdt.managedbuilder.core.ScannerConfigurationDiscoveryProfile">
+ <scannerInfoCollector
+ class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ scope="project"/>
+ <scannerInfoProvider providerId="specsFile">
+ <run
+ arguments="-E -P -v -dD ${plugin_state_location}/specs.c"
+ command="gcc"
+ class="org.eclipse.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider"/>
+ <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/>
+ </scannerInfoProvider>
+ </extension>
+ <extension
id="GCCWinManagedMakePerProjectProfile"
name="GNU C/C++ managed make per project SCD profile (Windows)"
- point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
+ point="org.eclipse.cdt.managedbuilder.core.ScannerConfigurationDiscoveryProfile">
<scannerInfoCollector
class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGnuWinScannerInfoCollector"
scope="project"/>
@@ -96,6 +133,36 @@
</scannerInfoProvider>
</extension>
<extension
+ id="GCCWinManagedMakePerProjectProfileCPP"
+ name="GNU C/C++ managed make per project SCD profile (Windows)"
+ point="org.eclipse.cdt.managedbuilder.core.ScannerConfigurationDiscoveryProfile">
+ <scannerInfoCollector
+ class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGnuWinScannerInfoCollector"
+ scope="project"/>
+ <scannerInfoProvider providerId="specsFile">
+ <run
+ arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp"
+ command="g++"
+ class="org.eclipse.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider"/>
+ <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/>
+ </scannerInfoProvider>
+ </extension>
+ <extension
+ id="GCCWinManagedMakePerProjectProfileC"
+ name="GNU C/C++ managed make per project SCD profile (Windows)"
+ point="org.eclipse.cdt.managedbuilder.core.ScannerConfigurationDiscoveryProfile">
+ <scannerInfoCollector
+ class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGnuWinScannerInfoCollector"
+ scope="project"/>
+ <scannerInfoProvider providerId="specsFile">
+ <run
+ arguments="-E -P -v -dD ${plugin_state_location}/specs.c"
+ command="gcc"
+ class="org.eclipse.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider"/>
+ <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/>
+ </scannerInfoProvider>
+ </extension>
+ <extension
point="org.eclipse.team.core.fileTypes">
<fileTypes
extension="cdtbuild"
@@ -142,6 +209,207 @@
<file-association
content-type="org.eclipse.cdt.managedbuilder.core.sharedLibrary"
file-extensions="dll,so,dylib"/>
+ </extension>
+ <extension
+ id="configurationDataProvider"
+ name="CDT Build System"
+ point="org.eclipse.cdt.core.CConfigurationDataProvider">
+ <provider
+ natures="org.eclipse.cdt.managedbuilder.core.managedBuildNature;org.eclipse.cdt.managedbuilder.core.ScannerConfigNature"
+ class="org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider"
+ />
+ </extension>
+ <extension
+ id="ProjectConverter"
+ name="pre-4.0 projects converter"
+ point="org.eclipse.cdt.core.projectConverter">
+ <converter
+ owners="org.eclipse.cdt.managedbuilder.core.managedMake;org.eclipse.cdt.make.core.make"
+ natures="org.eclipse.cdt.managedbuilder.core.managedBuildNature;org.eclipse.cdt.make.core.makeNature"
+ class="org.eclipse.cdt.managedbuilder.internal.dataprovider.ProjectConverter"
+ />
</extension>
+
+ <extension
+ id="baseProperties"
+ name="Base Build Properties Definition"
+ point="org.eclipse.cdt.managedbuilder.core.buildProperties">
+ <propertyType id="org.eclipse.cdt.build.core.buildType" name="Build Type"/>
+ <propertyType id="org.eclipse.cdt.build.core.buildArtefactType" name="Build Artefact Type"/>
+
+ <propertyValue
+ property="org.eclipse.cdt.build.core.buildType"
+ id="org.eclipse.cdt.build.core.buildType.debug"
+ name="Debug"/>
+ <propertyValue
+ property="org.eclipse.cdt.build.core.buildType"
+ id="org.eclipse.cdt.build.core.buildType.release"
+ name="Release"/>
+
+ <propertyValue
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ id="org.eclipse.cdt.build.core.buildArtefactType.exe"
+ name="Executable"/>
+ <propertyValue
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ id="org.eclipse.cdt.build.core.buildArtefactType.staticLib"
+ name="Static Library"/>
+ <propertyValue
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"
+ name="Shared Library"/>
+
+ </extension>
+
+ <extension
+ id="emptyConfigs"
+ name="Empty Configurations for make projects"
+ point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
+ <managedBuildRevision
+ fileVersion="4.0.0">
+ </managedBuildRevision>
+ <configuration
+ id="org.eclipse.cdt.build.core.emptycfg"
+ name="Configuration1">
+ </configuration>
+
+ <configuration
+ id="org.eclipse.cdt.build.core.prefbase.cfg"
+ name="Configuration1"
+ >
+ <toolChain
+ id="org.eclipse.cdt.build.core.prefbase.toolchain"
+ name="No ToolChain"
+ supportsManagedBuild="false"
+ isSystem="true">
+ <tool
+ id="org.eclipse.cdt.build.core.settings.holder.libs"
+ supportsManagedBuild="false"
+ name="holder for library settings"
+ isSystem="true">
+ <option
+ id="org.eclipse.cdt.build.core.settings.holder.libpaths"
+ browseType="directory"
+ name="Library Paths"
+ valueType="libPaths"
+ />
+ <option
+ id="org.eclipse.cdt.build.core.settings.holder.libfiles"
+ name="Library Files"
+ valueType="libFiles"
+ browseType="file"
+ />
+
+ <!--option
+ id="org.eclipse.cdt.build.core.settings.holder.libpaths"
+ name="libraries"
+ browseType="none"
+ valueType="libs"
+ /-->
+ </tool>
+ <builder
+ isAbstract="true"
+ id="org.eclipse.cdt.build.core.settings.default.builder"
+ command="make"
+ arguments=""
+ variableFormat="${=}"
+ isVariableCaseSensitive="true"
+ reservedMacroNames="ROOT,DEPS,OBJS,.*_SRCS,EXECUTABLES,SUBDIRS,LIBS,USER_OBJS,.*_INPUTS,.*_OUTPUTS"
+ buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
+ macroInputFileNameValue="$(notdir $&lt;)"
+ macroInputFileExtValue="$(suffix $(notdir $&lt;))"
+ macroInputFileBaseNameValue="$(basename $(notdir $&lt;))"
+ macroInputFileRelPathValue="$&lt;"
+ macroInputDirRelPathValue="$(dir $&lt;)"
+ macroOutputFileNameValue="$(notdir $@)"
+ macroOutputFileExtValue="$(suffix $(notdir $@))"
+ macroOutputFileBaseNameValue="$(basename $(notdir $@))"
+ macroOutputFileRelPathValue="$@"
+ macroOutputDirRelPathValue="$(dir $@)"
+ autoBuildTarget="all"
+ incrementalBuildTarget="all"
+ cleanBuildTarget="clean"
+ ignoreErrCmd="-k"
+ parallelBuildCmd="-j*"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser"
+ name="Gnu Make Builder"
+ isSystem="true">
+ </builder>
+
+ </toolChain>
+ </configuration>
+
+ <tool
+ id="org.eclipse.cdt.build.core.settings.holder"
+ supportsManagedBuild="false"
+ name="holder for includes and symbols settings"
+ isSystem="true">
+ <inputType
+ id="org.eclipse.cdt.build.core.settings.holder.inType">
+ </inputType>
+ <option
+ id="org.eclipse.cdt.build.core.settings.holder.incpaths"
+ name="include paths"
+ browseType="directory"
+ valueType="includePath"
+ />
+ <option
+ id="org.eclipse.cdt.build.core.settings.holder.symbols"
+ name="Symbols"
+ valueType="definedSymbols"
+ />
+ <option
+ id="org.eclipse.cdt.build.core.settings.holder.symbolfiles"
+ name="Symbol Files"
+ browseType="file"
+ valueType="symbolFiles"
+ />
+ <option
+ id="org.eclipse.cdt.build.core.settings.holder.includefiles"
+ name="Include Files"
+ browseType="file"
+ valueType="includeFiles"
+ />
+ <!--option
+ id="org.eclipse.cdt.build.core.settings.holder.includes"
+ name="holder for includes"
+ valueType="includePath"
+ /-->
+ </tool>
+
+ <builder
+ id="org.eclipse.cdt.build.core.internal.builder"
+ name="CDT Internal Builder">
+ </builder>
+ </extension>
+
+ <extension
+ id="ScannerConfigNature"
+ name="%epScannerConfigNature.name"
+ point="org.eclipse.core.resources.natures">
+ <requires-nature
+ id="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
+ </requires-nature>
+ <runtime>
+ <run
+ class="org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature">
+ </run>
+ </runtime>
+ <builder
+ id="org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder">
+ </builder>
+ </extension>
+ <extension
+ id="ScannerConfigBuilder"
+ name="%epScannerConfigBuilder.name"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ hasNature="true">
+ <run
+ class="org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder">
+ </run>
+ </builder>
+ </extension>
+
</plugin>
diff --git a/build/org.eclipse.cdt.make.core/schema/ScannerConfigurationDiscoveryProfile.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/ScannerConfigurationDiscoveryProfile.exsd
index b4ec5732bdb..7f0f29f5614 100644
--- a/build/org.eclipse.cdt.make.core/schema/ScannerConfigurationDiscoveryProfile.exsd
+++ b/build/org.eclipse.cdt.managedbuilder.core/schema/ScannerConfigurationDiscoveryProfile.exsd
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.make.core">
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.core">
<annotation>
<appInfo>
- <meta.schema plugin="org.eclipse.cdt.make.core" id="ScannerConfigurationDiscoveryProfile" name="Scanner Configuration Discovery Profile"/>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.core" id="ScannerConfigurationDiscoveryProfile" name="Scanner Configuration Discovery Profile"/>
</appInfo>
<documentation>
A unified definition of a scanner configuration profile. Usually consists of &lt;p&gt;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd
index ca76538a094..57ecbeb1510 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd
+++ b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd
@@ -21,7 +21,7 @@
<element ref="builder" minOccurs="0" maxOccurs="unbounded"/>
<element ref="dynamicElementProvider" minOccurs="0" maxOccurs="unbounded"/>
<element ref="managedBuildRevision" minOccurs="0" maxOccurs="1"/>
- <element ref="buildDefinitionStartup"/>
+ <element ref="buildDefinitionStartup" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -67,7 +67,7 @@
</documentation>
</annotation>
</attribute>
- <attribute name="name" type="string" use="required">
+ <attribute name="name" type="string">
<annotation>
<documentation>
A human-readable project type name, such as &apos;Executable&apos;. This will be the name the user sees displayed in the UI.
@@ -142,6 +142,14 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="buildProperties" type="string">
+ <annotation>
+ <documentation>
+ Specifies the comma-separated list of build property type - value pairs to be applied for all configurations of this project type.
+property type-value pairs are specified in the type_id=value_id format.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -183,8 +191,9 @@
</annotation>
<complexType>
<sequence>
- <element ref="toolChain"/>
+ <element ref="toolChain" minOccurs="0" maxOccurs="1"/>
<element ref="resourceConfiguration" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
@@ -282,6 +291,14 @@
</appInfo>
</annotation>
</attribute>
+ <attribute name="buildProperties" type="string">
+ <annotation>
+ <documentation>
+ Specifies the comma-separated list of build property type - value pairs defined for this configuration.
+property type-value pairs are specified in the type_id=value_id format.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -294,8 +311,8 @@
<complexType>
<sequence>
<element ref="tool" minOccurs="1" maxOccurs="unbounded"/>
- <element ref="targetPlatform"/>
- <element ref="builder"/>
+ <element ref="targetPlatform" minOccurs="0" maxOccurs="1"/>
+ <element ref="builder" minOccurs="0" maxOccurs="1"/>
<element ref="optionCategory" minOccurs="0" maxOccurs="unbounded"/>
<element ref="option" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
@@ -435,6 +452,13 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
</appInfo>
</annotation>
</attribute>
+ <attribute name="supportsManagedBuild" type="boolean">
+ <annotation>
+ <documentation>
+ Specifies whether or not the tool-chain supports managed build. Default value is true.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -506,11 +530,13 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
</annotation>
<complexType>
<sequence>
- <element ref="option" minOccurs="1" maxOccurs="unbounded"/>
- <element ref="optionCategory" minOccurs="1" maxOccurs="unbounded"/>
+ <element ref="option" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="optionCategory" minOccurs="0" maxOccurs="unbounded"/>
<element ref="inputType" minOccurs="0" maxOccurs="unbounded"/>
<element ref="outputType" minOccurs="0" maxOccurs="unbounded"/>
<element ref="envVarBuildPath" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="supportedProperties" minOccurs="0" maxOccurs="1"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
@@ -713,6 +739,13 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
</appInfo>
</annotation>
</attribute>
+ <attribute name="supportsManagedBuild" type="boolean">
+ <annotation>
+ <documentation>
+ Specifies whether or not the tool supports managed build. Default value is true.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -726,6 +759,7 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
<sequence>
<element ref="inputOrder" minOccurs="0" maxOccurs="unbounded"/>
<element ref="additionalInput" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
@@ -824,6 +858,20 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
</documentation>
</annotation>
</attribute>
+ <attribute name="scannerConfigDiscoveryProfileId" type="string">
+ <annotation>
+ <documentation>
+ Specifies an id of scanner configuration discovery profile for gathering the built-in compiler settings for resource type presented with this input type.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="languageId" type="string">
+ <annotation>
+ <documentation>
+ Represents the language id, i.e. the id of language defined via the org.eclipse.cdt.core.language extension point
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -899,6 +947,9 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
</documentation>
</annotation>
<complexType>
+ <sequence>
+ <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
@@ -1154,6 +1205,14 @@ Additional special types exist to flag options of special relevance to the build
</enumeration>
<enumeration value="userObjs">
</enumeration>
+ <enumeration value="symbolFiles">
+ </enumeration>
+ <enumeration value="includeFiles">
+ </enumeration>
+ <enumeration value="libPaths">
+ </enumeration>
+ <enumeration value="libFiles">
+ </enumeration>
</restriction>
</simpleType>
</attribute>
@@ -1535,6 +1594,49 @@ If this attribute is not specified, MBS will assume that there are no reserved m
</documentation>
</annotation>
</attribute>
+ <attribute name="supportsManagedBuild" type="boolean">
+ <annotation>
+ <documentation>
+ Specifies whether the duilder supports managed build. Default value is true.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="autoBuildTarget" type="string">
+ <annotation>
+ <documentation>
+ represents the build target to be used for auto build
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="incrementalBuildTarget" type="string">
+ <annotation>
+ <documentation>
+ represents the build target to be used for incremental build
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="cleanBuildTarget" type="string">
+ <annotation>
+ <documentation>
+ represents the build target to be used for clean build
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="ignoreErrCmd" type="string">
+ <annotation>
+ <documentation>
+ specifies the &quot;ignore error&quot; builder option.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="parallelBuildCmd" type="string">
+ <annotation>
+ <documentation>
+ specifies the &quot;parallel build&quot; builder option.
+If the builder supports specifying custom number of parallel jobs, the option definition may contain &quot;*&quot; the Build System sill substitute the &quot;*&quot; with the number of parallel threads to be used.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -1747,13 +1849,14 @@ If the &quot;buildPathResolver&quot; attribute is specified, the &quot;pathDelim
</annotation>
<complexType>
<choice>
- <element ref="and"/>
- <element ref="or"/>
- <element ref="not"/>
- <element ref="checkOption"/>
- <element ref="checkString"/>
- <element ref="false"/>
- <element ref="checkHolder"/>
+ <element ref="and" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="or" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="not" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkOption" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkString" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="false" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkHolder" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkBuildProperty" minOccurs="0" maxOccurs="unbounded"/>
</choice>
<attribute name="type" type="string" use="default" value="ALL">
<annotation>
@@ -1777,6 +1880,9 @@ type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
This attribute should be used only for the CONTAINER_ATTRIBUTE enablement to specify the name of the attribute for which this enablement applies. Currently the following option attributes are supported:
&quot;command&quot;
&quot;commandFalse&quot;
+&quot;defaultValue&quot;
+&quot;value&quot;
+&quot;artifactExtension&quot;
</documentation>
</annotation>
<simpleType>
@@ -1785,6 +1891,12 @@ type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
</enumeration>
<enumeration value="commandFalse">
</enumeration>
+ <enumeration value="defaultValue">
+ </enumeration>
+ <enumeration value="value">
+ </enumeration>
+ <enumeration value="artifactExtension">
+ </enumeration>
</restriction>
</simpleType>
</attribute>
@@ -1795,6 +1907,16 @@ type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
</documentation>
</annotation>
</attribute>
+ <attribute name="extensionAdjustment" type="boolean">
+ <annotation>
+ <documentation>
+ The attribute is valid for the CONTAINER_ATTRIBUTE enablement type.
+true specifies that the enablement is defined for adjusting extension elements (extension elements are adjusted on tool-chain definition load)
+false specifies that the enablement is defined for non-extension elements adjustment. This adjustment is performed, e.g. when the Build properties set is chenged for configuration
+Default value is true.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -1806,12 +1928,13 @@ type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
</annotation>
<complexType>
<sequence>
- <element ref="and"/>
- <element ref="or"/>
- <element ref="not"/>
- <element ref="checkOption"/>
- <element ref="checkString"/>
- <element ref="checkHolder"/>
+ <element ref="and" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="or" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="not" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkOption" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkString" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkHolder" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkBuildProperty" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
@@ -1824,12 +1947,13 @@ type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
</annotation>
<complexType>
<sequence>
- <element ref="and"/>
- <element ref="or"/>
- <element ref="not"/>
- <element ref="checkOption"/>
- <element ref="checkString"/>
- <element ref="checkHolder"/>
+ <element ref="and" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="or" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="not" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkOption" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkString" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkHolder" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkBuildProperty" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
@@ -1842,12 +1966,13 @@ type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
</annotation>
<complexType>
<choice>
- <element ref="and"/>
- <element ref="or"/>
- <element ref="not"/>
- <element ref="checkOption"/>
- <element ref="checkString"/>
- <element ref="checkHolder"/>
+ <element ref="and" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="or" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="not" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkOption" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkString" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkHolder" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="checkBuildProperty" minOccurs="0" maxOccurs="unbounded"/>
</choice>
</complexType>
</element>
@@ -1963,6 +2088,80 @@ The way the value is specified and treated depends on the value of the isRegex a
</complexType>
</element>
+ <element name="checkBuildProperty">
+ <annotation>
+ <documentation>
+ Performs the Build Property check
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="property" type="string">
+ <annotation>
+ <documentation>
+ specifies the id of the Build Property to be checked
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="value" type="string">
+ <annotation>
+ <documentation>
+ Specifies the Build Property Value id to be checked
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="supportedProperties">
+ <annotation>
+ <documentation>
+ contains the list of supported properties
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="property"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="property">
+ <annotation>
+ <documentation>
+ contains the supported values for the property
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="value" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ the property type id
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="value">
+ <annotation>
+ <documentation>
+ represents the property value
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ represents the property value id
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appInfo>
<meta.section type="since"/>
diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/buildProperties.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/buildProperties.exsd
new file mode 100644
index 00000000000..b21a6e00848
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/schema/buildProperties.exsd
@@ -0,0 +1,87 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.core" id="buildProperties" name="Build Properties"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java
index 9cbeca1b47e..d775b0be7eb 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java
@@ -37,7 +37,7 @@ public class DiscoveredScannerInfo implements IScannerInfo {
private ArrayList activeSymbols;
private ArrayList removedSymbols;
- private org.eclipse.cdt.make.core.MakeScannerInfo userInfo;
+ private org.eclipse.cdt.newmake.core.MakeScannerInfo userInfo;
/**
* @param project
@@ -68,11 +68,11 @@ public class DiscoveredScannerInfo implements IScannerInfo {
return iPaths;
}
- public org.eclipse.cdt.make.core.MakeScannerInfo getUserScannerInfo() {
+ public org.eclipse.cdt.newmake.core.MakeScannerInfo getUserScannerInfo() {
return userInfo;
}
- public synchronized void setUserScannerInfo( org.eclipse.cdt.make.core.MakeScannerInfo info) {
+ public synchronized void setUserScannerInfo( org.eclipse.cdt.newmake.core.MakeScannerInfo info) {
userInfo = info;
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java
index 24d17bf7af2..0817c773d1a 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java
@@ -23,8 +23,8 @@ import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.resources.ScannerProvider;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -38,10 +38,10 @@ import org.eclipse.core.runtime.QualifiedName;
public class DiscoveredScannerInfoProvider extends ScannerProvider {
// This is the id of the IScannerInfoProvider extension point entry
- public static final String INTERFACE_IDENTITY = MakeCorePlugin.getUniqueIdentifier() + ".DiscoveredScannerInfoProvider"; //$NON-NLS-1$
+ public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".DiscoveredScannerInfoProvider"; //$NON-NLS-1$
// Name we will use to store build property with the project
- private static final QualifiedName scannerInfoProperty = new QualifiedName(MakeCorePlugin.getUniqueIdentifier(),
+ private static final QualifiedName scannerInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(),
"discoveredMakeBuildInfo"); //$NON-NLS-1$
// Singleton
@@ -95,7 +95,7 @@ public class DiscoveredScannerInfoProvider extends ScannerProvider {
if (scannerInfo == null) {
scannerInfo = new DiscoveredScannerInfo(project);
// this will convert user info
- org.eclipse.cdt.make.core.MakeScannerInfo makeScannerInfo = org.eclipse.cdt.make.core.MakeScannerProvider.getDefault().getMakeScannerInfo(
+ org.eclipse.cdt.newmake.core.MakeScannerInfo makeScannerInfo = org.eclipse.cdt.newmake.core.MakeScannerProvider.getDefault().getMakeScannerInfo(
project, cacheInfo);
scannerInfo.setUserScannerInfo(makeScannerInfo);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IConfigurationScannerConfigBuilderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IConfigurationScannerConfigBuilderInfo.java
new file mode 100644
index 00000000000..8fe675fff26
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IConfigurationScannerConfigBuilderInfo.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.core.scannerconfig;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+
+
+public interface IConfigurationScannerConfigBuilderInfo {
+ boolean isPerRcTypeDiscovery();
+
+ void setPerRcTypeDiscovery(boolean on);
+
+ Map getInfoMap();
+
+ InfoContext[] getContexts();
+
+ IScannerConfigBuilderInfo2 getInfo(InfoContext context);
+
+ IScannerConfigBuilderInfo2 applyInfo(InfoContext context, IScannerConfigBuilderInfo2 base) throws CoreException;
+
+ IScannerConfigBuilderInfo2 getDefaultInfo();
+
+// boolean isAutoDiscoveryEnabled();
+// void setAutoDiscoveryEnabled(boolean enable);
+//
+// boolean isProblemReportingEnabled();
+// void setProblemReportingEnabled(boolean enable);
+//
+// String getSelectedProfileId();
+// void setSelectedProfileId(String profileId);
+//
+// List getProfileIdList();
+//
+// // SCD profile - buildOutputProvider options
+// boolean isBuildOutputFileActionEnabled();
+// void setBuildOutputFileActionEnabled(boolean enable);
+//
+// String getBuildOutputFilePath();
+// void setBuildOutputFilePath(String path);
+//
+// boolean isBuildOutputParserEnabled();
+// void setBuildOutputParserEnabled(boolean enable);
+//
+// // SCD profile - scanner info provider options
+// List getProviderIdList();
+//// void addSIProvider(String providerId);
+//// void removeSIProvider(String providerId);
+//
+// boolean isProviderOutputParserEnabled(String providerId);
+// void setProviderOutputParserEnabled(String providerId, boolean enable);
+//
+// boolean isUseDefaultProviderCommand(String providerId);
+// void setUseDefaultProviderCommand(String providerId, boolean enable);
+//
+// String getProviderRunCommand(String providerId);
+// void setProviderRunCommand(String providerId, String command);
+//
+// String getProviderRunArguments(String providerId);
+// void setProviderRunArguments(String providerId, String arguments);
+//
+// String getProviderOpenFilePath(String providerId);
+// void setProviderOpenFilePath(String providerId, String filePath);
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
index fd91aa6587d..f954abfb9cb 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
@@ -14,13 +14,13 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.w3c.dom.Element;
public interface IDiscoveredPathManager {
-
interface IDiscoveredPathInfo {
IProject getProject();
@@ -99,11 +99,20 @@ public interface IDiscoveredPathManager {
void infoChanged(IDiscoveredPathInfo info);
void infoRemoved(IDiscoveredPathInfo info);
}
-
+
IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException;
+ IDiscoveredPathInfo getDiscoveredInfo(IProject project, InfoContext context) throws CoreException;
+
void removeDiscoveredInfo(IProject project);
+ void removeDiscoveredInfo(IProject project, InfoContext context);
+
void updateDiscoveredInfo(IDiscoveredPathInfo info, List changedResources) throws CoreException;
- void changeDiscoveredContainer(IProject project, ScannerConfigScope profileScope, List changedResources);
+ void updateDiscoveredInfo(IDiscoveredPathInfo info, InfoContext context, List changedResources) throws CoreException;
+
+ void changeDiscoveredContainer(IProject project, ScannerConfigScope profileScope, List changedResources);
+// void changeDiscoveredContainer(IProject project, InfoContext context, ScannerConfigScope profileScope, List changedResources);
+
+ void updateCoreSettings(IProject project, IConfiguration cfgs[]);
void addDiscoveredInfoListener(IDiscoveredInfoListener listener);
void removeDiscoveredInfoListener(IDiscoveredInfoListener listener);
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java
index 3569e543558..5d390c7361d 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.make.core.scannerconfig;
-import java.util.Properties;
-
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -36,22 +34,4 @@ public interface IExternalScannerInfoProvider {
IScannerConfigBuilderInfo2 buildInfo,
IScannerInfoCollector collector);
- /**
- * Alternative interface to pass down the environment.
- *
- * @param monitor
- * @param resource
- * @param providerId
- * @param buildInfo
- * @param collector
- * @param env
- * @return
- */
- public boolean invokeProvider(IProgressMonitor monitor,
- IResource resource,
- String providerId,
- IScannerConfigBuilderInfo2 buildInfo,
- IScannerInfoCollector collector,
- Properties env);
-
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java
index f063bdbb6dd..f063bdbb6dd 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java
index 6069064435a..6069064435a 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java
index e1a6a2c1af0..e1a6a2c1af0 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java
index 539be721a22..539be721a22 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector3.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector3.java
new file mode 100644
index 00000000000..6b57c79f099
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector3.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.core.scannerconfig;
+
+
+public interface IScannerInfoCollector3 extends IScannerInfoCollector2 {
+ void setContext(InfoContext context);
+
+ InfoContext getContext();
+
+ boolean isInfoCollected();
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java
index 5b7d92aabe3..5b7d92aabe3 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java
index 3c4dcffd456..3c4dcffd456 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/InfoContext.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/InfoContext.java
new file mode 100644
index 00000000000..0b37653da5e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/InfoContext.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.core.scannerconfig;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+public final class InfoContext{
+ private static final int NULL_OBJ_CODE = 29;
+ private IConfiguration fCfg;
+ private IResourceInfo fRcInfo;
+ private ITool fTool;
+ private IInputType fInType;
+
+ public InfoContext(IResourceInfo rcInfo, ITool tool, IInputType inType){
+ this.fRcInfo = rcInfo;
+ this.fTool = tool;
+ this.fInType = inType;
+ this.fCfg = fRcInfo.getParent();
+ }
+
+ public InfoContext(IConfiguration cfg){
+ this.fCfg = cfg;
+ }
+
+ public IConfiguration getConfiguration(){
+ return fCfg;
+ }
+
+ public IResourceInfo getResourceInfo(){
+ return fRcInfo;
+ }
+
+ public ITool getTool(){
+ return fTool;
+ }
+
+ public IInputType getInputType(){
+ return fInType;
+ }
+
+ public boolean equals(Object obj) {
+ if(this == obj)
+ return true;
+
+ if(!(obj instanceof InfoContext))
+ return false;
+
+ InfoContext other = (InfoContext)obj;
+ if(!checkBuildObjects(other.fCfg, fCfg))
+ return false;
+
+ if(!checkBuildObjects(other.fRcInfo, fRcInfo))
+ return false;
+
+ if(!checkBuildObjects(other.fTool, fTool))
+ return false;
+
+ if(!checkBuildObjects(other.fInType, fInType))
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int code = getCode(fCfg);
+ code += getCode(fRcInfo);
+ code += getCode(fTool);
+ code += getCode(fInType);
+ return code;
+ }
+
+ private boolean checkBuildObjects(IBuildObject bo1, IBuildObject bo2){
+ if(bo1 == null)
+ return bo2 == null;
+ if(bo2 == null)
+ return false;
+ return bo1.getId().equals(bo2.getId());
+ }
+
+ private int getCode(IBuildObject bo){
+ if(bo == null)
+ return NULL_OBJ_CODE;
+ return bo.getId().hashCode();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
new file mode 100644
index 00000000000..8f852d35e9e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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 - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.core.scannerconfig;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.resources.ACBuilder;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
+import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.SCJobsUtil;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import sun.security.action.GetPropertyAction;
+
+/**
+ * Runs after standard make builder.
+ * Consolidates discovered scanner configuration and updates project's scanner configuration.
+ *
+ * @see IncrementalProjectBuilder
+ */
+public class ScannerConfigBuilder extends ACBuilder {
+ /*
+ * calculation flags
+ */
+ /**
+ * tells the discovery mechanism to perform core settings update
+ */
+ public static final int PERFORM_CORE_UPDATE = 1;
+
+ /**
+ * force the discovery, i.e. run the discovery even if it is disabled
+ */
+ public static final int FORCE_DISCOVERY = 1 << 1;
+
+ public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$
+
+ public ScannerConfigBuilder() {
+ super();
+ }
+
+ /**
+ * @see IncrementalProjectBuilder#build
+ */
+ protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
+ // If auto discovery is disabled, do nothing
+// boolean autodiscoveryEnabled;
+// boolean autodiscoveryEnabled2;
+// IScannerConfigBuilderInfo2 buildInfo2 = null;
+// IConfiguration cfg = ScannerConfigUtil.getActiveConfiguration(getProject());
+ IManagedBuildInfo bInfo = ManagedBuildManager.getBuildInfo(getProject());
+ if(bInfo != null){
+ IConfiguration cfgs[] = bInfo.getManagedProject().getConfigurations();
+ if(cfgs.length != 0){
+ monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), cfgs.length);
+ for(int i = 0; i < cfgs.length; i++){
+ build(cfgs[i], 0, new SubProgressMonitor(monitor, 1));
+ }
+ }
+
+ ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateCoreSettings(getProject(), cfgs);
+ }
+
+
+ return getProject().getReferencedProjects();
+ }
+
+ public static void build(IConfiguration cfg, int flags, IProgressMonitor monitor){
+ if(cfg != null){
+ // IScannerConfigBuilderInfo buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(getProject(), BUILDER_ID);
+ // autodiscoveryEnabled = buildInfo.isAutoDiscoveryEnabled();
+ //
+ // if (autodiscoveryEnabled) {
+ // monitor.beginTask("ScannerConfigBuilder.Invoking_Builder", 100); //$NON-NLS-1$
+ // monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
+ // getProject().getName());
+ // ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(), new SubProgressMonitor(monitor, 100));
+ // }
+ IConfigurationScannerConfigBuilderInfo info = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
+ IProject project = cfg.getOwner().getProject();
+ Map infoMap = info.getInfoMap();
+ int num = infoMap.size();
+ if(num != 0){
+ monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), num);
+ for(Iterator iter = infoMap.entrySet().iterator(); iter.hasNext();){
+ try {
+ Map.Entry entry = (Map.Entry)iter.next();
+ InfoContext c = (InfoContext)entry.getKey();
+ IScannerConfigBuilderInfo2 buildInfo2 = (IScannerConfigBuilderInfo2)entry.getValue();
+ build(c, buildInfo2, (flags & (~PERFORM_CORE_UPDATE)), new SubProgressMonitor(monitor, 1));
+ } catch (CoreException e){
+ // builder not installed or disabled
+ // autodiscoveryEnabled = false;
+ // autodiscoveryEnabled2 = false;
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+ }
+ if((flags & PERFORM_CORE_UPDATE) != 0)
+ ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateCoreSettings(project, new IConfiguration[]{cfg});
+ }
+
+ }
+
+ public static SCProfileInstance build(InfoContext context, IScannerConfigBuilderInfo2 buildInfo2, int flags, IProgressMonitor monitor) throws CoreException{
+ IConfiguration cfg = context.getConfiguration();
+ IProject project = cfg.getOwner().getProject();
+ boolean autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
+
+ if (autodiscoveryEnabled2 || ((flags & FORCE_DISCOVERY) != 0)) {
+ monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$
+ monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
+ project.getName());
+
+ // get scanner info from all external providers
+ SCProfileInstance instance = SCJobsUtil.getProviderScannerInfo(project, context, null, buildInfo2, new SubProgressMonitor(monitor, 70));
+
+ // update and persist scanner configuration
+ SCJobsUtil.updateScannerConfiguration(project, context, instance, buildInfo2, new SubProgressMonitor(monitor, 30));
+
+ if((flags & PERFORM_CORE_UPDATE) != 0)
+ ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateCoreSettings(project, new IConfiguration[]{cfg});
+
+ return instance;
+ }
+
+ return null;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java
index fcee6909118..02a9da22024 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java
@@ -10,17 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.make.core.scannerconfig;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -32,7 +22,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public class ScannerConfigNature implements IProjectNature {
- public final static String NATURE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ScannerConfigNature"; //$NON-NLS-1$
+ public final static String NATURE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ScannerConfigNature"; //$NON-NLS-1$
private IProject fProject;
/**
@@ -172,69 +162,69 @@ public class ScannerConfigNature implements IProjectNature {
/**
* @param project
*/
- public static void initializeDiscoveryOptions(IProject project) {
- try {
- IScannerConfigBuilderInfo2 scPrefInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(
- MakeCorePlugin.getDefault().getPluginPreferences(), false);
- String selectedProfile = scPrefInfo.getSelectedProfileId();
- IScannerConfigBuilderInfo2 scProjInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(
- project, selectedProfile);
-
- scProjInfo.setAutoDiscoveryEnabled(scPrefInfo.isAutoDiscoveryEnabled());
- scProjInfo.setProblemReportingEnabled(scPrefInfo.isProblemReportingEnabled());
-
- scProjInfo.setBuildOutputParserEnabled(scPrefInfo.isBuildOutputParserEnabled());
- scProjInfo.setBuildOutputFileActionEnabled(scPrefInfo.isBuildOutputFileActionEnabled());
- scProjInfo.setBuildOutputFilePath(scPrefInfo.getBuildOutputFilePath());
-
- ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(selectedProfile);
- List providerIdList = scPrefInfo.getProviderIdList();
- for (Iterator i = providerIdList.iterator(); i.hasNext();) {
- String providerId = (String) i.next();
-
- scProjInfo.setProviderOutputParserEnabled(providerId, scPrefInfo.isProviderOutputParserEnabled(providerId));
- if (profile.getScannerInfoProviderElement(providerId).getProviderKind().equals(
- ScannerConfigProfile.ScannerInfoProvider.RUN)) {
- scProjInfo.setProviderRunCommand(providerId, scPrefInfo.getProviderRunCommand(providerId));
- scProjInfo.setProviderRunArguments(providerId, scPrefInfo.getProviderRunArguments(providerId));
- }
- else {
- scProjInfo.setProviderOpenFilePath(providerId, scPrefInfo.getProviderOpenFilePath(providerId));
- }
- }
- scProjInfo.save();
-
- // the last step is to add discovered paths container
- ICProject cProject = CoreModel.getDefault().create(project);
- IPathEntry[] rawPathEntries = CoreModel.getRawPathEntries(cProject);
- boolean found = false;
- for (int i = 0; i < rawPathEntries.length; i++) {
- if (rawPathEntries[i].getEntryKind() == IPathEntry.CDT_CONTAINER) {
- IContainerEntry container = (IContainerEntry) rawPathEntries[i];
- if (container.getPath().equals(DiscoveredPathContainer.CONTAINER_ID)) {
- found = true;
- break;
- }
- }
- }
- if (!found) {
- IPathEntry[] newRawPathEntries = new IPathEntry[rawPathEntries.length + 1];
- System.arraycopy(rawPathEntries, 0, newRawPathEntries, 0, rawPathEntries.length);
- newRawPathEntries[rawPathEntries.length] = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
- CoreModel.setRawPathEntries(cProject, newRawPathEntries, null);
- }
-// if (profile.getProfileScope().equals(ScannerConfigScope.PROJECT_SCOPE)) {
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// new DiscoveredPathContainer(project), null);
+//FIXME public static void initializeDiscoveryOptions(IProject project) {
+// try {
+// IScannerConfigBuilderInfo2 scPrefInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(
+// ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), false);
+// String selectedProfile = scPrefInfo.getSelectedProfileId();
+// IScannerConfigBuilderInfo2 scProjInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(
+// project, selectedProfile);
+//
+// scProjInfo.setAutoDiscoveryEnabled(scPrefInfo.isAutoDiscoveryEnabled());
+// scProjInfo.setProblemReportingEnabled(scPrefInfo.isProblemReportingEnabled());
+//
+// scProjInfo.setBuildOutputParserEnabled(scPrefInfo.isBuildOutputParserEnabled());
+// scProjInfo.setBuildOutputFileActionEnabled(scPrefInfo.isBuildOutputFileActionEnabled());
+// scProjInfo.setBuildOutputFilePath(scPrefInfo.getBuildOutputFilePath());
+//
+// ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(selectedProfile);
+// List providerIdList = scPrefInfo.getProviderIdList();
+// for (Iterator i = providerIdList.iterator(); i.hasNext();) {
+// String providerId = (String) i.next();
+//
+// scProjInfo.setProviderOutputParserEnabled(providerId, scPrefInfo.isProviderOutputParserEnabled(providerId));
+// if (profile.getScannerInfoProviderElement(providerId).getProviderKind().equals(
+// ScannerConfigProfile.ScannerInfoProvider.RUN)) {
+// scProjInfo.setProviderRunCommand(providerId, scPrefInfo.getProviderRunCommand(providerId));
+// scProjInfo.setProviderRunArguments(providerId, scPrefInfo.getProviderRunArguments(providerId));
+// }
+// else {
+// scProjInfo.setProviderOpenFilePath(providerId, scPrefInfo.getProviderOpenFilePath(providerId));
+// }
// }
-// else { // file scope
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// new PerFileDiscoveredPathContainer(project), null);
+// scProjInfo.save();
+//
+// // the last step is to add discovered paths container
+// ICProject cProject = CoreModel.getDefault().create(project);
+// IPathEntry[] rawPathEntries = CoreModel.getRawPathEntries(cProject);
+// boolean found = false;
+// for (int i = 0; i < rawPathEntries.length; i++) {
+// if (rawPathEntries[i].getEntryKind() == IPathEntry.CDT_CONTAINER) {
+// IContainerEntry container = (IContainerEntry) rawPathEntries[i];
+// if (container.getPath().equals(DiscoveredPathContainer.CONTAINER_ID)) {
+// found = true;
+// break;
+// }
+// }
// }
- }
- catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
- }
+// if (!found) {
+// IPathEntry[] newRawPathEntries = new IPathEntry[rawPathEntries.length + 1];
+// System.arraycopy(rawPathEntries, 0, newRawPathEntries, 0, rawPathEntries.length);
+// newRawPathEntries[rawPathEntries.length] = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
+// CoreModel.setRawPathEntries(cProject, newRawPathEntries, null);
+// }
+//// if (profile.getProfileScope().equals(ScannerConfigScope.PROJECT_SCOPE)) {
+//// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+//// new DiscoveredPathContainer(project), null);
+//// }
+//// else { // file scope
+//// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+//// new PerFileDiscoveredPathContainer(project), null);
+//// }
+// }
+// catch (CoreException e) {
+// ManagedBuilderCorePlugin.log(e);
+// }
+// }
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java
index e77d94d617d..8e042cd88d7 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java
@@ -42,4 +42,4 @@ public class ScannerConfigScope {
public int hashCode() {
return scope.hashCode();
}
-} \ No newline at end of file
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java
index de3732ec1ec..de3732ec1ec 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java
index d952523e24d..2cb82a804e9 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java
@@ -19,9 +19,9 @@ import java.util.Map.Entry;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -63,7 +63,7 @@ public class DiscoveredPathContainer implements IPathEntryContainer {
fPathEntries = computeNewPathEntries();
}
catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
return new IPathEntry[0];
}
}
@@ -71,7 +71,7 @@ public class DiscoveredPathContainer implements IPathEntryContainer {
}
private IPathEntry[] computeNewPathEntries() throws CoreException {
- IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
+ IDiscoveredPathInfo info = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
IPath[] includes = info.getIncludePaths();
Map syms = info.getSymbols();
List entries = new ArrayList(includes.length + syms.size());
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java
index cecddaa0b95..79c64a55e18 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java
@@ -17,6 +17,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
@@ -42,6 +44,8 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
private List activePaths;
private Map activeSymbols;
+
+ private boolean loadded;
public DiscoveredPathInfo(IProject project) {
this.project = project;
@@ -49,6 +53,32 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
discoveredSymbols = new LinkedHashMap();
}
+ public DiscoveredPathInfo(IProject project, IScannerInfoCollector collector) {
+ this(project);
+ if(collector != null)
+ init(collector);
+ }
+
+ private void init(IScannerInfoCollector c){
+ List list = c.getCollectedScannerInfo(project, ScannerInfoTypes.INCLUDE_PATHS);
+ if(list != null){
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ String s = (String)iter.next();
+ if(s != null){
+ discoveredPaths.put(s, null);
+ }
+ }
+ }
+ activePaths = null;
+
+ list = c.getCollectedScannerInfo(project, ScannerInfoTypes.SYMBOL_DEFINITIONS);
+ if(list != null){
+ ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(discoveredSymbols, list, true);
+ }
+ activeSymbols = null;
+ }
+
+
public IProject getProject() {
return project;
}
@@ -170,6 +200,7 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
*/
public void deserialize(Element collectorElem) {
+ loadded = true;
LinkedHashMap includes = getIncludeMap();
LinkedHashMap symbols = getSymbolMap();
@@ -205,5 +236,9 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
public IDiscoveredScannerInfoSerializable getSerializable() {
return this;
}
+
+ public boolean isLoadded(){
+ return loadded;
+ }
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java
index ac3d3ccd4e9..3e0cd10ab51 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java
@@ -13,11 +13,12 @@ package org.eclipse.cdt.make.internal.core.scannerconfig;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -28,20 +29,21 @@ import org.eclipse.core.runtime.Status;
public class DiscoveredPathInitializer extends PathEntryContainerInitializer {
public void initialize(IPath containerPath, ICProject cProject) throws CoreException {
- IProject project = cProject.getProject();
- IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
- ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(buildInfo.getSelectedProfileId()).getProfileScope();
- if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
- CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(project), null);
- }
- else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
- CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new PerFileDiscoveredPathContainer(project), null);
- }
- else {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1,
- MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
- }
+// IProject project = cProject.getProject();
+// InfoContext context = ScannerConfigUtil.createContextForProject(project);
+// IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(context);
+// ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
+// getSCProfileConfiguration(buildInfo.getSelectedProfileId()).getProfileScope();
+// if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
+// CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(project), null);
+// }
+// else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
+// CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new PerFileDiscoveredPathContainer(project), null);
+// }
+// else {
+// throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), 1,
+// MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
+// }
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
new file mode 100644
index 00000000000..365cbb97681
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
@@ -0,0 +1,555 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.core.scannerconfig;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+
+
+public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceChangeListener {
+
+// private Map fDiscoveredMap = new HashMap();
+ private List listeners = Collections.synchronizedList(new ArrayList());
+
+ private static final int INFO_CHANGED = 1;
+ private static final int INFO_REMOVED = 2;
+
+ public DiscoveredPathManager() {
+
+ }
+
+ public void startup() {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+ }
+
+ public void shutdown() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ if (event.getSource() instanceof IWorkspace) {
+ IResource resource = event.getResource();
+
+ switch (event.getType()) {
+ case IResourceChangeEvent.POST_CHANGE :
+ DiscoveredScannerInfoStore.getInstance().updateScannerConfigStore(event.getDelta());
+ break;
+ case IResourceChangeEvent.PRE_DELETE :
+ case IResourceChangeEvent.PRE_CLOSE :
+ if (resource.getType() == IResource.PROJECT) {
+// fDiscoveredMap.remove(resource);
+ }
+ break;
+ }
+ }
+ }
+
+ public IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException {
+// IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.get(project);
+// if (info == null) {
+// info = loadPathInfo(project);
+// fDiscoveredMap.put(project, info);
+// }
+// return info;
+// InfoContext c = ScannerConfigUtil.createContextForProject(project);
+// if(c != null)
+ return getDiscoveredInfo(project, null);
+// return null;
+ }
+
+ private IDiscoveredPathInfo loadPathInfo(IConfiguration cfg, InfoContext c) throws CoreException {
+ IDiscoveredPathInfo pathInfo = null;
+
+ IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(c);
+ IScannerInfoCollector collector = null;
+ if(buildInfo != null){
+ String profileId = buildInfo.getSelectedProfileId();
+ SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
+ getSCProfileInstance(c, profileId);
+ collector = profileInstance.getScannerInfoCollector();
+
+ if (collector instanceof IScannerInfoCollector2) {
+ IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
+ pathInfo = collector2.createPathInfoObject();
+ if(collector2 instanceof IScannerInfoCollector3){
+ IScannerInfoCollector3 collector3 = (IScannerInfoCollector3)collector2;
+ if(!collector3.isInfoCollected()){
+ setCachedPathInfo(c, pathInfo);
+ SCProfileInstance instance = ScannerConfigBuilder.build(c, buildInfo, 0, new NullProgressMonitor());
+ if(instance != null){
+ IScannerInfoCollector newC = instance.getScannerInfoCollector();
+ if(newC instanceof IScannerInfoCollector2){
+ pathInfo = ((IScannerInfoCollector2)newC).createPathInfoObject();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(pathInfo == null) {
+ IProject project = c.getConfiguration().getOwner().getProject();
+ pathInfo = new DiscoveredPathInfo(project, collector);
+ }
+ return pathInfo;
+ }
+
+// private IDiscoveredPathInfo createPathInfo(IProject project, InfoContext context) throws CoreException{
+// IConfigurationScannerConfigBuilderInfo cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+//
+// IScannerConfigBuilderInfo2 info2 =cfgInfo.getInfo(context);
+// if(info2 != null){
+// ScannerConfigBuilder.build(context, info2, 0, new NullProgressMonitor());
+// }
+// info = new DiscoveredPathInfo(project);
+// return info;
+// }
+
+ public void removeDiscoveredInfo(IProject project) {
+ removeDiscoveredInfo(project, null);
+
+// IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.remove(project);
+// if (info != null) {
+// fireUpdate(INFO_REMOVED, info);
+// }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#updateDiscoveredInfo(org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo, java.util.List)
+ */
+ public void updateDiscoveredInfo(IDiscoveredPathInfo info, List changedResources) throws CoreException {
+// InfoContext c = ScannerConfigUtil.createContextForProject(info.getProject());
+// if(c != null)
+ updateDiscoveredInfo(info, null, changedResources);
+// if (fDiscoveredMap.get(info.getProject()) != null) {
+// IDiscoveredScannerInfoSerializable serializable = info.getSerializable();
+// if (serializable != null) {
+// IProject project = info.getProject();
+// DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, serializable);
+// fireUpdate(INFO_CHANGED, info);
+//
+//// ICProject cProject = CoreModel.getDefault().create(info.getProject());
+//// if (cProject != null) {
+//// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+//// new DiscoveredPathContainer(info.getProject()), null);
+//// }
+// IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
+// String profileId = buildInfo.getSelectedProfileId();
+// ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
+// getSCProfileConfiguration(profileId).getProfileScope();
+// changeDiscoveredContainer(project, profileScope, changedResources);
+// }
+// else {
+// throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+// MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$
+// }
+// }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#changeDiscoveredContainer(org.eclipse.core.resources.IProject, java.lang.String)
+ */
+ public void changeDiscoveredContainer(final IProject project, final ScannerConfigScope profileScope, final List changedResources) {
+// InfoContext c = ScannerConfigUtil.createContextForProject(project);
+// if(c != null){
+ changeDiscoveredContainer(project, null, profileScope, changedResources);
+// }
+// // order here is of essence
+// // 1. clear DiscoveredPathManager's path info cache
+// IDiscoveredPathInfo oldInfo = (IDiscoveredPathInfo) fDiscoveredMap.remove(project);
+//
+// // 2. switch the containers
+// try {
+// IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+// public void run(IProgressMonitor monitor) throws CoreException {
+// ICProject cProject = CoreModel.getDefault().create(project);
+// if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
+// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+// new DiscoveredPathContainer(project), null);
+// }
+// else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
+// PerFileDiscoveredPathContainer container = new PerFileDiscoveredPathContainer(project);
+// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+// container, null);
+// if (changedResources != null) {
+// List changeDelta = new ArrayList(changedResources.size());
+// for (Iterator i = changedResources.iterator(); i.hasNext(); ) {
+// IResource resource = (IResource) i.next();
+// IPath path = resource.getFullPath();
+// changeDelta.add(new PathEntryContainerChanged(path,
+// PathEntryContainerChanged.INCLUDE_CHANGED |
+// PathEntryContainerChanged.MACRO_CHANGED)); // both include paths and symbols changed
+// }
+// CoreModel.pathEntryContainerUpdates(container,
+// (PathEntryContainerChanged[]) changeDelta.toArray(new PathEntryContainerChanged[changeDelta.size()]),
+// null);
+// }
+// }
+// else {
+// ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), 1,
+// MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
+// }
+//
+// }
+// };
+// CoreModel.run(runnable, null);
+// }
+// catch (CoreException e) {
+// ManagedBuilderCorePlugin.log(e);
+// }
+//
+// // 3. clear the container's path entry cache
+// if (oldInfo != null) {
+// fireUpdate(INFO_REMOVED, oldInfo);
+// }
+ }
+
+ private void fireUpdate(final int type, final IDiscoveredPathInfo info) {
+ Object[] list = listeners.toArray();
+ for (int i = 0; i < list.length; i++) {
+ final IDiscoveredInfoListener listener = (IDiscoveredInfoListener)list[i];
+ if (listener != null) {
+ Platform.run(new ISafeRunnable() {
+
+ public void handleException(Throwable exception) {
+ IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+ CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
+ CCorePlugin.log(status);
+ }
+
+ public void run() throws Exception {
+ switch (type) {
+ case INFO_CHANGED :
+ listener.infoChanged(info);
+ break;
+ case INFO_REMOVED :
+ listener.infoRemoved(info);
+ break;
+ }
+ }
+ });
+ }
+ }
+ }
+
+ public void addDiscoveredInfoListener(IDiscoveredInfoListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeDiscoveredInfoListener(IDiscoveredInfoListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void changeDiscoveredContainer(final IProject project,
+ InfoContext c, final ScannerConfigScope profileScope,
+ final List changedResources) {
+ // order here is of essence
+ // 1. clear DiscoveredPathManager's path info cache
+ final InfoContext context = adjustContext(c);
+// Tool tool = (Tool)context.getTool();
+ IDiscoveredPathInfo oldInfo = setCachedPathInfo(context, null);
+// if(context == null)
+// context = ScannerConfigUtil.createContextForProject(project);
+ // 2. switch the containers
+ try {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+// ICProject cProject = CoreModel.getDefault().create(project);
+// if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
+// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+// new DiscoveredPathContainer(project), null);
+// }
+// else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
+// PerFileDiscoveredPathContainer container = new PerFileDiscoveredPathContainer(project);
+// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+// container, null);
+// if (changedResources != null) {
+// List changeDelta = new ArrayList(changedResources.size());
+// for (Iterator i = changedResources.iterator(); i.hasNext(); ) {
+// IResource resource = (IResource) i.next();
+// IPath path = resource.getFullPath();
+// changeDelta.add(new PathEntryContainerChanged(path,
+// PathEntryContainerChanged.INCLUDE_CHANGED |
+// PathEntryContainerChanged.MACRO_CHANGED)); // both include paths and symbols changed
+// }
+// CoreModel.pathEntryContainerUpdates(container,
+// (PathEntryContainerChanged[]) changeDelta.toArray(new PathEntryContainerChanged[changeDelta.size()]),
+// null);
+// }
+// }
+// else {
+// ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), 1,
+// MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
+// }
+//
+ if(context == null)
+ ManagedBuildManager.updateCoreSettings(project);
+ else
+ ManagedBuildManager.updateCoreSettings(context.getConfiguration());
+ }
+ };
+ CoreModel.run(runnable, null);
+ }
+ catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+
+ // 3. clear the container's path entry cache
+ if (oldInfo != null) {
+ fireUpdate(INFO_REMOVED, oldInfo);
+ }
+ }
+
+ public void updateCoreSettings(final IProject project, final IConfiguration cfgs[]) {
+ try {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ManagedBuildManager.updateCoreSettings(project, cfgs);
+ }
+ };
+ CoreModel.run(runnable, null);
+ }
+ catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+
+
+ public IDiscoveredPathInfo getDiscoveredInfo(IProject project,
+ InfoContext context) throws CoreException {
+ if(context == null)
+ context = ScannerConfigUtil.createContextForProject(project);
+
+ context = adjustContext(context);
+
+ IDiscoveredPathInfo info = getCachedPathInfo(context);
+ if (info == null) {
+ info = loadPathInfo(context.getConfiguration(), context);
+ setCachedPathInfo(context, info);
+// if(info instanceof DiscoveredPathInfo && !((DiscoveredPathInfo)info).isLoadded()){
+// info = createPathInfo(project, context);
+// setCachedPathInfo(context, info);
+// }
+ }
+ return info;
+ }
+
+ private IDiscoveredPathInfo getCachedPathInfo(InfoContext context){
+ IConfigurationScannerConfigBuilderInfo cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+ IDiscoveredPathInfo info = null;
+ boolean queryCfg = !cfgInfo.isPerRcTypeDiscovery();
+ if(!queryCfg){
+ Tool tool = (Tool)context.getTool();
+ if(tool != null){
+ info = tool.getDiscoveredPathInfo(context.getInputType());
+ } else {
+ queryCfg = true;
+ }
+ }
+ if(queryCfg) {
+ info = ((Configuration)context.getConfiguration()).getDiscoveredPathInfo();
+ }
+ return info;
+ }
+
+ private InfoContext adjustContext(InfoContext context){
+ return adjustContext(context, null);
+
+ }
+
+ private InfoContext adjustContext(InfoContext context, IConfigurationScannerConfigBuilderInfo cfgInfo){
+ if(cfgInfo == null)
+ cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+
+ boolean queryCfg = !cfgInfo.isPerRcTypeDiscovery();
+
+ Tool tool = (Tool)context.getTool();
+ IResourceInfo rcInfo = context.getResourceInfo();
+ IInputType inType = context.getInputType();
+ boolean adjust = false;
+ InfoContext newContext = context;
+
+ if(!queryCfg){
+ if(tool != null){
+ if(inType != null){
+ if(!tool.hasScannerConfigSettings(inType)){
+// tool = null;
+ inType = null;
+ adjust = true;
+ }
+ }
+ if(inType == null){
+ if(!tool.hasScannerConfigSettings(null)){
+ tool = null;
+ adjust = true;
+ }
+ }
+ }
+ if(tool == null){
+ if(inType != null){
+ inType = null;
+ adjust = true;
+ }
+
+ if(rcInfo != null){
+ ToolChain tc = rcInfo instanceof FolderInfo ?
+ (ToolChain)((FolderInfo)rcInfo).getToolChain()
+ : (ToolChain)((ResourceConfiguration)rcInfo).getBaseToolChain();
+
+ if(tc != null){
+ if(!tc.hasScannerConfigSettings()){
+ adjust = true;
+ rcInfo = null;
+ }
+ }
+ }
+ }
+ } else {
+ if(tool != null){
+ tool = null;
+ adjust = true;
+ }
+ if(rcInfo != null){
+ rcInfo = null;
+ adjust = true;
+ }
+ if(inType != null){
+ inType = null;
+ adjust = true;
+ }
+ }
+
+ if(adjust){
+ if(rcInfo == null)
+ newContext = new InfoContext(context.getConfiguration());
+ else
+ newContext = new InfoContext(rcInfo, tool, inType);
+ }
+
+ return newContext;
+ }
+
+ private IDiscoveredPathInfo setCachedPathInfo(InfoContext context, IDiscoveredPathInfo info){
+ IConfigurationScannerConfigBuilderInfo cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+ boolean cacheOnCfg = !cfgInfo.isPerRcTypeDiscovery();
+ IDiscoveredPathInfo oldInfo = null;
+ if(!cacheOnCfg){
+ Tool tool = (Tool)context.getTool();
+ if(tool != null){
+ if(info != null)
+ oldInfo = tool.setDiscoveredPathInfo(context.getInputType(), info);
+ else
+ oldInfo = tool.clearDiscoveredPathInfo(context.getInputType());
+ }
+ } else {
+ if(info != null)
+ oldInfo = ((Configuration)context.getConfiguration()).setDiscoveredPathInfo(info);
+ else
+ oldInfo = ((Configuration)context.getConfiguration()).clearDiscoveredPathInfo();
+ }
+ return oldInfo;
+ }
+
+ public void removeDiscoveredInfo(IProject project, InfoContext context) {
+ if(context == null)
+ context = ScannerConfigUtil.createContextForProject(project);
+
+ context = adjustContext(context);
+
+ IDiscoveredPathInfo info = setCachedPathInfo(context, null);
+ if (info != null) {
+ fireUpdate(INFO_REMOVED, info);
+ }
+ }
+
+ public void updateDiscoveredInfo(IDiscoveredPathInfo info,
+ InfoContext context, List changedResources) throws CoreException {
+// if(context == null){
+// updateDiscoveredInfo(info, changedResources);
+// return;
+// }
+ if(context == null)
+ context = ScannerConfigUtil.createContextForProject(info.getProject());
+ context = adjustContext(context);
+
+ IDiscoveredPathInfo oldInfo = getCachedPathInfo(context);
+ if (oldInfo != null) {
+ IDiscoveredScannerInfoSerializable serializable = info.getSerializable();
+ if (serializable != null) {
+ DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(context, serializable);
+ fireUpdate(INFO_CHANGED, info);
+
+// ICProject cProject = CoreModel.getDefault().create(info.getProject());
+// if (cProject != null) {
+// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
+// new DiscoveredPathContainer(info.getProject()), null);
+// }
+ IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(context);
+ String profileId = buildInfo.getSelectedProfileId();
+ ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
+ getSCProfileConfiguration(profileId).getProfileScope();
+// changeDiscoveredContainer(context.getConfiguration().getOwner().getProject(),
+// context,
+// profileScope,
+// changedResources);
+ }
+ else {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$
+ }
+ setCachedPathInfo(context, info);
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java
index a9bad020a1a..97198be41ee 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java
@@ -28,10 +28,14 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
@@ -55,11 +59,14 @@ import org.xml.sax.SAXException;
*/
public class DiscoveredScannerInfoStore {
private static final QualifiedName dscFileNameProperty = new
- QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "discoveredScannerConfigFileName"); //$NON-NLS-1$
- private static final String CDESCRIPTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".discoveredScannerInfo"; //$NON-NLS-1$
+ QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "discoveredScannerConfigFileName"); //$NON-NLS-1$
+ private static final String CDESCRIPTOR_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".discoveredScannerInfo"; //$NON-NLS-1$
public static final String SCD_STORE_VERSION = "scdStore"; //$NON-NLS-1$
public static final String SI_ELEM = "scannerInfo"; //$NON-NLS-1$
public static final String COLLECTOR_ELEM = "collector"; //$NON-NLS-1$
+ public static final String CFG_ELEM = "configuration"; //$NON-NLS-1$
+ public static final String TOOL_ELEM = "tool"; //$NON-NLS-1$
+ public static final String INTYPE_ELEM = "inputType"; //$NON-NLS-1$
public static final String ID_ATTR = "id"; //$NON-NLS-1$
private static DiscoveredScannerInfoStore instance;
@@ -78,7 +85,15 @@ public class DiscoveredScannerInfoStore {
private DiscoveredScannerInfoStore() {
}
- public void loadDiscoveredScannerInfoFromState(IProject project, IDiscoveredScannerInfoSerializable serializable)
+ public void loadDiscoveredScannerInfoFromState(InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException{
+ loadDiscoveredScannerInfoFromState(context.getConfiguration().getOwner().getProject(), context, serializable);
+ }
+
+ public void loadDiscoveredScannerInfoFromState(IProject project, IDiscoveredScannerInfoSerializable serializable) throws CoreException{
+ loadDiscoveredScannerInfoFromState(project, null, serializable);
+ }
+
+ public void loadDiscoveredScannerInfoFromState(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable)
throws CoreException {
// Get the document
Document document = getDocument(project);
@@ -86,18 +101,52 @@ public class DiscoveredScannerInfoStore {
NodeList rootList = document.getElementsByTagName(SI_ELEM);
if (rootList.getLength() > 0) {
Element rootElem = (Element) rootList.item(0);
- // get the collector element
- NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM);
- if (collectorList.getLength() > 0) {
- // find the collector element
- for (int i = 0; i < collectorList.getLength(); ++i) {
- Element collectorElem = (Element) collectorList.item(i);
- String collectorId = collectorElem.getAttribute(ID_ATTR);
- if (serializable.getCollectorId().equals(collectorId)) {
- serializable.deserialize(collectorElem);
- break;
+
+ if(context != null && context.getConfiguration() != null){
+ IConfiguration cfg = context.getConfiguration();
+ ITool tool = context.getTool();
+ IInputType inType = context.getInputType();
+
+ Element cfgElem = findChild(rootElem, CFG_ELEM, ID_ATTR, cfg.getId());
+ Element toolElem = null;
+ Element inTypeEl = null;
+
+
+ if(cfgElem != null){
+ if(tool != null){
+ toolElem = findChild(cfgElem, TOOL_ELEM, ID_ATTR, tool.getId());
+ if(toolElem != null){
+ if(inType != null){
+ inTypeEl = findChild(toolElem, INTYPE_ELEM, ID_ATTR, inType.getId());
+ }
+ }
}
}
+
+ if(inType != null){
+ rootElem = inTypeEl;
+ } else if(tool != null){
+ rootElem = toolElem;
+ } else if(cfg != null){
+ rootElem = cfgElem;
+ }
+ }
+
+
+ // get the collector element
+ if(rootElem != null){
+ NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM);
+ if (collectorList.getLength() > 0) {
+ // find the collector element
+ for (int i = 0; i < collectorList.getLength(); ++i) {
+ Element collectorElem = (Element) collectorList.item(i);
+ String collectorId = collectorElem.getAttribute(ID_ATTR);
+ if (serializable.getCollectorId().equals(collectorId)) {
+ serializable.deserialize(collectorElem);
+ break;
+ }
+ }
+ }
}
}
}
@@ -132,18 +181,18 @@ public class DiscoveredScannerInfoStore {
fDocumentMap.put(project, document);
}
catch (IOException e) {
- MakeCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ ManagedBuilderCorePlugin.log(e);
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
catch (ParserConfigurationException e) {
- MakeCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ ManagedBuilderCorePlugin.log(e);
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
catch (SAXException e) {
- MakeCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ ManagedBuilderCorePlugin.log(e);
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
}
@@ -167,15 +216,91 @@ public class DiscoveredScannerInfoStore {
rootElem.appendChild(collectorElem);
}
+ private Element findChild(Element parentElem, String name, String attr, String attrValue){
+ Element cfgElem = null;
+ NodeList cfgList = parentElem.getElementsByTagName(name);
+ if (cfgList.getLength() > 0) {
+ // find per file collector element and remove children
+ for (int i = 0; i < cfgList.getLength(); ++i) {
+ Element cElem = (Element) cfgList.item(i);
+ String value = cElem.getAttribute(attr);
+ if (value.equals(attrValue)) {
+ cfgElem = cElem;
+ break;
+ }
+ }
+ }
+
+ return cfgElem;
+ }
+
+ private void clearChildren(Element cElem){
+ for (Node child = cElem.getFirstChild(); child != null;
+ child = cElem.getFirstChild()) {
+ cElem.removeChild(child);
+ }
+ }
+
+
+
/**
* @param scannerInfo
* @param rootElement
* @param doc
*/
- private void saveDiscoveredScannerInfo(IDiscoveredScannerInfoSerializable serializable, Document doc) {
+ private void saveDiscoveredScannerInfo(IDiscoveredScannerInfoSerializable serializable, Document doc, InfoContext context) {
NodeList rootList = doc.getElementsByTagName(SI_ELEM);
if (rootList.getLength() > 0) {
Element rootElem = (Element) rootList.item(0);
+ if(context != null){
+ IConfiguration cfg = context.getConfiguration();
+ ITool tool = context.getTool();
+ IInputType inType = context.getInputType();
+
+ // get the collector element
+ if(cfg != null){
+ Element cfgElem = findChild(rootElem, CFG_ELEM, ID_ATTR, cfg.getId());
+ Element toolElem = null;
+ Element inTypeElem = null;
+ if(cfgElem != null){
+ if(tool != null){
+ toolElem = findChild(cfgElem, TOOL_ELEM, ID_ATTR, tool.getId());
+ if(toolElem != null){
+ if(inType != null){
+ inTypeElem = findChild(toolElem, INTYPE_ELEM, ID_ATTR, inType.getId());
+ }
+ }
+ }
+ }
+ if(cfgElem == null){
+ cfgElem = doc.createElement(CFG_ELEM);
+ cfgElem.setAttribute(ID_ATTR, cfg.getId());
+ rootElem.appendChild(cfgElem);
+ }
+ if(tool != null){
+ if(toolElem == null){
+ toolElem = doc.createElement(TOOL_ELEM);
+ toolElem.setAttribute(ID_ATTR, tool.getId());
+ cfgElem.appendChild(toolElem);
+ }
+ if(inType != null){
+ if(inTypeElem == null){
+ inTypeElem = doc.createElement(INTYPE_ELEM);
+ inTypeElem.setAttribute(ID_ATTR, inType.getId());
+ toolElem.appendChild(inTypeElem);
+ }
+ }
+ }
+
+ if(inTypeElem != null){
+ rootElem = inTypeElem;
+ } else if(toolElem != null){
+ rootElem = toolElem;
+ } else {
+ rootElem = cfgElem;
+ }
+ }
+ }
// get the collector element
Element collectorElem = null;
NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM);
@@ -205,12 +330,20 @@ public class DiscoveredScannerInfoStore {
serializable.serialize(collectorElem);
}
}
-
+
+ public void saveDiscoveredScannerInfoToState(InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException {
+ saveDiscoveredScannerInfoToState(context.getConfiguration().getOwner().getProject(), context, serializable);
+ }
+
public void saveDiscoveredScannerInfoToState(IProject project, IDiscoveredScannerInfoSerializable serializable) throws CoreException {
+ saveDiscoveredScannerInfoToState(project, null, serializable);
+ }
+
+ public void saveDiscoveredScannerInfoToState(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException {
Document document = getDocument(project);
// Create document
try {
- saveDiscoveredScannerInfo(serializable, document);
+ saveDiscoveredScannerInfo(serializable, document, context);
// Transform the document to something we can save in a file
ByteArrayOutputStream stream = new ByteArrayOutputStream();
@@ -229,19 +362,19 @@ public class DiscoveredScannerInfoStore {
file.write(stream.toByteArray());
file.close();
} catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
// Close the streams
stream.close();
} catch (TransformerException e) {
- MakeCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ ManagedBuilderCorePlugin.log(e);
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
} catch (IOException e) {
- MakeCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ ManagedBuilderCorePlugin.log(e);
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
}
}
@@ -252,7 +385,7 @@ public class DiscoveredScannerInfoStore {
try {
storedFileName = project.getPersistentProperty(dscFileNameProperty);
} catch (CoreException e) {
- MakeCorePlugin.log(e.getStatus());
+ ManagedBuilderCorePlugin.log(e.getStatus());
}
if (storedFileName != null && !storedFileName.equals(fileName)) {
// try to move 2.x file name format to 3.x file name format
@@ -261,10 +394,10 @@ public class DiscoveredScannerInfoStore {
try {
project.setPersistentProperty(dscFileNameProperty, fileName);
} catch (CoreException e) {
- MakeCorePlugin.log(e.getStatus());
+ ManagedBuilderCorePlugin.log(e.getStatus());
}
- return MakeCorePlugin.getWorkingDirectory().append(fileName);
+ return ManagedBuilderCorePlugin.getWorkingDirectory().append(fileName);
}
/**
@@ -303,7 +436,7 @@ public class DiscoveredScannerInfoStore {
});
}
catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
@@ -316,7 +449,7 @@ public class DiscoveredScannerInfoStore {
* @param scFileName
*/
private void deletePluginStateFile(String scFileName) {
- IPath path = MakeCorePlugin.getWorkingDirectory().append(scFileName);
+ IPath path = ManagedBuilderCorePlugin.getWorkingDirectory().append(scFileName);
File file = path.toFile();
if (file.exists()) {
file.delete();
@@ -331,7 +464,7 @@ public class DiscoveredScannerInfoStore {
newProject.setPersistentProperty(dscFileNameProperty, scNewFileName);
}
catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
@@ -340,8 +473,8 @@ public class DiscoveredScannerInfoStore {
* @param newFileName
*/
private void movePluginStateFile(String oldFileName, String newFileName) {
- IPath oldPath = MakeCorePlugin.getWorkingDirectory().append(oldFileName);
- IPath newPath = MakeCorePlugin.getWorkingDirectory().append(newFileName);
+ IPath oldPath = ManagedBuilderCorePlugin.getWorkingDirectory().append(oldFileName);
+ IPath newPath = ManagedBuilderCorePlugin.getWorkingDirectory().append(newFileName);
File oldFile = oldPath.toFile();
File newFile = newPath.toFile();
if (oldFile.exists()) {
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java
index 0248fd7ec72..25bc5c9afe9 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java
@@ -18,9 +18,9 @@ import java.util.Map.Entry;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -39,7 +39,7 @@ public class PerFileDiscoveredPathContainer extends DiscoveredPathContainer
public IPathEntry[] getPathEntries(IPath path, int mask) {
ArrayList entries = new ArrayList();
try {
- IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
+ IDiscoveredPathInfo info = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
if (info instanceof IPerFileDiscoveredPathInfo) {
IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
@@ -97,7 +97,7 @@ public class PerFileDiscoveredPathContainer extends DiscoveredPathContainer
public boolean isEmpty(IPath path) {
IDiscoveredPathInfo info;
try {
- info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
+ info = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
if (info instanceof IPerFileDiscoveredPathInfo) {
IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
return filePathInfo.isEmpty(path);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathInfo.java
new file mode 100644
index 00000000000..aeba3b9ce59
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathInfo.java
@@ -0,0 +1,183 @@
+package org.eclipse.cdt.make.internal.core.scannerconfig;
+
+
+public class PerFileDiscoveredPathInfo /*implements IPerFileDiscoveredPathInfo, IDiscoveredScannerInfoSerializable*/{
+// public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
+// public static final String PATH = "path"; //$NON-NLS-1$
+// public static final String DEFINED_SYMBOL = "definedSymbol"; //$NON-NLS-1$
+// public static final String SYMBOL = "symbol"; //$NON-NLS-1$
+// public static final String REMOVED = "removed"; //$NON-NLS-1$
+//
+//// final private IProject project;
+// private final IConfiguration config;
+//// private LinkedHashMap discoveredPaths;
+//// private LinkedHashMap discoveredSymbols;
+//
+// private List activePaths;
+// private Map activeSymbols;
+//
+// public PerFileDiscoveredPathInfo(IConfiguration cfg) {
+// this.config = cfg;
+//// discoveredPaths = new LinkedHashMap();
+//// discoveredSymbols = new LinkedHashMap();
+// }
+//
+// public IProject getProject() {
+// return config.getOwner().getProject();
+// }
+//
+// public synchronized Map getSymbols() {
+// if (activeSymbols == null) {
+// createSymbolsMap();
+// }
+// Map dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols);
+// return dSymbols;
+// }
+//
+// public synchronized IPath[] getIncludePaths() {
+// if ( activePaths == null) {
+// createPathLists();
+// }
+// return (IPath[])activePaths.toArray(new IPath[activePaths.size()]);
+// }
+//
+// public LinkedHashMap getIncludeMap() {
+// return new LinkedHashMap(discoveredPaths);
+// }
+//
+// public synchronized void setIncludeMap(LinkedHashMap paths) {
+// discoveredPaths = new LinkedHashMap(paths);
+// activePaths = null;
+// }
+//
+// /**
+// * Populates active and removed include path lists
+// */
+// private void createPathLists() {
+// List aPaths = getActivePathList();
+// aPaths.clear();
+//
+// for (Iterator i = discoveredPaths.keySet().iterator(); i.hasNext(); ) {
+// String path = (String) i.next();
+// Boolean removed = (Boolean) discoveredPaths.get(path);
+// if (removed == null || removed.booleanValue() == false) {
+// aPaths.add(new Path(path));
+// }
+// }
+// }
+//
+// public LinkedHashMap getSymbolMap() {
+// return new LinkedHashMap(discoveredSymbols);
+// }
+//
+// public synchronized void setSymbolMap(LinkedHashMap symbols) {
+// discoveredSymbols = new LinkedHashMap(symbols);
+// activeSymbols = null;
+// }
+//
+// /**
+// * Populates active symbols sets
+// */
+// private void createSymbolsMap() {
+// Map aSymbols = getActiveSymbolsMap();
+// aSymbols.clear();
+//
+// aSymbols.putAll(ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols));
+// }
+//
+// private List getActivePathList() {
+// if (activePaths == null) {
+// activePaths = new ArrayList();
+// }
+// return activePaths;
+// }
+//
+// private Map getActiveSymbolsMap() {
+// if (activeSymbols == null) {
+// activeSymbols = new HashMap();
+// }
+// return activeSymbols;
+// }
+//
+// /* (non-Javadoc)
+// * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
+// */
+// public void serialize(Element collectorElem) {
+// Document doc = collectorElem.getOwnerDocument();
+//
+// Map includes = getIncludeMap();
+// Iterator iter = includes.keySet().iterator();
+// while (iter.hasNext()) {
+// Element pathElement = doc.createElement(INCLUDE_PATH);
+// String include = (String)iter.next();
+// pathElement.setAttribute(PATH, include);
+// Boolean removed = (Boolean)includes.get(include);
+// if (removed != null && removed.booleanValue() == true) {
+// pathElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
+// }
+// collectorElem.appendChild(pathElement);
+// }
+// // Now do the same for the symbols
+// Map symbols = getSymbolMap();
+// iter = symbols.keySet().iterator();
+// while (iter.hasNext()) {
+// String symbol = (String)iter.next();
+// SymbolEntry se = (SymbolEntry)symbols.get(symbol);
+// for (Iterator i = se.getActiveRaw().iterator(); i.hasNext();) {
+// String value = (String)i.next();
+// Element symbolElement = doc.createElement(DEFINED_SYMBOL);
+// symbolElement.setAttribute(SYMBOL, value);
+// collectorElem.appendChild(symbolElement);
+// }
+// for (Iterator i = se.getRemovedRaw().iterator(); i.hasNext();) {
+// String value = (String)i.next();
+// Element symbolElement = doc.createElement(DEFINED_SYMBOL);
+// symbolElement.setAttribute(SYMBOL, value);
+// symbolElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
+// collectorElem.appendChild(symbolElement);
+// }
+// }
+// }
+//
+// /* (non-Javadoc)
+// * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
+// */
+// public void deserialize(Element collectorElem) {
+// LinkedHashMap includes = getIncludeMap();
+// LinkedHashMap symbols = getSymbolMap();
+//
+// Node child = collectorElem.getFirstChild();
+// while (child != null) {
+// if (child.getNodeName().equals(INCLUDE_PATH)) {
+// // Add the path to the property list
+// includes.put( ((Element)child).getAttribute(PATH), Boolean.valueOf( ((Element)child).getAttribute(REMOVED)));
+// } else if (child.getNodeName().equals(DEFINED_SYMBOL)) {
+// // Add the symbol to the symbol list
+// String symbol = ((Element)child).getAttribute(SYMBOL);
+// String removed = ((Element)child).getAttribute(REMOVED);
+// boolean bRemoved = (removed != null && removed.equals("true")); //$NON-NLS-1$
+// ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol, !bRemoved);
+// }
+// child = child.getNextSibling();
+// }
+//
+// setIncludeMap(includes);
+// setSymbolMap(symbols);
+// }
+//
+// /* (non-Javadoc)
+// * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
+// */
+// public String getCollectorId() {
+// return PerProjectSICollector.COLLECTOR_ID;
+// }
+//
+// /* (non-Javadoc)
+// * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable()
+// */
+// public IDiscoveredScannerInfoSerializable getSerializable() {
+// return this;
+// }
+//
+//
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java
index 170adaf22cc..7e58166e498 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java
@@ -13,6 +13,12 @@ package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.util.Map;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -25,19 +31,13 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.MakeProjectNature;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
/**
* Creates a ScannerConfigBuilderInfo variant
* @author vhirsl
*/
public class ScannerConfigInfoFactory {
- private static final String PREFIX = MakeCorePlugin.getUniqueIdentifier();
+ private static final String PREFIX = ManagedBuilderCorePlugin.getUniqueIdentifier();
static final String BUILD_SCANNER_CONFIG_ENABLED = PREFIX + ".ScannerConfigDiscoveryEnabled"; //$NON-NLS-1$
static final String MAKE_BUILDER_PARSER_ENABLED = PREFIX + ".makeBuilderParserEnabled"; //$NON-NLS-1$
@@ -96,7 +96,7 @@ public class ScannerConfigInfoFactory {
public String getMakeBuilderConsoleParserId() {
String parserId = getString(MAKE_BUILDER_PARSER_ID);
if (parserId == null || parserId.length() == 0) {
- String[] parserIds = MakeCorePlugin.getDefault().
+ String[] parserIds = ManagedBuilderCorePlugin.getDefault().
getScannerInfoConsoleParserIds("makeBuilder"); //$NON-NLS-1$
// the default is the first one in the registry
parserId = parserIds[0];
@@ -194,7 +194,7 @@ public class ScannerConfigInfoFactory {
public String getESIProviderConsoleParserId() {
String parserId = getString(ESI_PROVIDER_PARSER_ID);
if (parserId == null || parserId.length() == 0) {
- String[] parserIds = MakeCorePlugin.getDefault().
+ String[] parserIds = ManagedBuilderCorePlugin.getDefault().
getScannerInfoConsoleParserIds("externalScannerInfoProvider"); //$NON-NLS-1$
// the default is the first one in the registry
parserId = parserIds[0];
@@ -256,10 +256,10 @@ public class ScannerConfigInfoFactory {
protected String getESIProviderParameter(String name) {
IExtension extension =
Platform.getExtensionRegistry().getExtension(
- MakeCorePlugin.getUniqueIdentifier(),
- MakeCorePlugin.EXTERNAL_SI_PROVIDER_SIMPLE_ID,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ ManagedBuilderCorePlugin.EXTERNAL_SI_PROVIDER_SIMPLE_ID,
// TODO VMIR make this configurable
- MakeCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID);
+ ManagedBuilderCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID);
if (extension == null)
return null;
IConfigurationElement[] configs = extension.getConfigurationElements();
@@ -318,7 +318,7 @@ public class ScannerConfigInfoFactory {
ICommand builder = ScannerConfigNature.getBuildSpec(project.getDescription(), builderID);
if (builder == null) {
throw new CoreException(new Status(IStatus.ERROR,
- MakeCorePlugin.getUniqueIdentifier(), -1,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("ScannerConfigInfoFactory.Missing_Builder")//$NON-NLS-1$
+ builderID, null));
}
@@ -334,7 +334,7 @@ public class ScannerConfigInfoFactory {
ICommand builder = ScannerConfigNature.getBuildSpec(description, builderID);
args.put(name, value);
builder.setArguments(args);
- MakeProjectNature.setBuildSpec(description, builder);
+ ManagedCProjectNature.setBuildSpec(description, builder);
project.setDescription(description, null);
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java
index 476d5d66b88..d38addd322c 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java
@@ -18,7 +18,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
/**
@@ -287,4 +292,18 @@ public final class ScannerConfigUtil {
return rv;
}
+ public static InfoContext createContextForProject(IProject project){
+ IConfiguration cfg = getActiveConfiguration(project);
+ if(cfg != null)
+ return new InfoContext(cfg);
+ return null;
+ }
+
+ public static IConfiguration getActiveConfiguration(IProject project){
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ if(info != null)
+ return info.getDefaultConfiguration();
+ return null;
+ }
+
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
index 19ebfc92207..a287cb2df45 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
@@ -15,15 +15,18 @@ import java.io.OutputStream;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.MakeBuilderUtil;
-import org.eclipse.cdt.make.core.MakeBuilder;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -58,10 +61,30 @@ public class ScannerInfoConsoleParserFactory {
IMarkerGenerator markerGenerator) {
if (scBuildInfo.isProviderOutputParserEnabled(providerId)) {
// get the ESIProvider console parser
+ InfoContext context = null;
+ IConfiguration cfg = null;
+ IBuilder builder = null;
+ if(collector instanceof IScannerInfoCollector3){
+ context = ((IScannerInfoCollector3)collector).getContext();
+ }
+ if(context == null){
+ context = ScannerConfigUtil.createContextForProject(currentProject);
+ }
+ if(context != null){
+ cfg = context.getConfiguration();
+ }
+ if(cfg != null){
+ builder = cfg.getBuilder();
+ }
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(currentProject, scBuildInfo.getSelectedProfileId());
+ getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId());
IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId);
- IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID);
+ IPath buildDirectory;
+ if(builder != null) {
+ buildDirectory = ManagedBuildManager.getBuildLocation(cfg, builder);
+ } else {
+ buildDirectory = currentProject.getLocation();
+ }
clParser.startup(currentProject, buildDirectory, collector, markerGenerator);
// create an output stream sniffer
return new ConsoleOutputSniffer(outputStream, errorStream, new
@@ -84,20 +107,50 @@ public class ScannerInfoConsoleParserFactory {
* @return ConsoleOutputSniffer
*/
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
+ OutputStream outputStream,
+ OutputStream errorStream,
+ IProject currentProject,
+ IPath workingDirectory,
+ IScannerConfigBuilderInfo2 scBuildInfo,
+ IMarkerGenerator markerGenerator,
+ IScannerInfoCollector collector) {
+ IConfiguration cfg = ScannerConfigUtil.getActiveConfiguration(currentProject);
+ return getMakeBuilderOutputSniffer(outputStream, errorStream, cfg, null, workingDirectory, scBuildInfo, markerGenerator, collector);
+ }
+
+ /**
+ * Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
+ * and a utility.
+ *
+ * @param outputStream
+ * @param errorStream
+ * @param cfg
+ * @param workingDirectory
+ * @param buildInfo
+ * @param markerGenerator
+ * @param IScannerInfoCollector2
+ * @return ConsoleOutputSniffer
+ */
+ public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
OutputStream outputStream,
OutputStream errorStream,
- IProject currentProject,
+ IConfiguration cfg,
+ InfoContext context,
IPath workingDirectory,
IScannerConfigBuilderInfo2 scBuildInfo,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) {
try {
// get the SC builder settings
- if (currentProject.hasNature(ScannerConfigNature.NATURE_ID)) {
+ IProject project = cfg.getOwner().getProject();
+ if (project.hasNature(ScannerConfigNature.NATURE_ID)) {
+ if(context == null){
+ context = new InfoContext(cfg);
+ }
if (scBuildInfo == null) {
try {
scBuildInfo = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2(currentProject);
+ createScannerConfigBuildInfo2(context);
}
catch (CoreException e) {
// builder not installed or disabled
@@ -108,21 +161,23 @@ public class ScannerInfoConsoleParserFactory {
scBuildInfo.isBuildOutputParserEnabled()) {
// get the make builder console parser
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(currentProject, scBuildInfo.getSelectedProfileId());
+ getSCProfileInstance(context, scBuildInfo.getSelectedProfileId());
IScannerInfoConsoleParser clParser = profileInstance.createBuildOutputParser();
- if (collector == null) {
- collector = profileInstance.getScannerInfoCollector();
- }
- clParser.startup(currentProject, workingDirectory, collector,
- scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
- // create an output stream sniffer
- return new ConsoleOutputSniffer(outputStream, errorStream, new
- IScannerInfoConsoleParser[] {clParser});
+ if(clParser != null){
+ if (collector == null) {
+ collector = profileInstance.getScannerInfoCollector();
+ }
+ clParser.startup(project, workingDirectory, collector,
+ scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
+ // create an output stream sniffer
+ return new ConsoleOutputSniffer(outputStream, errorStream, new
+ IScannerInfoConsoleParser[] {clParser});
+ }
}
}
}
catch (CoreException e) {
- MakeCorePlugin.log(e.getStatus());
+ ManagedBuilderCorePlugin.log(e.getStatus());
}
return null;
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java
index 586f3771272..56848a305b8 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java
@@ -10,8 +10,11 @@
*******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
@@ -30,6 +33,7 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
private IProject project;
private IScannerInfoCollector collector;
+ private InfoContext context;
private boolean bMultiline = false;
private String sMultiline = ""; //$NON-NLS-1$
@@ -50,6 +54,12 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
public void startup(IProject project, IScannerInfoCollector collector) {
this.project = project;
this.collector = collector;
+ if(collector instanceof IScannerInfoCollector3){
+ context = ((IScannerInfoCollector3)collector).getContext();
+ } else {
+ context = ScannerConfigUtil.createContextForProject(project);
+ }
+
}
/**
@@ -60,7 +70,7 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
public String[] getCompilerCommands() {
if (project != null) {
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ getSCProfileInstance(project, context, ScannerConfigProfileManager.NULL_PROFILE_ID);
BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement();
if (boProvider != null) {
String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands();
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
index 60a029e8aea..60a029e8aea 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
index 2e5126a63ff..2e5126a63ff 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java
index 73eac867443..73eac867443 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java
index 5a07a3a8fee..5a07a3a8fee 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java
index e111681cab3..d56c9077280 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java
@@ -14,8 +14,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
@@ -31,12 +31,12 @@ public class GCCScannerConfigUtil {
public static final String C_SPECS_FILE = "specs.c"; //$NON-NLS-1$
public static void createSpecs() {
- IPath path = MakeCorePlugin.getWorkingDirectory();
+ IPath path = ManagedBuilderCorePlugin.getWorkingDirectory();
try {
createSpecsFile(path, CPP_SPECS_FILE);
createSpecsFile(path, C_SPECS_FILE);
} catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
@@ -50,7 +50,7 @@ public class GCCScannerConfigUtil {
file.close();
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR,
- MakeCorePlugin.getUniqueIdentifier(), -1,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
MakeMessages.getString("GCCScannerConfigUtil.Error_Message"), e)); //$NON-NLS-1$
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java
index cba556e3673..5c7d63cc4c5 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java
@@ -21,8 +21,8 @@ import java.util.Map;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
index 7e378667105..7e378667105 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
index 2ee24b12b77..815e0cf2eb0 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
@@ -20,9 +20,9 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -172,7 +172,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser
}
}
} catch (CoreException e) {
- MakeCorePlugin.log(e.getStatus());
+ ManagedBuilderCorePlugin.log(e.getStatus());
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
index 62d65a98c8c..a684369dc96 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
@@ -10,8 +10,11 @@
*******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.jobs;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -30,15 +33,25 @@ public class BuildOutputReaderJob extends Job {
private IResource resource;
private IScannerConfigBuilderInfo2 buildInfo;
+ private InfoContext context;
/**
* @param project
* @param buildInfo
*/
+ /*uncomment
public BuildOutputReaderJob(IProject project, IScannerConfigBuilderInfo2 buildInfo) {
+ this(project, null, buildInfo);
+ }
+ */
+
+ public BuildOutputReaderJob(IProject project, InfoContext context, IScannerConfigBuilderInfo2 buildInfo) {
super(JOB_NAME);
this.resource = project;
this.buildInfo = buildInfo;
+ if(context == null)
+ context = ScannerConfigUtil.createContextForProject(project);
+ this.context = context;
setUser(true);
}
@@ -51,8 +64,10 @@ public class BuildOutputReaderJob extends Job {
monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
project.getName());
- boolean rc = SCJobsUtil.readBuildOutputFile(project, buildInfo, new SubProgressMonitor(monitor, 70));
- rc |= SCJobsUtil.getProviderScannerInfo(project, buildInfo, new SubProgressMonitor(monitor, 20));
+ SCProfileInstance instance = SCJobsUtil.readBuildOutputFile(project, context, buildInfo, new SubProgressMonitor(monitor, 70));
+ boolean rc = instance != null;
+ instance = SCJobsUtil.getProviderScannerInfo(project, context, instance, buildInfo, new SubProgressMonitor(monitor, 20));
+ rc |= instance != null;
if (rc) {
rc = SCJobsUtil.updateScannerConfiguration(project, buildInfo, new SubProgressMonitor(monitor, 10));
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
index b835386346e..eb48193bf9e 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
@@ -12,13 +12,15 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.jobs;
import java.util.List;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
@@ -52,6 +54,14 @@ public class SCJobsUtil {
}
private boolean rc;
}
+ /*uncomment
+ public static boolean getProviderScannerInfo(final IProject project,
+ final IScannerConfigBuilderInfo2 buildInfo,
+ final IProgressMonitor monitor) {
+ return getProviderScannerInfo(project, null, buildInfo, monitor);
+ }
+ */
+
/**
* Call ESI providers to get scanner info
*
@@ -59,13 +69,17 @@ public class SCJobsUtil {
* @param buildInfo
* @param monitor
*/
- public static boolean getProviderScannerInfo(final IProject project,
+ public static SCProfileInstance getProviderScannerInfo(final IProject project,
+ final InfoContext context,
+ SCProfileInstance profileInstance,
final IScannerConfigBuilderInfo2 buildInfo,
final IProgressMonitor monitor) {
final RC rc = new RC(false);
// get the collector
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, buildInfo.getSelectedProfileId());
+ if(profileInstance == null){
+ profileInstance = ScannerConfigProfileManager.getInstance().
+ getSCProfileInstance(project, context, buildInfo.getSelectedProfileId());
+ }
final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
List providerIds = buildInfo.getProviderIdList();
@@ -84,7 +98,7 @@ public class SCJobsUtil {
public void handleException(Throwable exception) {
rc.set(false);
- MakeCorePlugin.log(exception);
+ ManagedBuilderCorePlugin.log(exception);
}
};
@@ -92,9 +106,17 @@ public class SCJobsUtil {
}
}
}
- return rc.get();
+ if(rc.get())
+ return profileInstance;
+ return null;
}
-
+
+ public static boolean updateScannerConfiguration(IProject project,
+ IScannerConfigBuilderInfo2 buildInfo,
+ final IProgressMonitor monitor) {
+ return updateScannerConfiguration(project, null, null, buildInfo, monitor);
+ }
+
/**
* Update and persist scanner configuration
*
@@ -103,12 +125,19 @@ public class SCJobsUtil {
* @param monitor
*/
public static boolean updateScannerConfiguration(IProject project,
+ InfoContext context,
+ SCProfileInstance profileInstance,
IScannerConfigBuilderInfo2 buildInfo,
final IProgressMonitor monitor) {
final RC rc = new RC(false);
// get the collector
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, buildInfo.getSelectedProfileId());
+ if(context == null)
+ context = ScannerConfigUtil.createContextForProject(project);
+
+ if(profileInstance == null){
+ profileInstance = ScannerConfigProfileManager.getInstance().
+ getSCProfileInstance(project, context, buildInfo.getSelectedProfileId());
+ }
IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
if (collector instanceof IScannerInfoCollector2) {
final IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
@@ -121,7 +150,7 @@ public class SCJobsUtil {
public void handleException(Throwable exception) {
rc.set(false);
- MakeCorePlugin.log(exception);
+ ManagedBuilderCorePlugin.log(exception);
}
};
@@ -131,19 +160,14 @@ public class SCJobsUtil {
return rc.get();
}
- /**
- * @param project
- * @param buildInfo
- * @param monitor
- * @return
- */
- public static boolean readBuildOutputFile(final IProject project,
- final IScannerConfigBuilderInfo2 buildInfo,
- final IProgressMonitor monitor) {
+ public static SCProfileInstance readBuildOutputFile(final IProject project,
+ final InfoContext context,
+ final IScannerConfigBuilderInfo2 buildInfo,
+ final IProgressMonitor monitor) {
final RC rc = new RC(false);
// get the collector
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, buildInfo.getSelectedProfileId());
+ getSCProfileInstance(project, context, buildInfo.getSelectedProfileId());
final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
final IExternalScannerInfoProvider esiProvider = profileInstance.
createBuildOutputProvider();
@@ -158,14 +182,31 @@ public class SCJobsUtil {
public void handleException(Throwable exception) {
rc.set(false);
- MakeCorePlugin.log(exception);
+ ManagedBuilderCorePlugin.log(exception);
}
};
Platform.run(runnable);
}
- return rc.get();
+ if(rc.get())
+ return profileInstance;
+ return null;
+
+ }
+
+ /**
+ * @param project
+ * @param buildInfo
+ * @param monitor
+ * @return
+ */
+ /*uncomment
+ public static boolean readBuildOutputFile(final IProject project,
+ final IScannerConfigBuilderInfo2 buildInfo,
+ final IProgressMonitor monitor) {
+ return readBuildOutputFile(project, null, buildInfo, monitor);
}
+ */
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java
index ecc6439f43b..ecc6439f43b 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java
index 281de5f4dac..7536e0bea40 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java
@@ -19,8 +19,8 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCMarkerGenerator;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.cdt.utils.CygPath;
import org.eclipse.cdt.utils.ICygwinToolsFactroy;
import org.eclipse.core.resources.IProject;
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java
index 26f45e381cf..26f45e381cf 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java
index 4df20b5d79e..4df20b5d79e 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java
index 74eef6af315..74eef6af315 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java
index 376efa68ef3..376efa68ef3 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
index 0066722a245..0066722a245 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java
index 0d04dc0c86b..5307335a72f 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java
@@ -15,7 +15,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
/**
* Tracebility related utility functions
@@ -28,7 +28,7 @@ public class TraceUtil {
private static LogWriter logger = null;
static {
- logger = new LogWriter(MakeCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$
+ logger = new LogWriter(ManagedBuilderCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see java.lang.Object#finalize()
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
index 5fec278faa1..601f57fd98a 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
@@ -15,26 +15,32 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.IMarkerGenerator;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.MakeBuilder;
-import org.eclipse.cdt.make.core.MakeBuilderUtil;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
-import org.eclipse.cdt.make.internal.core.StreamMonitor;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
+import org.eclipse.cdt.newmake.internal.core.StreamMonitor;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -48,7 +54,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
*/
public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
private static final String EXTERNAL_SI_PROVIDER_ERROR = "ExternalScannerInfoProvider.Provider_Error"; //$NON-NLS-1$
- private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
+ private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
private static final String LANG_ENV_VAR = "LANG"; //$NON-NLS-1$
protected IResource resource;
@@ -62,18 +68,14 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
private SCMarkerGenerator markerGenerator = new SCMarkerGenerator();
- public boolean invokeProvider(IProgressMonitor monitor, IResource resource,
- String providerId, IScannerConfigBuilderInfo2 buildInfo,
- IScannerInfoCollector collector) {
- return invokeProvider(monitor, resource, providerId, buildInfo, collector, null);
- }
-
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider#invokeProvider(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.resources.IResource, java.lang.String, org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2)
+ */
public boolean invokeProvider(IProgressMonitor monitor,
IResource resource,
String providerId,
IScannerConfigBuilderInfo2 buildInfo,
- IScannerInfoCollector collector,
- Properties env) {
+ IScannerInfoCollector collector) {
// initialize fields
this.resource = resource;
this.providerId = providerId;
@@ -119,7 +121,7 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream());
OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream());
TraceUtil.outputTrace("Default provider is executing command:", fCompileCommand.toString() + ca, ""); //$NON-NLS-1$ //$NON-NLS-2$
- Process p = launcher.execute(fCompileCommand, compileArguments, setEnvironment(launcher, env), fWorkingDirectory);
+ Process p = launcher.execute(fCompileCommand, compileArguments, setEnvironment(launcher), fWorkingDirectory);
if (p != null) {
try {
// Close the input of the Process explicitely.
@@ -157,7 +159,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
}
-
/**
* Initialization of protected fields.
* Subclasses are most likely to override default implementation.
@@ -168,8 +169,35 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
protected boolean initialize() {
IProject currProject = resource.getProject();
+ IConfiguration cfg = null;
+ IBuilder builder = null;
+ if(collector instanceof IScannerInfoCollector3){
+ InfoContext context = ((IScannerInfoCollector3)collector).getContext();
+ if(context != null)
+ cfg = context.getConfiguration();
+ }
+
+ if(cfg == null){
+ cfg = ScannerConfigUtil.getActiveConfiguration(currProject);
+ }
+
+ if(cfg != null){
+ builder = cfg.getBuilder();
+ }
+
//fWorkingDirectory = resource.getProject().getLocation();
- fWorkingDirectory = MakeBuilderUtil.getBuildDirectory(currProject, MakeBuilder.BUILDER_ID);
+ if(builder != null){
+ IPath fullPath = ManagedBuildManager.getBuildFullPath(cfg, builder);
+ if(fullPath != null){
+ IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
+ if(rc != null && rc.getType() != IResource.FILE){
+ fWorkingDirectory = rc.getLocation();
+ }
+ }
+ }
+ if(fWorkingDirectory == null)
+ fWorkingDirectory = currProject.getLocation();
+
fCompileCommand = new Path(buildInfo.getProviderRunCommand(providerId));
fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(buildInfo.getProviderRunArguments(providerId), "\"");//$NON-NLS-1$
return (fCompileCommand != null);
@@ -206,29 +234,53 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
* @param launcher
* @return
*/
- protected String[] setEnvironment(CommandLauncher launcher, Properties initialEnv) {
+ protected String[] setEnvironment(CommandLauncher launcher) {
// Set the environmennt, some scripts may need the CWD var to be set.
- Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment();
- props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
- props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
- // On POSIX (Linux, UNIX) systems reset LANG variable to English with UTF-8 encoding
- // since GNU compilers can handle only UTF-8 characters. English language is chosen
- // beacuse GNU compilers inconsistently handle different locales when generating
- // output of the 'gcc -v' command. Include paths with locale characters will be
- // handled properly regardless of the language as long as the encoding is set to UTF-8.
- if (props.containsKey(LANG_ENV_VAR)) {
- props.put(LANG_ENV_VAR, "en_US.UTF-8"); //$NON-NLS-1$
- }
- String[] env = null;
- ArrayList envList = new ArrayList();
- Enumeration names = props.propertyNames();
- if (names != null) {
- while (names.hasMoreElements()) {
- String key = (String) names.nextElement();
- envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
- }
- env = (String[]) envList.toArray(new String[envList.size()]);
- }
+ IConfiguration cfg = null;
+ if(collector instanceof IScannerInfoCollector3){
+ InfoContext context = ((IScannerInfoCollector3)collector).getContext();
+ if(context != null){
+ cfg = context.getConfiguration();
+ }
+ }
+ String[] env = null;
+ if(cfg != null){
+ IEnvironmentVariable[] vars = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg, true);
+ List list = new ArrayList(vars.length);
+ for(int i = 0; i < vars.length; i++){
+ String var = vars[i].getName();
+ if(var != null && (var = var.trim()).length() != 0){
+ String val = vars[i].getValue();
+ if(val != null && (val = val.trim()).length() != 0){
+ var = var + "=" + val; //$NON-NLS-1$
+ }
+ list.add(var);
+ }
+ }
+ env = (String[])list.toArray(new String[list.size()]);
+ } else {
+ Properties props = launcher.getEnvironment();
+ props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
+ props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
+ // On POSIX (Linux, UNIX) systems reset LANG variable to English with UTF-8 encoding
+ // since GNU compilers can handle only UTF-8 characters. English language is chosen
+ // beacuse GNU compilers inconsistently handle different locales when generating
+ // output of the 'gcc -v' command. Include paths with locale characters will be
+ // handled properly regardless of the language as long as the encoding is set to UTF-8.
+ if (props.containsKey(LANG_ENV_VAR)) {
+ props.put(LANG_ENV_VAR, "en_US.UTF-8"); //$NON-NLS-1$
+ }
+// String[] env = null;
+ ArrayList envList = new ArrayList();
+ Enumeration names = props.propertyNames();
+ if (names != null) {
+ while (names.hasMoreElements()) {
+ String key = (String) names.nextElement();
+ envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
+ }
+ env = (String[]) envList.toArray(new String[envList.size()]);
+ }
+ }
return env;
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
index fe01f05e446..0b25b732203 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
@@ -18,18 +18,21 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
-import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.MakeBuilder;
-import org.eclipse.cdt.make.core.MakeBuilderUtil;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -42,18 +45,15 @@ import org.eclipse.core.runtime.IProgressMonitor;
* @author vhirsl
*/
public class DefaultSIFileReader implements IExternalScannerInfoProvider {
- private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
+ private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
private long fileSize = 0;
private SCMarkerGenerator markerGenerator = new SCMarkerGenerator();
- public boolean invokeProvider(IProgressMonitor monitor, IResource resource,
- String providerId, IScannerConfigBuilderInfo2 buildInfo,
- IScannerInfoCollector collector, Properties env) {
- return invokeProvider(monitor, resource, providerId, buildInfo, collector);
- }
-
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider#invokeProvider(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.resources.IResource, java.lang.String, org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2)
+ */
public boolean invokeProvider(IProgressMonitor monitor,
IResource resource,
String providerId,
@@ -76,11 +76,32 @@ public class DefaultSIFileReader implements IExternalScannerInfoProvider {
ostream = null;
}
+ IConfiguration cfg = null;
+ IBuilder builder = null;
+ InfoContext context = null;
+ if(collector instanceof IScannerInfoCollector3){
+ context = ((IScannerInfoCollector3)collector).getContext();
+ if(context != null)
+ cfg = context.getConfiguration();
+ }
+
+ if(cfg == null){
+ cfg = ScannerConfigUtil.getActiveConfiguration(project);
+ }
+
+ if(cfg != null){
+ builder = cfg.getBuilder();
+ }
+
// get build location
- IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(project, MakeBuilder.BUILDER_ID);
+ IPath buildDirectory;
+ if(builder != null)
+ buildDirectory = ManagedBuildManager.getBuildLocation(cfg, builder);
+ else
+ buildDirectory = project.getLocation();
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.
- getMakeBuilderOutputSniffer(ostream, null, project, buildDirectory, buildInfo, markerGenerator, collector);
+ getMakeBuilderOutputSniffer(ostream, null, cfg, context, buildDirectory, buildInfo, markerGenerator, collector);
if (sniffer != null) {
ostream = (sniffer == null ? null : sniffer.getOutputStream());
}
@@ -100,7 +121,7 @@ public class DefaultSIFileReader implements IExternalScannerInfoProvider {
fileSize = new File(inputFileName).length();
reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFileName)));
} catch (FileNotFoundException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
return reader;
}
@@ -127,17 +148,17 @@ public class DefaultSIFileReader implements IExternalScannerInfoProvider {
monitor.worked(bytes.length);
}
} catch (IOException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
} finally {
try {
ostream.flush();
} catch (IOException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
try {
ostream.close();
} catch (IOException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
monitor.done();
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
index 7b9a837fef2..daeb45aced6 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
@@ -14,9 +14,9 @@ import java.util.List;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -47,12 +47,12 @@ public class GCCSpecsRunSIProvider extends DefaultRunSIProvider {
// TODO Vmir - use string variable replacement
for (int i = 0; i < fCompileArguments.length; ++i) {
fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$
- MakeCorePlugin.getWorkingDirectory().toString());
+ ManagedBuilderCorePlugin.getWorkingDirectory().toString());
fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{specs_file\\}", targetFile); //$NON-NLS-1$
}
} catch (CoreException e) {
//TODO VMIR better error handling
- MakeCorePlugin.log(e.getStatus());
+ ManagedBuilderCorePlugin.log(e.getStatus());
rc = false;
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java
index eaf5730749d..d960ccafe83 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java
@@ -24,19 +24,20 @@ import java.util.SortedSet;
import java.util.TreeSet;
import java.util.Map.Entry;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -55,7 +56,7 @@ import org.w3c.dom.NodeList;
*
* @author vhirsl
*/
-public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoCollectorCleaner {
+public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoCollectorCleaner {
private static final int INCLUDE_PATH = 1;
private static final int QUOTE_INCLUDE_PATH = 2;
private static final int INCLUDE_FILE = 3;
@@ -110,6 +111,7 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
*/
public void deserialize(Element collectorElem) {
+ isInfoCollected = true;
for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child.getNodeName().equals(CC_ELEM)) {
Element cmdElem = (Element) child;
@@ -159,7 +161,7 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
}
}
- public static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$
+ public static final String COLLECTOR_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$
private static final String CC_ELEM = "compilerCommand"; //$NON-NLS-1$
private static final String ID_ATTR = "id"; //$NON-NLS-1$
private static final String FILE_TYPE_ATTR = "fileType"; //$NON-NLS-1$
@@ -168,6 +170,9 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
private static final String PATH_ATTR = "path"; //$NON-NLS-1$
IProject project;
+ InfoContext context;
+
+ private boolean isInfoCollected;
private ScannerInfoData sid; // scanner info data
private ProjectScannerInfo psi = null; // sum of all scanner info
@@ -197,17 +202,31 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
*/
public void setProject(IProject project) {
this.project = project;
-
+ this.context = ScannerConfigUtil.createContextForProject(project);
try {
// deserialize from SI store
- DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, sid);
+ DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, sid);
}
catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
+
+
+ public void setContext(InfoContext context) {
+ this.context = context;
+ this.project = context.getConfiguration().getOwner().getProject();
- /* (non-Javadoc)
+ try {
+ // deserialize from SI store
+ DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, sid);
+ }
+ catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
*/
public synchronized void contributeToScannerConfig(Object resource, Map scannerInfo) {
@@ -234,6 +253,7 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
return;
}
IFile file = (IFile) resource;
+ isInfoCollected = true;
for (Iterator i = scannerInfo.keySet().iterator(); i.hasNext(); ) {
ScannerInfoTypes type = (ScannerInfoTypes) i.next();
@@ -418,15 +438,15 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
// update scanner configuration
// MakeCorePlugin.getDefault().getDiscoveryManager().
// updateDiscoveredInfo(createPathInfoObject(), siChangedForFileList);
- IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
+ IDiscoveredPathInfo pathInfo = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context);
if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) {
pathInfo = createPathInfoObject();
}
- MakeCorePlugin.getDefault().getDiscoveryManager().
- updateDiscoveredInfo(pathInfo, new ArrayList(siChangedForFileMap.keySet()));
+ ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().
+ updateDiscoveredInfo(pathInfo, context, new ArrayList(siChangedForFileMap.keySet()));
monitor.worked(50);
} catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
// siChangedForFileList.clear();
@@ -570,6 +590,7 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
* @author vhirsl
*/
public class PerFileDiscoveredPathInfo implements IPerFileDiscoveredPathInfo {
+
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject()
*/
@@ -811,4 +832,12 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
return symbols;
}
+ public InfoContext getContext() {
+ return context;
+ }
+
+ public boolean isInfoCollected() {
+ return isInfoCollected;
+ }
+
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java
index e48194e6863..37a6cae52dc 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java
@@ -18,29 +18,28 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -58,10 +57,11 @@ import org.w3c.dom.Element;
* @since 3.0
* @author vhirsl
*/
-public class PerProjectSICollector implements IScannerInfoCollector2, IScannerInfoCollectorCleaner {
- public static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerProjectSICollector"; //$NON-NLS-1$
+public class PerProjectSICollector implements IScannerInfoCollector3, IScannerInfoCollectorCleaner {
+ public static final String COLLECTOR_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".PerProjectSICollector"; //$NON-NLS-1$
private IProject project;
+ private InfoContext context;
private Map discoveredSI;
// private List discoveredIncludes;
@@ -71,6 +71,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
private List sumDiscoveredIncludes;
private Map sumDiscoveredSymbols;
private boolean scPersisted = false;
+ private boolean isInfoCollected;
public PerProjectSICollector() {
discoveredSI = new HashMap();
@@ -87,6 +88,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
*/
public void setProject(IProject project) {
this.project = project;
+ this.context = ScannerConfigUtil.createContextForProject(project);
}
/* (non-Javadoc)
@@ -112,16 +114,18 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
return;
}
+ isInfoCollected = true;
+
if (scPersisted) {
// delete discovered scanner config
discoveredSI.clear();
// new collection cycle
scPersisted = false;
}
- try {
- if (project.hasNature(MakeProjectNature.NATURE_ID) && // limits to StandardMake projects
- (project.hasNature(CProjectNature.C_NATURE_ID) ||
- project.hasNature(CCProjectNature.CC_NATURE_ID))) {
+// try {
+// if (project.hasNature(MakeProjectNature.NATURE_ID) && // limits to StandardMake projects
+// (project.hasNature(CProjectNature.C_NATURE_ID) ||
+// project.hasNature(CCProjectNature.CC_NATURE_ID))) {
for (Iterator I = scannerInfo.keySet().iterator(); I.hasNext(); ) {
ScannerInfoTypes siType = (ScannerInfoTypes) I.next();
@@ -141,11 +145,11 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
}
}
}
- }
- }
- catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
+// }
+// }
+// catch (CoreException e) {
+// ManagedBuilderCorePlugin.log(e);
+// }
}
/**
@@ -189,7 +193,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
if (monitor == null) {
monitor = new NullProgressMonitor();
}
- IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
+ IDiscoveredPathInfo pathInfo = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context);
if (pathInfo instanceof IPerProjectDiscoveredPathInfo) {
IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) pathInfo;
@@ -203,10 +207,10 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
// update scanner configuration
List resourceDelta = new ArrayList(1);
resourceDelta.add(project);
- MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo, resourceDelta);
+ ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo, context, resourceDelta);
monitor.worked(50);
} catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
}
@@ -429,12 +433,17 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
*/
public IDiscoveredPathInfo createPathInfoObject() {
DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project);
+
try {
- DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, pathInfo);
+ DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, pathInfo);
}
catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
+
+ if(!isInfoCollected && pathInfo.isLoadded())
+ isInfoCollected = true;
+
return pathInfo;
}
@@ -446,13 +455,14 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
* @param project
* @throws CModelException
*/
+ /*uncomment
public static void calculateCompilerBuiltins(final IProject project) throws CModelException {
createDiscoveredPathContainer(project, new NullProgressMonitor());
String scdProfileId = ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID;
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(project, scdProfileId);
final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2(MakeCorePlugin.getDefault().getPluginPreferences(),
+ createScannerConfigBuildInfo2(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(),
scdProfileId, true);
final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
if (collector instanceof IScannerInfoCollectorCleaner) {
@@ -479,7 +489,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
}
};
Platform.run(runnable);
- }
+ }*/
private static void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) throws CModelException {
IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
@@ -493,7 +503,24 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
}
}
// create a new discovered scanner config store
- MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
+ ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
}
+
+ public void setContext(InfoContext context) {
+ this.context = context;
+ this.project = context.getConfiguration().getOwner().getProject();
+ }
+
+ public InfoContext getContext() {
+ return context;
+ }
+
+ protected IProject getProject(){
+ return project;
+ }
+
+ public boolean isInfoCollected() {
+ return isInfoCollected;
+ }
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java
index 0950319ae33..2a0e7204faa 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java
@@ -17,10 +17,10 @@ import java.io.PrintStream;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
/**
@@ -39,7 +39,7 @@ public class SCDMakefileGenerator extends DefaultRunSIProvider {
boolean rc = super.initialize();
if (rc) {
- fWorkingDirectory = MakeCorePlugin.getWorkingDirectory();
+ fWorkingDirectory = ManagedBuilderCorePlugin.getWorkingDirectory();
// replace string variables in compile arguments
// TODO Vmir - use string variable replacement
for (int i = 0; i < fCompileArguments.length; ++i) {
@@ -100,7 +100,7 @@ public class SCDMakefileGenerator extends DefaultRunSIProvider {
rc = true;
}
catch (FileNotFoundException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java
index 4badaee97e5..4badaee97e5 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java
index 7401c27ac08..1eb1ee5815d 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java
@@ -13,8 +13,8 @@ package org.eclipse.cdt.make.internal.core.scannerconfig2;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.Action;
@@ -22,6 +22,7 @@ import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.Bu
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoCollector;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoConsoleParser;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoProvider;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
/**
@@ -30,16 +31,24 @@ import org.eclipse.core.resources.IProject;
* @author vhirsl
*/
public class SCProfileInstance {
+ private InfoContext context;
private IProject project;
private ScannerConfigProfile profile;
private IScannerInfoCollector collector;
/**
*
*/
+ public SCProfileInstance(InfoContext context, ScannerConfigProfile profile) {
+ this.context = context;
+ this.project = context.getConfiguration().getOwner().getProject();
+ this.profile = profile;
+ }
+
public SCProfileInstance(IProject project, ScannerConfigProfile profile) {
this.project = project;
this.profile = profile;
}
+
/**
*
*/
@@ -50,15 +59,30 @@ public class SCProfileInstance {
// call collector.setProject(project) if class supports it
Class clazz = collector.getClass();
try {
- Method setProjectMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$
- setProjectMethod.invoke(collector, new Object[] {project});
- } catch (SecurityException e) {
- MakeCorePlugin.log(e);
- } catch (NoSuchMethodException e) {
+ Object[] args = null;
+ Method setMethod = null;
+ if(context != null){
+ try {
+ setMethod = clazz.getMethod("setContext", new Class[] {InfoContext.class});//$NON-NLS-1$
+ args = new Object[]{context};
+ } catch(NoSuchMethodException e) {
+ }
+ }
+
+ if(setMethod == null){
+
+ try {
+ setMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$
+ args = new Object[]{project};
+ } catch(NoSuchMethodException e) {
+ }
+ }
+ if(setMethod != null)
+ setMethod.invoke(collector, args);
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
- MakeCorePlugin.log(e.getCause());
+ ManagedBuilderCorePlugin.log(e.getCause());
}
}
// all other objects are created on request
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java
index 0e8f315e80a..1cbd8a58d4e 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java
@@ -11,26 +11,30 @@
package org.eclipse.cdt.make.internal.core.scannerconfig2;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.ICDescriptorOperation;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoProvider;
-import org.eclipse.core.resources.IProject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
/**
* New ScannerConfigInfoFactory
@@ -71,30 +75,212 @@ public class ScannerConfigInfoFactory2 {
private static final String SI_PROVIDER_RUN_ACTION_ARGUMENTS = ".run.arguments";//$NON-NLS-1$
private static final String SI_PROVIDER_OPEN_ACTION_FILE_PATH = ".open.path";//$NON-NLS-1$
private static final String SI_PROVIDER_PARSER_ENABLED = ".parser.enabled";//$NON-NLS-1$
+
+ private static class CfgInfo implements IConfigurationScannerConfigBuilderInfo {
+ private Configuration cfg;
+// private HashMap map;
+
+ CfgInfo(Configuration cfg){
+ this.cfg = (Configuration)cfg;
+// init();
+ }
+
+ public InfoContext[] getContexts() {
+ Map map = createMap();
+ return (InfoContext[])map.keySet().toArray(new InfoContext[map.size()]);
+ }
+
+ public IScannerConfigBuilderInfo2 getInfo(InfoContext context) {
+ return (IScannerConfigBuilderInfo2)createMap().get(context);
+// IScannerConfigBuilderInfo2 info = null;
+// if(!isPerRcTypeDiscovery()){
+// info = cfg.getScannerConfigInfo();
+// if(info == null){
+// info = ScannerConfigInfoFactory2.create(cfg, ManagedBuilderCorePlugin.getDefault().getPluginPreferences());
+// }
+// } else {
+// Tool tool = (Tool)context.getTool();
+// if(tool != null)
+// info = tool.getScannerConfigInfo(context.getInputType());
+//// else
+//// info = getDefaultInfo();
+// }
+// return info;
+ }
+
+ public boolean isPerRcTypeDiscovery() {
+ return cfg.isPerRcTypeDiscovery();
+ }
- private static abstract class Store implements IScannerConfigBuilderInfo2 {
+ private Map createMap(){
+ HashMap map = new HashMap();
+ boolean isPerRcType = cfg.isPerRcTypeDiscovery();
+ if(!isPerRcType){
+ IScannerConfigBuilderInfo2 info = cfg.getScannerConfigInfo();
+ if(info == null){
+ String id = cfg.getDiscoveryProfileId();
+ if(id == null)
+ id = ScannerConfigProfileManager.NULL_PROFILE_ID;
+ info = create(cfg, ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), id);
+ cfg.setScannerConfigInfo(info);
+ }
+ map.put(new InfoContext(cfg), info);
+ } else {
+ IResourceInfo[] rcInfos = cfg.getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ ITool tools[];
+ IResourceInfo rcInfo = rcInfos[i];
+ if(rcInfo instanceof IFolderInfo) {
+ tools = ((IFolderInfo)rcInfo).getFilteredTools();
+ } else {
+ tools = ((IFileInfo)rcInfo).getToolsToInvoke();
+ }
+ for(int k = 0; k < tools.length; k++){
+ Tool tool = (Tool)tools[k];
+ IInputType types[] = tool.getInputTypes();
+ if(types.length != 0){
+ for(int t = 0; t < types.length; t++){
+ IInputType type = types[t];
+ IScannerConfigBuilderInfo2 tInfo = tool.getScannerConfigInfo(type);
+ if(tInfo != null){
+ map.put(new InfoContext(rcInfo, tool, type), tInfo);
+ }
+ }
+ } else {
+ IScannerConfigBuilderInfo2 tInfo = tool.getScannerConfigInfo(null);
+ if(tInfo != null){
+ map.put(new InfoContext(rcInfo, tool, null), tInfo);
+ }
+ }
+ }
+ }
+ }
+ return map;
+ }
+
+ public Map getInfoMap() {
+ return createMap();
+ }
+
+ public void setPerRcTypeDiscovery(boolean on) {
+ cfg.setPerRcTypeDiscovery(on);
+ }
+
+ public IScannerConfigBuilderInfo2 getDefaultInfo() {
+ IScannerConfigBuilderInfo2 info = cfg.getScannerConfigInfo();
+ if(info == null){
+ Map map = createMap();
+ if(map.size() != 0){
+ info = (IScannerConfigBuilderInfo2)map.values().iterator().next();
+ } else {
+ info = ScannerConfigInfoFactory2.create(cfg, ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), cfg.getDiscoveryProfileId());
+ }
+ }
+ return info;
+ }
+
+ public IScannerConfigBuilderInfo2 applyInfo(InfoContext context,
+ IScannerConfigBuilderInfo2 base) {
+ IScannerConfigBuilderInfo2 newInfo;
+ if(base != null){
+ newInfo = create(context, base, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ setInfo(context, newInfo);
+ } else {
+ setInfo(context, null);
+ newInfo = getInfo(context);
+ }
+
+ return newInfo;
+ }
+
+ private void setInfo(InfoContext context, IScannerConfigBuilderInfo2 info) {
+ if(!isPerRcTypeDiscovery()){
+ cfg.setScannerConfigInfo(info);
+ } else {
+ Tool tool = (Tool)context.getTool();
+ if(tool != null)
+ info = tool.setScannerConfigInfo(context.getInputType(), info);
+// else
+// info = getDefaultInfo();
+ }
+ }
+
+ }
+
+ private static abstract class Store implements IScannerConfigBuilderInfo2, Cloneable {
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
protected boolean isDirty; // derived
protected boolean autoDiscoveryEnabled;
protected boolean problemReportingEnabled;
protected String selectedProfile = EMPTY_STRING;
- protected Map profileOptionsMap; // (profileId, options)
- static class ProfileOptions {
+ protected LinkedHashMap profileOptionsMap; // (profileId, options)
+ static class ProfileOptions implements Cloneable{
protected boolean buildOutputFileActionEnabled;
protected String buildOutputFilePath = EMPTY_STRING;
protected boolean buildOutputParserEnabled;
- protected Map providerOptionsMap; // {providerId, options}
- static class ProviderOptions {
+ protected LinkedHashMap providerOptionsMap; // {providerId, options}
+ static class ProviderOptions implements Cloneable{
protected String providerKind; // derived
protected boolean providerOutputParserEnabled;
protected boolean providerRunUseDefault;
protected String providerRunCommand = EMPTY_STRING;
protected String providerRunArguments = EMPTY_STRING;
protected String providerOpenFilePath = EMPTY_STRING;
+
+ public Object clone(){
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+
}
+
+ protected Object clone(){
+ try {
+ ProfileOptions clone = (ProfileOptions) super.clone();
+ clone.providerOptionsMap = (LinkedHashMap)providerOptionsMap.clone();
+ for(Iterator iter = clone.providerOptionsMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ ProviderOptions o = (ProviderOptions)entry.getValue();
+ o = (ProviderOptions)o.clone();
+ entry.setValue(o);
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
}
+ protected void copySettingsTo(Store clone){
+ clone.isDirty = isDirty;
+
+ clone.autoDiscoveryEnabled = autoDiscoveryEnabled;
+ clone.problemReportingEnabled = problemReportingEnabled;
+ clone.selectedProfile = selectedProfile;
+ clone.profileOptionsMap = (LinkedHashMap)profileOptionsMap.clone();
+ for(Iterator iter = clone.profileOptionsMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ ProfileOptions o = (ProfileOptions)entry.getValue();
+ o = (ProfileOptions)o.clone();
+ entry.setValue(o);
+ }
+ }
+
+ protected Object clone() {
+ try {
+ Store clone = (Store)super.clone();
+ copySettingsTo(clone);
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
protected Store() {
isDirty = false;
}
@@ -365,7 +551,7 @@ public class ScannerConfigInfoFactory2 {
return r;
}
- protected abstract void load();
+ protected abstract void load(ICStorageElement el, String profileId);
// public abstract void store();
/**
@@ -422,41 +608,67 @@ public class ScannerConfigInfoFactory2 {
*
* @author vhirsl
*/
- private static class BuildProperty extends Store {
- private IProject project;
+ public static class BuildProperty extends Store implements Cloneable{
+// private IProject project;
+ private InfoContext context;
+// private IResourceInfo rcInfo;
+// private ITool tool;
+// private InputType inType;
private String profileId;
- BuildProperty(IProject project, String profileId) {
+// private BuildProperty(IProject project, String profileId) {
+// super();
+// this.project = project;
+// this.profileId = profileId;
+// load();
+// }
+
+ private BuildProperty(InfoContext context, ICStorageElement el, String profileId) {
super();
- this.project = project;
- this.profileId = profileId;
- load();
+
+ this.context = context;
+
+ load(el, profileId);
+ // TODO Auto-generated constructor stub
+ }
+
+ private BuildProperty(InfoContext context, Store store){
+ super();
+
+ this.context = context;
+
+ store.copySettingsTo(this);
+ }
+
+ public boolean isDirty(){
+ return isDirty;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
*/
- protected void load() {
- ICDescriptor descriptor;
+ protected void load(ICStorageElement el, String profileId) {
+
List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds();
List loadedProfiles = new ArrayList();
- try {
- descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
- for (Node sc = descriptor.getProjectData(SCANNER_CONFIG).getFirstChild();
- sc != null; sc = sc.getNextSibling()) {
- if (sc.getNodeName().equals(SC_AUTODISCOVERY)) {
+// try {
+// descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
+ ICStorageElement children[] = el.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ ICStorageElement child = children[i];
+ if (child.getName().equals(SC_AUTODISCOVERY)) {
autoDiscoveryEnabled = Boolean.valueOf(
- ((Element)sc).getAttribute(ENABLED)).booleanValue();
- selectedProfile = (profileId == ScannerConfigProfileManager.NULL_PROFILE_ID)
- ? ((Element)sc).getAttribute(SELECTED_PROFILE_ID)
+ child.getAttribute(ENABLED)).booleanValue();
+ selectedProfile = (profileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID))
+ ? child.getAttribute(SELECTED_PROFILE_ID)
: profileId;
problemReportingEnabled = Boolean.valueOf(
- ((Element)sc).getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
+ child.getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
}
- else if (sc.getNodeName().equals(PROFILE)) {
- if (profileIds.contains(((Element)sc).getAttribute(ID))) {
- load(sc);
- loadedProfiles.add(((Element)sc).getAttribute(ID));
+ else if (child.getName().equals(PROFILE)) {
+ if (profileIds.contains(child.getAttribute(ID))) {
+ loadProfile(child);
+ loadedProfiles.add(child.getAttribute(ID));
}
}
}
@@ -473,7 +685,7 @@ public class ScannerConfigInfoFactory2 {
if (loadedProfiles.size() < profileIds.size()) {
// initialize remaining profiles with default values
for (Iterator i = profileIds.iterator(); i.hasNext(); ) {
- String profileId = (String) i.next();
+ /*String */profileId = (String) i.next();
if (!loadedProfiles.contains(profileId)) {
loadDefaults(profileId);
loadedProfiles.add(profileId);
@@ -484,9 +696,9 @@ public class ScannerConfigInfoFactory2 {
// store();
// save();
}
- } catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
+// } catch (CoreException e) {
+// ManagedBuilderCorePlugin.log(e);
+// }
}
/**
@@ -533,8 +745,8 @@ public class ScannerConfigInfoFactory2 {
private boolean migrateScannerConfigBuildInfo(String profileId) {
boolean rc = true;
try {
- IScannerConfigBuilderInfo oldInfo = MakeCorePlugin.
- createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
+ IScannerConfigBuilderInfo oldInfo = ManagedBuilderCorePlugin.
+ createScannerConfigBuildInfo(context.getConfiguration().getOwner().getProject(), ScannerConfigBuilder.BUILDER_ID);
autoDiscoveryEnabled = oldInfo.isAutoDiscoveryEnabled();
problemReportingEnabled = oldInfo.isSIProblemGenerationEnabled();
// effectively a PerProject profile
@@ -566,7 +778,7 @@ public class ScannerConfigInfoFactory2 {
save();
}
catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
rc = false;
}
return rc;
@@ -575,12 +787,12 @@ public class ScannerConfigInfoFactory2 {
/**
* @param profile
*/
- private void load(Node profile) {
+ private void loadProfile(ICStorageElement profile) {
if (profileOptionsMap == null) {
profileOptionsMap = new LinkedHashMap(1);
}
ProfileOptions po = new ProfileOptions();
- String profileId = ((Element)profile).getAttribute(ID);
+ String profileId = profile.getAttribute(ID);
profileOptionsMap.put(profileId, po);
// get the list of providers from the profile configuration
ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
@@ -589,28 +801,27 @@ public class ScannerConfigInfoFactory2 {
int providerCounter = 0;
po.providerOptionsMap = new LinkedHashMap(providerIds.size());
- for (Node child = profile.getFirstChild();
- child != null;
- child = child.getNextSibling()) {
+ ICStorageElement children[] = profile.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ ICStorageElement child = children[i];
// buildOutputProvider element
- if (BUILD_OUTPUT_PROVIDER.equals(child.getNodeName())) {
- for (Node grandchild = child.getFirstChild();
- grandchild != null;
- grandchild = grandchild.getNextSibling()) {
-
- if (OPEN_ACTION.equals(grandchild.getNodeName())) {
+ if (BUILD_OUTPUT_PROVIDER.equals(child.getName())) {
+ ICStorageElement grandChildren[] = child.getChildren();
+ for (int k = 0; k < grandChildren.length; k++) {
+ ICStorageElement grandChild = grandChildren[k];
+ if (OPEN_ACTION.equals(grandChild.getName())) {
po.buildOutputFileActionEnabled = Boolean.valueOf(
- ((Element)grandchild).getAttribute(ENABLED)).booleanValue();
- po.buildOutputFilePath = ((Element)grandchild).getAttribute(FILE_PATH);
+ grandChild.getAttribute(ENABLED)).booleanValue();
+ po.buildOutputFilePath = grandChild.getAttribute(FILE_PATH);
}
- else if (PARSER.equals(grandchild.getNodeName())) {
+ else if (PARSER.equals(grandChild.getName())) {
po.buildOutputParserEnabled = Boolean.valueOf(
- ((Element)grandchild).getAttribute(ENABLED)).booleanValue();
+ grandChild.getAttribute(ENABLED)).booleanValue();
}
}
}
- else if (SCANNER_INFO_PROVIDER.equals(child.getNodeName())) {
- String providerId = ((Element)child).getAttribute(ID);
+ else if (SCANNER_INFO_PROVIDER.equals(child.getName())) {
+ String providerId = child.getAttribute(ID);
if (providerIds.get(providerCounter).equals(providerId)) {
// new provider
ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
@@ -618,23 +829,23 @@ public class ScannerConfigInfoFactory2 {
ppo.providerKind = configuredProfile.getScannerInfoProviderElement(
providerId).getProviderKind();
- for (Node grandchild = child.getFirstChild();
- grandchild != null;
- grandchild = grandchild.getNextSibling()) {
+ ICStorageElement granChildren[] = child.getChildren();
+ for (int k = 0; k < granChildren.length; k++) {
+ ICStorageElement grandChild = granChildren[k];
// action
- if (RUN_ACTION.equals(grandchild.getNodeName())) {
+ if (RUN_ACTION.equals(grandChild.getName())) {
ppo.providerRunUseDefault = Boolean.valueOf(
- ((Element)grandchild).getAttribute(USE_DEFAULT)).booleanValue();
- ppo.providerRunCommand = ((Element)grandchild).getAttribute(COMMAND);
- ppo.providerRunArguments = ((Element)grandchild).getAttribute(ARGUMENTS);
+ grandChild.getAttribute(USE_DEFAULT)).booleanValue();
+ ppo.providerRunCommand = grandChild.getAttribute(COMMAND);
+ ppo.providerRunArguments = grandChild.getAttribute(ARGUMENTS);
}
- else if (OPEN_ACTION.equals(grandchild.getNodeName())) {
- ppo.providerOpenFilePath = ((Element)grandchild).getAttribute(FILE_PATH);
+ else if (OPEN_ACTION.equals(grandChild.getName())) {
+ ppo.providerOpenFilePath = grandChild.getAttribute(FILE_PATH);
}
// parser
- else if (PARSER.equals(grandchild.getNodeName())) {
+ else if (PARSER.equals(grandChild.getName())) {
ppo.providerOutputParserEnabled = Boolean.valueOf(
- ((Element)grandchild).getAttribute(ENABLED)).booleanValue();
+ grandChild.getAttribute(ENABLED)).booleanValue();
}
}
++providerCounter;
@@ -647,56 +858,49 @@ public class ScannerConfigInfoFactory2 {
}
}
- private boolean store() throws CoreException {
- if (isDirty) {
- ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
- Element sc = descriptor.getProjectData(SCANNER_CONFIG);
- Document doc = sc.getOwnerDocument();
+ private boolean store(ICStorageElement el) {
+// if (isDirty) {
+// ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
+// Element sc = descriptor.getProjectData(SCANNER_CONFIG);
+// Document doc = sc.getOwnerDocument();
// Clear out all current children
- Node child = sc.getFirstChild();
- while (child != null) {
- sc.removeChild(child);
- child = sc.getFirstChild();
- }
+// Node child = sc.getFirstChild();
+// while (child != null) {
+// sc.removeChild(child);
+// child = sc.getFirstChild();
+// }
- Element autod = doc.createElement(SC_AUTODISCOVERY);
- sc.appendChild(autod);
+ ICStorageElement autod = el.createChild(SC_AUTODISCOVERY);
autod.setAttribute(ENABLED, Boolean.toString(autoDiscoveryEnabled));
autod.setAttribute(SELECTED_PROFILE_ID, selectedProfile);
autod.setAttribute(PROBLEM_REPORTING_ENABLED, Boolean.toString(problemReportingEnabled));
for (Iterator i = profileOptionsMap.keySet().iterator(); i.hasNext();) {
String profileId = (String) i.next();
- Element profile = doc.createElement(PROFILE);
+ ICStorageElement profile = el.createChild(PROFILE);
profile.setAttribute(ID, profileId);
store(profile, (ProfileOptions) profileOptionsMap.get(profileId));
- sc.appendChild(profile);
}
isDirty = false;
return true;
- }
- return false;
+// }
+// return false;
}
/**
* @param profile element
* @param profile options
*/
- private void store(Element profile, ProfileOptions po) {
- Element child, grandchild;
- Document doc = profile.getOwnerDocument();
- // buildOutputProvider element
- child = doc.createElement(BUILD_OUTPUT_PROVIDER);
- grandchild = doc.createElement(OPEN_ACTION);
+ private void store(ICStorageElement el, ProfileOptions po) {
+ ICStorageElement child, grandchild;
+ child = el.createChild(BUILD_OUTPUT_PROVIDER);
+ grandchild = child.createChild(OPEN_ACTION);
grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputFileActionEnabled));
grandchild.setAttribute(FILE_PATH, po.buildOutputFilePath);
- child.appendChild(grandchild);
- grandchild = doc.createElement(PARSER);
+ grandchild = child.createChild(PARSER);
grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputParserEnabled));
- child.appendChild(grandchild);
- profile.appendChild(child);
// scannerInfoProvider elements
// get the list of providers from the profile configuration
// ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
@@ -708,7 +912,7 @@ public class ScannerConfigInfoFactory2 {
ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
if (ppo != null) {
- child = doc.createElement(SCANNER_INFO_PROVIDER);
+ child = el.createChild(SCANNER_INFO_PROVIDER);
child.setAttribute(ID, providerId);
// action
@@ -717,21 +921,18 @@ public class ScannerConfigInfoFactory2 {
String providerKind = ppo.providerKind;
if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
- grandchild = doc.createElement(RUN_ACTION);
+ grandchild = child.createChild(RUN_ACTION);
grandchild.setAttribute(USE_DEFAULT, Boolean.toString(ppo.providerRunUseDefault));
grandchild.setAttribute(COMMAND, ppo.providerRunCommand);
grandchild.setAttribute(ARGUMENTS, ppo.providerRunArguments);
}
else if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
- grandchild = doc.createElement(OPEN_ACTION);
+ grandchild = child.createChild(OPEN_ACTION);
grandchild.setAttribute(FILE_PATH, ppo.providerOpenFilePath);
}
- child.appendChild(grandchild);
// parser
- grandchild = doc.createElement(PARSER);
+ grandchild = child.createChild(PARSER);
grandchild.setAttribute(ENABLED, Boolean.toString(ppo.providerOutputParserEnabled));
- child.appendChild(grandchild);
- profile.appendChild(child);
}
else {
// missing provider options - error
@@ -743,20 +944,26 @@ public class ScannerConfigInfoFactory2 {
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#save()
*/
- public synchronized void save() throws CoreException {
- if (store()) {
- ICDescriptorOperation op = new ICDescriptorOperation() {
-
- public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
- descriptor.saveProjectData();
- }
-
- };
- CCorePlugin.getDefault().getCDescriptorManager().
- runDescriptorOperation(project, op, null);
- }
+ public void save() throws CoreException {
+ Tool tool = (Tool)context.getTool();
+ if(tool != null){
+ tool.setScannerConfigInfo(context.getInputType(), this);
+ } else {
+ Configuration cfg = (Configuration)context.getConfiguration();
+ cfg.setScannerConfigInfo(this);
+ }
+// if (store()) {
+// ICDescriptorOperation op = new ICDescriptorOperation() {
+//
+// public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
+// descriptor.saveProjectData();
+// }
+//
+// };
+// CCorePlugin.getDefault().getCDescriptorManager().
+// runDescriptorOperation(project, op, null);
+// }
}
-
}
/**
@@ -764,7 +971,7 @@ public class ScannerConfigInfoFactory2 {
*
* @author vhirsl
*/
- private static class Preference extends Store {
+ private static class Preference extends Store implements Cloneable {
private Preferences prefs;
private String profileId;
private boolean useDefaults;
@@ -779,14 +986,14 @@ public class ScannerConfigInfoFactory2 {
this.prefs = prefs;
this.profileId = profileId;
this.useDefaults = useDefaults;
- load();
+ load(null, profileId);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
*/
- protected void load() {
- autoDiscoveryEnabled = getBoolean(SCANNER_CONFIG_AUTODISCOVERY_ENABLED);
+ protected void load(ICStorageElement el, String profileId) {
+ autoDiscoveryEnabled = getBoolean(SCANNER_CONFIG_AUTODISCOVERY_ENABLED, Boolean.TRUE);
selectedProfile = (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(profileId)) ?
getString(SCANNER_CONFIG_SELECTED_PROFILE_ID) :
profileId;
@@ -798,7 +1005,7 @@ public class ScannerConfigInfoFactory2 {
List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds();
profileOptionsMap = new LinkedHashMap(profileIds.size());
for (Iterator I = profileIds.iterator(); I.hasNext(); ) {
- String profileId = (String) I.next();
+ /*String */profileId = (String) I.next();
ProfileOptions po = new ProfileOptions();
profileOptionsMap.put(profileId, po);
@@ -889,8 +1096,15 @@ public class ScannerConfigInfoFactory2 {
isDirty = false;
}
}
-
+
private boolean getBoolean(String name) {
+ return getBoolean(name, null);
+ }
+
+ private boolean getBoolean(String name, Boolean defaultValue) {
+ if(defaultValue != null && !prefs.contains(name)){
+ return defaultValue.booleanValue();
+ }
if (useDefaults) {
return prefs.getDefaultBoolean(name);
}
@@ -929,11 +1143,65 @@ public class ScannerConfigInfoFactory2 {
}
- public static IScannerConfigBuilderInfo2 create(IProject project, String profileId) throws CoreException {
- return new ScannerConfigInfoFactory2.BuildProperty(project, profileId);
+// public static IScannerConfigBuilderInfo2 create(IProject project, String profileId) throws CoreException {
+// return new ScannerConfigInfoFactory3.BuildProperty(project, profileId);
+// }
+ public static IScannerConfigBuilderInfo2 create(IConfiguration cfg, ICStorageElement el) {
+ return new ScannerConfigInfoFactory2.BuildProperty(new InfoContext(cfg), el, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ }
+
+ public static IScannerConfigBuilderInfo2 create(IConfiguration cfg, Preferences prefs, String id) {
+ return create(new InfoContext(cfg), prefs, id, false);
+ }
+
+ public static IScannerConfigBuilderInfo2 create(InfoContext context, Preferences prefs, String profileId, boolean useDefaults) {
+ ScannerConfigInfoFactory2.Preference pref = new ScannerConfigInfoFactory2.Preference(prefs, profileId, useDefaults);
+ return new ScannerConfigInfoFactory2.BuildProperty(context, pref);
}
public static IScannerConfigBuilderInfo2 create(Preferences prefs, String profileId, boolean useDefaults) {
return new ScannerConfigInfoFactory2.Preference(prefs, profileId, useDefaults);
}
+
+ public static IScannerConfigBuilderInfo2 create(InfoContext context, ICStorageElement el, String profileId) {
+ return new ScannerConfigInfoFactory2.BuildProperty(context, el, profileId);
+ }
+
+ public static IScannerConfigBuilderInfo2 create(InfoContext context, String profileId){
+ Configuration cfg = (Configuration)context.getConfiguration();
+
+ IConfigurationScannerConfigBuilderInfo cfgInfo = create(cfg, false);
+ return cfgInfo.getInfo(context);
+// if(cfgInfo.isPerRcTypeDiscovery()){
+// Tool tool = (Tool)context.getTool();
+// if(tool != null){
+// info = tool.getScannerConfigInfo(context.getInputType());
+// } else {
+// }
+// } else {
+// info = cfg.getScannerConfigInfo();
+// }
+//
+// return info;
+ }
+
+ public static IScannerConfigBuilderInfo2 create(InfoContext context,
+ IScannerConfigBuilderInfo2 base, String profileId){
+ ScannerConfigInfoFactory2.BuildProperty prop = (ScannerConfigInfoFactory2.BuildProperty)((ScannerConfigInfoFactory2.BuildProperty)base).clone();
+ prop.context = context;
+ prop.profileId = profileId;
+
+ return prop;
+ }
+
+ public static void serialize(IScannerConfigBuilderInfo2 info, ICStorageElement el){
+ ((ScannerConfigInfoFactory2.BuildProperty)info).store(el);
+ }
+
+ public static IConfigurationScannerConfigBuilderInfo create(IConfiguration cfg, boolean newInstance){
+ Configuration c = (Configuration)cfg;
+ if(newInstance)
+ return new CfgInfo(c);
+ return c.getCfgScannerConfigInfo();
+ }
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java
index 2fb0981c4f7..6f0bdffdf4b 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java
@@ -11,12 +11,13 @@
package org.eclipse.cdt.make.internal.core.scannerconfig2;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -45,7 +46,7 @@ public class ScannerConfigProfile {
try {
return configElem.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
return null;
}
}
@@ -71,7 +72,7 @@ public class ScannerConfigProfile {
try {
return configElem.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
return null;
}
}
@@ -96,7 +97,7 @@ public class ScannerConfigProfile {
try {
return configElem.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
}
}
return null;
@@ -245,10 +246,10 @@ public class ScannerConfigProfile {
* loads the profile from the manifest file.
*/
private void load() {
- IExtensionPoint extension = Platform.getExtensionRegistry().
- getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
+// IExtensionPoint extension = Platform.getExtensionRegistry().
+// getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
+// if (extension != null) {
+ IExtension[] extensions = getExtensions();//extension.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
String rProfileId = extensions[i].getUniqueIdentifier();
if (rProfileId != null && rProfileId.equals(getId())) {
@@ -273,7 +274,27 @@ public class ScannerConfigProfile {
break;
}
}
+// }
+ }
+
+ private IExtension[] getExtensions(){
+ IExtensionPoint extension = Platform.getExtensionRegistry().
+ getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
+ List list = new ArrayList();
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ list.addAll(Arrays.asList(extensions));
}
+
+ extension = Platform.getExtensionRegistry().
+ getExtensionPoint(ScannerConfigProfileManager.OLD_SI_PROFILE_FULL_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ list.addAll(Arrays.asList(extensions));
+ }
+
+ return (IExtension[])list.toArray(new IExtension[list.size()]);
+
}
/**
* @return Returns the id.
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
index 9ed8705bea6..269b8717c67 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
@@ -11,13 +11,19 @@
package org.eclipse.cdt.make.internal.core.scannerconfig2;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -30,11 +36,23 @@ import org.eclipse.core.runtime.Preferences;
* @author vhirsl
*/
public class ScannerConfigProfileManager {
+ private static final String OLD_MAKE_CORE_PLUGIN_ID = "org.eclipse.cdt.make.core"; //$NON-NLS-1$
public static final String SI_PROFILE_SIMPLE_ID = "ScannerConfigurationDiscoveryProfile"; //$NON-NLS-1$
- public static final String PER_PROJECT_PROFILE_ID = MakeCorePlugin.getUniqueIdentifier() + ".GCCStandardMakePerProjectProfile"; //$NON-NLS-1$
+ public static final String PER_PROJECT_PROFILE_ID = OLD_MAKE_CORE_PLUGIN_ID + ".GCCStandardMakePerProjectProfile"; //$NON-NLS-1$
public static final String DEFAULT_SI_PROFILE_ID = PER_PROJECT_PROFILE_ID;
public static final String NULL_PROFILE_ID = "";//$NON-NLS-1$
+ public static final String OLD_SI_PROFILE_FULL_ID = OLD_MAKE_CORE_PLUGIN_ID + "." + SI_PROFILE_SIMPLE_ID; //$NON-NLS-1$
+ private class CachedInstance {
+ InfoContext context;
+ SCProfileInstance instance;
+
+ CachedInstance(InfoContext c, SCProfileInstance instance){
+ this.context = c;
+ this.instance = instance;
+
+ }
+ }
private Map projectProfileInstance;
private List profileIds;
@@ -53,6 +71,7 @@ public class ScannerConfigProfileManager {
return instance;
}
+ /*uncomment
private String getProfileId(IProject project) {
String profileId;
IScannerConfigBuilderInfo2 buildInfo = null;
@@ -60,7 +79,21 @@ public class ScannerConfigProfileManager {
buildInfo = createScannerConfigBuildInfo2(project);
profileId = buildInfo.getSelectedProfileId();
} catch (CoreException e) {
- MakeCorePlugin.log(e);
+ ManagedBuilderCorePlugin.log(e);
+ profileId = DEFAULT_SI_PROFILE_ID;
+ }
+ return profileId;
+ }
+ */
+
+ private String getProfileId(InfoContext context) {
+ String profileId;
+ IScannerConfigBuilderInfo2 buildInfo = null;
+ try {
+ buildInfo = createScannerConfigBuildInfo2(context);
+ profileId = buildInfo.getSelectedProfileId();
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
profileId = DEFAULT_SI_PROFILE_ID;
}
return profileId;
@@ -72,15 +105,16 @@ public class ScannerConfigProfileManager {
* @param project
* @param profile
*/
- public void addProfile(IProject project, ScannerConfigProfile profile) {
- projectProfileInstance.put(project, profile);
- }
+// public void addProfile(IProject project, ScannerConfigProfile profile) {
+// projectProfileInstance.put(project, profile);
+// }
/**
* @param project
* @param profileId - if null, get the one associated with the project
* @return Returns the scannerConfigProfile instance for a project.
*/
+ /*uncomment
public SCProfileInstance getSCProfileInstance(IProject project, String profileId) {
// if not specified read from .project file
if (profileId == NULL_PROFILE_ID) {
@@ -94,6 +128,35 @@ public class ScannerConfigProfileManager {
}
return profileInstance;
}
+ */
+
+ public SCProfileInstance getSCProfileInstance(IProject project, InfoContext context, String profileId) {
+ if(context == null)
+ context = ScannerConfigUtil.createContextForProject(project);
+ return getSCProfileInstance(context, profileId);
+ }
+
+ public SCProfileInstance getSCProfileInstance(InfoContext context, String profileId) {
+ // if not specified read from .project file
+ if (profileId == NULL_PROFILE_ID) {
+ profileId = getProfileId(context);
+ }
+ IResource owner = context.getConfiguration().getOwner();
+ IProject project = null;
+ if(owner != null)
+ owner.getProject();
+
+ // is the project's profile already loaded?
+ CachedInstance ci = (CachedInstance)projectProfileInstance.get(project);
+ SCProfileInstance profileInstance = null;
+ if (ci == null || !ci.context.equals(context) || !ci.instance.getProfile().getId().equals(profileId)) {
+ profileInstance = new SCProfileInstance(context, getSCProfileConfiguration(profileId));
+ projectProfileInstance.put(project, new CachedInstance(context, profileInstance));
+ } else {
+ profileInstance = ci.instance;
+ }
+ return profileInstance;
+ }
/**
* @param profileId
@@ -102,7 +165,7 @@ public class ScannerConfigProfileManager {
public SCProfileInstance getSCProfileInstance(String profileId) {
SCProfileInstance profileInstance = null;
if (profileId != NULL_PROFILE_ID) {
- profileInstance = new SCProfileInstance(null, getSCProfileConfiguration(profileId));
+ profileInstance = new SCProfileInstance((IProject)null, getSCProfileConfiguration(profileId));
}
return profileInstance;
}
@@ -116,21 +179,41 @@ public class ScannerConfigProfileManager {
return new ScannerConfigProfile(profileId);
}
+ private IExtension[] getExtensions(){
+ IExtensionPoint extension = Platform.getExtensionRegistry().
+ getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
+ List list = new ArrayList();
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ list.addAll(Arrays.asList(extensions));
+ }
+
+ extension = Platform.getExtensionRegistry().
+ getExtensionPoint(ScannerConfigProfileManager.OLD_SI_PROFILE_FULL_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ list.addAll(Arrays.asList(extensions));
+ }
+
+ return (IExtension[])list.toArray(new IExtension[list.size()]);
+
+ }
+
/**
* @return
*/
public List getProfileIds() {
if (profileIds == null) {
profileIds = new ArrayList();
- IExtensionPoint extension = Platform.getExtensionRegistry().
- getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
+// IExtensionPoint extension = Platform.getExtensionRegistry().
+// getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
+// if (extension != null) {
+ IExtension[] extensions = getExtensions(); //extension.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
String rProfileId = extensions[i].getUniqueIdentifier();
profileIds.add(rProfileId);
}
- }
+// }
}
return profileIds;
}
@@ -149,9 +232,11 @@ public class ScannerConfigProfileManager {
* @return
* @throws CoreException
*/
+ /*uncomment
public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project, String profileId) throws CoreException {
return ScannerConfigInfoFactory2.create(project, profileId);
}
+ */
/**
* Use stored selectedProfile
@@ -159,9 +244,19 @@ public class ScannerConfigProfileManager {
* @return
* @throws CoreException
*/
+ /*uncomment
public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project) throws CoreException {
return ScannerConfigInfoFactory2.create(project, ScannerConfigProfileManager.NULL_PROFILE_ID);
}
+ */
+
+ public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(InfoContext context) throws CoreException {
+ return ScannerConfigInfoFactory2.create(context, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ }
+
+ public static IConfigurationScannerConfigBuilderInfo getCfgScannerConfigBuildInfo(IConfiguration cfg){
+ return ScannerConfigInfoFactory2.create(cfg, false);
+ }
/**
* Set selectedProfile to profileId
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperties.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperties.java
new file mode 100644
index 00000000000..dc8e1b9ba7e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperties.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.buildproperties;
+
+import org.eclipse.core.runtime.CoreException;
+
+public interface IBuildProperties extends Cloneable {
+ IBuildProperty[] getProperties();
+
+ IBuildProperty getProperty(String id);
+
+// IBuildProperty addProperty(IBuildProperty property);
+
+ IBuildProperty setProperty(String propertyId, String propertyValue) throws CoreException;
+
+// IBuildProperty addProperty(IBuildPropertyType type, String propertyValue) throws CoreException;
+
+ IBuildProperty removeProperty(String id);
+
+ boolean containsValue(String propertyId, String valueId);
+
+// IBuildProperty removeProperty(IBuildPropertyType propertyType);
+
+ void clear();
+
+ Object clone();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperty.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperty.java
new file mode 100644
index 00000000000..a6d83e74843
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildProperty.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.buildproperties;
+
+
+public interface IBuildProperty {
+ IBuildPropertyType getPropertyType();
+
+ IBuildPropertyValue getValue();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyManager.java
new file mode 100644
index 00000000000..63d880b7563
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyManager.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.buildproperties;
+
+public interface IBuildPropertyManager {
+ IBuildPropertyType[] getPropertyTypes();
+
+ IBuildPropertyType getPropertyType(String id);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyType.java
new file mode 100644
index 00000000000..3ed28754146
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyType.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.buildproperties;
+
+
+public interface IBuildPropertyType extends IPropertyBase {
+ IBuildPropertyValue[] getSupportedValues();
+
+ IBuildPropertyValue getSupportedValue(String id);
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyValue.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyValue.java
new file mode 100644
index 00000000000..b494f189c5a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IBuildPropertyValue.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.buildproperties;
+
+public interface IBuildPropertyValue extends IPropertyBase{
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IPropertyBase.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IPropertyBase.java
new file mode 100644
index 00000000000..015552397e3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildproperties/IPropertyBase.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.buildproperties;
+
+public interface IPropertyBase {
+ String getId();
+
+ String getName();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectProperties.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectProperties.java
new file mode 100644
index 00000000000..a54eb5a04a6
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectProperties.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperties;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+
+public interface IBuildObjectProperties extends IBuildProperties, IBuildPropertiesRestriction {
+ IBuildPropertyType[] getSupportedTypes();
+
+ IBuildPropertyValue[] getSupportedValues(String typeId);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectPropertiesContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectPropertiesContainer.java
new file mode 100644
index 00000000000..b73ca6c45cb
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObjectPropertiesContainer.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+
+public interface IBuildObjectPropertiesContainer {
+ IBuildObjectProperties getBuildProperties();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPropertiesRestriction.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPropertiesRestriction.java
new file mode 100644
index 00000000000..c4ac46a1dea
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPropertiesRestriction.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+
+public interface IBuildPropertiesRestriction {
+ String[] getSupportedTypeIds();
+
+ boolean supportsType(String id);
+
+ String[] getSupportedValueIds(String typeId);
+
+ boolean supportsValue(String typeId, String valueId);
+
+ boolean requiresType(String typeId);
+
+ String[] getRequiredTypeIds();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java
index 396e95aa16b..43fa722df37 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.managedbuilder.macros.IFileContextBuildMacroValues;
import org.eclipse.cdt.managedbuilder.macros.IReservedMacroNameSupplier;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
import org.eclipse.core.runtime.IConfigurationElement;
/**
@@ -26,7 +28,7 @@ import org.eclipse.core.runtime.IConfigurationElement;
*
* @since 2.1
*/
-public interface IBuilder extends IBuildObject {
+public interface IBuilder extends IBuildObject, IMakeBuilderInfo {
public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
public static final String BUILDER_ELEMENT_NAME = "builder"; //$NON-NLS-1$
public static final String BUILDFILEGEN_ID ="buildfileGenerator"; //$NON-NLS-1$
@@ -39,8 +41,49 @@ public interface IBuilder extends IBuildObject {
public static final String IS_VARIABLE_CASE_SENSITIVE = "isVariableCaseSensitive"; //$NON-NLS-1$
public static final String RESERVED_MACRO_NAMES = "reservedMacroNames"; //$NON-NLS-1$
public static final String RESERVED_MACRO_NAME_SUPPLIER = "reservedMacroNameSupplier"; //$NON-NLS-1$
+ public static final String IS_SYSTEM = "isSystem"; //$NON-NLS-1$
+// static final String BUILD_COMMAND = "buildCommand"; //$NON-NLS-1$
+ static final String ATTRIBUTE_BUILD_PATH = "buildPath"; //$NON-NLS-1$
+ static final String ATTRIBUTE_STOP_ON_ERROR = "stopOnError"; //$NON-NLS-1$
+// static final String USE_DEFAULT_BUILD_CMD = "useDefaultBuildCmd"; //$NON-NLS-1$
+ static final String ATTRIBUTE_TARGET_AUTO = "autoBuildTarget"; //$NON-NLS-1$
+ static final String ATTRIBUTE_TARGET_INCREMENTAL = "incrementalBuildTarget"; //$NON-NLS-1$
+// static final String BUILD_TARGET_FULL = "fullBuildTarget"; //$NON-NLS-1$
+ static final String ATTRIBUTE_TARGET_CLEAN = "cleanBuildTarget"; //$NON-NLS-1$
+// static final String BUILD_FULL_ENABLED = "enableFullBuild"; //$NON-NLS-1$
+ static final String ATTRIBUTE_CLEAN_ENABLED = "enableCleanBuild"; //$NON-NLS-1$
+ static final String ATTRIBUTE_INCREMENTAL_ENABLED = "enabledIncrementalBuild"; //$NON-NLS-1$
+ static final String ATTRIBUTE_AUTO_ENABLED = "enableAutoBuild"; //$NON-NLS-1$
+// static final String BUILD_ARGUMENTS = "buildArguments"; //$NON-NLS-1$
+ static final String ATTRIBUTE_ENVIRONMENT = "environment"; //$NON-NLS-1$
+ static final String ATTRIBUTE_APPEND_ENVIRONMENT = "appendEnvironment"; //$NON-NLS-1$
+// public final static String BUILD_TARGET_INCREMENTAL = "build.target.inc"; //$NON-NLS-1$
+// public final static String BUILD_TARGET_AUTO = "build.target.auto"; //$NON-NLS-1$
+// public final static String BUILD_TARGET_CLEAN = "build.target.clean"; //$NON-NLS-1$
+// public final static String BUILD_LOCATION = "build.location"; //$NON-NLS-1$
+// public final static String BUILD_COMMAND = "build.command"; //$NON-NLS-1$
+// public final static String BUILD_ARGUMENTS = "build.arguments"; //$NON-NLS-1$
+
+ static final String ATTRIBUTE_MANAGED_BUILD_ON = "managedBuildOn"; //$NON-NLS-1$
+ static final String ATTRIBUTE_KEEP_ENV = "keepEnvironmentInBuildfile"; //$NON-NLS-1$
+ static final String ATTRIBUTE_SUPORTS_MANAGED_BUILD = "supportsManagedBuild"; //$NON-NLS-1$
+
+ static final String ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS = "customizedErrorParsers"; //$NON-NLS-1$
+ static final String ATTRIBUTE_CUSTOM_PROPS = "customBuilderProperties"; //$NON-NLS-1$
+
+// static final String ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS = "customizedErrorParsers"; //$NON-NLS-1$
+
+ static final String ATTRIBUTE_IGNORE_ERR_CMD = "ignoreErrCmd"; //$NON-NLS-1$
+ static final String ATTRIBUTE_STOP_ON_ERR = "stopOnErr"; //$NON-NLS-1$
+ static final String ATTRIBUTE_PARALLEL_BUILD_CMD = "parallelBuildCmd"; //$NON-NLS-1$
+ static final String ATTRIBUTE_PARALLELIZATION_NUMBER = "parallelizationNumber"; //$NON-NLS-1$
+ static final String ATTRIBUTE_PARALLEL_BUILD_ON = "parallelBuildOn"; //$NON-NLS-1$
+ static final String PARALLEL_PATTERN_NUM = "*"; //$NON-NLS-1$
+ static final String PARALLEL_PATTERN_NUM_START = "["; //$NON-NLS-1$
+ static final String PARALLEL_PATTERN_NUM_END = "]"; //$NON-NLS-1$
+ static final String OUTPUT_ENTRIES = "outputEntries"; //$NON-NLS-1$
/**
* Returns the command line arguments to pass to the build/make utility used
@@ -246,5 +289,29 @@ public interface IBuilder extends IBuildObject {
* to be used for detecting the builder/buildfile-generator reserved variables
* @return IReservedMacroNameSupplier
*/
- public IReservedMacroNameSupplier getReservedMacroNameSupplier();
+ public IReservedMacroNameSupplier getReservedMacroNameSupplier();
+
+ public CBuildData getBuildData();
+
+ public boolean isCustomBuilder();
+
+ public boolean supportsCustomizedBuild();
+
+ public boolean keepEnvironmentVariablesInBuildfile();
+
+ public void setKeepEnvironmentVariablesInBuildfile(boolean keep);
+
+ public boolean canKeepEnvironmentVariablesInBuildfile();
+
+ void setBuildPath(String path);
+
+ String getBuildPath();
+
+ boolean isInternalBuilder();
+
+ boolean matches(IBuilder builder);
+
+ boolean isSystemObject();
+
+ String getUniqueRealName();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java
index 7308ddc64b9..20181864ba4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -10,10 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
/**
* A tool-integrator defines default configurations as children of the project type.
@@ -27,7 +30,7 @@ import org.eclipse.core.resources.IResource;
*
* @since 2.1
*/
-public interface IConfiguration extends IBuildObject {
+public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesContainer {
public static final String ARTIFACT_NAME = "artifactName"; //$NON-NLS-1$
public static final String CLEAN_COMMAND = "cleanCommand"; //$NON-NLS-1$
public static final String PREBUILD_STEP = "prebuildStep"; //$NON-NLS-1$
@@ -41,6 +44,11 @@ public interface IConfiguration extends IBuildObject {
public static final String PARENT = "parent"; //$NON-NLS-1$
public static final String DESCRIPTION = "description"; //$NON-NLS-1$
+
+ public static final String BUILD_PROPERTIES = "buildProperties"; //$NON-NLS-1$
+ public static final String IS_SYSTEM = "isSystem"; //$NON-NLS-1$
+
+
@@ -323,7 +331,9 @@ public interface IConfiguration extends IBuildObject {
*
* @param option
*/
- public void removeResourceConfiguration(IResourceConfiguration resConfig);
+ public void removeResourceConfiguration(IResourceInfo resConfig);
+
+ public void removeResourceInfo(IPath path);
/**
* Set (override) the extension that should be appended to the build artifact
@@ -405,6 +415,8 @@ public interface IConfiguration extends IBuildObject {
*/
public void setErrorParserIds(String ids);
+ public void setErrorParserList(String ids[]);
+
/**
* Sets the name of the receiver to the value specified in the argument
*
@@ -547,4 +559,65 @@ public interface IConfiguration extends IBuildObject {
* @since 3.1
*/
public ITool getToolFromInputExtension(String sourceExtension);
+
+ IResourceInfo getResourceInfo(IPath path, boolean exactPath);
+
+ IResourceInfo[] getResourceInfos();
+
+ IResourceInfo getResourceInfoById(String id);
+
+ IFolderInfo getRootFolderInfo();
+
+ IFileInfo createFileInfo(IPath path);
+
+ IFileInfo createFileInfo(IPath path, String id, String name);
+
+ IFileInfo createFileInfo(IPath path, IFolderInfo base, ITool baseTool, String id, String name);
+
+ IFileInfo createFileInfo(IPath path, IFileInfo base, String id, String name);
+
+ IFolderInfo createFolderInfo(IPath path);
+
+ IFolderInfo createFolderInfo(IPath path, String id, String name);
+
+ IFolderInfo createFolderInfo(IPath path, IFolderInfo base, String id, String name);
+
+ CConfigurationData getConfigurationData();
+
+ IPath[] getSourcePaths();
+
+ void setSourcePaths(IPath[] paths);
+
+ CBuildData getBuildData();
+
+ IBuilder getBuilder();
+
+ IBuilder getEditableBuilder();
+
+ String getOutputPrefix(String outputExtension);
+
+ boolean isSystemObject();
+
+ String getOutputExtension(String resourceExtension);
+
+ String getOutputFlag(String outputExt);
+
+ IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation );
+
+ String[] getUserObjects(String extension);
+
+ String[] getLibs(String extension);
+
+ boolean buildsFileType(String srcExt);
+
+ boolean supportsBuild(boolean managed);
+
+ boolean isManagedBuildOn();
+
+ void setManagedBuildOn(boolean on) throws BuildException;
+
+ boolean isBuilderCompatible(IBuilder builder);
+
+ void changeBuilder(IBuilder newBuilder, String id, String name);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFileInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFileInfo.java
new file mode 100644
index 00000000000..46be4b85b32
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFileInfo.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+
+public interface IFileInfo extends IResourceConfiguration {
+ public static final String FILE_INFO_ELEMENT_NAME = "fileInfo";
+
+ CFileData getFileData();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFolderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFolderInfo.java
new file mode 100644
index 00000000000..3401e7a4835
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IFolderInfo.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+
+public interface IFolderInfo extends IResourceInfo {
+ public final static String FOLDER_INFO_ELEMENT_NAME = "folderInfo";
+
+ ITool[] getFilteredTools();
+
+ IToolChain getToolChain();
+
+ ITool getTool(String id);
+
+ ITool[] getToolsBySuperClassId(String id);
+
+ CFolderData getFolderData();
+
+ /**
+ * Returns a <code>ITool</code> for the tool associated with the
+ * output extension.
+ *
+ * @param extension the file extension of the output file
+ * @return ITool
+ *
+ * @since 3.1
+ */
+ ITool getToolFromOutputExtension(String extension);
+
+ /**
+ * Returns a <code>ITool</code> for the tool associated with the
+ * input extension.
+ *
+ * @param extension the file extension of the input file
+ * @return ITool
+ *
+ * @since 3.1
+ */
+ ITool getToolFromInputExtension(String sourceExtension);
+
+ boolean buildsFileType(String srcExt);
+
+ IModificationStatus getToolChainModificationStatus(ITool[] removed, ITool[] added);
+
+ void modifyToolChain(ITool[] removed, ITool[] added) throws BuildException;
+
+ IToolChain changeToolChain(IToolChain newSuperClass, String Id, String name) throws BuildException;
+
+ boolean isToolChainCompatible(IToolChain tCh);
+
+ String getOutputExtension(String resourceExtension);
+
+ boolean isHeaderFile(String ext);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
index 1118055fe61..9e0243d791c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -24,7 +24,9 @@ import org.eclipse.core.runtime.content.IContentType;
public interface IInputType extends IBuildObject {
public static final String INPUT_TYPE_ELEMENT_NAME = "inputType"; //$NON-NLS-1$
public static final String SOURCE_CONTENT_TYPE = "sourceContentType"; //$NON-NLS-1$
+ public static final String HEADER_CONTENT_TYPE = "headerContentType"; //$NON-NLS-1$
public static final String SOURCES = "sources"; //$NON-NLS-1$
+ public static final String HEADERS = "headers"; //$NON-NLS-1$
public static final String DEPENDENCY_CONTENT_TYPE = "dependencyContentType"; //$NON-NLS-1$
public static final String DEPENDENCY_EXTENSIONS = "dependencyExtensions"; //$NON-NLS-1$
public static final String OPTION = "option"; //$NON-NLS-1$
@@ -32,6 +34,15 @@ public interface IInputType extends IBuildObject {
public static final String MULTIPLE_OF_TYPE = "multipleOfType"; //$NON-NLS-1$
public static final String PRIMARY_INPUT = "primaryInput"; //$NON-NLS-1$
public static final String BUILD_VARIABLE = "buildVariable"; //$NON-NLS-1$
+ public static final String LANGUAGE_ID = "languageId"; //$NON-NLS-1$
+ public static final String LANGUAGE_NAME = "languageName"; //$NON-NLS-1$
+ public static final String LANGUAGE_INFO_CALCULATOR = "languageInfoCalculator"; //$NON-NLS-1$
+
+ // The attribute name for the scanner info collector
+ public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$
+ public static final String DISCOVERY_INFO = "discoveryInfo"; //$NON-NLS-1$
+
+
/**
* Creates an inputOrder child for this InputType.
@@ -147,7 +158,28 @@ public interface IInputType extends IBuildObject {
* @return IContentType
*/
public IContentType getSourceContentType();
+
+ public IContentType[] getSourceContentTypes();
+
+ public IContentType[] getHeaderContentTypes();
+ public String[] getSourceContentTypeIds();
+
+ public String[] getHeaderContentTypeIds();
+
+ public String[] getHeaderExtensions(ITool tool);
+
+ public String[] getHeaderExtensionsAttribute();
+
+ public void setSourceContentTypeIds(String[] ids);
+
+ public void setHeaderContentTypeIds(String[] ids);
+
+ public void setSourceExtensionsAttribute(String[] extensions);
+
+ public void setHeaderExtensionsAttribute(String[] extensions);
+
+
/**
* Sets the Eclipse <code>IContentType</code> that describes this
* input type.
@@ -388,4 +420,14 @@ public interface IInputType extends IBuildObject {
*/
public void setDirty(boolean isDirty);
+ String getLanguageId(ITool tool);
+
+ String getLanguageName(ITool tool);
+
+ String getDiscoveryProfileId(ITool tool);
+
+ void setLanguageIdAttribute(String id);
+
+ void setLanguageNameAttribute(String name);
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ILanguageInfoCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ILanguageInfoCalculator.java
new file mode 100644
index 00000000000..af2edce6f52
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ILanguageInfoCalculator.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+public interface ILanguageInfoCalculator {
+ String getLanguageName(IResourceInfo rcInfo, ITool tool, IInputType type);
+
+ String getLanguageId(IResourceInfo rcInfo, ITool tool, IInputType type);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java
index b18bd0e858a..0c1ff5912f8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -38,9 +38,11 @@ import org.w3c.dom.Element;
*
* @since 2.1
*/
-public interface IManagedProject extends IBuildObject {
+public interface IManagedProject extends IBuildObject, IBuildObjectPropertiesContainer {
public static final String MANAGED_PROJECT_ELEMENT_NAME = "project"; //$NON-NLS-1$
public static final String PROJECTTYPE = "projectType"; //$NON-NLS-1$
+ public static final String BUILD_PROPERTIES = "buildProperties"; //$NON-NLS-1$
+
/**
* Creates a configuration for this project populated with the tools
@@ -151,7 +153,7 @@ public interface IManagedProject extends IBuildObject {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element);
+// public void serialize(Document doc, Element element);
/**
* Returns the default build artifact name for the project
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IModificationStatus.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IModificationStatus.java
new file mode 100644
index 00000000000..684104882b5
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IModificationStatus.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+
+public interface IModificationStatus extends IStatus {
+ /**
+ * flags should be obtained via {@link IStatus#getCode()}
+ */
+
+
+ public static final int TOOLS_CONFLICT = 1;
+ public static final int PROPS_NOT_SUPPORTED = 1 << 1;
+ public static final int REQUIRED_PROPS_NOT_SUPPORTED = 1 << 2;
+
+ /**
+ * some properties used in the toolChain are not defined in the System
+ */
+ public static final int PROPS_NOT_DEFINED = 1 << 3;
+
+ /**
+ * some tools do not support Managed Build Mode
+ */
+ public static final int TOOLS_DONT_SUPPORT_MANAGED_BUILD = 1 << 4;
+
+ /**
+ *
+ * @return Map containing property Id to property Value associations.
+ * If value is not null then the given value is not supported
+ * If Value is not null then the fiven property is not supported
+ */
+ Map getUnsupportedProperties();
+
+ /**
+ *
+ * @return Map containing property Id to property Value associations.
+ * If value is not null then the given value is not supported
+ * If Value is not null then the fiven property is not supported
+ */
+ Map getUnsupportedRequiredProperties();
+
+ /**
+ *
+ * @return Set containing undefined property IDs
+ */
+ Set getUndefinedProperties();
+
+ ITool[][] getToolsConflicts();
+
+ ITool[] getNonManagedBuildTools();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java
index 255483d0c6a..5e4359d658f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -25,7 +25,11 @@ public interface IOption extends IBuildObject {
public static final int PREPROCESSOR_SYMBOLS = 5;
public static final int LIBRARIES = 6;
public static final int OBJECTS = 7;
-
+ public static final int INCLUDE_FILES = 8;
+ public static final int LIBRARY_PATHS = 9;
+ public static final int LIBRARY_FILES = 10;
+ public static final int MACRO_FILES = 11;
+
// Browse type
public static final int BROWSE_NONE = 0;
public static final String NONE = "none"; //$NON-NLS-1$
@@ -61,6 +65,10 @@ public interface IOption extends IBuildObject {
public static final String TYPE_STR_LIST = "stringList"; //$NON-NLS-1$
public static final String TYPE_USER_OBJS = "userObjs"; //$NON-NLS-1$
public static final String TYPE_DEFINED_SYMBOLS = "definedSymbols"; //$NON-NLS-1$
+ public static final String TYPE_LIB_PATHS = "libPaths"; //$NON-NLS-1$
+ public static final String TYPE_LIB_FILES = "libFiles"; //$NON-NLS-1$
+ public static final String TYPE_INC_FILES = "includeFiles"; //$NON-NLS-1$
+ public static final String TYPE_SYMBOL_FILES = "symbolFiles"; //$NON-NLS-1$
public static final String VALUE = "value"; //$NON-NLS-1$
public static final String VALUE_TYPE = "valueType"; //$NON-NLS-1$
public static final String VALUE_HANDLER = "valueHandler"; //$NON-NLS-1$
@@ -426,4 +434,28 @@ public interface IOption extends IBuildObject {
* @pre Can only be used after Ids in MBS grammar have been resolved by pointers.
*/
public boolean isValid();
+
+ /**
+ * Returns the type of the option value, i.e. whether it is string, boolean,
+ * string list or enumenration. As opposed to the getValueType() method,
+ * the returned type does not specifies the "sense" of the value, e.g. whether it represents the list of includes or not.
+ *
+ * possible return values:
+ * IOption.BOOLEAN
+ * IOption.STRING
+ * IOption.ENUMERATED
+ * IOption.STRING_LIST
+ *
+ * the STRING_LIST basic value type corresponds to the following option value types:
+ * INCLUDE_PATH, PREPROCESSOR_SYMBOLS, LIBRARIES, OBJECTS, INCLUDE_FILES, LIBRARY_PATHS, LIBRARY_FILES, MACRO_FILES
+ *
+ */
+ int getBasicValueType() throws BuildException ;
+
+ /**
+ * in case the option basic value type is STRING_LIST, returns the String list value,
+ * throws BuildException otherwise
+ * @return
+ */
+ String[] getBasicStringListValue() throws BuildException;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java
index 9d2a70a2226..72270058fa2 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -59,7 +59,10 @@ public interface IOptionCategory extends IBuildObject {
*
* @since 3.1
*/
- public Object[][] getOptions(IResourceConfiguration resConfig, IHoldsOptions optHolder);
+// public Object[][] getOptions(IResourceConfiguration resConfig, IHoldsOptions optHolder);
+
+ public Object[][] getOptions(IResourceInfo resInfo, IHoldsOptions optHolder);
+
/**
* @deprecated since 3.1 - use getOption with IHoldsOptions aregument instead
*/
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java
index e52ef3a3901..c2f6a7d0f1c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -41,7 +41,7 @@ import org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier;
*
* @since 2.1
*/
-public interface IProjectType extends IBuildObject {
+public interface IProjectType extends IBuildObject, IBuildObjectPropertiesContainer {
public static final String PROJECTTYPE_ELEMENT_NAME = "projectType"; //$NON-NLS-1$
public static final String SUPERCLASS = "superClass"; //$NON-NLS-1$
public static final String IS_ABSTRACT = "isAbstract"; //$NON-NLS-1$
@@ -51,6 +51,8 @@ public interface IProjectType extends IBuildObject {
public static final String CONFIGURATION_NAME_PROVIDER = "configurationNameProvider"; //$NON-NLS-1$
public static final String PROJECT_ENVIRONMENT_SUPPLIER = "projectEnvironmentSupplier"; //$NON-NLS-1$
public static final String PROJECT_MACRO_SUPPLIER = "projectMacroSupplier"; //$NON-NLS-1$
+ public static final String BUILD_PROPERTIES = "buildProperties"; //$NON-NLS-1$
+
/**
* Creates a configuration for this project-type populated with the tools
@@ -187,4 +189,6 @@ public interface IProjectType extends IBuildObject {
*/
public boolean checkForMigrationSupport();
+
+ public String getNameAttribute();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java
index 297b4b66efe..b8b78036f2d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -22,10 +22,8 @@ import org.eclipse.core.resources.IResource;
*
* @since 2.1
*/
-public interface IResourceConfiguration extends IBuildObject {
+public interface IResourceConfiguration extends IResourceInfo {
public static final String RESOURCE_CONFIGURATION_ELEMENT_NAME = "resourceConfiguration"; //$NON-NLS-1$
- public static final String RESOURCE_PATH = "resourcePath"; //$NON-NLS-1$
- public static final String EXCLUDE = "exclude"; //$NON-NLS-1$
public static final String RCBS_APPLICABILITY = "rcbsApplicability"; //$NON-NLS-1$
public static final String TOOLS_TO_INVOKE = "toolsToInvoke"; //$NON-NLS-1$
public static final String APPLY_RCBS_TOOL_AS_OVERRIDE = "override"; //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceInfo.java
new file mode 100644
index 00000000000..c0c0440be95
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceInfo.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.core.runtime.IPath;
+
+public interface IResourceInfo extends IBuildObject {
+// public static final String PARENT_FOLDER_INFO_ID = "parentFolderInfoId";
+// public static final String BASE_TOOLCHAIN_ID = "baseToolChainId";
+// public static final String INHERIT_PARENT_INFO = "inheritParentInfo"; //$NON-NLS-1$
+ public static final String RESOURCE_PATH = "resourcePath"; //$NON-NLS-1$
+ public static final String EXCLUDE = "exclude"; //$NON-NLS-1$
+
+ IPath getPath();
+
+ void setPath(IPath path);
+
+ boolean isExcluded();
+
+ boolean isExtensionElement();
+
+ void setExclude(boolean excluded);
+
+ boolean isDirty();
+
+ boolean needsRebuild();
+
+ void setDirty(boolean dirty);
+
+ void setRebuildState(boolean rebuild);
+
+ int getKind();
+
+ IConfiguration getParent();
+
+// IFolderInfo getParentFolderInfo();
+
+// IToolChain getBaseToolChain();
+
+ CResourceData getResourceData();
+
+ boolean isValid();
+
+ CLanguageData[] getCLanguageDatas();
+
+ ITool[] getTools();
+
+// boolean isParentInfoInherited();
+
+ boolean supportsBuild(boolean managed);
+
+ /**
+ * Sets the value of a boolean option for this resource configuration.
+ *
+ * @param parent The holder/parent of the option.
+ * @param option The option to change.
+ * @param value The value to apply to the option.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
+ * @throws BuildException
+ *
+ */
+ public IOption setOption(IHoldsOptions parent, IOption option, boolean value)
+ throws BuildException;
+
+ /**
+ * Sets the value of a string option for this resource configuration.
+ *
+ * @param parent The holder/parent of the option.
+ * @param option The option that will be effected by change.
+ * @param value The value to apply to the option.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
+ * @throws BuildException
+ *
+ */
+ public IOption setOption(IHoldsOptions parent, IOption option, String value)
+ throws BuildException;
+
+ /**
+ * Sets the value of a list option for this resource configuration.
+ *
+ * @param parent The holder/parent of the option.
+ * @param option The option to change.
+ * @param value The values to apply to the option.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
+ * @throws BuildException
+ *
+ */
+ public IOption setOption(IHoldsOptions parent, IOption option, String[] value)
+ throws BuildException;
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java
index a95d1895b34..52fdcdd4eee 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+
/**
* This class defines the os/architecture combination upon which the
* outputs of a tool-chain can be deployed. The osList and archList
@@ -142,5 +144,7 @@ public interface ITargetPlatform extends IBuildObject {
* @return boolean
*/
public boolean isExtensionElement();
+
+ public CTargetPlatformData getTargetPlatformData();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
index 33590d6aba3..920b5876f4d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
@@ -43,10 +44,14 @@ public interface ITool extends IBuildObject, IHoldsOptions {
public static final String TOOL_ELEMENT_NAME = "tool"; //$NON-NLS-1$
public static final String WHITE_SPACE = " "; //$NON-NLS-1$
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ public static final String IS_SYSTEM = "isSystem"; //$NON-NLS-1$
public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
public static final String CONVERT_TO_ID = "convertToId"; //$NON-NLS-1$
public static final String OPTIONPATHCONVERTER = "optionPathConverter"; //$NON-NLS-1$
+
+ public static final String SUPPORTS_MANAGED_BUILD = "supportsManagedBuild";
+
public static final int FILTER_C = 0;
public static final int FILTER_CC = 1;
@@ -730,4 +735,34 @@ public interface ITool extends IBuildObject, IHoldsOptions {
* or null, if no conversion is required
*/
public IOptionPathConverter getOptionPathConverter() ;
+
+ CLanguageData getCLanguageData(IInputType type);
+
+ CLanguageData[] getCLanguageDatas();
+
+ IInputType getInputTypeForCLanguageData(CLanguageData data);
+
+ IResourceInfo getParentResourceInfo();
+
+/* IInputType setSourceContentTypeIds(IInputType type, String[] ids);
+
+ IInputType setHeaderContentTypeIds(IInputType type, String[] ids);
+
+ IInputType setSourceExtensionsAttribute(IInputType type, String[] extensions);
+
+ IInputType setHeaderExtensionsAttribute(IInputType type, String[] extensions);
+*/
+ IInputType getEdtableInputType(IInputType base);
+
+ boolean isEnabled();
+
+// boolean isReal();
+
+ boolean supportsBuild(boolean managed);
+
+ boolean matches(ITool tool);
+
+ boolean isSystemObject();
+
+ String getUniqueRealName();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
index 519ceafccae..f9d171d2d24 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
@@ -42,9 +43,14 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
public static final String IS_TOOL_CHAIN_SUPPORTED = "isToolChainSupported"; //$NON-NLS-1$
public static final String CONFIGURATION_ENVIRONMENT_SUPPLIER = "configurationEnvironmentSupplier"; //$NON-NLS-1$
public static final String CONFIGURATION_MACRO_SUPPLIER = "configurationMacroSupplier"; //$NON-NLS-1$
+ public static final String SUPPORTS_MANAGED_BUILD = "supportsManagedBuild";
+ public static final String IS_SYSTEM= "isSystem"; //$NON-NLS-1$
+ public static final String NON_INTERNAL_BUILDER_ID = "nonInternalBuilderId"; //$NON-NLS-1$
+ public static final String RESOURCE_TYPE_BASED_DISCOVERY = "resourceTypeBasedDiscovery"; //$NON-NLS-1$
// The attribute name for the scanner info collector
public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$
+ public static final String DISCOVERY_INFO = "discoveryInfo"; //$NON-NLS-1$
/**
* Returns the configuration that is the parent of this tool-chain.
@@ -382,4 +388,16 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
* or null, if no conversion is required
*/
public IOptionPathConverter getOptionPathConverter() ;
+
+ IFolderInfo getParentFolderInfo();
+
+ CTargetPlatformData getTargetPlatformData();
+
+ boolean supportsBuild(boolean managed);
+
+ boolean isSystemObject();
+
+ boolean matches(IToolChain tc);
+
+ String getUniqueRealName();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
index 34eb4c1c082..8a01758d848 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -19,40 +17,46 @@ import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Random;
+import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.AbstractCExtension;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyManager;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
+import org.eclipse.cdt.managedbuilder.internal.buildproperties.BuildPropertyManager;
import org.eclipse.cdt.managedbuilder.internal.core.BooleanExpressionApplicabilityCalculator;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
+import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
+import org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.IMatchKeyProvider;
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedCommandLineGenerator;
@@ -67,21 +71,28 @@ import org.eclipse.cdt.managedbuilder.internal.core.Target;
import org.eclipse.cdt.managedbuilder.internal.core.TargetPlatform;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -89,16 +100,17 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
/**
* This is the main entry point for getting at the build information
@@ -132,10 +144,24 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static final int ERROR_CATEGORY = 0;
public static final int ERROR_FILTER = 1;
+ public static final String BUILD_TYPE_PROPERTY_ID = "org.eclipse.cdt.build.core.buildType"; //$NON-NLS-1$
+ public static final String BUILD_ARTEFACT_TYPE_PROPERTY_ID = "org.eclipse.cdt.build.core.buildArtefactType"; //$NON-NLS-1$
+
+ public static final String BUILD_TYPE_PROPERTY_DEBUG = "org.eclipse.cdt.build.core.buildType.debug"; //$NON-NLS-1$
+ public static final String BUILD_TYPE_PROPERTY_RELEASE = "org.eclipse.cdt.build.core.buildType.release"; //$NON-NLS-1$
+ public static final String BUILD_ARTEFACT_TYPE_PROPERTY_EXE = "org.eclipse.cdt.build.core.buildArtefactType.exe"; //$NON-NLS-1$
+ public static final String BUILD_ARTEFACT_TYPE_PROPERTY_STATICLIB = "org.eclipse.cdt.build.core.buildArtefactType.staticLib"; //$NON-NLS-1$
+ public static final String BUILD_ARTEFACT_TYPE_PROPERTY_SHAREDLIB = "org.eclipse.cdt.build.core.buildArtefactType.sharedLib"; //$NON-NLS-1$
+
+ public static final String CFG_DATA_PROVIDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".configurationDataProvider";
+
private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
+ public static final String INTERNAL_BUILDER_ID = "org.eclipse.cdt.build.core.internal.builder"; //$NON-NLS-1$
+
// This is the version of the manifest and project files
- private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(3, 1, 0);
+ private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(4, 0, 0);
+ private static final Version version = new Version(4, 0, 0);
private static Map depCalculatorsMap;
private static boolean projectTypesLoaded = false;
private static boolean projectTypesLoading = false;
@@ -177,6 +203,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// reflects the content and structure of the extension section within the
// declaring plug-in's manifest (plugin.xml) file.
private static Map configElementMap;
+
+// private static List sortedToolChains;
+// private static Map builtTypeToToolChainListMap;
// Listeners interested in build model changes
private static Map buildModelListeners;
// Random number for derived object model elements
@@ -184,14 +213,39 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Environment Build Paths Change Listener
private static IEnvironmentBuildPathsChangeListener fEnvironmentBuildPathsChangeListener;
+ private static HashMap fSortedToolChains;
+ private static HashMap fSortedTools;
+ private static HashMap fSortedBuilders;
+
+ private static ISorter fToolChainSorter = new ISorter(){
+ public void sort() {
+ resortToolChains();
+ }
+ };
+ private static ISorter fToolSorter = new ISorter(){
+ public void sort() {
+ resortTools();
+ }
+ };
+ private static ISorter fBuilderSorter = new ISorter(){
+ public void sort() {
+ resortBuilders();
+ }
+ };
+
+ private static interface ISorter {
+ void sort();
+ }
+
+
static {
getEnvironmentVariableProvider().subscribe(
fEnvironmentBuildPathsChangeListener = new IEnvironmentBuildPathsChangeListener(){
public void buildPathsChanged(IConfiguration configuration, int buildPathType){
- if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE){
- initializePathEntries(configuration,null);
- notifyListeners(configuration,null);
- }
+// if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE){
+// initializePathEntries(configuration,null);
+// notifyListeners(configuration,null);
+// }
}
});
}
@@ -268,7 +322,15 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return (IProjectType)getExtensionProjectTypeMap().get(id);
}
+ public static Version getVersion(){
+ return version;
+ }
+
protected static Map getExtensionDepCalcMap() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
if (depCalculatorsMap == null) {
depCalculatorsMap = new HashMap();
}
@@ -281,6 +343,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @return Map
*/
public static SortedMap getExtensionProjectTypeMap() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
if (projectTypeMap == null) {
projectTypeMap = new TreeMap();
}
@@ -317,6 +383,11 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @return Map
*/
public static SortedMap getExtensionToolChainMap() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
+
if (extensionToolChainMap == null) {
extensionToolChainMap = new TreeMap();
}
@@ -329,6 +400,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @return Map
*/
public static SortedMap getExtensionToolMap() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
if (extensionToolMap == null) {
extensionToolMap = new TreeMap();
}
@@ -353,6 +428,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @return Map
*/
public static SortedMap getExtensionBuilderMap() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
if (extensionBuilderMap == null) {
extensionBuilderMap = new TreeMap();
}
@@ -776,7 +855,12 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
//build path change listener
if (config.isTemporary() ||
(option != null && option.getValueType() != IOption.INCLUDE_PATH
- && option.getValueType() != IOption.PREPROCESSOR_SYMBOLS)) {
+ && option.getValueType() != IOption.PREPROCESSOR_SYMBOLS
+ && option.getValueType() != IOption.INCLUDE_FILES
+ && option.getValueType() != IOption.LIBRARY_PATHS
+ && option.getValueType() != IOption.LIBRARY_FILES
+ && option.getValueType() != IOption.MACRO_FILES
+ )) {
return;
}
} catch (BuildException e) {return;}
@@ -799,17 +883,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
(option != null
&& option.getValueType() != IOption.INCLUDE_PATH
&& option.getValueType() != IOption.PREPROCESSOR_SYMBOLS
- && option.getValueType() != IOption.LIBRARIES
+ && option.getValueType() != IOption.INCLUDE_FILES
+ && option.getValueType() != IOption.LIBRARY_PATHS
+ && option.getValueType() != IOption.LIBRARY_FILES
+ && option.getValueType() != IOption.MACRO_FILES
))
return;
} catch (BuildException e){
return;
}
- IResource rc = config.getOwner();
- if(rc != null){
- IManagedBuildInfo info = getBuildInfo(rc);
- if(info instanceof ManagedBuildInfo && config.equals(info.getDefaultConfiguration()))
- ((ManagedBuildInfo)info).initializePathEntries();
+
+ try {
+ updateCoreSettings(config);
+ } catch (CoreException e) {
}
}
@@ -820,18 +906,23 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
initializePathEntries(cfg,option);
}
- private static void notifyListeners(IResourceConfiguration resConfig, IOption option) {
+ private static void notifyListeners(IResourceInfo resConfig, IOption option) {
// Continue if change is something that effect the scanreser
try {
if (resConfig.getParent().isTemporary() ||
(option != null && option.getValueType() != IOption.INCLUDE_PATH
- && option.getValueType() != IOption.PREPROCESSOR_SYMBOLS)) {
+ && option.getValueType() != IOption.PREPROCESSOR_SYMBOLS
+ && option.getValueType() != IOption.INCLUDE_FILES
+ && option.getValueType() != IOption.LIBRARY_PATHS
+ && option.getValueType() != IOption.LIBRARY_FILES
+ && option.getValueType() != IOption.MACRO_FILES
+ )) {
return;
}
} catch (BuildException e) {return;}
// Figure out if there is a listener for this change
- IResource resource = resConfig.getOwner();
+ IResource resource = resConfig.getParent().getOwner();
List listeners = (List) getBuildModelListeners().get(resource);
if (listeners == null) {
return;
@@ -850,8 +941,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*/
public static void setNewProjectVersion(IProject newProject) {
// Get the build info for the argument
- ManagedBuildInfo info = findBuildInfo(newProject, true);
- info.setVersion(buildInfoVersion.toString());
+// ManagedBuildInfo info = findBuildInfo(newProject, true);
+// info.setVersion(buildInfoVersion.toString());
}
/**
@@ -884,8 +975,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} else {
// Event handling Failed.
}
- initializePathEntries(config,retOpt);
- notifyListeners(config, retOpt);
+// initializePathEntries(config,retOpt);
+// notifyListeners(config, retOpt);
} catch (BuildException e) {
return null;
}
@@ -906,7 +997,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* has changed to <code>IHoldsOptions holder</code>. Client code
* assuming <code>ITool</code> as type, will continue to work unchanged.
*/
- public static IOption setOption(IResourceConfiguration resConfig, IHoldsOptions holder, IOption option, boolean value) {
+ public static IOption setOption(IResourceInfo resConfig, IHoldsOptions holder, IOption option, boolean value) {
IOption retOpt;
try {
// Request a value change and set dirty if real change results
@@ -922,7 +1013,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} else {
// Event handling Failed.
}
- initializePathEntries(resConfig,retOpt);
+ // initializePathEntries(resConfig,retOpt);
notifyListeners(resConfig, retOpt);
} catch (BuildException e) {
return null;
@@ -958,8 +1049,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} else {
// Event handling Failed.
}
- initializePathEntries(config,retOpt);
- notifyListeners(config, retOpt);
+// initializePathEntries(config,retOpt);
+// notifyListeners(config, retOpt);
} catch (BuildException e) {
return null;
}
@@ -980,7 +1071,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* has changed to <code>IHoldsOptions holder</code>. Client code
* assuming <code>ITool</code> as type, will continue to work unchanged.
*/
- public static IOption setOption(IResourceConfiguration resConfig, IHoldsOptions holder, IOption option, String value) {
+ public static IOption setOption(IResourceInfo resConfig, IHoldsOptions holder, IOption option, String value) {
IOption retOpt;
try {
retOpt = resConfig.setOption(holder, option, value);
@@ -995,7 +1086,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} else {
// Event handling Failed.
}
- initializePathEntries(resConfig,retOpt);
+ // initializePathEntries(resConfig,retOpt);
notifyListeners(resConfig, retOpt);
} catch (BuildException e) {
return null;
@@ -1031,8 +1122,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} else {
// Event handling Failed.
}
- initializePathEntries(config,retOpt);
- notifyListeners(config, retOpt);
+// initializePathEntries(config,retOpt);
+// notifyListeners(config, retOpt);
} catch (BuildException e) {
return null;
}
@@ -1053,7 +1144,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* has changed to <code>IHoldsOptions holder</code>. Client code
* assuming <code>ITool</code> as type, will continue to work unchanged.
*/
- public static IOption setOption(IResourceConfiguration resConfig, IHoldsOptions holder, IOption option, String[] value) {
+ public static IOption setOption(IResourceInfo resConfig, IHoldsOptions holder, IOption option, String[] value) {
IOption retOpt;
try {
retOpt = resConfig.setOption(holder, option, value);
@@ -1068,7 +1159,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} else {
// Event handling Failed.
}
- initializePathEntries(resConfig,retOpt);
+// initializePathEntries(resConfig,retOpt);
notifyListeners(resConfig, retOpt);
} catch (BuildException e) {
return null;
@@ -1100,6 +1191,16 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
resConfig.setToolCommand(tool, command);
}
}
+
+ public static boolean saveBuildInfo(IProject project, boolean force) {
+ try {
+ return updateBuildInfo(project, force);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ return false;
+ }
+ }
+
/**
* Saves the build information associated with a project and all resources
* in the project to the build info file.
@@ -1107,7 +1208,39 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param project
* @param force
*/
- public static boolean saveBuildInfo(IProject project, boolean force) {
+ private static boolean updateBuildInfo(IProject project, boolean force) throws CoreException {
+ IManagedBuildInfo info = getBuildInfo(project, false);
+ if(info == null)
+ return true;
+
+ ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
+ IManagedProject mProj = info.getManagedProject();
+
+ IConfiguration cfgs[] = mProj.getConfigurations();
+ ICConfigurationDescription cfgDess[] = projDes.getConfigurations();
+
+ for(int i = 0; i < cfgs.length; i++){
+ IConfiguration cfg = cfgs[i];
+// try {
+ applyConfiguration(cfg, projDes, force);
+// } catch (CoreException e) {
+// }
+ }
+
+ for(int i = 0; i < cfgDess.length; i++){
+ ICConfigurationDescription cfgDes = cfgDess[i];
+ IConfiguration cfg = mProj.getConfiguration(cfgDes.getId());
+ if(cfg == null)
+ mProj.removeConfiguration(cfgDes.getId());
+ }
+
+// try {
+ CoreModel.getDefault().setProjectDescription(project, projDes);
+// } catch (CoreException e) {
+// return false;
+// }
+ return true;
+ /*
// Create document
Exception err = null;
try {
@@ -1231,12 +1364,66 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// property page changes will be sticky, in the UI, which is nonintuitive and confusing
// Therefore, just always return success, i.e. true, from this routine
return true;
+ */
+ }
+
+ public static void updateCoreSettings(IProject project) throws CoreException {
+ updateBuildInfo(project, true);
}
+
+ public static void updateCoreSettings(IConfiguration cfg) throws CoreException{
+ IProject project = cfg.getOwner().getProject();
+ ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
+ if(projDes != null){
+ if(applyConfiguration(cfg, projDes, true)){
+ CoreModel.getDefault().setProjectDescription(project, projDes);
+ }
+ }
+ }
+
+ public static void updateCoreSettings(IProject project, IConfiguration[] cfgs) throws CoreException{
+ if(cfgs == null){
+ IManagedBuildInfo info = getBuildInfo(project);
+ if(info != null && info.isValid() && info.getManagedProject() != null)
+ cfgs = info.getManagedProject().getConfigurations();
+ }
+
+ if(cfgs == null || cfgs.length == 0)
+ return;
+
+ ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
+ boolean updated = false;
+ if(projDes != null){
+ for(int i = 0; i < cfgs.length; i++){
+ if(applyConfiguration(cfgs[i], projDes, true)){
+ updated = true;
+ }
+ }
+ if(updated)
+ CoreModel.getDefault().setProjectDescription(project, projDes);
+ }
+ }
+
+ private static boolean applyConfiguration(IConfiguration cfg, ICProjectDescription des, boolean force) throws CoreException{
+ boolean updated = false;
+ ICConfigurationDescription cfgDes = des.getConfigurationById(cfg.getId());
+ if(cfgDes == null){
+ des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
+ updated = true;
+ } else if(force || cfg.isDirty()){
+ cfgDes.setConfigurationData(CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
+ updated = true;
+ }
+
+ return updated;
+ }
+
/**
* @param resource
*/
public static void removeBuildInfo(IResource resource) {
+ /*
IManagedBuildInfo info = findBuildInfo(resource, false);
if(info != null){
IConfiguration[] configs = info.getManagedProject().getConfigurations();
@@ -1252,6 +1439,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} catch (CoreException e) {
}
}
+ */
}
/**
@@ -1278,6 +1466,22 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IManagedOptionValueHandler.EVENT_SETDEFAULT);
}
+
+ public static void resetOptionSettings(IResourceInfo rcInfo){
+ if(rcInfo instanceof IFileInfo){
+ Configuration cfg = (Configuration)rcInfo.getParent();
+ IProject project;
+ if(cfg.isExtensionElement() || cfg.isPreference())
+ project = null;
+ else
+ project = cfg.getOwner().getProject();
+
+ resetResourceConfiguration(project, (IFileInfo)rcInfo);
+ } else {
+ FolderInfo fo = (FolderInfo)rcInfo;
+ fo.resetOptionSettings();
+ }
+ }
/**
* Adds a ProjectType that is is specified in the manifest to the
* build system. It is available to any element that
@@ -1535,6 +1739,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @return
*/
public static IStatus initBuildInfoContainer(IResource resource) {
+ return Status.OK_STATUS;
+ /*
ManagedBuildInfo buildInfo = null;
// Get the build info associated with this project for this session
@@ -1553,6 +1759,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IStatus.OK,
ManagedMakeMessages.getFormattedString("ManagedBuildInfo.message.init.ok", resource.getName()), //$NON-NLS-1$
null);
+ */
}
/* (non-Javadoc)
@@ -1865,7 +2072,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// loaded from a manifest file or a dynamic element provider. It cannot
// be to an object loaded from a managed build system project file (.cdtbuild).
//
-
+
Iterator projectTypeIter = getExtensionProjectTypeMap().values().iterator();
while (projectTypeIter.hasNext()) {
try {
@@ -2071,6 +2278,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
customConfigLoader.buildDefsResolved();
}
}
+
performAdjustments();
projectTypesLoading = false;
projectTypesLoaded = true;
@@ -2095,35 +2303,44 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
private static void adjustConfig(IConfiguration cfg){
- IToolChain tc = cfg.getToolChain();
- adjustHolder(cfg, tc);
-
- ITool tools[] = cfg.getTools();
- for(int i = 0; i < tools.length; i++){
- adjustHolder(cfg, tools[i]);
+ IResourceInfo rcInfos[] = cfg.getResourceInfos();
+ for(int i = 0 ; i < rcInfos.length; i++){
+ if(rcInfos[i] instanceof IFolderInfo){
+ IFolderInfo info = (IFolderInfo)rcInfos[i];
+ IToolChain tc = info.getToolChain();
+ adjustHolder(info, tc);
+
+ ITool tools[] = tc.getTools();
+ for(int j = 0; j < tools.length; j++){
+ adjustHolder(info, tools[j]);
+ }
+ } else if (rcInfos[i] instanceof IFileInfo){
+ IFileInfo info = (IFileInfo)rcInfos[i];
+ ITool rcTools[] = info.getTools();
+ for(int j = 0; j < rcTools.length; j++){
+ adjustHolder(info, rcTools[j]);
+ }
+
+ }
}
IResourceConfiguration rcCfgs[] = cfg.getResourceConfigurations();
for(int i = 0; i <rcCfgs.length; i++){
- ITool rcTools[] = rcCfgs[i].getTools();
- for(int j = 0; j < rcTools.length; j++){
- adjustHolder(rcCfgs[i], rcTools[j]);
- }
}
}
- private static void adjustHolder(IBuildObject cfg, IHoldsOptions holder){
+ private static void adjustHolder(IResourceInfo rcInfo, IHoldsOptions holder){
IOption options[] = holder.getOptions();
for(int i = 0; i < options.length; i++){
Option option = (Option)options[i];
BooleanExpressionApplicabilityCalculator calc =
- option.getBooleanExpressionCalculator();
+ option.getBooleanExpressionCalculator(true);
if(calc != null)
- calc.performAdjustment(cfg,holder,option);
+ calc.adjustOption(rcInfo,holder,option, true);
}
}
@@ -2138,7 +2355,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} else if (element.getName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
new Configuration((ProjectType)null, element, revision);
} else if (element.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
- new ToolChain((Configuration)null, element, revision);
+ new ToolChain((IFolderInfo)null, element, revision);
} else if (element.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
new Tool((ProjectType)null, element, revision);
} else if (element.getName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
@@ -2217,17 +2434,21 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param resource The resource the build information is associated with
*/
public static ManagedBuildInfo createBuildInfo(IResource resource) {
- ManagedBuildInfo buildInfo = new ManagedBuildInfo(resource);
+ IProject proj = resource.getProject();
+ ManagedBuildInfo buildInfo = new ManagedBuildInfo(proj);
try {
- // Associate the build info with the project for the duration of the session
- resource.setSessionProperty(buildInfoProperty, buildInfo);
+ setLoaddedBuildInfo(proj, buildInfo);
} catch (CoreException e) {
- // There is no point in keeping the info around if it isn't associated with the project
buildInfo = null;
}
return buildInfo;
}
+ public static void setLoaddedBuildInfo(IProject project, IManagedBuildInfo info) throws CoreException{
+ // Associate the build info with the project for the duration of the session
+ project.setSessionProperty(buildInfoProperty, info);
+ }
+
private static IManagedConfigElementProvider createConfigProvider(
DefaultManagedConfigElement element) throws CoreException {
@@ -2247,30 +2468,42 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @return
*/
public static boolean manages(IResource resource) {
- // The managed build manager manages build information for the
- // resource IFF it it is a project and has a build file with the proper
- // root element
- IProject project = null;
- if (resource instanceof IProject){
- project = (IProject)resource;
- } else if (resource instanceof IFile) {
- project = ((IFile)resource).getProject();
- } else {
+ ICProjectDescription des = CoreModel.getDefault().getProjectDescription(resource.getProject(), false);
+ if(des == null){
return false;
}
- IFile file = project.getFile(SETTINGS_FILE_NAME);
- if (file.exists()) {
- try {
- InputStream stream = file.getContents();
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = parser.parse(stream);
- NodeList nodes = document.getElementsByTagName(ROOT_NODE_NAME);
- return (nodes.getLength() > 0);
- } catch (Exception e) {
- return false;
- }
- }
+
+ ICConfigurationDescription cfgDes = des.getActiveConfiguration();
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+ if(cfg != null)
+ return true;
return false;
+
+
+ // // The managed build manager manages build information for the
+// // resource IFF it it is a project and has a build file with the proper
+// // root element
+// IProject project = null;
+// if (resource instanceof IProject){
+// project = (IProject)resource;
+// } else if (resource instanceof IFile) {
+// project = ((IFile)resource).getProject();
+// } else {
+// return false;
+// }
+// IFile file = project.getFile(SETTINGS_FILE_NAME);
+// if (file.exists()) {
+// try {
+// InputStream stream = file.getContents();
+// DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+// Document document = parser.parse(stream);
+// NodeList nodes = document.getElementsByTagName(ROOT_NODE_NAME);
+// return (nodes.getLength() > 0);
+// } catch (Exception e) {
+// return false;
+// }
+// }
+// return false;
}
/* (non-Javadoc)
@@ -2283,25 +2516,32 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param resource
* @return
*/
- private static ManagedBuildInfo findBuildInfo(IResource resource, boolean forceLoad) {
+ private static ManagedBuildInfo findBuildInfo(IResource rc, boolean forceLoad) {
- if (resource == null) return null;
+ if (rc == null) return null;
ManagedBuildInfo buildInfo = null;
+ IProject proj = rc.getProject();
// Check if there is any build info associated with this project for this session
try {
- buildInfo = (ManagedBuildInfo)resource.getSessionProperty(buildInfoProperty);
- // Make sure that if a project has build info, that the info is not corrupted
- if (buildInfo != null) {
- buildInfo.updateOwner(resource);
- }
+ buildInfo = getLoaddedBuildInfo(proj);
} catch (CoreException e) {
return null;
}
-
- if (buildInfo == null && resource instanceof IProject)
- buildInfo = findBuildInfoSynchronized((IProject)resource, forceLoad);
+
+ if(buildInfo == null && forceLoad){
+ ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(proj, false);
+ if(projDes != null){
+ try {
+ buildInfo = getLoaddedBuildInfo(proj);
+ } catch (CoreException e) {
+ return null;
+ }
+ }
+ }
+// if (buildInfo == null && resource instanceof IProject)
+// buildInfo = findBuildInfoSynchronized((IProject)resource, forceLoad);
/*
// Nothing in session store, so see if we can load it from cdtbuild
if (buildInfo == null && resource instanceof IProject) {
@@ -2321,6 +2561,16 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*/
return buildInfo;
}
+
+ private static ManagedBuildInfo getLoaddedBuildInfo(IProject project) throws CoreException{
+ // Check if there is any build info associated with this project for this session
+ ManagedBuildInfo buildInfo = (ManagedBuildInfo)project.getSessionProperty(buildInfoProperty);
+ // Make sure that if a project has build info, that the info is not corrupted
+ if (buildInfo != null) {
+ buildInfo.updateOwner(project);
+ }
+ return buildInfo;
+ }
/* (non-Javadoc)
* Determine if build information can be found. Various attempts are made
@@ -2347,7 +2597,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Check if there is any build info associated with this project for this session
try {
- buildInfo = (ManagedBuildInfo)resource.getSessionProperty(buildInfoProperty);
+ buildInfo = (ManagedBuildInfo)getLoaddedBuildInfo(resource.getProject());
} catch (CoreException e) {
// Continue, to see if any of the upcoming checks are successful
}
@@ -2373,7 +2623,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param resource
* @return
*/
- synchronized private static ManagedBuildInfo findBuildInfoSynchronized(IProject project, boolean forceLoad) {
+/* synchronized private static ManagedBuildInfo findBuildInfoSynchronized(IProject project, boolean forceLoad) {
ManagedBuildInfo buildInfo = null;
// Check if there is any build info associated with this project for this session
@@ -2447,7 +2697,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return buildInfo;
}
-
+*/
/**
* Finds, but does not create, the managed build information for the
* argument.
@@ -2464,6 +2714,25 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return getBuildInfo(resource, true);
}
+ public static IManagedBuildInfo getBuildInfoLegacy(IProject project){
+ IManagedBuildInfo info = null;
+ try {
+ info = getLoaddedBuildInfo(project);
+ } catch (CoreException e) {
+ }
+
+ if(info == null){
+ try {
+ info = loadBuildInfo(project);
+
+ if(info != null)
+ setLoaddedBuildInfo(project, info);
+ } catch (Exception e) {
+ }
+ }
+
+ return info;
+ }
/**
* Finds, but does not create, the managed build information for the
* argument.
@@ -2855,12 +3124,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*
* @since 3.0
*/
- public static void performValueHandlerEvent(IResourceConfiguration config, int event) {
+ public static void performValueHandlerEvent(IResourceInfo config, int event) {
// Note: Resource configurations have no toolchain options
// Get options associated with the resource configuration
- ITool[] tools = config.getToolsToInvoke();
+ ITool[] tools = config instanceof IFileInfo ?
+ ((IFileInfo)config).getToolsToInvoke() :
+ ((IFolderInfo)config).getFilteredTools();
for (int i = 0; i < tools.length; ++i) {
IOption[] toolOptions = tools[i].getOptions();
for (int j = 0; j < toolOptions.length; ++j) {
@@ -3247,4 +3518,749 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
return path;
}
+
+/* private static IBuildObject getBuildObjectFromDataObject(CDataObject data){
+ if(data instanceof BuildConfigurationData)
+ return ((BuildConfigurationData)data).getConfiguration();
+ else if(data instanceof BuildFolderData)
+ return ((BuildFolderData)data).getFolderInfo();
+ else if(data instanceof BuildFileData)
+ return ((BuildFileData)data).getFileInfo();
+ return null;
+ }
+*/
+ public static IConfiguration getConfigurationForDescription(ICConfigurationDescription cfgDes){
+ if(cfgDes == null)
+ return null;
+ CConfigurationData cfgData = cfgDes.getConfigurationData();
+ if(cfgData instanceof BuildConfigurationData)
+ return ((BuildConfigurationData)cfgData).getConfiguration();
+ return null;
+ }
+
+ public static int optionTypeToEntryKind(int type){
+ switch(type){
+ case IOption.INCLUDE_PATH:
+ return ICLanguageSettingEntry.INCLUDE_PATH;
+ case IOption.PREPROCESSOR_SYMBOLS:
+ return ICLanguageSettingEntry.MACRO;
+ case IOption.INCLUDE_FILES:
+ return ICLanguageSettingEntry.INCLUDE_FILE;
+ case IOption.LIBRARY_PATHS:
+ return ICLanguageSettingEntry.LIBRARY_PATH;
+ case IOption.LIBRARY_FILES:
+ return ICLanguageSettingEntry.LIBRARY_FILE;
+ case IOption.MACRO_FILES:
+ return ICLanguageSettingEntry.MACRO_FILE;
+// case IOption.LIBRARIES:
+// return ICLanguageSettingEntry.LIBRARY_PATH;
+ }
+ return 0;
+ }
+
+ public static int entryKindToOptionType(int kind){
+ switch(kind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ return IOption.INCLUDE_PATH;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return IOption.INCLUDE_FILES;
+ case ICLanguageSettingEntry.MACRO:
+ return IOption.PREPROCESSOR_SYMBOLS;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return IOption.MACRO_FILES;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ return IOption.LIBRARY_PATHS;//TODO IOption.LIBRARIES;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ return IOption.LIBRARY_FILES;
+ }
+ return 0;
+ }
+
+ public static ICConfigurationDescription getDescriptionForConfiguration(IConfiguration cfg){
+ ICConfigurationDescription des = ((Configuration)cfg).getConfigurationDescription();
+ if(des == null){
+ if(((Configuration)cfg).isPreference()){
+ try {
+ des = CCorePlugin.getDefault().getPreferenceConfiguration(CFG_DATA_PROVIDER_ID);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ } else {
+ IProject project = cfg.getOwner().getProject();
+ ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project, false);
+ if(projDes != null){
+ des = projDes.getConfigurationById(cfg.getId());
+ }
+ }
+ }
+ return des;
+ }
+
+ public static IPath getBuildFullPath(IConfiguration cfg, IBuilder builder){
+ IProject project = cfg.getOwner().getProject();
+// String path = builder.getBuildPath();
+
+ IPath buildDirectory = builder.getBuildLocation();
+ IPath fullPath = null;
+ if (buildDirectory != null && !buildDirectory.isEmpty()) {
+ IResource res = project.getParent().findMember(buildDirectory);
+ if (res instanceof IContainer && res.exists()) {
+ fullPath = res.getFullPath();
+ } else {
+ IContainer crs[] = ((IWorkspaceRoot)project.getParent()).findContainersForLocation(buildDirectory);
+ if(crs.length != 0){
+ String projName = project.getName();
+ for(int i = 0; i < crs.length; i++){
+ IPath path = crs[i].getFullPath();
+ if(path.segmentCount() != 0 && path.segment(0).equals(projName)){
+ fullPath = path;
+ break;
+ }
+ }
+
+ if(fullPath == null){
+ fullPath = crs[0].getFullPath();
+ }
+ }
+ }
+ } else {
+ fullPath = cfg.getOwner().getProject().getFullPath().append(cfg.getName());
+ }
+
+ return fullPath;
+ }
+
+ public static String locationToFullPath(String path){
+ if(!path.startsWith("${"))
+ return null;
+ int index = path.lastIndexOf('}');
+ if(index == -1)
+ return null;
+
+ String varName = "workspace_loc";
+ String str1 = path.substring(2, index);
+ String result = null;
+ if(str1.startsWith(varName)){
+ str1 = str1.substring(varName.length());
+ if(str1.length() != 0){
+ if(str1.startsWith(":")){
+ result = str1.substring(1);
+ }
+ } else {
+ result = "/";
+ }
+ }
+
+ return result;
+ }
+
+ public static String fullPathToLocation(String path){
+ StringBuffer buf = new StringBuffer();
+ return buf.append("${").append("workspace_loc:").append(path).append("}").toString();
+ }
+
+ public static IPath getBuildLocation(IConfiguration cfg, IBuilder builder) {
+ if(cfg.getOwner() == null)
+ return Path.EMPTY;
+
+ IProject project = cfg.getOwner().getProject();
+ IPath buildDirectory = builder.getBuildLocation();
+ if (buildDirectory != null && !buildDirectory.isEmpty()) {
+ IResource res = project.getParent().findMember(buildDirectory);
+ if (res instanceof IContainer && res.exists()) {
+ buildDirectory = res.getLocation();
+ }
+ } else {
+ buildDirectory = project.getLocation();
+ if(builder.isManagedBuildOn())
+ buildDirectory = buildDirectory.append(cfg.getName());
+ }
+ return buildDirectory;
+ }
+
+ public static IBuilder[] createBuilders(IProject project, Map args){
+ return ManagedBuilderCorePlugin.createBuilders(project, args);
+ }
+
+ public static IBuilder createCustomBuilder(IConfiguration cfg, String builderId) throws CoreException{
+ return ManagedBuilderCorePlugin.createCustomBuilder(cfg, builderId);
+ }
+
+ public static IBuilder createCustomBuilder(IConfiguration cfg, IBuilder base){
+ return ManagedBuilderCorePlugin.createCustomBuilder(cfg, base);
+ }
+
+ public static IBuilder createBuilderForEclipseBuilder(IConfiguration cfg, String eclipseBuilderID) throws CoreException {
+ return ManagedBuilderCorePlugin.createBuilderForEclipseBuilder(cfg, eclipseBuilderID);
+ }
+
+/* public static IToolChain[] getExtensionsToolChains(String propertyType, String propertyValue){
+ List all = getSortedToolChains();
+ List result = new ArrayList();
+ for(int i = 0; i < all.size(); i++){
+ List list = (List)all.get(i);
+ IToolChain tc = findToolChain(list, propertyType, propertyValue);
+ if(tc != null)
+ result.add(tc);
+ }
+ return (IToolChain[])result.toArray(new ToolChain[result.size()]);
+ }
+*/
+/* public static void resortToolChains(){
+ sortedToolChains = null;
+ getSortedToolChains();
+ }
+*/
+/* private static List getSortedToolChains(){
+ if(sortedToolChains == null){
+ sortedToolChains = new ArrayList();
+ SortedMap map = getExtensionToolChainMap();
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ ToolChain tc = (ToolChain)iter.next();
+ if(tc.isAbstract())
+ continue;
+ List list = searchIdentical(sortedToolChains, tc);
+ if(list == null){
+ list = new ArrayList();
+ sortedToolChains.add(list);
+ }
+ list.add(tc);
+ tc.setIdenticalList(list);
+ }
+ }
+ return sortedToolChains;
+ }
+*/
+// private static List findIdenticalToolChains(IToolChain tc){
+// ToolChain tCh = (ToolChain)tc;
+// List list = tCh.getIdenticalList();
+// if(list == null){
+// resortToolChains();
+// list = tCh.getIdenticalList();
+// if(list == null){
+// list = new ArrayList(0);
+// tCh.setIdenticalList(list);
+// }
+// }
+//
+// return ((ToolChain)tc).getIdenticalList();
+// }
+
+ public static IToolChain[] getExtensionToolChains(IProjectType type){
+ List result = new ArrayList();
+ IConfiguration cfgs[] = type.getConfigurations();
+
+ for(int i = 0; i < cfgs.length; i++){
+ IToolChain tc = cfgs[i].getToolChain();
+ if(tc == null)
+ continue;
+
+ List list = findIdenticalElements((ToolChain)tc, fToolChainSorter);
+ int k = 0;
+ for(; k < result.size(); k++){
+ if(findIdenticalElements((ToolChain)result.get(k), fToolChainSorter) == list)
+ break;
+ }
+
+ if(k == result.size()){
+ result.add(tc);
+ }
+ }
+ return (IToolChain[])result.toArray(new IToolChain[result.size()]);
+ }
+
+ public static IConfiguration[] getExtensionConfigurations(IToolChain tChain, IProjectType type){
+ List list = new ArrayList();
+ IConfiguration cfgs[] = type.getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ IToolChain cur = cfgs[i].getToolChain();
+ if(cur != null
+ && findIdenticalElements((ToolChain)cur, fToolChainSorter) == findIdenticalElements((ToolChain)tChain, fToolChainSorter)){
+ list.add(cfgs[i]);
+ }
+ }
+ return (IConfiguration[])list.toArray(new Configuration[list.size()]);
+ }
+
+ public static IConfiguration getFirstExtensionConfiguration(IToolChain tChain){
+ if(tChain.getParent() != null)
+ return tChain.getParent();
+
+ List list = findIdenticalElements((ToolChain)tChain, fToolChainSorter);
+ if(list != null){
+ for(int i = 0; i < list.size(); i++){
+ ToolChain cur = (ToolChain)list.get(i);
+ if(cur.getParent() != null)
+ return cur.getParent();
+ }
+ }
+
+ return null;
+ }
+
+ public static IConfiguration[] getExtensionConfigurations(IToolChain tChain, String propertyType, String propertyValue){
+// List all = getSortedToolChains();
+ List list = findIdenticalElements((ToolChain)tChain, fToolChainSorter);
+ List result = new ArrayList();
+ boolean tcFound = false;
+ if(list != null){
+ for(int i = 0; i < list.size(); i++){
+ ToolChain cur = (ToolChain)list.get(i);
+ if(cur == tChain){
+ tcFound = true;
+ }
+
+ IConfiguration cfg = cur.getParent();
+ if(cfg != null){
+ IBuildObjectProperties props = cfg.getBuildProperties();
+ if(props.containsValue(propertyType, propertyValue)){
+ result.add(cfg);
+ }
+ }
+ }
+
+ }
+
+ if(!tcFound) {
+ IConfiguration cfg = tChain.getParent();
+ if(cfg != null){
+ IBuildObjectProperties props = cfg.getBuildProperties();
+ if(props.containsValue(propertyType, propertyValue)){
+ result.add(cfg);
+ }
+ }
+ }
+
+// if(result.size() == 0){
+// if(((ToolChain)tChain).supportsValue(propertyType, propertyValue)){
+// IConfiguration cfg = getFirstExtensionConfiguration(tChain);
+// if(cfg != null){
+// result.add(cfg);
+// }
+// }
+// }
+ return (IConfiguration[])result.toArray(new IConfiguration[result.size()]);
+ }
+
+/* public static IToolChain[] getRealToolChains(){
+ List all = getSortedToolChains();
+ IToolChain tcs[] = new ToolChain[all.size()];
+ for(int i = 0; i < tcs.length; i++){
+ List list = (List)all.get(i);
+ tcs[i] = (ToolChain)list.get(0);
+ }
+ return tcs;
+ }
+*/
+
+ private static HashMap getSortedToolChains(){
+ if(fSortedToolChains == null){
+ fSortedToolChains = getSortedElements(ManagedBuildManager.getExtensionToolChainMap().values());
+ }
+ return fSortedToolChains;
+ }
+
+ private static HashMap getSortedTools(){
+ if(fSortedTools == null){
+ fSortedTools = getSortedElements(ManagedBuildManager.getExtensionToolMap().values());
+ }
+ return fSortedTools;
+ }
+
+ private static HashMap getSortedBuilders(){
+ if(fSortedBuilders == null){
+ fSortedBuilders = getSortedElements(ManagedBuildManager.getExtensionBuilderMap().values());
+ }
+ return fSortedBuilders;
+ }
+
+ private static HashMap getSortedElements(Collection elements){
+ HashMap map = new HashMap();
+ for(Iterator iter = elements.iterator(); iter.hasNext();){
+ IMatchKeyProvider p = (IMatchKeyProvider)iter.next();
+ Object key = p.getMatchKey();
+ if(key == null)
+ continue;
+
+ List list = (List)map.get(key);
+ if(list == null){
+ list = new ArrayList();
+ map.put(key, list);
+ }
+ list.add(p);
+ p.setIdenticalList(list);
+ }
+ return map;
+ }
+
+ public static IToolChain[] getRealToolChains(){
+ HashMap map = getSortedToolChains();
+ IToolChain tcs[] = new ToolChain[map.size()];
+ int i = 0;
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ List list = (List)iter.next();
+ tcs[i++] = (ToolChain)list.get(0);
+ }
+ return tcs;
+ }
+
+ public static ITool[] getRealTools(){
+ HashMap map = getSortedTools();
+ ITool ts[] = new Tool[map.size()];
+ int i = 0;
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ List list = (List)iter.next();
+ ts[i++] = (Tool)list.get(0);
+ }
+ return ts;
+ }
+
+ public static IBuilder[] getRealBuilders(){
+ HashMap map = getSortedBuilders();
+ IBuilder bs[] = new Builder[map.size()];
+ int i = 0;
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ List list = (List)iter.next();
+ bs[i++] = (Builder)list.get(0);
+ }
+ return bs;
+ }
+
+ public static IBuilder getRealBuilder(IBuilder builder){
+ IBuilder extBuilder = builder;
+ IBuilder realBuilder = null;
+ for(;extBuilder != null && !extBuilder.isExtensionElement(); extBuilder = extBuilder.getSuperClass());
+
+ if(extBuilder != null){
+ List list = findIdenticalElements((Builder)extBuilder, fBuilderSorter);
+ if(list.size() == 0){
+ realBuilder = extBuilder;
+ } else {
+ IBuilder[] realBs = getRealBuilders();
+ for(int i = 0; i < realBs.length; i++){
+ List rList = findIdenticalElements((Builder)realBs[i], fBuilderSorter);
+ if(rList == list){
+ realBuilder = realBs[i];
+ break;
+ }
+ }
+ }
+ } else {
+ //TODO:
+ }
+ return realBuilder;
+ }
+
+ public static ITool getRealTool(ITool tool){
+ ITool extTool = tool;
+ ITool realTool = null;
+ for(;extTool != null && !extTool.isExtensionElement(); extTool= extTool.getSuperClass());
+
+ if(extTool != null){
+ List list = findIdenticalElements((Tool)extTool, fToolSorter);
+ if(list.size() == 0){
+ realTool = extTool;
+ } else {
+ ITool[] realTs = getRealTools();
+ for(int i = 0; i < realTs.length; i++){
+ List rList = findIdenticalElements((Tool)realTs[i], fToolSorter);
+ if(rList == list){
+ realTool = realTs[i];
+ break;
+ }
+ }
+ }
+ } else {
+ //TODO:
+ }
+ return realTool;
+ }
+
+ public static IToolChain getRealToolChain(IToolChain tc){
+ IToolChain extTc = tc;
+ IToolChain realTc = null;
+ for(;extTc != null && !extTc.isExtensionElement(); extTc= extTc.getSuperClass());
+
+ if(extTc != null){
+ List list = findIdenticalElements((ToolChain)extTc, fToolChainSorter);
+ if(list.size() == 0){
+ realTc = extTc;
+ } else {
+ IToolChain[] realTcs = getRealToolChains();
+ for(int i = 0; i < realTcs.length; i++){
+ List rList = findIdenticalElements((ToolChain)realTcs[i], fToolChainSorter);
+ if(rList == list){
+ realTc = realTcs[i];
+ break;
+ }
+ }
+ }
+ } else {
+ //TODO:
+ }
+ return realTc;
+ }
+
+ public static IToolChain[] findIdenticalToolChains(IToolChain tc){
+ List list = findIdenticalElements((ToolChain)tc, fToolChainSorter);
+ return (ToolChain[])list.toArray(new ToolChain[list.size()]);
+ }
+
+ public static ITool[] findIdenticalTools(ITool tool){
+ List list = findIdenticalElements((Tool)tool, fToolSorter);
+ return (Tool[])list.toArray(new Tool[list.size()]);
+ }
+
+ public static IBuilder[] findIdenticalBuilders(IBuilder b){
+ List list = findIdenticalElements((Builder)b, fBuilderSorter);
+ return (Builder[])list.toArray(new Builder[list.size()]);
+ }
+
+ public static IToolChain[] getExtensionsToolChains(String propertyType, String propertyValue){
+ HashMap all = getSortedToolChains();
+ List result = new ArrayList();
+ for(Iterator iter = all.values().iterator(); iter.hasNext();){
+ List list = (List)iter.next();
+ IToolChain tc = findToolChain(list, propertyType, propertyValue);
+ if(tc != null)
+ result.add(tc);
+ }
+ return (IToolChain[])result.toArray(new ToolChain[result.size()]);
+ }
+
+ public static void resortToolChains(){
+ fSortedToolChains = null;
+ getSortedToolChains();
+ }
+
+ public static void resortTools(){
+ fSortedTools = null;
+ getSortedTools();
+ }
+
+ public static void resortBuilders(){
+ fSortedBuilders = null;
+ getSortedBuilders();
+ }
+
+ private static IToolChain findToolChain(List list, String propertyType, String propertyValue){
+ ToolChain bestMatch = null;
+ IConfiguration cfg = null;
+ IProjectType type = null;
+ for(int i = 0; i < list.size(); i++){
+ ToolChain tc = (ToolChain)list.get(i);
+ if(!tc.supportsValue(propertyType, propertyValue))
+ return null;
+
+ if(!tc.supportsBuild(true))
+ return null;
+
+ if(bestMatch == null)
+ bestMatch = tc;
+
+ IConfiguration tcCfg = tc.getParent();
+ if(tcCfg != null){
+ if(cfg == null){
+ bestMatch = tc;
+ cfg = tcCfg;
+ }
+
+ IBuildObjectProperties props =tcCfg.getBuildProperties();
+ IBuildProperty prop = props.getProperty(propertyType);
+ if(prop != null && propertyValue.equals(prop.getValue().getId())){
+ bestMatch = tc;
+ cfg = tcCfg;
+ }
+
+ IProjectType tcType = tcCfg.getProjectType();
+ if(tcType != null){
+ if(type == null){
+ type = tcType;
+ bestMatch = tc;
+ }
+ props = tcType.getBuildProperties();
+ prop = props.getProperty(propertyType);
+ if(prop != null && propertyValue.equals(prop.getValue().getId())){
+ type = tcType;
+ bestMatch = tc;
+ break;
+ }
+ }
+ }
+ }
+
+ return bestMatch;
+ }
+
+ private static List findIdenticalElements(IMatchKeyProvider p, ISorter sorter){
+ List list = p.getIdenticalList();
+ if(list == null){
+ sorter.sort();
+ list = p.getIdenticalList();
+ if(list == null){
+ list = new ArrayList(0);
+ p.setIdenticalList(list);
+ }
+ }
+
+ return list;
+ }
+
+
+
+ public static IBuildPropertyManager getBuildPropertyManager(){
+ return BuildPropertyManager.getInstance();
+ }
+
+ public static IConfiguration[] getReferencedConfigurations(IConfiguration config){
+ IConfiguration[] refConfigs = null;
+ ICConfigurationDescription cfgDes = getDescriptionForConfiguration(config);
+ if(cfgDes != null){
+ Map map = cfgDes.getReferenceInfo();
+ if(map.size() != 0){
+ List list = new ArrayList(map.size());
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ CoreModel model = CoreModel.getDefault();
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String projName = (String)entry.getKey();
+ String cfgId = (String)entry.getValue();
+ IProject project = root.getProject(projName);
+ if(!project.exists())
+ continue;
+
+ ICProjectDescription des = model.getProjectDescription(project, false);
+ if(des == null)
+ continue;
+
+ ICConfigurationDescription refCfgDes = des.getConfigurationById(cfgId);
+ if(refCfgDes == null)
+ continue;
+
+ IConfiguration refdCfg = ManagedBuildManager.getConfigurationForDescription(refCfgDes);
+ if(refdCfg == null)
+ continue;
+
+ list.add(refdCfg);
+ }
+
+ if(list.size() != 0){
+ refConfigs = (IConfiguration[])list.toArray(new Configuration[list.size()]);
+ }
+ }
+ }
+
+ if(refConfigs == null)
+ refConfigs = new Configuration[0];
+
+ return refConfigs;
+ }
+
+ public static void buildConfigurations(IConfiguration[] configs, IProgressMonitor monitor) throws CoreException{
+ buildConfigurations(configs, null, monitor);
+ }
+
+ public static void buildConfigurations(IConfiguration[] configs, IBuilder builder, IProgressMonitor monitor) throws CoreException{
+ Map map = sortConfigs(configs);
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ IProject proj = (IProject)entry.getKey();
+ IConfiguration[] cfgs = (IConfiguration[])entry.getValue();
+ buildConfigurations(proj, cfgs, builder, monitor);
+ }
+ }
+
+ private static Map sortConfigs(IConfiguration cfgs[]){
+ Map cfgMap = new HashMap();
+
+ for(int i = 0; i < cfgs.length; i++){
+ IConfiguration cfg = cfgs[i];
+ IProject proj = cfg.getOwner().getProject();
+ Set set = (Set)cfgMap.get(proj);
+ if(set == null){
+ set = new HashSet();
+ cfgMap.put(proj, set);
+ }
+
+ set.add(cfg);
+ }
+
+ if(cfgMap.size() != 0){
+ for(Iterator iter = cfgMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Set set = (Set)entry.getValue();
+ entry.setValue(set.toArray(new Configuration[set.size()]));
+ }
+ }
+
+ return cfgMap;
+ }
+
+ private static void buildConfigurations(final IProject project, IConfiguration[] configs, IBuilder builder, final IProgressMonitor monitor) throws CoreException{
+// final IProject project = configs[0].getOwner().getProject();
+ final boolean runAllBuidlers = false;
+ final Map map = builder != null ?
+ BuilderFactory.createBuildArgs(configs, builder)
+ : BuilderFactory.createBuildArgs(configs);
+
+ IWorkspaceRunnable op = new IWorkspaceRunnable() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void run(IProgressMonitor monitor) throws CoreException {
+ if (runAllBuidlers) {
+ ICommand[] commands = project.getDescription().getBuildSpec();
+ monitor.beginTask("", commands.length); //$NON-NLS-1$
+ for (int i = 0; i < commands.length; i++) {
+ if (commands[i].getBuilderName().equals(CommonBuilder.BUILDER_ID)) {
+ project.build(IncrementalProjectBuilder.FULL_BUILD, CommonBuilder.BUILDER_ID, map, new SubProgressMonitor(monitor, 1));
+ } else {
+ project.build(IncrementalProjectBuilder.FULL_BUILD, commands[i].getBuilderName(),
+ commands[i].getArguments(), new SubProgressMonitor(monitor, 1));
+ }
+ }
+ monitor.done();
+ } else {
+ project.build(IncrementalProjectBuilder.FULL_BUILD, CommonBuilder.BUILDER_ID, map, monitor);
+ }
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(op, monitor);
+ } finally {
+ monitor.done();
+ }
+
+ }
+
+ public static IBuilder getInternalBuilder(){
+ return getExtensionBuilder(INTERNAL_BUILDER_ID);
+ }
+
+ public static ITool getExtensionTool(ITool tool){
+ ITool extTool = tool;
+ for(;extTool != null && !extTool.isExtensionElement(); extTool = extTool.getSuperClass());
+ return extTool;
+ }
+
+ public static IConfiguration getPreferenceConfiguration(boolean write){
+ try {
+ ICConfigurationDescription des = CCorePlugin.getDefault().getPreferenceConfiguration(CFG_DATA_PROVIDER_ID, write);
+ if(des != null)
+ return getConfigurationForDescription(des);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ return null;
+ }
+
+ public static void setPreferenceConfiguration(IConfiguration cfg) throws CoreException{
+ ICConfigurationDescription des = getDescriptionForConfiguration(cfg);
+ if(des != null)
+ CCorePlugin.getDefault().setPreferenceConfiguration(CFG_DATA_PROVIDER_ID, des);
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
index 798994a9d79..1fd4331ad70 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -10,8 +10,22 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
+import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathManager;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigInfoFactory;
+import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
+import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DbgUtil;
+import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.ResourceChangeHandler;
@@ -23,10 +37,15 @@ import org.eclipse.core.resources.ISavedState;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.osgi.framework.BundleContext;
@@ -44,8 +63,21 @@ public class ManagedBuilderCorePlugin extends Plugin {
// NOTE: The code below is for tracking resource renaming and deleting. This is needed to keep
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
// elements
+
+ private static final String SCANNER_CONFIG = getUniqueIdentifier() + "/debug/scdiscovery"; //$NON-NLS-1$
+ public static final String EXTERNAL_SI_PROVIDER_SIMPLE_ID = "ExternalScannerInfoProvider"; //$NON-NLS-1$
+ public static final String SI_CONSOLE_PARSER_SIMPLE_ID = "ScannerInfoConsoleParser"; //$NON-NLS-1$
+ public static final String DEFAULT_EXTERNAL_SI_PROVIDER_ID = getUniqueIdentifier() + ".DefaultExternalScannerInfoProvider"; //$NON-NLS-1$
+
+ public static final String GCC_SPECS_CONSOLE_PARSER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".GCCSpecsConsoleParser"; //$NON-NLS-1$
+ public static final String GCC_SCANNER_INFO_CONSOLE_PARSER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".GCCScannerInfoConsoleParser"; //$NON-NLS-1$
+
+
+
private static ResourceChangeHandler listener;
+ private DiscoveredPathManager fDiscoveryPathManager;
+
/**
* @param descriptor
*/
@@ -79,6 +111,9 @@ public class ManagedBuilderCorePlugin extends Plugin {
super.start(context);
configurePluginDebugOptions();
+ GCCScannerConfigUtil.createSpecs();
+
+
// NOTE: The code below is for tracking resource renaming and deleting. This is needed to keep
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
// elements
@@ -153,6 +188,14 @@ public class ManagedBuilderCorePlugin extends Plugin {
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
+
+ if (fDiscoveryPathManager != null) {
+ fDiscoveryPathManager.shutdown();
+ fDiscoveryPathManager = null;
+ }
+
+
+
// NOTE: The code below is for tracking resource renaming and deleting. This is needed to keep
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
// elements
@@ -170,6 +213,21 @@ public class ManagedBuilderCorePlugin extends Plugin {
private static final String BUILDER = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/builder"; //$NON-NLS-1$
private static final String BUILD_MODEL = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/buildModel"; //$NON-NLS-1$
+ public static void log(IStatus status) {
+ ResourcesPlugin.getPlugin().getLog().log(status);
+ }
+
+ public static void log(Throwable e) {
+ if (e instanceof InvocationTargetException)
+ e = ((InvocationTargetException) e).getTargetException();
+ IStatus status = null;
+ if (e instanceof CoreException)
+ status = ((CoreException) e).getStatus();
+ else
+ status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
+ log(status);
+ }
+
/**
*
*/
@@ -191,6 +249,153 @@ public class ManagedBuilderCorePlugin extends Plugin {
if(buildModel != null){
DbgUtil.DEBUG = buildModel.equalsIgnoreCase("true"); //$NON-NLS-1$
}
+ String option = Platform.getDebugOption(SCANNER_CONFIG);
+ if (option != null) {
+ TraceUtil.SCANNER_CONFIG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
+ }
+
+ }
+ }
+
+ public static IBuilder[] createBuilders(IProject project, Map args){
+ return BuilderFactory.createBuilders(project, args);
+ }
+
+ public static IBuilder createCustomBuilder(IConfiguration cfg, String builderId) throws CoreException{
+ return BuilderFactory.createCustomBuilder(cfg, builderId);
+ }
+
+ public static IBuilder createCustomBuilder(IConfiguration cfg, IBuilder base){
+ return BuilderFactory.createCustomBuilder(cfg, base);
+ }
+
+ public static IBuilder createBuilderForEclipseBuilder(IConfiguration cfg, String eclipseBuilderID) throws CoreException {
+ return BuilderFactory.createBuilderForEclipseBuilder(cfg, eclipseBuilderID);
+ }
+
+ public IDiscoveredPathManager getDiscoveryManager() {
+ if ( fDiscoveryPathManager == null) {
+ fDiscoveryPathManager = new DiscoveredPathManager();
+ fDiscoveryPathManager.startup();
+ }
+ return fDiscoveryPathManager;
+ }
+
+ public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
+ Preferences prefs, String builderID, boolean useDefaults) {
+ return ScannerConfigInfoFactory.create(prefs, builderID, useDefaults);
+ }
+
+ public static IPath getWorkingDirectory() {
+ return ManagedBuilderCorePlugin.getDefault().getStateLocation();
+ }
+
+ public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
+ IProject project, String builderID) throws CoreException {
+ return ScannerConfigInfoFactory.create(project, builderID);
+ }
+
+ public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
+ Map args, String builderID) {
+ return ScannerConfigInfoFactory.create(args, builderID);
+ }
+
+ /**
+ * @param id - id specifying external scanner info provider
+ * @return provider - new instance of an external scanner info provider
+ */
+ public IExternalScannerInfoProvider getExternalScannerInfoProvider(String id) {
+ try {
+ IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, EXTERNAL_SI_PROVIDER_SIMPLE_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ String tool = extensions[i].getUniqueIdentifier();
+ if (tool != null && tool.equals(id)) {
+ IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+ IConfigurationElement[] runElement = configElements[j].getChildren("run"); //$NON-NLS-1$
+ if (runElement.length > 0) {
+ IExternalScannerInfoProvider builder = (IExternalScannerInfoProvider) runElement[0].createExecutableExtension("class"); //$NON-NLS-1$
+ return builder;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (CoreException e) {
+ log(e);
}
+ return null;
}
+
+ /**
+ * @param commandId
+ * @return String[] - array of parserIds associated with the commandId or 'all'
+ */
+ public String[] getScannerInfoConsoleParserIds(String commandId) {
+ String[] empty = new String[0];
+ if (commandId == null || commandId.length() == 0) {
+ commandId = "all"; //$NON-NLS-1$
+ }
+ IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ List parserIds = new ArrayList(extensions.length);
+ for (int i = 0; i < extensions.length; i++) {
+ String parserId = extensions[i].getUniqueIdentifier();
+ if (parserId != null) {
+ IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+ String id = configElements[0].getAttribute("commandId");//$NON-NLS-1$
+ if (id != null && (id.equals(commandId) || id.equals("all"))) { //$NON-NLS-1$
+ parserIds.add(parserId);
+ }
+ }
+ }
+ return (String[])parserIds.toArray(empty);
+ }
+ return empty;
+ }
+
+ /**
+ * @param parserId
+ * @return parser - parser object identified by the parserId
+ */
+ public IScannerInfoConsoleParser getScannerInfoConsoleParser(String parserId) {
+ try {
+ IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ String id = extensions[i].getUniqueIdentifier();
+ if (id != null && id.equals(parserId)) {
+ IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+ IScannerInfoConsoleParser parser = (IScannerInfoConsoleParser)configElements[0].createExecutableExtension("class");//$NON-NLS-1$
+ return parser;
+ }
+ }
+ }
+ }
+ catch (CoreException e) {
+ log(e);
+ }
+ return null;
+ }
+
+
+/*
+ public static IMakeBuilderInfo createBuildInfo(Preferences prefs, String builderID, boolean useDefaults) {
+ return BuildInfoFactory.create(prefs, builderID, useDefaults);
+ }
+
+ public static IMakeBuilderInfo createBuildInfo(IProject project, String builderID) throws CoreException {
+ return BuildInfoFactory.create(project, builderID);
+ }
+
+ public static IMakeBuilderInfo createBuildInfo(Map args, String builderID) {
+ return BuildInfoFactory.create(args, builderID);
+ }
+*/
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedCProjectNature.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedCProjectNature.java
index 16a4bcff575..648da45fd63 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedCProjectNature.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedCProjectNature.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * Copyright (c) 2002, 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
@@ -22,6 +22,7 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
@@ -104,6 +105,46 @@ public class ManagedCProjectNature implements IProjectNature {
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
}
+
+ /**
+ * Update the Java command in the build spec (replace existing one if present,
+ * add one first if none).
+ */
+ public static IProjectDescription setBuildSpec(IProjectDescription description, ICommand newCommand) {
+
+ ICommand[] oldCommands = description.getBuildSpec();
+ ICommand oldCommand = getBuildSpec(description, newCommand.getBuilderName());
+ ICommand[] newCommands;
+
+ if (oldCommand == null) {
+ // Add a Java build spec before other builders (1FWJK7I)
+ newCommands = new ICommand[oldCommands.length + 1];
+ System.arraycopy(oldCommands, 0, newCommands, 1, oldCommands.length);
+ newCommands[0] = newCommand;
+ } else {
+ for (int i = 0, max = oldCommands.length; i < max; i++) {
+ if (oldCommands[i].getBuilderName().equals(oldCommand.getBuilderName())) {
+ oldCommands[i] = newCommand;
+ break;
+ }
+ }
+ newCommands = oldCommands;
+ }
+
+ // Commit the spec change into the project
+ description.setBuildSpec(newCommands);
+ return description;
+ }
+
+ public static ICommand getBuildSpec(IProjectDescription description, String builderID) {
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ if (commands[i].getBuilderName().equals(builderID)) {
+ return commands[i];
+ }
+ }
+ return null;
+ }
/**
* Get the correct builderID
@@ -120,16 +161,14 @@ public class ManagedCProjectNature implements IProjectNature {
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
- // TODO Auto-generated method stub
-
+ addManagedBuilder(project, new NullProgressMonitor());
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IProjectNature#deconfigure()
*/
public void deconfigure() throws CoreException {
- // TODO Auto-generated method stub
-
+ // TODO remove builder from here
}
/* (non-Javadoc)
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedOptionValueHandler.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedOptionValueHandler.java
index 48096f0b2b7..011b4eb0671 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedOptionValueHandler.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedOptionValueHandler.java
@@ -143,7 +143,14 @@ public class ManagedOptionValueHandler implements
return true;
}
break;
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
default:
+ if (Arrays.equals(option.getBasicStringListValue(), (String[])defaultValue)) {
+ return true;
+ }
break;
}
} catch (BuildException e) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IBuildEnvironmentVariable.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IBuildEnvironmentVariable.java
index d7b0da46dd8..03133b1a817 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IBuildEnvironmentVariable.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IBuildEnvironmentVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,15 +10,17 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.envvar;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+
/**
* this interface represents the given environment variable
* @since 3.0
*/
-public interface IBuildEnvironmentVariable{
- public static final int ENVVAR_REPLACE = 1;
- public static final int ENVVAR_REMOVE = 2;
- public static final int ENVVAR_PREPEND = 3;
- public static final int ENVVAR_APPEND = 4;
+public interface IBuildEnvironmentVariable extends IEnvironmentVariable{
+ public static final int ENVVAR_REPLACE = IEnvironmentVariable.ENVVAR_REPLACE;
+ public static final int ENVVAR_REMOVE = IEnvironmentVariable.ENVVAR_REMOVE;
+ public static final int ENVVAR_PREPEND = IEnvironmentVariable.ENVVAR_PREPEND;
+ public static final int ENVVAR_APPEND = IEnvironmentVariable.ENVVAR_APPEND;
/**
*
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableProvider.java
index 5e6b46131bb..33480085f92 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.envvar;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
/**
@@ -45,21 +46,29 @@ public interface IEnvironmentVariableProvider{
* 2. IManagedProject to represent the managed project
* 3. IWorkspace to represent the workspace
* 4. null to represent the system environment passed to eclipse
+ * @deprecated use {@link IEnvironmentVariableProvider#getVariable(String, IConfiguration, boolean)} instead
*/
public IBuildEnvironmentVariable getVariable(
String variableName, Object level, boolean includeParentLevels, boolean resolveMacros);
+ public IEnvironmentVariable getVariable(String variableName,
+ IConfiguration cfg, boolean resolveMacros);
+
/**
*
* if environment variable names are case insensitive in the current OS,
* the environment variable provider will remove the duplicates of the variables if their names
* differ only by case
+ * @deprecated use {@link IEnvironmentVariableProvider#getVariables(IConfiguration, boolean)} instead
*
* @return the array of IBuildEnvironmentVariable that represents the environment variables
*/
public IBuildEnvironmentVariable[] getVariables(
Object level, boolean includeParentLevels, boolean resolveMacros);
+ public IEnvironmentVariable[] getVariables(
+ IConfiguration cfg, boolean resolveMacros);
+
/**
*
* @return the String representing default system delimiter. That is the ":" for Unix-like
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableSupplier.java
index 472e0fbda7c..699d94e078a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IEnvironmentVariableSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.envvar;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+
/**
*
* @since 3.0
@@ -23,12 +25,12 @@ public interface IEnvironmentVariableSupplier {
* @return the reference to the IBuildEnvironmentVariable interface representing
* the variable of a given name
*/
- IBuildEnvironmentVariable getVariable(String name, Object context);
+ IEnvironmentVariable getVariable(String name, Object context);
/**
*
* @param context the context
* @return the array of IBuildEnvironmentVariable that represents the environment variables
*/
- IBuildEnvironmentVariable[] getVariables(Object context);
+ IEnvironmentVariable[] getVariables(Object context);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java
index 8d50522db04..5a4236dacff 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Vector;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType;
@@ -32,6 +33,8 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
@@ -39,6 +42,7 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@@ -55,6 +59,7 @@ import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
+import org.eclipse.cdt.managedbuilder.makegen.gnu.ManagedBuildGnuToolInfo;
import org.eclipse.cdt.managedbuilder.pdomdepgen.PDOMDependencyGenerator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -79,7 +84,6 @@ public class BuildDescription implements IBuildDescription {
private Configuration fCfg;
private IResourceDelta fDelta;
- private Map fInTypeToGroupMap = new HashMap();
private Map fToolToMultiStepMap = new HashMap();
private BuildStep fOrderedMultiActions[];
@@ -105,12 +109,21 @@ public class BuildDescription implements IBuildDescription {
private Set fToolInProcesSet = new HashSet();
private ITool fOrderedTools[];
- private Map fExtToToolAndTypeListMap = new HashMap();
+ private IPath[] fSourcePaths;
+
+// private Map fExtToToolAndTypeListMap = new HashMap();
private Map fEnvironment;
private PDOMDependencyGenerator fPdomDepGen;
+ private PathSettingsContainer fToolInfos;
+
+ private class ToolInfoHolder {
+ Map fExtToToolAndTypeListMap;
+ Map fInTypeToGroupMap = new HashMap();
+ }
+
class ToolAndType{
ITool fTool;
IInputType fType;
@@ -423,8 +436,9 @@ public class BuildDescription implements IBuildDescription {
return null;
}
- private void initToolAndTypeMap(){
- ITool tools[] = fCfg.getFilteredTools();
+ private Map initToolAndTypeMap(IFolderInfo foInfo){
+ Map extToToolAndTypeListMap = new HashMap();
+ ITool tools[] = foInfo.getFilteredTools();
for(int i = 0; i < tools.length; i++){
ITool tool = tools[i];
IInputType types[] = tool.getInputTypes();
@@ -435,10 +449,10 @@ public class BuildDescription implements IBuildDescription {
for(int k = 0; k < exts.length; k++){
String ext = exts[k];
if(tool.buildsFileType(ext)){
- List list = (List)fExtToToolAndTypeListMap.get(ext);
+ List list = (List)extToToolAndTypeListMap.get(ext);
if(list == null){
list = new ArrayList();
- fExtToToolAndTypeListMap.put(ext, list);
+ extToToolAndTypeListMap.put(ext, list);
}
list.add(new ToolAndType(tool, type, ext));
}
@@ -449,24 +463,30 @@ public class BuildDescription implements IBuildDescription {
for(int k = 0; k < exts.length; k++){
String ext = exts[k];
if(tool.buildsFileType(ext)){
- List list = (List)fExtToToolAndTypeListMap.get(ext);
+ List list = (List)extToToolAndTypeListMap.get(ext);
if(list == null){
list = new ArrayList();
- fExtToToolAndTypeListMap.put(ext, list);
+ extToToolAndTypeListMap.put(ext, list);
}
list.add(new ToolAndType(tool, null, ext));
}
}
}
}
+ return extToToolAndTypeListMap;
}
-
+
ToolAndType getToolAndType(BuildResource rc, boolean checkVar){
+ ToolInfoHolder h = getToolInfo(rc);
+ return getToolAndType(h, rc, checkVar);
+ }
+
+ ToolAndType getToolAndType(ToolInfoHolder h, BuildResource rc, boolean checkVar){
String locString = rc.getLocation().toString();
BuildIOType arg = (BuildIOType)rc.getProducerIOType();
String linkId = (checkVar && arg != null) ? arg.getLinkId() : null;
- for(Iterator iter = fExtToToolAndTypeListMap.entrySet().iterator(); iter.hasNext();){
+ for(Iterator iter = h.fExtToToolAndTypeListMap.entrySet().iterator(); iter.hasNext();){
Map.Entry entry = (Map.Entry)iter.next();
String ext = (String)entry.getKey();
if(locString.endsWith("." + ext)){ //$NON-NLS-1$
@@ -498,11 +518,24 @@ public class BuildDescription implements IBuildDescription {
return null;
}
+ protected boolean isSource(IPath path){
+ path = path.makeRelative();
+ for(int i = 0; i < fSourcePaths.length; i++){
+ if(fSourcePaths[i].isPrefixOf(path))
+ return true;
+ }
+ return false;
+ }
+
+
private void composeOutputs(BuildStep inputAction, BuildIOType inputActionArg, BuildResource rc) throws CoreException{
boolean isSource = inputActionArg == null;
-
- if(!isSource){
+ if(isSource){
+ if(rc.isProjectResource()
+ && !isSource(rc.getFullPath().removeFirstSegments(1).makeRelative()))
+ return;
+ } else {
if(inputAction != null && inputAction == fTargetStep){
BuildIOType arg = (BuildIOType)rc.getProducerIOType();
if(arg.isPrimary()){
@@ -529,22 +562,24 @@ public class BuildDescription implements IBuildDescription {
IPath location = rc.getLocation();
- IResourceConfiguration rcCfg = rc.getFullPath() != null ?
- fCfg.getResourceConfiguration(rc.getFullPath().toString()) :
- null;
+ IResourceInfo rcInfo = rc.isProjectResource() ?
+ fCfg.getResourceInfo(rc.getFullPath().removeFirstSegments(1), false) :
+ fCfg.getRootFolderInfo();
ITool tool = null;
IInputType inputType = null;
String ext = null;
boolean stepRemoved = false;
- if(rcCfg != null){
- if(rcCfg.isExcluded()){
- if(rcCfg.needsRebuild())
- stepRemoved = true;
- else
- return;
- }
-
- tool = rcCfg.getToolsToInvoke()[0];
+ if(rcInfo.isExcluded()){
+ if(rcInfo.needsRebuild())
+ stepRemoved = true;
+ else
+ return;
+ }
+
+ ToolInfoHolder h = null;
+ if(rcInfo instanceof IFileInfo){
+ IFileInfo fi = (IFileInfo)rcInfo;
+ tool = fi.getToolsToInvoke()[0];
String exts[] = tool.getAllInputExtensions();
String locString = location.toString();
for(int i = 0; i < exts.length; i++){
@@ -554,9 +589,9 @@ public class BuildDescription implements IBuildDescription {
ext = e;
}
}
- }
- else {
- ToolAndType tt = getToolAndType(rc, true);
+ } else {
+ h = getToolInfo(rc);
+ ToolAndType tt = getToolAndType(h, rc, true);
if(tt != null){
tool = tt.fTool;
inputType = tt.fType;
@@ -577,8 +612,8 @@ public class BuildDescription implements IBuildDescription {
BuildStep action = null;
BuildIOType argument = null;
BuildGroup group = null;
- if(rcCfg == null)
- group = createGroup(inputType, ext);
+ if(h != null)
+ group = createGroup(h, inputType, ext);
action = createStep(tool, inputType);//new BuildStep(this, tool, inputType);
if(stepRemoved)
@@ -634,13 +669,13 @@ public class BuildDescription implements IBuildDescription {
}
}
- private BuildGroup createGroup(IInputType inType, String ext){
+ private BuildGroup createGroup(ToolInfoHolder h, IInputType inType, String ext){
String key = inType != null ?
inType.getId() : "ext:"+ext; //$NON-NLS-1$
- BuildGroup group = (BuildGroup)fInTypeToGroupMap.get(key);
+ BuildGroup group = (BuildGroup)h.fInTypeToGroupMap.get(key);
if(group == null){
group = new BuildGroup();
- fInTypeToGroupMap.put(key, group);
+ h.fInTypeToGroupMap.put(key, group);
}
return group;
}
@@ -670,6 +705,10 @@ public class BuildDescription implements IBuildDescription {
fInfo = ManagedBuildManager.getBuildInfo(fProject);
fFlags = flags;
+ fSourcePaths = fCfg.getSourcePaths();
+ if(fSourcePaths.length == 0){
+ fSourcePaths = new IPath[]{new Path("")};
+ }
fInputStep = createStep(null,null);
fOutputStep = createStep(null,null);
}
@@ -678,7 +717,7 @@ public class BuildDescription implements IBuildDescription {
if(fCfg.needsFullRebuild())
fInputStep.setRebuildState(true);
- initToolAndTypeMap();
+ initToolInfos();
initMultiSteps();
@@ -1070,7 +1109,11 @@ public class BuildDescription implements IBuildDescription {
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES) {
List outputList = (List)option.getValue();
// Add outputPrefix to each if necessary
if(outputList != null && outputList.size() > 0){
@@ -1372,7 +1415,12 @@ public class BuildDescription implements IBuildDescription {
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES
+ ) {
inputs = (List)option.getValue();
}
for (int j=0; j<inputs.size(); j++) {
@@ -2016,4 +2064,45 @@ public class BuildDescription implements IBuildDescription {
public IBuildResource getBuildResource(IResource resource){
return getBuildResource(calcResourceLocation(resource));
}
+
+ private void initToolInfos(){
+ fToolInfos = PathSettingsContainer.createRootContainer();
+
+ IResourceInfo rcInfos[] = fCfg.getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ IResourceInfo rcInfo = rcInfos[i];
+// if(rcInfo.isExcluded())
+// continue;
+
+ ToolInfoHolder h = getToolInfo(rcInfo.getPath(), true);
+ if(rcInfo instanceof IFolderInfo){
+ IFolderInfo fo = (IFolderInfo)rcInfo;
+ h.fExtToToolAndTypeListMap = initToolAndTypeMap(fo);
+ }
+ }
+ }
+
+ private ToolInfoHolder getToolInfo(BuildResource rc){
+ IPath path = rc.isProjectResource() ?
+ rc.getFullPath().removeFirstSegments(1).makeRelative() :
+ new Path("");
+ return getToolInfo(path);
+ }
+
+ private ToolInfoHolder getToolInfo(IPath path){
+ return getToolInfo(path, false);
+ }
+
+ private ToolInfoHolder getToolInfo(IPath path, boolean create){
+ PathSettingsContainer child = fToolInfos.getChildContainer(path, create, create);
+ ToolInfoHolder h = null;
+ if(child != null){
+ h = (ToolInfoHolder)child.getValue();
+ if(h == null && create){
+ h = new ToolInfoHolder();
+ child.setValue(h);
+ }
+ }
+ return h;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java
index cd2080cbf2a..e03abc9b7c9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -188,4 +188,4 @@ public class BuildProcessManager {
DbgUtil.trace("Number of processors detected: " + procNumber); //$NON-NLS-1$
return procNumber;
}
-}
+} \ No newline at end of file
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java
index daa81ee16c5..959da03b45b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
@@ -38,11 +39,10 @@ import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IFileContextData;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -422,18 +422,18 @@ public class BuildStep implements IBuildStep {
String result = str;
try {
if(resolveAll){
- IMacroSubstitutor sub = createSubstitutor(fileData);
- result = MacroResolver.resolveToString(str, sub);
+ SupplierBasedCdtVariableSubstitutor sub = createSubstitutor(fileData);
+ result = CdtVariableResolver.resolveToString(str, sub);
} else {
result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", " ", IBuildMacroProvider.CONTEXT_FILE, fileData); //$NON-NLS-1$ //$NON-NLS-2$
}
- } catch (BuildMacroException e) {
+ } catch (CdtVariableException e) {
}
return result;
}
- private IMacroSubstitutor createSubstitutor(IFileContextData fileData){
+ private SupplierBasedCdtVariableSubstitutor createSubstitutor(IFileContextData fileData){
BuildMacroProvider prov = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
IMacroContextInfo info = prov.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE, fileData);
FileMacroExplicitSubstitutor sub = new FileMacroExplicitSubstitutor(
@@ -447,7 +447,8 @@ public class BuildStep implements IBuildStep {
try {
return resolveAll ?
((Tool)fTool).getToolCommandFlags(inRcPath, outRcPath,
- createSubstitutor(new FileContextData(inRcPath, outRcPath, null, fTool)))
+ createSubstitutor(new FileContextData(inRcPath, outRcPath, null, fTool)),
+ BuildMacroProvider.getDefault())
:
fTool.getToolCommandFlags(inRcPath, outRcPath);
} catch (BuildException e) {
@@ -568,7 +569,11 @@ public class BuildStep implements IBuildStep {
optType == IOption.LIBRARIES ||
optType == IOption.OBJECTS ||
optType == IOption.INCLUDE_PATH ||
- optType == IOption.PREPROCESSOR_SYMBOLS){
+ optType == IOption.PREPROCESSOR_SYMBOLS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES){
// Mote that when using the enumerated inputs, the path(s) must be translated from project relative
// to top build directory relative
String[] paths = new String[bRcs.length];
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/FileMacroExplicitSubstitutor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/FileMacroExplicitSubstitutor.java
index c62e77c72a3..dd2a2e29720 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/FileMacroExplicitSubstitutor.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/FileMacroExplicitSubstitutor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -11,17 +11,17 @@
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
-public class FileMacroExplicitSubstitutor extends DefaultMacroSubstitutor {
+public class FileMacroExplicitSubstitutor extends SupplierBasedCdtVariableSubstitutor {
- public FileMacroExplicitSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
- super(contextType, contextData, inexistentMacroValue, listDelimiter);
- }
+// public FileMacroExplicitSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
+// super(contextType, contextData, inexistentMacroValue, listDelimiter);
+// }
public FileMacroExplicitSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
super(contextInfo, inexistentMacroValue, listDelimiter);
@@ -30,7 +30,7 @@ public class FileMacroExplicitSubstitutor extends DefaultMacroSubstitutor {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor#resolveMacro(org.eclipse.cdt.managedbuilder.macros.IBuildMacro)
*/
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
+ protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException{
if(macro instanceof MbsMacroSupplier.FileContextMacro){
MbsMacroSupplier.FileContextMacro fileMacro = (MbsMacroSupplier.FileContextMacro)macro;
String val = fileMacro.getExplicitMacroValue();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java
new file mode 100644
index 00000000000..bf482be05c9
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.buildproperties;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperties;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.core.runtime.CoreException;
+
+public class BuildProperties implements IBuildProperties {
+ private HashMap fPropertiesMap = new HashMap();
+ private ArrayList fInexistentProperties;
+
+ public BuildProperties(){
+
+ }
+
+ public BuildProperties(String properties){
+ StringTokenizer t = new StringTokenizer(properties, BuildPropertyManager.PROPERTIES_SEPARATOR);
+ while(t.hasMoreTokens()){
+ String property = t.nextToken();
+ try {
+ BuildProperty prop = new BuildProperty(property);
+ addProperty(prop);
+ } catch (CoreException e) {
+ if(fInexistentProperties == null)
+ fInexistentProperties = new ArrayList();
+
+ fInexistentProperties.add(property);
+ }
+ }
+
+ if(fInexistentProperties != null)
+ fInexistentProperties.trimToSize();
+ }
+
+ public BuildProperties(BuildProperties properties){
+ fPropertiesMap.putAll(properties.fPropertiesMap);
+ if(properties.fInexistentProperties != null)
+ fInexistentProperties = (ArrayList)properties.fInexistentProperties.clone();
+ }
+
+ public IBuildProperty[] getProperties(){
+ return (BuildProperty[])fPropertiesMap.values().toArray(new BuildProperty[fPropertiesMap.size()]);
+ }
+
+ public IBuildProperty getProperty(String id){
+ return (BuildProperty)fPropertiesMap.get(id);
+ }
+
+ void addProperty(IBuildProperty property){
+ fPropertiesMap.put(property.getPropertyType().getId(), property);
+ }
+
+ public IBuildProperty setProperty(String propertyId, String propertyValue) throws CoreException {
+ IBuildProperty property = BuildPropertyManager.getInstance().createProperty(propertyId, propertyValue);
+
+ addProperty(property);
+
+ return property;
+ }
+
+ public IBuildProperty removeProperty(String id){
+ return (IBuildProperty)fPropertiesMap.remove(id);
+ }
+
+ void removeProperty(BuildProperty property){
+ fPropertiesMap.remove(property.getPropertyType().getId());
+ }
+
+ public String toString(){
+ String props = toStringExistingProperties();
+ if(fInexistentProperties != null){
+ String inexistentProps = CDataUtil.arrayToString((String[])fInexistentProperties.toArray(new String[fInexistentProperties.size()]), BuildPropertyManager.PROPERTIES_SEPARATOR);
+ if(props.length() != 0){
+ StringBuffer buf = new StringBuffer();
+ buf.append(props).append(BuildPropertyManager.PROPERTIES_SEPARATOR).append(inexistentProps);
+ } else {
+ props = inexistentProps;
+ }
+ }
+ return props;
+ }
+
+ public String toStringExistingProperties(){
+ int size = fPropertiesMap.size();
+ if(size == 0)
+ return "";
+ else if(size == 1)
+ return fPropertiesMap.values().iterator().next().toString();
+
+ StringBuffer buf = new StringBuffer();
+ Iterator iter = fPropertiesMap.values().iterator();
+ buf.append(iter.next().toString());
+ for(;iter.hasNext();){
+ buf.append(BuildPropertyManager.PROPERTIES_SEPARATOR);
+ buf.append(iter.next().toString());
+ }
+ return buf.toString();
+ }
+
+ public Object clone() {
+ try {
+ BuildProperties clone = (BuildProperties)super.clone();
+
+ if(fInexistentProperties != null)
+ clone.fInexistentProperties = (ArrayList)fInexistentProperties.clone();
+
+ clone.fPropertiesMap = (HashMap)fPropertiesMap.clone();
+/* for(Iterator iter = clone.fPropertiesMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ BuildProperty prop = (BuildProperty)entry.getValue();
+ entry.setValue(prop.clone());
+ }
+*/
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ }
+ return null;
+ }
+
+ public void clear() {
+ fPropertiesMap.clear();
+ fInexistentProperties.clear();
+ }
+
+ public boolean containsValue(String propertyId, String valueId) {
+ IBuildProperty prop = getProperty(propertyId);
+ if(prop != null){
+ return valueId.equals(prop.getValue().getId());
+ }
+ return false;
+ }
+
+
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java
new file mode 100644
index 00000000000..25353ed6248
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.buildproperties;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class BuildProperty implements IBuildProperty{
+ private IBuildPropertyType fType;
+ private IBuildPropertyValue fValue;
+
+ BuildProperty(String property) throws CoreException {
+ int index = property.indexOf(BuildPropertyManager.PROPERTY_VALUE_SEPARATOR);
+ String type, value;
+ if(index != -1){
+ type = property.substring(0, index);
+ value = property.substring(index + 1);
+ } else {
+ type = property;
+ value = null;
+ }
+
+ fType = BuildPropertyManager.getInstance().getPropertyType(type);
+ if(fType == null){
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the specified type does not exist"));
+ }
+ setValue(value);
+ }
+
+ BuildProperty(IBuildPropertyType type, String valueId) throws CoreException {
+ fType = type;
+ setValue(valueId);
+ }
+
+ public IBuildPropertyType getPropertyType(){
+ return fType;
+ }
+
+ private void setValue(String id) throws CoreException {
+ IBuildPropertyValue value = fType.getSupportedValue(id);
+
+ if(value == null)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "invalid value id"));
+
+ setValue(value);
+ }
+
+ private void setValue(IBuildPropertyValue value){
+ fValue = value;
+ }
+
+ public IBuildPropertyValue getValue(){
+ return fValue;
+ }
+
+ public String toString(){
+ StringBuffer buf = new StringBuffer();
+ buf.append(fType.toString()).append(BuildPropertyManager.PROPERTY_VALUE_SEPARATOR).append(fValue.toString());
+ return buf.toString();
+ }
+
+/* public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ }
+ return null;
+ }
+*/
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyManager.java
new file mode 100644
index 00000000000..642d1eb8025
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyManager.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.buildproperties;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyManager;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+
+public class BuildPropertyManager implements IBuildPropertyManager{
+ private static final String PROPERTIES_EXT_POINT_ID = "org.eclipse.cdt.managedbuilder.core.buildProperties";
+ static final String PROPERTY_VALUE_SEPARATOR = "=";
+ static final String PROPERTIES_SEPARATOR = ",";
+ static final String ELEMENT_PROPERTY_TYPE = "propertyType";
+ static final String ELEMENT_PROPERTY_VALUE = "propertyValue";
+ static final String ATTRIBUTE_PROPERTY = "property";
+ static final String ATTRIBUTE_NAME = "name";
+ static final String ATTRIBUTE_ID = "id";
+
+ private static BuildPropertyManager fInstance;
+
+ private List fTypeCfgElements;
+ private List fValueCfgElements;
+
+ private BuildPropertyManager(){
+ loadExtensions();
+ }
+
+ public static BuildPropertyManager getInstance(){
+ if(fInstance == null)
+ fInstance = new BuildPropertyManager();
+ return fInstance;
+ }
+
+ public BuildProperties loadPropertiesFromString(String properties){
+ return new BuildProperties(properties);
+ }
+
+ public String savePropertiesToString(BuildProperties properties){
+ return properties.toString();
+ }
+
+ private Map fPropertyTypeMap = new HashMap();
+
+ public IBuildPropertyType getPropertyType(String id){
+ return (BuildPropertyType)fPropertyTypeMap.get(id);
+ }
+
+ public IBuildPropertyType createPropertyType(String id, String name) throws CoreException{
+ IBuildPropertyType type = getPropertyType(id);
+ if(type != null){
+ if(!name.equals(type.getName()))
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "property type of the specified id already exists and has different name"));
+ } else {
+ type = new BuildPropertyType(id, name);
+ fPropertyTypeMap.put(id, type);
+ }
+ return type;
+ }
+
+ public IBuildPropertyValue createPropertyValue(String typeId, String id, String name) throws CoreException{
+ IBuildPropertyType type = getPropertyType(typeId);
+ if(type == null)
+ throw new CoreException(new Status(
+ IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "specified property type does not exist"));
+
+ return createPropertyValue(type, id, name);
+ }
+
+ public IBuildPropertyValue createPropertyValue(IBuildPropertyType type, String id, String name) throws CoreException{
+ BuildPropertyValue value = (BuildPropertyValue)type.getSupportedValue(id);
+ if(value != null){
+ if(!name.equals(value.getName()))
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "property value of the specified id already exists and has different name"));
+ } else {
+ value = new BuildPropertyValue(id, name);
+ ((BuildPropertyType)type).addSupportedValue(value);
+ }
+
+ return value;
+ }
+
+ public IBuildPropertyType[] getPropertyTypes(){
+ return (BuildPropertyType[])fPropertyTypeMap.values().toArray(new BuildPropertyType[fPropertyTypeMap.size()]);
+ }
+
+ public IBuildProperty createProperty(String id, String value) throws CoreException {
+ IBuildPropertyType type = getPropertyType(id);
+ if(type == null)
+ throw new CoreException(new Status(
+ IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "specified property type does not exist"));
+
+ BuildProperty property = new BuildProperty(type, value);
+ return property;
+ }
+
+ private boolean addConfigElement(IConfigurationElement el){
+ if(ELEMENT_PROPERTY_TYPE.equals(el.getName())){
+ getTypeElList(true).add(el);
+ return true;
+ } else if(ELEMENT_PROPERTY_VALUE.equals(el.getName())){
+ getValueElList(true).add(el);
+ return true;
+ }
+ return false;
+ }
+
+ private List getTypeElList(boolean create){
+ if(fTypeCfgElements == null && create)
+ fTypeCfgElements = new ArrayList();
+ return fTypeCfgElements;
+ }
+
+ private List getValueElList(boolean create){
+ if(fValueCfgElements == null && create)
+ fValueCfgElements = new ArrayList();
+ return fValueCfgElements;
+ }
+
+ private void loadExtensions(){
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PROPERTIES_EXT_POINT_ID);
+ if( extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; ++i) {
+ IExtension extension = extensions[i];
+ IConfigurationElement els[] = extension.getConfigurationElements();
+ for(int k = 0; k < els.length; k++){
+ addConfigElement(els[k]);
+ }
+ }
+
+ resolveConfigElements();
+ }
+ }
+
+
+ private void resolveConfigElements(){
+ List typeEls = getTypeElList(false);
+ if(typeEls != null){
+ for(int i = 0; i < typeEls.size(); i++){
+ IConfigurationElement el = (IConfigurationElement)typeEls.get(i);
+ try {
+ createPropertyType(el);
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ List valEls = getValueElList(false);
+ if(valEls != null){
+ for(int i = 0; i < valEls.size(); i++){
+ IConfigurationElement el = (IConfigurationElement)valEls.get(i);
+ try {
+ createPropertyValue(el);
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ }
+
+ private IBuildPropertyType createPropertyType(IConfigurationElement el) throws CoreException{
+ String id = el.getAttribute(ATTRIBUTE_ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "id not specified"));
+ String name = el.getAttribute(ATTRIBUTE_NAME);
+ if(name == null)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "name not specified"));
+
+ return createPropertyType(id, name);
+ }
+
+ private IBuildPropertyValue createPropertyValue(IConfigurationElement el) throws CoreException{
+ String id = el.getAttribute(ATTRIBUTE_ID);
+ if(id == null)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "id not specified"));
+ String name = el.getAttribute(ATTRIBUTE_NAME);
+ if(name == null)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "name not specified"));
+ String property = el.getAttribute(ATTRIBUTE_PROPERTY);
+ if(property == null)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "property not specified"));
+
+
+ return createPropertyValue(property, id, name);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyType.java
new file mode 100644
index 00000000000..c2368e48027
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyType.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.buildproperties;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+
+
+public class BuildPropertyType extends PropertyBase implements IBuildPropertyType{
+ private Map fValuesMap = new HashMap();
+
+ BuildPropertyType(String id, String name){
+ super(id, name);
+ }
+
+ void addSupportedValue(BuildPropertyValue value){
+ fValuesMap.put(value.getId(), value);
+ }
+
+ public IBuildPropertyValue[] getSupportedValues(){
+ return (BuildPropertyValue[])fValuesMap.values().toArray(new BuildPropertyValue[fValuesMap.size()]);
+ }
+
+ public IBuildPropertyValue getSupportedValue(String id){
+ return (BuildPropertyValue)fValuesMap.get(id);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyValue.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyValue.java
new file mode 100644
index 00000000000..d8f9714d1b7
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildPropertyValue.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.buildproperties;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+
+
+public class BuildPropertyValue extends PropertyBase implements IBuildPropertyValue{
+ BuildPropertyValue(String id, String name) {
+ super(id, name);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/PropertyBase.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/PropertyBase.java
new file mode 100644
index 00000000000..2e320b07a47
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/PropertyBase.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.buildproperties;
+
+
+
+public abstract class PropertyBase {
+ private String fId;
+ private String fName;
+
+ PropertyBase(String id, String name){
+ fId = id;
+ fName = name;
+ }
+
+ public String getId(){
+ return fId;
+ }
+
+ public String getName(){
+ return fName;
+ }
+
+ public String toString(){
+ return getId();
+ }
+
+ public boolean equals(Object o){
+ if(!o.getClass().equals(getClass()))
+ return false;
+
+ return fId.equals(((PropertyBase)o).getId());
+ }
+
+ public int hashCode(){
+ return fId.hashCode();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java
index fd81fd1eb5b..edffa71e207 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,11 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
public class AdditionalInput implements IAdditionalInput {
@@ -77,7 +76,7 @@ public class AdditionalInput implements IAdditionalInput {
* @param parent The <code>ITool</code> the AdditionalInput will be added to.
* @param element The XML element that contains the AdditionalInput settings.
*/
- public AdditionalInput(IInputType parent, Element element) {
+ public AdditionalInput(IInputType parent, ICStorageElement element) {
this.parent = parent;
isExtensionAdditionalInput = false;
@@ -140,15 +139,15 @@ public class AdditionalInput implements IAdditionalInput {
*
* @param element An XML element containing the AdditionalInput information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// path
- if (element.hasAttribute(IAdditionalInput.PATHS)) {
+ if (element.getAttribute(IAdditionalInput.PATHS) != null) {
paths = element.getAttribute(IAdditionalInput.PATHS);
}
// kind
- if (element.hasAttribute(IAdditionalInput.KIND)) {
+ if (element.getAttribute(IAdditionalInput.KIND) != null) {
String kindStr = element.getAttribute(IAdditionalInput.KIND);
if (kindStr == null || kindStr.equals(ADDITIONAL_INPUT_DEPENDENCY)) {
kind = new Integer(KIND_ADDITIONAL_INPUT_DEPENDENCY);
@@ -166,7 +165,7 @@ public class AdditionalInput implements IAdditionalInput {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
if (paths != null) {
element.setAttribute(IAdditionalInput.PATHS, paths);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BooleanExpressionApplicabilityCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BooleanExpressionApplicabilityCalculator.java
index da934dc81ab..ad4814530d6 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BooleanExpressionApplicabilityCalculator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BooleanExpressionApplicabilityCalculator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,16 +10,31 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.internal.enablement.AdjustmentContext;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
public class BooleanExpressionApplicabilityCalculator implements IOptionApplicability {
private OptionEnablementExpression fExpressions[];
+ private Map fRefPropsMap;
+
public BooleanExpressionApplicabilityCalculator(IManagedConfigElement optionElement){
this(optionElement.getChildren(OptionEnablementExpression.NAME));
}
@@ -35,37 +50,185 @@ public class BooleanExpressionApplicabilityCalculator implements IOptionApplicab
public boolean isOptionVisible(IBuildObject configuration,
IHoldsOptions holder,
IOption option){
- return evaluate(configuration, holder, option, OptionEnablementExpression.FLAG_UI_VISIBILITY);
+ IResourceInfo rcInfo = rcInfoFromConfiguration(configuration);
+ if(rcInfo != null)
+ return evaluate(rcInfo, holder, option, OptionEnablementExpression.FLAG_UI_VISIBILITY);
+ return true;
+ }
+
+ public static IResourceInfo rcInfoFromConfiguration(IBuildObject configuration){
+ if(configuration instanceof IFolderInfo)
+ return (IFolderInfo)configuration;
+ if(configuration instanceof IFileInfo)
+ return (IFileInfo)configuration;
+ if(configuration instanceof IConfiguration)
+ return ((IConfiguration)configuration).getRootFolderInfo();
+ return null;
+ }
+
+ public boolean isInputTypeEnabled(ITool tool, IInputType type){
+ return evaluate(tool.getParentResourceInfo(), tool, null, OptionEnablementExpression.FLAG_CMD_USAGE);
+ }
+
+ public boolean isOutputTypeEnabled(ITool tool, IOutputType type){
+ return evaluate(tool.getParentResourceInfo(), tool, null, OptionEnablementExpression.FLAG_CMD_USAGE);
}
+ public boolean isToolUsedInCommandLine(IResourceInfo rcInfo,
+ ITool tool){
+ return evaluate(rcInfo, tool, null, OptionEnablementExpression.FLAG_CMD_USAGE);
+ }
+
public boolean isOptionEnabled(IBuildObject configuration,
IHoldsOptions holder,
IOption option){
- return evaluate(configuration, holder, option, OptionEnablementExpression.FLAG_UI_ENABLEMENT);
+ IResourceInfo rcInfo = rcInfoFromConfiguration(configuration);
+ if(rcInfo != null)
+ return evaluate(rcInfo, holder, option, OptionEnablementExpression.FLAG_UI_ENABLEMENT);
+ return true;
}
public boolean isOptionUsedInCommandLine(IBuildObject configuration,
IHoldsOptions holder,
IOption option){
- return evaluate(configuration, holder, option, OptionEnablementExpression.FLAG_CMD_USAGE);
+ IResourceInfo rcInfo = rcInfoFromConfiguration(configuration);
+ if(rcInfo != null)
+ return evaluate(rcInfo, holder, option, OptionEnablementExpression.FLAG_CMD_USAGE);
+ return true;
}
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder, IOption option, int flags){
for(int i = 0; i < fExpressions.length; i++){
- if(!fExpressions[i].evaluate(configuration, holder, option, flags))
+ if(!fExpressions[i].evaluate(rcInfo, holder, option, flags))
return false;
}
return true;
}
- public boolean performAdjustment(IBuildObject configuration,
- IHoldsOptions holder, IOption option){
+/* public boolean performAdjustment(IBuildObject configuration,
+ IHoldsOptions holder, IOption option, boolean extensionAdjustment){
+ boolean adjusted = false;
+ for(int i = 0; i < fExpressions.length; i++){
+ if(fExpressions[i].performAdjustment(configuration, holder, option, extensionAdjustment))
+ adjusted = true;
+ }
+ return adjusted;
+ }
+*/
+ public boolean adjustOption(IResourceInfo rcInfo,
+ IHoldsOptions holder,
+ IOption option,
+ boolean extensionAdjustment){
+ boolean adjusted = false;
+ AdjustmentContext context = extensionAdjustment ? null : new AdjustmentContext();
+ for(int i = 0; i < fExpressions.length; i++){
+ if(fExpressions[i].adjustOption(rcInfo, holder, option, context, extensionAdjustment))
+ adjusted = true;
+ }
+
+ if(context != null){
+ String unadjusted[] = context.getUnadjusted();
+ for(int i = 0; i < unadjusted.length; i++){
+ OptionEnablementExpression.adjustOption(rcInfo, holder, option, unadjusted[i], null, extensionAdjustment);
+ }
+ }
+ return adjusted;
+ }
+
+ public boolean adjustToolChain(IFolderInfo info,
+ IToolChain tChain,
+ boolean extensionAdjustment){
+ boolean adjusted = false;
+ AdjustmentContext context = extensionAdjustment ? null : new AdjustmentContext();
+ for(int i = 0; i < fExpressions.length; i++){
+ if(fExpressions[i].adjustToolChain(info, tChain, context, extensionAdjustment))
+ adjusted = true;
+ }
+
+ if(context != null){
+ String unadjusted[] = context.getUnadjusted();
+ for(int i = 0; i < unadjusted.length; i++){
+ OptionEnablementExpression.adjustToolChain(info, tChain, unadjusted[i], null, extensionAdjustment);
+ }
+ }
+
+ return adjusted;
+ }
+
+ public boolean adjustTool(IResourceInfo info,
+ ITool tool,
+ boolean extensionAdjustment){
boolean adjusted = false;
+ AdjustmentContext context = extensionAdjustment ? null : new AdjustmentContext();
for(int i = 0; i < fExpressions.length; i++){
- if(fExpressions[i].performAdjustment(configuration, holder, option))
+ if(fExpressions[i].adjustTool(info, tool, context, extensionAdjustment))
adjusted = true;
}
+
+ if(context != null){
+ String unadjusted[] = context.getUnadjusted();
+ for(int i = 0; i < unadjusted.length; i++){
+ OptionEnablementExpression.adjustTool(info, tool, unadjusted[i], null, extensionAdjustment);
+ }
+ }
+
return adjusted;
}
+
+ public boolean adjustConfiguration(IConfiguration cfg,
+ boolean extensionAdjustment){
+ boolean adjusted = false;
+ AdjustmentContext context = extensionAdjustment ? null : new AdjustmentContext();
+ for(int i = 0; i < fExpressions.length; i++){
+ if(fExpressions[i].adjustConfiguration(cfg, context, extensionAdjustment))
+ adjusted = true;
+ }
+
+ if(context != null){
+ String unadjusted[] = context.getUnadjusted();
+ for(int i = 0; i < unadjusted.length; i++){
+ OptionEnablementExpression.adjustConfiguration(cfg, unadjusted[i], null, extensionAdjustment);
+ }
+ }
+
+ return adjusted;
+ }
+
+ private Map getReferencedProperties(){
+ if(fRefPropsMap == null){
+ fRefPropsMap = new HashMap();
+
+ for(int i = 0; i < fExpressions.length; i++){
+ fExpressions[i].getReferencedProperties(fRefPropsMap);
+ }
+ }
+ return fRefPropsMap;
+ }
+
+ public boolean referesProperty(String id){
+ Map map = getReferencedProperties();
+
+ return map.containsKey(id);
+ }
+
+ public boolean referesPropertyValue(String propertyId, String valueId){
+ Map map = getReferencedProperties();
+ Set set = (Set)map.get(propertyId);
+ if(set != null)
+ return set.contains(valueId);
+ return false;
+ }
+
+ public String[] getReferencedPropertyIds(){
+ Map map = getReferencedProperties();
+ return (String[])map.entrySet().toArray(new String[map.size()]);
+ }
+
+ public String[] getReferencedValueIds(String propertyId){
+ Map map = getReferencedProperties();
+ Set set = (Set)map.get(propertyId);
+ return (String[])set.toArray(new String[set.size()]);
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java
index b33be6b53d0..0bd4e9a6676 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java
@@ -44,7 +44,7 @@ public class BuildObject implements IBuildObject {
public String getName() {
return name;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
*/
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObjectProperties.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObjectProperties.java
new file mode 100644
index 00000000000..d41437ad1ac
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObjectProperties.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
+import org.eclipse.cdt.managedbuilder.internal.buildproperties.BuildProperties;
+import org.eclipse.cdt.managedbuilder.internal.buildproperties.BuildPropertyManager;
+import org.eclipse.core.runtime.CoreException;
+
+public class BuildObjectProperties extends BuildProperties implements
+ IBuildObjectProperties {
+ private IBuildPropertiesRestriction fRestriction;
+ private IBuildPropertyChangeListener fListener;
+
+ public BuildObjectProperties(IBuildPropertiesRestriction restriction, IBuildPropertyChangeListener listener) {
+ super();
+ fRestriction = restriction;
+ fListener = listener;
+ }
+
+ public BuildObjectProperties(BuildObjectProperties properties, IBuildPropertiesRestriction restriction, IBuildPropertyChangeListener listener) {
+ super(properties);
+ fRestriction = restriction;
+ fListener = listener;
+ }
+
+ public BuildObjectProperties(String properties, IBuildPropertiesRestriction restriction, IBuildPropertyChangeListener listener) {
+ super(properties);
+ fRestriction = restriction;
+ fListener = listener;
+ }
+
+ public IBuildPropertyType[] getSupportedTypes() {
+ IBuildPropertyType types[] = BuildPropertyManager.getInstance().getPropertyTypes();
+
+ if(fRestriction != null && types.length != 0){
+ List list = new ArrayList(types.length);
+ for(int i = 0; i < types.length; i++){
+ if(fRestriction.supportsType(types[i].getId()))
+ list.add(types[i]);
+ }
+
+ types = (IBuildPropertyType[])list.toArray(new IBuildPropertyType[list.size()]);
+ }
+
+ return types;
+ }
+
+ public IBuildPropertyValue[] getSupportedValues(String typeId) {
+ IBuildPropertyType type = BuildPropertyManager.getInstance().getPropertyType(typeId);
+ if(type != null){
+ IBuildPropertyValue values[] = type.getSupportedValues();
+ if(fRestriction != null && values.length != 0){
+ List list = new ArrayList(values.length);
+ for(int i = 0; i < values.length; i++){
+ if(fRestriction.supportsValue(type.getId(), values[i].getId()))
+ list.add(values[i]);
+ }
+
+ return (IBuildPropertyValue[])list.toArray(new IBuildPropertyValue[list.size()]);
+ }
+ }
+ return new IBuildPropertyValue[0];
+ }
+
+ public boolean supportsType(String id) {
+ return fRestriction.supportsType(id);
+// IBuildPropertyType type = BuildPropertyManager.getInstance().getPropertyType(id);
+// if(type != null){
+// if(fRestriction != null){
+// return fRestriction.supportsType(type.getId());
+// }
+// return true;
+// }
+// return false;
+ }
+
+ public boolean supportsValue(String typeId, String valueId) {
+ return fRestriction.supportsValue(typeId, valueId);
+// IBuildPropertyType type = BuildPropertyManager.getInstance().getPropertyType(typeId);
+// if(type != null){
+// IBuildPropertyValue value = type.getSupportedValue(valueId);
+// if(value != null){
+// if(fRestriction != null){
+// return fRestriction.supportsValue(type.getId(), value.getId());
+// }
+// return true;
+// }
+// }
+// return false;
+ }
+
+ public void clear() {
+ super.clear();
+ fListener.propertiesChanged();
+ }
+
+ public IBuildProperty removeProperty(String id) {
+ IBuildProperty property = super.removeProperty(id);
+ if(property != null)
+ fListener.propertiesChanged();
+ return property;
+ }
+
+ IBuildProperty internalSetProperty(String propertyId, String propertyValue) throws CoreException{
+ return super.setProperty(propertyId, propertyValue);
+ }
+
+ public IBuildProperty setProperty(String propertyId, String propertyValue)
+ throws CoreException {
+// if(!supportsType(propertyId))
+// throw new CoreException(new Status(IStatus.ERROR,
+// ManagedBuilderCorePlugin.getUniqueIdentifier(),
+// "property type is not supported"));
+// if(!supportsValue(propertyId, propertyValue))
+// throw new CoreException(new Status(IStatus.ERROR,
+// ManagedBuilderCorePlugin.getUniqueIdentifier(),
+// "property value is not supported"));
+
+ IBuildProperty property = super.setProperty(propertyId, propertyValue);
+ fListener.propertiesChanged();
+ return property;
+ }
+
+ public String[] getRequiredTypeIds() {
+ return fRestriction.getRequiredTypeIds();
+ }
+
+ public boolean requiresType(String typeId) {
+ return fRestriction.requiresType(typeId);
+ }
+
+ public String[] getSupportedTypeIds() {
+ return fRestriction.getSupportedTypeIds();
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ return fRestriction.getSupportedValueIds(typeId);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java
new file mode 100644
index 00000000000..5a1df71318c
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+public class BuildSettingsUtil {
+ public static void disconnectDepentents(IConfiguration cfg, ITool[] tools){
+ for(int i = 0; i < tools.length; i++){
+ disconnectDepentents(cfg, tools[i]);
+ }
+ }
+
+ public static void disconnectDepentents(IConfiguration cfg, ITool tool){
+ ITool deps[] = getDependentTools(cfg, tool);
+ for(int i = 0; i < deps.length; i++){
+ disconnect(deps[i], tool);
+ }
+ }
+
+ private static void disconnect(ITool child, ITool superClass){
+ ITool directChild = child;
+ for(;directChild != null; directChild = directChild.getSuperClass()){
+ if(superClass.equals(directChild.getSuperClass()))
+ break;
+ }
+
+ if(directChild == null)
+ return;
+
+ ((Tool)directChild).copyNonoverriddenSettings((Tool)superClass);
+ ((Tool)directChild).setSuperClass(superClass.getSuperClass());
+ }
+
+ public static ITool[] getDependentTools(IConfiguration cfg, ITool tool){
+ IResourceInfo rcInfos[] = cfg.getResourceInfos();
+ List list = new ArrayList();
+ for(int i = 0; i < rcInfos.length; i++){
+ calcDependentTools(rcInfos[i], tool, list);
+ }
+ return (Tool[])list.toArray(new Tool[list.size()]);
+ }
+
+ private static List calcDependentTools(IResourceInfo info, ITool tool, List list){
+ return calcDependentTools(info.getTools(), tool, list);
+ }
+
+ public static List calcDependentTools(ITool tools[], ITool tool, List list){
+ if(list == null)
+ list = new ArrayList();
+
+ for(int i = 0; i < tools.length; i++){
+ ITool superTool = tools[i];
+ for(;superTool != null; superTool = superTool.getSuperClass()){
+ if(superTool.equals(tool)){
+ list.add(tools[i]);
+ }
+ }
+ }
+
+ return list;
+ }
+
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
index c9e35875a3a..4b133702aeb 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -11,11 +11,29 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
import java.util.StringTokenizer;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.COutputEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -25,23 +43,31 @@ import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildBuildData;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextBuildMacroValues;
+import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IFileContextBuildMacroValues;
import org.eclipse.cdt.managedbuilder.macros.IReservedMacroNameSupplier;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
-public class Builder extends BuildObject implements IBuilder {
+public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider {
- private static final String EMPTY_STRING = new String();
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
// Superclass
private IBuilder superClass;
@@ -64,6 +90,29 @@ public class Builder extends BuildObject implements IBuilder {
private IReservedMacroNameSupplier reservedMacroNameSupplier;
private IConfigurationElement reservedMacroNameSupplierElement;
+ private String autoBuildTarget;
+ private Boolean autoBuildEnabled;
+ private String incrementalBuildTarget;
+ private Boolean incrementalBuildEnabled;
+ private String cleanBuildTarget;
+ private Boolean cleanBuildEnabled;
+ private Boolean managedBuildOn;
+ private Boolean keepEnvVarInBuildfile;
+ private Boolean supportsManagedBuild;
+ //custom builder settings
+ private String[] customizedErrorParserIds;
+ private HashMap customizedEnvironment;
+ private Boolean appendEnvironment;// = Boolean.valueOf(true);
+ private String buildPath;
+ private HashMap customBuildProperties;
+// private Boolean isWorkspaceBuildPath;
+ private String ignoreErrCmd;
+ private String parallelBuildCmd;
+ private Boolean stopOnErr;
+ private Integer parallelNum;
+ private Boolean parallelBuildOn;
+ private boolean isTest;
+
// Miscellaneous
private boolean isExtensionBuilder = false;
private boolean isDirty = false;
@@ -71,6 +120,15 @@ public class Builder extends BuildObject implements IBuilder {
private IConfigurationElement previousMbsVersionConversionElement = null;
private IConfigurationElement currentMbsVersionConversionElement = null;
+
+ private BuildBuildData fBuildData;
+
+ private Boolean fSupportsCustomizedBuild;
+
+ private List identicalList;
+
+ private ICOutputEntry[] outputEntries;
+
/*
* C O N S T R U C T O R S
*/
@@ -101,7 +159,7 @@ public class Builder extends BuildObject implements IBuilder {
// Hook me up to the Managed Build Manager
ManagedBuildManager.addExtensionBuilder(this);
}
-
+
/**
* This constructor is called to create a Builder whose attributes and children will be
* added by separate calls.
@@ -128,6 +186,7 @@ public class Builder extends BuildObject implements IBuilder {
// Hook me up to the Managed Build Manager
ManagedBuildManager.addExtensionBuilder(this);
} else {
+ fBuildData = new BuildBuildData(this);
setDirty(true);
}
}
@@ -140,10 +199,12 @@ public class Builder extends BuildObject implements IBuilder {
* @param element The XML element that contains the Builder settings.
* @param managedBuildRevision The fileVersion of Managed Buid System
*/
- public Builder(IToolChain parent, Element element, String managedBuildRevision) {
+ public Builder(IToolChain parent, ICStorageElement element, String managedBuildRevision) {
this.parent = parent;
isExtensionBuilder = false;
+ fBuildData = new BuildBuildData(this);
+
// Set the managedBuildRevision
setManagedBuildRevision(managedBuildRevision);
@@ -159,15 +220,18 @@ public class Builder extends BuildObject implements IBuilder {
*/
public Builder(IToolChain parent, String Id, String name, Builder builder) {
this.parent = parent;
+
superClass = builder.superClass;
if (superClass != null) {
if (builder.superClassId != null) {
superClassId = new String(builder.superClassId);
}
}
+
setId(Id);
setName(name);
+ boolean copyIds = Id.equals(builder.getId());
// Set the managedBuildRevision & the version
setManagedBuildRevision(builder.getManagedBuildRevision());
setVersion(getVersionFromId());
@@ -196,6 +260,26 @@ public class Builder extends BuildObject implements IBuilder {
if (builder.args != null) {
args = new String(builder.args);
}
+ autoBuildTarget = builder.autoBuildTarget;
+ autoBuildEnabled = builder.autoBuildEnabled;
+ incrementalBuildTarget = builder.incrementalBuildTarget;
+ incrementalBuildEnabled = builder.incrementalBuildEnabled;
+ cleanBuildTarget = builder.cleanBuildTarget;
+ cleanBuildEnabled = builder.cleanBuildEnabled;
+ managedBuildOn = builder.managedBuildOn;
+ keepEnvVarInBuildfile = builder.keepEnvVarInBuildfile;
+ supportsManagedBuild = builder.supportsManagedBuild;
+ if(builder.customizedErrorParserIds != null)
+ customizedErrorParserIds = (String[])builder.customizedErrorParserIds.clone();
+ if(builder.customizedEnvironment != null)
+ customizedEnvironment = (HashMap)builder.customizedEnvironment.clone();
+ appendEnvironment = builder.appendEnvironment;
+ buildPath = builder.buildPath;
+ if(builder.customBuildProperties != null)
+ customBuildProperties = (HashMap)builder.customBuildProperties.clone();
+
+
+
buildFileGeneratorElement = builder.buildFileGeneratorElement;
if(builder.fileContextBuildMacroValues != null){
@@ -214,8 +298,129 @@ public class Builder extends BuildObject implements IBuilder {
reservedMacroNameSupplierElement = builder.reservedMacroNameSupplierElement;
reservedMacroNameSupplier = builder.reservedMacroNameSupplier;
+ fBuildData = new BuildBuildData(this);
+
+ stopOnErr = builder.stopOnErr;
+ ignoreErrCmd = builder.ignoreErrCmd;
+ parallelBuildCmd = builder.parallelBuildCmd;
+ parallelNum = builder.parallelNum;
+ parallelBuildOn = builder.parallelBuildOn;
+
+ if(builder.outputEntries != null){
+ outputEntries = (ICOutputEntry[])builder.outputEntries.clone();
+ }
+
+ if(copyIds){
+ isDirty = builder.isDirty;
+ } else {
+ setDirty(true);
+ }
+ }
+
+ public void copySettings(Builder builder, boolean allBuildSettings){
+ try {
+ if(isAutoBuildEnable() != builder.isAutoBuildEnable())
+ setAutoBuildEnable(builder.isAutoBuildEnable());
+ } catch (CoreException e) {
+ }
+ try {
+ if(isIncrementalBuildEnabled() != builder.isIncrementalBuildEnabled())
+ setIncrementalBuildEnable(builder.isIncrementalBuildEnabled());
+ } catch (CoreException e) {
+ }
+ try {
+ if(isFullBuildEnabled() != builder.isFullBuildEnabled())
+ setFullBuildEnable(builder.isFullBuildEnabled());
+ } catch (CoreException e) {
+ }
+ try {
+ if(isCleanBuildEnabled() != builder.isCleanBuildEnabled())
+ setCleanBuildEnable(builder.isCleanBuildEnabled());
+ } catch (CoreException e) {
+ }
+ if(isStopOnError() != builder.isStopOnError()
+ && supportsStopOnError(builder.isStopOnError())){
+ try {
+ setStopOnError(builder.isStopOnError());
+ } catch (CoreException e) {
+ }
+ }
+ if(getParallelizationNum() != builder.getParallelizationNum()
+ && supportsParallelBuild()){
+ try {
+ setParallelizationNum(builder.getParallelizationNum());
+ } catch (CoreException e) {
+ }
+ }
+ if(isParallelBuildOn() != builder.isParallelBuildOn()
+ && supportsParallelBuild()){
+ try {
+ setParallelBuildOn(builder.isParallelBuildOn());
+ } catch (CoreException e) {
+ }
+ }
+ if(builder.keepEnvironmentVariablesInBuildfile() &&
+ canKeepEnvironmentVariablesInBuildfile()){
+ setKeepEnvironmentVariablesInBuildfile(builder.keepEnvironmentVariablesInBuildfile());
+ }
+ if(isManagedBuildOn() != builder.isManagedBuildOn()
+ && supportsBuild(builder.isManagedBuildOn())){
+ try {
+ setManagedBuildOn(builder.isManagedBuildOn());
+ } catch (CoreException e) {
+ }
+ }
+
+ if(builder.customizedErrorParserIds != null)
+ customizedErrorParserIds = (String[])builder.customizedErrorParserIds.clone();
+ if(builder.customizedEnvironment != null)
+ customizedEnvironment = (HashMap)builder.customizedEnvironment.clone();
+ appendEnvironment = builder.appendEnvironment;
+ if(!getBuildPath().equals(builder.getBuildPath()))
+ setBuildPath(builder.getBuildPath());
+ if(builder.customBuildProperties != null)
+ customBuildProperties = (HashMap)builder.customBuildProperties.clone();
+
+ if(allBuildSettings){
+ if(!getCommand().equals(builder.getCommand()))
+ setCommand(builder.getCommand());
+ if(!getArgumentsAttribute().equals(builder.getArgumentsAttribute()))
+ setArgumentsAttribute(builder.getArgumentsAttribute());
+ if(!getAutoBuildTarget().equals(builder.getAutoBuildTarget())){
+ try {
+ setAutoBuildTarget(builder.getAutoBuildTarget());
+ } catch (CoreException e) {
+ }
+ }
+ if(!getIncrementalBuildTarget().equals(builder.getIncrementalBuildTarget())){
+ try {
+ setIncrementalBuildTarget(builder.getIncrementalBuildTarget());
+ } catch (CoreException e) {
+ }
+ }
+ if(!getFullBuildTarget().equals(builder.getFullBuildTarget())){
+ try {
+ setFullBuildTarget(builder.getFullBuildTarget());
+ } catch (CoreException e) {
+ }
+ }
+ if(!getCleanBuildTarget().equals(builder.getCleanBuildTarget())){
+ try {
+ setCleanBuildTarget(builder.getCleanBuildTarget());
+ } catch (CoreException e) {
+ }
+ }
+ }
+
setDirty(true);
}
+
+/* public Builder(IToolChain parent, String Id, String name, Builder builder, ICStorageElement el) {
+ this(parent, Id, name, builder);
+
+ loadFromProject(el);
+ }
+*/
/*
* E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
@@ -282,6 +487,57 @@ public class Builder extends BuildObject implements IBuilder {
// arguments
args = element.getAttribute(IBuilder.ARGUMENTS);
+
+ autoBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_AUTO);
+ String tmp = element.getAttribute(ATTRIBUTE_AUTO_ENABLED);
+ if(tmp != null)
+ autoBuildEnabled = Boolean.valueOf(tmp);
+ incrementalBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_INCREMENTAL);
+ tmp = element.getAttribute(ATTRIBUTE_AUTO_ENABLED);
+ if(tmp != null)
+ incrementalBuildEnabled = Boolean.valueOf(tmp);
+ cleanBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_CLEAN);
+ tmp = element.getAttribute(ATTRIBUTE_CLEAN_ENABLED);
+ if(tmp != null)
+ cleanBuildEnabled = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_MANAGED_BUILD_ON);
+ if(tmp != null)
+ managedBuildOn = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_KEEP_ENV);
+ if(tmp != null)
+ keepEnvVarInBuildfile = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_SUPORTS_MANAGED_BUILD);
+ if(tmp != null)
+ supportsManagedBuild = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS);
+ if(tmp != null)
+ customizedErrorParserIds = CDataUtil.stringToArray(tmp, ";"); //$NON-NLS-1$
+ tmp = element.getAttribute(ATTRIBUTE_ENVIRONMENT);
+ if(tmp != null)
+ customizedEnvironment = (HashMap)MapStorageElement.decodeMap(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_APPEND_ENVIRONMENT);
+ if(tmp != null)
+ appendEnvironment = Boolean.valueOf(tmp);;
+ buildPath = element.getAttribute(ATTRIBUTE_BUILD_PATH);
+ tmp = element.getAttribute(ATTRIBUTE_CUSTOM_PROPS);
+ if(tmp != null)
+ customBuildProperties = (HashMap)MapStorageElement.decodeMap(tmp);
+
+ ignoreErrCmd = element.getAttribute(ATTRIBUTE_IGNORE_ERR_CMD);
+ tmp = element.getAttribute(ATTRIBUTE_STOP_ON_ERR);
+ if(tmp != null)
+ stopOnErr = Boolean.valueOf(tmp);
+ parallelBuildCmd = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD);
+ tmp = element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER);
+ if(tmp != null){
+ try {
+ parallelNum = Integer.decode(tmp);
+ } catch (NumberFormatException e){
+ }
+ }
+ tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_ON);
+ if(tmp != null)
+ parallelBuildOn = Boolean.valueOf(tmp);
// Get the semicolon separated list of IDs of the error parsers
errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
@@ -294,6 +550,29 @@ public class Builder extends BuildObject implements IBuilder {
//load the File Context Build Macro Values
fileContextBuildMacroValues = new FileContextBuildMacroValues(this,element);
+
+ tmp = element.getAttribute(IS_SYSTEM);
+ if(tmp != null)
+ isTest = Boolean.valueOf(tmp).booleanValue();
+
+ IManagedConfigElement[] children = element.getChildren();
+ for(int i = 0; i < children.length; i++){
+ IManagedConfigElement child = children[i];
+ String name = child.getName();
+ if(OUTPUT_ENTRIES.equals(name)){
+ ICLanguageSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(new ManagedConfigStorageElement(child));
+ if(entries.length == 0){
+ outputEntries = new ICOutputEntry[0];
+ } else {
+ List list = new ArrayList(entries.length);
+ for(int k = 0; k < entries.length; k++){
+ if(entries[k].getKind() == ICLanguageSettingEntry.OUTPUT_PATH)
+ list.add(entries[k]);
+ }
+ outputEntries = (ICOutputEntry[])list.toArray(new ICOutputEntry[list.size()]);
+ }
+ }
+ }
}
/* (non-Javadoc)
@@ -302,13 +581,13 @@ public class Builder extends BuildObject implements IBuilder {
*
* @param element An XML element containing the builder information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@@ -324,22 +603,22 @@ public class Builder extends BuildObject implements IBuilder {
}
// Get the 'versionSupported' attribute
- if (element.hasAttribute(VERSIONS_SUPPORTED)) {
+ if (element.getAttribute(VERSIONS_SUPPORTED) != null) {
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
}
// Get the 'convertToId' id
- if (element.hasAttribute(CONVERT_TO_ID)) {
+ if (element.getAttribute(CONVERT_TO_ID) != null) {
convertToId = element.getAttribute(CONVERT_TO_ID);
}
// Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) {
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
}
// isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ if (element.getAttribute(IProjectType.IS_ABSTRACT) != null) {
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
if (isAbs != null){
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
@@ -347,25 +626,100 @@ public class Builder extends BuildObject implements IBuilder {
}
// command
- if (element.hasAttribute(IBuilder.COMMAND)) {
+ if (element.getAttribute(IBuilder.COMMAND) != null) {
command = element.getAttribute(IBuilder.COMMAND);
}
// arguments
- if (element.hasAttribute(IBuilder.ARGUMENTS)) {
+ if (element.getAttribute(IBuilder.ARGUMENTS) != null) {
args = element.getAttribute(IBuilder.ARGUMENTS);
}
+ autoBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_AUTO);
+ String tmp = element.getAttribute(ATTRIBUTE_AUTO_ENABLED);
+ if(tmp != null)
+ autoBuildEnabled = Boolean.valueOf(tmp);
+ incrementalBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_INCREMENTAL);
+ tmp = element.getAttribute(ATTRIBUTE_AUTO_ENABLED);
+ if(tmp != null)
+ incrementalBuildEnabled = Boolean.valueOf(tmp);
+ cleanBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_CLEAN);
+ tmp = element.getAttribute(ATTRIBUTE_CLEAN_ENABLED);
+ if(tmp != null)
+ cleanBuildEnabled = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_MANAGED_BUILD_ON);
+ if(tmp != null)
+ managedBuildOn = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_KEEP_ENV);
+ if(tmp != null)
+ keepEnvVarInBuildfile = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_SUPORTS_MANAGED_BUILD);
+ if(tmp != null)
+ supportsManagedBuild = Boolean.valueOf(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS);
+ if(tmp != null)
+ customizedErrorParserIds = CDataUtil.stringToArray(tmp, ";"); //$NON-NLS-1$
+ tmp = element.getAttribute(ATTRIBUTE_ENVIRONMENT);
+ if(tmp != null)
+ customizedEnvironment = (HashMap)MapStorageElement.decodeMap(tmp);
+ tmp = element.getAttribute(ATTRIBUTE_APPEND_ENVIRONMENT);
+ if(tmp != null)
+ appendEnvironment = Boolean.valueOf(tmp);;
+ buildPath = element.getAttribute(ATTRIBUTE_BUILD_PATH);
+ tmp = element.getAttribute(ATTRIBUTE_CUSTOM_PROPS);
+ if(tmp != null)
+ customBuildProperties = (HashMap)MapStorageElement.decodeMap(tmp);
+
// Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(IToolChain.ERROR_PARSERS)) {
+ if (element.getAttribute(IToolChain.ERROR_PARSERS) != null) {
errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
}
// Note: build file generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
- if (element.hasAttribute(IBuilder.BUILDFILEGEN_ID)) {
+ if (element.getAttribute(IBuilder.BUILDFILEGEN_ID) != null) {
// TODO: Issue warning?
}
+
+ ignoreErrCmd = element.getAttribute(ATTRIBUTE_IGNORE_ERR_CMD);
+ tmp = element.getAttribute(ATTRIBUTE_STOP_ON_ERR);
+ if(tmp != null)
+ stopOnErr = Boolean.valueOf(tmp);
+ parallelBuildCmd = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD);
+ tmp = element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER);
+ if(tmp != null){
+ try {
+ parallelNum = Integer.decode(tmp);
+ } catch (NumberFormatException e){
+ }
+ }
+ tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_ON);
+ if(tmp != null)
+ parallelBuildOn = Boolean.valueOf(tmp);
+
+ ICStorageElement[] children = element.getChildren();
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ String name = child.getName();
+ if(OUTPUT_ENTRIES.equals(name)){
+ ICLanguageSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(child);
+ if(entries.length == 0){
+ outputEntries = new ICOutputEntry[0];
+ } else {
+ List list = new ArrayList(entries.length);
+ for(int k = 0; k < entries.length; k++){
+ if(entries[k].getKind() == ICLanguageSettingEntry.OUTPUT_PATH)
+ list.add(entries[k]);
+ }
+ outputEntries = (ICOutputEntry[])list.toArray(new ICOutputEntry[list.size()]);
+ }
+ }
+ }
+
+ }
+
+ public void serialize(ICStorageElement element) {
+ serialize(element, true);
}
/**
@@ -374,7 +728,7 @@ public class Builder extends BuildObject implements IBuilder {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element, boolean resetDirtyState) {
if (superClass != null)
element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
@@ -413,15 +767,61 @@ public class Builder extends BuildObject implements IBuilder {
if (args != null) {
element.setAttribute(IBuilder.ARGUMENTS, args);
}
-
+
+ if(autoBuildTarget != null)
+ element.setAttribute(ATTRIBUTE_TARGET_AUTO, autoBuildTarget);
+ if(autoBuildEnabled != null)
+ element.setAttribute(ATTRIBUTE_AUTO_ENABLED, autoBuildEnabled.toString());
+ if(incrementalBuildTarget != null)
+ element.setAttribute(ATTRIBUTE_TARGET_INCREMENTAL, incrementalBuildTarget);
+ if(incrementalBuildEnabled != null)
+ element.setAttribute(ATTRIBUTE_AUTO_ENABLED, incrementalBuildEnabled.toString());
+ if(cleanBuildTarget != null)
+ element.setAttribute(ATTRIBUTE_TARGET_CLEAN, cleanBuildTarget);
+ if(cleanBuildEnabled != null)
+ element.setAttribute(ATTRIBUTE_CLEAN_ENABLED, cleanBuildEnabled.toString());
+ if(managedBuildOn != null)
+ element.setAttribute(ATTRIBUTE_MANAGED_BUILD_ON, managedBuildOn.toString());
+ if(keepEnvVarInBuildfile != null)
+ element.setAttribute(ATTRIBUTE_KEEP_ENV, keepEnvVarInBuildfile.toString());
+ if(supportsManagedBuild != null)
+ element.setAttribute(ATTRIBUTE_SUPORTS_MANAGED_BUILD, supportsManagedBuild.toString());
+ if(customizedErrorParserIds != null)
+ element.setAttribute(ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS, CDataUtil.arrayToString(customizedErrorParserIds, ";"));
+ if(customizedEnvironment != null)
+ element.setAttribute(ATTRIBUTE_ENVIRONMENT, MapStorageElement.encodeMap(customizedEnvironment));
+ if(appendEnvironment != null)
+ element.setAttribute(ATTRIBUTE_APPEND_ENVIRONMENT, appendEnvironment.toString());
+ if(buildPath != null)
+ element.setAttribute(ATTRIBUTE_BUILD_PATH, buildPath);
+ if(customBuildProperties != null)
+ element.setAttribute(ATTRIBUTE_CUSTOM_PROPS, MapStorageElement.encodeMap(customBuildProperties));
+
+ if(ignoreErrCmd != null)
+ element.setAttribute(ATTRIBUTE_IGNORE_ERR_CMD, ignoreErrCmd);
+ if(stopOnErr != null)
+ element.setAttribute(ATTRIBUTE_STOP_ON_ERR, stopOnErr.toString());
+ if(parallelBuildCmd != null)
+ element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD, parallelBuildCmd);
+ if(parallelNum != null)
+ element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, parallelNum.toString());
+ if(parallelBuildOn != null)
+ element.setAttribute(ATTRIBUTE_MANAGED_BUILD_ON, parallelBuildOn.toString());
// Note: build file generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (buildFileGeneratorElement != null) {
// TODO: issue warning?
}
- // I am clean now
- isDirty = false;
+ if(outputEntries != null){
+ ICStorageElement outEl = element.createChild(OUTPUT_ENTRIES);
+ LanguageSettingEntriesSerializer.serializeEntries(outputEntries, outEl);
+ }
+
+ if(resetDirtyState){
+ // I am clean now
+ isDirty = false;
+ }
}
/*
@@ -493,13 +893,141 @@ public class Builder extends BuildObject implements IBuilder {
* @see org.eclipse.cdt.core.build.managed.IBuilder#getArguments()
*/
public String getArguments() {
+ String args = getArgumentsAttribute();
+ String stopOnErrCmd = getStopOnErrCmd(isStopOnError());
+ String parallelBuildCmd = isParallelBuildOn() ? getParallelizationCmd(getParallelizationNum()) : EMPTY_STRING;
+
+ args = addCmd(args, stopOnErrCmd);
+ args = addCmd(args, parallelBuildCmd);
+
+ return args;
+ }
+
+ private String addCmd(String args, String cmd){
+ if(getCmdIndex(args, cmd) == -1){
+ if(args.length() != 0){
+ args += ' ';
+ }
+ args += cmd;
+ }
+ return args;
+ }
+
+ private String removeCmd(String args, String cmd){
+ int index = getCmdIndex(args, cmd);
+ if(index != -1){
+ String prefix = args.substring(0, index).trim();
+ String suffix = args.substring(index + cmd.length(), args.length()).trim();
+ if(prefix.length() == 0){
+ args = suffix;
+ } else if (suffix.length() == 0){
+ args = prefix;
+ } else {
+ args = prefix + ' ' + suffix;
+ }
+
+ args = args.trim();
+ }
+ return args;
+ }
+
+ private int getCmdIndex(String args, String cmd){
+ if(cmd.length() == 0)
+ return -1;
+
+ String tmp = args;
+ int index = -1;
+ for(index = tmp.indexOf(cmd); index != -1; index = tmp.indexOf(cmd, index + 1)){
+ if(index != 0){
+ char c = tmp.charAt(index-1);
+ if(c != '\t' && c != ' ')
+ continue;
+ }
+ int end = index + cmd.length();
+ if(end < tmp.length()){
+ char c = tmp.charAt(end);
+ if(c != '\t' && c != ' ')
+ continue;
+ }
+
+ //found
+ break;
+ }
+ return index;
+ }
+
+ public String getParallelizationCmd(int num){
+ String pattern = getParrallelBuildCmd();
+ if(pattern.length() == 0){
+ return EMPTY_STRING;
+ }if(num == 0){
+ return EMPTY_STRING;
+ }
+
+ return processParallelPattern(pattern, num < 0, num);
+ }
+
+ private String processParallelPattern(String pattern, boolean empty, int num){
+ int start = pattern.indexOf(PARALLEL_PATTERN_NUM_START);
+ int end = -1;
+ boolean hasStartChar = false;
+ String result;
+ if(start != -1){
+ end = pattern.indexOf(PARALLEL_PATTERN_NUM_END);
+ if(end != -1){
+ hasStartChar = true;
+ } else {
+ start = -1;
+ }
+ }
+ if(start == -1){
+ start = pattern.indexOf(PARALLEL_PATTERN_NUM);
+ if(start != -1){
+ end = start + PARALLEL_PATTERN_NUM.length();
+ }
+ }
+ if(start == -1){
+ result = pattern;
+ } else {
+ String prefix;
+ String suffix;
+ String numStr;
+ prefix = pattern.substring(0, start);
+ suffix = pattern.substring(end);
+ numStr = pattern.substring(start, end);
+ if(empty){
+ result = prefix + suffix;
+ } else {
+ String resolvedNum;
+ if(hasStartChar){
+ String numPrefix, numSuffix;
+ numStr = numStr.substring(0, PARALLEL_PATTERN_NUM_START.length());
+ numStr = numStr.substring(numStr.length() - PARALLEL_PATTERN_NUM_END.length());
+ int numStart = pattern.indexOf(PARALLEL_PATTERN_NUM);
+ if(numStart != -1){
+ int numEnd = numStart + PARALLEL_PATTERN_NUM.length();
+ numPrefix = numStr.substring(0, numStart);
+ numSuffix = numStr.substring(numEnd);
+ resolvedNum = numPrefix + new Integer(num).toString() + numSuffix;
+ } else {
+ resolvedNum = EMPTY_STRING;
+ }
+ } else {
+ resolvedNum = new Integer(num).toString();
+ }
+ result = prefix + resolvedNum + suffix;
+ }
+ }
+ return result;
+ }
+
+ public String getArgumentsAttribute() {
if (args == null) {
// If I have a superClass, ask it
if (superClass != null) {
- return superClass.getArguments();
- } else {
- return new String("-k"); //$NON-NLS-1$
+ return ((Builder)superClass).getArgumentsAttribute();
}
+ return EMPTY_STRING;
}
return args;
}
@@ -547,6 +1075,7 @@ public class Builder extends BuildObject implements IBuilder {
* @see org.eclipse.cdt.core.build.managed.IBuilder.setCommand(String)
*/
public void setCommand(String cmd) {
+ if(getCommand().equals(cmd)) return;
if (cmd == null && command == null) return;
if (command == null || cmd == null || !cmd.equals(command)) {
command = cmd;
@@ -558,6 +1087,12 @@ public class Builder extends BuildObject implements IBuilder {
* @see org.eclipse.cdt.core.build.managed.IBuilder#setArguments(String)
*/
public void setArguments(String newArgs) {
+ if(getArguments().equals(newArgs))
+ return;
+ setArgumentsAttribute(newArgs);
+ }
+
+ public void setArgumentsAttribute(String newArgs) {
if (newArgs == null && args == null) return;
if (args == null || newArgs == null || !newArgs.equals(args)) {
args = newArgs;
@@ -982,4 +1517,887 @@ public class Builder extends BuildObject implements IBuilder {
public IConfigurationElement getCurrentMbsVersionConversionElement() {
return currentMbsVersionConversionElement;
}
+
+ public CBuildData getBuildData() {
+ return fBuildData;
+ }
+
+ public String[] getErrorParsers() {
+ if(isCustomBuilder() && customizedErrorParserIds != null)
+ return (String[])customizedErrorParserIds.clone();
+
+ IToolChain parent = getParent();
+ IConfiguration parentConfig = parent.getParent();
+ return parentConfig.getErrorParserList();
+ }
+
+ public void setErrorParsers(String[] parsers) throws CoreException {
+ if(isCustomBuilder()){
+ customizedErrorParserIds = (parsers != null && parsers.length != 0) ? (String[])parsers.clone() : parsers;
+ } else {
+ IToolChain parent = getParent();
+ IConfiguration parentConfig = parent.getParent();
+ parentConfig.setErrorParserList(parsers);
+ }
+ }
+
+ private Object getMacroContextData(){
+ return this;//!isExtensionBuilder ? (Object)this : (Object)getParent().getParent();
+ }
+
+ public String getBuildArguments() {
+ String args = getArguments();
+ IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
+
+ try {
+ args = provider.resolveValue(args, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, getMacroContextData());
+ } catch (BuildMacroException e) {
+ }
+
+ return args;
+ }
+
+ public IPath getBuildCommand() {
+ String command = getCommand();
+ IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
+
+ try {
+ command = provider.resolveValue(command, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, getMacroContextData());
+ } catch (BuildMacroException e) {
+ }
+
+ return new Path(command);
+ }
+
+ private String getBuildPathAttribute(){
+ if(buildPath == null){
+ if(superClass != null){
+ return ((Builder)superClass).getBuildPathAttribute();
+ }
+ }
+ return buildPath;
+ }
+
+ public void setBuildPath(String path){
+ buildPath = path;
+ setDirty(true);
+ }
+
+ public String getBuildPath(){
+ String path = getBuildPathAttribute();
+ if(path == null){
+ boolean initBuildPathVar = false;
+ Configuration cfg = (Configuration)getConfguration();
+ if(cfg != null && !cfg.isPreference()){
+ IProject project = cfg.getOwner().getProject();
+ IPath projPath = project.getFullPath();
+ if(isManagedBuildOn()){
+ path = projPath.append(cfg.getName()).toString();
+ initBuildPathVar = !isExtensionBuilder;
+ } else {
+ path = projPath.toString();
+ }
+ IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
+ path = mngr.generateVariableExpression("workspace_loc", path); //$NON-NLS-1$
+ if(initBuildPathVar)
+ buildPath = path;
+ } else {
+ path = ""; //$NON-NLS-1$
+ }
+ }
+ return path;
+ }
+
+/* public boolean isWorkspaceBuildPath(){
+ String path = getBuildPathAttribute();
+ if(path == null)
+ return true;
+
+ if(isWorkspaceBuildPath == null){
+ if(superClass != null)
+ return superClass.isWorkspaceBuildPath();
+ return true;
+ }
+ return isWorkspaceBuildPath.booleanValue();
+ }
+*/
+ public IPath getBuildLocation() {
+ String path = getBuildPath();
+
+ IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
+
+ try {
+ path = provider.resolveValue(path, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, getMacroContextData());
+ } catch (BuildMacroException e) {
+ }
+
+ return new Path(path);
+ }
+
+ public boolean isDefaultBuildCmd() {
+ return isExtensionBuilder || (command == null && args == null && superClass != null);
+ }
+
+ public boolean isStopOnError() {
+ if(stopOnErr == null){
+ if(superClass != null){
+ return superClass.isStopOnError();
+ }
+ return true;
+ }
+ return stopOnErr.booleanValue();
+ }
+
+ public void setBuildArguments(String args) throws CoreException {
+ setArguments(args);
+ }
+
+ public void setBuildCommand(IPath command) throws CoreException {
+ String cmd = command != null ? command.toString() : null;
+ setCommand(cmd);
+ }
+
+ public void setBuildLocation(IPath location) throws CoreException {
+ String path = location != null ? location.toString() : null;
+ setBuildPath(path);
+ }
+
+ public void setStopOnError(boolean on) throws CoreException {
+ if(isStopOnError() == on)
+ return;
+
+ if(supportsStopOnError(on)){
+ String curCmd = getStopOnErrCmd(isStopOnError());
+ String args = getArgumentsAttribute();
+ String updatedArgs = removeCmd(args, curCmd);
+ if(!updatedArgs.equals(args))
+ setArgumentsAttribute(updatedArgs);
+ stopOnErr = Boolean.valueOf(on);
+ }
+ setDirty(true);
+ }
+
+ public void setUseDefaultBuildCmd(boolean on) throws CoreException {
+ if(!isExtensionBuilder && superClass != null){
+ if(on){
+ command = null;
+ args = null;
+ } else {
+ command = getCommand();
+ }
+ }
+ }
+
+ public String getAutoBuildTargetAttribute() {
+ if(autoBuildTarget == null){
+ if(superClass != null)
+ return ((Builder)superClass).getAutoBuildTargetAttribute();
+ return null;
+ }
+ return autoBuildTarget;
+ }
+
+ public String getAutoBuildTarget() {
+ String attr = getAutoBuildTargetAttribute();
+
+ IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
+
+ try {
+ attr = provider.resolveValue(attr, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, getMacroContextData());
+ } catch (BuildMacroException e) {
+ }
+
+ return attr;
+ }
+
+
+ public String getCleanBuildTargetAttribute() {
+ if(cleanBuildTarget == null){
+ if(superClass != null)
+ return ((Builder)superClass).getCleanBuildTargetAttribute();
+ return null;
+ }
+ return cleanBuildTarget;
+ }
+
+ public String getCleanBuildTarget() {
+ String attr = getCleanBuildTargetAttribute();
+
+ IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
+
+ try {
+ attr = provider.resolveValue(attr, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, getMacroContextData());
+ } catch (BuildMacroException e) {
+ }
+
+ return attr;
+ }
+
+
+ public String getFullBuildTarget() {
+ return getIncrementalBuildTarget();
+ }
+
+ public String getIncrementalBuildTargetAttribute() {
+ if(incrementalBuildTarget == null){
+ if(superClass != null)
+ return ((Builder)superClass).getIncrementalBuildTargetAttribute();
+ return null;
+ }
+ return incrementalBuildTarget;
+ }
+
+ public String getIncrementalBuildTarget() {
+ String attr = getIncrementalBuildTargetAttribute();
+
+ IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
+
+ try {
+ attr = provider.resolveValue(attr, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, getMacroContextData());
+ } catch (BuildMacroException e) {
+ }
+
+ return attr;
+ }
+
+ public boolean isAutoBuildEnable() {
+ if(autoBuildEnabled == null){
+ if(superClass != null)
+ return superClass.isAutoBuildEnable();
+ return true;
+ }
+ return autoBuildEnabled.booleanValue();
+ }
+
+ public boolean isCleanBuildEnabled() {
+ if(cleanBuildEnabled == null){
+ if(superClass != null)
+ return superClass.isCleanBuildEnabled();
+ return true;
+ }
+ return cleanBuildEnabled.booleanValue();
+ }
+
+ public boolean isFullBuildEnabled() {
+ return isIncrementalBuildEnabled();
+ }
+
+ public boolean isIncrementalBuildEnabled() {
+ if(incrementalBuildEnabled == null){
+ if(superClass != null)
+ return superClass.isIncrementalBuildEnabled();
+ return true;
+ }
+ return incrementalBuildEnabled.booleanValue();
+ }
+
+ public void setAutoBuildEnable(boolean enabled) throws CoreException {
+ autoBuildEnabled = Boolean.valueOf(enabled);
+ }
+
+ public void setAutoBuildTarget(String target) throws CoreException {
+ autoBuildTarget = target;
+ }
+
+ public void setCleanBuildEnable(boolean enabled) throws CoreException {
+ cleanBuildEnabled = Boolean.valueOf(enabled);
+ }
+
+ public void setCleanBuildTarget(String target) throws CoreException {
+ cleanBuildTarget = target;
+ }
+
+ public void setFullBuildEnable(boolean enabled) throws CoreException {
+ setIncrementalBuildEnable(enabled);
+ }
+
+ public void setFullBuildTarget(String target) throws CoreException {
+ setIncrementalBuildTarget(target);
+ }
+
+ public void setIncrementalBuildEnable(boolean enabled) throws CoreException {
+ incrementalBuildEnabled = Boolean.valueOf(enabled);
+ }
+
+ public void setIncrementalBuildTarget(String target) throws CoreException {
+ incrementalBuildTarget = target;
+ }
+
+ public boolean appendEnvironment() {
+ if(appendEnvironment == null){
+ if(superClass != null){
+ return superClass.appendEnvironment();
+ }
+ return true;
+ }
+ return appendEnvironment.booleanValue();
+ }
+
+ public String getBuildAttribute(String name, String defaultValue) {
+ String result = null;
+ if(BUILD_TARGET_INCREMENTAL.equals(name)){
+ result = getIncrementalBuildTargetAttribute();
+ } else if(BUILD_TARGET_AUTO.equals(name)){
+ result = getAutoBuildTargetAttribute();
+ } else if(BUILD_TARGET_CLEAN.equals(name)){
+ result = getCleanBuildTargetAttribute();
+ } else if(BUILD_LOCATION.equals(name)){
+ result = getBuildPathAttribute();
+ } else if(BUILD_COMMAND.equals(name)){
+ result = getCommand();
+ } else if(BUILD_ARGUMENTS.equals(name)){
+ result = getArguments();
+ } else if(BuilderFactory.BUILD_COMMAND.equals(name)){
+ result = getCommand();
+ } else if(BuilderFactory.BUILD_LOCATION.equals(name)){
+ result = getBuildPathAttribute();
+ } else if(BuilderFactory.STOP_ON_ERROR.equals(name)){
+ result = Boolean.valueOf(isStopOnError()).toString();
+ } else if(BuilderFactory.USE_DEFAULT_BUILD_CMD.equals(name)){
+ result = Boolean.valueOf(isDefaultBuildCmd()).toString();
+ } else if(BuilderFactory.BUILD_TARGET_AUTO.equals(name)){
+ result = getAutoBuildTargetAttribute();
+ } else if(BuilderFactory.BUILD_TARGET_INCREMENTAL.equals(name)){
+ result = getIncrementalBuildTargetAttribute();
+ } else if(BuilderFactory.BUILD_TARGET_FULL.equals(name)){
+ result = getIncrementalBuildTargetAttribute();
+ } else if(BuilderFactory.BUILD_TARGET_CLEAN.equals(name)){
+ result = getCleanBuildTargetAttribute();
+ } else if(BuilderFactory.BUILD_FULL_ENABLED.equals(name)){
+ result = Boolean.valueOf(isFullBuildEnabled()).toString();
+ } else if(BuilderFactory.BUILD_CLEAN_ENABLED.equals(name)){
+ result = Boolean.valueOf(isCleanBuildEnabled()).toString();
+ } else if(BuilderFactory.BUILD_INCREMENTAL_ENABLED.equals(name)){
+ result = Boolean.valueOf(isIncrementalBuildEnabled()).toString();
+ } else if(BuilderFactory.BUILD_AUTO_ENABLED.equals(name)){
+ result = Boolean.valueOf(isAutoBuildEnable()).toString();
+ } else if(BuilderFactory.BUILD_ARGUMENTS.equals(name)){
+ result = getArguments();
+ } else if(BuilderFactory.ENVIRONMENT.equals(name)){
+ result = customizedEnvironment != null ?
+ MapStorageElement.encodeMap(customizedEnvironment) : null;
+ } else if(BuilderFactory.BUILD_APPEND_ENVIRONMENT.equals(name)){
+ result = Boolean.valueOf(appendEnvironment()).toString();
+ } else if(customBuildProperties != null){
+ result = (String)customBuildProperties.get(name);
+ }
+
+ if(result == null)
+ return defaultValue;
+ return result;
+ }
+
+ public static String[] toBuildAttributes(String name) {
+
+ if(ATTRIBUTE_TARGET_INCREMENTAL.equals(name)){
+ return new String[]{BUILD_TARGET_INCREMENTAL, BuilderFactory.BUILD_TARGET_INCREMENTAL, BUILD_TARGET_FULL, BuilderFactory.BUILD_TARGET_FULL};
+ } else if(ATTRIBUTE_TARGET_AUTO.equals(name)){
+ return new String[]{BUILD_TARGET_AUTO, BuilderFactory.BUILD_TARGET_AUTO};
+ } else if(ATTRIBUTE_TARGET_CLEAN.equals(name)){
+ return new String[]{BUILD_TARGET_CLEAN, BuilderFactory.BUILD_TARGET_CLEAN};
+ } else if(ATTRIBUTE_BUILD_PATH.equals(name)){
+ return new String[]{BUILD_LOCATION, BuilderFactory.BUILD_LOCATION};
+ } else if(COMMAND.equals(name)){
+ return new String[]{BUILD_COMMAND, BuilderFactory.BUILD_COMMAND};
+ } else if(ARGUMENTS.equals(name)){
+ return new String[]{BUILD_ARGUMENTS, BuilderFactory.BUILD_ARGUMENTS};
+ } else if(ATTRIBUTE_STOP_ON_ERROR.equals(name)){
+ return new String[]{BuilderFactory.STOP_ON_ERROR};
+ } //TODO else if(BuilderFactory.USE_DEFAULT_BUILD_CMD.equals(name)){
+ // return getCommand();
+ //}
+ else if(ATTRIBUTE_INCREMENTAL_ENABLED.equals(name)) {
+ return new String[]{BuilderFactory.BUILD_INCREMENTAL_ENABLED, BuilderFactory.BUILD_FULL_ENABLED};
+ } else if(ATTRIBUTE_CLEAN_ENABLED.equals(name)){
+ return new String[]{BuilderFactory.BUILD_CLEAN_ENABLED};
+ } else if(ATTRIBUTE_AUTO_ENABLED.equals(name)){
+ return new String[]{BuilderFactory.BUILD_AUTO_ENABLED};
+ } else if(ATTRIBUTE_ENVIRONMENT.equals(name)){
+ return new String[]{BuilderFactory.ENVIRONMENT};
+ } else if(ATTRIBUTE_APPEND_ENVIRONMENT.equals(name)){
+ return new String[]{BuilderFactory.BUILD_APPEND_ENVIRONMENT};
+ } else if(ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS.equals(name)){
+ return new String[]{ErrorParserManager.PREF_ERROR_PARSER};
+ }
+
+ return new String[0];
+ }
+
+
+
+ public Map getEnvironment() {
+ if(customizedEnvironment != null)
+ return (HashMap)customizedEnvironment.clone();
+ return null;
+ }
+
+ public Map getExpandedEnvironment() throws CoreException {
+ if(customizedEnvironment != null){
+ Map expanded = (HashMap)customizedEnvironment.clone();
+ ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
+ String separator = CCorePlugin.getDefault().getBuildEnvironmentManager().getDefaultDelimiter();
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(getParent().getParent());
+ for(Iterator iter = expanded.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String value = (String)entry.getValue();
+ try {
+ value = mngr.resolveValue(value, "", separator, cfgDes);
+ entry.setValue(value);
+ } catch (CdtVariableException e){
+ }
+ }
+
+ return expanded;
+ }
+ return null;
+ }
+
+ public void setAppendEnvironment(boolean append) throws CoreException {
+ appendEnvironment = Boolean.valueOf(append);
+ }
+
+ public void setBuildAttribute(String name, String value)
+ throws CoreException {
+ if(BUILD_TARGET_INCREMENTAL.equals(name)){
+ incrementalBuildTarget = value;
+ } else if(BUILD_TARGET_AUTO.equals(name)){
+ autoBuildTarget = value;
+ } else if(BUILD_TARGET_CLEAN.equals(name)){
+ cleanBuildTarget = value;
+ } else if(BUILD_LOCATION.equals(name)){
+ buildPath = value;
+ } else if(BUILD_COMMAND.equals(name)){
+ command = value;
+ } else if(BUILD_ARGUMENTS.equals(name)){
+ args = value;
+ } else if(BuilderFactory.BUILD_COMMAND.equals(name)){
+ command = value;
+ } else if(BuilderFactory.BUILD_LOCATION.equals(name)){
+ buildPath = value;
+ } else if(BuilderFactory.STOP_ON_ERROR.equals(name)){
+ stopOnErr = Boolean.valueOf(value);
+ } else if(BuilderFactory.USE_DEFAULT_BUILD_CMD.equals(name)){
+ if(value == null || Boolean.valueOf(value).booleanValue()){
+ if(superClass != null)
+ command = null;
+ }
+ } else if(BuilderFactory.BUILD_TARGET_AUTO.equals(name)){
+ autoBuildTarget = value;
+ } else if(BuilderFactory.BUILD_TARGET_INCREMENTAL.equals(name)){
+ incrementalBuildTarget = value;
+ } else if(BuilderFactory.BUILD_TARGET_FULL.equals(name)){
+ autoBuildTarget = value;
+ } else if(BuilderFactory.BUILD_TARGET_CLEAN.equals(name)){
+ cleanBuildTarget = value;
+ } else if(BuilderFactory.BUILD_FULL_ENABLED.equals(name)){
+ autoBuildEnabled = value != null ?
+ Boolean.valueOf(value) : null;
+ } else if(BuilderFactory.BUILD_CLEAN_ENABLED.equals(name)){
+ cleanBuildEnabled = value != null ?
+ Boolean.valueOf(value) : null;
+ } else if(BuilderFactory.BUILD_INCREMENTAL_ENABLED.equals(name)){
+ incrementalBuildEnabled = value != null ?
+ Boolean.valueOf(value) : null;
+ } else if(BuilderFactory.BUILD_AUTO_ENABLED.equals(name)){
+ autoBuildEnabled = value != null ?
+ Boolean.valueOf(value) : null;
+ } else if(BuilderFactory.BUILD_ARGUMENTS.equals(name)){
+ args = value;
+ } else if(BuilderFactory.ENVIRONMENT.equals(name)){
+ if(value == null){
+ customizedEnvironment = null;
+ } else {
+ customizedEnvironment = (HashMap)MapStorageElement.decodeMap(value);
+ }
+ } else if(BuilderFactory.BUILD_APPEND_ENVIRONMENT.equals(name)){
+ appendEnvironment = value != null ?
+ Boolean.valueOf(value) : null;
+ } else {
+ getCustomBuildPropertiesMap().put(name, value);
+ }
+ }
+
+ private Map getCustomBuildPropertiesMap(){
+ if(customBuildProperties == null){
+ customBuildProperties = new HashMap();
+ }
+ return customBuildProperties;
+ }
+
+ public void setEnvironment(Map env) throws CoreException {
+ customizedEnvironment = new HashMap(env);
+ }
+
+ public boolean isCustomBuilder() {
+ if(!isExtensionBuilder && getParent().getBuilder() != this)
+ return true;
+ return false;
+ }
+
+ public IConfiguration getConfguration(){
+ if(getParent() != null)
+ return getParent().getParent();
+ return null;
+ }
+
+ public boolean isManagedBuildOn() {
+ IConfiguration cfg = getConfguration();
+ if(cfg != null){
+ if(!cfg.supportsBuild(true))
+ return false;
+ else if(!cfg.supportsBuild(false))
+ return true;
+ }
+ if(managedBuildOn == null){
+ if(superClass != null)
+ return superClass.isManagedBuildOn();
+ return true;
+ }
+ return managedBuildOn.booleanValue();
+ }
+
+ public void setManagedBuildOn(boolean on) throws CoreException {
+ managedBuildOn = Boolean.valueOf(on);
+ }
+
+ public boolean canKeepEnvironmentVariablesInBuildfile() {
+ return BuildMacroProvider.canKeepMacrosInBuildfile(this);
+ }
+
+ public boolean keepEnvironmentVariablesInBuildfile() {
+ if(keepEnvVarInBuildfile == null){
+ if(superClass != null)
+ return superClass.keepEnvironmentVariablesInBuildfile();
+ return false;
+ }
+ return keepEnvVarInBuildfile.booleanValue();
+ }
+
+ public void setKeepEnvironmentVariablesInBuildfile(boolean keep) {
+ keepEnvVarInBuildfile = Boolean.valueOf(keep);
+ }
+
+ public boolean supportsCustomizedBuild() {
+ if(fSupportsCustomizedBuild == null){
+ IManagedBuilderMakefileGenerator makeGen = getBuildFileGenerator();
+ if(makeGen instanceof IManagedBuilderMakefileGenerator2)
+ fSupportsCustomizedBuild = Boolean.valueOf(true);
+ else
+ fSupportsCustomizedBuild = Boolean.valueOf(false);
+ }
+ return fSupportsCustomizedBuild.booleanValue();
+ }
+
+ public boolean supportsBuild(boolean managed) {
+ if(supportsManagedBuild == null){
+ if(superClass != null)
+ return superClass.supportsBuild(managed);
+ return managed || !isInternalBuilder();
+ }
+ return supportsManagedBuild.booleanValue();
+ }
+
+ public void setParent(IToolChain toolChain){
+ parent = toolChain;
+ }
+
+ public boolean matches(IBuilder builder){
+ if(builder == this)
+ return true;
+
+ IBuilder rBld = ManagedBuildManager.getRealBuilder(this);
+ if(rBld == null)
+ return false;
+
+ return rBld == ManagedBuildManager.getRealBuilder(builder);
+ }
+
+ public boolean performMatchComparison(IBuilder builder){
+ if(builder == null)
+ return false;
+
+ if(builder == this)
+ return true;
+
+// if(tool.isReal() && isReal())
+// return false;
+// if(!tool.getToolCommand().equals(getToolCommand()))
+// return false;
+
+ if(!builder.getName().equals(getName()))
+ return false;
+
+ String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(builder.getId());
+ if(thisVersion == null || thisVersion.length() == 0){
+ if(otherVersion != null && otherVersion.length() != 0)
+ return false;
+ } else {
+ if(!thisVersion.equals(otherVersion))
+ return false;
+ }
+
+ return true;
+ }
+
+ private class MatchKey {
+ Builder builder;
+
+ public MatchKey(Builder builder) {
+ this.builder = builder;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+ if(!(obj instanceof MatchKey))
+ return false;
+ MatchKey other = (MatchKey)obj;
+ return builder.performMatchComparison(other.builder);
+ }
+
+ public int hashCode() {
+ String name = getName();
+ if(name == null)
+ name = getId();
+ int code = name.hashCode();
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null)
+ code += version.hashCode();
+ return code;
+ }
+
+ }
+
+ public Object getMatchKey() {
+ if(isAbstract())
+ return null;
+ if(!isExtensionBuilder)
+ return null;
+ return new MatchKey(this);
+ }
+
+ public void setIdenticalList(List list) {
+ identicalList = list;
+ }
+
+ public String getNameAndVersion(){
+ String name = getName();
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null && version.length() != 0){
+ return new StringBuffer().append(name).append(" (").append(version).append("").toString();
+ }
+ return name;
+ }
+
+ public List getIdenticalList() {
+ return identicalList;
+ }
+
+ public boolean isInternalBuilder() {
+ IBuilder internalBuilder = ManagedBuildManager.getInternalBuilder();
+ for(IBuilder builder = this; builder != null; builder = builder.getSuperClass()){
+ if(internalBuilder == builder)
+ return true;
+ }
+ return false;
+ }
+
+ public int getParallelizationNum() {
+ if(supportsParallelBuild())
+ return getParallelizationNumAttribute();
+ return 1;
+ }
+
+ public int getParallelizationNumAttribute(){
+ if(parallelNum == null){
+ if(superClass != null){
+ return ((Builder)superClass).getParallelizationNumAttribute();
+ }
+ return 1;
+ }
+ return parallelNum.intValue();
+ }
+
+ public void setParallelizationNum(int num) throws CoreException {
+// if(num == 0 || supportsParallelBuild()){
+ parallelNum = new Integer(num);
+ String curCmd = getParallelizationCmd(getParallelizationNum());
+ String args = getArgumentsAttribute();
+ String updatedArgs = removeCmd(args, curCmd);
+ if(!updatedArgs.equals(args)){
+ setArgumentsAttribute(updatedArgs);
+ }
+ setDirty(true);
+// }
+ }
+
+ public boolean supportsParallelBuild() {
+ if(isInternalBuilder())
+ return true;
+ return getParrallelBuildCmd().length() != 0;
+ }
+
+ public boolean supportsStopOnError(boolean on) {
+ if(isInternalBuilder())
+ return true;
+
+ if(!on)
+ return getIgnoreErrCmdAttribute().length() != 0;
+ return true;
+ }
+
+ public String getStopOnErrCmd(boolean stop){
+ if(!stop)
+ return getIgnoreErrCmdAttribute();
+ return EMPTY_STRING;
+ }
+
+ public String getIgnoreErrCmdAttribute(){
+ if(ignoreErrCmd == null){
+ if(superClass != null){
+ return ((Builder)superClass).getIgnoreErrCmdAttribute();
+ }
+ return EMPTY_STRING;
+ }
+ return ignoreErrCmd;
+ }
+
+ public String getParrallelBuildCmd(){
+ if(parallelBuildCmd == null){
+ if(superClass != null){
+ return ((Builder)superClass).getParrallelBuildCmd();
+ }
+ return EMPTY_STRING;
+ }
+ return parallelBuildCmd;
+ }
+
+ public boolean isParallelBuildOn() {
+ if(parallelBuildOn == null){
+ if(superClass != null){
+ return superClass.isParallelBuildOn();
+ }
+ return false;
+ }
+ return parallelBuildOn.booleanValue();
+ }
+
+ public void setParallelBuildOn(boolean on) throws CoreException{
+ if(isParallelBuildOn() == on)
+ return;
+ if(on && !supportsParallelBuild())
+ return;
+
+ String curCmd = getParallelizationCmd(getParallelizationNum());
+ String args = getArgumentsAttribute();
+ String updatedArgs = removeCmd(args, curCmd);
+ if(!updatedArgs.equals(args)){
+ setArgumentsAttribute(updatedArgs);
+ }
+ parallelBuildOn = Boolean.valueOf(on);
+ setDirty(true);
+ }
+
+ public Set contributeErrorParsers(Set set){
+ if(set == null)
+ set = new HashSet();
+
+ String ids[] = getErrorParserList();
+ if(ids.length != 0)
+ set.addAll(Arrays.asList(ids));
+ return set;
+ }
+
+ public void resetErrorParsers(){
+ errorParserIds = null;
+ }
+
+ void removeErrorParsers(Set set){
+ Set oldSet = contributeErrorParsers(null);
+ oldSet.removeAll(set);
+ setErrorParserList((String[])oldSet.toArray(new String[oldSet.size()]));
+ }
+
+ public void setErrorParserList(String[] ids) {
+ if(ids == null){
+ errorParserIds = null;
+ } else if(ids.length == 0){
+ errorParserIds = EMPTY_STRING;
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append(ids[0]);
+ for(int i = 1; i < ids.length; i++){
+ buf.append(";").append(ids[i]);
+ }
+ errorParserIds = buf.toString();
+ }
+ }
+
+ public boolean isSystemObject() {
+ if(isTest)
+ return true;
+ if(getParent() != null)
+ return getParent().isSystemObject();
+ return false;
+ }
+
+ public String getUniqueRealName() {
+ String name = getName();
+ if(name == null){
+ name = getId();
+ } else {
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null){
+ StringBuffer buf = new StringBuffer();
+ buf.append(name);
+ buf.append(" (v").append(version).append(")");
+ name = buf.toString();
+ }
+ }
+ return name;
+ }
+
+ public ICOutputEntry[] getOutputEntries(){
+ if(isManagedBuildOn()){
+ return getDefaultOutputSettings(true);
+ }
+ ICOutputEntry[] entries = getOutputEntrySettings();
+ if(entries == null || entries.length == 0){
+ entries = getDefaultOutputSettings(false);
+ }
+ return entries;
+ }
+
+ private ICOutputEntry[] getDefaultOutputSettings(boolean managedBuildOn){
+ Configuration cfg = (Configuration)getConfguration();
+ if(cfg == null || cfg.isPreference() || cfg.isExtensionElement()){
+ return new ICOutputEntry[]{new COutputEntry(Path.EMPTY, null, ICLanguageSettingEntry.VALUE_WORKSPACE_PATH | ICLanguageSettingEntry.RESOLVED)};
+ }
+
+ IPath path = cfg.getOwner().getProject().getFullPath();;
+ if(managedBuildOn){
+ path = path.append(cfg.getName());
+ }
+ return new ICOutputEntry[]{new COutputEntry(path, null, ICLanguageSettingEntry.VALUE_WORKSPACE_PATH | ICLanguageSettingEntry.RESOLVED)};
+ }
+
+ public ICOutputEntry[] getOutputEntrySettings(){
+ if(outputEntries == null){
+ if(superClass != null){
+ return ((Builder)superClass).getOutputEntrySettings();
+ }
+ return null;
+
+ }
+ return (ICOutputEntry[])outputEntries.clone();
+ }
+
+ public void setOutputEntries(ICOutputEntry[] entries){
+ if(entries != null)
+ outputEntries = (ICOutputEntry[])entries.clone();
+ else
+ outputEntries = null;
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
new file mode 100644
index 00000000000..adf9909e638
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
@@ -0,0 +1,343 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class BuilderFactory {
+
+ private static final String PREFIX = "org.eclipse.cdt.make.core"; //$NON-NLS-1$
+ private static final String PREFIX_WITH_DOT = PREFIX + '.'; //$NON-NLS-1$
+
+ static final String BUILD_COMMAND = PREFIX + ".buildCommand"; //$NON-NLS-1$
+ static final String BUILD_LOCATION = PREFIX + ".buildLocation"; //$NON-NLS-1$
+ static final String STOP_ON_ERROR = PREFIX + ".stopOnError"; //$NON-NLS-1$
+ static final String USE_DEFAULT_BUILD_CMD = PREFIX + ".useDefaultBuildCmd"; //$NON-NLS-1$
+ static final String BUILD_TARGET_AUTO = PREFIX + ".autoBuildTarget"; //$NON-NLS-1$
+ static final String BUILD_TARGET_INCREMENTAL = PREFIX + ".incrementalBuildTarget"; //$NON-NLS-1$
+ static final String BUILD_TARGET_FULL = PREFIX + ".fullBuildTarget"; //$NON-NLS-1$
+ static final String BUILD_TARGET_CLEAN = PREFIX + ".cleanBuildTarget"; //$NON-NLS-1$
+ static final String BUILD_FULL_ENABLED = PREFIX + ".enableFullBuild"; //$NON-NLS-1$
+ static final String BUILD_CLEAN_ENABLED = PREFIX + ".enableCleanBuild"; //$NON-NLS-1$
+ static final String BUILD_INCREMENTAL_ENABLED = PREFIX + ".enabledIncrementalBuild"; //$NON-NLS-1$
+ static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild"; //$NON-NLS-1$
+ static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments"; //$NON-NLS-1$
+ static final String ENVIRONMENT = PREFIX + ".environment"; //$NON-NLS-1$
+ static final String BUILD_APPEND_ENVIRONMENT = PREFIX + ".append_environment"; //$NON-NLS-1$
+
+ static final String CONTENTS = PREFIX + ".contents"; //$NON-NLS-1$
+ static final String CONTENTS_BUILDER = PREFIX + ".builder"; //$NON-NLS-1$
+// static final String CONTENTS_BUILDER_CUSTOMIZATION = PREFIX + ".builderCustomization"; //$NON-NLS-1$
+ static final String CONTENTS_CONFIGURATION_IDS = PREFIX + ".configurationIds"; //$NON-NLS-1$
+
+// static final String IDS = PREFIX + ".ids"; //$NON-NLS-1$
+ static final String CONFIGURATION_IDS = PREFIX + ".configurationIds"; //$NON-NLS-1$
+
+ static final IBuilder[] EMPTY_BUILDERS_ARRAY = new IBuilder[0];
+ static final String[] EMPTY_STRING_ARRAY = new String[0];
+ static final IConfiguration[] EMPTY_CFG_ARAY = new IConfiguration[0];
+
+ private static class BuildArgsStorageElement extends MapStorageElement{
+
+ public BuildArgsStorageElement(Map map, MapStorageElement parent) {
+ super(map, parent);
+ }
+
+ public BuildArgsStorageElement(String name, MapStorageElement parent) {
+ super(name, parent);
+ }
+
+ public String getAttribute(String name) {
+ String value = super.getAttribute(name);
+ if(value == null){
+ String keys[] = Builder.toBuildAttributes(name);
+ for(int i = 0; i < keys.length; i++){
+ value = super.getAttribute(keys[i]);
+ if(value != null)
+ break;
+ }
+ }
+ return value;
+ }
+
+// protected String getMapKey(String name) {
+// if(name.indexOf('.') == -1)
+// return PREFIX_WITH_DOT + name;
+// return super.getMapKey(name);
+// }
+
+ protected MapStorageElement createChildElement(Map childMap) {
+ return new BuildArgsStorageElement(childMap, this);
+ }
+
+ protected MapStorageElement createChildElement(String name) {
+ return new BuildArgsStorageElement(name, this);
+ }
+ }
+
+/* public static IMakeBuilderInfo create(Preferences prefs, String builderID, boolean useDefaults) {
+ return new BuildInfoPreference(prefs, builderID, useDefaults);
+ }
+
+ public static IMakeBuilderInfo create(IProject project, String builderID) throws CoreException {
+ return new BuildInfoProject(project, builderID);
+ }
+
+ public static IMakeBuilderInfo create(Map args, String builderID) {
+ return new BuildInfoMap(args, builderID);
+ }
+ */
+/*
+ private static IBuilder customizeBuilder(IBuilder builder, Map args){
+ if(args.get(IBuilder.ID) == null){
+ args = new HashMap(args);
+ String id = builder.getSuperClass().getId();
+ id = ManagedBuildManager.calculateChildId(id, null);
+ args.put(IBuilder.ID, id);
+ }
+ MapStorageElement el = new MapStorageElement(args, null);
+
+ Builder builder = new Builder(builder.getParent(), )
+
+
+ }
+*/
+
+ public static Map createBuildArgs(IConfiguration cfgs[], IBuilder builder){
+ Map map = builderToMap(builder);
+ cfgsToMap(cfgs, map);
+ map.put(CONTENTS, /*CONTENTS_BUILDER_CUSTOMIZATION*/CONTENTS_BUILDER);
+ return map;
+ }
+
+ public static Map createBuildArgs(IConfiguration cfgs[]){
+ Map map = new HashMap();
+ cfgsToMap(cfgs, map);
+ map.put(CONTENTS, CONTENTS_CONFIGURATION_IDS);
+ return map;
+ }
+
+ private static Map cfgIdsToMap(String ids[], Map map){
+ map.put(CONFIGURATION_IDS, MapStorageElement.encodeList(Arrays.asList(ids)));
+ return map;
+ }
+
+ private static String[] cfgIdsFromMap(Map map){
+ String idsString = (String)map.get(CONFIGURATION_IDS);
+ if(idsString != null){
+ List list = MapStorageElement.decodeList(idsString);
+ return (String[])list.toArray(new String[list.size()]);
+ }
+ return EMPTY_STRING_ARRAY;
+ }
+
+ private static IConfiguration[] configsFromMap(Map map, IManagedBuildInfo info){
+ String ids[] = cfgIdsFromMap(map);
+ if(ids.length == 0){
+ IConfiguration cfg = info.getDefaultConfiguration();
+ if(cfg != null)
+ return new IConfiguration[]{cfg};
+ return EMPTY_CFG_ARAY;
+ }
+ IManagedProject mProj = info.getManagedProject();
+ if(mProj != null)
+ return idsToConfigurations(ids, mProj.getConfigurations());
+ return EMPTY_CFG_ARAY;
+ }
+
+ private static IConfiguration[] idsToConfigurations(String ids[], IConfiguration allCfgs[]){
+ List list = new ArrayList(ids.length);
+ for(int i = 0; i < ids.length; i++){
+ String id = ids[i];
+ for(int j = 0; j < allCfgs.length; j++){
+ if(allCfgs[j].getId().equals(id)){
+ list.add(allCfgs[j]);
+ break;
+ }
+ }
+ }
+ return (IConfiguration[])list.toArray(new IConfiguration[list.size()]);
+ }
+
+ private static Map cfgsToMap(IConfiguration cfgs[], Map map){
+ String ids[] = getCfgIds(cfgs);
+ return cfgIdsToMap(ids, map);
+ }
+
+ private static String[] getCfgIds(IConfiguration cfgs[]){
+ String ids[] = new String[cfgs.length];
+ for(int i = 0; i < cfgs.length; i++){
+ ids[i] = cfgs[i].getId();
+ }
+ return ids;
+ }
+
+ private static Map builderToMap(IBuilder builder){
+ MapStorageElement el = new MapStorageElement("", null);
+ ((Builder)builder).serialize(el, false);
+
+ return el.toStringMap();
+ }
+
+ public static IBuilder createCustomBuilder(IConfiguration cfg, String builderId) throws CoreException{
+ IBuilder builder = cfg.getBuilder();
+ if(!builderId.equals(builder.getId())){
+ builder = ManagedBuildManager.getExtensionBuilder(builderId);
+ }
+
+ if(builder != null)
+ return createCustomBuilder(cfg, builder);
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ "can not find builder with the specified id", null));
+ }
+
+ public static IBuilder createCustomBuilder(IConfiguration cfg, IBuilder base){
+ String subId;
+ String subName = base.getName();
+ if (base.getSuperClass() != null) {
+ subId = ManagedBuildManager.calculateChildId(
+ base.getSuperClass().getId(),
+ null);
+ } else {
+ subId = ManagedBuildManager.calculateChildId(
+ base.getId(),
+ null);
+ }
+
+ return new Builder(cfg.getToolChain(), subId, subName, (Builder)base);
+ }
+
+ public static IBuilder createBuilderFromCommand(IConfiguration cfg, ICommand command){
+ Map args = command.getArguments();
+ if(!args.containsKey(IBuilder.ID)){
+ args.put(IBuilder.ID, ManagedBuildManager.calculateChildId(command.getBuilderName(), null));
+ }
+
+ return createBuilder(cfg, args);
+ }
+
+ public static IBuilder createBuilderForEclipseBuilder(IConfiguration cfg, String eclipseBuilderID) throws CoreException {
+ IProject project = cfg.getOwner().getProject();
+ ICommand command = getBuildSpec(project.getDescription(), eclipseBuilderID);
+ if (command == null) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ MakeMessages.getString("BuildInfoFactory.Missing_Builder") + eclipseBuilderID, null)); //$NON-NLS-1$
+ }
+
+ return createBuilderFromCommand(cfg, command);
+// Map args = command.getArguments();
+// if(!args.containsKey(IBuilder.ID)){
+// args.put(IBuilder.ID, ManagedBuildManager.calculateChildId(eclipseBuilderID, null));
+// }
+//
+// return createBuilder(cfg, args);
+ }
+
+ public static ICommand getBuildSpec(IProjectDescription description, String builderID) {
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ if (commands[i].getBuilderName().equals(builderID)) {
+ return commands[i];
+ }
+ }
+ return null;
+ }
+
+
+
+ private static IBuilder createBuilder(IConfiguration cfg, Map args){
+ IToolChain tCh = cfg.getToolChain();
+ MapStorageElement el = new BuildArgsStorageElement(args, null);
+ Builder builder = new Builder(tCh, el, ManagedBuildManager.getVersion().toString());
+ return builder;
+ }
+
+ public static IBuilder[] createBuilders(IProject project, Map args){
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IBuilder[] builders = null;
+ if(info != null){
+ if(args == null){
+ IConfiguration cfg = info.getDefaultConfiguration();
+ IBuilder builder = cfg.getEditableBuilder();
+ builders = new IBuilder[]{builder};
+ } else {
+ String type = (String)args.get(CONTENTS);
+ if(type == null){
+ IConfiguration cfg = info.getDefaultConfiguration();
+ IBuilder builder = cfg.getEditableBuilder();
+ builders = new IBuilder[]{builder};
+ //TODO:
+ } else if (CONTENTS_BUILDER.equals(type)){
+ IConfiguration cfgs[] = configsFromMap(args, info);
+ if(cfgs.length != 0){
+ List list = new ArrayList(cfgs.length);
+ for(int i = 0; i < cfgs.length; i++){
+ IBuilder builder = createBuilder(cfgs[i], args);
+ if(builder != null)
+ list.add(builder);
+ }
+ builders = (IBuilder[])list.toArray(new IBuilder[list.size()]);
+ }
+ } else if (CONTENTS_CONFIGURATION_IDS.equals(type)){
+ IConfiguration cfgs[] = configsFromMap(args, info);
+ if(cfgs.length != 0){
+ List list = new ArrayList(cfgs.length);
+ for(int i = 0; i < cfgs.length; i++){
+ list.add(cfgs[i].getEditableBuilder());
+ }
+ builders = (IBuilder[])list.toArray(new IBuilder[list.size()]);
+ }
+ } /*else if (CONTENTS_BUILDER_CUSTOMIZATION.equals(type)){
+ String idsString = (String)args.get(CONFIGURATION_IDS);
+ if(idsString != null){
+ String[] ids = CDataUtil.stringToArray(idsString, SEPARATOR);
+ if(ids.length != 0){
+ IManagedProject mProj = info.getManagedProject();
+ List list = new ArrayList(ids.length);
+ for(int i = 0; i < ids.length; i++){
+ IConfiguration cfg = mProj.getConfiguration(ids[i]);
+ if(cfg != null){
+ IBuilder builder = customizeBuilder(cfg.getEditableBuilder(), args);
+ if(builder != null)
+ list.add(builder);
+ }
+ }
+ builders = (IBuilder[])list.toArray(new IBuilder[list.size()]);
+ }
+ }
+ }*/
+ }
+ }
+
+ if(builders != null)
+ return builders;
+ return EMPTY_BUILDERS_ARRAY;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
new file mode 100644
index 00000000000..af6ca83cd34
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
@@ -0,0 +1,1612 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.resources.ACBuilder;
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.util.ListComparator;
+import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
+import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
+import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
+import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType;
+import org.eclipse.cdt.managedbuilder.buildmodel.IBuildResource;
+import org.eclipse.cdt.managedbuilder.buildmodel.IBuildStep;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.buildmodel.DescriptionBuilder;
+import org.eclipse.cdt.managedbuilder.internal.buildmodel.IBuildModelBuilder;
+import org.eclipse.cdt.managedbuilder.internal.buildmodel.ParallelBuilder;
+import org.eclipse.cdt.managedbuilder.internal.buildmodel.StepBuilder;
+import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator2;
+import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
+import org.eclipse.cdt.newmake.internal.core.MakeMessages;
+import org.eclipse.cdt.newmake.internal.core.StreamMonitor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IResourceRuleFactory;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+
+public class CommonBuilder extends ACBuilder {
+
+ public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".commonBuilder"; //$NON-NLS-1$
+ private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$
+ private static final String BUILD_FINISHED = "ManagedMakeBuilder.message.finished"; //$NON-NLS-1$
+ private static final String CONSOLE_HEADER = "ManagedMakeBuilder.message.console.header"; //$NON-NLS-1$
+ private static final String ERROR_HEADER = "GeneratedmakefileBuilder error ["; //$NON-NLS-1$
+ private static final String MAKE = "ManagedMakeBuilder.message.make"; //$NON-NLS-1$
+ private static final String MARKERS = "ManagedMakeBuilder.message.creating.markers"; //$NON-NLS-1$
+ private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
+ private static final String NOTHING_BUILT = "ManagedMakeBuilder.message.no.build"; //$NON-NLS-1$
+ private static final String REFRESH = "ManagedMakeBuilder.message.updating"; //$NON-NLS-1$
+ private static final String REFRESH_ERROR = BUILD_ERROR + ".refresh"; //$NON-NLS-1$
+ private static final String TRACE_FOOTER = "]: "; //$NON-NLS-1$
+ private static final String TRACE_HEADER = "GeneratedmakefileBuilder trace ["; //$NON-NLS-1$
+ private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
+ private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
+ private static final String WARNING_UNSUPPORTED_CONFIGURATION = "ManagedMakeBuilder.warning.unsupported.configuration"; //$NON-NLS-1$
+ private static final String BUILD_CANCELLED = "ManagedMakeBuilder.message.cancelled"; //$NON-NLS-1$
+ private static final String BUILD_FINISHED_WITH_ERRS = "ManagedMakeBuilder.message.finished.with.errs"; //$NON-NLS-1$
+ private static final String BUILD_FAILED_ERR = "ManagedMakeBuilder.message.internal.builder.error"; //$NON-NLS-1$
+ private static final String BUILD_STOPPED_ERR = "ManagedMakeBuilder.message.stopped.error"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER_HEADER_NOTE = "ManagedMakeBuilder.message.internal.builder.header.note"; //$NON-NLS-1$
+ private static final String TYPE_REBUILD = "ManagedMakeBuider.type.rebuild"; //$NON-NLS-1$
+ private static final String INTERNAL_BUILDER = "ManagedMakeBuilder.message.internal.builder"; //$NON-NLS-1$
+ public static boolean VERBOSE = false;
+
+
+ public CommonBuilder() {
+ }
+
+ public static void outputTrace(String resourceName, String message) {
+ if (VERBOSE) {
+ System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
+ }
+ }
+
+ public static void outputError(String resourceName, String message) {
+ if (VERBOSE) {
+ System.err.println(ERROR_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
+ }
+ }
+
+ public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ private String buildGoalName;
+ private IProject project;
+ private IConfiguration cfg;
+ private IConfiguration allConfigs[];
+ private IPath buildPaths[];
+ private boolean incrBuildNeeded = false;
+ private boolean fullBuildNeeded = false;
+ private List reservedNames;
+
+ /**
+ *
+ */
+ public ResourceDeltaVisitor(IConfiguration cfg, IConfiguration allConfigs[]) {
+ this.cfg = cfg;
+ this.project = cfg.getOwner().getProject();
+ this.allConfigs = allConfigs;
+ buildPaths = new IPath[allConfigs.length];
+ for(int i = 0; i < buildPaths.length; i++){
+ buildPaths[i] = ManagedBuildManager.getBuildFullPath(allConfigs[i], allConfigs[i].getBuilder());
+ }
+ String ext = cfg.getArtifactExtension();
+ //try to resolve build macros in the build artifact extension
+ try{
+ ext = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ ext,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ cfg);
+ } catch (BuildMacroException e){
+ }
+
+ String name = cfg.getArtifactName();
+ //try to resolve build macros in the build artifact name
+ try{
+ String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ name,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ cfg);
+ if((resolved = resolved.trim()).length() > 0)
+ name = resolved;
+ } catch (BuildMacroException e){
+ }
+
+ if (ext.length() > 0) {
+ buildGoalName = cfg.getOutputPrefix(ext) + name + IManagedBuilderMakefileGenerator.DOT + ext;
+ } else {
+ buildGoalName = name;
+ }
+ reservedNames = Arrays.asList(new String[]{".cdtbuild", ".cdtproject", ".project"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ * @param changedResource
+ * @return
+ */
+ private boolean isGeneratedResource(IResource resource) {
+ // Is this a generated directory ...
+ IPath path = resource.getFullPath();
+ for (int i = 0; i < buildPaths.length; i++) {
+ if(buildPaths[i] != null && buildPaths[i].isPrefixOf(path)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param resource
+ * @return
+ */
+ private boolean isProjectFile(IResource resource) {
+ return reservedNames.contains(resource.getName());
+ }
+
+ public boolean shouldBuildIncr() {
+ return incrBuildNeeded;
+ }
+
+ public boolean shouldBuildFull() {
+ return fullBuildNeeded;
+ }
+
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IResource resource = delta.getResource();
+ // If the project has changed, then a build is needed and we can stop
+ if (resource != null && resource.getProject() == project) {
+ switch(resource.getType()){
+ case IResource.FILE:
+ String name = resource.getName();
+ if ((!name.equals(buildGoalName) &&
+ // TODO: Also need to check for secondary outputs
+ (resource.isDerived() ||
+ (isProjectFile(resource)) ||
+ (isGeneratedResource(resource))))) {
+ // The resource that changed has attributes which make it uninteresting,
+ // so don't do anything
+ ;
+ }
+ else {
+ // TODO: Should we do extra checks here to determine if a build is really needed,
+ // or do you just do exclusion checks like above?
+ // We could check for:
+ // o The build goal name
+ // o A secondary output
+ // o An input file to a tool:
+ // o Has an extension of a source file used by a tool
+ // o Has an extension of a header file used by a tool
+ // o Has the name of an input file specified in an InputType via:
+ // o An Option
+ // o An AdditionalInput
+ //
+ //if (resourceName.equals(buildGoalName) ||
+ // (buildInfo.buildsFileType(ext) || buildInfo.isHeaderFile(ext))) {
+
+ // We need to do an incremental build, at least
+ incrBuildNeeded = true;
+ if (delta.getKind() == IResourceDelta.REMOVED) {
+ // If a meaningful resource was removed, then force a full build
+ // This is required because an incremental build will trigger make to
+ // do nothing for a missing source, since the state after the file
+ // removal is uptodate, as far as make is concerned
+ // A full build will clean, and ultimately trigger a relink without
+ // the object generated from the deleted source, which is what we want
+ fullBuildNeeded = true;
+ // There is no point in checking anything else since we have
+ // decided to do a full build anyway
+ break;
+ }
+
+ //}
+ }
+
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ private static class OtherConfigVerifier implements IResourceDeltaVisitor {
+ IBuilder builders[];
+ IPath buildFullPaths[];
+// IConfiguration buildConfigs[];
+ IConfiguration allConfigs[];
+ Configuration otherConfigs[];
+ int resourceChangeState;
+
+ private static final IPath[] ignoreList = {
+ new Path(".cdtproject"), //$NON-NLS-1$
+ new Path(".cproject"), //$NON-NLS-1$
+ new Path(".cdtbuild"), //$NON-NLS-1$
+ new Path(".settings"), //$NON-NLS-1$
+ };
+
+ OtherConfigVerifier(IBuilder builders[], IConfiguration allCfgs[]){
+ this.builders = builders;
+ allConfigs = allCfgs;
+ Set buildCfgSet = new HashSet();
+ for(int i = 0; i < builders.length; i++){
+ buildCfgSet.add(builders[i].getParent().getParent());
+ }
+ List othersList = ListComparator.getAdded(allCfgs, buildCfgSet.toArray());
+ if(othersList != null)
+ otherConfigs = (Configuration[])othersList.toArray(new Configuration[othersList.size()]);
+ else
+ otherConfigs = new Configuration[0];
+
+ List list = new ArrayList(builders.length);
+// buildFullPaths = new IPath[builders.length];
+ for(int i = 0; i < builders.length; i++){
+ IPath path = ManagedBuildManager.getBuildFullPath(builders[i].getParent().getParent(), builders[i]);
+ if(path != null)
+ list.add(path);
+// buildFullPaths[i] = ManagedBuildManager.getBuildFullPath(builders[i].getParent().getParent(), builders[i]);
+ }
+ buildFullPaths = (IPath[])list.toArray(new IPath[list.size()]);
+
+ }
+
+ public boolean visit(IResourceDelta delta) throws CoreException {
+
+ IResource rc = delta.getResource();
+ if(rc.getType() == IResource.FILE){
+ if(isResourceValuable(rc))
+ resourceChangeState |= delta.getKind();
+ return false;
+ }
+
+ if(!isResourceValuable(rc))
+ return false;
+ for(int i = 0; i < buildFullPaths.length; i++){
+ if(buildFullPaths[i].isPrefixOf(rc.getFullPath()))
+ return false;
+ }
+ return true;
+ }
+
+ public void updateOtherConfigs(IResourceDelta delta){
+ if(delta == null)
+ resourceChangeState = ~0;
+ else {
+ try {
+ delta.accept(this);
+ } catch (CoreException e) {
+ resourceChangeState = ~0;
+ }
+ }
+
+ setResourceChangeStateForOtherConfigs();
+ }
+
+ private void setResourceChangeStateForOtherConfigs(){
+ for(int i = 0; i < otherConfigs.length; i++){
+ otherConfigs[i].addResourceChangeState(resourceChangeState);
+ }
+ }
+
+ private boolean isResourceValuable(IResource rc){
+ IPath path = rc.getProjectRelativePath();
+ for(int i = 0; i < ignoreList.length; i++){
+ if(ignoreList[i].equals(path))
+ return false;
+ }
+ return true;
+ }
+ }
+
+ /**
+ * @see IncrementalProjectBuilder#build
+ */
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
+ IBuilder builders[] = BuilderFactory.createBuilders(getProject(), args);
+ int num = builders.length;
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ IConfiguration activeCfg = info.getDefaultConfiguration();
+ if(num != 0){
+
+ MultiStatus status = checkBuilders(builders, activeCfg);
+ if(status.getSeverity() != IStatus.OK)
+ throw new CoreException(status);
+
+ IConfiguration cfgs[] = getReferencedConfigs(builders);
+
+ monitor.beginTask("", num + cfgs.length);
+
+ if(cfgs.length != 0)
+ ManagedBuildManager.buildConfigurations(cfgs, new SubProgressMonitor(monitor, 1));
+
+ for(int i = 0; i < num; i++){
+ build(kind, builders[i], info, new SubProgressMonitor(monitor, 1));
+ }
+ }
+
+ updateOtherConfigs(builders, kind);
+
+ monitor.done();
+ return getProject().getReferencedProjects();
+ }
+
+ private IConfiguration[] getReferencedConfigs(IBuilder[] builders){
+ Set set = new HashSet();
+ for(int i = 0; i < builders.length; i++){
+ IConfiguration cfg = builders[i].getParent().getParent();
+ IConfiguration refs[] = ManagedBuildManager.getReferencedConfigurations(cfg);
+ for(int k = 0; k < refs.length; k++){
+ set.add(refs[k]);
+ }
+ }
+ return (IConfiguration[]) set.toArray(new Configuration[set.size()]);
+ }
+
+ protected MultiStatus checkBuilders(IBuilder builders[], IConfiguration activeCfg){
+ MultiStatus status = null;
+ for(int i = 0; i < builders.length; i++){
+ IBuilder builder = builders[i];
+ boolean supportsCustomization = builder.supportsCustomizedBuild();
+ boolean isManagedBuildOn = builder.isManagedBuildOn();
+ if(isManagedBuildOn && !supportsCustomization){
+ if(builder.isCustomBuilder()){
+ if(status == null){
+ status = new MultiStatus(
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ IStatus.ERROR,
+ new String(),
+ null);
+ }
+
+ status.add(new Status (
+ IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ 0,
+ "customized builder created for builder that does not support customization",
+ null));
+
+ }
+ else if(builder.getParent().getParent() != activeCfg){
+ if(status == null){
+ status = new MultiStatus(
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ IStatus.ERROR,
+ new String(),
+ null);
+ }
+
+ status.add(new Status (
+ IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ 0,
+ "request for building non active configuration for the builder that does not support this",
+ null));
+
+ }
+ }
+ }
+
+ if(status == null){
+ status = new MultiStatus(
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ IStatus.OK,
+ new String(),
+ null);
+ }
+
+ return status;
+ }
+
+ private void updateOtherConfigs(IBuilder builders[], int buildKind){
+ //IProject project
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ IConfiguration allCfgs[] = info.getManagedProject().getConfigurations();
+ new OtherConfigVerifier(builders, allCfgs).updateOtherConfigs(buildKind == FULL_BUILD ? null : getDelta(getProject()));
+ }
+
+ protected class BuildStatus {
+ private boolean fManagedBuildOn;
+ private boolean fRebuild;
+ private boolean fBuild = true;
+ private List fConsoleMessages = new ArrayList();
+ private IManagedBuilderMakefileGenerator fMakeGen;
+
+ public BuildStatus(IBuilder builder){
+ fManagedBuildOn = builder.isManagedBuildOn();
+ }
+
+ public void setRebuild(){
+ fRebuild = true;
+ }
+
+ public boolean isRebuild(){
+ return fRebuild;
+ }
+
+ public boolean isManagedBuildOn(){
+ return fManagedBuildOn;
+ }
+
+ public boolean isBuild(){
+ return fBuild;
+ }
+
+ public void cancelBuild(){
+ fBuild = false;
+ }
+
+ public List getConsoleMessagesList(){
+ return fConsoleMessages;
+ }
+
+ public IManagedBuilderMakefileGenerator getMakeGen(){
+ return fMakeGen;
+ }
+
+ public void setMakeGen(IManagedBuilderMakefileGenerator makeGen){
+ fMakeGen = makeGen;
+ }
+ }
+
+ protected void build(int kind, IBuilder builder, IManagedBuildInfo info, IProgressMonitor monitor) throws CoreException{
+ BuildStatus status = new BuildStatus(builder);
+ if (!shouldBuild(kind, builder)) {
+ return;
+ }
+// if (kind == IncrementalProjectBuilder.AUTO_BUILD) {
+// IResourceDelta delta = getDelta(getProject());
+// if (delta != null) {
+// IResource res = delta.getResource();
+// if (res != null) {
+// bPerformBuild = res.getProject().equals(getProject());
+// }
+// } else {
+// bPerformBuild = false;
+// }
+// }
+
+ if (status.isBuild()) {
+// IManagedBuilderMakefileGenerator makeGen = null;
+ if(status.isManagedBuildOn()){
+ status = performPrebuildGeneration(kind, builder, info, status, monitor);
+ }
+
+ IConfiguration cfg = builder.getParent().getParent();
+
+ if(status.isBuild()){
+ try {
+ boolean isClean = invokeBuilder(kind, builder, monitor);
+ if (isClean) {
+ forgetLastBuiltState();
+ cfg.setRebuildState(true);
+ } else {
+ if(status.isManagedBuildOn()){
+ performPostbuildGeneration(kind, builder, info, status, monitor);
+ }
+ cfg.setRebuildState(false);
+ }
+ } catch(CoreException e){
+ cfg.setRebuildState(true);
+ throw e;
+ }
+ } else if(status.getConsoleMessagesList().size() != 0) {
+ emitMessage(concatMessages(status.getConsoleMessagesList()));
+ }
+ }
+ checkCancel(monitor);
+ }
+
+
+
+ private String concatMessages(List msgs){
+ int size = msgs.size();
+ if(size == 0){
+ return "";
+ } else if(size == 1){
+ return (String)msgs.get(0);
+ }
+
+ StringBuffer buf = new StringBuffer();
+ buf.append(msgs.get(0));
+ for(int i = 1; i < size; i++){
+ buf.append("\n");
+ buf.append((String)msgs.get(i));
+ }
+ return buf.toString();
+ }
+
+ /* (non-javadoc)
+ * Emits a message to the console indicating that there were no source files to build
+ * @param buildType
+ * @param status
+ * @param configName
+ */
+ private String createNoSourceMessage(int buildType, IStatus status, String configName) throws CoreException {
+ StringBuffer buf = new StringBuffer();
+ String[] consoleHeader = new String[3];
+ if (buildType == FULL_BUILD || buildType == INCREMENTAL_BUILD) {
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
+ } else {
+ consoleHeader[0] = new String();
+ outputError(getProject().getName(), "The given build type is not supported in this context"); //$NON-NLS-1$
+ }
+ consoleHeader[1] = configName;
+ consoleHeader[2] = getProject().getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(status.getMessage());
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ return buf.toString();
+ }
+
+ private void emitMessage(String msg) throws CoreException {
+ try {
+ IConsole console = getConsole();
+ ConsoleOutputStream consoleOutStream = console.getOutputStream();
+ // Report a successful clean
+ consoleOutStream.write(msg.getBytes());
+ consoleOutStream.flush();
+ consoleOutStream.close();
+ } catch (CoreException e) {
+ // Throw the exception back to the builder
+ throw e;
+ } catch (IOException io) { // Ignore console failures...
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ io.getLocalizedMessage(), io));
+ }
+ }
+
+ private IConsole getConsole(){
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(getProject());
+ return console;
+ }
+ /**
+ * called to invoke the MBS Internal Builder for building the given configuration
+ *
+ * @param cfg configuration to be built
+ * @param buildIncrementaly if true, incremental build will be performed,
+ * only files that need rebuild will be built.
+ * If false, full rebuild will be performed
+ * @param resumeOnErr if true, build will continue in case of error while building.
+ * If false the build will stop on the first error
+ * @param monitor monitor
+ */
+ protected boolean invokeInternalBuilder(int kind, IBuilder builder,
+ IProgressMonitor monitor) {
+
+ IConfiguration cfg = builder.getParent().getParent();
+ boolean isParallel = builder.getParallelizationNum() != 0;
+ boolean buildIncrementaly = true;
+ boolean resumeOnErr = !builder.isStopOnError();
+
+ // Get the project and make sure there's a monitor to cancel the build
+ IProject currentProject = cfg.getOwner().getProject();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ String[] msgs = new String[2];
+ msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER);
+ msgs[1] = currentProject.getName();
+
+ ConsoleOutputStream consoleOutStream = null;
+ IConsole console = null;
+ OutputStream epmOutputStream = null;
+ try {
+ int flags = 0;
+ IResourceDelta delta = null;
+
+ if(buildIncrementaly){
+ flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS;
+ delta = getDelta(currentProject);
+ }
+
+ IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags);
+
+ DescriptionBuilder dBuilder = null;
+ if (!isParallel)
+ dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr);
+
+ // Get a build console for the project
+ StringBuffer buf = new StringBuffer();
+ console = CCorePlugin.getDefault().getConsole();
+ console.start(currentProject);
+ consoleOutStream = console.getOutputStream();
+ String[] consoleHeader = new String[3];
+ if(buildIncrementaly)
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
+ else
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_REBUILD);
+
+ consoleHeader[1] = cfg.getName();
+ consoleHeader[2] = currentProject.getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ buf.append(ManagedMakeMessages.getResourceString(INTERNAL_BUILDER_HEADER_NOTE));
+ buf.append("\n"); //$NON-NLS-1$
+
+ if(!cfg.isSupported()){
+ buf.append(ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+
+ if(isParallel || dBuilder.getNumCommands() > 0) {
+ // Remove all markers for this project
+ removeAllMarkers(currentProject);
+
+ // Hook up an error parser manager
+ String[] errorParsers = builder.getErrorParsers();
+ ErrorParserManager epm = new ErrorParserManager(getProject(), des.getDefaultBuildDirLocation(), this, errorParsers);
+ epm.setOutputStream(consoleOutStream);
+ // This variable is necessary to ensure that the EPM stream stay open
+ // until we explicitly close it. See bug#123302.
+ epmOutputStream = epm.getOutputStream();
+
+ int status = 0;
+
+ long t1 = System.currentTimeMillis();
+ if (isParallel)
+ status = ParallelBuilder.build(des, null, null, epmOutputStream, epmOutputStream, monitor, resumeOnErr, buildIncrementaly);
+ else
+ status = dBuilder.build(epmOutputStream, epmOutputStream, monitor);
+ long t2 = System.currentTimeMillis();
+
+ // Report either the success or failure of our mission
+ buf = new StringBuffer();
+
+ switch(status){
+ case IBuildModelBuilder.STATUS_OK:
+ buf.append(ManagedMakeMessages
+ .getFormattedString(BUILD_FINISHED,
+ currentProject.getName()));
+ break;
+ case IBuildModelBuilder.STATUS_CANCELLED:
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_CANCELLED));
+ break;
+ case IBuildModelBuilder.STATUS_ERROR_BUILD:
+ String msg = resumeOnErr ?
+ ManagedMakeMessages.getResourceString(BUILD_FINISHED_WITH_ERRS) :
+ ManagedMakeMessages.getResourceString(BUILD_STOPPED_ERR);
+ buf.append(msg);
+ break;
+ case IBuildModelBuilder.STATUS_ERROR_LAUNCH:
+ default:
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_FAILED_ERR));
+ break;
+ }
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+
+ // Report time and number of threads used
+ buf.append("Time consumed: ");
+ buf.append(t2 - t1);
+ buf.append(" ms. ");
+ if (isParallel) {
+ buf.append("Parallel threads used: ");
+ buf.append(ParallelBuilder.lastThreadsUsed);
+ }
+ buf.append("\n");
+ // Write message on the console
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ epmOutputStream.close();
+ epmOutputStream = null;
+ // Generate any error markers that the build has discovered
+ monitor.subTask(ManagedMakeMessages
+ .getResourceString(MARKERS));
+//TODO: addBuilderMarkers(epm);
+ epm.reportProblems();
+ } else {
+ buf = new StringBuffer();
+ buf.append(ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ }
+
+ } catch (Exception e) {
+ if(consoleOutStream != null){
+ StringBuffer buf = new StringBuffer();
+ String errorDesc = ManagedMakeMessages
+ .getResourceString(BUILD_ERROR);
+ buf.append(errorDesc);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ buf.append("(").append(e.getLocalizedMessage()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+
+ try {
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ } catch (IOException e1) {
+ }
+ }
+ forgetLastBuiltState();
+ } finally {
+ if(epmOutputStream != null){
+ try {
+ epmOutputStream.close();
+ } catch (IOException e) {
+ }
+ }
+ if(consoleOutStream != null){
+ try {
+ consoleOutStream.close();
+ } catch (IOException e) {
+ }
+ }
+// getGenerationProblems().clear();
+ monitor.done();
+ }
+ return false;
+ }
+
+ protected String[] calcEnvironment(IBuilder builder) throws CoreException{
+ HashMap envMap = new HashMap();
+ if (builder.appendEnvironment()) {
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(builder.getParent().getParent());
+ IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
+ IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
+ for(int i = 0; i < vars.length; i++){
+ envMap.put(vars[i].getName(), vars[i].getValue());
+ }
+ }
+ // Add variables from build info
+ Map builderEnv = builder.getExpandedEnvironment();
+ if(builderEnv != null)
+ envMap.putAll(builderEnv);
+ Iterator iter = envMap.entrySet().iterator();
+ List strings= new ArrayList(envMap.size());
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ StringBuffer buffer= new StringBuffer((String) entry.getKey());
+ buffer.append('=').append((String) entry.getValue());
+ strings.add(buffer.toString());
+ }
+ return (String[]) strings.toArray(new String[strings.size()]);
+ }
+
+
+ /**
+ * Called to invoke the MBS Internal Builder for building the given resources in
+ * the given configuration
+ *
+ * This method is considered experimental. Clients implementing this API should expect
+ * possible changes in the API.
+ *
+ * @param cfg configuration to be built
+ * @param buildIncrementaly if true, incremental build will be performed,
+ * only files that need rebuild will be built.
+ * If false, full rebuild will be performed
+ * @param resumeOnErr if true, build will continue in case of error while building.
+ * If false the build will stop on the first error
+ * @param monitor Progress monitor. For every resource built this monitor will consume one unit of work.
+ */
+ public void invokeInternalBuilder(IResource[] resourcesToBuild, IConfiguration cfg,
+ boolean buildIncrementaly,
+ boolean resumeOnErr,
+ boolean initNewConsole,
+ boolean printFinishedMessage,
+ IProgressMonitor monitor) {
+ // Get the project and make sure there's a monitor to cancel the build
+
+ IProject currentProject = cfg.getOwner().getProject();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ try {
+ int flags = 0;
+ IResourceDelta delta = null;
+
+ if(buildIncrementaly){
+ flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS;
+ delta = getDelta(currentProject);
+ }
+
+
+ String[] msgs = new String[2];
+ msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER);
+ msgs[1] = currentProject.getName();
+
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(currentProject);
+ ConsoleOutputStream consoleOutStream = console.getOutputStream();
+
+ StringBuffer buf = new StringBuffer();
+
+ if (initNewConsole) {
+ if (buildIncrementaly)
+ buf.append(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildSelectedIncremental")); //$NON-NLS-1$
+ else
+ buf.append(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildSelectedRebuild")); //$NON-NLS-1$
+
+
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ buf.append(ManagedMakeMessages
+ .getResourceString(INTERNAL_BUILDER_HEADER_NOTE));
+ buf.append("\n"); //$NON-NLS-1$
+ }
+
+
+ if(!cfg.isSupported()){
+ buf.append(ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+
+ // Remove all markers for this project
+ // TODO remove only necessary markers
+ removeAllMarkers(currentProject);
+
+ IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags);
+
+ // Hook up an error parser manager
+ String[] errorParsers = cfg.getErrorParserList();
+ ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocation(), this, errorParsers);
+ epm.setOutputStream(consoleOutStream);
+ // This variable is necessary to ensure that the EPM stream stay open
+ // until we explicitly close it. See bug#123302.
+ OutputStream epmOutputStream = epm.getOutputStream();
+
+ boolean errorsFound = false;
+
+ doneBuild: for (int k = 0; k < resourcesToBuild.length; k++) {
+ IBuildResource buildResource = des
+ .getBuildResource(resourcesToBuild[k]);
+
+// step collector
+ Set dependentSteps = new HashSet();
+
+// get dependent IO types
+ IBuildIOType depTypes[] = buildResource.getDependentIOTypes();
+
+// iterate through each type and add the step the type belongs to to the collector
+ for(int j = 0; j < depTypes.length; j++){
+ IBuildIOType type = depTypes[j];
+ if(type != null && type.getStep() != null)
+ dependentSteps.add(type.getStep());
+ }
+
+ monitor.subTask(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildingFile") + resourcesToBuild[k].getProjectRelativePath()); //$NON-NLS-1$
+
+ // iterate through all build steps
+ Iterator stepIter = dependentSteps.iterator();
+
+ while(stepIter.hasNext())
+ {
+ IBuildStep step = (IBuildStep) stepIter.next();
+
+ StepBuilder stepBuilder = new StepBuilder(step);
+
+ int status = stepBuilder.build(consoleOutStream, epmOutputStream, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+
+ // Refresh the output resource without allowing the user to cancel.
+ // This is probably unkind, but short of this there is no way to ensure
+ // the UI is up-to-date with the build results
+ IBuildIOType[] outputIOTypes = step.getOutputIOTypes();
+
+ for(int j = 0; j < outputIOTypes.length; j++ )
+ {
+ IBuildResource[] resources = outputIOTypes[j].getResources();
+
+ for(int i = 0; i < resources.length; i++)
+ {
+ IFile file = currentProject.getFile(resources[i].getLocation());
+ file.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+ }
+
+ // check status
+
+ switch (status) {
+ case IBuildModelBuilder.STATUS_OK:
+ // don't print anything if the step was successful,
+ // since the build might not be done as a whole
+ break;
+ case IBuildModelBuilder.STATUS_CANCELLED:
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_CANCELLED));
+ break doneBuild;
+ case IBuildModelBuilder.STATUS_ERROR_BUILD:
+ errorsFound = true;
+ if (!resumeOnErr) {
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_STOPPED_ERR));
+ break doneBuild;
+ }
+ break;
+ case IBuildModelBuilder.STATUS_ERROR_LAUNCH:
+ default:
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_FAILED_ERR));
+ break doneBuild;
+ }
+ }
+
+
+ }
+
+ // check status
+ // Report either the success or failure of our mission
+ buf = new StringBuffer();
+
+
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+
+ if (printFinishedMessage) {
+ if (errorsFound) {
+ buf.append(ManagedMakeMessages
+ .getResourceString(BUILD_FAILED_ERR));
+ } else {
+ buf
+ .append(ManagedMakeMessages
+ .getResourceString("GeneratedMakefileBuilder.buildResourcesFinished")); //$NON-NLS-1$
+ }
+ }
+
+ // Write message on the console
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ epmOutputStream.close();
+
+ // Generate any error markers that the build has discovered
+//TODO: addBuilderMarkers(epm);
+ epm.reportProblems();
+ consoleOutStream.close();
+ } catch (Exception e) {
+ StringBuffer buf = new StringBuffer();
+ String errorDesc = ManagedMakeMessages
+ .getResourceString(BUILD_ERROR);
+ buf.append(errorDesc);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ buf.append("(").append(e.getLocalizedMessage()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ forgetLastBuiltState();
+ } finally {
+// getGenerationProblems().clear();
+ }
+ }
+
+ protected BuildStatus performPostbuildGeneration(int kind, IBuilder builder, IManagedBuildInfo mInfo, BuildStatus buildStatus, IProgressMonitor monitor) throws CoreException{
+ if(builder.isInternalBuilder())
+ return buildStatus;
+
+ if(buildStatus.isRebuild()){
+ buildStatus.getMakeGen().regenerateDependencies(false);
+ } else {
+ buildStatus.getMakeGen().generateDependencies();
+ }
+
+ return buildStatus;
+ }
+
+ protected BuildStatus performPrebuildGeneration(int kind, IBuilder builder, IManagedBuildInfo mInfo, BuildStatus buildStatus, IProgressMonitor monitor) throws CoreException{
+ if(builder.isInternalBuilder())
+ return buildStatus;
+
+ IConfiguration cfg = builder.getParent().getParent();
+ buildStatus = performCleanning(kind, cfg, builder, mInfo, buildStatus, monitor);
+ IManagedBuilderMakefileGenerator generator = builder.getBuildFileGenerator();
+ if(generator != null){
+ initializeGenerator(generator, kind, cfg, builder, mInfo, monitor);
+ buildStatus.setMakeGen(generator);
+
+ MultiStatus result = performMakefileGeneration(generator, buildStatus, monitor);
+ if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
+ IStatus[] kids = result.getChildren();
+ for (int index = 0; index < kids.length; ++index) {
+ // One possibility is that there is nothing to build
+ IStatus status = kids[index];
+// if(messages == null){
+// messages = new MultiStatus(
+// ManagedBuilderCorePlugin.getUniqueIdentifier(),
+// IStatus.INFO,
+// "",
+// null);
+//
+// }
+ if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) {
+// performBuild = false;
+ buildStatus.getConsoleMessagesList().add(createNoSourceMessage(kind, status, cfg.getName()));
+ buildStatus.cancelBuild();
+// break;
+
+ } else {
+ // Stick this in the list of stuff to warn the user about
+
+ //TODO: messages.add(status);
+ }
+ }
+ }
+
+ checkCancel(monitor);
+
+
+
+// if(result.getSeverity() != IStatus.OK)
+// throw new CoreException(result);
+ } else {
+ buildStatus.cancelBuild();
+ }
+
+// if(messages == null){
+// messages = createMultiStatus(IStatus.OK);
+// }
+
+ return buildStatus;
+ }
+
+ protected BuildStatus performCleanning(int kind, IConfiguration cfg, IBuilder builder, IManagedBuildInfo mInfo, BuildStatus status, IProgressMonitor monitor) throws CoreException{
+ boolean makefileRegenerationNeeded = false;
+ //perform necessary cleaning and build type calculation
+ if(cfg.needsFullRebuild()){
+ //configuration rebuild state is set to true,
+ //full rebuild is needed in any case
+ //clean first, then make a full build
+ outputTrace(getProject().getName(), "config rebuild state is set to true, making a full rebuild"); //$NON-NLS-1$
+ clean(builder, new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
+ makefileRegenerationNeeded = true;
+ } else {
+ makefileRegenerationNeeded = cfg.needsRebuild();
+ IBuildDescription des = null;
+
+ IResourceDelta delta = kind == FULL_BUILD ? null : getDelta(getProject());
+ if(delta == null)
+ makefileRegenerationNeeded = true;
+ if(cfg.needsRebuild() || delta != null){
+ //use a build desacription model to calculate the resources to be cleaned
+ //only in case there are some changes to the project sources or build information
+ try{
+ int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.DEPFILES | BuildDescriptionManager.DEPS;
+ if(delta != null)
+ flags |= BuildDescriptionManager.REMOVED;
+
+ outputTrace(getProject().getName(), "using a build description.."); //$NON-NLS-1$
+
+ des = BuildDescriptionManager.createBuildDescription(cfg, getDelta(getProject()), flags);
+
+ BuildDescriptionManager.cleanGeneratedRebuildResources(des);
+ } catch (Throwable e){
+ //TODO: log error
+ outputError(getProject().getName(), "error occured while build description calculation: " + e.getLocalizedMessage()); //$NON-NLS-1$
+ //in case an error occured, make it behave in the old stile:
+ if(cfg.needsRebuild()){
+ //make a full clean if an info needs a rebuild
+ clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
+ makefileRegenerationNeeded = true;
+ }
+ else if(delta != null && !makefileRegenerationNeeded){
+ // Create a delta visitor to detect the build type
+ ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(cfg, mInfo.getManagedProject().getConfigurations());
+ delta.accept(visitor);
+ if (visitor.shouldBuildFull()) {
+ clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
+ makefileRegenerationNeeded = true;
+ }
+ }
+ }
+ }
+ }
+
+ if(makefileRegenerationNeeded){
+ status.setRebuild();
+ }
+ return status;
+ }
+
+ protected MultiStatus performMakefileGeneration(IManagedBuilderMakefileGenerator generator, BuildStatus buildStatus, IProgressMonitor monitor) throws CoreException {
+ // Need to report status to the user
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ // Ask the makefile generator to generate any makefiles needed to build delta
+ checkCancel(monitor);
+ String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.update.makefiles", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+
+ MultiStatus result;
+ if(buildStatus.isRebuild()){
+ result = generator.regenerateMakefiles();
+ } else {
+ result = generator.generateMakefiles(getDelta(getProject()));
+ }
+
+ return result;
+ }
+
+ private MultiStatus createMultiStatus(int severity){
+ return new MultiStatus(
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ severity,
+ new String(),
+ null);
+ }
+
+
+ protected void initializeGenerator(IManagedBuilderMakefileGenerator generator, int kind, IConfiguration cfg, IBuilder builder, IManagedBuildInfo info, IProgressMonitor monitor){
+ if(generator instanceof IManagedBuilderMakefileGenerator2){
+ IManagedBuilderMakefileGenerator2 gen2 = (IManagedBuilderMakefileGenerator2)generator;
+ gen2.initialize(kind, cfg, builder, monitor);
+ } else {
+ generator.initialize(getProject(), info, monitor);
+ }
+
+ }
+
+ protected void clean(IProgressMonitor monitor) throws CoreException {
+ IBuilder[] builders = BuilderFactory.createBuilders(getProject(), null);
+ for(int i = 0; i < builders.length; i++){
+ IBuilder builder = builders[i];
+ clean(builder, monitor);
+ }
+ }
+
+ protected void clean(IBuilder builder, IProgressMonitor monitor) throws CoreException{
+ if (shouldBuild(CLEAN_BUILD, builder)) {
+ boolean performExternalClean = true;
+ if(shouldCleanProgrammatically(builder)){
+ try {
+ cleanProgrammatically(builder, monitor);
+ performExternalClean = false;
+ } catch (CoreException e) {
+ }
+ }
+
+ if(performExternalClean){
+ performExternalClean(builder, false, monitor);
+ }
+ }
+
+ }
+
+ protected void performExternalClean(final IBuilder builder, boolean separateJob, IProgressMonitor monitor) throws CoreException {
+ IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
+ final ISchedulingRule rule = ruleFactory.modifyRule(getProject());
+
+ if(separateJob){
+ Job backgroundJob = new Job("CDT Common Builder"){ //$NON-NLS-1$
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ invokeMake(CLEAN_BUILD, builder, monitor);
+ }
+ }, rule, IWorkspace.AVOID_UPDATE, monitor);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ IStatus returnStatus = Status.OK_STATUS;
+ return returnStatus;
+ }
+
+
+ };
+
+ backgroundJob.setRule(rule);
+ backgroundJob.schedule();
+ } else {
+ invokeMake(CLEAN_BUILD, builder, monitor);
+ }
+
+ }
+
+ protected boolean shouldCleanProgrammatically(IBuilder builder){
+ if(!builder.isManagedBuildOn())
+ return false;
+ return true;
+// IConfiguration cfg = builder.getParent().getParent();
+// IPath path = ManagedBuildManager.getBuildFullPath(cfg, builder);
+// if(path == null)
+// return false;
+//
+// return cfg.getOwner().getProject().getFullPath().isPrefixOf(path);
+ }
+
+ protected void cleanProgrammatically(IBuilder builder, IProgressMonitor monitor) throws CoreException {
+// referencedProjects = getProject().getReferencedProjects();
+ outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$
+ IConfiguration cfg = builder.getParent().getParent();
+ IPath buildPath = ManagedBuildManager.getBuildFullPath(cfg, builder);
+ if(buildPath == null){
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "can not clean programmatically: build workspace path is not specified"));
+ }
+
+ IPath projectFullPath = getProject().getFullPath();
+ if(!projectFullPath.isPrefixOf(buildPath)){
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "can not clean programmatically: build workspace path is not the project path"));
+ }
+
+ IWorkspace workspace = CCorePlugin.getWorkspace();
+ IResource rc = workspace.getRoot().findMember(buildPath);
+ if(rc != null){
+ if(rc.getType() != IResource.FOLDER){
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "can not clean programmatically: build workspace path is not folder"));
+ }
+
+ IFolder buildDir = (IFolder)rc;
+ if (!buildDir.isAccessible()){
+ outputError(buildDir.getName(), "Could not delete the build directory"); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "can not clean programmatically: build folder is not accessible"));
+ }
+ String status;
+ try {
+ // try the brute force approach first
+ status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
+ monitor.subTask(status);
+ workspace.delete(new IResource[]{buildDir}, true, monitor);
+ StringBuffer buf = new StringBuffer();
+ // write to the console
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(getProject());
+ ConsoleOutputStream consoleOutStream = console.getOutputStream();
+ String[] consoleHeader = new String[3];
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
+ consoleHeader[1] = cfg.getName();
+ consoleHeader[2] = getProject().getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ buf = new StringBuffer();
+ // Report a successful clean
+ String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName());
+ buf.append(successMsg);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ consoleOutStream.close();
+ } catch (IOException io) {} // Ignore console failures...
+ }
+ }
+
+ protected boolean invokeBuilder(int kind, IBuilder builder, IProgressMonitor monitor) throws CoreException {
+ if(builder.isInternalBuilder())
+ return invokeInternalBuilder(kind, builder, monitor);
+ return invokeMake(kind, builder, monitor);
+ }
+
+
+ protected boolean invokeMake(int kind, IBuilder builder, IProgressMonitor monitor) throws CoreException {
+ boolean isClean = false;
+ IProject currProject = getProject();
+
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(MakeMessages.getString("MakeBuilder.Invoking_Make_Builder") + currProject.getName(), 100); //$NON-NLS-1$
+
+ try {
+ IPath buildCommand = builder.getBuildCommand();
+ if (buildCommand != null) {
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(currProject);
+
+ OutputStream cos = console.getOutputStream();
+ StringBuffer buf = new StringBuffer();
+
+ String[] consoleHeader = new String[3];
+ switch (kind) {
+ case FULL_BUILD:
+ case INCREMENTAL_BUILD:
+ case AUTO_BUILD:
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
+ break;
+ case CLEAN_BUILD:
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
+ break;
+ }
+
+ IConfiguration cfg = builder.getParent().getParent();
+ consoleHeader[1] = cfg.getName();
+ consoleHeader[2] = getProject().getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if(!cfg.isSupported()){
+ buf.append(ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ cos.write(buf.toString().getBytes());
+ cos.flush();
+
+ // remove all markers for this project
+ removeAllMarkers(currProject);
+
+ IPath workingDirectory = ManagedBuildManager.getBuildLocation(cfg, builder);
+
+ String[] targets = getTargets(kind, builder);
+ if (targets.length != 0 && targets[targets.length - 1].equals(builder.getCleanBuildTarget())) //$NON-NLS-1$
+ isClean = true;
+
+ String errMsg = null;
+ CommandLauncher launcher = new CommandLauncher();
+ // Print the command for visual interaction.
+ launcher.showCommand(true);
+
+ // Set the environment
+ String[] env = calcEnvironment(builder);
+ String[] buildArguments = targets;
+ if (builder.isDefaultBuildCmd()) {
+// if (!builder.isStopOnError()) {
+// buildArguments = new String[targets.length + 1];
+// buildArguments[0] = "-k"; //$NON-NLS-1$
+// System.arraycopy(targets, 0, buildArguments, 1, targets.length);
+// }
+ } else {
+ String args = builder.getBuildArguments();
+ if (args != null && !args.equals("")) { //$NON-NLS-1$
+ String[] newArgs = makeArray(args);
+ buildArguments = new String[targets.length + newArgs.length];
+ System.arraycopy(newArgs, 0, buildArguments, 0, newArgs.length);
+ System.arraycopy(targets, 0, buildArguments, newArgs.length, targets.length);
+ }
+ }
+// MakeRecon recon = new MakeRecon(buildCommand, buildArguments, env, workingDirectory, makeMonitor, cos);
+// recon.invokeMakeRecon();
+// cos = recon;
+ QualifiedName qName = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "progressMonitor"); //$NON-NLS-1$
+ Integer last = (Integer)getProject().getSessionProperty(qName);
+ if (last == null) {
+ last = new Integer(100);
+ }
+ StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), cos, last.intValue());
+ ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectory, this, builder.getErrorParsers());
+ epm.setOutputStream(streamMon);
+ OutputStream stdout = epm.getOutputStream();
+ OutputStream stderr = epm.getOutputStream();
+ // Sniff console output for scanner info
+ ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getMakeBuilderOutputSniffer(
+ stdout, stderr, cfg, null, workingDirectory, null, this, null);
+ OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream());
+ OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream());
+ Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory);
+ if (p != null) {
+ try {
+ // Close the input of the Process explicitly.
+ // We will never write to it.
+ p.getOutputStream().close();
+ } catch (IOException e) {
+ }
+ // Before launching give visual cues via the monitor
+ monitor.subTask(MakeMessages.getString("MakeBuilder.Invoking_Command") + launcher.getCommandLine()); //$NON-NLS-1$
+ if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0))
+ != CommandLauncher.OK)
+ errMsg = launcher.getErrorMessage();
+ monitor.subTask(MakeMessages.getString("MakeBuilder.Updating_project")); //$NON-NLS-1$
+
+ try {
+ // Do not allow the cancel of the refresh, since the builder is external
+ // to Eclipse, files may have been created/modified and we will be out-of-sync.
+ // The caveat is for hugue projects, it may take sometimes at every build.
+ currProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ }
+ } else {
+ errMsg = launcher.getErrorMessage();
+ }
+ getProject().setSessionProperty(qName, !monitor.isCanceled() && !isClean ? new Integer(streamMon.getWorkDone()) : null);
+
+ if (errMsg != null) {
+ buf = new StringBuffer(buildCommand.toString() + " "); //$NON-NLS-1$
+ for (int i = 0; i < buildArguments.length; i++) {
+ buf.append(buildArguments[i]);
+ buf.append(' ');
+ }
+
+ String errorDesc = MakeMessages.getFormattedString("MakeBuilder.buildError", buf.toString()); //$NON-NLS-1$
+ buf = new StringBuffer(errorDesc);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+ cos.write(buf.toString().getBytes());
+ cos.flush();
+ }
+
+ stdout.close();
+ stderr.close();
+
+ monitor.subTask(MakeMessages.getString("MakeBuilder.Creating_Markers")); //$NON-NLS-1$
+ consoleOut.close();
+ consoleErr.close();
+ epm.reportProblems();
+ cos.close();
+ }
+ } catch (Exception e) {
+ CCorePlugin.log(e);
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ e.getLocalizedMessage(),
+ e));
+ } finally {
+ monitor.done();
+ }
+ return (isClean);
+ }
+
+ /**
+ * Check whether the build has been canceled.
+ */
+ public void checkCancel(IProgressMonitor monitor) {
+ if (monitor != null && monitor.isCanceled())
+ throw new OperationCanceledException();
+ }
+
+ protected boolean shouldBuild(int kind, IMakeBuilderInfo info) {
+ switch (kind) {
+ case IncrementalProjectBuilder.AUTO_BUILD :
+ return info.isAutoBuildEnable();
+ case IncrementalProjectBuilder.INCREMENTAL_BUILD : // now treated as the same!
+ case IncrementalProjectBuilder.FULL_BUILD :
+ return info.isFullBuildEnabled() | info.isIncrementalBuildEnabled() ;
+ case IncrementalProjectBuilder.CLEAN_BUILD :
+ return info.isCleanBuildEnabled();
+ }
+ return true;
+ }
+
+ protected String[] getTargets(int kind, IBuilder builder) {
+ String targetsArray[] = null;
+
+ if(kind != CLEAN_BUILD && !builder.isCustomBuilder() && builder.isManagedBuildOn()){
+ IConfiguration cfg = builder.getParent().getParent();
+ String preBuildStep = cfg.getPrebuildStep();
+ try {
+ preBuildStep = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ preBuildStep,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ cfg);
+ } catch (BuildMacroException e) {
+ }
+
+ if(preBuildStep != null && preBuildStep.length() != 0){
+ targetsArray = new String[]{"pre-build", "main-build"};
+ }
+ }
+
+ if(targetsArray == null){
+ String targets = ""; //$NON-NLS-1$
+ switch (kind) {
+ case IncrementalProjectBuilder.AUTO_BUILD :
+ targets = builder.getAutoBuildTarget();
+ break;
+ case IncrementalProjectBuilder.INCREMENTAL_BUILD : // now treated as the same!
+ case IncrementalProjectBuilder.FULL_BUILD :
+ targets = builder.getIncrementalBuildTarget();
+ break;
+ case IncrementalProjectBuilder.CLEAN_BUILD :
+ targets = builder.getCleanBuildTarget();
+ break;
+ }
+
+ targetsArray = makeArray(targets);
+ }
+
+ return targetsArray;
+ }
+
+ // Turn the string into an array.
+ String[] makeArray(String string) {
+ string.trim();
+ char[] array = string.toCharArray();
+ ArrayList aList = new ArrayList();
+ StringBuffer buffer = new StringBuffer();
+ boolean inComment = false;
+ for (int i = 0; i < array.length; i++) {
+ char c = array[i];
+ if (array[i] == '"' || array[i] == '\'') {
+ if (i > 0 && array[i - 1] == '\\') {
+ inComment = false;
+ } else {
+ inComment = !inComment;
+ }
+ }
+ if (c == ' ' && !inComment) {
+ aList.add(buffer.toString());
+ buffer = new StringBuffer();
+ } else {
+ buffer.append(c);
+ }
+ }
+ if (buffer.length() > 0)
+ aList.add(buffer.toString());
+ return (String[]) aList.toArray(new String[aList.size()]);
+ }
+
+ private void removeAllMarkers(IProject currProject) throws CoreException {
+ IWorkspace workspace = currProject.getWorkspace();
+
+ // remove all markers
+ IMarker[] markers = currProject.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
+ if (markers != null) {
+ workspace.deleteMarkers(markers);
+ }
+ }}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index 4b465707d5e..9cf9c34086e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -13,35 +13,61 @@ package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
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.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildProcessManager;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
+import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.UserDefinedMacroSupplier;
+import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
+import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
+import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -49,26 +75,26 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-public class Configuration extends BuildObject implements IConfiguration {
+public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction, IBuildPropertyChangeListener {
- private static final String EMPTY_STRING = new String();
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private static final IPath EMPTY_PATH_ARRAY[] = new IPath[0];
+ private static final String EMPTY_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$
// Parent and children
+ private String parentId;
private IConfiguration parent;
private ProjectType projectType;
private ManagedProject managedProject;
- private ToolChain toolChain;
- private List resourceConfigurationList;
- private Map resourceConfigurationMap;
+// private ToolChain toolChain;
+// private List resourceConfigurationList;
+// private Map resourceConfigurationMap;
// Managed Build model attributes
private String artifactName;
private String cleanCommand;
@@ -79,6 +105,11 @@ public class Configuration extends BuildObject implements IConfiguration {
private String preannouncebuildStep;
private String postannouncebuildStep;
private String description;
+ private IPath[] sourcePaths;
+ private BuildObjectProperties buildProperties;
+ private boolean isTest;
+ private SupportedProperties supportedProperties;
+
// Miscellaneous
private boolean isExtensionConfig = false;
private boolean isDirty = false;
@@ -86,6 +117,19 @@ public class Configuration extends BuildObject implements IConfiguration {
private boolean resolved = true;
private boolean isTemporary = false;
+ private PathSettingsContainer pathSettings = PathSettingsContainer.createRootContainer();
+ private ResourceInfoContainer rcInfos = new ResourceInfoContainer(pathSettings, true);
+ private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
+
+ private FolderInfo rootFolderInfo;
+ private BuildConfigurationData fCfgData;
+ private ICConfigurationDescription fCfgDes;
+// private IScannerConfigBuilderInfo2 scannerCfgBuilderInfo;
+// private IDiscoveredPathManager.IDiscoveredPathInfo discoveredInfo;
+// private Boolean isPerResourceDiscovery;
+ private IConfigurationScannerConfigBuilderInfo cfgScannerInfo;
+ private boolean isPreferenceConfig;
+
//property name for holding the rebuild state
private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
@@ -114,29 +158,27 @@ public class Configuration extends BuildObject implements IConfiguration {
//as a special Builder object of the tool-chain and implement the internal
//builder enabling/disabling as the Builder substitution functionality
//
- private static final String INTERNAL_BUILDER = "internalBuilder"; //$NON-NLS-1$
+// private static final String INTERNAL_BUILDER = "internalBuilder"; //$NON-NLS-1$
//preference key that holds the Internal Builder enable state
- private static final String INTERNAL_BUILDER_ENABLED = "enabled"; //$NON-NLS-1$
+// private static final String INTERNAL_BUILDER_ENABLED = "enabled"; //$NON-NLS-1$
//preference key that holds the internal builder mode
- private static final String INTERNAL_BUILDER_IGNORE_ERR = "ignoreErr"; //$NON-NLS-1$
+// private static final String INTERNAL_BUILDER_IGNORE_ERR = "ignoreErr"; //$NON-NLS-1$
//preference key that holds the internal builder mode
- private static final String INTERNAL_BUILDER_PARALLEL = "parallel"; //$NON-NLS-1$
+// private static final String INTERNAL_BUILDER_PARALLEL = "parallel"; //$NON-NLS-1$
//preference key that holds the internal builder mode
- private static final String INTERNAL_BUILDER_PARALLEL_DEF = "paralleldef"; //$NON-NLS-1$
+// private static final String INTERNAL_BUILDER_PARALLEL_DEF = "paralleldef"; //$NON-NLS-1$
//preference key that holds the internal builder mode
- private static final String INTERNAL_BUILDER_PARALLELNUMBER = "parallelnumber"; //$NON-NLS-1$
+// private static final String INTERNAL_BUILDER_PARALLELNUMBER = "parallelnumber"; //$NON-NLS-1$
//Internal Builder enable state
- private boolean internalBuilderEnabled;
+// private boolean internalBuilderEnabled;
//Internal Builder mode
- private boolean internalBuilderIgnoreErr = true;
+// private boolean internalBuilderIgnoreErr = true;
//Internal Builder parallel mode
- private boolean internalBuilderParallel = true;
+// private boolean internalBuilderParallel = true;
//Internal Builder parallel mode - default jobs #
- private boolean internalBuilderParallelDef = true;
+// private boolean internalBuilderParallelDef = true;
//Number of parallel threads
- private int internalBuilderParallelNumber = 1; // default value
-
-
+// private int internalBuilderParallelNumber = 1; // default value
/*
* C O N S T R U C T O R S
*/
@@ -168,17 +210,60 @@ public class Configuration extends BuildObject implements IConfiguration {
projectType.addConfiguration(this);
}
+ IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
+ if(enablements.length > 0)
+ booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
+
+
// Load the children
IManagedConfigElement[] configElements = element.getChildren();
+ List srcPathList = new ArrayList();
for (int l = 0; l < configElements.length; ++l) {
IManagedConfigElement configElement = configElements[l];
if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
- toolChain = new ToolChain(this, configElement, managedBuildRevision);
- }else if (configElement.getName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
+ rootFolderInfo = new FolderInfo(this, configElement, managedBuildRevision, false);
+ addResourceConfiguration(rootFolderInfo);
+ } else if (IFolderInfo.FOLDER_INFO_ELEMENT_NAME.equals(configElement.getName())) {
+ FolderInfo resConfig = new FolderInfo(this, configElement, managedBuildRevision, true);
+ addResourceConfiguration(resConfig);
+ } else if (IFileInfo.FILE_INFO_ELEMENT_NAME.equals(configElement.getName())
+ || IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME.equals(configElement.getName())) {
ResourceConfiguration resConfig = new ResourceConfiguration(this, configElement, managedBuildRevision);
addResourceConfiguration(resConfig);
+ } else if (SourcePath.ELEMENT_NAME.equals(configElement.getName())){
+ SourcePath p = new SourcePath(configElement);
+ if(p.getPath() != null)
+ srcPathList.add(p.getPath());
+ } else if (configElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
+ loadProperties(configElement);
+ }
+ }
+
+ if(srcPathList.size() > 0)
+ sourcePaths = (IPath[])srcPathList.toArray(new IPath[srcPathList.size()]);
+
+ if(rootFolderInfo == null)
+ createRootFolderInfo();
+
+ String props = element.getAttribute(BUILD_PROPERTIES);
+ if(props != null)
+ buildProperties = new BuildObjectProperties(props, this, this);
+ if(projectType != null && projectType.buildProperties != null){
+ if(buildProperties == null){
+ buildProperties = new BuildObjectProperties(projectType.buildProperties, this, this);
+ } else {
+ IBuildProperty properties[] = projectType.buildProperties.getProperties();
+ for(int i = 0; i < properties.length; i++){
+ try {
+ buildProperties.internalSetProperty(properties[i].getPropertyType().getId(),
+ properties[i].getValue().getId());
+ } catch (CoreException e) {
+ }
+ }
}
}
+
+ setDirty(false);
}
/**
@@ -249,9 +334,11 @@ public class Configuration extends BuildObject implements IConfiguration {
* @param element The XML element that contains the configuration settings.
*
*/
- public Configuration(ManagedProject managedProject, Element element, String managedBuildRevision) {
+ public Configuration(ManagedProject managedProject, ICStorageElement element, String managedBuildRevision, boolean isPreference) {
this.managedProject = managedProject;
+ this.isPreferenceConfig = isPreference;
isExtensionConfig = false;
+ fCfgData = new BuildConfigurationData(this);
setManagedBuildRevision(managedBuildRevision);
@@ -259,19 +346,36 @@ public class Configuration extends BuildObject implements IConfiguration {
loadFromProject(element);
// Hook me up
- managedProject.addConfiguration(this);
+ if(managedProject != null)
+ managedProject.addConfiguration(this);
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
- toolChain = new ToolChain(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
- ResourceConfiguration resConfig = new ResourceConfiguration(this, (Element)configElement, managedBuildRevision);
+ ICStorageElement configElements[] = element.getChildren();
+ List srcPathList = new ArrayList();
+ for (int i = 0; i < configElements.length; ++i) {
+ ICStorageElement configElement = configElements[i];
+ if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
+ rootFolderInfo = new FolderInfo(this, configElement, managedBuildRevision, false);
+ addResourceConfiguration(rootFolderInfo);
+ } else if (IFolderInfo.FOLDER_INFO_ELEMENT_NAME.equals(configElement.getName())) {
+ FolderInfo resConfig = new FolderInfo(this, configElement, managedBuildRevision, true);
addResourceConfiguration(resConfig);
+ } else if (IFileInfo.FILE_INFO_ELEMENT_NAME.equals(configElement.getName())
+ || IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME.equals(configElement.getName())) {
+ ResourceConfiguration resConfig = new ResourceConfiguration(this, configElement, managedBuildRevision);
+ addResourceConfiguration(resConfig);
+ } else if (SourcePath.ELEMENT_NAME.equals(configElement.getName())){
+ SourcePath p = new SourcePath(configElement);
+ if(p.getPath() != null)
+ srcPathList.add(p.getPath());
}
}
+ resolveProjectReferences(true);
+
+ if(srcPathList.size() > 0)
+ sourcePaths = (IPath[])srcPathList.toArray(new IPath[srcPathList.size()]);
+
+
PropertyManager mngr = PropertyManager.getInstance();
String rebuild = mngr.getProperty(this, REBUILD_STATE);
if(rebuild == null || Boolean.valueOf(rebuild).booleanValue())
@@ -288,6 +392,8 @@ public class Configuration extends BuildObject implements IConfiguration {
}
}
+ setDirty(false);
+
// Preferences prefs = getPreferences(INTERNAL_BUILDER);
//
// internalBuilderEnabled = prefs != null ?
@@ -296,6 +402,111 @@ public class Configuration extends BuildObject implements IConfiguration {
// prefs.getBoolean(INTERNAL_BUILDER_IGNORE_ERR, true) : true;
}
+ public Configuration(ManagedProject managedProject, ToolChain tCh, String id, String name) {
+ setId(id);
+ setName(name);
+
+// this.description = cloneConfig.getDescription();
+ this.managedProject = managedProject;
+ isExtensionConfig = false;
+
+ if(tCh == null){
+ //create configuration based upon the preference config
+ IConfiguration cfg = ManagedBuildManager.getPreferenceConfiguration(false);
+ if(cfg != null)
+ copySettingsFrom((Configuration)cfg, true);
+ } else {
+ Configuration baseCfg = (Configuration)ManagedBuildManager.getExtensionConfiguration(EMPTY_CFG_ID);
+ // this.isTemporary = temporary;
+ fCfgData = new BuildConfigurationData(this);
+ if(baseCfg.buildProperties != null)
+ this.buildProperties = new BuildObjectProperties(baseCfg.buildProperties, this, this);
+
+ // set managedBuildRevision
+ setManagedBuildRevision(baseCfg.getManagedBuildRevision());
+
+ // if(!baseCfg.isExtensionConfig)
+ // cloneChildren = true;
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the cloning config should be stored.
+ parent = baseCfg.isExtensionConfig || baseCfg.getParent() == null ? baseCfg : baseCfg.getParent();
+
+ // Copy the remaining attributes
+ projectType = baseCfg.projectType;
+
+ artifactName = baseCfg.artifactName;
+
+ cleanCommand = baseCfg.cleanCommand;
+
+ artifactExtension = baseCfg.artifactExtension;
+
+ errorParserIds = baseCfg.errorParserIds;
+
+ prebuildStep = baseCfg.prebuildStep;
+
+ postbuildStep = baseCfg.postbuildStep;
+
+ preannouncebuildStep = baseCfg.preannouncebuildStep;
+
+ postannouncebuildStep = baseCfg.postannouncebuildStep;
+
+ if(baseCfg.sourcePaths != null)
+ sourcePaths = (IPath[])baseCfg.sourcePaths.clone();
+
+ // enableInternalBuilder(baseCfg.isInternalBuilderEnabled());
+ // setInternalBuilderIgnoreErr(baseCfg.getInternalBuilderIgnoreErr());
+ // setInternalBuilderParallel(baseCfg.getInternalBuilderParallel());
+ // setParallelDef(baseCfg.getParallelDef());
+ // setParallelNumber(baseCfg.getParallelNumber());
+ // internalBuilderEnabled = cloneConfig.internalBuilderEnabled;
+ // internalBuilderIgnoreErr = cloneConfig.internalBuilderIgnoreErr;
+
+ // Clone the configuration's children
+ // Tool Chain
+
+ String tcId = ManagedBuildManager.calculateChildId(tCh.getId(), null);
+
+ createToolChain(tCh, tcId, tCh.getId(), false);
+
+ // if(cloneChildren){
+ //copy expand build macros setting
+ // BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
+ // macroProvider.expandMacrosInBuildfile(this,
+ // macroProvider.areMacrosExpandedInBuildfile(baseCfg));
+
+ //copy user-defined build macros
+ /* UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
+ userMacros.setMacros(
+ userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
+ BuildMacroProvider.CONTEXT_CONFIGURATION,
+ this);
+ */
+ //copy user-defined environment
+ // UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
+ // userEnv.setVariables(
+ // userEnv.getVariables(cloneConfig), this);
+
+ // }
+
+ // Hook me up
+ managedProject.addConfiguration(this);
+
+ IBuilder builder = getEditableBuilder();
+ try {
+ builder.setManagedBuildOn(false);
+ } catch (CoreException e) {
+ }
+
+ propertiesChanged();
+ }
+ setDirty(true);
+ setRebuildState(true);
+ }
+
+ public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
+ this(managedProject, cloneConfig, id, cloneChildren, temporary, false);
+ }
+
/**
* Create a new project, non-extension, configuration based on one already defined.
*
@@ -304,20 +515,33 @@ public class Configuration extends BuildObject implements IConfiguration {
* @param id A unique ID for the new configuration.
* @param cloneChildren If <code>true</code>, the configuration's tools are cloned
*/
- public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
+ public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary, boolean isPreferenceConfig) {
setId(id);
setName(cloneConfig.getName());
- this.description = cloneConfig.getDescription();
+ this.isPreferenceConfig = isPreferenceConfig;
this.managedProject = managedProject;
isExtensionConfig = false;
this.isTemporary = temporary;
+
+ copySettingsFrom(cloneConfig, cloneChildren);
+ }
+
+ private void copySettingsFrom(Configuration cloneConfig, boolean cloneChildren){
+ fCfgData = new BuildConfigurationData(this);
+ if(cloneConfig.buildProperties != null)
+ this.buildProperties = new BuildObjectProperties(cloneConfig.buildProperties, this, this);
+
+ this.description = cloneConfig.getDescription();
// set managedBuildRevision
setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
-
+
+ if(!cloneConfig.isExtensionConfig)
+ cloneChildren = true;
// If this contructor is called to clone an existing
// configuration, the parent of the cloning config should be stored.
- parent = cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
+ parent = cloneConfig.isExtensionConfig || cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
+ parentId = parent.getId();
// Copy the remaining attributes
projectType = cloneConfig.projectType;
@@ -345,95 +569,88 @@ public class Configuration extends BuildObject implements IConfiguration {
if (cloneConfig.postannouncebuildStep != null) {
postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
}
+ if(cloneConfig.sourcePaths != null)
+ sourcePaths = (IPath[])cloneConfig.sourcePaths.clone();
- enableInternalBuilder(cloneConfig.isInternalBuilderEnabled());
- setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr());
- setInternalBuilderParallel(cloneConfig.getInternalBuilderParallel());
- setParallelDef(cloneConfig.getParallelDef());
- setParallelNumber(cloneConfig.getParallelNumber());
+// enableInternalBuilder(cloneConfig.isInternalBuilderEnabled());
+// setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr());
+// setInternalBuilderParallel(cloneConfig.getInternalBuilderParallel());
+// setParallelDef(cloneConfig.getParallelDef());
+// setParallelNumber(cloneConfig.getParallelNumber());
// internalBuilderEnabled = cloneConfig.internalBuilderEnabled;
// internalBuilderIgnoreErr = cloneConfig.internalBuilderIgnoreErr;
// Clone the configuration's children
// Tool Chain
+ boolean copyIds = cloneConfig.getId().equals(id);
String subId;
- String subName;
- if (cloneConfig.parent != null) {
- subId = ManagedBuildManager.calculateChildId(
- cloneConfig.parent.getToolChain().getId(),
- null);
- subName = cloneConfig.parent.getToolChain().getName();
-
- } else {
- subId = ManagedBuildManager.calculateChildId(
- cloneConfig.getToolChain().getId(),
- null);
- subName = cloneConfig.getToolChain().getName();
+ // Resource Configurations
+ Map toolIdMap = new HashMap();
+ IResourceInfo infos[] = cloneConfig.rcInfos.getResourceInfos();
+ for(int i = 0; i < infos.length; i++){
+ if(infos[i] instanceof FolderInfo){
+ FolderInfo folderInfo = (FolderInfo)infos[i];
+ subId = copyIds ? folderInfo.getId() : ManagedBuildManager.calculateChildId(getId(), folderInfo.getPath().toString());
+ FolderInfo newFolderInfo = new FolderInfo(this, folderInfo, subId, toolIdMap, cloneChildren);
+ addResourceConfiguration(newFolderInfo);
+ } else {
+ ResourceConfiguration fileInfo = (ResourceConfiguration)infos[i];
+ subId = copyIds ? fileInfo.getId() : ManagedBuildManager.calculateChildId(getId(), fileInfo.getPath().toString());
+ ResourceConfiguration newResConfig = new ResourceConfiguration(this, fileInfo, subId, toolIdMap, cloneChildren);
+ addResourceConfiguration(newResConfig);
+
+ }
}
- if (cloneChildren) {
- toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain());
-
+ resolveProjectReferences(false);
+
+ if(cloneChildren){
//copy expand build macros setting
BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
macroProvider.expandMacrosInBuildfile(this,
macroProvider.areMacrosExpandedInBuildfile(cloneConfig));
//copy user-defined build macros
- UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
+/* UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
userMacros.setMacros(
userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
BuildMacroProvider.CONTEXT_CONFIGURATION,
this);
-
+*/
//copy user-defined environment
- UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
- userEnv.setVariables(
- userEnv.getVariables(cloneConfig), this);
+// UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
+// userEnv.setVariables(
+// userEnv.getVariables(cloneConfig), this);
- } else {
- // Add a tool-chain element that specifies as its superClass the
- // tool-chain that is the child of the configuration.
- ToolChain superChain = (ToolChain)cloneConfig.getToolChain();
- subId = ManagedBuildManager.calculateChildId(
- superChain.getId(),
- null);
- IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false);
-
- // For each option/option category child of the tool-chain that is
- // the child of the selected configuration element, create an option/
- // option category child of the cloned configuration's tool-chain element
- // that specifies the original tool element as its superClass.
- newChain.createOptions(superChain);
-
- // For each tool element child of the tool-chain that is the child of
- // the selected configuration element, create a tool element child of
- // the cloned configuration's tool-chain element that specifies the
- // original tool element as its superClass.
- ITool[] tools = superChain.getTools();
- for (int i=0; i<tools.length; i++) {
- Tool toolChild = (Tool)tools[i];
- subId = ManagedBuildManager.calculateChildId(toolChild.getId(),null);
- newChain.createTool(toolChild, subId, toolChild.getName(), false);
- }
- }
-
- // Resource Configurations
- if (cloneConfig.resourceConfigurationList != null) {
- List resElements = cloneConfig.getResourceConfigurationList();
- Iterator iter = resElements.listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
- subId = ManagedBuildManager.calculateChildId(getId(), resConfig.getResourcePath());
- ResourceConfiguration newResConfig = new ResourceConfiguration(this, resConfig, subId);
- addResourceConfiguration(newResConfig);
- }
}
// Hook me up
+ if(managedProject != null){
+ managedProject.addConfiguration(this);
+ }
+
+ if(cloneConfig.isExtensionConfig){
+ propertiesChanged();
+ }
+
+ if(copyIds){
+ rebuildNeeded = cloneConfig.rebuildNeeded;
+ resourceChangeState = cloneConfig.resourceChangeState;
+ isDirty = cloneConfig.isDirty;
+ } else {
+ if(cloneConfig.isExtensionConfig)
+ exportArtifactInfo();
+ setDirty(true);
+ setRebuildState(true);
+ }
+
+ }
+
+ public void applyToManagedProject(ManagedProject mProj){
+ managedProject = mProj;
+ isPreferenceConfig = false;
+ isTemporary = false;
managedProject.addConfiguration(this);
- setDirty(true);
- setRebuildState(true);
}
/*
@@ -459,11 +676,11 @@ public class Configuration extends BuildObject implements IConfiguration {
description = element.getAttribute(IConfiguration.DESCRIPTION);
// parent
- String parentID = element.getAttribute(IConfiguration.PARENT);
- if (parentID != null) {
- // Lookup the parent configuration by ID
- parent = ManagedBuildManager.getExtensionConfiguration(parentID);
- }
+ parentId = element.getAttribute(IConfiguration.PARENT);
+// if (parentID != null) {
+// // Lookup the parent configuration by ID
+// parent = ManagedBuildManager.getExtensionConfiguration(parentID);
+// }
// Get the name of the build artifact associated with configuration
artifactName = element.getAttribute(ARTIFACT_NAME);
@@ -483,7 +700,11 @@ public class Configuration extends BuildObject implements IConfiguration {
// Get the pre-build and post-build announcements
preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
- postannouncebuildStep = element.getAttribute(POSTANNOUNCEBUILD_STEP);
+ postannouncebuildStep = element.getAttribute(POSTANNOUNCEBUILD_STEP);
+
+ String tmp = element.getAttribute(IS_SYSTEM);
+ if(tmp != null)
+ isTest = Boolean.valueOf(tmp).booleanValue();
}
/* (non-Javadoc)
@@ -492,22 +713,27 @@ public class Configuration extends BuildObject implements IConfiguration {
*
* @param element An XML element containing the configuration information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IConfiguration.ID));
// name
- if (element.hasAttribute(IConfiguration.NAME))
+ if (element.getAttribute(IConfiguration.NAME) != null)
setName(element.getAttribute(IConfiguration.NAME));
// description
- if (element.hasAttribute(IConfiguration.DESCRIPTION))
+ if (element.getAttribute(IConfiguration.DESCRIPTION) != null)
this.description = element.getAttribute(IConfiguration.DESCRIPTION);
- if (element.hasAttribute(IConfiguration.PARENT)) {
+ String props = element.getAttribute(BUILD_PROPERTIES);
+ if(props != null)
+ buildProperties = new BuildObjectProperties(props, this, this);
+
+ if (element.getAttribute(IConfiguration.PARENT) != null) {
// See if the parent belongs to the same project
- parent = managedProject.getConfiguration(element.getAttribute(IConfiguration.PARENT));
+ if(managedProject != null)
+ parent = managedProject.getConfiguration(element.getAttribute(IConfiguration.PARENT));
// If not, then try the extension configurations
if (parent == null) {
parent = ManagedBuildManager.getExtensionConfiguration(element.getAttribute(IConfiguration.PARENT));
@@ -516,40 +742,40 @@ public class Configuration extends BuildObject implements IConfiguration {
// Get the name of the build artifact associated with target (usually
// in the plugin specification).
- if (element.hasAttribute(ARTIFACT_NAME)) {
+ if (element.getAttribute(ARTIFACT_NAME) != null) {
artifactName = element.getAttribute(ARTIFACT_NAME);
}
// Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(ERROR_PARSERS)) {
+ if (element.getAttribute(ERROR_PARSERS) != null) {
errorParserIds = element.getAttribute(ERROR_PARSERS);
}
// Get the artifact extension
- if (element.hasAttribute(EXTENSION)) {
+ if (element.getAttribute(EXTENSION) != null) {
artifactExtension = element.getAttribute(EXTENSION);
}
// Get the clean command
- if (element.hasAttribute(CLEAN_COMMAND)) {
+ if (element.getAttribute(CLEAN_COMMAND) != null) {
cleanCommand = element.getAttribute(CLEAN_COMMAND);
}
// Get the pre-build and post-build commands
- if (element.hasAttribute(PREBUILD_STEP)) {
+ if (element.getAttribute(PREBUILD_STEP) != null) {
prebuildStep = element.getAttribute(PREBUILD_STEP);
}
- if (element.hasAttribute(POSTBUILD_STEP)) {
+ if (element.getAttribute(POSTBUILD_STEP) != null) {
postbuildStep = element.getAttribute(POSTBUILD_STEP);
}
// Get the pre-build and post-build announcements
- if (element.hasAttribute(PREANNOUNCEBUILD_STEP)) {
+ if (element.getAttribute(PREANNOUNCEBUILD_STEP) != null) {
preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
}
- if (element.hasAttribute(POSTANNOUNCEBUILD_STEP)) {
+ if (element.getAttribute(POSTANNOUNCEBUILD_STEP) != null) {
postannouncebuildStep = element
.getAttribute(POSTANNOUNCEBUILD_STEP);
}
@@ -561,7 +787,7 @@ public class Configuration extends BuildObject implements IConfiguration {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
element.setAttribute(IConfiguration.ID, id);
if (name != null)
@@ -570,6 +796,9 @@ public class Configuration extends BuildObject implements IConfiguration {
if (description != null)
element.setAttribute(IConfiguration.DESCRIPTION, description);
+ if(buildProperties != null)
+ element.setAttribute(BUILD_PROPERTIES, buildProperties.toString());
+
if (parent != null)
element.setAttribute(IConfiguration.PARENT, parent.getId());
@@ -598,20 +827,24 @@ public class Configuration extends BuildObject implements IConfiguration {
element.setAttribute(POSTANNOUNCEBUILD_STEP, postannouncebuildStep);
// Serialize my children
- Element toolChainElement = doc.createElement(IToolChain.TOOL_CHAIN_ELEMENT_NAME);
- element.appendChild(toolChainElement);
- toolChain.serialize(doc, toolChainElement);
- List resElements = getResourceConfigurationList();
- Iterator iter = resElements.listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
- Element resElement = doc.createElement(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME);
- element.appendChild(resElement);
- resConfig.serialize(doc, resElement);
+ IResourceInfo infos[] = rcInfos.getResourceInfos();
+ for(int i = 0; i < infos.length; i++){
+ String elementName = infos[i].getKind() == ICSettingBase.SETTING_FILE ? IFileInfo.FILE_INFO_ELEMENT_NAME :
+ IFolderInfo.FOLDER_INFO_ELEMENT_NAME;
+
+ ICStorageElement resElement = element.createChild(elementName);
+ ((ResourceInfo)infos[i]).serialize(resElement);
}
PropertyManager.getInstance().serialize(this);
+ if(sourcePaths != null && sourcePaths.length > 0){
+ for(int i = 0; i < sourcePaths.length; i++){
+ SourcePath p = new SourcePath(sourcePaths[i]);
+ ICStorageElement el = element.createChild(SourcePath.ELEMENT_NAME);
+ p.serialize(el);
+ }
+ }
// I am clean now
isDirty = false;
}
@@ -656,111 +889,84 @@ public class Configuration extends BuildObject implements IConfiguration {
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain(IToolChain, String, String, boolean)
*/
public IToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement) {
- toolChain = new ToolChain(this, superClass, Id, name, isExtensionElement);
- setDirty(true);
- return (IToolChain)toolChain;
+ if(rootFolderInfo == null){
+ createRootFolderInfo();
+ }
+
+ return rootFolderInfo.createToolChain(superClass, Id, name, isExtensionElement);
}
+ private IFolderInfo createRootFolderInfo(){
+ String id = ManagedBuildManager.calculateChildId(this.id, null);
+ String name = "/";
+
+ rootFolderInfo = new FolderInfo(this, new Path(name), id, name, isExtensionConfig);
+ addResourceConfiguration(rootFolderInfo);
+ return rootFolderInfo;
+ }
+/*
+ public IFolderInfo createFolderInfo(IPath path, IToolChain superClass, String Id, String name){
+
+ }
+
+ public IFolderInfo createFolderInfo(IPath path, IFolderInfo baseFolderInfo, String Id, String name){
+
+ }
+*/
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain()
*/
public IToolChain getToolChain() {
- return (IToolChain)toolChain;
+ return rootFolderInfo.getToolChain();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getResourceConfigurations()
*/
public IResourceConfiguration[] getResourceConfigurations() {
- IResourceConfiguration[] resConfigs = new IResourceConfiguration[getResourceConfigurationList().size()];
- Iterator iter = getResourceConfigurationList().listIterator();
- int i = 0;
- while (iter.hasNext()) {
- ResourceConfiguration resConfig = (ResourceConfiguration)iter.next();
- resConfigs[i++] = (IResourceConfiguration)resConfig;
- }
- return resConfigs;
+ return (IResourceConfiguration[])rcInfos.getResourceInfos(ICSettingBase.SETTING_FILE, IResourceConfiguration.class);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfiguration(java.lang.String)
*/
public IResourceConfiguration getResourceConfiguration(String resPath) {
- ResourceConfiguration resConfig = (ResourceConfiguration)getResourceConfigurationMap().get(resPath);
- return (IResourceConfiguration)resConfig;
+ return rcInfos.getFileInfo(new Path(resPath).removeFirstSegments(1));
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
*/
public ITool[] getFilteredTools() {
- if (toolChain == null) {
- return new ITool[0];
- }
- ITool[] localTools = toolChain.getTools();
- IManagedProject manProj = getManagedProject();
- if (manProj == null) {
- // If this is not associated with a project, then there is nothing to filter with
- return localTools;
- }
- IProject project = (IProject)manProj.getOwner();
- Vector tools = new Vector(localTools.length);
- for (int i = 0; i < localTools.length; i++) {
- ITool tool = localTools[i];
- try {
- // Make sure the tool is right for the project
- switch (tool.getNatureFilter()) {
- case ITool.FILTER_C:
- if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- tools.add(tool);
- }
- break;
- case ITool.FILTER_CC:
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- tools.add(tool);
- }
- break;
- case ITool.FILTER_BOTH:
- tools.add(tool);
- break;
- default:
- break;
- }
- } catch (CoreException e) {
- continue;
- }
- }
-
- // Answer the filtered tools as an array
- return (ITool[])tools.toArray(new ITool[tools.size()]);
+ return rootFolderInfo.getFilteredTools();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
*/
public ITool[] getTools() {
- return toolChain.getTools();
+ return rootFolderInfo.getTools();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTool(java.lang.String)
*/
public ITool getTool(String id) {
- return toolChain.getTool(id);
+ return rootFolderInfo.getTool(id);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String)
*/
public ITool[] getToolsBySuperClassId(String id) {
- return toolChain.getToolsBySuperClassId(id);
+ return rootFolderInfo.getToolsBySuperClassId(id);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
*/
public ITool getTargetTool() {
- String[] targetToolIds = toolChain.getTargetToolList();
+ String[] targetToolIds = rootFolderInfo.getToolChain().getTargetToolList();
if (targetToolIds == null || targetToolIds.length == 0) return null;
// For each target tool id, in list order,
@@ -803,107 +1009,43 @@ public class Configuration extends BuildObject implements IConfiguration {
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
*/
public IOption setOption(IHoldsOptions holder, IOption option, boolean value) throws BuildException {
- // Is there a change?
- IOption retOpt = option;
- if (option.getBooleanValue() != value) {
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
-// rebuildNeeded = true;
- }
- return retOpt;
+ return getRootFolderInfo().setOption(holder, option, value);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
*/
public IOption setOption(IHoldsOptions holder, IOption option, String value) throws BuildException {
- IOption retOpt = option;
- String oldValue;
- oldValue = option.getStringValue();
- if (oldValue != null && !oldValue.equals(value)) {
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
-// rebuildNeeded = true;
- }
- return retOpt;
+ return getRootFolderInfo().setOption(holder, option, value);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
*/
public IOption setOption(IHoldsOptions holder, IOption option, String[] value) throws BuildException {
- IOption retOpt = option;
- // Is there a change?
- String[] oldValue;
- switch (option.getValueType()) {
- case IOption.STRING_LIST :
- oldValue = option.getStringListValue();
- break;
- case IOption.INCLUDE_PATH :
- oldValue = option.getIncludePaths();
- break;
- case IOption.PREPROCESSOR_SYMBOLS :
- oldValue = option.getDefinedSymbols();
- break;
- case IOption.LIBRARIES :
- oldValue = option.getLibraries();
- break;
- case IOption.OBJECTS :
- oldValue = option.getUserObjects();
- break;
- default :
- oldValue = new String[0];
- break;
- }
- if(!Arrays.equals(value, oldValue)) {
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
-// rebuildNeeded = true;
- }
- return retOpt;
- }
-
- /* (non-Javadoc)
- * Safe accessor for the list of resource configs.
- *
- * @return List containing the tools
- */
- private List getResourceConfigurationList() {
- if (resourceConfigurationList == null) {
- resourceConfigurationList = new ArrayList();
- }
- return resourceConfigurationList;
+ return getRootFolderInfo().setOption(holder, option, value);
}
/* (non-Javadoc)
- * Safe accessor for the map of resource paths to resource configs
- *
- * @return
- */
- private Map getResourceConfigurationMap() {
- if (resourceConfigurationMap == null) {
- resourceConfigurationMap = new HashMap();
- }
- return resourceConfigurationMap;
- }
-
- /* (non-Javadoc)
* Adds the Resource Configuration to the Resource Configuration list and map
*
* @param resConfig
*/
- public void addResourceConfiguration(ResourceConfiguration resConfig) {
- getResourceConfigurationList().add(resConfig);
- getResourceConfigurationMap().put(resConfig.getResourcePath(), resConfig);
+ void addResourceConfiguration(IResourceInfo resConfig) {
+ if(resConfig.getPath().segmentCount() == 0)
+ rootFolderInfo = (FolderInfo)resConfig;
+ rcInfos.addResourceInfo(resConfig);
isDirty = true;
// rebuildNeeded = true;
}
- public void removeResourceConfiguration(IResourceConfiguration resConfig) {
+ public void removeResourceConfiguration(IResourceInfo resConfig) {
ManagedBuildManager.performValueHandlerEvent(resConfig,
IManagedOptionValueHandler.EVENT_CLOSE);
- getResourceConfigurationList().remove(resConfig);
- getResourceConfigurationMap().remove(resConfig.getResourcePath());
+ ITool tools[] = resConfig.getTools();
+ rcInfos.removeResourceInfo(resConfig.getPath());
+ ((ResourceInfo)resConfig).removed();
+ BuildSettingsUtil.disconnectDepentents(this, tools);
isDirty = true;
rebuildNeeded = true;
}
@@ -1109,37 +1251,76 @@ public class Configuration extends BuildObject implements IConfiguration {
// If no error parsers are specified by the configuration, the default
// is
// the error parsers from the tool-chain
- if (errorParsers == null && toolChain != null) {
- errorParsers = toolChain.getErrorParserIds(this);
+ //TODO
+ if (errorParsers == null && rootFolderInfo != null) {
+ errorParsers = rootFolderInfo.getErrorParserIds();
}
return errorParsers;
}
+ public String getErrorParserIdsAttribute() {
+ if (errorParserIds != null) {
+ return errorParserIds;
+ }
+ // If I have a parent, ask it
+ String errorParsers = null;
+ if (parent != null) {
+ errorParsers = ((Configuration)parent).getErrorParserIdsAttribute();
+ }
+
+ return errorParsers;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserList()
*/
public String[] getErrorParserList() {
- String parserIDs = getErrorParserIds();
- String[] errorParsers;
- if (parserIDs != null) {
- // Check for an empty string
- if (parserIDs.length() == 0) {
- errorParsers = new String[0];
- } else {
- StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
- List list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- String[] strArr = {""}; //$NON-NLS-1$
- errorParsers = (String[]) list.toArray(strArr);
+// String parserIDs = getErrorParserIds();
+// String[] errorParsers;
+// if (parserIDs != null) {
+// // Check for an empty string
+// if (parserIDs.length() == 0) {
+// errorParsers = new String[0];
+// } else {
+// StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+// List list = new ArrayList(tok.countTokens());
+// while (tok.hasMoreElements()) {
+// list.add(tok.nextToken());
+// }
+// String[] strArr = {""}; //$NON-NLS-1$
+// errorParsers = (String[]) list.toArray(strArr);
+// }
+// } else {
+// // If no error parsers are specified, the default is
+// // all error parsers
+// errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
+// }
+// return errorParsers;
+ Set set = contributeErrorParsers(null, true);
+ String result[] = new String[set.size()];
+ set.toArray(result);
+ return result;
+ }
+
+ public Set contributeErrorParsers(Set set, boolean includeChildren) {
+ String parserIDs = getErrorParserIdsAttribute();
+ if(set == null)
+ set = new HashSet();
+ if (parserIDs != null && parserIDs.length() != 0) {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ while (tok.hasMoreElements()) {
+ set.add(tok.nextToken());
}
- } else {
- // If no error parsers are specified, the default is
- // all error parsers
- errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
}
- return errorParsers;
+
+ if(includeChildren){
+ IResourceInfo[] rcInfos = getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ ResourceInfo rcInfo = (ResourceInfo)rcInfos[i];
+ rcInfo.contributeErrorParsers(set);
+ }
+ }
+ return set;
}
/* (non-Javadoc)
@@ -1159,6 +1340,7 @@ public class Configuration extends BuildObject implements IConfiguration {
}
}
isDirty = true;
+// exportArtifactInfo();
}
}
@@ -1179,6 +1361,8 @@ public class Configuration extends BuildObject implements IConfiguration {
}
// rebuildNeeded = true;
isDirty = true;
+// exportArtifactInfo();
+
}
}
@@ -1231,7 +1415,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (builder.isExtensionElement()) {
String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
- builder = toolChain.createBuilder(builder, subId, builderName, false);
+ builder = getToolChain().createBuilder(builder, subId, builderName, false);
}
builder.setArguments(makeArgs);
// rebuildNeeded = true;
@@ -1253,7 +1437,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (builder.isExtensionElement()) {
String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
- builder = toolChain.createBuilder(builder, subId, builderName, false);
+ builder = getToolChain().createBuilder(builder, subId, builderName, false);
}
builder.setCommand(command);
// rebuildNeeded = true;
@@ -1323,40 +1507,7 @@ public class Configuration extends BuildObject implements IConfiguration {
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isHeaderFile(java.lang.String)
*/
public boolean isHeaderFile(String ext) {
- // Check to see if there is a rule to build a file with this extension
- IManagedProject manProj = getManagedProject();
- IProject project = null;
- if (manProj != null) {
- project = (IProject)manProj.getOwner();
- }
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- try {
- if (project != null) {
- // Make sure the tool is right for the project
- switch (tool.getNatureFilter()) {
- case ITool.FILTER_C:
- if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- return tool.isHeaderFile(ext);
- }
- break;
- case ITool.FILTER_CC:
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- return tool.isHeaderFile(ext);
- }
- break;
- case ITool.FILTER_BOTH:
- return tool.isHeaderFile(ext);
- }
- } else {
- return tool.isHeaderFile(ext);
- }
- } catch (CoreException e) {
- continue;
- }
- }
- return false;
+ return getRootFolderInfo().isHeaderFile(ext);
}
/*
@@ -1381,13 +1532,12 @@ public class Configuration extends BuildObject implements IConfiguration {
if (isDirty) return true;
// Otherwise see if any children need saving
- if (toolChain.isDirty()) return true;
- Iterator iter = getResourceConfigurationList().listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration current = (ResourceConfiguration) iter.next();
- if (current.isDirty()) return true;
- }
+ IResourceInfo infos[] = rcInfos.getResourceInfos();
+ for(int i = 0; i < infos.length; i++){
+ if(infos[i].isDirty())
+ return true;
+ }
return isDirty;
}
@@ -1408,24 +1558,10 @@ public class Configuration extends BuildObject implements IConfiguration {
if(needRebuild || !checkChildren)
return needRebuild;
- if(toolChain.needsRebuild())
- return true;
-
- for(Iterator iter = resourceConfigurationList.iterator();iter.hasNext();){
- IResourceConfiguration rcCfg = (IResourceConfiguration)iter.next();
- if(rcCfg.needsRebuild())
- return true;
-
- ITool tools[] = rcCfg.getToolsToInvoke();
- for(int i = 0; i < tools.length; i++){
- if(tools[i].needsRebuild())
- return true;
- }
- }
+ IResourceInfo infos[] = rcInfos.getResourceInfos();
- ITool tools[] = getFilteredTools();
- for(int i = 0; i < tools.length; i++){
- if(tools[i].needsRebuild())
+ for(int i = 0; i < infos.length; i++){
+ if(infos[i].needsRebuild())
return true;
}
@@ -1440,12 +1576,11 @@ public class Configuration extends BuildObject implements IConfiguration {
this.isDirty = isDirty;
// Propagate "false" to the children
if (!isDirty) {
- toolChain.setDirty(false);
- Iterator iter = getResourceConfigurationList().listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration current = (ResourceConfiguration) iter.next();
- current.setDirty(false);
- }
+ IResourceInfo infos[] = rcInfos.getResourceInfos();
+
+ for(int i = 0; i < infos.length; i++){
+ infos[i].setDirty(false);
+ }
}
}
@@ -1464,23 +1599,10 @@ public class Configuration extends BuildObject implements IConfiguration {
if(!rebuildNeeded){
setResourceChangeState(0);
- toolChain.setRebuildState(false);
-
- if(resourceConfigurationList != null){
- for(Iterator iter = resourceConfigurationList.iterator();iter.hasNext();){
- IResourceConfiguration rcCfg = (IResourceConfiguration)iter.next();
- rcCfg.setRebuildState(false);
-
- ITool tools[] = rcCfg.getToolsToInvoke();
- for(int i = 0; i < tools.length; i++){
- tools[i].setRebuildState(false);
- }
- }
- }
-
- ITool tools[] = getFilteredTools();
- for(int i = 0; i < tools.length; i++){
- tools[i].setRebuildState(false);
+ IResourceInfo infos[] = rcInfos.getResourceInfos();
+
+ for(int i = 0; i < infos.length; i++){
+ infos[i].setRebuildState(false);
}
}
}
@@ -1521,12 +1643,17 @@ public class Configuration extends BuildObject implements IConfiguration {
resolved = true;
// call resolve references on any children
- toolChain.resolveReferences();
- Iterator resConfigIter = getResourceConfigurationList().iterator();
- while (resConfigIter.hasNext()) {
- ResourceConfiguration current = (ResourceConfiguration)resConfigIter.next();
- current.resolveReferences();
+ ResourceInfo infos[] = (ResourceInfo[])rcInfos.getResourceInfos(ResourceInfo.class);
+
+ for(int i = 0; i < infos.length; i++){
+ infos[i].resolveReferences();
}
+
+ if (parentId != null) {
+ // Lookup the parent configuration by ID
+ parent = ManagedBuildManager.getExtensionConfiguration(parentId);
+ }
+
}
}
@@ -1534,61 +1661,58 @@ public class Configuration extends BuildObject implements IConfiguration {
* Reset the configuration's, tools', options
*/
public void reset() {
- // We just need to remove all Options
- ITool[] tools = getTools();
- IToolChain toolChain = getToolChain();
- IOption[] opts;
-
- // Send out the event to notify the options that they are about to be removed.
- // Do not do this for the child resource configurations as they are handled when
- // the configuration itself is destroyed.
-// ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE, false);
- // Remove the configurations
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- opts = tool.getOptions();
- for (int j = 0; j < opts.length; j++) {
- tool.removeOption(opts[j]);
- }
- }
- opts = toolChain.getOptions();
- for (int j = 0; j < opts.length; j++) {
- toolChain.removeOption(opts[j]);
- }
-
-// rebuildNeeded = true;
+ ((FolderInfo)getRootFolderInfo()).resetOptionSettings();
}
/*
* Create a resource configuration object for the passed-in file
*/
public IResourceConfiguration createResourceConfiguration(IFile file)
- {
- String path = file.getFullPath().toString();
- String resourceName = file.getName();
- String id = ManagedBuildManager.calculateChildId(getId(), path);
- ResourceConfiguration resConfig = new ResourceConfiguration( (IConfiguration) this, id, resourceName, path);
-
- // Get file extension.
- String extString = file.getFileExtension();
-
- // Add the resource specific tools to this resource.
- ITool tools[] = getFilteredTools();
- String subId = new String();
- for (int i = 0; i < tools.length; i++) {
- if( tools[i].buildsFileType(extString) ) {
- subId = ManagedBuildManager.calculateChildId(tools[i].getId(), path);
- resConfig.createTool(tools[i], subId, tools[i].getName(), false);
- }
- }
+ {
+ return createFileInfo(file.getFullPath().removeFirstSegments(1));
- // Add this resource to the list.
- addResourceConfiguration(resConfig);
- ManagedBuildManager.performValueHandlerEvent(resConfig, IManagedOptionValueHandler.EVENT_OPEN);
-
- return resConfig;
+ }
+
+ public IFileInfo createFileInfo(IPath path){
+ String resourceName = path.lastSegment();
+ String id = ManagedBuildManager.calculateChildId(getId(), path.toString());
+ return createFileInfo(path, id, resourceName);
+ }
+
+ public IFileInfo createFileInfo(IPath path, String id, String name){
+ IResourceInfo info = getResourceInfo(path, false);
+ IFileInfo fileInfo = null;
+ if(info instanceof IFileInfo){
+ fileInfo = (IFileInfo)info;
+ } else if (info instanceof IFolderInfo){
+ IFolderInfo base = (IFolderInfo)info;
+ fileInfo = createFileInfo(path, base, null, id, name);
+ }
+ return fileInfo;
}
+ public IFileInfo createFileInfo(IPath path, IFolderInfo base, ITool baseTool, String id, String name){
+ if(base.getPath().equals(path))
+ return null;
+
+ IFileInfo fileInfo = new ResourceConfiguration((FolderInfo)base, baseTool, id, name, path);
+ addResourceConfiguration(fileInfo);
+ ManagedBuildManager.performValueHandlerEvent(fileInfo, IManagedOptionValueHandler.EVENT_OPEN);
+
+ return fileInfo;
+ }
+
+ public IFileInfo createFileInfo(IPath path, IFileInfo base, String id, String name){
+ if(base.getPath().equals(path))
+ return null;
+
+ IFileInfo fileInfo = new ResourceConfiguration((ResourceConfiguration)base, path, id, name);
+ addResourceConfiguration(fileInfo);
+ ManagedBuildManager.performValueHandlerEvent(fileInfo, IManagedOptionValueHandler.EVENT_OPEN);
+
+ return fileInfo;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEnvironmentVariableSupplier()
*/
@@ -1604,8 +1728,8 @@ public class Configuration extends BuildObject implements IConfiguration {
*/
public PluginVersionIdentifier getVersion() {
if ( version == null) {
- if ( toolChain != null) {
- return toolChain.getVersion();
+ if ( rootFolderInfo.getToolChain() != null) {
+ return rootFolderInfo.getToolChain().getVersion();
}
}
return version;
@@ -1638,10 +1762,11 @@ public class Configuration extends BuildObject implements IConfiguration {
*/
public void updateManagedBuildRevision(String revision){
super.updateManagedBuildRevision(revision);
- toolChain.updateManagedBuildRevision(revision);
- for(Iterator iter = getResourceConfigurationList().iterator(); iter.hasNext();){
- ((ResourceConfiguration)iter.next()).updateManagedBuildRevision(revision);
+ ResourceInfo infos[] = (ResourceInfo[])rcInfos.getResourceInfos(ResourceInfo.class);
+
+ for(int i = 0; i < infos.length; i++){
+ infos[i].updateManagedBuildRevision(revision);
}
}
@@ -1676,29 +1801,11 @@ public class Configuration extends BuildObject implements IConfiguration {
}
public ITool getToolFromOutputExtension(String extension) {
- // Treat a null argument as an empty string
- String ext = extension == null ? EMPTY_STRING : extension;
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- return tool;
- }
- }
- return null;
+ return getRootFolderInfo().getToolFromOutputExtension(extension);
}
public ITool getToolFromInputExtension(String sourceExtension) {
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(sourceExtension)) {
- return tool;
- }
- }
- return null;
+ return getRootFolderInfo().getToolFromInputExtension(sourceExtension);
}
/*
@@ -1757,7 +1864,7 @@ public class Configuration extends BuildObject implements IConfiguration {
*
*/
- public void setInternalBuilderBoolean(boolean value, String pref) {
+/* public void setInternalBuilderBoolean(boolean value, String pref) {
Preferences prefs = getPreferences(INTERNAL_BUILDER);
if(prefs != null){
prefs.putBoolean(pref, value);
@@ -1766,13 +1873,13 @@ public class Configuration extends BuildObject implements IConfiguration {
} catch (BackingStoreException e) {}
}
}
-
- public boolean getInternalBuilderBoolean(String pref, boolean defaultValue) {
+*/
+/* public boolean getInternalBuilderBoolean(String pref, boolean defaultValue) {
Preferences prefs = getPreferences(INTERNAL_BUILDER);
return prefs != null ?
prefs.getBoolean(pref, false) : defaultValue;
}
-
+*/
/*
* this method is used for enabling/disabling the internal builder
* for the given configuration
@@ -1780,18 +1887,122 @@ public class Configuration extends BuildObject implements IConfiguration {
* @param enable boolean
*/
public void enableInternalBuilder(boolean enable){
-// if(internalBuilderEnabled != enable){
- internalBuilderEnabled = enable;
- setInternalBuilderBoolean(enable, INTERNAL_BUILDER_ENABLED);
-// }
+ if(enable == isInternalBuilderEnabled())
+ return;
+
+ IBuilder builder = getBuilderForInternalBuilderEnablement(enable, true);
+ if(builder != null){
+ if(enable){
+ savePrevBuilderId(getBuilder());
+ }
+
+ changeBuilder(builder,
+ ManagedBuildManager.calculateChildId(builder.getId(), null),
+ builder.getName(),
+ true);
+
+ if(enable){
+ try {
+ setManagedBuildOn(true);
+ } catch (BuildException e) {
+ }
+ }
+ }
+ }
+
+ public boolean canEnableInternalBuilder(boolean enable){
+ return getBuilderForInternalBuilderEnablement(enable, true) != null;
+ }
+
+ private IBuilder getBuilderForInternalBuilderEnablement(boolean enable, boolean checkCompatibility){
+ IBuilder newBuilder = null;
+ if(enable){
+ if(supportsBuild(true, false)){
+ IBuilder b = ManagedBuildManager.getInternalBuilder();
+ if(b != null){
+ if(!checkCompatibility || isBuilderCompatible(b))
+ newBuilder = b;
+ }
+ }
+ } else {
+ String id = getPrevBuilderId();
+ if(id != null){
+ IBuilder b = ManagedBuildManager.getExtensionBuilder(id);
+ if(b != null){
+ if(!checkCompatibility || isBuilderCompatible(b))
+ newBuilder = b;
+ }
+ }
+ if(newBuilder == null){
+ for(IToolChain tc = getToolChain(); tc != null; tc = tc.getSuperClass()){
+ IBuilder b = tc.getBuilder();
+ if(b.isInternalBuilder())
+ continue;
+
+ for(;b != null && !b.isExtensionElement(); b = b.getSuperClass());
+
+ if(b != null){
+ if(!checkCompatibility || isBuilderCompatible(b)){
+ newBuilder = b;
+ break;
+ }
+ }
+ }
+ }
+
+ if(newBuilder == null){
+ IBuilder builders[] = ManagedBuildManager.getRealBuilders();
+ IBuilder tmpB = null;
+ for(int i = 0; i < builders.length; i++){
+ IBuilder b = builders[i];
+ if(b.isInternalBuilder())
+ continue;
+
+
+ if(isBuilderCompatible(b)){
+ newBuilder = b;
+ break;
+ } else if(!checkCompatibility){
+ tmpB = b;
+ }
+ }
+
+ if(newBuilder == null){
+ if(tmpB != null)
+ newBuilder = tmpB;
+ }
+ }
+
+ }
+
+ return newBuilder;
}
+ private void savePrevBuilderId(IBuilder builder){
+ IBuilder b = builder;
+ for(;b != null && !b.isExtensionElement(); b = b.getSuperClass());
+
+ if(b == null)
+ b = builder;
+
+ ToolChain tc = (ToolChain)getToolChain();
+ if(tc != null)
+ tc.setNonInternalBuilderId(b.getId());
+ }
+
+ private String getPrevBuilderId(){
+ ToolChain tc = (ToolChain)getToolChain();
+ if(tc != null)
+ return tc.getNonInternalBuilderId();
+ return null;
+ }
+
/*
* returns whether the internal builder is enabled
* @return boolean
*/
public boolean isInternalBuilderEnabled(){
- return getInternalBuilderBoolean(INTERNAL_BUILDER_ENABLED, internalBuilderEnabled);
+ return getBuilder().isInternalBuilder();
}
/*
@@ -1803,10 +2014,10 @@ public class Configuration extends BuildObject implements IConfiguration {
* otherwise it will stop at the first build error
*/
public void setInternalBuilderIgnoreErr(boolean ignore){
-// if(internalBuilderIgnoreErr != ignore){
- internalBuilderIgnoreErr = ignore;
- setInternalBuilderBoolean(ignore, INTERNAL_BUILDER_IGNORE_ERR);
-// }
+ try {
+ getEditableBuilder().setStopOnError(!ignore);
+ } catch (CoreException e) {
+ }
}
/*
@@ -1817,7 +2028,7 @@ public class Configuration extends BuildObject implements IConfiguration {
* @return boolean
*/
public boolean getInternalBuilderIgnoreErr(){
- return getInternalBuilderBoolean(INTERNAL_BUILDER_IGNORE_ERR, internalBuilderIgnoreErr);
+ return !getBuilder().isStopOnError();
}
/**
@@ -1827,8 +2038,13 @@ public class Configuration extends BuildObject implements IConfiguration {
* @param parallel if true, internal builder will use parallel mode
*/
public void setInternalBuilderParallel(boolean parallel){
- internalBuilderParallel = parallel;
- setInternalBuilderBoolean(parallel, INTERNAL_BUILDER_PARALLEL);
+ if(getInternalBuilderParallel() == parallel)
+ return;
+
+ try {
+ getEditableBuilder().setParallelBuildOn(parallel);
+ } catch (CoreException e) {
+ }
}
/**
@@ -1839,22 +2055,34 @@ public class Configuration extends BuildObject implements IConfiguration {
* @return boolean
*/
public boolean getInternalBuilderParallel(){
- return getInternalBuilderBoolean(INTERNAL_BUILDER_PARALLEL, internalBuilderParallel);
+ return getBuilder().isParallelBuildOn();
}
/**
* @param parallel if true, internal builder will use parallel mode
*/
public void setParallelDef(boolean parallel_def){
- internalBuilderParallelDef = parallel_def;
- setInternalBuilderBoolean(parallel_def, INTERNAL_BUILDER_PARALLEL_DEF);
+ if(getParallelDef() == parallel_def)
+ return;
+
+ int num = getParallelNumber();
+ if(num != 0){
+ setParallelNumber(-num);
+ } else {
+ if(parallel_def){
+ setParallelNumber(-1);
+ } else {
+ setParallelNumber(1);
+ }
+ }
}
/**
* @return boolean
*/
public boolean getParallelDef(){
- return getInternalBuilderBoolean(INTERNAL_BUILDER_PARALLEL_DEF, internalBuilderParallelDef);
+ int num = getBuilder().getParallelizationNum();
+ return num <= 0;
}
/**
@@ -1864,12 +2092,9 @@ public class Configuration extends BuildObject implements IConfiguration {
* @param int
*/
public void setParallelNumber(int n){
- internalBuilderParallelNumber = n;
- Preferences prefs = getPreferences(INTERNAL_BUILDER);
- if(prefs != null){
- prefs.putInt(INTERNAL_BUILDER_PARALLELNUMBER, n);
- try { prefs.flush(); }
- catch (BackingStoreException e) {}
+ try {
+ getEditableBuilder().setParallelizationNum(n);
+ } catch (CoreException e) {
}
}
@@ -1879,12 +2104,7 @@ public class Configuration extends BuildObject implements IConfiguration {
* @return int
*/
public int getParallelNumber(){
- Preferences prefs = getPreferences(INTERNAL_BUILDER);
- int cpus = BuildProcessManager.checkCPUNumber();
- int x = prefs != null ?
- prefs.getInt(INTERNAL_BUILDER_PARALLELNUMBER, cpus) :
- internalBuilderParallelNumber;
- return (x > 0) ? x : 1;
+ return getBuilder().getParallelizationNum();
}
private Preferences getPreferences(String name){
@@ -1904,4 +2124,677 @@ public class Configuration extends BuildObject implements IConfiguration {
}
return prefs;
}
+
+ public IResourceInfo[] getResourceInfos() {
+ return rcInfos.getResourceInfos();
+ }
+
+ public IResourceInfo getResourceInfo(IPath path, boolean exactPath) {
+ return rcInfos.getResourceInfo(path, exactPath);
+ }
+
+ public IResourceInfo getResourceInfoById(String id) {
+ IResourceInfo infos[] = rcInfos.getResourceInfos();
+ for(int i = 0; i < infos.length; i++){
+ if(id.equals(infos[i].getId()))
+ return infos[i];
+ }
+ return null;
+ }
+
+ public IFolderInfo getRootFolderInfo() {
+ return rootFolderInfo;
+ }
+
+ ResourceInfoContainer getRcInfoContainer(IResourceInfo rcInfo){
+ PathSettingsContainer cr = pathSettings.getChildContainer(rcInfo.getPath(), true, true);
+ return new ResourceInfoContainer(cr, false);
+ }
+
+ public CConfigurationData getConfigurationData(){
+ return fCfgData;
+ }
+
+ public void removeResourceInfo(IPath path) {
+ IResourceInfo info = getResourceInfo(path, true);
+ if(info != null)
+ removeResourceConfiguration(info);
+ }
+
+ public IFolderInfo createFolderInfo(IPath path) {
+ String resourceName = path.lastSegment();
+ String id = ManagedBuildManager.calculateChildId(getId(), path.toString());
+ return createFolderInfo(path, id, resourceName);
+ }
+
+ public IFolderInfo createFolderInfo(IPath path, String id, String name) {
+ IResourceInfo info = getResourceInfo(path, false);
+ IFolderInfo folderInfo = null;
+ if(info instanceof IFileInfo){
+ folderInfo = null;
+ } else if (info instanceof IFolderInfo){
+ IFolderInfo base = (IFolderInfo)info;
+ folderInfo = createFolderInfo(path, base, id, name);
+ }
+ return folderInfo;
+ }
+
+ public IFolderInfo createFolderInfo(IPath path, IFolderInfo base, String id, String name) {
+ if(base.getPath().equals(path))
+ return null;
+
+ FolderInfo folderInfo = new FolderInfo((FolderInfo)base, id, name, path);
+ addResourceConfiguration(folderInfo);
+ folderInfo.propertiesChanged();
+ ManagedBuildManager.performValueHandlerEvent(folderInfo, IManagedOptionValueHandler.EVENT_OPEN);
+
+ return folderInfo;
+ }
+
+ public IPath[] getSourcePaths() {
+ if(sourcePaths == null){
+ if(parent != null)
+ return parent.getSourcePaths();
+ return new IPath[]{new Path("")};
+
+ }
+ return (IPath[])sourcePaths.clone();
+ }
+
+ public void setSourcePaths(IPath[] paths) {
+ if(Arrays.equals(sourcePaths, paths))
+ return;
+ sourcePaths = (IPath[])paths.clone();
+// for(int i = 0; i < sourcePaths.length; i++){
+// sourcePaths[i] = sourcePaths[i].makeRelative();
+// }
+ exportArtifactInfo();
+ setDirty(true);
+ setRebuildState(true);
+ }
+
+ public void setErrorParserAttribute(String[] ids) {
+ if(ids == null){
+ errorParserIds = null;
+ } else if(ids.length == 0){
+ errorParserIds = EMPTY_STRING;
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append(ids[0]);
+ for(int i = 1; i < ids.length; i++){
+ buf.append(";").append(ids[i]);
+ }
+ errorParserIds = buf.toString();
+ }
+ }
+
+ public void setErrorParserList(String[] ids) {
+ if(ids == null){
+ //reset
+ resetErrorParsers();
+ } else {
+ resetErrorParsers();
+ Set oldSet = contributeErrorParsers(null, true);
+ HashSet newSet = new HashSet();
+ newSet.addAll(Arrays.asList(ids));
+ newSet.remove(null);
+ HashSet newCopy = (HashSet)newSet.clone();
+ newSet.removeAll(oldSet);
+ oldSet.removeAll(newCopy);
+ Set removed = oldSet;
+ Set added = newSet;
+
+ removeErrorParsers(removed);
+ setErrorParserAttribute((String[])added.toArray(new String[added.size()]));
+ }
+ }
+
+ public void resetErrorParsers(){
+ errorParserIds = null;
+ IResourceInfo rcInfos[] = getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ ResourceInfo rcInfo = (ResourceInfo)rcInfos[i];
+ rcInfo.resetErrorParsers();
+ }
+ }
+
+ void removeErrorParsers(Set set){
+ Set oldSet = contributeErrorParsers(null, false);
+ oldSet.removeAll(set);
+ setErrorParserAttribute((String[])oldSet.toArray(new String[oldSet.size()]));
+
+ IResourceInfo rcInfos[] = getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ ResourceInfo rcInfo = (ResourceInfo)rcInfos[i];
+ rcInfo.removeErrorParsers(set);
+ }
+ }
+
+ public CBuildData getBuildData() {
+ return getEditableBuilder().getBuildData();
+ }
+
+ public IBuilder getEditableBuilder(){
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if(builder.isExtensionElement()){
+ String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
+ String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
+ builder = getToolChain().createBuilder(builder, subId, builderName, false);
+ }
+ return builder;
+ }
+
+ public IBuilder getBuilder(){
+ return getToolChain().getBuilder();
+ }
+
+ public String getOutputPrefix(String outputExtension) {
+ // Treat null extensions as empty string
+ String ext = outputExtension == null ? new String() : outputExtension;
+
+ // Get all the tools for the current config
+ String flags = new String();
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(ext)) {
+ flags = tool.getOutputPrefix();
+ }
+ }
+ return flags;
+ }
+
+ public ICConfigurationDescription getConfigurationDescription(){
+ return fCfgDes;
+ }
+
+ public void setConfigurationDescription(ICConfigurationDescription cfgDes){
+ fCfgDes = cfgDes;
+ }
+
+ public IBuildObjectProperties getBuildProperties() {
+ if(buildProperties == null){
+ BuildObjectProperties parentProps = findBuildProperties();
+ if(parentProps != null)
+ buildProperties = new BuildObjectProperties(parentProps, this, this);
+ else
+ buildProperties = new BuildObjectProperties(this, this);
+ }
+ return buildProperties;
+ }
+
+ private BuildObjectProperties findBuildProperties(){
+ if(buildProperties == null){
+ if(parent != null){
+ return ((Configuration)parent).findBuildProperties();
+ }
+ return null;
+ }
+ return buildProperties;
+ }
+
+ public boolean supportsType(IBuildPropertyType type) {
+ return supportsType(type.getId());
+ }
+
+ public boolean supportsValue(IBuildPropertyType type,
+ IBuildPropertyValue value) {
+ return supportsValue(type.getId(), value.getId());
+ }
+
+ public void propertiesChanged() {
+ if(isExtensionConfig)
+ return;
+
+ BooleanExpressionApplicabilityCalculator calculator = getBooleanExpressionCalculator();
+ if(calculator != null)
+ calculator.adjustConfiguration(this, false);
+
+ IResourceInfo infos[] = getResourceInfos();
+ for(int i = 0; i < infos.length; i++){
+ ((ResourceInfo)infos[i]).propertiesChanged();
+ }
+ }
+
+ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
+ if(booleanExpressionCalculator == null){
+ if(parent != null){
+ return ((Configuration)parent).getBooleanExpressionCalculator();
+ }
+ }
+ return booleanExpressionCalculator;
+ }
+
+ public boolean isSystemObject() {
+ if(isTest)
+ return true;
+
+ if(getProjectType() != null)
+ return getProjectType().isTestProjectType();
+
+ return false;
+ }
+
+ public String getOutputExtension(String resourceExtension) {
+ return getRootFolderInfo().getOutputExtension(resourceExtension);
+ }
+
+ public String getOutputFlag(String outputExt) {
+ // Treat null extension as an empty string
+ String ext = outputExt == null ? new String() : outputExt;
+
+ // Get all the tools for the current config
+ String flags = new String();
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ // It's OK
+ if (tool.producesFileType(ext)) {
+ flags = tool.getOutputFlag();
+ }
+ }
+ return flags;
+ }
+
+ public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(sourceExtension)) {
+ String cmd = tool.getToolCommand();
+ //try to resolve the build macros in the tool command
+ try{
+ String resolvedCommand = null;
+
+ if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$
+ (outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$
+ {
+ resolvedCommand = ManagedBuildManager
+ .getBuildMacroProvider().resolveValue(
+ cmd,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputLocation,
+ outputLocation, null,
+ tool));
+ }
+
+ else {
+ resolvedCommand = ManagedBuildManager
+ .getBuildMacroProvider()
+ .resolveValueToMakefileFormat(
+ cmd,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputLocation,
+ outputLocation, null,
+ tool));
+ }
+ if((resolvedCommand = resolvedCommand.trim()).length() > 0)
+ cmd = resolvedCommand;
+
+ } catch (BuildMacroException e){
+ }
+
+ IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
+ return gen.generateCommandLineInfo( tool, cmd,
+ flags, outputFlag, outputPrefix, outputName, inputResources,
+ tool.getCommandLinePattern() );
+ }
+ }
+ return null;
+ }
+
+ public String[] getUserObjects(String extension) {
+ Vector objs = new Vector();
+ ITool tool = calculateTargetTool();
+ if(tool == null)
+ tool = getToolFromOutputExtension(extension);
+
+ if(tool != null){
+ IOption[] opts = tool.getOptions();
+ // Look for the user object option type
+ for (int i = 0; i < opts.length; i++) {
+ IOption option = opts[i];
+ try {
+ if (option.getValueType() == IOption.OBJECTS) {
+ String unresolved[] = option.getUserObjects();
+ if(unresolved != null && unresolved.length > 0){
+ for(int k = 0; k < unresolved.length; k++){
+ try {
+ String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
+ unresolved[k],
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_OPTION,
+ new OptionContextData(option, tool));
+ if(resolved != null && resolved.length > 0)
+ objs.addAll(Arrays.asList(resolved));
+ } catch (BuildMacroException e) {
+ // TODO: report error
+ continue;
+ }
+ }
+ }
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
+ }
+ }
+ }
+ return (String[])objs.toArray(new String[objs.size()]);
+ }
+
+ public String[] getLibs(String extension) {
+ Vector libs = new Vector();
+ ITool tool = calculateTargetTool();
+ if(tool == null)
+ tool = getToolFromOutputExtension(extension);
+
+ if(tool != null){
+ IOption[] opts = tool.getOptions();
+ // Look for the lib option type
+ for (int i = 0; i < opts.length; i++) {
+ IOption option = opts[i];
+ try {
+ if (option.getValueType() == IOption.LIBRARIES) {
+
+ // check to see if the option has an applicability calculator
+ IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
+
+ if (applicabilitytCalculator == null
+ || applicabilitytCalculator.isOptionUsedInCommandLine(this, tool, option)) {
+ String command = option.getCommand();
+ String[] allLibs = option.getLibraries();
+ for (int j = 0; j < allLibs.length; j++)
+ {
+ try {
+ String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
+ allLibs[j],
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_OPTION,
+ new OptionContextData(option, tool));
+ if(resolved != null && resolved.length > 0){
+ for(int k = 0; k < resolved.length; k++){
+ String string = resolved[k];
+ if(string.length() > 0)
+ libs.add(command + string);
+ }
+ }
+ } catch (BuildMacroException e) {
+ // TODO: report error
+ continue;
+ }
+
+ }
+ }
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
+ }
+ }
+ }
+ return (String[])libs.toArray(new String[libs.size()]);
+ }
+
+ public boolean buildsFileType(String srcExt) {
+ return getRootFolderInfo().buildsFileType(srcExt);
+ }
+
+ public void exportArtifactInfo(){
+ if(isExtensionConfig)
+ return;
+
+ IBuildObjectProperties props = getBuildProperties();
+ IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID);
+ if(prop != null){
+ String valueId = prop.getValue().getId();
+ if(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_SHAREDLIB.equals(valueId)
+ || ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_STATICLIB.equals(valueId)){
+ ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(this);
+ if(des != null && !des.isReadOnly()){
+ ICOutputEntry entries[] = getConfigurationData().getBuildData().getOutputDirectories();
+ IPath path = getOwner().getFullPath();
+
+ List list = new ArrayList(entries.length + 1);
+
+ list.add(new CIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH));
+ for(int i = 0; i < entries.length; i++){
+ ICOutputEntry out = entries[i];
+ ICLibraryPathEntry lib = new CLibraryPathEntry(out.getValue(), out.getFlags() & (~ICLanguageSettingEntry.RESOLVED));
+ list.add(lib);
+ }
+
+ des.createExternalSetting(null, null, null, (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]));
+ }
+
+ }
+ }
+ }
+ public boolean supportsBuild(boolean managed) {
+ return supportsBuild(managed, true);
+ }
+
+ public boolean supportsBuild(boolean managed, boolean checkBuilder) {
+ IResourceInfo[] rcs = getResourceInfos();
+ for(int i = 0; i < rcs.length; i++){
+ if(!rcs[i].supportsBuild(managed))
+ return false;
+ }
+
+ if(checkBuilder){
+ IBuilder builder = getBuilder();
+ if(builder != null && !builder.supportsBuild(managed))
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean supportsType(String typeId) {
+ SupportedProperties props = findSupportedProperties();
+ boolean supports = false;
+ if(props != null){
+ supports = props.supportsType(typeId);
+ }
+
+ if(!supports)
+ supports = ((ToolChain)getToolChain()).supportsType(typeId);
+
+ return supports;
+ }
+
+ public boolean supportsValue(String typeId, String valueId) {
+ SupportedProperties props = findSupportedProperties();
+ boolean supports = false;
+ if(props != null){
+ supports = props.supportsValue(typeId, valueId);
+ }
+
+ if(!supports)
+ supports = ((ToolChain)getToolChain()).supportsValue(typeId, valueId);
+
+ return supports;
+ }
+
+ private SupportedProperties findSupportedProperties(){
+ if(supportedProperties == null){
+ if(parent != null){
+ return ((Configuration)parent).findSupportedProperties();
+ }
+ }
+ return supportedProperties;
+ }
+
+ private void loadProperties(IManagedConfigElement el){
+ supportedProperties = new SupportedProperties(el);
+ }
+
+ public String[] getRequiredTypeIds() {
+ SupportedProperties props = findSupportedProperties();
+ List list = new ArrayList();
+ if(props != null){
+ list.addAll(Arrays.asList(props.getRequiredTypeIds()));
+ }
+
+ list.addAll(Arrays.asList(((ToolChain)getToolChain()).getRequiredTypeIds()));
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public String[] getSupportedTypeIds() {
+ SupportedProperties props = findSupportedProperties();
+ List list = new ArrayList();
+ if(props != null){
+ list.addAll(Arrays.asList(props.getSupportedTypeIds()));
+ }
+
+ list.addAll(Arrays.asList(((ToolChain)getToolChain()).getSupportedTypeIds()));
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ SupportedProperties props = findSupportedProperties();
+ List list = new ArrayList();
+ if(props != null){
+ list.addAll(Arrays.asList(props.getSupportedValueIds(typeId)));
+ }
+
+ list.addAll(Arrays.asList(((ToolChain)getToolChain()).getSupportedValueIds(typeId)));
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public boolean requiresType(String typeId) {
+ SupportedProperties props = findSupportedProperties();
+ boolean requires = false;
+ if(props != null){
+ requires = props.requiresType(typeId);
+ }
+
+ if(!requires)
+ requires = ((ToolChain)getToolChain()).requiresType(typeId);
+
+ return requires;
+ }
+
+ public boolean isManagedBuildOn() {
+ return getBuilder().isManagedBuildOn();
+ }
+
+ public void setManagedBuildOn(boolean on) throws BuildException {
+ try {
+ getEditableBuilder().setManagedBuildOn(on);
+ } catch (CoreException e) {
+ throw new BuildException(e.getLocalizedMessage());
+ }
+ }
+
+ public void changeBuilder(IBuilder newBuilder, String id, String name){
+ changeBuilder(newBuilder, id, name, false);
+ }
+
+ public void changeBuilder(IBuilder newBuilder, String id, String name, boolean allBuildSettings){
+ ToolChain tc = (ToolChain)getToolChain();
+ Builder cur = (Builder)getEditableBuilder();
+ Builder newCfgBuilder = null;
+ if(newBuilder.getParent() == tc){
+ newCfgBuilder = (Builder)newBuilder;
+ } else {
+ IBuilder extBuilder = newBuilder;
+ for(;extBuilder != null && !extBuilder.isExtensionElement(); extBuilder = extBuilder.getSuperClass());
+ if(extBuilder == null)
+ extBuilder = newBuilder;
+ newCfgBuilder = new Builder(tc, extBuilder, id, name, false);
+ newCfgBuilder.copySettings(cur, allBuildSettings);
+ tc.setBuilder(newCfgBuilder);
+ }
+ }
+
+ public boolean isBuilderCompatible(IBuilder builder){
+ return builder.supportsBuild(isManagedBuildOn());
+ }
+
+ ITool findToolById(String id){
+ IResourceInfo[] rcInfos = getResourceInfos();
+ ITool tool = null;
+ for(int i = 0; i < rcInfos.length; i++){
+ ResourceInfo info = (ResourceInfo)rcInfos[i];
+ tool = info.getToolById(id);
+ if(tool != null)
+ break;
+ }
+ return tool;
+ }
+
+ void resolveProjectReferences(boolean onLoad){
+ IResourceInfo[] rcInfos = getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ ResourceInfo info = (ResourceInfo)rcInfos[i];
+ info.resolveProjectReferences(onLoad);
+ }
+ }
+
+ public boolean isPerRcTypeDiscovery(){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ return tc.isPerRcTypeDiscovery();
+ }
+
+ public void setPerRcTypeDiscovery(boolean on){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ tc.setPerRcTypeDiscovery(on);
+ }
+
+ public IScannerConfigBuilderInfo2 getScannerConfigInfo(){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ return tc.getScannerConfigBuilderInfo();
+ }
+
+ public IScannerConfigBuilderInfo2 setScannerConfigInfo(IScannerConfigBuilderInfo2 info){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ return tc.setScannerConfigBuilderInfo(info);
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo setDiscoveredPathInfo(IDiscoveredPathManager.IDiscoveredPathInfo info){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ return tc.setDiscoveredPathInfo(info);
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo getDiscoveredPathInfo(){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ return tc.getDiscoveredPathInfo();
+ }
+
+ public String getDiscoveryProfileId(){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ return tc.getScannerConfigDiscoveryProfileId();
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo clearDiscoveredPathInfo(){
+ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+ return tc.setDiscoveredPathInfo(null);
+ }
+
+ public IConfigurationScannerConfigBuilderInfo getCfgScannerConfigInfo(){
+ if(cfgScannerInfo == null){
+ cfgScannerInfo = ScannerConfigInfoFactory2.create(this, true);
+ }
+ return cfgScannerInfo;
+ }
+
+ public void setCfgScannerConfigInfo(IConfigurationScannerConfigBuilderInfo info){
+ cfgScannerInfo = info;
+ }
+
+ public boolean isPreference(){
+ return isPreferenceConfig;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConverterInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConverterInfo.java
new file mode 100644
index 00000000000..422697a3eeb
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConverterInfo.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class ConverterInfo {
+ IBuildObject fFromObject;
+ IBuildObject fToObject;
+ IConfigurationElement fConverterElement;
+ boolean fIsConversionPerformed;
+
+ public ConverterInfo(IBuildObject fromObject, IBuildObject toObject, IConfigurationElement el){
+ fFromObject = fromObject;
+ fToObject = toObject;
+ fConverterElement = el;
+ }
+
+ public IBuildObject getFromObject(){
+ return fFromObject;
+ }
+
+ public IBuildObject getToObject(){
+ return fToObject;
+ }
+
+ public IConfigurationElement getConverterElement(){
+ return fConverterElement;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java
new file mode 100644
index 00000000000..50def1b5167
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java
@@ -0,0 +1,1221 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.buildproperties.BuildPropertyManager;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildFolderData;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class FolderInfo extends ResourceInfo implements IFolderInfo {
+ private ToolChain toolChain;
+ private boolean isExtensionElement;
+
+ public FolderInfo(FolderInfo folderInfo, String id, String resourceName, IPath path){
+ super(folderInfo, path, id, resourceName);
+// setParentFolder(folderInfo);
+// setParentFolderId(folderInfo.getId());
+
+ isExtensionElement = folderInfo.isExtensionElement();
+ if(!isExtensionElement)
+ setResourceData(new BuildFolderData(this));
+
+ if ( folderInfo.getParent() != null)
+ setManagedBuildRevision(folderInfo.getParent().getManagedBuildRevision());
+
+ IToolChain parTc = folderInfo.getToolChain();
+ IToolChain extTc = parTc;
+ for(; extTc != null && !extTc.isExtensionElement(); extTc = extTc.getSuperClass());
+ if(extTc == null)
+ extTc = parTc;
+
+ String tcId = ManagedBuildManager.calculateChildId(extTc.getId(), null);
+ createToolChain(extTc, tcId, parTc.getName(), false);
+
+ toolChain.createOptions(parTc);
+
+ ITool tools[] = parTc.getTools();
+ String subId = new String();
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ ITool extTool = tool;
+ for(; extTool != null && !extTool.isExtensionElement(); extTool = extTool.getSuperClass());
+ if(extTool == null)
+ extTool = tool;
+
+ subId = ManagedBuildManager.calculateChildId(extTool.getId(), null);
+ toolChain.createTool(tool, subId, tool.getName(), false);
+ }
+
+
+ setDirty(true);
+ setRebuildState(true);
+ }
+
+ public FolderInfo(IConfiguration parent, IManagedConfigElement element, String managedBuildRevision, boolean hasBody) {
+ super(parent, element, hasBody);
+
+ isExtensionElement = true;
+ IManagedConfigElement tcEl = null;
+ if(!hasBody){
+ setPath(new Path("/"));
+ setId(ManagedBuildManager.calculateChildId(parent.getId(), null));
+ setName("/");
+ tcEl = element;
+ } else {
+ IManagedConfigElement children[] = element.getChildren(IToolChain.TOOL_CHAIN_ELEMENT_NAME);
+ if(children.length > 0)
+ tcEl = children[0];
+ }
+
+ if(tcEl != null)
+ toolChain = new ToolChain(this, tcEl, managedBuildRevision);
+
+ }
+
+ public FolderInfo(IConfiguration parent, ICStorageElement element, String managedBuildRevision, boolean hasBody) {
+ super(parent, element, hasBody);
+
+ isExtensionElement = false;
+ setResourceData(new BuildFolderData(this));
+ ICStorageElement tcEl = null;
+ if(!hasBody){
+ setPath(new Path("/"));
+ setId(ManagedBuildManager.calculateChildId(parent.getId(), null));
+ setName("/");
+ tcEl = element;
+ } else {
+ ICStorageElement nodes[] = element.getChildren();
+ for(int i = 0; i < nodes.length; i++){
+ ICStorageElement node = nodes[i];
+ if(IToolChain.TOOL_CHAIN_ELEMENT_NAME.equals(node.getName()))
+ tcEl = node;
+ }
+ }
+
+ if(tcEl != null)
+ toolChain = new ToolChain(this, tcEl, managedBuildRevision);
+ }
+/*TODO
+ public FolderInfo(FolderInfo base, IPath path, String id, String name) {
+ super(base, path, id, name);
+ }
+*/
+ public FolderInfo(IConfiguration parent, IPath path, String id, String name, boolean isExtensionElement) {
+ super(parent, path, id, name);
+
+ this.isExtensionElement = isExtensionElement;
+ if(!isExtensionElement)
+ setResourceData(new BuildFolderData(this));
+
+ }
+
+/* public IToolChain setToolChain(IToolChain toolChain, String id, String name){
+ if
+ }
+*/
+ public FolderInfo(IConfiguration cfg, FolderInfo cloneInfo, String id, Map superIdMap, boolean cloneChildren) {
+ super(cfg, cloneInfo, id);
+
+ isExtensionElement = cfg.isExtensionElement();
+ if(!isExtensionElement)
+ setResourceData(new BuildFolderData(this));
+
+// String subId;
+ String subName;
+ if(!cloneInfo.isExtensionElement)
+ cloneChildren = true;
+
+ boolean copyIds = cloneChildren && id.equals(cloneInfo.id);
+
+ IToolChain cloneToolChain = cloneInfo.getToolChain();
+ IToolChain extToolChain = cloneToolChain;
+ for(; !extToolChain.isExtensionElement(); extToolChain = extToolChain.getSuperClass());
+
+// if(cloneInfo.isParentInfoInherited()){
+// IFolderInfo parent = (IFolderInfo)cfg.getResourceInfo(cloneInfo.getPath().removeLastSegments(1), false);
+// baseToolChain = parent.getToolChain();
+// } else {
+// for(baseToolChain = cloneInfo.getToolChain();
+// !baseToolChain.isExtensionElement();
+// baseToolChain=baseToolChain.getSuperClass());
+// }
+
+ //getParentFolderInfo() != null ?
+ // cloneInfo.getParentFolderInfo().getToolChain() : cloneInfo.getToolChain();
+
+ subName = cloneToolChain.getName();
+
+ if (cloneChildren) {
+ String subId = copyIds ? cloneToolChain.getId() : ManagedBuildManager.calculateChildId(extToolChain.getId(),
+ null);
+ toolChain = new ToolChain(this, subId, subName, superIdMap, (ToolChain)cloneToolChain);
+
+ } else {
+ // Add a tool-chain element that specifies as its superClass the
+ // tool-chain that is the child of the configuration.
+// ToolChain superChain = (ToolChain)cloneInfo.getToolChain();
+ String subId = ManagedBuildManager.calculateChildId(
+ extToolChain.getId(),
+ null);
+// for(; !superChain.isExtensionElement(); superChain = (ToolChain)superChain.getSuperClass());
+
+ IToolChain newChain = createToolChain(extToolChain, subId, extToolChain.getName(), false);
+
+ // For each option/option category child of the tool-chain that is
+ // the child of the selected configuration element, create an option/
+ // option category child of the cloned configuration's tool-chain element
+ // that specifies the original tool element as its superClass.
+ newChain.createOptions(extToolChain);
+
+ // For each tool element child of the tool-chain that is the child of
+ // the selected configuration element, create a tool element child of
+ // the cloned configuration's tool-chain element that specifies the
+ // original tool element as its superClass.
+ ITool[] tools = extToolChain.getTools();
+ for (int i=0; i<tools.length; i++) {
+ Tool toolChild = (Tool)tools[i];
+ subId = ManagedBuildManager.calculateChildId(toolChild.getId(),null);
+ newChain.createTool(toolChild, subId, toolChild.getName(), false);
+ }
+
+ ITargetPlatform tpBase = cloneInfo.getToolChain().getTargetPlatform();
+ ITargetPlatform extTp = tpBase;
+ for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass());
+
+ TargetPlatform tp;
+ if(extTp != null){
+ int nnn = ManagedBuildManager.getRandomNumber();
+ subId = copyIds ? tpBase.getId() : extTp.getId() + "." + nnn; //$NON-NLS-1$
+// subName = tpBase.getName();
+ tp = new TargetPlatform(newChain, subId, tpBase.getName(), (TargetPlatform)tpBase);
+ } else {
+ subId = copyIds ? tpBase.getId() : ManagedBuildManager.calculateChildId(getId(), null);
+ subName = tpBase != null ? tpBase.getName() : "";
+ tp = new TargetPlatform((ToolChain)newChain, null, subId, subName, false);
+ }
+
+ ((ToolChain)newChain).setTargetPlatform(tp);
+ }
+
+ if(copyIds){
+ isDirty = cloneInfo.isDirty;
+ needsRebuild = cloneInfo.needsRebuild;
+ } else {
+ setDirty(true);
+ setRebuildState(true);
+ }
+
+ }
+
+ public static ITool[] filtereTools(ITool localTools[], IManagedProject manProj) {
+// ITool[] localTools = toolChain.getTools();
+// IManagedProject manProj = getParent().getManagedProject();
+ if (manProj == null) {
+ // If this is not associated with a project, then there is nothing to filter with
+ return localTools;
+ }
+ IProject project = (IProject)manProj.getOwner();
+ Vector tools = new Vector(localTools.length);
+ for (int i = 0; i < localTools.length; i++) {
+ ITool tool = localTools[i];
+ if(!tool.isEnabled())
+ continue;
+
+ try {
+ // Make sure the tool is right for the project
+ switch (tool.getNatureFilter()) {
+ case ITool.FILTER_C:
+ if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ tools.add(tool);
+ }
+ break;
+ case ITool.FILTER_CC:
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ tools.add(tool);
+ }
+ break;
+ case ITool.FILTER_BOTH:
+ tools.add(tool);
+ break;
+ default:
+ break;
+ }
+ } catch (CoreException e) {
+ continue;
+ }
+ }
+
+ // Answer the filtered tools as an array
+ return (ITool[])tools.toArray(new ITool[tools.size()]);
+ }
+
+ public ITool[] getFilteredTools() {
+ if (toolChain == null) {
+ return new ITool[0];
+ }
+ ITool[] localTools = toolChain.getTools();
+ IManagedProject manProj = getParent().getManagedProject();
+ return filtereTools(localTools, manProj);
+// if (manProj == null) {
+// // If this is not associated with a project, then there is nothing to filter with
+// return localTools;
+// }
+// IProject project = (IProject)manProj.getOwner();
+// Vector tools = new Vector(localTools.length);
+// for (int i = 0; i < localTools.length; i++) {
+// ITool tool = localTools[i];
+// if(!tool.isEnabled())
+// continue;
+//
+// try {
+// // Make sure the tool is right for the project
+// switch (tool.getNatureFilter()) {
+// case ITool.FILTER_C:
+// if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+// tools.add(tool);
+// }
+// break;
+// case ITool.FILTER_CC:
+// if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+// tools.add(tool);
+// }
+// break;
+// case ITool.FILTER_BOTH:
+// tools.add(tool);
+// break;
+// default:
+// break;
+// }
+// } catch (CoreException e) {
+// continue;
+// }
+// }
+//
+// // Answer the filtered tools as an array
+// return (ITool[])tools.toArray(new ITool[tools.size()]);
+ }
+
+ public final int getKind() {
+ return ICSettingBase.SETTING_FOLDER;
+ }
+
+ public boolean isDirty() {
+ if(super.isDirty())
+ return true;
+
+ if (toolChain.isDirty()) return true;
+
+ return false;
+ }
+
+ public boolean needsRebuild() {
+ if(super.needsRebuild())
+ return true;
+
+ if(toolChain.needsRebuild())
+ return true;
+
+// ITool tools[] = getFilteredTools();
+// for(int i = 0; i < tools.length; i++){
+// if(tools[i].needsRebuild())
+// return true;
+// }
+
+
+ return false;
+ }
+
+ public void setRebuildState(boolean rebuild) {
+ super.setRebuildState(rebuild);
+
+ if(!rebuild){
+ toolChain.setRebuildState(false);
+
+// ITool tools[] = getFilteredTools();
+// for(int i = 0; i < tools.length; i++){
+// tools[i].setRebuildState(false);
+// }
+ }
+
+ }
+
+ public IToolChain getToolChain() {
+ return toolChain;
+ }
+
+ public ITool[] getTools() {
+ return toolChain.getTools();
+ }
+
+ public ITool getTool(String id) {
+ return toolChain.getTool(id);
+ }
+
+ public ITool[] getToolsBySuperClassId(String id) {
+ return toolChain.getToolsBySuperClassId(id);
+ }
+
+ ToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement) {
+ toolChain = new ToolChain(this, superClass, Id, name, isExtensionElement);
+ setDirty(true);
+ return toolChain;
+ }
+
+ void serialize(ICStorageElement element){
+ super.serialize(element);
+
+ ICStorageElement toolChainElement = element.createChild(IToolChain.TOOL_CHAIN_ELEMENT_NAME);
+ toolChain.serialize(toolChainElement);
+ }
+
+ void resolveReferences(){
+// super.resolveReferences();
+ if(toolChain != null)
+ toolChain.resolveReferences();
+ }
+
+ public void updateManagedBuildRevision(String revision){
+ super.updateManagedBuildRevision(revision);
+
+ if(toolChain != null)
+ toolChain.updateManagedBuildRevision(revision);
+ }
+
+ public boolean isExtensionElement(){
+ return isExtensionElement;
+ }
+
+ public String getErrorParserIds(){
+ if(toolChain != null)
+ return toolChain.getErrorParserIds(getParent());
+ return null;
+ }
+
+ public CFolderData getFolderData(){
+ return (CFolderData)getResourceData();
+ }
+
+ public CLanguageData[] getCLanguageDatas() {
+ ITool tools[] = getFilteredTools();
+ List list = new ArrayList();
+ for(int i = 0; i < tools.length; i++){
+ CLanguageData datas[] = tools[i].getCLanguageDatas();
+ for(int j = 0; j < datas.length; j++){
+ list.add(datas[j]);
+ }
+ }
+ return (BuildLanguageData[])list.toArray(new BuildLanguageData[list.size()]);
+ }
+
+ public ITool getToolFromOutputExtension(String extension) {
+ // Treat a null argument as an empty string
+ String ext = extension == null ? "" : extension;
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(ext)) {
+ return tool;
+ }
+ }
+ return null;
+ }
+
+ public ITool getToolFromInputExtension(String sourceExtension) {
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(sourceExtension)) {
+ return tool;
+ }
+ }
+ return null;
+ }
+
+ public void propertiesChanged() {
+ if(isExtensionElement)
+ return;
+
+ toolChain.propertiesChanged();
+
+ super.propertiesChanged();
+ }
+
+/* public IToolChain getBaseToolChain() {
+ if(toolChain.isExtensionElement())
+ return toolChain;
+ return toolChain.getSuperClass();
+ }
+*/
+
+ public void setDirty(boolean isDirty) {
+ if (isExtensionElement && isDirty) return;
+
+ super.setDirty(isDirty);
+
+ // Propagate "false" to the children
+ if (!isDirty) {
+ if(toolChain != null)
+ toolChain.setDirty(false);
+ }
+ }
+
+ private Map typeIdsToMap(String [] ids){
+ Map map = new HashMap(ids.length);
+ for(int i = 0; i < ids.length; i++){
+ map.put(ids[i], null);
+ }
+
+ return map;
+ }
+
+ private Map propsToMap(IBuildProperty props[]){
+ Map map = new HashMap(props.length);
+ for(int i = 0; i < props.length; i++){
+ map.put(props[i].getPropertyType().getId(), props[i].getValue().getId());
+ }
+
+ return map;
+ }
+
+ private void checkPropertiesModificationCompatibility(IBuildPropertiesRestriction r, Map unspecifiedRequiredProps, Map unspecifiedProps, Set undefinedSet){
+ IBuildObjectProperties props = null;
+ IConfiguration cfg = getParent();
+ if(cfg != null){
+ props = cfg.getBuildProperties();
+ }
+
+ unspecifiedProps.clear();
+ unspecifiedRequiredProps.clear();
+
+ if(props != null){
+ String[] requiredIds = props.getRequiredTypeIds();
+
+ IBuildPropertyType[] supportedTypes = props.getSupportedTypes();
+ if(supportedTypes.length != 0 || requiredIds.length != 0){
+ Map requiredMap = typeIdsToMap(requiredIds);
+ getUnsupportedProperties(requiredMap, r, unspecifiedRequiredProps, undefinedSet);
+ unspecifiedProps.putAll(unspecifiedRequiredProps);
+
+ IBuildProperty[] ps = props.getProperties();
+ Map propsMap = propsToMap(ps);
+ getUnsupportedProperties(propsMap, r, unspecifiedProps, undefinedSet);
+ }
+ }
+ }
+
+ private void getUnsupportedProperties(Map props, IBuildPropertiesRestriction restriction, Map unsupported, Set inexistent){
+ BuildPropertyManager mngr = BuildPropertyManager.getInstance();
+ for(Iterator iter = props.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String propId = (String)entry.getKey();
+ String valueId = (String)entry.getValue();
+ IBuildPropertyType type = mngr.getPropertyType(propId);
+ if(type == null){
+ if(inexistent != null){
+ inexistent.add(propId);
+ }
+ }
+
+ if(!restriction.supportsType(propId)){
+ unsupported.put(propId, null);
+ } else if (!restriction.supportsValue(propId, valueId)){
+ unsupported.put(propId, valueId);
+ }
+ }
+ }
+
+ public void checkPropertiesModificationCompatibility(final ITool tools[], Map unspecifiedRequiredProps, Map unspecifiedProps, Set undefinedSet){
+ final ToolChain tc = (ToolChain)getToolChain();
+ IBuildPropertiesRestriction r = new IBuildPropertiesRestriction(){
+ public boolean supportsType(String typeId) {
+ if(tc.supportsType(typeId, false))
+ return true;
+
+ for(int i = 0; i < tools.length; i++){
+ if(((Tool)tools[i]).supportsType(typeId))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean supportsValue(String typeId, String valueId) {
+ if(tc.supportsValue(typeId, valueId, false))
+ return true;
+
+ for(int i = 0; i < tools.length; i++){
+ if(((Tool)tools[i]).supportsValue(typeId, valueId))
+ return true;
+ }
+ return false;
+ }
+
+ public String[] getRequiredTypeIds() {
+ List list = new ArrayList();
+
+ list.addAll(Arrays.asList(tc.getRequiredTypeIds(false)));
+
+ for(int i = 0; i < tools.length; i++){
+ list.addAll(Arrays.asList(((Tool)tools[i]).getRequiredTypeIds()));
+ }
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public String[] getSupportedTypeIds() {
+ List list = new ArrayList();
+
+ list.addAll(Arrays.asList(tc.getSupportedTypeIds(false)));
+
+ for(int i = 0; i < tools.length; i++){
+ list.addAll(Arrays.asList(((Tool)tools[i]).getSupportedTypeIds()));
+ }
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ List list = new ArrayList();
+
+ list.addAll(Arrays.asList(tc.getSupportedValueIds(typeId, false)));
+
+ for(int i = 0; i < tools.length; i++){
+ list.addAll(Arrays.asList(((Tool)tools[i]).getSupportedValueIds(typeId)));
+ }
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public boolean requiresType(String typeId) {
+ if(tc.requiresType(typeId, false))
+ return true;
+
+ for(int i = 0; i < tools.length; i++){
+ if(((Tool)tools[i]).requiresType(typeId))
+ return true;
+ }
+ return false;
+ }
+ };
+
+ checkPropertiesModificationCompatibility(r, unspecifiedRequiredProps, unspecifiedProps, undefinedSet);
+ }
+
+ public void checkPropertiesModificationCompatibility(IToolChain tc, Map unspecifiedRequiredProps, Map unspecifiedProps, Set undefinedSet){
+ checkPropertiesModificationCompatibility((IBuildPropertiesRestriction)tc, unspecifiedRequiredProps, unspecifiedProps, undefinedSet);
+ }
+
+ public boolean isPropertiesModificationCompatible(IToolChain tc){
+ Map requiredMap = new HashMap();
+ Map unsupportedMap = new HashMap();
+ Set undefinedSet = new HashSet();
+ checkPropertiesModificationCompatibility(tc, requiredMap, unsupportedMap, undefinedSet);
+ if(requiredMap.size() != 0)
+ return false;
+
+ return true;
+// boolean compatible = false;
+//
+// IBuildObjectProperties props = null;
+// IConfiguration cfg = getParent();
+// if(cfg != null){
+// props = cfg.getBuildProperties();
+// }
+//
+// if(props != null){
+// String[] requiredIds = props.getRequiredTypeIds();
+// IBuildPropertyType[] supportedTypes = props.getSupportedTypes();
+// if(supportedTypes.length != 0 || requiredIds.length != 0){
+// ToolChain toolChain = (ToolChain)tc;
+// if(requiredIds.length != 0){
+// int i = 0;
+// for(; i < requiredIds.length; i++){
+// IBuildPropertyType type = BuildPropertyManager.getInstance().getPropertyType(requiredIds[i]);
+// if(type == null)
+// break;
+//
+// if(!toolChain.supportsType(type))
+// break;
+// }
+//
+// if(i == requiredIds.length)
+// compatible = true;
+// } else {
+// int i = 0;
+// for(; i < supportedTypes.length; i++){
+// if(!toolChain.supportsType(supportedTypes[i]))
+// break;
+// }
+// if(i == supportedTypes.length)
+// compatible = true;
+// }
+// }
+// }
+// return compatible;
+ }
+
+ private Set getRequiredUnspecifiedProperties(){
+ IBuildObjectProperties props = null;
+ IConfiguration cfg = getParent();
+ if(cfg != null){
+ props = cfg.getBuildProperties();
+ }
+
+ Set set = new HashSet();
+ if(props != null){
+ String[] requiredIds = props.getRequiredTypeIds();
+ for(int i = 0; i < requiredIds.length; i++){
+ if(props.getProperty(requiredIds[i]) == null)
+ set.add(requiredIds[i]);
+ }
+ }
+
+ return set;
+
+ }
+
+ public boolean isToolChainCompatible(IToolChain tCh){
+ boolean compatible = false;
+
+ if(tCh != null){
+ if(getToolChainConverterElement(tCh) != null)
+ compatible = true;
+
+ if(!compatible)
+ compatible = isPropertiesModificationCompatible(tCh);
+ } else {
+ compatible = this.toolChain != null && this.toolChain.isPreferenceToolChain();
+ }
+ return compatible;
+ }
+
+ public IToolChain changeToolChain(IToolChain newSuperClass, String Id, String name) throws BuildException{
+ IConfigurationElement el = getToolChainConverterElement(newSuperClass);
+ ToolChain oldToolChain = toolChain;
+ ITool oldTools[] = oldToolChain.getTools();
+
+ if(el != null){
+ updateToolChainWithConverter(el, newSuperClass, Id, name);
+ } else {
+ updateToolChainWithProperties(newSuperClass, Id, name);
+ }
+
+ BuildSettingsUtil.disconnectDepentents(getParent(), oldTools);
+
+ return toolChain;
+ }
+
+ void updateToolChainWithProperties(IToolChain newSuperClass, String Id, String name) {
+ ToolChain oldTc = (ToolChain)getToolChain();
+ if(newSuperClass != null) {
+ createToolChain(newSuperClass, Id, name, false);
+ } else {
+ Configuration cfg = ConfigurationDataProvider.getClearPreference(null);
+ ToolChain prefTch = (ToolChain)cfg.getRootFolderInfo().getToolChain();
+
+ toolChain = new ToolChain(this, ManagedBuildManager.calculateChildId(prefTch.getSuperClass().getId(), null), prefTch.getName(), new HashMap(), (ToolChain)prefTch);
+ }
+ toolChain.propertiesChanged();
+
+ //TODO: copy includes, symbols, etc.
+ }
+
+ void updateToolChainWithConverter(IConfigurationElement el, IToolChain newSuperClass, String Id, String name) throws BuildException{
+ IBuildObject bo = ManagedBuildManager.convert(getToolChain(), newSuperClass.getId(), true);
+ if(!(bo instanceof ToolChain)){
+ throw new BuildException("converter invocation failed");
+ }
+ if(toolChain != bo){
+ setUpdatedToolChain((ToolChain)bo);
+ }
+
+ toolChain.setName(name);
+ }
+
+ void setUpdatedToolChain(ToolChain tch){
+ toolChain = tch;
+ tch.updateParentFolderInfo(this);
+ }
+
+ private IConfigurationElement getToolChainConverterElement(IToolChain tCh){
+ if(tCh == null)
+ return null;
+
+ ToolChain curTc = (ToolChain)getToolChain();
+ if(curTc != null){
+ return curTc.getConverterModificationElement(tCh);
+ }
+ return null;
+ }
+
+ public void modifyToolChain(ITool[] removed, ITool[] added){
+ List remainingRemoved = new ArrayList();
+ List remainingAdded = new ArrayList();
+ Map converterMap = calculateConverterTools(removed, added, remainingRemoved, remainingAdded);
+ invokeConverters(converterMap);
+ List newTools = new ArrayList(added.length);
+ for(Iterator iter = converterMap.values().iterator(); iter.hasNext();){
+ ConverterInfo info = (ConverterInfo)iter.next();
+ if(info.fIsConversionPerformed){
+ Tool newTool = (Tool)info.fToObject;
+ newTool.updateParent(getToolChain());
+ newTools.add(newTool);
+ } else {
+ remainingAdded.add(info.fToObject);
+ }
+ }
+
+ for(Iterator iter = remainingAdded.iterator(); iter.hasNext();){
+ Tool tool = (Tool)iter.next();
+ Tool newTool = new Tool(toolChain, tool, ManagedBuildManager.calculateChildId(tool.getId(), null), tool.getName(), false);
+ newTools.add(newTool);
+ }
+
+ performToolChainModification(removed, (Tool[])newTools.toArray(new Tool[newTools.size()]));
+ }
+
+ private void performToolChainModification(ITool removed[], ITool[] added){
+ BuildSettingsUtil.disconnectDepentents(getParent(), removed);
+
+ for(int i = 0; i < removed.length; i++){
+ toolChain.removeTool((Tool)removed[i]);
+ }
+
+ for(int i = 0; i < added.length; i++){
+ toolChain.addTool((Tool)added[i]);
+ }
+
+ adjustTargetTools(removed, getTools());
+
+ toolChain.propertiesChanged();
+ }
+
+ private void adjustTargetTools(ITool removed[], ITool allTools[]){
+ if(!isRoot())
+ return;
+
+ Set set = new HashSet();
+ String [] ids = toolChain.getTargetToolList();
+ boolean targetToolsModified = false;
+ set.addAll(Arrays.asList(ids));
+
+ for(int i = 0; i < removed.length; i++){
+ ITool target = getTargetTool(removed[i]);
+
+ if(target == null)
+ continue;
+
+ List list = BuildSettingsUtil.calcDependentTools(allTools, target, null);
+ if(list.size() != 0)
+ continue;
+
+ ITool newTargetTool = findCompatibleTargetTool(target, allTools);
+ if(newTargetTool != null){
+ set.remove(target.getId());
+ set.add(newTargetTool.getId());
+ targetToolsModified = true;
+ }
+ }
+
+ if(targetToolsModified){
+ toolChain.setTargetToolIds(CDataUtil.arrayToString((String[])set.toArray(new String[set.size()]), ";")); //$NON-NLS-1$
+ }
+ }
+
+ private ITool findCompatibleTargetTool(ITool tool, ITool allTools[]){
+ IProject project = getParent().getOwner().getProject();
+ String exts[] = ((Tool)tool).getAllOutputExtensions(project);
+ Set extsSet = new HashSet(Arrays.asList(exts));
+ ITool compatibleTool = null;
+ for(int i = 0; i < allTools.length; i++){
+ String otherExts[] = ((Tool)allTools[i]).getAllOutputExtensions(project);
+ for(int k = 0; k < otherExts.length; k++){
+ if(extsSet.contains(otherExts[k])){
+ compatibleTool = allTools[i];
+ break;
+ }
+ }
+ if(compatibleTool != null)
+ break;
+ }
+
+ return compatibleTool;
+ }
+
+ private ITool getTargetTool(ITool tool){
+ String [] ids = toolChain.getTargetToolList();
+
+ for(int i = 0; i < ids.length; i++){
+ String id = ids[i];
+ ITool target = tool;
+ for(; target != null; target = target.getSuperClass()){
+ if(id.equals(target.getId()))
+ break;
+ }
+ if(target != null)
+ return target;
+
+ }
+ return null;
+ }
+
+// private void disconnectDepentents(ITool[] tools){
+// for(int i = 0; i < tools.length; i++){
+// disconnectDepentents(tools[i]);
+// }
+// }
+//
+// private void disconnectDepentents(ITool tool){
+// ITool deps[] = ManagedBuildManager.getDependentTools(getParent(), tool);
+// for(int i = 0; i < deps.length; i++){
+// disconnect(deps[i], tool);
+// }
+// }
+//
+// private void disconnect(ITool child, ITool superClass){
+// ITool directChild = child;
+// for(;directChild != null; directChild = directChild.getSuperClass()){
+// if(superClass.equals(directChild.getSuperClass()))
+// break;
+// }
+//
+// if(directChild == null)
+// return;
+//
+// ((Tool)directChild).copyNonoverriddenSettings((Tool)superClass);
+// ((Tool)directChild).setSuperClass(superClass.getSuperClass());
+// }
+//
+
+ private List invokeConverters(Map converterMap){
+ List failed = new ArrayList();
+ for(Iterator iter = converterMap.values().iterator();iter.hasNext();){
+ ConverterInfo info = (ConverterInfo)iter.next();
+ IBuildObject converted = ManagedBuildManager.convert(info.getFromObject(), info.getToObject().getId(), true);
+ if(converted == null || !converted.getClass().equals(info.getFromObject().getClass())){
+ failed.add(info);
+ } else {
+ info.fToObject = converted;
+ info.fIsConversionPerformed = true;
+ }
+ }
+ return failed;
+ }
+
+ private Map calculateConverterTools(ITool[] removed, ITool[] added, List remainingRemoved, List remainingAdded){
+ if(remainingAdded == null)
+ remainingAdded = new ArrayList(added.length);
+ if(remainingRemoved == null)
+ remainingRemoved = new ArrayList(removed.length);
+
+ remainingAdded.clear();
+ remainingRemoved.clear();
+
+ remainingAdded.addAll(Arrays.asList(added));
+ remainingRemoved.addAll(Arrays.asList(removed));
+
+ Map resultMap = new HashMap();
+
+ for(Iterator rIter = remainingRemoved.iterator(); rIter.hasNext();){
+ ITool r = (ITool)rIter.next();
+
+ if(r.getParentResourceInfo() != this)
+ continue;
+
+
+ Map map = ManagedBuildManager.getConversionElements(r);
+ if(map.size() == 0)
+ continue;
+
+ for(Iterator aIter = remainingAdded.iterator(); aIter.hasNext();){
+ ITool a = (ITool)aIter.next();
+
+ if(a.getParentResourceInfo() == this)
+ continue;
+
+ IConfigurationElement el = getToolConverterElement(r, a);
+ if(el != null){
+ resultMap.put(r, new ConverterInfo(r, a, el));
+ rIter.remove();
+ aIter.remove();
+ break;
+ }
+ }
+ }
+
+ return resultMap;
+ }
+
+ private ITool[] calculateToolsArray(ITool[] removed, ITool[] added){
+ ITool tools[] = getTools();
+ HashSet set = new HashSet();
+ set.addAll(Arrays.asList(tools));
+ set.removeAll(Arrays.asList(removed));
+ set.addAll(Arrays.asList(added));
+
+ return (ITool[])set.toArray(new ITool[set.size()]);
+ }
+
+ private ITool[][] calculateConflictingTools(ITool[] newTools){
+ HashSet set = new HashSet();
+ set.addAll(Arrays.asList(newTools));
+ List result = new ArrayList();
+ for(Iterator iter = set.iterator(); iter.hasNext();){
+ ITool t = (ITool)iter.next();
+ iter.remove();
+ HashSet tmp = (HashSet)set.clone();
+ List list = new ArrayList();
+ for(Iterator tmpIt = tmp.iterator(); tmpIt.hasNext();){
+ ITool other = (ITool)tmpIt.next();
+ String conflicts[] = getConflictingInputExts(t, other);
+ if(conflicts.length != 0){
+ list.add(other);
+ tmpIt.remove();
+ }
+ }
+
+ if(list.size() != 0){
+ list.add(t);
+ result.add(list.toArray(new Tool[list.size()]));
+ }
+ set = tmp;
+ iter = set.iterator();
+ }
+
+ return (ITool[][])result.toArray(new ITool[result.size()][]);
+ }
+
+ private String[] getConflictingInputExts(ITool tool1, ITool tool2){
+ IProject project = getParent().getOwner().getProject();
+ String ext1[] = ((Tool)tool1).getAllInputExtensions(project);
+ String ext2[] = ((Tool)tool2).getAllInputExtensions(project);
+ Set set1 = new HashSet(Arrays.asList(ext1));
+ Set result = new HashSet();
+ for(int i = 0; i < ext2.length; i++){
+ if(set1.remove(ext2[i]))
+ result.add(ext2[i]);
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+
+ public IModificationStatus getToolChainModificationStatus(ITool[] removed, ITool[] added){
+// Map converterMap = calculateConverterTools(removed, added, null, null);
+ ITool newTools[] = calculateToolsArray(removed, added);
+ ITool[][] conflicting = calculateConflictingTools(filtereTools(newTools, getParent().getManagedProject()));
+ Map unspecifiedRequiredProps = new HashMap();
+ Map unspecifiedProps = new HashMap();
+ Set undefinedSet = new HashSet();
+ IConfiguration cfg = getParent();
+ ITool[] nonManagedTools = null;
+ if(cfg.isManagedBuildOn() && cfg.supportsBuild(true)){
+ List list = new ArrayList();
+ for(int i = 0; i < newTools.length; i++){
+ if(!newTools[i].supportsBuild(true)){
+ list.add(newTools[i]);
+ }
+ }
+ if(list.size() != 0){
+ nonManagedTools = (ITool[])list.toArray(new Tool[list.size()]);
+ }
+ }
+ return new ModificationStatus(unspecifiedRequiredProps, unspecifiedProps, undefinedSet, conflicting, nonManagedTools);
+ }
+
+ private IConfigurationElement getToolConverterElement(ITool fromTool, ITool toTool){
+ ToolChain curTc = (ToolChain)getToolChain();
+ if(curTc != null){
+ return curTc.getConverterModificationElement(fromTool, toTool);
+ }
+ return null;
+ }
+
+ public boolean supportsBuild(boolean managed) {
+ Set set = getRequiredUnspecifiedProperties();
+ if(set.size() != 0)
+ return false;
+
+ ToolChain tCh = (ToolChain)getToolChain();
+ if(tCh == null || !tCh.getSupportsManagedBuildAttribute())
+ return !managed;
+
+ ITool tools[] = getFilteredTools();
+ for(int i = 0; i < tools.length; i++){
+ if(!tools[i].supportsBuild(managed))
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean buildsFileType(String srcExt) {
+ // Check to see if there is a rule to build a file with this extension
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool != null && tool.buildsFileType(srcExt)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getOutputExtension(String resourceExtension) {
+ String outputExtension = null;
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ outputExtension = tool.getOutputExtension(resourceExtension);
+ if (outputExtension != null) {
+ return outputExtension;
+ }
+ }
+ return null;
+ }
+
+ public boolean isHeaderFile(String ext) {
+ // Check to see if there is a rule to build a file with this extension
+ IManagedProject manProj = getParent().getManagedProject();
+ IProject project = null;
+ if (manProj != null) {
+ project = (IProject)manProj.getOwner();
+ }
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ try {
+ if (project != null) {
+ // Make sure the tool is right for the project
+ switch (tool.getNatureFilter()) {
+ case ITool.FILTER_C:
+ if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ return tool.isHeaderFile(ext);
+ }
+ break;
+ case ITool.FILTER_CC:
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ return tool.isHeaderFile(ext);
+ }
+ break;
+ case ITool.FILTER_BOTH:
+ return tool.isHeaderFile(ext);
+ }
+ } else {
+ return tool.isHeaderFile(ext);
+ }
+ } catch (CoreException e) {
+ continue;
+ }
+ }
+ return false;
+ }
+
+ public Set contributeErrorParsers(Set set){
+ if(set == null)
+ set = new HashSet();
+
+ if(toolChain != null)
+ toolChain.contributeErrorParsers(this, set, true);
+
+ return set;
+ }
+
+ public void resetErrorParsers() {
+ if(toolChain != null)
+ toolChain.resetErrorParsers(this);
+ }
+
+ void removeErrorParsers(Set set) {
+ if(toolChain != null)
+ toolChain.removeErrorParsers(this, set);
+ }
+
+ public ITool getToolById(String id) {
+ if(toolChain != null)
+ return toolChain.getTool(id);
+ return null;
+ }
+
+ void resolveProjectReferences(boolean onLoad){
+ if(toolChain != null)
+ toolChain.resolveProjectReferences(onLoad);
+ }
+
+ public void resetOptionSettings() {
+ // We just need to remove all Options
+ ITool[] tools = getTools();
+ IToolChain toolChain = getToolChain();
+ IOption[] opts;
+
+ // Send out the event to notify the options that they are about to be removed.
+ // Do not do this for the child resource configurations as they are handled when
+ // the configuration itself is destroyed.
+// ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE, false);
+ // Remove the configurations
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ opts = tool.getOptions();
+ for (int j = 0; j < opts.length; j++) {
+ tool.removeOption(opts[j]);
+ }
+ }
+ opts = toolChain.getOptions();
+ for (int j = 0; j < opts.length; j++) {
+ toolChain.removeOption(opts[j]);
+ }
+
+// rebuildNeeded = true;
+ }
+
+
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HoldsOptions.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HoldsOptions.java
index 461af6aa688..15a6d937a17 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HoldsOptions.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HoldsOptions.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Symbian Ltd and others.
+ * Copyright (c) 2005, 2007 Symbian Ltd 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
@@ -11,22 +11,25 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
/**
* Implements the functionality that is needed to hold options and option
@@ -46,7 +49,7 @@ import org.w3c.dom.Node;
*
* @since 3.0
*/
-public class HoldsOptions extends BuildObject implements IHoldsOptions {
+public abstract class HoldsOptions extends BuildObject implements IHoldsOptions, IBuildPropertiesRestriction, IBuildPropertyChangeListener {
private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
@@ -88,6 +91,8 @@ public class HoldsOptions extends BuildObject implements IHoldsOptions {
// Note: This function ignores OptionCategories since they should not be
// found on an non-extension tools
+
+ boolean copyIds = id.equals(source.id);
if (source.optionList != null) {
Iterator iter = source.getOptionList().listIterator();
while (iter.hasNext()) {
@@ -96,16 +101,47 @@ public class HoldsOptions extends BuildObject implements IHoldsOptions {
String subId;
String subName;
if (option.getSuperClass() != null) {
- subId = option.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subId = copyIds ? option.getId() : option.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
subName = option.getSuperClass().getName();
} else {
- subId = option.getId() + "." + nnn; //$NON-NLS-1$
+ subId = copyIds ? option.getId() : option.getId() + "." + nnn; //$NON-NLS-1$
subName = option.getName();
}
Option newOption = new Option(this, subId, subName, option);
addOption(newOption);
}
- }
+ }
+
+ if(copyIds){
+ isDirty = source.isDirty;
+ rebuildState = source.rebuildState;
+ }
+ }
+
+ void copyNonoverriddenSettings(HoldsOptions ho){
+ if (ho.optionList == null || ho.optionList.size() == 0)
+ return;
+
+ IOption options[] = getOptions();
+ for(int i = 0; i < options.length; i++){
+ if(!options[i].getParent().equals(ho))
+ continue;
+
+ Option option = (Option)options[i];
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (option.getSuperClass() != null) {
+ subId = option.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = option.getSuperClass().getName();
+ } else {
+ subId = option.getId() + "." + nnn; //$NON-NLS-1$
+ subName = option.getName();
+ }
+ Option newOption = new Option(this, subId, subName, option);
+ addOption(newOption);
+
+ }
}
/*
@@ -118,13 +154,13 @@ public class HoldsOptions extends BuildObject implements IHoldsOptions {
* @param element which is loaded as child only iff it is of the correct type
* @return true when a child has been loaded, false otherwise
*/
- protected boolean loadChild(Node element) {
- if (element.getNodeName().equals(ITool.OPTION)) {
- Option option = new Option(this, (Element)element);
+ protected boolean loadChild(ICStorageElement element) {
+ if (element.getName().equals(ITool.OPTION)) {
+ Option option = new Option(this, element);
addOption(option);
return true;
- } else if (element.getNodeName().equals(ITool.OPTION_CAT)) {
- new OptionCategory(this, (Element)element);
+ } else if (element.getName().equals(ITool.OPTION_CAT)) {
+ new OptionCategory(this, element);
return true;
}
return false;
@@ -156,7 +192,7 @@ public class HoldsOptions extends BuildObject implements IHoldsOptions {
* @param element
* @throws BuildException
*/
- protected void serialize(Document doc, Element element) throws BuildException {
+ protected void serialize(ICStorageElement element) throws BuildException {
Iterator iter;
@@ -164,9 +200,8 @@ public class HoldsOptions extends BuildObject implements IHoldsOptions {
iter = childOptionCategories.listIterator();
while (iter.hasNext()) {
OptionCategory optCat = (OptionCategory)iter.next();
- Element optCatElement = doc.createElement(OPTION);
- element.appendChild(optCatElement);
- optCat.serialize(doc, optCatElement);
+ ICStorageElement optCatElement = element.createChild(OPTION);
+ optCat.serialize(optCatElement);
}
}
@@ -174,9 +209,8 @@ public class HoldsOptions extends BuildObject implements IHoldsOptions {
iter = optionElements.listIterator();
while (iter.hasNext()) {
Option option = (Option) iter.next();
- Element optionElement = doc.createElement(OPTION);
- element.appendChild(optionElement);
- option.serialize(doc, optionElement);
+ ICStorageElement optionElement = element.createChild(OPTION);
+ option.serialize(optionElement);
}
}
@@ -608,4 +642,105 @@ public class HoldsOptions extends BuildObject implements IHoldsOptions {
}
}
}
+
+ public void propertiesChanged() {
+ if(isExtensionElement())
+ return;
+ adjustOptions(false);
+ }
+
+ public void adjustOptions(boolean extensions){
+ IOption options[] = getOptions();
+
+ for(int i = 0; i < options.length; i++){
+ Option option = (Option)options[i];
+ BooleanExpressionApplicabilityCalculator calc =
+ option.getBooleanExpressionCalculator(extensions);
+
+ if(calc != null)
+ calc.adjustOption(getParentResourceInfo(),this,option, extensions);
+ }
+ }
+
+ public boolean supportsType(String type) {
+ IOption options[] = getOptions();
+ boolean supports = false;
+ for(int i = 0; i < options.length; i++){
+ Option option = (Option)options[i];
+ if(option.supportsType(type)){
+ supports = true;
+ break;
+ }
+ }
+ return supports;
+ }
+
+ public boolean supportsType(IBuildPropertyType type) {
+ return supportsType(type.getId());
+ }
+
+ public boolean supportsValue(String type, String value){
+ IOption options[] = getOptions();
+ boolean supports = false;
+ for(int i = 0; i < options.length; i++){
+ Option option = (Option)options[i];
+ if(option.supportsValue(type, value)){
+ supports = true;
+ break;
+ }
+ }
+ return supports;
+ }
+
+ public boolean supportsValue(IBuildPropertyType type,
+ IBuildPropertyValue value) {
+ return supportsValue(type.getId(), value.getId());
+ }
+
+ public abstract boolean isExtensionElement();
+
+ protected abstract IResourceInfo getParentResourceInfo();
+
+ public String[] getRequiredTypeIds() {
+ List list = new ArrayList();
+ IOption options[] = getOptions();
+ for(int i = 0; i < options.length; i++){
+ Option option = (Option)options[i];
+ list.addAll(Arrays.asList(option.getRequiredTypeIds()));
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public String[] getSupportedTypeIds() {
+ List list = new ArrayList();
+ IOption options[] = getOptions();
+ for(int i = 0; i < options.length; i++){
+ Option option = (Option)options[i];
+ list.addAll(Arrays.asList(option.getSupportedTypeIds()));
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ List list = new ArrayList();
+ IOption options[] = getOptions();
+ for(int i = 0; i < options.length; i++){
+ Option option = (Option)options[i];
+ list.addAll(Arrays.asList(option.getSupportedValueIds(typeId)));
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public boolean requiresType(String typeId) {
+ IOption options[] = getOptions();
+ boolean requires = false;
+ for(int i = 0; i < options.length; i++){
+ Option option = (Option)options[i];
+ if(option.requiresType(typeId)){
+ requires = true;
+ break;
+ }
+ }
+ return requires;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IBuildPropertyChangeListener.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IBuildPropertyChangeListener.java
new file mode 100644
index 00000000000..11b52bbeac4
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IBuildPropertyChangeListener.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+public interface IBuildPropertyChangeListener {
+ void propertiesChanged();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IMatchKeyProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IMatchKeyProvider.java
new file mode 100644
index 00000000000..e3855c0c13b
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IMatchKeyProvider.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.List;
+
+public interface IMatchKeyProvider {
+ Object getMatchKey();
+
+ void setIdenticalList(List list);
+
+ List getIdenticalList();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ISettingsChangeListener.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ISettingsChangeListener.java
new file mode 100644
index 00000000000..1dc239dd46d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ISettingsChangeListener.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+
+public interface ISettingsChangeListener {
+ void optionChanged(IResourceInfo rcInfo, IHoldsOptions holder, IOption option, Object oldValue);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java
index 84517d40f5f..7ef86afb231 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,11 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.managedbuilder.core.IInputOrder;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
public class InputOrder implements IInputOrder {
@@ -77,7 +76,7 @@ public class InputOrder implements IInputOrder {
* @param parent The <code>ITool</code> the InputOrder will be added to.
* @param element The XML element that contains the InputOrder settings.
*/
- public InputOrder(IInputType parent, Element element) {
+ public InputOrder(IInputType parent, ICStorageElement element) {
this.parent = parent;
isExtensionInputOrder = false;
@@ -143,20 +142,20 @@ public class InputOrder implements IInputOrder {
*
* @param element An XML element containing the InputOrder information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// path
- if (element.hasAttribute(IInputOrder.PATH)) {
+ if (element.getAttribute(IInputOrder.PATH) != null) {
path = element.getAttribute(IInputOrder.PATH);
}
// order
- if (element.hasAttribute(IInputOrder.ORDER)) {
+ if (element.getAttribute(IInputOrder.ORDER) != null) {
order = element.getAttribute(IInputOrder.ORDER);
}
// excluded
- if (element.hasAttribute(IInputOrder.EXCLUDED)) {
+ if (element.getAttribute(IInputOrder.EXCLUDED) != null) {
String isEx = element.getAttribute(IInputOrder.EXCLUDED);
if (isEx != null){
excluded = new Boolean("true".equals(isEx)); //$NON-NLS-1$
@@ -170,7 +169,7 @@ public class InputOrder implements IInputOrder {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
if (path != null) {
element.setAttribute(IInputOrder.PATH, path);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
index 5c0df40bd47..51b58f809d3 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -11,31 +11,41 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
-import org.eclipse.core.runtime.content.*;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IInputOrder;
-import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.ILanguageInfoCalculator;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
public class InputType extends BuildObject implements IInputType {
@@ -50,9 +60,12 @@ public class InputType extends BuildObject implements IInputType {
private Vector inputOrderList;
private Vector additionalInputList;
// Managed Build model attributes
- private String sourceContentTypeId;
- private IContentType sourceContentType;
- private List inputExtensions;
+ private String[] sourceContentTypeIds;
+ private IContentType[] sourceContentTypes;
+ private String[] headerContentTypeIds;
+ private IContentType[] headerContentTypes;
+ private String[] inputExtensions;
+ private String[] headerExtensions;
private String dependencyContentTypeId;
private IContentType dependencyContentType;
private List dependencyExtensions;
@@ -63,12 +76,35 @@ public class InputType extends BuildObject implements IInputType {
private Boolean primaryInput;
private IConfigurationElement dependencyGeneratorElement = null;
private IManagedDependencyGeneratorType dependencyGenerator = null;
+ private String languageId;
+ private String languageName;
+ private IConfigurationElement languageInfoCalculatorElement;
+ private ILanguageInfoCalculator languageInfoCalculator;
+ private String buildInfoDicsoveryProfileId;
+ private IScannerConfigBuilderInfo2 scannerConfigInfo;
+
+ private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
+
// Miscellaneous
private boolean isExtensionInputType = false;
private boolean isDirty = false;
private boolean resolved = true;
private boolean rebuildState;
+// private class DefaultLanguageInfoCalculator implements ILanguageInfoCalculator {
+//
+// public String getLanguageId(IResourceInfo rcInfo, ITool tool, IInputType type) {
+// if(languageId == null && superClass != null)
+// return ((InputType)superClass).getLanguageInfoCalculator().getLanguageId(rcInfo, tool, type);
+// return languageId;
+// }
+//
+// public String getLanguageName(IResourceInfo rcInfo, ITool tool, IInputType type) {
+// if(languageName == null && superClass != null)
+// return ((InputType)superClass).getLanguageInfoCalculator().getLanguageName(rcInfo, tool, type);
+// return languageName;
+// }
+// }
/*
* C O N S T R U C T O R S
*/
@@ -90,6 +126,10 @@ public class InputType extends BuildObject implements IInputType {
loadFromManifest(element);
+ IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
+ if(enablements.length > 0)
+ booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
+
// Hook me up to the Managed Build Manager
ManagedBuildManager.addExtensionInputType(this);
@@ -103,6 +143,9 @@ public class InputType extends BuildObject implements IInputType {
} else if (iElement.getName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
AdditionalInput addlInput = new AdditionalInput(this, iElement);
getAdditionalInputList().add(addlInput);
+ } else if (iElement.getName().equals(DISCOVERY_INFO)){
+ ICStorageElement el = new ManagedConfigStorageElement(iElement);
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(null), el, ScannerConfigProfileManager.NULL_PROFILE_ID);
}
}
}
@@ -144,7 +187,7 @@ public class InputType extends BuildObject implements IInputType {
* @param element The XML element that contains the InputType settings.
*
*/
- public InputType(ITool parent, Element element) {
+ public InputType(ITool parent, ICStorageElement element) {
this.parent = parent;
isExtensionInputType = false;
@@ -152,15 +195,17 @@ public class InputType extends BuildObject implements IInputType {
loadFromProject(element);
// Load children
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
- InputOrder inputOrder = new InputOrder(this, (Element)configElement);
+ ICStorageElement configElements[] = element.getChildren();
+ for (int i = 0; i < configElements.length; ++i) {
+ ICStorageElement configElement = configElements[i];
+ if (configElement.getName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
+ InputOrder inputOrder = new InputOrder(this, configElement);
getInputOrderList().add(inputOrder);
- } else if (configElement.getNodeName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
- AdditionalInput addlInput = new AdditionalInput(this, (Element)configElement);
+ } else if (configElement.getName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
+ AdditionalInput addlInput = new AdditionalInput(this, configElement);
getAdditionalInputList().add(addlInput);
+ } else if(configElement.getName().equals(DISCOVERY_INFO)){
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(parent.getParentResourceInfo(), parent, this), configElement, ScannerConfigProfileManager.NULL_PROFILE_ID);
}
}
}
@@ -185,16 +230,29 @@ public class InputType extends BuildObject implements IInputType {
setName(name);
isExtensionInputType = false;
+ boolean copyIds = Id.equals(inputType.id);
// Copy the remaining attributes
- if (inputType.sourceContentTypeId != null) {
- sourceContentTypeId = new String(inputType.sourceContentTypeId);
+ if (inputType.sourceContentTypeIds != null) {
+ sourceContentTypeIds = (String[])inputType.sourceContentTypeIds.clone();
+ }
+ if(inputType.sourceContentTypes != null) {
+ sourceContentTypes = (IContentType[])inputType.sourceContentTypes.clone();
}
- sourceContentType = inputType.sourceContentType;
if (inputType.inputExtensions != null) {
- inputExtensions = new ArrayList(inputType.inputExtensions);
+ inputExtensions = (String[])inputType.inputExtensions.clone();
}
+ if (inputType.headerContentTypeIds != null) {
+ headerContentTypeIds = (String[])inputType.headerContentTypeIds.clone();
+ }
+ if (inputType.headerContentTypes != null) {
+ headerContentTypes = (IContentType[])inputType.headerContentTypes.clone();
+ }
+ if (inputType.headerExtensions != null) {
+ headerExtensions = (String[])inputType.headerExtensions.clone();
+ }
+
if (inputType.dependencyContentTypeId != null) {
dependencyContentTypeId = new String(inputType.dependencyContentTypeId);
}
@@ -220,6 +278,15 @@ public class InputType extends BuildObject implements IInputType {
dependencyGeneratorElement = inputType.dependencyGeneratorElement;
dependencyGenerator = inputType.dependencyGenerator;
+ languageId = inputType.languageId;
+ languageName = inputType.languageName;
+ languageInfoCalculatorElement = inputType.languageInfoCalculatorElement;
+ languageInfoCalculator = inputType.languageInfoCalculator;
+ buildInfoDicsoveryProfileId = inputType.buildInfoDicsoveryProfileId;
+
+ if(inputType.scannerConfigInfo != null){
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(parent.getParentResourceInfo(), parent, this), inputType.scannerConfigInfo, inputType.scannerConfigInfo.getSelectedProfileId());
+ }
// Clone the children
if (inputType.inputOrderList != null) {
Iterator iter = inputType.getInputOrderList().listIterator();
@@ -238,8 +305,13 @@ public class InputType extends BuildObject implements IInputType {
}
}
- setDirty(true);
- setRebuildState(true);
+ if(copyIds){
+ isDirty = inputType.isDirty;
+ rebuildState = inputType.rebuildState;
+ } else {
+ setDirty(true);
+ setRebuildState(true);
+ }
}
/*
@@ -265,17 +337,60 @@ public class InputType extends BuildObject implements IInputType {
superClassId = element.getAttribute(IProjectType.SUPERCLASS);
// sourceContentType
- sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
+ List list = new ArrayList();
+ String ids = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
+ if(ids != null){
+ StringTokenizer tokenizer = new StringTokenizer(ids, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+ if(list.size() != 0){
+ sourceContentTypeIds = (String[])list.toArray(new String[list.size()]);
+ list.clear();
+ }
+ }
// Get the supported input file extensions
String inputs = element.getAttribute(ITool.SOURCES);
if (inputs != null) {
StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
+ list.add(tokenizer.nextElement());
+ }
+
+ if(list.size() != 0){
+ inputExtensions = (String[])list.toArray(new String[list.size()]);
+ list.clear();
+ }
+ }
+
+ // headerContentType
+ ids = element.getAttribute(IInputType.HEADER_CONTENT_TYPE);
+ if(ids != null){
+ StringTokenizer tokenizer = new StringTokenizer(ids, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+ if(list.size() != 0){
+ headerContentTypeIds = (String[])list.toArray(new String[list.size()]);
+ list.clear();
}
}
+ // Get the supported header file extensions
+ String hs = element.getAttribute(HEADERS);
+ if (hs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(hs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+
+ if(list.size() != 0){
+ headerExtensions = (String[])list.toArray(new String[list.size()]);
+ list.clear();
+ }
+ }
+
// dependencyContentType
dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
@@ -309,6 +424,16 @@ public class InputType extends BuildObject implements IInputType {
// buildVariable
buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
+ languageId = element.getAttribute(LANGUAGE_ID);
+ languageName = element.getAttribute(LANGUAGE_NAME);
+ if (element.getAttribute(LANGUAGE_INFO_CALCULATOR) != null && element instanceof DefaultManagedConfigElement) {
+ languageInfoCalculatorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+// else {
+// languageInfoCalculator = new DefaultLanguageInfoCalculator();
+// }
+ buildInfoDicsoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
+
// Store the configuration element IFF there is a dependency generator defined
String depGenerator = element.getAttribute(ITool.DEP_CALC_ID);
if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
@@ -322,13 +447,13 @@ public class InputType extends BuildObject implements IInputType {
*
* @param element An XML element containing the InputType information
*/
- protected boolean loadFromProject(Element element) {
+ protected boolean loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@@ -343,26 +468,98 @@ public class InputType extends BuildObject implements IInputType {
// sourceContentType
IContentTypeManager manager = Platform.getContentTypeManager();
- if (element.hasAttribute(IInputType.SOURCE_CONTENT_TYPE)) {
- sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
- if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
- sourceContentType = manager.getContentType(sourceContentTypeId);
+ List list = new ArrayList();
+ if (element.getAttribute(IInputType.SOURCE_CONTENT_TYPE) != null) {
+ String ids = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
+ if (ids != null) {
+ StringTokenizer tokenizer = new StringTokenizer(ids, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+
+ if(list.size() != 0){
+ sourceContentTypeIds = (String[])list.toArray(new String[list.size()]);
+ list.clear();
+ }
+
+ if(sourceContentTypeIds != null){
+ for(int i = 0; i < sourceContentTypeIds.length; i++){
+ IContentType type = manager.getContentType(sourceContentTypeIds[i]);
+ if(type != null)
+ list.add(type);
+ }
+
+ if(list.size() != 0){
+ sourceContentTypes = (IContentType[])list.toArray(new IContentType[list.size()]);
+ list.clear();
+ }
+ }
}
}
// sources
- if (element.hasAttribute(IInputType.SOURCES)) {
+ if (element.getAttribute(IInputType.SOURCES) != null) {
String inputs = element.getAttribute(ITool.SOURCES);
if (inputs != null) {
StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
+ list.add(tokenizer.nextElement());
+ }
+
+ if(list.size() != 0){
+ inputExtensions = (String[])list.toArray(new String[list.size()]);
+ list.clear();
+ }
+ }
+ }
+
+ //header content types
+ if (element.getAttribute(IInputType.HEADER_CONTENT_TYPE) != null) {
+ String ids = element.getAttribute(IInputType.HEADER_CONTENT_TYPE);
+ if (ids != null) {
+ StringTokenizer tokenizer = new StringTokenizer(ids, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+
+ if(list.size() != 0){
+ headerContentTypeIds = (String[])list.toArray(new String[list.size()]);
+ list.clear();
+ }
+
+ if(headerContentTypeIds != null){
+ for(int i = 0; i < headerContentTypeIds.length; i++){
+ IContentType type = manager.getContentType(headerContentTypeIds[i]);
+ if(type != null)
+ list.add(type);
+ }
+
+ if(list.size() != 0){
+ headerContentTypes = (IContentType[])list.toArray(new IContentType[list.size()]);
+ list.clear();
+ }
+ }
+ }
+ }
+
+ // headers
+ if (element.getAttribute(IInputType.HEADERS) != null) {
+ String inputs = element.getAttribute(HEADERS);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+
+ if(list.size() != 0){
+ headerExtensions = (String[])list.toArray(new String[list.size()]);
+ list.clear();
}
}
}
// dependencyContentType
- if (element.hasAttribute(IInputType.DEPENDENCY_CONTENT_TYPE)) {
+ if (element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE) != null) {
dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
dependencyContentType = manager.getContentType(dependencyContentTypeId);
@@ -371,7 +568,7 @@ public class InputType extends BuildObject implements IInputType {
// dependencyExtensions
// Get the dependency (header file) extensions
- if (element.hasAttribute(IInputType.DEPENDENCY_EXTENSIONS)) {
+ if (element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS) != null) {
String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
if (headers != null) {
StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
@@ -382,17 +579,17 @@ public class InputType extends BuildObject implements IInputType {
}
// option
- if (element.hasAttribute(IInputType.OPTION)) {
+ if (element.getAttribute(IInputType.OPTION) != null) {
optionId = element.getAttribute(IInputType.OPTION);
}
// assignToOption
- if (element.hasAttribute(IInputType.ASSIGN_TO_OPTION)) {
+ if (element.getAttribute(IInputType.ASSIGN_TO_OPTION) != null) {
assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
}
// multipleOfType
- if (element.hasAttribute(IInputType.MULTIPLE_OF_TYPE)) {
+ if (element.getAttribute(IInputType.MULTIPLE_OF_TYPE) != null) {
String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
if (isMOT != null){
multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
@@ -400,7 +597,7 @@ public class InputType extends BuildObject implements IInputType {
}
// primaryInput
- if (element.hasAttribute(IInputType.PRIMARY_INPUT)) {
+ if (element.getAttribute(IInputType.PRIMARY_INPUT) != null) {
String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
if (isPI != null){
primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
@@ -408,18 +605,37 @@ public class InputType extends BuildObject implements IInputType {
}
// buildVariable
- if (element.hasAttribute(IInputType.BUILD_VARIABLE)) {
+ if (element.getAttribute(IInputType.BUILD_VARIABLE) != null) {
buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
}
+ languageId = element.getAttribute(LANGUAGE_ID);
+ languageName = element.getAttribute(LANGUAGE_NAME);
+ buildInfoDicsoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
+
// Note: dependency generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
- if (element.hasAttribute(ITool.DEP_CALC_ID)) {
+ if (element.getAttribute(ITool.DEP_CALC_ID) != null) {
// TODO: Issue warning?
}
return true;
}
+
+ private String composeString(String array[], String separator){
+ if(array == null)
+ return null;
+ if(array.length == 0)
+ return "";
+
+ StringBuffer buf = new StringBuffer();
+ buf.append(array[0]);
+ for(int i = 1; i < array.length; i++){
+ buf.append(separator).append(array[i]);
+ }
+
+ return buf.toString();
+ }
/**
* Persist the InputType to the project file.
@@ -427,7 +643,7 @@ public class InputType extends BuildObject implements IInputType {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
if (superClass != null)
element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
@@ -438,23 +654,29 @@ public class InputType extends BuildObject implements IInputType {
}
// sourceContentType
- if (sourceContentTypeId != null) {
- element.setAttribute(IInputType.SOURCE_CONTENT_TYPE, sourceContentTypeId);
+ if (sourceContentTypeIds != null) {
+ String s = composeString(sourceContentTypeIds, DEFAULT_SEPARATOR);
+ element.setAttribute(IInputType.SOURCE_CONTENT_TYPE, s);
}
// input file extensions
- if (getInputExtensionsList().size() > 0) {
- String inputs;
- List list = getInputExtensionsList();
- Iterator iter = list.listIterator();
- inputs = (String)iter.next();
- while (iter.hasNext()) {
- inputs += DEFAULT_SEPARATOR;
- inputs += iter.next();
- }
+ if (inputExtensions != null) {
+ String inputs = composeString(inputExtensions, DEFAULT_SEPARATOR);
element.setAttribute(IInputType.SOURCES, inputs);
}
+
+ // headerContentType
+ if (headerContentTypeIds != null) {
+ String s = composeString(headerContentTypeIds, DEFAULT_SEPARATOR);
+ element.setAttribute(IInputType.HEADER_CONTENT_TYPE, s);
+ }
+ // input file extensions
+ if (headerExtensions != null) {
+ String inputs = composeString(headerExtensions, DEFAULT_SEPARATOR);
+ element.setAttribute(IInputType.HEADERS, inputs);
+ }
+
// dependencyContentType
if (dependencyContentTypeId != null) {
element.setAttribute(IInputType.DEPENDENCY_CONTENT_TYPE, dependencyContentTypeId);
@@ -493,6 +715,15 @@ public class InputType extends BuildObject implements IInputType {
element.setAttribute(IInputType.BUILD_VARIABLE, buildVariable);
}
+ if(languageId != null)
+ element.setAttribute(LANGUAGE_ID, languageId);
+
+ if(languageName != null)
+ element.setAttribute(LANGUAGE_NAME, languageName);
+
+ if(buildInfoDicsoveryProfileId != null)
+ element.setAttribute(SCANNER_CONFIG_PROFILE_ID, buildInfoDicsoveryProfileId);
+
// Note: dependency generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (dependencyGeneratorElement != null) {
@@ -504,17 +735,20 @@ public class InputType extends BuildObject implements IInputType {
Iterator iter = childElements.listIterator();
while (iter.hasNext()) {
InputOrder io = (InputOrder) iter.next();
- Element ioElement = doc.createElement(InputOrder.INPUT_ORDER_ELEMENT_NAME);
- element.appendChild(ioElement);
- io.serialize(doc, ioElement);
+ ICStorageElement ioElement = element.createChild(InputOrder.INPUT_ORDER_ELEMENT_NAME);
+ io.serialize(ioElement);
}
childElements = getAdditionalInputList();
iter = childElements.listIterator();
while (iter.hasNext()) {
AdditionalInput ai = (AdditionalInput) iter.next();
- Element aiElement = doc.createElement(AdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME);
- element.appendChild(aiElement);
- ai.serialize(doc, aiElement);
+ ICStorageElement aiElement = element.createChild(AdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME);
+ ai.serialize(aiElement);
+ }
+
+ if(scannerConfigInfo != null){
+ ICStorageElement el = element.createChild(DISCOVERY_INFO);
+ ScannerConfigInfoFactory2.serialize(scannerConfigInfo, el);
}
// I am clean now
@@ -1023,73 +1257,248 @@ public class InputType extends BuildObject implements IInputType {
* @see org.eclipse.cdt.core.build.managed.IInputType#getSourceContentType()
*/
public IContentType getSourceContentType() {
- if (sourceContentType == null) {
+ IContentType[] types = getSourceContentTypes();
+
+ if(types != null && types.length != 0) {
+ return types[0];
+ }
+ return null;
+ }
+
+ public IContentType[] getSourceContentTypes() {
+ if (sourceContentTypes == null) {
if (superClass != null) {
- return superClass.getSourceContentType();
- } else {
- return null;
- }
+ return superClass.getSourceContentTypes();
+ }
+
+ return new IContentType[0];
+ }
+ return (IContentType[])sourceContentTypes.clone();
+ }
+
+ public IContentType[] getHeaderContentTypes() {
+ if (headerContentTypes == null) {
+ if (superClass != null) {
+ return superClass.getHeaderContentTypes();
+ }
+
+ return new IContentType[0];
+ }
+ return (IContentType[])headerContentTypes.clone();
+ }
+
+ public String[] getHeaderExtensionsAttribute() {
+ if (headerExtensions == null) {
+ if (superClass != null) {
+ return superClass.getHeaderExtensionsAttribute();
+ }
+
+ return new String[0];
+ }
+ return (String[])headerExtensions.clone();
+ }
+
+
+
+ public String[] getHeaderContentTypeIds() {
+ if (headerContentTypeIds == null) {
+ if (superClass != null) {
+ return superClass.getHeaderContentTypeIds();
+ }
+
+ return new String[0];
+ }
+ return (String[])headerContentTypeIds.clone();
+ }
+
+ public String[] getSourceContentTypeIds() {
+ if (sourceContentTypeIds == null) {
+ if (superClass != null) {
+ return superClass.getSourceContentTypeIds();
+ }
+
+ return new String[0];
+ }
+ return (String[])sourceContentTypeIds.clone();
+ }
+
+ public void setHeaderContentTypeIds(String[] ids) {
+ if(!Arrays.equals(headerContentTypeIds, ids)){
+ headerContentTypeIds = ids != null ?
+ (String[])ids.clone() : null;
+
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+
+ public void setHeaderExtensionsAttribute(String[] extensions) {
+ if(!Arrays.equals(headerExtensions, extensions)){
+ headerExtensions = extensions != null ?
+ (String[])extensions.clone() : null;
+
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+
+ public void setSourceContentTypeIds(String[] ids) {
+ if(!Arrays.equals(sourceContentTypeIds, ids)){
+ sourceContentTypeIds = ids != null ?
+ (String[])ids.clone() : null;
+
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+
+ public void setSourceExtensionsAttribute(String[] extensions) {
+ if(!Arrays.equals(inputExtensions, extensions)){
+ inputExtensions = extensions != null ?
+ (String[])extensions.clone() : null;
+
+ setDirty(true);
+ setRebuildState(true);
}
- return sourceContentType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#setSourceContentType()
*/
public void setSourceContentType(IContentType type) {
- if (sourceContentType != type) {
- sourceContentType = type;
- if (sourceContentType != null) {
- sourceContentTypeId = sourceContentType.getId();
- } else {
- sourceContentTypeId = null;
+ if(type == null){
+ if(sourceContentTypes != null){
+ sourceContentTypes = null;
+ sourceContentTypeIds = null;
+ setDirty(true);
+ setRebuildState(true);
+ }
+ } else {
+ if(sourceContentTypes == null
+ || sourceContentTypes.length != 1
+ || sourceContentTypes[0] != type){
+ sourceContentTypes = new IContentType[1];
+ sourceContentTypes[0] = type;
+ sourceContentTypeIds = new String[1];
+ sourceContentTypeIds[0] = type.getId();
+ setDirty(true);
+ setRebuildState(true);
+ }
+ return;
+ }
+ }
+
+ public void setSourceContentTypes(IContentType types[]) {
+ if(types == null){
+ if(sourceContentTypes != null){
+ sourceContentTypes = null;
+ sourceContentTypeIds = null;
+ setDirty(true);
+ setRebuildState(true);
+ }
+ } else {
+ sourceContentTypes = (IContentType[])types.clone();
+ sourceContentTypeIds = new String[types.length];
+ for(int i = 0; i < types.length; i++){
+ sourceContentTypeIds[i] = types[i].getId();
}
setDirty(true);
setRebuildState(true);
}
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#getSourceExtensionsAttribute()
*/
public String[] getSourceExtensionsAttribute() {
- if( (inputExtensions == null) || ( inputExtensions.size() == 0) ) {
+ if( inputExtensions == null ) {
// If I have a superClass, ask it
if (superClass != null) {
return superClass.getSourceExtensionsAttribute();
- } else {
- inputExtensions = new ArrayList();
}
+
+ return new String[0];
}
- return (String[])inputExtensions.toArray(new String[inputExtensions.size()]);
+ return (String[])inputExtensions.clone();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#setSourceExtensionsAttribute()
*/
public void setSourceExtensionsAttribute(String extensions) {
- getInputExtensionsList().clear();
- if (extensions != null) {
- StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
+ if(extensions == null){
+ if(inputExtensions != null){
+ inputExtensions = null;
+ setDirty(true);
+ setRebuildState(true);
+ }
+ } else {
+ List list = new ArrayList();
+ if (extensions != null) {
+ StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+ }
+
+ String[] newExts = (String[])list.toArray(new String[list.size()]);
+ if(!Arrays.equals(newExts, inputExtensions)){
+ inputExtensions = newExts;
+ setDirty(true);
+ setRebuildState(true);
}
}
- setDirty(true);
- setRebuildState(true);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#getSourceExtensions()
*/
public String[] getSourceExtensions(ITool tool) {
+ return getSourceExtensions(tool, ((Tool)tool).getProject());
+// // Use content type if specified and registered with Eclipse
+// IContentType types[] = getSourceContentTypes();
+// if (types.length != 0) {
+// IContentType type;
+// List list = new ArrayList();
+// for(int i = 0; i < types.length; i++){
+// type = types[i];
+// list.addAll(Arrays.asList(((Tool)tool).getContentTypeFileSpecs(type)));
+// }
+// return (String[])list.toArray(new String[list.size()]);
+// }
+// return getSourceExtensionsAttribute();
+ }
+
+ public String[] getSourceExtensions(ITool tool, IProject project) {
// Use content type if specified and registered with Eclipse
- IContentType type = getSourceContentType();
- if (type != null) {
- return ((Tool)tool).getContentTypeFileSpecs(type);
+ IContentType types[] = getSourceContentTypes();
+ if (types.length != 0) {
+ IContentType type;
+ List list = new ArrayList();
+ for(int i = 0; i < types.length; i++){
+ type = types[i];
+ list.addAll(Arrays.asList(((Tool)tool).getContentTypeFileSpecs(type, project)));
+ }
+ return (String[])list.toArray(new String[list.size()]);
}
return getSourceExtensionsAttribute();
}
+
+
+ public String[] getHeaderExtensions(ITool tool) {
+ IContentType types[] = getHeaderContentTypes();
+ if (types.length != 0) {
+ IContentType type;
+ List list = new ArrayList();
+ for(int i = 0; i < types.length; i++){
+ type = types[i];
+ list.addAll(Arrays.asList(((Tool)tool).getContentTypeFileSpecs(type)));
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
+ return getHeaderExtensionsAttribute();
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#isSourceExtension()
@@ -1102,13 +1511,6 @@ public class InputType extends BuildObject implements IInputType {
return false;
}
- private List getInputExtensionsList() {
- if (inputExtensions == null) {
- inputExtensions = new ArrayList();
- }
- return inputExtensions;
- }
-
/*
* O B J E C T S T A T E M A I N T E N A N C E
*/
@@ -1183,9 +1585,35 @@ public class InputType extends BuildObject implements IInputType {
// Resolve content types
IContentTypeManager manager = Platform.getContentTypeManager();
- if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
- sourceContentType = manager.getContentType(sourceContentTypeId);
+ List list = new ArrayList();
+ if (sourceContentTypeIds != null) {
+ for(int i = 0; i < sourceContentTypeIds.length; i++){
+ IContentType type = manager.getContentType(sourceContentTypeIds[i]);
+ if(type != null)
+ list.add(type);
+ }
+ if(list.size() != 0){
+ sourceContentTypes = (IContentType[])list.toArray(new IContentType[list.size()]);
+ list.clear();
+ } else {
+ sourceContentTypes = new IContentType[0];
+ }
+ }
+
+ if (headerContentTypeIds != null) {
+ for(int i = 0; i < headerContentTypeIds.length; i++){
+ IContentType type = manager.getContentType(headerContentTypeIds[i]);
+ if(type != null)
+ list.add(type);
+ }
+ if(list.size() != 0){
+ headerContentTypes = (IContentType[])list.toArray(new IContentType[list.size()]);
+ list.clear();
+ } else {
+ headerContentTypes = new IContentType[0];
+ }
}
+
if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
dependencyContentType = manager.getContentType(dependencyContentTypeId);
}
@@ -1272,4 +1700,198 @@ public class InputType extends BuildObject implements IInputType {
}
+ public IResourceInfo getRcInfo(ITool tool) {
+ IBuildObject parent = tool.getParent();
+ if(parent instanceof IFileInfo)
+ return (IFileInfo)parent;
+ else if(parent instanceof IToolChain)
+ return ((IToolChain)parent).getParentFolderInfo();
+ return null;
+ }
+
+ private ILanguageInfoCalculator getLanguageInfoCalculator(){
+ if(languageInfoCalculator == null){
+ if(languageInfoCalculatorElement != null){
+ try {
+ Object ex = languageInfoCalculatorElement.createExecutableExtension(LANGUAGE_INFO_CALCULATOR);
+ if(ex instanceof ILanguageInfoCalculator)
+ languageInfoCalculator = (ILanguageInfoCalculator)ex;
+ } catch (CoreException e) {
+ }
+ }
+
+// if(languageInfoCalculator == null)
+// languageInfoCalculator = new DefaultLanguageInfoCalculator();
+ }
+ return languageInfoCalculator;
+ }
+
+ public String getLanguageIdAttribute(){
+ if(languageId == null){
+ if(superClass != null){
+ return ((InputType)superClass).getLanguageIdAttribute();
+ }
+ return null;
+ }
+ return languageId;
+ }
+
+ public String getLanguageNameAttribute(){
+ if(languageName == null){
+ if(superClass != null){
+ return ((InputType)superClass).getLanguageNameAttribute();
+ }
+ return null;
+ }
+ return languageName;
+ }
+
+ public String getLanguageId(ITool tool){
+ IResourceInfo rcInfo = getRcInfo(tool);
+ String langId = this.languageId;
+ if(langId == null || isExtensionInputType){
+ ILanguageInfoCalculator calc = getLanguageInfoCalculator();
+ if(calc != null)
+ langId = calc.getLanguageId(rcInfo, tool, this);
+ }
+
+ if(langId == null){
+ langId = getLanguageIdAttribute();
+ }
+
+ return langId;
+ }
+
+ public String getLanguageName(ITool tool){
+ IResourceInfo rcInfo = getRcInfo(tool);
+ String langName = this.languageName;
+ if(langName == null || isExtensionInputType){
+ ILanguageInfoCalculator calc = getLanguageInfoCalculator();
+ if(calc != null)
+ langName = calc.getLanguageName(rcInfo, tool, this);
+ }
+
+ if(langName == null){
+ langName = getLanguageNameAttribute();
+ if(langName == null){
+ IContentType types[] = getSourceContentTypes();
+ for(int i = 0; i < types.length; i++){
+ String name = types[i].getName();
+ if(name != null && name.length() != 0){
+ langName = name;
+ break;
+ }
+ }
+
+ if(langName == null){
+ types = getHeaderContentTypes();
+ for(int i = 0; i < types.length; i++){
+ String name = types[i].getName();
+ if(name != null && name.length() != 0){
+ langName = name;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if(langName == null){
+ String[] exts = getSourceExtensions(tool);
+ if(exts.length != 0){
+ langName = CDataUtil.arrayToString(exts, ","); //$NON-NLS-1$
+ } else {
+ exts = getHeaderExtensions(tool);
+ if(exts.length != 0)
+ langName = CDataUtil.arrayToString(exts, ","); //$NON-NLS-1$
+ }
+ }
+
+ if(langName == null){
+ langName = getName();
+ if(langName == null){
+ langName = tool.getName();
+ if(langName == null){
+ langName = getId();
+ }
+ }
+ }
+
+ return langName;
+ }
+
+ public String getDiscoveryProfileId(ITool tool) {
+ String id = getDiscoveryProfileIdAttribute();
+ if(id == null){
+ id = ((Tool)tool).getDiscoveryProfileId();
+ }
+ return id;
+ }
+
+ public String getDiscoveryProfileIdAttribute(){
+ if(buildInfoDicsoveryProfileId == null && superClass != null)
+ return ((InputType)superClass).getDiscoveryProfileIdAttribute();
+ return buildInfoDicsoveryProfileId;
+ }
+
+ public void setLanguageIdAttribute(String id) {
+ languageId = id;
+ }
+
+ public void setLanguageNameAttribute(String name) {
+ languageName = name;
+ }
+
+ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
+ if(booleanExpressionCalculator == null){
+ if(superClass != null){
+ return ((InputType)superClass).getBooleanExpressionCalculator();
+ }
+ }
+ return booleanExpressionCalculator;
+ }
+
+ public boolean isEnabled(ITool tool) {
+ if(tool.isExtensionElement())
+ return true;
+
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc == null)
+ return true;
+
+ return calc.isInputTypeEnabled(tool, this);
+ }
+
+ public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfoElement(boolean searchSuper){
+ if(scannerConfigInfo == null){
+ if(superClass != null && searchSuper){
+ return ((InputType)superClass).getScannerConfigBuilderInfoElement(true);
+ }
+ return null;
+ }
+ return scannerConfigInfo;
+ }
+
+ IScannerConfigBuilderInfo2 getScannerConfigBuilderInfo(ITool tool){
+ IScannerConfigBuilderInfo2 info = getScannerConfigBuilderInfoElement(true);
+ if(info == null){
+ info = ((Tool)tool).getScannerConfigBuilderInfo();
+ }
+ return info;
+ }
+
+ public void setScannerConfigBuilderInfo(IScannerConfigBuilderInfo2 info){
+ scannerConfigInfo = info;
+ }
+
+ public boolean hasScannerConfigSettings(){
+ if(getScannerConfigBuilderInfoElement(true) != null)
+ return true;
+
+ if(getDiscoveryProfileIdAttribute() != null)
+ return true;
+
+ return false;
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
index e8d5a0216b9..aa81fab35c7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Software Corporation and others.
+ * Copyright (c) 2002, 2007 IBM Software 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
@@ -11,12 +11,10 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
@@ -27,16 +25,16 @@ import org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
@@ -46,10 +44,8 @@ import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
@@ -61,8 +57,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -73,7 +67,7 @@ import org.w3c.dom.NodeList;
public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// The path container used for all managed projects
public static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
- private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_CONFIGURATION);
+// private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_CONFIGURATION);
//private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_TARGET);
public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
@@ -81,8 +75,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private IManagedProject managedProject;
private ICProject cProject;
- private IConfiguration defaultConfig;
- private String defaultConfigId;
+// private IConfiguration defaultConfig;
+// private String defaultConfigId;
private boolean isDirty;
private boolean isValid = false;
private IResource owner;
@@ -111,14 +105,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
rebuildNeeded = true;
// Get the default configs
- IProject project = owner.getProject();
- defaultConfigId = null;
- try {
- defaultConfigId = project.getPersistentProperty(defaultConfigProperty);
- } catch (CoreException e) {
- // Hitting this error just means the default config is not set
- return;
- }
+// IProject project = owner.getProject();
+// defaultConfigId = null;
+// try {
+// defaultConfigId = project.getPersistentProperty(defaultConfigProperty);
+// } catch (CoreException e) {
+// // Hitting this error just means the default config is not set
+// return;
+// }
}
/**
@@ -166,16 +160,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#buildsFileType(java.lang.String)
*/
public boolean buildsFileType(String srcExt) {
- // Check to see if there is a rule to build a file with this extension
- IConfiguration config = getDefaultConfiguration();
- ITool[] tools = config.getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool != null && tool.buildsFileType(srcExt)) {
- return true;
- }
- }
- return false;
+ return getDefaultConfiguration().buildsFileType(srcExt);
}
/* (non-Javadoc)
@@ -248,7 +233,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
public IConfiguration getDefaultConfiguration() {
// Get the default config associated with the project
- if (defaultConfig == null) {
+/* if (defaultConfig == null) {
if (managedProject != null) {
if (defaultConfigId != null) {
defaultConfig = managedProject.getConfiguration(defaultConfigId);
@@ -270,6 +255,22 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
}
return defaultConfig;
+*/
+ ICProjectDescription des = CoreModel.getDefault().getProjectDescription(getOwner().getProject(), false);
+ IConfiguration activeCfg = null;
+ if(des != null){
+ ICConfigurationDescription cfgDes = des.getActiveConfiguration();
+ activeCfg = managedProject.getConfiguration(cfgDes.getId());
+ }
+
+ if(activeCfg == null){
+ IConfiguration cfgs[] = managedProject.getConfigurations();
+ if(cfgs.length != 0)
+ activeCfg = cfgs[0];
+ }
+
+ return activeCfg;
+
}
/* (non-Javadoc)
@@ -407,57 +408,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForConfiguration(java.lang.String)
*/
public String[] getLibsForConfiguration(String extension) {
- Vector libs = new Vector();
- ITool tool = getDefaultConfiguration().calculateTargetTool();
- if(tool == null)
- tool = getToolFromOutputExtension(extension);
-
- if(tool != null){
- IOption[] opts = tool.getOptions();
- // Look for the lib option type
- for (int i = 0; i < opts.length; i++) {
- IOption option = opts[i];
- try {
- if (option.getValueType() == IOption.LIBRARIES) {
-
- // check to see if the option has an applicability calculator
- IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
-
- if (applicabilitytCalculator == null
- || applicabilitytCalculator.isOptionUsedInCommandLine(getDefaultConfiguration(), tool, option)) {
- String command = option.getCommand();
- String[] allLibs = option.getLibraries();
- for (int j = 0; j < allLibs.length; j++)
- {
- try {
- String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
- allLibs[j],
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_OPTION,
- new OptionContextData(option, tool));
- if(resolved != null && resolved.length > 0){
- for(int k = 0; k < resolved.length; k++){
- String string = resolved[k];
- if(string.length() > 0)
- libs.add(command + string);
- }
- }
- } catch (BuildMacroException e) {
- // TODO: report error
- continue;
- }
-
- }
- }
- }
- } catch (BuildException e) {
- // TODO: report error
- continue;
- }
- }
- }
- return (String[])libs.toArray(new String[libs.size()]);
+ return getDefaultConfiguration().getLibs(extension);
}
private HashMap getMacroPathEntries() {
@@ -575,16 +526,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
*/
public String getOutputExtension(String resourceExtension) {
- String outputExtension = null;
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- outputExtension = tool.getOutputExtension(resourceExtension);
- if (outputExtension != null) {
- return outputExtension;
- }
- }
- return null;
+ return getDefaultConfiguration().getOutputExtension(resourceExtension);
}
/*
@@ -593,39 +535,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputFlag()
*/
public String getOutputFlag(String outputExt) {
- // Treat null extension as an empty string
- String ext = outputExt == null ? new String() : outputExt;
-
- // Get all the tools for the current config
- String flags = new String();
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- // It's OK
- if (tool.producesFileType(ext)) {
- flags = tool.getOutputFlag();
- }
- }
- return flags;
+ return getDefaultConfiguration().getOutputFlag(outputExt);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputPrefix(java.lang.String)
*/
public String getOutputPrefix(String outputExtension) {
- // Treat null extensions as empty string
- String ext = outputExtension == null ? new String() : outputExtension;
-
- // Get all the tools for the current config
- String flags = new String();
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- flags = tool.getOutputPrefix();
- }
- }
- return flags;
+ return getDefaultConfiguration().getOutputPrefix(outputExtension);
}
/**
@@ -698,98 +615,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(sourceExtension)) {
- String cmd = tool.getToolCommand();
- //try to resolve the build macros in the tool command
- try{
- String resolvedCommand = null;
-
- if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$
- (outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$
- {
- resolvedCommand = ManagedBuildManager
- .getBuildMacroProvider().resolveValue(
- cmd,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputLocation,
- outputLocation, null,
- tool));
- }
-
- else {
- resolvedCommand = ManagedBuildManager
- .getBuildMacroProvider()
- .resolveValueToMakefileFormat(
- cmd,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputLocation,
- outputLocation, null,
- tool));
- }
- if((resolvedCommand = resolvedCommand.trim()).length() > 0)
- cmd = resolvedCommand;
-
- } catch (BuildMacroException e){
- }
-
- IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
- return gen.generateCommandLineInfo( tool, cmd,
- flags, outputFlag, outputPrefix, outputName, inputResources,
- tool.getCommandLinePattern() );
- }
- }
- return null;
+ return getDefaultConfiguration().generateToolCommandLineInfo(sourceExtension, flags, outputFlag, outputPrefix, outputName, inputResources, inputLocation, outputLocation);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getUserObjectsForConfiguration(java.lang.String)
*/
public String[] getUserObjectsForConfiguration(String extension) {
- Vector objs = new Vector();
- ITool tool = getDefaultConfiguration().calculateTargetTool();
- if(tool == null)
- tool = getToolFromOutputExtension(extension);
-
- if(tool != null){
- IOption[] opts = tool.getOptions();
- // Look for the user object option type
- for (int i = 0; i < opts.length; i++) {
- IOption option = opts[i];
- try {
- if (option.getValueType() == IOption.OBJECTS) {
- String unresolved[] = option.getUserObjects();
- if(unresolved != null && unresolved.length > 0){
- for(int k = 0; k < unresolved.length; k++){
- try {
- String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
- unresolved[k],
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_OPTION,
- new OptionContextData(option, tool));
- if(resolved != null && resolved.length > 0)
- objs.addAll(Arrays.asList(resolved));
- } catch (BuildMacroException e) {
- // TODO: report error
- continue;
- }
- }
- }
- }
- } catch (BuildException e) {
- // TODO: report error
- continue;
- }
- }
- }
- return (String[])objs.toArray(new String[objs.size()]);
+ return getDefaultConfiguration().getUserObjects(extension);
}
/* (non-Javadoc)
@@ -874,7 +707,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
/* (non-Javadoc)
*
*/
- private void persistDefaultConfiguration() {
+/* private void persistDefaultConfiguration() {
// Persist the default configuration
IProject project = owner.getProject();
try {
@@ -884,7 +717,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Too bad
}
}
-
+*/
/**
* Write the contents of the build model to the persistent store
* specified in the argument.
@@ -892,7 +725,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+/* public void serialize(Document doc, Element element) {
// Write out the managed build project
if(managedProject != null){
@@ -920,7 +753,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// I'm clean now
setDirty(false);
}
-
+*/
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
@@ -931,21 +764,26 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
if (configuration == null) return;
if (!configuration.equals(getDefaultConfiguration())) {
- // Save it
- defaultConfig = configuration;
- defaultConfigId = configuration.getId();
-
- IProject proj = getOwner().getProject();
- IResource cdtbuildFile = proj.findMember(ManagedBuildManager.SETTINGS_FILE_NAME);
- if(cdtbuildFile != null){
- try {
- cdtbuildFile.touch(new NullProgressMonitor());
- } catch (CoreException e) {
- //TODO: log an error
+ IProject project = owner.getProject();
+ ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project);
+ if(des != null){
+ ICConfigurationDescription activeCfgDes = des.getConfigurationById(configuration.getId());
+ if(activeCfgDes == null){
+ try {
+ activeCfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, configuration.getConfigurationData());
+ } catch (WriteAccessException e) {
+ } catch (CoreException e) {
+ }
+ }
+
+ if(activeCfgDes != null){
+ des.setActiveConfiguration(activeCfgDes);
+ try {
+ CoreModel.getDefault().setProjectDescription(project, des);
+ } catch (CoreException e) {
+ }
}
}
- // TODO: is this appropriate?
- persistDefaultConfiguration();
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java
new file mode 100644
index 00000000000..1eb73d43c0b
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java
@@ -0,0 +1,83 @@
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+
+public class ManagedConfigStorageElement implements ICStorageElement {
+ private IManagedConfigElement fElement;
+ private List fChildList;
+ private ManagedConfigStorageElement fParent;
+ public ManagedConfigStorageElement(IManagedConfigElement el){
+ this(el, null);
+ }
+
+ public ManagedConfigStorageElement(IManagedConfigElement el, ManagedConfigStorageElement parent){
+ fElement = el;
+ fParent = parent;
+ }
+
+ public void clear() {
+ throw new WriteAccessException();
+ }
+
+ public ICStorageElement createChild(String name) {
+ throw new WriteAccessException();
+ }
+
+ public String getAttribute(String name) {
+ return fElement.getAttribute(name);
+ }
+
+ public ICStorageElement[] getChildren() {
+ List list = getChildList(true);
+ return (ManagedConfigStorageElement[])list.toArray(new ManagedConfigStorageElement[list.size()]);
+ }
+
+ private List getChildList(boolean create){
+ if(fChildList == null && create){
+ IManagedConfigElement children[] = fElement.getChildren();
+
+ fChildList = new ArrayList(children.length);
+ fChildList.addAll(Arrays.asList(children));
+ }
+ return fChildList;
+ }
+
+ public String getName() {
+ return fElement.getName();
+ }
+
+ public ICStorageElement getParent() {
+ return fParent;
+ }
+
+ public String getValue() {
+ return null;
+ }
+
+ public ICStorageElement importChild(ICStorageElement el)
+ throws UnsupportedOperationException {
+ throw new WriteAccessException();
+ }
+
+ public void removeAttribute(String name) {
+ throw new WriteAccessException();
+ }
+
+ public void removeChild(ICStorageElement el) {
+ throw new WriteAccessException();
+ }
+
+ public void setAttribute(String name, String value) {
+ throw new WriteAccessException();
+ }
+
+ public void setValue(String value) {
+ throw new WriteAccessException();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java
index e16b3c3e0db..e8700c5d70d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -17,14 +17,14 @@ import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICOwner;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Preferences;
/**
* @since 2.0
@@ -47,20 +47,21 @@ public class ManagedMakeProject implements ICOwner {
cproject.remove(CCorePlugin.BUILDER_MODEL_ID);
cproject.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
- updateIndexers(cproject);
+// updateIndexers(cproject);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.ICOwner#update(org.eclipse.cdt.core.ICDescriptor, java.lang.String)
*/
public void update(ICDescriptor cproject, String extensionID) throws CoreException {
- if (extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) {
+/* if (extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) {
updateBinaryParsers(cproject);
}
if (extensionID.equals(CCorePlugin.INDEXER_UNIQ_ID)) {
updateIndexers(cproject);
}
+*/
}
private void updateBinaryParsers(ICDescriptor cDescriptor) throws CoreException {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
index fad07ac2220..b3f36c6fa78 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -11,35 +11,35 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.util.XmlStorageElement;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment;
-import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros;
-import org.eclipse.core.resources.IProject;
+import org.eclipse.cdt.utils.envvar.StorableEnvironment;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-public class ManagedProject extends BuildObject implements IManagedProject {
+public class ManagedProject extends BuildObject implements IManagedProject, IBuildPropertiesRestriction, IBuildPropertyChangeListener {
private static final String EMPTY_STRING = new String();
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
@@ -48,16 +48,19 @@ public class ManagedProject extends BuildObject implements IManagedProject {
private IProjectType projectType;
private String projectTypeId;
private IResource owner;
- private List configList; // Configurations of this project type
+// private List configList; // Configurations of this project type
private Map configMap;
// Miscellaneous
private boolean isDirty = false;
private boolean isValid = true;
private boolean resolved = true;
//holds the user-defined macros
- private StorableMacros userDefinedMacros;
+// private StorableMacros userDefinedMacros;
//holds user-defined environment
private StorableEnvironment userDefinedEnvironment;
+
+ private BuildObjectProperties buildProperties;
+
/*
* C O N S T R U C T O R S
*/
@@ -96,6 +99,24 @@ public class ManagedProject extends BuildObject implements IManagedProject {
setDirty(true);
}
+ public ManagedProject(ICProjectDescription des) {
+ // Make the owner of the ProjectType the project resource
+ this(des.getProject());
+
+ // Copy the parent's identity
+// this.projectType = projectType;
+ int id = ManagedBuildManager.getRandomNumber();
+ setId(owner.getName() + "." + des.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
+ setName(des.getName());
+
+// setManagedBuildRevision(projectType.getManagedBuildRevision());
+
+ // Hook me up
+// IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
+// buildInfo.setManagedProject(this);
+// setDirty(true);
+ }
+
/**
* Create the project instance from project file.
*
@@ -122,11 +143,13 @@ public class ManagedProject extends BuildObject implements IManagedProject {
for (int i = 0; i < configElements.getLength(); ++i) {
Node configElement = configElements.item(i);
if (configElement.getNodeName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
- Configuration config = new Configuration(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
+ ICStorageElement el = new XmlStorageElement((Element)configElement);
+ Configuration config = new Configuration(this, el, managedBuildRevision, false);
+ }/*else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
//load user-defined macros
- userDefinedMacros = new StorableMacros((Element)configElement);
- }
+ ICStorageElement el = new XmlStorageElement((Element)configElement);
+ userDefinedMacros = new StorableMacros(el);
+ }*/
}
} else {
@@ -165,13 +188,18 @@ public class ManagedProject extends BuildObject implements IManagedProject {
return false;
}
}
+
+ String props = element.getAttribute(BUILD_PROPERTIES);
+ if(props != null && props.length() != 0)
+ buildProperties = new BuildObjectProperties(props, this, this);
+
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedProject#serialize()
*/
- public void serialize(Document doc, Element element) {
+/* public void serialize(Document doc, Element element) {
element.setAttribute(IBuildObject.ID, id);
if (name != null) {
@@ -206,7 +234,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
// I am clean now
isDirty = false;
}
-
+*/
/*
* P A R E N T A N D C H I L D H A N D L I N G
*/
@@ -239,7 +267,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public IConfiguration createConfiguration(IConfiguration parent, String id) {
- Configuration config = new Configuration(this, (Configuration)parent, id, false, false);
+ Configuration config = new Configuration(this, (Configuration)parent, id, false, false, false);
ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
return (IConfiguration)config;
}
@@ -248,7 +276,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfigurationClone(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public IConfiguration createConfigurationClone(IConfiguration parent, String id) {
- Configuration config = new Configuration(this, (Configuration)parent, id, true, false);
+ Configuration config = new Configuration(this, (Configuration)parent, id, true, false, false);
// Inform all options in the configuration and all its resource configurations
ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
return (IConfiguration)config;
@@ -265,8 +293,8 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* @see org.eclipse.cdt.managedbuilder.core.IManagedProject#getConfigurations()
*/
public IConfiguration[] getConfigurations() {
- IConfiguration[] configs = new IConfiguration[getConfigurationList().size()];
- Iterator iter = getConfigurationList().listIterator();
+ IConfiguration[] configs = new IConfiguration[getConfigurationCollection().size()];
+ Iterator iter = getConfigurationCollection().iterator();
int i = 0;
while (iter.hasNext()) {
Configuration config = (Configuration)iter.next();
@@ -285,58 +313,60 @@ public class ManagedProject extends BuildObject implements IManagedProject {
if(getConfigurationMap().get(id) == null)
return;
- IWorkspaceRunnable remover = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- // Remove the specified configuration from the list and map
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfiguration config = (IConfiguration)iter.next();
- if (config.getId().equals(removeId)) {
- // TODO: For now we clean the entire project. This may be overkill, but
- // it avoids a problem with leaving the configuration output directory
- // around and having the outputs try to be used by the makefile generator code.
- IResource proj = config.getOwner();
- IManagedBuildInfo info = null;
- if (proj instanceof IProject) {
- info = ManagedBuildManager.getBuildInfo(proj);
- }
- IConfiguration currentConfig = null;
- boolean isCurrent = true;
- if (info != null) {
- currentConfig = info.getDefaultConfiguration();
- if (!currentConfig.getId().equals(removeId)) {
- info.setDefaultConfiguration(config);
- isCurrent = false;
- }
- }
- ((IProject)proj).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
-
- ManagedBuildManager.performValueHandlerEvent(config,
- IManagedOptionValueHandler.EVENT_CLOSE);
- PropertyManager.getInstance().clearProperties(config);
- getConfigurationList().remove(config);
- getConfigurationMap().remove(removeId);
-
- if (info != null) {
- if (!isCurrent) {
- info.setDefaultConfiguration(currentConfig);
- } else {
- // If the current default config is the one being removed, reset the default config
- String[] configs = info.getConfigurationNames();
- if (configs.length > 0) {
- info.setDefaultConfiguration(configs[0]);
- }
- }
- }
- break;
- }
- }
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run( remover, null );
- }
- catch( CoreException e ) {}
+ getConfigurationMap().remove(removeId);
+//
+// IWorkspaceRunnable remover = new IWorkspaceRunnable() {
+// public void run(IProgressMonitor monitor) throws CoreException {
+// // Remove the specified configuration from the list and map
+// Iterator iter = getConfigurationCollection().iterator();
+// while (iter.hasNext()) {
+// IConfiguration config = (IConfiguration)iter.next();
+// if (config.getId().equals(removeId)) {
+// // TODO: For now we clean the entire project. This may be overkill, but
+// // it avoids a problem with leaving the configuration output directory
+// // around and having the outputs try to be used by the makefile generator code.
+// IResource proj = config.getOwner();
+// IManagedBuildInfo info = null;
+// if (proj instanceof IProject) {
+// info = ManagedBuildManager.getBuildInfo(proj);
+// }
+// IConfiguration currentConfig = null;
+// boolean isCurrent = true;
+// if (info != null) {
+// currentConfig = info.getDefaultConfiguration();
+// if (!currentConfig.getId().equals(removeId)) {
+// info.setDefaultConfiguration(config);
+// isCurrent = false;
+// }
+// }
+// ((IProject)proj).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
+//
+// ManagedBuildManager.performValueHandlerEvent(config,
+// IManagedOptionValueHandler.EVENT_CLOSE);
+// PropertyManager.getInstance().clearProperties(config);
+//// getConfigurationList().remove(config);
+// getConfigurationMap().remove(removeId);
+//
+// if (info != null) {
+// if (!isCurrent) {
+// info.setDefaultConfiguration(currentConfig);
+// } else {
+// // If the current default config is the one being removed, reset the default config
+// String[] configs = info.getConfigurationNames();
+// if (configs.length > 0) {
+// info.setDefaultConfiguration(configs[0]);
+// }
+// }
+// }
+// break;
+// }
+// }
+// }
+// };
+// try {
+// ResourcesPlugin.getWorkspace().run( remover, null );
+// }
+// catch( CoreException e ) {}
setDirty(true);
}
@@ -347,7 +377,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
*/
public void addConfiguration(Configuration configuration) {
if(!configuration.isTemporary()){
- getConfigurationList().add(configuration);
+// getConfigurationList().add(configuration);
getConfigurationMap().put(configuration.getId(), configuration);
}
}
@@ -357,11 +387,12 @@ public class ManagedProject extends BuildObject implements IManagedProject {
*
* @return List containing the configurations
*/
- private List getConfigurationList() {
- if (configList == null) {
- configList = new ArrayList();
- }
- return configList;
+ private Collection getConfigurationCollection() {
+ return getConfigurationMap().values();
+// if (configList == null) {
+// configList = new ArrayList();
+// }
+// return configList;
}
/* (non-Javadoc)
@@ -412,7 +443,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
}
// call resolve references on any children
- Iterator configIter = getConfigurationList().iterator();
+ Iterator configIter = getConfigurationCollection().iterator();
while (configIter.hasNext()) {
Configuration current = (Configuration)configIter.next();
current.resolveReferences();
@@ -429,8 +460,8 @@ public class ManagedProject extends BuildObject implements IManagedProject {
if (isDirty) return true;
//check whether the project - specific macros are dirty
- if(userDefinedMacros != null && userDefinedMacros.isDirty())
- return true;
+// if(userDefinedMacros != null && userDefinedMacros.isDirty())
+// return true;
//check whether the project - specific environment is dirty
if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
@@ -438,7 +469,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
// Otherwise see if any configurations need saving
- Iterator iter = getConfigurationList().listIterator();
+ Iterator iter = getConfigurationCollection().iterator();
while (iter.hasNext()) {
Configuration current = (Configuration) iter.next();
if (current.isDirty()) return true;
@@ -454,7 +485,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
this.isDirty = isDirty;
// Propagate "false" to the children
if (!isDirty) {
- Iterator iter = getConfigurationList().listIterator();
+ Iterator iter = getConfigurationCollection().iterator();
while (iter.hasNext()) {
Configuration current = (Configuration) iter.next();
current.setDirty(false);
@@ -498,12 +529,12 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* this method is called by the UserDefinedMacroSupplier to obtain user-defined
* macros available for this managed project
*/
- public StorableMacros getUserDefinedMacros(){
+/* public StorableMacros getUserDefinedMacros(){
if(userDefinedMacros == null)
userDefinedMacros = new StorableMacros();
return userDefinedMacros;
}
-
+*/
public StorableEnvironment getUserDefinedEnvironmet(){
return userDefinedEnvironment;
}
@@ -517,7 +548,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
*/
public void updateManagedBuildRevision(String revision){
super.updateManagedBuildRevision(revision);
- for(Iterator iter = getConfigurationList().iterator(); iter.hasNext();){
+ for(Iterator iter = getConfigurationCollection().iterator(); iter.hasNext();){
Configuration cfg = (Configuration)iter.next();
cfg.updateManagedBuildRevision(revision);
}
@@ -533,4 +564,99 @@ public class ManagedProject extends BuildObject implements IManagedProject {
}
}
}
+
+ public void applyConfiguration(Configuration cfg){
+ cfg.applyToManagedProject(this);
+ }
+
+ public IBuildObjectProperties getBuildProperties() {
+ if(buildProperties == null){
+ BuildObjectProperties parentProps = findBuildProperties();
+ if(parentProps != null)
+ buildProperties = new BuildObjectProperties(parentProps, this, this);
+ else
+ buildProperties = new BuildObjectProperties(this, this);
+ }
+ return buildProperties;
+ }
+
+ private BuildObjectProperties findBuildProperties(){
+ if(buildProperties == null){
+ if(projectType != null){
+ return ((ProjectType)projectType).findBuildProperties();
+ }
+ return null;
+ }
+ return buildProperties;
+ }
+
+ public void propertiesChanged() {
+ IConfiguration cfgs[] = getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ ((Configuration)cfgs[i]).propertiesChanged();
+ }
+ }
+
+ public boolean supportsType(IBuildPropertyType type) {
+ return supportsType(type.getId());
+ }
+
+ public boolean supportsValue(IBuildPropertyType type,
+ IBuildPropertyValue value) {
+ return supportsValue(type.getId(), value.getId());
+ }
+
+ public boolean supportsType(String typeId) {
+ IConfiguration cfgs[] = getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ if(((Configuration)cfgs[i]).supportsType(typeId))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean supportsValue(String typeId, String valueId) {
+ IConfiguration cfgs[] = getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ if(((Configuration)cfgs[i]).supportsValue(typeId, valueId))
+ return true;
+ }
+ return false;
+ }
+
+ public String[] getRequiredTypeIds() {
+ List result = new ArrayList();
+ IConfiguration cfgs[] = getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ result.addAll(Arrays.asList(((Configuration)cfgs[i]).getRequiredTypeIds()));
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public String[] getSupportedTypeIds() {
+ List result = new ArrayList();
+ IConfiguration cfgs[] = getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ result.addAll(Arrays.asList(((Configuration)cfgs[i]).getSupportedTypeIds()));
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ List result = new ArrayList();
+ IConfiguration cfgs[] = getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ result.addAll(Arrays.asList(((Configuration)cfgs[i]).getSupportedValueIds(typeId)));
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public boolean requiresType(String typeId) {
+ IConfiguration cfgs[] = getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ if(((Configuration)cfgs[i]).requiresType(typeId))
+ return true;
+ }
+ return false;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java
new file mode 100644
index 00000000000..0558d319366
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java
@@ -0,0 +1,273 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+
+public class MapStorageElement implements ICStorageElement {
+ private HashMap fMap;
+ private String fName;
+ private MapStorageElement fParent;
+ private static final String CHILDREN_KEY = "?children?";
+ private static final String NAME_KEY = "?name?";
+ private static final String VALUE_KEY = "?value?";
+ private List fChildren = new ArrayList();
+ private String fValue;
+
+ public MapStorageElement(String name, MapStorageElement parent){
+ fName = name;
+ fParent = parent;
+ fMap = new HashMap();
+ }
+
+ public MapStorageElement(Map map, MapStorageElement parent){
+ fName = (String)map.get(getMapKey(NAME_KEY));
+ fValue = (String)map.get(getMapKey(VALUE_KEY));
+ fMap = new HashMap(map);
+ fParent = parent;
+
+ String children = (String)map.get(getMapKey(CHILDREN_KEY));
+ if(children != null){
+ List childrenStrList = decodeList(children);
+ int size = childrenStrList.size();
+ if(size != 0){
+ for(int i = 0; i < size; i++){
+ Map childMap = decodeMap((String)childrenStrList.get(i));
+ MapStorageElement child = createChildElement(childMap);
+ fChildren.add(child);
+ }
+ }
+ }
+ }
+
+ protected MapStorageElement createChildElement(Map childMap){
+ return new MapStorageElement(childMap, this);
+ }
+
+ protected String getMapKey(String name){
+ return name;
+ }
+
+ public Map toStringMap(){
+ Map map = (Map)fMap.clone();
+ if(fName != null)
+ map.put(getMapKey(NAME_KEY), fName);
+ else
+ map.remove(getMapKey(NAME_KEY));
+
+ if(fValue != null)
+ map.put(getMapKey(VALUE_KEY), fValue);
+ else
+ map.remove(getMapKey(VALUE_KEY));
+
+ int size = fChildren.size();
+ if(size != 0){
+ List childrenStrList = new ArrayList(size);
+ for(int i = 0; i < size; i++){
+ MapStorageElement child = (MapStorageElement)fChildren.get(i);
+ Map childStrMap = child.toStringMap();
+ String str = encodeMap(childStrMap);
+ childrenStrList.add(str);
+ }
+
+ String childrenStr = encodeList(childrenStrList);
+ map.put(getMapKey(CHILDREN_KEY), childrenStr);
+ } else {
+ map.remove(getMapKey(CHILDREN_KEY));
+ }
+
+ return map;
+ }
+
+ public void clear() {
+ fMap.clear();
+ }
+
+ public ICStorageElement createChild(String name) {
+ MapStorageElement child = createChildElement(name);
+ fChildren.add(child);
+ return child;
+ }
+
+ protected MapStorageElement createChildElement(String name){
+ return new MapStorageElement(name, this);
+ }
+
+ public String getAttribute(String name) {
+ Object o = fMap.get(getMapKey(name));
+ if(o instanceof String)
+ return (String)o;
+ return null;
+ }
+
+ public ICStorageElement[] getChildren() {
+ return (MapStorageElement[])fChildren.toArray(new MapStorageElement[fChildren.size()]);
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public ICStorageElement getParent() {
+ return fParent;
+ }
+
+ public void removeChild(ICStorageElement child){
+ fChildren.remove(child);
+ if(child instanceof MapStorageElement){
+ ((MapStorageElement)child).removed();
+ }
+ }
+
+ private void removed() {
+ fParent = null;
+ }
+
+ public void removeAttribute(String name) {
+ fMap.remove(getMapKey(name));
+ }
+
+ public void setAttribute(String name, String value) {
+ fMap.put(getMapKey(name), value);
+ }
+
+ public static Map decodeMap(String value) {
+ List list = decodeList(value);
+ Map map = new HashMap();
+ char escapeChar = '\\';
+
+ for(int i = 0; i < list.size(); i++){
+ StringBuffer line = new StringBuffer((String)list.get(i));
+ int lndx = 0;
+ while (lndx < line.length()) {
+ if (line.charAt(lndx) == '=') {
+ if (line.charAt(lndx - 1) == escapeChar) {
+ // escaped '=' - remove '\' and continue on.
+ line.deleteCharAt(lndx - 1);
+ } else {
+ break;
+ }
+ }
+ lndx++;
+ }
+ map.put(line.substring(0, lndx), line.substring(lndx + 1));
+ }
+
+ return map;
+
+ }
+
+ public static List decodeList(String value) {
+ List list = new ArrayList();
+ if (value != null) {
+ StringBuffer envStr = new StringBuffer(value);
+ String escapeChars = "|\\"; //$NON-NLS-1$
+ char escapeChar = '\\';
+ try {
+ while (envStr.length() > 0) {
+ int ndx = 0;
+ while (ndx < envStr.length()) {
+ if (escapeChars.indexOf(envStr.charAt(ndx)) != -1) {
+ if (envStr.charAt(ndx - 1) == escapeChar) {
+ // escaped '|' - remove '\' and continue on.
+ envStr.deleteCharAt(ndx - 1);
+ if (ndx == envStr.length()) {
+ break;
+ }
+ }
+ if (envStr.charAt(ndx) == '|')
+ break;
+ }
+ ndx++;
+ }
+ StringBuffer line = new StringBuffer(envStr.substring(0, ndx));
+/* int lndx = 0;
+ while (lndx < line.length()) {
+ if (line.charAt(lndx) == '=') {
+ if (line.charAt(lndx - 1) == escapeChar) {
+ // escaped '=' - remove '\' and continue on.
+ line.deleteCharAt(lndx - 1);
+ } else {
+ break;
+ }
+ }
+ lndx++;
+ }
+*/
+ list.add(line.toString());
+ envStr.delete(0, ndx + 1);
+ }
+ } catch (StringIndexOutOfBoundsException e) {
+ }
+ }
+ return list;
+ }
+
+ public static String encodeMap(Map values) {
+ List list = new ArrayList();
+ Iterator entries = values.entrySet().iterator();
+ StringBuffer str = new StringBuffer();
+ while (entries.hasNext()) {
+ Entry entry = (Entry)entries.next();
+ str.append(escapeChars((String)entry.getKey(), "=|\\", '\\')); //$NON-NLS-1$
+ str.append("="); //$NON-NLS-1$
+ str.append(escapeChars((String)entry.getValue(), "|\\", '\\')); //$NON-NLS-1$
+ list.add(str.toString());
+ str.delete(0, str.length());
+ }
+ return encodeList(list);
+ }
+
+ public static String encodeList(List values) {
+ StringBuffer str = new StringBuffer();
+ Iterator entries = values.iterator();
+ while (entries.hasNext()) {
+ String entry = (String)entries.next();
+ str.append(escapeChars(entry, "|\\", '\\')); //$NON-NLS-1$
+// str.append("="); //$NON-NLS-1$
+// str.append(escapeChars((String)entry.getValue(), "|\\", '\\')); //$NON-NLS-1$
+ str.append("|"); //$NON-NLS-1$
+ }
+ return str.toString();
+ }
+
+ public static String escapeChars(String string, String escapeChars, char escapeChar) {
+ StringBuffer str = new StringBuffer(string);
+ for (int i = 0; i < str.length(); i++) {
+ if (escapeChars.indexOf(str.charAt(i)) != -1) {
+ str.insert(i, escapeChar);
+ i++;
+ }
+ }
+ return str.toString();
+ }
+
+ public String getValue() {
+ return fValue;
+ }
+
+ public void setValue(String value) {
+ fValue = value;
+ }
+
+ public ICStorageElement importChild(ICStorageElement el)
+ throws UnsupportedOperationException {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ModificationStatus.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ModificationStatus.java
new file mode 100644
index 00000000000..cc72098d353
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ModificationStatus.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class ModificationStatus extends Status implements IModificationStatus {
+ private HashMap fUnsupportedProperties = new HashMap();
+ private HashMap fUnsupportedRequiredProperties = new HashMap();
+ private HashSet fUndefinedProperties = new HashSet();
+ private ITool[][] fToolConflicts;
+ private ITool[] fNonManagedBuildTools;
+
+ ModificationStatus(Map unsupportedRequiredProps,
+ Map unsupportedProps,
+ Set undefinedProps,
+ ITool[][] conflicts,
+ ITool nonMbsTools[]){
+ super(IStatus.OK, ManagedBuilderCorePlugin.getUniqueIdentifier(), "");
+
+ int severity = IStatus.OK;
+ int flags = 0;
+ if(unsupportedRequiredProps != null && unsupportedRequiredProps.size() != 0){
+ fUnsupportedRequiredProperties.putAll(unsupportedRequiredProps);
+ fUnsupportedProperties.putAll(unsupportedRequiredProps);
+ flags |= REQUIRED_PROPS_NOT_SUPPORTED | PROPS_NOT_DEFINED;
+ severity = IStatus.ERROR;
+ }
+
+ if(unsupportedProps != null && unsupportedProps.size() != 0){
+ fUnsupportedProperties.putAll(unsupportedProps);
+ flags |= PROPS_NOT_SUPPORTED;
+ if(severity == IStatus.OK)
+ severity = IStatus.WARNING;
+ }
+
+ if(undefinedProps != null && undefinedProps.size() != 0){
+ fUndefinedProperties.addAll(undefinedProps);
+ flags |= PROPS_NOT_DEFINED;
+ if(severity == IStatus.OK)
+ severity = IStatus.WARNING;
+ }
+
+ if(conflicts != null && conflicts.length != 0){
+ fToolConflicts = new ITool[conflicts.length][];
+ for(int i = 0; i < conflicts.length; i++){
+ fToolConflicts[i] = (ITool[])conflicts[i].clone();
+ }
+ flags |= TOOLS_CONFLICT;
+ if(severity == IStatus.OK)
+ severity = IStatus.WARNING;
+ } else {
+ fToolConflicts = new ITool[0][];
+ }
+
+ if(nonMbsTools != null && nonMbsTools.length != 0){
+ fNonManagedBuildTools = (ITool[])nonMbsTools.clone();;
+ flags |= TOOLS_DONT_SUPPORT_MANAGED_BUILD;
+ severity = IStatus.ERROR;
+ } else {
+ fNonManagedBuildTools = new ITool[0];
+ }
+
+ if(flags != 0){
+ setCode(flags);
+ }
+
+ if(severity != IStatus.OK){
+ setSeverity(severity);
+ }
+
+ }
+
+ public Map getUnsupportedProperties(){
+ return (HashMap)fUnsupportedProperties.clone();
+ }
+
+ public Map getUnsupportedRequiredProperties(){
+ return (HashMap)fUnsupportedRequiredProperties.clone();
+ }
+
+ public Set getUndefinedProperties(){
+ return (HashSet)fUndefinedProperties.clone();
+ }
+
+ public ITool[][] getToolsConflicts(){
+ ITool[][] copy = new ITool[fToolConflicts.length][];
+ for(int i = 0; i < fToolConflicts.length; i++){
+ copy[i] = (ITool[])fToolConflicts[i].clone();
+ }
+ return copy;
+ }
+
+ public ITool[] getNonManagedBuildTools(){
+ return (ITool[])fNonManagedBuildTools.clone();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/NotificationManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/NotificationManager.java
new file mode 100644
index 00000000000..e9de8b2d062
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/NotificationManager.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+
+public class NotificationManager /*implements ISettingsChangeListener */{
+ private static NotificationManager fInstance;
+ private List fListeners;
+
+ private NotificationManager(){
+ fListeners = new ArrayList();
+ }
+
+ public static NotificationManager getInstance(){
+ if(fInstance == null)
+ fInstance = new NotificationManager();
+ return fInstance;
+ }
+
+ public void optionChanged(IResourceInfo rcInfo, IHoldsOptions holder, IOption option, Object oldValue) {
+ for(Iterator iter = fListeners.iterator(); iter.hasNext();){
+ ISettingsChangeListener listener = (ISettingsChangeListener)iter.next();
+ listener.optionChanged(rcInfo, holder, option, oldValue);
+ }
+ }
+
+ public void subscribe(ISettingsChangeListener listener){
+// synchronized (this) {
+ fListeners.add(listener);
+// }
+ }
+
+ public void unsubscribe(ISettingsChangeListener listener){
+// synchronized (this) {
+ fListeners.remove(listener);
+// }
+ }
+
+
+
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
index 8dff3980578..b00f3d56827 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -20,8 +20,10 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
@@ -37,12 +39,8 @@ import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpres
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-public class Option extends BuildObject implements IOption {
+public class Option extends BuildObject implements IOption, IBuildPropertiesRestriction {
// Static default return values
private static final String EMPTY_STRING = new String();
private static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -149,7 +147,7 @@ public class Option extends BuildObject implements IOption {
* @param parent The <code>IHoldsOptions</code> the option will be added to.
* @param element The XML element that contains the option settings.
*/
- public Option(IHoldsOptions parent, Element element) {
+ public Option(IHoldsOptions parent, ICStorageElement element) {
this.holder = parent;
isExtensionOption = false;
@@ -174,6 +172,7 @@ public class Option extends BuildObject implements IOption {
setId(Id);
setName(name);
isExtensionOption = false;
+ boolean copyIds = Id.equals(option.id);
// Copy the remaining attributes
if (option.unusedChildren != null) {
@@ -239,6 +238,10 @@ public class Option extends BuildObject implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
if (option.value != null) {
value = new ArrayList((ArrayList)option.value);
}
@@ -266,7 +269,10 @@ public class Option extends BuildObject implements IOption {
valueHandlerExtraArgument = new String(option.valueHandlerExtraArgument);
}
- if(!isExtensionElement()){
+ if(copyIds){
+ isDirty = option.isDirty;
+ rebuildState = option.rebuildState;
+ } else {
setDirty(true);
setRebuildState(true);
}
@@ -385,13 +391,13 @@ public class Option extends BuildObject implements IOption {
*
* @param element An XML element containing the option information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@@ -405,12 +411,12 @@ public class Option extends BuildObject implements IOption {
}
// Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) {
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
}
// isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ if (element.getAttribute(IProjectType.IS_ABSTRACT) != null) {
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
if (isAbs != null){
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
@@ -418,22 +424,22 @@ public class Option extends BuildObject implements IOption {
}
// Get the command defined for the option
- if (element.hasAttribute(COMMAND)) {
+ if (element.getAttribute(COMMAND) != null) {
command = element.getAttribute(COMMAND);
}
// Get the command defined for a Boolean option when the value is False
- if (element.hasAttribute(COMMAND_FALSE)) {
+ if (element.getAttribute(COMMAND_FALSE) != null) {
commandFalse = element.getAttribute(COMMAND_FALSE);
}
// Get the tooltip for the option
- if (element.hasAttribute(TOOL_TIP)) {
+ if (element.getAttribute(TOOL_TIP) != null) {
tip = element.getAttribute(TOOL_TIP);
}
// Options hold different types of values
- if (element.hasAttribute(VALUE_TYPE)) {
+ if (element.getAttribute(VALUE_TYPE) != null) {
String valueTypeStr = element.getAttribute(VALUE_TYPE);
valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
}
@@ -444,37 +450,37 @@ public class Option extends BuildObject implements IOption {
switch (valType) {
case BOOLEAN:
// Convert the string to a boolean
- if (element.hasAttribute(VALUE)) {
+ if (element.getAttribute(VALUE) != null) {
value = new Boolean(element.getAttribute(VALUE));
}
- if (element.hasAttribute(DEFAULT_VALUE)) {
+ if (element.getAttribute(DEFAULT_VALUE) != null) {
defaultValue = new Boolean(element.getAttribute(DEFAULT_VALUE));
}
break;
case STRING:
// Just get the value out of the option directly
- if (element.hasAttribute(VALUE)) {
+ if (element.getAttribute(VALUE) != null) {
value = element.getAttribute(VALUE);
}
- if (element.hasAttribute(DEFAULT_VALUE)) {
+ if (element.getAttribute(DEFAULT_VALUE) != null) {
defaultValue = element.getAttribute(DEFAULT_VALUE);
}
break;
case ENUMERATED:
- if (element.hasAttribute(VALUE)) {
+ if (element.getAttribute(VALUE) != null) {
value = element.getAttribute(VALUE);
}
- if (element.hasAttribute(DEFAULT_VALUE)) {
+ if (element.getAttribute(DEFAULT_VALUE) != null) {
defaultValue = element.getAttribute(DEFAULT_VALUE);
}
// Do we have enumeratedOptionValue children? If so, load them
// to define the valid values and the default value.
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configNode = configElements.item(i);
- if (configNode.getNodeName().equals(ENUM_VALUE)) {
- Element configElement = (Element)configNode;
+ ICStorageElement configElements[] = element.getChildren();
+ for (int i = 0; i < configElements.length; ++i) {
+ ICStorageElement configNode = configElements[i];
+ if (configNode.getName().equals(ENUM_VALUE)) {
+ ICStorageElement configElement = configNode;
String optId = configElement.getAttribute(ID);
if (i == 0) {
enumList = new ArrayList();
@@ -483,13 +489,13 @@ public class Option extends BuildObject implements IOption {
}
}
enumList.add(optId);
- if (configElement.hasAttribute(COMMAND)) {
+ if (configElement.getAttribute(COMMAND) != null) {
getEnumCommandMap().put(optId, configElement.getAttribute(COMMAND));
} else {
getEnumCommandMap().put(optId, EMPTY_STRING);
}
getEnumNameMap().put(optId, configElement.getAttribute(NAME));
- if (configElement.hasAttribute(IS_DEFAULT)) {
+ if (configElement.getAttribute(IS_DEFAULT) != null) {
Boolean isDefault = new Boolean(configElement.getAttribute(IS_DEFAULT));
if (isDefault.booleanValue()) {
defaultValue = optId;
@@ -503,21 +509,25 @@ public class Option extends BuildObject implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
// Note: These string-list options do not load either the "value" or
// "defaultValue" attributes. Instead, the ListOptionValue children
// are loaded in the value field.
List valueList = null;
- configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
+ configElements = element.getChildren();
+ for (int i = 0; i < configElements.length; ++i) {
if (i == 0) {
valueList = new ArrayList();
builtIns = new ArrayList();
}
- Node configNode = configElements.item(i);
- if (configNode.getNodeName().equals(LIST_VALUE)) {
- Element valueElement = (Element)configNode;
+ ICStorageElement configNode = configElements[i];
+ if (configNode.getName().equals(LIST_VALUE)) {
+ ICStorageElement valueElement = configNode;
Boolean isBuiltIn;
- if (valueElement.hasAttribute(IS_DEFAULT)) {
+ if (valueElement.getAttribute(IS_DEFAULT) != null) {
isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
} else {
isBuiltIn = new Boolean(false);
@@ -540,7 +550,7 @@ public class Option extends BuildObject implements IOption {
}
// Determine if there needs to be a browse button
- if (element.hasAttribute(BROWSE_TYPE)) {
+ if (element.getAttribute(BROWSE_TYPE) != null) {
String browseTypeStr = element.getAttribute(BROWSE_TYPE);
if (browseTypeStr == null) {
@@ -558,7 +568,7 @@ public class Option extends BuildObject implements IOption {
}
}
- if (element.hasAttribute(CATEGORY)) {
+ if (element.getAttribute(CATEGORY) != null) {
categoryId = element.getAttribute(CATEGORY);
if (categoryId != null) {
category = holder.getOptionCategory(categoryId);
@@ -566,7 +576,7 @@ public class Option extends BuildObject implements IOption {
}
// Get the resourceFilter attribute
- if (element.hasAttribute(RESOURCE_FILTER)) {
+ if (element.getAttribute(RESOURCE_FILTER) != null) {
String resFilterStr = element.getAttribute(RESOURCE_FILTER);
if (resFilterStr == null) {
// Set to null, to indicate no resource filter specification
@@ -587,7 +597,7 @@ public class Option extends BuildObject implements IOption {
// as they are not saved. See note in serialize().
// valueHandlerExtraArgument
- if (element.hasAttribute(VALUE_HANDLER_EXTRA_ARGUMENT)) {
+ if (element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT) != null) {
valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
}
}
@@ -610,6 +620,14 @@ public class Option extends BuildObject implements IOption {
return OBJECTS;
else if (valueTypeStr.equals(TYPE_DEFINED_SYMBOLS))
return PREPROCESSOR_SYMBOLS;
+ else if (valueTypeStr.equals(TYPE_LIB_PATHS))
+ return LIBRARY_PATHS;
+ else if (valueTypeStr.equals(TYPE_LIB_FILES))
+ return LIBRARY_FILES;
+ else if (valueTypeStr.equals(TYPE_INC_FILES))
+ return INCLUDE_FILES;
+ else if (valueTypeStr.equals(TYPE_SYMBOL_FILES))
+ return MACRO_FILES;
else {
// TODO: This was the CDT 2.0 default - should we keep it?
return PREPROCESSOR_SYMBOLS;
@@ -622,7 +640,7 @@ public class Option extends BuildObject implements IOption {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) throws BuildException {
+ public void serialize(ICStorageElement element) throws BuildException {
if (superClass != null)
element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
@@ -675,24 +693,26 @@ public class Option extends BuildObject implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
if (value != null) {
ArrayList stringList = (ArrayList)value;
ListIterator iter = stringList.listIterator();
while (iter.hasNext()) {
- Element valueElement = doc.createElement(LIST_VALUE);
+ ICStorageElement valueElement = element.createChild(LIST_VALUE);
valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
valueElement.setAttribute(LIST_ITEM_BUILTIN, "false"); //$NON-NLS-1$
- element.appendChild(valueElement);
}
}
// Serialize the built-ins that have been overridden
if (builtIns != null) {
ListIterator iter = builtIns.listIterator();
while (iter.hasNext()) {
- Element valueElement = doc.createElement(LIST_VALUE);
+ ICStorageElement valueElement = element.createChild(LIST_VALUE);
valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
valueElement.setAttribute(LIST_ITEM_BUILTIN, "true"); //$NON-NLS-1$
- element.appendChild(valueElement);
}
}
break;
@@ -742,6 +762,18 @@ public class Option extends BuildObject implements IOption {
case PREPROCESSOR_SYMBOLS:
str = TYPE_DEFINED_SYMBOLS;
break;
+ case INCLUDE_FILES:
+ str = TYPE_INC_FILES;
+ break;
+ case LIBRARY_PATHS:
+ str = TYPE_LIB_PATHS;
+ break;
+ case LIBRARY_FILES:
+ str = TYPE_LIB_FILES;
+ break;
+ case MACRO_FILES:
+ str = TYPE_SYMBOL_FILES;
+ break;
default:
// TODO; is this a problem...
str = EMPTY_STRING;
@@ -1299,6 +1331,10 @@ public class Option extends BuildObject implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
val = new ArrayList();
break;
default:
@@ -1475,7 +1511,12 @@ public class Option extends BuildObject implements IOption {
|| getValueType() == INCLUDE_PATH
|| getValueType() == PREPROCESSOR_SYMBOLS
|| getValueType() == LIBRARIES
- || getValueType() == OBJECTS)) {
+ || getValueType() == OBJECTS
+ || getValueType() == INCLUDE_FILES
+ || getValueType() == LIBRARY_PATHS
+ || getValueType() == LIBRARY_FILES
+ || getValueType() == MACRO_FILES
+ )) {
// Just replace what the option reference is holding onto
if(value == null)
this.value = null;
@@ -1728,6 +1769,10 @@ public class Option extends BuildObject implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
// Note: These string-list options do not load either the "value" or
// "defaultValue" attributes. Instead, the ListOptionValue children
// are loaded in the value field.
@@ -1870,7 +1915,12 @@ public class Option extends BuildObject implements IOption {
// Do nothing
}
- public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
+ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(boolean isExtensionAdjustment){
+ if(booleanExpressionCalculator == null && !isExtensionAdjustment){
+ if(superClass != null){
+ return ((Option)superClass).getBooleanExpressionCalculator(isExtensionAdjustment);
+ }
+ }
return booleanExpressionCalculator;
}
@@ -1906,4 +1956,102 @@ public class Option extends BuildObject implements IOption {
rebuildState = rebuild;
}
+
+ public boolean matches(IOption option){
+ try {
+ if(option.getValueType() != getValueType())
+ return false;
+
+ if(!option.getName().equals(getName()))
+ return false;
+ } catch (BuildException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public String[] getRequiredTypeIds() {
+ return new String[0];
+ }
+
+ public String[] getSupportedTypeIds() {
+ String referenced[] = null;
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator(false);
+
+ if(calc != null){
+ referenced = calc.getReferencedPropertyIds();
+ }
+
+ if(referenced == null)
+ referenced = new String[0];
+ return referenced;
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ String referenced[] = null;
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator(false);
+
+ if(calc != null){
+ referenced = calc.getReferencedValueIds(typeId);
+ }
+
+ if(referenced == null)
+ referenced = new String[0];
+ return referenced;
+ }
+
+ public boolean requiresType(String typeId) {
+ return false;
+ }
+
+ public boolean supportsType(String id) {
+ boolean supports = false;
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator(false);
+
+ if(calc != null){
+ if(calc.referesProperty(id)){
+ supports = true;
+ }
+ }
+ return supports;
+ }
+
+ public boolean supportsValue(String typeId, String valueId) {
+ boolean supports = false;
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator(false);
+
+ if(calc != null){
+ if(calc.referesPropertyValue(typeId, valueId)){
+ supports = true;
+ }
+ }
+ return supports;
+ }
+
+ public String[] getBasicStringListValue() throws BuildException {
+ if (getBasicValueType() != STRING_LIST) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ }
+
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+
+ public int getBasicValueType() throws BuildException {
+ switch(getValueType()){
+ case IOption.BOOLEAN:
+ return IOption.BOOLEAN;
+ case IOption.STRING:
+ return IOption.STRING;
+ case IOption.ENUMERATED:
+ return IOption.ENUMERATED;
+ default:
+ return IOption.STRING_LIST;
+ }
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java
index 3e48336580c..a57b548648f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -15,6 +15,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
@@ -22,13 +23,12 @@ import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
/**
*
@@ -90,7 +90,7 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
* @param parent The <code>IHoldsOptions</code> object the OptionCategory will be added to.
* @param element The XML element that contains the OptionCategory settings.
*/
- public OptionCategory(IHoldsOptions parent, Element element) {
+ public OptionCategory(IHoldsOptions parent, ICStorageElement element) {
this.holder = parent;
isExtensionOptionCategory = false;
@@ -131,18 +131,18 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
*
* @param element An XML element containing the OptionCategory information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
// owner
- if (element.hasAttribute(IOptionCategory.OWNER)) {
+ if (element.getAttribute(IOptionCategory.OWNER) != null) {
ownerId = element.getAttribute(IOptionCategory.OWNER);
}
if (ownerId != null) {
@@ -152,7 +152,7 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
}
// icon - was saved as URL in string form
- if (element.hasAttribute(IOptionCategory.ICON)) {
+ if (element.getAttribute(IOptionCategory.ICON) != null) {
String iconPath = element.getAttribute(IOptionCategory.ICON);
try {
iconPathURL = new URL(iconPath);
@@ -188,7 +188,7 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
element.setAttribute(IBuildObject.ID, id);
if (name != null) {
@@ -260,7 +260,7 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions()
*/
- public Object[][] getOptions(IResourceConfiguration resConfig, IHoldsOptions optionHolder) {
+ public Object[][] getOptions(IResourceInfo resinfo, IHoldsOptions optionHolder) {
IHoldsOptions[] optionHolders = new IHoldsOptions[1];
optionHolders[0] = optionHolder;
return getOptions(optionHolders, FILTER_FILE);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java
index 3cc56e9934c..94517f029ba 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java
@@ -17,13 +17,13 @@ import java.util.List;
import java.util.ListIterator;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
-import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.PluginVersionIdentifier;
@@ -133,6 +133,11 @@ public class OptionReference implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
+
List valueList = new ArrayList();
NodeList nodes = element.getElementsByTagName(LIST_VALUE);
for (int i = 0; i < nodes.getLength(); ++i) {
@@ -196,6 +201,10 @@ public class OptionReference implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
List valueList = new ArrayList();
IManagedConfigElement[] valueElements = element.getChildren(LIST_VALUE);
for (int i = 0; i < valueElements.length; ++i) {
@@ -245,6 +254,10 @@ public class OptionReference implements IOption {
case PREPROCESSOR_SYMBOLS:
case LIBRARIES:
case OBJECTS:
+ case INCLUDE_FILES:
+ case LIBRARY_PATHS:
+ case LIBRARY_FILES:
+ case MACRO_FILES:
ArrayList stringList = (ArrayList)value;
ListIterator iter = stringList.listIterator();
while (iter.hasNext()) {
@@ -634,7 +647,11 @@ public class OptionReference implements IOption {
|| getValueType() == INCLUDE_PATH
|| getValueType() == PREPROCESSOR_SYMBOLS
|| getValueType() == LIBRARIES
- || getValueType() == OBJECTS) {
+ || getValueType() == OBJECTS
+ || getValueType() == INCLUDE_FILES
+ || getValueType() == LIBRARY_PATHS
+ || getValueType() == LIBRARY_FILES
+ || getValueType() == MACRO_FILES) {
// Just replace what the option reference is holding onto
this.value = new ArrayList(Arrays.asList(value));
}
@@ -815,4 +832,30 @@ public class OptionReference implements IOption {
public boolean isValid() {
return option.isValid();
}
+
+ public String[] getBasicStringListValue() throws BuildException {
+ if (getBasicValueType() != STRING_LIST) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return new String[0];
+ }
+
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+
+ public int getBasicValueType() throws BuildException {
+ switch(getValueType()){
+ case IOption.BOOLEAN:
+ return IOption.BOOLEAN;
+ case IOption.STRING:
+ return IOption.STRING;
+ case IOption.ENUMERATED:
+ return IOption.ENUMERATED;
+ default:
+ return IOption.STRING_LIST;
+ }
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java
index a63cf61136d..d2291a8b125 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,26 +10,23 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.content.*;
-import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
-import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
public class OutputType extends BuildObject implements IOutputType {
@@ -56,6 +53,9 @@ public class OutputType extends BuildObject implements IOutputType {
private String namePattern;
private IConfigurationElement nameProviderElement = null;
private IManagedOutputNameProvider nameProvider = null;
+
+ private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
+
// Miscellaneous
private boolean isExtensionOutputType = false;
private boolean isDirty = false;
@@ -83,6 +83,10 @@ public class OutputType extends BuildObject implements IOutputType {
loadFromManifest(element);
+ IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
+ if(enablements.length > 0)
+ booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
+
// Hook me up to the Managed Build Manager
ManagedBuildManager.addExtensionOutputType(this);
}
@@ -122,7 +126,7 @@ public class OutputType extends BuildObject implements IOutputType {
* @param parent The <code>ITool</code> the OutputType will be added to.
* @param element The XML element that contains the OutputType settings.
*/
- public OutputType(ITool parent, Element element) {
+ public OutputType(ITool parent, ICStorageElement element) {
this.parent = parent;
isExtensionOutputType = false;
@@ -149,6 +153,7 @@ public class OutputType extends BuildObject implements IOutputType {
setId(Id);
setName(name);
isExtensionOutputType = false;
+ boolean copyIds = Id.equals(outputType.id);
// Copy the remaining attributes
if (outputType.outputContentTypeId != null) {
@@ -187,8 +192,13 @@ public class OutputType extends BuildObject implements IOutputType {
nameProviderElement = outputType.nameProviderElement;
nameProvider = outputType.nameProvider;
- setDirty(true);
- setRebuildState(true);
+ if(copyIds) {
+ isDirty = outputType.isDirty;
+ rebuildState = outputType.rebuildState;
+ } else {
+ setDirty(true);
+ setRebuildState(true);
+ }
}
/*
@@ -262,13 +272,13 @@ public class OutputType extends BuildObject implements IOutputType {
*
* @param element An XML element containing the OutputType information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@@ -282,22 +292,22 @@ public class OutputType extends BuildObject implements IOutputType {
}
// outputContentType
- if (element.hasAttribute(IOutputType.OUTPUT_CONTENT_TYPE)) {
+ if (element.getAttribute(IOutputType.OUTPUT_CONTENT_TYPE) != null) {
outputContentTypeId = element.getAttribute(IOutputType.OUTPUT_CONTENT_TYPE);
}
// outputs
- if (element.hasAttribute(IOutputType.OUTPUTS)) {
+ if (element.getAttribute(IOutputType.OUTPUTS) != null) {
outputs = element.getAttribute(IOutputType.OUTPUTS);
}
// option
- if (element.hasAttribute(IOutputType.OPTION)) {
+ if (element.getAttribute(IOutputType.OPTION) != null) {
optionId = element.getAttribute(IOutputType.OPTION);
}
// multipleOfType
- if (element.hasAttribute(IOutputType.MULTIPLE_OF_TYPE)) {
+ if (element.getAttribute(IOutputType.MULTIPLE_OF_TYPE) != null) {
String isMOT = element.getAttribute(IOutputType.MULTIPLE_OF_TYPE);
if (isMOT != null){
multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
@@ -305,13 +315,13 @@ public class OutputType extends BuildObject implements IOutputType {
}
// primaryInputType
- if (element.hasAttribute(IOutputType.PRIMARY_INPUT_TYPE)) {
+ if (element.getAttribute(IOutputType.PRIMARY_INPUT_TYPE) != null) {
primaryInputTypeId = element.getAttribute(IOutputType.PRIMARY_INPUT_TYPE);
primaryInputType = parent.getInputTypeById(primaryInputTypeId);
}
// primaryOutput
- if (element.hasAttribute(IOutputType.PRIMARY_OUTPUT)) {
+ if (element.getAttribute(IOutputType.PRIMARY_OUTPUT) != null) {
String isPO = element.getAttribute(IOutputType.PRIMARY_OUTPUT);
if (isPO != null){
primaryOutput = new Boolean("true".equals(isPO)); //$NON-NLS-1$
@@ -319,28 +329,28 @@ public class OutputType extends BuildObject implements IOutputType {
}
// outputPrefix
- if (element.hasAttribute(IOutputType.OUTPUT_PREFIX)) {
+ if (element.getAttribute(IOutputType.OUTPUT_PREFIX) != null) {
outputPrefix = element.getAttribute(IOutputType.OUTPUT_PREFIX);
}
// outputNames
- if (element.hasAttribute(IOutputType.OUTPUT_NAMES)) {
+ if (element.getAttribute(IOutputType.OUTPUT_NAMES) != null) {
outputNames = element.getAttribute(IOutputType.OUTPUT_NAMES);
}
// namePattern
- if (element.hasAttribute(IOutputType.NAME_PATTERN)) {
+ if (element.getAttribute(IOutputType.NAME_PATTERN) != null) {
namePattern = element.getAttribute(IOutputType.NAME_PATTERN);
}
// buildVariable
- if (element.hasAttribute(IOutputType.BUILD_VARIABLE)) {
+ if (element.getAttribute(IOutputType.BUILD_VARIABLE) != null) {
buildVariable = element.getAttribute(IOutputType.BUILD_VARIABLE);
}
// Note: Name Provider cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
- if (element.hasAttribute(IOutputType.NAME_PROVIDER)) {
+ if (element.getAttribute(IOutputType.NAME_PROVIDER) != null) {
// TODO: Issue warning?
}
}
@@ -351,7 +361,7 @@ public class OutputType extends BuildObject implements IOutputType {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
if (superClass != null)
element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
@@ -649,19 +659,23 @@ public class OutputType extends BuildObject implements IOutputType {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputExtensions()
- */
- public String[] getOutputExtensions(ITool tool) {
+ public String[] getOutputExtensions(ITool tool, IProject project) {
// Use content type if specified and registered with Eclipse
IContentType type = getOutputContentType();
if (type != null) {
- return ((Tool)tool).getContentTypeFileSpecs(type);
+ return ((Tool)tool).getContentTypeFileSpecs(type, project);
}
return getOutputExtensionsAttribute();
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputExtensions()
+ */
+ public String[] getOutputExtensions(ITool tool) {
+ return getOutputExtensions(tool, ((Tool)tool).getProject());
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOutputType#isOutputExtension()
*/
public boolean isOutputExtension(ITool tool, String ext) {
@@ -884,4 +898,26 @@ public class OutputType extends BuildObject implements IOutputType {
rebuildState = rebuild;
}
+
+ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
+ if(booleanExpressionCalculator == null){
+ if(superClass != null){
+ return ((OutputType)superClass).getBooleanExpressionCalculator();
+ }
+ }
+ return booleanExpressionCalculator;
+ }
+
+ public boolean isEnabled(ITool tool) {
+ if(tool.isExtensionElement())
+ return true;
+
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc == null)
+ return true;
+
+ return calc.isOutputTypeEnabled(tool, this);
+ }
+
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java
index 6202041708e..2c2285d841d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -11,16 +11,21 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider;
-import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier;
@@ -32,7 +37,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-public class ProjectType extends BuildObject implements IProjectType {
+public class ProjectType extends BuildObject implements IProjectType, IBuildPropertiesRestriction, IBuildPropertyChangeListener {
private static final String EMPTY_STRING = new String();
//private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
@@ -56,6 +61,9 @@ public class ProjectType extends BuildObject implements IProjectType {
private IProjectEnvironmentVariableSupplier environmentVariableSupplier = null;
private IConfigurationElement buildMacroSupplierElement = null;
private IProjectBuildMacroSupplier buildMacroSupplier = null;
+
+ BuildObjectProperties buildProperties;
+
// Miscellaneous
private boolean resolved = true;
@@ -155,6 +163,11 @@ public class ProjectType extends BuildObject implements IProjectType {
// superClass
superClassId = element.getAttribute(SUPERCLASS);
+
+ String props = element.getAttribute(BUILD_PROPERTIES);
+ if(props != null)
+ buildProperties = new BuildObjectProperties(props, this, this);
+
// Get the unused children, if any
unusedChildren = element.getAttribute(UNUSED_CHILDREN);
@@ -286,10 +299,21 @@ public class ProjectType extends BuildObject implements IProjectType {
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
*/
public String getName() {
+ String name = getNameAttribute();
+ if(name.length() == 0){
+ IBuildObjectProperties props = getBuildProperties();
+ IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID);
+ if(prop != null)
+ name = prop.getValue().getName();
+ }
+ return name;
+ }
+
+ public String getNameAttribute() {
// If I am unnamed, see if I can inherit one from my parent
if (name == null) {
if (superClass != null) {
- return superClass.getName();
+ return (superClass).getNameAttribute();
} else {
return new String(""); //$NON-NLS-1$
}
@@ -644,4 +668,95 @@ public class ProjectType extends BuildObject implements IProjectType {
public IConfigurationElement getCurrentMbsVersionConversionElement() {
return currentMbsVersionConversionElement;
}
+
+ public IBuildObjectProperties getBuildProperties() {
+ if(buildProperties == null){
+ BuildObjectProperties parentProps = findBuildProperties();
+ if(parentProps != null)
+ buildProperties = new BuildObjectProperties(parentProps, this, this);
+ else
+ buildProperties = new BuildObjectProperties(this, this);
+ }
+ return buildProperties;
+ }
+
+ BuildObjectProperties findBuildProperties(){
+ if(buildProperties == null){
+ if(superClass != null){
+ return ((ProjectType)superClass).findBuildProperties();
+ }
+ return null;
+ }
+ return buildProperties;
+ }
+
+ public void propertiesChanged() {
+ List list = getConfigurationList();
+ for(int i = 0; i < list.size(); i++){
+ ((Configuration)list.get(i)).propertiesChanged();
+ }
+ }
+
+ public boolean supportsType(IBuildPropertyType type) {
+ return supportsType(type.getId());
+ }
+
+ public boolean supportsValue(IBuildPropertyType type,
+ IBuildPropertyValue value) {
+ return supportsValue(type.getId(), value.getId());
+ }
+
+ public boolean supportsType(String typeId) {
+ List list = getConfigurationList();
+ for(int i = 0; i < list.size(); i++){
+ if(((Configuration)list.get(i)).supportsType(typeId))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean supportsValue(String typeId, String valueId) {
+ List list = getConfigurationList();
+ for(int i = 0; i < list.size(); i++){
+ if(((Configuration)list.get(i)).supportsValue(typeId, valueId))
+ return true;
+ }
+ return false;
+ }
+
+ public String[] getRequiredTypeIds() {
+ List result = new ArrayList();
+ List list = getConfigurationList();
+ for(int i = 0; i < list.size(); i++){
+ result.addAll(Arrays.asList(((Configuration)list.get(i)).getRequiredTypeIds()));
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public String[] getSupportedTypeIds() {
+ List result = new ArrayList();
+ List list = getConfigurationList();
+ for(int i = 0; i < list.size(); i++){
+ result.addAll(Arrays.asList(((Configuration)list.get(i)).getSupportedTypeIds()));
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ List result = new ArrayList();
+ List list = getConfigurationList();
+ for(int i = 0; i < list.size(); i++){
+ result.addAll(Arrays.asList(((Configuration)list.get(i)).getSupportedValueIds(typeId)));
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public boolean requiresType(String typeId) {
+ List list = getConfigurationList();
+ for(int i = 0; i < list.size(); i++){
+ if(((Configuration)list.get(i)).requiresType(typeId))
+ return true;
+ }
+ return false;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
index 3fbeef5ae73..7bec9ed8d0e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
@@ -60,6 +60,8 @@ public class PropertyManager {
}
protected void setProperty(IConfiguration cfg, IBuildObject bo, String prop, String value){
+ if(((Configuration)cfg).isPreference())
+ return;
Properties props = getProperties(cfg, bo);
if(props != null){
props.setProperty(prop, value);
@@ -67,6 +69,8 @@ public class PropertyManager {
}
protected String getProperty(IConfiguration cfg, IBuildObject bo, String prop){
+ if(((Configuration)cfg).isPreference())
+ return null;
Properties props = getProperties(cfg, bo);
if(props != null)
return props.getProperty(prop);
@@ -313,7 +317,10 @@ public class PropertyManager {
}
public void setProperty(ITool tool, String key, String value){
- setProperty(getConfiguration(tool), tool, key, value);
+ Configuration cfg = (Configuration)getConfiguration(tool);
+ if(cfg.isPreference())
+ return;
+ setProperty(cfg, tool, key, value);
}
public void setProperty(IBuilder builder, String key, String value){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
index 977cf282fd6..11565f01181 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -430,10 +430,10 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
if(rcCfg != null && !oldPath.equals(newPath)){
- config.removeResourceConfiguration(rcCfg);
+// config.removeResourceConfiguration(rcCfg);
rcCfg.setResourcePath(newPath.toString());
- rcCfg.setRebuildState(true);
- ((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
+// rcCfg.setRebuildState(true);
+// ((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
// config.setRebuildState(true);
return true;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
index 1bff6fb8f5e..224e2c71bed 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -11,30 +11,35 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildFileData;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-public class ResourceConfiguration extends BuildObject implements IResourceConfiguration {
+public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
private static final String EMPTY_STRING = new String();
@@ -42,19 +47,14 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
// Parent and children
- private IConfiguration parent;
private List toolList;
private Map toolMap;
// Managed Build model attributes
- private String resPath;
- private Boolean isExcluded;
private Integer rcbsApplicability;
private String toolsToInvoke;
// Miscellaneous
private boolean isExtensionResourceConfig = false;
- private boolean isDirty = false;
private boolean resolved = true;
- private boolean rebuildState;
/*
* C O N S T R U C T O R S
@@ -70,7 +70,7 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
* @param managedBuildRevision
*/
public ResourceConfiguration(IConfiguration parent, IManagedConfigElement element, String managedBuildRevision) {
- this.parent = parent;
+ super(parent, element, true);
isExtensionResourceConfig = true;
// setup for resolving
@@ -88,6 +88,8 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
Tool toolChild = new Tool(this, tools[n], getManagedBuildRevision());
toolList.add(toolChild);
}
+
+ setDirty(false);
}
/**
@@ -98,44 +100,69 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
* @param element The XML element that contains the resource configuration settings.
* @param managedBuildRevision
*/
- public ResourceConfiguration(IConfiguration parent, Element element, String managedBuildRevision) {
- this.parent = parent;
+ public ResourceConfiguration(IConfiguration parent, ICStorageElement element, String managedBuildRevision) {
+ super(parent, element, true);
isExtensionResourceConfig = false;
+ setResourceData(new BuildFileData(this));
setManagedBuildRevision(managedBuildRevision);
// Initialize from the XML attributes
loadFromProject(element);
// Load children
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(ITool.TOOL_ELEMENT_NAME)) {
- Tool tool = new Tool((IBuildObject)this, (Element)configElement, getManagedBuildRevision());
+ ICStorageElement configElements[] = element.getChildren();
+ for (int i = 0; i < configElements.length; ++i) {
+ ICStorageElement configElement = configElements[i];
+ if (configElement.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
+ Tool tool = new Tool((IBuildObject)this, configElement, getManagedBuildRevision());
addTool(tool);
}
}
String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
if(rebuild == null || Boolean.valueOf(rebuild).booleanValue())
- rebuildState = true;
+ setRebuildState(true);
+ setDirty(false);
}
- public ResourceConfiguration(IConfiguration parent, String id, String resourceName, String path){
- this.parent = parent;
-
- setId(id);
- setName(resourceName);
+ public ResourceConfiguration(FolderInfo folderInfo, ITool baseTool, String id, String resourceName, IPath path){
+ super(folderInfo, path, id, resourceName);
+// setParentFolder(folderInfo);
+// setParentFolderId(folderInfo.getId());
- if ( parent != null)
- setManagedBuildRevision(parent.getManagedBuildRevision());
+ isExtensionResourceConfig = folderInfo.isExtensionElement();
+ if(!isExtensionResourceConfig)
+ setResourceData(new BuildFileData(this));
+
+ if ( folderInfo.getParent() != null)
+ setManagedBuildRevision(folderInfo.getParent().getManagedBuildRevision());
- resPath = path;
- isDirty = false;
- isExcluded = new Boolean(false);
+ setDirty(false);
toolsToInvoke = EMPTY_STRING;
rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL);
- setRebuildState(true);
+
+
+ // Get file extension.
+ String extString = path.getFileExtension();
+ if(baseTool != null){
+ if(baseTool.getParentResourceInfo() != folderInfo)
+ baseTool = null;
+ }
+ // Add the resource specific tools to this resource.
+ ITool tools[] = folderInfo.getFilteredTools();
+ String subId = new String();
+ for (int i = 0; i < tools.length; i++) {
+ if( tools[i].buildsFileType(extString) ) {
+ baseTool = tools[i];
+ break;
+ }
+ }
+
+ if(baseTool != null){
+ subId = ManagedBuildManager.calculateChildId(baseTool.getId(), null);
+ createTool(baseTool, subId, baseTool.getName(), false);
+ setRebuildState(true);
+ }
}
/**
@@ -145,67 +172,165 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
* @param parentConfig The <code>IConfiguration</code> to copy the settings from.
* @param id A unique ID for the new configuration.
*/
- public ResourceConfiguration(IConfiguration parent, ResourceConfiguration cloneConfig, String id) {
- setId(id);
- setName(cloneConfig.getName());
- this.parent = parent;
- isExtensionResourceConfig = false;
+ public ResourceConfiguration(IConfiguration cfg, ResourceConfiguration cloneConfig, String id, Map superClassIdMap, boolean cloneChildren) {
+ super(cfg, cloneConfig, id);
+
+ isExtensionResourceConfig = cfg.isExtensionElement();
+ if(!cloneConfig.isExtensionResourceConfig)
+ cloneChildren = true;
+
+ if(!isExtensionResourceConfig)
+ setResourceData(new BuildFileData(this));
setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
// Copy the remaining attributes
- if (cloneConfig.resPath != null) {
- resPath = new String(cloneConfig.resPath);
- }
- if (cloneConfig.isExcluded != null) {
- isExcluded = new Boolean(cloneConfig.isExcluded.booleanValue());
- }
if (cloneConfig.toolsToInvoke != null) {
toolsToInvoke = new String(cloneConfig.toolsToInvoke);
}
if (cloneConfig.rcbsApplicability != null) {
rcbsApplicability = new Integer(cloneConfig.rcbsApplicability.intValue());
}
-
+
+ boolean copyIds = cloneChildren && id.equals(cloneConfig.id);
// Clone the resource configuration's tool children
if (cloneConfig.toolList != null) {
Iterator iter = cloneConfig.getToolList().listIterator();
while (iter.hasNext()) {
Tool toolChild = (Tool) iter.next();
- String subId;
+ String subId = null;
String subName;
- if (toolChild.getSuperClass() != null) {
- subId = ManagedBuildManager.calculateChildId(
- toolChild.getSuperClass().getId(),
- null);
- subName = toolChild.getSuperClass().getName();
- } else {
- subId = ManagedBuildManager.calculateChildId(
- toolChild.getId(),
- null);
- subName = toolChild.getName();
- }
+ Map curIdMap = (Map)superClassIdMap.get(cloneConfig.getPath());
+ ITool extTool = ManagedBuildManager.getExtensionTool(toolChild);
+ if(curIdMap != null){
+ if(extTool != null){
+ subId = (String)curIdMap.get(extTool.getId());
+ }
+ }
+
+ subName = toolChild.getName();
+
+ if(subId == null){
+ if (extTool != null) {
+ subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(
+ extTool.getId(),
+ null);
+ // subName = toolChild.getSuperClass().getName();
+ } else {
+ subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(
+ toolChild.getId(),
+ null);
+ // subName = toolChild.getName();
+ }
+ }
// The superclass for the cloned tool is not the same as the one from the tool being cloned.
// The superclasses reside in different configurations.
ITool toolSuperClass = null;
+ String superId = null;
// Search for the tool in this configuration that has the same grand-superClass as the
// tool being cloned
- ITool[] tools = parent.getTools();
- for (int i=0; i<tools.length; i++) {
- ITool configTool = tools[i];
- if (toolChild.getSuperClass() != null
- && configTool.getSuperClass() == toolChild.getSuperClass().getSuperClass())
- {
- toolSuperClass = configTool;
- break;
- }
- }
- if (toolSuperClass == null) {
- // TODO: report an error
+ ITool otherSuperTool = toolChild.getSuperClass();
+ if(otherSuperTool != null){
+ if(otherSuperTool.isExtensionElement()){
+ toolSuperClass = otherSuperTool;
+ } else {
+ IResourceInfo otherRcInfo = otherSuperTool.getParentResourceInfo();
+ IResourceInfo thisRcInfo = cfg.getResourceInfo(otherRcInfo.getPath(), true);
+ ITool otherExtTool = ManagedBuildManager.getExtensionTool(otherSuperTool);
+ if(otherExtTool != null){
+ if(thisRcInfo != null){
+ ITool tools[] = thisRcInfo.getTools();
+ for(int i = 0; i < tools.length; i++){
+ ITool thisExtTool = ManagedBuildManager.getExtensionTool(tools[i]);
+ if(otherExtTool.equals(thisExtTool)){
+ toolSuperClass = tools[i];
+ superId = toolSuperClass.getId();
+ break;
+ }
+ }
+ } else {
+ superId = copyIds ? otherSuperTool.getId() : ManagedBuildManager.calculateChildId(otherExtTool.getId(), null);
+ Map idMap = (Map)superClassIdMap.get(otherRcInfo.getPath());
+ if(idMap == null){
+ idMap = new HashMap();
+ superClassIdMap.put(otherRcInfo.getPath(), idMap);
+ }
+ idMap.put(otherExtTool.getId(), superId);
+ }
+ }
+ }
}
- Tool newTool = new Tool(this, toolSuperClass, subId, subName, toolChild);
+// IToolChain tCh = cloneConfig.getBaseToolChain();
+// if(tCh != null){
+// if(!tCh.isExtensionElement()){
+// IFolderInfo fo = tCh.getParentFolderInfo();
+// IPath path = fo.getPath();
+// IResourceInfo baseFo = cfg.getResourceInfo(path, false);
+// if(baseFo instanceof IFileInfo)
+// baseFo = cfg.getResourceInfo(path.removeLastSegments(1), false);
+// tCh = ((IFolderInfo)baseFo).getToolChain();
+//
+// }
+// ITool[] tools = tCh.getTools();
+// for (int i=0; i<tools.length; i++) {
+// ITool configTool = tools[i];
+// if (toolChild.getSuperClass() != null
+// && configTool.getSuperClass() == toolChild.getSuperClass().getSuperClass())
+// {
+// toolSuperClass = configTool;
+// break;
+// }
+// }
+// } else {
+// //TODO:
+// }
+
+ Tool newTool = null;
+ if(toolSuperClass != null)
+ newTool = new Tool(this, toolSuperClass, subId, subName, toolChild);
+ else
+ newTool = new Tool(this, superId, subId, subName, toolChild);
+
+ if(newTool != null)
+ addTool(newTool);
+ }
+ }
+
+ if(copyIds){
+ isDirty = cloneConfig.isDirty;
+ needsRebuild = cloneConfig.needsRebuild;
+ } else {
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+
+ public ResourceConfiguration(ResourceConfiguration baseInfo, IPath path, String id, String name) {
+ super(baseInfo, path, id, name);
+
+ isExtensionResourceConfig = false;
+ setResourceData(new BuildFileData(this));
+
+ setManagedBuildRevision(baseInfo.getManagedBuildRevision());
+
+ // Copy the remaining attributes
+ toolsToInvoke = baseInfo.toolsToInvoke;
+
+ rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL);
+
+ // Clone the resource configuration's tool children
+ if (baseInfo.toolList != null) {
+ Iterator iter = baseInfo.getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ ITool superTool = toolChild.getSuperClass();
+ String baseId = superTool != null ? superTool.getId() : toolChild.getId();
+ String subId = ManagedBuildManager.calculateChildId(baseId, null);
+ String subName = toolChild.getName();
+
+ Tool newTool = new Tool(this, superTool, subId, subName, toolChild);
addTool(newTool);
}
}
@@ -213,7 +338,7 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
setDirty(true);
setRebuildState(true);
}
-
+
/*
* E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
*/
@@ -226,21 +351,7 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
*/
protected void loadFromManifest(IManagedConfigElement element) {
ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // Get the name
- setName(element.getAttribute(IBuildObject.NAME));
-
- // resourcePath
- resPath = element.getAttribute(IResourceConfiguration.RESOURCE_PATH);
- // exclude
- String excludeStr = element.getAttribute(IResourceConfiguration.EXCLUDE);
- if (excludeStr != null){
- isExcluded = new Boolean("true".equals(excludeStr)); //$NON-NLS-1$
- }
// toolsToInvoke
toolsToInvoke = element.getAttribute(IResourceConfiguration.TOOLS_TO_INVOKE);
@@ -263,36 +374,14 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
*
* @param element An XML element containing the resource configuration information
*/
- protected void loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // exclude
- if (element.hasAttribute(IResourceConfiguration.EXCLUDE)) {
- String excludeStr = element.getAttribute(IResourceConfiguration.EXCLUDE);
- if (excludeStr != null){
- isExcluded = new Boolean("true".equals(excludeStr)); //$NON-NLS-1$
- }
- }
-
- // resourcePath
- if (element.hasAttribute(IResourceConfiguration.RESOURCE_PATH)) {
- resPath = element.getAttribute(IResourceConfiguration.RESOURCE_PATH);
- }
-
+ protected void loadFromProject(ICStorageElement element) {
// toolsToInvoke
- if (element.hasAttribute(IResourceConfiguration.TOOLS_TO_INVOKE)) {
+ if (element.getAttribute(IResourceConfiguration.TOOLS_TO_INVOKE) != null) {
toolsToInvoke = element.getAttribute(IResourceConfiguration.TOOLS_TO_INVOKE);
}
// rcbsApplicability
- if (element.hasAttribute(IResourceConfiguration.RCBS_APPLICABILITY)) {
+ if (element.getAttribute(IResourceConfiguration.RCBS_APPLICABILITY) != null) {
String rcbsApplicabilityStr = element.getAttribute(IResourceConfiguration.RCBS_APPLICABILITY);
if (rcbsApplicabilityStr == null || rcbsApplicabilityStr.equals(DISABLE_RCBS_TOOL)) {
rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL);
@@ -312,22 +401,8 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
-
- element.setAttribute(IBuildObject.ID, id);
-
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- if (isExcluded != null) {
- element.setAttribute(IResourceConfiguration.EXCLUDE, isExcluded.toString());
- }
-
- if (resPath != null) {
- element.setAttribute(IResourceConfiguration.RESOURCE_PATH, resPath);
- }
-
+ public void serialize(ICStorageElement element) {
+ super.serialize(element);
if (toolsToInvoke != null) {
element.setAttribute(IResourceConfiguration.TOOLS_TO_INVOKE, toolsToInvoke);
}
@@ -359,25 +434,18 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
Iterator iter = toolElements.listIterator();
while (iter.hasNext()) {
Tool tool = (Tool) iter.next();
- Element toolElement = doc.createElement(ITool.TOOL_ELEMENT_NAME);
- element.appendChild(toolElement);
- tool.serialize(doc, toolElement);
+ ICStorageElement toolElement = element.createChild(ITool.TOOL_ELEMENT_NAME);
+ tool.serialize(toolElement);
}
// I am clean now
- isDirty = false;
+ setDirty(false);
}
/*
* P A R E N T A N D C H I L D H A N D L I N G
*/
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IResourceConfiguration#getParent()
- */
- public IConfiguration getParent() {
- return parent;
- }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IResourceConfiguration#getTools()
@@ -452,24 +520,12 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
*/
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IResourceConfiguration#isExcluded()
- */
- public boolean isExcluded() {
- if (isExcluded != null) {
- return isExcluded.booleanValue();
- } else {
- return false;
- }
- }
-
-
- /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IResourceConfiguration#getResourcePath()
*/
public String getResourcePath() {
- String path = resPath;
- if (path == null) return EMPTY_STRING;
- return path;
+ IPath path = getParent().getOwner().getProject().getFullPath();
+ path = path.append(getPath());
+ return path.toString();
}
/* (non-Javadoc)
@@ -641,17 +697,6 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
*/
if (rcbsApplicability == null || !(rcbsApplicability.intValue() == newValue)) {
rcbsApplicability = new Integer(newValue);
- isDirty = true;
- setRebuildState(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IResourceConfiguration#setExclude()
- */
- public void setExclude(boolean excluded) {
- if (isExcluded == null || excluded != isExcluded.booleanValue()) {
- isExcluded = new Boolean(excluded);
setDirty(true);
setRebuildState(true);
}
@@ -663,11 +708,8 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
public void setResourcePath(String path) {
if( path == null)
return;
- if (resPath == null || !path.equals(resPath)) {
- resPath = path;
- setDirty(true);
- setRebuildState(true);
- }
+ IPath p = new Path(path).removeFirstSegments(1);
+ setPath(p);
}
/*
@@ -689,7 +731,8 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
if (isExtensionResourceConfig) return false;
// If I need saving, just say yes
- if (isDirty) return true;
+ if (super.isDirty())
+ return true;
// Otherwise see if any tools need saving
Iterator iter = getToolList().listIterator();
@@ -698,15 +741,18 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
if (toolChild.isDirty()) return true;
}
- return isDirty;
+ return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IResourceConfiguration#setDirty(boolean)
*/
public void setDirty(boolean isDirty) {
- this.isDirty = isDirty;
- // Propagate "false" to the children
+ if (isExtensionResourceConfig) return;
+
+ super.setDirty(isDirty);
+
+ // Propagate "false" to the children
if (!isDirty) {
Iterator iter = getToolList().listIterator();
while (iter.hasNext()) {
@@ -752,7 +798,8 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
tool.removeOption(opts[j]);
}
}
- isExcluded = new Boolean(false);
+
+ setExclude(false);
}
/* (non-Javadoc)
@@ -773,74 +820,6 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
return null;
}
- public IOption setOption(IHoldsOptions holder, IOption option, boolean value) throws BuildException {
- // Is there a change?
- IOption retOpt = option;
- if (option.getBooleanValue() != value) {
- // If this resource config does not already override this option, then we need to
- // create a new option
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
- // TODO: This causes the entire project to be rebuilt. Is there a way to only have this
- // file rebuilt? "Clean" its output? Change its modification date?
-// parent.setRebuildState(true);
- }
- return retOpt;
- }
-
- public IOption setOption(IHoldsOptions holder, IOption option, String value) throws BuildException {
- IOption retOpt = option;
- String oldValue;
- oldValue = option.getStringValue();
- if (oldValue != null && !oldValue.equals(value)) {
- // If this resource config does not already override this option, then we need to
- // create a new option
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
- // TODO: This causes the entire project to be rebuilt. Is there a way to only have this
- // file rebuilt? "Clean" its output? Change its modification date?
-// parent.setRebuildState(true);
- }
- return retOpt;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
- */
- public IOption setOption(IHoldsOptions holder, IOption option, String[] value) throws BuildException {
- IOption retOpt = option;
- // Is there a change?
- String[] oldValue;
- switch (option.getValueType()) {
- case IOption.STRING_LIST :
- oldValue = option.getStringListValue();
- break;
- case IOption.INCLUDE_PATH :
- oldValue = option.getIncludePaths();
- break;
- case IOption.PREPROCESSOR_SYMBOLS :
- oldValue = option.getDefinedSymbols();
- break;
- case IOption.LIBRARIES :
- oldValue = option.getLibraries();
- break;
- case IOption.OBJECTS :
- oldValue = option.getUserObjects();
- break;
- default :
- oldValue = new String[0];
- break;
- }
- if(!Arrays.equals(value, oldValue)) {
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
- // TODO: This causes the entire project to be rebuilt. Is there a way to only have this
- // file rebuilt? "Clean" its output? Change its modification date?
-// parent.setRebuildState(true);
- }
- return retOpt;
- }
-
public IResource getOwner() {
return getParent().getOwner();
}
@@ -876,7 +855,7 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
* @see org.eclipse.cdt.managedbuilder.core.IResourceConfiguration#needsRebuild()
*/
public boolean needsRebuild() {
- if(rebuildState)
+ if(super.needsRebuild())
return true;
ITool tools[] = getToolsToInvoke();
@@ -885,7 +864,7 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
return true;
}
- return rebuildState;
+ return false;
}
/* (non-Javadoc)
@@ -895,12 +874,12 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
if(isExtensionResourceConfiguration() && rebuild)
return;
- if(rebuildState != rebuild){
- rebuildState = rebuild;
+ if(needsRebuild() != rebuild){
+ super.setRebuildState(rebuild);
saveRebuildState();
}
- if(!rebuildState){
+ if(!rebuild){
ITool tools[] = getToolsToInvoke();
for(int i = 0; i < tools.length; i++){
tools[i].setRebuildState(false);
@@ -910,7 +889,86 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
}
private void saveRebuildState(){
- PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(rebuildState));
+ PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(needsRebuild()));
}
+ public final int getKind() {
+ return ICSettingBase.SETTING_FILE;
+ }
+
+ public CFileData getFileData(){
+ return (CFileData)getResourceData();
+ }
+
+ public CLanguageData[] getCLanguageDatas() {
+ ITool tools[] = getTools/*ToInvoke*/();
+ List list = new ArrayList();
+ for(int i = 0; i < tools.length; i++){
+ CLanguageData datas[] = tools[i].getCLanguageDatas();
+ for(int j = 0; j < datas.length; j++){
+ list.add(datas[j]);
+ }
+ }
+ return (BuildLanguageData[])list.toArray(new BuildLanguageData[list.size()]);
+ }
+
+ public IToolChain getBaseToolChain() {
+ ITool tools[] = getToolsToInvoke();
+ ITool baseTool = null;
+ for(int i = 0; i < tools.length; i++){
+ ITool tool = tools[i];
+ ITool superTool = tool.getSuperClass();
+ if(superTool != null){
+ baseTool = superTool;
+ if(!superTool.isExtensionElement()){
+ break;
+ }
+ }
+ }
+
+ IToolChain baseTc = null;
+ if(baseTool != null){
+ IBuildObject parent = baseTool.getParent();
+ if(parent instanceof IToolChain){
+ baseTc = (IToolChain)parent;
+ } else if(parent instanceof ResourceConfiguration){
+ baseTc = ((ResourceConfiguration)parent).getBaseToolChain();
+ }
+ }
+
+ return baseTc;
+ }
+
+ public boolean isExtensionElement() {
+ return isExtensionResourceConfig;
+ }
+
+ public boolean supportsBuild(boolean managed) {
+ ITool tools[] = getToolsToInvoke();
+ for(int i = 0; i < tools.length; i++){
+ if(!tools[i].supportsBuild(managed))
+ return false;
+ }
+
+ return true;
+ }
+
+ public Set contributeErrorParsers(Set set) {
+ return contributeErrorParsers(getToolsToInvoke(), set);
+ }
+
+ public void resetErrorParsers() {
+ resetErrorParsers(getToolsToInvoke());
+ }
+
+ void removeErrorParsers(Set set) {
+ removeErrorParsers(getToolsToInvoke(), set);
+ }
+
+ void resolveProjectReferences(boolean onLoad){
+ for(Iterator iter = getToolList().iterator(); iter.hasNext();){
+ Tool tool = (Tool)iter.next();
+ tool.resolveProjectReferences(onLoad);
+ }
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java
new file mode 100644
index 00000000000..7d64a686d32
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java
@@ -0,0 +1,450 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public abstract class ResourceInfo extends BuildObject implements IResourceInfo {
+// private IFolderInfo parentFolderInfo;
+// private String parentFolderInfoId;
+ private IConfiguration config;
+ private IPath path;
+ boolean isDirty;
+ private boolean isExcluded;
+ boolean needsRebuild;
+ private ResourceInfoContainer rcInfo;
+ private CResourceData resourceData;
+// private boolean inheritParentInfo;
+// private IToolChain baseToolChain;
+// private String baseToolChainId;
+
+ ResourceInfo(IConfiguration cfg, IManagedConfigElement element, boolean hasBody){
+ config = cfg;
+ if(hasBody)
+ loadFromManifest(element);
+ }
+
+ ResourceInfo(IConfiguration cfg, ResourceInfo base, String id) {
+ config = cfg;
+ path = base.path;
+ internalSetExclude(base.isExcluded);
+
+ setId(id);
+ setName(base.getName());
+
+// inheritParentInfo = base.inheritParentInfo;
+/* if(!isRoot()){
+ IFolderInfo pfi = base.getParentFolderInfo();
+ IResourceInfo pf = null;
+ if(pfi != null){
+ pf = config.getResourceInfo(pfi.getPath(), true);
+ }
+
+ if(pf instanceof IFolderInfo)
+ this.parentFolderInfo = (IFolderInfo)pf;
+ else
+ this.parentFolderInfo = config.getRootFolderInfo();
+
+ // if()
+ this.parentFolderInfoId = this.parentFolderInfo.getId();
+ }
+*/
+ if(id.equals(base.getId())){
+ isDirty = base.isDirty;
+ needsRebuild = base.needsRebuild;
+ } else {
+ needsRebuild = true;
+ isDirty = true;
+ }
+ }
+
+ public boolean isRoot(){
+ return path.segmentCount() == 0;
+ }
+
+ ResourceInfo(IConfiguration cfg, IPath path, String id, String name) {
+ config = cfg;
+ this.path = path;
+
+// inheritParentInfo = inherit;
+ setId(id);
+ setName(name);
+ }
+
+ ResourceInfo(IFileInfo base, IPath path, String id, String name) {
+ config = base.getParent();
+
+ setId(id);
+ setName(name);
+
+ this.path = path;
+ internalSetExclude(base.isExcluded());
+// parentFolderInfoId = base.getId();
+// parentFolderInfo = base;
+// inheritParentInfo = false;
+ needsRebuild = true;
+ isDirty = true;
+ }
+
+ ResourceInfo(FolderInfo base, IPath path, String id, String name) {
+ config = base.getParent();
+
+ setId(id);
+ setName(name);
+
+ this.path = path;
+ internalSetExclude(base.isExcluded());
+// parentFolderInfoId = base.getId();
+// parentFolderInfo = base;
+// inheritParentInfo = base.getPath().isPrefixOf(path);
+ needsRebuild = true;
+ isDirty = true;
+ }
+
+ ResourceInfo(IConfiguration cfg, ICStorageElement element, boolean hasBody){
+ config = cfg;
+ if(hasBody)
+ loadFromProject(element);
+ }
+
+ private void loadFromManifest(IManagedConfigElement element) {
+
+ // id
+ setId(element.getAttribute(ID));
+
+ // Get the name
+ setName(element.getAttribute(NAME));
+
+// parentFolderInfoId = element.getAttribute(PARENT_FOLDER_INFO_ID);
+// baseToolChainId = element.getAttribute(BASE_TOOLCHAIN_ID);
+
+ // resourcePath
+ String tmp = element.getAttribute(RESOURCE_PATH);
+ if(tmp != null)
+ path = new Path(tmp);
+ else {
+ //TODO
+ }
+
+// inheritParentInfo = "true".equals(element.getAttribute(INHERIT_PARENT_INFO));
+
+ // exclude
+ String excludeStr = element.getAttribute(EXCLUDE);
+ if (excludeStr != null){
+ internalSetExclude("true".equals(excludeStr)); //$NON-NLS-1$
+ }
+ }
+
+ private void loadFromProject(ICStorageElement element) {
+
+ // id
+ setId(element.getAttribute(ID));
+
+ // name
+ if (element.getAttribute(NAME) != null) {
+ setName(element.getAttribute(NAME));
+ }
+
+ // resourcePath
+ if (element.getAttribute(RESOURCE_PATH) != null) {
+ String tmp = element.getAttribute(RESOURCE_PATH);
+ if(tmp != null){
+ path = new Path(tmp);
+ if(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME.equals(element.getName())){
+ path = path.removeFirstSegments(1);
+ }
+ } else {
+ //TODO
+ }
+ }
+
+ // exclude
+ if (element.getAttribute(EXCLUDE) != null) {
+ String excludeStr = element.getAttribute(EXCLUDE);
+ if (excludeStr != null){
+ internalSetExclude("true".equals(excludeStr)); //$NON-NLS-1$
+ }
+ }
+
+// inheritParentInfo = "true".equals(element.getAttribute(INHERIT_PARENT_INFO));
+
+// parentFolderInfoId = element.getAttribute(PARENT_FOLDER_INFO_ID);
+// baseToolChainId = element.getAttribute(BASE_TOOLCHAIN_ID);
+ }
+
+
+ public IConfiguration getParent() {
+ return config;
+ }
+
+/* public IFolderInfo getParentFolderInfo() {
+ if(parentFolderInfo == null && parentFolderInfoId != null){
+ IResourceInfo rcInfo = config.getResourceInfoById(parentFolderInfoId);
+ if(rcInfo instanceof IFolderInfo)
+ parentFolderInfo = (IFolderInfo)rcInfo;
+ else
+ parentFolderInfo = config.getRootFolderInfo();
+ }
+ return parentFolderInfo;
+ }
+*/
+ public IPath getPath() {
+ return path;
+ }
+
+ public boolean isDirty() {
+ return isDirty;
+ }
+
+ public boolean isExcluded() {
+ return isExcluded;
+ }
+
+ public boolean needsRebuild() {
+ return needsRebuild;
+ }
+
+ public void setDirty(boolean dirty) {
+ isDirty = dirty;
+ }
+
+ public void setExclude(boolean excluded) {
+ if (isExcluded != internalSetExclude(excluded)) {
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+
+ private boolean internalSetExclude(boolean excluded){
+ if(excluded && isRoot())
+ return isExcluded;
+
+ return isExcluded = excluded;
+ }
+
+ public void setPath(IPath p) {
+ if(path == null)
+ path = p;
+ else if (!p.equals(this.path)) {
+ ResourceInfoContainer info = getRcInfo();
+ info.changeCurrentPath(p, true);
+ this.path = p;
+ setDirty(true);
+ setRebuildState(true);
+ }
+
+ }
+
+ private ResourceInfoContainer getRcInfo(){
+ if(rcInfo == null)
+ rcInfo = ((Configuration)config).getRcInfoContainer(this);
+ return rcInfo;
+ }
+
+ public void setRebuildState(boolean rebuild) {
+ needsRebuild = rebuild;
+ }
+
+ void serialize(ICStorageElement element){
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (isExcluded) {
+ element.setAttribute(IResourceInfo.EXCLUDE, "true");
+ }
+
+ if (path != null) {
+ element.setAttribute(IResourceInfo.RESOURCE_PATH, path.toString());
+ }
+
+// if(parentFolderInfoId != null){
+// element.setAttribute(IResourceInfo.PARENT_FOLDER_INFO_ID, parentFolderInfoId);
+// }
+
+// if(baseToolChainId != null){
+// element.setAttribute(IResourceInfo.BASE_TOOLCHAIN_ID, baseToolChainId);
+// }
+ }
+
+ void resolveReferences(){
+// getParentFolderInfo();
+ }
+
+// void setParentFolderId(String id){
+// parentFolderInfoId = id;
+// }
+
+// void setParentFolder(IFolderInfo info){
+// parentFolderInfo = info;
+// }
+
+ public CResourceData getResourceData(){
+ return resourceData;
+ }
+
+ protected void setResourceData(CResourceData data){
+ resourceData = data;
+ }
+
+ void removed(){
+ config = null;
+ }
+
+ public boolean isValid(){
+ return config != null;
+ }
+
+// public boolean isParentInfoInherited() {
+// return inheritParentInfo;
+// }
+
+ public IOption setOption(IHoldsOptions parent, IOption option, boolean value) throws BuildException {
+ // Is there a change?
+ IOption retOpt = option;
+ boolean oldVal = option.getBooleanValue();
+ if (oldVal != value) {
+ retOpt = parent.getOptionToSet(option, false);
+ retOpt.setValue(value);
+// if(resourceData != null)
+// ((ISettingsChangeListener)resourceData).optionChanged(this, parent, option, new Boolean(oldVal));
+ NotificationManager.getInstance().optionChanged(this, parent, option, new Boolean(oldVal));
+// rebuildNeeded = true;
+ }
+ return retOpt;
+ }
+
+ public IOption setOption(IHoldsOptions parent, IOption option, String value) throws BuildException {
+ IOption retOpt = option;
+ String oldValue;
+ oldValue = option.getStringValue();
+ if (oldValue != null && !oldValue.equals(value)) {
+ retOpt = parent.getOptionToSet(option, false);
+ retOpt.setValue(value);
+// if(resourceData != null)
+// ((ISettingsChangeListener)resourceData).optionChanged(this, parent, option, oldValue);
+ NotificationManager.getInstance().optionChanged(this, parent, option, oldValue);
+// rebuildNeeded = true;
+ }
+ return retOpt;
+ }
+
+ public IOption setOption(IHoldsOptions parent, IOption option, String[] value) throws BuildException {
+ IOption retOpt = option;
+ // Is there a change?
+ String[] oldValue;
+ switch (option.getBasicValueType()) {
+ case IOption.STRING_LIST :
+ oldValue = option.getBasicStringListValue();
+ break;
+// case IOption.STRING_LIST :
+// oldValue = option.getStringListValue();
+// break;
+// case IOption.INCLUDE_PATH :
+// oldValue = option.getIncludePaths();
+// break;
+// case IOption.PREPROCESSOR_SYMBOLS :
+// oldValue = option.getDefinedSymbols();
+// break;
+// case IOption.LIBRARIES :
+// oldValue = option.getLibraries();
+// break;
+// case IOption.OBJECTS :
+// oldValue = option.getUserObjects();
+// break;
+ default :
+ oldValue = new String[0];
+ break;
+ }
+ if(!Arrays.equals(value, oldValue)) {
+ retOpt = parent.getOptionToSet(option, false);
+ retOpt.setValue(value);
+// if(resourceData != null)
+// ((ISettingsChangeListener)resourceData).optionChanged(this, parent, option, oldValue);
+ NotificationManager.getInstance().optionChanged(this, parent, option, oldValue);
+// rebuildNeeded = true;
+ }
+ return retOpt;
+ }
+
+ public void propertiesChanged(){
+ if(isExtensionElement())
+ return;
+
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ ((Tool)tools[i]).propertiesChanged();
+ }
+ }
+
+ public abstract boolean isExtensionElement();
+
+ public abstract Set contributeErrorParsers(Set set);
+
+ protected Set contributeErrorParsers(ITool[] tools, Set set){
+ if(set == null)
+ set = new HashSet();
+ for(int i = 0; i < tools.length; i++){
+ Tool tool = (Tool)tools[i];
+ tool.contributeErrorParsers(set);
+ }
+ return set;
+ }
+
+ public abstract void resetErrorParsers();
+
+ protected void resetErrorParsers(ITool tools[]){
+ for(int i = 0; i < tools.length; i++){
+ Tool tool = (Tool)tools[i];
+ tool.resetErrorParsers();
+ }
+ }
+
+ abstract void removeErrorParsers(Set set);
+
+ protected void removeErrorParsers(ITool tools[], Set set){
+ for(int i = 0; i < tools.length; i++){
+ Tool tool = (Tool)tools[i];
+ tool.removeErrorParsers(set);
+ }
+ }
+
+ public ITool getToolById(String id) {
+ ITool[] tools = getTools();
+ for(int i = 0; i < tools.length; i++){
+ if(id.equals(tools[i].getId()))
+ return tools[i];
+ }
+ return null;
+ }
+
+ abstract void resolveProjectReferences(boolean onLoad);
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java
new file mode 100644
index 00000000000..347ee2fbc9c
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.core.runtime.IPath;
+
+public class ResourceInfoContainer {
+ private PathSettingsContainer fRcDataContainer;
+ private boolean fIncludeCurrent;
+
+ public ResourceInfoContainer(PathSettingsContainer pathSettings, boolean includeCurrent){
+ fRcDataContainer = pathSettings;
+ fIncludeCurrent = includeCurrent;
+ }
+
+ public void changeCurrentPath(IPath path, boolean moveChildren){
+ fRcDataContainer.setPath(path, moveChildren);
+ }
+
+ public IPath getCurrentPath(){
+ return fRcDataContainer.getPath();
+ }
+
+ public IResourceInfo getCurrentResourceInfo(){
+ return (IResourceInfo)fRcDataContainer.getValue();
+ }
+
+ public IResourceInfo getResourceInfo(IPath path, boolean exactPath) {
+ PathSettingsContainer cr = fRcDataContainer.getChildContainer(path, false, exactPath);
+ if(cr != null)
+ return (IResourceInfo)cr.getValue();
+ return null;
+ }
+
+ public IResourceInfo[] getResourceInfos(Class clazz) {
+ return getResourceInfos(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER, clazz);
+ }
+
+ public IResourceInfo[] getResourceInfos() {
+ return getResourceInfos(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER);
+ }
+
+ public IResourceInfo[] getResourceInfos(final int kind) {
+ return getResourceInfos(kind, IResourceInfo.class);
+ }
+
+ public IResourceInfo[] getResourceInfos(int kind, Class clazz){
+ List list = getRcInfoList(kind);
+
+ IResourceInfo datas[] = (IResourceInfo[])Array.newInstance(clazz, list.size());
+
+ return (IResourceInfo[])list.toArray(datas);
+ }
+
+ public List getRcInfoList(final int kind){
+ final List list = new ArrayList();
+ fRcDataContainer.accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ if(fIncludeCurrent || container != fRcDataContainer){
+ IResourceInfo data = (IResourceInfo)container.getValue();
+ if((data.getKind() & kind) == data.getKind())
+ list.add(data);
+ }
+ return true;
+ }
+ });
+
+ return list;
+ }
+
+ public IResourceInfo getResourceInfo(IPath path, boolean exactPath, int kind){
+ IResourceInfo data = getResourceInfo(path, exactPath);
+ if(data != null && (data.getKind() & kind) == data.getKind())
+ return data;
+ return null;
+ }
+
+ public void removeResourceInfo(IPath path) {
+ fRcDataContainer.removeChildContainer(path);
+ }
+
+ public void addResourceInfo(IResourceInfo data){
+ PathSettingsContainer cr = fRcDataContainer.getChildContainer(data.getPath(), true, true);
+ cr.setValue(data);
+ }
+
+ public IFileInfo getFileInfo(IPath path){
+ return (IFileInfo)getResourceInfo(path, true, ICSettingBase.SETTING_FILE);
+ }
+
+ public IFolderInfo getFolderInfo(IPath path){
+ return (IFolderInfo)getResourceInfo(path, true, ICSettingBase.SETTING_FOLDER);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SourcePath.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SourcePath.java
new file mode 100644
index 00000000000..2a079babb16
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SourcePath.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+class SourcePath {
+ static final String ELEMENT_NAME = "sourcePath";
+ private static final String ATTRIBUTE_PATH = "path";
+ private IPath path;
+
+ SourcePath(IPath path) {
+ this.path = path;
+ }
+
+ SourcePath(ICStorageElement el) {
+ String pathStr = el.getAttribute(ATTRIBUTE_PATH);
+ if(pathStr != null)
+ path = new Path(pathStr);
+ }
+
+ SourcePath(IManagedConfigElement el) {
+ String pathStr = el.getAttribute(ATTRIBUTE_PATH);
+ if(pathStr != null)
+ path = new Path(pathStr);
+ }
+
+ public IPath getPath(){
+ return path;
+ }
+
+ void serialize(ICStorageElement el){
+ if(path != null){
+ String strPath = path.toString();
+ el.setAttribute(ATTRIBUTE_PATH, strPath);
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SupportedProperties.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SupportedProperties.java
new file mode 100644
index 00000000000..8b243dd97e2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/SupportedProperties.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+
+public class SupportedProperties implements IBuildPropertiesRestriction {
+ public static final String SUPPORTED_PROPERTIES = "supportedProperties"; //$NON-NLS-1$
+ public static final String PROPERTY = "property"; //$NON-NLS-1$
+ public static final String PROPERTY_VALUE = "value"; //$NON-NLS-1$
+ public static final String ID = "id"; //$NON-NLS-1$
+ public static final String REQUIRED = "required"; //$NON-NLS-1$
+
+ private HashMap fSupportedProperties = new HashMap();
+
+ private class SupportedProperty {
+ private boolean fIsRequired;
+ private Set fValues = new HashSet();
+ private String fId;
+
+ SupportedProperty(String id){
+ fId = id;
+ }
+
+ void updateRequired(boolean required){
+ if(!fIsRequired)
+ fIsRequired = required;
+ }
+
+ public String getId(){
+ return fId;
+ }
+
+/* SupportedProperty(IManagedConfigElement el) {
+ fId = el.getAttribute(ID);
+
+// IBuildPropertyType type = mngr.getPropertyType(id);
+// if(type == null)
+// continue;
+
+ fIsRequired = Boolean.valueOf(el.getAttribute(REQUIRED)).booleanValue();
+
+ fValues = new HashSet();
+
+ IManagedConfigElement values[] = el.getChildren();
+ for(int k = 0; k < values.length; k++){
+ IManagedConfigElement value = values[k];
+ if(PROPERTY_VALUE.equals(value.getName())){
+ String valueId = value.getAttribute(ID);
+ if(valueId == null && valueId.length() == 0)
+ continue;
+
+// IBuildPropertyValue val = type.getSupportedValue(valueId);
+// if(val != null)
+// set.add(val.getId());
+ fValues.add(valueId);
+ }
+ }
+ }
+*/
+ public boolean isValid(){
+ return fId != null && fValues.size() != 0;
+ }
+
+ public boolean isRequired(){
+ return fIsRequired;
+ }
+
+ public void addValueIds(Set ids){
+ fValues.addAll(ids);
+ }
+
+ public boolean supportsValue(String id){
+ return fValues.contains(id);
+ }
+
+ public String[] getSupportedValues(){
+ return (String[])fValues.toArray(new String[fValues.size()]);
+ }
+
+ }
+
+ public SupportedProperties(IManagedConfigElement el){
+// IBuildPropertyManager mngr = BuildPropertyManager.getInstance();
+
+ IManagedConfigElement children[] = el.getChildren();
+ for(int i = 0; i < children.length; i++){
+ IManagedConfigElement child = children[i];
+ if(PROPERTY.equals(child.getName())){
+ String id = child.getAttribute(ID);
+ if(id == null)
+ continue;
+
+ boolean required = Boolean.valueOf(el.getAttribute(REQUIRED)).booleanValue();
+
+// IBuildPropertyType type = mngr.getPropertyType(id);
+// if(type == null)
+// continue;
+
+ Set set = new HashSet();
+
+ IManagedConfigElement values[] = child.getChildren();
+ for(int k = 0; k < values.length; k++){
+ IManagedConfigElement value = values[k];
+ if(PROPERTY_VALUE.equals(value.getName())){
+ String valueId = value.getAttribute(ID);
+ if(valueId == null || valueId.length() == 0)
+ continue;
+
+// IBuildPropertyValue val = type.getSupportedValue(valueId);
+// if(val != null)
+// set.add(val.getId());
+
+ set.add(valueId);
+ }
+ }
+
+ if(set.size() != 0){
+ SupportedProperty stored = (SupportedProperty)fSupportedProperties.get(id);
+ if(stored == null){
+ stored = new SupportedProperty(id);
+ fSupportedProperties.put(id, stored);
+ }
+ stored.addValueIds(set);
+ stored.updateRequired(required);
+ }
+ }
+ }
+
+ }
+
+// public boolean supportsType(IBuildPropertyType type) {
+// return supportsType(type.getId());
+// }
+
+ public boolean supportsType(String type) {
+ return fSupportedProperties.containsKey(type);
+ }
+
+ public boolean supportsValue(String type, String value){
+ boolean suports = false;
+ SupportedProperty prop = (SupportedProperty)fSupportedProperties.get(type);
+ if(prop != null){
+ suports = prop.supportsValue(value);
+ }
+ return suports;
+ }
+
+// public boolean supportsValue(IBuildPropertyType type,
+// IBuildPropertyValue value) {
+// return supportsValue(type.getId(), value.getId());
+// }
+
+ public String[] getRequiredTypeIds() {
+ List list = new ArrayList(fSupportedProperties.size());
+ for(Iterator iter = fSupportedProperties.values().iterator(); iter.hasNext();){
+ SupportedProperty prop = (SupportedProperty)iter.next();
+ if(prop.isRequired())
+ list.add(prop.getId());
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public String[] getSupportedTypeIds() {
+ String result[] = new String[fSupportedProperties.size()];
+ fSupportedProperties.keySet().toArray(result);
+ return result;
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ SupportedProperty prop = (SupportedProperty)fSupportedProperties.get(typeId);
+ if(prop != null)
+ return prop.getSupportedValues();
+ return new String[0];
+ }
+
+ public boolean requiresType(String typeId) {
+ SupportedProperty prop = (SupportedProperty)fSupportedProperties.get(typeId);
+ if(prop != null)
+ return prop.isRequired();
+ return false;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java
index 04f0f7491b4..9d5e1eca79f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -14,15 +14,16 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildTargetPlatformData;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
public class TargetPlatform extends BuildObject implements ITargetPlatform {
@@ -44,6 +45,7 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
private boolean isExtensionTargetPlatform = false;
private boolean isDirty = false;
private boolean resolved = true;
+ private BuildTargetPlatformData fTargetPlatformData;
/*
* C O N S T R U C T O R S
@@ -98,6 +100,7 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
// Hook me up to the Managed Build Manager
ManagedBuildManager.addExtensionTargetPlatform(this);
} else {
+ fTargetPlatformData = new BuildTargetPlatformData(this);
setDirty(true);
}
}
@@ -110,9 +113,10 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
* @param element The XML element that contains the TargetPlatform settings.
* @param managedBuildRevision the fileVersion of Managed Build System
*/
- public TargetPlatform(IToolChain parent, Element element, String managedBuildRevision) {
+ public TargetPlatform(IToolChain parent, ICStorageElement element, String managedBuildRevision) {
this.parent = parent;
isExtensionTargetPlatform = false;
+ fTargetPlatformData = new BuildTargetPlatformData(this);
setManagedBuildRevision(managedBuildRevision);
// Initialize from the XML attributes
@@ -127,15 +131,17 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
*/
public TargetPlatform(IToolChain parent, String Id, String name, TargetPlatform targetPlatform) {
this.parent = parent;
- superClass = targetPlatform.superClass;
+
+ superClass = targetPlatform.isExtensionTargetPlatform ? targetPlatform : targetPlatform.superClass;
if (superClass != null) {
- if (targetPlatform.superClassId != null) {
- superClassId = new String(targetPlatform.superClassId);
- }
+// if (targetPlatform.superClassId != null) {
+ superClassId = superClass.getId();// new String(targetPlatform.superClassId);
+// }
}
setId(Id);
setName(name);
isExtensionTargetPlatform = false;
+ fTargetPlatformData = new BuildTargetPlatformData(this);
if ( targetPlatform != null)
setManagedBuildRevision(targetPlatform.getManagedBuildRevision());
@@ -231,13 +237,13 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
*
* @param element An XML element containing the target platform information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@@ -251,12 +257,12 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
}
// Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) {
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
}
// isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ if (element.getAttribute(IProjectType.IS_ABSTRACT) != null) {
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
if (isAbs != null){
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
@@ -264,7 +270,7 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
}
// Get the comma-separated list of valid OS
- if (element.hasAttribute(OS_LIST)) {
+ if (element.getAttribute(OS_LIST) != null) {
String os = element.getAttribute(OS_LIST);
if (os != null) {
osList = new ArrayList();
@@ -276,7 +282,7 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
}
// Get the comma-separated list of valid Architectures
- if (element.hasAttribute(ARCH_LIST)) {
+ if (element.getAttribute(ARCH_LIST) != null) {
String arch = element.getAttribute(ARCH_LIST);
if (arch != null) {
archList = new ArrayList();
@@ -288,7 +294,7 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
}
// Get the semi-colon-separated list of binaryParserIds
- if (element.hasAttribute(BINARY_PARSER)) {
+ if (element.getAttribute(BINARY_PARSER) != null) {
String bpars = element.getAttribute(BINARY_PARSER);
if (bpars != null) {
binaryParserList = new ArrayList();
@@ -307,7 +313,7 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
if (superClass != null)
element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
@@ -491,14 +497,18 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
* @see org.eclipse.cdt.core.build.managed.IBuilder#setBinaryParserList(String[])
*/
public void setBinaryParserList(String[] ids) {
- if (binaryParserList == null) {
- binaryParserList = new ArrayList();
+ if(ids != null){
+ if (binaryParserList == null) {
+ binaryParserList = new ArrayList();
+ } else {
+ binaryParserList.clear();
+ }
+ for (int i = 0; i < ids.length; i++) {
+ binaryParserList.add(ids[i]);
+ }
} else {
- binaryParserList.clear();
+ binaryParserList = null;
}
- for (int i = 0; i < ids.length; i++) {
- binaryParserList.add(ids[i]);
- }
setDirty(true);
}
@@ -608,4 +618,8 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
// Do nothing
}
+ public CTargetPlatformData getTargetPlatformData() {
+ return fTargetPlatformData;
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
index cfa10f1ae16..33d28d46255 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -13,19 +13,33 @@ package org.eclipse.cdt.managedbuilder.internal.core;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
import java.util.StringTokenizer;
import java.util.Vector;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
@@ -34,21 +48,27 @@ 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.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData;
+import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildfileMacroSubstitutor;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
+import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
+import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfoProvider;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
@@ -62,17 +82,13 @@ import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeSettings;
import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* Represents a tool that can be invoked during a build.
* Note that this class implements IOptionCategory to represent the top
* category.
*/
-public class Tool extends HoldsOptions implements ITool, IOptionCategory {
+public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatchKeyProvider {
public static final String DEFAULT_PATTERN = "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}"; //$NON-NLS-1$
public static final String DEFAULT_CBS_PATTERN = "${COMMAND}"; //$NON-NLS-1$
@@ -126,6 +142,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
private URL iconPathURL;
private IConfigurationElement pathconverterElement = null ;
private IOptionPathConverter optionPathConverter = null ;
+ private SupportedProperties supportedProperties;
+ private Boolean supportsManagedBuild;
+ private boolean isTest;
// Miscellaneous
private boolean isExtensionTool = false;
private boolean isDirty = false;
@@ -133,6 +152,71 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
private IConfigurationElement previousMbsVersionConversionElement = null;
private IConfigurationElement currentMbsVersionConversionElement = null;
private boolean rebuildState;
+ private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
+
+ private HashMap typeToDataMap = new HashMap();
+ private boolean fDataMapInited;
+ private List identicalList;
+ private HashMap scannerInfoMap;
+ private HashMap discoveredInfoMap = new HashMap();
+ private String scannerConfigDiscoveryProfileId;
+ private IScannerConfigBuilderInfo2 scannerConfigInfo;
+
+
+ interface IScannerConfigInfo {
+ String getProfileId();
+
+ IScannerConfigBuilderInfo2 getInfo2();
+ }
+
+ static class ScannerConfigInfo implements IScannerConfigInfo {
+ private String profileId;
+ private IScannerConfigBuilderInfo2 info2;
+
+ public ScannerConfigInfo(ICStorageElement el, InfoContext context){
+ profileId = el.getAttribute(IInputType.SCANNER_CONFIG_PROFILE_ID);
+
+ ICStorageElement children[] = el.getChildren();
+ for(int i = 0; i < children.length; i++){
+ if(IInputType.DISCOVERY_INFO.equals(children[i].getName())){
+ String defaultProfile = profileId;
+ if(defaultProfile == null)
+ defaultProfile = ScannerConfigProfileManager.NULL_PROFILE_ID;
+
+ ScannerConfigInfoFactory2.create(context, children[i], defaultProfile);
+ break;
+ }
+ }
+ }
+
+ public ScannerConfigInfo(IManagedConfigElement el, InfoContext context){
+ this(new ManagedConfigStorageElement(el), context);
+ }
+
+ public ScannerConfigInfo(String profileId, IScannerConfigBuilderInfo2 info2){
+ this.profileId = profileId;
+ this.info2 = info2;
+ }
+
+ public void serialize(ICStorageElement element){
+ if(profileId != null){
+ element.setAttribute(IInputType.SCANNER_CONFIG_PROFILE_ID, profileId);
+ }
+
+ if(info2 != null){
+ ICStorageElement el = element.createChild(IInputType.DISCOVERY_INFO);
+ ScannerConfigInfoFactory2.serialize(info2, el);
+ }
+ }
+
+ public IScannerConfigBuilderInfo2 getInfo2() {
+ return info2;
+ }
+
+ public String getProfileId() {
+ return profileId;
+ }
+ }
/*
* C O N S T R U C T O R S
@@ -162,6 +246,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// set up the category map
addOptionCategory(this);
+
+ IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
+ if(enablements.length > 0)
+ booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
+
// Load children
IManagedConfigElement[] toolElements = element.getChildren();
@@ -177,6 +266,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
addOutputType(outputType);
} else if (toolElement.getName().equals(IEnvVarBuildPath.BUILD_PATH_ELEMENT_NAME)){
addEnvVarBuildPath(new EnvVarBuildPath(this,toolElement));
+ } else if (toolElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
+ loadProperties(toolElement);
+ } else if(toolElement.getName().equals(IToolChain.DISCOVERY_INFO)){
+ ICStorageElement se = new ManagedConfigStorageElement(toolElement);
+ String profileId = getDiscoveryProfileId();
+ if(profileId == null)
+ profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(null), se, profileId);
}
}
}
@@ -218,6 +315,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
setName(name);
setVersion(getVersionFromId());
+ if(!superClass.isExtensionElement()){
+ ((Tool)superClass).updateScannerInfoSettingsToInputTypes();
+ }
+
isExtensionTool = isExtensionElement;
if (isExtensionElement) {
// Hook me up to the Managed Build Manager
@@ -252,6 +353,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
setVersion(getVersionFromId());
isExtensionTool = isExtensionElement;
+ if(superClass != null && !superClass.isExtensionElement()){
+ ((Tool)superClass).updateScannerInfoSettingsToInputTypes();
+ }
if (isExtensionElement) {
// Hook me up to the Managed Build Manager
ManagedBuildManager.addExtensionTool(this);
@@ -270,7 +374,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @param element The XML element that contains the tool settings.
* @param managedBuildRevision the fileVersion of Managed Build System
*/
- public Tool(IBuildObject parent, Element element, String managedBuildRevision) {
+ public Tool(IBuildObject parent, ICStorageElement element, String managedBuildRevision) {
super(resolvedDefault);
this.parent = parent;
isExtensionTool = false;
@@ -285,17 +389,22 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
addOptionCategory(this);
// Load children
- NodeList toolElements = element.getChildNodes();
- for (int i = 0; i < toolElements.getLength(); ++i) {
- Node toolElement = toolElements.item(i);
+ ICStorageElement toolElements[] = element.getChildren();
+ for (int i = 0; i < toolElements.length; ++i) {
+ ICStorageElement toolElement = toolElements[i];
if (loadChild(toolElement)) {
// do nothing
- } else if (toolElement.getNodeName().equals(ITool.INPUT_TYPE)) {
- InputType inputType = new InputType(this, (Element)toolElement);
+ } else if (toolElement.getName().equals(ITool.INPUT_TYPE)) {
+ InputType inputType = new InputType(this, toolElement);
addInputType(inputType);
- } else if (toolElement.getNodeName().equals(ITool.OUTPUT_TYPE)) {
- OutputType outputType = new OutputType(this, (Element)toolElement);
+ } else if (toolElement.getName().equals(ITool.OUTPUT_TYPE)) {
+ OutputType outputType = new OutputType(this, toolElement);
addOutputType(outputType);
+ } else if(toolElement.getName().equals(IToolChain.DISCOVERY_INFO)){
+ String profileId = getDiscoveryProfileId();
+ if(profileId == null)
+ profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, null), toolElement, profileId);
}
}
@@ -313,16 +422,22 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @param tool The existing tool to clone.
*/
public Tool(IBuildObject parent, ITool toolSuperClass, String Id, String name, Tool tool){
+ this(parent, toolSuperClass.getId(), Id, name, tool);
+
+ setSuperClassInternal(toolSuperClass);
+ }
+
+ public Tool(IBuildObject parent, String toolSuperClassId, String Id, String name, Tool tool){
super(resolvedDefault);
this.parent = parent;
- if (toolSuperClass != null) {
- setSuperClassInternal( toolSuperClass );
- } else {
- setSuperClassInternal( tool.getSuperClass() );
- }
- if (getSuperClass() != null) {
- superClassId = getSuperClass().getId();
- }
+// if (toolSuperClass != null) {
+// setSuperClassInternal( toolSuperClass );
+// } else {
+// setSuperClassInternal( tool.getSuperClass() );
+// }
+// if (getSuperClass() != null) {
+ superClassId = toolSuperClassId;//getSuperClass().getId();
+// }
setId(Id);
setName(name);
@@ -331,6 +446,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
setVersion(getVersionFromId());
isExtensionTool = false;
+ boolean copyIds = Id.equals(tool.id);
// Copy the remaining attributes
if(tool.versionsSupported != null) {
@@ -381,6 +497,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (tool.announcement != null) {
announcement = new String(tool.announcement);
}
+ supportsManagedBuild = tool.supportsManagedBuild;
+
commandLineGeneratorElement = tool.commandLineGeneratorElement;
commandLineGenerator = tool.commandLineGenerator;
@@ -392,6 +510,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if(tool.envVarBuildPathList != null)
envVarBuildPathList = new ArrayList(tool.envVarBuildPathList);
+ tool.updateScannerInfoSettingsToInputTypes();
+
// Clone the children in superclass
super.copyChildren(tool);
// Clone the children
@@ -403,6 +523,138 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
String subId;
String subName;
if (inputType.getSuperClass() != null) {
+ subId = copyIds ? inputType.id : inputType.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = inputType.getSuperClass().getName();
+ } else {
+ subId = copyIds ? inputType.id : inputType.getId() + "." + nnn; //$NON-NLS-1$
+ subName = inputType.getName();
+ }
+ InputType newInputType = new InputType(this, subId, subName, inputType);
+ addInputType(newInputType);
+ }
+ }
+ if (tool.outputTypeList != null) {
+ Iterator iter = tool.getOutputTypeList().listIterator();
+ while (iter.hasNext()) {
+ OutputType outputType = (OutputType) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (outputType.getSuperClass() != null) {
+ subId = copyIds ? outputType.id : outputType.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = outputType.getSuperClass().getName();
+ } else {
+ subId = copyIds ? outputType.id : outputType.getId() + "." + nnn; //$NON-NLS-1$
+ subName = outputType.getName();
+ }
+ OutputType newOutputType = new OutputType(this, subId, subName, outputType);
+ addOutputType(newOutputType);
+ }
+ }
+
+ // icon
+ if ( tool.iconPathURL != null ) {
+ iconPathURL = tool.iconPathURL;
+ }
+
+ if(copyIds){
+ isDirty = tool.isDirty;
+ rebuildState = tool.rebuildState;
+ } else{
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+
+ void copyNonoverriddenSettings(Tool tool){
+ if(name == null)
+ setName(tool.name);
+
+ // Set the managedBuildRevision & the version
+// setManagedBuildRevision(tool.getManagedBuildRevision());
+// setVersion(getVersionFromId());
+
+ // Copy the remaining attributes
+ if(versionsSupported == null) {
+ versionsSupported = tool.versionsSupported;
+ }
+ if(convertToId == null) {
+ convertToId = tool.convertToId;
+ }
+ if (unusedChildren == null) {
+ unusedChildren = tool.unusedChildren;
+ }
+ if (errorParserIds == null) {
+ errorParserIds = tool.errorParserIds;
+ }
+ if (isAbstract == null) {
+ isAbstract = tool.isAbstract;
+ }
+ if (command == null) {
+ command = tool.command;
+ }
+ if (commandLinePattern == null) {
+ commandLinePattern = tool.commandLinePattern;
+ }
+ if (inputExtensions == null && tool.inputExtensions != null) {
+ inputExtensions = new ArrayList(tool.inputExtensions);
+ }
+ if (interfaceExtensions == null && tool.interfaceExtensions != null) {
+ interfaceExtensions = new ArrayList(tool.interfaceExtensions);
+ }
+ if (natureFilter == null) {
+ natureFilter = tool.natureFilter;
+ }
+ if (outputExtensions == null) {
+ outputExtensions = tool.outputExtensions;
+ }
+ if (outputFlag == null) {
+ outputFlag = tool.outputFlag;
+ }
+ if (outputPrefix == null) {
+ outputPrefix = tool.outputPrefix;
+ }
+ if (advancedInputCategory == null) {
+ advancedInputCategory = tool.advancedInputCategory;
+ }
+ if (customBuildStep == null) {
+ customBuildStep = tool.customBuildStep;
+ }
+ if (announcement == null) {
+ announcement = tool.announcement;
+ }
+
+ if(supportsManagedBuild == null)
+ supportsManagedBuild = tool.supportsManagedBuild;
+
+
+ if(commandLineGeneratorElement == null)
+ commandLineGeneratorElement = tool.commandLineGeneratorElement;
+ if(commandLineGenerator == null)
+ commandLineGenerator = tool.commandLineGenerator;
+ if(dependencyGeneratorElement == null)
+ dependencyGeneratorElement = tool.dependencyGeneratorElement;
+ if(dependencyGenerator == null)
+ dependencyGenerator = tool.dependencyGenerator;
+ if(pathconverterElement == null)
+ pathconverterElement = tool.pathconverterElement ;
+ if(optionPathConverter == null)
+ optionPathConverter = tool.optionPathConverter ;
+
+ if(envVarBuildPathList == null && tool.envVarBuildPathList != null)
+ envVarBuildPathList = new ArrayList(tool.envVarBuildPathList);
+
+ // Clone the children in superclass
+ super.copyNonoverriddenSettings(tool);
+ // Clone the children
+ if (inputTypeList == null && tool.inputTypeList != null) {
+ Iterator iter = tool.getInputTypeList().listIterator();
+ while (iter.hasNext()) {
+ InputType inputType = (InputType) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (inputType.getSuperClass() != null) {
subId = inputType.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
subName = inputType.getSuperClass().getName();
} else {
@@ -413,7 +665,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
addInputType(newInputType);
}
}
- if (tool.outputTypeList != null) {
+ if (outputTypeList == null && tool.outputTypeList != null) {
Iterator iter = tool.getOutputTypeList().listIterator();
while (iter.hasNext()) {
OutputType outputType = (OutputType) iter.next();
@@ -433,7 +685,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// icon
- if ( tool.iconPathURL != null ) {
+ if ( iconPathURL == null ) {
iconPathURL = tool.iconPathURL;
}
@@ -570,6 +822,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (pathconverterTypeName != null && element instanceof DefaultManagedConfigElement) {
pathconverterElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
+
+ String tmp = element.getAttribute(SUPPORTS_MANAGED_BUILD);
+ if(tmp != null)
+ supportsManagedBuild = Boolean.valueOf(tmp);
+
+ scannerConfigDiscoveryProfileId = element.getAttribute(IToolChain.SCANNER_CONFIG_PROFILE_ID);
+
+ tmp = element.getAttribute(IS_SYSTEM);
+ if(tmp != null)
+ isTest = Boolean.valueOf(tmp).booleanValue();
}
/* (non-Javadoc)
@@ -578,13 +840,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
*
* @param element An XML element containing the tool information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@@ -593,26 +855,26 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// superClass
superClassId = element.getAttribute(IProjectType.SUPERCLASS);
- if (superClassId != null && superClassId.length() > 0) {
- if( getParent() instanceof IResourceConfiguration ) {
- IResourceConfiguration resConfig = (IResourceConfiguration) getParent();
- setSuperClassInternal( resConfig.getParent().getTool(superClassId) );
- } else {
- setSuperClassInternal( ManagedBuildManager.getExtensionTool(superClassId) );
- }
-
- // Check for migration support
- checkForMigrationSupport();
-
- }
+// if (superClassId != null && superClassId.length() > 0) {
+// if( getParent() instanceof IResourceConfiguration ) {
+// IResourceConfiguration resConfig = (IResourceConfiguration) getParent();
+// setSuperClassInternal( resConfig.getParent().getTool(superClassId) );
+// } else {
+// setSuperClassInternal( ManagedBuildManager.getExtensionTool(superClassId) );
+// }
+//
+// // Check for migration support
+// checkForMigrationSupport();
+//
+// }
// Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) {
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
}
// isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ if (element.getAttribute(IProjectType.IS_ABSTRACT) != null) {
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
if (isAbs != null){
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
@@ -620,22 +882,22 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// Get the 'versionSupported' attribute
- if (element.hasAttribute(VERSIONS_SUPPORTED)) {
+ if (element.getAttribute(VERSIONS_SUPPORTED) != null) {
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
}
// Get the 'convertToId' id
- if (element.hasAttribute(CONVERT_TO_ID)) {
+ if (element.getAttribute(CONVERT_TO_ID) != null) {
convertToId = element.getAttribute(CONVERT_TO_ID);
}
// Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(IToolChain.ERROR_PARSERS)) {
+ if (element.getAttribute(IToolChain.ERROR_PARSERS) != null) {
errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
}
// Get the nature filter
- if (element.hasAttribute(NATURE)) {
+ if (element.getAttribute(NATURE) != null) {
String nature = element.getAttribute(NATURE);
if (nature != null) {
if ("both".equals(nature)) { //$NON-NLS-1$
@@ -651,7 +913,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// Get the supported input file extension
- if (element.hasAttribute(ITool.SOURCES)) {
+ if (element.getAttribute(ITool.SOURCES) != null) {
String inputs = element.getAttribute(ITool.SOURCES);
if (inputs != null) {
StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
@@ -662,7 +924,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// Get the interface (header file) extensions
- if (element.hasAttribute(INTERFACE_EXTS)) {
+ if (element.getAttribute(INTERFACE_EXTS) != null) {
String headers = element.getAttribute(INTERFACE_EXTS);
if (headers != null) {
StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
@@ -673,32 +935,32 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// Get the output extension
- if (element.hasAttribute(ITool.OUTPUTS)) {
+ if (element.getAttribute(ITool.OUTPUTS) != null) {
outputExtensions = element.getAttribute(ITool.OUTPUTS);
}
// Get the tool invocation command
- if (element.hasAttribute(ITool.COMMAND)) {
+ if (element.getAttribute(ITool.COMMAND) != null) {
command = element.getAttribute(ITool.COMMAND);
}
// Get the flag to control output
- if (element.hasAttribute(ITool.OUTPUT_FLAG)) {
+ if (element.getAttribute(ITool.OUTPUT_FLAG) != null) {
outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
}
// Get the output prefix
- if (element.hasAttribute(ITool.OUTPUT_PREFIX)) {
+ if (element.getAttribute(ITool.OUTPUT_PREFIX) != null) {
outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
}
// Get command line pattern
- if( element.hasAttribute( ITool.COMMAND_LINE_PATTERN ) ) {
+ if( element.getAttribute( ITool.COMMAND_LINE_PATTERN ) != null) {
commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
}
// advancedInputCategory
- if (element.hasAttribute(ITool.ADVANCED_INPUT_CATEGORY)) {
+ if (element.getAttribute(ITool.ADVANCED_INPUT_CATEGORY) != null) {
String advInput = element.getAttribute(ITool.ADVANCED_INPUT_CATEGORY);
if (advInput != null){
advancedInputCategory = new Boolean("true".equals(advInput)); //$NON-NLS-1$
@@ -706,7 +968,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// customBuildStep
- if (element.hasAttribute(ITool.CUSTOM_BUILD_STEP)) {
+ if (element.getAttribute(ITool.CUSTOM_BUILD_STEP) != null) {
String cbs = element.getAttribute(ITool.CUSTOM_BUILD_STEP);
if (cbs != null){
customBuildStep = new Boolean("true".equals(cbs)); //$NON-NLS-1$
@@ -714,12 +976,12 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// Get the announcement text
- if (element.hasAttribute(ITool.ANNOUNCEMENT)) {
+ if (element.getAttribute(ITool.ANNOUNCEMENT) != null) {
announcement = element.getAttribute(ITool.ANNOUNCEMENT);
}
// icon - was saved as URL in string form
- if (element.hasAttribute(IOptionCategory.ICON)) {
+ if (element.getAttribute(IOptionCategory.ICON) != null) {
String iconPath = element.getAttribute(IOptionCategory.ICON);
try {
iconPathURL = new URL(iconPath);
@@ -730,6 +992,28 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
}
+ scannerConfigDiscoveryProfileId = element.getAttribute(IToolChain.SCANNER_CONFIG_PROFILE_ID);
+ }
+
+ void resolveProjectReferences(boolean onLoad){
+ if (superClassId != null && superClassId.length() > 0) {
+ ITool tool = ManagedBuildManager.getExtensionTool(superClassId);
+ if(tool == null){
+ Configuration cfg = (Configuration)getParentResourceInfo().getParent();
+ tool = cfg.findToolById(superClassId);
+ }
+ if(tool != null)
+ superClass = tool;
+
+ if(onLoad){
+ // Check for migration support
+ checkForMigrationSupport();
+ }
+ }
+ }
+
+ private void loadProperties(IManagedConfigElement el){
+ supportedProperties = new SupportedProperties(el);
}
/**
@@ -738,7 +1022,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
try {
if (getSuperClass() != null)
element.setAttribute(IProjectType.SUPERCLASS, getSuperClass().getId());
@@ -856,25 +1140,25 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
// Serialize elements from my super class
- super.serialize(doc, element);
+ super.serialize(element);
// Serialize my children
+ updateScannerInfoSettingsToInputTypes();
+
Iterator iter;
List typeElements = getInputTypeList();
iter = typeElements.listIterator();
while (iter.hasNext()) {
InputType type = (InputType) iter.next();
- Element typeElement = doc.createElement(INPUT_TYPE);
- element.appendChild(typeElement);
- type.serialize(doc, typeElement);
+ ICStorageElement typeElement = element.createChild(INPUT_TYPE);
+ type.serialize(typeElement);
}
typeElements = getOutputTypeList();
iter = typeElements.listIterator();
while (iter.hasNext()) {
OutputType type = (OutputType) iter.next();
- Element typeElement = doc.createElement(OUTPUT_TYPE);
- element.appendChild(typeElement);
- type.serialize(doc, typeElement);
+ ICStorageElement typeElement = element.createChild(OUTPUT_TYPE);
+ type.serialize(typeElement);
}
// Note: command line generator cannot be specified in a project file because
@@ -900,6 +1184,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// TODO: issue warning?
}
+ if(scannerConfigDiscoveryProfileId != null)
+ element.setAttribute(IToolChain.SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
+ if(scannerConfigInfo != null){
+ ICStorageElement cfgInfoEl = element.createChild(IToolChain.DISCOVERY_INFO);
+ ScannerConfigInfoFactory2.serialize(scannerConfigInfo, cfgInfoEl);
+ }
+
saveRebuildState();
// I am clean now
@@ -908,6 +1199,34 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// TODO: issue an error message
}
}
+
+ private void updateScannerInfoSettingsToInputTypes(){
+ if(isExtensionTool)
+ return;
+
+ HashMap scannerCfgMap = getScannerInfoMap(false);
+ if(scannerCfgMap != null){
+ scannerCfgMap = (HashMap)scannerCfgMap.clone();
+ for(Iterator iter = scannerCfgMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String id = (String)entry.getKey();
+ InputType type = (InputType)getInputTypeById(id);
+ if(type == null)
+ continue;
+
+ ScannerConfigInfoFactory2.BuildProperty info = (ScannerConfigInfoFactory2.BuildProperty)entry.getValue();
+ if(info.isDirty()){
+ if(type.isExtensionElement()){
+ type = (InputType)getEdtableInputType(type);
+ }
+ type.setScannerConfigBuilderInfo(info);
+ } else {
+ if(type.getScannerConfigBuilderInfoElement(false) != null)
+ type.setScannerConfigBuilderInfo(info);
+ }
+ }
+ }
+ }
/*
* P A R E N T A N D C H I L D H A N D L I N G
@@ -939,8 +1258,26 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
*/
public IInputType createInputType(IInputType superClass, String Id, String name, boolean isExtensionElement) {
InputType type = new InputType(this, superClass, Id, name, isExtensionElement);
+
+ if(superClass != null){
+ BuildLanguageData data = (BuildLanguageData)typeToDataMap.remove(superClass);
+ if(data != null){
+ data.updateInputType(type);
+ typeToDataMap.put(type, data);
+ }
+
+ HashMap scannerInfoMap = getScannerInfoMap(false);
+ if(scannerInfoMap != null){
+ IScannerConfigBuilderInfo2 info = (IScannerConfigBuilderInfo2)scannerInfoMap.get(getTypeKey(superClass));
+ if(info != null){
+ info = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, type), info, info.getSelectedProfileId());
+ scannerInfoMap.put(getTypeKey(type), info);
+ }
+ }
+ }
addInputType(type);
setDirty(true);
+
return type;
}
@@ -957,10 +1294,15 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @see org.eclipse.cdt.managedbuilder.core.ITool#getInputTypes()
*/
public IInputType[] getInputTypes() {
+ IInputType[] types = getAllInputTypes();
+ return filterInputTypes(types);
+ }
+
+ public IInputType[] getAllInputTypes() {
IInputType[] types = null;
// Merge our input types with our superclass' input types.
if (getSuperClass() != null) {
- types = getSuperClass().getInputTypes();
+ types = ((Tool)getSuperClass()).getAllInputTypes();
}
// Our options take precedence.
Vector ourTypes = getInputTypeList();
@@ -991,6 +1333,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
return types;
}
+
private boolean hasInputTypes() {
Vector ourTypes = getInputTypeList();
if (ourTypes.size() > 0) return true;
@@ -998,15 +1341,24 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
public IInputType getInputTypeById(String id) {
+ InputType type = (InputType)getAllInputTypeById(id);
+
+ if(isExtensionTool || type == null || type.isEnabled(this))
+ return type;
+ return null;
+ }
+
+ public IInputType getAllInputTypeById(String id) {
IInputType type = (IInputType)getInputTypeMap().get(id);
if (type == null) {
if (getSuperClass() != null) {
- return getSuperClass().getInputTypeById(id);
+ return ((Tool)getSuperClass()).getAllInputTypeById(id);
}
}
+
return type;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#createOutputType(IOutputType, String, String, boolean)
*/
@@ -1030,10 +1382,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputTypes()
*/
public IOutputType[] getOutputTypes() {
+ IOutputType[] types = getAllOutputTypes();
+
+ return filterOutputTypes(types);
+ }
+
+ public IOutputType[] getAllOutputTypes() {
IOutputType[] types = null;
// Merge our output types with our superclass' output types.
if (getSuperClass() != null) {
- types = getSuperClass().getOutputTypes();
+ types = ((Tool)getSuperClass()).getAllOutputTypes();
}
// Our options take precedence.
Vector ourTypes = getOutputTypeList();
@@ -1064,6 +1422,36 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
return types;
}
+ private IOutputType[] filterOutputTypes(IOutputType types[]){
+ if(isExtensionTool || types.length == 0)
+ return types;
+
+ List list = new ArrayList(types.length);
+ OutputType type;
+ for(int i = 0; i < types.length; i++){
+ type = (OutputType)types[i];
+ if(type.isEnabled(this))
+ list.add(type);
+ }
+
+ return (OutputType[])list.toArray(new OutputType[list.size()]);
+ }
+
+ private IInputType[] filterInputTypes(IInputType types[]){
+ if(isExtensionTool || types.length == 0)
+ return types;
+
+ List list = new ArrayList(types.length);
+ InputType type;
+ for(int i = 0; i < types.length; i++){
+ type = (InputType)types[i];
+ if(type.isEnabled(this))
+ list.add(type);
+ }
+
+ return (InputType[])list.toArray(new InputType[list.size()]);
+ }
+
private boolean hasOutputTypes() {
Vector ourTypes = getOutputTypeList();
if (ourTypes.size() > 0) return true;
@@ -1086,10 +1474,18 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
public IOutputType getOutputTypeById(String id) {
+ OutputType type = (OutputType)getAllOutputTypeById(id);
+
+ if(isExtensionTool || type == null || type.isEnabled(this))
+ return type;
+ return null;
+ }
+
+ public IOutputType getAllOutputTypeById(String id) {
IOutputType type = (IOutputType)getOutputTypeMap().get(id);
if (type == null) {
if (getSuperClass() != null) {
- return getSuperClass().getOutputTypeById(id);
+ return ((Tool)getSuperClass()).getAllOutputTypeById(id);
}
}
return type;
@@ -1137,9 +1533,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions()
*/
- public Object[][] getOptions(IResourceConfiguration resConfig, IHoldsOptions optionHolder) {
+ public Object[][] getOptions(IResourceInfo resInfo, IHoldsOptions optionHolder) {
if (optionHolder != this) return null;
- return getOptions(resConfig);
+ return getOptions(resInfo);
}
/* (non-Javadoc)
@@ -1149,7 +1545,12 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
ITool[] tools = resConfig.getTools();
return getOptions(tools);
}
-
+
+ public Object[][] getOptions(IResourceInfo resConfig) {
+ ITool[] tools = resConfig.getTools();
+ return getOptions(tools);
+ }
+
private Object[][] getOptions(ITool[] tools) {
ITool catTool = this;
ITool tool = null;
@@ -1377,6 +1778,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
return errorParsers;
}
+
+ public Set contributeErrorParsers(Set set){
+ if(set == null)
+ set = new HashSet();
+
+ String ids[] = getErrorParserList();
+ if(ids.length != 0)
+ set.addAll(Arrays.asList(ids));
+ return set;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions()
@@ -1451,11 +1862,34 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @see org.eclipse.cdt.managedbuilder.core.ITool#getAllInputExtensions()
*/
public String[] getAllInputExtensions() {
+// IInputType[] types = getInputTypes();
+// if (types != null && types.length > 0) {
+// List allExts = new ArrayList();
+// for (int i=0; i<types.length; i++) {
+// String[] exts = types[i].getSourceExtensions(this);
+// for (int j=0; j<exts.length; j++) {
+// allExts.add(exts[j]);
+// }
+// }
+// if (allExts.size() > 0) {
+// return (String[])allExts.toArray(new String[allExts.size()]);
+// }
+// }
+// // If none, use the input extensions specified for the Tool (backwards compatibility)
+// List extsList = getInputExtensionsAttribute();
+// if (extsList != null && extsList.size() > 0) {
+// return (String[])extsList.toArray(new String[extsList.size()]);
+// }
+// return EMPTY_STRING_ARRAY;
+ return getAllInputExtensions(getProject());
+ }
+
+ public String[] getAllInputExtensions(IProject project) {
IInputType[] types = getInputTypes();
if (types != null && types.length > 0) {
List allExts = new ArrayList();
for (int i=0; i<types.length; i++) {
- String[] exts = types[i].getSourceExtensions(this);
+ String[] exts = ((InputType)types[i]).getSourceExtensions(this, project);
for (int j=0; j<exts.length; j++) {
allExts.add(exts[j]);
}
@@ -1531,7 +1965,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES) {
List inputNames = (List)option.getValue();
for (int j=0; j<inputNames.size(); j++) {
inputs.add(Path.fromOSString((String)inputNames.get(j)));
@@ -1906,15 +2344,12 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
return natureFilter.intValue();
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getAllOutputExtensions()
- */
- public String[] getAllOutputExtensions() {
+ public String[] getAllOutputExtensions(IProject project) {
IOutputType[] types = getOutputTypes();
if (types != null && types.length > 0) {
List allExts = new ArrayList();
for (int i=0; i<types.length; i++) {
- String[] exts = types[i].getOutputExtensions(this);
+ String[] exts = ((OutputType)types[i]).getOutputExtensions(this, project);
if (exts != null) {
for (int j=0; j<exts.length; j++) {
allExts.add(exts[j]);
@@ -1934,6 +2369,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getAllOutputExtensions()
+ */
+ public String[] getAllOutputExtensions() {
+ return getAllOutputExtensions(getProject());
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputExtensions()
* @deprecated
*/
@@ -2145,7 +2587,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @throws BuildException
*/
public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation,
- IMacroSubstitutor macroSubstitutor) throws BuildException {
+ SupplierBasedCdtVariableSubstitutor macroSubstitutor,
+ IMacroContextInfoProvider provider) throws BuildException {
IOption[] opts = getOptions();
ArrayList flags = new ArrayList();
StringBuffer sb = new StringBuffer();
@@ -2185,57 +2628,77 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
break;
- case IOption.STRING :
- String strCmd = option.getCommand();
- String val = option.getStringValue();
- macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputFileLocation, outputFileLocation, option, this));
- if (val.length() > 0
- && (val = MacroResolver.resolveToString(val, macroSubstitutor)).length() > 0) {
- sb.append( evaluateCommand( strCmd, val ) );
+ case IOption.STRING :{
+ String strCmd = option.getCommand();
+ String val = option.getStringValue();
+ IMacroContextInfo info = provider.getMacroContextInfo(BuildMacroProvider.CONTEXT_FILE, new FileContextData(inputFileLocation, outputFileLocation, option, this));
+ if(info != null){
+ macroSubstitutor.setMacroContextInfo(info);
+ if (val.length() > 0
+ && (val = CdtVariableResolver.resolveToString(val, macroSubstitutor)).length() > 0) {
+ sb.append( evaluateCommand( strCmd, val ) );
+ }
+ }
}
break;
case IOption.STRING_LIST :
- String listCmd = option.getCommand();
- macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputFileLocation, outputFileLocation, option, this));
- String[] list = MacroResolver.resolveStringListValues(option.getStringListValue(), macroSubstitutor, true);
- if(list != null){
- for (int j = 0; j < list.length; j++) {
- String temp = list[j];
- if(temp.length() > 0)
- sb.append( evaluateCommand( listCmd, temp ) + WHITE_SPACE );
+ case IOption.INCLUDE_FILES :
+ case IOption.LIBRARY_PATHS :
+ case IOption.LIBRARY_FILES :
+ case IOption.MACRO_FILES :
+ {
+ String listCmd = option.getCommand();
+ IMacroContextInfo info = provider.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputFileLocation, outputFileLocation, option, this));
+ if(info != null){
+ macroSubstitutor.setMacroContextInfo(info);
+ String[] list = CdtVariableResolver.resolveStringListValues(option.getStringListValue(), macroSubstitutor, true);
+ if(list != null){
+ for (int j = 0; j < list.length; j++) {
+ String temp = list[j];
+ if(temp.length() > 0)
+ sb.append( evaluateCommand( listCmd, temp ) + WHITE_SPACE );
+ }
+ }
}
}
break;
- case IOption.INCLUDE_PATH :
+ case IOption.INCLUDE_PATH :{
String incCmd = option.getCommand();
- macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputFileLocation, outputFileLocation, option, this));
- String[] paths = MacroResolver.resolveStringListValues(option.getIncludePaths(), macroSubstitutor, true);
- if(paths != null){
- for (int j = 0; j < paths.length; j++) {
- String temp = paths[j];
- if(temp.length() > 0)
- sb.append( evaluateCommand( incCmd, temp ) + WHITE_SPACE);
+ IMacroContextInfo info = provider.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputFileLocation, outputFileLocation, option, this));
+ if(info != null) {
+ macroSubstitutor.setMacroContextInfo(info);
+ String[] paths = CdtVariableResolver.resolveStringListValues(option.getIncludePaths(), macroSubstitutor, true);
+ if(paths != null){
+ for (int j = 0; j < paths.length; j++) {
+ String temp = paths[j];
+ if(temp.length() > 0)
+ sb.append( evaluateCommand( incCmd, temp ) + WHITE_SPACE);
+ }
}
}
+ }
break;
- case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.PREPROCESSOR_SYMBOLS :{
String defCmd = option.getCommand();
- macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputFileLocation, outputFileLocation, option, this));
- String[] symbols = MacroResolver.resolveStringListValues(option.getDefinedSymbols(), macroSubstitutor, true);
- if(symbols != null){
- for (int j = 0; j < symbols.length; j++) {
- String temp = symbols[j];
- if(temp.length() > 0)
- sb.append( evaluateCommand( defCmd, temp ) + WHITE_SPACE);
+ IMacroContextInfo info = provider.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputFileLocation, outputFileLocation, option, this));
+ if(info != null){
+ macroSubstitutor.setMacroContextInfo(info);
+ String[] symbols = CdtVariableResolver.resolveStringListValues(option.getDefinedSymbols(), macroSubstitutor, true);
+ if(symbols != null){
+ for (int j = 0; j < symbols.length; j++) {
+ String temp = symbols[j];
+ if(temp.length() > 0)
+ sb.append( evaluateCommand( defCmd, temp ) + WHITE_SPACE);
+ }
}
}
+ }
break;
default :
@@ -2244,7 +2707,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (sb.toString().trim().length() > 0)
flags.add(sb.toString().trim());
- } catch (BuildMacroException e) {
+ } catch (CdtVariableException e) {
}
}
@@ -2257,8 +2720,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* @see org.eclipse.cdt.managedbuilder.core.ITool#getToolCommandFlags(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
*/
public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation) throws BuildException{
- IMacroSubstitutor macroSubstitutor = new BuildfileMacroSubstitutor(null,EMPTY_STRING,WHITE_SPACE);
- return getToolCommandFlags(inputFileLocation, outputFileLocation, macroSubstitutor );
+ SupplierBasedCdtVariableSubstitutor macroSubstitutor = new BuildfileMacroSubstitutor(null,EMPTY_STRING,WHITE_SPACE);
+ return getToolCommandFlags(inputFileLocation, outputFileLocation, macroSubstitutor, BuildMacroProvider.getDefault() );
}
/* (non-Javadoc)
@@ -2889,9 +3352,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
}
public String[] getContentTypeFileSpecs (IContentType type) {
+ return getContentTypeFileSpecs(type, getProject());
+ }
+
+ public String[] getContentTypeFileSpecs (IContentType type, IProject project) {
String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
IContentTypeSettings settings = null;
- IProject project = getProject();
+// IProject project = getProject();
if (project != null) {
IScopeContext projectScope = new ProjectScope(project);
try {
@@ -2978,4 +3445,635 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(needsRebuild()));
}
+ public CLanguageData getCLanguageData(IInputType type) {
+ initDataMap();
+ return (CLanguageData)typeToDataMap.get(type);
+ }
+
+ private void initDataMap(){
+ if(fDataMapInited)
+ return;
+
+ Collection types = getLanguageInputTypes();
+ if(types != null){
+ if(types.size() == 0){
+ CLanguageData data = (CLanguageData)typeToDataMap.get(null);
+ if(data == null){
+ data = new BuildLanguageData(this, null);
+ if(typeToDataMap.size() != 0){
+ typeToDataMap.clear();
+ }
+ typeToDataMap.put(null, data);
+ }
+ } else {
+ Map map = (Map)typeToDataMap.clone();
+ for(Iterator iter = types.iterator(); iter.hasNext();){
+ IInputType type = (IInputType)iter.next();
+ CLanguageData data = (CLanguageData)map.remove(type);
+ if(data == null){
+ data = new BuildLanguageData(this, type);
+ typeToDataMap.put(type, data);
+ }
+ }
+
+ if(map.size() > 0){
+ for(Iterator iter = map.keySet().iterator(); iter.hasNext();){
+ typeToDataMap.remove(iter.next());
+ }
+ }
+ }
+ }
+ fDataMapInited = true;
+ }
+
+ private boolean isLanguageInputType(IInputType type, boolean checkLangSettings){
+ boolean supports = type.getLanguageId(this) != null
+ || typeContributesToScannerConfig((InputType)type);
+
+ if(supports && checkLangSettings){
+ supports = supportsLanguageSettings();
+ }
+
+ return supports;
+ }
+
+ public boolean supportsLanguageSettings(){
+ IOption options[] = getOptions();
+ boolean found = false;
+ for(int i = 0; i < options.length; i++){
+ IOption option = options[i];
+ try {
+ int type = option.getValueType();
+ if(ManagedBuildManager.optionTypeToEntryKind(type) != 0){
+ found = true;
+ break;
+ }
+ } catch (BuildException e) {
+ }
+ }
+ return found;
+ }
+
+ private Collection getLanguageInputTypes(){
+ List list = new ArrayList();
+ IInputType types[] = getInputTypes();
+ for(int i = 0; i < types.length; i++){
+ InputType type = (InputType)types[i];
+ if(isLanguageInputType(type, false))
+ list.add(type);
+ }
+ if(list.size() == 0){
+ if(types.length == 1){
+ list.add(types[0]);
+ } else {
+ for(int i = 0; i < types.length; i++){
+ if(types[i].getPrimaryInput()){
+ list.add(types[i]);
+ break;
+ }
+ }
+ }
+ }
+
+ boolean found = supportsLanguageSettings();
+ if(!found)
+ return null;
+ return list;
+ }
+
+ public CLanguageData[] getCLanguageDatas() {
+ initDataMap();
+ return (CLanguageData[])typeToDataMap.values().toArray(new BuildLanguageData[typeToDataMap.size()]);
+ }
+
+ public IInputType getInputTypeForCLanguageData(CLanguageData data) {
+ if(data instanceof BuildLanguageData)
+ return ((BuildLanguageData)data).getInputType();
+ return null;
+ }
+
+ public IResourceInfo getParentResourceInfo() {
+ if(parent instanceof IFileInfo)
+ return (IResourceInfo)parent;
+ else if(parent instanceof IToolChain)
+ return ((IToolChain)parent).getParentFolderInfo();
+ return null;
+ }
+
+
+ public IInputType getEdtableInputType(IInputType base) {
+ if(base.getParent() == this)
+ return base;
+
+ IInputType extType = base;
+ for(;extType != null && !extType.isExtensionElement();extType = extType.getSuperClass());
+ String id;
+ if(extType != null){
+ id = ManagedBuildManager.calculateChildId(extType.getId(), null);
+ } else {
+ id = ManagedBuildManager.calculateChildId(getId(), null);
+ }
+ return createInputType(extType, id, base.getName(), false);
+ }
+
+ public boolean supportsType(IBuildPropertyType type) {
+ return supportsType(type.getId());
+ }
+
+ public boolean supportsType(String type) {
+ boolean suports = false;
+
+ SupportedProperties props = findSupportedProperties();
+ if(props != null) {
+ suports = props.supportsType(type);
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc != null){
+ suports = calc.referesProperty(type);
+ }
+
+ if(!suports)
+ suports = super.supportsType(type);
+ }
+ return suports;
+ }
+
+ public boolean supportsValue(String type, String value){
+ boolean suports = false;
+ SupportedProperties props = findSupportedProperties();
+ if(props != null) {
+ suports = props.supportsValue(type, value);
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc != null){
+ suports = calc.referesPropertyValue(type, value);
+ }
+
+ if(!suports)
+ suports = super.supportsValue(type, value);
+ }
+ return suports;
+ }
+
+ public boolean supportsValue(IBuildPropertyType type,
+ IBuildPropertyValue value) {
+ return supportsValue(type.getId(), value.getId());
+ }
+
+ public void propertiesChanged() {
+ if(isExtensionTool)
+ return;
+
+ BooleanExpressionApplicabilityCalculator calculator = getBooleanExpressionCalculator();
+ if(calculator != null)
+ calculator.adjustTool(getParentResourceInfo(), this, false);
+
+ super.propertiesChanged();
+ }
+
+ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
+ if(booleanExpressionCalculator == null){
+ if(superClass != null){
+ return ((Tool)superClass).getBooleanExpressionCalculator();
+ }
+ }
+ return booleanExpressionCalculator;
+ }
+
+ public boolean isEnabled() {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc == null)
+ return true;
+
+ return calc.isToolUsedInCommandLine(getParentResourceInfo(), this);
+ }
+
+ public boolean matches(ITool tool){
+ if(tool == this)
+ return true;
+
+ ITool rT = ManagedBuildManager.getRealTool(this);
+ if(rT == null)
+ return false;
+
+ return rT == ManagedBuildManager.getRealTool(tool);
+ }
+
+ boolean performMatchComparison(ITool tool){
+ if(tool == null)
+ return false;
+
+ if(tool == this)
+ return true;
+
+// if(tool.isReal() && isReal())
+// return false;
+// if(!tool.getToolCommand().equals(getToolCommand()))
+// return false;
+
+ if(!tool.getName().equals(getName()))
+ return false;
+
+ String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(tool.getId());
+ if(thisVersion == null || thisVersion.length() == 0){
+ if(otherVersion != null && otherVersion.length() != 0)
+ return false;
+ } else {
+ if(!thisVersion.equals(otherVersion))
+ return false;
+ }
+
+ return true;
+/* IOption options[] = getOptions();
+ IOption otherOptions[] = tool.getOptions();
+
+ if(!ListComparator.match(options,
+ otherOptions,
+ new Comparator(){
+ public boolean equal(Object o1, Object o2){
+ return ((Option)o1).matches((Option)o2);
+ }
+ }))
+ return false;
+
+ return true;
+ */
+ }
+
+/* public SupportedProperties getSupportedProperties(){
+ Map map = findSupportedProperties();
+ if(map != null)
+ return new HashMap(map);
+ return null;
+ }
+*/
+ private SupportedProperties findSupportedProperties(){
+ if(supportedProperties == null){
+ if(superClass != null){
+ return ((Tool)superClass).findSupportedProperties();
+ }
+ }
+ return supportedProperties;
+ }
+
+ public boolean supportsBuild(boolean managed){
+ if(supportsManagedBuild == null){
+ if(superClass != null){
+ return ((Tool)superClass).supportsBuild(managed);
+ }
+ return true;
+ }
+ return supportsManagedBuild.booleanValue();
+ }
+
+ private class MatchKey {
+ Tool tool;
+
+ public MatchKey(Tool tch) {
+ tool = tch;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+ if(!(obj instanceof MatchKey))
+ return false;
+ MatchKey other = (MatchKey)obj;
+ return tool.performMatchComparison(other.tool);
+ }
+
+ public int hashCode() {
+ String name = getName();
+ if(name == null)
+ name = getId();
+ int code = name.hashCode();
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null)
+ code += version.hashCode();
+ return code;
+ }
+
+ }
+
+ public Object getMatchKey() {
+ if(isAbstract())
+ return null;
+ if(!isExtensionTool)
+ return null;
+ return new MatchKey(this);
+ }
+
+ public void setIdenticalList(List list) {
+ identicalList = list;
+ }
+
+ public String getNameAndVersion(){
+ String name = getName();
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null && version.length() != 0){
+ return new StringBuffer().append(name).append(" (").append(version).append("").toString();
+ }
+ return name;
+ }
+
+ public IConfigurationElement getConverterModificationElement(ITool toTool){
+ Map map = ManagedBuildManager.getConversionElements(this);
+ IConfigurationElement element = null;
+ if(!map.isEmpty()){
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ IConfigurationElement el = (IConfigurationElement)iter.next();
+ String toId = el.getAttribute("toId"); //$NON-NLS-1$
+ ITool to = toTool;
+ if(toId != null){
+ for(;to != null; to = to.getSuperClass()){
+ if(toId.equals(to.getId()))
+ break;
+ }
+ }
+
+ if(to != null){
+ element = el;
+ break;
+ }
+ }
+ }
+
+ return element;
+ }
+
+ void updateParent(IBuildObject parent){
+ this.parent = parent;
+ }
+
+ public List getIdenticalList() {
+ return identicalList;
+ }
+
+ public String[] getRequiredTypeIds() {
+ SupportedProperties props = findSupportedProperties();
+ String[] required = null;
+ if(props != null) {
+ required = props.getRequiredTypeIds();
+ } else {
+ required = super.getRequiredTypeIds();
+ }
+ return required;
+ }
+
+ public String[] getSupportedTypeIds() {
+ SupportedProperties props = findSupportedProperties();
+ String[] supported = null;
+ if(props != null) {
+ supported = props.getSupportedTypeIds();
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ List list = new ArrayList();
+ if(calc != null){
+ list.addAll(Arrays.asList(calc.getReferencedPropertyIds()));
+ }
+
+ list.addAll(Arrays.asList(super.getSupportedTypeIds()));
+ supported = (String[])list.toArray(new String[list.size()]);
+ }
+ return supported;
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ SupportedProperties props = findSupportedProperties();
+ String[] supported = null;
+ if(props != null) {
+ supported = props.getSupportedValueIds(typeId);
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ List list = new ArrayList();
+ if(calc != null){
+ list.addAll(Arrays.asList(calc.getReferencedValueIds(typeId)));
+ }
+
+ list.addAll(Arrays.asList(super.getSupportedValueIds(typeId)));
+ supported = (String[])list.toArray(new String[list.size()]);
+ }
+ return supported;
+ }
+
+ public boolean requiresType(String typeId) {
+ SupportedProperties props = findSupportedProperties();
+ boolean required;
+ if(props != null) {
+ required = props.requiresType(typeId);
+ } else {
+ required = super.requiresType(typeId);
+ }
+ return required;
+ }
+
+ public void resetErrorParsers(){
+ errorParserIds = null;
+ }
+
+ void removeErrorParsers(Set set){
+ Set oldSet = contributeErrorParsers(null);
+ oldSet.removeAll(set);
+ setErrorParserList((String[])oldSet.toArray(new String[oldSet.size()]));
+ }
+
+ public void setErrorParserList(String[] ids) {
+ if(ids == null){
+ errorParserIds = null;
+ } else if(ids.length == 0){
+ errorParserIds = EMPTY_STRING;
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append(ids[0]);
+ for(int i = 1; i < ids.length; i++){
+ buf.append(";").append(ids[i]);
+ }
+ errorParserIds = buf.toString();
+ }
+ }
+
+ public boolean isSystemObject() {
+ if(isTest)
+ return true;
+ IBuildObject bo = getParent();
+ if(bo instanceof IToolChain)
+ return ((IToolChain)bo).isSystemObject();
+ return false;
+ }
+
+ public String getUniqueRealName() {
+ String name = getName();
+ if(name == null){
+ name = getId();
+ } else {
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null){
+ StringBuffer buf = new StringBuffer();
+ buf.append(name);
+ buf.append(" (v").append(version).append(")");
+ name = buf.toString();
+ }
+ }
+ return name;
+ }
+
+ public IScannerConfigBuilderInfo2 setScannerConfigInfo(IInputType type, IScannerConfigBuilderInfo2 info){
+ if(isExtensionTool)
+ return null;
+ InputType inType = (InputType)type;
+ HashMap map = getScannerInfoMap(true);
+ IScannerConfigBuilderInfo2 oldInfo = (IScannerConfigBuilderInfo2)map.put(getTypeKey(inType), info);
+ return oldInfo;
+ }
+
+ public IScannerConfigBuilderInfo2 getScannerConfigInfo(IInputType type){
+ if(isExtensionTool)
+ return null;
+ InputType inType = (InputType)type;
+ IScannerConfigBuilderInfo2 info = null;
+// if(inType.getParent() == this){
+// info = inType.getScannerConfigBuilderInfo();
+// }
+
+ if(info == null){
+ HashMap scannerInfoMap = getScannerInfoMap(true);
+ info = (IScannerConfigBuilderInfo2)scannerInfoMap.get(getTypeKey(inType));
+
+ if(info == null){
+ boolean create = inType != null ? inType.getDiscoveryProfileIdAttribute() != null : getDiscoveryProfileIdAttribute() != null;
+ if(create){
+ String id = inType != null ? inType.getDiscoveryProfileId(this) : null;
+ if(id == null)
+ id = ScannerConfigProfileManager.NULL_PROFILE_ID;
+ info = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, type), ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), id, false);
+ }
+ }
+ if(info != null)
+ scannerInfoMap.put(getTypeKey(inType), info);
+ }
+
+ return info;
+ }
+
+ private boolean typeContributesToScannerConfig(InputType inType){
+// InputType inType = (InputType)type;
+ if(inType.getScannerConfigBuilderInfo(this) != null)
+ return true;
+
+ if(inType.getDiscoveryProfileId(this) != null)
+ return true;
+
+ return false;
+ }
+
+ public boolean hasScannerConfigSettings(IInputType type){
+ if(type == null){
+ return hasScannerConfigSettings();
+ }
+ return ((InputType)type).hasScannerConfigSettings();
+ }
+
+ private boolean hasScannerConfigSettings(){
+ if(getScannerConfigBuilderInfoElement(true) != null)
+ return true;
+
+ if(getDiscoveryProfileIdAttribute() != null)
+ return true;
+
+ return false;
+ }
+
+ private HashMap getScannerInfoMap(boolean create){
+ if(scannerInfoMap == null && create && !isExtensionTool){
+ Collection types = getLanguageInputTypes();
+ scannerInfoMap = new HashMap();
+ if(types != null){
+ if(types.size() != 0){
+ for(Iterator iter = types.iterator(); iter.hasNext();){
+ InputType type = (InputType)iter.next();
+ IScannerConfigBuilderInfo2 info = type.getScannerConfigBuilderInfoElement(true);
+ if(info != null){
+ if(info != type.getScannerConfigBuilderInfoElement(false)){
+ info = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, type), info, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ }
+ scannerInfoMap.put(getTypeKey(type), info);
+ }
+ }
+ } else {
+
+ }
+ }
+ }
+ return scannerInfoMap;
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo setDiscoveredPathInfo(IInputType type, IDiscoveredPathManager.IDiscoveredPathInfo info){
+ return (IDiscoveredPathManager.IDiscoveredPathInfo)discoveredInfoMap.put(getTypeKey(type), info);
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo getDiscoveredPathInfo(IInputType type){
+ return (IDiscoveredPathManager.IDiscoveredPathInfo)discoveredInfoMap.get(getTypeKey(type));
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo clearDiscoveredPathInfo(IInputType type){
+ return (IDiscoveredPathManager.IDiscoveredPathInfo)discoveredInfoMap.remove(getTypeKey(type));
+ }
+
+ private Object getTypeKey(IInputType type){
+ if(type != null)
+ return type.getId();
+ return null;
+ }
+
+ public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfoElement(boolean searchSuper){
+ if(scannerConfigInfo == null){
+ if(superClass != null && searchSuper){
+ return ((Tool)superClass).getScannerConfigBuilderInfoElement(true);
+ }
+ return null;
+ }
+ return scannerConfigInfo;
+ }
+
+ IScannerConfigBuilderInfo2 getScannerConfigBuilderInfo(){
+ IScannerConfigBuilderInfo2 info = getScannerConfigBuilderInfoElement(true);
+ if(info == null){
+ IToolChain tc = getToolChain();
+ if(tc != null)
+ info = ((ToolChain)tc).getScannerConfigBuilderInfo();
+ }
+ return info;
+ }
+
+ public void setScannerConfigBuilderInfo(IScannerConfigBuilderInfo2 info){
+ scannerConfigInfo = info;
+ }
+
+ public String getDiscoveryProfileIdAttribute(){
+ if(scannerConfigDiscoveryProfileId == null && superClass != null)
+ return ((Tool)superClass).getDiscoveryProfileIdAttribute();
+ return scannerConfigDiscoveryProfileId;
+ }
+
+ private IToolChain getToolChain(){
+ IBuildObject bo = getParent();
+ IToolChain tCh = null;
+ if(bo instanceof IToolChain){
+ tCh = ((IToolChain)bo);
+ } else if(bo instanceof IFileInfo){
+ tCh = ((ResourceConfiguration)bo).getBaseToolChain();
+ }
+ return tCh;
+ }
+
+ public String getDiscoveryProfileId(){
+ String id = getDiscoveryProfileIdAttribute();
+ if(id == null){
+ IToolChain tc = getToolChain();
+ if(tc != null)
+ id = tc.getScannerConfigDiscoveryProfileId();
+ }
+ return id;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
index e3335f74ca7..55a01ffa408 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -11,31 +11,45 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
import java.util.StringTokenizer;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment;
-import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
+import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -43,12 +57,8 @@ import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-public class ToolChain extends HoldsOptions implements IToolChain {
+public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropertiesRestriction, IMatchKeyProvider {
private static final String EMPTY_STRING = new String();
@@ -62,7 +72,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
// to access it. This avoids widespread casts from IHoldsOptions to IToolChain.
private String superClassId;
// Parent and children
- private IConfiguration parent;
+ private IConfiguration config;
private List toolList;
private Map toolMap;
private TargetPlatform targetPlatform;
@@ -86,19 +96,34 @@ public class ToolChain extends HoldsOptions implements IToolChain {
private IConfigurationBuildMacroSupplier buildMacroSupplier = null;
private IConfigurationElement pathconverterElement = null ;
private IOptionPathConverter optionPathConverter = null ;
+ private Boolean supportsManagedBuild;
+ private boolean isTest;
+ private SupportedProperties supportedProperties;
+ private String nonInternalBuilderId;
// Miscellaneous
private boolean isExtensionToolChain = false;
private boolean isDirty = false;
private boolean resolved = resolvedDefault;
//holds the user-defined macros
- private StorableMacros userDefinedMacros;
+// private StorableMacros userDefinedMacros;
//holds user-defined macros
- private StorableEnvironment userDefinedEnvironment;
+// private StorableEnvironment userDefinedEnvironment;
private IConfigurationElement previousMbsVersionConversionElement = null;
private IConfigurationElement currentMbsVersionConversionElement = null;
private boolean rebuildState;
+ private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
+
+ private List identicalList;
+
+
+ private IFolderInfo parentFolderInfo;
+
+ private IScannerConfigBuilderInfo2 scannerConfigInfo;
+ private IDiscoveredPathManager.IDiscoveredPathInfo discoveredInfo;
+ private Boolean isRcTypeBasedDiscovery;
+
/*
* C O N S T R U C T O R S
@@ -114,17 +139,25 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* provider
* @param managedBuildRevision the fileVersion of Managed Build System
*/
- public ToolChain(IConfiguration parent, IManagedConfigElement element, String managedBuildRevision) {
+ public ToolChain(IFolderInfo folderInfo, IManagedConfigElement element, String managedBuildRevision) {
// setup for resolving
super(false);
resolved = false;
- this.parent = parent;
+ if(folderInfo != null){
+ this.config = folderInfo.getParent();
+ parentFolderInfo = folderInfo;
+ }
+
isExtensionToolChain = true;
// Set the managedBuildRevision
setManagedBuildRevision(managedBuildRevision);
-
+
+ IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
+ if(enablements.length > 0)
+ booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
+
loadFromManifest(element);
// Hook me up to the Managed Build Manager
@@ -159,6 +192,14 @@ public class ToolChain extends HoldsOptions implements IToolChain {
} else if (toolChainElement.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
Tool toolChild = new Tool(this, toolChainElement, managedBuildRevision);
addTool(toolChild);
+ } else if (toolChainElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
+ loadProperties(toolChainElement);
+ } else if(toolChainElement.getName().equals(DISCOVERY_INFO)){
+ ICStorageElement el = new ManagedConfigStorageElement(toolChainElement);
+ String profileId = getScannerConfigDiscoveryProfileId();
+ if(profileId == null)
+ profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(null), el, profileId);
}
}
}
@@ -173,11 +214,13 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* @param String The name for the new tool chain
* @param boolean Indicates whether this is an extension element or a managed project element
*/
- public ToolChain(Configuration parent, IToolChain superClass, String Id, String name, boolean isExtensionElement) {
+ public ToolChain(IFolderInfo folderInfo, IToolChain superClass, String Id, String name, boolean isExtensionElement) {
super(resolvedDefault);
- this.parent = parent;
+ this.config = folderInfo.getParent();
+ parentFolderInfo = folderInfo;
+
setSuperClassInternal(superClass);
- setManagedBuildRevision(parent.getManagedBuildRevision());
+ setManagedBuildRevision(config.getManagedBuildRevision());
if (getSuperClass() != null) {
superClassId = getSuperClass().getId();
@@ -204,9 +247,11 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* @param element The XML element that contains the tool-chain settings.
* @param managedBuildRevision the fileVersion of Managed Build System
*/
- public ToolChain(IConfiguration parent, Element element, String managedBuildRevision) {
+ public ToolChain(IFolderInfo folderInfo, ICStorageElement element, String managedBuildRevision) {
super(resolvedDefault);
- this.parent = parent;
+ this.config = folderInfo.getParent();
+ parentFolderInfo = folderInfo;
+
isExtensionToolChain = false;
// Set the managedBuildRevision
@@ -216,28 +261,33 @@ public class ToolChain extends HoldsOptions implements IToolChain {
loadFromProject(element);
// Load children
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
+ ICStorageElement configElements[] = element.getChildren();
+ for (int i = 0; i < configElements.length; ++i) {
+ ICStorageElement configElement = configElements[i];
if (loadChild(configElement)) {
// do nothing
- } else if (configElement.getNodeName().equals(ITool.TOOL_ELEMENT_NAME)) {
- Tool tool = new Tool(this, (Element)configElement, managedBuildRevision);
+ } else if (configElement.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
+ Tool tool = new Tool(this, configElement, managedBuildRevision);
addTool(tool);
- }else if (configElement.getNodeName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
+ }else if (configElement.getName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
if (targetPlatform != null) {
// TODO: report error
}
- targetPlatform = new TargetPlatform(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(IBuilder.BUILDER_ELEMENT_NAME)) {
+ targetPlatform = new TargetPlatform(this, configElement, managedBuildRevision);
+ }else if (configElement.getName().equals(IBuilder.BUILDER_ELEMENT_NAME)) {
if (builder != null) {
// TODO: report error
}
- builder = new Builder(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
+ builder = new Builder(this, configElement, managedBuildRevision);
+ }/*else if (configElement.getName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
//load user-defined macros
- userDefinedMacros = new StorableMacros((Element)configElement);
+ userDefinedMacros = new StorableMacros(configElement);
+ }*/else if(configElement.getName().equals(DISCOVERY_INFO)){
+ String profileId = getScannerConfigDiscoveryProfileId();
+ if(profileId == null)
+ profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), null, null), configElement, profileId);
}
}
@@ -253,9 +303,10 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* @param parent The <code>IConfiguration</code> the tool-chain will be added to.
* @param toolChain The existing tool-chain to clone.
*/
- public ToolChain(IConfiguration parent, String Id, String name, ToolChain toolChain) {
+ public ToolChain(IFolderInfo folderInfo, String Id, String name, Map superIdMap, ToolChain toolChain) {
super(resolvedDefault);
- this.parent = parent;
+ this.config = folderInfo.getParent();
+ parentFolderInfo = folderInfo;
setSuperClassInternal(toolChain.getSuperClass());
if (getSuperClass() != null) {
if (toolChain.superClassId != null) {
@@ -303,6 +354,14 @@ public class ToolChain extends HoldsOptions implements IToolChain {
if (toolChain.scannerConfigDiscoveryProfileId != null) {
scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId);
}
+
+ isRcTypeBasedDiscovery = toolChain.isRcTypeBasedDiscovery;
+ if(toolChain.scannerConfigInfo != null){
+ scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(folderInfo, null, null), toolChain.scannerConfigInfo, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ }
+
+ supportsManagedBuild = toolChain.supportsManagedBuild;
+
managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement;
managedIsToolChainSupported = toolChain.managedIsToolChainSupported;
@@ -315,7 +374,10 @@ public class ToolChain extends HoldsOptions implements IToolChain {
pathconverterElement = toolChain.pathconverterElement ;
optionPathConverter = toolChain.optionPathConverter ;
+ nonInternalBuilderId = toolChain.nonInternalBuilderId;
+
// Clone the children in superclass
+ boolean copyIds = toolChain.getId().equals(id);
super.copyChildren(toolChain);
// Clone the children
if (toolChain.builder != null) {
@@ -323,12 +385,12 @@ public class ToolChain extends HoldsOptions implements IToolChain {
String subName;
if (toolChain.builder.getSuperClass() != null) {
- subId = ManagedBuildManager.calculateChildId(
+ subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId(
toolChain.builder.getSuperClass().getId(),
null);
subName = toolChain.builder.getSuperClass().getName();
} else {
- subId = ManagedBuildManager.calculateChildId(
+ subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId(
toolChain.builder.getId(),
null);
subName = toolChain.builder.getName();
@@ -336,50 +398,130 @@ public class ToolChain extends HoldsOptions implements IToolChain {
builder = new Builder(this, subId, subName, toolChain.builder);
}
- if (toolChain.targetPlatform != null) {
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId;
- String subName;
- if (toolChain.targetPlatform.getSuperClass() != null) {
- subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
- subName = toolChain.targetPlatform.getSuperClass().getName();
- } else {
- subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
- subName = toolChain.targetPlatform.getName();
- }
- targetPlatform = new TargetPlatform(this, subId, subName, toolChain.targetPlatform);
+// if (toolChain.targetPlatform != null)
+ {
+ ITargetPlatform tpBase = toolChain.getTargetPlatform();
+ if(tpBase != null){
+ ITargetPlatform extTp = tpBase;
+ for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass());
+
+ String subId;
+ if(copyIds){
+ subId = tpBase != null ? tpBase.getId() : ManagedBuildManager.calculateChildId(getId(), null);
+ } else {
+ subId = extTp != null ? ManagedBuildManager.calculateChildId(extTp.getId(), null):
+ ManagedBuildManager.calculateChildId(getId(), null);
+ }
+ String subName = tpBase.getName();
+
+// if (toolChain.targetPlatform.getSuperClass() != null) {
+// subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+// subName = toolChain.targetPlatform.getSuperClass().getName();
+// } else {
+// subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
+// subName = toolChain.targetPlatform.getName();
+// }
+ targetPlatform = new TargetPlatform(this, subId, subName, (TargetPlatform)tpBase);
}
+//
+ }
+
+ IConfiguration cfg = parentFolderInfo.getParent();
if (toolChain.toolList != null) {
Iterator iter = toolChain.getToolList().listIterator();
while (iter.hasNext()) {
Tool toolChild = (Tool) iter.next();
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId;
- String tmpId;
+// int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = null;
+// String tmpId;
String subName;
- String version;
+// String version;
+ ITool extTool = ManagedBuildManager.getExtensionTool(toolChild);
+ Map curIdMap = (Map)superIdMap.get(folderInfo.getPath());
+ if(curIdMap != null){
+ if(extTool != null)
+ subId = (String)curIdMap.get(extTool.getId());
+ }
- if (toolChild.getSuperClass() != null) {
- tmpId = toolChild.getSuperClass().getId();
- subName = toolChild.getSuperClass().getName();
- } else {
- tmpId = toolChild.getId();
- subName = toolChild.getName();
+ subName = toolChild.getName();
+
+ if(subId == null){
+ if (extTool != null) {
+ subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(extTool.getId(), null);
+ // subName = toolChild.getSuperClass().getName();
+ } else {
+ subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(toolChild.getId(), null);
+ // subName = toolChild.getName();
+ }
}
- version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
- if ( version != null) { // If the 'tmpId' contains version information
- subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- subId = tmpId + "." + nnn; //$NON-NLS-1$
+// version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
+// if ( version != null) { // If the 'tmpId' contains version information
+// subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
+// } else {
+// subId = tmpId + "." + nnn; //$NON-NLS-1$
+// }
+
+ // The superclass for the cloned tool is not the same as the one from the tool being cloned.
+ // The superclasses reside in different configurations.
+ ITool toolSuperClass = null;
+ String superId = null;
+ // Search for the tool in this configuration that has the same grand-superClass as the
+ // tool being cloned
+ ITool otherSuperTool = toolChild.getSuperClass();
+ if(otherSuperTool != null){
+ if(otherSuperTool.isExtensionElement()){
+ toolSuperClass = otherSuperTool;
+ } else {
+ IResourceInfo otherRcInfo = otherSuperTool.getParentResourceInfo();
+ IResourceInfo thisRcInfo = cfg.getResourceInfo(otherRcInfo.getPath(), true);
+ ITool otherExtTool = ManagedBuildManager.getExtensionTool(otherSuperTool);
+ if(otherExtTool != null){
+ if(thisRcInfo != null){
+ ITool tools[] = thisRcInfo.getTools();
+ for(int i = 0; i < tools.length; i++){
+ ITool thisExtTool = ManagedBuildManager.getExtensionTool(tools[i]);
+ if(otherExtTool.equals(thisExtTool)){
+ toolSuperClass = tools[i];
+ superId = toolSuperClass.getId();
+ break;
+ }
+ }
+ } else {
+ superId = copyIds ? otherSuperTool.getId() : ManagedBuildManager.calculateChildId(otherExtTool.getId(), null);
+ Map idMap = (Map)superIdMap.get(otherRcInfo.getPath());
+ if(idMap == null){
+ idMap = new HashMap();
+ superIdMap.put(otherRcInfo.getPath(), idMap);
+ }
+ idMap.put(otherExtTool.getId(), superId);
+ }
+ }
+ }
}
+// Tool newTool = new Tool(this, (Tool)null, subId, subName, toolChild);
+// addTool(newTool);
+
+ Tool newTool = null;
+ if(toolSuperClass != null)
+ newTool = new Tool(this, toolSuperClass, subId, subName, toolChild);
+ else if(superId != null)
+ newTool = new Tool(this, superId, subId, subName, toolChild);
+ else{
+ //TODO: Error
+ }
+ if(newTool != null)
+ addTool(newTool);
- Tool newTool = new Tool(this, null, subId, subName, toolChild);
- addTool(newTool);
}
}
- setDirty(true);
- setRebuildState(true);
+ if(copyIds){
+ rebuildState = toolChain.rebuildState;
+ isDirty = toolChain.isDirty;
+ } else {
+ setDirty(true);
+ setRebuildState(true);
+ }
}
/*
@@ -427,6 +569,9 @@ public class ToolChain extends HoldsOptions implements IToolChain {
// Get the scanner config discovery profile id
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
+ String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
+ if(tmp != null)
+ isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
// Get the 'versionsSupported' attribute
versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
@@ -434,6 +579,15 @@ public class ToolChain extends HoldsOptions implements IToolChain {
// Get the 'convertToId' attribute
convertToId = element.getAttribute(CONVERT_TO_ID);
+ tmp = element.getAttribute(SUPPORTS_MANAGED_BUILD);
+ if(tmp != null)
+ supportsManagedBuild = Boolean.valueOf(tmp);
+
+ tmp = element.getAttribute(IS_SYSTEM);
+ if(tmp != null)
+ isTest = Boolean.valueOf(tmp).booleanValue();
+
+
// Get the comma-separated list of valid OS
String os = element.getAttribute(OS_LIST);
if (os != null) {
@@ -477,6 +631,8 @@ public class ToolChain extends HoldsOptions implements IToolChain {
if (pathconverterTypeName != null && element instanceof DefaultManagedConfigElement) {
pathconverterElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
+
+ nonInternalBuilderId = element.getAttribute(NON_INTERNAL_BUILDER_ID);
}
@@ -486,13 +642,13 @@ public class ToolChain extends HoldsOptions implements IToolChain {
*
* @param element An XML element containing the tool-chain information
*/
- protected void loadFromProject(Element element) {
+ protected void loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
- if (element.hasAttribute(IBuildObject.NAME)) {
+ if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@@ -508,12 +664,12 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
// Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) {
unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
}
// isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ if (element.getAttribute(IProjectType.IS_ABSTRACT) != null) {
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
if (isAbs != null){
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
@@ -521,37 +677,37 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
// Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(ERROR_PARSERS)) {
+ if (element.getAttribute(ERROR_PARSERS) != null) {
errorParserIds = element.getAttribute(ERROR_PARSERS);
}
// Get the semicolon separated list of IDs of the secondary outputs
- if (element.hasAttribute(SECONDARY_OUTPUTS)) {
+ if (element.getAttribute(SECONDARY_OUTPUTS) != null) {
secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS);
}
// Get the target tool id
- if (element.hasAttribute(TARGET_TOOL)) {
+ if (element.getAttribute(TARGET_TOOL) != null) {
targetToolIds = element.getAttribute(TARGET_TOOL);
}
// Get the scanner config discovery profile id
- if (element.hasAttribute(SCANNER_CONFIG_PROFILE_ID)) {
+ if (element.getAttribute(SCANNER_CONFIG_PROFILE_ID) != null) {
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
}
// Get the 'versionSupported' attribute
- if (element.hasAttribute(VERSIONS_SUPPORTED)) {
+ if (element.getAttribute(VERSIONS_SUPPORTED) != null) {
versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
}
// Get the 'convertToId' id
- if (element.hasAttribute(CONVERT_TO_ID)) {
+ if (element.getAttribute(CONVERT_TO_ID) != null) {
convertToId = element.getAttribute(CONVERT_TO_ID);
}
// Get the comma-separated list of valid OS
- if (element.hasAttribute(OS_LIST)) {
+ if (element.getAttribute(OS_LIST) != null) {
String os = element.getAttribute(OS_LIST);
if (os != null) {
osList = new ArrayList();
@@ -563,7 +719,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
// Get the comma-separated list of valid Architectures
- if (element.hasAttribute(ARCH_LIST)) {
+ if (element.getAttribute(ARCH_LIST) != null) {
String arch = element.getAttribute(ARCH_LIST);
if (arch != null) {
archList = new ArrayList();
@@ -580,7 +736,15 @@ public class ToolChain extends HoldsOptions implements IToolChain {
// TODO: issue warning?
}
+ // Get the scanner config discovery profile id
+ scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
+ String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
+ if(tmp != null)
+ isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
+ nonInternalBuilderId = element.getAttribute(NON_INTERNAL_BUILDER_ID);
+
+// String tmp = element.getAttribute(name)
}
/**
@@ -589,7 +753,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* @param doc
* @param element
*/
- public void serialize(Document doc, Element element) {
+ public void serialize(ICStorageElement element) {
try {
if (getSuperClass() != null)
element.setAttribute(IProjectType.SUPERCLASS, getSuperClass().getId());
@@ -661,26 +825,23 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
// Serialize elements from my super class
- super.serialize(doc, element);
+ super.serialize(element);
// Serialize my children
if (targetPlatform != null) {
- Element targetPlatformElement = doc.createElement(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
- element.appendChild(targetPlatformElement);
- targetPlatform.serialize(doc, targetPlatformElement);
+ ICStorageElement targetPlatformElement = element.createChild(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
+ targetPlatform.serialize(targetPlatformElement);
}
if (builder != null) {
- Element builderElement = doc.createElement(IBuilder.BUILDER_ELEMENT_NAME);
- element.appendChild(builderElement);
- builder.serialize(doc, builderElement);
+ ICStorageElement builderElement = element.createChild(IBuilder.BUILDER_ELEMENT_NAME);
+ builder.serialize(builderElement);
}
List toolElements = getToolList();
Iterator iter = toolElements.listIterator();
while (iter.hasNext()) {
Tool tool = (Tool) iter.next();
- Element toolElement = doc.createElement(ITool.TOOL_ELEMENT_NAME);
- element.appendChild(toolElement);
- tool.serialize(doc, toolElement);
+ ICStorageElement toolElement = element.createChild(ITool.TOOL_ELEMENT_NAME);
+ tool.serialize(toolElement);
}
// Note: isToolChainSupported cannot be specified in a project file because
@@ -702,21 +863,32 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
//serialize user-defined macros
- if(userDefinedMacros != null){
- Element macrosElement = doc.createElement(StorableMacros.MACROS_ELEMENT_NAME);
- element.appendChild(macrosElement);
- userDefinedMacros.serialize(doc,macrosElement);
+/* if(userDefinedMacros != null){
+ ICStorageElement macrosElement = element.createChild(StorableMacros.MACROS_ELEMENT_NAME);
+ userDefinedMacros.serialize(macrosElement);
}
-
+*/
// Note: optionPathConverter cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (pathconverterElement != null) {
// TODO: issue warning?
}
- if(userDefinedEnvironment != null)
- EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
+// if(userDefinedEnvironment != null)
+// EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
+
+ if(nonInternalBuilderId != null)
+ element.setAttribute(NON_INTERNAL_BUILDER_ID, nonInternalBuilderId);
+
+ if(scannerConfigDiscoveryProfileId != null)
+ element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
+ if(isRcTypeBasedDiscovery != null)
+ element.setAttribute(RESOURCE_TYPE_BASED_DISCOVERY, isRcTypeBasedDiscovery.toString());
+ if(scannerConfigInfo != null){
+ ICStorageElement cfgInfoEl = element.createChild(DISCOVERY_INFO);
+ ScannerConfigInfoFactory2.serialize(scannerConfigInfo, cfgInfoEl);
+ }
saveRebuildState();
// I am clean now
@@ -734,7 +906,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* @see org.eclipse.cdt.core.build.managed.IToolChain#getConfiguration()
*/
public IConfiguration getParent() {
- return parent;
+ return config;
}
/* (non-Javadoc)
@@ -775,6 +947,10 @@ public class ToolChain extends HoldsOptions implements IToolChain {
setDirty(true);
return (IBuilder)builder;
}
+
+ public void setBuilder(Builder builder){
+ this.builder = builder;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IToolChain#getBuilder()
@@ -806,15 +982,29 @@ public class ToolChain extends HoldsOptions implements IToolChain {
setDirty(true);
return (ITool)tool;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IToolChain#getTools()
*/
public ITool[] getTools() {
+ ITool tools[] = getAllTools();
+ if(!isExtensionToolChain){
+ for(int i = 0; i < tools.length; i++){
+ if(tools[i].isExtensionElement()){
+ String subId = ManagedBuildManager.calculateChildId(tools[i].getId(), null);
+ tools[i] = createTool(tools[i], subId, tools[i].getName(), false);
+ }
+ }
+ }
+
+ return tools;
+ }
+
+ public ITool[] getAllTools() {
ITool[] tools = null;
// Merge our tools with our superclass' tools
if (getSuperClass() != null) {
- tools = getSuperClass().getTools();
+ tools = ((ToolChain)getSuperClass()).getAllTools();
}
// Our tools take precedence
if (tools != null) {
@@ -823,11 +1013,22 @@ public class ToolChain extends HoldsOptions implements IToolChain {
Tool tool = (Tool)iter.next();
int j;
for (j = 0; j < tools.length; j++) {
- if (tool.getSuperClass() != null // Remove assumption that ALL tools must have superclasses
- && tool.getSuperClass().getId().equals(tools[j].getId())) {
- tools[j] = tool;
- break;
+ ITool superTool = tool.getSuperClass();
+ if(superTool != null){
+ if(!superTool.isExtensionElement())
+ superTool = superTool.getSuperClass();
+
+ if(superTool != null && superTool.getId().equals(tools[j].getId())){
+ tools[j] = tool;
+ break;
+ }
}
+
+// if (tool.getSuperClass() != null // Remove assumption that ALL tools must have superclasses
+// && tool.getSuperClass().getId().equals(tools[j].getId())) {
+// tools[j] = tool;
+// break;
+// }
}
// No Match? Insert it (may be re-ordered)
if (j == tools.length) {
@@ -915,6 +1116,11 @@ public class ToolChain extends HoldsOptions implements IToolChain {
getToolList().add(tool);
getToolMap().put(tool.getId(), tool);
}
+
+ public void removeTool(Tool tool){
+ getToolList().remove(tool);
+ getToolMap().remove(tool.getId());
+ }
/*
* M O D E L A T T R I B U T E A C C E S S O R S
@@ -1007,6 +1213,17 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
return ids;
}
+
+ public String getErrorParserIdsAttribute() {
+ String ids = errorParserIds;
+ if (ids == null) {
+ // If I have a superClass, ask it
+ if (getSuperClass() != null) {
+ ids = ((ToolChain)getSuperClass()).getErrorParserIdsAttribute();
+ }
+ }
+ return ids;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSecondaryOutputs()
@@ -1137,6 +1354,30 @@ public class ToolChain extends HoldsOptions implements IToolChain {
}
return errorParsers;
}
+
+ public Set contributeErrorParsers(FolderInfo info, Set set, boolean includeChildren){
+ if(set == null)
+ set = new HashSet();
+
+ String parserIDs = getErrorParserIdsAttribute();
+ if (parserIDs != null && parserIDs.length() != 0) {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ while (tok.hasMoreElements()) {
+ set.add(tok.nextToken());
+ }
+ }
+
+ if(includeChildren){
+ ITool tools[] = info.getFilteredTools();
+ info.contributeErrorParsers(tools, set);
+
+ if(info.isRoot()){
+ Builder builder = (Builder)getBuilder();
+ builder.contributeErrorParsers(set);
+ }
+ }
+ return set;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getArchList()
@@ -1321,11 +1562,11 @@ public class ToolChain extends HoldsOptions implements IToolChain {
if (isDirty) return true;
//check whether the tool-chain - specific macros are dirty
- if(userDefinedMacros != null && userDefinedMacros.isDirty())
- return true;
+// if(userDefinedMacros != null && userDefinedMacros.isDirty())
+// return true;
- if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
- return true;
+// if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
+// return true;
if(builder != null && builder.isDirty())
return true;
@@ -1546,7 +1787,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* this method is called by the UserDefinedMacroSupplier to obtain user-defined
* macros available for this tool-chain
*/
- public StorableMacros getUserDefinedMacros(){
+/* public StorableMacros getUserDefinedMacros(){
if(isExtensionToolChain)
return null;
@@ -1554,18 +1795,18 @@ public class ToolChain extends HoldsOptions implements IToolChain {
userDefinedMacros = new StorableMacros();
return userDefinedMacros;
}
+*/
+// public StorableEnvironment getUserDefinedEnvironment(){
+// if(isExtensionToolChain)
+// return null;
+//
+// return userDefinedEnvironment;
+// }
- public StorableEnvironment getUserDefinedEnvironment(){
- if(isExtensionToolChain)
- return null;
-
- return userDefinedEnvironment;
- }
-
- public void setUserDefinedEnvironment(StorableEnvironment env){
- if(!isExtensionToolChain)
- userDefinedEnvironment = env;
- }
+// public void setUserDefinedEnvironment(StorableEnvironment env){
+// if(!isExtensionToolChain)
+// userDefinedEnvironment = env;
+// }
/**
@@ -1809,6 +2050,13 @@ public class ToolChain extends HoldsOptions implements IToolChain {
public boolean needsRebuild() {
if(rebuildState)
return true;
+
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ if(tools[i].needsRebuild())
+ return true;
+ }
+
return super.needsRebuild();
}
@@ -1824,11 +2072,598 @@ public class ToolChain extends HoldsOptions implements IToolChain {
saveRebuildState();
}
- if(!rebuild)
- super.setRebuildState(rebuild);
+ if(!rebuild){
+ super.setRebuildState(false);
+
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ tools[i].setRebuildState(false);
+ }
+ }
}
private void saveRebuildState(){
+ if(((Configuration)config).isPreference())
+ return;
PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(needsRebuild()));
}
+
+ public IFolderInfo getParentFolderInfo() {
+ return parentFolderInfo;
+ }
+
+ void setTargetPlatform(TargetPlatform tp){
+ targetPlatform = tp;
+ }
+
+ public CTargetPlatformData getTargetPlatformData() {
+ if(isExtensionToolChain)
+ return null;
+ if(targetPlatform == null){
+ ITargetPlatform platform = getTargetPlatform();
+ if(platform != null){
+ ITargetPlatform extPlatform = platform;
+ for(;extPlatform != null && !extPlatform.isExtensionElement();
+ extPlatform = extPlatform.getSuperClass());
+ String subId;
+ if(extPlatform != null)
+ subId = ManagedBuildManager.calculateChildId(extPlatform.getId(), null);
+ else
+ subId = ManagedBuildManager.calculateChildId(getId(), null);
+
+ targetPlatform = new TargetPlatform(this, subId, platform.getName(), (TargetPlatform)extPlatform);
+ } else {
+ String subId = ManagedBuildManager.calculateChildId(getId(), null);
+ targetPlatform = new TargetPlatform(this, null, subId, "", false);
+ }
+ }
+
+ return targetPlatform.getTargetPlatformData();
+ }
+
+ public boolean supportsType(String type, boolean checkTools) {
+ SupportedProperties props = findSupportedProperties();
+ boolean supports = false;
+ if(props != null){
+ supports = props.supportsType(type);
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc != null){
+ supports = calc.referesProperty(type);
+ }
+
+ if(!supports)
+ supports = super.supportsType(type);
+ }
+ if(!supports && checkTools){
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ if(((Tool)tools[i]).supportsType(type)){
+ supports = true;
+ break;
+ }
+ }
+ }
+ return supports;
+ }
+
+ public boolean supportsType(String type) {
+ return supportsType(type, true);
+ }
+
+ public boolean supportsType(IBuildPropertyType type) {
+ return supportsType(type.getId());
+ }
+
+ public boolean supportsValue(String type, String value){
+ return supportsValue(type, value, true);
+ }
+
+ public boolean supportsValue(String type, String value, boolean checkTools){
+ SupportedProperties props = findSupportedProperties();
+ boolean supports = false;
+ if(props != null){
+ supports = props.supportsValue(type, value);
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc != null){
+ supports = calc.referesPropertyValue(type, value);
+ }
+
+ if(!supports)
+ supports = super.supportsValue(type, value);
+ }
+
+ if(!supports && checkTools){
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ if(((Tool)tools[i]).supportsValue(type, value)){
+ supports = true;
+ break;
+ }
+ }
+ }
+ return supports;
+ }
+
+ public boolean supportsValue(IBuildPropertyType type,
+ IBuildPropertyValue value) {
+ return supportsValue(type.getId(), value.getId());
+ }
+
+ public void propertiesChanged() {
+ if(isExtensionToolChain)
+ return;
+
+ BooleanExpressionApplicabilityCalculator calculator = getBooleanExpressionCalculator();
+ if(calculator != null)
+ calculator.adjustToolChain(getParentFolderInfo(), this, false);
+
+ super.propertiesChanged();
+ }
+
+ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
+ if(booleanExpressionCalculator == null){
+ if(superClass != null){
+ return ((ToolChain)superClass).getBooleanExpressionCalculator();
+ }
+ }
+ return booleanExpressionCalculator;
+ }
+
+ protected IResourceInfo getParentResourceInfo() {
+ return getParentFolderInfo();
+ }
+
+ public boolean matches(IToolChain tc){
+ if(tc == this)
+ return true;
+
+ IToolChain rTc = ManagedBuildManager.getRealToolChain(this);
+ if(rTc == null)
+ return false;
+
+ return rTc == ManagedBuildManager.getRealToolChain(tc);
+ }
+
+ private boolean performMatchCompatison(IToolChain tCh){
+ if(tCh == null)
+ return false;
+
+ if(tCh == this)
+ return true;
+
+// if(tCh.isReal() && isReal())
+// return false;
+
+ String name = tCh.getName();
+ if(name == null){
+ if(getName() != null)
+ return false;
+ } else if(!name.equals(getName())){
+ return false;
+ }
+
+ String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(tCh.getId());
+ if(thisVersion == null || thisVersion.length() == 0){
+ if(otherVersion != null && otherVersion.length() != 0)
+ return false;
+ } else {
+ if(!thisVersion.equals(otherVersion))
+ return false;
+ }
+
+ return true;
+
+// if(true)
+// return true;
+//
+// ITool tools[] = getTools();
+// ITool otherTools[] = tCh.getTools();
+//
+// if(tools.length != otherTools.length)
+// return false;
+//
+// if(!ListComparator.match(tools,
+// otherTools,
+// new Comparator(){
+// public boolean equal(Object o1, Object o2){
+// return ((Tool)o1).performMatchComparison((Tool)o2);
+// }
+// }))
+// return false;
+//
+// return true;
+ }
+
+ public List getIdenticalList(){
+ return identicalList;//;(ArrayList)identicalToolChainsList.clone();
+ }
+
+ public boolean supportsBuild(boolean managed) {
+ if(!getSupportsManagedBuildAttribute())
+ return !managed;
+
+ IBuilder builder = getBuilder();
+ if(builder != null && !builder.supportsBuild(managed))
+ return false;
+
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ if(!tools[i].supportsBuild(managed))
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean getSupportsManagedBuildAttribute(){
+ if(supportsManagedBuild == null){
+ if(superClass != null){
+ return ((ToolChain)superClass).getSupportsManagedBuildAttribute();
+ }
+ return true;
+ }
+ return supportsManagedBuild.booleanValue();
+ }
+
+ public boolean isSystemObject() {
+ if(isTest)
+ return true;
+
+ if(getParent() != null)
+ return getParent().isSystemObject();
+
+ return false;
+ }
+
+ private class MatchKey {
+ ToolChain toolChain;
+
+ public MatchKey(ToolChain tch) {
+ toolChain = tch;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+ if(!(obj instanceof MatchKey))
+ return false;
+ MatchKey other = (MatchKey)obj;
+ return toolChain.performMatchCompatison(other.toolChain);
+ }
+
+ public int hashCode() {
+ String name = getName();
+ if(name == null)
+ name = getId();
+ int code = name.hashCode();
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null)
+ code += version.hashCode();
+ return code;
+ }
+
+ }
+
+ public Object getMatchKey() {
+ if(isAbstract())
+ return null;
+ if(!isExtensionToolChain)
+ return null;
+ return new MatchKey(this);
+ }
+
+ public void setIdenticalList(List list) {
+ identicalList = list;
+ }
+
+ public String getNameAndVersion(){
+ String name = getName();
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null && version.length() != 0){
+ return new StringBuffer().append(name).append(" (").append(version).append("").toString();
+ }
+ return name;
+ }
+
+ public IConfigurationElement getConverterModificationElement(IToolChain tc){
+ Map map = ManagedBuildManager.getConversionElements(this);
+ IConfigurationElement element = null;
+ if(!map.isEmpty()){
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ IConfigurationElement el = (IConfigurationElement)iter.next();
+ String toId = el.getAttribute("toId"); //$NON-NLS-1$
+ IToolChain toTc = tc;
+ if(toId != null){
+ for(;toTc != null; toTc = toTc.getSuperClass()){
+ if(toId.equals(toTc.getId()))
+ break;
+ }
+ }
+
+ if(toTc != null){
+ element = el;
+ break;
+ }
+ }
+ }
+
+ return element;
+ }
+
+ public IConfigurationElement getConverterModificationElement(ITool fromTool, ITool toTool){
+ return ((Tool)fromTool).getConverterModificationElement(toTool);
+ }
+
+ void updateParentFolderInfo(FolderInfo info){
+ parentFolderInfo = info;
+ config = parentFolderInfo.getParent();
+ }
+
+ public String[] getRequiredTypeIds() {
+ return getRequiredTypeIds(true);
+ }
+
+ public String[] getRequiredTypeIds(boolean checkTools) {
+ SupportedProperties props = findSupportedProperties();
+ List result = new ArrayList();
+ if(props != null) {
+ result.addAll(Arrays.asList(props.getRequiredTypeIds()));
+ } else {
+// BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+// if(calc != null){
+// result.addAll(Arrays.asList(calc.getReferencedPropertyIds()));
+// }
+
+ result.addAll(Arrays.asList(super.getRequiredTypeIds()));
+ }
+
+ //call tools anyway
+ if(checkTools){
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ result.addAll(Arrays.asList(((Tool)tools[i]).getRequiredTypeIds()));
+ }
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public String[] getSupportedTypeIds() {
+ return getSupportedTypeIds(true);
+ }
+
+ public String[] getSupportedTypeIds(boolean checkTools) {
+ SupportedProperties props = findSupportedProperties();
+ List result = new ArrayList();
+ if(props != null) {
+ result.addAll(Arrays.asList(props.getSupportedTypeIds()));
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc != null){
+ result.addAll(Arrays.asList(calc.getReferencedPropertyIds()));
+ }
+
+ result.addAll(Arrays.asList(super.getSupportedTypeIds()));
+ }
+
+ //call tools anyway
+ if(checkTools){
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedTypeIds()));
+ }
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public String[] getSupportedValueIds(String typeId) {
+ return getSupportedValueIds(typeId, true);
+ }
+
+ public String[] getSupportedValueIds(String typeId, boolean checkTools) {
+ SupportedProperties props = findSupportedProperties();
+ List result = new ArrayList();
+ if(props != null) {
+ result.addAll(Arrays.asList(props.getSupportedValueIds(typeId)));
+ } else {
+ BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
+ if(calc != null){
+ result.addAll(Arrays.asList(calc.getReferencedValueIds(typeId)));
+ }
+
+ result.addAll(Arrays.asList(super.getSupportedValueIds(typeId)));
+ }
+
+ //call tools anyway
+ if(checkTools){
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedValueIds(typeId)));
+ }
+ }
+ return (String[])result.toArray(new String[result.size()]);
+ }
+
+ public boolean requiresType(String typeId) {
+ return requiresType(typeId, true);
+ }
+
+ public boolean requiresType(String typeId, boolean checkTools) {
+ SupportedProperties props = findSupportedProperties();
+ boolean required = false;
+ if(props != null) {
+ required = props.requiresType(typeId);
+ } else {
+ required = super.requiresType(typeId);
+ }
+
+ //call tools if not found
+ if(!required && checkTools){
+ ITool tools[] = getTools();
+ for(int i = 0; i < tools.length; i++){
+ if(((Tool)tools[i]).requiresType(typeId)){
+ required = true;
+ break;
+ }
+ }
+ }
+ return required;
+ }
+
+ private SupportedProperties findSupportedProperties(){
+ if(supportedProperties == null){
+ if(superClass != null){
+ return ((ToolChain)superClass).findSupportedProperties();
+ }
+ }
+ return supportedProperties;
+ }
+
+ private void loadProperties(IManagedConfigElement el){
+ supportedProperties = new SupportedProperties(el);
+ }
+
+ void setNonInternalBuilderId(String id){
+ nonInternalBuilderId = id;
+ }
+
+ String getNonInternalBuilderId(){
+ if(nonInternalBuilderId == null){
+ if(superClass != null){
+ return ((ToolChain)superClass).getNonInternalBuilderId();
+ }
+ return null;
+ }
+ return nonInternalBuilderId;
+ }
+
+ public void resetErrorParsers(FolderInfo info){
+ errorParserIds = null;
+ info.resetErrorParsers(info.getFilteredTools());
+
+ if(info.isRoot()){
+ if(builder != null){
+ builder.resetErrorParsers();
+ }
+ }
+ }
+
+ void removeErrorParsers(FolderInfo info, Set set){
+ Set oldSet = contributeErrorParsers(info, null, false);
+ oldSet.removeAll(set);
+ setErrorParserList((String[])oldSet.toArray(new String[oldSet.size()]));
+
+ info.removeErrorParsers(info.getFilteredTools(), set);
+
+
+ if(info.isRoot()){
+ Builder builder = (Builder)info.getParent().getEditableBuilder();
+ builder.removeErrorParsers(set);
+ }
+ }
+
+ public void setErrorParserList(String[] ids) {
+ if(ids == null){
+ errorParserIds = null;
+ } else if(ids.length == 0){
+ errorParserIds = EMPTY_STRING;
+ } else {
+ StringBuffer buf = new StringBuffer();
+ buf.append(ids[0]);
+ for(int i = 1; i < ids.length; i++){
+ buf.append(";").append(ids[i]);
+ }
+ errorParserIds = buf.toString();
+ }
+ }
+
+ public String getUniqueRealName() {
+ String name = getName();
+ if(name == null){
+ name = getId();
+ } else {
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
+ if(version != null){
+ StringBuffer buf = new StringBuffer();
+ buf.append(name);
+ buf.append(" (v").append(version).append(")");
+ name = buf.toString();
+ }
+ }
+ return name;
+ }
+
+ void resolveProjectReferences(boolean onLoad){
+ for(Iterator iter = getToolList().iterator(); iter.hasNext();){
+ Tool tool = (Tool)iter.next();
+ tool.resolveProjectReferences(onLoad);
+ }
+ }
+
+ public IScannerConfigBuilderInfo2 setScannerConfigBuilderInfo(IScannerConfigBuilderInfo2 info){
+ IScannerConfigBuilderInfo2 oldInfo = scannerConfigInfo;
+ scannerConfigInfo = info;
+ return oldInfo;
+ }
+
+ public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfoElement(boolean searchSuper){
+ if(scannerConfigInfo == null){
+ if(superClass != null && searchSuper){
+ return ((ToolChain)superClass).getScannerConfigBuilderInfoElement(true);
+ }
+ return null;
+ }
+ return scannerConfigInfo;
+ }
+
+ public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfo(){
+ return getScannerConfigBuilderInfoElement(true);
+ }
+
+ public boolean hasScannerConfigSettings(){
+ if(getScannerConfigBuilderInfoElement(true) != null)
+ return true;
+
+ if(getScannerConfigDiscoveryProfileId() != null)
+ return true;
+
+ return false;
+ }
+
+ public boolean isPerRcTypeDiscovery(){
+ if(isRcTypeBasedDiscovery == null){
+ if(superClass != null){
+ return ((ToolChain)superClass).isPerRcTypeDiscovery();
+ }
+ return true;
+ }
+ return isRcTypeBasedDiscovery.booleanValue();
+ }
+
+ public void setPerRcTypeDiscovery(boolean on){
+ isRcTypeBasedDiscovery = Boolean.valueOf(on);
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo setDiscoveredPathInfo(IDiscoveredPathManager.IDiscoveredPathInfo info){
+ IDiscoveredPathManager.IDiscoveredPathInfo oldInfo = discoveredInfo;
+ discoveredInfo = info;
+ return oldInfo;
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo getDiscoveredPathInfo(){
+ return discoveredInfo;
+ }
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo clearDiscoveredPathInfo(){
+ IDiscoveredPathManager.IDiscoveredPathInfo oldInfo = discoveredInfo;
+ discoveredInfo = null;
+ return oldInfo;
+ }
+
+ public boolean isPreferenceToolChain(){
+ IToolChain tch = ManagedBuildManager.getRealToolChain(this);
+ return tch != null && tch.getId().equals(ConfigurationDataProvider.PREF_TC_ID);
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
index 44c91b81adc..075eb593a51 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -15,24 +15,26 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
+import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
-import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -1275,6 +1277,52 @@ public class ToolReference implements IToolReference {
}
return null;
}
-
-
+
+ public CLanguageData getCLanguageData(IInputType type) {
+ return null;
+ }
+
+ public CLanguageData[] getCLanguageDatas() {
+ return new CLanguageData[0];
+ }
+
+ public IInputType getInputTypeForCLanguageData(CLanguageData data) {
+ return null;
+ }
+
+ public IResourceInfo getParentResourceInfo() {
+ return null;
+ }
+
+ public IInputType getEdtableInputType(IInputType base) {
+ return null;
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public boolean isReal() {
+ return false;
+ }
+
+ public boolean supportsManagedBuild() {
+ return true;
+ }
+
+ public boolean supportsBuild(boolean managed) {
+ return true;
+ }
+
+ public boolean matches(ITool tool) {
+ return false;
+ }
+
+ public boolean isSystemObject() {
+ return false;
+ }
+
+ public String getUniqueRealName() {
+ return getName();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java
new file mode 100644
index 00000000000..f0fc943c5e4
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.settings.model.COutputEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Builder;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+
+public class BuildBuildData extends CBuildData {
+ private Builder fBuilder;
+ private Configuration fCfg;
+ private BuildEnvironmentContributor fEnvContibutor;
+ public BuildBuildData(IBuilder builder){
+ fBuilder = (Builder)builder;
+ fCfg = (Configuration)fBuilder.getParent().getParent();
+ }
+
+ public IPath getBuilderCWD() {
+ return new Path(fBuilder.getBuildPath());//ManagedBuildManager.getBuildLocation(fCfg, fBuilder);
+ }
+
+ private IPath createAbsolutePathFromWorkspacePath(IPath path){
+ IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
+ String locationString = mngr.generateVariableExpression("workspace_loc", path.toString());
+ return new Path(locationString);
+ }
+
+ public String[] getErrorParserIDs() {
+ return fCfg.getErrorParserList();
+ }
+
+ public ICOutputEntry[] getOutputDirectories() {
+ return fBuilder.getOutputEntries();
+ }
+
+ public void setBuilderCWD(IPath path) {
+ fBuilder.setBuildPath(path.toString());
+ }
+
+ public void setErrorParserIDs(String[] ids) {
+ fCfg.setErrorParserList(ids);
+ }
+
+ public void setOutputDirectories(ICOutputEntry[] entries) {
+ fBuilder.setOutputEntries(entries);
+ }
+
+ public String getId() {
+ return fBuilder.getId();
+ }
+
+ public String getName() {
+ return fBuilder.getName();
+ }
+
+ public boolean isValid() {
+ return fBuilder != null;
+ }
+
+ public void setName(String name) {
+ //TODO
+ }
+
+ public IEnvironmentContributor getBuildEnvironmentContributor() {
+ if(fEnvContibutor == null)
+ fEnvContibutor = new BuildEnvironmentContributor(this);
+ return fEnvContibutor;
+ }
+
+ public IBuilder getBuilder(){
+ return fBuilder;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java
new file mode 100644
index 00000000000..714c411074c
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public class BuildConfigurationData extends CConfigurationData {
+ private IConfiguration fCfg;
+ private BuildVariablesContributor fCdtVars;
+ public BuildConfigurationData(IConfiguration cfg){
+ fCfg = cfg;
+ }
+
+ public IConfiguration getConfiguration(){
+ return fCfg;
+ }
+
+ public CFileData createFileData(IPath path, CFileData base)
+ throws CoreException {
+ String id = ManagedBuildManager.calculateChildId(fCfg.getId(),null);
+ IFileInfo info = fCfg.createFileInfo(path, ((BuildFileData)base).getFileInfo(), id, path.lastSegment());
+ return info.getFileData();
+ }
+
+ public CFileData createFileData(IPath path, CFolderData base, CLanguageData baseLangData)
+ throws CoreException {
+ String id = ManagedBuildManager.calculateChildId(fCfg.getId(),null);
+ ITool baseTool;
+ if(baseLangData instanceof BuildLanguageData){
+ baseTool = ((BuildLanguageData)baseLangData).getTool();
+ } else {
+ baseTool = null;
+ }
+ IFileInfo info = fCfg.createFileInfo(path, ((BuildFolderData)base).getFolderInfo(), baseTool, id, path.lastSegment());
+ return info.getFileData();
+ }
+
+
+
+ public CFolderData createFolderData(IPath path, CFolderData base)
+ throws CoreException {
+ String id = ManagedBuildManager.calculateChildId(fCfg.getId(),null);
+ IFolderInfo folderInfo = fCfg.createFolderInfo(path, ((BuildFolderData)base).getFolderInfo(), id, base.getName());
+ return folderInfo.getFolderData();
+ }
+
+ public String getDescription() {
+ return fCfg.getDescription();
+ }
+
+ public CResourceData[] getResourceDatas() {
+ IResourceInfo infos[] = fCfg.getResourceInfos();
+ CResourceData datas[] = new CResourceData[infos.length];
+ for(int i = 0; i < infos.length; i++){
+ datas[i] = infos[i].getResourceData();
+ }
+ return datas;
+ }
+
+ public CFolderData getRootFolderData() {
+ return fCfg.getRootFolderInfo().getFolderData();
+ }
+
+ public void removeResourceData(CResourceData data) throws CoreException {
+ fCfg.removeResourceInfo(data.getPath());
+ }
+
+ public void setDescription(String description) {
+ fCfg.setDescription(description);
+ }
+
+ public String getId() {
+ return fCfg.getId();
+ }
+
+ public String getName() {
+ return fCfg.getName();
+ }
+
+ public void setName(String name) {
+ fCfg.setName(name);
+ }
+
+ public boolean isValid() {
+ return fCfg != null;
+ }
+
+ public CTargetPlatformData getTargetPlatformData() {
+ return fCfg.getToolChain().getTargetPlatformData();
+ }
+
+ public IPath[] getSourcePaths() {
+ return fCfg.getSourcePaths();
+ }
+
+ public void setSourcePaths(IPath[] paths) {
+ fCfg.setSourcePaths(paths);
+ }
+
+ public CBuildData getBuildData() {
+ return fCfg.getBuildData();
+ }
+
+ public ICdtVariablesContributor getBuildVariablesContributor() {
+ if(fCdtVars == null)
+ fCdtVars = new BuildVariablesContributor(this);
+ return fCdtVars;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEnvironmentContributor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEnvironmentContributor.java
new file mode 100644
index 00000000000..26430564861
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEnvironmentContributor.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.internal.envvar.ExternalExtensionEnvironmentSupplier;
+import org.eclipse.cdt.managedbuilder.internal.envvar.MbsEnvironmentSupplier;
+import org.eclipse.cdt.utils.envvar.EnvironmentCollector;
+
+public class BuildEnvironmentContributor implements IEnvironmentContributor {
+ private BuildBuildData fBuildData;
+ private IConfiguration fCfg;
+
+ private MbsEnvironmentSupplier fMbsSupplier = new MbsEnvironmentSupplier();
+
+ public BuildEnvironmentContributor(BuildBuildData buildData){
+ fBuildData = buildData;
+ fCfg = fBuildData.getBuilder().getParent().getParent();
+ }
+
+ public IEnvironmentVariable getVariable(String name,
+ IEnvironmentVariableManager provider) {
+
+ EnvironmentCollector collector = new EnvironmentCollector();
+ IEnvironmentVariable result = null;
+ ExternalExtensionEnvironmentSupplier extSupplier = new ExternalExtensionEnvironmentSupplier(provider);
+
+ IEnvironmentVariable var = extSupplier.getVariable(name, fCfg.getManagedProject());
+ if(var != null)
+ result = collector.addVariable(var);
+
+ var = fMbsSupplier.getVariable(name, fCfg);
+ if(var != null)
+ result = collector.addVariable(var);
+
+ var = extSupplier.getVariable(name, fCfg);
+ if(var != null)
+ result = collector.addVariable(var);
+ return result;
+ }
+
+ public IEnvironmentVariable[] getVariables(
+ IEnvironmentVariableManager provider) {
+ EnvironmentCollector collector = new EnvironmentCollector();
+ ExternalExtensionEnvironmentSupplier extSupplier = new ExternalExtensionEnvironmentSupplier(provider);
+
+ IEnvironmentVariable vars[] = extSupplier.getVariables(fCfg.getManagedProject());
+ if(vars != null && vars.length != 0)
+ collector.addVariables(vars);
+
+ vars = fMbsSupplier.getVariables(fCfg);
+ if(vars != null && vars.length != 0)
+ collector.addVariables(vars);
+
+ vars = extSupplier.getVariables(fCfg);
+ if(vars != null && vars.length != 0)
+ collector.addVariables(vars);
+ return collector.getVariables();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFileData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFileData.java
new file mode 100644
index 00000000000..7154b514248
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFileData.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.core.runtime.IPath;
+
+public class BuildFileData extends CFileData {
+ private IFileInfo fFileInfo;
+ public BuildFileData(IFileInfo fileInfo){
+ fFileInfo = fileInfo;
+ }
+
+ public IFileInfo getFileInfo(){
+ return fFileInfo;
+ }
+
+ public IPath getPath() {
+ return fFileInfo.getPath();
+ }
+
+ public boolean isExcluded() {
+ return fFileInfo.isExcluded();
+ }
+
+ public void setExcluded(boolean excluded) {
+ fFileInfo.setExclude(excluded);
+ }
+
+ public void setPath(IPath path) {
+ fFileInfo.setPath(path);
+ }
+
+ public String getId() {
+ return fFileInfo.getId();
+ }
+
+ public String getName() {
+ return fFileInfo.getName();
+ }
+
+ public void setName(String name) {
+// fFileInfo.setN
+ }
+
+ public boolean isValid() {
+ return fFileInfo.isValid();
+ }
+
+ public CLanguageData getLanguageData() {
+ CLanguageData datas[] = fFileInfo.getCLanguageDatas();
+ if(datas.length > 0)
+ return datas[0];
+ return null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFolderData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFolderData.java
new file mode 100644
index 00000000000..f545947cd8d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildFolderData.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.core.runtime.IPath;
+
+public class BuildFolderData extends CFolderData {
+ private IFolderInfo fFolderInfo;
+ public BuildFolderData(IFolderInfo folderInfo){
+ fFolderInfo = folderInfo;
+ }
+
+ public IFolderInfo getFolderInfo(){
+ return fFolderInfo;
+ }
+
+ public CLanguageData[] getLanguageDatas() {
+ return fFolderInfo.getCLanguageDatas();
+ }
+
+ public IPath getPath() {
+ return fFolderInfo.getPath();
+ }
+
+ public boolean isExcluded() {
+ return fFolderInfo.isExcluded();
+ }
+
+ public void setExcluded(boolean excluded) {
+ fFolderInfo.setExclude(excluded);
+ }
+
+ public void setPath(IPath path) {
+ fFolderInfo.setPath(path);
+ }
+
+ public String getId() {
+ return fFolderInfo.getId();
+ }
+
+ public String getName() {
+ return fFolderInfo.getName();
+ }
+
+ public void setName(String name) {
+ // TODO Auto-generated method stub
+ }
+
+ public boolean isValid() {
+ return fFolderInfo.isValid();
+ }
+
+ public CLanguageData createLanguageDataForContentTypes(String languageId,
+ String[] typesIds) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public CLanguageData createLanguageDataForExtensions(String languageId,
+ String[] extensions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java
new file mode 100644
index 00000000000..6c54be83b2f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildLanguageData.java
@@ -0,0 +1,453 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.IKindBasedInfo;
+import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.InputType;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProfileInfoProvider.DiscoveredEntry;
+
+public class BuildLanguageData extends CLanguageData {
+ private ITool fTool;
+ private IInputType fInputType;
+ private KindBasedStore fKindToOptionArrayStore = new KindBasedStore();
+ private static final IOption[] EMPTY_OPTION_ARRAY = new IOption[0];
+ private boolean fOptionStoreInited;
+// private Map fKindToEntryArrayMap = new HashMap();
+ private ProfileInfoProvider fDiscoveredInfo;
+ private KindBasedStore fKindToEntryStore = new KindBasedStore();
+ private String fId;
+
+
+ public BuildLanguageData(ITool tool, IInputType inType){
+ fTool = tool;
+ fInputType = inType;
+ if(inType != null){
+ IInputType extType = inType;
+ for(;extType != null && !extType.isExtensionElement(); extType = extType.getSuperClass());
+ String typeId;
+ if(extType != null)
+ typeId = extType.getId();
+ else
+ typeId = inType.getId();
+ fId = new StringBuffer(fTool.getId()).append(".").append(typeId).toString();
+ } else {
+ fId = new StringBuffer(fTool.getId()).append(".").append("languagedata").toString();
+ }
+
+ fDiscoveredInfo = new ProfileInfoProvider(this);
+ }
+
+ public void setEntries(int kind, ICLanguageSettingEntry entries[]) {
+ EntryStorage storage = getEntryStorage(kind);
+ if(storage != null)
+ storage.setEntries(entries);
+ }
+
+ private EntryStorage getEntryStorage(int kind){
+ if(getOptionsForKind(kind).length == 0 && isToolChainDiscoveryProfile())
+ return null;
+
+ EntryStorage starage = (EntryStorage)fKindToEntryStore.get(kind);
+ if(starage == null){
+ starage = new EntryStorage(kind, this);
+ fKindToEntryStore.put(kind, starage);
+ }
+ return starage;
+ }
+
+ private void optionsChanged(int kind, IOption option, Object oldValue){
+ fOptionStoreInited = false;
+ EntryStorage storage = getEntryStorage(kind);
+ if(storage != null)
+ storage.optionsChanged(option, oldValue);
+ }
+
+ public void optionChanged(IOption option, Object oldValue){
+ try {
+ int kind = ManagedBuildManager.optionTypeToEntryKind(option.getValueType());
+ if(kind != 0)
+ optionsChanged(kind, option, oldValue);
+ } catch (BuildException e) {
+ }
+ }
+
+ private ProfileInfoProvider getDiscoveredInfoProvider(){
+ return fDiscoveredInfo;
+ }
+/*
+ private String getOptionValueFromEntry(ICLanguageSettingEntry entry){
+ String optValue = entry.getName();
+ if(entry.getKind() == ICLanguageSettingEntry.MACRO){
+ String macroValue = entry.getValue();
+ StringBuffer buf = new StringBuffer(optValue).append('=').append(macroValue);
+ optValue = buf.toString();
+ }
+ return optValue;
+
+ }
+*/
+ public String getLanguageId() {
+ return fInputType != null ? fInputType.getLanguageId(fTool) : null;
+ }
+
+ public ICLanguageSettingEntry[] getEntries(int kinds) {
+ List list = new ArrayList();
+
+ if((kinds & ICLanguageSettingEntry.INCLUDE_PATH) != 0) {
+ EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.INCLUDE_PATH);
+ if(storage != null)
+ storage.getEntries(list);
+ } else if((kinds & ICLanguageSettingEntry.INCLUDE_FILE) != 0) {
+ EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.INCLUDE_FILE);
+ if(storage != null)
+ storage.getEntries(list);
+ } else if((kinds & ICLanguageSettingEntry.MACRO) != 0) {
+ EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.MACRO);
+ if(storage != null)
+ storage.getEntries(list);
+ } else if((kinds & ICLanguageSettingEntry.MACRO_FILE) != 0) {
+ EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.MACRO_FILE);
+ if(storage != null)
+ storage.getEntries(list);
+ } else if((kinds & ICLanguageSettingEntry.LIBRARY_PATH) != 0) {
+ EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.LIBRARY_PATH);
+ if(storage != null)
+ storage.getEntries(list);
+ } else if((kinds & ICLanguageSettingEntry.LIBRARY_FILE) != 0) {
+ EntryStorage storage = getEntryStorage(ICLanguageSettingEntry.LIBRARY_FILE);
+ if(storage != null)
+ storage.getEntries(list);
+ }
+
+ return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ }
+
+ public void updateInputType(IInputType type){
+ fInputType = type;
+ }
+
+ public String[] getSourceContentTypeIds() {
+ if(fInputType != null){
+ return fInputType.getSourceContentTypeIds();
+ }
+ return null;
+ }
+
+ public String[] getSourceExtensions() {
+ return fInputType != null ? fInputType.getSourceExtensions(fTool) : fTool.getPrimaryInputExtensions();
+ }
+/*
+ private List getUserEntryValues(int kind){
+ IOption options[] = getOptionsForKind(kind);
+ List valueList = new ArrayList();
+ for(int i = 0; i < options.length; i++){
+ IOption option = options[i];
+ List value = (List)option.getValue();
+ valueList.addAll(value);
+ }
+ return valueList;
+ }
+*/
+ DiscoveredEntry[] getDiscoveredEntryValues(int kind){
+ return getDiscoveredInfoProvider().getEntryValues(kind);
+ }
+/*
+ private List addLanguageEntries(int kind, List list){
+ ICLanguageSettingEntry entries[] = getLanguageEntries(kind);
+ for(int i = 0; i < entries.length; i++){
+ list.add(entries[i]);
+ }
+ return list;
+ }
+
+ private ICLanguageSettingEntry[] getLanguageEntries(int kind){
+ Integer iKind = new Integer(kind);
+ ICLanguageSettingEntry[] entries = (ICLanguageSettingEntry[])fKindToEntryArrayMap.get(iKind);
+ if(entries == null){
+ entries = calculateLanguageEntries(kind);
+ fKindToEntryArrayMap.put(iKind, entries);
+ }
+ return entries;
+ }
+
+ private ICLanguageSettingEntry[] calculateLanguageEntries(int kind){
+ List discoveredList = fDiscoveredInfo.getEntryValues(kind);
+ List optionValueList = getUserEntryValues(kind);
+ List entryList = new ArrayList();
+ if(discoveredList != null && optionValueList != null){
+ Set set = new HashSet();
+ if(optionValueList != null)
+ processValues(kind, optionValueList, false, entryList, set);
+ if(discoveredList != null)
+ processValues(kind, discoveredList, true, entryList, set);
+ }
+ return (ICLanguageSettingEntry[])entryList.toArray(new ICLanguageSettingEntry[entryList.size()]);
+ }
+
+ private List processValues(int kind, List valuesList, boolean discovered, List entriesList, Set processedValuesSet){
+ for(Iterator iter = valuesList.iterator(); iter.hasNext();){
+ String value = (String)iter.next();
+ if(processedValuesSet.add(value)){
+ ICLanguageSettingEntry entry = createEntry(kind, value, discovered);
+ if(entry != null)
+ entriesList.add(entry);
+ }
+ }
+ return entriesList;
+ }
+
+ private ICLanguageSettingEntry createEntry(int kind, String value, boolean discovered){
+ ICLanguageSettingEntry entry = null;
+ switch (kind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ entry = new CIncludePathEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
+ break;
+ case ICLanguageSettingEntry.MACRO:
+ int index = value.indexOf('=');
+ String macroName;
+ String macroValue;
+ if(index > 0){
+ macroName = value.substring(index);
+ macroValue = value.substring(index + 1, value.length());
+ } else {
+ macroName = value;
+ macroValue = EMPTY_STRING;
+ }
+ entry = new CMacroEntry(macroName, macroValue, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
+ break;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ entry = new CIncludeFileEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
+ break;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ entry = new CMacroFileEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ entry = new CLibraryPathEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ entry = new CLibraryFileEntry(value, discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0);
+ break;
+ }
+ return entry;
+
+ }
+
+ private String optionPathToEntryValue(String path, boolean discovered) {
+ //TODO:
+ String result = path;
+ if (path != null) {
+ IOptionPathConverter optionPathConverter = fTool.getOptionPathConverter();
+ if (null!=optionPathConverter) {
+ IPath platformPath = optionPathConverter.convertToPlatformLocation(path, null, null);
+ if(platformPath != null)
+ result = platformPath.toString();
+ } else {
+
+ }
+ }
+ return result;
+ }
+
+
+ private String toEntryPathValue(String path, boolean discovered){
+ //TODO:
+ return path;
+ }
+*/
+ public int getSupportedEntryKinds() {
+ KindBasedStore store = getKindToOptionArrayStore();
+ IKindBasedInfo infos[] = store.getContents();
+ int kinds = 0;
+ for(int i = 0; i < infos.length; i++){
+ if(((IOption[])infos[i].getInfo()).length > 0)
+ kinds |= infos[i].getKind();
+ }
+ return kinds;
+ }
+
+ private KindBasedStore getKindToOptionArrayStore(){
+ if(!fOptionStoreInited){
+ calculateKindToOptionArrayStore();
+ fOptionStoreInited = true;
+ }
+ return fKindToOptionArrayStore;
+ }
+ private void calculateKindToOptionArrayStore(){
+ fKindToOptionArrayStore.clear();
+ IOption options[] = fTool.getOptions();
+ for(int i = 0; i < options.length; i++){
+ IOption option = options[i];
+ try {
+ int type = option.getValueType();
+ int entryKind = ManagedBuildManager.optionTypeToEntryKind(type);
+ if(entryKind != 0){
+ getOptionList(fKindToOptionArrayStore, entryKind).add(option);
+ }
+ } catch (BuildException e) {
+ }
+ }
+
+ IKindBasedInfo infos[] = fKindToOptionArrayStore.getContents();
+ IKindBasedInfo info;
+ for(int i = 0; i < infos.length; i++){
+ info = infos[i];
+ List list = (List)info.getInfo();
+ if(list != null){
+ IOption[] opts = (IOption[])list.toArray(new IOption[list.size()]);
+ info.setInfo(opts);
+ } else {
+ info.setInfo(EMPTY_OPTION_ARRAY);
+ }
+ }
+ }
+
+ IOption[] getOptionsForKind(int entryKind){
+ KindBasedStore store = getKindToOptionArrayStore();
+ return (IOption[])store.get(entryKind);
+ }
+
+/* private IOption[] getOptionsForType(int type){
+ Map map = getTypeToOptionArrayMap();
+ return (IOption[])map.get(new Integer(type));
+
+ }
+*/
+ private List getOptionList(KindBasedStore store, int kind){
+ List list = (List)store.get(kind);
+ if(list == null){
+ list = new ArrayList();
+ store.put(kind, list);
+ }
+ return list;
+ }
+
+ public void setLanguageId(String id) {
+ if(CDataUtil.objectsEqual(id, fInputType.getLanguageId(fTool))){
+ fInputType = fTool.getEdtableInputType(fInputType);
+ fInputType.setLanguageIdAttribute(id);
+ }
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public String getName() {
+ String name;
+ if(fInputType == null){
+ name = fTool.getName();
+ if(name == null){
+ String[] exts = getSourceExtensions();
+ if(exts.length != 0){
+ name = CDataUtil.arrayToString(exts, ","); //$NON-NLS-1$
+ } else {
+ name = fTool.getId();
+ }
+ }
+ } else {
+ name = fInputType.getLanguageName(fTool);
+ }
+ return name;
+ }
+
+ public boolean isValid() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ public void setName(String name) {
+ // TODO Auto-generated method stub
+ }
+
+ public ITool getTool(){
+ return fTool;
+ }
+
+ public IInputType getInputType() {
+ return fInputType;
+ }
+
+ boolean isToolChainDiscoveryProfile(){
+ return fInputType != null ?
+ ((InputType)fInputType).getDiscoveryProfileIdAttribute() == null :
+ true;
+ }
+
+ String getDiscoveryProfileId(){
+ if(fInputType != null)
+ return fInputType.getDiscoveryProfileId(fTool);
+ IBuildObject bo = fTool.getParent();
+ if(bo instanceof IToolChain)
+ return ((IToolChain)bo).getScannerConfigDiscoveryProfileId();
+ else if(bo instanceof IResourceInfo){
+ IToolChain tCh = ((ResourceConfiguration)bo).getBaseToolChain();
+ if(tCh != null)
+ return tCh.getScannerConfigDiscoveryProfileId();
+ }
+ return null;
+ }
+
+ public void setSourceContentTypeIds(String[] ids) {
+ String[] headerIds = fInputType.getHeaderContentTypeIds();
+
+ List newSrc = new ArrayList(ids.length);
+ List newHeaders = new ArrayList(ids.length);
+ for(int i = 0; i < ids.length; i++){
+ String id = ids[i];
+ int j = 0;
+ for(; j < headerIds.length; j++){
+ if(id.equals(headerIds[j])){
+ newHeaders.add(id);
+ break;
+ }
+ }
+ if(j == headerIds.length){
+ newSrc.add(id);
+ }
+ }
+
+ String newSrcIds[] = (String[])newSrc.toArray(new String[newSrc.size()]);
+ String newHeaderIds[] = (String[])newHeaders.toArray(new String[newHeaders.size()]);
+
+ if(!Arrays.equals(newSrcIds, fInputType.getSourceContentTypeIds())){
+ fInputType = fTool.getEdtableInputType(fInputType);
+ fInputType.setSourceContentTypeIds(newSrcIds);
+ }
+
+ if(!Arrays.equals(newHeaderIds, fInputType.getHeaderContentTypeIds())){
+ fInputType = fTool.getEdtableInputType(fInputType);
+ fInputType.setHeaderContentTypeIds(newHeaderIds);
+ }
+
+ }
+
+ public void setSourceExtensions(String[] exts) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildTargetPlatformData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildTargetPlatformData.java
new file mode 100644
index 00000000000..92f5507c16a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildTargetPlatformData.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.managedbuilder.internal.core.TargetPlatform;
+
+public class BuildTargetPlatformData extends CTargetPlatformData {
+ private TargetPlatform fTargetPlatform;
+
+ public BuildTargetPlatformData(TargetPlatform targetPlatform){
+ fTargetPlatform = targetPlatform;
+ }
+ public String[] getBinaryParserIds() {
+ return fTargetPlatform.getBinaryParserList();
+ }
+
+ public void setBinaryParserIds(String[] ids) {
+ fTargetPlatform.setBinaryParserList(ids);
+ }
+
+ public String getId() {
+ return fTargetPlatform.getId();
+ }
+
+ public String getName() {
+ return fTargetPlatform.getName();
+ }
+
+ public boolean isValid() {
+ //TODO:
+ return true;
+ }
+
+ public void setName(String name) {
+ fTargetPlatform.setName(name);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java
new file mode 100644
index 00000000000..9275ad62e7a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildVariablesContributor.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
+import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
+import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+public class BuildVariablesContributor implements ICdtVariablesContributor {
+ private BuildConfigurationData fCfgData;
+
+ private class ContributorMacroContextInfo extends DefaultMacroContextInfo {
+ ICdtVariableManager fMngr;
+ private ICConfigurationDescription fCfgDes;
+
+ public ContributorMacroContextInfo(ICdtVariableManager mngr, ICConfigurationDescription cfgDes,
+ int type, Object data) {
+ super(type, data);
+ fMngr = mngr;
+ fCfgDes = cfgDes;
+ }
+
+
+ protected ICdtVariableSupplier[] getSuppliers(int type, Object data) {
+ switch(type){
+ case IBuildMacroProvider.CONTEXT_CONFIGURATION:
+ return new ICdtVariableSupplier[]{
+ new ExternalExtensionMacroSupplier(fMngr, fCfgDes)
+ };
+ case IBuildMacroProvider.CONTEXT_PROJECT:
+ return new ICdtVariableSupplier[]{
+ new ExternalExtensionMacroSupplier(fMngr, fCfgDes)
+ };
+ case IBuildMacroProvider.CONTEXT_WORKSPACE:
+ return new ICdtVariableSupplier[]{
+ MbsMacroSupplier.getInstance()
+ };
+ }
+ return null;
+ }
+
+
+ public IVariableContextInfo getNext() {
+ switch(getContextType()){
+ case IBuildMacroProvider.CONTEXT_CONFIGURATION:{
+ Object data = getContextData();
+ IConfiguration configuration = null;
+ if(data instanceof IBuilder)
+ configuration = ((IBuilder)data).getParent().getParent();
+ else if(data instanceof IConfiguration)
+ configuration = (IConfiguration)data;
+
+ if(configuration != null){
+ IManagedProject managedProject = configuration.getManagedProject();
+ if(managedProject != null)
+ return new ContributorMacroContextInfo(
+ fMngr,
+ fCfgDes,
+ IBuildMacroProvider.CONTEXT_PROJECT,
+ managedProject);
+ }
+ }
+ break;
+ case IBuildMacroProvider.CONTEXT_PROJECT:{
+ Object data = getContextData();
+ if(data instanceof IManagedProject){
+ IWorkspace wsp = ResourcesPlugin.getWorkspace();
+ if(wsp != null)
+ return new ContributorMacroContextInfo(
+ fMngr,
+ fCfgDes,
+ IBuildMacroProvider.CONTEXT_WORKSPACE,
+ wsp);
+ }
+ }
+ break;
+ case IBuildMacroProvider.CONTEXT_WORKSPACE:
+ if(getContextData() instanceof IWorkspace){
+ return new ContributorMacroContextInfo(
+ fMngr,
+ fCfgDes,
+ IBuildMacroProvider.CONTEXT_INSTALLATIONS,
+ null);
+ }
+ break;
+ }
+ return null;
+ }
+ }
+
+ BuildVariablesContributor(BuildConfigurationData data){
+ fCfgData = data;
+ }
+
+ public ICdtVariable getVariable(String name, ICdtVariableManager provider) {
+ ContributorMacroContextInfo info = createContextInfo(provider);
+ if(info != null)
+ return SupplierBasedCdtVariableManager.getVariable(name, info, true);
+ return null;
+ }
+
+ private ContributorMacroContextInfo createContextInfo(ICdtVariableManager mngr){
+ IConfiguration cfg = fCfgData.getConfiguration();
+ IProject project = cfg.getOwner().getProject();
+ ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project);
+ if(des != null){
+ ICConfigurationDescription cfgDes = des.getConfigurationById(cfg.getId());
+ if(cfgDes != null){
+ return new ContributorMacroContextInfo(mngr,
+ cfgDes,
+ BuildMacroProvider.CONTEXT_CONFIGURATION,
+ cfg);
+ }
+ }
+ return null;
+ }
+ public ICdtVariable[] getVariables(ICdtVariableManager provider) {
+ ContributorMacroContextInfo info = createContextInfo(provider);
+ if(info != null)
+ return SupplierBasedCdtVariableManager.getVariables(info, true);
+ return null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
new file mode 100644
index 00000000000..8b364b8f38f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
@@ -0,0 +1,357 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.model.ILanguageDescriptor;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+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.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
+import org.eclipse.cdt.managedbuilder.internal.core.InputType;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.managedbuilder.internal.core.NotificationManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentType;
+
+public class ConfigurationDataProvider extends CConfigurationDataProvider implements ISettingsChangeListener {
+ private static final String BUILD_SYSTEM_DATA_MODULE_NAME = "cdtBuildSystem"; //$NON-NLS-1$
+ private static final String VERSION_ATTRIBUTE = "version"; //$NON-NLS-1$
+ private static final String PREF_CFG_ID = "org.eclipse.cdt.build.core.prefbase.cfg"; //$NON-NLS-1$
+ public static final String PREF_TC_ID = "org.eclipse.cdt.build.core.prefbase.toolchain"; //$NON-NLS-1$
+ private static final String PREF_TOOL_ID = "org.eclipse.cdt.build.core.settings.holder"; //$NON-NLS-1$
+
+ private static boolean registered;
+
+ public ConfigurationDataProvider(){
+ if(!registered){
+ registered = true;
+ NotificationManager.getInstance().subscribe(this);
+ }
+ }
+
+ static BuildConfigurationData writeConfiguration(ICConfigurationDescription des,
+ CConfigurationData base) throws CoreException {
+ BuildConfigurationData appliedCfg = (BuildConfigurationData)base;
+ ICStorageElement rootElement = des.getStorage(BUILD_SYSTEM_DATA_MODULE_NAME, true);
+ rootElement.clear();
+ rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString());
+ ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME);
+ Configuration cfg = (Configuration)appliedCfg.getConfiguration();
+ cfg.setConfigurationDescription(des);
+ cfg.serialize(cfgElemen);
+
+ return appliedCfg;
+ }
+
+ protected CConfigurationData applyPreferences(
+ ICConfigurationDescription des, CConfigurationData base) throws CoreException{
+
+ BuildConfigurationData appliedCfg = writeConfiguration(des, base);
+
+ return appliedCfg;
+ }
+
+ public CConfigurationData applyConfiguration(
+ ICConfigurationDescription des, CConfigurationData base)
+ throws CoreException {
+ if(des.isPreferenceConfiguration())
+ return applyPreferences(des, base);
+
+ BuildConfigurationData appliedCfg = writeConfiguration(des, base);
+
+ IManagedBuildInfo info = getBuildInfo(des);
+ ManagedProject mProj = (ManagedProject)info.getManagedProject();
+ mProj.applyConfiguration((Configuration)appliedCfg.getConfiguration());
+ info.setValid(true);
+
+ return appliedCfg;
+ }
+
+ protected CConfigurationData createPreferences(
+ ICConfigurationDescription des, CConfigurationData base)
+ throws CoreException {
+ Configuration cfg = (Configuration)((BuildConfigurationData)base).getConfiguration();
+ Configuration newCfg = new Configuration((ManagedProject)cfg.getManagedProject(), cfg, des.getId(), true, true, true);
+ newCfg.setConfigurationDescription(des);
+ newCfg.setName(des.getName());
+// if(!newCfg.getId().equals(cfg.getId())){
+// newCfg.exportArtifactInfo();
+// }
+
+ return newCfg.getConfigurationData();
+ }
+
+
+ public CConfigurationData createConfiguration(
+ ICConfigurationDescription des, CConfigurationData base, boolean clone)
+ throws CoreException {
+ if(des.isPreferenceConfiguration())
+ return createPreferences(des, base);
+
+ Configuration cfg = (Configuration)((BuildConfigurationData)base).getConfiguration();
+ Configuration newCfg = new Configuration((ManagedProject)cfg.getManagedProject(), cfg, des.getId(), true, true, false);
+ newCfg.setConfigurationDescription(des);
+ newCfg.setName(des.getName());
+ if(!newCfg.getId().equals(cfg.getId())){
+ newCfg.exportArtifactInfo();
+ }
+
+ return newCfg.getConfigurationData();
+ }
+
+ private IManagedBuildInfo getBuildInfo(ICConfigurationDescription des){
+ IProject project = des.getProjectDescription().getProject();
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, false);
+ if(info == null)
+ info = ManagedBuildManager.createBuildInfo(project);
+
+ getManagedProject(des, info);
+
+ return info;
+ }
+
+ private IManagedProject getManagedProject(ICConfigurationDescription des, IManagedBuildInfo info){
+ IManagedProject mProj = info.getManagedProject();
+ if(mProj == null){
+ mProj = new ManagedProject(des.getProjectDescription());
+ info.setManagedProject(mProj);
+ }
+ return mProj;
+ }
+
+ private Configuration load(ICConfigurationDescription des, ManagedProject mProj, boolean isPreference) throws CoreException{
+ ICStorageElement rootElement = des.getStorage(BUILD_SYSTEM_DATA_MODULE_NAME, true);
+ ICStorageElement children[] = rootElement.getChildren();
+ String version = rootElement.getAttribute(VERSION_ATTRIBUTE);
+ Configuration cfg = null;
+
+ for(int i = 0; i < children.length; i++){
+ if(IConfiguration.CONFIGURATION_ELEMENT_NAME.equals(children[i].getName())){
+ cfg = new Configuration(mProj, children[i], version, isPreference);
+ break;
+ }
+ }
+ return cfg;
+ }
+
+ protected CConfigurationData loadPreferences(ICConfigurationDescription des)
+ throws CoreException {
+
+ Configuration cfg = load(des, null, true);
+
+ cfg = updatePreferenceOnLoad(cfg, des);
+
+ return cfg.getConfigurationData();
+ }
+
+ public static Configuration getClearPreference(String id){
+ Configuration cfg = createEmptyPrefConfiguration(id, null);
+
+ cfg = adjustPreferenceConfig(cfg);
+
+ return cfg;
+ }
+
+ private static Configuration updatePreferenceOnLoad(Configuration cfg, ICConfigurationDescription des){
+ if(cfg == null)
+ cfg = createEmptyPrefConfiguration(des.getId(), des.getName());
+
+ cfg = adjustPreferenceConfig(cfg);
+
+ return cfg;
+ }
+
+ private static Configuration adjustPreferenceConfig(Configuration cfg){
+ LanguageManager mngr = LanguageManager.getInstance();
+ ILanguageDescriptor dess[] = mngr.getLanguageDescriptors();
+ Map map = mngr.getContentTypeIdToLanguageDescriptionsMap();
+
+ IResourceInfo[] rcInfos = cfg.getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ if(rcInfos[i] instanceof IFolderInfo){
+ adjustFolderInfo((IFolderInfo)rcInfos[i], dess, new HashMap(map));
+ }
+ }
+
+ return cfg;
+ }
+
+ private static void adjustFolderInfo(IFolderInfo info, ILanguageDescriptor dess[], HashMap map){
+ IToolChain tch = info.getToolChain();
+ Map langMap = new HashMap();
+ for(int i = 0; i < dess.length; i++){
+ langMap.put(dess[i].getId(), dess[i]);
+ }
+ if(PREF_TC_ID.equals(tch.getSuperClass().getId())){
+ ITool[] tools = tch.getTools();
+ for(int i = 0; i < tools.length; i++){
+ Tool tool = (Tool)tools[i];
+ IInputType types[] = tool.getAllInputTypes();
+ for(int k = 0; k < types.length; k++){
+ InputType type = (InputType)types[k];
+ String langId = type.getLanguageId(tool);
+ if(langId != null){
+ ILanguageDescriptor des = (ILanguageDescriptor)langMap.remove(langId);
+ adjustInputType(tool, type, des);
+ continue;
+ } else {
+ IContentType[] cTypes = type.getSourceContentTypes();
+ for(int c = 0; c < cTypes.length; c++){
+ IContentType cType = cTypes[c];
+ ILanguageDescriptor[] langs = (ILanguageDescriptor[])map.remove(cType.getId());
+ if(langs != null && langs.length != 0){
+ for(int q = 0; q < langs.length; q++){
+ langMap.remove(langs[q].getId());
+ }
+
+ adjustInputType(tool, type, langs[0]);
+ }
+ }
+ }
+ }
+ }
+
+ if(!langMap.isEmpty()){
+ addTools(tch, langMap, map);
+ }
+ }
+ }
+
+ private static InputType adjustInputType(Tool tool, InputType type, ILanguageDescriptor des){
+ String [] cTypeIds = des.getContentTypeIds();
+ String srcIds[] = type.getSourceContentTypeIds();
+ String hIds[] = type.getHeaderContentTypeIds();
+
+ Set landTypes = new HashSet(Arrays.asList(cTypeIds));
+ landTypes.removeAll(Arrays.asList(srcIds));
+ landTypes.removeAll(Arrays.asList(hIds));
+
+ if(landTypes.size() != 0){
+ List srcList = new ArrayList();
+ srcList.addAll(landTypes);
+ type = (InputType)tool.getEdtableInputType(type);
+ type.setSourceContentTypeIds((String[])srcList.toArray(new String[srcList.size()]));
+ }
+
+ if(!des.getId().equals(type.getLanguageId(tool))){
+ type = (InputType)tool.getEdtableInputType(type);
+ type.setLanguageIdAttribute(des.getId());
+ type.setLanguageNameAttribute(des.getName());
+ }
+ return type;
+ }
+
+ private static void addTools(IToolChain tc, Map langMap, Map cTypeToLangMap){
+ ITool extTool = ManagedBuildManager.getExtensionTool(PREF_TOOL_ID);
+ List list = new ArrayList(langMap.values());
+ ILanguageDescriptor des;
+ while(list.size() != 0){
+ des = (ILanguageDescriptor)list.remove(list.size() - 1);
+ String[] ctypeIds = des.getContentTypeIds();
+ boolean addLang = false;
+ for(int i = 0; i < ctypeIds.length; i++){
+ ILanguageDescriptor[] langs = (ILanguageDescriptor[])cTypeToLangMap.remove(ctypeIds[i]);
+ if(langs != null && langs.length != 0){
+ addLang = true;
+ for(int q = 0; q < langs.length; q++){
+ list.remove(langs[q]);
+ }
+ }
+ }
+
+ if(addLang){
+ String id = ManagedBuildManager.calculateChildId(extTool.getId(), null);
+ String name = des.getName();
+ Tool tool = (Tool)tc.createTool(extTool, id, name, false);
+ InputType type = (InputType)tool.getInputTypes()[0];
+ type = (InputType)tool.getEdtableInputType(type);
+ type.setSourceContentTypes(type.getSourceContentTypes());
+ type.setLanguageNameAttribute(des.getName());
+ type.setName(des.getName());
+ type.setLanguageIdAttribute(des.getId());
+ }
+ }
+ }
+
+
+ private static Configuration createEmptyPrefConfiguration(String id, String name){
+ Configuration extCfg = (Configuration)ManagedBuildManager.getExtensionConfiguration(PREF_CFG_ID);
+ Configuration emptyPrefCfg = null;
+ if(extCfg != null){
+ if(id == null)
+ id = ManagedBuildManager.calculateChildId(extCfg.getId(), null);
+ if(name == null)
+ name = extCfg.getName();
+ emptyPrefCfg = new Configuration(null, extCfg, id, false, true, true);
+ emptyPrefCfg.setName(name);
+ emptyPrefCfg.setPerRcTypeDiscovery(false);
+ }
+
+ return emptyPrefCfg;
+ }
+
+ public CConfigurationData loadConfiguration(ICConfigurationDescription des)
+ throws CoreException {
+ if(des.isPreferenceConfiguration())
+ return loadPreferences(des);
+
+ IManagedBuildInfo info = getBuildInfo(des);
+ Configuration cfg = load(des, (ManagedProject)info.getManagedProject(), false);
+
+ if(cfg != null){
+ cfg.setConfigurationDescription(des);
+ info.setValid(true);
+ return cfg.getConfigurationData();
+ }
+ return null;
+ }
+
+ public void optionChanged(IResourceInfo rcInfo, IHoldsOptions holder, IOption option, Object oldValue) {
+ BuildLanguageData datas[] = (BuildLanguageData[])rcInfo.getCLanguageDatas();
+ for(int i = 0; i < datas.length; i++){
+ datas[i].optionChanged(option, oldValue);
+ }
+ }
+
+
+ public void removeConfiguration(ICConfigurationDescription des,
+ CConfigurationData data) {
+ IConfiguration cfg = ((BuildConfigurationData)data).getConfiguration();
+ IManagedBuildInfo info = getBuildInfo(des);
+ IManagedProject mProj = info.getManagedProject();
+ mProj.removeConfiguration(cfg.getId());
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java
new file mode 100644
index 00000000000..cbaf65f9fc1
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryInfo.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class EntryInfo {
+ private ICLanguageSettingEntry fEntry;
+// private IOption fOption;
+// private String fEnvVarName;
+// private int fPosition;
+ private boolean fIsDiscovered;
+ private boolean fIsOverRidden;
+
+ EntryInfo(ICLanguageSettingEntry entry, boolean discovered, boolean isOverridden){
+ fEntry = entry;
+ fIsDiscovered = discovered;
+ fIsOverRidden = isOverridden;
+ }
+
+/* EntryInfo(ICLanguageSettingEntry entry, boolean discovered, IOption option, int position){
+ fEntry = entry;
+ fIsDiscovered = discovered;
+ fOption = option;
+ fPosition = position;
+ }
+
+ EntryInfo(ICLanguageSettingEntry entry, boolean discovered, String envVarName, int position){
+ fEntry = entry;
+ fIsDiscovered = discovered;
+ fEnvVarName = envVarName;
+ fPosition = position;
+ }
+*/
+/* public void setOptionInfo(IOption option, int pos){
+ fOption = option;
+ fPosition = pos;
+ }
+*/
+ public void makeOverridden(boolean overrridden){
+/* fOption = null;
+ fEnvVarName = null;
+ fPosition = 0;
+*/
+ fIsOverRidden = overrridden;
+
+ }
+
+/* public void setEnvironmentInfo(String envVarName, int pos){
+ fEnvVarName = envVarName;
+ fPosition = pos;
+ }
+*/
+ public ICLanguageSettingEntry getEntry(){
+ return fEntry;
+ }
+
+ public boolean isDiscovered(){
+ return fIsDiscovered;
+ }
+
+ public boolean isOverridden(){
+// return fOption != null || fEnvVarName != null;
+ return fIsOverRidden;
+ }
+
+ public boolean isUndefined(){
+ //TODO
+ return false;
+ }
+
+/* public IOption getOption(){
+ return fOption;
+ }
+*/
+/* public String getEnvVarName(){
+ return fEnvVarName;
+ }
+*/
+/* public int getPosition(){
+ return fPosition;
+ }
+*/
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java
new file mode 100644
index 00000000000..1be6c5d1010
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryListMap.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.EntryNameKey;
+
+public class EntryListMap {
+ private HashMap fMap = new HashMap();
+ private ArrayList fList = new ArrayList();
+
+ public EntryInfo getEntryInfo(ICLanguageSettingEntry entry){
+ return (EntryInfo)fMap.get(new EntryNameKey(entry));
+ }
+
+ public void addEntryInfo(EntryInfo info){
+ ICLanguageSettingEntry entry = info.getEntry();
+ EntryNameKey key = new EntryNameKey(entry);
+ EntryInfo old = (EntryInfo)fMap.remove(key);
+ if(old != null)
+ fList.remove(old);
+ fMap.put(key, info);
+ fList.add(info);
+ }
+
+ public Map getEntryInfoMap(){
+ return (Map)fMap.clone();
+ }
+
+ public List getEntryInfoList(){
+ return (List)fList.clone();
+ }
+
+ private class EntryIterator implements Iterator{
+ Iterator fIter;
+ Object fCurrent;
+ EntryIterator (Iterator iter){
+ fIter = iter;
+ }
+ public boolean hasNext() {
+ return fIter.hasNext();
+ }
+
+ public Object next() {
+ return fCurrent = fIter.next();
+ }
+
+ public void remove() {
+ fMap.remove(new EntryNameKey(((EntryInfo)fCurrent).getEntry()));
+ fIter.remove();
+ }
+
+ }
+
+ public Iterator getIterator(){
+ return new EntryIterator(fList.iterator());
+ }
+
+ public EntryInfo[] getEntries(){
+ return (EntryInfo[])fList.toArray(new EntryInfo[fList.size()]);
+ }
+
+ public void clear(){
+ fMap.clear();
+ fList.clear();
+ }
+
+ public int getSize(){
+ return fList.size();
+ }
+
+ public EntryInfo getEntryInfo(int i){
+ return (EntryInfo)fList.get(i);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java
new file mode 100644
index 00000000000..169e71e5a5c
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
+import org.eclipse.cdt.core.settings.model.util.EntryNameKey;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProfileInfoProvider.DiscoveredEntry;
+
+
+public class EntryStorage {
+ private int fKind;
+ private EntryListMap fDiscoveredEntries = new EntryListMap();
+ private EntryListMap fUserEntries = new EntryListMap();
+// private ICLanguageSettingEntry fEntries[];
+ private BuildLanguageData fLangData;
+ private boolean fCacheInited;
+ private boolean fUserValuesInited;
+
+ private static final String EMPTY_STRING = new String();
+
+ public EntryStorage(int kind, BuildLanguageData lData){
+ fKind = kind;
+ fLangData = lData;
+ }
+
+ public int getKind(){
+ return fKind;
+ }
+
+ void optionsChanged(IOption option, Object oldValue){
+ fUserValuesInited = false;
+ }
+
+ public List getEntries(List list){
+ initCache();
+ if(list == null)
+ list = new ArrayList();
+
+ for(Iterator iter = fUserEntries.getIterator(); iter.hasNext();){
+ EntryInfo info = (EntryInfo)iter.next();
+// if(!info.isOverridden())
+ list.add(info.getEntry());
+ }
+ for(Iterator iter = fDiscoveredEntries.getIterator(); iter.hasNext();){
+ EntryInfo info = (EntryInfo)iter.next();
+ if(!info.isOverridden())
+ list.add(info.getEntry());
+ }
+ return list;
+ }
+
+ private void resetDefaults(){
+ resetCache();
+
+ IOption options[] = fLangData.getOptionsForKind(fKind);
+ ITool tool = fLangData.getTool();
+ for(int i = 0; i < options.length; i++){
+ IOption option = options[i];
+ if(option.getParent() == tool){
+ tool.removeOption(option);
+ }
+ }
+ }
+
+ private void resetCache(){
+ fCacheInited = false;
+ }
+
+ public void setEntries(ICLanguageSettingEntry entries[]){
+ if(entries == null){
+ resetDefaults();
+ return;
+ }
+ initCache();
+ ArrayList userList = new ArrayList();
+ Map discoveredMap = fDiscoveredEntries.getEntryInfoMap();
+ boolean discoveredReadOnly = isDiscoveredEntriesReadOnly();
+
+ for(int i = 0; i < entries.length; i++){
+ ICLanguageSettingEntry entry = entries[i];
+ EntryInfo info = (EntryInfo)discoveredMap.remove(new EntryNameKey(entry));
+ if(info == null || info.isOverridden() || !discoveredReadOnly){
+ if(info != null){
+ info.makeOverridden(true);
+ }
+ ICLanguageSettingEntry usrEntry = createEntry(entry, false);
+ userList.add(usrEntry);
+ }
+ }
+
+ for(Iterator iter = discoveredMap.values().iterator(); iter.hasNext();){
+ EntryInfo info = (EntryInfo)iter.next();
+ info.makeOverridden(false);
+ }
+
+ IOption options[] = fLangData.getOptionsForKind(fKind);
+ fUserEntries.clear();
+ if(options.length > 0){
+ IOption option = options[0];
+ int size = userList.size();
+ String optValue[] = new String[size];
+ for(int i = 0; i < size; i++){
+ ICLanguageSettingEntry entry = (ICLanguageSettingEntry)userList.get(i);
+ EntryInfo info = new EntryInfo(entry, false, true);
+ fUserEntries.addEntryInfo(info);
+ optValue[i] = entryValueToOption(entry);
+ }
+
+ ITool tool = fLangData.getTool();
+ IResourceInfo rcInfo = tool.getParentResourceInfo();
+ IOption newOption = ManagedBuildManager.setOption(rcInfo, tool, option, optValue);
+ options = fLangData.getOptionsForKind(fKind);
+ for(int i = 0; i < options.length; i++){
+ if(options[i] != newOption)
+ ManagedBuildManager.setOption(rcInfo, tool, option, new String[0]);
+ }
+ }
+ }
+
+ private void initCache(){
+// if(fCacheInited){
+// if(!fUserValuesInited){
+// for(Iterator iter = fDiscoveredEntries.getIterator(); iter.hasNext();){
+// EntryInfo info = (EntryInfo)iter.next();
+// info.makeOverridden(false);
+// }
+// initUserValues();
+// fUserValuesInited = true;
+// }
+//
+// } else {
+ fCacheInited = true;
+ DiscoveredEntry[] dEntries = fLangData.getDiscoveredEntryValues(fKind);
+ fDiscoveredEntries.clear();
+ boolean readOnly = isDiscoveredEntriesReadOnly();
+ if(dEntries.length != 0){
+ for(int i = 0; i < dEntries.length; i++){
+ DiscoveredEntry dEntry = dEntries[i];
+ ICLanguageSettingEntry entry = createEntry(dEntry, true, readOnly);
+ EntryInfo info = new EntryInfo(entry, true, false);
+ fDiscoveredEntries.addEntryInfo(info);
+ }
+ }
+ initUserValues();
+ fUserValuesInited = true;
+// }
+ }
+
+ private boolean isDiscoveredEntriesReadOnly(){
+ if(fKind == ICLanguageSettingEntry.MACRO){
+ return fLangData.getOptionsForKind(fKind).length != 0;
+ }
+ return true;
+ }
+
+ private void initUserValues(){
+ IOption options[] = fLangData.getOptionsForKind(fKind);
+ fUserEntries.clear();
+ if(options.length > 0){
+ for(int i = 0; i < options.length; i++){
+ IOption option = options[i];
+ List list = (List)option.getValue();
+ int size = list.size();
+ if(size > 0){
+ for(int j = 0; j < size; j++){
+ String value = (String)list.get(j);
+ ICLanguageSettingEntry entry = createEntry(discoveredEntryFromString(value), false, false);
+ EntryInfo discoveredInfo = fDiscoveredEntries.getEntryInfo(entry);
+ if(discoveredInfo != null){
+// discoveredInfo.setOptionInfo(option, j);
+ discoveredInfo.makeOverridden(true);
+ }
+ EntryInfo userInfo = new EntryInfo(entry, false, true);
+ fUserEntries.addEntryInfo(userInfo);
+ }
+ }
+
+ }
+ }
+ }
+
+ private DiscoveredEntry discoveredEntryFromString(String str){
+ if(fKind == ICLanguageSettingEntry.MACRO){
+ String nv[] = macroNameValueFromValue(str);
+ return new DiscoveredEntry(nv[0], nv[1]);
+ }
+ return new DiscoveredEntry(str);
+ }
+
+/* private List processValues(List valuesList, boolean discovered, List entriesList){
+ for(Iterator iter = valuesList.iterator(); iter.hasNext();){
+ String value = (String)iter.next();
+ ICLanguageSettingEntry entry = createEntry(value, discovered);
+ if(entry != null)
+ entriesList.add(entry);
+ }
+ return entriesList;
+ }
+*/
+ private ICLanguageSettingEntry createEntry(DiscoveredEntry dEntry, boolean discovered, boolean readOnly){
+ ICLanguageSettingEntry entry = null;
+ int flags = discovered ? ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY : 0;
+ Object v[];
+ String value = dEntry.getValue();
+ String name = dEntry.getName();
+ switch (fKind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ v = optionPathValueToEntry(value);
+ value = (String)v[0];
+ if(((Boolean)v[1]).booleanValue())
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ entry = new CIncludePathEntry(value, flags);
+ break;
+ case ICLanguageSettingEntry.MACRO:
+ //String nv[] = macroNameValueFromValue(value);
+
+ entry = new CMacroEntry(name, value, flags);
+ break;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ v = optionPathValueToEntry(value);
+ value = (String)v[0];
+ if(((Boolean)v[1]).booleanValue())
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ entry = new CIncludeFileEntry(value, flags);
+ break;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ v = optionPathValueToEntry(value);
+ value = (String)v[0];
+ if(((Boolean)v[1]).booleanValue())
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ entry = new CMacroFileEntry(value, flags);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ v = optionPathValueToEntry(value);
+ value = (String)v[0];
+ if(((Boolean)v[1]).booleanValue())
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ entry = new CLibraryPathEntry(value, flags);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ v = optionPathValueToEntry(value);
+ value = (String)v[0];
+ if(((Boolean)v[1]).booleanValue())
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ entry = new CLibraryFileEntry(value, flags);
+ break;
+ }
+ return entry;
+
+ }
+
+ private ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, boolean discovered){
+ //ICLanguageSettingEntry entry = null;
+ int flags = entry.getFlags();
+ if(discovered)
+ flags |= ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.READONLY;
+
+ switch (fKind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ entry = new CIncludePathEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.MACRO:
+ entry = new CMacroEntry(entry.getName(), entry.getValue(), flags);
+ break;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ entry = new CIncludeFileEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ entry = new CMacroFileEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ entry = new CLibraryPathEntry(entry.getName(), flags);
+ break;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ entry = new CLibraryFileEntry(entry.getName(), flags);
+ break;
+ }
+ return entry;
+
+ }
+
+ private String[] macroNameValueFromValue(String value){
+ String nv[] = new String[2];
+ int index = value.indexOf('=');
+ if(index > 0){
+ nv[0] = value.substring(0, index);
+ nv[1] = value.substring(index + 1);
+ } else {
+ nv[0] = value;
+ nv[1] = EMPTY_STRING;
+ }
+ return nv;
+ }
+
+ private String nameFromValue(String value){
+ if(fKind != ICLanguageSettingEntry.MACRO){
+ return value;
+ }
+ return macroNameValueFromValue(value)[0];
+ }
+
+ private String entryValueToOption(ICLanguageSettingEntry entry){
+ if(entry.getKind() == ICLanguageSettingEntry.MACRO && entry.getValue().length() > 0){
+ return new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
+ } else if(entry instanceof ICLanguageSettingPathEntry){
+ ICLanguageSettingPathEntry pathEntry = (ICLanguageSettingPathEntry)entry;
+ if(pathEntry.isValueWorkspacePath()){
+ return ManagedBuildManager.fullPathToLocation(pathEntry.getValue());
+ }
+ }
+ return entry.getName();
+ }
+
+ private Object[] optionPathValueToEntry(String value){
+ String wspPath = ManagedBuildManager.locationToFullPath(value);
+ if(wspPath != null)
+ return new Object[]{wspPath, Boolean.valueOf(true)};
+ return new Object[]{value, Boolean.valueOf(false)};
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExternalExtensionMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ExternalExtensionMacroSupplier.java
index 4950f414247..bbaa5c9f0c8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExternalExtensionMacroSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ExternalExtensionMacroSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,30 +8,42 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
+import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
+import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
/**
* This supplier is used to suply macros provided by the tool-integrator
*
* @since 3.0
*/
-public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
+public class ExternalExtensionMacroSupplier implements ICdtVariableSupplier{
private static final String fNonOverloadableMacros[] = new String[]{
//tool-integrators not allowed currently to override the "CWD" and "PWD" macros
"CWD", //$NON-NLS-1$
"PWD" //$NON-NLS-1$
};
+
+ private ICdtVariableManager fMngr;
+ private ICConfigurationDescription fCfgDes;
- private static ExternalExtensionMacroSupplier fInstance;
+// private static ExternalExtensionMacroSupplier fInstance;
private class ExtensionMacroProvider extends BuildMacroProvider{
private IMacroContextInfo fStartInfo;
@@ -47,20 +59,22 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable(java.lang.String, java.lang.Object, boolean)
*/
- public IBuildMacro getMacro(String macroName,
+ public ICdtVariable getVariable(String macroName,
int contextType,
Object contextData,
boolean includeParent) {
if(getValidName(macroName) == null)
return null;
- return super.getMacro(macroName,contextType,contextData,includeParent);
+ return fMngr.getVariable(macroName, fCfgDes);
+// return super.getMacro(macroName,contextType,contextData,includeParent);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#getMacros(int, java.lang.Object, boolean)
*/
- public IBuildMacro[] getMacros(int contextType,Object contextData, boolean includeParent) {
- return filterMacros(super.getMacros(contextType, contextData, includeParent));
+ public ICdtVariable[] getVariables(int contextType,Object contextData, boolean includeParent) {
+// return filterVariables(super.getMacros(contextType, contextData, includeParent));
+ return filterVariables(fMngr.getVariables(fCfgDes));
}
/* (non-Javadoc)
@@ -76,7 +90,7 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
if(info == null)
return null;
- if(checkParentContextRelation(startInfo,info))
+ if(SupplierBasedCdtVariableManager.checkParentContextRelation(startInfo,info))
return info;
return null;
}
@@ -85,12 +99,12 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
if(fStartInfo == null && !fStartInitialized){
IMacroContextInfo info = super.getMacroContextInfo(fContextType,fContextData);
if(info != null){
- IBuildMacroSupplier suppliers[] = info.getSuppliers();
+ ICdtVariableSupplier suppliers[] = info.getSuppliers();
suppliers = filterValidSuppliers(suppliers);
if(suppliers != null)
fStartInfo = new DefaultMacroContextInfo(fContextType,fContextData,suppliers);
else
- fStartInfo = info.getNext();
+ fStartInfo = (IMacroContextInfo)info.getNext();
fStartInitialized = true;
}
fStartInitialized = true;
@@ -100,28 +114,33 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
}
- private ExternalExtensionMacroSupplier(){
-
+ public ExternalExtensionMacroSupplier(ICdtVariableManager mngr, ICConfigurationDescription cfgDes){
+ fMngr = mngr;
+ fCfgDes = cfgDes;
}
- public static ExternalExtensionMacroSupplier getInstance(){
- if(fInstance == null)
- fInstance = new ExternalExtensionMacroSupplier();
- return fInstance;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
*/
- public IBuildMacro getMacro(String macroName, int contextType,
- Object contextData) {
+ public ICdtVariable getVariable(String macroName, IVariableContextInfo context) {
if((macroName = getValidName(macroName)) == null)
return null;
-
+
+ IMacroContextInfo info = (IMacroContextInfo)context;
+ int contextType = info.getContextType();
+ Object contextData = info.getContextData();
switch(contextType){
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
- if(contextData instanceof IConfiguration){
- IConfiguration cfg = (IConfiguration)contextData;
+ IConfiguration cfg = null;
+ IBuilder builder = null;
+ if(contextData instanceof IBuilder){
+ builder = (IBuilder)contextData;
+ cfg = builder.getParent().getParent();
+ } else if(contextData instanceof IConfiguration){
+ cfg = (IConfiguration)contextData;
+ builder = cfg.getBuilder();
+ }
+ if(cfg != null){
IConfigurationBuildMacroSupplier supplier = cfg.getBuildMacroSupplier();
if(supplier == null)
return null;
@@ -142,12 +161,24 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
*/
- public IBuildMacro[] getMacros(int contextType, Object contextData) {
+ public ICdtVariable[] getVariables(IVariableContextInfo context) {
IBuildMacro macros[] = null;
+ IMacroContextInfo info = (IMacroContextInfo)context;
+ int contextType = info.getContextType();
+ Object contextData = info.getContextData();
+
switch(contextType){
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
- if(contextData instanceof IConfiguration){
- IConfiguration cfg = (IConfiguration)contextData;
+ IConfiguration cfg = null;
+ IBuilder builder = null;
+ if(contextData instanceof IBuilder){
+ builder = (IBuilder)contextData;
+ cfg = builder.getParent().getParent();
+ }else if(contextData instanceof IConfiguration){
+ cfg = (IConfiguration)contextData;
+ builder = cfg.getBuilder();
+ }
+ if(cfg != null){
IConfigurationBuildMacroSupplier supplier = cfg.getBuildMacroSupplier();
if(supplier != null)
macros = supplier.getMacros(cfg,new ExtensionMacroProvider(contextType, contextData));
@@ -161,7 +192,7 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
macros = supplier.getMacros(project,new ExtensionMacroProvider(contextType, contextData));
}
}
- return filterMacros(macros);
+ return filterVariables(macros);
}
protected String getValidName(String name){
@@ -176,11 +207,45 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
return name;
}
- protected IBuildMacro[] filterMacros(IBuildMacro macros[]){
- return MacroResolver.filterMacros(macros,fNonOverloadableMacros);
+ protected ICdtVariable[] filterVariables(ICdtVariable macros[]){
+ return filterVariables(macros,fNonOverloadableMacros);
+ }
+
+ private ICdtVariable[] filterVariables(ICdtVariable macros[], String remove[]){
+ if(macros == null || macros.length == 0)
+ return macros;
+
+ ICdtVariable filtered[] = new IBuildMacro[macros.length];
+ int filteredNum = 0;
+ for(int i = 0; i < macros.length; i++){
+ ICdtVariable var = macros[i];
+ String name = null;
+ if(var != null && (name = var.getName().trim()).length() != 0){
+ boolean skip = false;
+ if(remove != null && remove.length > 0){
+ for(int j = 0; j < remove.length; j++){
+ if(remove[j] != null && remove[j].equals(name)){
+ skip = true;
+ break;
+ }
+ }
+ }
+ if(!skip)
+ filtered[filteredNum++] = var;
+ }
+ }
+
+ if(filteredNum != filtered.length){
+ ICdtVariable m[] = new ICdtVariable[filteredNum];
+ for(int i = 0; i < filteredNum; i++)
+ m[i] = filtered[i];
+ filtered = m;
+ }
+ return filtered;
+
}
- protected IBuildMacroSupplier[] filterValidSuppliers(IBuildMacroSupplier suppliers[]){
+ protected ICdtVariableSupplier[] filterValidSuppliers(ICdtVariableSupplier suppliers[]){
if(suppliers == null)
return null;
@@ -196,8 +261,8 @@ public class ExternalExtensionMacroSupplier implements IBuildMacroSupplier {
int startNum = i + 1;
- IBuildMacroSupplier validSuppliers[] =
- new IBuildMacroSupplier[suppliers.length - startNum];
+ ICdtVariableSupplier validSuppliers[] =
+ new ICdtVariableSupplier[suppliers.length - startNum];
for(i = startNum, j = 0; i < suppliers.length; i++, j++)
validSuppliers[j] = suppliers[i];
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java
new file mode 100644
index 00000000000..ab12b7bded2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public class ProfileInfoProvider {
+ static class DiscoveredEntry {
+ private String fName;
+ private String fValue;
+
+ public DiscoveredEntry(IPath path){
+ fName = path.toString();
+ fValue = fName;
+ }
+
+ public DiscoveredEntry(String name){
+ fName = name;
+ fValue = fName;
+ }
+
+ public DiscoveredEntry(String name, String value){
+ fName = name;
+ fValue = value;
+ }
+
+ public String getName(){
+ return fName;
+ }
+
+ public String getValue(){
+ return fValue;
+ }
+ }
+
+ private BuildLanguageData fLlanguageData;
+// private String fProfileId;
+// private IScannerInfoCollector fCollector;
+// private boolean fDataCollected;
+// private IProject fProject;
+// private IResource fResource;
+// private IPath fRcPath;
+ private IProject fProject;
+ private InfoContext fContext;
+ private IDiscoveredPathManager fMngr;
+
+ public ProfileInfoProvider(BuildLanguageData lData){
+ fLlanguageData = lData;
+ IResourceInfo rcInfo = lData.getTool().getParentResourceInfo();
+ fContext = new InfoContext(rcInfo, lData.getTool(), lData.getInputType());
+ fMngr = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager();
+ IResource rc = rcInfo.getParent().getOwner();
+ fProject = rc != null ? rc.getProject() : null;
+
+// clear();
+ }
+
+// public void clear(){
+// fDataCollected = false;
+// }
+//
+// private void invoke(){
+// if(fDataCollected)
+// return;
+// fDataCollected = true;
+//
+// fProfileId = fLlanguageData.getDiscoveryProfileId();
+//
+// if (fProfileId != null){
+//
+// SCProfileInstance profileInstance = null;
+// IResourceInfo rcInfo = fLlanguageData.getTool().getParentResourceInfo();
+// fProject = rcInfo.getParent().getOwner().getProject();
+// fRcPath = rcInfo.getPath();
+// fResource = fProject.findMember(fRcPath);
+//
+// if(fResource != null){
+// //FIXME:
+// InfoContext context = ScannerConfigUtil.createContextForProject(fProject);
+// profileInstance = ScannerConfigProfileManager.getInstance().
+// getSCProfileInstance(fProject, context, fProfileId);
+// fCollector = profileInstance.createScannerInfoCollector();
+//
+// // synchronized(this) {
+// if (fCollector != null) {
+// if(fCollector instanceof IManagedScannerInfoCollector)
+// ((IManagedScannerInfoCollector)fCollector).setProject(fProject);
+// calculateEntriesDynamically(fProject, profileInstance, fCollector);
+// }
+// // }
+// }
+// }
+// }
+//
+ public DiscoveredEntry[] getEntryValues(int kind){
+// ScannerInfoTypes type = kindToType(kind);
+// if(type != null){
+ if(fProject != null){
+ try {
+ IDiscoveredPathManager.IDiscoveredPathInfo info = fMngr.getDiscoveredInfo(fProject, fContext);
+ if(info != null){
+ return entriesForKind(info, kind);
+ }
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+// }
+ return new DiscoveredEntry[0];
+ }
+
+// private ScannerInfoTypes kindToType(int kind){
+// switch (kind) {
+// case ICLanguageSettingEntry.INCLUDE_PATH:
+// return ScannerInfoTypes.INCLUDE_PATHS;
+// case ICLanguageSettingEntry.MACRO:
+// return ScannerInfoTypes.SYMBOL_DEFINITIONS;
+// }
+// return null;
+// }
+
+ private DiscoveredEntry[] entriesForKind(IDiscoveredPathManager.IDiscoveredPathInfo info, int kind){
+ switch (kind) {
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ return calculateEntries(info.getIncludePaths());
+ case ICLanguageSettingEntry.MACRO:
+ return calculateEntries(info.getSymbols());
+ }
+ return new DiscoveredEntry[0];
+ }
+
+ private DiscoveredEntry[] calculateEntries(Map map){
+ DiscoveredEntry entries[] = new DiscoveredEntry[map.size()];
+ int num = 0;
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String name = (String)entry.getKey();
+ String value = (String)entry.getValue();
+ entries[num++] = new DiscoveredEntry(name, value);
+ }
+ return entries;
+ }
+
+ private DiscoveredEntry[] calculateEntries(String[] values){
+ DiscoveredEntry entries[] = new DiscoveredEntry[values.length];
+ for(int i = 0; i < values.length; i++){
+ String name = values[i];
+ entries[i] = new DiscoveredEntry(name);
+ }
+ return entries;
+ }
+
+ private DiscoveredEntry[] calculateEntries(IPath[] values){
+ DiscoveredEntry entries[] = new DiscoveredEntry[values.length];
+ for(int i = 0; i < values.length; i++){
+ String name = values[i].toString();
+ entries[i] = new DiscoveredEntry(name);
+ }
+ return entries;
+ }
+
+ private DiscoveredEntry[] calculateEntries(List list){
+ DiscoveredEntry entries[] = new DiscoveredEntry[list.size()];
+ int num = 0;
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ String name = (String)iter.next();
+ entries[num++] = new DiscoveredEntry(name);
+ }
+ return entries;
+ }
+
+//
+// private void calculateEntriesDynamically(final IProject project,
+// SCProfileInstance profileInstance,
+// final IScannerInfoCollector collector) {
+// // TODO Get the provider from the toolchain specification
+//
+// final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.
+// createScannerConfigBuildInfo2(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(),
+// profileInstance.getProfile().getId(), false);
+// List providerIds = buildInfo.getProviderIdList();
+// for (Iterator i = providerIds.iterator(); i.hasNext(); ) {
+// final String providerId = (String) i.next();
+// final IExternalScannerInfoProvider esiProvider = profileInstance.createExternalScannerInfoProvider(providerId);
+//
+// // Set the arguments for the provider
+//
+// ISafeRunnable runnable = new ISafeRunnable() {
+// public void run() {
+// IProgressMonitor monitor = new NullProgressMonitor();
+// esiProvider.invokeProvider(monitor, project, providerId, buildInfo, collector);
+// }
+//
+// public void handleException(Throwable exception) {
+// if (exception instanceof OperationCanceledException) {
+// throw (OperationCanceledException) exception;
+// }
+// }
+// };
+// Platform.run(runnable);
+// }
+// }
+//
+//
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java
new file mode 100644
index 00000000000..229aefad0a7
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.dataprovider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
+import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator;
+import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.ReferenceSettingsInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.Builder;
+import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public class ProjectConverter implements ICProjectConverter {
+ private final static String OLD_MAKE_BUILDER_ID = "org.eclipse.cdt.make.core.makeBuilder"; //$NON-NLS-1$
+ private final static String OLD_MAKE_NATURE_ID = "org.eclipse.cdt.make.core.makeNature"; //$NON-NLS-1$
+ private final static String OLD_MNG_BUILDER_ID = "org.eclipse.cdt.managedbuilder.core.genmakebuilder"; //$NON-NLS-1$
+ private final static String OLD_MNG_NATURE_ID = "org.eclipse.cdt.managedbuilder.core.managedBuildNature"; //$NON-NLS-1$
+ private final static String OLD_DISCOVERY_MODULE_ID = "scannerConfiguration"; //$NON-NLS-1$
+ private final static String OLD_BINARY_PARSER_ID = "org.eclipse.cdt.core.BinaryParser"; //$NON-NLS-1$
+ private final static String OLD_ERROR_PARSER_ID = "org.eclipse.cdt.core.ErrorParser"; //$NON-NLS-1$
+ private final static String OLD_PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
+ private final static String OLD_DISCOVERY_NATURE_ID = "org.eclipse.cdt.make.core.ScannerConfigNature"; //$NON-NLS-1$
+ private final static String OLD_DISCOVERY_BUILDER_ID = "org.eclipse.cdt.make.core.ScannerConfigBuilder"; //$NON-NLS-1$
+
+
+ public boolean canConvertProject(IProject project, String oldOwnerId, ICProjectDescription oldDes) {
+ try {
+ IProjectDescription eDes = project.getDescription();
+ Set natureSet = new HashSet(Arrays.asList(eDes.getNatureIds()));
+ if(natureSet.contains(OLD_MAKE_NATURE_ID))
+ return true;
+
+ if(natureSet.contains(OLD_MNG_NATURE_ID))
+ return true;
+
+ } catch (CoreException e) {
+ }
+
+ return false;
+// return ManagedBuildManager.canGetBuildInfo(project);
+ }
+
+ public ICProjectDescription convertProject(IProject project, IProjectDescription eDes, String oldOwnerId, ICProjectDescription oldDes)
+ throws CoreException {
+ Set natureSet = new HashSet(Arrays.asList(eDes.getNatureIds()));
+ CoreModel model = CoreModel.getDefault();
+ ICProjectDescription newDes = null;
+ IManagedBuildInfo info = null;
+ boolean adjustBinErrParsers = false;
+
+ if(natureSet.contains(OLD_MNG_NATURE_ID)){
+ newDes = model.createProjectDescription(project, false);
+ info = convertManagedBuildInfo(project, newDes);
+ } else if(natureSet.contains(OLD_MAKE_NATURE_ID)){
+ adjustBinErrParsers = true;
+ newDes = oldDes;
+ ICConfigurationDescription des = newDes.getConfigurations()[0];
+ info = ManagedBuildManager.createBuildInfo(project);
+ ManagedProject mProj = new ManagedProject(newDes);
+ info.setManagedProject(mProj);
+
+ Configuration cfg = ConfigurationDataProvider.getClearPreference(des.getId());
+ cfg.applyToManagedProject(mProj);
+
+ des.setConfigurationData(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
+ }
+
+ if(newDes == null || !newDes.isValid() || newDes.getConfigurations().length == 0){
+ newDes = null;
+ } else {
+ boolean changeEDes = false;
+ if(natureSet.remove(OLD_MAKE_NATURE_ID))
+ changeEDes = true;
+ if(natureSet.remove(OLD_DISCOVERY_NATURE_ID))
+ changeEDes = true;
+
+ if(changeEDes)
+ eDes.setNatureIds((String[])natureSet.toArray(new String[natureSet.size()]));
+
+ changeEDes = false;
+ ICommand[] cmds = eDes.getBuildSpec();
+ List list = new ArrayList(Arrays.asList(cmds));
+ ICommand makeBuilderCmd = null;
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ ICommand cmd = (ICommand)iter.next();
+ if(OLD_MAKE_BUILDER_ID.equals(cmd.getBuilderName())){
+ makeBuilderCmd = cmd;
+ iter.remove();
+ changeEDes = true;
+ } else if(OLD_DISCOVERY_BUILDER_ID.equals(cmd.getBuilderName())){
+ iter.remove();
+ changeEDes = true;
+ }
+ }
+
+ ICConfigurationDescription cfgDess[] = newDes.getConfigurations();
+ for(int i = 0; i < cfgDess.length; i++){
+ ICConfigurationDescription cfgDes = cfgDess[i];
+ BuildConfigurationData data = (BuildConfigurationData)cfgDes.getConfigurationData();
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+
+ if(makeBuilderCmd != null)
+ loadBuilderSettings(cfg, makeBuilderCmd);
+
+ loadDiscoveryOptions(cfgDes, cfg);
+
+ loadPathEntryInfo(project, cfgDes, data);
+
+ if(adjustBinErrParsers){
+ ICConfigExtensionReference refs[] = cfgDes.get(OLD_ERROR_PARSER_ID);
+ String ids[] = idsFromRefs(refs);
+ data.getTargetPlatformData().setBinaryParserIds(ids);
+
+ refs = cfgDes.get(OLD_ERROR_PARSER_ID);
+ ids = idsFromRefs(refs);
+ data.getBuildData().setErrorParserIDs(ids);
+ }
+
+ try {
+ ConfigurationDataProvider.writeConfiguration(cfgDes, data);
+ } catch (CoreException e){
+ }
+ }
+
+ if(changeEDes){
+ cmds = (ICommand[])list.toArray(new ICommand[list.size()]);
+ eDes.setBuildSpec(cmds);
+ }
+
+ info.setValid(true);
+
+
+ try {
+ ManagedBuildManager.setLoaddedBuildInfo(project, info);
+ } catch (Exception e) {
+ }
+ }
+
+ return newDes;
+ }
+
+ private void loadPathEntryInfo(IProject project, ICConfigurationDescription des, CConfigurationData data){
+ try {
+ ICStorageElement el = des.getStorage(OLD_PATH_ENTRY_ID, false);
+ if(el != null){
+ IPathEntry[] entries = PathEntryTranslator.decodePathEntries(project, el);
+ if(entries.length != 0){
+ List list = new ArrayList(Arrays.asList(entries));
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ IPathEntry entry = (IPathEntry)iter.next();
+ if(entry.getEntryKind() == IPathEntry.CDT_CONTAINER){
+ iter.remove();
+ continue;
+ }
+ }
+
+ if(list.size() != 0){
+ PathEntryTranslator tr = new PathEntryTranslator(project, data);
+ entries = (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
+ ReferenceSettingsInfo refInfo = tr.applyPathEntries(entries, null, PathEntryTranslator.OP_REPLACE);
+ ICExternalSetting extSettings[] = refInfo.getExternalSettings();
+ des.removeExternalSettings();
+ if(extSettings.length != 0){
+ ICExternalSetting setting;
+ for(int i = 0; i < extSettings.length; i++){
+ setting = extSettings[i];
+ des.createExternalSetting(setting.getCompatibleLanguageIds(),
+ setting.getCompatibleContentTypeIds(),
+ setting.getCompatibleExtensions(),
+ setting.getEntries());
+ }
+ }
+
+ IPath projPaths[] = refInfo.getReferencedProjectsPaths();
+ if(projPaths.length != 0){
+ Map map = new HashMap(projPaths.length);
+ for(int i = 0; i < projPaths.length; i++){
+ map.put(projPaths[i].segment(0), ""); //$NON-NLS-1$
+ }
+ des.setReferenceInfo(map);
+ }
+ }
+ }
+ des.removeStorage(OLD_PATH_ENTRY_ID);
+ }
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+
+ private String[] idsFromRefs(ICConfigExtensionReference refs[]){
+ String ids[] = new String[refs.length];
+ for(int i = 0; i < ids.length; i++){
+ ids[i] = refs[i].getID();
+ }
+ return ids;
+ }
+
+ private void loadDiscoveryOptions(ICConfigurationDescription des, IConfiguration cfg){
+ try {
+ ICStorageElement discoveryStorage = des.getStorage(OLD_DISCOVERY_MODULE_ID, false);
+ if(discoveryStorage != null){
+ Configuration config = (Configuration)cfg;
+ IScannerConfigBuilderInfo2 scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(cfg), discoveryStorage, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ config.setPerRcTypeDiscovery(false);
+ config.setScannerConfigInfo(scannerConfigInfo);
+ des.removeStorage(OLD_DISCOVERY_MODULE_ID);
+ }
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+
+
+ }
+
+ private void loadBuilderSettings(IConfiguration cfg, ICommand cmd){
+ IBuilder builder = BuilderFactory.createBuilderFromCommand(cfg, cmd);
+ if(builder.getCommand() != null && builder.getCommand().length() != 0){
+ ((ToolChain)cfg.getToolChain()).setBuilder((Builder)builder);
+ }
+ }
+
+ private IManagedBuildInfo convertManagedBuildInfo(IProject project, ICProjectDescription newDes){
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfoLegacy(project);
+ if(info != null && info.isValid()){
+ IManagedProject mProj = info.getManagedProject();
+ IConfiguration cfgs[] = mProj.getConfigurations();
+ if(cfgs.length != 0){
+ Configuration cfg;
+ CConfigurationData data;
+
+ for(int i = 0; i < cfgs.length; i++){
+ cfg = (Configuration)cfgs[i];
+ data = cfg.getConfigurationData();
+ try {
+ newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ } catch (WriteAccessException e) {
+ ManagedBuilderCorePlugin.log(e);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ cfg.exportArtifactInfo();
+ }
+ }
+ }
+ return info;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AdjustmentContext.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AdjustmentContext.java
new file mode 100644
index 00000000000..7ce13d88f18
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AdjustmentContext.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.enablement;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+public class AdjustmentContext {
+// static final int TYPE_CONFIGURATION = 1;
+// static final int TYPE_TOOL_CHAIN = 2;
+// static final int TYPE_TOOL = 3;
+// static final int TYPE_OPTION = 4;
+// static final int TYPE_OUTPUT_TYPE = 5;
+
+// private IBuildObject fObject;
+// private int fType;
+
+// class AfjustedInfo{
+// private boolean fAdjusted;
+//
+// void addAdjustmentState(boolean adjusted){
+// if(!fAdjusted && adjusted){
+// fAdjusted = adjusted;
+// }
+// }
+//
+// boolean isAdjusted(){
+// return fAdjusted;
+// }
+// }
+
+// AdjustmentInfo(IConfiguration cfg){
+// fObject = cfg;
+// fType = TYPE_CONFIGURATION;
+// }
+
+// public int getType(){
+// return fType;
+// }
+
+ private HashMap fMap = new HashMap();
+
+ public void addAdjustedState(String attr, boolean adjusted){
+ Boolean b = (Boolean)fMap.get(attr);
+ if(b == null ||
+ (adjusted &&
+ !b.booleanValue())){
+ fMap.put(attr, Boolean.valueOf(adjusted));
+ }
+ }
+
+ public String[] getUnadjusted(){
+ if(fMap.size() == 0)
+ return new String[0];
+
+ ArrayList list = new ArrayList(fMap.size());
+ for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Boolean b = (Boolean)entry.getValue();
+ if(!b.booleanValue()){
+ list.add(entry.getKey());
+ }
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AndExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AndExpression.java
index df698683cf5..4127b181ee7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AndExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/AndExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class AndExpression extends CompositeExpression {
public static final String NAME = "and"; //$NON-NLS-1$
@@ -22,12 +22,12 @@ public class AndExpression extends CompositeExpression {
super(element);
}
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option) {
IBooleanExpression children[] = getChildren();
for(int i = 0; i < children.length; i++){
- if(!children[i].evaluate(configuration, holder, option))
+ if(!children[i].evaluate(rcInfo, holder, option))
return false;
}
return true;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckBuildPropertyExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckBuildPropertyExpression.java
new file mode 100644
index 00000000000..98bb131a5f3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckBuildPropertyExpression.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.enablement;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+
+public class CheckBuildPropertyExpression implements IBooleanExpression {
+ public static final String NAME = "checkBuildProperty"; //$NON-NLS-1$
+
+ public static final String PROPERTY = "property"; //$NON-NLS-1$
+ public static final String VALUE = "value"; //$NON-NLS-1$
+
+ private String fPropertyId;
+ private String fValueId;
+
+ public CheckBuildPropertyExpression(IManagedConfigElement element){
+ fPropertyId = element.getAttribute(PROPERTY);
+ if(fPropertyId == null)
+ fPropertyId = ""; //$NON-NLS-1$
+
+ fValueId = element.getAttribute(VALUE);
+// if(fValueId == null)
+// fValueId = ""; //$NON-NLS-1$
+
+// fIsRegex = getBooleanValue(element.getAttribute(IS_REGEX));
+ }
+
+
+ public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
+ IOption option) {
+ IConfiguration cfg = rcInfo.getParent();
+ IBuildProperty prop = getBuildProperty(cfg, fPropertyId);
+ if(prop != null){
+ return fValueId != null ? fValueId.equals(prop.getValue().getId()) : true;
+ }
+ return false;
+ }
+/*
+ public static IBuildProperty getBuildProperty(IHoldsOptions ho, String id){
+ if(ho instanceof ITool)
+ return getBuildProperty((ITool)ho, id);
+ if(ho instanceof IToolChain)
+ return getBuildProperty((IToolChain)ho, id);
+ return null;
+ }
+
+ public static IBuildProperty getBuildProperty(ITool tool, String id){
+ IBuildProperty prop = tool.getBuildProperties().getProperty(id);
+ if(prop == null){
+ IBuildObject parent = tool.getParent();
+ if(parent instanceof IToolChain){
+ prop = getBuildProperty((IToolChain)parent, id);
+ } else if (parent instanceof IFileInfo) {
+ prop = getBuildProperty((IFileInfo)parent, id);
+ }
+ }
+ return prop;
+ }
+
+ public static IBuildProperty getBuildProperty(IFileInfo info, String id){
+ return getBuildProperty(info.getParent(), id);
+ }
+
+ public static IBuildProperty getBuildProperty(IFolderInfo info, String id){
+ return getBuildProperty(info.getParent(), id);
+ }
+
+ public static IBuildProperty getBuildProperty(IToolChain toolChain, String id){
+ IBuildProperty prop = null;
+ if(toolChain.getParentFolderInfo() == toolChain.getParent().getRootFolderInfo())
+ prop = toolChain.getBuildProperties().getProperty(id);
+
+ if(prop == null){
+ prop = getBuildProperty(toolChain.getParentFolderInfo(), id);
+ }
+ return prop;
+ }
+*/
+ public static IBuildProperty getBuildProperty(IConfiguration cfg, String id){
+ IBuildProperty prop = cfg.getBuildProperties().getProperty(id);
+
+// if(prop == null)
+// prop = cfg.getManagedProject().getBuildProperties().getProperty(id);
+
+ return prop;
+ }
+
+ public String getPropertyId(){
+ return fPropertyId;
+ }
+
+ public String getValueId(){
+ return fValueId;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckHolderExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckHolderExpression.java
index 5bf316b81fe..640c4f2c20f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckHolderExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckHolderExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
@@ -29,7 +29,7 @@ public class CheckHolderExpression implements IBooleanExpression {
}
- public boolean evaluate(IBuildObject configuration, IHoldsOptions holder,
+ public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOption option) {
if(fHolderId != null){
for(; holder != null; holder = getHolderSuperClass(holder)){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckOptionExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckOptionExpression.java
index 1ff7431d059..eb1d445e1f4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckOptionExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckOptionExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -14,23 +14,26 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
public class CheckOptionExpression implements IBooleanExpression {
public static final String NAME = "checkOption"; //$NON-NLS-1$
@@ -42,9 +45,6 @@ public class CheckOptionExpression implements IBooleanExpression {
public static final String OTHER_OPTION_ID = "otherOptionId"; //$NON-NLS-1$
public static final String OTHER_HOLDER_ID = "otherHolderId"; //$NON-NLS-1$
- public static final String YES = "yes"; //$NON-NLS-1$
- public static final String TRUE = "true"; //$NON-NLS-1$
-
private String fOptionId;
private String fHolderId;
private String fValue;
@@ -56,24 +56,24 @@ public class CheckOptionExpression implements IBooleanExpression {
fOptionId = element.getAttribute(OPTION_ID);
fHolderId = element.getAttribute(HOLDER_ID);
fValue = element.getAttribute(VALUE);
- fIsRegex = getBooleanValue(element.getAttribute(IS_REGEX));
+ fIsRegex = OptionEnablementExpression.getBooleanValue(element.getAttribute(IS_REGEX));
fOtherOptionId = element.getAttribute(OTHER_OPTION_ID);
fOtherHolderId = element.getAttribute(OTHER_HOLDER_ID);
}
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option) {
boolean result = false;
IBuildObject ho[] = getHolderAndOption(fOptionId, fHolderId,
- configuration, holder, option);
+ rcInfo, holder, option);
if(ho != null){
if(fValue != null)
result = evaluate((IOption)ho[1],((IHoldsOptions)ho[0]),fValue);
else {
IBuildObject otherHo[] = getHolderAndOption(fOtherOptionId, fOtherHolderId,
- configuration, holder, option);
+ rcInfo, holder, option);
if(otherHo != null)
result = evaluate((IOption)ho[1],((IHoldsOptions)ho[0]),
(IOption)otherHo[1],((IHoldsOptions)otherHo[0]));
@@ -107,12 +107,16 @@ public class CheckOptionExpression implements IBooleanExpression {
return stringValue.equals(resolvedValue);
}
case IOption.BOOLEAN:
- return option.getBooleanValue() == getBooleanValue(resolvedValue);
+ return option.getBooleanValue() == OptionEnablementExpression.getBooleanValue(resolvedValue);
case IOption.INCLUDE_PATH:
case IOption.STRING_LIST:
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
- case IOption.OBJECTS:{
+ case IOption.OBJECTS:
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:{
List list = (List)option.getValue();
String listValue = provider.convertStringListToString((String[])list.toArray(new String[list.size()]),delimiter);
@@ -136,14 +140,6 @@ public class CheckOptionExpression implements IBooleanExpression {
return false;
}
- protected boolean getBooleanValue(String value){
- if(TRUE.equalsIgnoreCase(value))
- return true;
- else if(YES.equalsIgnoreCase(value))
- return true;
- return false;
- }
-
public boolean evaluate(IOption option, IHoldsOptions holder,
IOption otherOption, IHoldsOptions otherHolder){
try {
@@ -175,7 +171,11 @@ public class CheckOptionExpression implements IBooleanExpression {
case IOption.STRING_LIST:
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
- case IOption.OBJECTS:{
+ case IOption.OBJECTS:
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:{
List list = (List)option.getValue();
String listValue[] = (String[])list.toArray(new String[list.size()]);
@@ -184,15 +184,15 @@ public class CheckOptionExpression implements IBooleanExpression {
IMacroContextInfo info = provider.getMacroContextInfo(IBuildMacroProvider.CONTEXT_OPTION,
new OptionContextData(option,holder));
- IMacroSubstitutor subst = provider.getMacroSubstitutor(info,inexVal,delimiter);
+ SupplierBasedCdtVariableSubstitutor subst = provider.getMacroSubstitutor(info,inexVal,delimiter);
- listValue = MacroResolver.resolveStringListValues(listValue,subst,false);
+ listValue = CdtVariableResolver.resolveStringListValues(listValue,subst,false);
info = provider.getMacroContextInfo(IBuildMacroProvider.CONTEXT_OPTION,
new OptionContextData(otherOption,otherHolder));
subst = provider.getMacroSubstitutor(info,inexVal,delimiter);
- otherValue = MacroResolver.resolveStringListValues(otherValue,subst,false);
+ otherValue = CdtVariableResolver.resolveStringListValues(otherValue,subst,false);
if(listValue.length == otherValue.length){
for(int i = 0; i < listValue.length; i++){
@@ -207,7 +207,7 @@ public class CheckOptionExpression implements IBooleanExpression {
break;
}
} catch (BuildException e) {
- } catch (BuildMacroException e) {
+ } catch (CdtVariableException e) {
} catch (ClassCastException e) {
}
return false;
@@ -215,7 +215,7 @@ public class CheckOptionExpression implements IBooleanExpression {
protected IBuildObject[] getHolderAndOption(String optionId,
String holderId,
- IBuildObject configuration,
+ IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option
){
@@ -227,7 +227,7 @@ public class CheckOptionExpression implements IBooleanExpression {
if(holderId == null)
hld = holder;
else
- hld = getHolder(holderId,configuration);
+ hld = getHolder(holderId,rcInfo);
if(hld != null) {
IOption opt = getOption(optionId,hld);
@@ -244,18 +244,18 @@ public class CheckOptionExpression implements IBooleanExpression {
}
protected IHoldsOptions getHolder(String id,
- IBuildObject cfg){
+ IResourceInfo rcInfo){
IHoldsOptions holder = null;
- if(cfg instanceof IResourceConfiguration){
- IHoldsOptions holders[] = ((IResourceConfiguration)cfg).getTools();
+ if(rcInfo instanceof IFileInfo){
+ IHoldsOptions holders[] = ((IResourceConfiguration)rcInfo).getTools();
for(int i = 0; i < holders.length; i++){
if(isHolder(id,holders[i])){
holder = holders[i];
break;
}
}
- } else if (cfg instanceof IConfiguration){
- IToolChain tc = ((IConfiguration)cfg).getToolChain();
+ } else if (rcInfo instanceof IFolderInfo){
+ IToolChain tc = ((IFolderInfo)rcInfo).getToolChain();
if(isHolder(id,tc))
holder = tc;
else {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckStringExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckStringExpression.java
index 8d7d8859fbb..b46eb3161ec 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckStringExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CheckStringExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -17,6 +17,7 @@ import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
@@ -30,9 +31,6 @@ public class CheckStringExpression implements IBooleanExpression {
public static final String VALUE = "value"; //$NON-NLS-1$
public static final String IS_REGEX = "isRegex"; //$NON-NLS-1$
- public static final String YES = "yes"; //$NON-NLS-1$
- public static final String TRUE = "true"; //$NON-NLS-1$
-
private String fString;
private String fValue;
private boolean fIsRegex;
@@ -46,18 +44,10 @@ public class CheckStringExpression implements IBooleanExpression {
if(fValue == null)
fValue = new String();
- fIsRegex = getBooleanValue(element.getAttribute(IS_REGEX));
+ fIsRegex = OptionEnablementExpression.getBooleanValue(element.getAttribute(IS_REGEX));
}
- protected boolean getBooleanValue(String value){
- if(TRUE.equalsIgnoreCase(value))
- return true;
- else if(YES.equalsIgnoreCase(value))
- return true;
- return false;
- }
-
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CompositeExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CompositeExpression.java
index a327a94b198..c8c1e962496 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CompositeExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/CompositeExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,6 +10,11 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
public abstract class CompositeExpression implements IBooleanExpression {
@@ -48,10 +53,40 @@ public abstract class CompositeExpression implements IBooleanExpression {
return new FalseExpression(element);
else if(CheckHolderExpression.NAME.equals(name))
return new CheckHolderExpression(element);
+ else if(CheckBuildPropertyExpression.NAME.equals(name)){
+ return new CheckBuildPropertyExpression(element);
+ }
return null;
}
public IBooleanExpression[] getChildren(){
return fChildren;
}
+
+ public Map getReferencedProperties(Map map){
+ IBooleanExpression children[] = getChildren();
+ if(map == null)
+ map = new HashMap();
+
+ for(int i = 0; i < children.length; i++){
+ IBooleanExpression child = children[i];
+ if(child instanceof CompositeExpression){
+ ((CompositeExpression)child).getReferencedProperties(map);
+ } else if(child instanceof CheckBuildPropertyExpression){
+ CheckBuildPropertyExpression bp = (CheckBuildPropertyExpression)child;
+ String prop = bp.getPropertyId();
+ String val = bp.getValueId();
+ if(prop != null && prop.length() != 0
+ && val != null && val.length() != 0){
+ Set set = (Set)map.get(prop);
+ if(set == null){
+ set = new HashSet();
+ map.put(prop, set);
+ }
+ set.add(val);
+ }
+ }
+ }
+ return map;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/FalseExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/FalseExpression.java
index 9e29ca2b523..59d6a9598e9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/FalseExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/FalseExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class FalseExpression implements IBooleanExpression {
public static final String NAME = "false"; //$NON-NLS-1$
@@ -21,7 +21,7 @@ public class FalseExpression implements IBooleanExpression {
public FalseExpression(IManagedConfigElement element) {
}
- public boolean evaluate(IBuildObject configuration, IHoldsOptions holder,
+ public boolean evaluate(IResourceInfo rcInfo, IHoldsOptions holder,
IOption option) {
return false;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/IBooleanExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/IBooleanExpression.java
index 124495845ad..b3718be6143 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/IBooleanExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/IBooleanExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement;
-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.IResourceInfo;
public interface IBooleanExpression {
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/NotExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/NotExpression.java
index 137295efdfd..927b33de382 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/NotExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/NotExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -14,6 +14,7 @@ import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class NotExpression extends AndExpression {
public static final String NAME = "not"; //$NON-NLS-1$
@@ -22,10 +23,10 @@ public class NotExpression extends AndExpression {
super(element);
}
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option) {
- return !super.evaluate(configuration, holder, option);
+ return !super.evaluate(rcInfo, holder, option);
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OptionEnablementExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OptionEnablementExpression.java
index 0e10a7708ef..fdf46a054ea 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OptionEnablementExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OptionEnablementExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -14,10 +14,15 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.managedbuilder.core.BuildException;
-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.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
public class OptionEnablementExpression extends AndExpression{
public static final String NAME = "enablement"; //$NON-NLS-1$
@@ -34,11 +39,28 @@ public class OptionEnablementExpression extends AndExpression{
public static final String ATTRIBUTE = "attribute"; //$NON-NLS-1$
public static final String VALUE = "value"; //$NON-NLS-1$
- private static final String fSupportedAttributes[] = {
+ public static final String EXTENSION_ADJUSTMENT = "extensionAdjustment"; //$NON-NLS-1$
+
+ public static final String YES = "yes"; //$NON-NLS-1$
+ public static final String TRUE = "true"; //$NON-NLS-1$
+
+
+ private static final String fSupportedOptionAttributes[] = {
IOption.COMMAND,
IOption.COMMAND_FALSE,
+ IOption.VALUE,
+ IOption.DEFAULT_VALUE,
};
-
+
+ private static final String fSupportedToolChainAttributes[] = {
+ IToolChain.TARGET_TOOL,
+ };
+
+ private static final String fSupportedConfigurationAttributes[] = {
+ IConfiguration.EXTENSION,
+ IConfiguration.ARTIFACT_NAME,
+ };
+
public static final int FLAG_UI_VISIBILITY = 0x01;
public static final int FLAG_UI_ENABLEMENT = 0x02;
public static final int FLAG_CMD_USAGE = 0x04;
@@ -48,6 +70,7 @@ public class OptionEnablementExpression extends AndExpression{
private int fEnablementFlags;
private String fAttribute;
private String fValue;
+ private boolean fIsExtensionAdjustment;
public OptionEnablementExpression(IManagedConfigElement element) {
super(element);
@@ -56,18 +79,46 @@ public class OptionEnablementExpression extends AndExpression{
fAttribute = element.getAttribute(ATTRIBUTE);
fValue = element.getAttribute(VALUE);
+ String tmp = element.getAttribute(EXTENSION_ADJUSTMENT);
+
adjustAttributeSupport();
+
+ if(tmp != null) {
+ fIsExtensionAdjustment = getBooleanValue(tmp);
+ } else {
+ fIsExtensionAdjustment = checkFlags(FLAG_CONTAINER_ATTRIBUTE) ?
+ false : true;
+ }
}
private void adjustAttributeSupport(){
boolean cleanAttrFlag = true;
if(fAttribute != null && fValue != null){
- for(int i = 0; i < fSupportedAttributes.length; i++){
- if(fAttribute.equals(fSupportedAttributes[i])){
+ for(int i = 0; i < fSupportedOptionAttributes.length; i++){
+ if(fAttribute.equals(fSupportedOptionAttributes[i])){
cleanAttrFlag = false;
break;
}
}
+
+ if(cleanAttrFlag){
+ for(int i = 0; i < fSupportedToolChainAttributes.length; i++){
+ if(fAttribute.equals(fSupportedToolChainAttributes[i])){
+ cleanAttrFlag = false;
+ break;
+ }
+ }
+ }
+
+ if(cleanAttrFlag){
+ for(int i = 0; i < fSupportedConfigurationAttributes.length; i++){
+ if(fAttribute.equals(fSupportedConfigurationAttributes[i])){
+ cleanAttrFlag = false;
+ break;
+ }
+ }
+ }
+
}
if(cleanAttrFlag){
@@ -127,19 +178,19 @@ public class OptionEnablementExpression extends AndExpression{
return flags;
}
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option,
int flags){
- return evaluate(configuration, holder, option, flags, (FLAG_CONTAINER_ATTRIBUTE & flags) == 0);
+ return evaluate(rcInfo, holder, option, flags, (FLAG_CONTAINER_ATTRIBUTE & flags) == 0);
}
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option,
int flags,
boolean bDefault){
- return checkFlags(flags) ? evaluate(configuration, holder, option)
+ return checkFlags(flags) ? evaluate(rcInfo, holder, option)
: bDefault;
}
@@ -159,24 +210,289 @@ public class OptionEnablementExpression extends AndExpression{
return fEnablementFlags;
}
- public boolean performAdjustment(IBuildObject configuration,
+/* public boolean performAdjustment(IBuildObject configuration,
IHoldsOptions holder,
- IOption option){
- if(evaluate(configuration,holder,option,FLAG_CONTAINER_ATTRIBUTE)){
- try{
- if(IOption.COMMAND.equals(fAttribute)){
- IOption setOption = holder.getOptionToSet(option, true);
- setOption.setCommand(fValue);
- }else if(IOption.COMMAND_FALSE.equals(fAttribute)){
- IOption setOption = holder.getOptionToSet(option, true);
- setOption.setCommandFalse(fValue);
- }else
- return false;
- }catch (BuildException e){
- return false;
+ IOption option,
+ boolean extensionAdjustment){
+ boolean adjusted = false;
+ if(canPerformAdjustment(extensionAdjustment)){
+ if(evaluate(configuration,holder,option,FLAG_CONTAINER_ATTRIBUTE)){
+ if(option != null){
+ adjusted = adjustOption(configuration, holder, option, extensionAdjustment);
+ } else if (holder != null){
+ if(holder instanceof ITool){
+ adjusted = adjustTool(configuration, (ITool)holder, extensionAdjustment);
+ } else if(holder instanceof IToolChain){
+ adjusted = adjustToolChain(configuration, (IToolChain)holder, extensionAdjustment);
+ }
+ } else if (configuration != null){
+ if(configuration instanceof IConfiguration){
+ adjusted = adjustConfiguration((IConfiguration)holder, extensionAdjustment);
+ }
+ }
}
- return true;
}
+ return adjusted;
+ }
+*/
+ private static IOption getOptionToSet(IHoldsOptions holder,
+ IOption option,
+ String value,
+ boolean extensionAdjustment){
+ IOption optionToSet = null;
+ if(value != null){
+ try {
+ optionToSet = holder.getOptionToSet(option, extensionAdjustment);
+ } catch (BuildException e) {
+ }
+ } else {
+ if(!extensionAdjustment && option.getOptionHolder() == holder){
+ optionToSet = option;
+ }
+ }
+ return optionToSet;
+ }
+
+ public static boolean adjustOption(IResourceInfo rcInfo,
+ IHoldsOptions holder,
+ IOption option,
+ String attribute,
+ String value,
+ boolean extensionAdjustment
+ ){
+
+ if(value == null && rcInfo.isExtensionElement())
+ return false;
+
+ IOption setOption = getOptionToSet(holder, option, value, extensionAdjustment);
+ if(setOption == null)
+ return false;
+
+ boolean adjusted = true;
+ try{
+ if(IOption.COMMAND.equals(attribute)){
+// IOption setOption = holder.getOptionToSet(option, extensionAdjustment);
+ setOption.setCommand(value);
+ }else if(IOption.COMMAND_FALSE.equals(attribute)){
+// IOption setOption = holder.getOptionToSet(option, extensionAdjustment);
+ setOption.setCommandFalse(value);
+ }else if(IOption.VALUE.equals(attribute)){
+// IOption setOption = holder.getOptionToSet(option, extensionAdjustment);
+ switch(setOption.getValueType()){
+ case IOption.BOOLEAN:
+ Boolean bValue = value != null ? Boolean.valueOf(value) : null;
+ if(extensionAdjustment)
+ setOption.setValue(bValue);
+ else{
+ if (bValue == null) {
+ IOption superOption = setOption.getSuperClass();
+ if(superOption != null){
+ bValue = Boolean.valueOf(superOption.getBooleanValue());
+ }
+ }
+
+ if(bValue != null)
+ ManagedBuildManager.setOption(rcInfo, holder, setOption, bValue.booleanValue());
+ else
+ setOption.setValue((Object)null);
+ }
+ break;
+ case IOption.ENUMERATED:
+ case IOption.STRING:
+ if(extensionAdjustment)
+ setOption.setValue(value);
+ else
+ ManagedBuildManager.setOption(rcInfo, holder, setOption, value);
+ break;
+ case IOption.STRING_LIST:
+ case IOption.INCLUDE_PATH:
+ case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
+ case IOption.OBJECTS:
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
+ //TODO: add String list value support
+ adjusted = false;
+ break;
+ }
+ } else if(IOption.DEFAULT_VALUE.equals(attribute)){
+ switch(setOption.getValueType()){
+ case IOption.BOOLEAN:
+ Boolean bValue = value != null ? Boolean.valueOf(value) : null;
+ setOption.setDefaultValue(bValue);
+ break;
+ case IOption.ENUMERATED:
+ case IOption.STRING:
+ setOption.setDefaultValue(value);
+ break;
+ case IOption.STRING_LIST:
+ case IOption.INCLUDE_PATH:
+ case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
+ case IOption.OBJECTS:
+ //TODO: add String list value support
+ adjusted = false;
+ break;
+ }
+ } else
+ adjusted = false;
+ }catch (BuildException e){
+ adjusted = false;
+ }
+ return adjusted;
+ }
+
+ public boolean adjustOption(IResourceInfo rcInfo,
+ IHoldsOptions holder,
+ IOption option,
+ AdjustmentContext context,
+ boolean extensionAdjustment){
+ if(!canPerformAdjustment(extensionAdjustment))
+ return false;
+
+ boolean needed = adjustmentNeeded(rcInfo, holder, option);
+
+ if(context != null)
+ context.addAdjustedState(fAttribute, needed);
+
+ if(needed)
+ return adjustOption(rcInfo, holder, option, fAttribute, fValue, extensionAdjustment);
+ return false;
+ }
+
+ private boolean adjustmentNeeded(IResourceInfo rcInfo,
+ IHoldsOptions holder,
+ IOption option){
+ return evaluate(rcInfo,holder,option,FLAG_CONTAINER_ATTRIBUTE);
+ }
+
+ private boolean adjustmentNeeded(IFolderInfo info, IToolChain tChain){
+ return adjustmentNeeded(info,tChain,null);
+ }
+
+ private boolean adjustmentNeeded(IResourceInfo info, ITool tool){
+ return adjustmentNeeded(info,tool,null);
+ }
+
+ private boolean adjustmentNeeded(IConfiguration cfg){
+ return adjustmentNeeded(cfg.getRootFolderInfo(),null,null);
+ }
+
+ public static boolean adjustToolChain(IFolderInfo info,
+ IToolChain tChain,
+ String attrbute,
+ String value,
+ boolean extensionAdjustment){
+
+ if(value == null && tChain.isExtensionElement())
+ return false;
+
+ boolean adjusted = true;
+
+ if(IToolChain.TARGET_TOOL.equals(attrbute)){
+ tChain.setTargetToolIds(value);
+ }else{
+ adjusted = false;
+ }
+
+ return adjusted;
+ }
+
+ public boolean adjustToolChain(IFolderInfo info,
+ IToolChain tChain,
+ AdjustmentContext context,
+ boolean extensionAdjustment){
+ if(!canPerformAdjustment(extensionAdjustment))
+ return false;
+
+ boolean needed = adjustmentNeeded(info, tChain);
+
+ if(context != null)
+ context.addAdjustedState(fAttribute, needed);
+
+ if(needed)
+ return adjustToolChain(info, tChain, fAttribute, fValue, extensionAdjustment);
+ return false;
+ }
+
+ public static boolean adjustTool(IResourceInfo info,
+ ITool tool,
+ String attribute,
+ String value,
+ boolean extensionAdjustment){
+
+ if(value == null && tool.isExtensionElement())
+ return false;
+
+ return false;
+ }
+
+ public boolean adjustTool(IResourceInfo info,
+ ITool tool,
+ AdjustmentContext context,
+ boolean extensionAdjustment){
+ if(!canPerformAdjustment(extensionAdjustment))
+ return false;
+
+ boolean needed = adjustmentNeeded(info, tool);
+
+ if(context != null)
+ context.addAdjustedState(fAttribute, needed);
+
+ if(needed)
+ return adjustTool(info, tool, fAttribute, fValue, extensionAdjustment);
+ return false;
+ }
+
+ public static boolean adjustConfiguration(IConfiguration cfg,
+ String attribute,
+ String value,
+ boolean extensionAdjustment){
+
+ if(value == null && cfg.isExtensionElement())
+ return false;
+
+ boolean adjusted = true;
+
+ if(IConfiguration.EXTENSION.equals(attribute)){
+ cfg.setArtifactExtension(value);
+ } else if(IConfiguration.ARTIFACT_NAME.equals(attribute)){
+ cfg.setArtifactName(value);
+ } else{
+ adjusted = false;
+ }
+
+ return adjusted;
+ }
+
+ public boolean adjustConfiguration(IConfiguration cfg,
+ AdjustmentContext context,
+ boolean extensionAdjustment){
+ if(!canPerformAdjustment(extensionAdjustment))
+ return false;
+
+ boolean needed = adjustmentNeeded(cfg);
+
+ if(context != null)
+ context.addAdjustedState(fAttribute, needed);
+
+ if(needed)
+ return adjustConfiguration(cfg, fAttribute, fValue, extensionAdjustment);
+ return false;
+ }
+
+ public boolean canPerformAdjustment(boolean extensionAdjustment){
+ return fIsExtensionAdjustment == extensionAdjustment
+ && checkFlags(FLAG_CONTAINER_ATTRIBUTE);
+ }
+
+ public static boolean getBooleanValue(String value){
+ if(TRUE.equalsIgnoreCase(value))
+ return true;
+ else if(YES.equalsIgnoreCase(value))
+ return true;
return false;
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OrExpression.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OrExpression.java
index 402ecef2b35..55f13650c8a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OrExpression.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/enablement/OrExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.enablement;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
public class OrExpression extends CompositeExpression {
public static final String NAME = "or"; //$NON-NLS-1$
@@ -22,12 +22,12 @@ public class OrExpression extends CompositeExpression {
super(element);
}
- public boolean evaluate(IBuildObject configuration,
+ public boolean evaluate(IResourceInfo rcInfo,
IHoldsOptions holder,
IOption option) {
IBooleanExpression children[] = getChildren();
for(int i = 0; i < children.length; i++){
- if(children[i].evaluate(configuration, holder, option))
+ if(children[i].evaluate(rcInfo, holder, option))
return true;
}
return false;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java
index 33b93d7dc02..7c336657357 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.envvar;
+import org.eclipse.cdt.core.envvar.EnvirinmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
/**
@@ -17,17 +19,9 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
*
* @since 3.0
*/
-public class BuildEnvVar implements IBuildEnvironmentVariable {
- protected String fName;
- protected String fValue;
- protected String fDelimiter;
- protected int fOperation;
-
+public class BuildEnvVar extends EnvirinmentVariable implements IBuildEnvironmentVariable {
public BuildEnvVar(String name, String value, int op, String delimiter){
- fName = name;
- fOperation = op;
- fValue = value;
- fDelimiter = delimiter;
+ super(name, value, op, delimiter);
}
protected BuildEnvVar(){
@@ -35,46 +29,18 @@ public class BuildEnvVar implements IBuildEnvironmentVariable {
}
public BuildEnvVar(String name){
- this(name,null,ENVVAR_REPLACE,null);
+ super(name);
}
public BuildEnvVar(String name, String value){
- this(name,value,ENVVAR_REPLACE,null);
+ super(name, value);
}
public BuildEnvVar(String name, String value, String delimiter){
- this(name,value,ENVVAR_REPLACE,delimiter);
+ super(name, value, delimiter);
}
- public BuildEnvVar(IBuildEnvironmentVariable var){
- this(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getName()
- */
- public String getName(){
- return fName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getValue()
- */
- public String getValue(){
- return fValue;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getOperation()
- */
- public int getOperation(){
- return fOperation;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getDelimiter()
- */
- public String getDelimiter(){
- return fDelimiter;
+ public BuildEnvVar(IEnvironmentVariable var){
+ super(var);
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/DefaultContextInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/DefaultContextInfo.java
deleted file mode 100644
index 90044eb5a94..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/DefaultContextInfo.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-/**
- * The default implementation of the IContextInfo used by the Environment Variable Provider
- * Used to represent the Configuration, Project, Workspace and Eclipse environment contexts
- *
- * @since 3.0
- */
-public class DefaultContextInfo implements IContextInfo{
- private Object fContextObject;
- private IEnvironmentVariableSupplier fContextSuppliers[];
-
- /**
- * This constructor is used to create the default context info given a context object
- *
- * @param context
- */
- public DefaultContextInfo(Object context){
- fContextObject = context;
- }
-
- protected DefaultContextInfo(Object context, IEnvironmentVariableSupplier suppliers[]){
- fContextSuppliers = suppliers;
- fContextObject = context;
- }
-
- /*
- * answers the list of suppliers that should be used for the given context
- */
- protected IEnvironmentVariableSupplier[] getSuppliers(Object context){
- IEnvironmentVariableSupplier suppliers[];
- if(context == null)
- suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fEclipseSupplier};
- else if(context instanceof IWorkspace)
- suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fUserSupplier};
- else if(context instanceof IManagedProject)
- suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fUserSupplier,EnvironmentVariableProvider.fExternalSupplier};
- else if(context instanceof IConfiguration)
- suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fUserSupplier,EnvironmentVariableProvider.fExternalSupplier,EnvironmentVariableProvider.fMbsSupplier};
- else
- suppliers = null;
- return suppliers;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext()
- */
- public IContextInfo getNext(){
- DefaultContextInfo next = null;
- if(fContextObject == null)
- next = null;
- else if(fContextObject instanceof IWorkspace)
- next = new DefaultContextInfo(null);
- else if(fContextObject instanceof IManagedProject)
- next = new DefaultContextInfo(ResourcesPlugin.getWorkspace());
- else if(fContextObject instanceof IConfiguration)
- next = new DefaultContextInfo(((IConfiguration)fContextObject).getManagedProject());
- else
- next = null;
-
- if(next != null && next.getSuppliers() == null)
- next = null;
- return next;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getSuppliers()
- */
- public IEnvironmentVariableSupplier[] getSuppliers(){
- if(fContextSuppliers == null)
- fContextSuppliers = getSuppliers(fContextObject);
- return fContextSuppliers;
- }
-
- protected void setSuppliers(IEnvironmentVariableSupplier suppliers[]){
- fContextSuppliers = suppliers;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getContext()
- */
- public Object getContext(){
- return fContextObject;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvironmentVariableProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvironmentVariableProvider.java
index 8f5a4bbb8ee..97dd530bef8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvironmentVariableProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvironmentVariableProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -12,31 +12,23 @@ package org.eclipse.cdt.managedbuilder.internal.envvar;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.EnvironmentMacroSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
/**
* This class implements the IEnvironmentVariableProvider interface and provides all
@@ -47,24 +39,18 @@ import org.eclipse.core.runtime.QualifiedName;
*/
public class EnvironmentVariableProvider implements
IEnvironmentVariableProvider {
- private static final QualifiedName fBuildPathVarProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "buildPathVar"); //$NON-NLS-1$
+// private static final QualifiedName fBuildPathVarProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "buildPathVar"); //$NON-NLS-1$
- private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
- private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
+// private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
+// private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
private static EnvironmentVariableProvider fInstance = null;
private List fListeners = null;
+ private IEnvironmentVariableManager fMngr;
- private EnvVarMacroSubstitutor fMacroSubstitutor;
+// private StoredBuildPathEnvironmentContainer fIncludeStoredBuildPathVariables;
+// private StoredBuildPathEnvironmentContainer fLibraryStoredBuildPathVariables;
- private StoredBuildPathEnvironmentContainer fIncludeStoredBuildPathVariables;
- private StoredBuildPathEnvironmentContainer fLibraryStoredBuildPathVariables;
-
- public static final UserDefinedEnvironmentSupplier fUserSupplier = new UserDefinedEnvironmentSupplier();
- public static final ExternalExtensionEnvironmentSupplier fExternalSupplier = new ExternalExtensionEnvironmentSupplier();
- public static final MbsEnvironmentSupplier fMbsSupplier = new MbsEnvironmentSupplier();
- public static final EclipseEnvironmentSupplier fEclipseSupplier = new EclipseEnvironmentSupplier();
-
/**
* This class is used by the EnvironmentVariableProvider to calculate the build paths
* in case a tool-integrator did not provide the special logic for obtaining the build
@@ -92,293 +78,108 @@ public class EnvironmentVariableProvider implements
}
- public class EnvVarMacroSubstitutor extends DefaultMacroSubstitutor {
- private String fDefaultDelimiter;
- public EnvVarMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
- super(contextType,contextData,inexistentMacroValue,listDelimiter);
- fDefaultDelimiter = listDelimiter;
- }
-
- public EnvVarMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
- super(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
- fDefaultDelimiter = listDelimiter;
- }
-
- public IBuildEnvironmentVariable resolveVariable(EnvVarDescriptor var) throws BuildMacroException {
- String value;
- if(var == null || (value = var.getValue()) == null || value.length() == 0 || var.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
- return var;
-
- String listDelimiter = var.getDelimiter();
- if(listDelimiter == null)
- listDelimiter = fDefaultDelimiter;
- setListDelimiter(listDelimiter);
- IBuildMacro macro = EnvironmentMacroSupplier.getInstance().createBuildMacro(var);
- IMacroContextInfo varMacroInfo = getVarMacroContextInfo(var);
- int varSupplierNum = getVarMacroSupplierNum(var,varMacroInfo);
- value = resolveToString(new MacroDescriptor(macro,varMacroInfo,varSupplierNum));
- removeResolvedMacro(var.getName());
- return new BuildEnvVar(var.getName(),value,var.getOperation(),var.getDelimiter());
- }
-
- protected IMacroContextInfo getVarMacroContextInfo(EnvVarDescriptor var){
- IContextInfo info = var.getContextInfo();
- if(info != null)
- return getMacroContextInfoForContext(info.getContext());
- return null;
- }
-
- protected int getVarMacroSupplierNum(EnvVarDescriptor var, IMacroContextInfo varMacroInfo){
- int varSupplierNum = -1;
- IBuildMacroSupplier macroSuppliers[] = varMacroInfo.getSuppliers();
- for(int i = 0; i < macroSuppliers.length; i++){
- if(macroSuppliers[i] instanceof EnvironmentMacroSupplier){
- varSupplierNum = i;
- break;
- }
- }
- return varSupplierNum;
- }
- }
-
- protected EnvironmentVariableProvider(){
-
+ protected EnvironmentVariableProvider(IEnvironmentVariableManager mngr){
+ fMngr = mngr;
}
public static EnvironmentVariableProvider getDefault(){
if(fInstance == null)
- fInstance = new EnvironmentVariableProvider();
+ fInstance = new EnvironmentVariableProvider(CCorePlugin.getDefault().getBuildEnvironmentManager());
return fInstance;
}
- /*
- * returns a variable of a given name or null
- * the context information is taken from the contextInfo passed
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
*/
- public EnvVarDescriptor getVariable(String variableName,
- IContextInfo contextInfo, boolean includeParentLevels){
+ public IBuildEnvironmentVariable getVariable(String variableName,
+ Object level, boolean includeParentLevels, boolean resolveMacros) {
- if(contextInfo == null)
- return null;
- if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null) //$NON-NLS-1$
+ if(variableName == null || "".equals(variableName)) //$NON-NLS-1$
return null;
-
-
- IContextInfo infos[] = getAllContextInfos(contextInfo);
-
- if(!includeParentLevels){
- IEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
- boolean bVarFound = false;
- for(int i = 0; i < suppliers.length; i++){
- if(suppliers[i].getVariable(variableName,infos[0].getContext()) != null){
- bVarFound = true;
- break;
- }
- }
- if(!bVarFound)
- return null;
- }
-
- IBuildEnvironmentVariable variable = null;
- IContextInfo varContextInfo = null;
- int varSupplierNum = -1;
- for(int i = infos.length-1 ; i >=0 ; i-- ) {
- IContextInfo info = infos[i];
- IEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
-
- for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
- IEnvironmentVariableSupplier supplier = suppliers[j];
- IBuildEnvironmentVariable var = supplier.getVariable(variableName,info.getContext());
-
- if(var == null)
- continue;
-
- varContextInfo = info;
- varSupplierNum = j;
-
- if(variable == null)
- variable = var;
- else
- variable = EnvVarOperationProcessor.performOperation(variable,var);
- }
+ if(level instanceof IConfiguration){
+ return wrap(getVariable(variableName, (IConfiguration)level, resolveMacros));
}
+ return null;
+ }
- if(variable != null){
- if(variable.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
- return null;
- return new EnvVarDescriptor(variable,varContextInfo,varSupplierNum);
+ public IEnvironmentVariable getVariable(String variableName,
+ IConfiguration cfg, boolean resolveMacros){
+ ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ if(des != null){
+ return fMngr.getVariable(variableName, des, resolveMacros);
}
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
- */
- public IBuildEnvironmentVariable getVariable(String variableName,
- Object level, boolean includeParentLevels, boolean resolveMacros) {
-
- if(variableName == null || "".equals(variableName)) //$NON-NLS-1$
- return null;
-
- IContextInfo info = getContextInfo(level);
- EnvVarDescriptor var = getVariable(variableName,info,includeParentLevels);
- if(level instanceof IConfiguration && includeParentLevels)
- checkBuildPathVariable((IConfiguration)level,variableName,var);
-
- return resolveMacros ? calculateResolvedVariable(var,info) : var;
+ public IEnvironmentVariable[] getVariables(IConfiguration cfg, boolean resolveMacros){
+ ICConfigurationDescription des = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ if(des != null){
+ return fMngr.getVariables(des, resolveMacros);
+ }
+ return new IBuildEnvironmentVariable[0];
}
- /*
- * returns the context info that should be used for the given level
- * or null if the the given level is not supported
- */
- public IContextInfo getContextInfo(Object level){
- DefaultContextInfo info = new DefaultContextInfo(level);
- if(info.getSuppliers() == null)
+ public static IBuildEnvironmentVariable wrap(IEnvironmentVariable var){
+ if(var == null)
return null;
- return info;
+ if(var instanceof IBuildEnvironmentVariable)
+ return (IBuildEnvironmentVariable)var;
+ return new BuildEnvVar(var);
}
-
- /*
- * returns a list of defined variables.
- * the context information is taken from the contextInfo passed
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
- */
- public EnvVarCollector getVariables(IContextInfo contextInfo,
- boolean includeParentLevels) {
- if(contextInfo == null)
+
+ public static IBuildEnvironmentVariable[] wrap(IEnvironmentVariable vars[]){
+ if(vars == null)
return null;
+ if(vars instanceof IBuildEnvironmentVariable[])
+ return (IBuildEnvironmentVariable[])vars;
- IContextInfo infos[] = getAllContextInfos(contextInfo);
- HashSet set = null;
-
- if(!includeParentLevels){
- IEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
- set = new HashSet();
- for(int i = 0; i < suppliers.length; i++){
- IBuildEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
- if(vars != null){
- for(int j = 0; j < vars.length; j++){
- String name = EnvVarOperationProcessor.normalizeName(vars[j].
- getName());
- if(name != null)
- set.add(name);
- }
- }
- }
- if(set.size() == 0)
- return new EnvVarCollector();
+ IBuildEnvironmentVariable[] buildVars = new IBuildEnvironmentVariable[vars.length];
+ for(int i = 0; i < vars.length; i++){
+ buildVars[i] = wrap(vars[i]);
}
-
- EnvVarCollector envVarSet = new EnvVarCollector();
-
- for(int i = infos.length-1 ; i >=0 ; i-- ) {
- IContextInfo info = infos[i];
- IEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
-
- for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
- IEnvironmentVariableSupplier supplier = suppliers[j];
- IBuildEnvironmentVariable vars[] = null;
- if(set != null){
- List varList = new ArrayList();
- Iterator iter = set.iterator();
-
- while(iter.hasNext()){
- IBuildEnvironmentVariable var = supplier.getVariable((String)iter.next(),info.getContext());
- if(var != null)
- varList.add(var);
- }
- vars = (IBuildEnvironmentVariable[])varList.toArray(new IBuildEnvironmentVariable[varList.size()]);
- }
- else{
- vars = supplier.getVariables(info.getContext());
- }
- envVarSet.add(vars,info,j);
- }
- }
-
- return envVarSet;
+ return buildVars;
}
+/* protected ICConfigurationDescription getDescription(IConfiguration cfg){
+ IProject project = cfg.getOwner().getProject();
+ ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project, false);
+ if(des != null){
+ return des.getConfigurationById(cfg.getId());
+ }
+ return null;
+ }
+*/
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables()
*/
public IBuildEnvironmentVariable[] getVariables(Object level,
boolean includeParentLevels, boolean resolveMacros) {
-
- IContextInfo info = getContextInfo(level);
- EnvVarCollector varSet = getVariables(info,includeParentLevels);
-
- EnvVarDescriptor vars[] = varSet != null ? varSet.toArray(false) : null;
-
- if(level instanceof IConfiguration)
- if(includeParentLevels)
- checkBuildPathVariables((IConfiguration)level,varSet);
- else if (vars != null){
- for(int i = 0; i < vars.length; i++)
- checkBuildPathVariable((IConfiguration)level,vars[i].getName(),vars[i]);
- }
- if(vars != null){
- if(!resolveMacros)
- return vars;
-
- IBuildEnvironmentVariable resolved[] = new IBuildEnvironmentVariable[vars.length];
- for(int i = 0; i < vars.length; i++)
- resolved[i] = calculateResolvedVariable(vars[i], info);
- return resolved;
+ if(level instanceof IConfiguration){
+ return wrap(getVariables((IConfiguration)level, resolveMacros));
}
- return null;
- }
-
- /*
- * returns an array of the IContextInfo that holds the context informations
- * starting from the one passed to this method and including all subsequent parents
- */
- private IContextInfo[] getAllContextInfos(IContextInfo contextInfo){
- if(contextInfo == null)
- return null;
-
- List list = new ArrayList();
-
- list.add(contextInfo);
-
- while((contextInfo = contextInfo.getNext()) != null)
- list.add(contextInfo);
-
- return (IContextInfo[])list.toArray(new IContextInfo[list.size()]);
- }
-
- private boolean isWin32(){
- String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
- if (os.startsWith("windows ")) //$NON-NLS-1$
- return true;
- return false;
+ return new IBuildEnvironmentVariable[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getDefaultDelimiter()
*/
public String getDefaultDelimiter() {
- return isWin32() ? DELIMITER_WIN32 : DELIMITER_UNIX;
+ return fMngr.getDefaultDelimiter();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#isVariableCaseSensitive()
*/
public boolean isVariableCaseSensitive() {
- return !isWin32();
+ return fMngr.isVariableCaseSensitive();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getSuppliers()
*/
public IEnvironmentVariableSupplier[] getSuppliers(Object level) {
- IContextInfo info = getContextInfo(level);
- if(info != null)
- return info.getSuppliers();
return null;
}
@@ -416,11 +217,11 @@ public class EnvironmentVariableProvider implements
for(int k = 0; k < vars.length; k++){
String varName = vars[k];
- EnvVarDescriptor var = getVariable(varName,getContextInfo(configuration),true);
+ IEnvironmentVariable var = getVariable(varName,configuration,true);
if(var == null)
continue;
- String varValue = calculateResolvedVariable(var, getContextInfo(configuration)).getValue();
+ String varValue = var.getValue();
String paths[] = pathResolver.resolveBuildPaths(buildPathType,varName,varValue,configuration);
if(paths != null && paths.length != 0)
list.addAll(Arrays.asList(paths));
@@ -476,36 +277,21 @@ public class EnvironmentVariableProvider implements
}
/*
- * returns true if the first passed contextInfo is the child of the second one
- */
- public boolean checkParentContextRelation(IContextInfo child, IContextInfo parent){
- if(child == null || parent == null)
- return false;
-
- IContextInfo enumInfo = child;
- do{
- if(parent.getContext() == enumInfo.getContext())
- return true;
- }while((enumInfo = enumInfo.getNext()) != null);
- return false;
- }
-
- /*
* performs a check of the build path variables for the given configuration
* If the build variables are changed, the notification is sent
*/
- public void checkBuildPathVariables(IConfiguration configuration){
- checkBuildPathVariables(configuration,getVariables(getContextInfo(configuration),true));
- }
+// public void checkBuildPathVariables(IConfiguration configuration){
+// checkBuildPathVariables(configuration,getVariables(getContextInfo(configuration),true));
+// }
/*
* performs a check of the build path variables of the specified type
* for the given configuration
* If the build variables are changed, the notification is sent
*/
- public void checkBuildPathVariables(IConfiguration configuration,int buildPathType){
- checkBuildPathVariables(configuration,buildPathType,getVariables(getContextInfo(configuration),true));
- }
+// public void checkBuildPathVariables(IConfiguration configuration,int buildPathType){
+// checkBuildPathVariables(configuration,buildPathType,getVariables(getContextInfo(configuration),true));
+// }
/*
* performs a check of the build path variables
@@ -513,10 +299,10 @@ public class EnvironmentVariableProvider implements
* defined for this configuration
* If the build variables are changed, the notification is sent
*/
- protected void checkBuildPathVariables(IConfiguration configuration, EnvVarCollector varSet){
- checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_INCLUDE,varSet);
- checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_LIBRARY,varSet);
- }
+// protected void checkBuildPathVariables(IConfiguration configuration, EnvVarCollector varSet){
+// checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_INCLUDE,varSet);
+// checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_LIBRARY,varSet);
+// }
/*
* performs a check of whether the given variable is the build path variable
@@ -526,10 +312,10 @@ public class EnvironmentVariableProvider implements
* If it is not changed, other build path variables are not checked
* In the case of the given variable is not the build path one, this method does nothing
*/
- protected void checkBuildPathVariable(IConfiguration configuration, String varName, EnvVarDescriptor var){
- checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_INCLUDE, varName, var);
- checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_LIBRARY, varName, var);
- }
+// protected void checkBuildPathVariable(IConfiguration configuration, String varName, EnvVarDescriptor var){
+// checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_INCLUDE, varName, var);
+// checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_LIBRARY, varName, var);
+// }
/*
* performs a check of whether the given variable is the build path variable
@@ -539,15 +325,15 @@ public class EnvironmentVariableProvider implements
* If it is not changed, other build path variables are not checked
* In the case of the given variable is not the build path one, this method does nothing
*/
- protected void checkBuildPathVariable(IConfiguration configuration, int buildPathType, String varName, EnvVarDescriptor var){
- StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
- if(buildPathVars == null)
- return;
- if(buildPathVars.isVariableChanged(varName,var,configuration)){
- buildPathVars.synchronize(getVariables(getContextInfo(configuration),true),configuration);
- notifyListeners(configuration, buildPathType);
- }
- }
+// protected void checkBuildPathVariable(IConfiguration configuration, int buildPathType, String varName, EnvVarDescriptor var){
+// StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
+// if(buildPathVars == null)
+// return;
+// if(buildPathVars.isVariableChanged(varName,var,configuration)){
+// buildPathVars.synchronize(getVariables(getContextInfo(configuration),true),configuration);
+// notifyListeners(configuration, buildPathType);
+// }
+// }
/*
* performs a check of the build path variables of the specified type
@@ -555,96 +341,39 @@ public class EnvironmentVariableProvider implements
* defined for this configuration.
* If the build variables are changed, the notification is sent
*/
- protected void checkBuildPathVariables(IConfiguration configuration, int buildPathType, EnvVarCollector varSet){
- StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
- if(buildPathVars == null)
- return;
- if(buildPathVars.checkBuildPathChange(varSet,configuration)){
- notifyListeners(configuration, buildPathType);
- }
- }
+// protected void checkBuildPathVariables(IConfiguration configuration, int buildPathType, EnvVarCollector varSet){
+// StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
+// if(buildPathVars == null)
+// return;
+// if(buildPathVars.checkBuildPathChange(varSet,configuration)){
+// notifyListeners(configuration, buildPathType);
+// }
+// }
/*
* returns the container of the build variables of the specified type
*/
- protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
- return buildPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
- getStoredLibraryBuildPathVariables() :
- getStoredIncludeBuildPathVariables();
- }
+// protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
+// return buildPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
+// getStoredLibraryBuildPathVariables() :
+// getStoredIncludeBuildPathVariables();
+// }
/*
* returns the container of the Include path variables
*/
- protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
- if(fIncludeStoredBuildPathVariables == null)
- fIncludeStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_INCLUDE);
- return fIncludeStoredBuildPathVariables;
- }
+// protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
+// if(fIncludeStoredBuildPathVariables == null)
+// fIncludeStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_INCLUDE);
+// return fIncludeStoredBuildPathVariables;
+// }
/*
* returns the container of the Library path variables
*/
- protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
- if(fLibraryStoredBuildPathVariables == null)
- fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
- return fLibraryStoredBuildPathVariables;
- }
-
- public IBuildEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IContextInfo info){
- if(des == null || info == null)
- return null;
-
- return calculateResolvedVariable(des,getMacroSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public IBuildEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IMacroSubstitutor sub){
- if(des == null)
- return null;
- IBuildEnvironmentVariable var = des;
-
- try{
- if(sub instanceof EnvVarMacroSubstitutor)
- var = ((EnvVarMacroSubstitutor)sub).resolveVariable(des);
- else if(des.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE){
- String name = des.getName();
- var = new BuildEnvVar(name,sub.resolveToString(name),des.getOperation(),des.getDelimiter());
- }
- } catch (BuildMacroException e){
- }
- return var;
-
- }
-
- protected int getMacroContextTypeFromContext(Object context){
- if(context instanceof IConfiguration)
- return IBuildMacroProvider.CONTEXT_CONFIGURATION;
- else if(context instanceof IManagedProject)
- return IBuildMacroProvider.CONTEXT_PROJECT;
- else if(context instanceof IWorkspace)
- return IBuildMacroProvider.CONTEXT_WORKSPACE;
- else if(context == null)
- return IBuildMacroProvider.CONTEXT_ECLIPSEENV;
- return 0;
- }
-
- public IMacroContextInfo getMacroContextInfoForContext(Object context){
- return new DefaultMacroContextInfo(getMacroContextTypeFromContext(context),context);
- }
-
- public IMacroSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
- if(fMacroSubstitutor == null)
- fMacroSubstitutor = new EnvVarMacroSubstitutor(info,inexistentMacroValue,listDelimiter);
- else {
- try {
- fMacroSubstitutor.setMacroContextInfo(info);
- fMacroSubstitutor.setInexistentMacroValue(inexistentMacroValue);
- fMacroSubstitutor.setListDelimiter(listDelimiter);
- } catch (BuildMacroException e){
- fMacroSubstitutor = new EnvVarMacroSubstitutor(info,inexistentMacroValue,listDelimiter);
- }
- }
- return fMacroSubstitutor;
- }
-
+// protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
+// if(fLibraryStoredBuildPathVariables == null)
+// fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
+// return fLibraryStoredBuildPathVariables;
+// }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/ExternalExtensionEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/ExternalExtensionEnvironmentSupplier.java
index 359df964b3e..176a1a5c94a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/ExternalExtensionEnvironmentSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/ExternalExtensionEnvironmentSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,18 +10,16 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.envvar;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.EnvironmentMacroSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
/**
* This is the Environment Variable Supplier used to supply variables
@@ -31,6 +29,7 @@ import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
*/
public class ExternalExtensionEnvironmentSupplier implements
IEnvironmentVariableSupplier {
+ private EnvironmentVariableProvider fProvider;
private static final String fNonOverloadableVariables[] = new String[]{
//tool-integrators not allowed currently to override the "CWD" and "PWD" variables
EnvVarOperationProcessor.normalizeName("CWD"), //$NON-NLS-1$
@@ -44,135 +43,16 @@ public class ExternalExtensionEnvironmentSupplier implements
*
* @since 3.0
*/
- private class ExtensionEnvVarProvider extends EnvironmentVariableProvider{
- private IContextInfo fStartInfo;
- private Object fStartLevel;
- private boolean fStartInitialized;
- private int fStartType;
- private Object fStartData;
- private IMacroContextInfo fStartMacroContextInfo;
- private boolean fStartMacroInfoInitialized;
-
- public ExtensionEnvVarProvider(Object level){
- fStartLevel = level;
- fStartType = getMacroContextTypeFromContext(level);
- fStartData = level;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable(java.lang.String, java.lang.Object, boolean)
- */
- public IBuildEnvironmentVariable getVariable(String variableName,
- Object level, boolean includeParentLevels, boolean resolveMacros) {
- if(getValidName(variableName) == null)
- return null;
- return super.getVariable(variableName,level,includeParentLevels,resolveMacros);
- }
-
- public IBuildEnvironmentVariable[] getVariables(Object level, boolean includeParentLevels, boolean resolveMacros) {
- return filterVariables(super.getVariables(level,includeParentLevels,resolveMacros));
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getContextInfo(java.lang.Object)
- */
- public IContextInfo getContextInfo(Object level){
- IContextInfo startInfo = getStartInfo();
- if(level == fStartLevel)
- return startInfo;
-
- IContextInfo info = super.getContextInfo(level);
- if(info == null)
- return null;
-
- if(checkParentContextRelation(startInfo,info))
- return info;
- return null;
- }
-
- protected IContextInfo getStartInfo(){
- if(fStartInfo == null && !fStartInitialized){
- IContextInfo info = super.getContextInfo(fStartLevel);
- if(info != null){
- IEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
- suppliers = filterValidSuppliers(suppliers);
- if(suppliers != null)
- fStartInfo = new DefaultContextInfo(fStartLevel,suppliers);
- else
- fStartInfo = info.getNext();
- fStartInitialized = true;
- }
- fStartInitialized = true;
- }
- return fStartInfo;
- }
-
- public IMacroSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
- return super.getMacroSubstitutor(getSubstitutorMacroContextInfo(info),inexistentMacroValue,listDelimiter);
- }
-
- protected IMacroContextInfo getSubstitutorMacroContextInfo(IMacroContextInfo info){
- IMacroContextInfo startInfo = getStartMacroContextInfo();
- if(info == null)
- return null;
-
- if(info.getContextType() == fStartType &&
- info.getContextData() == fStartData)
- return startInfo;
-
-
- if(BuildMacroProvider.getDefault().checkParentContextRelation(startInfo,info))
- return info;
- return null;
- }
-
- protected IMacroContextInfo getStartMacroContextInfo(){
- if(fStartMacroContextInfo == null && !fStartMacroInfoInitialized){
- final IMacroContextInfo info = getMacroContextInfoForContext(fStartLevel);
- if(info != null){
- fStartMacroContextInfo = new DefaultMacroContextInfo(fStartType,fStartData){
- protected IBuildMacroSupplier[] getSuppliers(int type, Object data){
- IBuildMacroSupplier suppliers[] = info.getSuppliers();
- return filterValidMacroSuppliers(suppliers);
- }
-
- public IMacroContextInfo getNext() {
- return info.getNext();
- }
- };
- fStartInitialized = true;
- }
- fStartInitialized = true;
- }
- return fStartMacroContextInfo;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredBuildPathVariables(int)
- */
- protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredIncludeBuildPathVariables()
- */
- protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredLibraryBuildPathVariables()
- */
- protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
- return null;
- }
+ public ExternalExtensionEnvironmentSupplier(IEnvironmentVariableManager mngr){
+ fProvider = new EnvironmentVariableProvider(mngr);
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
*/
- public IBuildEnvironmentVariable getVariable(String name, Object context) {
+ public IEnvironmentVariable getVariable(String name, Object context) {
if(context == null)
return null;
if((name = getValidName(name)) == null)
@@ -183,14 +63,16 @@ public class ExternalExtensionEnvironmentSupplier implements
IConfigurationEnvironmentVariableSupplier supplier = cfg.getEnvironmentVariableSupplier();
if(supplier == null)
return null;
- return supplier.getVariable(name,cfg,new ExtensionEnvVarProvider(context));
+ return supplier.getVariable(name,cfg,fProvider);
}
else if (context instanceof IManagedProject) {
IManagedProject project = (IManagedProject)context;
- IProjectEnvironmentVariableSupplier supplier = project.getProjectType().getEnvironmentVariableSupplier();
+ IProjectType pType = project.getProjectType();
+ IProjectEnvironmentVariableSupplier supplier = pType != null ?
+ pType.getEnvironmentVariableSupplier() : null;
if(supplier == null)
return null;
- return supplier.getVariable(name,project,new ExtensionEnvVarProvider(context));
+ return supplier.getVariable(name,project,fProvider);
}
return null;
}
@@ -198,7 +80,7 @@ public class ExternalExtensionEnvironmentSupplier implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
*/
- public IBuildEnvironmentVariable[] getVariables(Object context) {
+ public IEnvironmentVariable[] getVariables(Object context) {
if(context == null)
return null;
IBuildEnvironmentVariable variables[] = null;
@@ -207,14 +89,14 @@ public class ExternalExtensionEnvironmentSupplier implements
IConfigurationEnvironmentVariableSupplier supplier = cfg.getEnvironmentVariableSupplier();
if(supplier == null)
return null;
- variables = supplier.getVariables(cfg,new ExtensionEnvVarProvider(context));
+ variables = supplier.getVariables(cfg,fProvider);
}
else if (context instanceof IManagedProject) {
IManagedProject project = (IManagedProject)context;
- IProjectEnvironmentVariableSupplier supplier = project.getProjectType().getEnvironmentVariableSupplier();
+ IProjectEnvironmentVariableSupplier supplier = null;//project.getProjectType().getEnvironmentVariableSupplier();
if(supplier == null)
return null;
- variables = supplier.getVariables(project,new ExtensionEnvVarProvider(context));
+ variables = supplier.getVariables(project,fProvider);
}
return filterVariables(variables);
@@ -259,33 +141,7 @@ public class ExternalExtensionEnvironmentSupplier implements
return name;
}
- protected IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
+ protected IEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
return EnvVarOperationProcessor.filterVariables(variables,fNonOverloadableVariables);
}
-
- protected IBuildMacroSupplier[] filterValidMacroSuppliers(IBuildMacroSupplier suppliers[]){
- if(suppliers == null)
- return null;
-
- int i = 0, j = 0;
- for(i = 0; i < suppliers.length; i++){
- if(suppliers[i] instanceof EnvironmentMacroSupplier)
- break;
- }
-
-
- if(i >= suppliers.length)
- return suppliers;
-
- int startNum = i + 1;
-
- IBuildMacroSupplier validSuppliers[] =
- new IBuildMacroSupplier[suppliers.length - startNum];
-
- for(i = startNum, j = 0; i < suppliers.length; i++, j++)
- validSuppliers[j] = suppliers[i];
-
- return validSuppliers;
- }
-
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/MbsEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/MbsEnvironmentSupplier.java
index cd91afe66c4..b94e971e9d3 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/MbsEnvironmentSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/MbsEnvironmentSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -13,13 +13,12 @@ package org.eclipse.cdt.managedbuilder.internal.envvar;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -39,7 +38,7 @@ public class MbsEnvironmentSupplier implements IEnvironmentVariableSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
*/
- public IBuildEnvironmentVariable getVariable(String name, Object context) {
+ public IEnvironmentVariable getVariable(String name, Object context) {
if(context instanceof IConfiguration)
return getConfigurationVariable(name,(IConfiguration)context);
return null;
@@ -50,20 +49,23 @@ public class MbsEnvironmentSupplier implements IEnvironmentVariableSupplier {
if("CWD".equals(name) || "PWD".equals(name)){ //$NON-NLS-1$ //$NON-NLS-2$
IResource owner = configuration.getOwner();
if(owner != null){
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(owner);
- if(info != null && configuration.equals(info.getDefaultConfiguration())){
- IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(configuration);
- generator.initialize((IProject)owner,info,null);
-
- IPath topBuildDir = generator.getBuildWorkingDir();
- if(topBuildDir == null)
- topBuildDir = new Path(info.getConfigurationName());
-
- IPath projectLocation = owner.getLocation();
- IPath workingDirectory = projectLocation.append(topBuildDir);
- String value = workingDirectory.toOSString();
- variable = new BuildEnvVar(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
- }
+// IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(owner);
+// if(info != null && configuration.equals(info.getDefaultConfiguration())){
+// IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(configuration);
+// generator.initialize((IProject)owner,info,null);
+ IBuilder builder = configuration.getEditableBuilder();
+ IPath topBuildDir = ManagedBuildManager.getBuildLocation(configuration, builder);
+
+
+//// IPath topBuildDir = generator.getBuildWorkingDir();
+// if(topBuildDir == null)
+// topBuildDir = new Path(configuration.getName());
+//
+// IPath projectLocation = owner.getLocation();
+// IPath workingDirectory = projectLocation.append(topBuildDir);
+// String value = workingDirectory.toOSString();
+ variable = new BuildEnvVar(name, topBuildDir.toOSString(), IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
+// }
}
}
return variable;
@@ -72,7 +74,7 @@ public class MbsEnvironmentSupplier implements IEnvironmentVariableSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
*/
- public IBuildEnvironmentVariable[] getVariables(Object context) {
+ public IEnvironmentVariable[] getVariables(Object context) {
if(context instanceof IConfiguration){
List variables = new ArrayList(fVariableNames.length);
for(int i = 0; i < fVariableNames.length; i++){
@@ -82,7 +84,7 @@ public class MbsEnvironmentSupplier implements IEnvironmentVariableSupplier {
}
if(variables.size() == 0)
return null;
- return (IBuildEnvironmentVariable[])variables.toArray(new IBuildEnvironmentVariable[variables.size()]);
+ return (IEnvironmentVariable[])variables.toArray(new IBuildEnvironmentVariable[variables.size()]);
}
return null;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java
deleted file mode 100644
index 0cbe8a0c900..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * This class represents the set of environment variables that could be loaded
- * and stored in XML
- *
- * @since 3.0
- *
- */
-public class StorableEnvironment {
- public static final String ENVIRONMENT_ELEMENT_NAME = "environment"; //$NON-NLS-1$
- private Map fVariables;
- private boolean fIsDirty = false;
- private boolean fIsChanged = false;
-
- private Map getMap(){
- if(fVariables == null)
- fVariables = new HashMap();
- return fVariables;
- }
-
- public StorableEnvironment() {
-
- }
-
- public StorableEnvironment(Element element) {
- load(element);
- }
-
- private void load(Element element){
- NodeList nodeList = element.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); ++i) {
- Node node = nodeList.item(i);
- if (node.getNodeName().equals(StorableEnvVar.VARIABLE_ELEMENT_NAME)) {
- addVariable(new StorableEnvVar((Element)node));
- }
- }
- fIsDirty = false;
- fIsChanged = false;
- }
-
- public void serialize(Document doc, Element element){
- if(fVariables != null){
- Iterator iter = fVariables.values().iterator();
- while(iter.hasNext()){
- StorableEnvVar var = (StorableEnvVar)iter.next();
- Element varEl = doc.createElement(StorableEnvVar.VARIABLE_ELEMENT_NAME);
- element.appendChild(varEl);
- var.serialize(doc,varEl);
- }
- }
- fIsDirty = false;
- }
-
- private void addVariable(IBuildEnvironmentVariable var){
- String name = var.getName();
- if(name == null)
- return;
- IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
- if(!provider.isVariableCaseSensitive())
- name = name.toUpperCase();
-
- getMap().put(name,var);
- }
-
- public IBuildEnvironmentVariable createVariable(String name, String value, int op, String delimiter){
- if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
- return null;
-
- IBuildEnvironmentVariable var = checkVariable(name,value,op,delimiter);
- if(var == null){
- var = new StorableEnvVar(name, value, op, delimiter);
- addVariable(var);
- fIsDirty = true;
- fIsChanged = true;
- }
- return var;
- }
-
- public IBuildEnvironmentVariable createVariable(String name){
- return createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
- }
-
- public IBuildEnvironmentVariable createVariable(String name, String value){
- return createVariable(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
- }
-
- public IBuildEnvironmentVariable createVariable(String name, String value, String delimiter){
- return createVariable(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,delimiter);
- }
-
- public IBuildEnvironmentVariable checkVariable(String name, String value, int op, String delimiter){
- IBuildEnvironmentVariable var = getVariable(name);
- if(var != null
- && checkStrings(var.getValue(),value)
- && var.getOperation() == op
- && checkStrings(var.getDelimiter(),delimiter))
- return var;
- return null;
- }
-
- private boolean checkStrings(String str1, String str2){
- if(str1 != null &&
- str1.equals(str2))
- return true;
- return str1 == str2;
- }
-
- /**
- * Returns the "dirty" state of the environment.
- * If the dirty state is <code>true</code>, that means that the environment
- * is out of synch with the repository and the environment needs to be serialized.
- * <br><br>
- * The dirty state is automatically set to <code>false</code> when the environment is serialized
- * by calling the serialize() method
- * @return boolean
- */
- public boolean isDirty(){
- return fIsDirty;
- }
-
- /**
- * sets the "dirty" state of the environment
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment#isDirty()
- * @param dirty represents the new state
- */
- public void setDirty(boolean dirty){
- fIsDirty = dirty;
- }
-
- /**
- * Returns the "change" state of the environment.
- * The "change" state represents whether the environment was changed or not.
- * This state is not reset when the serialize() method is called
- * Users can use this state to monitor whether the environment was changed or not.
- * This state can be reset to <code>false</code> only by calling the setChanged(false) method
- * @return boolean
- */
- public boolean isChanged(){
- return fIsChanged;
- }
-
- /**
- * sets the "change" state of the environment
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment#isChanged()
- * @param changed represents the new "change" state
- */
- public void setChanged(boolean changed){
- fIsChanged = changed;
- }
-
- public IBuildEnvironmentVariable getVariable(String name){
- if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
- return null;
- IEnvironmentVariableProvider provider = EnvironmentVariableProvider.getDefault();
- if(!provider.isVariableCaseSensitive())
- name = name.toUpperCase();
-
- return (IBuildEnvironmentVariable)getMap().get(name);
- }
-
- public void setVariales(IBuildEnvironmentVariable vars[]){
- if(vars == null || vars.length == 0)
- deleteAll();
- else{
- if (getMap().size() != 0) {
- Iterator iter = getMap().values().iterator();
- while(iter.hasNext()){
- IBuildEnvironmentVariable v = (IBuildEnvironmentVariable)iter.next();
- int i;
- for(i = 0 ; i < vars.length; i++){
- if(v.getName().equals(vars[i].getName()))
- break;
- }
- if(i == vars.length)
- deleteVariable(v.getName());
- }
- }
- createVriables(vars);
- }
- }
-
- public void createVriables(IBuildEnvironmentVariable vars[]){
- for(int i = 0; i < vars.length; i++)
- createVariable(vars[i].getName(),
- vars[i].getValue(),
- vars[i].getOperation(),
- vars[i].getDelimiter());
- }
-
- public IBuildEnvironmentVariable[] getVariables(){
- Collection vars = getMap().values();
-
- return (IBuildEnvironmentVariable[])vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
- }
-
- IBuildEnvironmentVariable deleteVariable(String name){
- if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
- return null;
- IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
- if(!provider.isVariableCaseSensitive())
- name = name.toUpperCase();
-
- IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)getMap().remove(name);
- if(var != null){
- fIsDirty = true;
- fIsChanged = true;
- }
-
- return var;
- }
-
- public boolean deleteAll(){
- Map map = getMap();
- if(map.size() > 0){
- fIsDirty = true;
- fIsChanged = true;
- map.clear();
- return true;
- }
-
- return false;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java
deleted file mode 100644
index 25f19f5e702..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StoredBuildPathEnvironmentContainer.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.CoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * This class holds the build path variable values and allows
- * checking the stored variable values with the values of the current environment environment
- *
- * @since 3.0
- *
- */
-public class StoredBuildPathEnvironmentContainer extends
- StorableEnvironmentLoader {
- public static final String NODENAME = "environment"; //$NON-NLS-1$
- public static final String NODENAME_PREFIX_CFG = "buildEnvironment"; //$NON-NLS-1$
- public static final String NODENAME_CFG_INCLUDE = NODENAME_PREFIX_CFG + "Include"; //$NON-NLS-1$
- public static final String NODENAME_CFG_LIBRARY = NODENAME_PREFIX_CFG + "Library"; //$NON-NLS-1$
-
- private IConfiguration fConfiguration;
- private StorableEnvironment fEnvironment;
- private int fPathType;
- private boolean fIsVariableCaseSensitive = ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive();
-
- public StoredBuildPathEnvironmentContainer(int pathType){
- fPathType = pathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
- IEnvVarBuildPath.BUILDPATH_LIBRARY : IEnvVarBuildPath.BUILDPATH_INCLUDE;
- }
-
- protected StorableEnvironment getEnvironment(Object context) {
- StorableEnvironment env = null;
- if(context instanceof IConfiguration){
- if(fConfiguration != null && context == fConfiguration && fEnvironment != null)
- env = fEnvironment;
- else {
- env = loadEnvironment(context);
- if(env != null){
- if(fConfiguration != null && fEnvironment != null){
- try{
- storeEnvironment(fEnvironment,fConfiguration,false);
- }catch(CoreException e){
- }
- }
-
- checkLoadedVarNames(env,context);
-
- fConfiguration = (IConfiguration)context;
- fEnvironment = env;
- }
- }
- }
- return env;
- }
-
- private boolean haveIdenticalValues(IBuildEnvironmentVariable var1,
- IBuildEnvironmentVariable var2){
- if(var1 == null)
- return var2 == null || var2.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE;
- if(var2 == null)
- return var1 == null || var1.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE;
- int op1 = var1.getOperation();
- int op2 = var2.getOperation();
- if(op1 == IBuildEnvironmentVariable.ENVVAR_REMOVE ||
- op2 == IBuildEnvironmentVariable.ENVVAR_REMOVE)
- return op1 == op2;
-
- return maskNull(var1.getValue()).equals(maskNull(var2.getValue()));
- }
-
- private String maskNull(String val){
- return val == null ? "" : val; //$NON-NLS-1$
- }
-
- public boolean checkBuildPathChange(EnvVarCollector existingVariables,
- IConfiguration configuration){
- StorableEnvironment env = getEnvironment(configuration);
- if(env == null)
- return false;
- IBuildEnvironmentVariable vars[] = env.getVariables();
- for(int i = 0; i < vars.length; i++){
- IBuildEnvironmentVariable var = vars[i];
- String name = var.getName();
- EnvVarDescriptor des = existingVariables != null ?
- existingVariables.getVariable(name) : null;
- EnvironmentVariableProvider provider = ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider());
- IBuildEnvironmentVariable curVar = des != null ?
- provider.calculateResolvedVariable(des,provider.getContextInfo(configuration)) : null;
- if(!haveIdenticalValues(var,curVar)){
- if(curVar == null){
- env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
- }
- else{
- env.createVariable(curVar.getName(),curVar.getValue(),curVar.getOperation(),curVar.getDelimiter());
- }
- }
- }
- boolean changed = env.isChanged();
- env.setChanged(false);
- if(changed && !configuration.isTemporary())
- try{
- storeEnvironment(env,configuration,false);
- }catch(CoreException e){
- }
- return changed;
- }
-
- /*
- * checks whether the variable of a given name is the build path variable
- * for the given configuration
- * If it is, than performs a check and returns true if the variable was changed
- * If it is not the build path variable, no check is performed and this method always
- * returns false in this case
- */
- public boolean isVariableChanged(String name,
- EnvVarDescriptor variable,
- IConfiguration configuration){
- StorableEnvironment env = getEnvironment(configuration);
- if(env == null)
- return false;
- IBuildEnvironmentVariable var = env.getVariable(name);
- if(var == null)
- return false;
-
- EnvironmentVariableProvider provider = ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider());
- IBuildEnvironmentVariable curVar = variable != null ?
- provider.calculateResolvedVariable(variable,provider.getContextInfo(configuration)) : null;
-
- if(haveIdenticalValues(var,curVar))
- return false;
-
- return true;
- }
-
- /*
- * synchronizes the stored variables with the ones passed to this method
- */
- public void synchronize(EnvVarCollector existingVariables,
- IConfiguration configuration){
- checkBuildPathChange(existingVariables,configuration);
- }
-
- private void checkLoadedVarNames(StorableEnvironment env, Object context){
- String varNames[] = getBuildPathVarNames((IConfiguration)context, fPathType);
- for(int i = 0; i < varNames.length; i++){
- String name = varNames[i];
- if(env.getVariable(name) == null)
- env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
- }
-
- IBuildEnvironmentVariable vars[] = env.getVariables();
- for(int i = 0; i < vars.length; i++){
- IBuildEnvironmentVariable var = vars[i];
- boolean validVar = false;
- for(int j = 0; j < varNames.length; j++){
- String varName = varNames[j];
- if(varNamesEqual(var.getName(),varName)){
- validVar = true;
- break;
- }
- }
- if(!validVar){
- env.deleteVariable(var.getName());
- }
- }
- }
-
- /*
- * returns true if the variable names are equal and false otherwise
- */
- private boolean varNamesEqual(String name1, String name2){
- return fIsVariableCaseSensitive ?
- name1.equals(name2) : name1.equalsIgnoreCase(name2);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironmentLoader#getSerializeInfo(java.lang.Object)
- */
- protected ISerializeInfo getSerializeInfo(Object context) {
- ISerializeInfo serializeInfo = null;
- if(context instanceof IConfiguration){
- IConfiguration cfg = (IConfiguration)context;
- final Preferences prefs = getConfigurationNode(cfg);
- final String name = cfg.getId();
- if(prefs != null && name != null)
- serializeInfo = new ISerializeInfo(){
- public Preferences getNode(){
- return prefs;
- }
-
- public String getPrefName(){
- return name;
- }
- };
- }
- return serializeInfo;
- }
-
- public void serialize(boolean force) {
- if(fEnvironment != null){
- try{
- storeEnvironment(fEnvironment,fConfiguration,force);
- }catch(CoreException e){
- }
- }
- }
-
- private Preferences getConfigurationNode(IConfiguration cfg){
- IProject project = (IProject)cfg.getOwner();
- if(project == null || !project.exists())
- return null;
-
- Preferences prefNode = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
- if(prefNode == null)
- return null;
-
- prefNode = prefNode.node(NODENAME);
- if(prefNode == null)
- return null;
-
- if(fPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY)
- return prefNode.node(NODENAME_CFG_LIBRARY);
- return prefNode.node(NODENAME_CFG_INCLUDE);
- }
-
- private String[] getBuildPathVarNames(IConfiguration configuration,int buildPathType){
- ITool tools[] = configuration.getFilteredTools();
- List list = new ArrayList();
-
- for(int i = 0; i < tools.length; i++){
- IEnvVarBuildPath pathDescriptors[] = tools[i].getEnvVarBuildPaths();
-
- if(pathDescriptors == null || pathDescriptors.length == 0)
- continue;
-
- for(int j = 0; j < pathDescriptors.length; j++){
- IEnvVarBuildPath curPathDes = pathDescriptors[j];
- if(curPathDes.getType() != buildPathType)
- continue;
-
- String vars[] = curPathDes.getVariableNames();
- if(vars == null || vars.length == 0)
- continue;
-
- list.addAll(Arrays.asList(vars));
- }
- }
-
- return (String[])list.toArray(new String[list.size()]);
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java
deleted file mode 100644
index 047b9d312f4..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
-import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * This is the Environment Variable Supplier used to supply variables
- * defined by a user
- *
- * @since 3.0
- */
-public class UserDefinedEnvironmentSupplier extends
- StorableEnvironmentLoader
- implements IEnvironmentVariableSupplier{
-
- public static final String NODENAME = "environment"; //$NON-NLS-1$
- public static final String PREFNAME_WORKSPACE = "workspace"; //$NON-NLS-1$
- public static final String PREFNAME_PROJECT = "project"; //$NON-NLS-1$
- public static final String NODENAME_CFG = "project"; //$NON-NLS-1$
-
- private static final String fNonOverloadableVariables[] = new String[]{
- //users not allowed currently to override the "CWD" and "PWD" variables
- EnvVarOperationProcessor.normalizeName("CWD"), //$NON-NLS-1$
- EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$
- };
-
- private StorableEnvironment fWorkspaceVariables;
-
- protected StorableEnvironment getEnvironment(Object context){
- return getEnvironment(context,true);
- }
-
- protected StorableEnvironment getEnvironment(Object context, boolean forceLoad){
- if(context == null)
- return null;
-
- StorableEnvironment env = null;
- if(context instanceof IConfiguration){
- IConfiguration cfg = (IConfiguration)context;
- env = ((ToolChain)cfg.getToolChain()).getUserDefinedEnvironment();
- if(env == null && forceLoad){
- env = loadEnvironment(cfg);
- ((ToolChain)cfg.getToolChain()).setUserDefinedEnvironment(env);
- }
- }
- else if(context instanceof ManagedProject){
- ManagedProject proj = (ManagedProject)context;
- env = proj.getUserDefinedEnvironmet();
- if(env == null && forceLoad){
- env = loadEnvironment(proj);
- proj.setUserDefinedEnvironmet(env);
- }
- }
- else if(context instanceof IWorkspace){
- if(fWorkspaceVariables == null && forceLoad)
- fWorkspaceVariables = loadEnvironment(context);
- env = fWorkspaceVariables;
- }
-
- return env;
- }
-
- protected ISerializeInfo getSerializeInfo(Object context){
- ISerializeInfo serializeInfo = null;
-
- if(context instanceof IConfiguration){
- IConfiguration cfg = (IConfiguration)context;
- IManagedProject project = cfg.getManagedProject();
-
- final Preferences prefs = project != null ? getConfigurationNode(project) : null;
- final String name = cfg.getId();
- if(prefs != null && name != null)
- serializeInfo = new ISerializeInfo(){
- public Preferences getNode(){
- return prefs;
- }
-
- public String getPrefName(){
- return name;
- }
- };
- }
- else if(context instanceof IManagedProject){
- IManagedProject proj = (IManagedProject)context;
- final Preferences prefs = getProjectNode(proj);
- final String name = PREFNAME_PROJECT;
- if(prefs != null && name != null)
- serializeInfo = new ISerializeInfo(){
- public Preferences getNode(){
- return prefs;
- }
-
- public String getPrefName(){
- return name;
- }
- };
- }
- else if(context instanceof IWorkspace){
- final Preferences prefs = getWorkspaceNode();
- final String name = PREFNAME_WORKSPACE;
- if(prefs != null && name != null)
- serializeInfo = new ISerializeInfo(){
- public Preferences getNode(){
- return prefs;
- }
-
- public String getPrefName(){
- return name;
- }
- };
- }
- return serializeInfo;
- }
- private Preferences getConfigurationNode(IManagedProject managedProject){
- Preferences prefNode = getProjectNode(managedProject);
- if(prefNode == null)
- return null;
-
- return prefNode.node(NODENAME_CFG);
- }
-
- private Preferences getProjectNode(IManagedProject managedProject){
- IProject project = (IProject)managedProject.getOwner();
- if(!project.exists())
- return null;
-
- Preferences prefNode = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
- if(prefNode == null)
- return null;
-
- return prefNode.node(NODENAME);
- }
-
- private Preferences getWorkspaceNode(){
- Preferences prefNode = new InstanceScope().getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
- if(prefNode == null)
- return null;
-
- return prefNode.node(NODENAME);
- }
-
- public void checkInexistentConfigurations(IManagedProject managedProject){
- Preferences prefNode = getConfigurationNode(managedProject);
- if(prefNode == null)
- return;
-
- try{
- String ids[] = prefNode.keys();
- boolean found = false;
- for( int i = 0; i < ids.length; i++){
- if(managedProject.getConfiguration(ids[i]) == null){
- prefNode.remove(ids[i]);
- found = true;
- }
- }
-
- if(found)
- prefNode.flush();
- }
- catch(BackingStoreException e){
- }
- }
-
- public void serialize(boolean force){
- if(fWorkspaceVariables != null){
- try{
- storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force);
- } catch(CoreException e){
-
- }
- }
- }
-
- public void storeEnvironment(Object context, boolean force){
- StorableEnvironment env = getEnvironment(context, false);
- if(env != null){
- try {
- storeEnvironment(env, context, force);
- } catch (CoreException e) {
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
- */
- public IBuildEnvironmentVariable getVariable(String name, Object context) {
- if(getValidName(name) == null)
- return null;
- StorableEnvironment env = getEnvironment(context);
- if(env == null)
- return null;
- return env.getVariable(name);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
- */
- public IBuildEnvironmentVariable[] getVariables(Object context) {
- StorableEnvironment env = getEnvironment(context);
- if(env == null)
- return null;
- return filterVariables(env.getVariables());
- }
-
- public IBuildEnvironmentVariable createVariable(String name, String value, int op, String delimiter, Object context){
- if(getValidName(name) == null)
- return null;
- StorableEnvironment env = getEnvironment(context);
- if(env == null)
- return null;
- IBuildEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
- if(env.isChanged()){
- setRebuildStateForContext(context);
- env.setChanged(false);
- }
- return var;
- }
-
- public IBuildEnvironmentVariable deleteVariable(String name, Object context){
- StorableEnvironment env = getEnvironment(context);
- if(env == null)
- return null;
- IBuildEnvironmentVariable var = env.deleteVariable(name);
- if(var != null)
- setRebuildStateForContext(context);
- return var;
- }
-
- public void deleteAll(Object context){
- StorableEnvironment env = getEnvironment(context);
- if(env == null)
- return;
-
- if(env.deleteAll())
- setRebuildStateForContext(context);
- }
-
- public void setVariables(IBuildEnvironmentVariable vars[], Object context){
- StorableEnvironment env = getEnvironment(context);
- if(env == null)
- return;
-
- env.setVariales(vars);
- if(env.isChanged()){
- setRebuildStateForContext(context);
- env.setChanged(false);
- }
- }
-
- protected void setRebuildStateForContext(Object context){
- if(context == null)
- return;
- if(context instanceof IConfiguration){
- cfgVarsModified((IConfiguration)context);
- }
- else if(context instanceof IManagedProject){
- IConfiguration cfgs[] = ((IManagedProject)context).getConfigurations();
- for(int i = 0; i < cfgs.length; i++){
- cfgVarsModified(cfgs[i]);
- }
- }
- else if(context instanceof IWorkspace){
- IProject projects[] = ((IWorkspace)context).getRoot().getProjects();
- for(int i = 0; i < projects.length; i++){
- if(ManagedBuildManager.manages(projects[i])){
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i]);
- if(info != null){
- IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
- for(int j = 0; j < cfgs.length; j++){
- cfgVarsModified(cfgs[j]);
- }
- }
- }
- }
- }
-
- }
-
- protected void cfgVarsModified(IConfiguration cfg){
- cfg.setRebuildState(true);
- EnvironmentVariableProvider.getDefault().checkBuildPathVariables(cfg);
- }
-
- protected String getValidName(String name){
- if(name == null || (name = name.trim()).length() == 0)
- return null;
- if(fNonOverloadableVariables != null){
- for(int i = 0; i < fNonOverloadableVariables.length; i++){
- if(fNonOverloadableVariables[i].equals(EnvVarOperationProcessor.normalizeName(name)))
- return null;
- }
- }
- return name;
- }
-
- protected IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
- return EnvVarOperationProcessor.filterVariables(variables,fNonOverloadableVariables);
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildCdtVariablesSupplierBase.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildCdtVariablesSupplierBase.java
new file mode 100644
index 00000000000..4d27b829dbd
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildCdtVariablesSupplierBase.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.macros;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+
+public abstract class BuildCdtVariablesSupplierBase implements IBuildMacroSupplier {
+
+ public abstract IBuildMacro getMacro(String macroName, int contextType,
+ Object contextData);
+
+ public abstract IBuildMacro[] getMacros(int contextType, Object contextData);
+
+ public ICdtVariable getVariable(String macroName,
+ IMacroContextInfo context) {
+ return getMacro(macroName, context.getContextType(), context.getContextData());
+ }
+
+ public ICdtVariable[] getVariables(IMacroContextInfo context) {
+ return getMacros(context.getContextType(), context.getContextData());
+ }
+
+ public ICdtVariable getVariable(String macroName,
+ IVariableContextInfo context) {
+ if(context instanceof IMacroContextInfo){
+ IMacroContextInfo info = (IMacroContextInfo)context;
+ return getMacro(macroName, info.getContextType(), info.getContextData());
+ }
+ return null;
+ }
+
+ public ICdtVariable[] getVariables(IVariableContextInfo context) {
+ if(context instanceof IMacroContextInfo){
+ IMacroContextInfo info = (IMacroContextInfo)context;
+ return getMacros(info.getContextType(), info.getContextData());
+ }
+ return null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacro.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacro.java
index a13982d6c18..a055f6046ca 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacro.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacro.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,69 +10,54 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.macros;
+import org.eclipse.cdt.core.cdtvariables.CdtVariable;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
/**
* This is the trivial implementation of the IBuildMacro used internaly by the MBS
*
* @since 3.0
*/
-public class BuildMacro implements IBuildMacro {
- protected String fName;
- protected int fType;
- protected String fStringValue;
- protected String fStringListValue[];
+public class BuildMacro extends CdtVariable implements IBuildMacro {
- protected BuildMacro(){
-
+ public BuildMacro() {
+ super();
}
- public BuildMacro(String name, int type, String value){
- fName = name;
- fType = type;
- fStringValue = value;
+ public BuildMacro(ICdtVariable var) {
+ super(var);
}
- public BuildMacro(String name, int type, String value[]){
- fName = name;
- fType = type;
- fStringListValue = value;
+ public BuildMacro(String name, int type, String value) {
+ super(name, type, value);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getName()
- */
- public String getName() {
- return fName;
+ public BuildMacro(String name, int type, String[] value) {
+ super(name, type, value);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getMacroValueType()
- */
public int getMacroValueType() {
- return fType;
+ return getValueType();
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringValue()
- */
- public String getStringValue() throws BuildMacroException {
- if(MacroResolver.isStringListMacro(fType))
- throw new BuildMacroException(IBuildMacroStatus.TYPE_MACRO_NOT_STRING,fName,null,fName,0,null);
-
- return fStringValue;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringListValue()
- */
public String[] getStringListValue() throws BuildMacroException {
- if(!MacroResolver.isStringListMacro(fType))
- throw new BuildMacroException(IBuildMacroStatus.TYPE_MACRO_NOT_STRINGLIST,fName,null,fName,0,null);
-
- return fStringListValue;
+ // TODO Auto-generated method stub
+ try {
+ return super.getStringListValue();
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
}
+ public String getStringValue() throws BuildMacroException {
+ try {
+ return super.getStringValue();
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroProvider.java
index 116f6886f85..534cd77c347 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -11,31 +11,44 @@
package org.eclipse.cdt.managedbuilder.internal.macros;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.IStringVariable;
/**
* The default IBuildMacroProvider implementation
* @since 3.0
*/
-public class BuildMacroProvider implements IBuildMacroProvider {
+public class BuildMacroProvider implements IBuildMacroProvider, IMacroContextInfoProvider {
+ private static final String PATTERN_MACRO_NAME = "="; //$NON-NLS-1$
+
static private BuildMacroProvider fDefault;
- public static UserDefinedMacroSupplier fUserDefinedMacroSupplier = UserDefinedMacroSupplier.getInstance();
- public static ExternalExtensionMacroSupplier fExternalExtensionMacroSupplier = ExternalExtensionMacroSupplier.getInstance();
- public static EnvironmentMacroSupplier fEnvironmentMacroSupplier = EnvironmentMacroSupplier.getInstance();
public static MbsMacroSupplier fMbsMacroSupplier = MbsMacroSupplier.getInstance();
- public static CdtPathEntryMacroSupplier fCdtPathEntryMacroSupplier = CdtPathEntryMacroSupplier.getInstance();
- public static EclipseVariablesMacroSupplier fEclipseVariablesMacroSupplier = EclipseVariablesMacroSupplier.getInstance();
protected BuildMacroProvider(){
@@ -51,31 +64,9 @@ public class BuildMacroProvider implements IBuildMacroProvider {
*/
public IBuildMacro getMacro(String macroName, int contextType,
Object contextData, boolean includeParentContexts) {
- return getMacro(macroName,
- getMacroContextInfo(contextType,contextData),includeParentContexts);
- }
-
- /**
- * @param macroName
- * @param contextInfo
- * @param includeParentContexts
- * @return
- */
- static public IBuildMacro getMacro(String macroName, IMacroContextInfo contextInfo, boolean includeParentContexts) {
- if(contextInfo == null || macroName == null)
- return null;
-
- do{
- IBuildMacroSupplier suppliers[] = contextInfo.getSuppliers();
- if(suppliers != null){
- for(int i = 0; i < suppliers.length; i++){
- IBuildMacro macro = suppliers[i].getMacro(macroName,contextInfo.getContextType(),contextInfo.getContextData());
- if(macro != null)
- return macro;
- }
- }
- }while(includeParentContexts && (contextInfo = contextInfo.getNext()) != null);
-
+ ICdtVariable var = getVariable(macroName, contextType, contextData, includeParentContexts);
+ if(var != null)
+ return wrap(var);
return null;
}
@@ -84,62 +75,32 @@ public class BuildMacroProvider implements IBuildMacroProvider {
*/
public IBuildMacro[] getMacros(int contextType, Object contextData,
boolean includeParentContexts) {
- return getMacros(getMacroContextInfo(contextType,contextData),
- includeParentContexts);
+ ICdtVariable[] vars = getVariables(contextType, contextData, includeParentContexts);
+ if(vars != null)
+ return wrap(vars);
+ return null;
}
-
- /**
- * @param contextInfo
- * @param includeParentContexts
- * @return
- */
- static public IBuildMacro[] getMacros(IMacroContextInfo contextInfo,
- boolean includeParentContexts) {
- if(contextInfo == null)
- return null;
-
- Map map = new HashMap();
- IMacroContextInfo infos[] = includeParentContexts ?
- getAllMacroContextInfos(contextInfo) :
- new IMacroContextInfo[]{contextInfo};
-
- for(int k = infos.length - 1; k >= 0; k--){
- contextInfo = infos[k];
- IBuildMacroSupplier suppliers[] = contextInfo.getSuppliers();
- if(suppliers != null){
- for(int i = suppliers.length - 1; i >= 0; i--){
- IBuildMacro macros[] = suppliers[i].getMacros(contextInfo.getContextType(),contextInfo.getContextData());
- if(macros != null){
- for(int j = 0; j < macros.length; j++){
- map.put(macros[j].getName(),macros[j]);
- }
- }
- }
- }
+
+ public static CoreMacrosSupplier createCoreSupplier(IConfiguration cfg){
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ if(cfgDes != null){
+ return new CoreMacrosSupplier(cfgDes);
}
-
- Collection values = map.values();
- return (IBuildMacro[])values.toArray(new IBuildMacro[values.size()]);
+ return null;
}
- /*
- * returns an array of the IMacroContextInfo that holds the context informations
- * starting from the one passed to this method and including all subsequent parents
- */
- private static IMacroContextInfo[] getAllMacroContextInfos(IMacroContextInfo contextInfo){
- if(contextInfo == null)
- return null;
-
- List list = new ArrayList();
- list.add(contextInfo);
-
- while((contextInfo = contextInfo.getNext()) != null)
- list.add(contextInfo);
-
- return (IMacroContextInfo[])list.toArray(new IMacroContextInfo[list.size()]);
+
+ public ICdtVariable getVariable(String macroName, int contextType,
+ Object contextData, boolean includeParentContexts) {
+ return SupplierBasedCdtVariableManager.getVariable(macroName,
+ getMacroContextInfo(contextType,contextData),includeParentContexts);
}
+ public ICdtVariable[] getVariables(int contextType, Object contextData,
+ boolean includeParentContexts) {
+ return SupplierBasedCdtVariableManager.getVariables(getMacroContextInfo(contextType,contextData),includeParentContexts);
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#getSuppliers(int, java.lang.Object)
@@ -147,10 +108,22 @@ public class BuildMacroProvider implements IBuildMacroProvider {
public IBuildMacroSupplier[] getSuppliers(int contextType,
Object contextData) {
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- if(info != null)
- return info.getSuppliers();
+ if(info != null){
+ ICdtVariableSupplier suppliers[] = info.getSuppliers();
+ if(suppliers != null)
+ return filterMacroSuppliers(suppliers);
+ }
return null;
}
+
+ private static IBuildMacroSupplier[] filterMacroSuppliers(ICdtVariableSupplier suppliers[]){
+ List list = new ArrayList(suppliers.length);
+ for(int i = 0; i < suppliers.length; i++){
+ if(suppliers[i] instanceof IBuildMacroSupplier)
+ list.add(suppliers[i]);
+ }
+ return (IBuildMacroSupplier[])list.toArray(new IBuildMacroSupplier[list.size()]);
+ }
/**
* @param contextType
@@ -170,7 +143,26 @@ public class BuildMacroProvider implements IBuildMacroProvider {
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#convertStringListToString(java.lang.String[], java.lang.String)
*/
public String convertStringListToString(String[] value, String listDelimiter) {
- return MacroResolver.convertStringListToString(value,listDelimiter);
+ return CdtVariableResolver.convertStringListToString(value,listDelimiter);
+ }
+
+ public static IBuildMacro wrap(ICdtVariable var){
+ if(var == null)
+ return null;
+ if(var instanceof IBuildMacro)
+ return (IBuildMacro)var;
+ return new BuildMacro(var);
+ }
+
+ public static IBuildMacro[] wrap(ICdtVariable vars[]){
+ if(vars instanceof IBuildMacro[])
+ return (IBuildMacro[])vars;
+
+ IBuildMacro macros[] = new IBuildMacro[vars.length];
+ for(int i = 0; i < macros.length; i++){
+ macros[i] = wrap(vars[i]);
+ }
+ return macros;
}
/* (non-Javadoc)
@@ -179,12 +171,16 @@ public class BuildMacroProvider implements IBuildMacroProvider {
public String resolveValue(String value, String nonexistentMacrosValue,
String listDelimiter, int contextType, Object contextData)
throws BuildMacroException {
-
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- if(info != null)
- return MacroResolver.resolveToString(value,
- getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
- return null;
+ if(info != null){
+ try {
+ return CdtVariableResolver.resolveToString(value,
+ getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
+ return value;
}
/* (non-Javadoc)
@@ -195,8 +191,13 @@ public class BuildMacroProvider implements IBuildMacroProvider {
int contextType, Object contextData) throws BuildMacroException {
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- if(info != null)
- return MacroResolver.resolveToStringList(value,getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ if(info != null){
+ try {
+ return CdtVariableResolver.resolveToStringList(value,getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
return null;
}
@@ -208,9 +209,14 @@ public class BuildMacroProvider implements IBuildMacroProvider {
int contextType, Object contextData) throws BuildMacroException {
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- if(info != null)
- return MacroResolver.resolveToString(value,
- getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ if(info != null){
+ try {
+ return CdtVariableResolver.resolveToString(value,
+ getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
return null;
}
@@ -222,8 +228,13 @@ public class BuildMacroProvider implements IBuildMacroProvider {
throws BuildMacroException {
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- if(info != null)
- return MacroResolver.resolveToStringList(value,getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ if(info != null){
+ try {
+ return CdtVariableResolver.resolveToStringList(value,getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
return null;
}
@@ -232,8 +243,8 @@ public class BuildMacroProvider implements IBuildMacroProvider {
*/
public boolean isStringListValue(String value, int contextType, Object contextData) throws BuildMacroException {
try {
- MacroResolver.resolveToStringList(value,getMacroSubstitutor(getMacroContextInfo(contextType,contextData)," ",null)); //$NON-NLS-1$
- }catch(BuildMacroException e){
+ CdtVariableResolver.resolveToStringList(value,getMacroSubstitutor(getMacroContextInfo(contextType,contextData)," ",null)); //$NON-NLS-1$
+ }catch(CdtVariableException e){
return false;
}
return true;
@@ -246,42 +257,33 @@ public class BuildMacroProvider implements IBuildMacroProvider {
public void checkIntegrity(int contextType, Object contextData)
throws BuildMacroException {
+ final ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- IMacroSubstitutor subst = new DefaultMacroSubstitutor(info,null,""){ //$NON-NLS-1$
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException {
- if(macro instanceof EclipseVariablesMacroSupplier.EclipseVarMacro)
+ IVariableSubstitutor subst = new SupplierBasedCdtVariableSubstitutor(info,null,""){ //$NON-NLS-1$
+ protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException {
+ IStringVariable var = mngr.toEclipseVariable(macro, null);
+ if(var instanceof IDynamicVariable)
return new ResolvedMacro(macro.getName(),""); //$NON-NLS-1$
return super.resolveMacro(macro);
}
};
- if(info != null)
- MacroResolver.checkIntegrity(info,subst);
+ if(info != null){
+ try {
+ CdtVariableResolver.checkIntegrity(info,subst);
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
}
- public IMacroSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
- return new DefaultMacroSubstitutor(info, inexistentMacroValue, listDelimiter);
+ public SupplierBasedCdtVariableSubstitutor getMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
+ return new SupplierBasedCdtVariableSubstitutor(info, inexistentMacroValue, listDelimiter);
}
- public IMacroSubstitutor getBuildfileMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
+ public IVariableSubstitutor getBuildfileMacroSubstitutor(IMacroContextInfo info, String inexistentMacroValue, String listDelimiter){
return new BuildfileMacroSubstitutor(info, inexistentMacroValue, listDelimiter);
}
- /*
- * returns true if the first passed contextInfo is the child of the second one
- */
- public boolean checkParentContextRelation(IMacroContextInfo child, IMacroContextInfo parent){
- if(child == null || parent == null)
- return false;
-
- IMacroContextInfo enumInfo = child;
- do{
- if(parent.getContextType() == enumInfo.getContextType() &&
- parent.getContextData() == enumInfo.getContextData())
- return true;
- }while((enumInfo = enumInfo.getNext()) != null);
- return false;
- }
-
/**
* answers whether the environment macros are to be expanded in the buildfile
*
@@ -289,7 +291,8 @@ public class BuildMacroProvider implements IBuildMacroProvider {
* @return
*/
public boolean areMacrosExpandedInBuildfile(IConfiguration cfg){
- boolean expanded = fUserDefinedMacroSupplier.areMacrosExpanded(cfg);
+ IBuilder builder = cfg.getBuilder();
+ boolean expanded = !builder.keepEnvironmentVariablesInBuildfile();
if(expanded || canKeepMacrosInBuildfile(cfg))
return expanded;
return true;
@@ -307,12 +310,46 @@ public class BuildMacroProvider implements IBuildMacroProvider {
*/
public boolean expandMacrosInBuildfile(IConfiguration cfg, boolean expand){
if(expand || canKeepMacrosInBuildfile(cfg)){
- fUserDefinedMacroSupplier.setMacrosExpanded(cfg,expand);
+ IBuilder builder = cfg.getEditableBuilder();
+ builder.setKeepEnvironmentVariablesInBuildfile(!expand);
return expand;
}
return true;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValues(java.lang.String[], java.lang.String, java.lang.String, int, java.lang.Object)
+ */
+ public String[] resolveStringListValues(String[] value, String nonexistentMacrosValue, String listDelimiter, int contextType, Object contextData) throws BuildMacroException {
+ IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
+ if(info != null){
+ try {
+ return CdtVariableResolver.resolveStringListValues(value,
+ getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter), true);
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValuesToMakefileFormat(java.lang.String[], java.lang.String, java.lang.String, int, java.lang.Object)
+ */
+ public String[] resolveStringListValuesToMakefileFormat(String[] value, String nonexistentMacrosValue, String listDelimiter, int contextType, Object contextData) throws BuildMacroException {
+ IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
+ if(info != null){
+ try {
+ return CdtVariableResolver.resolveStringListValues(value,
+ getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter), true);
+ } catch (CdtVariableException e) {
+ throw new BuildMacroException(e);
+ }
+ }
+ return null;
+ }
+
/**
* answers whether the builder used for the given configuration is capable
* of handling macros in the buildfile
@@ -320,8 +357,13 @@ public class BuildMacroProvider implements IBuildMacroProvider {
* @param cfg
* @return
*/
- public boolean canKeepMacrosInBuildfile(IConfiguration cfg){
- return MacroResolver.canKeepMacrosInBuildfile(cfg);
+ public static boolean canKeepMacrosInBuildfile(IConfiguration cfg){
+ if(cfg != null){
+ IToolChain toolChain = cfg.getToolChain();
+ if(toolChain != null)
+ return canKeepMacrosInBuildfile(toolChain.getBuilder());
+ }
+ return false;
}
/**
@@ -331,29 +373,101 @@ public class BuildMacroProvider implements IBuildMacroProvider {
* @param builder
* @return
*/
- public boolean canKeepMacrosInBuildfile(IBuilder builder){
- return MacroResolver.canKeepMacrosInBuildfile(builder);
+ public static boolean canKeepMacrosInBuildfile(IBuilder builder){
+ if(builder != null){
+ String pattern = builder.getBuilderVariablePattern();
+ if(pattern != null && pattern.indexOf(PATTERN_MACRO_NAME) != -1)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * creates a macro reference in the buildfile format for the given builder.
+ * If the builder can not treat macros, returns null
+ * @param name
+ * @param builder
+ * @return String
+ */
+ public static String createBuildfileMacroReference(String name, IBuilder builder){
+ String ref = null;
+ if(builder != null){
+ String pattern = builder.getBuilderVariablePattern();
+ if(pattern != null && pattern.indexOf(PATTERN_MACRO_NAME) != -1)
+ ref = pattern.replaceAll(PATTERN_MACRO_NAME,name);
+ }
+ return ref;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValues(java.lang.String[], java.lang.String, java.lang.String, int, java.lang.Object)
+ /**
+ * creates a macro reference in the buildfile format for the builder used for
+ * the given configuration.
+ * If the builder can not treat macros, returns null
+ * @param name
+ * @param cfg
+ * @return String
*/
- public String[] resolveStringListValues(String[] value, String nonexistentMacrosValue, String listDelimiter, int contextType, Object contextData) throws BuildMacroException {
- IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- if(info != null)
- return MacroResolver.resolveStringListValues(value,
- getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter), true);
+ public static String createBuildfileMacroReference(String name, IConfiguration cfg){
+ String ref = null;
+ if(cfg != null){
+ IToolChain toolChain = cfg.getToolChain();
+ if(toolChain != null)
+ ref = createBuildfileMacroReference(name,toolChain.getBuilder());
+ }
+ return ref;
+ }
+
+ /**
+ * Returns the array of the explicit file macros, referenced in the tool's options
+ * (Explicit file macros are the file-specific macros, whose values are not provided
+ * by the tool-integrator. As a result these macros contain explicit values, but not the values
+ * specified in the format of the builder automatic variables and text functions)
+ *
+ * @param tool
+ * @return
+ */
+ public static IBuildMacro[] getReferencedExplitFileMacros(ITool tool){
+ if(tool instanceof Tool){
+ Tool t = (Tool)tool;
+ ExplicitFileMacroCollector collector = new ExplicitFileMacroCollector(null);
+ try {
+ t.getToolCommandFlags(null,null,collector, getDefault());
+ } catch (BuildException e){
+ }
+ return collector.getExplicisFileMacros();
+ }
+ return new IBuildMacro[0];
+ }
+
+ static IConfiguration getConfiguration(ITool tool){
+ IBuildObject bo = tool.getParent();
+ if(bo instanceof IResourceConfiguration)
+ return ((IResourceConfiguration)bo).getParent();
+ else if (bo instanceof IToolChain)
+ return ((IToolChain)bo).getParent();
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValuesToMakefileFormat(java.lang.String[], java.lang.String, java.lang.String, int, java.lang.Object)
+
+
+ /**
+ * Returns the array of the explicit file macros, referenced in the given string
+ * (Explicit file macros are the file-specific macros, whose values are not provided
+ * by the tool-integrator. As a result these macros contain explicit values, but not the values
+ * specified in the format of the builder automatic variables and text functions)
+ *
+ * @param expression
+ * @param contextType
+ * @param contextData
+ * @return
*/
- public String[] resolveStringListValuesToMakefileFormat(String[] value, String nonexistentMacrosValue, String listDelimiter, int contextType, Object contextData) throws BuildMacroException {
- IMacroContextInfo info = getMacroContextInfo(contextType,contextData);
- if(info != null)
- return MacroResolver.resolveStringListValues(value,
- getBuildfileMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter), true);
- return null;
+ public static IBuildMacro[] getReferencedExplitFileMacros(String expression, int contextType, Object contextData){
+ ExplicitFileMacroCollector collector = new ExplicitFileMacroCollector(getDefault().getMacroContextInfo(contextType, contextData));
+ try {
+ CdtVariableResolver.resolveToString(expression,collector);
+ } catch (CdtVariableException e){
+ }
+ return collector.getExplicisFileMacros();
}
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroStatus.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroStatus.java
index 48c3a7fe063..f25cb85ab52 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroStatus.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroStatus.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,204 +10,65 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.macros;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableStatus;
/**
* This class implements the IBuildMacroStatus interface
*
* @since 3.0
*/
-public class BuildMacroStatus extends Status implements IBuildMacroStatus {
- /*
- * String constants
- */
- private static final String PREFIX = "BuildMacroStatus"; //$NON-NLS-1$
- private static final String STATUS = PREFIX + ".status"; //$NON-NLS-1$
- private static final String STATUS_MACRO_UNDEFINED = STATUS + ".macro.undefined"; //$NON-NLS-1$
- private static final String STATUS_MACROS_REFERENCE_EACHOTHER = STATUS + ".reference.eachother"; //$NON-NLS-1$
- private static final String STATUS_MACRO_REFERENCE_INCORRECT = STATUS + ".reference.incorrect"; //$NON-NLS-1$
- private static final String STATUS_MACRO_NOT_STRING = STATUS + ".macro.not.string"; //$NON-NLS-1$
- private static final String STATUS_MACRO_NOT_STRINGLIST = STATUS + ".macro.not.stringlist"; //$NON-NLS-1$
- private static final String STATUS_ERROR = STATUS + ".error"; //$NON-NLS-1$
- private static final String VALUE_UNDEFINED = PREFIX + ".value.undefined"; //$NON-NLS-1$
+public class BuildMacroStatus extends SupplierBasedCdtVariableStatus implements IBuildMacroStatus {
- private String fMacroName;
- private String fExpression;
- private String fReferencedName;
- private int fContextType;
- private Object fContextData;
-
- /**
- *
- * @param severity one of the IStatus.xxx severity statuses
- * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
- * @param message message, can be null. In this case the default message will
- * be generated base upon the other status info
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- * @param macroName the name of the build macro whose resolution caused this status creation or null if none
- * @param expression the string whose resolutinon caused caused this status creation or null if none
- * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
- * @param contextType the context type used in the operation
- * @param contextData the context data used in the operation
- */
- public BuildMacroStatus(int severity,
- int code,
- String message,
- Throwable exception,
- String macroName,
- String expression,
- String referencedName,
- int contextType,
- Object contextData) {
- super(severity,ManagedBuilderCorePlugin.getUniqueIdentifier(),code,message != null ? message : "",exception); //$NON-NLS-1$
- fExpression = expression;
- fReferencedName = referencedName;
- fContextType = contextType;
- fContextData = contextData;
- fMacroName = macroName;
- if(message == null)
- setMessage(generateMessage());
+ public BuildMacroStatus(int severity, int code, String message,
+ Throwable exception, String macroName, String expression,
+ String referencedName, IVariableContextInfo info) {
+ super(severity, code, message, exception, macroName, expression,
+ referencedName, info);
}
- /**
- * Creates status with the IStatus.ERROR severity
- *
- * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
- * @param message message, can be null. In this case the default message will
- * be generated base upon the other status info
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- * @param macroName the name of the build macro whose resolution caused this status creation or null if none
- * @param expression the string whose resolutinon caused caused this status creation or null if none
- * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
- * @param contextType the context type used in the operation
- * @param contextData the context data used in the operation
- */
- public BuildMacroStatus(
- int code,
- String message,
- Throwable exception,
- String macroName,
- String expression,
- String referencedName,
- int contextType,
- Object contextData) {
- this(IStatus.ERROR,code,message,exception,macroName,expression,referencedName,contextType,contextData);
+ public BuildMacroStatus(int code, String macroName, String expression,
+ String referencedName, IVariableContextInfo info) {
+ super(code, macroName, expression, referencedName, info);
}
- /**
- * Creates status with the IStatus.ERROR severity and with the default message
- *
- * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- * @param macroName the name of the build macro whose resolution caused this status creation or null if none
- * @param expression the string whose resolutinon caused caused this status creation or null if none
- * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
- * @param contextType the context type used in the operation
- * @param contextData the context data used in the operation
- */
- public BuildMacroStatus(
- int code,
- String macroName,
- String expression,
- String referencedName,
- int contextType,
- Object contextData) {
- this(IStatus.ERROR,code,null,null,macroName,expression,referencedName,contextType,contextData);
- }
-
- /**
- * generates and returns the default status message based upon then status data
- *
- * @return String
- */
- protected String generateMessage(){
- String message = null;
- switch(getCode()){
- case TYPE_MACRO_UNDEFINED:{
- String refName = fReferencedName;
- if(refName == null)
- refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
- message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_UNDEFINED,refName);
- }
- break;
- case TYPE_MACROS_REFERENCE_EACHOTHER:{
- String name = fMacroName;
- String refName = fReferencedName;
- if(name == null)
- name = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
- if(refName == null)
- refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
- message = ManagedMakeMessages.getFormattedString(STATUS_MACROS_REFERENCE_EACHOTHER,new String[]{name,refName});
- }
- break;
- case TYPE_MACRO_REFERENCE_INCORRECT:{
- String refName = fReferencedName;
- if(refName == null)
- refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
- message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_REFERENCE_INCORRECT,refName);
- }
- break;
- case TYPE_MACRO_NOT_STRING:{
- String refName = fReferencedName;
- if(refName == null)
- refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
- message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_NOT_STRING,refName);
- }
- break;
- case TYPE_MACRO_NOT_STRINGLIST:{
- String refName = fReferencedName;
- if(refName == null)
- refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
- message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_NOT_STRINGLIST,refName);
- }
- break;
- case TYPE_ERROR:
- default:
- message = ManagedMakeMessages.getResourceString(STATUS_ERROR);
- }
- return message;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getMacroName()
- */
- public String getMacroName() {
- return fMacroName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getExpression()
- */
- public String getExpression() {
- return fExpression;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getReferencedName()
- */
- public String getReferencedMacroName() {
- return fReferencedName;
+ public BuildMacroStatus(int code, String message, Throwable exception,
+ String macroName, String expression, String referencedName,
+ IVariableContextInfo info) {
+ super(code, message, exception, macroName, expression, referencedName, info);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getContextType()
*/
public int getContextType() {
- return fContextType;
+ IMacroContextInfo info = getMacroContextInfo();
+ if(info != null){
+ return info.getContextType();
+ }
+ return 0;
+ }
+
+ private IMacroContextInfo getMacroContextInfo(){
+ IVariableContextInfo info = getVariableContextInfo();
+ if(info instanceof IMacroContextInfo)
+ return (IMacroContextInfo)info;
+ return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getContextData()
*/
public Object getContextData() {
- return fContextData;
+ IMacroContextInfo info = getMacroContextInfo();
+ if(info != null){
+ return info.getContextData();
+ }
+ return null;
}
+ public String getMacroName() {
+ return getVariableName();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildfileMacroSubstitutor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildfileMacroSubstitutor.java
index 8c6dcbf6420..f1c0a749a33 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildfileMacroSubstitutor.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildfileMacroSubstitutor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -15,6 +15,12 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IInputType;
@@ -22,13 +28,13 @@ import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IReservedMacroNameSupplier;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
import org.eclipse.core.resources.IResource;
/**
@@ -39,11 +45,13 @@ import org.eclipse.core.resources.IResource;
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor
* @since 3.0
*/
-public class BuildfileMacroSubstitutor extends DefaultMacroSubstitutor {
+public class BuildfileMacroSubstitutor extends SupplierBasedCdtVariableSubstitutor {
private static final String PATTERN_MACRO_NAME = "="; //$NON-NLS-1$
private IConfiguration fConfiguration;
private IBuilder fBuilder;
private HashSet fCaseInsensitiveReferencedNames;
+ private ICdtVariableManager fVarMngr;
+ private ICConfigurationDescription fCfgDes;
private class DefaultReservedMacroNameSupplier implements IReservedMacroNameSupplier{
String fReservedNames[];
@@ -112,35 +120,66 @@ public class BuildfileMacroSubstitutor extends DefaultMacroSubstitutor {
}
}
- public BuildfileMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
- super(contextType, contextData, inexistentMacroValue, listDelimiter);
- init();
+// public BuildfileMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
+// super(contextType, contextData, inexistentMacroValue, listDelimiter);
+// init();
+// }
+
+ public BuildfileMacroSubstitutor(IBuilder builder, IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
+ super(contextInfo, inexistentMacroValue, listDelimiter);
+ init(builder, contextInfo);
}
public BuildfileMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
- super(contextInfo, inexistentMacroValue, listDelimiter);
- init();
+ this(null, contextInfo, inexistentMacroValue, listDelimiter);
}
- private void init(){
- IMacroContextInfo contextInfo = getMacroContextInfo();
+
+
+ private void init(IBuilder builder, IMacroContextInfo contextInfo){
if(contextInfo == null)
return;
+ fVarMngr = CCorePlugin.getDefault().getCdtVariableManager();
+
+ if(builder != null){
+ fBuilder = builder;
+ fConfiguration = builder.getParent().getParent();
+ } else {
+ IBuildObject[] bos = findConfigurationAndBuilderFromContext(contextInfo);
+ if(bos != null){
+ fConfiguration = (IConfiguration)bos[0];
+ fBuilder = (IBuilder)bos[1];
+ }
+ }
+
+ if(fConfiguration != null){
+ fCfgDes = ManagedBuildManager.getDescriptionForConfiguration(fConfiguration);
+ }
+ }
+
+ static IBuildObject[] findConfigurationAndBuilderFromContext(IMacroContextInfo contextInfo){
int type = contextInfo.getContextType();
+ IConfiguration cfg = null;
+ IBuilder builder = null;
switch(type){
case IBuildMacroProvider.CONTEXT_FILE:
- contextInfo = contextInfo.getNext();
+ contextInfo = (IMacroContextInfo)contextInfo.getNext();
if(contextInfo == null)
break;
case IBuildMacroProvider.CONTEXT_OPTION:
- contextInfo = contextInfo.getNext();
+ contextInfo = (IMacroContextInfo)contextInfo.getNext();
if(contextInfo == null)
break;
case IBuildMacroProvider.CONTEXT_CONFIGURATION:{
Object contextData = contextInfo.getContextData();
- if(contextData instanceof IConfiguration)
- fConfiguration = (IConfiguration)contextData;
+ if(contextData instanceof IConfiguration){
+ cfg = (IConfiguration)contextData;
+ builder = cfg.getBuilder();
+ } else if (contextData instanceof IBuilder){
+ builder = (IBuilder)contextData;
+ cfg = builder.getParent().getParent();
+ }
}
break;
case IBuildMacroProvider.CONTEXT_PROJECT:{
@@ -149,29 +188,29 @@ public class BuildfileMacroSubstitutor extends DefaultMacroSubstitutor {
IResource rc = ((IManagedProject)contextData).getOwner();
if(rc != null){
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(rc);
- fConfiguration = info.getDefaultConfiguration();
+ cfg = info.getDefaultConfiguration();
+ builder = cfg.getBuilder();
}
}
}
break;
}
- if(fConfiguration != null){
- IToolChain toolChain = fConfiguration.getToolChain();
- if(toolChain != null)
- fBuilder = toolChain.getBuilder();
- }
+
+ if(cfg != null && builder != null)
+ return new IBuildObject[]{cfg, builder};
+ return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor#resolveMacro(org.eclipse.cdt.managedbuilder.macros.IBuildMacro)
*/
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
+ protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException{
ResolvedMacro resolved = null;
if(fConfiguration != null && fBuilder != null &&
- !UserDefinedMacroSupplier.getInstance().areMacrosExpanded(fConfiguration) &&
- macro instanceof EnvironmentMacroSupplier.EnvVarMacro &&
- !MacroResolver.isStringListMacro(macro.getMacroValueType())){
+ fBuilder.keepEnvironmentVariablesInBuildfile() &&
+ fVarMngr.isEnvironmentVariable(macro, fCfgDes) &&
+ !CdtVariableResolver.isStringListVariable(macro.getValueType())){
String ref = getMacroReference(macro);
if(ref != null)
resolved = new ResolvedMacro(macro.getName(),ref);
@@ -196,7 +235,7 @@ public class BuildfileMacroSubstitutor extends DefaultMacroSubstitutor {
return supplier;
}
- protected String getMacroReference(IBuildMacro macro){
+ protected String getMacroReference(ICdtVariable macro){
String macroName = macro.getName();
String ref = null;
IReservedMacroNameSupplier supplier = getReservedMacroNameSupplier();
@@ -222,18 +261,18 @@ public class BuildfileMacroSubstitutor extends DefaultMacroSubstitutor {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor#setMacroContextInfo(org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo)
*/
- public void setMacroContextInfo(IMacroContextInfo info)
- throws BuildMacroException{
+ public void setMacroContextInfo(IVariableContextInfo info)
+ throws CdtVariableException{
super.setMacroContextInfo(info);
- init();
+// init();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#setMacroContextInfo(int, java.lang.Object)
*/
- public void setMacroContextInfo(int contextType, Object contextData) throws BuildMacroException{
- super.setMacroContextInfo(contextType, contextData);
- init();
- }
+// public void setMacroContextInfo(int contextType, Object contextData) throws BuildMacroException{
+// super.setMacroContextInfo(contextType, contextData);
+// init();
+// }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CdtPathEntryMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CdtPathEntryMacroSupplier.java
deleted file mode 100644
index dcabe92a7a2..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CdtPathEntryMacroSupplier.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * This supplier suplies the macros that represent the CDT Path entry variables
- *
- * @since 3.0
- */
-public class CdtPathEntryMacroSupplier implements IBuildMacroSupplier {
- private static CdtPathEntryMacroSupplier fInstance;
-
- private CdtPathEntryMacroSupplier(){
-
- }
-
- public static CdtPathEntryMacroSupplier getInstance(){
- if(fInstance == null)
- fInstance = new CdtPathEntryMacroSupplier();
- return fInstance;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
- */
- public IBuildMacro getMacro(String macroName, int contextType,
- Object contextData) {
- if(contextType != IBuildMacroProvider.CONTEXT_WORKSPACE)
- return null;
- if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
- return null;
-
- IPathEntryVariableManager mngr = CCorePlugin.getDefault().getPathEntryVariableManager();
- if(mngr == null)
- return null;
-
- IPath path = mngr.getValue(macroName);
- if(path != null)
- return new BuildMacro(macroName,BuildMacro.VALUE_PATH_ANY,path.toOSString());
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
- */
- public IBuildMacro[] getMacros(int contextType, Object contextData) {
- if(contextType != IBuildMacroProvider.CONTEXT_WORKSPACE)
- return null;
- IPathEntryVariableManager mngr = CCorePlugin.getDefault().getPathEntryVariableManager();
- if(mngr == null)
- return null;
-
- String names[] = mngr.getVariableNames();
- BuildMacro macros[] = new BuildMacro[names.length];
- for(int i = 0; i < names.length; i++)
- macros[i] = new BuildMacro(names[i],BuildMacro.VALUE_PATH_ANY,mngr.getValue(names[i]).toOSString());
- return macros;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CoreMacrosSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CoreMacrosSupplier.java
new file mode 100644
index 00000000000..a72ada614c0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/CoreMacrosSupplier.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.macros;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
+
+public class CoreMacrosSupplier extends BuildCdtVariablesSupplierBase {
+ private ICConfigurationDescription fCfgDes;
+ private ICdtVariableManager fMngr;
+ CoreMacrosSupplier(ICConfigurationDescription cfgDes){
+ fCfgDes = cfgDes;
+ fMngr = CCorePlugin.getDefault().getCdtVariableManager();
+ }
+
+ public IBuildMacro getMacro(String macroName, int contextType,
+ Object contextData) {
+ return BuildMacroProvider.wrap(getVariable(macroName, null));
+ }
+
+ public IBuildMacro[] getMacros(int contextType, Object contextData) {
+ return BuildMacroProvider.wrap(getVariables(null));
+ }
+
+ public ICdtVariable getVariable(String macroName, IMacroContextInfo context) {
+ return fMngr.getVariable(macroName, fCfgDes);
+ }
+
+ public ICdtVariable[] getVariables(IMacroContextInfo context) {
+ return fMngr.getVariables(fCfgDes);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroContextInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroContextInfo.java
index 936661b4abc..27a18eb81be 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroContextInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroContextInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -11,6 +11,7 @@
package org.eclipse.cdt.managedbuilder.internal.macros;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
@@ -18,9 +19,10 @@ import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
import org.eclipse.cdt.managedbuilder.macros.IFileContextData;
import org.eclipse.cdt.managedbuilder.macros.IOptionContextData;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -30,7 +32,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
* @since 3.0
*/
public class DefaultMacroContextInfo implements IMacroContextInfo {
- private IBuildMacroSupplier fSuppliers[];
+ private ICdtVariableSupplier fSuppliers[];
private int fType;
private Object fData;
@@ -39,48 +41,56 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
fData = data;
}
- protected DefaultMacroContextInfo(int type, Object data, IBuildMacroSupplier suppliers[]){
+ public DefaultMacroContextInfo(int type, Object data, ICdtVariableSupplier suppliers[]){
fType = type;
fData = data;
fSuppliers = suppliers;
}
- protected IBuildMacroSupplier[] getSuppliers(int type, Object data){
+ protected ICdtVariableSupplier[] getSuppliers(int type, Object data){
switch(type){
case IBuildMacroProvider.CONTEXT_FILE:
if(data instanceof IFileContextData){
- return new IBuildMacroSupplier[]{
+ return new ICdtVariableSupplier[]{
BuildMacroProvider.fMbsMacroSupplier
};
}
break;
case IBuildMacroProvider.CONTEXT_OPTION:
if(data instanceof IOptionContextData){
- return new IBuildMacroSupplier[]{
+ return new ICdtVariableSupplier[]{
BuildMacroProvider.fMbsMacroSupplier
};
}
break;
case IBuildMacroProvider.CONTEXT_TOOL:
if(data instanceof ITool){
- return new IBuildMacroSupplier[]{
+ return new ICdtVariableSupplier[]{
BuildMacroProvider.fMbsMacroSupplier
};
}
break;
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
+ IConfiguration cfg = null;
+
if(data instanceof IConfiguration){
- return new IBuildMacroSupplier[]{
- BuildMacroProvider.fUserDefinedMacroSupplier,
- BuildMacroProvider.fExternalExtensionMacroSupplier,
- BuildMacroProvider.fEnvironmentMacroSupplier,
- BuildMacroProvider.fMbsMacroSupplier
- };
+ cfg = (IConfiguration)data;
+ } else if(data instanceof IBuilder){
+ cfg = ((IBuilder)data).getParent().getParent();
+ }
+
+ if(cfg != null){
+ CoreMacrosSupplier supplier = BuildMacroProvider.createCoreSupplier(cfg);
+ if(supplier != null){
+ return new ICdtVariableSupplier[]{
+ supplier
+ };
+ }
}
break;
- case IBuildMacroProvider.CONTEXT_PROJECT:
+/* case IBuildMacroProvider.CONTEXT_PROJECT:
if(data instanceof IManagedProject){
- return new IBuildMacroSupplier[]{
+ return new ICdtVariableSupplier[]{
BuildMacroProvider.fUserDefinedMacroSupplier,
BuildMacroProvider.fExternalExtensionMacroSupplier,
BuildMacroProvider.fEnvironmentMacroSupplier,
@@ -90,7 +100,7 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
break;
case IBuildMacroProvider.CONTEXT_WORKSPACE:
if(data instanceof IWorkspace){
- return new IBuildMacroSupplier[]{
+ return new ICdtVariableSupplier[]{
BuildMacroProvider.fUserDefinedMacroSupplier,
BuildMacroProvider.fEnvironmentMacroSupplier,
BuildMacroProvider.fMbsMacroSupplier,
@@ -101,18 +111,19 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
break;
case IBuildMacroProvider.CONTEXT_INSTALLATIONS:
if(data == null){
- return new IBuildMacroSupplier[]{
+ return new ICdtVariableSupplier[]{
BuildMacroProvider.fMbsMacroSupplier
};
}
break;
case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
if(data == null){
- return new IBuildMacroSupplier[]{
+ return new ICdtVariableSupplier[]{
BuildMacroProvider.fEnvironmentMacroSupplier
};
}
break;
+ */
}
return null;
}
@@ -134,7 +145,7 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getSuppliers()
*/
- public IBuildMacroSupplier[] getSuppliers() {
+ public ICdtVariableSupplier[] getSuppliers() {
if(fSuppliers == null)
fSuppliers = getSuppliers(fType, fData);
return fSuppliers;
@@ -143,7 +154,7 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getNext()
*/
- public IMacroContextInfo getNext() {
+ public IVariableContextInfo getNext() {
switch(fType){
case IBuildMacroProvider.CONTEXT_FILE:
if(fData instanceof IFileContextData){
@@ -203,8 +214,14 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
}
break;
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
+ IConfiguration configuration = null;
if(fData instanceof IConfiguration){
- IConfiguration configuration = (IConfiguration)fData;
+ configuration = (IConfiguration)fData;
+ } else if(fData instanceof IBuilder){
+ configuration = ((IBuilder)fData).getParent().getParent();
+ }
+
+ if(configuration != null){
IManagedProject managedProject = configuration.getManagedProject();
if(managedProject != null)
return new DefaultMacroContextInfo(
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/EnvironmentMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/EnvironmentMacroSupplier.java
deleted file mode 100644
index 866708f1b7b..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/EnvironmentMacroSupplier.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
-
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
-import org.eclipse.core.resources.IWorkspace;
-
-/**
- * This supplier suplies the macros that represent the Managed Build environment variables
- *
- * @since 3.0
- */
-public class EnvironmentMacroSupplier implements IBuildMacroSupplier {
- private static EnvironmentMacroSupplier fInstance;
- private EnvironmentVariableProvider fEnvironmentProvider;
-
- public class EnvVarMacro extends BuildMacro{
- private IBuildEnvironmentVariable fVariable;
- private EnvVarMacro(IBuildEnvironmentVariable var){
- fName = var.getName();
- fVariable = var;
- }
-
- private void loadValue(IBuildEnvironmentVariable var){
- String delimiter = var.getDelimiter();
- String value = var.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE ?
- var.getValue() : null;
-
- if(delimiter != null && !"".equals(delimiter)){ //$NON-NLS-1$
- fType = VALUE_TEXT_LIST;
- if(value != null){
- List list = EnvVarOperationProcessor.convertToList(value,delimiter);
- fStringListValue = (String[])list.toArray(new String[list.size()]);
- } else {
- fStringListValue = null;
- }
- } else {
- fType = VALUE_TEXT;
- fStringValue = value;
- }
- }
-
-
- public int getMacroValueType() {
- if(fVariable != null){
- loadValue(fVariable);
-
- //we do not need it any more, release clean the reference
- fVariable = null;
- }
- return super.getMacroValueType();
- }
-
- public String getStringValue() throws BuildMacroException {
- if(fVariable != null){
- loadValue(fVariable);
-
- //we do not need it any more, release clean the reference
- fVariable = null;
- }
- return super.getStringValue();
- }
-
- public String[] getStringListValue() throws BuildMacroException {
- if(fVariable != null){
- loadValue(fVariable);
-
- //we do not need it any more, release clean the reference
- fVariable = null;
- }
- return super.getStringListValue();
- }
- }
-
- protected EnvironmentMacroSupplier(){
- this((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider());
- }
-
- public EnvironmentMacroSupplier(EnvironmentVariableProvider varProvider){
- fEnvironmentProvider = varProvider;
- }
-
- public IBuildMacro createBuildMacro(IBuildEnvironmentVariable var){
- if(var != null)
- return new EnvVarMacro(var);
- return null;
- }
-
- public static EnvironmentMacroSupplier getInstance(){
- if(fInstance == null)
- fInstance = new EnvironmentMacroSupplier();
- return fInstance;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
- */
- public IBuildMacro getMacro(String macroName, int contextType,
- Object contextData) {
- if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
- return null;
-
- IBuildEnvironmentVariable var = null;
- switch(contextType){
- case IBuildMacroProvider.CONTEXT_CONFIGURATION:
- if(contextData instanceof IConfiguration){
- var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
- }
- break;
- case IBuildMacroProvider.CONTEXT_PROJECT:
- if(contextData instanceof IManagedProject){
- var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
- }
- break;
- case IBuildMacroProvider.CONTEXT_WORKSPACE:
- if(contextData instanceof IWorkspace){
- var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
- }
- break;
- case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
- if(contextData == null){
- var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
- }
- break;
- }
- if(var != null && var.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE)
- return new EnvVarMacro(var);
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
- */
- public IBuildMacro[] getMacros(int contextType, Object contextData) {
- IBuildEnvironmentVariable vars[] = null;
-
- switch(contextType){
- case IBuildMacroProvider.CONTEXT_CONFIGURATION:
- if(contextData instanceof IConfiguration){
- vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
- }
- break;
- case IBuildMacroProvider.CONTEXT_PROJECT:
- if(contextData instanceof IManagedProject){
- vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
- }
- break;
- case IBuildMacroProvider.CONTEXT_WORKSPACE:
- if(contextData instanceof IWorkspace){
- vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
- }
- break;
- case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
- if(contextData == null){
- vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
- }
- break;
- }
-
- if(vars != null){
- EnvVarMacro macros[] = new EnvVarMacro[vars.length];
- for(int i = 0; i < macros.length; i++)
- macros[i] = new EnvVarMacro(vars[i]);
-
- return macros;
- }
- return null;
- }
-
- public EnvironmentVariableProvider getEnvironmentVariableProvider(){
- return fEnvironmentProvider;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExplicitFileMacroCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExplicitFileMacroCollector.java
index 8e1be85fdd1..9f7d238ab35 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExplicitFileMacroCollector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/ExplicitFileMacroCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -13,6 +13,8 @@ package org.eclipse.cdt.managedbuilder.internal.macros;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
@@ -21,6 +23,7 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
/**
* This class is used by the MacroResolver to collect and present
@@ -28,19 +31,19 @@ import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
*
* @since 3.0
*/
-public class ExplicitFileMacroCollector extends DefaultMacroSubstitutor {
+public class ExplicitFileMacroCollector extends SupplierBasedCdtVariableSubstitutor {
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private List fMacrosList = new ArrayList();
- public ExplicitFileMacroCollector(int contextType, Object contextData){
+/* public ExplicitFileMacroCollector(int contextType, Object contextData){
super(contextType, contextData, EMPTY_STRING, EMPTY_STRING);
}
-
+*/
public ExplicitFileMacroCollector(IMacroContextInfo contextInfo){
super(contextInfo, EMPTY_STRING, EMPTY_STRING);
}
-
+/*
public ExplicitFileMacroCollector(ITool tool){
super(null, EMPTY_STRING, EMPTY_STRING);
IBuildObject bo = tool.getParent();
@@ -54,11 +57,10 @@ public class ExplicitFileMacroCollector extends DefaultMacroSubstitutor {
}catch (BuildMacroException e){
}
}
-
+*/
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor#resolveMacro(org.eclipse.cdt.managedbuilder.macros.IBuildMacro)
*/
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
+ protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException{
if(macro instanceof MbsMacroSupplier.FileContextMacro){
MbsMacroSupplier.FileContextMacro fileMacro = (MbsMacroSupplier.FileContextMacro)macro;
if(fileMacro.isExplicit())
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfo.java
index c9b371e4c63..0f4f344afaf 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,14 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.macros;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
/**
* This interface represents the context information.
*
* @since 3.0
*/
-public interface IMacroContextInfo {
+public interface IMacroContextInfo extends IVariableContextInfo{
/**
* returns the context type
*
@@ -31,18 +31,4 @@ public interface IMacroContextInfo {
* @return Object
*/
public Object getContextData();
-
- /**
- * Returns suppliers to be used for this context
- *
- * @return IBuildMacroSupplier[]
- */
- public IBuildMacroSupplier[] getSuppliers();
-
- /**
- * Returns context info for the next lower-precedence context
- *
- * @return IMacroContextInfo
- */
- public IMacroContextInfo getNext();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfoProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfoProvider.java
new file mode 100644
index 00000000000..8e8ac13d5e0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroContextInfoProvider.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.macros;
+
+
+public interface IMacroContextInfoProvider {
+ IMacroContextInfo getMacroContextInfo(int type, Object context);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java
index aebbaadc103..4a4eca5831b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -11,13 +11,13 @@
package org.eclipse.cdt.managedbuilder.internal.macros;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
@@ -28,14 +28,12 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
import org.eclipse.cdt.managedbuilder.macros.IFileContextBuildMacroValues;
import org.eclipse.cdt.managedbuilder.macros.IFileContextData;
import org.eclipse.cdt.managedbuilder.macros.IOptionContextData;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.utils.Platform;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -47,7 +45,7 @@ import org.osgi.framework.Bundle;
*
* @since 3.0
*/
-public class MbsMacroSupplier implements IBuildMacroSupplier {
+public class MbsMacroSupplier extends BuildCdtVariablesSupplierBase {
private static MbsMacroSupplier fInstance;
public final static String DOT = "."; //$NON-NLS-1$
public final static String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -76,8 +74,8 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
};
private static final String fConfigurationMacros[] = new String[]{
- "ConfigName", //$NON-NLS-1$
- "ConfigDescription", //$NON-NLS-1$
+// "ConfigName", //$NON-NLS-1$
+// "ConfigDescription", //$NON-NLS-1$
"BuildArtifactFileName", //$NON-NLS-1$
"BuildArtifactFileExt", //$NON-NLS-1$
"BuildArtifactFileBaseName", //$NON-NLS-1$
@@ -89,24 +87,24 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
};
private static final String fProjectMacros[] = new String[]{
- "ProjName", //$NON-NLS-1$
- "ProjDirPath", //$NON-NLS-1$
+// "ProjName", //$NON-NLS-1$
+// "ProjDirPath", //$NON-NLS-1$
};
private static final String fWorkspaceMacros[] = new String[]{
- "WorkspaceDirPath", //$NON-NLS-1$
- "DirectoryDelimiter", //$NON-NLS-1$
- "PathDelimiter", //$NON-NLS-1$
+// "WorkspaceDirPath", //$NON-NLS-1$
+// "DirectoryDelimiter", //$NON-NLS-1$
+// "PathDelimiter", //$NON-NLS-1$
};
private static final String fCDTEclipseMacros[] = new String[]{
- "EclipseVersion", //$NON-NLS-1$
- "CDTVersion", //$NON-NLS-1$
+// "EclipseVersion", //$NON-NLS-1$
+// "CDTVersion", //$NON-NLS-1$
"MBSVersion", //$NON-NLS-1$
- "HostOsName", //$NON-NLS-1$
- "HostArchName", //$NON-NLS-1$
- "OsType", //$NON-NLS-1$
- "ArchType", //$NON-NLS-1$
+// "HostOsName", //$NON-NLS-1$
+// "HostArchName", //$NON-NLS-1$
+// "OsType", //$NON-NLS-1$
+// "ArchType", //$NON-NLS-1$
};
private class OptionData extends OptionContextData {
@@ -128,6 +126,8 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
public class FileContextMacro extends BuildMacro{
private IFileContextData fContextData;
private IConfiguration fConfiguration;
+ //TODO: initialize builder
+ private IBuilder fBuilder;
private boolean fIsExplicit = true;
private boolean fIsInitialized;
private String fExplicitValue;
@@ -175,7 +175,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
if(fStringValue == null){
fIsExplicit = true;
- fStringValue = getExplicitFileMacroValue(fName, fContextData.getInputFileLocation(), fContextData.getOutputFileLocation(), fConfiguration);
+ fStringValue = getExplicitFileMacroValue(fName, fContextData.getInputFileLocation(), fContextData.getOutputFileLocation(), fBuilder, fConfiguration);
fExplicitValue = fStringValue;
fIsExplicitResolved = true;
}
@@ -186,7 +186,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
public String getExplicitMacroValue(){
loadValue();
if(!fIsExplicitResolved){
- fExplicitValue = getExplicitFileMacroValue(fName, fContextData.getInputFileLocation(), fContextData.getOutputFileLocation(), fConfiguration);
+ fExplicitValue = getExplicitFileMacroValue(fName, fContextData.getInputFileLocation(), fContextData.getOutputFileLocation(), fBuilder, fConfiguration);
fIsExplicitResolved = true;
}
return fExplicitValue;
@@ -206,7 +206,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
}
}
- private String getExplicitFileMacroValue(String name, IPath inputFileLocation, IPath outputFileLocation, IConfiguration cfg){
+ private String getExplicitFileMacroValue(String name, IPath inputFileLocation, IPath outputFileLocation, IBuilder builder, IConfiguration cfg){
String value = null;
if("InputFileName".equals(name)){ //$NON-NLS-1$
if(inputFileLocation != null && inputFileLocation.segmentCount() > 0)
@@ -219,7 +219,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
value = getBaseName(inputFileLocation.lastSegment());
}else if("InputFileRelPath".equals(name)){ //$NON-NLS-1$
if(inputFileLocation != null && inputFileLocation.segmentCount() > 0){
- IPath workingDirectory = getBuilderCWD(cfg);
+ IPath workingDirectory = getBuilderCWD(builder, cfg);
if(workingDirectory != null){
IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, inputFileLocation);
if(filePath != null)
@@ -229,7 +229,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
}
else if("InputDirRelPath".equals(name)){ //$NON-NLS-1$
if(inputFileLocation != null && inputFileLocation.segmentCount() > 0){
- IPath workingDirectory = getBuilderCWD(cfg);
+ IPath workingDirectory = getBuilderCWD(builder, cfg);
if(workingDirectory != null){
IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, inputFileLocation.removeLastSegments(1).addTrailingSeparator());
if(filePath != null)
@@ -248,7 +248,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
value = getBaseName(outputFileLocation.lastSegment());
}else if("OutputFileRelPath".equals(name)){ //$NON-NLS-1$
if(outputFileLocation != null && outputFileLocation.segmentCount() > 0){
- IPath workingDirectory = getBuilderCWD(cfg);
+ IPath workingDirectory = getBuilderCWD(builder, cfg);
if(workingDirectory != null){
IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, outputFileLocation);
if(filePath != null)
@@ -257,7 +257,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
}
}else if("OutputDirRelPath".equals(name)){ //$NON-NLS-1$
if(outputFileLocation != null && outputFileLocation.segmentCount() > 0){
- IPath workingDirectory = getBuilderCWD(cfg);
+ IPath workingDirectory = getBuilderCWD(builder, cfg);
if(workingDirectory != null){
IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, outputFileLocation.removeLastSegments(1).addTrailingSeparator());
if(filePath != null)
@@ -343,9 +343,18 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
}
break;
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
+ IConfiguration cfg = null;
+ IBuilder builder = null;
if(contextData instanceof IConfiguration){
- macro = getMacro(macroName, (IConfiguration)contextData);
+ cfg = (IConfiguration)contextData;
+ builder = cfg.getBuilder();
+ } else if (contextData instanceof IBuilder){
+ builder = (IBuilder)contextData;
+ cfg = builder.getParent().getParent();
}
+ if(cfg != null)
+ macro = getMacro(macroName, builder, cfg);
+
break;
case IBuildMacroProvider.CONTEXT_PROJECT:
if(contextData instanceof IManagedProject){
@@ -391,7 +400,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
return macro;
}
- public IBuildMacro getMacro(String macroName, IConfiguration cfg){
+ public IBuildMacro getMacro(String macroName, IBuilder builder, IConfiguration cfg){
IBuildMacro macro = null;
if("ConfigName".equals(macroName)){ //$NON-NLS-1$
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,cfg.getName());
@@ -677,28 +686,11 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
return null;
}
- private IPath getBuilderCWD(IConfiguration cfg){
- IPath workingDirectory = null;
- IResource owner = cfg.getOwner();
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(owner);
-
- if(info != null){
- if(info.getDefaultConfiguration().equals(cfg)){
- IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
- generator.initialize((IProject)owner,info,null);
-
- IPath topBuildDir = generator.getBuildWorkingDir();
- if(topBuildDir == null)
- topBuildDir = new Path(info.getConfigurationName());
-
- IPath projectLocation = owner.getLocation();
- workingDirectory = projectLocation.append(topBuildDir);
- }
- }
- return workingDirectory;
+ private IPath getBuilderCWD(IBuilder builder, IConfiguration cfg){
+ return ManagedBuildManager.getBuildLocation(cfg, builder);
}
- private IPath getOutputFilePath(IPath inputPath, IConfiguration cfg){
+ private IPath getOutputFilePath(IPath inputPath, IBuilder builder, IConfiguration cfg){
ITool buildTools[] = null;
IResourceConfiguration rcCfg = cfg.getResourceConfiguration(inputPath.toString());
if(rcCfg != null) {
@@ -726,7 +718,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
path = namePath;
}
else{
- IPath cwd = getBuilderCWD(cfg);
+ IPath cwd = getBuilderCWD(builder, cfg);
if(cwd != null)
path = cwd.append(namePath);
}
@@ -757,16 +749,16 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
return null;
}
- private class IncludeDefaultsSubstitutor implements IMacroSubstitutor {
+ private class IncludeDefaultsSubstitutor implements IVariableSubstitutor {
private IOptionContextData fOptionContextData;
public IncludeDefaultsSubstitutor(IOptionContextData data){
fOptionContextData = data;
}
- public String resolveToString(String macroName) throws BuildMacroException {
+ public String resolveToString(String macroName) throws CdtVariableException {
if(!"IncludeDefaults".equals(macroName)) //$NON-NLS-1$
- return MacroResolver.createMacroReference(macroName);
+ return CdtVariableResolver.createVariableReference(macroName);
IOptionContextData parent = getParent(fOptionContextData);
if(parent == null)
return EMPTY_STRING;
@@ -775,46 +767,46 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
String str = null;
String strL[] = null;
try{
- switch(option.getValueType()){
+ switch(option.getBasicValueType()){
case IOption.STRING :
str = option.getStringValue();
break;
case IOption.STRING_LIST :
- strL = option.getStringListValue();
- break;
- case IOption.INCLUDE_PATH :
- strL = option.getIncludePaths();
- break;
- case IOption.PREPROCESSOR_SYMBOLS :
- strL = option.getDefinedSymbols();
- break;
- case IOption.LIBRARIES :
- strL = option.getLibraries();
- break;
- case IOption.OBJECTS :
- strL = option.getUserObjects();
+ strL = option.getBasicStringListValue();
break;
+// case IOption.INCLUDE_PATH :
+// strL = option.getIncludePaths();
+// break;
+// case IOption.PREPROCESSOR_SYMBOLS :
+// strL = option.getDefinedSymbols();
+// break;
+// case IOption.LIBRARIES :
+// strL = option.getLibraries();
+// break;
+// case IOption.OBJECTS :
+// strL = option.getUserObjects();
+// break;
default :
break;
}
if(str != null)
- return MacroResolver.resolveToString(str,sub);
+ return CdtVariableResolver.resolveToString(str,sub);
else if(strL != null){
- strL = MacroResolver.resolveStringListValues(strL,sub,true);
- return MacroResolver.convertStringListToString(strL," "); //$NON-NLS-1$
+ strL = CdtVariableResolver.resolveStringListValues(strL,sub,true);
+ return CdtVariableResolver.convertStringListToString(strL," "); //$NON-NLS-1$
}
} catch (BuildException e){
- } catch (BuildMacroException e){
+ } catch (CdtVariableException e){
}
return null;
}
- public String[] resolveToStringList(String macroName) throws BuildMacroException {
+ public String[] resolveToStringList(String macroName) throws CdtVariableException {
if(!"IncludeDefaults".equals(macroName)) //$NON-NLS-1$
- return new String[]{MacroResolver.createMacroReference(macroName)};
+ return new String[]{CdtVariableResolver.createVariableReference(macroName)};
IOptionContextData parent = getParent(fOptionContextData);
if(parent == null)
@@ -824,36 +816,36 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
String str = null;
String strL[] = null;
try{
- switch(option.getValueType()){
+ switch(option.getBasicValueType()){
case IOption.STRING :
str = option.getStringValue();
break;
case IOption.STRING_LIST :
- strL = option.getStringListValue();
- break;
- case IOption.INCLUDE_PATH :
- strL = option.getIncludePaths();
- break;
- case IOption.PREPROCESSOR_SYMBOLS :
- strL = option.getDefinedSymbols();
- break;
- case IOption.LIBRARIES :
- strL = option.getLibraries();
- break;
- case IOption.OBJECTS :
- strL = option.getUserObjects();
+ strL = option.getBasicStringListValue();
break;
+// case IOption.INCLUDE_PATH :
+// strL = option.getIncludePaths();
+// break;
+// case IOption.PREPROCESSOR_SYMBOLS :
+// strL = option.getDefinedSymbols();
+// break;
+// case IOption.LIBRARIES :
+// strL = option.getLibraries();
+// break;
+// case IOption.OBJECTS :
+// strL = option.getUserObjects();
+// break;
default :
break;
}
if(str != null)
- return MacroResolver.resolveToStringList(str,sub);
+ return CdtVariableResolver.resolveToStringList(str,sub);
else if(strL != null)
- return MacroResolver.resolveStringListValues(strL,sub,true);
+ return CdtVariableResolver.resolveStringListValues(strL,sub,true);
} catch (BuildException e){
- } catch (BuildMacroException e){
+ } catch (CdtVariableException e){
}
return null;
@@ -907,18 +899,34 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
fStringListValue = option.getDefinedSymbols();
break;
case IOption.LIBRARIES:
- fType = IBuildMacro.VALUE_PATH_FILE_LIST;
+ fType = IBuildMacro.VALUE_TEXT_LIST;
fStringListValue = option.getLibraries();
break;
case IOption.OBJECTS:
fType = IBuildMacro.VALUE_PATH_FILE_LIST;
fStringListValue = option.getUserObjects();
break;
+ case IOption.INCLUDE_FILES:
+ fType = IBuildMacro.VALUE_PATH_FILE_LIST;
+ fStringListValue = option.getBasicStringListValue();
+ break;
+ case IOption.LIBRARY_PATHS:
+ fType = IBuildMacro.VALUE_PATH_DIR_LIST;
+ fStringListValue = option.getBasicStringListValue();
+ break;
+ case IOption.LIBRARY_FILES:
+ fType = IBuildMacro.VALUE_PATH_FILE_LIST;
+ fStringListValue = option.getBasicStringListValue();
+ break;
+ case IOption.MACRO_FILES:
+ fType = IBuildMacro.VALUE_PATH_FILE_LIST;
+ fStringListValue = option.getBasicStringListValue();
+ break;
}
if(fStringValue != null)
- fStringValue = MacroResolver.resolveToString(fStringValue,new IncludeDefaultsSubstitutor(fParentOptionContextData));
+ fStringValue = CdtVariableResolver.resolveToString(fStringValue,new IncludeDefaultsSubstitutor(fParentOptionContextData));
else if(fStringListValue != null)
- fStringListValue = MacroResolver.resolveStringListValues(fStringListValue,new IncludeDefaultsSubstitutor(fParentOptionContextData), true);
+ fStringListValue = CdtVariableResolver.resolveStringListValues(fStringListValue,new IncludeDefaultsSubstitutor(fParentOptionContextData), true);
}catch(Exception e){
fType = 0;
}
@@ -983,7 +991,7 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
boolean can = false;
try{
- switch (option.getValueType()) {
+ switch (option.getBasicValueType()) {
case IOption.BOOLEAN:
break;
case IOption.STRING:
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java
index 7ea8419f859..67f16a5bdea 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGCCScannerInfoCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -10,17 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.scannerconfig;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
/**
* Implementation class for gathering the built-in compiler settings for
@@ -30,118 +22,5 @@ import org.eclipse.core.resources.IResource;
*
* @since 2.0
*/
-public class DefaultGCCScannerInfoCollector implements IManagedScannerInfoCollector {
- protected Map definedSymbols;
- protected static final String EQUALS = "="; //$NON-NLS-1$
- protected List includePaths;
- protected IProject project;
-
- /**
- *
- */
- public DefaultGCCScannerInfoCollector() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
- */
- public void contributeToScannerConfig(Object resource, Map scannerInfo) {
- // check the resource
- if (resource != null && resource instanceof IResource &&
- ((IResource) resource).getProject() == project ) {
- List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
- List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
-
- // This method will be called by the parser each time there is a new value
- Iterator pathIter = includes.listIterator();
- while (pathIter.hasNext()) {
- String path = (String) pathIter.next();
- getIncludePaths().add(path);
- }
-
- // Now add the macros
- Iterator symbolIter = symbols.listIterator();
- while (symbolIter.hasNext()) {
- // See if it has an equals
- String[] macroTokens = ((String)symbolIter.next()).split(EQUALS);
- String macro = macroTokens[0].trim();
- String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String();
- getDefinedSymbols().put(macro, value);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols()
- */
- public Map getDefinedSymbols() {
- if (definedSymbols == null) {
- definedSymbols = new HashMap();
- }
- return definedSymbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector#getIncludePaths()
- */
- public List getIncludePaths() {
- if (includePaths == null) {
- includePaths = new ArrayList();
- }
- return includePaths;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector#setProject(org.eclipse.core.resources.IProject)
- */
- public void setProject(IProject project) {
- this.project = project;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
- */
- public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
- List rv = null;
- String errorMessage = null;
- if (resource == null) {
- errorMessage = "resource is null";//$NON-NLS-1$
- }
- else if (!(resource instanceof IResource)) {
- errorMessage = "resource is not an IResource";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() == null) {
- errorMessage = "project is null";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() != project) {
- errorMessage = "wrong project";//$NON-NLS-1$
- }
-
- if (errorMessage != null) {
- TraceUtil.outputError("DefaultGCCScannerInfoCollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
- }
- else if (type.equals(ScannerInfoTypes.INCLUDE_PATHS)) {
- rv = getIncludePaths();
- }
- else if (type.equals(ScannerInfoTypes.SYMBOL_DEFINITIONS)) {
- rv = new ArrayList();
- Map symbols = getDefinedSymbols();
- for (Iterator i = symbols.keySet().iterator(); i.hasNext(); ) {
- String macro = (String) i.next();
- String value = (String) symbols.get(macro);
- if (value.length() > 0) {
- rv.add(macro + EQUALS + value);
- }
- else {
- rv.add(macro);
- }
- }
- }
- else {
- rv = new ArrayList();
- }
- return rv;
- }
-
+public class DefaultGCCScannerInfoCollector extends PerProjectSICollector implements IScannerInfoCollector3, IManagedScannerInfoCollector {
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java
index 7219f50f13e..b6bb3df6e6c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -16,7 +16,6 @@ import java.util.Map;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
-import org.eclipse.core.resources.IResource;
/**
* Implementation class for gathering the built-in compiler settings for
@@ -31,34 +30,37 @@ public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoColl
*/
public void contributeToScannerConfig(Object resource, Map scannerInfo) {
// check the resource
- if (resource != null && resource instanceof IResource &&
- ((IResource) resource).getProject() == project ) {
+// if (resource != null && resource instanceof IResource &&
+// ((IResource) resource).getProject().equals(getProject())) {
List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
- List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
+// List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
// This method will be called by the parser each time there is a new value
- List translatedIncludes = CygpathTranslator.translateIncludePaths(project, includes);
+ List translatedIncludes = CygpathTranslator.translateIncludePaths(getProject(), includes);
Iterator pathIter = translatedIncludes.listIterator();
while (pathIter.hasNext()) {
String convertedPath = (String) pathIter.next();
// On MinGW, there is no facility for converting paths
- if (convertedPath.startsWith("/")) continue; //$NON-NLS-1$
- // Add it if it is not a duplicate
- if (!getIncludePaths().contains(convertedPath)){
- getIncludePaths().add(convertedPath);
- }
+ if (convertedPath.startsWith("/")) //$NON-NLS-1$
+ pathIter.remove();
+// // Add it if it is not a duplicate
+// if (!getIncludePaths().contains(convertedPath)){
+// getIncludePaths().add(convertedPath);
+// }
}
+ scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludes);
- // Now add the macros
- Iterator symbolIter = symbols.listIterator();
- while (symbolIter.hasNext()) {
- // See if it has an equals
- String[] macroTokens = ((String)symbolIter.next()).split(EQUALS);
- String macro = macroTokens[0].trim();
- String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String();
- getDefinedSymbols().put(macro, value);
- }
+// // Now add the macros
+// Iterator symbolIter = symbols.listIterator();
+// while (symbolIter.hasNext()) {
+// // See if it has an equals
+// String[] macroTokens = ((String)symbolIter.next()).split(EQUALS);
+// String macro = macroTokens[0].trim();
+// String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String();
+// getDefinedSymbols().put(macro, value);
+// }
+ super.contributeToScannerConfig(resource, scannerInfo);
}
- }
+// }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
index 8c52bbbfc74..638b43084a9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
@@ -21,10 +21,11 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -135,7 +136,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
// TODO Get the provider from the toolchain specification
final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2(MakeCorePlugin.getDefault().getPluginPreferences(),
+ createScannerConfigBuildInfo2(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(),
profileInstance.getProfile().getId(), false);
List providerIds = buildInfo.getProviderIdList();
for (Iterator i = providerIds.iterator(); i.hasNext(); ) {
@@ -154,7 +155,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
if (vars != null)
for (int i = 0; i < vars.length; ++i)
env.put(vars[i].getName(), vars[i].getValue());
- esiProvider.invokeProvider(monitor, project, providerId, buildInfo, collector, env);
+ esiProvider.invokeProvider(monitor, project, providerId, buildInfo, collector/*, env*/);
}
public void handleException(Throwable exception) {
@@ -188,8 +189,10 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
SCProfileInstance profileInstance = null;
if (scdProfileId != null) {
// See if we can load a dynamic resolver
+ //FIXME:
+ InfoContext context = ScannerConfigUtil.createContextForProject(project);
profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, scdProfileId);
+ getSCProfileInstance(project, context, scdProfileId);
collector = profileInstance.createScannerInfoCollector();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/BuildMacroException.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/BuildMacroException.java
index 12171c02ee1..2e5c41d291c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/BuildMacroException.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/BuildMacroException.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.macros;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroStatus;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.core.runtime.IStatus;
/**
@@ -20,7 +19,7 @@ import org.eclipse.core.runtime.IStatus;
*
* @since 3.0
*/
-public class BuildMacroException extends CoreException {
+public class BuildMacroException extends CdtVariableException {
/**
* All serializable objects should have a stable serialVersionUID
*/
@@ -51,16 +50,16 @@ public class BuildMacroException extends CoreException {
* @param contextType the context type used in the operation
* @param contextData the context data used in the operation
*/
- public BuildMacroException(int code,
- String message,
- Throwable exception,
- String macroName,
- String expression,
- String referencedName,
- int contextType,
- Object contextData) {
- super(new BuildMacroStatus(code, message, exception, macroName, expression, referencedName, contextType, contextData));
- }
+// public BuildMacroException(int code,
+// String message,
+// Throwable exception,
+// String macroName,
+// String expression,
+// String referencedName,
+// int contextType,
+// Object contextData) {
+// super(new BuildMacroStatus(code, message, exception, macroName, expression, referencedName, contextType, contextData));
+// }
/**
* Creates an exception containing a single IBuildMacroStatus status with the IStatus.ERROR severity and with the default message
@@ -74,13 +73,17 @@ public class BuildMacroException extends CoreException {
* @param contextType the context type used in the operation
* @param contextData the context data used in the operation
*/
- public BuildMacroException(int code,
- String macroName,
- String expression,
- String referencedName,
- int contextType,
- Object contextData) {
- super(new BuildMacroStatus(code, macroName, expression, referencedName, contextType, contextData));
+// public BuildMacroException(int code,
+// String macroName,
+// String expression,
+// String referencedName,
+// int contextType,
+// Object contextData) {
+// super(new BuildMacroStatus(code, macroName, expression, referencedName, contextType, contextData));
+// }
+
+ public BuildMacroException(CdtVariableException e){
+ super(e.getStatus());
}
/**
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacro.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacro.java
index aebe5ef31a9..a23beae0f2f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacro.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacro.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,70 +10,26 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.macros;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+
+
/**
* this interface represents the given build macro
* @since 3.0
*/
-public interface IBuildMacro{
- /**
- * can hold any text string
- */
- public static final int VALUE_TEXT = 1;
-
- /**
- * can hold the array of text string values
- */
- public static final int VALUE_TEXT_LIST = 2;
-
- /**
- * can hold file path
- */
- public static final int VALUE_PATH_FILE = 3;
-
- /**
- * can hold the array of file path values
- */
- public static final int VALUE_PATH_FILE_LIST = 4;
-
- /**
- * can hold dir path
- */
- public static final int VALUE_PATH_DIR = 5;
-
- /**
- * can hold the array of dir path values
- */
- public static final int VALUE_PATH_DIR_LIST = 6;
+public interface IBuildMacro extends ICdtVariable{
+ int getMacroValueType();
- /**
- * can hold both file and dir path
- */
- public static final int VALUE_PATH_ANY = 7;
-
- /**
- * can hold the array of PATH_ANY values
- */
- public static final int VALUE_PATH_ANY_LIST = 8;
-
- /**
- * Returns the macro name
- * @return
- */
- String getName();
-
- /**
- * @return IBuildMacro.VALUE_xxx
- */
- int getMacroValueType();
-
/**
- * @throws BuildMacroException if macro holds StringList-type value
+ * @throws CdtVariableException if macro holds StringList-type value
*/
String getStringValue() throws BuildMacroException;
/**
- * @throws BuildMacroException if macro holds single String-type value
+ * @throws CdtVariableException if macro holds single String-type value
*/
String[] getStringListValue() throws BuildMacroException;
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java
index 137b046c4e8..d60c9f0fd68 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.macros;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+
/**
*
* @since 3.0
@@ -66,6 +68,19 @@ public interface IBuildMacroProvider{
boolean includeParentContexts);
+ public ICdtVariable getVariable(String macroName,
+ int contextType,
+ Object contextData,
+ boolean includeParentContexts);
+
+ /**
+ *
+ * @return the array of the IBuildMacro representing all available macros
+ */
+ public ICdtVariable[] getVariables(int contextType,
+ Object contextData,
+ boolean includeParentContexts);
+
/**
* This method is defined to be used primarily by the UI classes and should not be used by the
* tool-integrator
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroStatus.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroStatus.java
index 03a14d8ce03..465e3f55aa8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroStatus.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroStatus.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,66 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.macros;
-import org.eclipse.core.runtime.IStatus;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus;
/**
* This interface represents the status of a build macro operation
*
* @since 3.0
*/
-public interface IBuildMacroStatus extends IStatus {
- /**
- * This type is used to present that the inexistent macro reference
- * is encountered while resolving macros in some expression
- */
- public static final int TYPE_MACRO_UNDEFINED = 1;
-
- /**
- * This type is used to present that two macros reference each other
- */
- public static final int TYPE_MACROS_REFERENCE_EACHOTHER = 2;
-
- /**
- * This type is used to present that the incorrect macro reference
- * is encountered while resolving macros in some expression
- */
- public static final int TYPE_MACRO_REFERENCE_INCORRECT = 3;
-
- /**
- * The status of this type is created by the Build Macro of the String-List type
- * when the String value is requested
- */
- public static final int TYPE_MACRO_NOT_STRING = 4;
-
- /**
- * The status of this type is created by the Build Macro of the String type
- * when the String-List value is requested
- */
- public static final int TYPE_MACRO_NOT_STRINGLIST = 5;
-
- /**
- * This type is used to present that some error other than the one represented
- * by other TYPE_xxx has occured
- */
- public static final int TYPE_ERROR = -1;
-
- /**
- * returns the name of the build macro whose resolution caused this status creation or null if none
- * @return IBuildMacro
- */
- public String getMacroName();
-
- /**
- * returns the string whose resolutinon caused caused this status creation or null if none
- * @return String
- */
- public String getExpression();
-
- /**
- * returns the macro name referenced in the resolution string that caused this this status creation or null if none
- * @return String
- */
- public String getReferencedMacroName();
+public interface IBuildMacroStatus extends ICdtVariableStatus {
/**
* returns the context type used in the operation
@@ -83,4 +31,6 @@ public interface IBuildMacroStatus extends IStatus {
*/
public Object getContextData();
+ public String getMacroName();
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroSupplier.java
index bf13f979200..4629f5a4db0 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -10,11 +10,15 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.macros;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+
/**
*
* @since 3.0
*/
-public interface IBuildMacroSupplier {
+public interface IBuildMacroSupplier extends ICdtVariableSupplier{
/**
*
@@ -35,4 +39,10 @@ public interface IBuildMacroSupplier {
*/
public IBuildMacro[] getMacros(int contextType,
Object contextData);
+
+
+ public ICdtVariable getVariable(String macroName,
+ IMacroContextInfo context);
+
+ public ICdtVariable[] getVariables(IMacroContextInfo context);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator2.java
new file mode 100644
index 00000000000..2649faee889
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator2.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.makegen;
+
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface IManagedBuilderMakefileGenerator2 extends
+ IManagedBuilderMakefileGenerator {
+
+ public void initialize(int buildKind, IConfiguration cfg, IBuilder builder, IProgressMonitor monitor);
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
index 8fa330cf536..769ce0a8722 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
@@ -213,7 +214,8 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
} else {
ITool tool = null;
- tools = config.getFilteredTools();
+ IFolderInfo foInfo = (IFolderInfo)config.getResourceInfo(resource.getProjectRelativePath(), false);
+ tools = foInfo.getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tmp = tools[index];
if (tmp.buildsFileType(inputExtension)) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java
index a748ba0dc55..b7e66a2b27b 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -14,15 +14,16 @@ package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
/**
* This dependency calculator uses the GCC -MMD -MF -MP -MT options in order to
@@ -76,9 +77,9 @@ public class DefaultGCCDependencyCalculator2Commands implements
if (buildContext instanceof IConfiguration) {
IConfiguration config = (IConfiguration)buildContext;
project = (IProject)config.getOwner();
- } else if (buildContext instanceof IResourceConfiguration) {
- IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
- project = (IProject)resConfig.getOwner();
+ } else if (buildContext instanceof IResourceInfo) {
+ IResourceInfo rcInfo = (IResourceInfo)buildContext;
+ project = rcInfo.getParent().getOwner().getProject();
}
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
@@ -104,8 +105,8 @@ public class DefaultGCCDependencyCalculator2Commands implements
}
needExplicitRuleForFile = resourceNameRequiresExplicitRule ||
- MacroResolver.getReferencedExplitFileMacros(tool).length > 0
- || MacroResolver.getReferencedExplitFileMacros(
+ BuildMacroProvider.getReferencedExplitFileMacros(tool).length > 0
+ || BuildMacroProvider.getReferencedExplitFileMacros(
tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation,
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3.java
index b4efe9e26c3..38c36cda6ee 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -16,6 +16,7 @@ import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
@@ -96,6 +97,9 @@ public class DefaultGCCDependencyCalculator3 implements
makefilePath = makefilePath.removeFirstSegments(rootPath.segmentCount());
}
makefile = root.getFile(makefilePath);
+ IResourceInfo rcInfo = tool.getParentResourceInfo();
+ if(rcInfo != null)
+ return GnuMakefileGenerator.populateDummyTargets(rcInfo, makefile, false);
return GnuMakefileGenerator.populateDummyTargets(buildContext, makefile, false);
} catch (CoreException e) {
} catch (IOException e) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3Commands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3Commands.java
index 22f730bd532..1526b00b6f1 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3Commands.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3Commands.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -19,15 +19,15 @@ import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
/**
* This dependency calculator uses the same dependency management technique as the
@@ -118,8 +118,8 @@ public class DefaultGCCDependencyCalculator3Commands implements
}
needExplicitRuleForFile = resourceNameRequiresExplicitRule ||
- MacroResolver.getReferencedExplitFileMacros(tool).length > 0
- || MacroResolver.getReferencedExplitFileMacros(
+ BuildMacroProvider.getReferencedExplitFileMacros(tool).length > 0
+ || BuildMacroProvider.getReferencedExplitFileMacros(
tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation,
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java
index 07ea96f7bad..3e36a81e1d9 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
+import java.util.Vector;
+
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -19,16 +21,15 @@ import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import java.util.Vector;
+import org.eclipse.core.runtime.IPath;
/**
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to
@@ -110,8 +111,8 @@ public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedD
}
needExplicitRuleForFile = resourceNameRequiresExplicitRule ||
- MacroResolver.getReferencedExplitFileMacros(tool).length > 0
- || MacroResolver.getReferencedExplitFileMacros(
+ BuildMacroProvider.getReferencedExplitFileMacros(tool).length > 0
+ || BuildMacroProvider.getReferencedExplitFileMacros(
tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation,
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
index 138785ecc3a..a2dd2f958d9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -22,21 +22,23 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap; // Note: We use LinkedHashMap instead of HashMap
- // only to keep the generation of makefiles constant
- // for our test set. Make itself doesn't care
- // about the order.
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
@@ -44,23 +46,24 @@ import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceInfo;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator2;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -90,7 +93,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
* @since 1.2
*/
-public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
+public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
/**
* This class walks the delta supplied by the build system to determine
@@ -108,14 +111,20 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
private GnuMakefileGenerator generator;
- private IManagedBuildInfo info;
+// private IManagedBuildInfo info;
+ private IConfiguration config;
/**
* The constructor
*/
public ResourceDeltaVisitor(GnuMakefileGenerator generator, IManagedBuildInfo info) {
this.generator = generator;
- this.info = info;
+ this.config = info.getDefaultConfiguration();
+ }
+
+ public ResourceDeltaVisitor(GnuMakefileGenerator generator, IConfiguration cfg) {
+ this.generator = generator;
+ this.config = cfg;
}
/* (non-Javadoc)
@@ -125,43 +134,51 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Should the visitor keep iterating in current directory
boolean keepLooking = false;
IResource resource = delta.getResource();
-
+ IResourceInfo rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false);
+ IFolderInfo fo = null;
+ boolean isSource = isSource(resource.getProjectRelativePath());
+ if(rcInfo instanceof IFolderInfo){
+ fo = (IFolderInfo)rcInfo;
+ }
// What kind of resource change has occurred
- if (resource.getType() == IResource.FILE) {
- String ext = resource.getFileExtension();
- switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- if (!generator.isGeneratedResource(resource)) {
- // This is a source file so just add its container
- if (info.buildsFileType(ext)) {
- generator.appendModifiedSubdirectory(resource);
+ if(!rcInfo.isExcluded() && isSource){
+ if (resource.getType() == IResource.FILE) {
+ String ext = resource.getFileExtension();
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ if (!generator.isGeneratedResource(resource)) {
+ // This is a source file so just add its container
+ if (fo == null || fo.buildsFileType(ext)) {
+ generator.appendModifiedSubdirectory(resource);
+ }
}
- }
- break;
- case IResourceDelta.REMOVED:
- // we get this notification if a resource is moved too
- if (!generator.isGeneratedResource(resource)) {
- // This is a source file so just add its container
- if (info.buildsFileType(ext)) {
- generator.appendDeletedFile(resource);
- generator.appendModifiedSubdirectory(resource);
+ break;
+ case IResourceDelta.REMOVED:
+ // we get this notification if a resource is moved too
+ if (!generator.isGeneratedResource(resource)) {
+ // This is a source file so just add its container
+ if (fo == null || fo.buildsFileType(ext)) {
+ generator.appendDeletedFile(resource);
+ generator.appendModifiedSubdirectory(resource);
+ }
}
- }
- break;
- default:
- keepLooking = true;
- break;
- }
- }
- if (resource.getType() == IResource.FOLDER) {
- // I only care about delete event
- switch (delta.getKind()) {
- case IResourceDelta.REMOVED:
- if (!generator.isGeneratedResource(resource)) {
- generator.appendDeletedSubdirectory((IContainer)resource);
- }
- default:
- break;
+ break;
+ default:
+ keepLooking = true;
+ break;
+ }
+ }
+
+ if (resource.getType() == IResource.FOLDER) {
+ // I only care about delete event
+ switch (delta.getKind()) {
+ case IResourceDelta.REMOVED:
+ if (!generator.isGeneratedResource(resource)) {
+ generator.appendDeletedSubdirectory((IContainer)resource);
+ }
+ default:
+ break;
+ }
}
}
if (resource.getType() == IResource.PROJECT) {
@@ -172,7 +189,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
} else {
// If the resource is part of the generated directory structure don't recurse
- if (!generator.isGeneratedResource(resource)) {
+ if (resource.getType() == IResource.ROOT ||
+ (isSource && !generator.isGeneratedResource(resource))) {
keepLooking = true;
}
}
@@ -189,7 +207,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/
protected class ResourceProxyVisitor implements IResourceProxyVisitor {
private GnuMakefileGenerator generator;
- private IManagedBuildInfo info;
+ private IConfiguration config;
+// private IManagedBuildInfo info;
/**
* Constructs a new resource proxy visitor to quickly visit project
@@ -197,7 +216,12 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/
public ResourceProxyVisitor(GnuMakefileGenerator generator, IManagedBuildInfo info) {
this.generator = generator;
- this.info = info;
+ this.config = info.getDefaultConfiguration();
+ }
+
+ public ResourceProxyVisitor(GnuMakefileGenerator generator, IConfiguration cfg) {
+ this.generator = generator;
+ this.config = cfg;
}
/* (non-Javadoc)
@@ -209,28 +233,42 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
return false;
}
+ IResource resource = proxy.requestResource();
+ boolean isSource = isSource(resource.getProjectRelativePath());
+
// Is this a resource we should even consider
if (proxy.getType() == IResource.FILE) {
// If this resource has a Resource Configuration and is not excluded or
// if it has a file extension that one of the tools builds, add the sudirectory to the list
- IResource resource = proxy.requestResource();
- boolean willBuild = false;
- IResourceConfiguration resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
- if (resConfig != null) willBuild = true;
- if (!willBuild) {
- String ext = resource.getFileExtension();
- if (info.buildsFileType(ext) &&
- // If this file resource is a generated resource, then it is uninteresting
- !generator.isGeneratedResource(resource)) {
+// boolean willBuild = false;
+ IResourceInfo rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false);
+ if (isSource && !rcInfo.isExcluded()) {
+ boolean willBuild = false;
+ if(rcInfo instanceof IFolderInfo){
+ String ext = resource.getFileExtension();
+ if (((IFolderInfo)rcInfo).buildsFileType(ext) &&
+ // If this file resource is a generated resource, then it is uninteresting
+ !generator.isGeneratedResource(resource)) {
+ willBuild = true;
+ }
+ } else {
willBuild = true;
}
- }
- if (willBuild) {
- if ((resConfig == null) || (!(resConfig.isExcluded()))) {
+
+ if(willBuild)
generator.appendBuildSubdirectory(resource);
- }
- }
+ }
+// if (willBuild) {
+// if ((resConfig == null) || (!(resConfig.isExcluded()))) {
+// generator.appendBuildSubdirectory(resource);
+// }
+// }
return false;
+ } else if (proxy.getType() == IResource.FOLDER){
+
+ if(!isSource || generator.isGeneratedResource(resource))
+ return false;
+ return true;
}
// Recurse into subdirectories
@@ -282,16 +320,28 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
PROJECT_SUBDIR_RELATIVE = 2,
ABSOLUTE = 3;
+ class ToolInfoHolder {
+ ITool[] buildTools;
+ boolean[] buildToolsUsed;
+ ManagedBuildGnuToolInfo[] gnuToolInfos;
+ Set outputExtensionsSet;
+ List dependencyMakefiles;
+ }
+
+
// Local variables needed by generator
private String buildTargetName;
private String buildTargetExt;
private IConfiguration config;
- private ITool[] buildTools;
- private boolean[] buildToolsUsed;
- private ManagedBuildGnuToolInfo[] gnuToolInfos;
+ private IBuilder builder;
+// private ITool[] buildTools;
+// private boolean[] buildToolsUsed;
+// private ManagedBuildGnuToolInfo[] gnuToolInfos;
+ private PathSettingsContainer toolInfos;
private Vector deletedFileList;
private Vector deletedDirList;
- private IManagedBuildInfo info;
+// private IManagedBuildInfo info;
+// private IConfiguration cfg
private Vector invalidDirList;
private Vector modifiedList;
private IProgressMonitor monitor;
@@ -302,7 +352,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
private Vector depRuleList; // String's of rules for generating dependency files
private Vector subdirList;
private IPath topBuildDir; // Build directory - relative to the workspace
- private Set outputExtensionsSet;
+// private Set outputExtensionsSet;
// Maps of macro names (String) to values (List)
private HashMap buildSrcVars = new HashMap(); // Map of source file build variable names
// to a List of source file Path's
@@ -312,7 +362,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// to a List of GnuDependencyGroupInfo objects
private LinkedHashMap topBuildOutVars = new LinkedHashMap();
// Dependency file variables
- private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute
+// private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute
+
+ private IPath srcPaths[];
public GnuMakefileGenerator() {
@@ -342,7 +394,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Save the monitor reference for reporting back to the user
this.monitor = monitor;
// Get the build info for the project
- this.info = info;
+// this.info = info;
// Get the name of the build target
buildTargetName = info.getBuildArtifactName();
// Get its extension
@@ -367,7 +419,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_CONFIGURATION,
info.getDefaultConfiguration());
- if((resolved = resolved.trim()).length() > 0)
+ if(resolved != null && (resolved = resolved.trim()).length() > 0)
buildTargetName = resolved;
} catch (BuildMacroException e){
}
@@ -378,11 +430,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
// Cache the build tools
config = info.getDefaultConfiguration();
- buildTools = config.getFilteredTools();
- buildToolsUsed = new boolean[buildTools.length];
- for (int i=0; i<buildTools.length; i++) buildToolsUsed[i] = false;
- // Initialize the tool info array
- gnuToolInfos = new ManagedBuildGnuToolInfo[buildTools.length];
+ builder = config.getEditableBuilder();
+ initToolInfos();
//set the top build dir path
topBuildDir = project.getFolder(info.getConfigurationName()).getFullPath();
}
@@ -390,12 +439,22 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
/**
* This method calls the dependency postprocessors defined for the tool chain
*/
- private void callDependencyPostProcessors(IFile depFile,
+ private void callDependencyPostProcessors(IResourceInfo rcInfo, ToolInfoHolder h, IFile depFile,
IManagedDependencyGenerator2[] postProcessors, // This array is the same size as the buildTools array and has
// an entry set when the corresponding tool has a dependency calculator
boolean callPopulateDummyTargets,
boolean force) throws CoreException {
try {
+// IPath path = depFile.getFullPath();
+// path = inFullPathFromOutFullPath(path);
+// IResourceInfo rcInfo = config.getResourceInfo(path, false);
+// IFolderInfo fo;
+// if(rcInfo instanceof IFileInfo){
+// fo = (IFolderInfo)config.getResourceInfo(path.removeLastSegments(1), false);
+// } else {
+// fo = (IFolderInfo)rcInfo;
+// }
+// ToolInfoHolder h = getToolInfo(fo.getPath());
updateMonitor(ManagedMakeMessages.getFormattedString("GnuMakefileGenerator.message.postproc.dep.file", depFile.getName())); //$NON-NLS-1$
if (postProcessors != null) {
IPath absolutePath = depFile.getLocation();
@@ -404,12 +463,12 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
for (int i=0; i<postProcessors.length; i++) {
IManagedDependencyGenerator2 depGen = postProcessors[i];
if (depGen != null) {
- depGen.postProcessDependencyFile(depPath, config, buildTools[i], getTopBuildDir());
+ depGen.postProcessDependencyFile(depPath, config, h.buildTools[i], getTopBuildDir());
}
}
}
if (callPopulateDummyTargets) {
- populateDummyTargets(config, depFile, force);
+ populateDummyTargets(rcInfo, depFile, force);
}
} catch (CoreException e) {
throw e;
@@ -421,12 +480,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* This method collects the dependency postprocessors and file extensions defined for the tool chain
*/
private boolean collectDependencyGeneratorInformation(
+ ToolInfoHolder h,
Vector depExts, // Vector of dependency file extensions
IManagedDependencyGenerator2[] postProcessors) {
boolean callPopulateDummyTargets = false;
- for (int i=0; i<buildTools.length; i++) {
- ITool tool = buildTools[i];
+ for (int i=0; i<h.buildTools.length; i++) {
+ ITool tool = h.buildTools[i];
IManagedDependencyGeneratorType depType = tool.getDependencyGeneratorForExtension(tool.getDefaultInputExtension());
if (depType != null) {
int calcType = depType.getCalculatorType();
@@ -451,26 +511,56 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
return callPopulateDummyTargets;
}
+
+ protected boolean isSource(IPath path){
+ path = path.makeRelative();
+ for(int i = 0; i < srcPaths.length; i++){
+ if(srcPaths[i].isPrefixOf(path))
+ return true;
+ }
+ return false;
+ }
+
+ private class DepInfo {
+ Vector depExts;
+ IManagedDependencyGenerator2[] postProcessors;
+ boolean callPopulateDummyTargets;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#generateDependencies()
*/
public void generateDependencies() throws CoreException {
+ final PathSettingsContainer postProcs = PathSettingsContainer.createRootContainer();
// Note: PopulateDummyTargets is a hack for the pre-3.x GCC compilers
// Collect the methods that will need to be called
- Vector depExts = new Vector(); // Vector of dependency file extensions
- IManagedDependencyGenerator2[] postProcessors = new IManagedDependencyGenerator2[buildTools.length];
- boolean callPopulateDummyTargets = collectDependencyGeneratorInformation(depExts, postProcessors);
-
- // Is there anyone to call if we do find dependency files?
- if (!callPopulateDummyTargets) {
- int i;
- for (i=0; i<postProcessors.length; i++) {
- if (postProcessors[i] != null) break;
+ toolInfos.accept(new IPathSettingsContainerVisitor(){
+ public boolean visit(PathSettingsContainer container){
+ ToolInfoHolder h = (ToolInfoHolder)container.getValue();
+ Vector depExts = new Vector(); // Vector of dependency file extensions
+ IManagedDependencyGenerator2[] postProcessors = new IManagedDependencyGenerator2[h.buildTools.length];
+ boolean callPopulateDummyTargets = collectDependencyGeneratorInformation(h, depExts, postProcessors);
+
+ // Is there anyone to call if we do find dependency files?
+ if (!callPopulateDummyTargets) {
+ int i;
+ for (i=0; i<postProcessors.length; i++) {
+ if (postProcessors[i] != null) break;
+ }
+ if (i == postProcessors.length) return true;
+ }
+
+ PathSettingsContainer child = postProcs.getChildContainer(container.getPath(), true, true);
+ DepInfo di = new DepInfo();
+ di.depExts = depExts;
+ di.postProcessors = postProcessors;
+ di.callPopulateDummyTargets = callPopulateDummyTargets;
+ child.setValue(di);
+
+ return true;
}
- if (i == postProcessors.length) return;
- }
+ });
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
Iterator subDirs = getSubdirList().listIterator();
@@ -478,6 +568,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// The builder creates a subdir with same name as source in the build location
IContainer subDir = (IContainer)subDirs.next();
IPath projectRelativePath = subDir.getProjectRelativePath();
+ IResourceInfo rcInfo = config.getResourceInfo(projectRelativePath, false);
+ PathSettingsContainer cr = postProcs.getChildContainer(rcInfo.getPath(), false, true);
+ if(cr == null || cr.getValue() == null)
+ continue;
+
+ DepInfo di = (DepInfo)cr.getValue();
+
+ ToolInfoHolder h = getToolInfo(projectRelativePath);
IPath buildRelativePath = topBuildDir.append(projectRelativePath);
IFolder buildFolder = root.getFolder(buildRelativePath);
if (buildFolder == null) continue;
@@ -487,13 +585,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
for (int index = 0; index < files.length; ++index){
IResource file = files[index];
String fileExt = file.getFileExtension();
- Iterator iter = depExts.iterator();
+ Iterator iter = di.depExts.iterator();
while (iter.hasNext()) {
String ext = (String)iter.next();
if (ext.equals(fileExt)) {
IFile depFile = root.getFile(file.getFullPath());
if (depFile == null) continue;
- callDependencyPostProcessors(depFile, postProcessors, callPopulateDummyTargets, false);
+ callDependencyPostProcessors(rcInfo, h, depFile, di.postProcessors, di.callPopulateDummyTargets, false);
}
}
}
@@ -510,7 +608,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* 1. This is an incremental build, so if the top-level directory is not
* there, then a rebuild is needed.
*/
- IFolder folder = project.getFolder(info.getConfigurationName());
+ IFolder folder = project.getFolder(config.getName());
if (!folder.exists()) {
return regenerateMakefiles();
}
@@ -520,13 +618,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Visit the resources in the delta and compile a list of subdirectories to regenerate
updateMonitor(ManagedMakeMessages.getFormattedString("MakefileGenerator.message.calc.delta", project.getName())); //$NON-NLS-1$
- ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(this, info);
+ ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(this, config);
delta.accept(visitor);
checkCancel();
// Get all the subdirectories participating in the build
updateMonitor(ManagedMakeMessages.getFormattedString("MakefileGenerator.message.finding.sources", project.getName())); //$NON-NLS-1$
- ResourceProxyVisitor resourceVisitor = new ResourceProxyVisitor(this, info);
+ ResourceProxyVisitor resourceVisitor = new ResourceProxyVisitor(this, config);
project.accept(resourceVisitor, IResource.NONE);
checkCancel();
@@ -549,7 +647,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
// Make sure the build directory is available
- topBuildDir = createDirectory(info.getConfigurationName());
+ topBuildDir = createDirectory(config.getName());
checkCancel();
// Make sure that there is a makefile containing all the folders participating
@@ -691,7 +789,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
public boolean isGeneratedResource(IResource resource) {
// Is this a generated directory ...
IPath path = resource.getProjectRelativePath();
- String[] configNames = info.getConfigurationNames();
+ //TODO: fix to use builder output dir instead
+ String[] configNames = ManagedBuildManager.getBuildInfo(project).getConfigurationNames();
for (int i = 0; i < configNames.length; i++) {
String name = configNames[i];
IPath root = new Path(name);
@@ -707,30 +806,46 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/
public void regenerateDependencies(boolean force) throws CoreException {
// A hack for the pre-3.x GCC compilers is to put dummy targets for deps
- IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
+ final IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
+ final CoreException[] es = new CoreException[1];
- // Collect the methods that will need to be called
- Vector depExts = new Vector(); // Vector of dependency file extensions
- IManagedDependencyGenerator2[] postProcessors = new IManagedDependencyGenerator2[buildTools.length];
- boolean callPopulateDummyTargets = collectDependencyGeneratorInformation(depExts, postProcessors);
-
- // Is there anyone to call if we do find dependency files?
- if (!callPopulateDummyTargets) {
- int i;
- for (i=0; i<postProcessors.length; i++) {
- if (postProcessors[i] != null) break;
- }
- if (i == postProcessors.length) return;
- }
+ toolInfos.accept(new IPathSettingsContainerVisitor(){
+ public boolean visit(PathSettingsContainer container){
+ ToolInfoHolder h = (ToolInfoHolder)container.getValue();
+ // Collect the methods that will need to be called
+ Vector depExts = new Vector(); // Vector of dependency file extensions
+ IManagedDependencyGenerator2[] postProcessors = new IManagedDependencyGenerator2[h.buildTools.length];
+ boolean callPopulateDummyTargets = collectDependencyGeneratorInformation(h, depExts, postProcessors);
+
+ // Is there anyone to call if we do find dependency files?
+ if (!callPopulateDummyTargets) {
+ int i;
+ for (i=0; i<postProcessors.length; i++) {
+ if (postProcessors[i] != null) break;
+ }
+ if (i == postProcessors.length) return true;
+ }
- Iterator iter = getDependencyMakefiles().listIterator();
- while (iter.hasNext()) {
- // The path to search for the dependency makefile
- IPath relDepFilePath = topBuildDir.append((Path)iter.next());
- IFile depFile = root.getFile(relDepFilePath);
- if (depFile == null || !depFile.isAccessible()) continue;
- callDependencyPostProcessors(depFile, postProcessors, callPopulateDummyTargets, true);
- }
+ Iterator iter = getDependencyMakefiles(h).listIterator();
+ IResourceInfo rcInfo = config.getResourceInfo(container.getPath(), false);
+ while (iter.hasNext()) {
+ // The path to search for the dependency makefile
+ IPath relDepFilePath = topBuildDir.append((Path)iter.next());
+ IFile depFile = root.getFile(relDepFilePath);
+ if (depFile == null || !depFile.isAccessible()) continue;
+ try {
+ callDependencyPostProcessors(rcInfo, h, depFile, postProcessors, callPopulateDummyTargets, true);
+ } catch (CoreException e) {
+ es[0] = e;
+ return false;
+ }
+ }
+ return true;
+ }
+ });
+
+ if(es[0] != null)
+ throw es[0];
}
/* (non-Javadoc)
@@ -739,7 +854,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
public MultiStatus regenerateMakefiles() throws CoreException {
MultiStatus status;
// Visit the resources in the project
- ResourceProxyVisitor visitor = new ResourceProxyVisitor(this, info);
+ ResourceProxyVisitor visitor = new ResourceProxyVisitor(this, config);
project.accept(visitor, IResource.NONE);
// See if the user has cancelled the build
@@ -764,7 +879,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
// Create the top-level directory for the build output
- topBuildDir = createDirectory(info.getConfigurationName());
+ topBuildDir = createDirectory(config.getName());
checkCancel();
// Get the list of subdirectories
@@ -893,7 +1008,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Add the libraries this project depends on
valueList = new ArrayList();
- String[] libs = info.getLibsForConfiguration(buildTargetExt);
+ String[] libs = config.getLibs(buildTargetExt);
for (int i = 0; i < libs.length; i++) {
String string = libs[i];
valueList.add(string);
@@ -902,7 +1017,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Add the extra user-specified objects
valueList = new ArrayList();
- String[] userObjs = info.getUserObjectsForConfiguration(buildTargetExt);
+ String[] userObjs = config.getUserObjects(buildTargetExt);
for (int i = 0; i < userObjs.length; i++) {
String string = userObjs[i];
valueList.add(string);
@@ -936,58 +1051,65 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
StringBuffer buffer = addDefaultHeader();
// Determine the set of macros
- HashSet handledInputExtensions = new HashSet();
- String buildMacro;
- for (int i=0; i<buildTools.length; i++) {
- // Add the known sources macros
- String[] extensionsList = buildTools[i].getAllInputExtensions();
- for (int j=0; j<extensionsList.length; j++) {
- // create a macro of the form "EXTENSION_SRCS :="
- String extensionName = extensionsList[j];
- if(//!getOutputExtensions().contains(extensionName) &&
- !handledInputExtensions.contains(extensionName)) {
- handledInputExtensions.add(extensionName);
- buildMacro = getSourceMacroName(extensionName).toString();
- if (!buildSrcVars.containsKey(buildMacro)) {
- buildSrcVars.put(buildMacro, new ArrayList());
- }
- // Add any generated dependency file macros
- IManagedDependencyGeneratorType depType = buildTools[i].getDependencyGeneratorForExtension(extensionName);
- if (depType != null) {
- int calcType = depType.getCalculatorType();
- if (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND ||
- calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS ||
- calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) {
- buildMacro = getDepMacroName(extensionName).toString();
- if (!buildDepVars.containsKey(buildMacro)) {
- buildDepVars.put(buildMacro, new GnuDependencyGroupInfo(buildMacro,
- (calcType != IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS)));
+ toolInfos.accept(new IPathSettingsContainerVisitor() {
+
+ public boolean visit(PathSettingsContainer container){
+ ToolInfoHolder h = (ToolInfoHolder)container.getValue();
+ ITool[] buildTools = h.buildTools;
+ HashSet handledInputExtensions = new HashSet();
+ String buildMacro;
+ for (int i=0; i<buildTools.length; i++) {
+ // Add the known sources macros
+ String[] extensionsList = buildTools[i].getAllInputExtensions();
+ for (int j=0; j<extensionsList.length; j++) {
+ // create a macro of the form "EXTENSION_SRCS :="
+ String extensionName = extensionsList[j];
+ if(//!getOutputExtensions().contains(extensionName) &&
+ !handledInputExtensions.contains(extensionName)) {
+ handledInputExtensions.add(extensionName);
+ buildMacro = getSourceMacroName(extensionName).toString();
+ if (!buildSrcVars.containsKey(buildMacro)) {
+ buildSrcVars.put(buildMacro, new ArrayList());
}
+ // Add any generated dependency file macros
+ IManagedDependencyGeneratorType depType = buildTools[i].getDependencyGeneratorForExtension(extensionName);
+ if (depType != null) {
+ int calcType = depType.getCalculatorType();
+ if (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND ||
+ calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS ||
+ calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) {
+ buildMacro = getDepMacroName(extensionName).toString();
+ if (!buildDepVars.containsKey(buildMacro)) {
+ buildDepVars.put(buildMacro, new GnuDependencyGroupInfo(buildMacro,
+ (calcType != IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS)));
+ }
+ if (!buildOutVars.containsKey(buildMacro)) {
+ buildOutVars.put(buildMacro, new ArrayList());
+ }
+ }
+ }
+ }
+ }
+ // Add the specified output build variables
+ IOutputType[] outTypes = buildTools[i].getOutputTypes();
+ if (outTypes != null && outTypes.length > 0) {
+ for (int j=0; j<outTypes.length; j++) {
+ buildMacro = outTypes[j].getBuildVariable();
if (!buildOutVars.containsKey(buildMacro)) {
buildOutVars.put(buildMacro, new ArrayList());
}
- }
- }
- }
- }
- // Add the specified output build variables
- IOutputType[] outTypes = buildTools[i].getOutputTypes();
- if (outTypes != null && outTypes.length > 0) {
- for (int j=0; j<outTypes.length; j++) {
- buildMacro = outTypes[j].getBuildVariable();
- if (!buildOutVars.containsKey(buildMacro)) {
- buildOutVars.put(buildMacro, new ArrayList());
+ }
+ } else {
+ // For support of pre-CDT 3.0 integrations.
+ buildMacro = OBJS_MACRO; //$NON-NLS-1$
+ if (!buildOutVars.containsKey(buildMacro)) {
+ buildOutVars.put(buildMacro, new ArrayList());
+ }
}
}
- } else {
- // For support of pre-CDT 3.0 integrations.
- buildMacro = OBJS_MACRO; //$NON-NLS-1$
- if (!buildOutVars.containsKey(buildMacro)) {
- buildOutVars.put(buildMacro, new ArrayList());
- }
+ return true;
}
- }
-
+ });
// Add the macros to the makefile
Iterator iterator = buildSrcVars.entrySet().iterator();
while (iterator.hasNext()) {
@@ -1071,11 +1193,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
buffer.append("RM := "); //$NON-NLS-1$
// support macros in the clean command
- String cleanCommand = info.getCleanCommand();
+ String cleanCommand = config.getCleanCommand();
try {
cleanCommand = ManagedBuildManager.getBuildMacroProvider()
- .resolveValueToMakefileFormat(info.getCleanCommand(),
+ .resolveValueToMakefileFormat(config.getCleanCommand(),
EMPTY_STRING, WHITESPACE,
IBuildMacroProvider.CONTEXT_CONFIGURATION, config);
} catch (BuildMacroException e) {
@@ -1143,10 +1265,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
private StringBuffer addTargets(List outputVarsAdditionsList, boolean rebuild) {
StringBuffer buffer = new StringBuffer();
- IConfiguration config = info.getDefaultConfiguration();
+// IConfiguration config = info.getDefaultConfiguration();
// Assemble the information needed to generate the targets
- String prebuildStep = info.getPrebuildStep();
+ String prebuildStep = config.getPrebuildStep();
try{
//try to resolve the build macros in the prebuild step
prebuildStep = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
@@ -1159,7 +1281,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
prebuildStep = prebuildStep.trim(); // Remove leading and trailing whitespace (and control characters)
- String postbuildStep = info.getPostbuildStep();
+ String postbuildStep = config.getPostbuildStep();
try{
//try to resolve the build macros in the postbuild step
postbuildStep = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
@@ -1172,8 +1294,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} catch (BuildMacroException e){
}
postbuildStep = postbuildStep.trim(); // Remove leading and trailing whitespace (and control characters)
- String preannouncebuildStep = info.getPreannouncebuildStep();
- String postannouncebuildStep = info.getPostannouncebuildStep();
+ String preannouncebuildStep = config.getPreannouncebuildStep();
+ String postannouncebuildStep = config.getPostannouncebuildStep();
String targets = rebuild ? "clean all" : "all"; //$NON-NLS-1$ //$NON-NLS-2$
ITool targetTool = config.calculateTargetTool();
@@ -1182,14 +1304,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// }
// Get all the projects the build target depends on
- IProject[] refdProjects = null;
- try {
+// IProject[] refdProjects = null;
+ IConfiguration[] refConfigs = ManagedBuildManager.getReferencedConfigurations(config);
+/* try {
refdProjects = project.getReferencedProjects();
} catch (CoreException e) {
// There are 2 exceptions; the project does not exist or it is not open
// and neither conditions apply if we are building for it ....
}
-
+*/
// If a prebuild step exists, redefine the all target to be
// all: {pre-build} main-build
// and then reset the "traditional" all target to main-build
@@ -1247,27 +1370,33 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* are captured in the deps target: deps: <cd <Proj_Dep_1/build_dir>;
* $(MAKE) [clean all | all]>
*/
- Vector managedProjectOutputs = new Vector(refdProjects.length);
- if (refdProjects.length > 0) {
+// Vector managedProjectOutputs = new Vector(refdProjects.length);
+// if (refdProjects.length > 0) {
+ Vector managedProjectOutputs = new Vector(refConfigs.length);
+ if (refConfigs.length > 0) {
boolean addDeps = true;
- if (refdProjects != null) {
- for (int i = 0; i < refdProjects.length; i++) {
- IProject dep = refdProjects[i];
- if (!dep.exists()) continue;
+// if (refdProjects != null) {
+ for (int i = 0; i < refConfigs.length; i++) {
+// IProject dep = refdProjects[i];
+ IConfiguration depCfg = refConfigs[i];
+ if(!depCfg.isManagedBuildOn())
+ continue;
+
+// if (!dep.exists()) continue;
if (addDeps) {
buffer.append("dependents:" + NEWLINE); //$NON-NLS-1$
addDeps = false;
}
- String buildDir = dep.getLocation().toString();
+ String buildDir = depCfg.getOwner().getLocation().toString();
String depTargets = targets;
- if (ManagedBuildManager.manages(dep)) {
+// if (ManagedBuildManager.manages(dep)) {
// Add the current configuration to the makefile path
- IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(dep);
- buildDir += SEPARATOR + depInfo.getConfigurationName();
+// IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(dep);
+ buildDir += SEPARATOR + depCfg.getName();
// Extract the build artifact to add to the dependency list
- String depTarget = depInfo.getBuildArtifactName();
- String depExt = depInfo.getBuildArtifactExtension();
+ String depTarget = depCfg.getArtifactName();
+ String depExt = depCfg.getArtifactExtension();
try{
//try to resolve the build macros in the artifact extension
@@ -1276,7 +1405,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
+ config);
} catch (BuildMacroException e){
}
@@ -1287,14 +1416,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
+ config);
if((resolved = resolved.trim()).length() > 0)
depTarget = resolved;
} catch (BuildMacroException e){
}
- String depPrefix = depInfo.getOutputPrefix(depExt);
- if (depInfo.needsRebuild()) {
+ String depPrefix = depCfg.getOutputPrefix(depExt);
+ if (depCfg.needsRebuild()) {
depTargets = "clean all"; //$NON-NLS-1$
}
String dependency = buildDir + SEPARATOR + depPrefix + depTarget;
@@ -1303,10 +1432,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
dependency = escapeWhitespaces(dependency);
managedProjectOutputs.add(dependency);
- }
+ //}
buffer.append(TAB + "-cd" + WHITESPACE + escapeWhitespaces(buildDir) + WHITESPACE + LOGICAL_AND + WHITESPACE + "$(MAKE) " + depTargets + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
}
- }
+// }
buffer.append(NEWLINE);
}
@@ -1381,7 +1510,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
StringBuffer buffer = new StringBuffer();
// Add the comment
buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(BUILD_TOP) + NEWLINE);
-
+
+ ToolInfoHolder h = (ToolInfoHolder)toolInfos.getValue();
+ ITool[] buildTools = h.buildTools;
+ boolean[] buildToolsUsed = h.buildToolsUsed;
// Get the target tool and generate the rule
if (targetTool != null) {
if (addRuleForTool(targetTool, buffer, true, buildTargetName, buildTargetExt,
@@ -1622,6 +1754,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/
private void generateRulesForConsumers(ITool generatingTool, List outputVarsAdditionsList, StringBuffer buffer) {
// Generate a build rule for any tool that consumes the output of this tool
+ ToolInfoHolder h = (ToolInfoHolder)toolInfos.getValue();
+ ITool[] buildTools = h.buildTools;
+ boolean[] buildToolsUsed = h.buildToolsUsed;
IOutputType[] outTypes = generatingTool.getOutputTypes();
for (int i=0; i<outTypes.length; i++) {
String[] outExts = outTypes[i].getOutputExtensions(generatingTool);
@@ -1658,7 +1793,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs,
Vector outputVariables, Vector additionalTargets,
boolean bTargetTool, Vector managedProjectOutputs) {
-
+ ToolInfoHolder h = (ToolInfoHolder)toolInfos.getValue();
+ ITool[] buildTools = h.buildTools;
+ ManagedBuildGnuToolInfo[] gnuToolInfos = h.gnuToolInfos;
// Get the information regarding the tool's inputs and outputs from the objects
// created by calculateToolInputsOutputs
IManagedBuildGnuToolInfo toolInfo = null;
@@ -1697,6 +1834,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* @throws CoreException
*/
protected Vector calculateSecondaryOutputs(IOutputType[] secondaryOutputs) {
+ ToolInfoHolder h = (ToolInfoHolder)toolInfos.getValue();
+ ITool[] buildTools = h.buildTools;
Vector buildVars = new Vector();
for (int i=0; i<buildTools.length; i++) {
// Add the specified output build variables
@@ -1723,7 +1862,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
return buildVars;
}
- protected boolean isSecondaryOutputVar(IOutputType[] secondaryOutputs, String varName) {
+ protected boolean isSecondaryOutputVar(ToolInfoHolder h, IOutputType[] secondaryOutputs, String varName) {
+ ITool[] buildTools = h.buildTools;
for (int i=0; i<buildTools.length; i++) {
// Add the specified output build variables
IOutputType[] outTypes = buildTools[i].getOutputTypes();
@@ -1835,18 +1975,18 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Visit the resources in this folder and add each one to a sources macro, and generate a build rule, if appropriate
IResource[] resources = module.members();
- IResourceConfiguration resConfig;
- IFolder folder = project.getFolder(info.getConfigurationName());
+ IResourceInfo rcInfo;
+ IFolder folder = project.getFolder(config.getName());
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (resource.getType() == IResource.FILE) {
// Check whether this resource is excluded from build
- resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
- if( (resConfig != null) && (resConfig.isExcluded()) )
+ rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false);
+ if( (rcInfo.isExcluded()) )
continue;
addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer,
- folder, relativePath, resource, resource.getLocation(), resConfig, null, false);
+ folder, relativePath, resource, resource.getLocation(), rcInfo, null, false);
}
}
@@ -1870,27 +2010,42 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* @param generatedSource if <code>true</code>, this file was generated by another tool in the tool-chain
*/
protected void addFragmentMakefileEntriesForSource (LinkedHashMap buildVarToRuleStringMap, StringBuffer ruleBuffer,
- IFolder folder, String relativePath, IResource resource, IPath sourceLocation, IResourceConfiguration resConfig,
+ IFolder folder, String relativePath, IResource resource, IPath sourceLocation, IResourceInfo rcInfo,
String varName, boolean generatedSource) {
// Determine which tool, if any, builds files with this extension
String ext = sourceLocation.getFileExtension();
ITool tool = null;
+ //TODO: remove
+// IResourceConfiguration resConfig = null;
+// if(rcInfo instanceof IFileInfo){
+// resConfig = (IFileInfo)rcInfo;
+// }
+ //end remove
+
// Use the tool from the resource configuration if there is one
- if (resConfig != null) {
- ITool[] tools = resConfig.getToolsToInvoke();
+ if (rcInfo instanceof IFileInfo) {
+ IFileInfo fi = (IFileInfo)rcInfo;
+ ITool[] tools = fi.getToolsToInvoke();
if (tools != null && tools.length > 0) {
tool = tools[0];
+ if(!tool.getCustomBuildStep())
+ addToBuildVar(buildVarToRuleStringMap, ext, varName, relativePath, sourceLocation, generatedSource);
}
}
- for (int j=0; j<buildTools.length; j++) {
- if (buildTools[j].buildsFileType(ext)) {
- if (tool == null) {
- tool = buildTools[j];
+ ToolInfoHolder h = getToolInfo(rcInfo.getPath());
+ ITool buildTools[] = h.buildTools;
+
+ if(tool == null){
+ for (int j=0; j<buildTools.length; j++) {
+ if (buildTools[j].buildsFileType(ext)) {
+ if (tool == null) {
+ tool = buildTools[j];
+ }
+ addToBuildVar(buildVarToRuleStringMap, ext, varName, relativePath, sourceLocation, generatedSource);
+ break;
}
- addToBuildVar(buildVarToRuleStringMap, ext, varName, relativePath, sourceLocation, generatedSource);
- break;
}
}
@@ -1904,7 +2059,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Try to add the rule for the file
Vector generatedOutputs = new Vector(); // IPath's - build directory relative
Vector generatedDepFiles = new Vector(); // IPath's - build directory relative or absolute
- addRuleForSource(relativePath, ruleBuffer, resource, sourceLocation, resConfig, generatedSource, generatedDepFiles, generatedOutputs);
+ addRuleForSource(relativePath, ruleBuffer, resource, sourceLocation, rcInfo, generatedSource, generatedDepFiles, generatedOutputs);
// If the rule generates a dependency file(s), add the file(s) to the variable
if (generatedDepFiles.size() > 0) {
@@ -1962,8 +2117,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
generatedOutput = project.getLocation().append(getBuildWorkingDir()).append((IPath)generatedOutputs.get(k));
generateOutputResource = project.getFile(getBuildWorkingDir().append((IPath)generatedOutputs.get(k)));
}
+ IResourceInfo nextRcInfo;
+ if(rcInfo instanceof IFileInfo){
+ nextRcInfo = config.getResourceInfo(rcInfo.getPath().removeLastSegments(1), false);
+ } else {
+ nextRcInfo = rcInfo;
+ }
addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer,
- folder, relativePath, generateOutputResource, generatedOutput, null, buildVariable, true);
+ folder, relativePath, generateOutputResource, generatedOutput, nextRcInfo, buildVariable, true);
}
}
} else {
@@ -1980,7 +2141,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
else {
IOutputType[] secondaryOutputs = config.getToolChain().getSecondaryOutputs();
if (secondaryOutputs.length > 0) {
- if (isSecondaryOutputVar(secondaryOutputs, varName)) {
+ if (isSecondaryOutputVar(h, secondaryOutputs, varName)) {
addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, sourceLocation, generatedSource);
}
}
@@ -2025,6 +2186,53 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
}
+ private IManagedCommandLineInfo generateToolCommandLineInfo(ITool tool, String sourceExtension, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){
+
+ String cmd = tool.getToolCommand();
+ //try to resolve the build macros in the tool command
+ try{
+ String resolvedCommand = null;
+
+ if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$
+ (outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$
+ {
+ resolvedCommand = ManagedBuildManager
+ .getBuildMacroProvider().resolveValue(
+ cmd,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputLocation,
+ outputLocation, null,
+ tool));
+ }
+
+ else {
+ resolvedCommand = ManagedBuildManager
+ .getBuildMacroProvider()
+ .resolveValueToMakefileFormat(
+ cmd,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputLocation,
+ outputLocation, null,
+ tool));
+ }
+ if((resolvedCommand = resolvedCommand.trim()).length() > 0)
+ cmd = resolvedCommand;
+
+ } catch (BuildMacroException e){
+ }
+
+ IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
+ return gen.generateCommandLineInfo( tool, cmd,
+ flags, outputFlag, outputPrefix, outputName, inputResources,
+ tool.getCommandLinePattern() );
+
+ }
+
/* (non-Javadoc)
* Create a rule for this source file. We create a pattern rule if possible.
*
@@ -2063,23 +2271,30 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* @param enumeratedOutputs vector of the filenames that are the output of this rule
*/
protected void addRuleForSource(String relativePath, StringBuffer buffer, IResource resource,
- IPath sourceLocation, IResourceConfiguration resConfig,
+ IPath sourceLocation, IResourceInfo rcInfo,
boolean generatedSource, Vector generatedDepFiles, Vector enumeratedOutputs) {
String fileName = sourceLocation.removeFileExtension().lastSegment();
String inputExtension = sourceLocation.getFileExtension();
- String outputExtension = info.getOutputExtension(inputExtension);
+ String outputExtension;
ITool tool = null;
- if( resConfig != null) {
- ITool[] tools = resConfig.getToolsToInvoke();
+ if( rcInfo instanceof IFileInfo) {
+ IFileInfo fi = (IFileInfo)rcInfo;
+ ITool[] tools = fi.getToolsToInvoke();
if (tools != null && tools.length > 0) {
tool = tools[0];
}
+ } else {
+ IFolderInfo foInfo = (IFolderInfo)rcInfo;
+ tool = foInfo.getToolFromInputExtension(inputExtension);
}
- if (tool == null) {
- tool = info.getToolFromInputExtension(inputExtension);
- }
+
+ ToolInfoHolder h = getToolInfo(rcInfo.getPath());
+
+ outputExtension = tool.getOutputExtension(inputExtension);
+ if(outputExtension == null)
+ outputExtension = EMPTY_STRING;
// Get the dependency generator information for this tool and file extension
IManagedDependencyGenerator oldDepGen = null; // This interface is deprecated but still supported
@@ -2098,13 +2313,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND);
if (doDepGen) {
IPath depFile = Path.fromOSString(relativePath + fileName + DOT + DEP_EXT);
- getDependencyMakefiles().add(depFile);
+ getDependencyMakefiles(h).add(depFile);
generatedDepFiles.add(depFile);
}
} else {
depGen = (IManagedDependencyGenerator2)t;
doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS);
- IBuildObject buildContext = (resConfig != null) ? (IBuildObject)resConfig : (IBuildObject)config;
+ IBuildObject buildContext = rcInfo;//(resConfig != null) ? (IBuildObject)resConfig : (IBuildObject)config;
depInfo = depGen.getDependencySourceInfo(resource.getProjectRelativePath(), resource, buildContext, tool, getBuildWorkingDir());
@@ -2117,7 +2332,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
if (depFiles != null) {
for (int i=0; i<depFiles.length; i++) {
- getDependencyMakefiles().add(depFiles[i]);
+ getDependencyMakefiles(h).add(depFiles[i]);
generatedDepFiles.add(depFiles[i]);
}
}
@@ -2179,8 +2394,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
.getProjectRelativePath().toString()));
boolean needExplicitRuleForFile = resourceNameRequiresExplicitRule ||
- MacroResolver.getReferencedExplitFileMacros(tool).length > 0
- || MacroResolver.getReferencedExplitFileMacros(tool
+ BuildMacroProvider.getReferencedExplitFileMacros(tool).length > 0
+ || BuildMacroProvider.getReferencedExplitFileMacros(tool
.getToolCommand(), IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation,
null, tool)).length > 0;
@@ -2240,7 +2455,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Use the relative path (not really needed to store per se but in the future someone may want this)
resourcePath = relativePath;
// The rule and command to add to the makefile
- if( resConfig != null || needExplicitRuleForFile) {
+ if( rcInfo instanceof IFileInfo || needExplicitRuleForFile) {
// Need a hardcoded rule, not a pattern rule
defaultOutputName = escapeWhitespaces(resourcePath + fileName + optDotExt);
patternRule = false;
@@ -2413,7 +2628,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
String outflag = null;
String outputPrefix = null;
- if( resConfig != null || needExplicitRuleForFile || needExplicitDependencyCommands) {
+ if( rcInfo instanceof IFileInfo || needExplicitRuleForFile || needExplicitDependencyCommands) {
outflag = tool.getOutputFlag();
outputPrefix = tool.getOutputPrefix();
@@ -2423,11 +2638,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
OUT_MACRO + otherPrimaryOutputs, inputStrings, tool.getCommandLinePattern() );
} else {
- outflag = info.getOutputFlag(outputExtension);
- outputPrefix = info.getOutputPrefix(outputExtension);
+ outflag = tool.getOutputFlag();//config.getOutputFlag(outputExtension);
+ outputPrefix = tool.getOutputPrefix();//config.getOutputPrefix(outputExtension);
// Call the command line generator
- cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix,
+ cmdLInfo = generateToolCommandLineInfo(tool, inputExtension, flags, outflag, outputPrefix,
OUT_MACRO + otherPrimaryOutputs, inputStrings, sourceLocation, outputLocation );
}
@@ -2487,7 +2702,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
String[] depCmds = null;
if (oldDepGen != null) {
depCmds = new String[1];
- depCmds[0] = oldDepGen.getDependencyCommand(resource, info);
+ depCmds[0] = oldDepGen.getDependencyCommand(resource, ManagedBuildManager.getBuildInfo(project));
} else {
if (depCommands != null) {
depCmds = depCommands.getPostToolDependencyCommands();
@@ -2731,8 +2946,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if (assignToOption != null && option == null) {
try {
int optType = assignToOption.getValueType();
- IBuildObject toolParent = tool.getParent();
- if (toolParent != null) {
+ IResourceInfo rcInfo = tool.getParentResourceInfo();
+ if (rcInfo != null) {
if (optType == IOption.STRING) {
String optVal = ""; //$NON-NLS-1$
for (int j=0; j<allRes.size(); j++) {
@@ -2751,18 +2966,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
optVal += ManagedBuildManager.calculateRelativePath(getTopBuildDir(), Path.fromOSString(resPath)).toString();
}
- if (toolParent instanceof IToolChain) {
- IConfiguration config = ((IToolChain)toolParent).getParent();
- if (config != null) {
- ManagedBuildManager.setOption(config, tool, assignToOption, optVal);
- }
- } else if (toolParent instanceof IResourceConfiguration) {
- ManagedBuildManager.setOption(((IResourceConfiguration)toolParent), tool, assignToOption, optVal);
- }
+ ManagedBuildManager.setOption(rcInfo, tool, assignToOption, optVal);
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES) {
// Note that the path(s) must be translated from project relative
// to top build directory relative
String[] paths = new String[allRes.size()];
@@ -2778,36 +2990,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
}
}
- if (toolParent instanceof IToolChain) {
- IConfiguration config = ((IToolChain)toolParent).getParent();
- if (config != null) {
- ManagedBuildManager.setOption(config, tool, assignToOption, paths);
- }
- } else if (toolParent instanceof IResourceConfiguration) {
- ManagedBuildManager.setOption(((IResourceConfiguration)toolParent), tool, assignToOption, paths);
- }
+ ManagedBuildManager.setOption(rcInfo, tool, assignToOption, paths);
} else if (optType == IOption.BOOLEAN) {
boolean b = false;
if (allRes.size() > 0) b = true;
- if (toolParent instanceof IToolChain) {
- IConfiguration config = ((IToolChain)toolParent).getParent();
- if (config != null) {
- ManagedBuildManager.setOption(config, tool, assignToOption, b);
- }
- } else if (toolParent instanceof IResourceConfiguration) {
- ManagedBuildManager.setOption(((IResourceConfiguration)toolParent), tool, assignToOption, b);
- }
+ ManagedBuildManager.setOption(rcInfo, tool, assignToOption, b);
} else if (optType == IOption.ENUMERATED) {
if (allRes.size() > 0) {
String s = allRes.get(0).toString();
- if (toolParent instanceof IToolChain) {
- IConfiguration config = ((IToolChain)toolParent).getParent();
- if (config != null) {
- ManagedBuildManager.setOption(config, tool, assignToOption, s);
- }
- } else if (toolParent instanceof IResourceConfiguration) {
- ManagedBuildManager.setOption(((IResourceConfiguration)toolParent), tool, assignToOption, s);
- }
+ ManagedBuildManager.setOption(rcInfo, tool, assignToOption, s);
}
}
allRes.clear();
@@ -2847,6 +3038,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
IPath sourceLocation, Vector ruleOutputs, Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs) {
String inExt = sourceLocation.getFileExtension();
String outExt = tool.getOutputExtension(inExt);
+ IResourceInfo rcInfo = tool.getParentResourceInfo();
IOutputType[] outTypes = tool.getOutputTypes();
if (outTypes != null && outTypes.length > 0) {
@@ -2863,29 +3055,29 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// next best thing, i.e. configuration context.
// figure out the configuration we're using
- IBuildObject toolParent = tool.getParent();
- IConfiguration config = null;
+// IBuildObject toolParent = tool.getParent();
+// IConfiguration config = null;
// if the parent is a config then we're done
- if (toolParent instanceof IConfiguration)
- config = (IConfiguration) toolParent;
- else if (toolParent instanceof IToolChain) {
- // must be a toolchain
- config = (IConfiguration) ((IToolChain) toolParent)
- .getParent();
- }
-
- else if (toolParent instanceof IResourceConfiguration) {
- config = (IConfiguration) ((IResourceConfiguration) toolParent)
- .getParent();
- }
-
- else {
- // bad
- throw new AssertionError(
- "tool parent must be one of configuration, toolchain, or resource configuration");
- }
-
- if (config != null) {
+// if (toolParent instanceof IConfiguration)
+// config = (IConfiguration) toolParent;
+// else if (toolParent instanceof IToolChain) {
+// // must be a toolchain
+// config = (IConfiguration) ((IToolChain) toolParent)
+// .getParent();
+// }
+//
+// else if (toolParent instanceof IResourceConfiguration) {
+// config = (IConfiguration) ((IResourceConfiguration) toolParent)
+// .getParent();
+// }
+
+// else {
+// // bad
+// throw new AssertionError(
+// "tool parent must be one of configuration, toolchain, or resource configuration");
+// }
+
+// if (config != null) {
try {
@@ -2915,7 +3107,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
catch (BuildMacroException e) {
}
- }
+// }
@@ -2937,7 +3129,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES) {
outputList = (List)option.getValue();
// Add outputPrefix to each if necessary
if (outputPrefix.length() > 0) {
@@ -3278,24 +3474,24 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*
* @return a <code>Set</code> containing all of the output extensions
*/
- public Set getOutputExtensions() {
- if (outputExtensionsSet == null) {
+ public Set getOutputExtensions(ToolInfoHolder h) {
+ if (h.outputExtensionsSet == null) {
// The set of output extensions which will be produced by this tool.
// It is presumed that this set is not very large (likely < 10) so
// a HashSet should provide good performance.
- outputExtensionsSet = new HashSet();
+ h.outputExtensionsSet = new HashSet();
// For each tool for the target, lookup the kinds of sources it outputs
// and add that to our list of output extensions.
- for (int i=0; i<buildTools.length; i++) {
- ITool tool = buildTools[i];
+ for (int i=0; i<h.buildTools.length; i++) {
+ ITool tool = h.buildTools[i];
String[] outputs = tool.getAllOutputExtensions();
if (outputs != null) {
- outputExtensionsSet.addAll(Arrays.asList(outputs));
+ h.outputExtensionsSet.addAll(Arrays.asList(outputs));
}
}
}
- return outputExtensionsSet;
+ return h.outputExtensionsSet;
}
/**
@@ -3313,6 +3509,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* @return a <code>true</code> if the dependency file is modified
*/
static public boolean populateDummyTargets(IConfiguration cfg, IFile makefile, boolean force) throws CoreException, IOException {
+ return populateDummyTargets(cfg.getRootFolderInfo(), makefile, force);
+ }
+
+ static public boolean populateDummyTargets(IResourceInfo rcInfo, IFile makefile, boolean force) throws CoreException, IOException {
+
if (makefile == null || !makefile.exists()) return false;
// Get the contents of the dependency file
@@ -3465,13 +3666,20 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
outBuffer.append(NEWLINE);
save = true;
+ IFolderInfo fo = null;
+ if(rcInfo instanceof IFolderInfo){
+ fo = (IFolderInfo)rcInfo;
+ } else {
+ IConfiguration c = rcInfo.getParent();
+ fo = (IFolderInfo)c.getResourceInfo(rcInfo.getPath().removeLastSegments(1), false);
+ }
// Dummy targets to add to the makefile
Iterator dummyIter = deps.iterator();
while (dummyIter.hasNext()) {
String dummy = (String)dummyIter.next();
IPath dep = new Path(dummy);
String extension = dep.getFileExtension();
- if (cfg.isHeaderFile(extension)) {
+ if (fo.isHeaderFile(extension)) {
/*
* The formatting here is
* <dummy_target>:
@@ -3701,132 +3909,140 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*/
protected void calculateToolInputsOutputs() {
- // We are "done" when the information for all tools has been calculated,
- // or we are not making any progress
- boolean done = false;
- boolean lastChance = false;
- int[] doneState = new int[buildTools.length];
-
- // Identify the target tool
- ITool targetTool = config.calculateTargetTool();
-// if (targetTool == null) {
-// targetTool = info.getToolFromOutputExtension(buildTargetExt);
-// }
+ toolInfos.accept(new IPathSettingsContainerVisitor(){
+ public boolean visit(PathSettingsContainer container){
+ ToolInfoHolder h = (ToolInfoHolder)container.getValue();
+ ITool[] buildTools = h.buildTools;
+ ManagedBuildGnuToolInfo[] gnuToolInfos = h.gnuToolInfos;
+ // We are "done" when the information for all tools has been calculated,
+ // or we are not making any progress
+ boolean done = false;
+ boolean lastChance = false;
+ int[] doneState = new int[buildTools.length];
+
+ // Identify the target tool
+ ITool targetTool = config.calculateTargetTool();
+ // if (targetTool == null) {
+ // targetTool = info.getToolFromOutputExtension(buildTargetExt);
+ // }
+
+ // Initialize the tool info array and the done state
+ for (int i=0; i<buildTools.length; i++) {
+ if ((buildTools[i] == targetTool)) {
+ String ext = config.getArtifactExtension();
+ //try to resolve the build macros in the artifact extension
+ try{
+ ext = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ ext,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ config);
+ } catch (BuildMacroException e){
+ }
+
+ String name = config.getArtifactName();
+ //try to resolve the build macros in the artifact name
+ try{
+ String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ name,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ config);
+ if((resolved = resolved.trim()).length() > 0)
+ name = resolved;
+ } catch (BuildMacroException e){
+ }
- // Initialize the tool info array and the done state
- for (int i=0; i<buildTools.length; i++) {
- if ((buildTools[i] == targetTool)) {
- String ext = info.getBuildArtifactExtension();
- //try to resolve the build macros in the artifact extension
- try{
- ext = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- ext,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
- } catch (BuildMacroException e){
+ gnuToolInfos[i] = new ManagedBuildGnuToolInfo(project, buildTools[i], true,
+ name, ext);
+ } else {
+ gnuToolInfos[i] = new ManagedBuildGnuToolInfo(project, buildTools[i], false, null, null);
+ }
+ doneState[i] = 0;
}
- String name = info.getBuildArtifactName();
- //try to resolve the build macros in the artifact name
- try{
- String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- name,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
- if((resolved = resolved.trim()).length() > 0)
- name = resolved;
- } catch (BuildMacroException e){
+ // Initialize the build output variable to file additions map
+ LinkedHashMap map = getTopBuildOutputVars();
+ Iterator iterator = buildOutVars.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Map.Entry)iterator.next();
+ String macroName = (String)entry.getKey();
+ addMacroAdditionPrefix(map, macroName, "", false); //$NON-NLS-1$
}
-
- gnuToolInfos[i] = new ManagedBuildGnuToolInfo(project, buildTools[i], true,
- name, ext);
- } else {
- gnuToolInfos[i] = new ManagedBuildGnuToolInfo(project, buildTools[i], false, null, null);
- }
- doneState[i] = 0;
- }
-
- // Initialize the build output variable to file additions map
- LinkedHashMap map = getTopBuildOutputVars();
- Iterator iterator = buildOutVars.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry)iterator.next();
- String macroName = (String)entry.getKey();
- addMacroAdditionPrefix(map, macroName, "", false); //$NON-NLS-1$
- }
-
- // Set of input extensions for which macros have been created so far
- HashSet handledDepsInputExtensions = new HashSet();
- HashSet handledOutsInputExtensions = new HashSet();
- while (!done) {
- int[] testState = new int[doneState.length];
- for (int i=0; i<testState.length; i++) testState[i] = 0;
-
- // Calculate inputs
- for (int i=0; i<gnuToolInfos.length; i++) {
- if (gnuToolInfos[i].areInputsCalculated()) {
- testState[i]++;
- } else {
- if (gnuToolInfos[i].calculateInputs(this, info.getDefaultConfiguration(), projectResources, lastChance)) {
- testState[i]++;
+ // Set of input extensions for which macros have been created so far
+ HashSet handledDepsInputExtensions = new HashSet();
+ HashSet handledOutsInputExtensions = new HashSet();
+
+ while (!done) {
+ int[] testState = new int[doneState.length];
+ for (int i=0; i<testState.length; i++) testState[i] = 0;
+
+ // Calculate inputs
+ for (int i=0; i<gnuToolInfos.length; i++) {
+ if (gnuToolInfos[i].areInputsCalculated()) {
+ testState[i]++;
+ } else {
+ if (gnuToolInfos[i].calculateInputs(GnuMakefileGenerator.this, config, projectResources, h, lastChance)) {
+ testState[i]++;
+ }
+ }
}
- }
- }
- // Calculate dependencies
- for (int i=0; i<gnuToolInfos.length; i++) {
- if (gnuToolInfos[i].areDependenciesCalculated()) {
- testState[i]++;
- } else {
- if (gnuToolInfos[i].calculateDependencies(this, info.getDefaultConfiguration(), handledDepsInputExtensions, lastChance)) {
- testState[i]++;
+ // Calculate dependencies
+ for (int i=0; i<gnuToolInfos.length; i++) {
+ if (gnuToolInfos[i].areDependenciesCalculated()) {
+ testState[i]++;
+ } else {
+ if (gnuToolInfos[i].calculateDependencies(GnuMakefileGenerator.this, config, handledDepsInputExtensions, h, lastChance)) {
+ testState[i]++;
+ }
+ }
}
- }
- }
- // Calculate outputs
- for (int i=0; i<gnuToolInfos.length; i++) {
- if (gnuToolInfos[i].areOutputsCalculated()) {
- testState[i]++;
- } else {
- if (gnuToolInfos[i].calculateOutputs(this, info.getDefaultConfiguration(), handledOutsInputExtensions, lastChance)) {
- testState[i]++;
+ // Calculate outputs
+ for (int i=0; i<gnuToolInfos.length; i++) {
+ if (gnuToolInfos[i].areOutputsCalculated()) {
+ testState[i]++;
+ } else {
+ if (gnuToolInfos[i].calculateOutputs(GnuMakefileGenerator.this, config, handledOutsInputExtensions, lastChance)) {
+ testState[i]++;
+ }
+ }
}
- }
- }
- // Are all calculated? If so, done.
- done = true;
- for (int i=0; i<testState.length; i++) {
- if (testState[i] != 3) {
- done = false;
- break;
- }
- }
-
- // Test our "done" state vs. the previous "done" state.
- // If we have made no progress, give it a "last chance" and then quit
- if (!done) {
- done = true;
- for (int i=0; i<testState.length; i++) {
- if (testState[i] != doneState[i]) {
- done = false;
- break;
+ // Are all calculated? If so, done.
+ done = true;
+ for (int i=0; i<testState.length; i++) {
+ if (testState[i] != 3) {
+ done = false;
+ break;
+ }
+ }
+
+ // Test our "done" state vs. the previous "done" state.
+ // If we have made no progress, give it a "last chance" and then quit
+ if (!done) {
+ done = true;
+ for (int i=0; i<testState.length; i++) {
+ if (testState[i] != doneState[i]) {
+ done = false;
+ break;
+ }
+ }
+ }
+ if (done) {
+ if (!lastChance) {
+ lastChance = true;
+ done = false;
+ }
+ }
+ if (!done) {
+ doneState = testState;
}
- }
- }
- if (done) {
- if (!lastChance) {
- lastChance = true;
- done = false;
}
- }
- if (!done) {
- doneState = testState;
+ return true;
}
- }
+ });
}
/* (non-javadoc)
@@ -3839,7 +4055,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* variable have done so.
* @return List
*/
- public List getBuildVariableList(String variable, int locationType, IPath directory, boolean getAll) {
+ public List getBuildVariableList(ToolInfoHolder h, String variable, int locationType, IPath directory, boolean getAll) {
+ ManagedBuildGnuToolInfo[] gnuToolInfos = h.gnuToolInfos;
boolean done = true;
for (int i=0; i<gnuToolInfos.length; i++) {
if (!gnuToolInfos[i].areOutputVariablesCalculated()) {
@@ -4123,7 +4340,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Get the project relative path of the file
String fileName = getFileName(deletedFile);
String srcExtension = deletedFile.getFileExtension();
- String targetExtension = info.getOutputExtension(srcExtension);
+ IPath folderPath = inFullPathFromOutFullPath(deletedFile.getFullPath().removeLastSegments(1));
+ if(folderPath != null){
+ folderPath = folderPath.removeFirstSegments(1);
+ } else {
+ folderPath = new Path("");
+ }
+ IResourceInfo rcInfo = config.getResourceInfo(folderPath, false);
+ if(rcInfo instanceof IFileInfo){
+ rcInfo = config.getResourceInfo(folderPath.removeLastSegments(1), false);
+ }
+ String targetExtension = ((IFolderInfo)rcInfo).getOutputExtension(srcExtension);
if (targetExtension != "") //$NON-NLS-1$
fileName += DOT + targetExtension;
IPath projectRelativePath = deletedFile.getProjectRelativePath().removeLastSegments(1);
@@ -4139,6 +4366,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
}
+ private IPath inFullPathFromOutFullPath(IPath path){
+ IPath inPath = null;
+ if(topBuildDir.isPrefixOf(path)){
+ inPath = path.removeFirstSegments(topBuildDir.segmentCount());
+ inPath = project.getFullPath().append(path);
+ }
+ return inPath;
+ }
+
/**
* @param deletedFile
*/
@@ -4148,7 +4384,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
ITool tool = null;
IManagedDependencyGeneratorType depType = null;
String sourceExtension = deletedFile.getFileExtension();
- ITool[] tools = config.getFilteredTools();
+ IPath folderPath = inFullPathFromOutFullPath(deletedFile.getFullPath().removeLastSegments(1));
+ if(folderPath != null){
+ folderPath = folderPath.removeFirstSegments(1);
+ } else {
+ folderPath = new Path("");
+ }
+ ToolInfoHolder h = getToolInfo(folderPath);
+ ITool[] tools = h.buildTools;
for (int index = 0; index < tools.length; ++index) {
if (tools[index].buildsFileType(sourceExtension)) {
tool = tools[index];
@@ -4219,11 +4462,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
/* (non-Javadoc)
* @return
*/
- private Vector getDependencyMakefiles() {
- if (dependencyMakefiles == null) {
- dependencyMakefiles = new Vector();
+ private List getDependencyMakefiles(ToolInfoHolder h) {
+ if (h.dependencyMakefiles == null) {
+ h.dependencyMakefiles = new ArrayList();
}
- return dependencyMakefiles;
+ return h.dependencyMakefiles;
}
/* (non-Javadoc)
@@ -4355,4 +4598,109 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
boolean singleQuoted = path.startsWith("'") && path.endsWith("'");
return doubleQuoted || singleQuoted ? path.substring(1,path.length()-1) : path;
}
+
+ public void initialize(int buildKind, IConfiguration cfg, IBuilder builder,
+ IProgressMonitor monitor) {
+ // Save the project so we can get path and member information
+ this.project = cfg.getOwner().getProject();
+ if(builder == null){
+ builder = cfg.getEditableBuilder();
+ }
+ try {
+ projectResources = project.members();
+ } catch (CoreException e) {
+ projectResources = null;
+ }
+ // Save the monitor reference for reporting back to the user
+ this.monitor = monitor;
+ // Get the build info for the project
+// this.info = info;
+ // Get the name of the build target
+ buildTargetName = cfg.getArtifactName();
+ // Get its extension
+ buildTargetExt = cfg.getArtifactExtension();
+
+ try{
+ //try to resolve the build macros in the target extension
+ buildTargetExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ buildTargetExt,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ builder);
+ } catch (BuildMacroException e){
+ }
+
+ try{
+ //try to resolve the build macros in the target name
+ String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ buildTargetName,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ builder);
+ if((resolved = resolved.trim()).length() > 0)
+ buildTargetName = resolved;
+ } catch (BuildMacroException e){
+ }
+
+
+ if (buildTargetExt == null) {
+ buildTargetExt = new String();
+ }
+ // Cache the build tools
+ config = cfg;
+ this.builder = builder;
+
+ initToolInfos();
+ //set the top build dir path
+ topBuildDir = project.getFolder(cfg.getName()).getFullPath();
+
+ srcPaths = config.getSourcePaths();
+ if(srcPaths.length == 0){
+ srcPaths = new IPath[]{new Path("")};
+ } else {
+ }
+ }
+
+ private void initToolInfos(){
+ toolInfos = PathSettingsContainer.createRootContainer();
+
+ IResourceInfo rcInfos[] = config.getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ IResourceInfo rcInfo = rcInfos[i];
+ if(rcInfo.isExcluded() /*&& !((ResourceInfo)rcInfo).isRoot()*/)
+ continue;
+
+ ToolInfoHolder h = getToolInfo(rcInfo.getPath(), true);
+ if(rcInfo instanceof IFolderInfo){
+ IFolderInfo fo = (IFolderInfo)rcInfo;
+ h.buildTools = fo.getFilteredTools();
+ h.buildToolsUsed = new boolean[h.buildTools.length];
+ h.gnuToolInfos = new ManagedBuildGnuToolInfo[h.buildTools.length];
+ } else {
+ IFileInfo fi = (IFileInfo)rcInfo;
+ h.buildTools = fi.getToolsToInvoke();
+ h.buildToolsUsed = new boolean[h.buildTools.length];
+ h.gnuToolInfos = new ManagedBuildGnuToolInfo[h.buildTools.length];
+ }
+ }
+ }
+
+ private ToolInfoHolder getToolInfo(IPath path){
+ return getToolInfo(path, false);
+ }
+
+ private ToolInfoHolder getToolInfo(IPath path, boolean create){
+ PathSettingsContainer child = toolInfos.getChildContainer(path, create, create);
+ ToolInfoHolder h = null;
+ if(child != null){
+ h = (ToolInfoHolder)child.getValue();
+ if(h == null && create){
+ h = new ToolInfoHolder();
+ child.setValue(h);
+ }
+ }
+ return h;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
index 659c7314007..c8d90713952 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -41,6 +41,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
+import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.ToolInfoHolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
@@ -156,7 +157,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
* Other Methods
*/
- public boolean calculateInputs(GnuMakefileGenerator makeGen, IConfiguration config, IResource[] projResources, boolean lastChance) {
+ public boolean calculateInputs(GnuMakefileGenerator makeGen, IConfiguration config, IResource[] projResources, ToolInfoHolder h, boolean lastChance) {
// Get the inputs for this tool invocation
// Note that command inputs that are also dependencies are also added to the command dependencies list
@@ -194,7 +195,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES) {
inputs = (List)option.getValue();
}
for (int j=0; j<inputs.size(); j++) {
@@ -266,7 +271,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
}
// If there is an output variable with the same name, get
// the files associated with it.
- List outMacroList = makeGen.getBuildVariableList(variable, GnuMakefileGenerator.PROJECT_RELATIVE,
+ List outMacroList = makeGen.getBuildVariableList(h, variable, GnuMakefileGenerator.PROJECT_RELATIVE,
null, true);
if (outMacroList != null) {
itEnumeratedInputs.addAll(outMacroList);
@@ -375,7 +380,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES) {
// Mote that when using the enumerated inputs, the path(s) must be translated from project relative
// to top build directory relative
String[] paths = new String[itEnumeratedInputs.size()];
@@ -524,7 +533,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} else if (
optType == IOption.STRING_LIST ||
optType == IOption.LIBRARIES ||
- optType == IOption.OBJECTS) {
+ optType == IOption.OBJECTS ||
+ optType == IOption.INCLUDE_FILES ||
+ optType == IOption.LIBRARY_PATHS ||
+ optType == IOption.LIBRARY_FILES ||
+ optType == IOption.MACRO_FILES) {
outputs = (List)option.getValue();
// Add outputPrefix to each if necessary
if (outputPrefix.length() > 0) {
@@ -771,7 +784,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
private boolean callDependencyCalculator (GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions,
IManagedDependencyGeneratorType depGen, String[] extensionsList, Vector myCommandDependencies, HashMap myOutputMacros,
- Vector myAdditionalTargets, boolean done) {
+ Vector myAdditionalTargets, ToolInfoHolder h, boolean done) {
int calcType = depGen.getCalculatorType();
switch (calcType) {
@@ -782,7 +795,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
String extensionName = extensionsList[i];
// Generated files should not appear in the list.
- if(!makeGen.getOutputExtensions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
+ if(!makeGen.getOutputExtensions(h).contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
handledInputExtensions.add(extensionName);
String depExt = IManagedBuilderMakefileGenerator.DEP_EXT;
if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS) {
@@ -868,7 +881,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
return done;
}
- public boolean calculateDependencies(GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, boolean lastChance) {
+ public boolean calculateDependencies(GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, ToolInfoHolder h, boolean lastChance) {
// Get the dependencies for this tool invocation
boolean done = true;
Vector myCommandDependencies = new Vector();
@@ -887,7 +900,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
if (depGen != null) {
done = callDependencyCalculator (makeGen, config, handledInputExtensions,
depGen, extensionsList, myCommandDependencies, myOutputMacros,
- myAdditionalTargets, done);
+ myAdditionalTargets, h, done);
}
// Add additional dependencies specified in AdditionalInput elements
@@ -940,7 +953,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
if (depGen != null) {
done = callDependencyCalculator (makeGen, config, handledInputExtensions,
depGen, extensionsList, myCommandDependencies, myOutputMacros,
- myAdditionalTargets, done);
+ myAdditionalTargets, h, done);
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java
index 15c829ed106..d1b49dc7ed9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 Intel Corporation and others.
+ * Copyright (c) 2004, 2007 Intel 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
@@ -319,7 +319,7 @@ public class UpdateManagedProjectManager {
version = getManagedBuildInfoVersion(info.getVersion());
}
- if(!isCompatibleProject(info)){
+ if(/*!isCompatibleProject(info)*/ !version.equals(new PluginVersionIdentifier(3,1,0))){
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
ConverterMessages.getFormattedString("UpdateManagedProjectManager.5", //$NON-NLS-1$
new String [] {
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeBuilderInfo.java
index 15a07585594..fa77150b60e 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeBuilderInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.core;
+package org.eclipse.cdt.newmake.core;
import org.eclipse.core.runtime.CoreException;
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeCommonBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java
index 1c64b20c70d..4aa48e9540b 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeCommonBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/IMakeCommonBuildInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
+ * Copyright (c) 2004, 2007 QNX Software Systems 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
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.core;
+package org.eclipse.cdt.newmake.core;
import java.util.Map;
@@ -17,7 +17,7 @@ import org.eclipse.core.runtime.IPath;
public interface IMakeCommonBuildInfo {
- public final static String ARGS_PREFIX = MakeCorePlugin.getUniqueIdentifier();
+ public final static String ARGS_PREFIX = "org.eclipse.cdt.make.core"; //$NON-NLS-1$
public final static String BUILD_LOCATION = ARGS_PREFIX + ".build.location"; //$NON-NLS-1$
public final static String BUILD_COMMAND = ARGS_PREFIX + ".build.command"; //$NON-NLS-1$
@@ -35,10 +35,17 @@ public interface IMakeCommonBuildInfo {
boolean isStopOnError();
void setStopOnError(boolean on) throws CoreException;
+ boolean supportsStopOnError(boolean on);
+
+ int getParallelizationNum();
+ void setParallelizationNum(int num) throws CoreException;
+ boolean supportsParallelBuild();
+ boolean isParallelBuildOn();
+ void setParallelBuildOn(boolean on) throws CoreException;
boolean isDefaultBuildCmd();
void setUseDefaultBuildCmd(boolean on) throws CoreException;
-
+
IPath getBuildCommand();
/**
@@ -63,4 +70,9 @@ public interface IMakeCommonBuildInfo {
boolean appendEnvironment();
void setAppendEnvironment(boolean append) throws CoreException;
+
+ boolean isManagedBuildOn();
+ void setManagedBuildOn(boolean on) throws CoreException;
+ boolean supportsBuild(boolean managed);
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeBuilderUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeBuilderUtil.java
new file mode 100644
index 00000000000..03ebde8af9f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeBuilderUtil.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2006 QNX Software Systems 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:
+ * QNX Software Systems - Initial implementation
+ * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
+ *******************************************************************************/
+package org.eclipse.cdt.newmake.core;
+
+
+public class MakeBuilderUtil {
+
+//FIXME: public static IPath getBuildDirectory(IProject project, IPath subPath, String builderID) {
+// IPath rootPath = getBuildDirectory(project, builderID);
+// return rootPath.append(subPath);
+// }
+//
+// public static IPath getBuildDirectory(IProject project, String builderID) {
+// IMakeBuilderInfo info;
+// try {
+// info = MakeCorePlugin.createBuildInfo(project, builderID);
+// } catch (CoreException e) {
+// return project.getLocation();
+// }
+// return getBuildDirectory(project, info);
+// }
+//
+// public static IPath getBuildDirectory(IProject project, IMakeBuilderInfo info) {
+// IPath buildDirectory = info.getBuildLocation();
+// if (!buildDirectory.isEmpty()) {
+// IResource res = project.getParent().findMember(buildDirectory);
+// if (res instanceof IContainer && res.exists()) {
+// buildDirectory = res.getLocation();
+// }
+// } else {
+// buildDirectory = project.getLocation();
+// }
+// return buildDirectory;
+// }
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeScannerInfo.java
index 5108de96350..2654cc0ffa5 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeScannerInfo.java
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.core;
+package org.eclipse.cdt.newmake.core;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeScannerProvider.java
index 3a759742995..b013d95604c 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/core/MakeScannerProvider.java
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.core;
+package org.eclipse.cdt.newmake.core;
import java.util.ArrayList;
import java.util.Arrays;
@@ -26,6 +26,7 @@ import org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.resources.ScannerProvider;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
@@ -42,14 +43,14 @@ import org.w3c.dom.Node;
*
*/
public class MakeScannerProvider extends ScannerProvider {
-
+ private static final String MAKE_CORE_ID = "org.eclipse.cdt.make.core"; //$NON-NLS-1$
// This is the id of the IScannerInfoProvider extension point entry
- public static final String INTERFACE_IDENTITY = MakeCorePlugin.getUniqueIdentifier() + ".MakeScannerProvider"; //$NON-NLS-1$
+ public static final String INTERFACE_IDENTITY = MAKE_CORE_ID + ".MakeScannerProvider"; //$NON-NLS-1$
// Name we will use to store build property with the project
- private static final QualifiedName scannerInfoProperty = new QualifiedName(MakeCorePlugin.getUniqueIdentifier(),
+ private static final QualifiedName scannerInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(),
"makeBuildInfo"); //$NON-NLS-1$
- static final String CDESCRIPTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeScannerInfo"; //$NON-NLS-1$
+ static final String CDESCRIPTOR_ID = MAKE_CORE_ID + ".makeScannerInfo"; //$NON-NLS-1$
public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
public static final String PATH = "path"; //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.java
new file mode 100644
index 00000000000..eef8ab4cde9
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2007 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.newmake.internal.core;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class MakeMessages {
+
+ private static final String RESOURCE_BUNDLE= MakeMessages.class.getName();
+ private static ResourceBundle fgResourceBundle;
+ static {
+ try {
+ fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
+ } catch (MissingResourceException x) {
+ fgResourceBundle = null;
+ }
+ }
+
+ private MakeMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ } catch (NullPointerException e) {
+ return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Gets a string from the resource bundle and formats it with the argument
+ *
+ * @param key the string used to get the bundle value, must not be null
+ */
+ public static String getFormattedString(String key, Object arg) {
+ return MessageFormat.format(getString(key), new Object[] { arg });
+ }
+
+ /**
+ * Gets a string from the resource bundle and formats it with arguments
+ */
+ public static String getFormattedString(String key, Object[] args) {
+ return MessageFormat.format(getString(key), args);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.properties
new file mode 100644
index 00000000000..73c58f90598
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/MakeMessages.properties
@@ -0,0 +1,55 @@
+###############################################################################
+# Copyright (c) 2003, 2007 QNX Software Systems 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:
+# QNX Software Systems - initial API and implementation
+###############################################################################
+
+MakeBuilder.buildError=Error launching builder ({0})
+MakeBuilder.Invoking_Make_Builder=Invoking Make Builder...
+MakeBuilder.Invoking_Command=Invoking Command:
+MakeBuilder.Updating_project=Updating project...
+MakeBuilder.Creating_Markers=Generating markers...
+
+BuildInfoFactory.Missing_Builder=Missing Builder:
+
+MakeTargetManager.add_to_workspace_root=Cannot add make targets to workspace root
+MakeTargetManager.add_temporary_target=Cannot add temporart Target to manager.
+MakeTargetManager.target_exists=Target exists
+MakeTargetManager.failed_initializing_targets=Failed initializing make targets
+MakeTargetManager.error_writing_file=Error writing target file
+
+ProjectTargets.error_reading_project_targets=Error reading project targets.
+
+ScannerConfigBuilder.Invoking_Builder=Invoking scanner config builder on project
+ScannerConfigNature.Missing_Project=Missing or closed project
+
+ScannerConfigInfoFactory.Missing_Builder=Missing Builder:
+
+ExternalScannerInfoProvider.Provider_Error=Error launching external scanner info generator ({0})
+ExternalScannerInfoProvider.Reading_Specs=Reading specs ...
+ExternalScannerInfoProvider.Invoking_Command=Invoking Command:
+ExternalScannerInfoProvider.Parsing_Output=Parsing output ...
+ExternalScannerInfoProvider.Creating_Markers=Generating markers ...
+
+ScannerInfoCollector.Processing=Processing discovered scanner configuration ...
+ScannerInfoCollector.Updating=Updating Scanner Configuration for project
+
+DiscoveredPathManager.File_Error_Message=Error accessing scanner config file for project
+DiscoveredPathManager.Info_Not_Serializable=Error persisting discovered scanner config
+
+GCCScannerConfigUtil.Error_Message=Error creating specs file
+
+ConsoleParser.Filename_Missing_Error_Message=CDT Path Discovery is unable to determine source file name in build command:
+ConsoleParser.Ambiguous_Filepath_Error_Message=CDT Path Discovery is unable to resolve ambiguous file path:
+ConsoleParser.Working_Directory_Error_Message=CDT Path Discovery is unable to determine working directory of the build command
+ConsoleParser.Nonexistent_Include_Path_Error_Message=CDT Path Discovery has discovered and will ignore a non-existent include path:
+
+DiscoveredContainer.description=Discovered Paths
+DiscoveredContainer.ScopeErrorMessage=Invalid scanner configuration discovery profile scope
+
+CygpathTranslator.NotAvailableErrorMessage=Error launching 'cygpath' command
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/PreferenceInitializer.java
index 937bbeab521..cb7c42ea155 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/PreferenceInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * Copyright (c) 2004, 2007 QNX Software Systems 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
@@ -8,17 +8,13 @@
* Contributors:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.internal.core;
+package org.eclipse.cdt.newmake.internal.core;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
-import org.eclipse.cdt.make.core.MakeBuilder;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
@@ -30,7 +26,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
- IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
+/* IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
try {
info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make"); //$NON-NLS-1$
info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, ""); //$NON-NLS-1$
@@ -48,9 +44,9 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
} catch (CoreException e) {
}
MakeCorePlugin.getDefault().getPluginPreferences().setDefault(CCorePlugin.PREF_BINARY_PARSER, CCorePlugin.PLUGIN_ID + ".ELF"); //$NON-NLS-1$
-
+*/
// default plugin preferences for scanner configuration discovery
- IScannerConfigBuilderInfo scInfo = MakeCorePlugin.createScannerConfigBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), ScannerConfigBuilder.BUILDER_ID, true);
+ IScannerConfigBuilderInfo scInfo = ManagedBuilderCorePlugin.createScannerConfigBuildInfo(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), ScannerConfigBuilder.BUILDER_ID, true);
try {
scInfo.setAutoDiscoveryEnabled(true);
scInfo.setMakeBuilderConsoleParserEnabled(true);
@@ -58,15 +54,15 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
scInfo.setUseDefaultESIProviderCmd(true);
scInfo.setESIProviderCommand(new Path("gcc")); //$NON-NLS-1$
scInfo.setESIProviderArguments("-E -P -v -dD ${plugin_state_location}/${specs_file}"); //$NON-NLS-1$
- scInfo.setESIProviderConsoleParserId(MakeCorePlugin.GCC_SPECS_CONSOLE_PARSER_ID);
- scInfo.setMakeBuilderConsoleParserId(MakeCorePlugin.GCC_SCANNER_INFO_CONSOLE_PARSER_ID);
+ scInfo.setESIProviderConsoleParserId(ManagedBuilderCorePlugin.GCC_SPECS_CONSOLE_PARSER_ID);
+ scInfo.setMakeBuilderConsoleParserId(ManagedBuilderCorePlugin.GCC_SCANNER_INFO_CONSOLE_PARSER_ID);
scInfo.setSIProblemGenerationEnabled(true);
} catch (CoreException e) {
}
// default plugin preferences for new scanner configuration discovery
IScannerConfigBuilderInfo2 scInfo2 = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2(MakeCorePlugin.getDefault().getPluginPreferences(),
+ createScannerConfigBuildInfo2(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(),
ScannerConfigProfileManager.NULL_PROFILE_ID, true);
scInfo2.setAutoDiscoveryEnabled(true);
scInfo2.setProblemReportingEnabled(true);
@@ -87,7 +83,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
}
// Store default for makefile
- MakeCorePlugin.getDefault().getPluginPreferences().setDefault(MakeCorePlugin.MAKEFILE_STYLE, "GNU"); //$NON-NLS-1$
+// ManagedBuilderCorePlugin.getDefault().getPluginPreferences().setDefault(MakeCorePluginMigration.MAKEFILE_STYLE, "GNU"); //$NON-NLS-1$
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java
new file mode 100644
index 00000000000..9a135ba8a8e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/StreamMonitor.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 QNX Software Systems 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:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.newmake.internal.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class StreamMonitor extends OutputStream {
+
+ IProgressMonitor monitor;
+ OutputStream console;
+ public final int fTotalWork;
+ private int halfWay;
+ private int currentIncrement = 2;
+ private int nextProgress = currentIncrement;
+ private int worked = 0;
+
+ public StreamMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
+ monitor = mon;
+ console = cos;
+ fTotalWork = totalWork;
+ halfWay = fTotalWork / 2;
+ monitor.beginTask("", fTotalWork); //$NON-NLS-1$
+ }
+
+ private void progressUpdate() {
+ if (--nextProgress <= 0) {
+ //we have exhausted the current increment, so report progress
+ if (fTotalWork > worked) {
+ monitor.worked(1);
+ }
+ worked++;
+ if (worked >= halfWay) {
+ //we have passed the current halfway point, so double the
+ //increment and reset the halfway point.
+ currentIncrement *= 2;
+ halfWay += (fTotalWork - halfWay) / 2;
+ }
+ //reset the progress counter to another full increment
+ nextProgress = currentIncrement;
+ }
+ }
+ /**
+ * @see java.io.OutputStream#close()
+ */
+ public void close() throws IOException {
+ if (console != null) {
+ console.close();
+ }
+ monitor.done();
+ }
+
+ /**
+ * @see java.io.OutputStream#flush()
+ */
+ public void flush() throws IOException {
+ if (console != null) {
+ console.flush();
+ }
+ }
+
+ /**
+ * @see java.io.OutputStream#write(int)
+ */
+ public synchronized void write(int b) throws IOException {
+ if (console != null) {
+ console.write(b);
+ }
+ progressUpdate();
+ }
+
+ /**
+ * @see java.io.OutputStream#write(...)
+ */
+ public synchronized void write(byte[] b, int off, int len) throws IOException {
+ if (b == null) {
+ throw new NullPointerException();
+ } else if (off != 0 || (len < 0) || (len > b.length)) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return;
+ }
+ if (console != null) {
+ console.write(b, off, len);
+ }
+ progressUpdate();
+ }
+
+ public int getWorkDone() {
+ return worked;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties
index ba53c4c92b0..b6b20e848ff 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2006 Texas Instruments Inc. and others.
+# Copyright (c) 2005, 2007 Texas Instruments Inc. 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
@@ -45,6 +45,11 @@ ConfigName.Dbg=Debug
ToolChainName.Rel=GCC Tool Chain
ToolChainName.Dbg=GCC Tool Chain
+ToolChainName.Linux=GCC Tool Chain (Linux)
+ToolChainName.Win32=GCC Tool Chain (Windows)
+ToolChainName.Macosx=GCC Tool Chain (Macosx)
+ToolChainName.Solaris=GCC Tool Chain (Solaris)
+
# Generic platform names
PlatformName.Rel=Release Platform
PlatformName.Dbg=Debug Platform
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml
index 566d814eddc..6d09ddda85a 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml
@@ -9,14 +9,21 @@
name="Managed Build Tools Description"
point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
<managedBuildRevision
- fileVersion="3.1.0">
+ fileVersion="4.0.0">
</managedBuildRevision>
<tool
natureFilter="cnature"
name="%ToolName.linker.gnu.c"
outputFlag="-o"
command="gcc"
- id="cdt.managedbuild.tool.gnu.c.linker">
+ id="cdt.managedbuild.tool.gnu.c.linker"
+ errorParsers="org.eclipse.cdt.core.GLDErrorParser">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
<envVarBuildPath
pathType="buildpathLibrary"
variableList="LIBRARY_PATH">
@@ -125,6 +132,15 @@
command="-shared"
id="gnu.c.link.option.shared"
valueType="boolean">
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="true"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
</option>
<option
name="%Option.Posix.Linker.SOName"
@@ -168,14 +184,40 @@
buildVariable="EXECUTABLES"
nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
id="cdt.managedbuild.tool.gnu.c.linker.output">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="gnu.c.link.option.shared"
+ value="false"/>
+ </enablement>
</outputType>
+ <outputType
+ outputs="so"
+ outputPrefix="lib"
+ nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
+ buildVariable="LIBRARIES"
+ id="cdt.managedbuild.tool.gnu.c.linker.output.so">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="gnu.c.link.option.shared"
+ value="true"/>
+ </enablement>
+ </outputType>
</tool>
<tool
natureFilter="ccnature"
name="%ToolName.linker.gnu.cpp"
outputFlag="-o"
command="g++"
- id="cdt.managedbuild.tool.gnu.cpp.linker">
+ id="cdt.managedbuild.tool.gnu.cpp.linker"
+ errorParsers="org.eclipse.cdt.core.GLDErrorParser">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
<envVarBuildPath
pathType="buildpathLibrary"
variableList="LIBRARY_PATH">
@@ -275,6 +317,15 @@
command="-shared"
valueType="boolean"
id="gnu.cpp.link.option.shared">
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="true"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
</option>
<option
name="%Option.Posix.Linker.SOName"
@@ -318,6 +369,25 @@
buildVariable="EXECUTABLES"
nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
id="cdt.managedbuild.tool.gnu.cpp.linker.output">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="gnu.cpp.link.option.shared"
+ value="false"/>
+ </enablement>
+ </outputType>
+ <outputType
+ outputs="so"
+ outputPrefix="lib"
+ nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
+ buildVariable="LIBRARIES"
+ id="cdt.managedbuild.tool.gnu.cpp.linker.output.so">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="gnu.cpp.link.option.shared"
+ value="true"/>
+ </enablement>
</outputType>
</tool>
<tool
@@ -326,6 +396,11 @@
name="%ToolName.archiver.gnu"
command="ar"
id="cdt.managedbuild.tool.gnu.archiver">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </property>
+ </supportedProperties>
<optionCategory
owner="cdt.managedbuild.tool.gnu.archiver"
name="%OptionCategory.General"
@@ -430,7 +505,8 @@
name="%ToolName.assembler.gnu"
outputFlag="-o"
id="cdt.managedbuild.tool.gnu.assembler"
- natureFilter="both">
+ natureFilter="both"
+ errorParsers="org.eclipse.cdt.core.GASErrorParser">
<optionCategory
owner="cdt.managedbuild.tool.gnu.assembler"
name="%OptionCategory.General"
@@ -480,7 +556,14 @@
outputFlag="-o"
command="gcc"
commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}"
- id="cdt.managedbuild.tool.macosx.c.linker">
+ id="cdt.managedbuild.tool.macosx.c.linker"
+ errorParsers="org.eclipse.cdt.core.GLDErrorParser">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
<envVarBuildPath
pathType="buildpathLibrary"
variableList="LIBRARY_PATH">
@@ -498,6 +581,15 @@
command="-nostartfiles"
id="macosx.c.link.option.nostart"
valueType="boolean">
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="true"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
</option>
<option
defaultValue="false"
@@ -506,6 +598,15 @@
command="-nodefaultlibs"
id="macosx.c.link.option.nodeflibs"
valueType="boolean">
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="true"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
</option>
<option
defaultValue="false"
@@ -589,6 +690,15 @@
command="-dynamiclib"
id="macosx.c.link.option.shared"
valueType="boolean">
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="true"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
</option>
<inputType
sourceContentType="org.eclipse.cdt.managedbuilder.core.compiledObjectFile"
@@ -611,7 +721,26 @@
buildVariable="EXECUTABLES"
nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
id="cdt.managedbuild.tool.macosx.c.linker.output">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="macosx.c.link.option.shared"
+ value="false"/>
+ </enablement>
</outputType>
+ <outputType
+ outputs="dylib"
+ outputPrefix="lib"
+ nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
+ buildVariable="LIBRARIES"
+ id="cdt.managedbuild.tool.macosx.c.linker.output.so">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="macosx.c.link.option.shared"
+ value="true"/>
+ </enablement>
+ </outputType>
</tool>
<tool
natureFilter="ccnature"
@@ -619,7 +748,14 @@
outputFlag="-o"
command="g++"
commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}"
- id="cdt.managedbuild.tool.macosx.cpp.linker">
+ id="cdt.managedbuild.tool.macosx.cpp.linker"
+ errorParsers="org.eclipse.cdt.core.GLDErrorParser">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
<envVarBuildPath
pathType="buildpathLibrary"
variableList="LIBRARY_PATH">
@@ -719,6 +855,15 @@
command="-dynamiclib"
valueType="boolean"
id="macosx.cpp.link.option.shared">
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="true"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
</option>
<inputType
sourceContentType="org.eclipse.cdt.managedbuilder.core.compiledObjectFile"
@@ -741,6 +886,25 @@
buildVariable="EXECUTABLES"
nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
id="cdt.managedbuild.tool.macosx.cpp.linker.output">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="macosx.cpp.link.option.shared"
+ value="false"/>
+ </enablement>
+ </outputType>
+ <outputType
+ outputs="dylib"
+ outputPrefix="lib"
+ nameProvider="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuLinkOutputNameProvider"
+ buildVariable="LIBRARIES"
+ id="cdt.managedbuild.tool.macosx.cpp.linker.output.so">
+ <enablement
+ type="ALL">
+ <checkOption
+ optionId="macosx.cpp.link.option.shared"
+ value="true"/>
+ </enablement>
</outputType>
</tool>
@@ -750,7 +914,14 @@
isAbstract="true"
command="gcc"
natureFilter="both"
- outputFlag="-o">
+ outputFlag="-o"
+ errorParsers="org.eclipse.cdt.core.GCCErrorParser">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildType">
+ <value id="org.eclipse.cdt.build.core.buildType.debug"/>
+ <value id="org.eclipse.cdt.build.core.buildType.release"/>
+ </property>
+ </supportedProperties>
<envVarBuildPath
pathType="buildpathInclude"
variableList="CPATH,C_INCLUDE_PATH">
@@ -840,6 +1011,25 @@
command="-O3"
id="gnu.c.optimization.level.most">
</enumeratedOptionValue>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="gnu.c.optimization.level.most"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.release"/>
+ </enablement>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="defaultValue"
+ value="gnu.c.optimization.level.none"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.debug"/>
+ </enablement>
+
</option>
<option
name="%Option.Posix.Optimize.Flags"
@@ -879,6 +1069,25 @@
command="-g3"
id="gnu.c.debugging.level.max">
</enumeratedOptionValue>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="value"
+ value="gnu.c.debugging.level.none"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.release"/>
+ </enablement>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="value"
+ value="gnu.c.debugging.level.max"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.debug"/>
+ </enablement>
+
</option>
<option
name="%Option.Posix.Debug.Other"
@@ -989,7 +1198,9 @@
dependencyContentType="org.eclipse.cdt.core.cHeader"
dependencyExtensions="h"
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2"
- id="cdt.managedbuild.tool.gnu.c.compiler.input">
+ id="cdt.managedbuild.tool.gnu.c.compiler.input"
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"
+ languageId="org.eclipse.cdt.core.gcc">
</inputType>
<outputType
outputs="o"
@@ -1003,7 +1214,14 @@
isAbstract="true"
command="g++"
natureFilter="ccnature"
- outputFlag="-o">
+ outputFlag="-o"
+ errorParsers="org.eclipse.cdt.core.GCCErrorParser">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildType">
+ <value id="org.eclipse.cdt.build.core.buildType.debug"/>
+ <value id="org.eclipse.cdt.build.core.buildType.release"/>
+ </property>
+ </supportedProperties>
<envVarBuildPath
pathType="buildpathInclude"
variableList="CPATH,CPLUS_INCLUDE_PATH">
@@ -1087,6 +1305,24 @@
command="-O3"
id="gnu.cpp.compiler.optimization.level.most">
</enumeratedOptionValue>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="value"
+ value="gnu.cpp.compiler.optimization.level.most"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.release"/>
+ </enablement>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="value"
+ value="gnu.cpp.compiler.optimization.level.none"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.debug"/>
+ </enablement>
</option>
<option
name="%Option.Posix.Optimize.Flags"
@@ -1126,6 +1362,25 @@
command="-g3"
id="gnu.cpp.compiler.debugging.level.max">
</enumeratedOptionValue>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="value"
+ value="gnu.cpp.compiler.debugging.level.none"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.release"/>
+ </enablement>
+ <enablement
+ type="CONTAINER_ATTRIBUTE"
+ attribute="value"
+ value="gnu.cpp.compiler.debugging.level.max"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildType"
+ value="org.eclipse.cdt.build.core.buildType.debug"/>
+ </enablement>
+
</option>
<option
name="%Option.Posix.Debug.Other"
@@ -1228,7 +1483,9 @@
dependencyContentType="org.eclipse.cdt.core.cxxHeader"
dependencyExtensions="h,H,hpp"
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2"
- id="cdt.managedbuild.tool.gnu.cpp.compiler.input">
+ id="cdt.managedbuild.tool.gnu.cpp.compiler.input"
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"
+ languageId="org.eclipse.cdt.core.g++">
</inputType>
<outputType
outputs="o"
@@ -1250,6 +1507,11 @@
superClass="cdt.managedbuild.tool.gnu.c.linker.output"
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.output">
</outputType>
+ <outputType
+ outputs="dll,a.dll"
+ buildVariable="LIBRARIES"
+ id="cdt.managedbuild.tool.gnu.c.linker.cygwin.output.so">
+ </outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin"
@@ -1264,6 +1526,12 @@
superClass="cdt.managedbuild.tool.gnu.cpp.linker.output"
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.output">
</outputType>
+ <outputType
+ outputs="dll,a.dll"
+ buildVariable="LIBRARIES"
+ id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.output.so">
+ </outputType>
+
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin"
@@ -1273,6 +1541,10 @@
variableList="CPATH,C_INCLUDE_PATH"
buildPathResolver="org.eclipse.cdt.managedbuilder.gnu.cygwin.CygwinPathResolver">
</envVarBuildPath>
+ <inputType
+ id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.input"
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin"
@@ -1282,13 +1554,17 @@
variableList="CPATH,CPLUS_INCLUDE_PATH"
buildPathResolver="org.eclipse.cdt.managedbuilder.gnu.cygwin.CygwinPathResolver">
</envVarBuildPath>
+ <inputType
+ id="cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin"
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"
+ scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"/>
</tool>
<builder
isAbstract="true"
id="cdt.managedbuild.target.gnu.builder"
command="make"
- arguments="-k"
+ arguments=""
variableFormat="${=}"
isVariableCaseSensitive="true"
reservedMacroNames="ROOT,DEPS,OBJS,.*_SRCS,EXECUTABLES,SUBDIRS,LIBS,USER_OBJS,.*_INPUTS,.*_OUTPUTS"
@@ -1302,149 +1578,443 @@
macroOutputFileExtValue="$(suffix $(notdir $@))"
macroOutputFileBaseNameValue="$(basename $(notdir $@))"
macroOutputFileRelPathValue="$@"
- macroOutputDirRelPathValue="$(dir $@)">
- </builder>
-
+ macroOutputDirRelPathValue="$(dir $@)"
+ autoBuildTarget="all"
+ incrementalBuildTarget="all"
+ cleanBuildTarget="clean"
+ ignoreErrCmd="-k"
+ parallelBuildCmd="-j*"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser"
+ name="Gnu Make Builder">
+ </builder>
+
+ <toolChain
+ archList="all"
+ osList="linux,hpux,aix,qnx"
+ name="%ToolChainName.Linux"
+ targetTool="cdt.managedbuild.tool.gnu.c.linker;cdt.managedbuild.tool.gnu.cpp.linker;cdt.managedbuild.tool.gnu.archiver"
+ id="cdt.managedbuild.toolchain.gnu.base">
+ <targetPlatform
+ id="cdt.managedbuild.target.gnu.platform.base"
+ name="%PlatformName.Dbg"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ osList="linux,hpux,aix,qnx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ superClass="cdt.managedbuild.target.gnu.builder"
+ id="cdt.managedbuild.target.gnu.builder.base">
+ </builder>
+ <tool
+ id="cdt.managedbuild.tool.gnu.archiver.base"
+ superClass="cdt.managedbuild.tool.gnu.archiver">
+ <enablement
+ type="ALL">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.cpp.compiler.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.c.compiler.base"
+ superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.c.linker.base"
+ superClass="cdt.managedbuild.tool.gnu.c.linker">
+ <enablement
+ type="ALL">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.cpp.linker.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker">
+ <enablement
+ type="ALL">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.assembler.base"
+ superClass="cdt.managedbuild.tool.gnu.assembler">
+ </tool>
+ </toolChain>
+
+ <toolChain
+ archList="all"
+ osList="win32"
+ name="%ToolChainName.Win32"
+ configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
+ targetTool="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base;cdt.managedbuild.tool.gnu.c.linker.cygwin.base;cdt.managedbuild.tool.gnu.archiver"
+ id="cdt.managedbuild.toolchain.gnu.cygwin.base">
+ <targetPlatform
+ id="cdt.managedbuild.target.gnu.platform.cygwin.base"
+ name="%PlatformName.Dbg"
+ binaryParser="org.eclipse.cdt.core.PE"
+ osList="win32"
+ archList="all">
+ </targetPlatform>
+ <builder
+ superClass="cdt.managedbuild.target.gnu.builder"
+ id="cdt.managedbuild.target.gnu.builder.cygwin.base">
+ </builder>
+
+ <tool
+ id="cdt.managedbuild.tool.gnu.assembler.cygwin.base"
+ superClass="cdt.managedbuild.tool.gnu.assembler">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.archiver.cygwin.base"
+ superClass="cdt.managedbuild.tool.gnu.archiver">
+ <enablement
+ type="ALL">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base"
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.c.linker.cygwin.base"
+ superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
+ <enablement
+ type="ALL">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
+ <enablement
+ type="ALL">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+
+ </toolChain>
+
+ <toolChain
+ archList="all"
+ osList="macosx"
+ name="%ToolChainName.Macosx"
+ targetTool="cdt.managedbuild.tool.macosx.c.linker.macosx.base;cdt.managedbuild.tool.macosx.cpp.linker.macosx.base;cdt.managedbuild.tool.gnu.archiver"
+ id="cdt.managedbuild.toolchain.gnu.macosx.base">
+ <targetPlatform
+ id="cdt.managedbuild.target.gnu.platform.macosx.base"
+ name="%PlatformName.Dbg"
+ binaryParser="org.eclipse.cdt.core.MachO"
+ osList="macosx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ superClass="cdt.managedbuild.target.gnu.builder"
+ id="cdt.managedbuild.target.gnu.builder.macosx.base">
+ </builder>
+
+ <tool
+ id="cdt.managedbuild.tool.macosx.c.linker.macosx.base"
+ superClass="cdt.managedbuild.tool.macosx.c.linker">
+ <enablement
+ type="CMD_USAGE">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base"
+ superClass="cdt.managedbuild.tool.macosx.cpp.linker">
+ <enablement
+ type="CMD_USAGE">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.assembler.macosx.base"
+ superClass="cdt.managedbuild.tool.gnu.assembler">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.archiver.macosx.base"
+ superClass="cdt.managedbuild.tool.gnu.archiver">
+ <enablement
+ type="ALL">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.c.compiler.macosx.base"
+ superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ </tool>
+ </toolChain>
+
+ <!--toolChain
+ name="%ToolChainName.Solaris"
+ targetTool="cdt.managedbuild.tool.gnu.solaris.cpp.linker.base;cdt.managedbuild.tool.gnu.solaris.c.linker.base"
+ archList="all"
+ osList="solaris"
+ id="cdt.managedbuild.toolchain.gnu.solaris.base">
+ <targetPlatform
+ id="cdt.managedbuild.target.gnu.solaris.base"
+ name="%PlatformName.Dbg"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ osList="solaris"
+ archList="all">
+ </targetPlatform>
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"
+ commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.c.compiler.base"
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base"
+ commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.archiver.base"
+ superClass="cdt.managedbuild.tool.gnu.archiver">
+ <enablement
+ type="ALL">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.c.linker.base"
+ superClass="cdt.managedbuild.tool.gnu.c.linker">
+ <enablement
+ type="ALL">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.cpp.linker.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker">
+ <enablement
+ type="ALL">
+ <not>
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </not>
+ </enablement>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.assembler.base"
+ superClass="cdt.managedbuild.tool.gnu.assembler">
+ </tool>
+
+ </toolChain-->
+
+ <toolChain
+ archList="all"
+ osList="solaris"
+ id="cdt.managedbuild.toolchain.gnu.solaris.base"
+ name="%ToolChainName.Solaris"
+ superClass="cdt.managedbuild.toolchain.gnu.base">
+ <targetPlatform
+ id="cdt.managedbuild.target.gnu.solaris.base"
+ name="%PlatformName.Dbg"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ osList="solaris"
+ archList="all">
+ </targetPlatform>
+ <builder
+ superClass="cdt.managedbuild.target.gnu.builder"
+ id="cdt.managedbuild.target.gnu.builder.solaris.base">
+ </builder>
+
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base"
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"
+ commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.gnu.solaris.c.compiler.base"
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base"
+ commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ </tool>
+ </toolChain>
+
+ <configuration
+ id="cdt.managedbuild.config.gnu.base"
+ cleanCommand="rm -rf"
+ >
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="so"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="a"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </configuration>
+
<projectType
isAbstract="false"
isTest="false"
- name="%TargetName.gnu.exe"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe"
id="cdt.managedbuild.target.gnu.exe">
<configuration
name="%ConfigName.Dbg"
id="cdt.managedbuild.config.gnu.exe.debug"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
+ parent="cdt.managedbuild.config.gnu.base"
+ cleanCommand="rm -rf">
<toolChain
- archList="all"
- osList="linux,hpux,aix,qnx"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.exe.debug;cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.base"
id="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.exe.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="linux,hpux,aix,qnx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.exe.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.base"
+ id="cdt.managedbuild.target.gnu.builder.exe.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
- <option
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+ <option
id="gnu.cpp.compiler.exe.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.exe.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
- </option>
+ </option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option
id="gnu.c.compiler.exe.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.exe.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.c.linker">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
id="cdt.managedbuild.config.gnu.exe.release"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
+ parent="cdt.managedbuild.config.gnu.base"
+ cleanCommand="rm -rf">
<toolChain
- archList="all"
- osList="linux,hpux,aix,qnx"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.exe.release;cdt.managedbuild.tool.gnu.cpp.linker.exe.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.base"
id="cdt.managedbuild.toolchain.gnu.exe.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.exe.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="linux,hpux,aix,qnx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.exe.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.base"
+ id="cdt.managedbuild.target.gnu.builder.exe.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option
id="gnu.cpp.compiler.exe.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.exe.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.exe.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option
id="gnu.c.compiler.exe.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.exe.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.exe.release"
- superClass="cdt.managedbuild.tool.gnu.c.linker">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.exe.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.base">
</tool>
</toolChain>
</configuration>
@@ -1453,193 +2023,147 @@
<projectType
isAbstract="false"
isTest="false"
- name="%TargetName.gnu.so"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib"
id="cdt.managedbuild.target.gnu.so">
<configuration
name="%ConfigName.Dbg"
cleanCommand="rm -rf"
- artifactExtension="so"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
+ parent="cdt.managedbuild.config.gnu.base"
id="cdt.managedbuild.config.gnu.so.debug">
<toolChain
- archList="all"
- osList="linux,hpux,aix,qnx"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.so.debug;cdt.managedbuild.tool.gnu.cpp.linker.so.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.base"
id="cdt.managedbuild.toolchain.gnu.so.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.so.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="linux,hpux,aix,qnx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.so.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.base"
+ id="cdt.managedbuild.target.gnu.builder.so.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option
id="gnu.cpp.compiler.so.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.so.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.so.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option
id="gnu.c.compiler.so.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.so.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.so.debug"
- superClass="cdt.managedbuild.tool.gnu.c.linker">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.base">
<option
id="gnu.c.link.so.debug.option.shared"
- defaultValue="true"
superClass="gnu.c.link.option.shared">
</option>
<outputType
- outputs="so"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.c.linker.output"
+ superClass="cdt.managedbuild.tool.gnu.c.linker.output.so"
id="cdt.managedbuild.tool.gnu.c.linker.so.debug.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
<option
id="gnu.cpp.link.so.debug.option.shared"
- defaultValue="true"
superClass="gnu.cpp.link.option.shared">
</option>
<outputType
- outputs="so"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.output"
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.output.so"
id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.so.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
cleanCommand="rm -rf"
- artifactExtension="so"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
+ parent="cdt.managedbuild.config.gnu.base"
id="cdt.managedbuild.config.gnu.so.release">
<toolChain
- archList="all"
- osList="linux,hpux,aix,qnx"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.so.release;cdt.managedbuild.tool.gnu.cpp.linker.so.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.base"
id="cdt.managedbuild.toolchain.gnu.so.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.so.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="linux,hpux,aix,qnx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.so.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.base"
+ id="cdt.managedbuild.target.gnu.builder.so.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option
id="gnu.cpp.compiler.so.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.so.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.so.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option
id="gnu.c.compiler.so.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.so.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.so.release"
- superClass="cdt.managedbuild.tool.gnu.c.linker">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.base">
<option
id="gnu.c.link.so.release.option.shared"
- defaultValue="true"
superClass="gnu.c.link.option.shared">
</option>
<outputType
- outputs="so"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.c.linker.output"
+ superClass="cdt.managedbuild.tool.gnu.c.linker.output.so"
id="cdt.managedbuild.tool.gnu.c.linker.so.release.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.so.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
<option
id="gnu.cpp.link.so.release.option.shared"
- defaultValue="true"
superClass="gnu.cpp.link.option.shared">
</option>
<outputType
- outputs="so"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.output"
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.output.so"
id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.so.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.base">
</tool>
</toolChain>
</configuration>
@@ -1647,1185 +2171,991 @@
<projectType
isTest="false"
- name="%TargetName.gnu.lib"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib"
isAbstract="false"
id="cdt.managedbuild.target.gnu.lib">
<configuration
name="%ConfigName.Dbg"
- artifactExtension="a"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
+ parent="cdt.managedbuild.config.gnu.base"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
id="cdt.managedbuild.config.gnu.lib.debug">
<toolChain
- archList="all"
- osList="linux,hpux,aix,qnx"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.gnu.archiver.lib.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.base"
id="cdt.managedbuild.toolchain.gnu.lib.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.lib.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="linux,hpux,aix,qnx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.lib.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.base"
+ id="cdt.managedbuild.target.gnu.builder.lib.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option
id="gnu.cpp.compiler.lib.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.lib.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option
id="gnu.c.compiler.lib.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.lib.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.archiver.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.archiver">
+ superClass="cdt.managedbuild.tool.gnu.archiver.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
- artifactExtension="a"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
+ parent="cdt.managedbuild.config.gnu.base"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.gnu.lib.release">
+ id="cdt.managedbuild.config.gnu.lib.release">
<toolChain
- archList="all"
- osList="linux,hpux,aix,qnx"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.gnu.archiver.lib.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.base"
id="cdt.managedbuild.toolchain.gnu.lib.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.lib.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="linux,hpux,aix,qnx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.lib.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.base"
+ id="cdt.managedbuild.target.gnu.builder.lib.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option
id="gnu.cpp.compiler.lib.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.lib.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.lib.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option
id="gnu.c.compiler.lib.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.lib.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.archiver.lib.release"
- superClass="cdt.managedbuild.tool.gnu.archiver">
+ superClass="cdt.managedbuild.tool.gnu.archiver.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.lib.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.base">
</tool>
</toolChain>
</configuration>
</projectType>
+ <configuration
+ id="cdt.managedbuild.config.gnu.cygwin.base"
+ cleanCommand="rm -rf"
+ artifactExtension="exe"
+ >
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="dll"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="a"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </configuration>
+
<projectType
- name="%TargetName.cygw.exe"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe"
id="cdt.managedbuild.target.gnu.cygwin.exe"
isTest="false"
isAbstract="false">
<configuration
name="%ConfigName.Dbg"
- artifactExtension="exe"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.gnu.cygwin.exe.debug">
+ id="cdt.managedbuild.config.gnu.cygwin.exe.debug"
+ parent="cdt.managedbuild.config.gnu.cygwin.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug">
<toolChain
- archList="all"
- osList="win32"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug;cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
- configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
+ superClass="cdt.managedbuild.toolchain.gnu.cygwin.base"
id="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.PE"
- osList="win32"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.cygwin.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
- </builder>
+ superClass="cdt.managedbuild.target.gnu.builder.cygwin.base"
+ id="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug">
+ </builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base">
<option
id="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base">
<option
id="gnu.c.compiler.cygwin.exe.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.cygwin.exe.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
- artifactExtension="exe"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.gnu.cygwin.exe.release">
+ id="cdt.managedbuild.config.gnu.cygwin.exe.release"
+ parent="cdt.managedbuild.config.gnu.cygwin.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release">
<toolChain
- archList="all"
- osList="win32"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release;cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
- configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
+ superClass="cdt.managedbuild.toolchain.gnu.cygwin.base"
id="cdt.managedbuild.toolchain.gnu.cygwin.exe.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.cygwin.exe.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.PE"
- osList="win32"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.cygwin.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.cygwin.exe.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.cygwin.base"
+ id="cdt.managedbuild.target.gnu.builder.cygwin.exe.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base">
<option
id="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base">
<option
id="gnu.c.compiler.cygwin.exe.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.cygwin.exe.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release"
- superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.base">
</tool>
</toolChain>
</configuration>
</projectType>
<projectType
- name="%TargetName.cygw.so"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib"
id="cdt.managedbuild.target.gnu.cygwin.so"
isAbstract="false"
isTest="false">
<configuration
name="%ConfigName.Dbg"
cleanCommand="rm -rf"
- artifactExtension="dll"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ parent="cdt.managedbuild.config.gnu.cygwin.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
id="cdt.managedbuild.config.gnu.cygwin.so.debug">
<toolChain
- archList="all"
- osList="win32"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.debug;cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
- configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
+ superClass="cdt.managedbuild.toolchain.gnu.cygwin.base"
id="cdt.managedbuild.toolchain.gnu.cygwin.so.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.cygwin.so.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.PE"
- osList="win32"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.cygwin.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.cygwin.so.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.cygwin.base"
+ id="cdt.managedbuild.target.gnu.builder.cygwin.so.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.so.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base">
<option
id="gnu.cpp.compiler.cygwin.so.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.cygwin.so.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.so.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base">
<option
id="gnu.c.compiler.cygwin.so.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.cygwin.so.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.debug"
- superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.base">
<option
id="gnu.c.link.cygwin.so.debug.option.shared"
- defaultValue="true"
superClass="gnu.c.link.option.shared">
</option>
<outputType
- outputs="dll,a.dll"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.output"
+ superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.output.so"
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.debug.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base">
<option
id="gnu.cpp.link.cygwin.so.debug.option.shared"
- defaultValue="true"
superClass="gnu.cpp.link.option.shared">
</option>
<outputType
- outputs="dll,a.dll"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.output"
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.output.so"
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.debug.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.cygwin.so.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
cleanCommand="rm -rf"
- artifactExtension="dll"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ parent="cdt.managedbuild.config.gnu.cygwin.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
id="cdt.managedbuild.config.gnu.cygwin.so.release">
<toolChain
- archList="all"
- osList="win32"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.release;cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
- configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
+ superClass="cdt.managedbuild.toolchain.gnu.cygwin.base"
id="cdt.managedbuild.toolchain.gnu.cygwin.so.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.cygwin.so.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.PE"
- osList="win32"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.cygwin.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.cygwin.so.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.cygwin.base"
+ id="cdt.managedbuild.target.gnu.builder.cygwin.so.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.so.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base">
<option
id="gnu.cpp.compiler.cygwin.so.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.cygwin.so.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.so.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base">
<option
id="gnu.c.compiler.cygwin.so.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.cygwin.so.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.release"
- superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.base">
<option
id="gnu.c.link.cygwin.so.release.option.shared"
- defaultValue="true"
superClass="gnu.c.link.option.shared">
</option>
<outputType
- outputs="dll,a.dll"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.output"
+ superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.output.so"
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.release.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base">
<option
id="gnu.cpp.link.cygwin.so.release.option.shared"
- defaultValue="true"
superClass="gnu.cpp.link.option.shared">
</option>
<outputType
- outputs="dll,a.dll"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.output"
+ superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.output.so"
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.release.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.cygwin.so.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.base">
</tool>
</toolChain>
</configuration>
</projectType>
<projectType
- name="%TargetName.cygw.lib"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib"
id="cdt.managedbuild.target.gnu.cygwin.lib"
isTest="false"
isAbstract="false">
<configuration
name="%ConfigName.Dbg"
- artifactExtension="a"
+ parent="cdt.managedbuild.config.gnu.cygwin.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
id="cdt.managedbuild.config.gnu.cygwin.lib.debug">
<toolChain
- archList="all"
- osList="win32"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
- configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
+ superClass="cdt.managedbuild.toolchain.gnu.cygwin.base"
id="cdt.managedbuild.toolchain.gnu.cygwin.lib.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.cygwin.lib.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.PE"
- osList="win32"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.cygwin.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.cygwin.lib.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.cygwin.base"
+ id="cdt.managedbuild.target.gnu.builder.cygwin.lib.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base">
<option
id="gnu.cpp.compiler.cygwin.lib.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.cygwin.lib.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base">
<option
id="gnu.c.compiler.cygwin.lib.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.cygwin.lib.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.archiver">
+ superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.cygwin.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
- artifactExtension="a"
+ parent="cdt.managedbuild.config.gnu.cygwin.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
id="cdt.managedbuild.config.gnu.cygwin.lib.release">
<toolChain
- archList="all"
- osList="win32"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
- configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
+ superClass="cdt.managedbuild.toolchain.gnu.cygwin.base"
id="cdt.managedbuild.toolchain.gnu.cygwin.lib.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.cygwin.lib.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.PE"
- osList="win32"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.cygwin.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.cygwin.lib.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.cygwin.base"
+ id="cdt.managedbuild.target.gnu.builder.cygwin.lib.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base">
<option
id="gnu.cpp.compiler.cygwin.lib.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.cygwin.lib.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base">
<option
id="gnu.c.compiler.cygwin.lib.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.cygwin.lib.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.release"
- superClass="cdt.managedbuild.tool.gnu.archiver">
+ superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.cygwin.lib.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.base">
</tool>
</toolChain>
</configuration>
</projectType>
+ <configuration
+ id="cdt.managedbuild.config.gnu.macosx.base"
+ cleanCommand="rm -rf"
+ >
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="dylib"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="a"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </configuration>
+
<projectType
- name="%TargetName.macosx.exe"
id="cdt.managedbuild.target.macosx.exe"
isTest="false"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe"
isAbstract="false">
<configuration
name="%ConfigName.Dbg"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
+ parent="cdt.managedbuild.config.gnu.macosx.base"
id="cdt.managedbuild.config.gnu.macosx.exe.debug">
<toolChain
- archList="all"
- osList="macosx"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.debug;cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.macosx.base"
id="cdt.managedbuild.toolchain.gnu.macosx.exe.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.macosx.exe.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.MachO"
- osList="macosx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.macosx.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.macosx.exe.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.macosx.base"
+ id="cdt.managedbuild.target.gnu.builder.macosx.exe.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option
id="gnu.cpp.compilermacosx.exe.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.macosx.exe.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.base">
<option
id="gnu.c.compiler.macosx.exe.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.macosx.exe.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.debug"
- superClass="cdt.managedbuild.tool.macosx.c.linker">
+ superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.base">
</tool>
<tool
id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug"
- superClass="cdt.managedbuild.tool.macosx.cpp.linker">
+ superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.macosx.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.macosx.exe.release">
+ id="cdt.managedbuild.config.macosx.exe.release"
+ parent="cdt.managedbuild.config.gnu.macosx.base" >
<toolChain
- archList="all"
- osList="macosx"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.release;cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.gnu.macosx.exe.release">
+ id="cdt.managedbuild.toolchain.gnu.macosx.exe.release"
+ superClass="cdt.managedbuild.toolchain.gnu.macosx.base">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.macosx.exe.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.MachO"
- osList="macosx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.macosx.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.macosx.exe.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.macosx.base"
+ id="cdt.managedbuild.target.gnu.builder.macosx.exe.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option
id="gnu.cpp.compiler.macosx.exe.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.macosx.exe.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.base">
<option
id="gnu.c.compiler.macosx.exe.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.macosx.exe.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.release"
- superClass="cdt.managedbuild.tool.macosx.c.linker">
+ superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.base">
</tool>
<tool
id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.release"
- superClass="cdt.managedbuild.tool.macosx.cpp.linker">
+ superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.macosx.exe.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
</tool>
</toolChain>
</configuration>
</projectType>
<projectType
- name="%TargetName.macosx.so"
id="cdt.managedbuild.target.macosx.so"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib"
isTest="false"
isAbstract="false">
<configuration
name="%ConfigName.Dbg"
- artifactExtension="dylib"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ parent="cdt.managedbuild.config.gnu.macosx.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
id="cdt.managedbuild.config.macosx.so.debug">
<toolChain
- archList="all"
- osList="macosx"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.tool.macosx.c.linker.macosx.so.debug;cdt.managedbuild.tool.macosx.cpp.linker.macosx.so.debug"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
- id="cdt.managedbuild.toolchain.gnu.macosx.so.debug">
+ superClass="cdt.managedbuild.toolchain.gnu.macosx.base"
+ id="cdt.managedbuild.toolchain.gnu.macosx.so.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.macosx.so.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.MachO"
- osList="macosx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.macosx.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.macosx.so.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.macosx.base"
+ id="cdt.managedbuild.target.gnu.builder.macosx.so.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.so.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option
id="gnu.cpp.compiler.macosx.so.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.macosx.so.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.macosx.so.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.base">
<option
id="gnu.c.compiler.macosx.so.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.macosx.so.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.macosx.c.linker.macosx.so.debug"
- superClass="cdt.managedbuild.tool.macosx.c.linker">
+ superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.base">
<option
id="macosx.c.link.macosx.so.debug.option.shared"
- defaultValue="true"
superClass="macosx.c.link.option.shared">
</option>
<option
id="macosx.c.link.macosx.so.debug.option.nostart"
- defaultValue="true"
superClass="macosx.c.link.option.nostart">
</option>
<option
id="macosx.c.link.macosx.so.debug.option.nodeflibs"
- defaultValue="true"
superClass="macosx.c.link.option.nodeflibs">
</option>
<outputType
- outputs="dylib"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.macosx.c.linker.output"
+ superClass="cdt.managedbuild.tool.macosx.c.linker.output.so"
id="cdt.managedbuild.tool.macosx.c.linker.macosx.so.debug.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.so.debug"
- superClass="cdt.managedbuild.tool.macosx.cpp.linker">
+ superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base">
<option
id="macosx.cpp.link.macosx.so.debug.option.shared"
- defaultValue="true"
superClass="macosx.cpp.link.option.shared">
</option>
<outputType
- outputs="dylib"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.macosx.cpp.linker.output"
+ superClass="cdt.managedbuild.tool.macosx.cpp.linker.output.so"
id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.so.debug.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.macosx.so.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
- artifactExtension="dylib"
+ parent="cdt.managedbuild.config.gnu.macosx.base"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
id="cdt.managedbuild.config.macosx.so.release">
<toolChain
- archList="all"
- osList="macosx"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.tool.macosx.c.linker.macosx.so.release;cdt.managedbuild.tool.macosx.cpp.linker.macosx.so.release"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.macosx.base"
id="cdt.managedbuild.toolchain.gnu.macosx.so.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.macosx.so.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.MachO"
- osList="macosx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.macosx.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.macosx.so.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.macosx.base"
+ id="cdt.managedbuild.target.gnu.builder.macosx.so.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.so.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option
id="gnu.cpp.compiler.macosx.so.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.macosx.so.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.macosx.so.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.base">
<option
id="gnu.c.compiler.macosx.so.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.macosx.so.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.macosx.c.linker.macosx.so.release"
- superClass="cdt.managedbuild.tool.macosx.c.linker">
+ superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.base">
<option
id="macosx.c.link.macosx.so.release.option.shared"
- defaultValue="true"
superClass="macosx.c.link.option.shared">
</option>
<option
id="macosx.c.link.macosx.so.release.option.nostart"
- defaultValue="true"
superClass="macosx.c.link.option.nostart">
</option>
<option
id="macosx.c.link.macosx.so.release.option.nodeflibs"
- defaultValue="true"
superClass="macosx.c.link.option.nodeflibs">
</option>
<outputType
- outputs="dylib"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.macosx.c.linker.output"
+ superClass="cdt.managedbuild.tool.macosx.c.linker.output.so"
id="cdt.managedbuild.tool.macosx.c.linker.macosx.so.release.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.so.release"
- superClass="cdt.managedbuild.tool.macosx.cpp.linker">
+ superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base">
<option
id="macosx.cpp.link.macosx.so.release.option.shared"
- defaultValue="true"
superClass="macosx.cpp.link.option.shared">
</option>
<outputType
- outputs="dylib"
- outputPrefix="lib"
- buildVariable="LIBRARIES"
- superClass="cdt.managedbuild.tool.macosx.cpp.linker.output"
+ superClass="cdt.managedbuild.tool.macosx.cpp.linker.output.so"
id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.so.release.output">
</outputType>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.macosx.so.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
</tool>
</toolChain>
</configuration>
</projectType>
<projectType
- name="%TargetName.macosx.lib"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib"
id="cdt.managedbuild.target.macosx.lib"
isTest="false"
isAbstract="false">
<configuration
name="%ConfigName.Dbg"
- artifactExtension="a"
+ parent="cdt.managedbuild.config.gnu.macosx.base"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
id="cdt.managedbuild.config.macosx.lib.debug">
<toolChain
- archList="all"
- osList="macosx"
- name="%ToolChainName.Dbg"
- targetTool="cdt.managedbuild.toolmacosx.lib.debug.gnu.archiver"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.macosx.base"
id="cdt.managedbuild.toolchain.gnu.macosx.lib.debug">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.macosx.lib.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.MachO"
- osList="macosx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.macosx.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.macosx.lib.debug"
- name="%BuilderName.Dbg"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.macosx.base"
+ id="cdt.managedbuild.target.gnu.builder.macosx.lib.debug">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option
id="gnu.cpp.compiler.macosx.lib.debug.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.none"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.macosx.lib.debug.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.max"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.macosx.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.base">
<option
id="gnu.c.compiler.macosx.lib.debug.option.optimization.level"
- defaultValue="gnu.c.optimization.level.none"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.macosx.lib.debug.option.debugging.level"
- defaultValue="gnu.c.debugging.level.max"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.toolmacosx.lib.debug.gnu.archiver"
- superClass="cdt.managedbuild.tool.gnu.archiver">
+ superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.macosx.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
- artifactExtension="a"
+ parent="cdt.managedbuild.config.gnu.macosx.base"
cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
id="cdt.managedbuild.config.macosx.lib.release">
<toolChain
- archList="all"
- osList="macosx"
- name="%ToolChainName.Rel"
- targetTool="cdt.managedbuild.toolmacosx.lib.release.gnu.archiver"
- scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"
+ superClass="cdt.managedbuild.toolchain.gnu.macosx.base"
id="cdt.managedbuild.toolchain.gnu.macosx.lib.release">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.macosx.lib.release"
- name="%PlatformName.Rel"
- binaryParser="org.eclipse.cdt.core.MachO"
- osList="macosx"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.platform.macosx.base">
</targetPlatform>
<builder
- superClass="cdt.managedbuild.target.gnu.builder"
- id="cdt.managedbuild.target.gnu.builder.macosx.lib.release"
- name="%BuilderName.Rel"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ superClass="cdt.managedbuild.target.gnu.builder.macosx.base"
+ id="cdt.managedbuild.target.gnu.builder.macosx.lib.release">
</builder>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.lib.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
+ superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option
id="gnu.cpp.compiler.macosx.lib.release.option.optimization.level"
- defaultValue="gnu.cpp.compiler.optimization.level.most"
superClass="gnu.cpp.compiler.option.optimization.level">
</option>
<option
id="gnu.cpp.compiler.macosx.lib.release.option.debugging.level"
- defaultValue="gnu.cpp.compiler.debugging.level.none"
superClass="gnu.cpp.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.c.compiler.macosx.lib.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler">
+ superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.base">
<option
id="gnu.c.compiler.macosx.lib.release.option.optimization.level"
- defaultValue="gnu.c.optimization.level.most"
superClass="gnu.c.compiler.option.optimization.level">
</option>
<option
id="gnu.c.compiler.macosx.lib.release.option.debugging.level"
- defaultValue="gnu.c.debugging.level.none"
superClass="gnu.c.compiler.option.debugging.level">
</option>
</tool>
<tool
id="cdt.managedbuild.toolmacosx.lib.release.gnu.archiver"
- superClass="cdt.managedbuild.tool.gnu.archiver">
+ superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.assembler.macosx.lib.release"
- superClass="cdt.managedbuild.tool.gnu.assembler">
+ superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
</tool>
</toolChain>
</configuration>
</projectType>
+ <configuration
+ id="cdt.managedbuild.config.gnu.solaris.base"
+ cleanCommand="rm -rf">
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="so"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </enablement>
+ <enablement type="CONTAINER_ATTRIBUTE"
+ attribute="artifactExtension"
+ value="a"
+ extensionAdjustment="false">
+ <checkBuildProperty
+ property="org.eclipse.cdt.build.core.buildArtefactType"
+ value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/>
+ </enablement>
+ </configuration>
+
<projectType
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe"
isAbstract="false"
isTest="false"
- name="%TargetName.solaris.exe"
id="cdt.managedbuild.target.gnu.solaris.exe">
<configuration
name="%ConfigName.Dbg"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
id="cdt.managedbuild.config.gnu.solaris.exe.debug"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
+ parent="cdt.managedbuild.config.gnu.solaris.base">
<toolChain
- archList="all"
- osList="solaris"
id="cdt.managedbuild.toolchain.gnu.solaris.exe.debug"
- superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
+ superClass="cdt.managedbuild.toolchain.gnu.solaris.base">
<targetPlatform
id="cdt.managedbuild.target.gnu.solaris.platform.exe.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.solaris.base">
</targetPlatform>
<tool
id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.solaris.c.compiler.exe.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.c.compiler.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
id="cdt.managedbuild.config.gnu.solaris.exe.release"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
+ parent="cdt.managedbuild.config.gnu.solaris.base">
<toolChain
- archList="all"
- osList="solaris"
id="cdt.managedbuild.toolchain.gnu.solaris.exe.release"
- superClass="cdt.managedbuild.toolchain.gnu.exe.release">
+ superClass="cdt.managedbuild.toolchain.gnu.solaris.base">
<targetPlatform
id="cdt.managedbuild.target.gnu.solaris.platform.exe.release"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.solaris.base">
</targetPlatform>
<tool
id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.exe.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.solaris.c.compiler.exe.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.c.compiler.base">
</tool>
</toolChain>
</configuration>
@@ -2834,65 +3164,49 @@
<projectType
isAbstract="false"
isTest="false"
- name="%TargetName.solaris.so"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib"
id="cdt.managedbuild.target.gnu.solaris.so">
<configuration
name="%ConfigName.Dbg"
- cleanCommand="rm -rf"
- artifactExtension="so"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
+ parent="cdt.managedbuild.config.gnu.solaris.base"
id="cdt.managedbuild.config.gnu.solaris.so.debug">
<toolChain
- archList="all"
- osList="solaris"
id="cdt.managedbuild.toolchain.gnu.solaris.so.debug"
- superClass="cdt.managedbuild.toolchain.gnu.so.debug">
+ superClass="cdt.managedbuild.toolchain.gnu.solaris.base">
<targetPlatform
id="cdt.managedbuild.target.gnu.solaris.platform.so.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.solaris.base">
</targetPlatform>
<tool
id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.so.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.solaris.c.compiler.so.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.c.compiler.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
- cleanCommand="rm -rf"
- artifactExtension="so"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
+ parent="cdt.managedbuild.config.gnu.solaris.base"
id="cdt.managedbuild.config.gnu.solaris.so.release">
<toolChain
- archList="all"
- osList="solaris"
id="cdt.managedbuild.toolchain.gnu.solaris.so.release"
- superClass="cdt.managedbuild.toolchain.gnu.so.release">
+ superClass="cdt.managedbuild.toolchain.gnu.solaris.base">
<targetPlatform
id="cdt.managedbuild.target.gnu.solaris.platform.so.release"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.solaris.base">
</targetPlatform>
<tool
id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.so.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.solaris.c.compiler.so.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.c.compiler.base">
</tool>
</toolChain>
</configuration>
@@ -2900,66 +3214,50 @@
<projectType
isTest="false"
- name="%TargetName.solaris.lib"
+ buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib"
isAbstract="false"
id="cdt.managedbuild.target.gnu.solaris.lib">
<configuration
name="%ConfigName.Dbg"
- artifactExtension="a"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
+ parent="cdt.managedbuild.config.gnu.solaris.base"
id="cdt.managedbuild.config.gnu.solaris.lib.debug">
<toolChain
- archList="all"
- osList="solaris"
id="cdt.managedbuild.toolchain.gnu.solaris.lib.debug"
- superClass="cdt.managedbuild.toolchain.gnu.lib.debug">
+ superClass="cdt.managedbuild.toolchain.gnu.solaris.base">
<targetPlatform
id="cdt.managedbuild.target.gnu.solaris.platform.lib.debug"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.solaris.base">
</targetPlatform>
<tool
id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.solaris.c.compiler.lib.debug"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.debug"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.c.compiler.base">
</tool>
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
- artifactExtension="a"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
+ parent="cdt.managedbuild.config.gnu.solaris.base"
id="cdt.managedbuild.config.gnu.solaris.lib.release">
<toolChain
- archList="all"
- osList="solaris"
id="cdt.managedbuild.toolchain.gnu.solaris.lib.release"
- superClass="cdt.managedbuild.toolchain.gnu.lib.release">
+ superClass="cdt.managedbuild.toolchain.gnu.solaris.base">
<targetPlatform
id="cdt.managedbuild.target.gnu.solaris.platform.lib.release"
- name="%PlatformName.Dbg"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris"
- archList="all">
+ superClass="cdt.managedbuild.target.gnu.solaris.base">
</targetPlatform>
<tool
id="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.lib.release"
- superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.cpp.compiler.base">
</tool>
<tool
id="cdt.managedbuild.tool.gnu.solaris.c.compiler.lib.release"
- superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.release"
- commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}">
+ superClass="cdt.managedbuild.tool.gnu.solaris.c.compiler.base">
</tool>
</toolChain>
</configuration>
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java
index 97cf871679b..5bf386f3b95 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -12,9 +12,10 @@ package org.eclipse.cdt.managedbuilder.gnu.cygwin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
+import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
+
public class GnuCygwinConfigurationEnvironmentSupplier implements
IConfigurationEnvironmentVariableSupplier {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCProjectPlatformPage.java b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCProjectPlatformPage.java
index 2a32540a5fd..bf4e6497be7 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCProjectPlatformPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCProjectPlatformPage.java
@@ -14,9 +14,7 @@ import junit.framework.TestCase;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.ui.wizards.CProjectPlatformPage;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
-import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectWizard;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -25,94 +23,95 @@ import org.eclipse.ui.PlatformUI;
* @author Elias Volanakis
*/
public class TestCProjectPlatformPage extends TestCase {
-
- private NewManagedProjectWizard wizard;
- private TestPage page;
-
- protected void setUp() throws Exception {
- MBSCustomPageManager.init();
- MBSCustomPageManager.loadExtensions();
- wizard = new NewManagedProjectWizard();
- page = new TestPage(wizard);
- wizard.addPages();
- }
-
- protected void tearDown() throws Exception {
- page.dispose();
- page = null;
- wizard = null;
- }
-
-
- // testing methods
- //////////////////
-
- /* Test the new page, set selection, create page lifecycle. */
- public void testSelectedProjectType1() throws Exception {
- page.createControl(getShell());
- final IProjectType type2 = page.getSecondType();
-
- TestPage page2 = new TestPage(wizard);
- page2.setSelectedProjectType(type2);
- page2.createControl(getShell());
- assertEquals(type2, page2.getSelectedProjectType());
- page2.dispose();
- }
-
- /* Test the new page, create page, set selection lifecycle. */
- public void testSelectedProjectType2() throws Exception {
- // test get null
- assertNull(page.getSelectedProjectType());
- // test set null
- page.setSelectedProjectType(null);
- assertNull(page.getSelectedProjectType()); // null, since no UI created
- // create ui
- page.createControl(getShell());
- final IProjectType type1 = page.getFirstType();
-
- // default behavior if selection set to null -> select first item
- assertEquals(type1, page.getSelectedProjectType());
- // set 2nd element from project types list
- final IProjectType type2 = page.getSecondType();
- assertNotNull(type2);
- page.setSelectedProjectType(type2);
- assertEquals(type2, page.getSelectedProjectType());
- }
-
- /*
- * Tests that setting the selection to a projectType thats not on the list,
- * is handled correctly.
- */
- public void testSelectedProjectType3() throws Exception {
- IProjectType testType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu21.so");
- assertNotNull(testType);
- assertTrue(testType.isTestProjectType());
- page.setSelectedProjectType(testType);
- page.createControl(getShell());
- // no selection made
- assertNull(null,page.getSelectedProjectType());
- assertFalse(page.canFlipToNextPage());
- }
-
-
- // helping methods and classes
- //////////////////////////////
-
- private Shell getShell() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
- class TestPage extends CProjectPlatformPage {
- TestPage(NewManagedProjectWizard wizard) throws Exception {
- super(TestCProjectPlatformPage.class.getName(), wizard);
- }
- IProjectType getFirstType() {
- return (IProjectType) projectTypes.get(0);
- }
- IProjectType getSecondType() {
- return (IProjectType) projectTypes.get(1);
- }
- }
+ //TODO: migrate to the new UI functionality
+// private NewManagedProjectWizard wizard;
+// private TestPage page;
+//
+// protected void setUp() throws Exception {
+// MBSCustomPageManager.init();
+// MBSCustomPageManager.loadExtensions();
+// wizard = new NewManagedProjectWizard();
+// page = new TestPage(wizard);
+// wizard.addPages();
+// }
+//
+// protected void tearDown() throws Exception {
+// page.dispose();
+// page = null;
+// wizard = null;
+// }
+//
+//
+// // testing methods
+// //////////////////
+//
+// /* Test the new page, set selection, create page lifecycle. */
+// public void testSelectedProjectType1() throws Exception {
+// page.createControl(getShell());
+// final IProjectType type2 = page.getSecondType();
+//
+// TestPage page2 = new TestPage(wizard);
+// page2.setSelectedProjectType(type2);
+// page2.createControl(getShell());
+// assertEquals(type2, page2.getSelectedProjectType());
+// page2.dispose();
+// }
+//
+// /* Test the new page, create page, set selection lifecycle. */
+// public void testSelectedProjectType2() throws Exception {
+// // test get null
+// assertNull(page.getSelectedProjectType());
+// // test set null
+// page.setSelectedProjectType(null);
+// assertNull(page.getSelectedProjectType()); // null, since no UI created
+//
+// // create ui
+// page.createControl(getShell());
+// final IProjectType type1 = page.getFirstType();
+//
+// // default behavior if selection set to null -> select first item
+// assertEquals(type1, page.getSelectedProjectType());
+// // set 2nd element from project types list
+// final IProjectType type2 = page.getSecondType();
+// assertNotNull(type2);
+// page.setSelectedProjectType(type2);
+// assertEquals(type2, page.getSelectedProjectType());
+// }
+//
+// /*
+// * Tests that setting the selection to a projectType thats not on the list,
+// * is handled correctly.
+// */
+// public void testSelectedProjectType3() throws Exception {
+// IProjectType testType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu21.so");
+// assertNotNull(testType);
+// assertTrue(testType.isTestProjectType());
+// page.setSelectedProjectType(testType);
+// page.createControl(getShell());
+// // no selection made
+// assertNull(null,page.getSelectedProjectType());
+// assertFalse(page.canFlipToNextPage());
+// }
+//
+//
+// // helping methods and classes
+// //////////////////////////////
+//
+// private Shell getShell() {
+// return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+// }
+//
+// class TestPage extends CProjectPlatformPage {
+// TestPage(NewManagedProjectWizard wizard) throws Exception {
+// super(TestCProjectPlatformPage.class.getName(), wizard);
+// }
+// IProjectType getFirstType() {
+// return (IProjectType) projectTypes.get(0);
+// }
+// IProjectType getSecondType() {
+// return (IProjectType) projectTypes.get(1);
+// }
+// }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCustomPageManager.java b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCustomPageManager.java
index b411ba8a521..6a1f947866c 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCustomPageManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/TestCustomPageManager.java
@@ -56,818 +56,819 @@ public class TestCustomPageManager extends TestCase
testFlag = false;
}
-
- /**
- * Test with a setup such that only an unconstrained page should show up.
- */
- public void testOneVisiblePage()
- {
- // set the project type to be "X"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
-
- // set the toolchain to "Y"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("Y");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "Z"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be null
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != null)
- {
- fail("AlwaysPresentWizardPage should not have a next page.");
- }
-
- // the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolChainCWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolChainCv20WizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
- }
-
-
- /**
- * Set the nature to "A". Only pages with no contraints or natures set to "A" should show up.
- */
- public void testNatureA()
- {
-// set the project type to be "X"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
-
- // set the toolchain to "Y"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("Y");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "A"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "A");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for Nature A
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(natureAPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be NatureAWizardPage");
- }
-
- // Nature A page's previous page should be the always present page
- if(MBSCustomPageManager.getPreviousPage(natureAPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("NatureAWizardPage's next page should be AlwaysPresentWizardPage");
- }
-
- // Nature A page should be visible
- if(!MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should be visible");
- }
-
- // Nature A page's next page should be null
- if(MBSCustomPageManager.getNextPage(natureAPageName) != null)
- {
- fail("NatureAWizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolChainCWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolChainCv20WizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
- }
-
- /**
- * Set the nature to "B". Only pages with no contraints or natures set to "B" should show up.
- */
- public void testNatureB()
- {
-// set the project type to be "X"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
-
- // set the toolchain to "Y"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("Y");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "B"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "B");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for Nature B
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(natureBPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be NatureBWizardPage");
- }
-
- // Nature B page's previous page should be the always present page
- if(MBSCustomPageManager.getPreviousPage(natureBPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("NatureBWizardPage's next page should be AlwaysPresentWizardPage");
- }
-
- // Nature B page should be visible
- if(!MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should be visible");
- }
-
- // Nature B page's next page should be null
- if(MBSCustomPageManager.getNextPage(natureBPageName) != null)
- {
- fail("NatureBWizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolChainCWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolChainCv20WizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
- }
-
- /**
- * Set the toolchain to "C". Only pages with no contraints or toolchains set to "C" should show up.
- */
- public void testToolchainC()
- {
-// set the project type to be "X"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
- // set the toolchain to "C"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("C");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "Z"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for toolchain C
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be ToolchainCWizardPage");
- }
-
- // toolchain C page's previous page should be the always present page
- if(MBSCustomPageManager.getPreviousPage(toolchainCPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("ToolchainCWizardPage's previous page should be AlwaysPresentWizardPage");
- }
-
- // Toolchain C page should be visible
- if(!MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolchainCWizardPage should be visible");
- }
-
- // Toolchain C page's next page should be null
- if(MBSCustomPageManager.getNextPage(toolchainCPageName) != null)
- {
- fail("ToolchainCWizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolChainCv20WizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should not be visible");
- }
-
- // the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should not be visible");
- }
-
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
- }
-
- /**
- * Set the toolchain to "C_2.0.0". Only pages with no contraints, or toolchains set to "C", or toolchains set to "C" version 2.0.0 should show up.
- */
- public void testToolchainCv20()
- {
-// set the project type to be "X"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
-
- // set the toolchain to "C"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("C_2.0.0");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "Z"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for toolchain C
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be ToolchainCWizardPage");
- }
-
- // toolchain C page's previous page should be the always present page
- if(MBSCustomPageManager.getPreviousPage(toolchainCPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("ToolchainCWizardPage's previous page should be AlwaysPresentWizardPage");
- }
-
- // Toolchain C page should be visible
- if(!MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolchainCWizardPage should be visible");
- }
-
- // Toolchain C page's next page should be the page for C 2.0
- if(MBSCustomPageManager.getNextPage(toolchainCPageName) != MBSCustomPageManager.getPageData(toolchainCv20PageName).getWizardPage())
- {
- fail("ToolchainCWizardPage's next page should be ToolchainCv20WizardPage.");
- }
-
- // toolchain C v 2.0.0 page's previous page should be the toolchain C page
- if(MBSCustomPageManager.getPreviousPage(toolchainCv20PageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
- {
- fail("ToolchainCv20WizardPage's previous page should be ToolchainCWizardPage");
- }
-
- // Toolchain C v 2.0.0 page should be visible
- if(!MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolchainCWizardPage should be visible");
- }
-
- // Toolchain C v 2.0.0 page's next page should be null
- if(MBSCustomPageManager.getNextPage(toolchainCv20PageName) != null)
- {
- fail("ToolchainCv20WizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should not be visible");
- }
-
- // the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should not be visible");
- }
-
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
- }
-
-
-
- /**
- * Set the project type to "D". Only pages with no contraints or project types set to "D" should show up.
- */
- public void testProjectTypeD()
- {
-// set the project type to be "D"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "D");
-
- // set the toolchain to "Y"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("Y");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "Z"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for project type D
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(projectTypeDPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be ProjectTypeDWizardPage");
- }
-
- // Project type D page's previous page should be the always present page
- if(MBSCustomPageManager.getPreviousPage(projectTypeDPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("ProjectTypeDWizardPage's next page should be AlwaysPresentWizardPage");
- }
-
- // Project type D page should be visible
- if(!MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should be visible");
- }
-
- // Project type D page's next page should be null
- if(MBSCustomPageManager.getNextPage(projectTypeDPageName) != null)
- {
- fail("ProjectTypeDWizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should not be visible");
- }
-
- // the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolChainCWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolChainCv20WizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
-
- }
-
-
-
- /**
- * Set the project type to "E". Only pages with no contraints or project types set to "E" should show up.
- */
- public void testProjectTypeE()
- {
-// set the project type to be "E"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "E");
-
- // set the toolchain to "Y"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("Y");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "Z"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for project type D
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(projectTypeEPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be ProjectTypeEWizardPage");
- }
-
- // Project type E page's previous page should be the always present page
- if(MBSCustomPageManager.getPreviousPage(projectTypeEPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("ProjectTypeDWizardPage's next page should be AlwaysPresentWizardPage");
- }
-
- // Project type E page should be visible
- if(!MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeDWizardPage should be visible");
- }
-
- // Project type D page's next page should be null
- if(MBSCustomPageManager.getNextPage(projectTypeEPageName) != null)
- {
- fail("ProjectTypeEWizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should not be visible");
- }
-
- // the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolChainCWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolChainCv20WizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
-
- }
-
- /**
- * Set the toolchain to "F". Only pages with no contraints or toolchains set to "F" should show up.
- */
- public void testToolchainF()
- {
-// set the project type to be "X"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
-
- // set the toolchain to "F"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("F");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "Z"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for toolchain F
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(toolchainFPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be ToolchainFWizardPage");
- }
-
- // toolchain F page's previous page should be the always present page
- if(MBSCustomPageManager.getPreviousPage(toolchainFPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("ToolchainFWizardPage's previous page should be AlwaysPresentWizardPage");
- }
-
- // Toolchain C page should be visible
- if(!MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should be visible");
- }
-
- // Toolchain F page's next page should be null
- if(MBSCustomPageManager.getNextPage(toolchainFPageName) != null)
- {
- fail("ToolchainCWizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should not be visible");
- }
-
- // the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
- {
- fail("ToolChainCv20WizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should not be visible");
- }
-
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolchainCWizardPage should not be visible");
- }
- }
-
- /**
- * Set nature to A, toolchain to C, project type to D. We should have several pages with different constraints appearing.
- */
- public void testMultiplePages()
- {
-// set the project type to be "D"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "D");
-
- // set the toolchain to "C"
- Set toolchainSet = new LinkedHashSet();
- TestToolchain toolchain = new TestToolchain();
- toolchain.setID("C");
- toolchainSet.add(toolchain);
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
-
- // set the nature to "A"
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "A");
-
- // check each of the pages
-
- // this page should always be visible
- if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
- {
- fail("AlwaysPresentWizardPage should be visible");
- }
-
- // next page for this page should be the page for Nature A
- if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(natureAPageName).getWizardPage())
- {
- fail("AlwaysPresentWizardPage's next page should be NatureAWizardPage");
- }
-
- // Nature A page's previous page should be the always present page
-// next page for this page should be the page for Nature A
- if(MBSCustomPageManager.getPreviousPage(natureAPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
- {
- fail("NatureAWizardPage's next page should be AlwaysPresentWizardPage");
- }
-
- // Nature A page should be visible
- if(!MBSCustomPageManager.isPageVisible(natureAPageName))
- {
- fail("NatureAWizardPage should be visible");
- }
-
- // next page for this page should be the page for toolchain C
- if(MBSCustomPageManager.getNextPage(natureAPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
- {
- fail("NatureAWizardPage's next page should be ToolchainCWizardPage");
- }
-
- // Toolchain C page's previous page should be NatureAWizardPage
- if(MBSCustomPageManager.getPreviousPage(toolchainCPageName) != MBSCustomPageManager.getPageData(natureAPageName).getWizardPage())
- {
- fail("ToolchainCWizardPage's previous page should be NatureAWizardPage");
- }
-
- // Toolchain C page should be visible
- if(!MBSCustomPageManager.isPageVisible(toolchainCPageName))
- {
- fail("ToolchainCWizardPage should be visible");
- }
-
- // next page for this page should be the page for project type D
- if(MBSCustomPageManager.getNextPage(toolchainCPageName) != MBSCustomPageManager.getPageData(projectTypeDPageName).getWizardPage())
- {
- fail("ToolchainCWizardPage's next page should be ProjectTypeDWizardPage");
- }
-
- // Project type D page's previous page should be the toolchain C page
- if(MBSCustomPageManager.getPreviousPage(projectTypeDPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
- {
- fail("ProjectTypeDWizardPage's previous page should be toolchainCPageName");
- }
-
- // Project type D page should be visible
- if(!MBSCustomPageManager.isPageVisible(projectTypeDPageName))
- {
- fail("ProjectTypeDWizardPage should be visible");
- }
-
- // Project type D page's next page should be null
- if(MBSCustomPageManager.getNextPage(projectTypeDPageName) != null)
- {
- fail("ProjectTypeDWizardPage should not have a next page.");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(natureBPageName))
- {
- fail("NatureBWizardPage should not be visible");
- }
-
- // the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
- {
- fail("ProjectTypeEWizardPage should not be visible");
- }
-
-// the rest of the pages should be invisible
- if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
- {
- fail("ToolchainFWizardPage should not be visible");
- }
- }
+ //TODO: migrate tests to new managed builder UI
+// /**
+// * Test with a setup such that only an unconstrained page should show up.
+// */
+// public void testOneVisiblePage()
+// {
+// // set the project type to be "X"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
+//
+// // set the toolchain to "Y"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("Y");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "Z"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be null
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != null)
+// {
+// fail("AlwaysPresentWizardPage should not have a next page.");
+// }
+//
+// // the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolChainCWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolChainCv20WizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+// }
+//
+//
+// /**
+// * Set the nature to "A". Only pages with no contraints or natures set to "A" should show up.
+// */
+// public void testNatureA()
+// {
+//// set the project type to be "X"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
+//
+// // set the toolchain to "Y"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("Y");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "A"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "A");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for Nature A
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(natureAPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be NatureAWizardPage");
+// }
+//
+// // Nature A page's previous page should be the always present page
+// if(MBSCustomPageManager.getPreviousPage(natureAPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("NatureAWizardPage's next page should be AlwaysPresentWizardPage");
+// }
+//
+// // Nature A page should be visible
+// if(!MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should be visible");
+// }
+//
+// // Nature A page's next page should be null
+// if(MBSCustomPageManager.getNextPage(natureAPageName) != null)
+// {
+// fail("NatureAWizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolChainCWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolChainCv20WizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+// }
+//
+// /**
+// * Set the nature to "B". Only pages with no contraints or natures set to "B" should show up.
+// */
+// public void testNatureB()
+// {
+//// set the project type to be "X"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
+//
+// // set the toolchain to "Y"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("Y");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "B"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "B");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for Nature B
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(natureBPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be NatureBWizardPage");
+// }
+//
+// // Nature B page's previous page should be the always present page
+// if(MBSCustomPageManager.getPreviousPage(natureBPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("NatureBWizardPage's next page should be AlwaysPresentWizardPage");
+// }
+//
+// // Nature B page should be visible
+// if(!MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should be visible");
+// }
+//
+// // Nature B page's next page should be null
+// if(MBSCustomPageManager.getNextPage(natureBPageName) != null)
+// {
+// fail("NatureBWizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolChainCWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolChainCv20WizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+// }
+//
+// /**
+// * Set the toolchain to "C". Only pages with no contraints or toolchains set to "C" should show up.
+// */
+// public void testToolchainC()
+// {
+//// set the project type to be "X"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
+//
+// // set the toolchain to "C"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("C");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "Z"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for toolchain C
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be ToolchainCWizardPage");
+// }
+//
+// // toolchain C page's previous page should be the always present page
+// if(MBSCustomPageManager.getPreviousPage(toolchainCPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("ToolchainCWizardPage's previous page should be AlwaysPresentWizardPage");
+// }
+//
+// // Toolchain C page should be visible
+// if(!MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolchainCWizardPage should be visible");
+// }
+//
+// // Toolchain C page's next page should be null
+// if(MBSCustomPageManager.getNextPage(toolchainCPageName) != null)
+// {
+// fail("ToolchainCWizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolChainCv20WizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should not be visible");
+// }
+//
+// // the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should not be visible");
+// }
+//
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+// }
+//
+// /**
+// * Set the toolchain to "C_2.0.0". Only pages with no contraints, or toolchains set to "C", or toolchains set to "C" version 2.0.0 should show up.
+// */
+// public void testToolchainCv20()
+// {
+//// set the project type to be "X"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
+//
+// // set the toolchain to "C"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("C_2.0.0");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "Z"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for toolchain C
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be ToolchainCWizardPage");
+// }
+//
+// // toolchain C page's previous page should be the always present page
+// if(MBSCustomPageManager.getPreviousPage(toolchainCPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("ToolchainCWizardPage's previous page should be AlwaysPresentWizardPage");
+// }
+//
+// // Toolchain C page should be visible
+// if(!MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolchainCWizardPage should be visible");
+// }
+//
+// // Toolchain C page's next page should be the page for C 2.0
+// if(MBSCustomPageManager.getNextPage(toolchainCPageName) != MBSCustomPageManager.getPageData(toolchainCv20PageName).getWizardPage())
+// {
+// fail("ToolchainCWizardPage's next page should be ToolchainCv20WizardPage.");
+// }
+//
+// // toolchain C v 2.0.0 page's previous page should be the toolchain C page
+// if(MBSCustomPageManager.getPreviousPage(toolchainCv20PageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
+// {
+// fail("ToolchainCv20WizardPage's previous page should be ToolchainCWizardPage");
+// }
+//
+// // Toolchain C v 2.0.0 page should be visible
+// if(!MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolchainCWizardPage should be visible");
+// }
+//
+// // Toolchain C v 2.0.0 page's next page should be null
+// if(MBSCustomPageManager.getNextPage(toolchainCv20PageName) != null)
+// {
+// fail("ToolchainCv20WizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should not be visible");
+// }
+//
+// // the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should not be visible");
+// }
+//
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+// }
+//
+//
+//
+// /**
+// * Set the project type to "D". Only pages with no contraints or project types set to "D" should show up.
+// */
+// public void testProjectTypeD()
+// {
+//// set the project type to be "D"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "D");
+//
+// // set the toolchain to "Y"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("Y");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "Z"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for project type D
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(projectTypeDPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be ProjectTypeDWizardPage");
+// }
+//
+// // Project type D page's previous page should be the always present page
+// if(MBSCustomPageManager.getPreviousPage(projectTypeDPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("ProjectTypeDWizardPage's next page should be AlwaysPresentWizardPage");
+// }
+//
+// // Project type D page should be visible
+// if(!MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should be visible");
+// }
+//
+// // Project type D page's next page should be null
+// if(MBSCustomPageManager.getNextPage(projectTypeDPageName) != null)
+// {
+// fail("ProjectTypeDWizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should not be visible");
+// }
+//
+// // the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolChainCWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolChainCv20WizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+//
+// }
+//
+//
+//
+// /**
+// * Set the project type to "E". Only pages with no contraints or project types set to "E" should show up.
+// */
+// public void testProjectTypeE()
+// {
+//// set the project type to be "E"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "E");
+//
+// // set the toolchain to "Y"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("Y");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "Z"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for project type D
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(projectTypeEPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be ProjectTypeEWizardPage");
+// }
+//
+// // Project type E page's previous page should be the always present page
+// if(MBSCustomPageManager.getPreviousPage(projectTypeEPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("ProjectTypeDWizardPage's next page should be AlwaysPresentWizardPage");
+// }
+//
+// // Project type E page should be visible
+// if(!MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeDWizardPage should be visible");
+// }
+//
+// // Project type D page's next page should be null
+// if(MBSCustomPageManager.getNextPage(projectTypeEPageName) != null)
+// {
+// fail("ProjectTypeEWizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should not be visible");
+// }
+//
+// // the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolChainCWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolChainCv20WizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+//
+// }
+//
+// /**
+// * Set the toolchain to "F". Only pages with no contraints or toolchains set to "F" should show up.
+// */
+// public void testToolchainF()
+// {
+//// set the project type to be "X"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "X");
+//
+// // set the toolchain to "F"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("F");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "Z"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "Z");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for toolchain F
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(toolchainFPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be ToolchainFWizardPage");
+// }
+//
+// // toolchain F page's previous page should be the always present page
+// if(MBSCustomPageManager.getPreviousPage(toolchainFPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("ToolchainFWizardPage's previous page should be AlwaysPresentWizardPage");
+// }
+//
+// // Toolchain C page should be visible
+// if(!MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should be visible");
+// }
+//
+// // Toolchain F page's next page should be null
+// if(MBSCustomPageManager.getNextPage(toolchainFPageName) != null)
+// {
+// fail("ToolchainCWizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should not be visible");
+// }
+//
+// // the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCv20PageName))
+// {
+// fail("ToolChainCv20WizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should not be visible");
+// }
+//
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolchainCWizardPage should not be visible");
+// }
+// }
+//
+// /**
+// * Set nature to A, toolchain to C, project type to D. We should have several pages with different constraints appearing.
+// */
+// public void testMultiplePages()
+// {
+//// set the project type to be "D"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.PROJECT_TYPE, "D");
+//
+// // set the toolchain to "C"
+// Set toolchainSet = new LinkedHashSet();
+// TestToolchain toolchain = new TestToolchain();
+// toolchain.setID("C");
+// toolchainSet.add(toolchain);
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.TOOLCHAIN, toolchainSet);
+//
+// // set the nature to "A"
+// MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, "A");
+//
+// // check each of the pages
+//
+// // this page should always be visible
+// if(!MBSCustomPageManager.isPageVisible(alwaysPresentPageName))
+// {
+// fail("AlwaysPresentWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for Nature A
+// if(MBSCustomPageManager.getNextPage(alwaysPresentPageName) != MBSCustomPageManager.getPageData(natureAPageName).getWizardPage())
+// {
+// fail("AlwaysPresentWizardPage's next page should be NatureAWizardPage");
+// }
+//
+// // Nature A page's previous page should be the always present page
+//// next page for this page should be the page for Nature A
+// if(MBSCustomPageManager.getPreviousPage(natureAPageName) != MBSCustomPageManager.getPageData(alwaysPresentPageName).getWizardPage())
+// {
+// fail("NatureAWizardPage's next page should be AlwaysPresentWizardPage");
+// }
+//
+// // Nature A page should be visible
+// if(!MBSCustomPageManager.isPageVisible(natureAPageName))
+// {
+// fail("NatureAWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for toolchain C
+// if(MBSCustomPageManager.getNextPage(natureAPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
+// {
+// fail("NatureAWizardPage's next page should be ToolchainCWizardPage");
+// }
+//
+// // Toolchain C page's previous page should be NatureAWizardPage
+// if(MBSCustomPageManager.getPreviousPage(toolchainCPageName) != MBSCustomPageManager.getPageData(natureAPageName).getWizardPage())
+// {
+// fail("ToolchainCWizardPage's previous page should be NatureAWizardPage");
+// }
+//
+// // Toolchain C page should be visible
+// if(!MBSCustomPageManager.isPageVisible(toolchainCPageName))
+// {
+// fail("ToolchainCWizardPage should be visible");
+// }
+//
+// // next page for this page should be the page for project type D
+// if(MBSCustomPageManager.getNextPage(toolchainCPageName) != MBSCustomPageManager.getPageData(projectTypeDPageName).getWizardPage())
+// {
+// fail("ToolchainCWizardPage's next page should be ProjectTypeDWizardPage");
+// }
+//
+// // Project type D page's previous page should be the toolchain C page
+// if(MBSCustomPageManager.getPreviousPage(projectTypeDPageName) != MBSCustomPageManager.getPageData(toolchainCPageName).getWizardPage())
+// {
+// fail("ProjectTypeDWizardPage's previous page should be toolchainCPageName");
+// }
+//
+// // Project type D page should be visible
+// if(!MBSCustomPageManager.isPageVisible(projectTypeDPageName))
+// {
+// fail("ProjectTypeDWizardPage should be visible");
+// }
+//
+// // Project type D page's next page should be null
+// if(MBSCustomPageManager.getNextPage(projectTypeDPageName) != null)
+// {
+// fail("ProjectTypeDWizardPage should not have a next page.");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(natureBPageName))
+// {
+// fail("NatureBWizardPage should not be visible");
+// }
+//
+// // the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(projectTypeEPageName))
+// {
+// fail("ProjectTypeEWizardPage should not be visible");
+// }
+//
+//// the rest of the pages should be invisible
+// if(MBSCustomPageManager.isPageVisible(toolchainFPageName))
+// {
+// fail("ToolchainFWizardPage should not be visible");
+// }
+// }
public void testOperation()
@@ -889,15 +890,15 @@ public class TestCustomPageManager extends TestCase
public static Test suite() {
TestSuite suite = new TestSuite(TestCustomPageManager.class.getName());
- suite.addTest(new TestCustomPageManager("testOneVisiblePage"));
- suite.addTest(new TestCustomPageManager("testNatureA"));
- suite.addTest(new TestCustomPageManager("testNatureB"));
- suite.addTest(new TestCustomPageManager("testToolchainC"));
- suite.addTest(new TestCustomPageManager("testToolchainCv20"));
- suite.addTest(new TestCustomPageManager("testProjectTypeD"));
- suite.addTest(new TestCustomPageManager("testProjectTypeE"));
- suite.addTest(new TestCustomPageManager("testToolchainF"));
- suite.addTest(new TestCustomPageManager("testMultiplePages"));
+// suite.addTest(new TestCustomPageManager("testOneVisiblePage"));
+// suite.addTest(new TestCustomPageManager("testNatureA"));
+// suite.addTest(new TestCustomPageManager("testNatureB"));
+// suite.addTest(new TestCustomPageManager("testToolchainC"));
+// suite.addTest(new TestCustomPageManager("testToolchainCv20"));
+// suite.addTest(new TestCustomPageManager("testProjectTypeD"));
+// suite.addTest(new TestCustomPageManager("testProjectTypeE"));
+// suite.addTest(new TestCustomPageManager("testToolchainF"));
+// suite.addTest(new TestCustomPageManager("testMultiplePages"));
suite.addTest(new TestCustomPageManager("testOperation"));
return suite;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestToolchain.java b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestToolchain.java
index ada012258cf..da17b1ef806 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestToolchain.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestToolchain.java
@@ -11,10 +11,13 @@
package org.eclipse.cdt.managedbuilder.ui.tests.util;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IOptionPathConverter;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
@@ -272,6 +275,41 @@ public class TestToolchain extends HoldsOptions implements IToolChain {
// TODO Auto-generated method stub
return null;
}
+
+ protected IResourceInfo getParentResourceInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IFolderInfo getParentFolderInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public CTargetPlatformData getTargetPlatformData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getUniqueRealName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isSystemObject() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean matches(IToolChain tc) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean supportsBuild(boolean managed) {
+ // TODO Auto-generated method stub
+ return false;
+ }
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
index b9b14e977b4..91dba982046 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
@@ -3,12 +3,11 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.ui; singleton:=true
Bundle-Version: 4.0.0.qualifier
-Bundle-Activator: org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin
+Bundle-Activator: org.eclipse.cdt.managedbuilder.ui.newui.ManagedBuilderUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Export-Package: org.eclipse.cdt.managedbuilder.internal.ui,
- org.eclipse.cdt.managedbuilder.ui.actions,
- org.eclipse.cdt.managedbuilder.ui.properties,
+Export-Package: org.eclipse.cdt.managedbuilder.ui.actions,
+ org.eclipse.cdt.managedbuilder.ui.newui,
org.eclipse.cdt.managedbuilder.ui.wizards
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/dlcl16/read_only.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/dlcl16/read_only.gif
new file mode 100644
index 00000000000..dde3cbd6150
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/dlcl16/read_only.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/built_in.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/built_in.gif
new file mode 100644
index 00000000000..b51281b2a8f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/built_in.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/discovery.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/discovery.gif
new file mode 100644
index 00000000000..ec6cca4525b
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/discovery.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/editable.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/editable.gif
new file mode 100644
index 00000000000..c34076a12c9
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/editable.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/read_only.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/read_only.gif
new file mode 100644
index 00000000000..dde3cbd6150
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/elcl16/read_only.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/artifact.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/artifact.gif
new file mode 100644
index 00000000000..67209cba8c0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/artifact.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/bin_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/bin_obj.gif
new file mode 100644
index 00000000000..66225ec45d0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/bin_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/build_settings.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/build_settings.gif
new file mode 100644
index 00000000000..c763251ffe3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/build_settings.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/define_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/define_obj.gif
new file mode 100644
index 00000000000..87d583e1dd3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/define_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/environment.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/environment.gif
new file mode 100644
index 00000000000..716df436f99
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/environment.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/error_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/error_obj.gif
new file mode 100644
index 00000000000..2cd37c2548e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/error_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/filesystem.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/filesystem.gif
new file mode 100644
index 00000000000..13ce11b1490
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/filesystem.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/fldr_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/fldr_obj.gif
new file mode 100644
index 00000000000..03ee1dcb8e3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/fldr_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/hfolder_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/hfolder_obj.gif
new file mode 100644
index 00000000000..b98b8172795
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/hfolder_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/lib_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/lib_obj.gif
new file mode 100644
index 00000000000..cb55e33b5eb
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/lib_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/opentype.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/opentype.gif
new file mode 100644
index 00000000000..e687f54e672
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/opentype.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/output_folder_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/output_folder_obj.gif
new file mode 100644
index 00000000000..07c4101589c
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/output_folder_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/search_ref_obj.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/search_ref_obj.gif
new file mode 100644
index 00000000000..f8f0ce5aa85
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/search_ref_obj.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/steps.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/steps.gif
new file mode 100644
index 00000000000..abebd508ca5
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/steps.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/workspace.gif b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/workspace.gif
new file mode 100644
index 00000000000..eb7b90c7671
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/icons/obj16/workspace.gif
Binary files differ
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
index ec805c443ce..bd83d2e1a86 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
@@ -22,6 +22,7 @@ MngBuildProp.name=C/C++ Build
MngOtherProp.name= Error/Binary Parsers
#The preference pages
+MakeBuildPref.name=Makefile Project
MngBuildPref.name=Managed Build
#The Resource Property page
@@ -42,4 +43,12 @@ BuildSelectedFiles.label=Build Selected &File(s)
CleanSelectedFiles.label=C&lean Selected File(s)
BuildSelectedFilesActionSet.label=Build/Clean Selected File(s)
BuildSelectedFiles.tooltip=Rebuilds the selected file(s)
-CleanSelectedFiles.tooltip=Cleans the output file(s) for the selected file(s) \ No newline at end of file
+CleanSelectedFiles.tooltip=Cleans the output file(s) for the selected file(s)
+
+## New CDT project model - property pages names
+CDTPathSymbolsProperty.name=CDT Project paths and symbols
+CDTExpPathSymbolsProperty.name=CDT Export settings
+CDTBuildProperty.name=CDT Build settings
+CDTToolchainProperty.name=CDT ToolChain edit
+CDTVariablesProperty.name=CDT Build variables
+
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index 09c2348370f..e6a7010df10 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -3,100 +3,62 @@
<plugin>
<extension-point id="newWizardPages" name="Custom MBS New Wizard Pages" schema="schema/newWizardPages.exsd"/>
+ <extension-point id="DiscoveryProfileUI" name="DiscoveryProfileUI" schema="schema/DiscoveryProfileUI.exsd"/>
+ <extension-point id="CDTWizard" name="CDTWizard" schema="schema/CDTWizard.exsd"/>
<extension
point="org.eclipse.ui.newWizards">
<!-- Managed Make Builder Projects -->
<wizard
- name="%MngCCWizard.name"
- icon="icons/elcl16/newmngcc_app.gif"
- category="org.eclipse.cdt.ui.newCCWizards"
- class="org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedCCProjectWizard"
- project="true"
+ canFinishEarly="false"
+ category="org.eclipse.cdt.ui.newCDTWizards"
+ class="org.eclipse.cdt.managedbuilder.ui.wizards.CDTProjectWizard"
finalPerspective="org.eclipse.cdt.ui.CPerspective"
- id="org.eclipse.cdt.managedbuilder.ui.wizards.StdCCWizard">
- <description>
- %MngCCWizard.description
- </description>
- </wizard>
+ hasPages="true"
+ icon="icons/elcl16/newmngcc_app.gif"
+ id="org.eclipse.cdt.managedbuilder.ui.wizards.NewCWizard3"
+ name="CDT project"
+ project="true">
+ <description>
+ Create a new language-neutral project
+ </description>
+ </wizard>
<wizard
- name="%MngCWizard.name"
- icon="icons/elcl16/newmngc_app.gif"
- category="org.eclipse.cdt.ui.newCWizards"
- class="org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedCProjectWizard"
- project="true"
+ canFinishEarly="false"
+ category="org.eclipse.cdt.ui.newCCWizards"
+ class="org.eclipse.cdt.managedbuilder.ui.wizards.CCProjectWizard"
finalPerspective="org.eclipse.cdt.ui.CPerspective"
- id="org.eclipse.cdt.managedbuilder.ui.wizards.StdCWizard">
+ hasPages="true"
+ icon="icons/elcl16/newmngcc_app.gif"
+ id="org.eclipse.cdt.managedbuilder.ui.wizards.NewCWizard1"
+ name="C++ project"
+ project="true">
+ <description>
+ Create a new C++ project
+ </description>
+ </wizard>
+ <wizard
+ canFinishEarly="false"
+ category="org.eclipse.cdt.ui.newCWizards"
+ class="org.eclipse.cdt.managedbuilder.ui.wizards.CProjectWizard"
+ finalPerspective="org.eclipse.cdt.ui.CPerspective"
+ hasPages="true"
+ icon="icons/elcl16/newmngcc_app.gif"
+ id="org.eclipse.cdt.managedbuilder.ui.wizards.NewCWizard2"
+ name="C project"
+ project="true">
<description>
- %MngCWizard.description
+ Create a new C project
</description>
</wizard>
</extension>
- <extension
- point="org.eclipse.ui.propertyPages">
- <page
- objectClass="org.eclipse.core.resources.IProject"
- adaptable="true"
- name="%MngBuildProp.name"
- class="org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage"
- id="org.eclipse.cdt.managedbuilder.ui.properties.BuildProperties">
- <filter
- name="nature"
- value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
- </filter>
- </page>
- <page
- objectClass="org.eclipse.core.resources.IFile"
- adaptable="true"
- name="%MngResourceProp.name"
- class="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage"
- id="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildProperties">
- <filter
- name="projectNature"
- value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
- </filter>
- </page>
-
- <!--page
- objectClass="org.eclipse.core.resources.IFile"
- adaptable="true"
- name="%MngResourceProp.name"
- nameFilter="*.c"
- class="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage"
- id="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildProperties.c">
- </page>
- <page
- objectClass="org.eclipse.core.resources.IFile"
- adaptable="true"
- name="%MngResourceProp.name"
- nameFilter="*.cpp"
- class="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage"
- id="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildProperties.cpp">
- </page>
- <page
- objectClass="org.eclipse.core.resources.IFile"
- adaptable="true"
- name="%MngResourceProp.name"
- nameFilter="*.cc"
- class="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage"
- id="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildProperties.cc">
- </page>
- <page
- objectClass="org.eclipse.core.resources.IFile"
- adaptable="true"
- name="%MngResourceProp.name"
- nameFilter="*.cxx"
- class="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage"
- id="org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildProperties.cxx">
- </page-->
- </extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
- name="%MngBuildPref.name"
+ name="%MakeBuildPref.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
- class="org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage"
+ class="org.eclipse.cdt.managedbuilder.ui.newui.PrefPage_NewCDTProject"
id="org.eclipse.cdt.managedbuilder.ui.preferences.BuildPreferences">
</page>
</extension>
@@ -120,76 +82,8 @@
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
</filter>
</objectContribution>
- </extension>
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- description="Build configuration for the current project"
- id="org.eclipse.cdt.managedbuilder.ui.buildConfigActionSet"
- label="%BuildConfigActionSet.label"
- visible="false">
- <action
- class="org.eclipse.cdt.managedbuilder.ui.actions.ChangeBuildConfigMenuAction"
- disabledIcon="icons/dlcl16/config-tool.gif"
- enablesFor="+"
- icon="icons/elcl16/config-tool.gif"
- id="org.eclipse.cdt.managedbuilder.ui.buildConfigToolbarAction"
- label="%BuildConfigToolbarAction.label"
- style="pulldown"
- toolbarPath="buildConfig"
- tooltip="%BuildConfigAction.tooltip"/>
- <action
- class="org.eclipse.cdt.managedbuilder.ui.actions.ChangeBuildConfigMenuAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.buildConfigMenuAction"
- label="%BuildConfigMenuAction.label"
- menubarPath="project/build"
- style="pulldown"
- tooltip="%BuildConfigAction.tooltip"/>
- </actionSet>
- <actionSet
- id="org.eclipse.cdt.managedbuilder.ui.buildSelectedFilesActionSet"
- label="%BuildSelectedFilesActionSet.label"
- visible="false">
- <action
- class="org.eclipse.cdt.managedbuilder.ui.actions.BuildFilesAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.buildFilesAction"
- label="%BuildSelectedFiles.label"
- menubarPath="project/build"
- style="push"
- tooltip="%buildSelectedFiles.tooltip">
- </action>
- <action
- class="org.eclipse.cdt.managedbuilder.ui.actions.CleanFilesAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.cleanFilesAction"
- label="%CleanSelectedFiles.label"
- menubarPath="project/build"
- style="push"
- tooltip="%cleanFilesAction.tooltip">
- </action>
- </actionSet>
- </extension>
- <extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- adaptable="true"
- id="org.eclipse.cdt.managedbuilder.ui.buildConfigContribution"
- objectClass="org.eclipse.core.resources.IResource">
- <action
- class="org.eclipse.cdt.managedbuilder.ui.actions.ChangeBuildConfigContextAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.buildConfigPulldownAction"
- label="%BuildConfigContextAction.label"
- menubarPath="buildGroup"
- style="pulldown"
- tooltip="%BuildConfigAction.tooltip"/>
- <filter
- name="projectNature"
- value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
- </objectContribution>
- <objectContribution
+
+ <objectContribution
adaptable="true"
id="org.eclipse.cdt.managedbuilder.ui.BuildSelectedFilesContribution"
objectClass="org.eclipse.core.resources.IResource">
@@ -219,11 +113,37 @@
</and>
</visibility>
</objectContribution>
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ id="org.eclipse.cdt.managedbuilder.ui.buildSelectedFilesActionSet"
+ label="%BuildSelectedFilesActionSet.label"
+ visible="false">
+ <action
+ class="org.eclipse.cdt.managedbuilder.ui.actions.BuildFilesAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.managedbuilder.ui.buildFilesAction"
+ label="%BuildSelectedFiles.label"
+ menubarPath="project/build"
+ style="push"
+ tooltip="%buildSelectedFiles.tooltip">
+ </action>
+ <action
+ class="org.eclipse.cdt.managedbuilder.ui.actions.CleanFilesAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.managedbuilder.ui.cleanFilesAction"
+ label="%CleanSelectedFiles.label"
+ menubarPath="project/build"
+ style="push"
+ tooltip="%cleanFilesAction.tooltip">
+ </action>
+ </actionSet>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="org.eclipse.cdt.ui.CPerspective">
- <actionSet id="org.eclipse.cdt.managedbuilder.ui.buildConfigActionSet"/>
<actionSet id="org.eclipse.cdt.managedbuilder.ui.buildSelectedFilesActionSet"/>
</perspectiveExtension>
</extension>
@@ -254,4 +174,387 @@
</includes>
</viewerContentBinding>
</extension>
+
+ <extension
+ point="org.eclipse.cdt.ui.cPropertyTab">
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.DiscoveryTab"
+ icon="icons/elcl16/discovery.gif"
+ name="Discovery options"
+ weight="005"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"/>
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.ToolSettingsTab"
+ icon="icons/elcl16/config-tool.gif"
+ name="Tool settings"
+ weight="001"
+ parent="org.eclipse.cdt.ui.newui.Page_BuildSettings"/>
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.BuildStepsTab"
+ icon="icons/obj16/steps.gif"
+ name="Build steps"
+ parent="org.eclipse.cdt.ui.newui.Page_BuildSettings"
+ weight="002"/>
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.ArtifactTab"
+ icon="icons/obj16/artifact.gif"
+ name="Build artifact"
+ parent="org.eclipse.cdt.ui.newui.Page_BuildSettings"
+ weight="003"/>
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.BuilderSettingsTab"
+ icon="icons/obj16/build_settings.gif"
+ name="Builder settings"
+ parent="org.eclipse.cdt.ui.newui.Page_BuildSettings"
+ weight="004"/>
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.CPropertyVarsTab"
+ name="(Single) CDT Vars (macros)"
+ parent="org.eclipse.cdt.ui.newui.Page_Variables"/>
+ <!--tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.ToolChainEditTab"
+ name="(Single) Tool chain edit"
+ parent="org.eclipse.cdt.ui.newui.Page_ToolChain"/-->
+
+<!-- exported from CORE -->
+ <tab
+ class="org.eclipse.cdt.ui.newui.IncludeTab"
+ icon="icons/obj16/hfolder_obj.gif"
+ name="Includes"
+ weight="001"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"
+ tooltip="&quot;Includes list&quot;"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.SymbolTab"
+ icon="icons/obj16/define_obj.gif"
+ name="Symbols"
+ weight="002"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"
+ tooltip="&quot;Macros list&quot;"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.LibraryTab"
+ icon="icons/obj16/lib_obj.gif"
+ name="Libraries"
+ weight="003"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"
+ tooltip="&quot;Libraries list&quot;"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.LibraryPathTab"
+ icon="icons/obj16/opentype.gif"
+ name="Library paths"
+ weight="004"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.RefsTab"
+ icon="icons/obj16/search_ref_obj.gif"
+ name="References"
+ weight="010"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.CLocationSourceTab"
+ icon="icons/obj16/fldr_obj.gif"
+ name="Source location"
+ weight="008"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"/>
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.CBuildLocationOutputTab"
+ icon="icons/obj16/output_folder_obj.gif"
+ name="Output location"
+ weight="009"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"/>
+<!-- temporary disabled
+ <tab
+ class="org.eclipse.cdt.ui.newui.SDKsTab"
+ name="SDKs"
+ parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"
+ />
+-->
+ <tab
+ class="org.eclipse.cdt.ui.newui.EnvironmentTab"
+ icon="icons/obj16/environment.gif"
+ name="Environment"
+ weight="005"
+ parent="org.eclipse.cdt.ui.newui.Page_BuildSettings"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.BinaryParsTab"
+ icon="icons/obj16/bin_obj.gif"
+ name="Binary parsers"
+ weight="006"
+ parent="org.eclipse.cdt.ui.newui.Page_BuildSettings"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.ErrorParsTab"
+ icon="icons/obj16/error_obj.gif"
+ name="Error parsers"
+ weight="007"
+ parent="org.eclipse.cdt.ui.newui.Page_BuildSettings"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.LanguagesTab"
+ name="(Single) Languages"
+ parent="org.eclipse.cdt.ui.newui.Page_Languages"
+ />
+ <!-- Export settings page -->
+ <tab
+ class="org.eclipse.cdt.ui.newui.ExpIncludeTab"
+ icon="icons/obj16/hfolder_obj.gif"
+ name="Includes"
+ parent="org.eclipse.cdt.ui.newui.Page_ExpPathAndSymb"
+ tooltip="&quot;Includes list&quot;"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.ExpSymbolTab"
+ icon="icons/obj16/define_obj.gif"
+ name="Symbols"
+ parent="org.eclipse.cdt.ui.newui.Page_ExpPathAndSymb"
+ tooltip="&quot;Macros list&quot;"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.ExpLibraryTab"
+ icon="icons/obj16/lib_obj.gif"
+ name="Libraries"
+ parent="org.eclipse.cdt.ui.newui.Page_ExpPathAndSymb"
+ tooltip="&quot;Libraries list&quot;"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.ExpLibraryPathTab"
+ icon="icons/obj16/opentype.gif"
+ name="Library paths"
+ parent="org.eclipse.cdt.ui.newui.Page_ExpPathAndSymb"/>
+
+ <!-- tabs for Preference pages -->
+ <tab
+ class="org.eclipse.cdt.ui.newui.EnvironmentTab"
+ icon="icons/obj16/environment.gif"
+ name="(Single) Environment"
+ parent="org.eclipse.cdt.ui.newui.PrefPage_Env"/>
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.CPropertyVarsTab"
+ name="(Single) CDT Vars (macros)"
+ parent="org.eclipse.cdt.ui.newui.PrefPage_Vars"/>
+ <tab
+ class="org.eclipse.cdt.ui.newui.BinaryParsTab"
+ name="Binary parsers"
+ icon="icons/obj16/bin_obj.gif"
+ parent="org.eclipse.cdt.managedbuilder.ui.newui.PrefPage_NewCDTProject"
+ />
+ <tab
+ class="org.eclipse.cdt.ui.newui.ErrorParsTab"
+ name="Error parsers"
+ icon="icons/obj16/error_obj.gif"
+ parent="org.eclipse.cdt.managedbuilder.ui.newui.PrefPage_NewCDTProject"
+ />
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.DiscoveryTab"
+ icon="icons/elcl16/discovery.gif"
+ name="Discovery options"
+ parent="org.eclipse.cdt.managedbuilder.ui.newui.PrefPage_NewCDTProject"
+ />
+ <tab
+ class="org.eclipse.cdt.managedbuilder.ui.newui.BuilderSettingsTab"
+ name="Builder settings"
+ parent="org.eclipse.cdt.managedbuilder.ui.newui.PrefPage_NewCDTProject"
+ />
+ </extension>
+
+ <extension
+ id="BuildSystemWizard"
+ name="BuildSystemWizard"
+ point="org.eclipse.cdt.managedbuilder.ui.CDTWizard">
+ <wizard
+ class="org.eclipse.cdt.managedbuilder.ui.wizards.CNewWizard"
+ name="Build System Wizard">
+ </wizard>
+ <wizard
+ class="org.eclipse.cdt.managedbuilder.ui.wizards.StdBuildWizard"
+ name="Make project Wizard">
+ </wizard>
+ </extension>
+
+ <extension
+ point="org.eclipse.cdt.managedbuilder.ui.DiscoveryProfileUI">
+ <profilePage
+ class="org.eclipse.cdt.managedbuilder.ui.newui.GCCPerProjectSCDProfilePage"
+ name="Per project"
+ profileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"
+ profilePattern="PerProjectProfile"/>
+ <profilePage
+ class="org.eclipse.cdt.managedbuilder.ui.newui.GCCPerFileSCDProfilePage"
+ name="Per file"
+ profileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"
+ profilePattern="PerFileProfile"/>
+ </extension>
+
+<!-- Custom wizard pages - for testing only
+ <extension
+ point="org.eclipse.cdt.managedbuilder.ui.newWizardPages">
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.AlwaysPresentWizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.AlwaysPresentWizardPage"/>
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureAWizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.NatureAWizardPage">
+ <nature natureID="org.eclipse.cdt.core.cnature"/>
+ </wizardPage>
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureBWizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.NatureBWizardPage">
+ <nature natureID="org.eclipse.cdt.core.ccnature"/>
+ </wizardPage>
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ToolchainCWizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.ToolchainCWizardPage">
+ <toolchain toolchainID="cdt.managedbuild.toolchain.gnu.exe.debug"/>
+ </wizardPage>
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ToolchainCv20WizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.ToolchainCv20WizardPage">
+ <toolchain
+ toolchainID="C"
+ versionsSupported="2.0.0"/>
+ </wizardPage>
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ProjectTypeDWizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.ProjectTypeDWizardPage">
+ <projectType projectTypeID="D"/>
+ </wizardPage>
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ProjectTypeEWizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.ProjectTypeEWizardPage">
+ <projectType projectTypeID="E"/>
+ </wizardPage>
+ <wizardPage
+ ID="org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ToolchainFWizardPage"
+ pageClass="org.eclipse.cdt.managedbuilder.ui.test.ToolchainFWizardPage">
+ <toolchain toolchainID="F"/>
+ </wizardPage>
+ </extension>
+-->
+ <extension
+ point="org.eclipse.cdt.ui.newCfgDialog">
+ <dialog
+ class="org.eclipse.cdt.managedbuilder.ui.newui.NewCfgDialog"
+ mbs_id="org.eclipse.cdt.managedbuilder.core.configurationDataProvider"
+ title="MBS: create configuration"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.eclipse.cdt.ui.newui.Page_Variables"
+ id="org.eclipse.ui.propertypages.project.ref10"
+ name="%CDTVariablesProperty.name"
+ >
+ <filter
+ name="projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
+ </filter>
+ <enabledWhen>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+ </or>
+ </enabledWhen>
+ </page>
+
+ <page
+ class="org.eclipse.cdt.ui.newui.Page_PathAndSymb"
+ id="org.eclipse.ui.propertypages.project.ref12"
+ name="%CDTPathSymbolsProperty.name"
+ >
+ <filter
+ name="projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
+ </filter>
+ <enabledWhen>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+
+ <instanceof value="org.eclipse.core.resources.IFolder"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
+
+ <and>
+ ` <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+ <and>
+ <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+
+ </or>
+ </enabledWhen>
+ </page>
+
+ <page
+ class="org.eclipse.cdt.ui.newui.Page_ExpPathAndSymb"
+ id="org.eclipse.ui.propertypages.project.ref16"
+ name="%CDTExpPathSymbolsProperty.name"
+ >
+ <filter
+ name="projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
+ </filter>
+ <enabledWhen>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+ </or>
+ </enabledWhen>
+ </page>
+
+ <page
+ class="org.eclipse.cdt.ui.newui.Page_BuildSettings"
+ id="org.eclipse.ui.propertypages.project.ref13"
+ name="%CDTBuildProperty.name"
+ >
+ <filter
+ name="projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
+ </filter>
+ <enabledWhen>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+
+ <instanceof value="org.eclipse.core.resources.IFolder"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
+
+ <and>
+` <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+ <and>
+ <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+ </or>
+ </enabledWhen>
+ </page>
+ <!--page
+ class="org.eclipse.cdt.ui.newui.Page_ToolChain"
+ id="org.eclipse.ui.propertypages.project.ref14"
+ name="%CDTToolchainProperty.name"
+ >
+ <filter
+ name="projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
+ </filter>
+ <enabledWhen>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+
+ <instanceof value="org.eclipse.core.resources.IFolder"/>
+ <instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
+
+ <and>
+ ` <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+ <and>
+ <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
+ <test property="org.eclipse.cdt.ui.isSource" value="" />
+ </and>
+ </or>
+ </enabledWhen>
+ </page-->
+ </extension>
+
</plugin>
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/schema/CDTWizard.exsd b/build/org.eclipse.cdt.managedbuilder.ui/schema/CDTWizard.exsd
new file mode 100644
index 00000000000..0c94ceb416f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/schema/CDTWizard.exsd
@@ -0,0 +1,122 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.ui" id="CDTWizard" name="CDTWizard"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="wizard" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="wizard">
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.ui.newproperties.build.ICNewWizard"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="parent" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/schema/CNewWizard.exsd b/build/org.eclipse.cdt.managedbuilder.ui/schema/CNewWizard.exsd
new file mode 100644
index 00000000000..64af2a6bdc2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/schema/CNewWizard.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.ui" id="CNewWizard" name="CNewWizard"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="wizard">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="parent" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.ui.newproperties.build.ICNewWizard"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/schema/DiscoveryProfileUI.exsd b/build/org.eclipse.cdt.managedbuilder.ui/schema/DiscoveryProfileUI.exsd
new file mode 100644
index 00000000000..9622c2e202d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/schema/DiscoveryProfileUI.exsd
@@ -0,0 +1,139 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.ui" id="DiscoveryProfileUI" name="Scanner configuration discovery profile options UI"/>
+ </appInfo>
+ <documentation>
+ A
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <documentation>
+ An extension to define implementation of a SCD profile options page.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="profilePage" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="profilePage">
+ <annotation>
+ <documentation>
+ Element defines a class that implements SCD profile options page for a profile with specified id.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ Page name.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="profileId" type="string" use="required">
+ <annotation>
+ <documentation>
+ Associated profile id.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ A class that extends &lt;samp&gt;AbstractDiscoveryPage&lt;/samp&gt; abstract class.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="profilePattern" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java
deleted file mode 100644
index bd3f0f72ade..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java
+++ /dev/null
@@ -1,747 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 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:
- * QNX Software Systems - Move to Make plugin
- * Intel Corp - Use in Managed Make system
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildProcessManager;
-import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Text;
-
-public class BuildSettingsBlock extends AbstractCOptionPage {
-
- /*
- * String constants
- */
- private static final String PREFIX = "BuildSettingsBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
- private static final String GROUP = LABEL + ".makecmdgroup"; //$NON-NLS-1$
- private static final String DEF_BTN = LABEL + ".makecmddef"; //$NON-NLS-1$
- private static final String OUTPUT_GROUP = LABEL + ".output.group"; //$NON-NLS-1$
- private static final String OUTPUT_EXT = LABEL + ".output.extension"; //$NON-NLS-1$
- private static final String OUTPUT_NAME = LABEL + ".output.name"; //$NON-NLS-1$
- private static final String MACROS_GROUP = LABEL + ".macros.group"; //$NON-NLS-1$
- private static final String MACROS_EXPAND_BTN = LABEL + ".macros.expand"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_GROUP = LABEL + ".internal.builder.group"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_ENABLE_BTN = LABEL + ".internal.builder.enable"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_IGNORE_ERR_BTN = LABEL + ".internal.builder.ignore.err"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_PARALLEL = LABEL + ".internal.builder.parallel.head"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_PARALLEL_BTN = LABEL + ".internal.builder.parallel.use"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_PARALLEL_DEF = LABEL + ".internal.builder.parallel.default"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_PARALLEL_NUM = LABEL + ".internal.builder.parallel.number"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_PARALLEL_TOOLTIP = LABEL + ".internal.builder.parallel.tooltip"; //$NON-NLS-1$
- private static final String INTERNAL_BUILDER_EXPERIMENTAL_NOTE = LABEL + ".internal.builder.experimental.note"; //$NON-NLS-1$
-
- private static final String EMPTY_STRING = new String();
-
- /*
- * Dialog widgets
- */
- protected Text buildArtifactExt;
- protected Text buildArtifactName;
- protected Button makeCommandDefault;
- protected Group makeCommandGroup;
- protected Text makeCommandEntry;
- protected Button buildMacrosExpand;
- protected Group buildMacrosExpandGroup;
- protected Group internalBuilderGroup;
- protected Button internalBuilderEnable;
- protected Button internalBuilderIgnoreErr;
- protected Button internalBuilderParallel;
- protected Button internalBuilderParallelDef1;
- protected Button internalBuilderParallelDef2;
- protected Spinner parallelProcesses;
- protected final int cpuNumber = BuildProcessManager.checkCPUNumber();
-
- /*
- * Bookeeping variables
- */
- private BuildPropertyPage parent;
- // Has the page been changed?
- private boolean dirty = false;
-
- private ModifyListener widgetModified = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- IConfiguration config = parent.getSelectedConfigurationClone();
- if(e.widget == buildArtifactName){
- String val = buildArtifactName.getText().trim();
- if(!val.equals(config.getArtifactName())){
- config.setArtifactName(val);
- setValues();
- setDirty(true);
- }
- } else if(e.widget == buildArtifactExt){
- String val = buildArtifactExt.getText().trim();
- if(!val.equals(config.getArtifactExtension())){
- config.setArtifactExtension(val);
- setValues();
- setDirty(true);
- }
- } else if(e.widget == makeCommandEntry) {
- String fullCommand = makeCommandEntry.getText().trim();
- String buildCommand = parseMakeCommand(fullCommand);
- String buildArgs = parseMakeArgs(fullCommand);
- if(!buildCommand.equals(config.getBuildCommand())
- || !buildArgs.equals(config.getBuildArguments())){
- parent.getSelectedConfigurationClone().setBuildCommand(buildCommand);
- parent.getSelectedConfigurationClone().setBuildArguments(buildArgs);
- setValues();
- setDirty(true);
- }
- }
- }
- };
-
-
- /*
- * Constructor
- */
- public BuildSettingsBlock(BuildPropertyPage parent)
- {
- super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
- super.setContainer(parent);
- this.parent = parent;
- }
-
- public void createControl(Composite parent) {
- Composite comp = new Composite(parent, SWT.NULL);
- comp.setFont(parent.getFont());
- comp.setLayout(new GridLayout(1, true));
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- setControl(comp);
-
- // Create a group for the build output
- createBuildArtifactGroup(comp);
-
- // Create the make command group area
- createMakeCommandGroup(comp);
-
- // Create the build macros usage configuration area
- createExpandMacrosGroup(comp);
-
- // Create the Internal Builder configuration area
- createInternalBuilderGroup(comp);
- }
-
- /* (non-Javadoc)
- * Creates the group that contains the build artifact name controls.
- */
- private void createBuildArtifactGroup(Composite parent) {
- final Group outputGroup = new Group(parent, SWT.NONE);
- outputGroup.setFont(parent.getFont());
- outputGroup.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_GROUP));
- outputGroup.setLayout(new GridLayout(3, false));
- outputGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Three labels
- final Label nameLabel = new Label(outputGroup, SWT.LEFT);
- nameLabel.setFont(outputGroup.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_NAME));
- nameLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- final Label placeHolder = new Label(outputGroup, SWT.CENTER);
- placeHolder.setText(new String());
- placeHolder.setLayoutData(new GridData());
-
- final Label extLabel = new Label(outputGroup, SWT.LEFT);
- extLabel.setFont(outputGroup.getFont());
- extLabel.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_EXT));
- extLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Now we need two text widgets separated by a label
- buildArtifactName = new Text(outputGroup, SWT.SINGLE | SWT.BORDER);
- buildArtifactName.setFont(outputGroup.getFont());
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- buildArtifactName.setLayoutData(data);
- buildArtifactName.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- buildArtifactName = null;
- }
- });
- buildArtifactName.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(OUTPUT_NAME);
- }
- });
- buildArtifactName.addModifyListener(widgetModified);
-
- final Label dotLabel = new Label(outputGroup, SWT.CENTER);
- dotLabel.setFont(outputGroup.getFont());
- dotLabel.setText(new String(".")); //$NON-NLS-1$
- dotLabel.setLayoutData(new GridData());
-
- buildArtifactExt = new Text(outputGroup, SWT.SINGLE | SWT.BORDER);
- buildArtifactExt.setFont(outputGroup.getFont());
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH / 2);
- buildArtifactExt.setLayoutData(data);
- buildArtifactExt.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- buildArtifactExt = null;
- }
- });
- buildArtifactExt.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(OUTPUT_EXT);
- }
- });
- buildArtifactExt.addModifyListener(widgetModified);
- }
-
- /* (non-Javadoc)
- * Creates the group control for the make command
- * @param parent
- */
- private void createMakeCommandGroup(Composite parent) {
- makeCommandGroup = new Group(parent, SWT.NONE);
- makeCommandGroup.setFont(parent.getFont());
- makeCommandGroup.setText(ManagedBuilderUIMessages.getResourceString(GROUP));
- makeCommandGroup.setLayout(new GridLayout(1, true));
- makeCommandGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- makeCommandDefault = new Button(makeCommandGroup, SWT.CHECK | SWT.LEFT);
- makeCommandDefault.setFont(makeCommandGroup.getFont());
- makeCommandDefault.setText(ManagedBuilderUIMessages.getResourceString(DEF_BTN));
- makeCommandDefault.setBackground(makeCommandGroup.getBackground());
- makeCommandDefault.setForeground(makeCommandGroup.getForeground());
- makeCommandDefault.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- handleUseDefaultPressed();
- }
- });
- makeCommandDefault.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- makeCommandDefault = null;
- }
- });
-
- makeCommandEntry = new Text(makeCommandGroup, SWT.SINGLE | SWT.BORDER);
- makeCommandEntry.setFont(makeCommandGroup.getFont());
- makeCommandEntry.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- makeCommandEntry.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- makeCommandEntry = null;
- }
- });
- makeCommandEntry.addModifyListener(widgetModified);
- }
-
- /* (non-Javadoc)
- * Creates the group containing the check-box that allow user to specify
- * whether the environment variable macros should be expanded or kept in the makefile
- * @param parent
- */
- private void createExpandMacrosGroup(Composite parent) {
- buildMacrosExpandGroup = new Group(parent, SWT.NONE);
- buildMacrosExpandGroup.setFont(parent.getFont());
- buildMacrosExpandGroup.setText(ManagedBuilderUIMessages.getResourceString(MACROS_GROUP));
- buildMacrosExpandGroup.setLayout(new GridLayout(1, true));
- buildMacrosExpandGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- buildMacrosExpand = new Button(buildMacrosExpandGroup, SWT.CHECK | SWT.LEFT);
- buildMacrosExpand.setFont(buildMacrosExpandGroup.getFont());
- buildMacrosExpand.setText(ManagedBuilderUIMessages.getResourceString(MACROS_EXPAND_BTN));
- buildMacrosExpand.setBackground(buildMacrosExpandGroup.getBackground());
- buildMacrosExpand.setForeground(buildMacrosExpandGroup.getForeground());
- buildMacrosExpand.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- IConfiguration config = BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
- if(buildMacrosExpand.getSelection() != provider.areMacrosExpandedInBuildfile(config)){
- provider.expandMacrosInBuildfile(config,
- buildMacrosExpand.getSelection());
- setValues();
- setDirty(true);
- }
- }
- });
- buildMacrosExpand.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- buildMacrosExpand = null;
- }
- });
- }
-
- /* (non-Javadoc)
- * Creates the group containing the check-box that allow user to specify
- * whether the environment variable macros should be expanded or kept in the makefile
- * @param parent
- */
- private void createInternalBuilderGroup(Composite parent) {
- internalBuilderGroup = new Group(parent, SWT.NONE);
- internalBuilderGroup.setFont(parent.getFont());
- internalBuilderGroup.setText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_GROUP));
- internalBuilderGroup.setLayout(new GridLayout(2, false));
- internalBuilderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label dotLabel = new Label(internalBuilderGroup, SWT.CENTER);
- dotLabel.setFont(internalBuilderGroup.getFont());
- dotLabel.setText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_EXPERIMENTAL_NOTE));
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- dotLabel.setLayoutData(gd);
-
- internalBuilderEnable = createInternalBuilderButton(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_ENABLE_BTN), 2);
- internalBuilderEnable.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
- config.enableInternalBuilder(internalBuilderEnable.getSelection());
- setValues();
- setDirty(true);
- }
- });
- internalBuilderEnable.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- internalBuilderEnable = null;
- }
- });
-
- internalBuilderIgnoreErr = createInternalBuilderButton(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_IGNORE_ERR_BTN), 2);
- internalBuilderIgnoreErr.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
- config.setInternalBuilderIgnoreErr(internalBuilderIgnoreErr.getSelection());
- setValues();
- setDirty(true);
- }
- });
- internalBuilderIgnoreErr.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- internalBuilderIgnoreErr = null;
- }
- });
-
- Label parallelLabel = new Label(internalBuilderGroup, SWT.CENTER);
- parallelLabel.setFont(internalBuilderGroup.getFont());
- parallelLabel.setBackground(internalBuilderGroup.getBackground());
- parallelLabel.setForeground(internalBuilderGroup.getForeground());
- parallelLabel.setText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_PARALLEL));
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- parallelLabel.setLayoutData(gd);
-
- internalBuilderParallel = createInternalBuilderButton(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_PARALLEL_BTN), 2);
- internalBuilderParallel.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
- config.setInternalBuilderParallel(internalBuilderParallel.getSelection());
- setValues();
- setDirty(true);
- }
- });
- internalBuilderParallel.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) { internalBuilderParallel = null; }
- });
-
- internalBuilderParallelDef1 = new Button(internalBuilderGroup, SWT.RADIO);
- internalBuilderParallelDef1.setFont(internalBuilderGroup.getFont());
- internalBuilderParallelDef1.setBackground(internalBuilderGroup.getBackground());
- internalBuilderParallelDef1.setForeground(internalBuilderGroup.getForeground());
- internalBuilderParallelDef1.setText("Use optimal jobs number");
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- gd.horizontalIndent = 15;
- internalBuilderParallelDef1.setLayoutData(gd);
- internalBuilderParallelDef1.setSelection(true);
-
- internalBuilderParallelDef1.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
- config.setParallelDef(internalBuilderParallelDef1.getSelection());
- setValues();
- setDirty(true);
- }
- });
-
- internalBuilderParallelDef1.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) { internalBuilderParallelDef1 = null; }
- });
-
- internalBuilderParallelDef2 = new Button(internalBuilderGroup, SWT.RADIO);
- internalBuilderParallelDef2.setFont(internalBuilderGroup.getFont());
- internalBuilderParallelDef2.setBackground(internalBuilderGroup.getBackground());
- internalBuilderParallelDef2.setForeground(internalBuilderGroup.getForeground());
- internalBuilderParallelDef2.setText("Use parallel jobs :");
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent = 15;
- internalBuilderParallelDef2.setLayoutData(gd);
-
- internalBuilderParallelDef2.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
- config.setParallelDef(!internalBuilderParallelDef2.getSelection());
- setValues();
- setDirty(true);
- }
- });
-
- internalBuilderParallelDef2.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) { internalBuilderParallelDef2 = null; }
- });
-
- parallelProcesses = new Spinner(internalBuilderGroup, SWT.BORDER);
- parallelProcesses.setFont(internalBuilderGroup.getFont());
- parallelProcesses.setBackground(internalBuilderGroup.getBackground());
- parallelProcesses.setForeground(internalBuilderGroup.getForeground());
- parallelProcesses.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- parallelProcesses.setValues(cpuNumber, 1, 10000, 0, 1, 10);
- parallelProcesses.setToolTipText(ManagedBuilderUIMessages.getResourceString(INTERNAL_BUILDER_PARALLEL_TOOLTIP));
-
- parallelProcesses.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- Configuration config = (Configuration)BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
- config.setParallelNumber(parallelProcesses.getSelection());
- setValues();
- setDirty(true);
- }
- });
-
- parallelProcesses.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) { parallelProcesses = null; }
- });
- }
-
- private Button createInternalBuilderButton(String s, int hSpan) {
- Button b = new Button(internalBuilderGroup, SWT.CHECK | SWT.LEFT);
- b.setFont(internalBuilderGroup.getFont());
- b.setText(s);
- b.setBackground(internalBuilderGroup.getBackground());
- b.setForeground(internalBuilderGroup.getForeground());
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = hSpan;
- b.setLayoutData(gd);
- return b;
- }
-
- protected void initializeValues() {
- setValues();
- setDirty(false);
- }
-
- public void updateValues() {
- setValues();
- makeCommandDefault.setSelection(!parent.getSelectedConfigurationClone().hasOverriddenBuildCommand());
- makeCommandEntry.setEditable(!makeCommandDefault.getSelection());
- }
-
- protected void setValues() {
- Configuration config = (Configuration)parent.getSelectedConfigurationClone();
- if(!config.getArtifactName().equals(buildArtifactName.getText()))
- buildArtifactName.setText(config.getArtifactName());
-
- if(!config.getArtifactExtension().equals(buildArtifactExt.getText()))
- buildArtifactExt.setText(config.getArtifactExtension());
- String makeCommand = config.getBuildCommand();
- String makeArgs = config.getBuildArguments();
- if (makeArgs != null) {
- makeCommand += " " + makeArgs; //$NON-NLS-1$
- }
- if(!makeCommand.equals(makeCommandEntry.getText()))
- makeCommandEntry.setText(makeCommand);
-
- BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- if(!provider.canKeepMacrosInBuildfile(config))
- buildMacrosExpandGroup.setVisible(false);
- else {
- buildMacrosExpandGroup.setVisible(true);
- buildMacrosExpand.setSelection(provider.areMacrosExpandedInBuildfile(config));
- }
-
- boolean internalBuilderOn = config.isInternalBuilderEnabled();
- internalBuilderEnable.setSelection(internalBuilderOn);
- internalBuilderIgnoreErr.setSelection(config.getInternalBuilderIgnoreErr());
- internalBuilderParallel.setSelection(config.getInternalBuilderParallel());
- internalBuilderParallelDef1.setSelection(config.getParallelDef());
- internalBuilderParallelDef2.setSelection(!config.getParallelDef());
- parallelProcesses.setSelection(config.getParallelNumber());
-
- makeCommandDefault.setEnabled(!internalBuilderOn);
- makeCommandEntry.setEnabled(!internalBuilderOn);
- makeCommandGroup.setEnabled(!internalBuilderOn);
- buildMacrosExpand.setEnabled(!internalBuilderOn);
- buildMacrosExpandGroup.setEnabled(!internalBuilderOn);
- internalBuilderIgnoreErr.setEnabled(internalBuilderOn);
- internalBuilderParallel.setEnabled(internalBuilderOn);
- internalBuilderParallelDef1.setEnabled(internalBuilderOn && config.getInternalBuilderParallel());
- internalBuilderParallelDef2.setEnabled(internalBuilderOn && config.getInternalBuilderParallel());
- parallelProcesses.setEnabled(internalBuilderOn && config.getInternalBuilderParallel() && !config.getParallelDef());
-
-// setDirty(false);
- }
-
- public void removeValues(String id) {
- // Nothing to do...
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
-
- IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
- cloneConfig.setArtifactName(cloneConfig.getManagedProject().getDefaultArtifactName());
- cloneConfig.setArtifactExtension(null);
- IBuilder cloneBuilder = cloneConfig.getToolChain().getBuilder();
- if (!cloneBuilder.isExtensionElement()) {
- cloneConfig.getToolChain().removeLocalBuilder();
- }
-
-
- //set the expand macros state to false
- BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- provider.expandMacrosInBuildfile(cloneConfig,false);
-
- setValues();
- makeCommandDefault.setSelection(true);
- makeCommandEntry.setEditable(false);
-
- setDirty(true);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- Configuration selectedConfiguration = (Configuration)parent.getSelectedConfiguration();
- Configuration cloneConfig = (Configuration)parent.getSelectedConfigurationClone();
-
- String buildCommand = cloneConfig.getBuildCommand();
- String buildArgs = cloneConfig.getBuildArguments();
- String artifactName = cloneConfig.getArtifactName();
- String artifactExt = cloneConfig.getArtifactExtension();
-
- // Set the build output name
- if (!selectedConfiguration.getArtifactName().equals(artifactName)) {
- selectedConfiguration.setArtifactName(artifactName);
- }
- // Set the build output extension
- if (!selectedConfiguration.getArtifactExtension().equals(artifactExt)) {
- selectedConfiguration.setArtifactExtension(artifactExt);
- }
- // Set the new make command
- if(!selectedConfiguration.getBuildCommand().equals(buildCommand))
- selectedConfiguration.setBuildCommand(buildCommand);
-
- if(!selectedConfiguration.getBuildArguments().equals(buildArgs))
- selectedConfiguration.setBuildArguments(buildArgs);
-
- BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- provider.expandMacrosInBuildfile(
- selectedConfiguration,
- provider.areMacrosExpandedInBuildfile(cloneConfig));
-
- selectedConfiguration.enableInternalBuilder(cloneConfig.isInternalBuilderEnabled());
- selectedConfiguration.setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr());
- selectedConfiguration.setInternalBuilderParallel(cloneConfig.getInternalBuilderParallel());
- selectedConfiguration.setParallelDef(cloneConfig.getParallelDef());
- selectedConfiguration.setParallelNumber(cloneConfig.getParallelNumber());
-
- setDirty(false);
- }
-
- /* (non-Javadoc)
- * @param rawCommand
- * @return
- */
- private String parseMakeArgs(String rawCommand) {
- StringBuffer result = new StringBuffer();
-
- // Parse out the command
- String actualCommand = parseMakeCommand(rawCommand);
-
- // The flags and targets are anything not in the command
- String arguments = rawCommand.substring(actualCommand.length());
-
- // If there aren't any, we can stop
- if (arguments.length() == 0) {
- return result.toString().trim();
- }
-
- String[] tokens = arguments.trim().split("\\s"); //$NON-NLS-1$
- /*
- * Cases to consider
- * --<flag> Sensible, modern single flag. Add to result and continue.
- * -<flags> Flags in single token, add to result and stop
- * -<flag_with_arg> ARG Flag with argument. Add next token if valid arg.
- * -<mixed_flags> ARG Mix of flags, one takes arg. Add next token if valid arg.
- * -<flag_with_arg>ARG Corrupt case where next token should be arg but isn't
- * -<flags> [target].. Flags with no args, another token, add flags and stop.
- */
- Pattern flagPattern = Pattern.compile("C|f|I|j|l|O|W"); //$NON-NLS-1$
- // Look for a '-' followed by 1 or more flags with no args and exactly 1 that expects args
- Pattern mixedFlagWithArg = Pattern.compile("-[^CfIjloW]*[CfIjloW]{1}.+"); //$NON-NLS-1$
- for (int i = 0; i < tokens.length; ++i) {
- String currentToken = tokens[i];
- if (currentToken.startsWith("--")) { //$NON-NLS-1$
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- } else if (currentToken.startsWith("-")) { //$NON-NLS-1$
- // Is there another token
- if (i + 1 >= tokens.length) {
- //We are done
- result.append(currentToken);
- } else {
- String nextToken = tokens[i + 1];
- // Are we expecting arguments
- Matcher flagMatcher = flagPattern.matcher(currentToken);
- if (!flagMatcher.find()) {
- // Evalutate whether the next token should be added normally
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- } else {
- // Look for the case where there is no space between flag and arg
- if (mixedFlagWithArg.matcher(currentToken).matches()) {
- // Add this single token and keep going
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- } else {
- // Add this token and the next one right now
- result.append(currentToken);
- result.append(" "); //$NON-NLS-1$
- result.append(nextToken);
- result.append(" "); //$NON-NLS-1$
- // Skip the next token the next time through, though
- ++i;
- }
- }
- }
- }
- }
-
- return result.toString().trim();
- }
-
- /* (non-Javadoc)
- *
- * @param string
- * @return
- */
- private String parseMakeCommand(String rawCommand) {
- StringBuffer command = new StringBuffer();
- boolean hasSpace = false;
-
- // Try to separate out the command from the arguments
- String[] result = rawCommand.split("\\s"); //$NON-NLS-1$
-
- /*
- * Here are the cases to consider:
- * cmd First segment is last segment, assume is command
- * cmd [flags] First segment is the command
- * path/cmd [flags] Same as above
- * path with space/make [flags] Must append each segment up-to flags as command
- */
- for (int i = 0; i < result.length; ++i) {
- // Get the segment
- String cmdSegment = result[i];
- // If there is not another segment, we found the end
- if (i + 1 >= result.length) {
- command.append(cmdSegment);
- } else {
- // See if the next segment is the start of the flags
- String nextSegment = result[i + 1];
- if (nextSegment.startsWith("-")) { //$NON-NLS-1$
- // we have found the end of the command
- command.append(cmdSegment);
- break;
- } else {
- command.append(cmdSegment);
- // Add the whitespace back
- command.append(" "); //$NON-NLS-1$
- hasSpace = true;
- }
- }
- }
-
-// if (hasSpace == true) {
-// return "\"" + command.toString().trim() + "\"";
-// } else {
- return command.toString().trim();
-// }
- }
-
- public IPreferenceStore getPreferenceStore() {
- return null;
- }
- /* (non-Javadoc)
- * Initialize the "Use default command" field
- */
- public void setVisible(boolean visible) {
- if (visible) {
- setValues();
- }
- super.setVisible(visible);
- }
-
- /* (non-Javadoc)
- * Event handler for the use default check box in the make command group
- */
- protected void handleUseDefaultPressed() {
- // If the state of the button is unchecked, then we want to enable the edit widget
- boolean checked = makeCommandDefault.getSelection();
- IConfiguration config = parent.getSelectedConfigurationClone();
- if (checked == true) {
- config.setBuildCommand(null);
- config.setBuildArguments(null);
- makeCommandEntry.setEditable(false);
- } else {
- makeCommandEntry.setEditable(true);
- }
- setValues();
- setDirty(true);
- }
-
- /**
- * Sets the "dirty" state
- */
- public void setDirty(boolean b) {
- dirty = b;
- }
-
- /**
- * Returns the "dirty" state
- */
- public boolean isDirty() {
- return dirty;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java
deleted file mode 100644
index e11187a1155..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-public class BuildStepSettingsBlock extends AbstractCOptionPage {
-
- /*
- * String constants
- */
- private static final String PREFIX = "BuildStepSettingsBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
- private static final String PREBUILD_GROUP = LABEL + ".prebuildstep.group"; //$NON-NLS-1$
- private static final String PREBUILD_CMD = LABEL + ".prebuildstep.cmd"; //$NON-NLS-1$
- private static final String PREBUILD_DESC = LABEL + ".prebuildstep.desc"; //$NON-NLS-1$
- private static final String POSTBUILD_GROUP = LABEL + ".postbuildstep.group"; //$NON-NLS-1$
- private static final String POSTBUILD_CMD = LABEL + ".postbuildstep.cmd"; //$NON-NLS-1$
- private static final String POSTBUILD_DESC = LABEL + ".postbuildstep.desc"; //$NON-NLS-1$
- private static final String EMPTY_STRING = new String();
-
- /*
- * Dialog widgets
- */
- protected Text preBuildCmd;
- protected Text preBuildAnnc;
- protected Text postBuildCmd;
- protected Text postBuildAnnc;
-
- /*
- * Bookeeping variables
- */
- private BuildPropertyPage parent;
-
- // Has the page been changed?
- private boolean dirty = false;
-
- private ModifyListener widgetModified = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- IConfiguration config = parent.getSelectedConfigurationClone();
- if(e.widget == preBuildCmd){
- String val = preBuildCmd.getText().trim();
- if(!val.equals(config.getPrebuildStep())){
- config.setPrebuildStep(val);
- setValues();
- setDirty(true);
- }
- } else if(e.widget == preBuildAnnc){
- String val = preBuildAnnc.getText().trim();
- if(!val.equals(config.getPreannouncebuildStep())){
- config.setPreannouncebuildStep(val);
- setValues();
- setDirty(true);
- }
- } else if(e.widget == postBuildCmd){
- String val = postBuildCmd.getText().trim();
- if(!val.equals(config.getPostbuildStep())){
- config.setPostbuildStep(val);
- setValues();
- setDirty(true);
- }
- } else if(e.widget == postBuildAnnc){
- String val = postBuildAnnc.getText().trim();
- if(!val.equals(config.getPostannouncebuildStep())){
- config.setPostannouncebuildStep(val);
- setValues();
- setDirty(true);
- }
- }
-
- }
- };
-
- /*
- * Constructor
- */
- public BuildStepSettingsBlock(BuildPropertyPage parent)
- {
- super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
- super.setContainer(parent);
- this.parent = parent;
- }
-
- public void createControl(Composite parent) {
- Composite comp = new Composite(parent, SWT.NULL);
- comp.setFont(parent.getFont());
- comp.setLayout(new GridLayout(1, true));
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- setControl(comp);
-
- // Create a group for the prebuild step
- createPreBuildStepGroup(comp);
-
- // Create a group for the postbuild step
- createPostBuildStepGroup(comp);
- }
-
- /* (non-Javadoc)
- * Creates the group that contains the pre-build step controls.
- */
- private void createPreBuildStepGroup(Composite parent) {
- final Group preBuildStepGroup = new Group(parent, SWT.NONE);
- preBuildStepGroup.setFont(parent.getFont());
- preBuildStepGroup.setText(ManagedBuilderUIMessages.getResourceString(PREBUILD_GROUP));
- preBuildStepGroup.setLayout(new GridLayout(1, true));
- preBuildStepGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Pre-build command label
- final Label cmdLabel = new Label(preBuildStepGroup, SWT.LEFT);
- cmdLabel.setFont(preBuildStepGroup.getFont());
- cmdLabel.setText(ManagedBuilderUIMessages.getResourceString(PREBUILD_CMD));
- cmdLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Text widget for pre-build command
- preBuildCmd = new Text(preBuildStepGroup, SWT.SINGLE | SWT.BORDER);
- preBuildCmd.setFont(preBuildStepGroup.getFont());
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- preBuildCmd.setLayoutData(data);
- preBuildCmd.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- preBuildCmd = null;
- }
- });
- preBuildCmd.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(PREBUILD_CMD);
- }
- });
- preBuildCmd.addModifyListener(widgetModified);
-
- final Label descLabel = new Label(preBuildStepGroup, SWT.LEFT);
- descLabel.setFont(preBuildStepGroup.getFont());
- descLabel.setText(ManagedBuilderUIMessages.getResourceString(PREBUILD_DESC));
- descLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Text widget for the pre-build description
- preBuildAnnc = new Text(preBuildStepGroup, SWT.SINGLE | SWT.BORDER);
- preBuildAnnc.setFont(preBuildStepGroup.getFont());
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH);
- preBuildAnnc.setLayoutData(data);
- preBuildAnnc.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- preBuildAnnc = null;
- }
- });
- preBuildAnnc.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(PREBUILD_DESC);
- }
- });
- preBuildAnnc.addModifyListener(widgetModified);
- }
-
- /* (non-Javadoc)
- * Creates the group that contains the post-build step controls.
- */
- private void createPostBuildStepGroup(Composite parent) {
- final Group postBuildStepGroup = new Group(parent, SWT.NONE);
- postBuildStepGroup.setFont(parent.getFont());
- postBuildStepGroup.setText(ManagedBuilderUIMessages.getResourceString(POSTBUILD_GROUP));
- postBuildStepGroup.setLayout(new GridLayout(1, true));
- postBuildStepGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Post-build command label
- final Label cmdLabel = new Label(postBuildStepGroup, SWT.LEFT);
- cmdLabel.setFont(postBuildStepGroup.getFont());
- cmdLabel.setText(ManagedBuilderUIMessages.getResourceString(POSTBUILD_CMD));
- cmdLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Text widget for the post-build command
- postBuildCmd = new Text(postBuildStepGroup, SWT.SINGLE | SWT.BORDER);
- postBuildCmd.setFont(postBuildStepGroup.getFont());
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- postBuildCmd.setLayoutData(data);
- postBuildCmd.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- postBuildCmd = null;
- }
- });
- postBuildCmd.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(POSTBUILD_CMD);
- }
- });
- postBuildCmd.addModifyListener(widgetModified);
-
- // Post-build description label
- final Label descLabel = new Label(postBuildStepGroup, SWT.LEFT);
- descLabel.setFont(postBuildStepGroup.getFont());
- descLabel.setText(ManagedBuilderUIMessages.getResourceString(POSTBUILD_DESC));
- descLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Text widget for the post-build description
- postBuildAnnc = new Text(postBuildStepGroup, SWT.SINGLE | SWT.BORDER);
- postBuildAnnc.setFont(postBuildStepGroup.getFont());
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH);
- postBuildAnnc.setLayoutData(data);
- postBuildAnnc.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- postBuildAnnc = null;
- }
- });
- postBuildAnnc.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(POSTBUILD_DESC);
- }
- });
- postBuildAnnc.addModifyListener(widgetModified);
- }
-
- protected void initializeValues() {
- setValues();
- setDirty(false);
- }
-
- public void updateValues() {
- setValues();
- }
-
- protected void setValues() {
- // Fetch values from the current configuration and set in the UI
- IConfiguration config = parent.getSelectedConfigurationClone();
- if(!config.getPrebuildStep().equals(preBuildCmd.getText()))
- preBuildCmd.setText(config.getPrebuildStep());
-
- if(!config.getPreannouncebuildStep().equals(preBuildAnnc.getText()))
- preBuildAnnc.setText(config.getPreannouncebuildStep());
-
- if(!config.getPostbuildStep().equals(postBuildCmd.getText()))
- postBuildCmd.setText(config.getPostbuildStep());
-
- if(!config.getPostannouncebuildStep().equals(postBuildAnnc.getText()))
- postBuildAnnc.setText(config.getPostannouncebuildStep());
- }
-
- public void removeValues(String id) {
- // Nothing to do...
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
-
- cloneConfig.setPrebuildStep(null);
- cloneConfig.setPreannouncebuildStep(null);
- cloneConfig.setPostbuildStep(null);
- cloneConfig.setPostannouncebuildStep(null);
-
- // Fetch and set the default values to be displayed in the UI
- setValues();
- setDirty(true);
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
-
- IConfiguration selectedConfiguration = parent.getSelectedConfiguration();
- IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
-
- if (!selectedConfiguration.getPrebuildStep().equals(
- cloneConfig.getPrebuildStep())) {
- selectedConfiguration.setPrebuildStep(cloneConfig.getPrebuildStep());
- }
- if (!selectedConfiguration.getPreannouncebuildStep().equals(
- cloneConfig.getPreannouncebuildStep())) {
- selectedConfiguration.setPreannouncebuildStep(cloneConfig.getPreannouncebuildStep());
- }
- if (!selectedConfiguration.getPostbuildStep().equals(
- cloneConfig.getPostbuildStep())) {
- selectedConfiguration.setPostbuildStep(cloneConfig.getPostbuildStep());
- }
- if (!selectedConfiguration.getPostannouncebuildStep().equals(
- cloneConfig.getPostannouncebuildStep())) {
- selectedConfiguration.setPostannouncebuildStep(cloneConfig.getPostannouncebuildStep());
- }
-
- setDirty(false); //Indicate that the UI state is consistent with internal state
- }
-
- public IPreferenceStore getPreferenceStore() {
- return null;
- }
-
- /**
- * Sets the "dirty" state, which indicates whether or not the state of the build step UI is consistent
- * with its corresponding internal state
- */
- public void setDirty(boolean b) {
- dirty = b;
- }
-
- /**
- * Returns the "dirty" state, which indicates whether or not the state of the build step UI is consistent
- * with its corresponding internal state
- */
- public boolean isDirty() {
- return dirty;
- }
-
- public void setVisible(boolean visible){
- if(visible)
- setValues();
- super.setVisible(visible);
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java
deleted file mode 100644
index a725c33bcb6..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java
+++ /dev/null
@@ -1,1230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
-import org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarCollector;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.EclipseVariablesMacroSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
-import org.eclipse.cdt.managedbuilder.ui.properties.AbstractBuildPropertyPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.variables.IDynamicVariable;
-import org.eclipse.core.variables.IStringVariable;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.JFacePreferences;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IFontProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableFontProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * displays the environment for the given context
- */
-public class EnvironmentBlock extends AbstractCOptionPage {
- /*
- * String constants
- */
- private static final String PREFIX = "EnvironmentBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
-
- private static final String USER_VAR = LABEL + ".user.var"; //$NON-NLS-1$
- private static final String SYSTEM_VAR = LABEL + ".system.var"; //$NON-NLS-1$
-
- private static final String HEADER = LABEL + ".header"; //$NON-NLS-1$
- private static final String HEADER_NAME = HEADER + ".name"; //$NON-NLS-1$
- private static final String HEADER_VALUE = HEADER + ".value"; //$NON-NLS-1$
-
- private static final String BUTTON = LABEL + ".button"; //$NON-NLS-1$
- private static final String BUTTON_NEW = BUTTON + ".new"; //$NON-NLS-1$
- private static final String BUTTON_EDIT = BUTTON + ".edit"; //$NON-NLS-1$
- private static final String BUTTON_DELETE = BUTTON + ".delete"; //$NON-NLS-1$
- private static final String BUTTON_UNDEF = BUTTON + ".undef"; //$NON-NLS-1$
-
- private static final String BUTTON_CHECK_SHOW_PARENT = BUTTON + ".check.chow.parent"; //$NON-NLS-1$
-
- private static final String VALUE_UNDEF = LABEL + ".value.undef"; //$NON-NLS-1$
-
- private static final String DELETE_CONFIRM_TITLE = LABEL + ".delete.confirm.title"; //$NON-NLS-1$
- private static final String DELETE_CONFIRM_MESSAGE = LABEL + ".delete.confirm.message"; //$NON-NLS-1$
-
- private static final String DELETE_ALL_CONFIRM_TITLE = LABEL + ".delete.all.confirm.title"; //$NON-NLS-1$
- private static final String DELETE_ALL_CONFIRM_MESSAGE = LABEL + ".delete.all.confirm.message"; //$NON-NLS-1$
-
- private static final String fHiddenVariables[] = new String[]{
- //currently the "CWD" and "PWD" variables are not displayed in UI and can not be creater by a user
- EnvVarOperationProcessor.normalizeName("CWD"), //$NON-NLS-1$
- EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$
- };
-
- /*
- * button IDs
- */
- private static final int IDX_BUTTON_NEW = 0;
- private static final int IDX_BUTTON_EDIT = 1;
- private static final int IDX_BUTTON_UNDEF = 2;
- private static final int IDX_BUTTON_DELETE = 3;
-
- //variable names deleted by a user
- private HashSet fDeletedUserVariableNames;
- //variables added by a user
- private Map fAddedUserVariables;
- //specifies whether a "delete All" button was previousely pressed
- private boolean fDeleteAll = false;
- //specifies whether the set of the user-defined variables was changed by a user
- //and the changes are not applied to the User Variable Supplier
- private boolean fModified = false;
- //holds the visible state.
-// private boolean fVisible = false;
- //specifies whether the "show parent level variables" checkbox should be created
- private boolean fShowParentViewCheckBox = true;
-
- private boolean fIsEditable = true;
- //inexistent context
- private static final Object fInexistentContext = new Object();
- //the context for which the variables are displayed
- private Object fContext = fInexistentContext;
- //specifies whether the parent level variables should be displayed
- private boolean fShowParentVariables = false;
-
- private IContextInfo fSystemContextInfo;
- private IContextInfo fCurrentContextInfo;
- private IContextInfo fParentContextInfo;
- private boolean fUseDefaultParentContextInfo = true;
-
- //the user defined variable supplier
- private UserDefinedEnvironmentSupplier fUserSupplier;
- //editable table viewer
- private TableViewer fEditableTable;
- //noneditable table viewer
- private TableViewer fNonEditableTable;
-
- private static final String[] fEditableTableColumnProps = new String[] {
- "editable name", //$NON-NLS-1$
- "editable value", //$NON-NLS-1$
- };
-
- private static final String[] fNonEditableTableColumnProps = new String[] {
- "noneditable name", //$NON-NLS-1$
- "noneditable value", //$NON-NLS-1$
- };
-
- private static final String[] fTableColumnNames = new String[] {
- ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
- ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
- };
-
- private static final ColumnLayoutData[] fTableColumnLayouts = {new ColumnPixelData(150), new ColumnPixelData(250)};
-
-
- //the set of names of the incorrestly defined variables
- private Set fIncorrectlyDefinedVariablesNames = new HashSet();
-
-
- /*
- * widgets
- */
- //show parent level variables check-box
- private Button fShowParentButton;
- //parent composite
- private Composite fParent;
- //status label
- private Label fStatusLabel;
- //buttons
- private Button fNewButton;
- private Button fEditButton;
- private Button fUndefButton;
- private Button fDeleteButton;
-
- private class SystemContextInfo extends DefaultContextInfo{
- protected SystemContextInfo(Object context){
- super(context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo#getSuppliers(java.lang.Object)
- */
- protected IEnvironmentVariableSupplier[] getSuppliers(Object context){
- IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context);
- if(suppliers == null || suppliers.length == 0)
- return null;
-
- List list = new ArrayList();
- for(int i = 0; i < suppliers.length; i++){
- if(!(suppliers[i] instanceof UserDefinedEnvironmentSupplier))
- list.add(suppliers[i]);
- }
-
- return (IEnvironmentVariableSupplier[])list.toArray(new IEnvironmentVariableSupplier[list.size()]);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext()
- */
- public IContextInfo getNext(){
- if(fUseDefaultParentContextInfo)
- return super.getNext();
- return fParentContextInfo;
- }
- }
-
- private class CurrentContextInfo extends DefaultContextInfo{
- protected CurrentContextInfo(Object context){
- super(context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo#getSuppliers(java.lang.Object)
- */
- public IEnvironmentVariableSupplier[] getSuppliers(Object context){
- IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context);
-
- if(context == fContext && storeDirectly())
- return suppliers;
-
- if(suppliers == null || suppliers.length == 0)
- return suppliers;
- if(!(suppliers[0] instanceof UserDefinedEnvironmentSupplier))
- return suppliers;
-
- List list = new ArrayList(suppliers.length);
- list.add(new UIVariableSupplier());
-
- for(int i = 1; i < suppliers.length; i++){
- list.add(suppliers[i]);
- }
-
- return (IEnvironmentVariableSupplier[])list.toArray(new IEnvironmentVariableSupplier[list.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext()
- */
- public IContextInfo getNext(){
- if(fUseDefaultParentContextInfo)
- return super.getNext();
- return fParentContextInfo;
- }
- }
-
- private class UIVariableSupplier implements IEnvironmentVariableSupplier{
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable(java.lang.String, java.lang.Object)
- */
- public IBuildEnvironmentVariable getVariable(String name, Object context){
- if(context != fContext)
- return null;
-
- return getUserVariable(name);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables(java.lang.Object)
- */
- public IBuildEnvironmentVariable[] getVariables(Object context){
- if(context != fContext)
- return null;
-
- return getUserVariables();
- }
- }
-
- private class EnvironmentContentProvider implements IStructuredContentProvider{
-
- public Object[] getElements(Object inputElement) {
- return (Object[])inputElement;
- }
-
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // TODO Auto-generated method stub
-
- }
-
- }
-
- private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
- private boolean fUser;
- public EnvironmentLabelProvider(boolean user){
- fUser = user;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- return getColumnText(element, 0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)element;
- switch(columnIndex){
- case 0:
- return var.getName();
- case 1:
- if(var.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
- return ManagedBuilderUIMessages.getResourceString(VALUE_UNDEF);
- return var.getValue();
- }
- return ""; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
- */
- public Font getFont(Object element) {
- return getFont(element, 0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableFontProvider#getFont(java.lang.Object, int)
- */
- public Font getFont(Object element, int columnIndex) {
- IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)element;
-
- switch(columnIndex){
- case 0:
- break;
- case 1:
- if(var.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
- return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);;
- break;
- }
-
- if(!fUser && getUserVariable(var.getName()) != null)
- return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element){
- IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)element;
- boolean incorrect = false;
- String name = var.getName();
- if(fUser || getUserVariable(name) == null)
- incorrect = fIncorrectlyDefinedVariablesNames.contains(name);
-
- if(incorrect)
- return JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
- return null;
-
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
- */
- public Color getBackground(Object element){
- return null;
- }
- }
-
- private class EnvVarUIMacroSubstitutor extends DefaultMacroSubstitutor{
- public EnvVarUIMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter) {
- super(contextInfo, inexistentMacroValue, listDelimiter);
- }
-
- public EnvVarUIMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
- super(contextType, contextData, inexistentMacroValue, listDelimiter);
- }
-
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
- if(macro instanceof EclipseVariablesMacroSupplier.EclipseVarMacro){
- EclipseVariablesMacroSupplier.EclipseVarMacro eclipseVarMacro =
- (EclipseVariablesMacroSupplier.EclipseVarMacro)macro;
- IStringVariable var = eclipseVarMacro.getVariable();
- String value = null;
- if(var instanceof IDynamicVariable){
- value = "dynamic<" + var.getName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- value = macro.getStringValue();
- }
- return new ResolvedMacro(macro.getName(),value);
- }
- return super.resolveMacro(macro);
- }
- }
-
-
- /*
- * constructor
- */
- public EnvironmentBlock(ICOptionContainer parent, String title, boolean editable, boolean showParentViewCheckBox){
- super(title);
- super.setContainer(parent);
-
- fIsEditable = editable;
- fShowParentViewCheckBox = showParentViewCheckBox;
- }
-
- /*
- * returns the map containing the user-defined variables
- */
- private Map getUserVariablesMap(){
- Map map = new HashMap();
- if(fUserSupplier != null) {
- if(!fDeleteAll){
- IBuildEnvironmentVariable vars[] = fUserSupplier.getVariables(fContext);
- if(vars != null) {
- for(int i = 0; i < vars.length; i++){
- String name = vars[i].getName();
- if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
- name = name.toUpperCase();
- map.put(name,vars[i]);
- }
- }
-
- Iterator iter = getDeletedUserVariableNames().iterator();
- while(iter.hasNext()){
- map.remove((String)iter.next());
- }
-
- iter = getAddedUserVariables().values().iterator();
- while(iter.hasNext()){
- IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
- String name = var.getName();
- if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
- name = name.toUpperCase();
- map.put(name,var);
- }
- }
- }
- return map;
- }
-
- private IBuildEnvironmentVariable[] getUserVariables(){
- if(storeDirectly() && fUserSupplier != null)
- return fUserSupplier.getVariables(fContext);
-
- Collection vars = getUserVariablesMap().values();
- return (IBuildEnvironmentVariable[])vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
- }
-
- /*
- * returns the HashSet holding the names of the user-deleted variables
- */
- private HashSet getDeletedUserVariableNames(){
- if(fDeletedUserVariableNames == null)
- fDeletedUserVariableNames = new HashSet();
- return fDeletedUserVariableNames;
- }
-
- /*
- * returns the map holding user-created.modified variables
- */
- private Map getAddedUserVariables(){
- if(fAddedUserVariables == null)
- fAddedUserVariables = new HashMap();
- return fAddedUserVariables;
- }
-
- /*
- * creates a user variable
- * the variables created are stored in the fAddedUserVariables Map, and are not actually added to the user supplier
- * the applyUserVariables() should be called to store those variabes to the user supplier
- */
- private void addUserVariable(String name, String value, int op, String delimiter){
- if(!canCreate(name))
- return;
-
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.createVariable(name,value, op, delimiter, fContext);
- } else {
- fDeleteAll = false;
- BuildEnvVar newVar = new BuildEnvVar(name,value,op,delimiter);
- if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
- name = name.toUpperCase();
- getDeletedUserVariableNames().remove(name);
- getAddedUserVariables().put(name,newVar);
- }
- fModified = true;
- }
-
- protected boolean storeDirectly(){
- if(fContext instanceof IConfiguration)
- return ((IConfiguration)fContext).isTemporary();
- return false;
- }
-
- /*
- * deletes a user variable
- * the variables deleted are stored in the fDeletedUserVariableNames HashSet, and are not actually deleted from the user supplier
- * the applyUserVariables() should be called to delete those variabes from the user supplier
- */
- private void deleteUserVariable(String name){
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.deleteVariable(name, fContext);
- } else {
- fDeleteAll = false;
- if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
- name = name.toUpperCase();
- getAddedUserVariables().remove(name);
- getDeletedUserVariableNames().add(name);
- }
- fModified = true;
- }
-
- /*
- * deletes all user variables
- * the applyUserVariables() should be called to delete those variabes from the user supplier
- */
- private void deleteAllUserVariables(){
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.deleteAll(fContext);
- } else {
- fDeleteAll = true;
- getDeletedUserVariableNames().clear();
- getAddedUserVariables().clear();
- }
- fModified = true;
- }
-
- /*
- * returns whether the user variables were modified
- */
- public boolean isModified(){
- return fModified;
- }
-
- /*
- * sets the modify state
- */
- public void setModified(boolean modified){
- fModified = modified;
- }
-
- /*
- * returns a user variable of a given name
- */
- private IBuildEnvironmentVariable getUserVariable(String name){
- if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
- name = name.toUpperCase();
-
- if(fUserSupplier != null && storeDirectly())
- return fUserSupplier.getVariable(name, fContext);
-
- return (IBuildEnvironmentVariable)getUserVariablesMap().get(name);
- }
-
- /*
- * applies user variables.
- *
- */
- private void applyUserVariables(){
- if(fUserSupplier != null){
- if(storeDirectly()){
- if(getContainer() instanceof AbstractBuildPropertyPage
- && fContext instanceof IConfiguration){
- AbstractBuildPropertyPage page = (AbstractBuildPropertyPage)getContainer();
- IConfiguration realCfg = page.getRealConfig((IConfiguration)fContext);
- IBuildEnvironmentVariable vars[] = getUserVariables();
- UserDefinedEnvironmentSupplier supplier = EnvironmentVariableProvider.fUserSupplier;
- supplier.setVariables(vars,realCfg);
- }
- } else {
- if(fDeleteAll){
- fUserSupplier.deleteAll(fContext);
- }
- else{
- Iterator iter = getDeletedUserVariableNames().iterator();
- while(iter.hasNext()){
- fUserSupplier.deleteVariable((String)iter.next(),fContext);
- }
-
- iter = getAddedUserVariables().values().iterator();
- while(iter.hasNext()){
- IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
- fUserSupplier.createVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter(),fContext);
- }
-
- getDeletedUserVariableNames().clear();
- getAddedUserVariables().clear();
- }
- }
- }
- }
-
- /*
- * applies user variables and asks the user supplier to serialize
- */
- private void storeUserVariables(){
- applyUserVariables();
-
- if(fUserSupplier != null)
- fUserSupplier.serialize(false);
- }
-
- /*
- * called when the user variable selection was changed
- */
- private void handleSelectionChanged(SelectionChangedEvent event){
- int size = ((IStructuredSelection)event.getSelection()).size();
- fEditButton.setEnabled(size == 1);
- fUndefButton.setEnabled(size > 0);
- fDeleteButton.setEnabled(size > 0);
- }
-
- /*
- * answers whether the list values can be edited
- */
-/* private boolean isEditable(ListDialogField field) {
- return field == fEditableList;
- }
-*/
- /*
- * called when a custom button was pressed
- */
- private void handleCustomButtonPressed(int index){
- switch(index){
- case IDX_BUTTON_NEW:{
- NewEnvVarDialog dlg = new NewEnvVarDialog(fParent.getShell(),this,null);
- if(dlg.open() == Dialog.OK){
- IBuildEnvironmentVariable var = dlg.getDefinedVariable();
- if(var != null){
- addUserVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter());
- updateValues();
- }
- }
- }
- break;
- case IDX_BUTTON_EDIT:{
- IBuildEnvironmentVariable vars[] = getSelectedUserVariables();
- if(vars != null && vars.length == 1){
- NewEnvVarDialog dlg = new NewEnvVarDialog(fParent.getShell(),this,getUserVariable(vars[0].getName()));
- if(dlg.open() == Dialog.OK){
- IBuildEnvironmentVariable var = dlg.getDefinedVariable();
- if(var != null){
- addUserVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter());
- updateValues();
- }
- }
- }
- }
- break;
- case IDX_BUTTON_UNDEF:{
- IBuildEnvironmentVariable vars[] = getSelectedUserVariables();
- if(vars != null){
- for(int i = 0; i < vars.length; i++){
- addUserVariable(vars[i].getName(),null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
- }
- updateValues();
- }
- }
- break;
- case IDX_BUTTON_DELETE:{
- IBuildEnvironmentVariable vars[] = getSelectedUserVariables();
- if(vars != null && vars.length > 0){
- if(MessageDialog.openQuestion(fParent.getShell(),
- ManagedBuilderUIMessages.getResourceString(DELETE_CONFIRM_TITLE),
- ManagedBuilderUIMessages.getResourceString(DELETE_CONFIRM_MESSAGE))){
- for(int i = 0; i < vars.length; i++){
- deleteUserVariable(vars[i].getName());
- }
- updateValues();
- }
- }
- }
- break;
- }
- }
-
- /*
- * returnes the selected user-defined variables
- */
- private IBuildEnvironmentVariable[] getSelectedUserVariables(){
- if(fEditableTable == null)
- return null;
-
- List list = ((IStructuredSelection)fEditableTable.getSelection()).toList();
- return (IBuildEnvironmentVariable[])list.toArray(new IBuildEnvironmentVariable[list.size()]);
- }
-
- /*
- * sets the context for which the variables should be displayed
- */
- public void setContext(Object context){
- if(context == fContext)
- return;
-
- fContext = context;
-
- IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
- IEnvironmentVariableSupplier suppliers[] = provider.getSuppliers(fContext);
- if(suppliers != null && suppliers.length != 0 && suppliers[0] instanceof UserDefinedEnvironmentSupplier){
- fUserSupplier = (UserDefinedEnvironmentSupplier)suppliers[0];
- }
-
- fSystemContextInfo = new SystemContextInfo(context);
- fCurrentContextInfo = new CurrentContextInfo(context);
- }
-
- public void setParentContextInfo(IContextInfo info){
- fParentContextInfo = info;
- fUseDefaultParentContextInfo = false;
- }
-
- public void resetDefaultParentContextInfo(){
- fUseDefaultParentContextInfo = true;
- fParentContextInfo = null;
- }
-
- public IContextInfo getContextInfo(){
- return fCurrentContextInfo;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- if(fUserSupplier == null)
- return;
- storeUserVariables();
- setModified(false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- if(MessageDialog.openQuestion(fParent.getShell(),
- ManagedBuilderUIMessages.getResourceString(DELETE_ALL_CONFIRM_TITLE),
- ManagedBuilderUIMessages.getResourceString(DELETE_ALL_CONFIRM_MESSAGE))){
- deleteAllUserVariables();
- updateValues();
- }
- }
-
- /*
- * updates both user- and sytem- variables tables.
- */
- public void updateValues(){
- if(fCurrentContextInfo == null)
- return;
- try{
- Object context = fCurrentContextInfo.getContext();
- int contextType = 0;
- Object contextData = null;
- if(context instanceof IConfiguration){
- contextType = IBuildMacroProvider.CONTEXT_CONFIGURATION;
- contextData = context;
- } else if(context instanceof IManagedProject) {
- contextType = IBuildMacroProvider.CONTEXT_PROJECT;
- contextData = context;
- } else if(context instanceof IWorkspace){
- contextType = IBuildMacroProvider.CONTEXT_WORKSPACE;
- contextData = context;
- } else {
- contextType = IBuildMacroProvider.CONTEXT_ECLIPSEENV;
- contextData = null;
- }
-
- BuildMacroProvider macroProvider = obtainMacroProvider();
- if(macroProvider != null){
- IMacroContextInfo macroContextInfo = macroProvider.getMacroContextInfo(contextType,contextData);
- if(macroContextInfo != null){
- EnvironmentVariableProvider provider = (EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider();
- EnvVarCollector v = provider.getVariables(fCurrentContextInfo,true);
- if(v != null){
- EnvVarUIMacroSubstitutor substitutor = new EnvVarUIMacroSubstitutor(macroContextInfo, null, " "); //$NON-NLS-1$
- IBuildEnvironmentVariable vars[] = v.toArray(false);
- for(int i = 0; i < vars.length; i++){
- MacroResolver.checkMacros(vars[i].getValue(), substitutor);
- }
- }
- }
- }
- updateState(null);
- } catch (BuildMacroException e){
- updateState(e);
- }
- updateUserVariables();
- updateSystemVariables();
- }
-
- /*
- * apdates a user-defined variables table
- */
- private void updateUserVariables(){
- if(fEditableTable == null || fContext == fInexistentContext)
- return;
-
-// fEditableList.selectFirstElement();
-// handleSelectionChanged(fEditableList);
-
- if(fUserSupplier != null) {
- IBuildEnvironmentVariable variables[] = getUserVariables();
-
- List list = new ArrayList(variables.length);
- for( int i = 0; i < variables.length; i++ ){
- IBuildEnvironmentVariable userVar = variables[i];
- if(userVar != null){
- IBuildEnvironmentVariable sysVar = getSystemVariable(userVar.getName(),true);
- IBuildEnvironmentVariable var = EnvVarOperationProcessor.performOperation(sysVar,userVar);
- if(var != null)
- list.add(var);
- }
- }
-
- fEditableTable.setInput(list.toArray(new IBuildEnvironmentVariable[list.size()]));
- }
- }
-
- /*
- * apdates a system-defined variables table
- */
- private void updateSystemVariables(){
- if(fNonEditableTable == null || fContext == fInexistentContext)
- return;
-
- List list = new ArrayList();
- IBuildEnvironmentVariable vars[] = getSystemVariables(fShowParentVariables);
- if(vars != null && vars.length != 0){
- for(int i = 0; i < vars.length; i++){
- if(vars[i] != null)
- list.add(vars[i]);
- }
- }
-
- fNonEditableTable.setInput(list.toArray(new IBuildEnvironmentVariable[list.size()]));
- }
-
- /*
- * return a system variable of a given name
- */
- public IBuildEnvironmentVariable getSystemVariable(String name,boolean includeParentLevels){
- if(name == null)
- return null;
- if(fSystemContextInfo == null)
- return null;
- if(!canDisplay(name))
- return null;
-
- return EnvironmentVariableProvider.getDefault().getVariable(name,fSystemContextInfo,includeParentLevels);
- }
-
- /*
- * returns an array of system variables
- */
- public IBuildEnvironmentVariable[] getSystemVariables(boolean includeParentLevels){
- EnvironmentVariableProvider provider = (EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider();
- EnvVarCollector variables = provider.getVariables(fSystemContextInfo,includeParentLevels);
- if(variables == null)
- return null;
- return filterVariables(variables.toArray(false));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- fParent = parent;
- FormLayout layout= new FormLayout();
- FormData fd;
- Control buttonsControl = null;
- Control listControl = null;
-
- Composite composite= new Composite(parent, SWT.NULL);
- composite.setLayout(layout);
- if(fIsEditable){
- Label nameLabel = new Label(composite, SWT.LEFT);
- nameLabel.setFont(composite.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(USER_VAR));
- fd = new FormData();
- fd.top = new FormAttachment(0,2);
- fd.left = new FormAttachment(0,0);
- nameLabel.setLayoutData(fd);
-
- listControl= createTableControl(composite, true);
-
- buttonsControl = createButtonsControl(composite);
-
- fd = new FormData();
- fd.top = new FormAttachment(nameLabel,0);
- fd.right = new FormAttachment(100,0);
- buttonsControl.setLayoutData(fd);
-
- fd = new FormData();
- fd.top = new FormAttachment(nameLabel,0);
- fd.left = new FormAttachment(0,0);
- fd.right = new FormAttachment(buttonsControl,-5);
- fd.bottom = new FormAttachment(50,-15);
- listControl.setLayoutData(fd);
-
- }
-
- Label nameLabel = new Label(composite, SWT.LEFT);
- nameLabel.setFont(composite.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(SYSTEM_VAR));
- fd = new FormData();
- if(fIsEditable)
- fd.top = new FormAttachment(listControl,2);
- else
- fd.top = new FormAttachment(0,2);
- fd.left = new FormAttachment(0,0);
- nameLabel.setLayoutData(fd);
-
- fStatusLabel = new Label(composite, SWT.LEFT);
- fStatusLabel.setFont(composite.getFont());
- fStatusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
- fd = new FormData();
- fd.bottom = new FormAttachment(100,-10);
- fd.left = new FormAttachment(0,10);
- fd.right = new FormAttachment(100,-10);
- fStatusLabel.setLayoutData(fd);
-
- if(fShowParentViewCheckBox){
- // Create a "show parent levels" button
- fShowParentButton = new Button(composite, SWT.CHECK);
- fShowParentButton.setFont(composite.getFont());
- fShowParentButton.setText(ManagedBuilderUIMessages.getResourceString(BUTTON_CHECK_SHOW_PARENT));
- fd = new FormData();
- fd.left = new FormAttachment(0,0);
-// fd.bottom = new FormAttachment(100,0);
- fd.bottom = new FormAttachment(fStatusLabel,-10);
- fShowParentButton.setLayoutData(fd);
- fShowParentButton.setSelection(fShowParentVariables);
- fShowParentButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fShowParentVariables = fShowParentButton.getSelection();
- updateSystemVariables();
- }
- });
- }
-
- listControl= createTableControl(composite,false);
- fd = new FormData();
- fd.top = new FormAttachment(nameLabel,0);
- fd.left = new FormAttachment(0,0);
- if(buttonsControl != null)
- fd.right = new FormAttachment(buttonsControl,-5);
- else
- fd.right = new FormAttachment(100,0);
- if(fShowParentButton != null)
- fd.bottom = new FormAttachment(fShowParentButton,-2);
- else
-// fd.bottom = new FormAttachment(100,0);
- fd.bottom = new FormAttachment(fStatusLabel,-10);
-
- listControl.setLayoutData(fd);
-
- this.setControl(composite);
- }
-
- private Control createTableControl(Composite parent, boolean editable){
- Composite listControl= new Composite(parent, SWT.NONE);
- TableViewer tableViewer;
- GridLayout gl = new GridLayout();
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- gl.numColumns = 1;
- listControl.setLayout(gl);
- tableViewer = new TableViewer(listControl, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
- | SWT.FULL_SELECTION);
-
- Table table = tableViewer.getTable();
- TableLayout tableLayout = new TableLayout();
- for (int i = 0; i < fTableColumnNames.length; i++) {
- tableLayout.addColumnData(fTableColumnLayouts[i]);
- TableColumn tc = new TableColumn(table, SWT.NONE, i);
- tc.setResizable(fTableColumnLayouts[i].resizable);
- tc.setText(fTableColumnNames[i]);
- }
- table.setLayout(tableLayout);
- table.setHeaderVisible(true);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 50;
- tableViewer.getControl().setLayoutData(gd);
- tableViewer.setContentProvider(new EnvironmentContentProvider());
- tableViewer.setLabelProvider(new EnvironmentLabelProvider(editable));
- tableViewer.setSorter(new ViewerSorter());
-
- if(editable){
- tableViewer.setColumnProperties(fEditableTableColumnProps);
- fEditableTable = tableViewer;
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChanged(event);
- }
- });
- tableViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(DoubleClickEvent event) {
- if (!fEditableTable.getSelection().isEmpty()) {
- handleCustomButtonPressed(IDX_BUTTON_EDIT);
- }
- }
- });
-
- table.addKeyListener(new KeyListener(){
- public void keyPressed(KeyEvent e){
- if(e.keyCode == SWT.DEL)
- handleCustomButtonPressed(IDX_BUTTON_DELETE);
- }
-
- public void keyReleased(KeyEvent e){
-
- }
- });
- } else {
- tableViewer.setColumnProperties(fNonEditableTableColumnProps);
- fNonEditableTable = tableViewer;
- }
- return listControl;
- }
-
- private Control createButtonsControl(Composite parent){
- Composite buttonsControl = new Composite(parent, SWT.NONE);
- GridLayout gl = new GridLayout();
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- gl.numColumns = 1;
- buttonsControl.setLayout(gl);
-
- GridData gd;
- fNewButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_NEW),null);
- fNewButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleCustomButtonPressed(IDX_BUTTON_NEW);
- }
- });
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = SWTUtil.getButtonHeigthHint(fNewButton);
- gd.widthHint = SWTUtil.getButtonWidthHint(fNewButton);
- fNewButton.setLayoutData(gd);
-
-
- fEditButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_EDIT),null);
- fEditButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleCustomButtonPressed(IDX_BUTTON_EDIT);
- }
- });
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = SWTUtil.getButtonHeigthHint(fEditButton);
- gd.widthHint = SWTUtil.getButtonWidthHint(fEditButton);
- fEditButton.setLayoutData(gd);
-
-
- fUndefButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_UNDEF),null);
- fUndefButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleCustomButtonPressed(IDX_BUTTON_UNDEF);
- }
- });
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = SWTUtil.getButtonHeigthHint(fUndefButton);
- gd.widthHint = SWTUtil.getButtonWidthHint(fUndefButton);
- fUndefButton.setLayoutData(gd);
-
- fDeleteButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_DELETE),null);
- fDeleteButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleCustomButtonPressed(IDX_BUTTON_DELETE);
- }
- });
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = SWTUtil.getButtonHeigthHint(fDeleteButton);
- gd.widthHint = SWTUtil.getButtonWidthHint(fDeleteButton);
- fDeleteButton.setLayoutData(gd);
- return buttonsControl;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible){
-// fVisible = visible;
-// if(visible)
-// updateValues();
- super.setVisible(visible);
- }
-
- /*
- * return the context for which the variables are displayed
- */
- public Object getContext(){
- return fContext;
- }
-
- public void displayParentVariables(boolean display){
- fShowParentVariables = display;
- if(fShowParentButton != null)
- fShowParentButton.setSelection(fShowParentVariables);
- updateSystemVariables();
- }
-
- /*
- * answers whether the given variable should be displayed in UI or not
- */
- protected boolean canDisplay(String name){
- return canCreate(name);
- }
-
- /*
- * answers whether the variable of a given name can be sreated
- */
- public boolean canCreate(String name){
- if((name = EnvVarOperationProcessor.normalizeName(name)) == null)
- return false;
-
- if(fHiddenVariables != null){
- for(int i = 0; i < fHiddenVariables.length; i++){
- if(name.equals(fHiddenVariables[i]))
- return false;
- }
- }
- return true;
- }
-
- /*
- * filteres the names to be displayed
- */
- protected IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
- return EnvVarOperationProcessor.filterVariables(variables,fHiddenVariables);
- }
-
- private void updateState(BuildMacroException e){
- fIncorrectlyDefinedVariablesNames.clear();
-
- if(e != null){
- fStatusLabel.setText(e.getMessage());
- fStatusLabel.setVisible(true);
- IBuildMacroStatus statuses[] = e.getMacroStatuses();
- for(int i = 0; i < statuses.length; i++){
- String name = statuses[i].getMacroName();
- if(name != null)
- fIncorrectlyDefinedVariablesNames.add(name);
- }
- }
- else{
- fStatusLabel.setVisible(false);
- }
- }
-
- /**
- * Returns the build macro provider to be used for macro resolution
- * In case the "Build Macros" tab is available, returns the BuildMacroProvider
- * supplied by that tab.
- * Unlike the default provider, that provider also contains
- * the user-modified macros that are not applied yet
- * If the "Build Macros" tab is not available, returns the default BuildMacroProvider
- */
- protected BuildMacroProvider obtainMacroProvider(){
- ICOptionContainer container = getContainer();
- ManagedBuildOptionBlock optionBlock = null;
- if(container instanceof BuildPropertyPage){
- BuildPropertyPage page = (BuildPropertyPage)container;
- optionBlock = page.getOptionBlock();
- } else if(container instanceof BuildPreferencePage){
- BuildPreferencePage page = (BuildPreferencePage)container;
- optionBlock = page.getOptionBlock();
- }
- if(optionBlock != null){
- MacrosSetBlock block = optionBlock.getMacrosBlock();
- if(block != null)
- return block.getBuildMacroProvider();
- }
- return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java
deleted file mode 100644
index 53efc1a0724..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.ui.dialogs.ICOptionPage;
-import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-
-/**
- * When used in the BuildPropertyPage the displays the tab-folder that contains the following tabs:
- * 1. a tab containing configuration-specific variables
- * 2. a tab containing project-specific variables
- *
- * Otherwise displays a single EnvironmentBlock that contains
- * the workspace-specific and eclipse process environment variables
- *
- */
-public class EnvironmentSetBlock extends AbstractCOptionPage {
- /*
- * String constants
- */
- private static final String PREFIX = "EnvironmentSetBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String ENVIRONMENT_LABEL = LABEL + ".environment"; //$NON-NLS-1$
-
- private static final String ENVIRONMENT_GROUP_LABEL = LABEL + ".environment.group"; //$NON-NLS-1$
-
- private static final String TAB = LABEL + ".tab"; //$NON-NLS-1$
- private static final String TAB_CONFIGURATION = TAB + ".configuration"; //$NON-NLS-1$
- private static final String TAB_PROJECT = TAB + ".project"; //$NON-NLS-1$
- private static final String TAB_WORKSPACE = TAB + ".workspace"; //$NON-NLS-1$
- private static final String TAB_ECLIPSE = TAB + ".eclipse"; //$NON-NLS-1$
-
- private EnvironmentTabFolder fEnvTabs;
- private EnvironmentBlock fEnvBlock;
-
- private ICOptionContainer fParentContainer;
-
- private UIEnvVarProvider fEnvProvider = null;
-
- private class UIEnvVarContextInfo extends DefaultContextInfo{
- public UIEnvVarContextInfo(Object context){
- super(context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getNext()
- */
- public IContextInfo getNext(){
- IContextInfo info = super.getNext();
- if(info != null){
- EnvironmentBlock blocks[] = getAllBlocks();
- for(int i = 0; i < blocks.length; i++){
- if(blocks[i].getContext() == info.getContext())
- return blocks[i].getContextInfo();
- }
- return new UIEnvVarContextInfo(info.getContext());
- }
- return null;
- }
- }
-
- /*
- * The EnvironmentVariableProvider to be used in UI
- * Unlike the default provider, this provider also contains
- * the user-modified variables that are not applied yet
- */
- private class UIEnvVarProvider extends EnvironmentVariableProvider{
- public IContextInfo getContextInfo(Object context){
- EnvironmentBlock blocks[] = getAllBlocks();
- for(int i = 0; i < blocks.length; i++){
- if(blocks[i].getContext() == context)
- return blocks[i].getContextInfo();
- }
- return new UIEnvVarContextInfo(context);
- }
- }
-
- private class EnvironmentTabFolder extends TabFolderOptionBlock{
- private EnvironmentBlock fFolderTabs[];
- public EnvironmentTabFolder() {
- super(fParentContainer, false);
- }
-
- public EnvironmentBlock[] getTabs(){
- return fFolderTabs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
- */
- protected void addTabs(){
- if(fParentContainer instanceof BuildPropertyPage) {
- // the EnvironmentSetBlock is used whithing the Build Property Page
- // create the project and configuration tabs
- fFolderTabs = new EnvironmentBlock[2];
- addTab(fFolderTabs[0] = new EnvironmentBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_CONFIGURATION),
- true,
- true));
- addTab(fFolderTabs[1] = new EnvironmentBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_PROJECT),
- true,
- true));
- }
- else {
- // the EnvironmentSetBlock is used whithing the Build Preference Page
- // create the workspace and eclipse environment tabs
- fFolderTabs = new EnvironmentBlock[2];
- addTab(fFolderTabs[0] = new EnvironmentBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_WORKSPACE),
- true,
- true));
- addTab(fFolderTabs[1] = new EnvironmentBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_ECLIPSE),
- false,
- false));
- }
- }
-
- /*
- * set the appropriate context data to the tabs
- */
- public void updateContexts(){
- if(fFolderTabs == null)
- return;
-
- if(fParentContainer instanceof BuildPropertyPage){
- BuildPropertyPage page = (BuildPropertyPage)fParentContainer;
- if(page.getSelectedConfigurationClone() != null)
- fFolderTabs[1].setContext(page.getSelectedConfigurationClone().getManagedProject());
-
- fFolderTabs[0].setContext(page.getSelectedConfigurationClone());
- fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
- }
- else {
- fFolderTabs[1].setContext(null);
-
- fFolderTabs[0].setContext(ResourcesPlugin.getWorkspace());
- fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
- }
- }
-
- public void setCurrentPage(ICOptionPage page) {
- ((EnvironmentBlock)page).updateValues();
- super.setCurrentPage(page);
- }
-
- }
-
-
- public EnvironmentSetBlock(ICOptionContainer parent){
- super(ManagedBuilderUIMessages.getResourceString(ENVIRONMENT_LABEL));
- super.setContainer(parent);
- fParentContainer = parent;
-
- if(fParentContainer instanceof BuildPropertyPage)
- fEnvTabs = new EnvironmentTabFolder();
- else {
- fEnvBlock = new EnvironmentBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_WORKSPACE),
- true,
- false);
- fEnvBlock.displayParentVariables(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- EnvironmentBlock tabs[] = getAllBlocks();
- if(tabs != null){
- for(int i = 0; i < tabs.length; i++)
- tabs[i].performApply(monitor);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- EnvironmentBlock tab = getSelectedBlock();
- if(tab != null)
- tab.performDefaults();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible){
- if(visible)
- updateValues();
- if(fEnvTabs != null)
- fEnvTabs.setVisible(visible);
- super.setVisible(visible);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Control ctrl = null;
- if(fEnvTabs != null){
- Group group = new Group(parent, SWT.NONE);
- group.setFont(parent.getFont());
- group.setText(ManagedBuilderUIMessages.getResourceString(ENVIRONMENT_GROUP_LABEL));
- group.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout gl = new GridLayout();
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- group.setLayout(gl);
- Control tabs = fEnvTabs.createContents(group);
- GridData gd = new GridData(GridData.FILL_BOTH);
- tabs.setLayoutData(gd);
- ctrl = group;
- }
- else if(fEnvBlock != null){
- fEnvBlock.createControl(parent);
- ctrl = fEnvBlock.getControl();
- ctrl.setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- setControl(ctrl);
- }
-
- public void updateValues(){
- EnvironmentBlock tab = getSelectedBlock();
-
- updateContexts();
- if(tab != null)
- tab.updateValues();
- }
-
- public boolean isConfigSelectionAllowed(){
- EnvironmentBlock block = getSelectedBlock();
- if(block != null)
- return block.getContext() instanceof IConfiguration;
- return false;
- }
-
- public boolean isModified(){
- EnvironmentBlock tabs[] = getAllBlocks();
- for(int i = 0; i < tabs.length; i++){
- if(tabs[i].isModified())
- return true;
- }
- return false;
- }
-
- public void setModified(boolean modified){
- EnvironmentBlock tabs[] = getAllBlocks();
- for(int i = 0; i < tabs.length; i++){
- tabs[i].setModified(modified);
- }
- }
-
- /*
- * returns the selected environment block
- */
- protected EnvironmentBlock getSelectedBlock(){
- if(fEnvTabs != null)
- return (EnvironmentBlock)fEnvTabs.getCurrentPage();
- return fEnvBlock;
- }
-
- /*
- * returns all available environment blocks
- */
- protected EnvironmentBlock[] getAllBlocks(){
- if(fEnvTabs != null)
- return fEnvTabs.getTabs();
- else if(fEnvBlock != null)
- return new EnvironmentBlock[]{fEnvBlock};
- return new EnvironmentBlock[0];
- }
-
- /*
- * updates the context of each EnvironmentBlock
- */
- protected void updateContexts(){
- if(fEnvTabs != null)
- fEnvTabs.updateContexts();
- else if(fEnvBlock != null)
- fEnvBlock.setContext(ResourcesPlugin.getWorkspace());
- }
-
- /*
- * returns the EnvironmentVariableProvider to be used in UI
- * Unlike the default provider, the returned provider also contains
- * the user-modified variables that are not applied yet
- */
- public EnvironmentVariableProvider getEnvironmentVariableProvider(){
- if(fEnvProvider == null)
- fEnvProvider = new UIEnvVarProvider();
- return fEnvProvider;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java
deleted file mode 100644
index 1f86d805e8f..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 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:
- * QNX Software Systems - Move to Make plugin
- * Intel Corp - Use in Managed Make system
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectOptionPage;
-import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectWizard;
-import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-public class ErrorParserBlock extends AbstractErrorParserBlock {
- private BuildPropertyPage parent;
- private String errorParsers[];
-
- public ErrorParserBlock(BuildPropertyPage parent) {
- super();
- this.parent = parent;
- }
-
- protected String[] getErrorParserIDs(IConfiguration config) {
- // Get the list of error parsers specified with this Configuration
- String[] errorParsers = config.getErrorParserList();
- if (errorParsers != null) {
- return errorParsers;
- }
- else {
- // If no error parsers are specified by the configuration, the default is
- // all error parsers
- return CCorePlugin.getDefault().getAllErrorParsersIDs();
- }
- }
-
- protected String[] getErrorParserIDs(IProject project) {
-
- IConfiguration config = null;
- if(parent != null)
- config = parent.getSelectedConfigurationClone();
- else if ((config = ManagedBuildManager.getSelectedConfiguration(project)) == null) {
- // This case occurs when modifying the properties of an existing
- // managed build project, and the user selects the error parsers
- // page before the "C/C++ Build" page.
-
- // Get the build information
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- config = info.getDefaultConfiguration();
- }
- if (config != null) {
- return getErrorParserIDs(config);
- } else {
- return CCorePlugin.getDefault().getAllErrorParsersIDs();
- }
- }
-
- protected String[] getErrorParserIDs() {
- // Get the currently selected configuration from the page's container
- // This is invoked by the managed builder new project wizard before the
- // project is created.
- if(parent != null){
- return getErrorParserIDs(parent.getSelectedConfigurationClone());
- }
- ICOptionContainer container = getContainer();
- if (container instanceof NewManagedProjectOptionPage) {
- NewManagedProjectOptionPage parent = (NewManagedProjectOptionPage)getContainer();
- NewManagedProjectWizard wizard = (NewManagedProjectWizard)parent.getWizard();
- // TODO: This is wrong since the Wizard does not have a selected configuration!
- IProjectType proj = wizard.getSelectedProjectType();
- IConfiguration[] configs = proj.getConfigurations();
- if (configs.length > 0)
- return getErrorParserIDs(configs[0]);
- else
- return new String[0];
- }
- return CCorePlugin.getDefault().getAllErrorParsersIDs();
- }
-
- public void saveErrorParsers(IProject project, String[] parsers) {
- IConfiguration config = null;
- if(parent != null)
- config = parent.getSelectedConfigurationClone();
- else
- config = ManagedBuildManager.getSelectedConfiguration(project);
- if (config != null) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < parsers.length; i++) {
- if (i > 0) buf.append(';');
- buf.append(parsers[i]);
- }
- config.setErrorParserIds(buf.toString());
- }
- }
-
- public IPreferenceStore getPreferenceStore() {
- return null;
- }
-
- protected boolean checkIds(String ids1[], String ids2[]){
- if(ids1.length != ids2.length)
- return true;
-
- for(int i = 0; i < ids1.length; i++){
- String id = ids1[i];
- int j;
- for(j = 0; j < ids2.length; j++){
- if(id.equals(ids2[j]))
- break;
- }
-
- if(j == ids2.length)
- return true;
- }
-
- return false;
- }
-
- protected void setValues() {
- super.setValues();
-
- if(parent != null && parent.getSelectedConfigurationClone() != null)
- errorParsers = getErrorParserIDs(parent.getSelectedConfigurationClone());
-
- // TODO: This reset belongs in AbstractErrorParserBlock.java?
- // Reset the "dirty" flag
- listDirty = false;
- }
-
- public void performApply(IProgressMonitor monitor) throws CoreException {
- super.performApply(monitor);
-
- if(parent != null){
- IConfiguration realConfig = ManagedBuildManager.getSelectedConfiguration(parent.getProject());
- realConfig.setErrorParserIds(parent.getSelectedConfigurationClone().getErrorParserIds());
- errorParsers = getErrorParserIDs(parent.getSelectedConfigurationClone());
- }
- // TODO: This reset belongs in AbstractErrorParserBlock.java?
- // Reset the "dirty" flag
- listDirty = false;
-
- }
-
- /**
- * Sets the "dirty" state
- */
- public void setDirty(boolean b) {
- listDirty = b;
- }
-
- /**
- * Returns the "dirty" state
- */
- public boolean isDirty() {
- return listDirty;
- }
-
- public void setVisible(boolean visible){
- if(parent != null){
- if(visible){
- boolean dirtyState = listDirty;
- updateListControl(parent.getSelectedConfigurationClone().getErrorParserList());
- if(dirtyState != listDirty)
- listDirty = checkIds(parent.getSelectedConfigurationClone().getErrorParserList(),errorParsers);
- } else {
- try {
- super.performApply(null);
- } catch (CoreException e) {
- }
- }
- }
- super.setVisible(visible);
- }
-
- protected void setDefaults() {
- if(parent != null){
- IConfiguration cfg = parent.getSelectedConfigurationClone();
- cfg.setErrorParserIds(null);
- updateListControl(cfg.getErrorParserList());
- listDirty = true;
- } else
- super.setDefaults();
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java
deleted file mode 100644
index 9a8ae9ca746..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java
+++ /dev/null
@@ -1,1294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.EclipseVariablesMacroSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.EnvironmentMacroSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.internal.macros.UserDefinedMacroSupplier;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
-import org.eclipse.cdt.managedbuilder.ui.properties.AbstractBuildPropertyPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.variables.IDynamicVariable;
-import org.eclipse.core.variables.IStringVariable;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.JFacePreferences;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IFontProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableFontProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * displays the build macros for the given context
- */
-public class MacrosBlock extends AbstractCOptionPage {
- /*
- * String constants
- */
- private static final String PREFIX = "MacrosBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
-
- private static final String USER_MACROS = LABEL + ".user.macros"; //$NON-NLS-1$
- private static final String SYSTEM_MACROS = LABEL + ".system.macros"; //$NON-NLS-1$
-
- private static final String HEADER = LABEL + ".header"; //$NON-NLS-1$
- private static final String HEADER_NAME = HEADER + ".name"; //$NON-NLS-1$
- private static final String HEADER_TYPE = HEADER + ".type"; //$NON-NLS-1$
- private static final String HEADER_VALUE = HEADER + ".value"; //$NON-NLS-1$
-
- private static final String TYPE = LABEL + ".type"; //$NON-NLS-1$
- private static final String TYPE_TEXT = TYPE + ".text"; //$NON-NLS-1$
- private static final String TYPE_TEXT_LIST = TYPE + ".text.list"; //$NON-NLS-1$
- private static final String TYPE_PATH_FILE = TYPE + ".path.file"; //$NON-NLS-1$
- private static final String TYPE_PATH_FILE_LIST = TYPE + ".path.file.list"; //$NON-NLS-1$
- private static final String TYPE_PATH_DIR = TYPE + ".path.dir"; //$NON-NLS-1$
- private static final String TYPE_PATH_DIR_LIST = TYPE + ".path.dir.list"; //$NON-NLS-1$
- private static final String TYPE_PATH_ANY = TYPE + ".path.any"; //$NON-NLS-1$
- private static final String TYPE_PATH_ANY_LIST = TYPE + ".path.any.list"; //$NON-NLS-1$
-
-
- private static final String BUTTON = LABEL + ".button"; //$NON-NLS-1$
- private static final String BUTTON_NEW = BUTTON + ".new"; //$NON-NLS-1$
- private static final String BUTTON_EDIT = BUTTON + ".edit"; //$NON-NLS-1$
- private static final String BUTTON_DELETE = BUTTON + ".delete"; //$NON-NLS-1$
-
- private static final String BUTTON_CHECK_SHOW_PARENT = BUTTON + ".check.chow.parent"; //$NON-NLS-1$
-
- private static final String DELETE_CONFIRM_TITLE = LABEL + ".delete.confirm.title"; //$NON-NLS-1$
- private static final String DELETE_CONFIRM_MESSAGE = LABEL + ".delete.confirm.message"; //$NON-NLS-1$
-
- private static final String DELETE_ALL_CONFIRM_TITLE = LABEL + ".delete.all.confirm.title"; //$NON-NLS-1$
- private static final String DELETE_ALL_CONFIRM_MESSAGE = LABEL + ".delete.all.confirm.message"; //$NON-NLS-1$
-
- private static final String VALUE = LABEL + ".value"; //$NON-NLS-1$
- private static final String VALUE_ECLIPSE_DYNAMIC = VALUE + ".eclipse.dynamic"; //$NON-NLS-1$
-
-
- private static final String VALUE_DELIMITER = " || "; //$NON-NLS-1$
-
-
- private static final String fHiddenMacros[] = new String[]{
- //currently the "CWD" and "PWD" macros are not displayed in UI
- "CWD", //$NON-NLS-1$
- "PWD" //$NON-NLS-1$
- };
-
- /*
- * button IDs
- */
- private static final int IDX_BUTTON_NEW = 0;
- private static final int IDX_BUTTON_EDIT = 1;
- private static final int IDX_BUTTON_DELETE = 2;
-
- //macro names deleted by a user
- private HashSet fDeletedUserMacroNames;
- //macros added by a user
- private Map fAddedUserMacros;
- //specifies whether a "delete All" button was previousely pressed
- private boolean fDeleteAll = false;
- //specifies whether the set of the user-defined macros was changed by a user
- //and the changes are not applied to the User Macro Supplier
- private boolean fModified = false;
- //holds the visible state.
-// private boolean fVisible = false;
- //specifies whether the "show parent context macros" checkbox should be created
- private boolean fShowParentViewCheckBox = true;
-
- private boolean fIsEditable = true;
-
- //inexistent context
- private static final Object fInexistentContext = new Object();
- //the context tyte for which the macros are displayed
- private int fContextType = 0;
- //the context data for which the macros are displayed
- private Object fContextData = fInexistentContext;
- //specifies whether the parent level macros should be displayed
- private boolean fShowParentMacros = false;
-
- private IMacroContextInfo fSystemContextInfo;
- private IMacroContextInfo fCurrentContextInfo;
- private IMacroContextInfo fParentContextInfo;
- private boolean fUseDefaultParentContextInfo = true;
-
- private Set fIncorrectlyDefinedMacrosNames = new HashSet();
-
- //the user defined macro supplier
- private UserDefinedMacroSupplier fUserSupplier;
- //editable table viewer
- private TableViewer fEditableTable;
- //noneditable table viewer
- private TableViewer fNonEditableTable;
-
- /*
- * widgets
- */
- //show parent level macros check-box
- private Button fShowParentButton;
- //parent composite
- private Composite fParent;
- //status label
- private Label fStatusLabel;
- //buttons
- private Button fNewButton;
- private Button fEditButton;
- private Button fDeleteButton;
-
-
- private static final String[] fEditableTableColumnProps = new String[] {
- "editable name", //$NON-NLS-1$
- "editable type", //$NON-NLS-1$
- "editable value", //$NON-NLS-1$
- };
-
- private static final String[] fNonEditableTableColumnProps = new String[] {
- "noneditable name", //$NON-NLS-1$
- "noneditable type", //$NON-NLS-1$
- "noneditable value", //$NON-NLS-1$
- };
-
- private static final String[] fTableColumnNames = new String[] {
- ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
- ManagedBuilderUIMessages.getResourceString(HEADER_TYPE),
- ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
- };
-
- private static final ColumnLayoutData[] fTableColumnLayouts = {new ColumnPixelData(100), new ColumnPixelData(100), new ColumnPixelData(250)};
-
-
- private class MacroUIMacroSubstitutor extends DefaultMacroSubstitutor{
- public MacroUIMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter) {
- super(contextInfo, inexistentMacroValue, listDelimiter);
- }
-
- public MacroUIMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
- super(contextType, contextData, inexistentMacroValue, listDelimiter);
- }
-
- protected ResolvedMacro resolveMacro(String macroName) throws BuildMacroException{
- String names[] = BuildMacroProvider.fMbsMacroSupplier.getMacroNames(IBuildMacroProvider.CONTEXT_FILE);
- for(int i = 0; i < names.length; i++){
- if(macroName.equals(names[i]))
- return new ResolvedMacro(macroName,MacroResolver.createMacroReference(macroName));
- }
- names = BuildMacroProvider.fMbsMacroSupplier.getMacroNames(IBuildMacroProvider.CONTEXT_OPTION);
- for(int i = 0; i < names.length; i++){
- if(macroName.equals(names[i]))
- return new ResolvedMacro(macroName,MacroResolver.createMacroReference(macroName));
- }
- return super.resolveMacro(macroName);
- }
-
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
- if(macro instanceof EclipseVariablesMacroSupplier.EclipseVarMacro){
- EclipseVariablesMacroSupplier.EclipseVarMacro eclipseVarMacro =
- (EclipseVariablesMacroSupplier.EclipseVarMacro)macro;
- IStringVariable var = eclipseVarMacro.getVariable();
- String value = null;
- if(var instanceof IDynamicVariable){
- value = "dynamic<" + var.getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$
- } else {
- value = macro.getStringValue();
- }
- return new ResolvedMacro(macro.getName(),value);
- }
- return super.resolveMacro(macro);
- }
- }
-
- private class MacroUIMacroSontextInfo extends DefaultMacroContextInfo{
- protected MacroUIMacroSontextInfo(int contextType, Object contextData){
- super(contextType,contextData);
- }
-
- protected IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){
- IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
- if(suppliers == null || suppliers.length == 0)
- return null;
- EnvironmentVariableProvider envProvider = obtainEnvironmentVariableProvider();
- if(envProvider != null){
- for(int i = 0; i < suppliers.length; i++){
- if((suppliers[i] instanceof EnvironmentMacroSupplier)){
- suppliers[i] = new EnvironmentMacroSupplier(envProvider);
- break;
- }
- }
- }
- return suppliers;
- }
-
- }
-
- private class SystemContextInfo extends MacroUIMacroSontextInfo{
- protected SystemContextInfo(int contextType, Object contextData){
- super(contextType,contextData);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo#getSuppliers(int, java.lang.Object)
- */
- protected IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){
- IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
- if(suppliers == null || suppliers.length == 0)
- return null;
-
- List list = new ArrayList();
- for(int i = 0; i < suppliers.length; i++){
- if(!(suppliers[i] instanceof UserDefinedMacroSupplier))
- list.add(suppliers[i]);
- }
-
- return (IBuildMacroSupplier[])list.toArray(new IBuildMacroSupplier[list.size()]);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getNext()
- */
- public IMacroContextInfo getNext(){
- if(fUseDefaultParentContextInfo)
- return super.getNext();
- return fParentContextInfo;
- }
- }
-
- private class CurrentContextInfo extends MacroUIMacroSontextInfo{
- protected CurrentContextInfo(int contextType, Object contextData){
- super(contextType,contextData);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo#getSuppliers(int, java.lang.Object)
- */
- public IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){
- IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
-
- if(contextType == fContextType && contextData == fContextData && storeDirectly())
- return suppliers;
-
- if(suppliers == null || suppliers.length == 0)
- return suppliers;
- if(!(suppliers[0] instanceof UserDefinedMacroSupplier))
- return suppliers;
-
- List list = new ArrayList(suppliers.length);
- list.add(new UIMacroSupplier());
-
- for(int i = 1; i < suppliers.length; i++){
- list.add(suppliers[i]);
- }
-
- return (IBuildMacroSupplier[])list.toArray(new IBuildMacroSupplier[list.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getNext()
- */
- public IMacroContextInfo getNext(){
- if(fUseDefaultParentContextInfo)
- return super.getNext();
- return fParentContextInfo;
- }
- }
-
- private class UIMacroSupplier implements IBuildMacroSupplier{
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
- */
- public IBuildMacro getMacro(String name, int contextType, Object contextData){
- if(contextType != fContextType || contextData != fContextData)
- return null;
-
- return getUserMacro(name);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
- */
- public IBuildMacro[] getMacros(int contextType, Object contextData){
- if(contextType != fContextType || contextData != fContextData)
- return null;
-
- return getUserMacros();
- }
- }
-
- private class MacroContentProvider implements IStructuredContentProvider{
-
- public Object[] getElements(Object inputElement) {
- return (Object[])inputElement;
- }
-
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // TODO Auto-generated method stub
-
- }
-
- }
-
-
- private class MacroLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
- private boolean fUser;
- public MacroLabelProvider(boolean user){
- fUser = user;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- return getColumnText(element, 0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- IBuildMacro macro = (IBuildMacro)element;
- switch(columnIndex){
- case 0:
- return macro.getName();
- case 1:
- switch(macro.getMacroValueType()){
- case IBuildMacro.VALUE_PATH_FILE:
- return ManagedBuilderUIMessages.getResourceString(TYPE_PATH_FILE);
- case IBuildMacro.VALUE_PATH_FILE_LIST:
- return ManagedBuilderUIMessages.getResourceString(TYPE_PATH_FILE_LIST);
- case IBuildMacro.VALUE_PATH_DIR:
- return ManagedBuilderUIMessages.getResourceString(TYPE_PATH_DIR);
- case IBuildMacro.VALUE_PATH_DIR_LIST:
- return ManagedBuilderUIMessages.getResourceString(TYPE_PATH_DIR_LIST);
- case IBuildMacro.VALUE_PATH_ANY:
- return ManagedBuilderUIMessages.getResourceString(TYPE_PATH_ANY);
- case IBuildMacro.VALUE_PATH_ANY_LIST:
- return ManagedBuilderUIMessages.getResourceString(TYPE_PATH_ANY_LIST);
- case IBuildMacro.VALUE_TEXT:
- return ManagedBuilderUIMessages.getResourceString(TYPE_TEXT);
- case IBuildMacro.VALUE_TEXT_LIST:
- return ManagedBuilderUIMessages.getResourceString(TYPE_TEXT_LIST);
- default:
- }
- case 2:
- return getDisplayedMacroValue(macro); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
-
- private String getDisplayedMacroValue(IBuildMacro macro){
- String value = ""; //$NON-NLS-1$
- try{
- if(macro instanceof EclipseVariablesMacroSupplier.EclipseVarMacro){
- EclipseVariablesMacroSupplier.EclipseVarMacro eclipseVarMacro =
- (EclipseVariablesMacroSupplier.EclipseVarMacro)macro;
- IStringVariable var = eclipseVarMacro.getVariable();
- if(var instanceof IDynamicVariable){
- value = ManagedBuilderUIMessages.getResourceString(VALUE_ECLIPSE_DYNAMIC);
- } else {
- value = macro.getStringValue();
- }
- } else {
- if(MacroResolver.isStringListMacro(macro.getMacroValueType()))
- value = BuildMacroProvider.getDefault().convertStringListToString(macro.getStringListValue(),VALUE_DELIMITER);
- else
- value = macro.getStringValue();
-
- }
- }catch (BuildMacroException e){
- }
- return value;
- }
-
- private Font getValueFont(IBuildMacro macro){
- Font font = null;
- if(macro instanceof EclipseVariablesMacroSupplier.EclipseVarMacro){
- EclipseVariablesMacroSupplier.EclipseVarMacro eclipseVarMacro =
- (EclipseVariablesMacroSupplier.EclipseVarMacro)macro;
- IStringVariable var = eclipseVarMacro.getVariable();
- if(var instanceof IDynamicVariable){
- font = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
- }
- }
-
- return font;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
- */
- public Font getFont(Object element) {
- return getFont(element, 0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableFontProvider#getFont(java.lang.Object, int)
- */
- public Font getFont(Object element, int columnIndex) {
- IBuildMacro macro = (IBuildMacro)element;
-
- switch(columnIndex){
- case 0:
- case 1:
- break;
- case 2:
- return getValueFont(macro);
- }
-
- if(!fUser && getUserMacro(macro.getName()) != null)
- return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element){
- IBuildMacro macro = (IBuildMacro)element;
- boolean incorrect = false;
- String name = macro.getName();
- if(fUser || getUserMacro(name) == null)
- incorrect = fIncorrectlyDefinedMacrosNames.contains(name);
-
- if(incorrect)
- return JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
- return null;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
- */
- public Color getBackground(Object element){
- return null;
- }
- }
-
- /*
- * constructor
- */
- public MacrosBlock(ICOptionContainer parent, String title, boolean editable, boolean showParentViewCheckBox){
- super(title);
- super.setContainer(parent);
-
- fShowParentViewCheckBox = showParentViewCheckBox;
- fIsEditable = editable;
- }
-
- private Map getUserMacrosMap(){
- Map map = new HashMap();
- if(fUserSupplier != null) {
- if(!fDeleteAll){
- IBuildMacro macros[] = fUserSupplier.getMacros(fContextType,fContextData);
- if(macros != null) {
- for(int i = 0; i < macros.length; i++){
- String name = macros[i].getName();
- map.put(name,macros[i]);
- }
- }
-
- Iterator iter = getDeletedUserMacroNames().iterator();
- while(iter.hasNext()){
- map.remove((String)iter.next());
- }
-
- iter = getAddedUserMacros().values().iterator();
- while(iter.hasNext()){
- IBuildMacro macro = (IBuildMacro)iter.next();
- String name = macro.getName();
- map.put(name,macro);
- }
- }
- }
- return map;
- }
-
- /*
- * returns the map containing the user-defined macros
- */
- private IBuildMacro[] getUserMacros(){
- if(storeDirectly() && fUserSupplier != null)
- return fUserSupplier.getMacros(fContextType,fContextData);
-
- Collection macros = getUserMacrosMap().values();
- return (IBuildMacro[])macros.toArray(new IBuildMacro[macros.size()]);
-
- }
-
- /*
- * returns the HashSet holding the names of the user-deleted macros
- */
- private HashSet getDeletedUserMacroNames(){
- if(fDeletedUserMacroNames == null)
- fDeletedUserMacroNames = new HashSet();
- return fDeletedUserMacroNames;
- }
-
- /*
- * returns the map holding user-created/modified macros
- */
- private Map getAddedUserMacros(){
- if(fAddedUserMacros == null)
- fAddedUserMacros = new HashMap();
- return fAddedUserMacros;
- }
-
- /*
- * creates a user macro
- * the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier
- * the applyUserMacros() should be called to store those macros to the user supplier
- */
-/* private void addUserMacro(String name, int type, String value){
- if(!canCreate(name))
- return;
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.createMacro(newMacro, fContextType, fContextData);
- } else {
- fDeleteAll = false;
- BuildMacro newMacro = new BuildMacro(name,type,value);
- getDeletedUserMacroNames().remove(name);
- getAddedUserMacros().put(name,newMacro);
- }
- fModified = true;
- }
-*/
- /*
- * creates a user macro
- * the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier
- * the applyUserMacros() should be called to store those macros to the user supplier
- */
- private void addUserMacro(IBuildMacro newMacro){
- String name = newMacro.getName();
- if(!canCreate(name))
- return;
-
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.createMacro(newMacro, fContextType, fContextData);
- } else {
- fDeleteAll = false;
- getDeletedUserMacroNames().remove(name);
- getAddedUserMacros().put(name,newMacro);
- }
-
- fModified = true;
- }
-
- /*
- * creates a user macro
- * the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier
- * the applyUserMacros() should be called to store those macros to the user supplier
- */
-/* private void addUserMacro(String name, int type, String value[]){
- if(!canCreate(name))
- return;
-
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.createMacro(newMacro, fContextType, fContextData);
- } else {
- fDeleteAll = false;
- BuildMacro newMacro = new BuildMacro(name,type,value);
- getDeletedUserMacroNames().remove(name);
- getAddedUserMacros().put(name,newMacro);
- }
- fModified = true;
- }
-*/
- /*
- * deletes a user macro
- * the macros deleted are stored in the fDeletedUserMacroNames HashSet, and are not actually deleted from the user supplier
- * the applyUserMacros() should be called to delete those macros from the user supplier
- */
- private void deleteUserMacro(String name){
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.deleteMacro(name, fContextType, fContextData);
- } else {
- fDeleteAll = false;
- getAddedUserMacros().remove(name);
- getDeletedUserMacroNames().add(name);
- }
- fModified = true;
- }
-
- /*
- * deletes all user macros
- * the applyUserMacros() should be called to delete those macros from the user supplier
- */
- private void deleteAllUserMacros(){
- if(storeDirectly() && fUserSupplier != null){
- fUserSupplier.deleteAll(fContextType, fContextData);
- } else {
- fDeleteAll = true;
- getDeletedUserMacroNames().clear();
- getAddedUserMacros().clear();
- }
- fModified = true;
- }
-
- /*
- * returns whether the user macros were modified
- */
- public boolean isModified(){
- return fModified;
- }
-
- /*
- * sets the modify state
- */
- public void setModified(boolean modified){
- fModified = modified;
- }
-
- /*
- * returns a user macro of a given name
- */
- private IBuildMacro getUserMacro(String name){
- if(storeDirectly() && fUserSupplier != null)
- return fUserSupplier.getMacro(name,fContextType,fContextData);
-
- Map macros = getUserMacrosMap();
- if(macros == null)
- return null;
-
- return (IBuildMacro)macros.get(name);
- }
-
- /*
- * applies user macros.
- *
- */
- private void applyUserMacros(){
- if(fUserSupplier != null){
- if(storeDirectly()){
- if(getContainer() instanceof AbstractBuildPropertyPage
- && fContextType == IBuildMacroProvider.CONTEXT_CONFIGURATION
- && fContextData instanceof IConfiguration){
- AbstractBuildPropertyPage page = (AbstractBuildPropertyPage)getContainer();
- IConfiguration realCfg = page.getRealConfig((IConfiguration)fContextData);
- IBuildMacro macros[] = getUserMacros();
- UserDefinedMacroSupplier supplier = BuildMacroProvider.fUserDefinedMacroSupplier;
- supplier.setMacros(macros, IBuildMacroProvider.CONTEXT_CONFIGURATION, realCfg);
- }
- } else {
- if(fDeleteAll){
- fUserSupplier.deleteAll(fContextType,fContextData);
- }
- else{
- Iterator iter = getDeletedUserMacroNames().iterator();
- while(iter.hasNext()){
- fUserSupplier.deleteMacro((String)iter.next(),fContextType,fContextData);
- }
-
- iter = getAddedUserMacros().values().iterator();
- while(iter.hasNext()){
- IBuildMacro macro = (IBuildMacro)iter.next();
- fUserSupplier.createMacro(macro,fContextType,fContextData);
- }
-
- getDeletedUserMacroNames().clear();
- getAddedUserMacros().clear();
- }
- }
- }
- }
-
- /*
- * applies user macros and asks the user supplier to serialize
- */
- private void storeUserMacros(){
- applyUserMacros();
- if(fUserSupplier != null)
- fUserSupplier.serialize(false);
- }
-
- /*
- * called when the user macro selection was changed
- */
- private void handleSelectionChanged(SelectionChangedEvent event){
- int size = ((IStructuredSelection)event.getSelection()).size();
- fEditButton.setEnabled(size == 1);
- fDeleteButton.setEnabled(size > 0);
- }
-
- /*
- * called when a custom button was pressed
- */
- private void handleCustomButtonPressed(int index){
-
- switch(index){
- case IDX_BUTTON_NEW:{
- NewBuildMacroDialog dlg = new NewBuildMacroDialog(fParent.getShell(),this,null);
- if(dlg.open() == Dialog.OK){
- IBuildMacro macro = dlg.getDefinedMacro();
- if(macro != null){
- addUserMacro(macro);
- updateValues();
- }
- }
- }
- break;
- case IDX_BUTTON_EDIT:{
- IBuildMacro macros[] = getSelectedUserMacros();
- if(macros != null && macros.length == 1){
- NewBuildMacroDialog dlg = new NewBuildMacroDialog(fParent.getShell(),this,getUserMacro(macros[0].getName()));
- if(dlg.open() == Dialog.OK){
- IBuildMacro macro = dlg.getDefinedMacro();
- if(macro != null){
- addUserMacro(macro);
- updateValues();
- }
- }
- }
- }
- break;
- case IDX_BUTTON_DELETE:{
- IBuildMacro macros[] = getSelectedUserMacros();
- if(macros != null && macros.length > 0){
- if(MessageDialog.openQuestion(fParent.getShell(),
- ManagedBuilderUIMessages.getResourceString(DELETE_CONFIRM_TITLE),
- ManagedBuilderUIMessages.getResourceString(DELETE_CONFIRM_MESSAGE))){
- for(int i = 0; i < macros.length; i++){
- deleteUserMacro(macros[i].getName());
- }
- updateValues();
- }
- }
- }
- break;
- }
-
- }
-
- /*
- * returnes the selected user-defined macros
- */
- private IBuildMacro[] getSelectedUserMacros(){
- if(fEditableTable == null)
- return null;
-
- List list = ((IStructuredSelection)fEditableTable.getSelection()).toList();
- return (IBuildMacro[])list.toArray(new IBuildMacro[list.size()]);
- }
-
- /*
- * sets the context for which the macros should be displayed
- */
- public void setContext(int contextType, Object contextData){
- if(contextType == fContextType && contextData == fContextData)
- return;
-
- fContextType = contextType;
- fContextData = contextData;
-
- IBuildMacroProvider provider = BuildMacroProvider.getDefault();
- IBuildMacroSupplier suppliers[] = provider.getSuppliers(fContextType, fContextData);
- if(suppliers != null && suppliers.length != 0 && suppliers[0] instanceof UserDefinedMacroSupplier){
- fUserSupplier = (UserDefinedMacroSupplier)suppliers[0];
- }
-
- fSystemContextInfo = new SystemContextInfo(fContextType, fContextData);
- fCurrentContextInfo = new CurrentContextInfo(fContextType, fContextData);
- }
-
- public void setParentContextInfo(IMacroContextInfo info){
- fParentContextInfo = info;
- fUseDefaultParentContextInfo = false;
- }
-
- public void resetDefaultParentContextInfo(){
- fUseDefaultParentContextInfo = true;
- fParentContextInfo = null;
- }
-
- public IMacroContextInfo getContextInfo(){
- return fCurrentContextInfo;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- if(fUserSupplier == null)
- return;
- storeUserMacros();
- setModified(false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- if(MessageDialog.openQuestion(fParent.getShell(),
- ManagedBuilderUIMessages.getResourceString(DELETE_ALL_CONFIRM_TITLE),
- ManagedBuilderUIMessages.getResourceString(DELETE_ALL_CONFIRM_MESSAGE))){
- deleteAllUserMacros();
- updateValues();
- }
- }
-
- /*
- * updates both user- and sytem- macros tables.
- */
- public void updateValues(){
- if(fCurrentContextInfo == null)
- return;
- try{
- MacroResolver.checkIntegrity(fCurrentContextInfo,new MacroUIMacroSubstitutor(fCurrentContextInfo,null," "));//$NON-NLS-1$ //$NON-NLS-2$
- updateState(null);
- } catch (BuildMacroException e){
- updateState(e);
- }
- updateUserMacros();
- updateSystemMacros();
- }
-
- private void updateState(BuildMacroException e){
- fIncorrectlyDefinedMacrosNames.clear();
-
- if(e != null){
- fStatusLabel.setText(e.getMessage());
- fStatusLabel.setVisible(true);
- IBuildMacroStatus statuses[] = e.getMacroStatuses();
- for(int i = 0; i < statuses.length; i++){
- String name = statuses[i].getMacroName();
- if(name != null)
- fIncorrectlyDefinedMacrosNames.add(name);
- }
- }
- else{
- fStatusLabel.setVisible(false);
- }
- }
-
- /*
- * apdates a user-defined macros table
- */
- private void updateUserMacros(){
- if(fEditableTable == null || fContextType == 0)
- return;
-
- IBuildMacro macros[] = getUserMacros();
- ArrayList list = new ArrayList(macros.length);
- for(int i = 0; i < macros.length; i++){
- if(macros[i] != null)
- list.add(macros[i]);
- }
- fEditableTable.setInput(list.toArray(new IBuildMacro[list.size()]));
- }
-
-
- /*
- * apdates a system-defined macros table
- */
- private void updateSystemMacros(){
- if(fNonEditableTable == null || fContextType == 0)
- return;
-
- ArrayList list = new ArrayList();
- IBuildMacro macros[] = getSystemMacros(fShowParentMacros);
- if(macros != null && macros.length != 0){
- for(int i = 0; i < macros.length; i++){
- if(macros[i] != null)
- list.add(macros[i]);
- }
- }
-
- fNonEditableTable.setInput(list.toArray(new IBuildMacro[list.size()]));
- }
-
- /*
- * return a system macro of a given name
- */
- public IBuildMacro getSystemMacro(String name,boolean includeParentLevels){
- if(name == null)
- return null;
- if(fSystemContextInfo == null)
- return null;
- if(!canDisplay(name))
- return null;
-
- return BuildMacroProvider.getMacro(name,fSystemContextInfo,includeParentLevels);
- }
-
- /*
- * returns an array of system macros
- */
- public IBuildMacro[] getSystemMacros(boolean includeParentLevels){
- IBuildMacro macros[] = BuildMacroProvider.getMacros(fSystemContextInfo,includeParentLevels);
- if(macros == null)
- return null;
- return filterMacros(macros);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- fParent = parent;
- FormLayout layout= new FormLayout();
- FormData fd;
- Control buttonsControl = null;
- Control listControl = null;
-
- Composite composite= new Composite(parent, SWT.NULL);
- composite.setLayout(layout);
-
- if(fIsEditable){
- Label nameLabel = new Label(composite, SWT.LEFT);
- nameLabel.setFont(composite.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(USER_MACROS));
- fd = new FormData();
- fd.top = new FormAttachment(0,2);
- fd.left = new FormAttachment(0,0);
- nameLabel.setLayoutData(fd);
-
- listControl= createTableControl(composite,true);
-
- buttonsControl= createButtonsControl(composite);
-
- fd = new FormData();
- fd.top = new FormAttachment(nameLabel,0);
- fd.right = new FormAttachment(100,0);
- buttonsControl.setLayoutData(fd);
-
- fd = new FormData();
- fd.top = new FormAttachment(nameLabel,0);
- fd.left = new FormAttachment(0,0);
- fd.right = new FormAttachment(buttonsControl,-5);
- fd.bottom = new FormAttachment(50,-15);
- listControl.setLayoutData(fd);
-
- }
-
- Label nameLabel = new Label(composite, SWT.LEFT);
- nameLabel.setFont(composite.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(SYSTEM_MACROS));
- fd = new FormData();
- if(fIsEditable)
- fd.top = new FormAttachment(listControl,2);
- else
- fd.top = new FormAttachment(0,2);
- fd.left = new FormAttachment(0,0);
- nameLabel.setLayoutData(fd);
-
- fStatusLabel = new Label(composite, SWT.LEFT);
- fStatusLabel.setFont(composite.getFont());
- fStatusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
- fd = new FormData();
- fd.bottom = new FormAttachment(100,-10);
- fd.left = new FormAttachment(0,10);
- fd.right = new FormAttachment(100,-10);
- fStatusLabel.setLayoutData(fd);
-
-
- if(fShowParentViewCheckBox){
- // Create a "show parent levels" button
- fShowParentButton = new Button(composite, SWT.CHECK);
- fShowParentButton.setFont(composite.getFont());
- fShowParentButton.setText(ManagedBuilderUIMessages.getResourceString(BUTTON_CHECK_SHOW_PARENT));
- fd = new FormData();
- fd.left = new FormAttachment(0,0);
- fd.bottom = new FormAttachment(fStatusLabel,-10);
- fShowParentButton.setLayoutData(fd);
- fShowParentButton.setSelection(fShowParentMacros);
- fShowParentButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fShowParentMacros = fShowParentButton.getSelection();
- updateSystemMacros();
- }
- });
- }
-
- listControl= createTableControl(composite,false);
- fd = new FormData();
- fd.top = new FormAttachment(nameLabel,0);
- fd.left = new FormAttachment(0,0);
- if(buttonsControl != null)
- fd.right = new FormAttachment(buttonsControl,-5);
- else
- fd.right = new FormAttachment(100,0);
- if(fShowParentButton != null)
- fd.bottom = new FormAttachment(fShowParentButton,-2);
- else
- fd.bottom = new FormAttachment(fStatusLabel,-10);
-
- listControl.setLayoutData(fd);
-
- this.setControl(composite);
- }
-
- private Control createTableControl(Composite parent, boolean editable){
- Composite listControl= new Composite(parent, SWT.NONE);
- TableViewer tableViewer;
- GridLayout gl = new GridLayout();
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- gl.numColumns = 1;
- listControl.setLayout(gl);
- tableViewer = new TableViewer(listControl, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
- | SWT.FULL_SELECTION);
-
- Table table = tableViewer.getTable();
- TableLayout tableLayout = new TableLayout();
- for (int i = 0; i < fTableColumnNames.length; i++) {
- tableLayout.addColumnData(fTableColumnLayouts[i]);
- TableColumn tc = new TableColumn(table, SWT.NONE, i);
- tc.setResizable(fTableColumnLayouts[i].resizable);
- tc.setText(fTableColumnNames[i]);
- }
- table.setLayout(tableLayout);
- table.setHeaderVisible(true);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 50;
- tableViewer.getControl().setLayoutData(gd);
- tableViewer.setContentProvider(new MacroContentProvider());
- tableViewer.setLabelProvider(new MacroLabelProvider(editable));
- tableViewer.setSorter(new ViewerSorter());
-
- if(editable){
- tableViewer.setColumnProperties(fEditableTableColumnProps);
- fEditableTable = tableViewer;
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChanged(event);
- }
- });
- tableViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(DoubleClickEvent event) {
- if (!fEditableTable.getSelection().isEmpty()) {
- handleCustomButtonPressed(IDX_BUTTON_EDIT);
- }
- }
- });
-
- table.addKeyListener(new KeyListener(){
- public void keyPressed(KeyEvent e){
- if(e.keyCode == SWT.DEL)
- handleCustomButtonPressed(IDX_BUTTON_DELETE);
- }
-
- public void keyReleased(KeyEvent e){
-
- }
- });
- } else {
- tableViewer.setColumnProperties(fNonEditableTableColumnProps);
- fNonEditableTable = tableViewer;
- }
- return listControl;
- }
-
- private Control createButtonsControl(Composite parent){
- Composite buttonsControl = new Composite(parent, SWT.NONE);
- GridLayout gl = new GridLayout();
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- gl.numColumns = 1;
- buttonsControl.setLayout(gl);
-
- GridData gd;
- fNewButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_NEW),null);
- fNewButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleCustomButtonPressed(IDX_BUTTON_NEW);
- }
- });
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = SWTUtil.getButtonHeigthHint(fNewButton);
- gd.widthHint = SWTUtil.getButtonWidthHint(fNewButton);
- fNewButton.setLayoutData(gd);
-
- fEditButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_EDIT),null);
- fEditButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleCustomButtonPressed(IDX_BUTTON_EDIT);
- }
- });
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = SWTUtil.getButtonHeigthHint(fEditButton);
- gd.widthHint = SWTUtil.getButtonWidthHint(fEditButton);
- fEditButton.setLayoutData(gd);
-
- fDeleteButton = createPushButton(buttonsControl,ManagedBuilderUIMessages.getResourceString(BUTTON_DELETE),null);
- fDeleteButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- handleCustomButtonPressed(IDX_BUTTON_DELETE);
- }
- });
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = SWTUtil.getButtonHeigthHint(fDeleteButton);
- gd.widthHint = SWTUtil.getButtonWidthHint(fDeleteButton);
- fDeleteButton.setLayoutData(gd);
- return buttonsControl;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible){
-// fVisible = visible;
-// if(visible)
-// updateValues();
- super.setVisible(visible);
- }
-
- /*
- * return the context for which the macros are displayed
- */
- public Object getContextData(){
- return fContextData;
- }
-
- public int getContextType(){
- return fContextType;
- }
-
- public void displayParentMacros(boolean display){
- fShowParentMacros = display;
- if(fShowParentButton != null)
- fShowParentButton.setSelection(fShowParentMacros);
- updateSystemMacros();
- }
-
- /*
- * answers whether the given macro should be displayed in UI or not
- */
- protected boolean canDisplay(String name){
- return canCreate(name);
- }
-
- /*
- * answers whether the macro of a given name can be sreated
- */
- public boolean canCreate(String name){
- if(name == null || (name = name.trim()).length() == 0)
- return false;
-
- if(fHiddenMacros != null){
- for(int i = 0; i < fHiddenMacros.length; i++){
- if(fHiddenMacros[i].equals(EnvVarOperationProcessor.normalizeName(name)))
- return false;
- }
- }
- return true;
- }
-
- /*
- * filteres the macros to be displayed
- */
- protected IBuildMacro[] filterMacros(IBuildMacro macros[]){
- return MacroResolver.filterMacros(macros,fHiddenMacros);
- }
-
- protected EnvironmentVariableProvider obtainEnvironmentVariableProvider(){
- ICOptionContainer container = getContainer();
- ManagedBuildOptionBlock optionBlock = null;
- if(container instanceof BuildPropertyPage){
- BuildPropertyPage page = (BuildPropertyPage)container;
- optionBlock = page.getOptionBlock();
- } else if(container instanceof BuildPreferencePage){
- BuildPreferencePage page = (BuildPreferencePage)container;
- optionBlock = page.getOptionBlock();
- }
- if(optionBlock != null){
- EnvironmentSetBlock block = optionBlock.getEnvironmentBlock();
- if(block != null)
- return block.getEnvironmentVariableProvider();
- }
- return null;
- }
-
- protected boolean storeDirectly(){
- if(fContextType == IBuildMacroProvider.CONTEXT_CONFIGURATION
- && fContextData instanceof IConfiguration)
- return ((IConfiguration)fContextData).isTemporary();
- return false;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java
deleted file mode 100644
index 300cdd449ce..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.ui.dialogs.ICOptionPage;
-import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-
-/**
- * Whe used in the BuildPropertyPage the displays the tab-folder that contains the following tabs:
- * 1. a tab containing configuration-specific macros
- * 2. a tab containing project-specific macros
- *
- * Otherwise displays a single MacrosBlock that contains
- * the workspace-specific, CDT/Eclipse installation and eclipse process environment macros
- *
- */public class MacrosSetBlock extends AbstractCOptionPage {
- /*
- * String constants
- */
- private static final String PREFIX = "MacrosSetBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String MACROS_LABEL = LABEL + ".macros"; //$NON-NLS-1$
-
- private static final String MACROS_GROUP_LABEL = LABEL + ".macros.group"; //$NON-NLS-1$
-
- private static final String TAB = LABEL + ".tab"; //$NON-NLS-1$
- private static final String TAB_CONFIGURATION = TAB + ".configuration"; //$NON-NLS-1$
- private static final String TAB_PROJECT = TAB + ".project"; //$NON-NLS-1$
- private static final String TAB_WORKSPACE = TAB + ".workspace"; //$NON-NLS-1$
- private static final String TAB_ECLIPSE = TAB + ".eclipse"; //$NON-NLS-1$
-
- private MacrosTabFolder fMacroTabs;
- private MacrosBlock fMacroBlock;
-
- private ICOptionContainer fParentContainer;
-
- private UIMacroProvider fMacroProvider;
-
- private class UIMacroContextInfo extends DefaultMacroContextInfo{
- public UIMacroContextInfo(int type, Object data){
- super(type,data);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getNext()
- */
- public IMacroContextInfo getNext(){
- IMacroContextInfo info = super.getNext();
- if(info != null){
- MacrosBlock blocks[] = getAllBlocks();
- for(int i = 0; i < blocks.length; i++){
- if(blocks[i].getContextType() == info.getContextType() &&
- blocks[i].getContextData() == info.getContextData())
- return blocks[i].getContextInfo();
- }
- return new UIMacroContextInfo(info.getContextType(),info.getContextData());
- }
- return null;
- }
- }
-
- /*
- * The BuildMacroProvider to be used in UI
- * Unlike the default provider, this provider also contains
- * the user-modified macros that are not applied yet
- */
- private class UIMacroProvider extends BuildMacroProvider {
- public IMacroContextInfo getMacroContextInfo(int contextType, Object contextData){
- MacrosBlock blocks[] = getAllBlocks();
- for(int i = 0; i < blocks.length; i++){
- if(blocks[i].getContextType() == contextType &&
- blocks[i].getContextData() == contextData)
- return blocks[i].getContextInfo();
- }
- return new UIMacroContextInfo(contextType,contextData);
- }
- }
-
- private class MacrosTabFolder extends TabFolderOptionBlock{
- private MacrosBlock fFolderTabs[];
- public MacrosTabFolder() {
- super(fParentContainer, false);
- }
-
- public MacrosBlock[] getTabs(){
- return fFolderTabs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
- */
- protected void addTabs(){
- if(fParentContainer instanceof BuildPropertyPage) {
- // the EnvironmentSetBlock is used whithing the Build Property Page
- // create the project and configuration tabs
- fFolderTabs = new MacrosBlock[2];
- addTab(fFolderTabs[0] = new MacrosBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_CONFIGURATION),
- true,
- true));
- addTab(fFolderTabs[1] = new MacrosBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_PROJECT),
- true,
- true));
- }
-/* else {
- // the EnvironmentSetBlock is used whithing the Build Preference Page
- // create the workspace and eclipse environment tabs
- fFolderTabs = new MacrosBlock[2];
- addTab(fFolderTabs[0] = new MacrosBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_WORKSPACE),
- true,
- true));
- addTab(fFolderTabs[1] = new MacrosBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_ECLIPSE),
- false,
- false));
- }
-*/
- }
-
- /*
- * set the appropriate context data to the tabs
- */
- public void updateContexts(){
- if(fFolderTabs == null)
- return;
-
- if(fParentContainer instanceof BuildPropertyPage){
- BuildPropertyPage page = (BuildPropertyPage)fParentContainer;
- if(page.getSelectedConfigurationClone() != null)
- fFolderTabs[1].setContext(IBuildMacroProvider.CONTEXT_PROJECT,page.getSelectedConfigurationClone().getManagedProject());
-
- fFolderTabs[0].setContext(IBuildMacroProvider.CONTEXT_CONFIGURATION,page.getSelectedConfigurationClone());
- fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
- }
-/* else {
- fFolderTabs[1].setContext(null);
-
- fFolderTabs[0].setContext(ResourcesPlugin.getWorkspace());
- fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
- }
-*/
- }
-
- public void setCurrentPage(ICOptionPage page) {
- ((MacrosBlock)page).updateValues();
- super.setCurrentPage(page);
- }
-
- }
-
-
- public MacrosSetBlock(ICOptionContainer parent){
- super(ManagedBuilderUIMessages.getResourceString(MACROS_LABEL));
- super.setContainer(parent);
- fParentContainer = parent;
-// fOptionBlock = optionBlock;
-
- if(fParentContainer instanceof BuildPropertyPage)
- fMacroTabs = new MacrosTabFolder();
- else {
- fMacroBlock = new MacrosBlock(fParentContainer,
- ManagedBuilderUIMessages.getResourceString(TAB_WORKSPACE),
- true,
- false);
- fMacroBlock.displayParentMacros(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- MacrosBlock tabs[] = getAllBlocks();
- if(tabs != null){
- for(int i = 0; i < tabs.length; i++)
- tabs[i].performApply(monitor);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- MacrosBlock tab = getSelectedBlock();
- if(tab != null)
- tab.performDefaults();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible){
- if(visible)
- updateValues();
- if(fMacroTabs != null)
- fMacroTabs.setVisible(visible);
- super.setVisible(visible);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Control ctrl = null;
- if(fMacroTabs != null){
- Group group = new Group(parent, SWT.NONE);
- group.setFont(parent.getFont());
- group.setText(ManagedBuilderUIMessages.getResourceString(MACROS_GROUP_LABEL));
- group.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout gl = new GridLayout();
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- group.setLayout(gl);
- Control tabs = fMacroTabs.createContents(group);
- GridData gd = new GridData(GridData.FILL_BOTH);
- tabs.setLayoutData(gd);
- ctrl = group;
- }
- else if(fMacroBlock != null){
- fMacroBlock.createControl(parent);
- ctrl = fMacroBlock.getControl();
- ctrl.setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- setControl(ctrl);
- }
-
- public void updateValues(){
- MacrosBlock tab = getSelectedBlock();
-
- updateContexts();
- if(tab != null)
- tab.updateValues();
- }
-
- public boolean isConfigSelectionAllowed(){
- MacrosBlock block = getSelectedBlock();
- if(block != null)
- return block.getContextData() instanceof IConfiguration;
- return false;
- }
-
- public boolean isModified(){
- MacrosBlock tabs[] = getAllBlocks();
- for(int i = 0; i < tabs.length; i++){
- if(tabs[i].isModified())
- return true;
- }
- return false;
- }
-
- public void setModified(boolean modified){
- MacrosBlock tabs[] = getAllBlocks();
- for(int i = 0; i < tabs.length; i++){
- tabs[i].setModified(modified);
- }
- }
-
- /*
- * returns the selected environment block
- */
- protected MacrosBlock getSelectedBlock(){
- if(fMacroTabs != null)
- return (MacrosBlock)fMacroTabs.getCurrentPage();
- return fMacroBlock;
- }
-
- /*
- * returns all available environment blocks
- */
- protected MacrosBlock[] getAllBlocks(){
- if(fMacroTabs != null)
- return fMacroTabs.getTabs();
- else if(fMacroBlock != null)
- return new MacrosBlock[]{fMacroBlock};
- return new MacrosBlock[0];
- }
-
- /*
- * updates the context of each EnvironmentBlock
- */
- protected void updateContexts(){
- if(fMacroTabs != null)
- fMacroTabs.updateContexts();
- else if(fMacroBlock != null)
- fMacroBlock.setContext(IBuildMacroProvider.CONTEXT_WORKSPACE,ResourcesPlugin.getWorkspace());
- }
-
- /*
- * returns the BuildMacroProvider to be used in UI
- * Unlike the default provider, the returned provider also contains
- * the user-modified macros that are not applied yet
- */
- public BuildMacroProvider getBuildMacroProvider(){
- if(fMacroProvider == null){
- updateContexts();
- fMacroProvider = new UIMacroProvider();
- }
- return fMacroProvider;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java
deleted file mode 100644
index 16d119a8934..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java
+++ /dev/null
@@ -1,438 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import java.util.Iterator;
-
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPreferenceStore;
-import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
-import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
-import org.eclipse.cdt.ui.dialogs.ICOptionPage;
-import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
-
- private ToolsSettingsBlock toolsSettingsBlock;
- private ResourceCustomBuildStepBlock resCustomBuildStepBlock;
- private BuildSettingsBlock buildSettingsBlock;
- private BuildStepSettingsBlock buildStepSettingsBlock;
- private ErrorParserBlock errParserBlock;
- private BinaryParserBlock binaryParserBlock;
- private EnvironmentSetBlock environmentBlock;
- private MacrosSetBlock macrosBlock;
- private Object element;
-
- /**
- * @param parent
- */
- public ManagedBuildOptionBlock(BuildPropertyPage parent) {
- super(parent, false);
- }
-
- public ManagedBuildOptionBlock(ResourceBuildPropertyPage resParent) {
- super(resParent, false);
- }
-
- public ManagedBuildOptionBlock(BuildPreferencePage wspParent){
- super(wspParent, false);
- }
-
- public BuildPropertyPage getBuildPropertyPage() {
- return (BuildPropertyPage)fParent;
- }
-
- public ResourceBuildPropertyPage getResourceBuildPropertyPage() {
- return (ResourceBuildPropertyPage)fParent;
- }
-
- public BuildPreferencePage getBuildPreferencePage() {
- return (BuildPreferencePage)fParent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
- */
- protected void addTabs() {
-
- if (element instanceof IProject) {
- addTab(toolsSettingsBlock = new ToolsSettingsBlock((BuildPropertyPage) fParent, element));
- addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent));
- addTab(buildStepSettingsBlock = new BuildStepSettingsBlock((BuildPropertyPage) fParent));
- addTab(errParserBlock = new ErrorParserBlock((BuildPropertyPage) fParent));
- addTab(binaryParserBlock = new BinaryParserBlock());
- addTab(environmentBlock = new EnvironmentSetBlock((BuildPropertyPage) fParent));
- addTab(macrosBlock = new MacrosSetBlock((BuildPropertyPage) fParent));
- } else if (element instanceof IFile) {
- /*
- * If the resource is a known build resource, display the tool settings tab and the rcbs tab.
- * If the resource is not a known build resource, only display the rcbs tab.
- */
- if(((ResourceBuildPropertyPage)fParent).isBuildResource((IFile)element)) {
- addTab(toolsSettingsBlock = new ToolsSettingsBlock((ResourceBuildPropertyPage) fParent, element));
- }
- addTab(resCustomBuildStepBlock = new ResourceCustomBuildStepBlock((ResourceBuildPropertyPage) fParent));
- } else if (element instanceof IWorkspace) {
- addTab(environmentBlock = new EnvironmentSetBlock((BuildPreferencePage) fParent));
- addTab(macrosBlock = new MacrosSetBlock((BuildPreferencePage) fParent));
- }
- }
-
- public ToolsSettingsBlock getToolsSettingsBlock() {
- return toolsSettingsBlock;
- }
-
- public ResourceCustomBuildStepBlock getResourceCustomBuildStepBlock() {
- return resCustomBuildStepBlock;
- }
-
- public BuildSettingsBlock getBuildSettingsBlock() {
- return buildSettingsBlock;
- }
-
- public BuildStepSettingsBlock getBuildStepSettingsBlock() {
- return buildStepSettingsBlock;
- }
-
- public BinaryParserBlock getBinaryParserBlock() {
- return binaryParserBlock;
- }
-
- public ErrorParserBlock getErrorParserBlock() {
- return errParserBlock;
- }
-
- public EnvironmentSetBlock getEnvironmentBlock() {
- return environmentBlock;
- }
-
- public MacrosSetBlock getMacrosBlock() {
- return macrosBlock;
- }
-
- public Control createContents(Composite parent, Object element) {
- this.element = element;
- Control control = super.createContents( parent );
- ((GridLayout)((Composite)control).getLayout()).marginWidth = 1;
- GridData gd = new GridData(GridData.FILL_BOTH);
- ((Composite)control).setLayoutData(gd);
-
- // TODO
- //if (getToolsSettingsBlock() != null)
- // WorkbenchHelp.setHelp(getToolsSettingsBlock().getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_ERROR_PARSER);
- if (getErrorParserBlock() != null)
- WorkbenchHelp.setHelp(getErrorParserBlock().getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_ERROR_PARSER);
-
- return control;
- }
-
- protected void initializeValues() {
- if (getToolsSettingsBlock()!= null) {
- getToolsSettingsBlock().initializeValues();
- }
- if (getResourceCustomBuildStepBlock()!= null) {
- getResourceCustomBuildStepBlock().initializeValues();
- }
- if (getBuildSettingsBlock()!= null) {
- getBuildSettingsBlock().initializeValues();
- }
- if (getBuildStepSettingsBlock()!= null) {
- getBuildStepSettingsBlock().initializeValues();
- }
- if (getErrorParserBlock()!= null) {
- // TODO
- //getErrorParserBlock().initializeValues();
- }
- if (getBinaryParserBlock()!= null) {
- // TODO
- //getBinaryParserBlock().initializeValues();
- }
- if(getEnvironmentBlock()!= null) {
- }
- if(getMacrosBlock()!= null) {
- }
- }
-
- public void updateValues() {
- if (element instanceof IProject) {
- if (getToolsSettingsBlock() != null) {
- getToolsSettingsBlock().updateValues();
- }
- if (getBuildSettingsBlock() != null) {
- getBuildSettingsBlock().updateValues();
- }
- if (getBuildStepSettingsBlock() != null) {
- getBuildStepSettingsBlock().updateValues();
- }
- if (getErrorParserBlock() != null) {
- getErrorParserBlock().updateValues();
- }
- if (getBinaryParserBlock() != null) {
- // TODO
- //getBinaryParserBlock().updateValues();
- }
- if(getCurrentPage() instanceof EnvironmentSetBlock) {
- ((EnvironmentSetBlock)getCurrentPage()).updateValues();
- }else if(getCurrentPage() instanceof MacrosSetBlock) {
- ((MacrosSetBlock)getCurrentPage()).updateValues();
- }
- } else if( element instanceof IFile) {
- if (getToolsSettingsBlock() != null) {
- getToolsSettingsBlock().updateValues();
- }
- if (getResourceCustomBuildStepBlock() != null) {
- getResourceCustomBuildStepBlock().updateValues();
- }
- } else if(element instanceof IWorkspace) {
- if(getCurrentPage() instanceof EnvironmentSetBlock) {
- ((EnvironmentSetBlock)getCurrentPage()).updateValues();
- }else if(getCurrentPage() instanceof MacrosSetBlock) {
- ((MacrosSetBlock)getCurrentPage()).updateValues();
- }
- }
- }
-
- public void setValues() {
- if (element instanceof IProject) {
- if (getToolsSettingsBlock() != null) {
- getToolsSettingsBlock().updateValues();
- }
- if (getBuildSettingsBlock() != null) {
- getBuildSettingsBlock().setValues();
- }
- if (getBuildStepSettingsBlock() != null) {
- getBuildStepSettingsBlock().setValues();
- }
- if (getErrorParserBlock() != null) {
- // TODO
- //getErrorParserBlock().setValues();
- }
- if (getBinaryParserBlock() != null) {
- // TODO
- //getBinaryParserBlock().setValues();
- }
-
- if(getCurrentPage() instanceof EnvironmentSetBlock) {
- ((EnvironmentSetBlock)getCurrentPage()).updateValues();
- }else if(getCurrentPage() instanceof MacrosSetBlock) {
- ((MacrosSetBlock)getCurrentPage()).updateValues();
- }
- } else if (element instanceof IFile) {
- if (getToolsSettingsBlock() != null) {
- getToolsSettingsBlock().updateValues();
- }
- if (getResourceCustomBuildStepBlock() != null) {
- getResourceCustomBuildStepBlock().setValues();
- }
- } else if (element instanceof IWorkspace) {
- if(getCurrentPage() instanceof EnvironmentSetBlock) {
- ((EnvironmentSetBlock)getCurrentPage()).updateValues();
- }else if(getCurrentPage() instanceof MacrosSetBlock) {
- ((MacrosSetBlock)getCurrentPage()).updateValues();
- }
- }
- }
-
- public void removeValues(String id) {
- if (element instanceof IProject) {
- if (getToolsSettingsBlock() != null) {
- getToolsSettingsBlock().removeValues(id);
- }
- if (getBuildSettingsBlock() != null) {
- getBuildSettingsBlock().removeValues(id);
- }
- if (getBuildStepSettingsBlock() != null) {
- getBuildStepSettingsBlock().removeValues(id);
- }
- if (getErrorParserBlock() != null) {
- // TODO
- //getErrorParserBlock().removeValues(id);
- }
- if (getBinaryParserBlock() != null) {
- // TODO
- //getBinaryParserBlock().removeValues(id);
- }
- if(getEnvironmentBlock()!= null) {
- }
- if(getMacrosBlock()!= null) {
- }
-
- } else if (element instanceof IFile) {
- if (getToolsSettingsBlock()!= null) {
- getToolsSettingsBlock().removeValues(id);
- }
- if (getResourceCustomBuildStepBlock() != null) {
- getResourceCustomBuildStepBlock().removeValues(id);
- }
- } else if (element instanceof IWorkspace) {
- if(getEnvironmentBlock()!= null) {
- }
- if(getMacrosBlock()!= null) {
- }
- }
- }
-
- public IPreferenceStore getPreferenceStore()
- {
- if (element instanceof IProject) {
- if (getCurrentPage() instanceof ToolsSettingsBlock) {
- return toolsSettingsBlock.getPreferenceStore();
- }
- if (getCurrentPage() instanceof BuildSettingsBlock) {
- return buildSettingsBlock.getPreferenceStore();
- }
- if (getCurrentPage() instanceof BuildStepSettingsBlock) {
- return buildStepSettingsBlock.getPreferenceStore();
- }
- if (getCurrentPage() instanceof ErrorParserBlock) {
- return errParserBlock.getPreferenceStore();
- }
- if (getCurrentPage() instanceof BinaryParserBlock) {
- return null;
- }
- if(getCurrentPage() instanceof EnvironmentSetBlock) {
- return null;
- }
- if(getCurrentPage() instanceof MacrosSetBlock) {
- return null;
- }
- } else if( element instanceof IFile) {
- if (getCurrentPage() instanceof ToolsSettingsBlock) {
- return toolsSettingsBlock.getPreferenceStore();
- }
- if (getCurrentPage() instanceof ResourceCustomBuildStepBlock) {
- return resCustomBuildStepBlock.getPreferenceStore();
- }
- } else if (element instanceof IWorkspace) {
- if(getCurrentPage() instanceof EnvironmentSetBlock) {
- return null;
- }
- if(getCurrentPage() instanceof MacrosSetBlock) {
- return null;
- }
- }
- return null;
- }
-
- public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore()
- {
- return toolsSettingsBlock.getPreferenceStore();
- }
-
- public void update() {
- super.update();
- ICOptionPage tab = getCurrentPage();
- // Currently, other settings are per-config, while binary parser settings are per-project
- if (tab instanceof BinaryParserBlock) {
- ((BuildPropertyPage)fParent).enableConfigSelection(false);
- }
- else {
- if(element instanceof IProject) {
- if(tab instanceof EnvironmentSetBlock){
- ((BuildPropertyPage)fParent).enableConfigSelection(
- ((EnvironmentSetBlock)tab).isConfigSelectionAllowed());
- }
- else if(tab instanceof MacrosSetBlock){
- ((BuildPropertyPage)fParent).enableConfigSelection(
- ((MacrosSetBlock)tab).isConfigSelectionAllowed());
- }
- else
- ((BuildPropertyPage)fParent).enableConfigSelection(true);
- } else if ( element instanceof IFile) {
- ((ResourceBuildPropertyPage)fParent).enableConfigSelection(true);
- } else if (element instanceof IWorkspace) {
- }
- }
- }
-
- /**
- * Sets the dirty state of the contained pages
- */
- public void setDirty(boolean b) {
- Iterator iter = getOptionPages().iterator();
- while (iter.hasNext()) {
- ICOptionPage tab = (ICOptionPage)iter.next();
- if (tab instanceof BuildSettingsBlock) {
- ((BuildSettingsBlock)tab).setDirty(b);
- } else if (tab instanceof ResourceCustomBuildStepBlock) {
- ((ResourceCustomBuildStepBlock)tab).setDirty(b);
- } else if (tab instanceof ToolsSettingsBlock) {
- ((ToolsSettingsBlock)tab).setDirty(b);
- } else if (tab instanceof BuildStepSettingsBlock) {
- ((BuildStepSettingsBlock)tab).setDirty(b);
- } else if (tab instanceof ErrorParserBlock) {
- ((ErrorParserBlock)tab).setDirty(b);
- } else if (tab instanceof BinaryParserBlock) {
- //TODO ManagedBuildSystem needs its own binary parser block
- } else if(tab instanceof EnvironmentSetBlock) {
- ((EnvironmentSetBlock)tab).setModified(b);
- } else if(tab instanceof MacrosSetBlock) {
- ((MacrosSetBlock)tab).setModified(b);
- }
- }
- }
-
- /**
- * Returns <code> true <code/> if any of the pages are dirty
- * @return boolean
- */
- public boolean isDirty() {
- Iterator iter = getOptionPages().iterator();
- while (iter.hasNext()) {
- ICOptionPage tab = (ICOptionPage)iter.next();
- if (tab instanceof BuildSettingsBlock) {
- if (((BuildSettingsBlock)tab).isDirty()) return true;
- } else if (tab instanceof ResourceCustomBuildStepBlock) {
- if (((ResourceCustomBuildStepBlock)tab).isDirty()) return true;
- } else if (tab instanceof ToolsSettingsBlock) {
- if (((ToolsSettingsBlock)tab).isDirty()) return true;
- } else if (tab instanceof BuildStepSettingsBlock) {
- if (((BuildStepSettingsBlock)tab).isDirty()) return true;
- } else if (tab instanceof ErrorParserBlock) {
- if (((ErrorParserBlock)tab).isDirty()) return true;
- } else if (tab instanceof BinaryParserBlock) {
- //TODO ManagedBuildSystem needs its own binary parser block
- } else if(tab instanceof EnvironmentSetBlock) {
- if (((EnvironmentSetBlock)tab).isModified()) return true;
- } else if(tab instanceof MacrosSetBlock) {
- if (((MacrosSetBlock)tab).isModified()) return true;
- }
-
- }
- return false;
- }
-
- public boolean containsDefaults(){
- Iterator iter = getOptionPages().iterator();
- while (iter.hasNext()) {
- ICOptionPage tab = (ICOptionPage)iter.next();
- if(tab instanceof ToolsSettingsBlock){
- if(!((ToolsSettingsBlock)tab).containsDefaults())
- return false;
- } else if(tab instanceof ResourceCustomBuildStepBlock) {
- if(!((ResourceCustomBuildStepBlock)tab).containsDefaults())
- return false;
- } else
- return false;
- }
- return true;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
deleted file mode 100644
index 7e6340edaf1..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class ManagedProjectOptionBlock extends TabFolderOptionBlock {
-
- private ErrorParserBlock errParserBlock;
- private BinaryParserBlock binaryParserBlock;
-
- /**
- * @param parent
- */
- public ManagedProjectOptionBlock(ICOptionContainer parent) {
- super(parent, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
- */
- protected void addTabs() {
- errParserBlock = new ErrorParserBlock(null);
- addTab(errParserBlock);
- addTab(binaryParserBlock = new BinaryParserBlock());
- }
-
- public BinaryParserBlock getBinaryParserBlock() {
- return binaryParserBlock;
- }
-
- public ErrorParserBlock getErrorParserBlock() {
- return errParserBlock;
- }
-
- public Control createContents(Composite parent) {
- Control control = super.createContents( parent );
- ((GridLayout)((Composite)control).getLayout()).marginWidth = 1;
- GridData gd = new GridData(GridData.FILL_BOTH);
- ((Composite)control).setLayoutData(gd);
-
- if (getErrorParserBlock()!= null)
- WorkbenchHelp.setHelp(getErrorParserBlock().getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_ERROR_PARSER);
-
- return control;
- }
-
- public void updateValues() {
- if (getErrorParserBlock()!= null) {
- getErrorParserBlock().updateValues();
- }
- if (getBinaryParserBlock()!= null) {
- // TODO
- //getBinaryParserBlock().updateValues();
- }
- }
-
- public void update() {
- super.update();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/NewEnvVarDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/NewEnvVarDialog.java
deleted file mode 100644
index 873ab426bc1..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/NewEnvVarDialog.java
+++ /dev/null
@@ -1,709 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import java.text.Collator;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/*
- * the dialog used to create or edit the environment variable
- */
-public class NewEnvVarDialog extends StatusDialog {
- // String constants
- private static final String PREFIX = "NewEnvVarDialog"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String NAME = LABEL + ".name"; //$NON-NLS-1$
- private static final String VALUE = LABEL + ".value"; //$NON-NLS-1$
-
- private static final String DELIMITER = LABEL + ".delimiter"; //$NON-NLS-1$
- private static final String OPERATION = LABEL + ".operation"; //$NON-NLS-1$
- private static final String OPERATION_REPLACE = OPERATION + ".replace"; //$NON-NLS-1$
- private static final String OPERATION_PREPEND = OPERATION + ".prepend"; //$NON-NLS-1$
- private static final String OPERATION_APPEND = OPERATION + ".append"; //$NON-NLS-1$
- private static final String OPERATION_REMOVE = OPERATION + ".remove"; //$NON-NLS-1$
-
- private static final String VALUE_PREPEND = VALUE + ".prepend"; //$NON-NLS-1$
- private static final String VALUE_APPEND = VALUE + ".append"; //$NON-NLS-1$
-
- private static final String TITLE_NEW = LABEL + ".title.new"; //$NON-NLS-1$
- private static final String TITLE_EDIT = LABEL + ".title.edit"; //$NON-NLS-1$
-
- private static final String STATUS = LABEL + ".status"; //$NON-NLS-1$
- private static final String STATUS_CANNOT_CTREATE = STATUS + ".cannot.create"; //$NON-NLS-1$
-
- private static final String EMPTY_STRING = new String();
-
- // The title of the dialog.
- private String fTitle;
- // hold the variable being edited(in the case of the "edit" mode)
- private IBuildEnvironmentVariable fEditedVar;
- //the environment block from which the dialog was called
- private EnvironmentBlock fEnvVarBlock;
- //the resulting variable. Can be accessed only when the dialog is closed
- private IBuildEnvironmentVariable fResultingVar;
- //the string that holds the value is used in the "replace" operation
- private String fReplaceValue = null;
- //the string that holds the value is used in the "append/prepend" operations
- private String fAppPrepValue = null;
- //specifies whether the fAppPrepValue holds the prepended or appended value
- private boolean fAppPrepPrepend = true;
-
- private String fTypedName;
-
- // Widgets
-// protected Text fVarNameEdit;
- private Combo fVarNameEdit;
- private Text fVarValueEdit;
- private Label fDelimiterLabel;
- private Text fDelimiterEdit;
- private Combo fOpSelector;
- private Label fOpVarValueLabel;
- private Text fOpVarValueEdit;
-
- public NewEnvVarDialog(Shell parentShell, EnvironmentBlock envBlock, IBuildEnvironmentVariable editedVar) {
- super(parentShell);
- if(editedVar != null)
- fTitle = ManagedBuilderUIMessages.getResourceString(TITLE_EDIT);
- else
- fTitle = ManagedBuilderUIMessages.getResourceString(TITLE_NEW);
- fEditedVar = editedVar;
- fEnvVarBlock = envBlock;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if (fTitle != null)
- shell.setText(fTitle);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite comp = new Composite(parent, SWT.NULL);
- comp.setFont(parent.getFont());
- comp.setLayout(new GridLayout(2, false));
- GridData gd = new GridData(GridData.FILL_BOTH);
- comp.setLayoutData(gd);
-
- Label nameLabel = new Label(comp, SWT.LEFT);
- nameLabel.setFont(comp.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(NAME));
- nameLabel.setLayoutData(new GridData());
-
-// fVarNameEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
- fVarNameEdit = new Combo(comp, SWT.SINGLE | SWT.DROP_DOWN);
- fVarNameEdit.setItems(getVarNames());
- fVarNameEdit.setFont(comp.getFont());
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 1;
- gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50;
- fVarNameEdit.setLayoutData(gd);
- fVarNameEdit.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleVarNameModified();
- }
- });
- fVarNameEdit.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e){
- handleVarNameSelection();
- }
- });
-
- Label valueLabel = new Label(comp, SWT.LEFT);
- valueLabel.setFont(comp.getFont());
- valueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE));
- gd = new GridData();
- gd.horizontalSpan = 1;
- valueLabel.setLayoutData(gd);
-
- fVarValueEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
- fVarValueEdit.setFont(comp.getFont());
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 100;
- gd.horizontalSpan = 1;
- fVarValueEdit.setLayoutData(gd);
- fVarValueEdit.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleVarValueModified();
- }
- });
-
- fDelimiterLabel = new Label(comp, SWT.LEFT);
- fDelimiterLabel.setFont(comp.getFont());
- fDelimiterLabel.setText(ManagedBuilderUIMessages.getResourceString(DELIMITER));
- gd = new GridData();
- gd.horizontalSpan = 1;
- gd.widthHint = 100;
- fDelimiterLabel.setLayoutData(gd);
-
- fDelimiterEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
- fDelimiterEdit.setFont(comp.getFont());
- gd = new GridData();
- gd.horizontalSpan = 1;
- gd.widthHint = 50;
- fDelimiterEdit.setLayoutData(gd);
- fDelimiterEdit.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleDelimiterModified();
- }
- });
-
- Label opLabel = new Label(comp, SWT.LEFT);
- opLabel.setFont(comp.getFont());
- opLabel.setText(ManagedBuilderUIMessages.getResourceString(OPERATION));
- gd = new GridData();
- gd.horizontalSpan = 1;
- opLabel.setLayoutData(gd);
-
- fOpSelector = new Combo(comp, SWT.READ_ONLY|SWT.DROP_DOWN);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalSpan = 1;
-// gd.widthHint = 70;
- fOpSelector.setLayoutData(gd);
- fOpSelector.setItems(new String[]{
- ManagedBuilderUIMessages.getResourceString(OPERATION_REPLACE),
- ManagedBuilderUIMessages.getResourceString(OPERATION_PREPEND),
- ManagedBuilderUIMessages.getResourceString(OPERATION_APPEND),
- ManagedBuilderUIMessages.getResourceString(OPERATION_REMOVE),
- });
- setSelectedOperation(IBuildEnvironmentVariable.ENVVAR_REPLACE);
-
- fOpSelector.addListener(SWT.Selection, new Listener () {
- public void handleEvent(Event e) {
- handleOperationModified();
- }
- });
-
- fOpVarValueLabel = new Label(comp, SWT.LEFT);
- fOpVarValueLabel.setFont(comp.getFont());
- gd = new GridData();
- gd.horizontalSpan = 1;
-// gd.widthHint = 100;
- fOpVarValueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE_PREPEND));
- fOpVarValueLabel.setLayoutData(gd);
- fOpVarValueEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
- fOpVarValueEdit.setFont(comp.getFont());
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50;
- fOpVarValueEdit.setLayoutData(gd);
- fOpVarValueEdit.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleOperationVarValueModified();
- }
- });
-
- if(fEditedVar != null){
- loadVariableSettings(fEditedVar,true);
- fVarNameEdit.setEnabled(false);
- }
-
- updateWidgetState();
-
- return comp;
- }
-
- /*
- * get the names to be displayed in the var Name combo.
- */
- private String[] getVarNames(){
- IBuildEnvironmentVariable vars[] = fEnvVarBlock.getSystemVariables(true);
- String names[] = null;
- if(vars == null || vars.length == 0)
- names = new String[0];
- else{
- names = new String[vars.length];
- for(int i = 0; i < vars.length; i++){
- names[i] = vars[i].getName();
- }
-
- final Collator collator = Collator.getInstance();
- Arrays.sort(names, new Comparator() {
- public int compare(Object a, Object b) {
- String strA = ((String)a).toUpperCase();
- String strB = ((String)b).toUpperCase();
- return collator.compare(strA,strB);
- }
- });
- }
-
- return names;
- }
-
- /*
- * called when the variable name is selected, loads all the dialog fields with the variable settings
- */
- private void handleVarNameSelection(){
- int index = fVarNameEdit.getSelectionIndex();
- if(index == -1)
- loadVariableSettings(null);
- else
- loadVariableSettings(fVarNameEdit.getItem(index));
- }
-
- private void loadVariableSettings(String name){
- IBuildEnvironmentVariable var = fEnvVarBlock.getSystemVariable(name,true);
- if(var != null)
- loadVariableSettings(var,false);
- else
- loadVariableSettings(name,EMPTY_STRING,IBuildEnvironmentVariable.ENVVAR_REPLACE,EMPTY_STRING);
- }
-
- private void loadVariableSettings(String name,
- String value,
- int op,
- String delimiter){
- setSelectedOperation(op);
-
- setSelectedVarName(notNull(name));
-
- switch(op){
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:
- fOpVarValueEdit.setText(notNull(value));
- fReplaceValue = null;
- fAppPrepValue = notNull(value);
- fAppPrepPrepend = true;
- break;
- case IBuildEnvironmentVariable.ENVVAR_APPEND:
- fOpVarValueEdit.setText(notNull(value));
- fReplaceValue = null;
- fAppPrepValue = notNull(value);
- fAppPrepPrepend = false;
- break;
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- break;
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
- default:
- fVarValueEdit.setText(notNull(value));
- fReplaceValue = notNull(value);
- fAppPrepValue = null;
- }
-
- fDelimiterEdit.setText(notNull(delimiter));
-
- updateWidgetState();
- }
-
- /*
- * loads all the dialog fields with the variable settings
- */
- private void loadVariableSettings(IBuildEnvironmentVariable var, boolean isUser){
- int op = var.getOperation();
- if(!isUser && op != IBuildEnvironmentVariable.ENVVAR_REMOVE)
- op = IBuildEnvironmentVariable.ENVVAR_REPLACE;
-
- loadVariableSettings(var.getName(),var.getValue(),op,var.getDelimiter());
- }
-
- /*
- * returns an empty string in the case the string passed is null.
- * otherwise returns the string passed
- */
- private String notNull(String str){
- return str == null ? EMPTY_STRING : str;
- }
-
- /*
- * returns the name typed in the dialog var name edit triming spaces
- */
- private String getSelectedVarName(){
- return fVarNameEdit.getText().trim();
- }
-
- /*
- * sets the variable name to the dialog "variable name" edit control
- */
- private void setSelectedVarName(String name){
- if(!varNamesEqual(fVarNameEdit.getText(),name)){
- fTypedName = name;
- fVarNameEdit.setText(notNull(name).trim());
- }
- }
-
- private boolean varNamesEqual(String name1, String name2){
- name1 = name1.trim();
- name2 = name2.trim();
- if(ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
- return name1.equals(name2);
- return name1.equalsIgnoreCase(name2);
- }
-
- /*
- * returns the selected operation
- */
- private int getSelectedOperation(){
- switch(fOpSelector.getSelectionIndex()){
- case 1:
- return IBuildEnvironmentVariable.ENVVAR_PREPEND;
- case 2:
- return IBuildEnvironmentVariable.ENVVAR_APPEND;
- case 3:
- return IBuildEnvironmentVariable.ENVVAR_REMOVE;
- case 0:
- default:
- return IBuildEnvironmentVariable.ENVVAR_REPLACE;
- }
- }
-
- /*
- * sets the selected operation
- */
- private void setSelectedOperation(int op){
- switch(op){
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:
- fOpSelector.select(1);
- break;
- case IBuildEnvironmentVariable.ENVVAR_APPEND:
- fOpSelector.select(2);
- break;
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- fOpSelector.select(3);
- break;
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
- default:
- fOpSelector.select(0);
- break;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed(){
- String name = getSelectedVarName();
- if(name != null || !EMPTY_STRING.equals(name))
- fResultingVar = new BuildEnvVar(name,getSelectedVariableValue(),getSelectedOperation(),fDelimiterEdit.getText());
-
- super.okPressed();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#open()
- */
- public int open(){
- fResultingVar = null;
- return super.open();
- }
-
- /*
- * returns the variable value that should be stored in the resulting variable
- */
- private String getSelectedVariableValue(){
- switch(getSelectedOperation()){
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:
- case IBuildEnvironmentVariable.ENVVAR_APPEND:
- return fOpVarValueEdit.getText();
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- return EMPTY_STRING;
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
- default:
- return fVarValueEdit.getText();
- }
- }
-
- /*
- * this method should be called after the dialog is closed
- * to obtain the created variable.
- * if the variable was not created, e.g. because a user has pressed
- * the cancel button this method returns null
- */
- public IBuildEnvironmentVariable getDefinedVariable(){
- return fResultingVar;
- }
-
- /*
- * called when the variable name is modified
- */
- private void handleVarNameModified(){
- String name = getSelectedVarName();
- if(fTypedName == null || !fTypedName.equals(name)){
- loadVariableSettings(name);
- }
- }
-
- /*
- * called when the variable value is modified
- */
- private void handleVarValueModified(){
- switch(getSelectedOperation()){
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:
- case IBuildEnvironmentVariable.ENVVAR_APPEND:
- fAppPrepValue = fVarValueEdit.getText();
- fReplaceValue = null;
- break;
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- break;
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
- default:
- fReplaceValue = fVarValueEdit.getText();
- fAppPrepValue = null;
- break;
- }
- }
-
- /*
- * called when the operation is modified
- */
- private void handleOperationModified(){
- int op = getSelectedOperation();
- String newValue = recalculateValueString();
-
- switch(op){
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:
- fVarValueEdit.setText(calculateAppendPrepend(
- getSelectedVarName(),
- newValue,
- fDelimiterEdit.getText(),
- true));
- fVarValueEdit.setEnabled(false);
- fOpVarValueEdit.setText(newValue);
- fOpVarValueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE_PREPEND));
- fOpVarValueLabel.setVisible(true);
- fOpVarValueEdit.setVisible(true);
- fDelimiterEdit.setEnabled(true);
- fAppPrepPrepend = true;
- fAppPrepValue = newValue;
- fReplaceValue = null;
- break;
- case IBuildEnvironmentVariable.ENVVAR_APPEND:
- fVarValueEdit.setText(calculateAppendPrepend(
- getSelectedVarName(),
- newValue,
- fDelimiterEdit.getText(),
- false));
- fVarValueEdit.setEnabled(false);
- fOpVarValueEdit.setText(newValue);
- fOpVarValueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE_APPEND));
- fOpVarValueLabel.setVisible(true);
- fOpVarValueEdit.setVisible(true);
- fDelimiterEdit.setEnabled(true);
- fAppPrepPrepend = false;
- fAppPrepValue = newValue;
- fReplaceValue = null;
- break;
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- fOpVarValueLabel.setVisible(false);
- fOpVarValueEdit.setVisible(false);
- fDelimiterEdit.setEnabled(false);
- fVarValueEdit.setText(EMPTY_STRING);
- fVarValueEdit.setEnabled(false);
- break;
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
- default:
- fVarValueEdit.setText(newValue);
- fOpVarValueLabel.setVisible(false);
- fOpVarValueEdit.setVisible(false);
- fDelimiterEdit.setEnabled(true);
- fVarValueEdit.setEnabled(true);
- fAppPrepValue = null;
- fReplaceValue = newValue;
-
-
- break;
- }
-
- fOpVarValueLabel.getParent().layout(true);
- }
-
- private String recalculateValueString(){
- String val = EMPTY_STRING;
-
- switch(getSelectedOperation()){
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:
- if(fAppPrepValue != null)
- val = fAppPrepValue;
- else if(fReplaceValue != null)
- val = calculateAppPrepFromReplace(fReplaceValue,fDelimiterEdit.getText(),true);
- break;
- case IBuildEnvironmentVariable.ENVVAR_APPEND:
- if(fAppPrepValue != null)
- val = fAppPrepValue;
- else if(fReplaceValue != null)
- val = calculateAppPrepFromReplace(fReplaceValue,fDelimiterEdit.getText(),false);
- break;
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- val = EMPTY_STRING;
- break;
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
- default:
- if(fReplaceValue != null)
- val = fReplaceValue;
- else if(fAppPrepValue != null)
- val = fReplaceValue = calculateReplaceFromAppPrep(fAppPrepValue,fDelimiterEdit.getText(),fAppPrepPrepend);
- break;
- }
- return val;
- }
-
- private String calculateAppPrepFromReplace(String replace, String delimiter, boolean prepend){
- String val = replace;
- IBuildEnvironmentVariable var = fEnvVarBlock.getSystemVariable(getSelectedVarName(),true);
- if(var != null && var.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE){
- String varValue = var.getValue();
- if(delimiter != null && !EMPTY_STRING.equals(delimiter)){
- List replaceValues = EnvVarOperationProcessor.convertToList(replace,delimiter);
- List varValues = EnvVarOperationProcessor.convertToList(varValue,delimiter);
- List result = EnvVarOperationProcessor.removeDuplicates(replaceValues,varValues);
- val = EnvVarOperationProcessor.convertToString(result,delimiter);
- }
- else{
- if(varValue != null && !EMPTY_STRING.equals(varValue)){
- int index = replace.indexOf(varValue);
- if(index == -1)
- val = EMPTY_STRING;
- else {
- try{
- if(index == 0)
- val = replace.substring(replace.length());
- else
- val = replace.substring(0,index);
-
- } catch (IndexOutOfBoundsException e){
- val = EMPTY_STRING;
- }
- }
- }
- }
- }
- return val;
- }
-
- private String calculateReplaceFromAppPrep(String value, String delimiter, boolean prepend){
- return calculateAppendPrepend(getSelectedVarName(),value,delimiter,prepend);
- }
-
- /*
- * updates the state of the dialog controls
- */
- private void updateWidgetState(){
- handleOperationModified();
- validateState();
- }
-
- /*
- * updates the variable value displayed in the dialog in case of append/prepend operation
- */
- private void updateVariableValueForAppendPrepend(boolean prepend){
- String name = getSelectedVarName();
- if(name == null || EMPTY_STRING.equals(name))
- return;
-
- String opValue = fOpVarValueEdit.getText();
-
- fVarValueEdit.setText(calculateAppendPrepend(name,opValue,fDelimiterEdit.getText(),prepend));
- }
-
- /*
- * calculates the resulting variable value
- */
- private String calculateAppendPrepend(String name, String opValue, String delimiter, boolean prepend){
- String varValue = null;
- IBuildEnvironmentVariable var = fEnvVarBlock.getSystemVariable(name,true);
- if(var == null)
- return opValue;
- return EnvVarOperationProcessor.performAppendPrepend(var.getValue(),opValue,delimiter,prepend);
- }
-
- /*
- * called when the delimiter is modified
- */
- private void handleDelimiterModified(){
- int op = getSelectedOperation();
- switch(op){
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:{
- String value = getSelectedVariableValue();
- fVarValueEdit.setText(calculateAppendPrepend(
- getSelectedVarName(),
- value,
- fDelimiterEdit.getText(),
- true));
- fAppPrepValue = value;
- fReplaceValue = null;
- }
- break;
- case IBuildEnvironmentVariable.ENVVAR_APPEND:{
- String value = getSelectedVariableValue();
- fVarValueEdit.setText(calculateAppendPrepend(
- getSelectedVarName(),
- value,
- fDelimiterEdit.getText(),
- false));
- fAppPrepValue = value;
- fReplaceValue = null;
- }
- break;
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- break;
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
- default:
- fAppPrepValue = null;
- fReplaceValue = getSelectedVariableValue();
- break;
- }
- }
-
- /*
- * called when the appended/prepended value is modified
- */
- private void handleOperationVarValueModified(){
- handleDelimiterModified();
- }
-
- /* (non-Javadoc)
- * Update the status message and button state based on the variable name
- *
- */
- private void validateState() {
- StatusInfo status= new StatusInfo();
- String name = getSelectedVarName();
-
- if(EMPTY_STRING.equals(name)){
- // Not an error
- status.setError(""); //$NON-NLS-1$
- }
- else if(!fEnvVarBlock.canCreate(name)){
- status.setError(ManagedBuilderUIMessages.getFormattedString(STATUS_CANNOT_CTREATE, name));
- }
-
-
- updateStatus(status);
- return;
- }
-}
-
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java
deleted file mode 100644
index ec68e31df05..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java
+++ /dev/null
@@ -1,618 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-
-public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
-
- /*
- * String constants
- */
- private static final String PREFIX = "ResourceCustomBuildStepBlock"; //$NON-NLS-1$
- private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String SETTINGS_LABEL = LABEL + ".settings"; //$NON-NLS-1$
- private static final String RCBS_TOOL_GROUP = LABEL + ".tool.group"; //$NON-NLS-1$
- private static final String RCBS_APPLICABILITY = LABEL + ".applicability"; //$NON-NLS-1$
- private static final String RCBS_BEFORE = LABEL + ".applicability.rule.before"; //$NON-NLS-1$
- private static final String RCBS_AFTER = LABEL + ".applicability.rule.after"; //$NON-NLS-1$
- private static final String RCBS_OVERRIDE = LABEL + ".applicability.rule.override"; //$NON-NLS-1$
- private static final String RCBS_DISABLE = LABEL + ".applicability.rule.disable"; //$NON-NLS-1$
- private static final String INPUT_FILENAMES = LABEL + ".input.filenames"; //$NON-NLS-1$
- private static final String OUTPUT_FILENAMES = LABEL + ".output.filenames"; //$NON-NLS-1$
- private static final String COMMAND_CMD = LABEL + ".command.cmd"; //$NON-NLS-1$
- private static final String DESCRIPTION_DESC = LABEL + ".description.desc"; //$NON-NLS-1$
- private static final String APPLICABILITY_TIP = TIP + ".applicability"; //$NON-NLS-1$
- private static final String INPUTS_TIP = TIP + ".inputs"; //$NON-NLS-1$
- private static final String OUTPUTS_TIP = TIP + ".outputs"; //$NON-NLS-1$
- private static final String COMMAND_TIP = TIP + ".command"; //$NON-NLS-1$
- private static final String ANNOUNCEMENT_TIP = TIP + ".announcement"; //$NON-NLS-1$
- private static final String CONFIRM_DEFAULT_TITLE = PREFIX + ".defaults.title"; //$NON-NLS-1$
- private static final String CONFIRM_DEFAULT_MESSAGE = PREFIX + ".defaults.message"; //$NON-NLS-1$
-
- /*
- * TODO: Currently, the makefile generator code would need significant work to support
- * the concept of ordering multiple tools. For CDT 3.0, we will implement the ability to
- * apply a resource custom build tool as an override to other tools or to be disabled.
- * When there is more time to enhance the makefile generator code, the RCBS_BEFORE and RCBS_AFTER
- * entries in this array can be uncommented again.
- */
- private static final String[] rcbsApplicabilityRules = {
- new String(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE)),
-// new String(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE)),
-// new String(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER)),
- new String(ManagedBuilderUIMessages.getResourceString(RCBS_DISABLE)),
- };
- private static final String EMPTY_STRING = new String();
-
- private static final String rcbsToolId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs"); //$NON-NLS-1$
- private static final String rcbsToolName = new String("Resource Custom Build Step"); //$NON-NLS-1$
- private static final String rcbsToolInputTypeId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype"); //$NON-NLS-1$
- private static final String rcbsToolInputTypeName = new String("Resource Custom Build Step Input Type"); //$NON-NLS-1$
- private static final String rcbsToolOutputTypeId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype"); //$NON-NLS-1$
- private static final String rcbsToolOutputTypeName = new String("Resource Custom Build Step Output Type"); //$NON-NLS-1$
- private static final String PATH_SEPERATOR = ";"; //$NON-NLS-1$
- /*
- * Dialog widgets
- */
- protected Combo rcbsApplicabilitySelector;
- protected Text buildInputs;
- protected Text buildOutputs;
- protected Text buildCommand;
- protected Text buildDescription;
-
- /*
- * Bookeeping variables
- */
- private ResourceBuildPropertyPage resParent;
- // Has the page been changed?
- private boolean dirty = false;
-
- private ModifyListener widgetModified = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if(e.widget == buildInputs){
- String val = buildInputs.getText().trim();
- IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
- ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
- if(rcbs != null){
- IAdditionalInput input = rcbs.getInputTypes()[0].getAdditionalInputs()[0];
- if(!createList(input.getPaths()).equals(val)){
- input.setPaths(val);
- setValues();
- setDirty(true);
- }
- }
- } else if(e.widget == buildOutputs){
- String val = buildOutputs.getText().trim();
- IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
- ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
- if(rcbs != null){
- IOutputType output = rcbs.getOutputTypes()[0];
- if(!createList(output.getOutputNames()).equals(val)){
- output.setOutputNames(val);
- setValues();
- setDirty(true);
- }
- }
- } else if(e.widget == buildCommand){
- String val = buildCommand.getText().trim();
- IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
- ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
- if(rcbs != null && !rcbs.getToolCommand().equals(val)){
- rcbs.setToolCommand(val);
- setValues();
- setDirty(true);
- }
- } else if(e.widget == buildDescription){
- String val = buildDescription.getText().trim();
- IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
- ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
- if(rcbs != null && !rcbs.getAnnouncement().equals(val)){
- rcbs.setAnnouncement(val);
- setValues();
- setDirty(true);
- }
- }
- }
- };
-
-
- /*
- * Constructor
- */
- public ResourceCustomBuildStepBlock(ResourceBuildPropertyPage resParent)
- {
- super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
- super.setContainer(resParent);
- this.resParent = resParent;
- }
-
- public void createControl(Composite resParent) {
- Composite comp = new Composite(resParent, SWT.NULL);
- comp.setFont(resParent.getFont());
- comp.setLayout(new GridLayout(1, true));
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- setControl(comp);
-
- // Create a group to present the controls that make up the rcbs tool
- final Group rcbsToolGroup = new Group(comp, SWT.NONE);
- rcbsToolGroup.setFont(resParent.getFont());
- rcbsToolGroup.setText(ManagedBuilderUIMessages.getResourceString(RCBS_TOOL_GROUP));
- rcbsToolGroup.setLayout(new GridLayout(1, false));
- rcbsToolGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Create a control for the rcbs Applicability combo and label
- createRcbsApplicabilityControl(rcbsToolGroup);
-
- // Create controls for the rcbs Additional Build Input Files Text and Label
- createBuildInputControl(rcbsToolGroup);
-
- // Create controls for the rcbs Additional Build Output Files Text and Label
- createBuildOutputControl(rcbsToolGroup);
-
- // Create controls for the rcbs Build Command Text and Label
- createBuildCommandControl(rcbsToolGroup);
-
- // Create controls for the rcbs Command Description (Announcement) Text and Label
- createCommandDescriptionControl(rcbsToolGroup);
-
- }
-
- /* (non-Javadoc)
- * Creates the group that contains the rcbs applicability combo.
- */
- private void createRcbsApplicabilityControl(Group rcbsApplicabilityGroup) {
- // One label
- final Label applicabilityLabel = new Label(rcbsApplicabilityGroup, SWT.LEFT);
- applicabilityLabel.setFont(rcbsApplicabilityGroup.getFont());
- applicabilityLabel.setText(ManagedBuilderUIMessages.getResourceString(RCBS_APPLICABILITY));
- applicabilityLabel.setToolTipText(ManagedBuilderUIMessages.getResourceString(APPLICABILITY_TIP));
- applicabilityLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- rcbsApplicabilitySelector = new Combo(rcbsApplicabilityGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
- rcbsApplicabilitySelector.setFont(rcbsApplicabilityGroup.getFont());
- rcbsApplicabilitySelector.setItems(rcbsApplicabilityRules);
- int idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE));
- rcbsApplicabilitySelector.select(idx);
- GridData gd1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gd1.horizontalSpan = 1;
- gd1.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- rcbsApplicabilitySelector.setLayoutData(gd1);
- rcbsApplicabilitySelector.addSelectionListener(
- new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- resParent.getCurrentResourceConfigClone().setRcbsApplicability(
- selectionToApplicability(rcbsApplicabilitySelector.getSelectionIndex()));
- setDirty(true);
- }
- });
- }
-
- /* (non-Javadoc)
- * Creates the controls for the rcbs additional build input file names text and label.
- */
- private void createBuildInputControl(Group inputGroup) {
- // One label
- final Label inputLabel = new Label(inputGroup, SWT.LEFT);
- inputLabel.setFont(inputGroup.getFont());
- inputLabel.setText(ManagedBuilderUIMessages.getResourceString(INPUT_FILENAMES));
- inputLabel.setToolTipText(ManagedBuilderUIMessages.getResourceString(INPUTS_TIP));
- inputLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Now we need one text widget
- buildInputs = new Text(inputGroup, SWT.SINGLE | SWT.BORDER);
- buildInputs.setFont(inputGroup.getFont());
- GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);
- buildInputs.setLayoutData(gd2);
- buildInputs.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- buildInputs = null;
- }
- });
- buildInputs.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(INPUT_FILENAMES);
- }
- });
- buildInputs.addModifyListener(widgetModified);
- }
-
- /* (non-Javadoc)
- * Creates the controls for the rcbs additional build output file names text and label.
- */
- private void createBuildOutputControl(Group outputGroup) {
- // One label
- final Label outputLabel = new Label(outputGroup, SWT.LEFT);
- outputLabel.setFont(outputGroup.getFont());
- outputLabel.setText(ManagedBuilderUIMessages.getResourceString(OUTPUT_FILENAMES));
- outputLabel.setToolTipText(ManagedBuilderUIMessages.getResourceString(OUTPUTS_TIP));
- outputLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Now we need one text widget
- buildOutputs = new Text(outputGroup, SWT.SINGLE | SWT.BORDER);
- buildOutputs.setFont(outputGroup.getFont());
- GridData gd3 = new GridData(GridData.FILL_HORIZONTAL);
- buildOutputs.setLayoutData(gd3);
- buildOutputs.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- buildOutputs = null;
- }
- });
- buildOutputs.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(OUTPUT_FILENAMES);
- }
- });
- buildOutputs.addModifyListener(widgetModified);
- }
-
- /* (non-Javadoc)
- * Creates the controls for the rcbs build command text and label.
- */
- private void createBuildCommandControl(Group commandGroup) {
- // One label
- final Label commandLabel = new Label(commandGroup, SWT.LEFT);
- commandLabel.setFont(commandGroup.getFont());
- commandLabel.setText(ManagedBuilderUIMessages.getResourceString(COMMAND_CMD));
- commandLabel.setToolTipText(ManagedBuilderUIMessages.getResourceString(COMMAND_TIP));
- commandLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Now we need one text widget
- buildCommand = new Text(commandGroup, SWT.SINGLE | SWT.BORDER);
- buildCommand.setFont(commandGroup.getFont());
- GridData gd4 = new GridData(GridData.FILL_HORIZONTAL);
- buildCommand.setLayoutData(gd4);
- buildCommand.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- buildCommand = null;
- }
- });
- buildCommand.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(COMMAND_CMD);
- }
- });
- buildCommand.addModifyListener(widgetModified);
- }
-
- /* (non-Javadoc)
- * Creates the controls for the rcbs build command description (announcement) text and label.
- */
- private void createCommandDescriptionControl(Group descriptionGroup) {
- // One label
- final Label descriptionLabel = new Label(descriptionGroup, SWT.LEFT);
- descriptionLabel.setFont(descriptionGroup.getFont());
- descriptionLabel.setText(ManagedBuilderUIMessages.getResourceString(DESCRIPTION_DESC));
- descriptionLabel.setToolTipText(ManagedBuilderUIMessages.getResourceString(ANNOUNCEMENT_TIP));
- descriptionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Now we need one text widget
- buildDescription = new Text(descriptionGroup, SWT.SINGLE | SWT.BORDER);
- buildDescription.setFont(descriptionGroup.getFont());
- GridData gd5 = new GridData(GridData.FILL_HORIZONTAL);
- buildDescription.setLayoutData(gd5);
- buildDescription.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- buildDescription = null;
- }
- });
- buildDescription.getAccessible().addAccessibleListener(new AccessibleAdapter(){
- public void getName(AccessibleEvent e) {
- e.result = ManagedBuilderUIMessages.getResourceString(DESCRIPTION_DESC);
- }
- });
- buildDescription.addModifyListener(widgetModified);
- }
-
- protected void initializeValues() {
- setValues();
- setDirty(false);
- }
-
- public void updateValues() {
- setValues();
- }
-
- protected void setValues() {
- IResourceConfiguration resConfig = resParent.getCurrentResourceConfigClone();
-
- /*
- * Examine the tools defined for the resource configuration.
- * There should be at most one tool defined for a custom build step which was not an
- * extension element (not defined by a tool integrator in a manifest).
- * If the rcbs tool has been defined, set the field values from the defined tool.
- * If the rcbs tool has not been defined yet, clear the field values.
- * Finally, set the rcbsApplicability selector from the current value in the resource configuration.
- */
- ITool tool = getRcbsTool(resConfig,false);
-
- if(tool != null){
- String tmp = createList(tool.getInputTypes()[0].getAdditionalInputs()[0].getPaths());
- if(!tmp.equals(buildInputs.getText()))
- buildInputs.setText(tmp);
-
- tmp = createList(tool.getOutputTypes()[0].getOutputNames());
- if(!tmp.equals(buildOutputs.getText()))
- buildOutputs.setText(tmp);
-
- tmp = tool.getToolCommand();
- if(!tmp.equals(buildCommand.getText()))
- buildCommand.setText(tmp);
-
- tmp = tool.getAnnouncement();
- if(!tmp.equals(buildDescription.getText()))
- buildDescription.setText(tmp);
- } else {
- buildInputs.setText(""); //$NON-NLS-1$
- buildOutputs.setText(""); //$NON-NLS-1$
- buildCommand.setText(""); //$NON-NLS-1$
- buildDescription.setText(""); //$NON-NLS-1$
- }
-
- /*
- * Set the state of the rcbs applicability selector.
- */
- rcbsApplicabilitySelector.select(applicabilityToSelection(resConfig.getRcbsApplicability()));
-
-// setDirty(false);
- }
-
- private int selectionToApplicability(int index){
- String sel = rcbsApplicabilitySelector.getItem(index);
- if(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE).equals(sel)){
- return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE;
- } else if(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER).equals(sel)){
- return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER;
- } else if(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE).equals(sel)){
- return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE;
- }
- return IResourceConfiguration.KIND_DISABLE_RCBS_TOOL;
- }
-
- private int applicabilityToSelection(int val){
- switch(val){
- case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER:
- return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER));
- case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE:
- return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE));
- case IResourceConfiguration.KIND_DISABLE_RCBS_TOOL:
- return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_DISABLE));
- case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE:
- default:
- return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE));
- }
-
- }
-
- public void removeValues(String id) {
- // Nothing to do...
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- IResourceConfiguration cloneResConfig;
-
- cloneResConfig = resParent.getCurrentResourceConfigClone();
- removeRcbsTools(cloneResConfig);
-
- setValues();
- setDirty(true);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
- IResourceConfiguration cloneResConfig;
- IResourceConfiguration rcConfig;
- boolean rebuildNeeded = false;
- boolean rcbsStillDisabledSoNoRebuild = false;
-
- /*
- * Gather the users input.
- * Examine the tools defined for the resource configuration.
- * There should be at most one tool defined for a custom build step which was not an
- * extension element (not defined by a tool integrator in a manifest).
- * If the rcbs tool has been defined, set the tool values from the user supplied values.
- * If the rcbs tool has not been defined yet, create the tool and set the tool values.
- * No validity checking of the users input is performed. The user is responsible for providing
- * proper input.
- * Finally, set the rcbsApplicability attribute in the resource configuration according to the user's
- * selection.
- */
-
- cloneResConfig = resParent.getCurrentResourceConfigClone();
- ITool cloneTool = getRcbsTool(cloneResConfig, false);
-
- rcConfig = resParent.getCurrentResourceConfig(false);
- if(cloneTool == null){
- if(rcConfig != null)
- rebuildNeeded = removeRcbsTools(rcConfig);
- } else {
- if(rcConfig == null)
- rcConfig = resParent.getCurrentResourceConfig(true);
-
-
- ITool realTool = getRcbsTool(rcConfig,true);
-
- realTool.getInputTypes()[0].getAdditionalInputs()[0].setPaths(
- createList(
- cloneTool.getInputTypes()[0].getAdditionalInputs()[0].getPaths()));
- realTool.getOutputTypes()[0].setOutputNames(
- createList(
- cloneTool.getOutputTypes()[0].getOutputNames()));
- realTool.setToolCommand(
- cloneTool.getToolCommand());
- realTool.setAnnouncement(
- cloneTool.getAnnouncement());
- if (realTool.isDirty()) {
- rebuildNeeded = true;
- }
-
- /*
- * Get the state of the rcbs applicability selector and set the rcbsApplicability attribute in the
- * resource configuration.
- */
- rcConfig.setRcbsApplicability(
- cloneResConfig.getRcbsApplicability());
-
- if(rcConfig.getRcbsApplicability() == IResourceConfiguration.KIND_DISABLE_RCBS_TOOL)
- rcbsStillDisabledSoNoRebuild = true;
-
- if (rcConfig.isDirty()) {
- rebuildNeeded = true;
- }
-
- if (rebuildNeeded && !rcbsStillDisabledSoNoRebuild) {
-// rcConfig.getParent().setRebuildState(true);
- }
-
- setDirty(false);
- }
- }
-
- private String createList(String[] items) {
- if(items == null)
- return new String();
-
- StringBuffer path = new StringBuffer(""); //$NON-NLS-1$
-
- for (int i = 0; i < items.length; i++) {
- path.append(items[i]);
- if (i < (items.length - 1)) {
- path.append(PATH_SEPERATOR);
- }
- }
- return path.toString();
- }
-
- private boolean removeRcbsTools(IResourceConfiguration rcConfig){
- ITool tools[] = getRcbsTools(rcConfig);
- if(tools != null){
- for(int i = 0; i < tools.length; i++)
- rcConfig.removeTool(tools[i]);
-
- boolean rebuildNeeded =
- rcConfig.getRcbsApplicability() != IResourceConfiguration.KIND_DISABLE_RCBS_TOOL;
-
- rcConfig.setRcbsApplicability(IResourceConfiguration.KIND_DISABLE_RCBS_TOOL);
-
- return rebuildNeeded;
- }
- return false;
- }
-
- private ITool getRcbsTool(IResourceConfiguration rcConfig, boolean create){
- ITool rcbsTools[] = getRcbsTools(rcConfig);
- ITool rcbsTool = null;
- if(rcbsTools != null)
- rcbsTool = rcbsTools[0];
- else if (create) {
- rcbsTool = rcConfig.createTool(null,rcbsToolId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolName,false); //$NON-NLS-1$
- rcbsTool.setCustomBuildStep(true);
- IInputType rcbsToolInputType = rcbsTool.createInputType(null,rcbsToolInputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolInputTypeName,false); //$NON-NLS-1$
- IAdditionalInput rcbsToolInputTypeAdditionalInput = rcbsToolInputType.createAdditionalInput(new String());
- rcbsToolInputTypeAdditionalInput.setKind(IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY);
- rcbsTool.createOutputType(null,rcbsToolOutputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolOutputTypeName,false); //$NON-NLS-1$
- }
- return rcbsTool;
- }
-
- private ITool[] getRcbsTools(IResourceConfiguration rcConfig){
- List list = new ArrayList();
- ITool tools[] = rcConfig.getTools();
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- if (tool.getCustomBuildStep() && !tool.isExtensionElement()) {
- list.add(tool);
- }
- }
- if(list.size() != 0)
- return (ITool[])list.toArray(new ITool[list.size()]);
- return null;
- }
-
- public IPreferenceStore getPreferenceStore() {
- return null;
- }
-
- /*
- * Sets the "dirty" state
- */
- public void setDirty(boolean b) {
- dirty = b;
- }
-
- /*
- * Returns the "dirty" state
- */
- public boolean isDirty() {
- return dirty;
- }
-
- public void setVisible(boolean visible){
- if(visible)
- setValues();
- super.setVisible(visible);
- }
-
- public boolean containsDefaults(){
- return containsDefaults(resParent.getCurrentResourceConfigClone());
- }
-
- protected boolean containsDefaults(IResourceConfiguration rcCfg){
- ITool tools[] = getRcbsTools(rcCfg);
-
- if(tools == null)
- return true;
-
- return false;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java
deleted file mode 100644
index fd352c01738..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java
+++ /dev/null
@@ -1,954 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 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:
- * QNX Software Systems - Move to Make plugin
- * Intel Corp - Use in Managed Make system
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.ui.properties.AbstractBuildPropertyPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildSettingsPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPreferenceStore;
-import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
-import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider;
-import org.eclipse.cdt.managedbuilder.ui.properties.ToolListLabelProvider;
-import org.eclipse.cdt.managedbuilder.ui.properties.ToolListElement;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-public class ToolsSettingsBlock extends AbstractCOptionPage {
-
- /*
- * String constants
- */
- private static final String PREFIX = "ToolsSettingsBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
- //private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
- //private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
- private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
-
- /*
- * Dialog widgets
- */
- private TreeViewer optionList;
- private SashForm sashForm;
- private Composite settingsPageContainer;
- private ScrolledComposite containerSC;
-
- /*
- * Bookeeping variables
- */
- private Map configToPageListMap;
- private BuildToolSettingsPreferenceStore settingsStore;
- private BuildPropertyPage parent;
- private ResourceBuildPropertyPage resParent;
- private BuildSettingsPage currentSettingsPage;
- private ToolListElement selectedElement;
- private ToolListContentProvider provider;
- private Object propertyObject;
-
- private boolean defaultNeeded;
-
- /**
- * The minimum page size; 200 by 200 by default.
- *
- * @see #setMinimumPageSize
- */
- private Point minimumPageSize = new Point(200, 200);
-
- /**
- * Layout for the page container.
- *
- */
- private class PageLayout extends Layout {
- public void layout(Composite composite, boolean force) {
- Rectangle rect = composite.getClientArea();
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].setSize(rect.width, rect.height);
- }
- }
- public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
- return new Point(wHint, hHint);
- }
- int x = minimumPageSize.x;
- int y = minimumPageSize.y;
-
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
- x = Math.max(x, size.x);
- y = Math.max(y, size.y);
- }
- if (wHint != SWT.DEFAULT) {
- x = wHint;
- }
- if (hHint != SWT.DEFAULT) {
- y = hHint;
- }
- return new Point(x, y);
- }
- }
-
- /*
- * Constructor
- */
- public ToolsSettingsBlock(BuildPropertyPage parent, Object element)
- {
- super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
- super.setContainer(parent);
- this.parent = parent;
- configToPageListMap = new HashMap();
- this.propertyObject = element;
- settingsStore = new BuildToolSettingsPreferenceStore(this);
- }
-
- public ToolsSettingsBlock(ResourceBuildPropertyPage resParent, Object element)
- {
- super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
- super.setContainer((ICOptionContainer) resParent);
- this.resParent = resParent;
- configToPageListMap = new HashMap();
- this.propertyObject = element;
- settingsStore = new BuildToolSettingsPreferenceStore(this);
- }
-
- public void createControl(Composite parent) {
-
- // Create the sash form
- sashForm = new SashForm(parent, SWT.NONE);
- sashForm.setOrientation(SWT.HORIZONTAL);
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- sashForm.setLayout(layout);
-
- setControl(sashForm);
- createSelectionArea(sashForm);
- createEditArea(sashForm);
- initializeSashForm();
-
- //WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
- }
-
- protected void createSelectionArea (Composite parent) {
- // Create a label and list viewer
- Composite composite = ControlFactory.createComposite(parent, 1);
- optionList = new TreeViewer(composite, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
- optionList.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleOptionSelection();
- }
- });
- optionList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- optionList.setLabelProvider(new ToolListLabelProvider());
- optionList.addFilter(new ViewerFilter() {
- public boolean select(Viewer viewer,
- Object parent,
- Object element) {
- if(parent instanceof IResourceConfiguration && element instanceof ITool) {
- return !((ITool)element).getCustomBuildStep();
- } else {
- return true;
- }
- }
- });
- }
-
- /* (non-Javadoc)
- * Method displayOptionsForCategory
- * @param category
- */
- private void displayOptionsForCategory(ToolListElement toolListElement) {
- selectedElement = toolListElement;
- IOptionCategory category = toolListElement.getOptionCategory();
- IHoldsOptions optionHolder = toolListElement.getHoldOptions();
-
- // Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
- currentSettingsPage = null;
-
- // Create a new settings page if necessary
- List pages = getPagesForConfig();
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page instanceof BuildOptionSettingsPage &&
- ((BuildOptionSettingsPage)page).isForCategory(optionHolder, category)) {
- currentSettingsPage = page;
- break;
- }
- }
- if (currentSettingsPage == null) {
- if ( this.propertyObject instanceof IProject) {
- currentSettingsPage = new BuildOptionSettingsPage(parent,parent.getSelectedConfigurationClone(), optionHolder, category);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(parent);
- } else if ( this.propertyObject instanceof IFile) {
- currentSettingsPage = new BuildOptionSettingsPage(resParent,resParent.getCurrentResourceConfigClone(), optionHolder, category);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(resParent);
- }
- if (currentSettingsPage.getControl() == null) {
- currentSettingsPage.createControl(settingsPageContainer);
- }
- }
-
- // Make all the other pages invisible
- Control[] children = settingsPageContainer.getChildren();
- Control currentControl = currentSettingsPage.getControl();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != currentControl)
- children[i].setVisible(false);
- }
- currentSettingsPage.setVisible(true);
-
- //update the field editors in the current page
- if(currentSettingsPage instanceof BuildOptionSettingsPage)
- ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
-
- if (oldPage != null && oldPage != currentSettingsPage)
- oldPage.setVisible(false);
-
- // Set the size of the scrolled area
- containerSC.setMinSize(currentSettingsPage.computeSize());
- settingsPageContainer.layout();
- }
-
- /* (non-Javadoc)
- * Method displayOptionsForTool
- * @param tool
- */
- private void displayOptionsForTool(ToolListElement toolListElement) {
- selectedElement = toolListElement;
- ITool tool = toolListElement.getTool();
-
- // Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
- currentSettingsPage = null;
-
- // Create a new page if we need one
- List pages = getPagesForConfig();
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page instanceof BuildToolSettingsPage &&
- ((BuildToolSettingsPage)page).isForTool(tool)) {
- currentSettingsPage = page;
- break;
- }
- }
- if (currentSettingsPage == null) {
- if ( this.propertyObject instanceof IProject) {
- currentSettingsPage = new BuildToolSettingsPage(parent,
- parent.getSelectedConfigurationClone(), tool);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(parent);
- } else if(this.propertyObject instanceof IFile) {
- currentSettingsPage = new BuildToolSettingsPage(resParent,
- resParent.getCurrentResourceConfigClone(), tool);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(resParent);
- }
- if (currentSettingsPage.getControl() == null) {
- currentSettingsPage.createControl(settingsPageContainer);
- }
- }
- // Make all the other pages invisible
- Control[] children = settingsPageContainer.getChildren();
- Control currentControl = currentSettingsPage.getControl();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != currentControl)
- children[i].setVisible(false);
- }
-
- // Make the current page visible
- currentSettingsPage.setVisible(true);
-
- // Save the last page build options.
- if (oldPage != null && oldPage != currentSettingsPage){
- if(oldPage instanceof BuildOptionSettingsPage) {
- ((BuildOptionSettingsPage)oldPage).storeSettings();
- }
- else if(oldPage instanceof BuildToolSettingsPage) {
- ((BuildToolSettingsPage)oldPage).storeSettings();
- //((BuildToolSettingsPage)oldPage).parseAllOptions();
- }
- }
- // Update the field editor that displays all the build options
- if(currentSettingsPage instanceof BuildToolSettingsPage)
- ((BuildToolSettingsPage)currentSettingsPage).setValues();
-
- if (oldPage != null && oldPage != currentSettingsPage)
- oldPage.setVisible(false);
-
- // Set the size of the scrolled area
- containerSC.setMinSize(currentSettingsPage.computeSize());
- settingsPageContainer.layout();
- }
-
- /* (non-Javadoc)
- * Add the tabs relevant to the project to edit area tab folder.
- */
- protected void createEditArea(Composite parent) {
- containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- containerSC.setExpandHorizontal(true);
- containerSC.setExpandVertical(true);
-
- // Add a container for the build settings page
- settingsPageContainer = new Composite(containerSC, SWT.NULL);
- settingsPageContainer.setLayout(new PageLayout());
-
- containerSC.setContent(settingsPageContainer);
- containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- settingsPageContainer.layout();
- }
-
- /*
- * (non-javadoc)
- * Initialize the relative weights (widths) of the 2 sides of the sash.
- */
- protected void initializeSashForm() {
- sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
- }
-
- protected void initializeValues() {
- setValues();
- }
-
- public void updateValues() {
- setValues();
- }
-
- public void setVisible(boolean visible){
- if(visible){
- selectedElement = null;
- handleOptionSelection();
- }
- super.setVisible(visible);
- }
-
- protected void setValues() {
- /*
- * This method updates the context of the build property pages
- * - Which configuration/resource configuration is selected
- * - Which tool/option category is selected
- *
- * It is called:
- * - When a property page becomes visible
- * - When the user changes the configuration selection
- * - When the user changes the "exclude" setting for a resource
- */
-
- // Create the Tree Viewer content provider if first time
- if (provider == null) {
- IResource resource = (IResource) propertyObject;
- provider = new ToolListContentProvider(resource.getType());
- optionList.setContentProvider(provider);
- }
-
- // Update the selected configuration and the Tree Viewer
- IConfiguration config = null;
- IResourceConfiguration resConfig = null;
- ToolListElement[] newElements;
-
- if ( propertyObject instanceof IProject ) {
- config = parent.getSelectedConfigurationClone();
- optionList.setInput(config);
- newElements = (ToolListElement[])provider.getElements(config);
- } else if ( propertyObject instanceof IFile){
- resConfig = resParent.getCurrentResourceConfigClone();
- optionList.setInput(resConfig);
- newElements = (ToolListElement[])provider.getElements(resConfig);
- } else
- return; // This should not happen
-
- optionList.expandAll();
-
- // Determine what the selection in the tree should be
- // If the saved selection is not null, try to match the saved selection
- // with an object in the new element list.
- // Otherwise, select the first tool in the tree
- Object primaryObject = null;
- if (selectedElement != null) {
- selectedElement = matchSelectionElement(selectedElement, newElements);
- }
-
- if (selectedElement == null) {
- selectedElement = (ToolListElement)(newElements.length > 0 ? newElements[0] : null);
- }
-
- if (selectedElement != null) {
- primaryObject = selectedElement.getTool();
- if (primaryObject == null) {
- primaryObject = selectedElement.getOptionCategory();
- }
- if (primaryObject != null) {
- if (primaryObject instanceof IOptionCategory) {
- if(resConfig != null)
- settingsStore.setSelection(resConfig, selectedElement, (IOptionCategory)primaryObject);
- else
- settingsStore.setSelection(config, selectedElement, (IOptionCategory)primaryObject);
- }
- optionList.setSelection(new StructuredSelection(selectedElement), true);
- }
- }
- }
-
- private ToolListElement matchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
- // First, look for an exact match
- ToolListElement match = exactMatchSelectionElement(currentElement, elements);
- if (match == null)
- // Else, look for the same tool/category in the new set of elements
- match = equivalentMatchSelectionElement(currentElement, elements);
- return match;
- }
-
- private ToolListElement exactMatchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
- for (int i=0; i<elements.length; i++) {
- ToolListElement e = elements[i];
- if (e == currentElement) {
- return currentElement;
- }
- e = exactMatchSelectionElement(currentElement, e.getChildElements());
- if (e != null) return e;
- }
- return null;
- }
-
- private ToolListElement equivalentMatchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
- for (int i=0; i<elements.length; i++) {
- ToolListElement e = elements[i];
- if (e.isEquivalentTo(currentElement)) {
- return e;
- }
- e = equivalentMatchSelectionElement(currentElement, e.getChildElements());
- if (e != null) return e;
- }
- return null;
- }
-
- public void removeValues(String id) {
- }
-
- private void handleOptionSelection() {
- // Get the selection from the tree list
- IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
-
- // Set the option page based on the selection
- ToolListElement toolListElement = (ToolListElement)selection.getFirstElement();
- if (toolListElement != null) {
- IOptionCategory cat = toolListElement.getOptionCategory();
- if (cat == null)
- cat = (IOptionCategory)toolListElement.getTool();
- if (cat != null) {
- if(resParent != null)
- settingsStore.setSelection(resParent.getCurrentResourceConfigClone(), toolListElement, cat);
- else
- settingsStore.setSelection(parent.getSelectedConfigurationClone(), toolListElement, cat);
- }
-
- cat = toolListElement.getOptionCategory();
- if (cat != null) {
- displayOptionsForCategory(toolListElement);
- } else {
- displayOptionsForTool(toolListElement);
- }
- }
- }
-
- /**
- * Call an MBS CallBack function to inform that default settings have been applied.
- * This has to be sent to all the Options associated with this configuration.
- */
-/* private void performSetDefaultsEventCallBack() {
-
- if ( element instanceof IProject) {
- // Do not send the event to the child resource configurations, as performDefaults
- // is only scoped to what is visible in the UI.
- ManagedBuildManager.performValueHandlerEvent(parent.getSelectedConfiguration(),
- IManagedOptionValueHandler.EVENT_SETDEFAULT, false);
- } else if ( element instanceof IFile) {
- IResourceConfiguration rcCfg = resParent.getCurrentResourceConfig(false);
- if(rcCfg != null)
- ManagedBuildManager.performValueHandlerEvent(rcCfg,
- IManagedOptionValueHandler.EVENT_SETDEFAULT);
- }
- }
-*/
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
- */
- public void performDefaults() {
- if ( propertyObject instanceof IProject) {
- performDefaults( (IProject)propertyObject);
- } else if ( propertyObject instanceof IFile) {
- performDefaults( (IFile)propertyObject);
- }
- defaultNeeded = true;
- return;
- }
-
- public void performDefaults(IProject project) {
- // TODO: Should this reset all tools of the configuration, or just
- // the currently selected tool category? Right now it is all tools.
-
-
- // Get the build manager to reset build info for project
- ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfigurationClone());
- ITool tools[] = parent.getSelectedConfigurationClone().getFilteredTools();
- for( int i = 0; i < tools.length; i++ ){
- if(!tools[i].getCustomBuildStep()) {
- tools[i].setToolCommand(null);
- tools[i].setCommandLinePattern(null);
- }
- }
-
- // Reset the category or tool selection and run selection event handler
- selectedElement = null;
- handleOptionSelection();
-
- setDirty(true);
- }
-
- public void performDefaults(IFile file) {
- // TODO: Should this reset all options of the tool in current resource configuration, or just
- // the currently selected tool category? Right now it is all options.
-
- // Get the build manager to reset build info for project
- ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfigClone());
- ITool tools[] = resParent.getCurrentResourceConfigClone().getTools();
- for( int i = 0; i < tools.length; i++ ){
- if(!tools[i].getCustomBuildStep()) {
- tools[i].setToolCommand(null);
- tools[i].setCommandLinePattern(null);
- }
- }
-
- // Reset the category or tool selection and run selection event handler
- selectedElement = null;
- handleOptionSelection();
-
- setDirty(true);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
- */
- public void performApply(IProgressMonitor monitor) throws CoreException {
-
- if(propertyObject instanceof IFile)
- resParent.getCurrentResourceConfig(true);
-
- if(defaultNeeded){
- if(propertyObject instanceof IFile)
- ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig(true));
- else
- ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration());
-
-// performSetDefaultsEventCallBack();
-
- defaultNeeded = false;
- }
- //some options might be changed that do not belong to the created pages,
- //we need to save all options instead
- saveAll();
-
- setDirty(false);
- }
-
- private void saveAll(){
- if(resParent != null)
- saveResourceConfig();
- else
- saveConfig();
- }
-
- private void saveResourceConfig(){
- IResourceConfiguration cloneRcCfg = resParent.getCurrentResourceConfigClone();
-
- ITool tools[] = cloneRcCfg.getTools();
-
- for(int i = 0; i < tools.length; i++){
- saveHoldsOptions(tools[i]);
- }
- }
-
- private void saveHoldsOptions(IHoldsOptions holder){
- if(holder instanceof ITool && ((ITool)holder).getCustomBuildStep())
- return;
- AbstractBuildPropertyPage page = resParent != null ?
- (AbstractBuildPropertyPage)resParent : (AbstractBuildPropertyPage)parent;
-
- IHoldsOptions realHo = page.getRealHoldsOptions(holder);
-
- if(realHo != null){
- IHoldsOptions realHolder;
- IConfiguration realCfg = null;
- IResourceConfiguration realRcCfg = null;
- if(resParent != null){
- realHolder = resParent.getRealHoldsOptions(holder);
- realRcCfg = (IResourceConfiguration)((ITool)realHolder).getParent();
- realCfg = realRcCfg.getParent();
- } else {
- realHolder = parent.getRealHoldsOptions(holder);
- realCfg = parent.getConfigurationFromHoldsOptions(realHolder);
- }
- if(holder instanceof ITool) {
- String currentValue = ((ITool)realHo).getToolCommand();
- if (!(currentValue.equals(((ITool)holder).getToolCommand()))) {
- ((ITool)realHo).setToolCommand(((ITool)holder).getToolCommand());
- //if(resParent != null){
- // TODO: This causes the entire project to be rebuilt. Is there a way to only have this
- // file rebuilt? "Clean" its output? Change its modification date?
- //realCfg.setRebuildState(true);
- //} else {
-// realCfg.setRebuildState(true);
- //}
- }
- currentValue = ((ITool)realHo).getCommandLinePattern();
- if (!(currentValue.equals(((ITool)holder).getCommandLinePattern()))) {
- ((ITool)realHo).setCommandLinePattern(((ITool)holder).getCommandLinePattern());
- //if(resParent != null){
- // TODO: This causes the entire project to be rebuilt. Is there a way to only have this
- // file rebuilt? "Clean" its output? Change its modification date?
- //realCfg.setRebuildState(true);
- //} else {
-// realCfg.setRebuildState(true);
- //}
- }
- }
- IOption options[] = holder.getOptions();
- for(int i = 0; i < options.length; i++){
- saveOption(options[i], holder, realHolder, realCfg, realRcCfg);
- }
- }
- }
- private void saveOption(IOption clonedOption, IHoldsOptions cloneHolder,
- IHoldsOptions realHolder, IConfiguration realCfg, IResourceConfiguration realRcCfg){
- IOption realOption;
-// IBuildObject handler = null;
-
- if(resParent != null){
- realOption = resParent.getRealOption(clonedOption,cloneHolder);
-// handler = realRcCfg;
- } else {
- realOption = parent.getRealOption(clonedOption,cloneHolder);
-// handler = realCfg;
- }
-
- try {
- // Transfer value from preference store to options
- IOption setOption = null;
- switch (clonedOption.getValueType()) {
- case IOption.BOOLEAN :
- boolean boolVal = clonedOption.getBooleanValue();
- if(realRcCfg != null) {
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, boolVal);
- } else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, boolVal);
- }
- // Reset the preference store since the Id may have changed
-// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
-// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
-// fe.setPreferenceName(setOption.getId());
-// }
- break;
- case IOption.ENUMERATED :
- String enumVal = clonedOption.getStringValue();
- String enumId = clonedOption.getEnumeratedId(enumVal);
- if(realRcCfg != null) {
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption,
- (enumId != null && enumId.length() > 0) ? enumId : enumVal);
- } else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption,
- (enumId != null && enumId.length() > 0) ? enumId : enumVal);
- }
- // Reset the preference store since the Id may have changed
-// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
-// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
-// fe.setPreferenceName(setOption.getId());
-// }
- break;
- case IOption.STRING :
- String strVal = clonedOption.getStringValue();
- if(realRcCfg != null){
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, strVal);
- } else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, strVal);
- }
-
- // Reset the preference store since the Id may have changed
-// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
-// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
-// fe.setPreferenceName(setOption.getId());
-// }
- break;
- case IOption.STRING_LIST :
- case IOption.INCLUDE_PATH :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- case IOption.OBJECTS :
- String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]);
- if( realRcCfg != null){
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, listVal);
- }else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, listVal);
- }
-
- // Reset the preference store since the Id may have changed
-// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
-// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
-// fe.setPreferenceName(setOption.getId());
-// }
- break;
- default :
- break;
- }
-
- // Call an MBS CallBack function to inform that Settings related to Apply/OK button
- // press have been applied.
- if (setOption == null)
- setOption = realOption;
-
-/* if (setOption.getValueHandler().handleValue(
- handler,
- setOption.getOptionHolder(),
- setOption,
- setOption.getValueHandlerExtraArgument(),
- IManagedOptionValueHandler.EVENT_APPLY)) {
- // TODO : Event is handled successfully and returned true.
- // May need to do something here say log a message.
- } else {
- // Event handling Failed.
- }
-*/
- } catch (BuildException e) {
- } catch (ClassCastException e) {
- }
-
- }
-
- private void saveConfig(){
- IConfiguration cfg = parent.getSelectedConfigurationClone();
-
- IToolChain tc = cfg.getToolChain();
- saveHoldsOptions(tc);
-
- ITool tools[] = cfg.getFilteredTools();
- for(int i = 0; i < tools.length; i++){
- saveHoldsOptions(tools[i]);
- }
- }
-
- public boolean containsDefaults(){
- if(resParent == null)
- return false;
- return containsDefaults(resParent.getCurrentResourceConfigClone());
- }
-
- protected boolean containsDefaults(IResourceConfiguration rcCfg){
- IConfiguration cfg = rcCfg.getParent();
- ITool tools[] = rcCfg.getTools();
- for(int i = 0; i < tools.length; i++){
- ITool tool = tools[i];
- if(!tool.getCustomBuildStep()){
- ITool cfgTool = cfg.getToolChain().getTool(tool.getSuperClass().getId());
- // Check for a non-default command or command-line-pattern
- if(cfgTool != null){
- if (!(tool.getToolCommand().equals(cfgTool.getToolCommand()))) return false;
- if (!(tool.getCommandLinePattern().equals(cfgTool.getCommandLinePattern()))) return false;
- }
- // Check for a non-default option
- IOption options[] = tool.getOptions();
- for( int j = 0; j < options.length; j++){
- IOption option = options[j];
- if(option.getParent() == tool){
- IOption ext = option;
- do{
- if(ext.isExtensionElement())
- break;
- } while((ext = ext.getSuperClass()) != null);
-
- if(ext != null){
- if(cfgTool != null){
- IOption defaultOpt = cfgTool.getOptionBySuperClassId(ext.getId());
- try {
- if(defaultOpt != null && defaultOpt.getValueType() == option.getValueType()){
- Object value = option.getValue();
- Object defaultVal = defaultOpt.getValue();
-
- if(value.equals(defaultVal))
- continue;
- //TODO: check list also
- }
- }catch (BuildException e) {
- }
- }
- }
- return false;
- }
- }
- }
- }
- return true;
- }
-
- /* (non-Javadoc)
- * Answers the list of settings pages for the selected configuration
- * @return
- */
- private List getPagesForConfig() {
- List pages = null;
- if ( propertyObject instanceof IProject) {
-// Make sure that something was selected
- if (parent.getSelectedConfigurationClone() == null) {
- return null;
- }
- pages = (List) configToPageListMap.get(parent.getSelectedConfigurationClone().getId());
- } else if (propertyObject instanceof IFile) {
- if ( resParent.getCurrentResourceConfigClone() == null ) {
- return null;
- }
- pages = (List) configToPageListMap.get(resParent.getCurrentResourceConfigClone().getId());
- }
-
- if (pages == null) {
- pages = new ArrayList();
- if ( propertyObject instanceof IProject) {
- configToPageListMap.put(parent.getSelectedConfigurationClone().getId(), pages);
- } else if ( propertyObject instanceof IFile) {
- configToPageListMap.put(resParent.getCurrentResourceConfigClone().getId(), pages);
- }
- }
- return pages;
- }
-
- public BuildToolSettingsPreferenceStore getPreferenceStore() {
- return settingsStore;
- }
-
- /**
- * Sets the "dirty" state
- */
- public void setDirty(boolean b) {
- // Set each settings page
- List pages = getPagesForConfig();
- // Make sure we have something to work on
- if (pages == null) {
- // Nothing to do
- return;
- }
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page == null) continue;
- page.setDirty(b);
- }
- }
-
- /**
- * Returns the "dirty" state
- */
- public boolean isDirty() {
- // Check each settings page
- List pages = getPagesForConfig();
- // Make sure we have something to work on
- if (pages == null) {
- // Nothing to do
- return false;
- }
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page == null) continue;
- if (page.isDirty()) return true;
- }
- return false;
- }
-
- /**
- * Returns the build macro provider to be used for macro resolution
- * In case the "Build Macros" tab is available, returns the BuildMacroProvider
- * supplied by that tab.
- * Unlike the default provider, that provider also contains
- * the user-modified macros that are not applied yet
- * If the "Build Macros" tab is not available, returns the default BuildMacroProvider
- */
- public BuildMacroProvider obtainMacroProvider(){
- ICOptionContainer container = getContainer();
- ManagedBuildOptionBlock optionBlock = null;
- if(container instanceof BuildPropertyPage){
- BuildPropertyPage page = (BuildPropertyPage)container;
- optionBlock = page.getOptionBlock();
- } else if(container instanceof BuildPreferencePage){
- BuildPreferencePage page = (BuildPreferencePage)container;
- optionBlock = page.getOptionBlock();
- }
- if(optionBlock != null){
- MacrosSetBlock block = optionBlock.getMacrosBlock();
- if(block != null)
- return block.getBuildMacroProvider();
- }
- return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- }
-}
-
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java
index 7f8c8189026..2ed4dbfeb55 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildFilesAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Texas Instruments Incorporated and others.
+ * Copyright (c) 2006, 2007 Texas Instruments Incorporated 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
@@ -295,7 +295,9 @@ public class BuildFilesAction extends ActionDelegate implements
IManagedBuildInfo buildInfo = ManagedBuildManager
.getBuildInfo(file.getProject());
- if (buildInfo == null || !buildInfo.isValid()) {
+ if (buildInfo == null || !buildInfo.isValid()
+ || buildInfo.getDefaultConfiguration() == null
+ || !buildInfo.getDefaultConfiguration().isManagedBuildOn()) {
return false;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java
index 1c4c67f0c4f..fe862eb9d33 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java
@@ -14,9 +14,9 @@ import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-
+import org.eclipse.cdt.managedbuilder.ui.newui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -69,7 +69,7 @@ public class ConvertTargetAction
public void run(IAction action) {
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ Shell shell = CUIPlugin.getActiveWorkbenchShell();
// Check whether the converters available for the selected project
// If there are no converters display error dialog otherwise display converters list
@@ -77,23 +77,23 @@ public class ConvertTargetAction
if( ManagedBuildManager.hasTargetConversionElements(getProjectType(getSelectedProject())) == true ) {
handleConvertTargetAction();
} else {
- MessageDialog.openError(shell,ManagedBuilderUIMessages.getResourceString("ProjectConvert.noConverterErrordialog.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("ProjectConvert.noConverterErrordialog.message", new String[] {getSelectedProject().getName()}) ); //$NON-NLS-1$
+ MessageDialog.openError(shell,"No converter", //$NON-NLS-1$
+ NewUIMessages.getFormattedString("ProjectConvert.noConverterErrordialog.message", new String[] {getSelectedProject().getName()}) ); //$NON-NLS-1$
}
}
private void handleConvertTargetAction() {
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- String title = ManagedBuilderUIMessages.getFormattedString(PROJECT_CONVERTER_DIALOG, new String(getSelectedProject().getName()));
+ String title = NewUIMessages.getFormattedString(PROJECT_CONVERTER_DIALOG, new String(getSelectedProject().getName()));
ConvertTargetDialog dialog = new ConvertTargetDialog(shell, getSelectedProject(), title);
if ( dialog.open() == ConvertTargetDialog.OK ) {
if ( ConvertTargetDialog.isConversionSuccessful() == false) {
MessageDialog.openError(
shell,
- ManagedBuilderUIMessages
+ NewUIMessages
.getResourceString("ProjectConvert.conversionErrordialog.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages
+ NewUIMessages
.getFormattedString(
"ProjectConvert.conversionErrordialog.message", new String[] { getSelectedProject().getName() })); //$NON-NLS-1$
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetDialog.java
index de9a12fdfde..09708b18011 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetDialog.java
@@ -12,14 +12,15 @@ package org.eclipse.cdt.managedbuilder.ui.actions;
import java.util.HashMap;
import java.util.Map;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -123,7 +124,7 @@ public class ConvertTargetDialog extends StatusDialog {
// Create the converters list group area
final Group convertersListGroup = new Group(comp, SWT.NONE);
convertersListGroup.setFont(parent.getFont());
- convertersListGroup.setText(ManagedBuilderUIMessages.getResourceString(CONVERTERS_LIST));
+ convertersListGroup.setText(NewUIMessages.getResourceString(CONVERTERS_LIST));
convertersListGroup.setLayout(new GridLayout(1, false));
convertersListGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractCBuildPropertyTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractCBuildPropertyTab.java
new file mode 100644
index 00000000000..f812ec19455
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractCBuildPropertyTab.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+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.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Proposed parent for Build System property tabs.
+ *
+ * In addition to AbstractCPropertyTab functionality,
+ * provides several utility methods for configurations
+ * handling.
+ */
+public abstract class AbstractCBuildPropertyTab extends AbstractCPropertyTab {
+ public IConfiguration getConfigurationFromHoldsOptions(IHoldsOptions ho){
+ if(ho instanceof IToolChain)
+ return ((IToolChain)ho).getParent();
+ else if(ho instanceof ITool)
+ return getConfigurationFromTool((ITool)ho);
+ return null;
+ }
+ public IConfiguration getConfigurationFromTool(ITool tool){
+ return tool.getParentResourceInfo().getParent();
+ }
+
+ public IConfiguration getCfg() {
+ return getCfg(getResDesc().getConfiguration());
+ }
+ public IConfiguration getCfg(ICConfigurationDescription cfgd) {
+ return ManagedBuildManager.getConfigurationForDescription(cfgd);
+ }
+
+ /**
+ * Returns ResourceInfo for given ResourceDescription.
+ * Creates resourceInfo if it has not exist before.
+ * @param cfgd
+ * @return
+ */
+ public IResourceInfo getResCfg(ICResourceDescription cfgd) {
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgd.getConfiguration());
+
+ if (page.isForProject())
+ return cfg.getRootFolderInfo();
+
+ IPath p = cfgd.getPath();
+ IResourceInfo f = null;
+ f = cfg.getResourceInfo(p, false);
+
+ if (f != null && (!p.equals(f.getPath()))) {
+ String s = p.toString().replace('/', '_').replace('\\', '_');
+ if (page.isForFile())
+ f = cfg.createFileInfo(p, (IFolderInfo)f, null,
+ f.getId()+ s, f.getName() + s);
+ else
+ f = cfg.createFolderInfo(p, (IFolderInfo)f,
+ f.getId() + s, f.getName() + s);
+ }
+ if (f == null) {
+ if (page.isForFile())
+ f = cfg.createFileInfo(p);
+
+ else
+ f = cfg.createFolderInfo(p);
+ }
+ return f;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractDiscoveryPage.java
index 867542f2299..3923be1cafa 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractDiscoveryPage.java
@@ -1,21 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2007 Intel 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 - Initial API and implementation
+ * Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.ui.dialogs;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.io.File;
-import org.eclipse.cdt.internal.ui.util.SWTUtil;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.BuildOutputReaderJob;
-import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@@ -23,6 +22,8 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -39,105 +40,204 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
- * SCD per project profile property/preference page
+ * Abstract SCD profile page
*
* @author vhirsl
*/
-public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
+public abstract class AbstractDiscoveryPage extends DialogPage {
+ protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
+ protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
+ protected static final String VARIABLES_BUTTON = PREFIX + ".common.variables.button"; //$NON-NLS-1$
private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
private static final String BO_PROVIDER_OPEN_FILE_DIALOG = PREFIX + ".boProvider.browse.openFileDialog"; //$NON-NLS-1$
- private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
+
+ protected IBuildInfoContainer fContainer; // parent
+ protected Shell shell;
+
+ // thread synchronization
+ protected static Object lock = AbstractDiscoveryPage.class;
+ protected static AbstractDiscoveryPage instance;
+ protected static boolean loadButtonInitialEnabled = true;
- private static final String providerId = "makefileGenerator"; //$NON-NLS-1$
+ // controls affected by LOAD button
+ // if descendant do not use it, it's not obligatory to initialize them.
+ protected Button bopLoadButton;
+ protected Button bopEnabledButton;
+ protected Text bopOpenFileText;
+
+ public AbstractDiscoveryPage() { super(); }
+ public AbstractDiscoveryPage(String title) { super(title); }
+ public AbstractDiscoveryPage(String title, ImageDescriptor image) { super(title, image); }
+ protected IBuildInfoContainer getContainer() { return fContainer; }
+ protected void setContainer(IBuildInfoContainer container) { fContainer = container; }
+ /**
+ * @param title
+ * @param image
+ */
+
+ protected Button addVariablesButton(Composite parent, final Text control) {
+ shell = parent.getShell();
+ Button variablesButton = ControlFactory.createPushButton(parent,
+ AbstractCPropertyTab.VARIABLESBUTTON_NAME);
+ ((GridData) variablesButton.getLayoutData()).widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
+ variablesButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent arg0) {
+ handleVariablesButtonSelected(control);
+ }
+ });
+ return variablesButton;
+ }
- private Button bopEnabledButton;
- private Text bopOpenFileText;
- private Button bopLoadButton;
+ /**
+ * A variable entry button has been pressed for the given text field. Prompt
+ * the user for a variable and enter the result in the given field.
+ */
+ private void handleVariablesButtonSelected(Text textField) {
+ String s = AbstractCPropertyTab.getVariableDialog(shell, fContainer.getConfiguration());
+ if (s != null) textField.append(s);
+ }
+
+ public abstract void initializeValues();
+ protected abstract void handlebopEnabledButtonPress();
+ protected abstract void createSpecific(Composite parent);
+
+ // Handle Load button press
+ protected void handleBOPLoadFileButtonSelected() {
+ loadButtonInitialEnabled = false;
+ bopLoadButton.setEnabled(false);
+
+ IProject project = getContainer().getProject();
+ Job readerJob = new BuildOutputReaderJob(project, getContainer().getContext(), getContainer().getBuildInfo());
+ readerJob.setPriority(Job.LONG);
+ readerJob.addJobChangeListener(new JobChangeAdapter() {
+ public void done(IJobChangeEvent event) {
+ synchronized (lock) {
+ if (!instance.shell.isDisposed()) {
+ instance.shell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (!instance.shell.isDisposed()) {
+ loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
+ instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
+ }
+ else {
+ loadButtonInitialEnabled = true;
+ }
+ }
+ });
+ }
+ else {
+ loadButtonInitialEnabled = true;
+ }
+ }
+ }
+ });
+ readerJob.schedule();
+ }
- // thread syncronization
- private static Object lock = GCCPerFileSCDProfilePage.class;
- private Shell shell;
- private static GCCPerFileSCDProfilePage instance;
- private static boolean loadButtonInitialEnabled = true;
+ protected boolean handleModifyOpenFileText() {
+ String fileName = getBopOpenFileText();
+ bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
+ fileName.length() > 0 &&
+ (new File(fileName)).exists());
+ return bopLoadButton.getEnabled();
+ }
+
+ protected String getBopOpenFileText() {
+ // from project relative path to absolute path
+ String fileName = bopOpenFileText.getText().trim();
+ if (fileName.length() > 0) {
+ IPath filePath = new Path(fileName);
+ if (!filePath.isAbsolute()) {
+ if (getContainer().getProject() != null) {
+ IPath projectPath = getContainer().getProject().getLocation();
+ filePath = projectPath.append(filePath);
+ fileName = filePath.toString();
+ }
+ }
+ }
+ return fileName;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ protected void setBopOpenFileText(String fileName) {
+ // from absolute path to project relative path
+ if (fileName.length() > 0) {
+ IPath filePath = new Path(fileName);
+ if (filePath.isAbsolute()) {
+ if (getContainer().getProject() != null) {
+ IPath projectPath = getContainer().getProject().getLocation();
+ if (projectPath.isPrefixOf(filePath)) {
+ filePath = filePath.removeFirstSegments(projectPath.segmentCount());
+ filePath = filePath.setDevice(null);
+ fileName = filePath.toString();
+ }
+ }
+ }
+ }
+ bopOpenFileText.setText(fileName);
+ }
+
+ /**
+ * A part of "createControl()" method: creates common widgets
+ * @param parent
+ * @return
*/
public void createControl(Composite parent) {
- Composite page = ControlFactory.createComposite(parent, 1);
-// ((GridData) page.getLayoutData()).grabExcessVerticalSpace = true;
-// ((GridData) page.getLayoutData()).verticalAlignment = GridData.FILL;
-
- // Add the profile UI contribution.
- Group profileGroup = ControlFactory.createGroup(page,
- MakeUIPlugin.getResourceString(PROFILE_GROUP_LABEL), 3);
-
+ Group profileGroup = ControlFactory.createGroup(parent, NewUIMessages.getResourceString(PROFILE_GROUP_LABEL), 3);
GridData gd = (GridData) profileGroup.getLayoutData();
+ gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
-// PixelConverter converter = new PixelConverter(profileGroup);
-// gd.heightHint = converter.convertVerticalDLUsToPixels(DEFAULT_HEIGHT);
((GridLayout) profileGroup.getLayout()).makeColumnsEqualWidth = false;
// Add bop enabled checkbox
- bopEnabledButton = ControlFactory.createCheckBox(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_PARSER_ENABLED_BUTTON));
-// bopEnabledButton.setFont(parent.getFont());
+ bopEnabledButton = ControlFactory.createCheckBox(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_PARSER_ENABLED_BUTTON));
+ bopEnabledButton.setFont(parent.getFont());
((GridData)bopEnabledButton.getLayoutData()).horizontalSpan = 3;
((GridData)bopEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
bopEnabledButton.addSelectionListener(new SelectionAdapter() {
-
public void widgetSelected(SelectionEvent e) {
+ handlebopEnabledButtonPress();
handleModifyOpenFileText();
}
-
});
// load label
- Label loadLabel = ControlFactory.createLabel(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
+ Label loadLabel = ControlFactory.createLabel(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_OPEN_LABEL));
((GridData) loadLabel.getLayoutData()).horizontalSpan = 2;
// load button
- bopLoadButton = ControlFactory.createPushButton(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
- ((GridData) bopLoadButton.getLayoutData()).widthHint =
- SWTUtil.getButtonWidthHint(bopLoadButton);
+ bopLoadButton = ControlFactory.createPushButton(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_LOAD_BUTTON));
+ ((GridData) bopLoadButton.getLayoutData()).widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
bopLoadButton.addSelectionListener(new SelectionAdapter() {
-
public void widgetSelected(SelectionEvent event) {
handleBOPLoadFileButtonSelected();
}
-
});
if (getContainer().getProject() == null) { // project properties
bopLoadButton.setVisible(false);
}
-
// text field
bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
bopOpenFileText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
+ getContainer().getBuildInfo().setBuildOutputFilePath(getBopOpenFileText());
handleModifyOpenFileText();
}
});
bopLoadButton.setEnabled(loadButtonInitialEnabled && handleModifyOpenFileText());
// browse button
- Button browseButton = ControlFactory.createPushButton(profileGroup,
- MakeUIPlugin.getResourceString(BO_PROVIDER_BROWSE_BUTTON));
- ((GridData) browseButton.getLayoutData()).widthHint =
- SWTUtil.getButtonWidthHint(browseButton);
+ Button browseButton = ControlFactory.createPushButton(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_BROWSE_BUTTON));
+ ((GridData) browseButton.getLayoutData()).widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
browseButton.addSelectionListener(new SelectionAdapter() {
-
public void widgetSelected(SelectionEvent event) {
handleBOPBrowseButtonSelected();
}
-
private void handleBOPBrowseButtonSelected() {
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
- dialog.setText(MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_FILE_DIALOG)); //$NON-NLS-1$
+ dialog.setText(NewUIMessages.getResourceString(BO_PROVIDER_OPEN_FILE_DIALOG));
String fileName = getBopOpenFileText();
IPath filterPath;
if (fileName.length() == 0 && getContainer().getProject() != null) {
@@ -158,133 +258,17 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
// variable button
addVariablesButton(profileGroup, bopOpenFileText);
-
- setControl(page);
+
+ createSpecific(profileGroup);
+
+ setControl(profileGroup);
// set the shell variable; must be after setControl
- //lock.acquire();
synchronized (lock) {
shell = getShell();
instance = this;
}
- //lock.release();
- initializeValues();
- }
-
- protected boolean handleModifyOpenFileText() {
- String fileName = getBopOpenFileText();
- bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
- fileName.length() > 0 &&
- (new File(fileName)).exists());
- return bopLoadButton.getEnabled();
- }
-
- private String getBopOpenFileText() {
- // from project relative path to absolute path
- String fileName = bopOpenFileText.getText().trim();
- if (fileName.length() > 0) {
- IPath filePath = new Path(fileName);
- if (!filePath.isAbsolute()) {
- if (getContainer().getProject() != null) {
- IPath projectPath = getContainer().getProject().getLocation();
- filePath = projectPath.append(filePath);
- fileName = filePath.toString();
- }
- }
- }
- return fileName;
- }
-
- private void setBopOpenFileText(String fileName) {
- // from absolute path to project relative path
- if (fileName.length() > 0) {
- IPath filePath = new Path(fileName);
- if (filePath.isAbsolute()) {
- if (getContainer().getProject() != null) {
- IPath projectPath = getContainer().getProject().getLocation();
- if (projectPath.isPrefixOf(filePath)) {
- filePath = filePath.removeFirstSegments(projectPath.segmentCount());
- filePath = filePath.setDevice(null);
- fileName = filePath.toString();
- }
- }
- }
- }
- bopOpenFileText.setText(fileName);
- }
-
- private void initializeValues() {
- bopEnabledButton.setSelection(getContainer().getBuildInfo().isBuildOutputParserEnabled());
- setBopOpenFileText(getContainer().getBuildInfo().getBuildOutputFilePath());
- }
-
- private void handleBOPLoadFileButtonSelected() {
- if (!getContainer().checkDialogForChanges()) return;
- loadButtonInitialEnabled = false;
- bopLoadButton.setEnabled(false);
- // populate buildInfo to be used by the reader job
- populateBuildInfo(getContainer().getBuildInfo());
- IProject project = getContainer().getProject();
- Job readerJob = new BuildOutputReaderJob(project, getContainer().getBuildInfo());
- readerJob.setPriority(Job.LONG);
- readerJob.addJobChangeListener(new JobChangeAdapter() {
-
- public void done(IJobChangeEvent event) {
- //lock.acquire();
- synchronized (lock) {
- if (!instance.shell.isDisposed()) {
- instance.shell.getDisplay().asyncExec(new Runnable() {
-
- public void run() {
- if (!instance.shell.isDisposed()) {
- loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
- instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
- }
- else {
- loadButtonInitialEnabled = true;
- }
- }
-
- });
- }
- else {
- loadButtonInitialEnabled = true;
- }
- }
- //lock.release();
- }
-
- });
- readerJob.schedule();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#isValid()
- */
- protected boolean isValid() {
- return true;
+ // this parameter should be always set.
+ getContainer().getBuildInfo().setBuildOutputFileActionEnabled(true);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#populateBuildInfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
- */
- protected void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
- if (buildInfo != null) {
- buildInfo.setBuildOutputFileActionEnabled(true);
- buildInfo.setBuildOutputFilePath(getBopOpenFileText());
- buildInfo.setBuildOutputParserEnabled(bopEnabledButton.getSelection());
- buildInfo.setProviderOutputParserEnabled(providerId, bopEnabledButton.getSelection());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#restoreFromBuildinfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
- */
- protected void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
- if (buildInfo != null) {
- setBopOpenFileText(buildInfo.getBuildOutputFilePath());
- bopEnabledButton.setSelection(buildInfo.isBuildOutputParserEnabled());
- }
- }
-
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractToolSettingUI.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractToolSettingUI.java
new file mode 100644
index 00000000000..9a139498c0d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractToolSettingUI.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Rational Software 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 Rational Software - Initial API and implementation
+ * Intel corp. 2007 - modification for new CDT model.
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+public abstract class AbstractToolSettingUI extends FieldEditorPreferencePage {
+
+ protected AbstractCBuildPropertyTab buildPropPage;
+ protected IResourceInfo fInfo;
+ private boolean dirty = false;
+
+ /**
+ * @param style
+ */
+ protected AbstractToolSettingUI(IResourceInfo info) {
+ // fix for PR 63973
+ // If we use a grid layout then widgets that should be layed out horizontally,
+ // e.g. StringButtonFieldEditor, will have their component widgets
+ // arranged vertically. This looks terrible when you have for instance
+ // a StringButtonFieldEditor, which has a label, an edit box, and a "modify" button
+ // to the right because all three will be stacked vertically.
+ super(FLAT);
+ // end fix for 63973
+ noDefaultAndApplyButton();
+ fInfo = info;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
+ */
+ protected void createFieldEditors() {
+ // Get the preference store for the build settings
+ IPreferenceStore settings = getToolSettingsPrefStore();
+ setPreferenceStore(settings);
+ }
+
+ /**
+ * Return the tool settings preference store
+ */
+ protected ToolSettingsPrefStore getToolSettingsPrefStore() {
+ return ToolSettingsPrefStore.getDefault();
+ }
+
+ /**
+ * Method called when the value of a dialog field changes
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+ if (event.getProperty().equals(FieldEditor.VALUE)) {
+ setDirty(true);
+ }
+ }
+
+ public void setDirty(boolean b) { dirty = b; }
+ public boolean isDirty() { return dirty; }
+ public void storeSettings() { super.performOk(); }
+
+ public abstract boolean isFor(Object obj1, Object obj2);
+ public abstract void updateFields();
+ public abstract void setValues();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ArtifactTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ArtifactTab.java
new file mode 100644
index 00000000000..ce06ab61eeb
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ArtifactTab.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class ArtifactTab extends AbstractCBuildPropertyTab {
+
+ static final public String PROPERTY = ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID;
+ Text t2, t3;
+ Combo c1;
+ int savedPos = -1; // current project type
+ IConfiguration fCfg;
+ IBuildObjectProperties fProp;
+ IBuildPropertyValue[] values;
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(2, false));
+
+ Label l1 = new Label(usercomp, SWT.NONE);
+ l1.setLayoutData(new GridData(GridData.BEGINNING));
+ l1.setText(Messages.getString("ArtifactTab.0")); //$NON-NLS-1$
+ c1 = new Combo(usercomp, SWT.DROP_DOWN);
+ c1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ c1.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ typeChanged();
+ }});
+
+ Label l2 = new Label(usercomp, SWT.NONE);
+ l2.setLayoutData(new GridData(GridData.BEGINNING));
+ l2.setText(Messages.getString("ArtifactTab.1")); //$NON-NLS-1$
+ t2 = new Text(usercomp, SWT.BORDER);
+ t2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ t2.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ fCfg.setArtifactName(t2.getText());
+ }} );
+ Label l3 = new Label(usercomp, SWT.NONE);
+ l3.setLayoutData(new GridData(GridData.BEGINNING));
+ l3.setText(Messages.getString("ArtifactTab.2")); //$NON-NLS-1$
+ t3 = new Text(usercomp, SWT.BORDER);
+ t3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ t3.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ fCfg.setArtifactExtension(t3.getText());
+ }} );
+
+ updateData(getResDesc());
+ }
+
+ private void typeChanged() {
+ if (fProp == null) return;
+ int n = c1.getSelectionIndex();
+ if (n != savedPos) {
+ savedPos = n;
+ try {
+ fProp.setProperty(PROPERTY, values[n].getId());
+ } catch (CoreException ex) {
+ System.out.println(ex.getMessage());
+ }
+ updateData(getResDesc());
+ }
+ }
+
+ public void updateData(ICResourceDescription cfgd) {
+ if (cfgd == null) return;
+ fCfg = getCfg();
+
+ fProp = fCfg.getBuildProperties();
+ values = fProp.getSupportedValues(PROPERTY);
+ c1.removeAll();
+ c1.setData(values);
+ for (int i=0; i<values.length; i++) {
+ c1.add(values[i].getName());
+ }
+ c1.setText(EMPTY_STR);
+ IBuildProperty pr = fProp.getProperty(PROPERTY);
+ if (pr != null) {
+ String s = pr.getValue().getId();
+ for (int i=0; i<values.length; i++) {
+ if (s.equals(values[i].getId())) {
+ c1.select(i);
+ savedPos = i;
+ break;
+ }
+ }
+ }
+
+ String s = fCfg.getArtifactName();
+ if (s == null || s.trim().length() == 0) {
+ s = getResDesc().getConfiguration().getProjectDescription().getName();
+ getCfg().setArtifactName(s);
+ }
+ t2.setText(s);
+
+ t3.setText(fCfg.getArtifactExtension());
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ IConfiguration cfg1 = getCfg(src.getConfiguration());
+ IConfiguration cfg2 = getCfg(dst.getConfiguration());
+ cfg2.setArtifactName(cfg1.getArtifactName());
+ cfg2.setArtifactExtension(cfg1.getArtifactExtension());
+ try {
+ IBuildProperty bp = cfg1.getBuildProperties().getProperty(PROPERTY);
+ if (bp != null) {
+ IBuildPropertyValue bv = bp.getValue();
+ if (bv != null) {
+ String s = bv.getId();
+ cfg2.getBuildProperties().setProperty(PROPERTY, s);
+ }
+ }
+ } catch (CoreException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ public void performDefaults() {
+ IConfiguration cfg = getCfg();
+ cfg.setArtifactName(cfg.getManagedProject().getDefaultArtifactName());
+ cfg.setArtifactExtension(null);
+ updateData(getResDesc());
+ }
+
+ public boolean canBeVisible() {
+ if (page.isForProject())
+ return getCfg().getBuilder().isManagedBuildOn();
+ else
+ return false;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildOptionComboFieldEditor.java
index 205f2cae63e..1c66553b5c9 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildOptionComboFieldEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * Copyright (c) 2002, 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
@@ -9,7 +9,7 @@
* IBM Rational Software - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.preference.FieldEditor;
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildOptionSettingsUI.java
index 41e62ca1fa1..893ff9f313d 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildOptionSettingsUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -9,7 +9,7 @@
* IBM Rational Software - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.util.Collection;
import java.util.HashMap;
@@ -27,6 +27,7 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor;
@@ -37,33 +38,21 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
-public class BuildOptionSettingsPage extends BuildSettingsPage {
+public class BuildOptionSettingsUI extends AbstractToolSettingUI {
private Map fieldsMap = new HashMap();
- private IOptionCategory clonedCategory;
+ private IOptionCategory category;
private IHoldsOptions optionHolder;
- private boolean isItResourceConfigPage;
private Map fieldEditorsToParentMap = new HashMap();
- private AbstractBuildPropertyPage buildPropPage;
- public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
- IConfiguration clonedConfig, IHoldsOptions optionHolder, IOptionCategory clonedCategory) {
- // Cache the configuration and option category this page is created for
- super(clonedConfig);
- this.clonedCategory = clonedCategory;
+ public BuildOptionSettingsUI(AbstractCBuildPropertyTab page,
+ IResourceInfo info, IHoldsOptions optionHolder,
+ IOptionCategory _category) {
+ super(info);
+ this.category = _category;
this.optionHolder = optionHolder;
- isItResourceConfigPage = false;
buildPropPage = page;
}
- public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
- IResourceConfiguration clonedResConfig, IHoldsOptions optionHolder, IOptionCategory clonedCategory) {
- // Cache the configuration and option category this page is created for
- super(clonedResConfig);
- this.clonedCategory = clonedCategory;
- this.optionHolder = optionHolder;
- isItResourceConfigPage = true;
- buildPropPage = page;
- }
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#computeSize()
*/
@@ -79,31 +68,18 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
super.createFieldEditors();
// Iterate over the options in the category and create a field editor
// for each
- Object[][] options;
- if ( isItResourceConfigPage ) {
- options = clonedCategory.getOptions(clonedResConfig, optionHolder);
- } else {
- options = clonedCategory.getOptions(clonedConfig, optionHolder);
- }
+ Object[][] options = category.getOptions(fInfo.getParent(), optionHolder);
for (int index = 0; index < options.length; ++index) {
// Get the option
IHoldsOptions holder = (IHoldsOptions)options[index][0];
if (holder == null) break; // The array may not be full
IOption opt = (IOption)options[index][1];
- String prefName = getToolSettingsPreferenceStore().getOptionPrefName(opt);
-
+ String prefName = opt.getName();
// check to see if the option has an applicability calculator
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
-
- // is the option visible?
- IBuildObject config;
- if ( isItResourceConfigPage ) {
- config = clonedResConfig;
- } else {
- config = clonedConfig;
- }
+ IBuildObject config = fInfo;
if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) {
@@ -180,7 +156,12 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.STRING_LIST:
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
- case IOption.OBJECTS: {
+ case IOption.OBJECTS:
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
+ {
fieldEditor = new FileListControlFieldEditor(prefName, opt.getName(), opt.getToolTip(), fieldEditorParent, opt.getBrowseType());
} break;
@@ -207,9 +188,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
* @param category
* @return
*/
- public boolean isForCategory(IHoldsOptions optionHolder, IOptionCategory category) {
- if (category != null) {
- if (this.optionHolder == optionHolder && category.equals(this.clonedCategory))
+ public boolean isFor(Object holder, Object cat) {
+ if (holder instanceof IHoldsOptions && cat != null && cat instanceof IOptionCategory) {
+ if (this.optionHolder == optionHolder && cat.equals(this.category))
return true;
}
return false;
@@ -228,28 +209,19 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
IConfiguration realCfg = null;
IBuildObject handler = null;
- if (isItResourceConfigPage){
- realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig);
- if(realRcCfg == null)
- return false;
- handler = realRcCfg;
- clonedOptions = clonedCategory.getOptions(clonedResConfig, optionHolder);
- } else {
- realCfg = buildPropPage.getRealConfig(clonedConfig);
- if(realCfg == null)
- return false;
- handler = realCfg;
- clonedOptions = clonedCategory.getOptions(clonedConfig, optionHolder);
- }
+ realCfg = buildPropPage.getCfg(); //.getRealConfig(clonedConfig);
+ if(realCfg == null) return false;
+ handler = realCfg;
+ clonedOptions = category.getOptions(fInfo.getParent(), optionHolder);
for (int i = 0; i < clonedOptions.length; i++) {
IHoldsOptions clonedHolder = (IHoldsOptions)clonedOptions[i][0];
if (clonedHolder == null) break; // The array may not be full
IOption clonedOption = (IOption)clonedOptions[i][1];
- IHoldsOptions realHolder = buildPropPage.getRealHoldsOptions(clonedHolder);
+ IHoldsOptions realHolder = clonedHolder; // buildPropPage.getRealHoldsOptions(clonedHolder);
if(realHolder == null) continue;
- IOption realOption = buildPropPage.getRealOption(clonedOption, clonedHolder);
+ IOption realOption = clonedOption; // buildPropPage.getRealOption(clonedOption, clonedHolder);
if(realOption == null) continue;
try {
@@ -258,14 +230,10 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
switch (clonedOption.getValueType()) {
case IOption.BOOLEAN :
boolean boolVal = clonedOption.getBooleanValue();
- if(isItResourceConfigPage) {
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, boolVal);
- } else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, boolVal);
- }
+ setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, boolVal);
// Reset the preference store since the Id may have changed
// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
+// getToolSettingsPrefStore().setValue(setOption.getId(), boolVal);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
// }
@@ -273,31 +241,21 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.ENUMERATED :
String enumVal = clonedOption.getStringValue();
String enumId = clonedOption.getEnumeratedId(enumVal);
- if(isItResourceConfigPage) {
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption,
- (enumId != null && enumId.length() > 0) ? enumId : enumVal);
- } else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption,
- (enumId != null && enumId.length() > 0) ? enumId : enumVal);
- }
+ setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption,
+ (enumId != null && enumId.length() > 0) ? enumId : enumVal);
// Reset the preference store since the Id may have changed
// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
+// getToolSettingsPrefStore().setValue(setOption.getId(), enumVal);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
-// }
+// }
break;
case IOption.STRING :
String strVal = clonedOption.getStringValue();
- if(isItResourceConfigPage){
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, strVal);
- } else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, strVal);
- }
-
+ setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, strVal);
// Reset the preference store since the Id may have changed
// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
+// getToolSettingsPrefStore().setValue(setOption.getId(), strVal);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
// }
@@ -307,16 +265,16 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.PREPROCESSOR_SYMBOLS :
case IOption.LIBRARIES :
case IOption.OBJECTS :
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]);
- if( isItResourceConfigPage){
- setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, listVal);
- }else {
- setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, listVal);
- }
+ setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, listVal);
// Reset the preference store since the Id may have changed
// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
+// getToolSettingsPrefStore().setValue(setOption.getId(), listStr);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
// }
@@ -330,7 +288,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
if (setOption == null)
setOption = realOption;
-/* if (setOption.getValueHandler().handleValue(
+ if (setOption.getValueHandler().handleValue(
handler,
setOption.getOptionHolder(),
setOption,
@@ -341,7 +299,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
} else {
// Event handling Failed.
}
-*/
+
} catch (BuildException e) {
} catch (ClassCastException e) {
}
@@ -355,13 +313,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
* Update field editors in this page when the page is loaded.
*/
public void updateFields() {
- Object[][] options;
- if (isItResourceConfigPage) {
- options = clonedCategory.getOptions(clonedResConfig, optionHolder);
- } else {
- options = clonedCategory.getOptions(clonedConfig, optionHolder);
- }
-
+ Object[][] options = category.getOptions(fInfo.getParent(), optionHolder);
// some option has changed on this page... update enabled/disabled state for all options
for (int index = 0; index < options.length; ++index) {
@@ -370,7 +322,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
if (holder == null)
break; // The array may not be full
IOption opt = (IOption) options[index][1];
- String prefName = getToolSettingsPreferenceStore().getOptionPrefName(opt);
+ String prefName = getToolSettingsPrefStore().getOptionPrefName(opt);
// is the option on this page?
@@ -391,32 +343,17 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
Iterator iter = fieldsList.iterator();
while (iter.hasNext()) {
FieldEditor editor = (FieldEditor) iter.next();
- // TODO: Why was loadDefault called before load? It results in String fields
- // setting the "dirty" flag
- //editor.loadDefault();
editor.load();
}
}
- /**
- * saves all field editors
- */
- public void storeSettings() {
-// super.performOk();
- }
-
private void setFieldEditorEnablement(IHoldsOptions holder, IOption option,
IOptionApplicability optionApplicability, FieldEditor fieldEditor, Composite parent) {
if (optionApplicability == null)
return;
// if the option is not enabled then disable it
- IBuildObject config;
- if ( isItResourceConfigPage ) {
- config = clonedResConfig;
- } else {
- config = clonedConfig;
- }
+ IBuildObject config = fInfo;
if (!optionApplicability.isOptionEnabled(config, holder, option )) {
fieldEditor.setEnabled(false, parent);
} else {
@@ -442,7 +379,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
id = fe.getPreferenceName();
- Object option[] = this.getToolSettingsPreferenceStore().getOption(id);
+ Object option[] = this.getToolSettingsPrefStore().getOption(id);
if(option != null){
changedOption = (IOption)option[1];
@@ -452,44 +389,21 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.STRING:
if(fe instanceof StringFieldEditor){
String val = ((StringFieldEditor)fe).getStringValue();
- if (isItResourceConfigPage) {
- newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,val);
-// newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
- } else {
- newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,val);
-// newOption = clonedConfig.setOption(changedHolder,changedOption,val);
- }
+ newOption = ManagedBuildManager.setOption(fInfo,changedHolder,changedOption,val);
}
break;
case IOption.BOOLEAN:
if(fe instanceof BooleanFieldEditor){
boolean val = ((BooleanFieldEditor)fe).getBooleanValue();
- if (isItResourceConfigPage) {
- newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,val);
-// newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
- } else {
- newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,val);
-// newOption = clonedConfig.setOption(changedHolder,changedOption,val);
- }
+ newOption = ManagedBuildManager.setOption(fInfo,changedHolder,changedOption,val);
}
break;
case IOption.ENUMERATED:
if(fe instanceof BuildOptionComboFieldEditor){
String name = ((BuildOptionComboFieldEditor)fe).getSelection();
String enumId = changedOption.getEnumeratedId(name);
- if(isItResourceConfigPage) {
- newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,
- (enumId != null && enumId.length() > 0) ? enumId : name);
-
-// newOption = clonedResConfig.setOption(changedHolder, changedOption,
-// (enumId != null && enumId.length() > 0) ? enumId : name);
- } else {
- newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,
- (enumId != null && enumId.length() > 0) ? enumId : name);
-
-// newOption = clonedConfig.setOption(changedHolder, changedOption,
-// (enumId != null && enumId.length() > 0) ? enumId : name);
- }
+ newOption = ManagedBuildManager.setOption(fInfo,changedHolder,changedOption,
+ (enumId != null && enumId.length() > 0) ? enumId : name);
}
break;
@@ -498,34 +412,24 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
case IOption.OBJECTS:
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
if(fe instanceof FileListControlFieldEditor){
String val[] =((FileListControlFieldEditor)fe).getStringListValue();
- if (isItResourceConfigPage) {
- newOption = ManagedBuildManager.setOption(clonedResConfig,changedHolder,changedOption,val);
-// newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
- } else {
- newOption = ManagedBuildManager.setOption(clonedConfig,changedHolder,changedOption,val);
-// newOption = clonedConfig.setOption(changedHolder,changedOption,val);
- }
+ newOption = ManagedBuildManager.setOption(fInfo, changedHolder, changedOption, val);
}
break;
default:
break;
-
}
} catch (BuildException e) {
}
-
}
}
-
- Object[][] options;
- if (isItResourceConfigPage) {
- options = clonedCategory.getOptions(clonedResConfig, optionHolder);
- } else {
- options = clonedCategory.getOptions(clonedConfig, optionHolder);
- }
+ Object[][] options = category.getOptions(fInfo.getParent(), optionHolder);
// some option has changed on this page... update enabled/disabled state for all options
@@ -535,7 +439,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
if (holder == null)
break; // The array may not be full
IOption opt = (IOption) options[index][1];
- String prefName = getToolSettingsPreferenceStore().getOptionPrefName(opt);
+ String prefName = getToolSettingsPrefStore().getOptionPrefName(opt);
// is the option on this page?
@@ -560,5 +464,10 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
}
}
+
+ public void setValues() {
+ updateFields();
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildStepsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildStepsTab.java
new file mode 100644
index 00000000000..7166c4b1ba6
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildStepsTab.java
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+
+
+public class BuildStepsTab extends AbstractCBuildPropertyTab {
+ Combo combo;
+ Text preCmd;
+ Text preDes;
+ Text postCmd;
+ Text postDes;
+ ITool tool;
+ IConfiguration config;
+ ICResourceDescription cfgdescr;
+ IFileInfo rcfg;
+
+ private static final String label1 = Messages.getString("BuildStepsTab.0"); //$NON-NLS-1$
+ private static final String label2 = Messages.getString("BuildStepsTab.1"); //$NON-NLS-1$
+ private static final String PATH_SEPERATOR = ";"; //$NON-NLS-1$
+ private static final String rcbsToolId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs"); //$NON-NLS-1$
+ private static final String rcbsToolName = new String("Resource Custom Build Step"); //$NON-NLS-1$
+ private static final String rcbsToolInputTypeId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype"); //$NON-NLS-1$
+ private static final String rcbsToolInputTypeName = new String("Resource Custom Build Step Input Type"); //$NON-NLS-1$
+ private static final String rcbsToolOutputTypeId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype"); //$NON-NLS-1$
+ private static final String rcbsToolOutputTypeName = new String("Resource Custom Build Step Output Type"); //$NON-NLS-1$
+
+ private static final String PREFIX = "ResourceCustomBuildStepBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String RCBS_APPLICABILITY = LABEL + ".applicability"; //$NON-NLS-1$
+ private static final String RCBS_BEFORE = LABEL + ".applicability.rule.before"; //$NON-NLS-1$
+ private static final String RCBS_AFTER = LABEL + ".applicability.rule.after"; //$NON-NLS-1$
+ private static final String RCBS_OVERRIDE = LABEL + ".applicability.rule.override"; //$NON-NLS-1$
+ private static final String RCBS_DISABLE = LABEL + ".applicability.rule.disable"; //$NON-NLS-1$
+
+ private static final String[] rcbsApplicabilityRules = {
+ new String(NewUIMessages.getResourceString(RCBS_OVERRIDE)),
+// new String(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE)),
+// new String(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER)),
+ new String(NewUIMessages.getResourceString(RCBS_DISABLE)),
+ };
+
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(1, false));
+
+ if (page.isForProject())
+ createForProject();
+ else
+ createForFile();
+ }
+
+ /**
+ *
+ */
+ private void createForProject() {
+ Group g1 = setupGroup (usercomp, Messages.getString("BuildStepsTab.2"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ setupLabel(g1, label1, 1, GridData.BEGINNING);
+ preCmd = setupText(g1, 1, GridData.FILL_HORIZONTAL);
+ preCmd.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getCfg().setPrebuildStep(preCmd.getText());
+ }});
+
+ setupLabel(g1, label2, 1, GridData.BEGINNING);
+ preDes = setupText(g1, 1, GridData.FILL_HORIZONTAL);
+ preDes.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getCfg().setPreannouncebuildStep(preDes.getText());
+ }});
+
+ Group g2 = setupGroup (usercomp, Messages.getString("BuildStepsTab.3"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ setupLabel(g2, label1, 1, GridData.BEGINNING);
+ postCmd = setupText(g2, 1, GridData.FILL_HORIZONTAL);
+ postCmd.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getCfg().setPostbuildStep(postCmd.getText());
+ }});
+
+ setupLabel(g2, label2, 1, GridData.BEGINNING);
+ postDes = setupText(g2, 1, GridData.FILL_HORIZONTAL);
+ postDes.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getCfg().setPostannouncebuildStep(postDes.getText());
+ }});
+ }
+
+ /**
+ *
+ */
+ private void createForFile() {
+ Group g1 = setupGroup (usercomp, Messages.getString("BuildStepsTab.4"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ setupLabel(g1, NewUIMessages.getResourceString(RCBS_APPLICABILITY), 1, GridData.BEGINNING);
+
+ combo = new Combo(g1, SWT.BORDER);
+ combo.setItems(rcbsApplicabilityRules);
+ combo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ rcfg.setRcbsApplicability(sel2app(combo.getSelectionIndex()));
+ }});
+
+ setupLabel(g1, Messages.getString("BuildStepsTab.5"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ preCmd = setupText(g1, 1, GridData.FILL_HORIZONTAL);
+ preCmd.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (page.isForProject())
+ getCfg().setPrebuildStep(preCmd.getText());
+ else {
+ IInputType[] ein = tool.getInputTypes();
+ if (ein != null && ein.length > 0) {
+ IAdditionalInput[] add = ein[0].getAdditionalInputs();
+ if (add != null && add.length > 0) {
+ add[0].setPaths(preCmd.getText());
+ }
+ }
+ }
+ }});
+
+ setupLabel(g1, Messages.getString("BuildStepsTab.6"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ preDes = setupText(g1, 1, GridData.FILL_HORIZONTAL);
+ preDes.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (page.isForProject())
+ getCfg().setPreannouncebuildStep(preDes.getText());
+ else {
+ IOutputType[] out = tool.getOutputTypes();
+ if (valid(out))
+ out[0].setOutputNames(preDes.getText());
+ }
+ }});
+
+ setupLabel(g1, label1, 1, GridData.BEGINNING);
+ postCmd = setupText(g1, 1, GridData.FILL_HORIZONTAL);
+ postCmd.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (page.isForProject())
+ getCfg().setPostbuildStep(postCmd.getText());
+ else
+ tool.setToolCommand(postCmd.getText());
+ }});
+
+ setupLabel(g1, label2, 1, GridData.BEGINNING);
+ postDes = setupText(g1, 1, GridData.FILL_HORIZONTAL);
+ postDes.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (page.isForProject())
+ getCfg().setPostannouncebuildStep(postDes.getText());
+ else
+ tool.setAnnouncement(postDes.getText());
+ }});
+ }
+
+ public void updateData(ICResourceDescription cfgd) {
+ if (cfgd == null) return;
+ config = getCfg(cfgd.getConfiguration());
+ cfgdescr = cfgd;
+ update();
+ }
+
+ private void update() {
+ if (page.isForProject()) {
+ preCmd.setText(config.getPrebuildStep());
+ preDes.setText(config.getPreannouncebuildStep());
+ postCmd.setText(config.getPostbuildStep());
+ postDes.setText(config.getPostannouncebuildStep());
+ } else {
+ rcfg = (IFileInfo)getResCfg(cfgdescr);
+ combo.select(app2sel(rcfg.getRcbsApplicability()));
+ tool = getRcbsTool(rcfg);
+
+ if(tool != null){
+ String s = EMPTY_STR;
+ IInputType[] tmp = tool.getInputTypes();
+ if (tmp != null && tmp.length > 0) {
+ IAdditionalInput[] add = tmp[0].getAdditionalInputs();
+ if (add != null && add.length > 0)
+ s = createList(add[0].getPaths());
+ }
+ preCmd.setText(s);
+ s = Messages.getString("BuildStepsTab.7"); //$NON-NLS-1$
+ IOutputType[] tmp2 = tool.getOutputTypes();
+ if (tmp2 != null && tmp2.length > 0) {
+ s = createList(tmp2[0].getOutputNames());
+ }
+ preDes.setText(s);
+ postCmd.setText(tool.getToolCommand());
+ postDes.setText(tool.getAnnouncement());
+ } else {
+ preCmd.setText(EMPTY_STR);
+ preDes.setText(EMPTY_STR);
+ postCmd.setText(EMPTY_STR);
+ postDes.setText(EMPTY_STR);
+ }
+ }
+ }
+
+ private ITool getRcbsTool(IFileInfo rcConfig){
+ ITool rcbsTools[] = getRcbsTools(rcConfig);
+ ITool rcbsTool = null;
+
+ if(rcbsTools != null)
+ rcbsTool = rcbsTools[0];
+ else {
+ rcbsTool = rcConfig.createTool(null,rcbsToolId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolName,false); //$NON-NLS-1$
+ rcbsTool.setCustomBuildStep(true);
+ IInputType rcbsToolInputType = rcbsTool.createInputType(null,rcbsToolInputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolInputTypeName,false); //$NON-NLS-1$
+ IAdditionalInput rcbsToolInputTypeAdditionalInput = rcbsToolInputType.createAdditionalInput(new String());
+ rcbsToolInputTypeAdditionalInput.setKind(IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY);
+ rcbsTool.createOutputType(null,rcbsToolOutputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolOutputTypeName,false); //$NON-NLS-1$
+ }
+ return rcbsTool;
+ }
+
+ private ITool[] getRcbsTools(IResourceInfo rcConfig){
+ List list = new ArrayList();
+ ITool tools[] = rcConfig.getTools();
+
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ if (tool.getCustomBuildStep() && !tool.isExtensionElement()) {
+ list.add(tool);
+ }
+ }
+ if(list.size() != 0) {
+ return (ITool[])list.toArray(new ITool[list.size()]);
+ }
+ return null;
+ }
+
+ private String createList(String[] items) {
+ if(items == null)
+ return new String();
+
+ StringBuffer path = new StringBuffer(EMPTY_STR);
+
+ for (int i = 0; i < items.length; i++) {
+ path.append(items[i]);
+ if (i < (items.length - 1)) {
+ path.append(PATH_SEPERATOR);
+ }
+ }
+ return path.toString();
+ }
+
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ if (page.isForProject()) {
+ IConfiguration cfg1 = getCfg(src.getConfiguration());
+ IConfiguration cfg2 = getCfg(dst.getConfiguration());
+ cfg2.setPrebuildStep(cfg1.getPrebuildStep());
+ cfg2.setPreannouncebuildStep(cfg1.getPreannouncebuildStep());
+ cfg2.setPostbuildStep(cfg1.getPostbuildStep());
+ cfg2.setPostannouncebuildStep(cfg1.getPostannouncebuildStep());
+ } else {
+ IFileInfo rcfg1 = (IFileInfo)getResCfg(src);
+ IFileInfo rcfg2 = (IFileInfo)getResCfg(dst);
+ rcfg2.setRcbsApplicability(rcfg1.getRcbsApplicability());
+ ITool tool1 = getRcbsTool(rcfg1);
+ ITool tool2 = getRcbsTool(rcfg2);
+
+ IInputType[] ein1 = tool1.getInputTypes();
+ IInputType[] ein2 = tool2.getInputTypes();
+ if (valid(ein1) && valid(ein2)) {
+ IAdditionalInput[] add1 = ein1[0].getAdditionalInputs();
+ IAdditionalInput[] add2 = ein2[0].getAdditionalInputs();
+ if (valid(add1) && valid(add2)) {
+// if (add1 != null && add2 != null && add1.length > 0 && add2.length > 0) {
+ add2[0].setPaths(createList(add1[0].getPaths()));
+ }
+ }
+ IOutputType[] tmp1 = tool1.getOutputTypes();
+ IOutputType[] tmp2 = tool2.getOutputTypes();
+// if (tmp1 != null && tmp2 != null && tmp1.length > 0 && tmp2.length > 0) {
+ if (valid(tmp1) && valid(tmp2)) {
+ tmp2[0].setOutputNames(createList(tmp1[0].getOutputNames()));
+ }
+ tool2.setToolCommand(tool1.getToolCommand());
+ tool2.setAnnouncement(tool1.getAnnouncement());
+ }
+ }
+
+ private int sel2app(int index){
+ String sel = combo.getItem(index);
+ if(NewUIMessages.getResourceString(RCBS_OVERRIDE).equals(sel)){
+ return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE;
+ } else if(NewUIMessages.getResourceString(RCBS_AFTER).equals(sel)){
+ return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER;
+ } else if(NewUIMessages.getResourceString(RCBS_BEFORE).equals(sel)){
+ return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE;
+ }
+ return IResourceConfiguration.KIND_DISABLE_RCBS_TOOL;
+ }
+
+ private boolean valid(Object[] arr) { return (arr != null && arr.length > 0); }
+
+ private int app2sel(int val){
+ switch(val){
+ case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER:
+ return combo.indexOf(NewUIMessages.getResourceString(RCBS_AFTER));
+ case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE:
+ return combo.indexOf(NewUIMessages.getResourceString(RCBS_BEFORE));
+ case IResourceConfiguration.KIND_DISABLE_RCBS_TOOL:
+ return combo.indexOf(NewUIMessages.getResourceString(RCBS_DISABLE));
+ case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE:
+ default:
+ return combo.indexOf(NewUIMessages.getResourceString(RCBS_OVERRIDE));
+ }
+ }
+
+
+ // This page can be displayed for managed project only
+ public boolean canBeVisible() {
+ if (page.isForProject() || page.isForFile())
+ return getCfg().getBuilder().isManagedBuildOn();
+ else
+ return false;
+ }
+
+ protected void performDefaults() {
+ if (page.isForProject()) {
+ config.setPrebuildStep(null);
+ config.setPreannouncebuildStep(null);
+ config.setPostbuildStep(null);
+ config.setPostannouncebuildStep(null);
+ } else {
+ rcfg.setRcbsApplicability(IResourceConfiguration.KIND_DISABLE_RCBS_TOOL);
+ ITool tool = getRcbsTool(rcfg);
+ IInputType[] ein = tool.getInputTypes();
+ if (valid(ein)) {
+ IAdditionalInput[] add = ein[0].getAdditionalInputs();
+ if (valid(add)) add[0].setPaths(null);
+ }
+ IOutputType[] tmp = tool.getOutputTypes();
+ if (valid(tmp)) tmp[0].setOutputNames(null);
+ tool.setToolCommand(null);
+ tool.setAnnouncement(null);
+ }
+ update();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildToolSettingUI.java
index 11fed1d23b5..9abe6a38696 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuildToolSettingUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.util.ArrayList;
import java.util.Arrays;
@@ -20,13 +20,11 @@ import java.util.Vector;
import org.eclipse.cdt.internal.ui.util.PixelConverter;
import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.cdt.ui.newui.MultiLineTextFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -36,13 +34,11 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-public class BuildToolSettingsPage extends BuildSettingsPage {
+public class BuildToolSettingUI extends AbstractToolSettingUI {
// Label class for a preference page.
class LabelFieldEditor extends FieldEditor {
-
private String fTitle;
-
private Label fTitleLabel;
public LabelFieldEditor( Composite parent, String title ) {
@@ -64,27 +60,19 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
fTitleLabel.setLayoutData( gd );
}
- public int getNumberOfControls() {
- return 1;
- }
-
+ public int getNumberOfControls() { return 1; }
/**
* The label field editor is only used to present a text label on a preference page.
*/
- protected void doLoad() {
- }
-
- protected void doLoadDefault() {
- }
-
- protected void doStore() {
- }
+ protected void doLoad() {}
+ protected void doLoadDefault() {}
+ protected void doStore() {}
}
// Data members
// all build options field editor label
- private static final String ALL_OPTIONS = ManagedBuilderUIMessages.getResourceString("BuildToolSettingsPage.alloptions"); //$NON-NLS-1$
+ private static final String ALL_OPTIONS = NewUIMessages.getResourceString("BuildToolSettingsPage.alloptions"); //$NON-NLS-1$
// Field editor label for tool command
private static final String COMMAND = "BuildToolSettingsPage.tool.command"; //$NON-NLS-1$
// Advanced settings label
@@ -108,35 +96,23 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// Map that holds all string options and its values
private HashMap stringOptionsMap;
- private ITool clonedTool;
+ private ITool fTool;
// Map that holds all user object options and its values
private HashMap userObjsMap;
- private boolean isItResourceConfigPage;
-
- private AbstractBuildPropertyPage buildPropPage;
+ private AbstractCBuildPropertyTab buildPropPage;
- public BuildToolSettingsPage(AbstractBuildPropertyPage page,
- IConfiguration clonedCfg, ITool clonedTool) {
+ public BuildToolSettingUI(AbstractCBuildPropertyTab page,
+ IResourceInfo info, ITool _tool) {
// Cache the configuration and tool this page is for
- super(clonedCfg);
- this.clonedTool = clonedTool;
+ //TODO: SHIT
+ super(info);
+ this.fTool = _tool;
buildPropPage = page;
stringOptionsMap = new HashMap();
userObjsMap = new HashMap();
- isItResourceConfigPage = false;
}
- public BuildToolSettingsPage(AbstractBuildPropertyPage page,
- IResourceConfiguration clonedRcCfg, ITool clonedTool) {
- // Cache the configuration and tool this page is for
- super(clonedRcCfg);
- this.clonedTool = clonedTool;
- buildPropPage = page;
- stringOptionsMap = new HashMap();
- userObjsMap = new HashMap();
- isItResourceConfigPage = true;
- }
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#computeSize()
*/
@@ -150,13 +126,14 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
protected void createFieldEditors() {
+
// Load up the preference store
super.createFieldEditors();
// Add a string editor to edit the tool command
Composite parent = getFieldEditorParent();
PixelConverter converter = new PixelConverter(parent);
- commandStringField = new StringFieldEditor(clonedTool.getId(),
- ManagedBuilderUIMessages.getResourceString(COMMAND),
+ commandStringField = new StringFieldEditor(fTool.getId(),
+ NewUIMessages.getResourceString(COMMAND),
parent);
commandStringField.setEmptyStringAllowed(false);
GridData gd = ((GridData)commandStringField.getTextControl(parent).getLayoutData());
@@ -164,10 +141,11 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
gd.minimumWidth = converter.convertWidthInCharsToPixels(3);
addField(commandStringField);
// Add a field editor that displays overall build options
- allOptionFieldEditor = new MultiLineTextFieldEditor(BuildToolSettingsPreferenceStore.ALL_OPTIONS_ID,
- ALL_OPTIONS, getFieldEditorParent());
- allOptionFieldEditor.getTextControl().setEditable(false);
- gd = ((GridData)allOptionFieldEditor.getTextControl().getLayoutData());
+ Composite par = getFieldEditorParent();
+ allOptionFieldEditor = new MultiLineTextFieldEditor(ToolSettingsPrefStore.ALL_OPTIONS_ID,
+ ALL_OPTIONS, par);
+ allOptionFieldEditor.getTextControl(par).setEditable(false);
+// gd = ((GridData)allOptionFieldEditor.getTextControl().getLayoutData());
gd.grabExcessHorizontalSpace = true;
gd.minimumWidth = converter.convertWidthInCharsToPixels(20);
addField(allOptionFieldEditor);
@@ -181,12 +159,12 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
*/
private void createAdvancedSettingsGroup(PixelConverter converter) {
addField( createLabelEditor( getFieldEditorParent(), WHITESPACE ) ); //$NON-NLS-1$
- addField( createLabelEditor( getFieldEditorParent(), ManagedBuilderUIMessages.getResourceString(ADVANCED_GROUP) ) );
+ addField( createLabelEditor( getFieldEditorParent(), NewUIMessages.getResourceString(ADVANCED_GROUP) ) );
// Add a string editor to edit the tool command line pattern
Composite parent = getFieldEditorParent();
- commandLinePatternField = new StringFieldEditor(BuildToolSettingsPreferenceStore.COMMAND_LINE_PATTERN_ID,
- ManagedBuilderUIMessages.getResourceString(COMMAND_LINE_PATTERN),
+ commandLinePatternField = new StringFieldEditor(ToolSettingsPrefStore.COMMAND_LINE_PATTERN_ID,
+ NewUIMessages.getResourceString(COMMAND_LINE_PATTERN),
parent);
GridData gd = ((GridData)commandLinePatternField.getTextControl(parent).getLayoutData());
gd.grabExcessHorizontalSpace = true;
@@ -285,9 +263,9 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
* @param tool
* @return
*/
- public boolean isForTool(ITool tool) {
- if (tool != null) {
- return tool.equals(this.clonedTool);
+ public boolean isFor(Object tool, Object unused) {
+ if (tool != null && tool instanceof ITool && unused == null) {
+ return tool.equals(fTool);
}
return false;
}
@@ -298,7 +276,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
*/
public void parseAllOptions() {
// Get the all build options string from all options field
- String alloptions = getToolSettingsPreferenceStore().getString(BuildToolSettingsPreferenceStore.ALL_OPTIONS_ID);
+ String alloptions = getToolSettingsPrefStore().getString(ToolSettingsPrefStore.ALL_OPTIONS_ID);
// list that holds the options for the option type other than
// boolean,string and enumerated
List optionsList = new ArrayList();
@@ -311,7 +289,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
String optionValue = (String)optIter.next();
boolean optionValueExist = false;
// get the options for this tool
- IOption[] options = clonedTool.getOptions();
+ IOption[] options = fTool.getOptions();
for (int k = 0; k < options.length; ++k) {
IOption opt = options[k];
//String name = opt.getId();
@@ -365,6 +343,10 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
case IOption.INCLUDE_PATH :
case IOption.PREPROCESSOR_SYMBOLS :
case IOption.LIBRARIES :
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
if (opt.getCommand() != null
&& optionValue.startsWith(opt
.getCommand())) {
@@ -425,7 +407,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
}
// Now update the preference store with parsed options
// Get the options for this tool
- IOption[] options = clonedTool.getOptions();
+ IOption[] options = fTool.getOptions();
for (int k = 0; k < options.length; ++k) {
IOption opt = options[k];
//String name = opt.getId();
@@ -490,32 +472,20 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
protected void setOption(IOption option, boolean value){
try{
- if(isItResourceConfigPage)
- clonedResConfig.setOption(clonedTool,option,value);
- else
- clonedConfig.setOption(clonedTool,option,value);
- } catch (BuildException e){
- }
+ fInfo.setOption(fTool,option,value);
+ } catch (BuildException e){}
}
protected void setOption(IOption option, String value){
- try{
- if(isItResourceConfigPage)
- clonedResConfig.setOption(clonedTool,option,value);
- else
- clonedConfig.setOption(clonedTool,option,value);
- } catch (BuildException e){
- }
+ try{
+ fInfo.setOption(fTool,option,value);
+ } catch (BuildException e){}
}
protected void setOption(IOption option, String value[]){
try{
- if(isItResourceConfigPage)
- clonedResConfig.setOption(clonedTool,option,value);
- else
- clonedConfig.setOption(clonedTool,option,value);
- } catch (BuildException e){
- }
+ fInfo.setOption(fTool,option,value);
+ } catch (BuildException e){ }
}
/* (non-Javadoc)
@@ -524,33 +494,14 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
public boolean performOk() {
// Do the super-class thang
boolean result = super.performOk();
-
+ /*
//parse and store all build options in the corresponding preference store
//parseAllOptions();
// Write the preference store values back to the build model
- IOptionCategory clonedCategory = (IOptionCategory)clonedTool;
- ITool tool = buildPropPage.getRealTool(clonedTool);
- if(tool == null)
- return false;
+ IOptionCategory clonedCategory = (IOptionCategory)fTool;
Object[][] clonedOptions;
- IResourceConfiguration realRcCfg = null;
- IConfiguration realCfg = null;
-// IBuildObject handler = null;
-
- if (isItResourceConfigPage){
- realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig);
- if(realRcCfg == null)
- return false;
-// handler = realRcCfg;
- clonedOptions = clonedCategory.getOptions(clonedResConfig, clonedTool);
- } else {
- realCfg = buildPropPage.getRealConfig(clonedConfig);
- if(realCfg == null)
- return false;
-// handler = realCfg;
- clonedOptions = clonedCategory.getOptions(clonedConfig, clonedTool);
- }
+ clonedOptions = clonedCategory.getOptions(cfg, clonedTool);
if ( clonedOptions == null)
return true;
@@ -560,40 +511,34 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
if (clonedTool == null) break; // The array may not be full
IOption clonedOption = (IOption)clonedOptions[i][1];
- ITool realTool = buildPropPage.getRealTool(clonedTool);
- if(realTool == null) continue;
- IOption realOption = buildPropPage.getRealOption(clonedOption, clonedTool);
- if(realOption == null) continue;
-
-
try {
// Transfer value from preference store to options
IOption setOption = null;
switch (clonedOption.getValueType()) {
case IOption.BOOLEAN :
boolean boolVal = clonedOption.getBooleanValue();;
- setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, boolVal);
+// setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, boolVal);
// Reset the preference store since the Id may have changed
- // if (setOption != option) {
- // getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
- // }
+// if (setOption != option) {
+// getToolSettingsPrefStore().setValue(setOption.getId(), boolVal);
+// }
break;
case IOption.ENUMERATED :
String enumVal = clonedOption.getStringValue();
String enumId = clonedOption.getEnumeratedId(enumVal);
- setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption,
- (enumId != null && enumId.length() > 0) ? enumId : enumVal);
+// setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption,
+// (enumId != null && enumId.length() > 0) ? enumId : enumVal);
// Reset the preference store since the Id may have changed
// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
+// getToolSettingsPrefStore().setValue(setOption.getId(), enumVal);
// }
break;
case IOption.STRING :
String strVal = clonedOption.getStringValue();
- setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, strVal);
+// setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, strVal);
// Reset the preference store since the Id may have changed
// if (setOption != option) {
-// getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
+// getToolSettingsPrefStore().setValue(setOption.getId(), strVal);
// }
break;
case IOption.STRING_LIST :
@@ -603,7 +548,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
case IOption.OBJECTS :
// String listStr = getToolSettingsPreferenceStore().getString(option.getId());
String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]);
- setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, listVal);
+// setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, listVal);
// Reset the preference store since the Id may have changed
// if (setOption != option) {
// getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
@@ -617,19 +562,19 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// press have been applied.
if (setOption == null)
setOption = realOption;
-/*
- if (setOption.getValueHandler().handleValue(
- handler,
- setOption.getOptionHolder(),
- setOption,
- setOption.getValueHandlerExtraArgument(),
- IManagedOptionValueHandler.EVENT_APPLY)) {
- // TODO : Event is handled successfully and returned true.
- // May need to do something here say log a message.
- } else {
- // Event handling Failed.
- }
-*/
+//
+// if (setOption.getValueHandler().handleValue(
+// handler,
+// setOption.getOptionHolder(),
+// setOption,
+// setOption.getValueHandlerExtraArgument(),
+// IManagedOptionValueHandler.EVENT_APPLY)) {
+// // TODO : Event is handled successfully and returned true.
+// // May need to do something here say log a message.
+// } else {
+// // Event handling Failed.
+// }
+
} catch (BuildException e) {
} catch (ClassCastException e) {
}
@@ -640,11 +585,13 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
String command = clonedTool.getToolCommand();
if (command.length() > 0 &&
(!command.equals(tool.getToolCommand()))) {
- if ( isItResourceConfigPage ) {
- ManagedBuildManager.setToolCommand(realRcCfg, tool, command);
- } else {
- ManagedBuildManager.setToolCommand(realCfg, tool, command);
- }
+
+// if ( isItResourceConfigPage ) {
+// ManagedBuildManager.setToolCommand(realRcCfg, tool, command);
+// } else {
+// ManagedBuildManager.setToolCommand(realCfg, tool, command);
+// }
+
}
// Save the tool command line pattern if it has changed
@@ -654,28 +601,22 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
(!commandLinePattern.equals(tool.getCommandLinePattern()))) {
tool.setCommandLinePattern(commandLinePattern);
}
+ */
return result;
}
/**
- * saves all field editors
- */
- public void storeSettings() {
-// super.performOk();
- }
-
- /**
* Update the field editor that displays all the build options
*/
- public void updateAllOptionField() {
+ public void updateFields() {
allOptionFieldEditor.load();
}
public void setValues(){
commandStringField.load();
commandLinePatternField.load();
- updateAllOptionField();
+ updateFields();
}
public void propertyChange(PropertyChangeEvent event) {
@@ -683,11 +624,11 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
super.propertyChange(event);
if(event.getSource() == commandStringField){
- clonedTool.setToolCommand(commandStringField.getStringValue());
- updateAllOptionField();
+ fTool.setToolCommand(commandStringField.getStringValue());
+ updateFields();
}
else if(event.getSource() == commandLinePatternField){
- clonedTool.setCommandLinePattern(commandLinePatternField.getStringValue());
+ fTool.setCommandLinePattern(commandLinePatternField.getStringValue());
}
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuilderSettingsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuilderSettingsTab.java
new file mode 100644
index 00000000000..c4ca0bc5928
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/BuilderSettingsTab.java
@@ -0,0 +1,581 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildProcessManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+
+
+public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
+ // Widgets
+ //1
+ Button b_useDefault;
+ Combo c_builderType;
+ Text t_buildCmd;
+ //2
+ Button b_genMakefileAuto;
+ Button b_expandVars;
+ //3
+ Button b_stopOnError;
+ Button b_parallel;
+ Button b_parallelOpt;
+ Button b_parallelNum;
+ Spinner parallelProcesses;
+ //4
+ Label title2;
+ Button b_autoBuild;
+ Text t_autoBuild;
+ Button b_cmdBuild;
+ Text t_cmdBuild;
+ Button b_cmdClean;
+ Text t_cmdClean;
+ //5
+ Text t_dir;
+ Button b_dirWsp;
+ Button b_dirFile;
+ Button b_dirVars;
+
+ protected final int cpuNumber = BuildProcessManager.checkCPUNumber();
+// Configuration cfg = null;
+ IBuilder bld;
+ Configuration cfg;
+// BuildMacroProvider bmp = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(1, false));
+
+ // Builder group
+ Group g1 = setupGroup(usercomp, Messages.getString("BuilderSettingsTab.0"), 3, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ setupLabel(g1, Messages.getString("BuilderSettingsTab.1"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ c_builderType = new Combo(g1, SWT.DROP_DOWN | SWT.BORDER);
+ setupControl(c_builderType, 2, GridData.FILL_HORIZONTAL);
+ c_builderType.add(Messages.getString("BuilderSettingsTab.2")); //$NON-NLS-1$
+ c_builderType.add(Messages.getString("BuilderSettingsTab.3")); //$NON-NLS-1$
+ c_builderType.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ cfg.enableInternalBuilder(c_builderType.getSelectionIndex() == 1);
+ setState();
+ }});
+
+ b_useDefault = setupCheck(g1, Messages.getString("BuilderSettingsTab.4"), 3, GridData.BEGINNING); //$NON-NLS-1$
+
+ setupLabel(g1, Messages.getString("BuilderSettingsTab.5"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ t_buildCmd = setupBlock(g1, b_useDefault);
+ t_buildCmd.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ String fullCommand = t_buildCmd.getText().trim();
+ String buildCommand = parseMakeCommand(fullCommand);
+ String buildArgs = parseMakeArgs(fullCommand);
+ if(!buildCommand.equals(bld.getCommand())
+ || !buildArgs.equals(bld.getArguments())){
+ bld.setCommand(buildCommand);
+ bld.setArguments(buildArgs);
+ }
+ }});
+
+ Group g2 = setupGroup(usercomp, Messages.getString("BuilderSettingsTab.6"), 2, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ ((GridLayout)(g2.getLayout())).makeColumnsEqualWidth = true;
+
+ b_genMakefileAuto = setupCheck(g2, Messages.getString("BuilderSettingsTab.7"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ b_expandVars = setupCheck(g2, Messages.getString("BuilderSettingsTab.8"), 1, GridData.BEGINNING); //$NON-NLS-1$
+
+ // Build setting group
+ Group g3 = setupGroup(usercomp, Messages.getString("BuilderSettingsTab.9"), 2, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ ((GridLayout)(g3.getLayout())).makeColumnsEqualWidth = true;
+
+ Composite c1 = new Composite(g3, SWT.NONE);
+ setupControl(c1, 1, GridData.FILL_BOTH);
+ c1.setLayout(new GridLayout(1, false));
+
+ b_stopOnError = setupCheck(c1, Messages.getString("BuilderSettingsTab.10"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ Composite c2 = new Composite(g3, SWT.NONE);
+ setupControl(c2, 1, GridData.FILL_BOTH);
+ c2.setLayout(new GridLayout(2, false));
+
+ b_parallel = setupCheck(c2, Messages.getString("BuilderSettingsTab.11"), 2, GridData.BEGINNING); //$NON-NLS-1$
+
+ b_parallelOpt= new Button(c2, SWT.RADIO);
+ b_parallelOpt.setText(Messages.getString("BuilderSettingsTab.12")); //$NON-NLS-1$
+ setupControl(b_parallelOpt, 2, GridData.BEGINNING);
+ ((GridData)(b_parallelOpt.getLayoutData())).horizontalIndent = 15;
+ b_parallelOpt.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ cfg.setParallelDef(b_parallelOpt.getSelection());
+ setState();
+ }});
+
+ b_parallelNum= new Button(c2, SWT.RADIO);
+ b_parallelNum.setText(Messages.getString("BuilderSettingsTab.13")); //$NON-NLS-1$
+ setupControl(b_parallelNum, 1, GridData.BEGINNING);
+ ((GridData)(b_parallelNum.getLayoutData())).horizontalIndent = 15;
+ b_parallelNum.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ cfg.setParallelDef(!b_parallelNum.getSelection());
+ setState();
+ }});
+
+ parallelProcesses = new Spinner(c2, SWT.BORDER);
+ setupControl(parallelProcesses, 1, GridData.BEGINNING);
+ parallelProcesses.setValues(cpuNumber, 1, 10000, 0, 1, 10);
+ parallelProcesses.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ cfg.setParallelNumber(parallelProcesses.getSelection());
+ setState();
+ }
+ });
+
+ // Workbench behaviour group
+ Group g4 = setupGroup(usercomp, Messages.getString("BuilderSettingsTab.14"), 3, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ setupLabel(g4, Messages.getString("BuilderSettingsTab.15"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ title2 = setupLabel(g4, Messages.getString("BuilderSettingsTab.16"), 2, GridData.BEGINNING); //$NON-NLS-1$
+ b_autoBuild = setupCheck(g4, Messages.getString("BuilderSettingsTab.17"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ t_autoBuild = setupBlock(g4, b_autoBuild);
+ t_autoBuild.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ try { bld.setAutoBuildTarget(t_autoBuild.getText());
+ } catch (CoreException ex) {}
+ }} );
+ setupLabel(g4, Messages.getString("BuilderSettingsTab.18"), 3, GridData.BEGINNING); //$NON-NLS-1$
+ b_cmdBuild = setupCheck(g4, Messages.getString("BuilderSettingsTab.19"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ t_cmdBuild = setupBlock(g4, b_cmdBuild);
+ t_cmdBuild.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ try { bld.setIncrementalBuildTarget(t_cmdBuild.getText());
+ } catch (CoreException ex) {}
+ }} );
+ b_cmdClean = setupCheck(g4, Messages.getString("BuilderSettingsTab.20"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ t_cmdClean = setupBlock(g4, b_cmdClean);
+ t_cmdClean.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ try { bld.setCleanBuildTarget(t_cmdClean.getText());
+ } catch (CoreException ex) {}
+ }} );
+
+ // Build location group
+ Group g5 = setupGroup(usercomp, Messages.getString("BuilderSettingsTab.21"), 2, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ setupLabel(g5, Messages.getString("BuilderSettingsTab.22"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ t_dir = setupText(g5, 1, GridData.FILL_HORIZONTAL);
+ t_dir.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ bld.setBuildPath(t_dir.getText());
+ }} );
+ Composite c = new Composite(g5, SWT.NONE);
+ setupControl(c, 2, GridData.FILL_HORIZONTAL);
+ FormLayout f = new FormLayout();
+ c.setLayout(f);
+ b_dirVars = setupBottomButton(c, VARIABLESBUTTON_NAME, null);
+ b_dirFile = setupBottomButton(c, FILESYSTEMBUTTON_NAME, b_dirVars);
+ b_dirWsp = setupBottomButton(c, WORKSPACEBUTTON_NAME, b_dirFile);
+ }
+
+ void setManagedBuild(boolean enable) {
+ try {
+ bld.setManagedBuildOn(enable);
+ page.informPages(MANAGEDBUILDSTATE, null);
+ setState();
+ } catch (CoreException ex) {}
+ }
+
+ /**
+ * sets widgets states
+ */
+ void setState() {
+ bld = cfg.getEditableBuilder();
+
+ b_genMakefileAuto.setEnabled(cfg.supportsBuild(true));
+ b_genMakefileAuto.setSelection(bld.isManagedBuildOn());
+ b_useDefault.setSelection(bld.isDefaultBuildCmd());
+
+ c_builderType.select(cfg.isInternalBuilderEnabled() ? 1 : 0);
+ c_builderType.setEnabled(
+ cfg.canEnableInternalBuilder(true) &&
+ cfg.canEnableInternalBuilder(false));
+
+ t_buildCmd.setText(getMC());
+
+ b_stopOnError.setSelection(bld.isStopOnError());
+ b_stopOnError.setEnabled(
+ bld.supportsStopOnError(true) &&
+ bld.supportsStopOnError(false));
+ // parallel
+ b_parallel.setSelection(cfg.getInternalBuilderParallel());
+ b_parallelOpt.setSelection(cfg.getParallelDef());
+ b_parallelNum.setSelection(!cfg.getParallelDef());
+ int n = cfg.getParallelNumber();
+ if (n < 0) n = -n;
+ parallelProcesses.setSelection(n);
+
+ b_parallel.setVisible(bld.supportsParallelBuild());
+ b_parallelOpt.setVisible(bld.supportsParallelBuild());
+ b_parallelNum.setVisible(bld.supportsParallelBuild());
+ parallelProcesses.setVisible(bld.supportsParallelBuild());
+
+ if(!bld.canKeepEnvironmentVariablesInBuildfile())
+ b_expandVars.setEnabled(false);
+ else {
+ b_expandVars.setEnabled(true);
+ b_expandVars.setSelection(!bld.keepEnvironmentVariablesInBuildfile());
+ }
+ t_dir.setText(bld.getBuildPath());
+ // cfg.getBuildData().getBuilderCWD().toOSString());
+
+ boolean mbOn = bld.isManagedBuildOn();
+ t_dir.setEnabled(!mbOn);
+ b_dirVars.setEnabled(!mbOn);
+ b_dirWsp.setEnabled(!mbOn);
+ b_dirFile.setEnabled(!mbOn);
+
+ b_autoBuild.setSelection(bld.isAutoBuildEnable());
+ t_autoBuild.setText(bld.getAutoBuildTarget());
+ b_cmdBuild.setSelection(bld.isIncrementalBuildEnabled());
+ t_cmdBuild.setText(bld.getIncrementalBuildTarget());
+ b_cmdClean.setSelection(bld.isCleanBuildEnabled());
+ t_cmdClean.setText(bld.getCleanBuildTarget());
+
+ boolean external = (c_builderType.getSelectionIndex() == 0);
+ boolean parallel = b_parallel.getSelection();
+
+ b_useDefault.setEnabled(external);
+ t_buildCmd.setEnabled(external);
+ ((Control)t_buildCmd.getData()).setEnabled(external & ! b_useDefault.getSelection());
+
+ b_genMakefileAuto.setEnabled(external && cfg.supportsBuild(true));
+ b_expandVars.setEnabled(external && b_genMakefileAuto.getSelection());
+ b_parallelNum.setEnabled(parallel);
+ b_parallelOpt.setEnabled(parallel);
+ parallelProcesses.setEnabled(parallel & b_parallelNum.getSelection());
+
+ title2.setVisible(external);
+ t_autoBuild.setVisible(external);
+ ((Control)t_autoBuild.getData()).setVisible(external);
+ t_cmdBuild.setVisible(external);
+ ((Control)t_cmdBuild.getData()).setVisible(external);
+ t_cmdClean.setVisible(external);
+ ((Control)t_cmdClean.getData()).setVisible(external);
+
+ if (external) {
+ checkPressed(b_useDefault);
+ checkPressed(b_autoBuild);
+ checkPressed(b_cmdBuild);
+ checkPressed(b_cmdClean);
+ }
+ }
+
+ Button setupBottomButton(Composite c, String name, Control x) {
+ Button b = new Button(c, SWT.PUSH);
+ b.setText(name);
+ FormData fd = new FormData();
+ fd.width = BUTTON_WIDTH;
+ fd.top = new FormAttachment(0, 2);
+ if (x != null)
+ fd.right = new FormAttachment(x, -5);
+ else
+ fd.right = new FormAttachment(100, 0);
+ b.setLayoutData(fd);
+ b.setData(t_dir);
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ buttonVarPressed(event);
+ }});
+ return b;
+ }
+
+ /**
+ * Sets up text + corresponding button
+ */
+ Text setupBlock(Composite c, Button check) {
+ Text t = setupText(c, 1, GridData.FILL_HORIZONTAL);
+ Button b = setupButton(c, VARIABLESBUTTON_NAME, 1, GridData.END);
+ b.setData(t); // to get know which text is affected
+ t.setData(b); // to get know which button to enable/disable
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ buttonVarPressed(event);
+ }});
+ if (check != null) check.setData(t);
+ return t;
+ }
+
+ /*
+ * Unified handler for "Variables" buttons
+ */
+ void buttonVarPressed(SelectionEvent e) {
+ Widget b = e.widget;
+ if (b == null || b.getData() == null) return;
+ if (b.getData() instanceof Text) {
+ String x = null;
+ if (b.equals(b_dirWsp)) {
+ x = getWorkspaceDirDialog(usercomp.getShell(), EMPTY_STR);
+ if (x != null) ((Text)b.getData()).setText(x);
+ } else if (b.equals(b_dirFile)) {
+ x = getFileSystemDirDialog(usercomp.getShell(), EMPTY_STR);
+ if (x != null) ((Text)b.getData()).setText(x);
+ } else {
+ x = AbstractCPropertyTab.getVariableDialog(usercomp.getShell(), getResDesc().getConfiguration());
+ if (x != null) ((Text)b.getData()).insert(x);
+ }
+ }
+ }
+
+ public void checkPressed(SelectionEvent e) {
+ checkPressed((Button)e.widget);
+ setState();
+ }
+
+ void checkPressed(Button b) {
+ if (b == null) return;
+
+ boolean val = b.getSelection();
+ if (b.getData() instanceof Text) {
+ Text t = (Text)b.getData();
+ if (b == b_useDefault) { val = !val; }
+ t.setEnabled(val);
+ if (t.getData() != null && t.getData() instanceof Control) {
+ Control c = (Control)t.getData();
+ c.setEnabled(val);
+ }
+ }
+ try {
+ if (b == b_autoBuild) {
+ bld.setAutoBuildEnable(val);
+ } else if (b == b_cmdBuild) {
+ bld.setIncrementalBuildEnable(val);
+ } else if (b == b_cmdClean) {
+ bld.setCleanBuildEnable(val);
+ } else if (b == b_useDefault) {
+ bld.setUseDefaultBuildCmd(!val);
+ } else if (b == b_genMakefileAuto) {
+ setManagedBuild(val);
+ } else if (b == b_expandVars) {
+ if(bld.canKeepEnvironmentVariablesInBuildfile())
+ bld.setKeepEnvironmentVariablesInBuildfile(!val);
+ } else if (b == b_stopOnError) {
+ bld.setStopOnError(val);
+ } else if (b == b_parallel) {
+ bld.setParallelBuildOn(val);
+ }
+ } catch (CoreException e) {}
+ }
+
+ /**
+ * get make command
+ * @return
+ */
+ private String getMC() {
+ String makeCommand = bld.getBuildCommand().toOSString();
+ String makeArgs = bld.getBuildArguments();
+ if (makeArgs != null) { makeCommand += " " + makeArgs; } //$NON-NLS-1$
+ return makeCommand;
+ }
+ /**
+ * Performs common settings for all controls
+ * (Copy from config to widgets)
+ * @param cfgd -
+ */
+
+ public void updateData(ICResourceDescription cfgd) {
+ if (cfgd == null) return;
+ IConfiguration icfg = getCfg(cfgd.getConfiguration());
+ if (!(icfg instanceof Configuration)) return;
+ cfg = (Configuration)icfg;
+ setState();
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ Configuration cfg01 = (Configuration)getCfg(src.getConfiguration());
+ Configuration cfg02 = (Configuration)getCfg(dst.getConfiguration());
+ cfg02.enableInternalBuilder(cfg01.isInternalBuilderEnabled());
+ copyBuilders(cfg01.getBuilder(), cfg02.getEditableBuilder());
+ }
+
+ private void copyBuilders(IBuilder b1, IBuilder b2) {
+ try {
+ b2.setUseDefaultBuildCmd(b1.isDefaultBuildCmd());
+ if (!b1.isDefaultBuildCmd()) {
+ b2.setCommand(b1.getCommand());
+ b2.setArguments(b1.getArguments());
+ } else {
+ b2.setCommand(null);
+ b2.setArguments(null);
+ }
+ b2.setStopOnError(b1.isStopOnError());
+ b2.setParallelBuildOn(b1.isParallelBuildOn());
+ b2.setParallelizationNum(b1.getParallelizationNum());
+ if (b2.canKeepEnvironmentVariablesInBuildfile())
+ b2.setKeepEnvironmentVariablesInBuildfile(b1.keepEnvironmentVariablesInBuildfile());
+ b2.setBuildPath(null);
+
+ b2.setAutoBuildEnable((b1.isAutoBuildEnable()));
+ b2.setBuildAttribute(IBuilder.BUILD_TARGET_AUTO, (b1.getBuildAttribute(IBuilder.BUILD_TARGET_AUTO, EMPTY_STR)));
+ b2.setCleanBuildEnable(b1.isCleanBuildEnabled());
+ b2.setBuildAttribute(IBuilder.BUILD_TARGET_CLEAN, (b1.getBuildAttribute(IBuilder.BUILD_TARGET_CLEAN, EMPTY_STR)));
+ b2.setIncrementalBuildEnable(b1.isIncrementalBuildEnabled());
+ b2.setBuildAttribute(IBuilder.BUILD_TARGET_INCREMENTAL, (b1.getBuildAttribute(IBuilder.BUILD_TARGET_INCREMENTAL, EMPTY_STR)));
+
+ b2.setManagedBuildOn(b1.isManagedBuildOn());
+ } catch (CoreException ex) {
+ //TODO: log
+ }
+ }
+
+ /* (non-Javadoc)
+ * @param rawCommand
+ * @return
+ */
+ private String parseMakeArgs(String rawCommand) {
+ StringBuffer result = new StringBuffer();
+
+ // Parse out the command
+ String actualCommand = parseMakeCommand(rawCommand);
+
+ // The flags and targets are anything not in the command
+ String arguments = rawCommand.substring(actualCommand.length());
+
+ // If there aren't any, we can stop
+ if (arguments.length() == 0) {
+ return result.toString().trim();
+ }
+
+ String[] tokens = arguments.trim().split("\\s"); //$NON-NLS-1$
+ /*
+ * Cases to consider
+ * --<flag> Sensible, modern single flag. Add to result and continue.
+ * -<flags> Flags in single token, add to result and stop
+ * -<flag_with_arg> ARG Flag with argument. Add next token if valid arg.
+ * -<mixed_flags> ARG Mix of flags, one takes arg. Add next token if valid arg.
+ * -<flag_with_arg>ARG Corrupt case where next token should be arg but isn't
+ * -<flags> [target].. Flags with no args, another token, add flags and stop.
+ */
+ Pattern flagPattern = Pattern.compile("C|f|I|j|l|O|W"); //$NON-NLS-1$
+ // Look for a '-' followed by 1 or more flags with no args and exactly 1 that expects args
+ Pattern mixedFlagWithArg = Pattern.compile("-[^CfIjloW]*[CfIjloW]{1}.+"); //$NON-NLS-1$
+ for (int i = 0; i < tokens.length; ++i) {
+ String currentToken = tokens[i];
+ if (currentToken.startsWith("--")) { //$NON-NLS-1$
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ } else if (currentToken.startsWith("-")) { //$NON-NLS-1$
+ // Is there another token
+ if (i + 1 >= tokens.length) {
+ //We are done
+ result.append(currentToken);
+ } else {
+ String nextToken = tokens[i + 1];
+ // Are we expecting arguments
+ Matcher flagMatcher = flagPattern.matcher(currentToken);
+ if (!flagMatcher.find()) {
+ // Evalutate whether the next token should be added normally
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ } else {
+ // Look for the case where there is no space between flag and arg
+ if (mixedFlagWithArg.matcher(currentToken).matches()) {
+ // Add this single token and keep going
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ } else {
+ // Add this token and the next one right now
+ result.append(currentToken);
+ result.append(" "); //$NON-NLS-1$
+ result.append(nextToken);
+ result.append(" "); //$NON-NLS-1$
+ // Skip the next token the next time through, though
+ ++i;
+ }
+ }
+ }
+ }
+ }
+
+ return result.toString().trim();
+ }
+
+ /* (non-Javadoc)
+ *
+ * @param string
+ * @return
+ */
+ private String parseMakeCommand(String rawCommand) {
+ StringBuffer command = new StringBuffer();
+
+ // Try to separate out the command from the arguments
+ String[] result = rawCommand.split("\\s"); //$NON-NLS-1$
+ /*
+ * Here are the cases to consider:
+ * cmd First segment is last segment, assume is command
+ * cmd [flags] First segment is the command
+ * path/cmd [flags] Same as above
+ * path with space/make [flags] Must append each segment up-to flags as command
+ */
+ for (int i = 0; i < result.length; ++i) {
+ // Get the segment
+ String cmdSegment = result[i];
+ // If there is not another segment, we found the end
+ if (i + 1 >= result.length) {
+ command.append(cmdSegment);
+ } else {
+ // See if the next segment is the start of the flags
+ String nextSegment = result[i + 1];
+ if (nextSegment.startsWith("-")) { //$NON-NLS-1$
+ // we have found the end of the command
+ command.append(cmdSegment);
+ break;
+ } else {
+ command.append(cmdSegment);
+ // Add the whitespace back
+ command.append(" "); //$NON-NLS-1$
+ }
+ }
+ }
+ return command.toString().trim();
+ }
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject() || page.isForPrefs();
+ }
+
+ public void setVisible (boolean b) {
+ super.setVisible(b);
+ }
+
+ protected void performDefaults() {
+ copyBuilders(bld.getSuperClass(), bld);
+ updateData(getResDesc());
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CBuildLocationOutputTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CBuildLocationOutputTab.java
new file mode 100644
index 00000000000..2a671bca486
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CBuildLocationOutputTab.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.ui.newui.CLocationOutputTab;
+
+/**
+ * The same as CLocationOutputTab - but can be hidden
+ * in case of managed project
+ */
+public class CBuildLocationOutputTab extends CLocationOutputTab {
+
+ public boolean canBeVisible() {
+ if (!page.isForProject()) return false;
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(getResDesc().getConfiguration());
+ return !cfg.getBuilder().isManagedBuildOn();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CNewOptionsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CNewOptionsPage.java
new file mode 100644
index 00000000000..cce6cf44bc4
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CNewOptionsPage.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
+import org.eclipse.cdt.ui.wizards.NewCProjectWizardOptionPage;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+public class CNewOptionsPage extends NewCProjectWizardOptionPage {
+
+ public CNewOptionsPage(String pageName, String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+ public CNewOptionsPage(String pageName) {
+ this(pageName, null, null);
+ }
+
+ protected TabFolderOptionBlock createOptionBlock() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Preferences getPreferences() {
+ return null;
+ }
+
+ public IProject getProject() {
+ return null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java
new file mode 100644
index 00000000000..d613f9fd0f6
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java
@@ -0,0 +1,509 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
+import org.eclipse.cdt.internal.core.cdtvariables.EclipseVariablesVariableSupplier;
+import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
+import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
+import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier;
+import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
+import org.eclipse.cdt.ui.newui.CDTListComparator;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * displays the build macros for the given context
+ */
+public class CPropertyVarsTab extends AbstractCPropertyTab {
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "MacrosBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+
+ private static final String HEADER = LABEL + ".header"; //$NON-NLS-1$
+ private static final String HEADER_NAME = HEADER + ".name"; //$NON-NLS-1$
+ private static final String HEADER_TYPE = HEADER + ".type"; //$NON-NLS-1$
+ private static final String HEADER_VALUE = HEADER + ".value"; //$NON-NLS-1$
+
+ private static final String TYPE = LABEL + ".type"; //$NON-NLS-1$
+ private static final String TYPE_TEXT = TYPE + ".text"; //$NON-NLS-1$
+ private static final String TYPE_TEXT_LIST = TYPE + ".text.list"; //$NON-NLS-1$
+ private static final String TYPE_PATH_FILE = TYPE + ".path.file"; //$NON-NLS-1$
+ private static final String TYPE_PATH_FILE_LIST = TYPE + ".path.file.list"; //$NON-NLS-1$
+ private static final String TYPE_PATH_DIR = TYPE + ".path.dir"; //$NON-NLS-1$
+ private static final String TYPE_PATH_DIR_LIST = TYPE + ".path.dir.list"; //$NON-NLS-1$
+ private static final String TYPE_PATH_ANY = TYPE + ".path.any"; //$NON-NLS-1$
+ private static final String TYPE_PATH_ANY_LIST = TYPE + ".path.any.list"; //$NON-NLS-1$
+
+ private static final String DELETE_CONFIRM_TITLE = LABEL + ".delete.confirm.title"; //$NON-NLS-1$
+ private static final String DELETE_CONFIRM_MESSAGE = LABEL + ".delete.confirm.message"; //$NON-NLS-1$
+
+ private static final String DELETE_ALL_CONFIRM_TITLE = LABEL + ".delete.all.confirm.title"; //$NON-NLS-1$
+ private static final String DELETE_ALL_CONFIRM_MESSAGE = LABEL + ".delete.all.confirm.message"; //$NON-NLS-1$
+
+ private static final String VALUE = LABEL + ".value"; //$NON-NLS-1$
+ private static final String VALUE_ECLIPSE_DYNAMIC = VALUE + ".eclipse.dynamic"; //$NON-NLS-1$
+
+ private static final String VALUE_DELIMITER = " || "; //$NON-NLS-1$
+
+ private static final ICdtVariableManager mgr = CCorePlugin.getDefault().getCdtVariableManager();
+ private static final UserDefinedVariableSupplier fUserSupplier = CdtVariableManager.fUserDefinedMacroSupplier;
+
+ private ICConfigurationDescription cfgd = null;
+ private StorableCdtVariables vars = null;
+
+ //currently the "CWD" and "PWD" macros are not displayed in UI
+ private static final String fHiddenMacros[] = new String[]{
+ "CWD", //$NON-NLS-1$
+ "PWD" //$NON-NLS-1$
+ };
+
+ private boolean fShowSysMacros = false;
+ private Set fIncorrectlyDefinedMacrosNames = new HashSet();
+ private static final int CONTEXT = ICoreVariableContextInfo.CONTEXT_CONFIGURATION;
+
+ private TableViewer tv;
+ private Label fStatusLabel;
+
+ private static final String[] fEditableTableColumnProps = new String[] {
+ "editable name", //$NON-NLS-1$
+ "editable type", //$NON-NLS-1$
+ "editable value", //$NON-NLS-1$
+ };
+
+ private static final String[] fTableColumnNames = new String[] {
+ NewUIMessages.getResourceString(HEADER_NAME),
+ NewUIMessages.getResourceString(HEADER_TYPE),
+ NewUIMessages.getResourceString(HEADER_VALUE),
+ };
+
+ private static final ColumnLayoutData[] fTableColumnLayouts = {new ColumnPixelData(100), new ColumnPixelData(100), new ColumnPixelData(250)};
+
+ private class MacroContentProvider implements IStructuredContentProvider{
+ public Object[] getElements(Object inputElement) { return (Object[])inputElement; }
+ public void dispose() { }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ }
+
+ private class MacroLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
+ public Image getImage(Object element) { return null; }
+ public String getText(Object element) { return getColumnText(element, 0); }
+ public Font getFont(Object element) { return getFont(element, 0); }
+ public Image getColumnImage(Object element, int columnIndex) { return null; }
+ public Color getBackground(Object element){ return null; }
+
+ public String getColumnText(Object element, int columnIndex) {
+ ICdtVariable var = (ICdtVariable)element;
+ switch(columnIndex){
+ case 0:
+ return var.getName();
+ case 1:
+ switch(var.getValueType()){
+ case ICdtVariable.VALUE_PATH_FILE:
+ return NewUIMessages.getResourceString(TYPE_PATH_FILE);
+ case ICdtVariable.VALUE_PATH_FILE_LIST:
+ return NewUIMessages.getResourceString(TYPE_PATH_FILE_LIST);
+ case ICdtVariable.VALUE_PATH_DIR:
+ return NewUIMessages.getResourceString(TYPE_PATH_DIR);
+ case ICdtVariable.VALUE_PATH_DIR_LIST:
+ return NewUIMessages.getResourceString(TYPE_PATH_DIR_LIST);
+ case ICdtVariable.VALUE_PATH_ANY:
+ return NewUIMessages.getResourceString(TYPE_PATH_ANY);
+ case ICdtVariable.VALUE_PATH_ANY_LIST:
+ return NewUIMessages.getResourceString(TYPE_PATH_ANY_LIST);
+ case ICdtVariable.VALUE_TEXT:
+ return NewUIMessages.getResourceString(TYPE_TEXT);
+ case ICdtVariable.VALUE_TEXT_LIST:
+ return NewUIMessages.getResourceString(TYPE_TEXT_LIST);
+ default:
+ return "? " + var.getValueType(); //$NON-NLS-1$
+ }
+ case 2:
+ return getString(var); //$NON-NLS-1$
+ }
+ return EMPTY_STR;
+ }
+
+ private Font getValueFont(ICdtVariable var){
+ Font font = null;
+ if(isUserVar(var))
+ font = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+ return font;
+ }
+ public Font getFont(Object element, int columnIndex) {
+ ICdtVariable var = (ICdtVariable)element;
+ switch(columnIndex){
+ case 0:
+ case 1:
+ break;
+ case 2:
+ return getValueFont(var);
+ }
+ if(isUserVar(var))
+ return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+ return null;
+ }
+ public Color getForeground(Object element){
+ if(fIncorrectlyDefinedMacrosNames.contains(((ICdtVariable)element).getName()))
+ return JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
+ return null;
+ }
+ }
+
+ /*
+ * called when the user macro selection was changed
+ */
+ private void handleSelectionChanged(SelectionChangedEvent event){
+ int size = ((IStructuredSelection)event.getSelection()).size();
+ buttonSetEnabled(1, size == 1);
+ buttonSetEnabled(2, size > 0);
+ }
+
+ /*
+ * called when a custom button was pressed
+ */
+ public void buttonPressed(int index){
+ switch(index){
+ case 0:{
+ NewVarDialog dlg = new NewVarDialog(usercomp.getShell(), null, cfgd);
+ if(dlg.open() == Dialog.OK){
+ ICdtVariable macro = dlg.getDefinedMacro();
+ if(canCreate(macro)) {
+ if (cfgd != null) {
+ if (dlg.isForAllCfgs) {
+ ICConfigurationDescription[] cfgs = page.getCfgsEditable();
+ for (int k=0; k<cfgs.length; k++)
+ fUserSupplier.createMacro(macro, CONTEXT, cfgs[k]);
+ } else
+ fUserSupplier.createMacro(macro, CONTEXT, cfgd);
+ }
+ else if (vars != null)
+ vars.createMacro(macro);
+ updateData();
+ }
+ }
+ }
+ break;
+ case 1:{
+ ICdtVariable _vars[] = getSelectedUserMacros();
+ if(_vars != null && _vars.length == 1){
+ NewVarDialog dlg = new NewVarDialog(usercomp.getShell() ,_vars[0], cfgd);
+ if(dlg.open() == Dialog.OK){
+ ICdtVariable macro = dlg.getDefinedMacro();
+ if(canCreate(macro)) {
+ if (cfgd != null)
+ fUserSupplier.createMacro(macro, CONTEXT, cfgd);
+ else if (vars != null)
+ vars.createMacro(macro);
+ updateData();
+ }
+ }
+ }
+ }
+ break;
+ case 2:{
+ ICdtVariable macros[] = getSelectedUserMacros();
+ if(macros != null && macros.length > 0){
+ if(MessageDialog.openQuestion(usercomp.getShell(),
+ NewUIMessages.getResourceString(DELETE_CONFIRM_TITLE),
+ NewUIMessages.getResourceString(DELETE_CONFIRM_MESSAGE))){
+ for(int i = 0; i < macros.length; i++){
+ if (cfgd != null)
+ fUserSupplier.deleteMacro(macros[i].getName(), CONTEXT, cfgd);
+ else if (vars != null)
+ vars.deleteMacro(macros[i].getName());
+ }
+ updateData();
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ /*
+ * returnes the selected user-defined macros
+ */
+ private ICdtVariable[] getSelectedUserMacros(){
+ if(tv == null) return null;
+ List list = ((IStructuredSelection)tv.getSelection()).toList();
+ return (ICdtVariable[])list.toArray(new ICdtVariable[list.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+ */
+ protected void performDefaults() {
+ if(MessageDialog.openQuestion(usercomp.getShell(),
+ NewUIMessages.getResourceString(DELETE_ALL_CONFIRM_TITLE),
+ NewUIMessages.getResourceString(DELETE_ALL_CONFIRM_MESSAGE))){
+ if (cfgd != null)
+ fUserSupplier.deleteAll(CONTEXT, cfgd);
+ else if (vars != null)
+ vars.deleteAll();
+ updateData();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ initButtons(new String[] {ADD_STR, EDIT_STR, DEL_STR});
+ usercomp.setLayout(new GridLayout(1, false));
+ createTableControl();
+
+ // Create a "show parent levels" button
+ final Button b = new Button(usercomp, SWT.CHECK);
+ b.setFont(usercomp.getFont());
+ b.setText(Messages.getString("CPropertyVarsTab.0")); //$NON-NLS-1$
+ b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b.setSelection(fShowSysMacros);
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ fShowSysMacros = b.getSelection();
+ updateData(getResDesc());
+ }
+ });
+ if (page.isForPrefs()) b.setVisible(false);
+
+ fStatusLabel = new Label(usercomp, SWT.LEFT);
+ fStatusLabel.setFont(usercomp.getFont());
+ fStatusLabel.setText(EMPTY_STR);
+ fStatusLabel.setLayoutData(new GridData(GridData.BEGINNING));
+ fStatusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
+ }
+
+ private void createTableControl(){
+ TableViewer tableViewer;
+ tableViewer = new TableViewer(usercomp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
+ | SWT.FULL_SELECTION);
+
+ Table table = tableViewer.getTable();
+ TableLayout tableLayout = new TableLayout();
+ for (int i = 0; i < fTableColumnNames.length; i++) {
+ tableLayout.addColumnData(fTableColumnLayouts[i]);
+ TableColumn tc = new TableColumn(table, SWT.NONE, i);
+ tc.setResizable(fTableColumnLayouts[i].resizable);
+ tc.setText(fTableColumnNames[i]);
+ }
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ tableViewer.getControl().setLayoutData(gd);
+ tableViewer.setContentProvider(new MacroContentProvider());
+ tableViewer.setLabelProvider(new MacroLabelProvider());
+ tableViewer.setSorter(new ViewerSorter());
+
+ tableViewer.setColumnProperties(fEditableTableColumnProps);
+ tv = tableViewer;
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleSelectionChanged(event);
+ }
+ });
+ tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ if (!tv.getSelection().isEmpty()) { buttonPressed(1); }
+ }
+ });
+
+ table.addKeyListener(new KeyListener(){
+ public void keyPressed(KeyEvent e){
+ if(e.keyCode == SWT.DEL) buttonPressed(2);
+ }
+
+ public void keyReleased(KeyEvent e){}
+ });
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ /*
+ * answers whether the macro of a given name can be sreated
+ */
+ private boolean canCreate(ICdtVariable v){
+ if (v == null) return false;
+ String name = v.getName();
+ if(name == null || (name = name.trim()).length() == 0)
+ return false;
+ if(fHiddenMacros != null){
+ for(int i = 0; i < fHiddenMacros.length; i++){
+ if(fHiddenMacros[i].equals(EnvVarOperationProcessor.normalizeName(name)))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void updateData(ICResourceDescription _cfgd) {
+ if (_cfgd == null) {
+ cfgd = null;
+ if (vars == null)
+ vars = fUserSupplier.getWorkspaceVariablesCopy();
+ } else {
+ cfgd = _cfgd.getConfiguration();
+ vars = null;
+ }
+ updateData();
+ }
+
+ private void updateData() {
+ if(tv == null) return;
+
+ // check integrity
+ try{
+ mgr.checkVariableIntegrity(cfgd);
+ updateState(null);
+ } catch (CdtVariableException e){
+ updateState(e);
+ }
+ // get variables
+ ICdtVariable[] _vars = (cfgd != null) ? mgr.getVariables(cfgd) : vars.getMacros();
+ if (_vars == null) return;
+
+ ArrayList list = new ArrayList(_vars.length);
+ for(int i = 0; i < _vars.length; i++){
+ if(_vars[i] != null && (fShowSysMacros || isUserVar(_vars[i])))
+ list.add(_vars[i]);
+ }
+ Collections.sort(list, CDTListComparator.getInstance());
+ tv.setInput(list.toArray(new ICdtVariable[list.size()]));
+ }
+
+ private void updateState(CdtVariableException e){
+ fIncorrectlyDefinedMacrosNames.clear();
+ if(e != null){
+ fStatusLabel.setText(e.getMessage());
+ fStatusLabel.setVisible(true);
+ ICdtVariableStatus statuses[] = e.getVariableStatuses();
+ for(int i = 0; i < statuses.length; i++){
+ String name = statuses[i].getVariableName();
+ if(name != null)
+ fIncorrectlyDefinedMacrosNames.add(name);
+ }
+ }
+ else
+ fStatusLabel.setVisible(false);
+ }
+
+ private boolean isUserVar(ICdtVariable v) {
+ return mgr.isUserVariable(v, cfgd);
+ }
+
+ /* check whether variable is dynamic */
+ private boolean isDynamic(ICdtVariable v) {
+ if (v instanceof EclipseVariablesVariableSupplier.EclipseVarMacro) {
+ EclipseVariablesVariableSupplier.EclipseVarMacro evar =
+ (EclipseVariablesVariableSupplier.EclipseVarMacro)v;
+ if (evar.getVariable() instanceof IDynamicVariable)
+ return true;
+ }
+ return false;
+ }
+
+ private String getString(ICdtVariable v) {
+ if (isDynamic(v))
+ return NewUIMessages.getResourceString(VALUE_ECLIPSE_DYNAMIC);
+ String value = EMPTY_STR;
+ try {
+ if (CdtVariableResolver.isStringListVariable(v.getValueType()))
+ value = mgr.convertStringListToString(v.getStringListValue(), VALUE_DELIMITER);
+ else
+ value = v.getStringValue();
+ } catch (CdtVariableException e1) {}
+ return value;
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ if (cfgd != null) // only for project, not for prefs
+ fUserSupplier.setMacros(fUserSupplier.getMacros(CONTEXT, src), CONTEXT, dst);
+ else if (vars != null)
+ fUserSupplier.storeWorkspaceVariables(true);
+ }
+
+ /**
+ * Unlike other pages, workspace variables
+ * should be stored explicitly on "OK".
+ */
+ protected void performOK() {
+ if (vars != null) try {
+ fUserSupplier.setWorkspaceVariables(vars);
+ } catch (CoreException e) {}
+ vars = null;
+ super.performOK();
+ }
+ protected void performCancel() {
+ vars = null;
+ super.performCancel();
+ }
+
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject() || page.isForPrefs();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/DiscoveryTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/DiscoveryTab.java
new file mode 100644
index 00000000000..7d0a9cdf09d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/DiscoveryTab.java
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.internal.ui.util.PixelConverter;
+import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInfoContainer {
+
+ protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
+// private static final String UNSAVEDCHANGES_TITLE = PREFIX + ".unsavedchanges.title"; //$NON-NLS-1$
+// private static final String UNSAVEDCHANGES_MESSAGE = PREFIX + ".unsavedchanges.message"; //$NON-NLS-1$
+// private static final String UNSAVEDCHANGES_BSAVE = PREFIX + ".unsavedchanges.button.save"; //$NON-NLS-1$
+// private static final String UNSAVEDCHANGES_BCANCEL = PREFIX + ".unsavedchanges.button.cancel"; //$NON-NLS-1$
+// private static final String ERROR_TITLE = PREFIX + ".error.title"; //$NON-NLS-1$
+// private static final String ERROR_MESSAGE = PREFIX + ".error.message"; //$NON-NLS-1$
+ private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
+// private static final String PROFILE_ID = "profileId"; //$NON-NLS-1$
+ private static final String PROFILE_PATTERN = "profilePattern"; //$NON-NLS-1$
+
+// private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
+
+// private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
+// private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
+ private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
+ private static final String SC_ENABLED_BUTTON = PREFIX + ".scGroup.enabled.button"; //$NON-NLS-1$
+ private static final String SC_PROBLEM_REPORTING_ENABLED_BUTTON = PREFIX + ".scGroup.problemReporting.enabled.button"; //$NON-NLS-1$
+ private static final String SC_SELECTED_PROFILE_COMBO = PREFIX + ".scGroup.selectedProfile.combo"; //$NON-NLS-1$
+// private static final String BO_PROVIDER_GROUP_LABEL = PREFIX + ".boProvider.group.label"; //$NON-NLS-1$
+// private static final String SC_APPLY_PROGRESS_MESSAGE = PREFIX + ".apply.progressMessage"; //$NON-NLS-1$
+ private static final int DEFAULT_HEIGHT = 110;
+
+ private Table resTable;
+ private Button scEnabledButton;
+ private Button scProblemReportingEnabledButton;
+ private Combo profileComboBox;
+ private Combo scopeComboBox;
+ private Composite profileComp;
+ private Group scGroup;
+
+ private IConfigurationScannerConfigBuilderInfo cbi;
+ private IScannerConfigBuilderInfo2 buildInfo;
+ private InfoContext icontext;
+ private List pagesList = null;
+ private List profilesList = null;
+ private IPath configPath;
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(2, false));
+
+ if (page.isForProject() || page.isForPrefs()) {
+ Group scopeGroup = setupGroup(usercomp, Messages.getString("DiscoveryTab.0"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ scopeGroup.setLayoutData(gd);
+ scopeComboBox = new Combo(scopeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
+ scopeComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ scopeComboBox.add(Messages.getString("DiscoveryTab.1")); //$NON-NLS-1$
+ scopeComboBox.add(Messages.getString("DiscoveryTab.2")); //$NON-NLS-1$
+ scopeComboBox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (cbi == null) return;
+ cbi.setPerRcTypeDiscovery(scopeComboBox.getSelectionIndex() == 0);
+ updateData();
+ }
+ });
+ }
+
+ resTable = new Table(usercomp, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_VERTICAL);
+ gd.verticalSpan = 2;
+ gd.widthHint = 150;
+ resTable.setLayoutData(gd);
+ resTable.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleToolSelected();
+ }});
+ initializeProfilePageMap();
+
+ createScannerConfigControls(usercomp);
+
+ profileComp = new Composite(usercomp, SWT.NONE);
+ gd = new GridData(GridData.FILL, GridData.FILL, true, true);
+ PixelConverter converter = new PixelConverter(parent);
+ gd.heightHint = converter.convertVerticalDLUsToPixels(DEFAULT_HEIGHT);
+ profileComp.setLayoutData(gd);
+ profileComp.setLayout(new TabFolderLayout());
+ }
+
+ private void createScannerConfigControls(Composite parent) {
+ scGroup = setupGroup(parent, NewUIMessages.getResourceString(SC_GROUP_LABEL), 2, GridData.FILL_HORIZONTAL);
+
+ scEnabledButton = setupCheck(scGroup, NewUIMessages.getResourceString(SC_ENABLED_BUTTON), 2, GridData.FILL_HORIZONTAL);
+ scEnabledButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
+ enableAllControls();
+ if (scEnabledButton.getSelection())
+ handleDiscoveryProfileChanged();
+ }
+ });
+ scProblemReportingEnabledButton = setupCheck(scGroup, NewUIMessages.getResourceString(SC_PROBLEM_REPORTING_ENABLED_BUTTON), 2, GridData.FILL_HORIZONTAL);
+ scProblemReportingEnabledButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
+ }
+ });
+
+ // Add profile combo box
+ setupLabel(scGroup,NewUIMessages.getResourceString(SC_SELECTED_PROFILE_COMBO), 1, GridData.BEGINNING);
+ profileComboBox = new Combo(scGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
+ profileComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ profileComboBox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int x = profileComboBox.getSelectionIndex();
+ String s = (String)profilesList.get(x);
+ buildInfo.setSelectedProfileId(s);
+ handleDiscoveryProfileChanged();
+ }
+ });
+ }
+
+ private void enableAllControls() {
+ boolean isSCDEnabled = scEnabledButton.getSelection();
+ scProblemReportingEnabledButton.setEnabled(isSCDEnabled);
+ profileComboBox.setEnabled(isSCDEnabled);
+ profileComp.setVisible(isSCDEnabled);
+ }
+
+ public void updateData(ICResourceDescription rcfg) {
+ configPath = rcfg.getPath();
+ IConfiguration cfg = getCfg(rcfg.getConfiguration());
+ cbi = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
+ updateData();
+ }
+
+ private void updateData() {
+ if (scopeComboBox != null)
+ scopeComboBox.select(cbi.isPerRcTypeDiscovery() ? 0 : 1);
+
+ Map m = cbi.getInfoMap();
+ Iterator it = m.keySet().iterator();
+ int pos = resTable.getSelectionIndex();
+ resTable.removeAll();
+ while (it.hasNext()) {
+ String s = null;
+ InfoContext ic = (InfoContext)it.next();
+ IResourceInfo rci = ic.getResourceInfo();
+ if (rci == null) { // per configuration
+ s = ic.getConfiguration().getName();
+ } else { // pre resource
+ if ( ! configPath.equals(rci.getPath())) continue;
+ IInputType typ = ic.getInputType();
+ if (typ != null) s = typ.getName();
+ if (s == null) {
+ ITool tool = ic.getTool();
+ if (tool != null)
+ s = tool.getName();
+ }
+ if (s == null) s = Messages.getString("DiscoveryTab.3"); //$NON-NLS-1$
+ }
+ IScannerConfigBuilderInfo2 bi2 = (IScannerConfigBuilderInfo2)m.get(ic);
+ TableItem ti = new TableItem(resTable, SWT.NONE);
+ ti.setText(s);
+ ti.setData("cont", ic); //$NON-NLS-1$
+ ti.setData("info", bi2); //$NON-NLS-1$
+ }
+ int len = resTable.getItemCount();
+ if (len > 0) {
+ scGroup.setVisible(true);
+ profileComp.setVisible(true);
+ resTable.setEnabled(true);
+ resTable.select((pos < len && pos > -1) ? pos : 0);
+ handleToolSelected();
+ } else {
+ scGroup.setVisible(false);
+ profileComp.setVisible(false);
+ TableItem ti = new TableItem(resTable, SWT.NONE);
+ resTable.setEnabled(false);
+ ti.setText(Messages.getString("DiscoveryTab.6")); //$NON-NLS-1$
+ }
+ }
+
+ private String getProfileName(String id) {
+ int x = id.lastIndexOf("."); //$NON-NLS-1$
+ return (x == -1) ? id : id.substring(x+1);
+ }
+
+ private void handleToolSelected() {
+ if (resTable.getSelectionCount() == 0) return;
+ TableItem ti = resTable.getSelection()[0];
+ buildInfo = (IScannerConfigBuilderInfo2)ti.getData("info"); //$NON-NLS-1$
+ icontext = (InfoContext)ti.getData("cont"); //$NON-NLS-1$
+ scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
+ scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
+
+ profileComboBox.removeAll();
+ profilesList = buildInfo.getProfileIdList();
+ Iterator it = profilesList.iterator();
+ int counter = 0;
+ int pos = 0;
+ while (it.hasNext()) {
+ String profileId = (String)it.next();
+ String profileName = getProfileName(profileId);
+ profileComboBox.add(profileName);
+ if (profileId.equals(buildInfo.getSelectedProfileId())) pos = counter;
+ counter ++;
+ }
+ if (profileComboBox.getItemCount() > 0) profileComboBox.select(pos);
+ enableAllControls();
+ handleDiscoveryProfileChanged();
+ }
+
+ private void handleDiscoveryProfileChanged() {
+ boolean found = false;
+ for (Iterator it = pagesList.iterator(); it.hasNext(); ) {
+ DiscoveryProfilePageConfiguration p = (DiscoveryProfilePageConfiguration)it.next();
+ if (p != null) {
+ AbstractDiscoveryPage pg = p.getPage();
+ if (pg != null) {
+ if (pg.getControl() == null) {
+ pg.setContainer(this);
+ pg.createControl(profileComp);
+ profileComp.layout(true);
+ }
+ // set visible and current only 1 page
+ if (!found) {
+ found = p.isProfileAccepted(buildInfo.getSelectedProfileId());
+ if (found)
+ pg.initializeValues();
+ pg.setVisible(found);
+ } else {
+ pg.setVisible(false); // for remaining pages
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void initializeProfilePageMap() {
+ pagesList = new ArrayList(5);
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(
+ Messages.getString("DiscoveryTab.10"), Messages.getString("DiscoveryTab.11")); //$NON-NLS-1$ //$NON-NLS-2$
+ if (point == null) return;
+ IConfigurationElement[] infos = point.getConfigurationElements();
+ for (int i = 0; i < infos.length; i++) {
+ if (infos[i].getName().equals(PROFILE_PAGE)) {
+ pagesList.add(new DiscoveryProfilePageConfiguration(infos[i]));
+ }
+ }
+ }
+
+ /**
+ * Create a profile page only on request
+ *
+ * @author vhirsl
+ */
+ protected static class DiscoveryProfilePageConfiguration {
+ IConfigurationElement fElement;
+ AbstractDiscoveryPage page;
+ String pattern, name;
+ public DiscoveryProfilePageConfiguration(IConfigurationElement element) {
+ fElement = element;
+ pattern = fElement.getAttribute(PROFILE_PATTERN);
+ name = fElement.getAttribute("name"); //$NON-NLS-1$
+ }
+ public String getPattern() { return pattern; }
+ public String getName() { return name; }
+
+ public boolean isProfileAccepted(String id) {
+ return (id.indexOf(getPattern()) > -1);
+ }
+
+ public AbstractDiscoveryPage getPage()
+ {
+ if (page == null) {
+ try {
+ page = (AbstractDiscoveryPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
+ } catch (CoreException e) {}
+ if (page == null)
+ System.out.println(Messages.getString("DiscoveryTab.13") + fElement.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return page;
+ }
+ }
+
+ public void performApply(ICResourceDescription src,ICResourceDescription dst) {
+ IConfigurationScannerConfigBuilderInfo cbi1 =
+ ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(src.getConfiguration()));
+ IConfigurationScannerConfigBuilderInfo cbi2 =
+ ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(dst.getConfiguration()));
+ cbi2.setPerRcTypeDiscovery(cbi1.isPerRcTypeDiscovery());
+
+ Map m1 = cbi1.getInfoMap();
+ Map m2 = cbi2.getInfoMap();
+ Iterator it2 = m2.keySet().iterator();
+ while (it2.hasNext()) {
+ InfoContext ic = (InfoContext)it2.next();
+ if (m1.keySet().contains(ic)) {
+ IScannerConfigBuilderInfo2 bi1 = (IScannerConfigBuilderInfo2)m1.get(ic);
+ try {
+ cbi2.applyInfo(ic, bi1);
+ } catch (CoreException e) {
+ System.out.println(Messages.getString("DiscoveryTab.15") + e.getLocalizedMessage()); //$NON-NLS-1$
+ }
+ } else
+ System.out.println(Messages.getString("DiscoveryTab.16")); //$NON-NLS-1$
+ }
+ }
+
+ public boolean canBeVisible() {
+ if (page.isForProject() || page.isForPrefs()) return true;
+ // Hide this page for folders and files
+ // if Discovery scope is "per configuration", not "per resource"
+ IConfigurationScannerConfigBuilderInfo _cbi =
+ ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(getCfg(page.getResDesc().getConfiguration()));
+ return _cbi.isPerRcTypeDiscovery();
+ }
+
+ /**
+ * IBuildInfoContainer methods - called from dynamic pages
+ */
+ public IScannerConfigBuilderInfo2 getBuildInfo() { return buildInfo; }
+ public InfoContext getContext() { return icontext; }
+ public IProject getProject() { return page.getProject(); }
+ public ICConfigurationDescription getConfiguration() { return getResDesc().getConfiguration(); }
+
+ protected void performDefaults() {
+ cbi.setPerRcTypeDiscovery(true);
+ Iterator it = cbi.getInfoMap().keySet().iterator();
+ while (it.hasNext()) {
+ try {
+ cbi.applyInfo((InfoContext)it.next(), null);
+ } catch (CoreException e) {}
+ }
+ updateData();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/FileListControl.java
index e9c869d6f32..deb51532600 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/FileListControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 BitMethods Inc and others.
+ * Copyright (c) 2004, 2007 BitMethods Inc 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
@@ -9,7 +9,7 @@
* BitMethods Inc - initial API and implementation
* Sascha Radike <sradike@ejectlag.com> - Support for workspace browsing and small improvements
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.util.ArrayList;
@@ -17,15 +17,9 @@ import java.util.Iterator;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -138,6 +132,7 @@ public class FileListControl {
currentPathText = getText().getText();
if(contextInfo != null){
+ /*
try {
currentPathText =
MacroResolver.resolveToString(currentPathText,
@@ -146,6 +141,7 @@ public class FileListControl {
" ")); //$NON-NLS-1$
} catch (BuildMacroException e) {
}
+ */
}
/* Remove double quotes */
@@ -276,27 +272,27 @@ public class FileListControl {
private static final String WORKSPACELOC_VAR = "workspace_loc"; //$NON-NLS-1$
/* Names, messages and titles */
- private static final String WORKSPACEBUTTON_NAME = ManagedBuilderUIMessages.getResourceString("FileListControl.button.workspace"); //$NON-NLS-1$
- private static final String FILESYSTEMBUTTON_NAME = ManagedBuilderUIMessages.getResourceString("FileListControl.button.fs"); //$NON-NLS-1$
-
- private static final String ADD_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.add"); //$NON-NLS-1$
- private static final String DEL_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.delete"); //$NON-NLS-1$
- private static final String EDIT_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.edit"); //$NON-NLS-1$
- private static final String MOVEUP_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.moveup"); //$NON-NLS-1$
- private static final String MOVEDOWN_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.movedown"); //$NON-NLS-1$
- private static final String FILE_TITLE_ADD = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.file.title.add"); //$NON-NLS-1$
- private static final String DIR_TITLE_ADD = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.dir.title.add"); //$NON-NLS-1$
- private static final String FILE_TITLE_EDIT = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.file.title.edit"); //$NON-NLS-1$
- private static final String DIR_TITLE_EDIT = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.dir.title.edit"); //$NON-NLS-1$
- private static final String WORKSPACE_DIR_DIALOG_TITLE = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.wsp.dir.dlg.title"); //$NON-NLS-1$
- private static final String WORKSPACE_FILE_DIALOG_TITLE = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.title"); //$NON-NLS-1$
- private static final String WORKSPACE_DIR_DIALOG_MSG = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.wsp.dir.dlg.msg"); //$NON-NLS-1$
- private static final String WORKSPACE_FILE_DIALOG_MSG = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.msg"); //$NON-NLS-1$
- private static final String WORKSPACE_FILE_DIALOG_ERR = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.err"); //$NON-NLS-1$
- private static final String FILESYSTEM_DIR_DIALOG_MSG = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.fs.dir.dlg.msg"); //$NON-NLS-1$
- private static final String FILE_MSG = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.message.file"); //$NON-NLS-1$
- private static final String DIR_MSG = ManagedBuilderUIMessages.getResourceString("BrowseEntryDialog.message.directory"); //$NON-NLS-1$
- private static final String TITLE = ManagedBuilderUIMessages.getResourceString("BuildPropertyCommon.label.title"); //$NON-NLS-1$
+ private static final String WORKSPACEBUTTON_NAME = NewUIMessages.getResourceString("FileListControl.button.workspace"); //$NON-NLS-1$
+ private static final String FILESYSTEMBUTTON_NAME = NewUIMessages.getResourceString("FileListControl.button.fs"); //$NON-NLS-1$
+
+ private static final String ADD_STR = NewUIMessages.getResourceString("FileListControl.add"); //$NON-NLS-1$
+ private static final String DEL_STR = NewUIMessages.getResourceString("FileListControl.delete"); //$NON-NLS-1$
+ private static final String EDIT_STR = NewUIMessages.getResourceString("FileListControl.edit"); //$NON-NLS-1$
+ private static final String MOVEUP_STR = NewUIMessages.getResourceString("FileListControl.moveup"); //$NON-NLS-1$
+ private static final String MOVEDOWN_STR = NewUIMessages.getResourceString("FileListControl.movedown"); //$NON-NLS-1$
+ private static final String FILE_TITLE_ADD = NewUIMessages.getResourceString("BrowseEntryDialog.file.title.add"); //$NON-NLS-1$
+ private static final String DIR_TITLE_ADD = NewUIMessages.getResourceString("BrowseEntryDialog.dir.title.add"); //$NON-NLS-1$
+ private static final String FILE_TITLE_EDIT = NewUIMessages.getResourceString("BrowseEntryDialog.file.title.edit"); //$NON-NLS-1$
+ private static final String DIR_TITLE_EDIT = NewUIMessages.getResourceString("BrowseEntryDialog.dir.title.edit"); //$NON-NLS-1$
+ private static final String WORKSPACE_DIR_DIALOG_TITLE = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.dir.dlg.title"); //$NON-NLS-1$
+ private static final String WORKSPACE_FILE_DIALOG_TITLE = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.title"); //$NON-NLS-1$
+ private static final String WORKSPACE_DIR_DIALOG_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.dir.dlg.msg"); //$NON-NLS-1$
+ private static final String WORKSPACE_FILE_DIALOG_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.msg"); //$NON-NLS-1$
+ private static final String WORKSPACE_FILE_DIALOG_ERR = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.err"); //$NON-NLS-1$
+ private static final String FILESYSTEM_DIR_DIALOG_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.fs.dir.dlg.msg"); //$NON-NLS-1$
+ private static final String FILE_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.message.file"); //$NON-NLS-1$
+ private static final String DIR_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.message.directory"); //$NON-NLS-1$
+ private static final String TITLE = NewUIMessages.getResourceString("BuildPropertyCommon.label.title"); //$NON-NLS-1$
//toolbar
private ToolBar toolBar;
@@ -320,7 +316,7 @@ public class FileListControl {
/* Workspace support */
private boolean fWorkspaceSupport = false;
- private IMacroContextInfo contextInfo;
+ private IVariableContextInfo contextInfo;
private IResource rc;
private java.util.List listeners = new ArrayList();
@@ -596,8 +592,8 @@ public class FileListControl {
private void removePressed() {
int index = list.getSelectionIndex();
if (browseType == IOption.BROWSE_DIR || browseType == IOption.BROWSE_FILE) {
- String quest = ManagedBuilderUIMessages.getResourceString("FileListControl.deletedialog.message"); //$NON-NLS-1$
- String title = ManagedBuilderUIMessages.getResourceString("FileListControl.deletedialog.title"); //$NON-NLS-1$
+ String quest = NewUIMessages.getResourceString("FileListControl.deletedialog.message"); //$NON-NLS-1$
+ String title = NewUIMessages.getResourceString("FileListControl.deletedialog.title"); //$NON-NLS-1$
boolean delDir = MessageDialog.openQuestion(list.getShell(), title,
quest);
if (delDir && index != -1){
@@ -664,7 +660,7 @@ public class FileListControl {
message, selItem, null, browseType);
} else {
- String title = ManagedBuilderUIMessages.getResourceString("FileListControl.editdialog.title"); //$NON-NLS-1$
+ String title = NewUIMessages.getResourceString("FileListControl.editdialog.title"); //$NON-NLS-1$
dialog = new InputDialog(null, title, compTitle,
selItem, null);
}
@@ -744,14 +740,16 @@ public class FileListControl {
* Set the field editor context.
* @param project
*/
- public void setContext(IMacroContextInfo info) {
+ public void setContext(IVariableContextInfo info) {
contextInfo = info;
for(;info != null;info = info.getNext()){
+ /*
if(info.getContextType() == IBuildMacroProvider.CONTEXT_PROJECT){
IManagedProject mngProj = (IManagedProject)info.getContextData();
this.rc = mngProj.getOwner();
break;
}
+ */
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/FileListControlFieldEditor.java
index ed7e5efa161..aca09055fb2 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/FileListControlFieldEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 BitMethods Inc and others.
+ * Copyright (c) 2004, 2007 BitMethods Inc 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
@@ -9,7 +9,7 @@
* BitMethods Inc - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.util.ArrayList;
@@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
+
/**
* Field editor that uses FileListControl for user input.
*/
@@ -199,15 +200,15 @@ public class FileListControlFieldEditor extends FieldEditor {
list.setList(array);
list.setSelection(0);
// Set the resource the editor works for
- if (store instanceof BuildToolSettingsPreferenceStore) {
- IConfiguration config = ((BuildToolSettingsPreferenceStore)store).getSelectedConfig();
+ if (store instanceof ToolSettingsPrefStore) {
+ IConfiguration config = ((ToolSettingsPrefStore)store).getSelectedConfig();
if (config != null) {
IResource project = config.getOwner();
if (project != null) {
/* Enable workspace support for list and set project */
list.setWorkspaceSupport(true);
- if (store instanceof BuildToolSettingsPreferenceStore){
- BuildToolSettingsPreferenceStore btsStore = ((BuildToolSettingsPreferenceStore)store);
+ if (store instanceof ToolSettingsPrefStore){
+ ToolSettingsPrefStore btsStore = ((ToolSettingsPrefStore)store);
Object[] option = btsStore.getOption(getPreferenceName());
if(option != null){
list.setContext(
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerFileSCDProfilePage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerFileSCDProfilePage.java
new file mode 100644
index 00000000000..44b75ea0679
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerFileSCDProfilePage.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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 - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * SCD per project profile property/preference page
+ *
+ * @author vhirsl
+ */
+public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
+ private static final String providerId = "makefileGenerator"; //$NON-NLS-1$
+
+ public void createSpecific(Composite parent) {}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#isValid()
+ */
+ protected boolean isValid() { return true; }
+
+ public void initializeValues() {
+ bopEnabledButton.setSelection(getContainer().getBuildInfo().isBuildOutputParserEnabled());
+ setBopOpenFileText(getContainer().getBuildInfo().getBuildOutputFilePath());
+ }
+
+ protected void handlebopEnabledButtonPress() {
+ getContainer().getBuildInfo().setBuildOutputParserEnabled(bopEnabledButton.getSelection());
+ getContainer().getBuildInfo().setProviderOutputParserEnabled(providerId, bopEnabledButton.getSelection());
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerProjectSCDProfilePage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerProjectSCDProfilePage.java
new file mode 100644
index 00000000000..82f5c48db50
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/GCCPerProjectSCDProfilePage.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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 - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.io.File;
+
+import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * SCD per project profile property/preference page
+ *
+ * @author vhirsl
+ */
+public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
+ private static final String SI_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".siProvider.parser.enabled.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_LABEL = PREFIX + ".siProvider.command.label"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_BROWSE_BUTTON = PREFIX + ".siProvider.browse.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_DIALOG = PREFIX + ".siProvider.browse.runCommandDialog"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_ERROR_MESSAGE= PREFIX + ".siProvider.command.errorMessage"; //$NON-NLS-1$
+ private static final String providerId = "specsFile"; //$NON-NLS-1$
+
+ private Button sipEnabledButton;
+ private Text sipRunCommandText;
+
+ private boolean isValid = true;
+
+ public void createSpecific(Composite parent) {
+ ControlFactory.createSeparator(parent, 3);
+
+ // si provider enabled checkbox
+ sipEnabledButton = ControlFactory.createCheckBox(parent, NewUIMessages.getResourceString(SI_PROVIDER_PARSER_ENABLED_BUTTON));
+ sipEnabledButton.setFont(parent.getFont());
+ ((GridData)sipEnabledButton.getLayoutData()).horizontalSpan = 3;
+ ((GridData)sipEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ sipEnabledButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ bopLoadButton.setEnabled(sipEnabledButton.getSelection());
+ getContainer().getBuildInfo().setProviderOutputParserEnabled(providerId, sipEnabledButton.getSelection());
+ }
+ });
+
+ // si command label
+ Label siCommandLabel = ControlFactory.createLabel(parent, NewUIMessages.getResourceString(SI_PROVIDER_COMMAND_LABEL));
+ ((GridData) siCommandLabel.getLayoutData()).horizontalSpan = 3;
+
+ // text field
+ sipRunCommandText = ControlFactory.createTextField(parent, SWT.SINGLE | SWT.BORDER);
+ //((GridData) sipRunCommandText.getLayoutData()).horizontalSpan = 2;
+ sipRunCommandText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ String cmd = sipRunCommandText.getText().trim();
+ isValid = (cmd.length() > 0);
+ if (isValid)
+ getContainer().getBuildInfo().setProviderRunCommand(providerId, cmd);
+ }
+ });
+
+ // si browse button
+ Button siBrowseButton = ControlFactory.createPushButton(parent, NewUIMessages.getResourceString(SI_PROVIDER_BROWSE_BUTTON));
+ ((GridData) siBrowseButton.getLayoutData()).widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
+ siBrowseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ handleSIPBrowseButtonSelected();
+ }
+ private void handleSIPBrowseButtonSelected() {
+ FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ dialog.setText(NewUIMessages.getResourceString(SI_PROVIDER_COMMAND_DIALOG));
+ String fileName = sipRunCommandText.getText().trim();
+ int lastSeparatorIndex = fileName.lastIndexOf(File.separator);
+ if (lastSeparatorIndex != -1) {
+ dialog.setFilterPath(fileName.substring(0, lastSeparatorIndex));
+ }
+ String res = dialog.open();
+ if (res == null) {
+ return;
+ }
+ sipRunCommandText.setText(res);
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#isValid()
+ */
+ public boolean isValid() { return isValid; }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return (isValid) ? null : NewUIMessages.getResourceString(SI_PROVIDER_COMMAND_ERROR_MESSAGE);
+ }
+
+ public void initializeValues() {
+ bopEnabledButton.setSelection(getContainer().getBuildInfo().isBuildOutputParserEnabled());
+ setBopOpenFileText(getContainer().getBuildInfo().getBuildOutputFilePath());
+ sipEnabledButton.setSelection(getContainer().getBuildInfo().isProviderOutputParserEnabled(providerId));
+ sipRunCommandText.setText(getContainer().getBuildInfo().getProviderRunCommand(providerId));
+ }
+
+ protected void handlebopEnabledButtonPress() {
+ getContainer().getBuildInfo().setBuildOutputParserEnabled(bopEnabledButton.getSelection());
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/IBuildInfoContainer.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/IBuildInfoContainer.java
new file mode 100644
index 00000000000..a60843eeb4f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/IBuildInfoContainer.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * This interface is used by dynamic discovery pages
+ * to refer to underlying tab (DiscoveryTab)
+ * and get all object-specific data.
+ *
+ * In previous code, reference to specific
+ * property page was used instead of interface.
+ */
+public interface IBuildInfoContainer {
+ public IScannerConfigBuilderInfo2 getBuildInfo();
+ public InfoContext getContext();
+ public ICConfigurationDescription getConfiguration();
+ public IProject getProject();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/IFileListChangeListener.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/IFileListChangeListener.java
index 0ab1b277132..d91956e5d52 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/IFileListChangeListener.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/IFileListChangeListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,8 +8,7 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
+package org.eclipse.cdt.managedbuilder.ui.newui;
public interface IFileListChangeListener {
void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]);
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIImages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ManagedBuilderUIImages.java
index e3839e8eef9..d3691dace48 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIImages.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ManagedBuilderUIImages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 Rational Software Corporation and others.
+ * Copyright (c) 2002, 2007 Rational Software 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.net.MalformedURLException;
@@ -19,6 +19,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
+
/**
* Bundle of all images used by the C plugin.
*/
@@ -71,7 +72,13 @@ public class ManagedBuilderUIImages {
public static final String IMG_FILELIST_MOVEDOWN = NAME_PREFIX + "list-movedown.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_FILELIST_MOVEDOWN = createManaged(T_LIST, IMG_FILELIST_MOVEDOWN);
-
+ // new images
+ public static final String IMG_READ_ONLY = NAME_PREFIX + "read_only.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_READ_ONLY = createManaged(T_LIST, IMG_READ_ONLY);
+ public static final String IMG_EDITABLE = NAME_PREFIX + "editable.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_EDITABLE = createManaged(T_LIST, IMG_EDITABLE);
+ public static final String IMG_BUILT_IN = NAME_PREFIX + "built_in.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_BUILT_IN = createManaged(T_LIST, IMG_EDITABLE);
private static ImageDescriptor createManaged(String prefix, String name) {
return createManaged(imageRegistry, prefix, name);
@@ -87,9 +94,9 @@ public class ManagedBuilderUIImages {
return imageRegistry.get(key);
}
- private static ImageDescriptor create(String prefix, String name) {
- return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
- }
+// private static ImageDescriptor create(String prefix, String name) {
+// return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
+// }
private static URL makeIconFileURL(String prefix, String name) {
StringBuffer buffer= new StringBuffer(prefix);
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ManagedBuilderUIPlugin.java
index 5c7540f6652..4a498918c49 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIPlugin.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ManagedBuilderUIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * Copyright (c) 2002, 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.lang.reflect.InvocationTargetException;
@@ -34,7 +34,7 @@ public class ManagedBuilderUIPlugin extends AbstractUIPlugin {
* The constructor
*/
public ManagedBuilderUIPlugin() {
- super();
+// super();
plugin = this;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/Messages.java
new file mode 100644
index 00000000000..e260c1ab776
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/Messages.java
@@ -0,0 +1,22 @@
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.ui.newui.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewBuildConfigurationDialog.java
index 2b65712e6f8..5b98c5bbf86 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewBuildConfigurationDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -8,21 +8,21 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -40,7 +40,12 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-public class NewConfigurationDialog extends StatusDialog {
+/**
+ * Build-system specific version
+ * for "add new configuration" dialog
+ * in "Manage configurations" feature
+ */
+public class NewBuildConfigurationDialog extends Dialog {
// String constants
private static final String PREFIX = "NewConfiguration"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
@@ -49,7 +54,6 @@ public class NewConfigurationDialog extends StatusDialog {
private static final String GROUP = LABEL + ".group"; //$NON-NLS-1$
private static final String COPY = LABEL + ".copy"; //$NON-NLS-1$
private static final String CLONE = LABEL + ".clone"; //$NON-NLS-1$
- private static final String SHOWALL = LABEL + ".showall"; //$NON-NLS-1$
private static final String DUPLICATE = ERROR + ".duplicateName"; //$NON-NLS-1$
private static final String CASE = ERROR + ".caseName"; //$NON-NLS-1$
private static final String INVALID = ERROR + ".invalidName"; //$NON-NLS-1$
@@ -62,20 +66,18 @@ public class NewConfigurationDialog extends StatusDialog {
private Text configDescription;
private Combo copyConfigSelector;
private Combo cloneConfigSelector;
- private Button btnShowAll;
-
+ private Label statusLabel;
+
// Bookeeping
private boolean clone;
/** Default configurations defined in the toolchain description */
- private IConfiguration[] defaultConfigs;
+ private IConfiguration[] defaultCfgds;
/** Configurations defined in the target */
- private IConfiguration[] definedConfigs;
+ private IConfiguration[] definedCfgds;
private IConfiguration parentConfig;
- private IManagedProject managedProject;
+ private ICProjectDescription des;
private String newName;
private String newDescription;
- /** A list containing config names that have been defined but not added to the target */
- final private ArrayList reservedNames;
final private String title;
@@ -85,28 +87,28 @@ public class NewConfigurationDialog extends StatusDialog {
* @param nameList A list of names (Strings) that have been added by the user but have not yet been added to the target
* @param title The title of the dialog
*/
- protected NewConfigurationDialog(Shell parentShell, IManagedProject managedProject, String title) {
+ protected NewBuildConfigurationDialog(Shell parentShell,
+ ICProjectDescription prjd,
+ ICConfigurationDescription[] _cfgds,
+ IConfiguration[] _defs,
+ String title) {
super(parentShell);
this.title = title;
+ des = prjd;
setShellStyle(getShellStyle()|SWT.RESIZE);
+
newName = new String();
newDescription = new String();
+
parentConfig = null;
- this.managedProject = managedProject;
- reservedNames = new ArrayList();
// The default behaviour is to clone the settings
clone = true;
// Populate the list of default and defined configurations
- definedConfigs = managedProject.getConfigurations();
- IProjectType projectType = managedProject.getProjectType();
- defaultConfigs = projectType.getConfigurations();
-
- // Get the defined configuration names
- for (int i = 0; i < definedConfigs.length; i++) {
- reservedNames.add(definedConfigs[i].getName());
- }
-
+ definedCfgds = new IConfiguration[_cfgds.length];
+ for (int i=0; i<_cfgds.length; i++)
+ definedCfgds[i] = ManagedBuildManager.getConfigurationForDescription(_cfgds[i]);
+ defaultCfgds = _defs;
}
/* (non-Javadoc)
@@ -125,34 +127,32 @@ public class NewConfigurationDialog extends StatusDialog {
if (clone) {
baseConfigNameAndDescription = cloneConfigSelector.getItem(cloneConfigSelector.getSelectionIndex());
- for (int i = 0; i < definedConfigs.length; i++) {
- IConfiguration config = definedConfigs[i];
- description = config.getDescription();
+ for (int i = 0; i < definedCfgds.length; i++) {
+ description = definedCfgds[i].getDescription();
if( (description == null) || (description.equals("")) ){ //$NON-NLS-1$
- nameAndDescription = config.getName();
+ nameAndDescription = definedCfgds[i].getName();
} else {
- nameAndDescription = config.getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
+ nameAndDescription = definedCfgds[i].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
if (nameAndDescription.equals(baseConfigNameAndDescription)) {
- parentConfig = config;
+ parentConfig = definedCfgds[i];
break;
}
}
} else {
// Get the parent config out of the default config list
baseConfigNameAndDescription = copyConfigSelector.getItem(copyConfigSelector.getSelectionIndex());
- for (int i = 0; i < defaultConfigs.length; i++) {
- IConfiguration config = defaultConfigs[i];
- description = config.getDescription();
+ for (int i = 0; i < defaultCfgds.length; i++) {
+ description = defaultCfgds[i].getDescription();
if( (description == null) || (description.equals("")) ) { //$NON-NLS-1$
- nameAndDescription = config.getName();
+ nameAndDescription = defaultCfgds[i].getName();
} else {
- nameAndDescription = config.getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
+ nameAndDescription = defaultCfgds[i].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
if (nameAndDescription.equals(baseConfigNameAndDescription)) {
- parentConfig = config;
+ parentConfig = defaultCfgds[i];
break;
}
}
@@ -206,7 +206,7 @@ public class NewConfigurationDialog extends StatusDialog {
// Add a label and a text widget for Configuration's name
final Label nameLabel = new Label(group1, SWT.LEFT);
nameLabel.setFont(parent.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(NAME));
+ nameLabel.setText(NewUIMessages.getResourceString(NAME));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
@@ -230,7 +230,7 @@ public class NewConfigurationDialog extends StatusDialog {
// Add a label and a text widget for Configuration's description
final Label descriptionLabel = new Label(group1, SWT.LEFT);
descriptionLabel.setFont(parent.getFont());
- descriptionLabel.setText(ManagedBuilderUIMessages.getResourceString(DESCRIPTION));
+ descriptionLabel.setText(NewUIMessages.getResourceString(DESCRIPTION));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
@@ -250,7 +250,7 @@ public class NewConfigurationDialog extends StatusDialog {
final Group group = new Group(composite, SWT.NONE);
group.setFont(composite.getFont());
- group.setText(ManagedBuilderUIMessages.getResourceString(GROUP));
+ group.setText(NewUIMessages.getResourceString(GROUP));
GridLayout layout = new GridLayout(3, false);
group.setLayout(layout);
gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -266,7 +266,7 @@ public class NewConfigurationDialog extends StatusDialog {
// Add a radio button and combo box to copy from default config
btnCopy = new Button(group, SWT.RADIO);
btnCopy.setFont(group.getFont());
- btnCopy.setText(ManagedBuilderUIMessages.getResourceString(COPY));
+ btnCopy.setText(NewUIMessages.getResourceString(COPY));
setButtonLayoutData(btnCopy);
btnCopy.addSelectionListener(radioListener);
@@ -288,7 +288,7 @@ public class NewConfigurationDialog extends StatusDialog {
// Create a radio button and combo for clonable configs
btnClone = new Button(group, SWT.RADIO);
btnClone.setFont(group.getFont());
- btnClone.setText(ManagedBuilderUIMessages.getResourceString(CLONE));
+ btnClone.setText(NewUIMessages.getResourceString(CLONE));
setButtonLayoutData(btnClone);
btnClone.addSelectionListener(radioListener);
btnClone.setSelection(true);
@@ -307,68 +307,34 @@ public class NewConfigurationDialog extends StatusDialog {
validateState();
}
});
-
- // Create a "show all configurations" button
- btnShowAll = new Button(composite, SWT.CHECK);
- btnShowAll.setFont(composite.getFont());
- btnShowAll.setText(ManagedBuilderUIMessages.getResourceString(SHOWALL));
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 1;
- btnShowAll.setLayoutData(gd);
- btnShowAll.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- updateDefaultConfigs();
- }
- });
updateComboState();
updateDefaultConfigs();
+
+ statusLabel = new Label(composite, SWT.CENTER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ statusLabel.setLayoutData(gd);
+ statusLabel.setFont(composite.getFont());
+ statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
return composite;
}
/**
- * @return the <code>IConfiguration</code> the user selected as
- * the parent of the new configuration.
- */
- public IConfiguration getParentConfiguration() {
- return parentConfig;
- }
-
- /**
* updates the list of default configurations
*/
- private void updateDefaultConfigs(){
- IConfiguration cfgs[] = managedProject.getProjectType().getConfigurations();
- boolean showAll = btnShowAll != null ? btnShowAll.getSelection() : false;
-
- if(showAll)
- defaultConfigs = cfgs;
- else {
- ArrayList list = new ArrayList();
- for (int i = 0; i < cfgs.length; i++) {
- if (cfgs[i].isSupported()) {
- IToolChain tc = cfgs[i].getToolChain();
-
- // Determine if the tool-chain has 'convertToId' attribute.
- // If so, do not add this configuration to the list.
- if (!tc.getConvertToId().equals(""))
- continue;
- list.add(cfgs[i]);
- }
- }
- defaultConfigs = (IConfiguration[]) list
- .toArray(new IConfiguration[list.size()]);
- }
- if(defaultConfigs.length != 0){
- String namesAndDescriptions[] = new String[defaultConfigs.length];
- for (int i = 0; i < defaultConfigs.length; ++i) {
- if ( (defaultConfigs[i].getDescription() == null) || defaultConfigs[i].getDescription().equals("")) //$NON-NLS-1$
- namesAndDescriptions[i] = defaultConfigs[i].getName();
+ private void updateDefaultConfigs(){
+// IConfiguration cfgs[] = managedProject.getProjectType().getConfigurations();
+ if(defaultCfgds.length != 0){
+ String namesAndDescriptions[] = new String[defaultCfgds.length];
+ for (int i = 0; i < defaultCfgds.length; ++i) {
+ if ( (defaultCfgds[i].getDescription() == null) || defaultCfgds[i].getDescription().equals("")) //$NON-NLS-1$
+ namesAndDescriptions[i] = defaultCfgds[i].getName();
else
- namesAndDescriptions[i] = defaultConfigs[i].getName() + "( " + defaultConfigs[i].getDescription() + " )"; //$NON-NLS-1$ //$NON-NLS-2$
+ namesAndDescriptions[i] = defaultCfgds[i].getName() + "( " + defaultCfgds[i].getDescription() + " )"; //$NON-NLS-1$ //$NON-NLS-2$
}
int selectionIndex = copyConfigSelector.getSelectionIndex();
@@ -395,13 +361,12 @@ public class NewConfigurationDialog extends StatusDialog {
* clone.
*/
private String [] getDefinedConfigNamesAndDescriptions() {
- String [] namesAndDescriptions = new String[definedConfigs.length];
- for (int index = 0; index < definedConfigs.length; ++index) {
- IConfiguration config = definedConfigs[index];
- if ( (config.getDescription() == null) || config.getDescription().equals("")) //$NON-NLS-1$
- namesAndDescriptions[index] = config.getName();
+ String [] namesAndDescriptions = new String[definedCfgds.length];
+ for (int i = 0; i < definedCfgds.length; ++i) {
+ if ( (definedCfgds[i].getDescription() == null) || definedCfgds[i].getDescription().equals("")) //$NON-NLS-1$
+ namesAndDescriptions[i] = definedCfgds[i].getName();
else
- namesAndDescriptions[index] = config.getName() + "( " + config.getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$
+ namesAndDescriptions[i] = definedCfgds[i].getName() + "( " + definedCfgds[i].getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$
}
return namesAndDescriptions;
}
@@ -414,47 +379,18 @@ public class NewConfigurationDialog extends StatusDialog {
return newName;
}
- /* (non-Javadoc)
- * Answers <code>true</code> if the name entered by the user clashes
- * with an existing configuration name.
- *
- * @param newName
- * @return
- */
protected boolean isDuplicateName(String newName) {
- // Return true if there is already a config of that name defined
- for (int index = 0; index < definedConfigs.length; index++) {
- IConfiguration configuration = definedConfigs[index];
- if (configuration.getName().equals(newName)) {
+ for (int i = 0; i < definedCfgds.length; i++) {
+ if (definedCfgds[i].getName().equals(newName))
return true;
- }
- }
- if (reservedNames.contains(newName)) {
- return true;
}
return false;
}
-
- /* (non-Javadoc)
- * Answers <code>true</code> if the name entered by the user differs
- * only in case from an existing name.
- *
- * @param newName
- * @return
- */
+
protected boolean isSimilarName(String newName) {
- // Return true if there is already a config of that name defined on the target
- for (int index = 0; index < definedConfigs.length; index++) {
- IConfiguration configuration = definedConfigs[index];
- if (configuration.getName().equalsIgnoreCase(newName)) {
+ for (int i = 0; i < definedCfgds.length; i++) {
+ if (definedCfgds[i].getName().equalsIgnoreCase(newName))
return true;
- }
- }
- Iterator iter = reservedNames.listIterator();
- while (iter.hasNext()) {
- if (((String)iter.next()).equalsIgnoreCase(newName)) {
- return true;
- }
}
return false;
}
@@ -466,7 +402,7 @@ public class NewConfigurationDialog extends StatusDialog {
protected void updateComboState() {
cloneConfigSelector.setEnabled(clone);
copyConfigSelector.setEnabled(!clone);
- btnShowAll.setVisible(!clone);
+// btnShowAll.setVisible(!clone);
validateState();
}
@@ -512,7 +448,7 @@ public class NewConfigurationDialog extends StatusDialog {
*
*/
private void validateState() {
- StatusInfo status= new StatusInfo();
+ String s = null;
String currentName = configName.getText();
// Trim trailing whitespace
while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
@@ -521,21 +457,28 @@ public class NewConfigurationDialog extends StatusDialog {
// Make sure that the name is at least one character in length
if (currentName.length() == 0) {
// No error message, but cannot select OK
- status.setError(""); //$NON-NLS-1$
- } else if(clone ? definedConfigs.length == 0 : defaultConfigs.length == 0) {
- // Not an error
- status.setError(""); //$NON-NLS-1$
+ s = ""; //$NON-NLS-1$
+ } else if(clone ? definedCfgds.length == 0 : defaultCfgds.length == 0) {
+ s = ""; //$NON-NLS-1$
// Make sure the name is not a duplicate
} else if (isDuplicateName(currentName)) {
- status.setError(ManagedBuilderUIMessages.getFormattedString(DUPLICATE, currentName));
+ s = NewUIMessages.getFormattedString(DUPLICATE, currentName);
} else if (isSimilarName(currentName)) {
- status.setError(ManagedBuilderUIMessages.getFormattedString(CASE, currentName));
+ s = NewUIMessages.getFormattedString(CASE, currentName);
} else if (!validateName(currentName)) {
// TODO Create a decent I18N string to describe this problem
- status.setError(ManagedBuilderUIMessages.getFormattedString(INVALID, currentName));
+ s = NewUIMessages.getFormattedString(INVALID, currentName);
}
-
- updateStatus(status);
+ if (statusLabel == null) return;
+ Button b = getButton(IDialogConstants.OK_ID);
+ if (s != null) {
+ statusLabel.setText(s);
+ statusLabel.setVisible(true);
+ if (b != null) b.setEnabled(false);
+ } else {
+ statusLabel.setVisible(false);
+ if (b != null) b.setEnabled(true);
+ }
return;
}
public String getNewDescription() {
@@ -546,10 +489,32 @@ public class NewConfigurationDialog extends StatusDialog {
* Create a new configuration, using the values currently set in
* the dialog.
*/
- public IConfiguration newConfiguration(IManagedBuildInfo info) {
+ public ICConfigurationDescription newConfiguration() {
+ Configuration cfg = (Configuration)parentConfig;
+ String id = ManagedBuildManager.calculateChildId(cfg.getId(), null);
+ ManagedProject mp = (ManagedProject)ManagedBuildManager.getBuildInfo(des.getProject()).getManagedProject();
+// Configuration config = new Configuration(mp, (ToolChain)cfg.getToolChain(), id, getNewName());
+ Configuration config = new Configuration(mp, cfg, id, true, false);
+ config.setName(getNewName());
+ config.setDescription(getNewDescription());
+ CConfigurationData data = config.getConfigurationData();
+ try {
+ des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ } catch (CoreException e) {
+ System.out.println(Messages.getString("NewBuildConfigurationDialog.0")); //$NON-NLS-1$
+ System.out.println(Messages.getString("NewBuildConfigurationDialog.1") + e.getLocalizedMessage()); //$NON-NLS-1$
+ }
+ /*
+ String id = ManagedBuildManager.calculateChildId(base.getId(), null);
+ Configuration config = new Configuration(m, base, id, false, true);
+ CConfigurationData data = config.getConfigurationData();
+ mp.getProjectType().createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ IBuilder bld = config.getEditableBuilder();
+ if (bld != null) { bld.setManagedBuildOn(true); }
+
String newId = null;
- IConfiguration newConfig;
+ ICConfiguration newConfig;
if (parentConfig.isExtensionElement()) {
// If parent config is an extension element,
@@ -567,6 +532,13 @@ public class NewConfigurationDialog extends StatusDialog {
newConfig.setDescription(newDescription);
newConfig.setArtifactName(info.getManagedProject().getDefaultArtifactName());
return newConfig;
+ */
+
+ /*
+
+ */
+
+ return null;
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewCfgDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewCfgDialog.java
new file mode 100644
index 00000000000..3ea5f3f55d2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewCfgDialog.java
@@ -0,0 +1,432 @@
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.ui.newui.INewCfgDialog;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class NewCfgDialog implements INewCfgDialog {
+ private static final String PREFIX = "NewConfiguration"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String ERROR = PREFIX + ".error"; //$NON-NLS-1$
+ private static final String NAME = LABEL + ".name"; //$NON-NLS-1$
+ private static final String GROUP = LABEL + ".group"; //$NON-NLS-1$
+ private static final String DUPLICATE = ERROR + ".duplicateName"; //$NON-NLS-1$
+ private static final String CASE = ERROR + ".caseName"; //$NON-NLS-1$
+ private static final String INVALID = ERROR + ".invalidName"; //$NON-NLS-1$
+ private static final String DESCRIPTION = LABEL + ".description"; //$NON-NLS-1$
+ private static final String NULL = "[null]"; //$NON-NLS-1$
+ // Widgets
+ private Text configName;
+ private Text configDescription;
+ private Combo cloneConfigSelector;
+ private Combo realConfigSelector;
+ private Button b_clone;
+ private Button b_real;
+ private Label statusLabel;
+
+ /** Default configurations defined in the toolchain description */
+ private ICProjectDescription des;
+ private IConfiguration[] cfgds;
+ private IConfiguration[] rcfgs;
+ private IConfiguration parentConfig;
+ private String newName;
+ private String newDescription;
+ private String title;
+
+ protected Shell parentShell;
+
+ private class LocalDialog extends Dialog {
+ LocalDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(getShellStyle()|SWT.RESIZE);
+ }
+ /* (non-Javadoc)
+ * Method declared on Dialog. Cache the name and base config selections.
+ * We don't have to worry that the index or name is wrong because we
+ * enable the OK button IFF those conditions are met.
+ */
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+ newName = configName.getText().trim();
+ newDescription = configDescription.getText().trim();
+ if (b_clone.getSelection())
+ parentConfig = cfgds[cloneConfigSelector.getSelectionIndex()];
+ else // real cfg
+ parentConfig = rcfgs[realConfigSelector.getSelectionIndex()];
+ newConfiguration();
+ } else {
+ newName = null;
+ newDescription = null;
+ parentConfig = null;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null)
+ shell.setText(title);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ configName.setFocus();
+ if (configName != null) {
+ configName.setText(newName);
+ }
+ setButtons();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Create a group for the name & description
+
+ final Group group1 = new Group(composite, SWT.NONE);
+ group1.setFont(composite.getFont());
+ GridLayout layout1 = new GridLayout(3, false);
+ group1.setLayout(layout1);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ group1.setLayoutData(gd);
+
+ // Add a label and a text widget for Configuration's name
+ final Label nameLabel = new Label(group1, SWT.LEFT);
+ nameLabel.setFont(parent.getFont());
+ nameLabel.setText(NewUIMessages.getResourceString(NAME));
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ gd.grabExcessHorizontalSpace = false;
+ nameLabel.setLayoutData(gd);
+
+ configName = new Text(group1, SWT.SINGLE | SWT.BORDER);
+ configName.setFont(group1.getFont());
+ configName.setText(newName);
+ configName.setFocus();
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ configName.setLayoutData(gd);
+ configName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }
+ });
+
+// Add a label and a text widget for Configuration's description
+ final Label descriptionLabel = new Label(group1, SWT.LEFT);
+ descriptionLabel.setFont(parent.getFont());
+ descriptionLabel.setText(NewUIMessages.getResourceString(DESCRIPTION));
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ gd.grabExcessHorizontalSpace = false;
+ descriptionLabel.setLayoutData(gd);
+ configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
+ configDescription.setFont(group1.getFont());
+ configDescription.setText(newDescription);
+ configDescription.setFocus();
+
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ configDescription.setLayoutData(gd);
+
+ final Group group = new Group(composite, SWT.NONE);
+ group.setFont(composite.getFont());
+ group.setText(NewUIMessages.getResourceString(GROUP));
+ GridLayout layout = new GridLayout(2, false);
+ group.setLayout(layout);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ group.setLayoutData(gd);
+
+ b_clone = new Button(group, SWT.RADIO);
+ b_clone.setText(Messages.getString("NewCfgDialog.0")); //$NON-NLS-1$
+ gd = new GridData(GridData.BEGINNING);
+ b_clone.setLayoutData(gd);
+ b_clone.setSelection(true);
+ b_clone.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setButtons();
+ }
+ });
+
+ cloneConfigSelector = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+ cloneConfigSelector.setFont(group.getFont());
+ cloneConfigSelector.setItems(getConfigNamesAndDescriptions(cfgds, false));
+ int index = cloneConfigSelector.indexOf(newName);
+ cloneConfigSelector.select(index < 0 ? 0 : index);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ cloneConfigSelector.setLayoutData(gd);
+ cloneConfigSelector.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setButtons();
+ }
+ });
+
+ b_real = new Button(group, SWT.RADIO);
+ b_real.setText(Messages.getString("NewCfgDialog.1")); //$NON-NLS-1$
+ gd = new GridData(GridData.BEGINNING);
+ b_real.setLayoutData(gd);
+ b_real.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setButtons();
+ }
+ });
+
+ realConfigSelector = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+ realConfigSelector.setFont(group.getFont());
+ realConfigSelector.setItems(getConfigNamesAndDescriptions(rcfgs, true));
+ index = realConfigSelector.indexOf(newName);
+ realConfigSelector.select(index < 0 ? 0 : index);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ realConfigSelector.setLayoutData(gd);
+ realConfigSelector.setEnabled(false);
+ realConfigSelector.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setButtons();
+ }
+ });
+
+ statusLabel = new Label(composite, SWT.CENTER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ statusLabel.setLayoutData(gd);
+ statusLabel.setFont(composite.getFont());
+ statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
+
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * Update the status message and button state based on the input selected
+ * by the user
+ *
+ */
+ private void setButtons() {
+ String s = null;
+ String currentName = configName.getText();
+ // Trim trailing whitespace
+ while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
+ currentName = currentName.substring(0, currentName.length()-1);
+ }
+ // Make sure that the name is at least one character in length
+ if (currentName.length() == 0) {
+ // No error message, but cannot select OK
+ s = ""; //$NON-NLS-1$
+ } else if (cfgds.length == 0) {
+ s = ""; //$NON-NLS-1$
+ // Make sure the name is not a duplicate
+ } else if (isDuplicateName(currentName)) {
+ s = NewUIMessages.getFormattedString(DUPLICATE, currentName);
+ } else if (isSimilarName(currentName)) {
+ s = NewUIMessages.getFormattedString(CASE, currentName);
+ } else if (!validateName(currentName)) {
+ // TODO Create a decent I18N string to describe this problem
+ s = NewUIMessages.getFormattedString(INVALID, currentName);
+ }
+ if (statusLabel == null) return;
+ Button b = getButton(IDialogConstants.OK_ID);
+ if (s != null) {
+ statusLabel.setText(s);
+ statusLabel.setVisible(true);
+ if (b != null) b.setEnabled(false);
+ } else {
+ statusLabel.setVisible(false);
+ if (b != null) b.setEnabled(true);
+ }
+
+ cloneConfigSelector.setEnabled(b_clone.getSelection());
+ realConfigSelector.setEnabled(b_real.getSelection());
+ }
+
+}
+
+ public int open() {
+ if (parentShell == null) return 1;
+ LocalDialog dlg = new LocalDialog(parentShell);
+ return dlg.open();
+ }
+
+ /**
+ */
+ public NewCfgDialog() {
+ newName = new String();
+ newDescription = new String();
+ }
+
+ public void setShell(Shell shell) {
+ parentShell = shell;
+ }
+
+ public void setProject(ICProjectDescription prj) {
+ des = prj;
+ ICConfigurationDescription[] descs = des.getConfigurations();
+ cfgds = new IConfiguration[descs.length];
+ ArrayList lst = new ArrayList();
+ for (int i = 0; i < descs.length; ++i) {
+ cfgds[i] = ManagedBuildManager.getConfigurationForDescription(descs[i]);
+ IConfiguration cfg = cfgds[i];
+ for(; cfg != null && !cfg.isExtensionElement(); cfg = cfg.getParent());
+ if (cfg != null && !lst.contains(cfg)) lst.add(cfg);
+ }
+ rcfgs = (IConfiguration[])lst.toArray(new IConfiguration[lst.size()]);
+ }
+
+ public void setTitle(String _title) {
+ title = _title;
+ }
+
+
+ private String [] getConfigNamesAndDescriptions(IConfiguration[] arr, boolean check) {
+ String [] names = new String[arr.length];
+ for (int i = 0; i < arr.length; ++i)
+ names[i] = getNameAndDescription(arr[i]);
+
+ if (check) {
+ boolean doubles = false;
+ for (int i=0; i<names.length; i++) {
+ for (int j=0; j<names.length; j++) {
+ if (i != j && names[i].equals(names[j])) {
+ doubles = true;
+ break;
+ }
+ }
+ }
+ if (doubles) {
+ for (int i=0; i<names.length; i++) {
+ IToolChain tc = arr[i].getToolChain();
+ String s = (tc == null) ? NULL : tc.getName();
+ names[i] = names[i] + " : " + s; //$NON-NLS-1$
+ }
+ }
+ }
+ return names;
+ }
+
+ private String getNameAndDescription(IConfiguration cfg) {
+ String name = cfg.getName();
+ if (name == null) name = NULL;
+ if ( (cfg.getDescription() == null) || cfg.getDescription().equals("")) //$NON-NLS-1$
+ return name;
+ else
+ return name + "( " + cfg.getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ protected boolean isDuplicateName(String newName) {
+ for (int i = 0; i < cfgds.length; i++) {
+ if (cfgds[i].getName().equals(newName))
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean isSimilarName(String newName) {
+ for (int i = 0; i < cfgds.length; i++) {
+ if (cfgds[i].getName().equalsIgnoreCase(newName))
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * Checks the argument for leading whitespaces and invalid directory name characters.
+ * @param name
+ * @return <I>true</i> is the name is a valid directory name with no whitespaces
+ */
+ private boolean validateName(String name) {
+ // Names must be at least one character in length
+ if (name.trim().length() == 0)
+ return false;
+
+ // Iterate over the name checking for bad characters
+ char[] chars = name.toCharArray();
+ // No whitespaces at the start of a name
+ if (Character.isWhitespace(chars[0])) {
+ return false;
+ }
+ for (int index = 0; index < chars.length; ++index) {
+ // Config name must be a valid dir name too, so we ban "\ / : * ? " < >" in the names
+ if (!Character.isLetterOrDigit(chars[index])) {
+ switch (chars[index]) {
+ case '/':
+ case '\\':
+ case ':':
+ case '*':
+ case '?':
+ case '\"':
+ case '<':
+ case '>':
+ return false;
+ default:
+ break;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Create a new configuration, using the values currently set in
+ * the dialog.
+ */
+ private void newConfiguration() {
+ String id = ManagedBuildManager.calculateChildId(parentConfig.getId(), null);
+ IManagedProject imp = ManagedBuildManager.getBuildInfo(des.getProject()).getManagedProject();
+ if (imp == null || !(imp instanceof ManagedProject)) return;
+ ManagedProject mp = (ManagedProject) imp;
+ try {
+ Configuration config = new Configuration(mp, (Configuration)parentConfig, id, false, true);
+ CConfigurationData data = config.getConfigurationData();
+ ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ config.setConfigurationDescription(cfgDes);
+ config.exportArtifactInfo();
+ config.setName(newName);
+ config.setDescription(newDescription);
+ } catch (CoreException e) {
+ System.out.println("Cannot create config\n"+ e.getLocalizedMessage()); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/NewBuildMacroDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewVarDialog.java
index dd4293c4a60..308dd9cee50 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/NewBuildMacroDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/NewVarDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,20 +8,22 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.text.Collator;
import java.util.Arrays;
import java.util.Comparator;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.ui.properties.FileListControl;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -46,11 +48,11 @@ import org.eclipse.swt.widgets.Text;
/*
* the dialog used to create or edit the build macro
*/
-public class NewBuildMacroDialog extends StatusDialog {
+public class NewVarDialog extends StatusDialog {
// String constants
private static final String PREFIX = "NewBuildMacroDialog"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String NAME = LABEL + ".name"; //$NON-NLS-1$
+ private static final String ZNAME = LABEL + ".name"; //$NON-NLS-1$
private static final String VALUE = LABEL + ".value"; //$NON-NLS-1$
private static final String TYPE = LABEL + ".type"; //$NON-NLS-1$
@@ -70,30 +72,29 @@ public class NewBuildMacroDialog extends StatusDialog {
private static final String TITLE_NEW = LABEL + ".title.new"; //$NON-NLS-1$
private static final String TITLE_EDIT = LABEL + ".title.edit"; //$NON-NLS-1$
- private static final String STATUS = LABEL + ".status"; //$NON-NLS-1$
- private static final String STATUS_CANNOT_CTREATE = STATUS + ".cannot.create"; //$NON-NLS-1$
+// private static final String STATUS = LABEL + ".status"; //$NON-NLS-1$
+// private static final String STATUS_CANNOT_CTREATE = STATUS + ".cannot.create"; //$NON-NLS-1$
private static final String EMPTY_STRING = new String();
// The title of the dialog.
private String fTitle;
// hold the macro being edited(in the case of the "edit" mode)
- private IBuildMacro fEditedMacro;
- //the macros block block from which the dialog was called
- private MacrosBlock fMacrosBlock;
+ private ICdtVariable fEditedMacro;
//the resulting macro. Can be accessed only when the dialog is closed
- private IBuildMacro fResultingMacro;
+ private ICdtVariable fResultingMacro;
//the string that holds the value is used in the "replace" operation
- private String fReplaceValue = null;
+ //private String fReplaceValue = null;
//the string that holds the value is used in the "append/prepend" operations
- private String fAppPrepValue = null;
+ //private String fAppPrepValue = null;
//specifies whether the fAppPrepValue holds the prepended or appended value
- private boolean fAppPrepPrepend = true;
+ //private boolean fAppPrepPrepend = true;
private boolean fTotalSizeCalculated;
private String fTypedName;
private int fTypedType = -1;
+ public boolean isForAllCfgs = false;
// Widgets
// protected Text fMacroNameEdit;
@@ -106,16 +107,17 @@ public class NewBuildMacroDialog extends StatusDialog {
private Composite fListEditorContainier;
private FileListControl fListEditor;
+ ICConfigurationDescription cfgd;
+
-
- public NewBuildMacroDialog(Shell parentShell, MacrosBlock macrosBlock, IBuildMacro editedMacro) {
+ public NewVarDialog(Shell parentShell, ICdtVariable editedMacro, ICConfigurationDescription _cfgd) {
super(parentShell);
+ cfgd = _cfgd;
if(editedMacro != null)
- fTitle = ManagedBuilderUIMessages.getResourceString(TITLE_EDIT);
+ fTitle = NewUIMessages.getResourceString(TITLE_EDIT);
else
- fTitle = ManagedBuilderUIMessages.getResourceString(TITLE_NEW);
+ fTitle = NewUIMessages.getResourceString(TITLE_NEW);
fEditedMacro = editedMacro;
- fMacrosBlock = macrosBlock;
}
/* (non-Javadoc)
@@ -141,7 +143,7 @@ public class NewBuildMacroDialog extends StatusDialog {
Label nameLabel = new Label(comp, SWT.LEFT);
nameLabel.setFont(comp.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(NAME));
+ nameLabel.setText(Messages.getString("NewVarDialog.0")); //$NON-NLS-1$
nameLabel.setLayoutData(new GridData());
// fMacroNameEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
@@ -162,12 +164,24 @@ public class NewBuildMacroDialog extends StatusDialog {
handleMacroNameSelection();
}
});
+
+ if (fEditedMacro == null && cfgd != null) {
+ Button c_all = new Button(comp, SWT.CHECK);
+ c_all.setText(Messages.getString("NewVarDialog.1")); //$NON-NLS-1$
+ gd = new GridData(GridData.BEGINNING);
+ gd.horizontalSpan = 3;
+ c_all.setLayoutData(gd);
+ c_all.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e){
+ isForAllCfgs = ((Button)e.widget).getSelection();
+ }
+ });
+ }
Label typeLabel = new Label(comp, SWT.LEFT);
typeLabel.setFont(comp.getFont());
- typeLabel.setText(ManagedBuilderUIMessages.getResourceString(TYPE));
+ typeLabel.setText(NewUIMessages.getResourceString(TYPE));
gd = new GridData();
- gd.horizontalSpan = 1;
typeLabel.setLayoutData(gd);
fTypeSelector = new Combo(comp, SWT.READ_ONLY|SWT.DROP_DOWN);
@@ -176,14 +190,14 @@ public class NewBuildMacroDialog extends StatusDialog {
// gd.widthHint = 100;
fTypeSelector.setLayoutData(gd);
fTypeSelector.setItems(new String[]{
- ManagedBuilderUIMessages.getResourceString(TYPE_TEXT),
- ManagedBuilderUIMessages.getResourceString(TYPE_TEXT_LIST),
- ManagedBuilderUIMessages.getResourceString(TYPE_PATH_FILE),
- ManagedBuilderUIMessages.getResourceString(TYPE_PATH_FILE_LIST),
- ManagedBuilderUIMessages.getResourceString(TYPE_PATH_DIR),
- ManagedBuilderUIMessages.getResourceString(TYPE_PATH_DIR_LIST),
- ManagedBuilderUIMessages.getResourceString(TYPE_PATH_ANY),
- ManagedBuilderUIMessages.getResourceString(TYPE_PATH_ANY_LIST)
+ NewUIMessages.getResourceString(TYPE_TEXT),
+ NewUIMessages.getResourceString(TYPE_TEXT_LIST),
+ NewUIMessages.getResourceString(TYPE_PATH_FILE),
+ NewUIMessages.getResourceString(TYPE_PATH_FILE_LIST),
+ NewUIMessages.getResourceString(TYPE_PATH_DIR),
+ NewUIMessages.getResourceString(TYPE_PATH_DIR_LIST),
+ NewUIMessages.getResourceString(TYPE_PATH_ANY),
+ NewUIMessages.getResourceString(TYPE_PATH_ANY_LIST)
});
setSelectedType(IBuildMacro.VALUE_TEXT);
@@ -195,7 +209,7 @@ public class NewBuildMacroDialog extends StatusDialog {
fMacroValueLabel = new Label(comp, SWT.LEFT);
fMacroValueLabel.setFont(comp.getFont());
- fMacroValueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE));
+ fMacroValueLabel.setText(NewUIMessages.getResourceString(VALUE));
gd = new GridData();
gd.horizontalSpan = 1;
fMacroValueLabel.setLayoutData(gd);
@@ -214,7 +228,7 @@ public class NewBuildMacroDialog extends StatusDialog {
fBrowseButton = new Button(comp,SWT.PUSH);
fBrowseButton.setFont(comp.getFont());
- fBrowseButton.setText(ManagedBuilderUIMessages.getResourceString(BROWSE));
+ fBrowseButton.setText(NewUIMessages.getResourceString(BROWSE));
fBrowseButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
handleBrowseButtonPressed();
@@ -232,11 +246,12 @@ public class NewBuildMacroDialog extends StatusDialog {
fListEditorContainier.setLayoutData(gd);
fListEditorContainier.setLayout(new GridLayout());
- fListEditor = new FileListControl(fListEditorContainier, ManagedBuilderUIMessages.getResourceString(LIST_TITLE), IOption.BROWSE_NONE);
+ fListEditor = new FileListControl(fListEditorContainier, NewUIMessages.getResourceString(LIST_TITLE), IOption.BROWSE_NONE);
/* Enable workspace support for list editor */
fListEditor.setWorkspaceSupport(true);
-
- fListEditor.setContext(fMacrosBlock.getContextInfo());
+
+ // TODO: getContextInfo
+ // fListEditor.setContext(fMacrosBlock.getContextInfo());
if(fEditedMacro != null){
loadMacroSettings(fEditedMacro,true);
@@ -250,7 +265,9 @@ public class NewBuildMacroDialog extends StatusDialog {
* get the names to be displayed in the var Name combo.
*/
private String[] getMacroNames(){
- IBuildMacro macros[] = fMacrosBlock.getSystemMacros(true);
+ IBuildMacro macros[] = null;
+ //TODO:
+ //fMacrosBlock.getSystemMacros(true);
String names[] = null;
if(macros == null || macros.length == 0)
names = new String[0];
@@ -262,9 +279,9 @@ public class NewBuildMacroDialog extends StatusDialog {
final Collator collator = Collator.getInstance();
Arrays.sort(names, new Comparator() {
- public int compare(Object a, Object b) {
- String strA = ((String)a).toUpperCase();
- String strB = ((String)b).toUpperCase();
+ public int compare(final Object a, final Object b) {
+ final String strA = ((String)a).toUpperCase();
+ final String strB = ((String)b).toUpperCase();
return collator.compare(strA,strB);
}
});
@@ -324,7 +341,9 @@ public class NewBuildMacroDialog extends StatusDialog {
}
private void loadMacroSettings(String name){
- IBuildMacro macro = fMacrosBlock.getSystemMacro(name,true);
+ IBuildMacro macro = null;
+ // TODO:
+ // fMacrosBlock.getSystemMacro(name,true);
if(macro != null)
loadMacroSettings(macro,false);
else
@@ -356,13 +375,13 @@ public class NewBuildMacroDialog extends StatusDialog {
/*
* loads all the dialog fields with the variable settings
*/
- private void loadMacroSettings(IBuildMacro macro, boolean isUser){
+ private void loadMacroSettings(ICdtVariable var, boolean isUser){
try{
- if(MacroResolver.isStringListMacro(macro.getMacroValueType()))
- loadMacroSettings(macro.getName(),macro.getMacroValueType(),macro.getStringListValue());
+ if(CdtVariableResolver.isStringListVariable(var.getValueType()))
+ loadMacroSettings(var.getName(),var.getValueType(),var.getStringListValue());
else
- loadMacroSettings(macro.getName(),macro.getMacroValueType(),macro.getStringValue());
- }catch(BuildMacroException e){
+ loadMacroSettings(var.getName(),var.getValueType(),var.getStringValue());
+ }catch(CdtVariableException e){
}
}
@@ -462,7 +481,7 @@ public class NewBuildMacroDialog extends StatusDialog {
String name = getSelectedVarName();
if(name != null || !EMPTY_STRING.equals(name)){
int type = getSelectedType();
- if(MacroResolver.isStringListMacro(type))
+ if(CdtVariableResolver.isStringListVariable(type))
fResultingMacro = new BuildMacro(name,type,getSelectedStringListValue());
else
fResultingMacro = new BuildMacro(name,type,getSelectedStringValue());
@@ -496,7 +515,7 @@ public class NewBuildMacroDialog extends StatusDialog {
* if the variable was not created, e.g. because a user has pressed
* the cancel button this method returns null
*/
- public IBuildMacro getDefinedMacro(){
+ public ICdtVariable getDefinedMacro(){
return fResultingMacro;
}
@@ -536,7 +555,7 @@ public class NewBuildMacroDialog extends StatusDialog {
GridData editGd = (GridData)fMacroValueEdit.getLayoutData();
GridData browseGd = (GridData)fBrowseButton.getLayoutData();
- if(MacroResolver.isStringListMacro(type)){
+ if(CdtVariableResolver.isStringListVariable(type)){
listGd.exclude = false;
labelGd.exclude = true;
editGd.exclude = true;
@@ -546,7 +565,8 @@ public class NewBuildMacroDialog extends StatusDialog {
fMacroValueLabel.setVisible(false);
fMacroValueEdit.setVisible(false);
fBrowseButton.setVisible(false);
- } else {
+ } else
+ {
listGd.exclude = true;
labelGd.exclude = false;
editGd.exclude = false;
@@ -598,11 +618,11 @@ public class NewBuildMacroDialog extends StatusDialog {
// Not an error
status.setError(""); //$NON-NLS-1$
}
- else if(!fMacrosBlock.canCreate(name)){
- status.setError(ManagedBuilderUIMessages.getFormattedString(STATUS_CANNOT_CTREATE, name));
- }
-
+ //TODO:
+ //else if(!fMacrosBlock.canCreate(name)){
+ // status.setError(ManagedBuilderUIMessages.getFormattedString(STATUS_CANNOT_CTREATE, name));
+ //}
updateStatus(status);
return;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PageLayout.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PageLayout.java
new file mode 100644
index 00000000000..5efb395ab7d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PageLayout.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+
+
+/**
+ * Layout for the page container.
+ *
+ */
+public class PageLayout extends Layout {
+
+ /**
+ * The minimum page size; 200 by 200 by default.
+ *
+ * @see #setMinimumPageSize
+ */
+ private Point minimumPageSize = new Point(200, 200);
+
+ public void layout(Composite composite, boolean force) {
+ Rectangle rect = composite.getClientArea();
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ children[i].setSize(rect.width, rect.height);
+ }
+ }
+ public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
+ if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
+ return new Point(wHint, hHint);
+ }
+ int x = minimumPageSize.x;
+ int y = minimumPageSize.y;
+
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
+ x = Math.max(x, size.x);
+ y = Math.max(y, size.y);
+ }
+ if (wHint != SWT.DEFAULT) {
+ x = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ y = hHint;
+ }
+ return new Point(x, y);
+ }
+}
+
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PrefPage_NewCDTProject.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PrefPage_NewCDTProject.java
new file mode 100644
index 00000000000..ee899e2402e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/PrefPage_NewCDTProject.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.ui.newui.AbstractPrefPage;
+import org.eclipse.core.runtime.CoreException;
+
+public class PrefPage_NewCDTProject extends AbstractPrefPage {
+ protected boolean isSingle() { return false; }
+
+ private static ICConfigurationDescription prefCfgd = null;
+
+ public ICResourceDescription getResDesc() {
+ if (prefCfgd == null)
+ try {
+ prefCfgd = CCorePlugin.getDefault().getPreferenceConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID);
+ } catch (CoreException e) { return null; }
+ return prefCfgd.getRootFolderDescription();
+ }
+
+ public boolean performOk() {
+ try {
+ CCorePlugin.getDefault().setPreferenceConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, prefCfgd);
+ } catch (CoreException e) { return false; }
+ return true;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolChainEditTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolChainEditTab.java
new file mode 100644
index 00000000000..e86b390e96e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolChainEditTab.java
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+
+public class ToolChainEditTab extends AbstractCBuildPropertyTab {
+ private static final IToolChain[] r_tcs = ManagedBuildManager.getRealToolChains();
+ private static final IBuilder[] r_bs = ManagedBuildManager.getRealBuilders();
+ private static final ITool[] r_tools = ManagedBuildManager.getRealTools();
+
+ private Text text;
+ private Button b_dispCompatible;
+ private Combo c_toolchain;
+ private Combo c_builder;
+
+ private IBuilder[] v_bs;
+ private IToolChain[] v_tcs;
+ private ITool[] v_tools;
+
+ private IConfiguration cfg;
+ private IResourceInfo ri;
+ private IFolderInfo fi;
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(2, false));
+
+ b_dispCompatible = setupCheck(usercomp, Messages.getString("ToolChainEditTab.0"), 2, GridData.BEGINNING); //$NON-NLS-1$
+
+
+ setupLabel(usercomp, Messages.getString("ToolChainEditTab.1"), 2, GridData.BEGINNING); //$NON-NLS-1$
+ c_toolchain = new Combo(usercomp, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ c_toolchain.setLayoutData(gd);
+ c_toolchain.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (fi != null) {
+ int x = c_toolchain.getSelectionIndex();
+ IToolChain tc = v_tcs[x];
+ if (tc == null) return;
+ try {
+ fi.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
+ } catch (BuildException be) {}
+ updateData();
+ }
+ }});
+ c_toolchain.setEnabled(!page.isForFile());
+
+ setupLabel(usercomp, Messages.getString("ToolChainEditTab.2"), 2, GridData.BEGINNING); //$NON-NLS-1$
+ c_builder = new Combo(usercomp, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ c_builder.setLayoutData(gd);
+ c_builder.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int x = c_builder.getSelectionIndex();
+ IBuilder b = v_bs[x];
+ cfg.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
+ updateData();
+ }});
+ c_builder.setEnabled(page.isForProject());
+
+ // make table for tools list
+ Group g = setupGroup(usercomp, Messages.getString("ToolChainEditTab.3"), 2, GridData.FILL_BOTH); //$NON-NLS-1$
+
+ text = new Text(g, SWT.BORDER | SWT.WRAP | SWT.MULTI |
+ SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ text.setLayoutData(gd);
+
+ Button b = new Button(g, SWT.PUSH);
+ GridData gdb = new GridData(GridData.VERTICAL_ALIGN_CENTER);
+ gdb.grabExcessHorizontalSpace = false;
+ gdb.horizontalAlignment = SWT.FILL;
+ gdb.widthHint = 80;
+ b.setLayoutData(gdb);
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell());
+ d.all = v_tools;
+ d.fi = fi;
+ int result = d.open();
+ if (result == 0 && (d.removed.size() > 0 || d.added.size() > 0)) {
+ try {
+ fi.modifyToolChain(
+ (ITool[])d.removed.toArray(new ITool[d.removed.size()]),
+ (ITool[])d.added.toArray(new ITool[d.added.size()]));
+ } catch (BuildException b) {}
+ updateData();
+ }
+ }});
+
+ b.setLayoutData(new GridData(GridData.END));
+ b.setText(Messages.getString("ToolChainEditTab.4")); //$NON-NLS-1$
+ }
+ public void updateData(ICResourceDescription rcfg) {
+ cfg = getCfg(rcfg.getConfiguration());
+ ri = cfg.getResourceInfo(rcfg.getPath(), false);
+ if (ri instanceof IFolderInfo)
+ fi = (IFolderInfo)ri;
+ else
+ fi = null;
+ updateData();
+ }
+ private void updateData() {
+ v_tcs = new IToolChain[r_tcs.length];
+ v_bs = new IBuilder[r_bs.length];
+ v_tools = new ITool[r_tools.length];
+
+ IToolChain tc = null;
+ if (fi != null) {
+ tc = ManagedBuildManager.getRealToolChain(fi.getToolChain());
+ }
+
+ int cnt = 0;
+ int pos = -1;
+ c_toolchain.removeAll();
+ for (int i=0; i<r_tcs.length; i++) {
+ if (r_tcs[i].isSystemObject()) continue;
+ if (b_dispCompatible.getSelection() &&
+ fi != null && ! fi.isToolChainCompatible(r_tcs[i]))
+ continue;
+ c_toolchain.add(r_tcs[i].getUniqueRealName());
+ v_tcs[cnt] = r_tcs[i];
+ if (r_tcs[i].equals(tc)) pos = cnt;
+ cnt++;
+ }
+ if (pos != -1)
+ c_toolchain.select(pos);
+ else
+ c_toolchain.setText(EMPTY_STR);
+
+ IBuilder b = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
+ cnt = 0;
+ pos = -1;
+ c_builder.removeAll();
+ for (int i=0; i<r_bs.length; i++) {
+ if (r_bs[i].isSystemObject()) continue;
+ if (b_dispCompatible.getSelection() &&
+ ! cfg.isBuilderCompatible(r_bs[i]))
+ continue; // not compatible builder
+ c_builder.add(r_bs[i].getUniqueRealName());
+ v_bs[cnt] = r_bs[i];
+ if (r_bs[i].equals(b)) pos = cnt;
+ cnt++;
+ }
+ if (pos != -1)
+ c_builder.select(pos);
+ else
+ c_builder.setText(EMPTY_STR);
+
+ cnt = 0;
+ for (int i=0; i<r_tools.length; i++) {
+ if (r_tools[i].isSystemObject()) continue;
+ v_tools[cnt++] = r_tools[i];
+ }
+ ITool[] tmp = new ITool[cnt];
+ System.arraycopy(v_tools, 0, tmp, 0, cnt);
+ v_tools = tmp;
+
+ if (fi != null) {
+ ITool[] tools = fi.getTools();
+ String s = EMPTY_STR;
+ for (int i = 0; i < tools.length; i++) {
+ s = s + tools[i].getUniqueRealName() + "\n"; //$NON-NLS-1$
+ }
+ text.setText(s);
+ }
+
+ }
+
+ public void checkPressed(SelectionEvent e) {
+ updateData();
+ }
+ public void performApply(ICResourceDescription src,
+ ICResourceDescription dst) {
+ IConfiguration cfg1 = getCfg(src.getConfiguration());
+ IConfiguration cfg2 = getCfg(dst.getConfiguration());
+ IBuilder b = cfg1.getBuilder();
+ cfg2.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
+ IResourceInfo ri1 = cfg1.getResourceInfo(src.getPath(), false);
+ IResourceInfo ri2 = cfg2.getResourceInfo(dst.getPath(), false);
+ if (ri1 instanceof IFolderInfo && ri2 instanceof IFolderInfo) {
+ IFolderInfo fi1 = (IFolderInfo)ri1;
+ IFolderInfo fi2 = (IFolderInfo)ri2;
+ IToolChain tc = fi1.getToolChain();
+ ITool[] tools1 = fi1.getTools();
+ ITool[] tools2 = fi2.getTools();
+ try {
+ fi2.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
+ fi2.modifyToolChain(tools2, tools1);
+ } catch (BuildException e) {}
+ } else {}
+ }
+
+ protected void performDefaults() {
+ updateData();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListContentProvider.java
index 0d04accfa0f..bb3b2695f43 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 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
@@ -9,27 +9,35 @@
* Timesys - Initial API and implementation
* IBM Rational Software
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
-import org.eclipse.cdt.managedbuilder.core.*;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
public class ToolListContentProvider implements ITreeContentProvider{
public static final int FILE = 0x1;
+ public static final int FOLDER = 0x2;
public static final int PROJECT = 0x4;
- private IConfiguration configRoot;
- private IResourceConfiguration resConfigRoot;
+ private IResourceInfo fInfo;
private int elementType;
private ToolListElement[] elements;
/**
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
- public void dispose() {
- }
+ public void dispose() {}
public ToolListContentProvider(int elementType) {
this.elementType = elementType;
@@ -61,10 +69,16 @@ public class ToolListContentProvider implements ITreeContentProvider{
return (ToolListElement[])elementList.toArray(new ToolListElement[elementList.size()]);
}
- private ToolListElement[] createElements(IResourceConfiguration resConfig) {
+ private ToolListElement[] createElements(IResourceInfo info) {
List elementList = new ArrayList();
- if (resConfig != null) {
- ITool[] tools = resConfig.getTools();
+ if (info != null) {
+ ITool[] tools = null;
+ if(info instanceof IFolderInfo){
+ tools = ((IFolderInfo)info).getFilteredTools();
+ } else {
+ tools = ((IFileInfo)info).getToolsToInvoke();
+ }
+
// Create an element for each one
for (int i=0; i<tools.length; i++) {
ToolListElement e = new ToolListElement(tools[i]);
@@ -128,23 +142,13 @@ public class ToolListContentProvider implements ITreeContentProvider{
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // If the input hasn't changed, there is no reason to re-create the content
- if (oldInput == newInput) return;
-
- if(elementType == FILE) {
- resConfigRoot = (IResourceConfiguration)newInput;
- configRoot = null;
- // Create a ToolListElement to represent each item that will appear
- // in the TreeViewer.
- elements = createElements(resConfigRoot);
- }
- else if(elementType == PROJECT) {
- configRoot = (IConfiguration) newInput;
- resConfigRoot = null;
- // Create a ToolListElement to represent each item that will appear
- // in the TreeViewer.
- elements = createElements(configRoot);
- }
+ if (newInput == null || oldInput == newInput) return;
+ fInfo = (IResourceInfo)newInput;
+ if (elementType == PROJECT)
+ elements = createElements(fInfo.getParent());
+ else
+ elements = createElements(fInfo);
+
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListElement.java
index b49cf4c2b90..16cd4e2520a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListElement.java
@@ -9,14 +9,16 @@
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import org.eclipse.cdt.managedbuilder.core.*;
-import org.eclipse.cdt.managedbuilder.internal.core.OptionCategory;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.internal.core.OptionCategory;
+
/*******************************************************************************
* This class represent the elements in the TreeViewer that displays the tools
* and categories in the tool options property pages. The reason for these
@@ -60,7 +62,7 @@ public class ToolListElement {
ITool matchTool = e.getTool();
if (matchTool == tool) return true;
if (matchTool == null) return false;
- if (matchTool.getName().equals(tool.getName())) return true;
+ if (matchTool.getName().equals(tool.getUniqueRealName())) return true;
return false;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListLabelProvider.java
index ddb9c1d0587..96602c9d3b4 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolListLabelProvider.java
@@ -8,15 +8,13 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.net.URL;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.ResourceManager;
@@ -93,7 +91,7 @@ public class ToolListLabelProvider extends LabelProvider {
if (cat == null) {
ITool tool = toolListElement.getTool();
- return tool.getName();
+ return tool.getUniqueRealName();
}
else {
return cat.getName();
@@ -101,7 +99,7 @@ public class ToolListLabelProvider extends LabelProvider {
}
protected RuntimeException unknownElement(Object element) {
- return new RuntimeException(ManagedBuilderUIMessages.getFormattedString(ERROR_UNKNOWN_ELEMENT, element.getClass().getName()));
+ return new RuntimeException(NewUIMessages.getFormattedString(ERROR_UNKNOWN_ELEMENT, element.getClass().getName()));
}
/**
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSelectionDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSelectionDialog.java
new file mode 100644
index 00000000000..f23a9938f7d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSelectionDialog.java
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class ToolSelectionDialog extends StatusDialog {
+
+ private Table t1, t2;
+ private CLabel errorLabel;
+ public ITool[] all, used;
+ public IFolderInfo fi;
+ ArrayList added, removed, left, right;
+ Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+ Color red;
+
+ public ToolSelectionDialog(Shell shell ) {
+ super (shell);
+ this.setTitle(Messages.getString("ToolSelectionDialog.0")); //$NON-NLS-1$
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout(3, false));
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 300;
+ composite.setLayoutData(gd);
+
+ added = new ArrayList();
+ removed = new ArrayList();
+ left = new ArrayList();
+ right = new ArrayList();
+
+ t1 = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ t1.setLayoutData(new GridData(GridData.FILL_BOTH));
+ t1.setHeaderVisible(true);
+ t1.setLinesVisible(true);
+
+ TableColumn col = new TableColumn(t1, SWT.NONE);
+ col.setText(Messages.getString("ToolSelectionDialog.1")); //$NON-NLS-1$
+ col.setWidth(200);
+
+ Composite c2 = new Composite(composite, SWT.BORDER);
+ c2.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ t2 = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ t2.setLayoutData(new GridData(GridData.FILL_BOTH));
+ t2.setHeaderVisible(true);
+ t2.setLinesVisible(true);
+
+ col = new TableColumn(t2, SWT.NONE);
+ col.setText(Messages.getString("ToolSelectionDialog.2")); //$NON-NLS-1$
+ col.setWidth(200);
+
+ Display display = composite.getDisplay();
+ red = display.getSystemColor(SWT.COLOR_RED);
+ /*
+ Color gray = display.getSystemColor(SWT.COLOR_GRAY);
+ ti.setForeground(0, red);
+ ti = new TableItem(t3, 0);
+ ti.setForeground(0, red);
+ */
+
+ c2.setLayout(new GridLayout(1, false));
+ Button b1 = new Button(c2, SWT.PUSH);
+ b1.setText(" > "); //$NON-NLS-1$
+ b1.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int x = t1.getSelectionIndex();
+ ITool tool = (ITool)t1.getItem(x).getData();
+ left.remove(tool);
+ right.add(tool);
+ updateData(true);
+ }});
+ Button b2 = new Button(c2, SWT.PUSH);
+ b2.setText(" < "); //$NON-NLS-1$
+ b2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b2.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int x = t2.getSelectionIndex();
+ ITool tool = (ITool)t2.getItem(x).getData();
+ right.remove(tool);
+ left.add(ManagedBuildManager.getRealTool(tool));
+ updateData(true);
+ }});
+
+ errorLabel = new CLabel(composite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ errorLabel.setLayoutData(gd);
+ errorLabel.setForeground(red);
+
+ used = fi.getTools();
+ for (int i=0; i< used.length; i++) {
+ right.add(used[i]);
+ for (int j = 0; j<all.length; j++) {
+ if (all[j] != null && all[j].matches(used[i]))
+ all[j] = null;
+ }
+ }
+ for (int j = 0; j<all.length; j++) {
+ if (all[j] != null) left.add(all[j]);
+ }
+ updateData(false);
+
+ return composite;
+ }
+
+ private void add(ITool tool, Table table, boolean bold) {
+ TableItem ti = new TableItem(table, 0);
+ ti.setText(tool.getUniqueRealName());
+ if (bold) ti.setFont(boldFont);
+ ti.setData(tool);
+ }
+
+ private void updateData(boolean check) {
+ removed.clear();
+ added.clear();
+ t1.removeAll();
+ t2.removeAll();
+ Iterator it = left.iterator();
+ while(it.hasNext()) {
+ ITool t = (ITool)it.next();
+ boolean exists = false;
+ for (int i=0; i<all.length; i++) {
+ if (all[i] != null && t.matches(all[i])) {
+ exists = true;
+ break;
+ }
+ }
+ if (!exists) removed.add(t);
+ add(t, t1, !exists);
+ }
+ it = right.iterator();
+ while(it.hasNext()) {
+ ITool t = (ITool)it.next();
+ boolean exists = false;
+ for (int i=0; i<used.length; i++) {
+ if (t.matches(used[i])) {
+ exists = true;
+ break;
+ }
+ }
+ if (!exists) added.add(t);
+ add(t, t2, !exists);
+ }
+ if (check && removed.size() > 0 || added.size() > 0) {
+ IModificationStatus st = fi.getToolChainModificationStatus(
+ (ITool[])removed.toArray(new ITool[removed.size()]),
+ (ITool[])added.toArray(new ITool[added.size()]));
+ if (st.isOK()) {
+ errorLabel.setText(""); //$NON-NLS-1$
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ } else {
+ int c = st.getCode();
+ String s = ""; //$NON-NLS-1$
+ if ((c & IModificationStatus.TOOLS_CONFLICT) != 0) {
+ s = s + Messages.getString("ToolSelectionDialog.7"); //$NON-NLS-1$
+ ITool[][] tools = st.getToolsConflicts();
+ for (int k=0; k<t2.getItemCount(); k++) {
+ TableItem ti = t2.getItem(k);
+ ITool t = (ITool)ti.getData();
+ loop:
+ for (int i=0;i<tools.length;i++) {
+ for (int j=0;j<tools[i].length;j++) {
+ if (t.matches(tools[i][j])) {
+ ti.setForeground(red);
+ break loop;
+ }
+ }
+ }
+ }
+ }
+ if ((c & IModificationStatus.TOOLS_DONT_SUPPORT_MANAGED_BUILD) != 0) {
+ s = s + Messages.getString("ToolSelectionDialog.8"); //$NON-NLS-1$
+ ITool[] tools = st.getNonManagedBuildTools();
+ for (int k=0; k<t2.getItemCount(); k++) {
+ TableItem ti = t2.getItem(k);
+ ITool t = (ITool)ti.getData();
+ for (int i=0;i<tools.length;i++) {
+ if (t.matches(tools[i])) {
+ ti.setForeground(red);
+ break;
+ }
+ }
+ }
+
+ }
+ if ((c & IModificationStatus.PROPS_NOT_DEFINED) != 0) {
+ s = s + Messages.getString("ToolSelectionDialog.9"); //$NON-NLS-1$
+ }
+ if ((c & IModificationStatus.PROPS_NOT_SUPPORTED) != 0) {
+ s = s + Messages.getString("ToolSelectionDialog.10"); //$NON-NLS-1$
+ }
+ if ((c & IModificationStatus.REQUIRED_PROPS_NOT_SUPPORTED) != 0) {
+ s = s + Messages.getString("ToolSelectionDialog.11"); //$NON-NLS-1$
+ }
+ errorLabel.setText(s);
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPreferenceStore.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSettingsPrefStore.java
index 73c28f18f18..d9b6c787706 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPreferenceStore.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSettingsPrefStore.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,109 +8,58 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.managedbuilder.ui.newui;
import java.util.Collection;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Option;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
-import org.eclipse.cdt.managedbuilder.internal.ui.MacrosSetBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ToolsSettingsBlock;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildfileMacroSubstitutor;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
-public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
+public class ToolSettingsPrefStore implements IPreferenceStore {
public static final String DEFAULT_SEPERATOR = ";"; //$NON-NLS-1$
private final static String EMPTY_STRING = new String();
- private final static String WHITESPACE = " "; //$NON-NLS-1$
+
+ static ToolSettingsPrefStore store = null;
public final static String ALL_OPTIONS_ID = EMPTY_STRING;
- public final static String COMMAND_LINE_PATTERN_ID = "org.eclipse.commandLinePatternId";
- private IConfiguration config;
- private IResourceConfiguration rcConfig;
+ public final static String COMMAND_LINE_PATTERN_ID = Messages.getString("ToolSettingsPrefStore.0"); //$NON-NLS-1$
+ private IResourceInfo rcInfo = null;
private IOptionCategory optCategory;
private ToolListElement selectedElement;
private ListenerList listenerList;
private boolean dirtyFlag;
-
- private ToolsSettingsBlock block;
-
- //macro substitutor used in the macro resolution in UI
- //resolves all macros except for the option-specific macros
- //and the explicit file macros
- public class UIMacroSubstitutor extends DefaultMacroSubstitutor {
- private BuildMacroProvider fProvider;
-
- public UIMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter, BuildMacroProvider provider){
- super(contextType,contextData,inexistentMacroValue,listDelimiter);
- fProvider = provider;
- }
- public UIMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
- super(contextInfo,inexistentMacroValue,listDelimiter);
- }
-
- protected IMacroContextInfo getMacroContextInfo(int contextType, Object contextData){
- if(fProvider != null)
- return fProvider.getMacroContextInfo(contextType,contextData);
- return super.getMacroContextInfo();
- }
-
-
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
- if(macro instanceof MbsMacroSupplier.FileContextMacro){
- MbsMacroSupplier.FileContextMacro fileMacro = (MbsMacroSupplier.FileContextMacro)macro;
- if(fileMacro.isExplicit()){
- String name = macro.getName();
- return new ResolvedMacro(name,MacroResolver.createMacroReference(name));
- }
- } else if (macro instanceof MbsMacroSupplier.OptionMacro) {
- String name = macro.getName();
- return new ResolvedMacro(name,MacroResolver.createMacroReference(name));
- }
- return super.resolveMacro(macro);
- }
+ public static ToolSettingsPrefStore getDefault() {
+ if (store == null)
+ store = new ToolSettingsPrefStore();
+ return store;
}
-
- public BuildToolSettingsPreferenceStore(ToolsSettingsBlock block){
- this.block = block;
- }
-
- public void setSelection(IConfiguration cfg, ToolListElement element, IOptionCategory category){
+ public void setSelection(ICResourceDescription rd, ToolListElement element, IOptionCategory category){
selectedElement = element;
optCategory = category;
- rcConfig = null;
- config = cfg;
+ rcInfo = get(rd);
}
- public void setSelection(IResourceConfiguration cfg, ToolListElement element, IOptionCategory category){
- selectedElement = element;
- optCategory = category;
- rcConfig = cfg;
- config = cfg.getParent();
- }
-
public IConfiguration getSelectedConfig(){
- return config;
+ return rcInfo.getParent();
}
public String getOptionPrefName(IOption option){
@@ -168,42 +117,22 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
return getDefaultBoolean(name);
}
- public boolean getDefaultBoolean(String name) {
- return false;
- }
-
- public double getDefaultDouble(String name) {
- return 0;
- }
-
- public float getDefaultFloat(String name) {
- return 0;
- }
-
- public int getDefaultInt(String name) {
- return 0;
- }
-
- public long getDefaultLong(String name) {
- return 0;
- }
-
- public String getDefaultString(String name) {
- return EMPTY_STRING;
- }
+ public boolean getDefaultBoolean(String name) { return false; }
+ public double getDefaultDouble(String name) { return 0; }
+ public float getDefaultFloat(String name) { return 0; }
+ public int getDefaultInt(String name) { return 0; }
+ public long getDefaultLong(String name) { return 0; }
+ public String getDefaultString(String name) { return EMPTY_STRING; }
public double getDouble(String name) {
return getDefaultDouble(name);
}
-
public float getFloat(String name) {
return getDefaultFloat(name);
}
-
public int getInt(String name) {
return getDefaultInt(name);
}
-
public long getLong(String name) {
return getDefaultLong(name);
}
@@ -216,18 +145,13 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
return ((Tool)optCategory).getCommandLinePattern();
else if(ALL_OPTIONS_ID.equals(name)){
try {
+ SupplierBasedCdtVariableSubstitutor macroSubstitutor = new BuildfileMacroSubstitutor(null, EMPTY_STRING, " "); //$NON-NLS-1$
return listToString(((Tool)optCategory).getToolCommandFlags(
null,
null,
- new UIMacroSubstitutor(
- 0,
- null,
- EMPTY_STRING,
- WHITESPACE,
- obtainMacroProvider())),
- WHITESPACE);
- } catch (BuildException e) {
- }
+ macroSubstitutor,
+ obtainMacroProvider()));
+ } catch (BuildException e) {}
}
} else {
Object val = getOptionValue(name);
@@ -241,8 +165,6 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
}
public BuildMacroProvider obtainMacroProvider(){
- if(block != null)
- return block.obtainMacroProvider();
return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
}
@@ -267,14 +189,11 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
}
public Object[] getOption(String name){
- Object options[][];
-
+ if (selectedElement == null) return null;
+
IHoldsOptions selectedHolder = selectedElement.getHoldOptions();
if (selectedHolder == null) selectedHolder = selectedElement.getTool();
- if(rcConfig != null)
- options = optCategory.getOptions(rcConfig, selectedHolder);
- else
- options = optCategory.getOptions(config, selectedHolder);
+ Object options[][] = optCategory.getOptions(rcInfo, selectedHolder);
for(int i = 0; i < options.length; i++){
IHoldsOptions ho = (IHoldsOptions)options[i][0];
@@ -282,7 +201,7 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
IOption option = (IOption)options[i][1];
- if(option.getId().equals(name)
+ if(option.getName().equals(name) //TODO: name vs ID !
|| ((!option.isExtensionElement() || ((Option)option).isAdjustedExtension() || ((Option)option).wasOptRef())
&& option.getSuperClass() != null
&& option.getSuperClass().getId().equals(name)))
@@ -292,59 +211,25 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
}
- public boolean isDefault(String name) {
- return false;
- }
-
- public boolean needsSaving() {
- return dirtyFlag;
- }
-
- public void putValue(String name, String value) {
- setValue(name,value);
- }
+ public boolean isDefault(String name) { return false;}
+ public boolean needsSaving() { return dirtyFlag;}
+ public void putValue(String name, String value) {setValue(name,value);}
public void removePropertyChangeListener(IPropertyChangeListener listener) {
listenerList.remove(listener);
}
-
- public void setDefault(String name, double value) {
- }
-
- public void setDefault(String name, float value) {
- }
-
- public void setDefault(String name, int value) {
- }
-
- public void setDefault(String name, long value) {
- }
-
- public void setDefault(String name, String defaultObject) {
- }
-
- public void setDefault(String name, boolean value) {
- }
-
- public void setToDefault(String name) {
- }
-
- protected void setDirty( boolean isDirty )
- {
- dirtyFlag = isDirty;
- }
-
- public void setValue(String name, double value) {
- }
-
- public void setValue(String name, float value) {
- }
-
- public void setValue(String name, int value) {
- }
-
- public void setValue(String name, long value) {
- }
+ public void setDefault(String name, double value) {}
+ public void setDefault(String name, float value) {}
+ public void setDefault(String name, int value) {}
+ public void setDefault(String name, long value) {}
+ public void setDefault(String name, String defaultObject) {}
+ public void setDefault(String name, boolean value) {}
+ public void setToDefault(String name) {}
+ protected void setDirty( boolean isDirty ) {dirtyFlag = isDirty;}
+ public void setValue(String name, double value) {}
+ public void setValue(String name, float value) {}
+ public void setValue(String name, int value) {}
+ public void setValue(String name, long value) {}
public void setValue(String name, String value) {
if(optCategory instanceof Tool){
@@ -370,35 +255,21 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
switch(option.getValueType()){
case IOption.STRING:
if(value instanceof String){
- if (rcConfig != null) {
- newOption = rcConfig.setOption(holder,option,(String)value);
- } else {
- newOption = config.setOption(holder,option,(String)value);
- }
+ newOption = rcInfo.setOption(holder, option, (String)value);
}
break;
case IOption.BOOLEAN:
if(value instanceof Boolean){
boolean val = ((Boolean)value).booleanValue();
- if (rcConfig != null) {
- newOption = rcConfig.setOption(holder,option,val);
- } else {
- newOption = config.setOption(holder,option,val);
- }
+ newOption = rcInfo.setOption(holder,option,val);
}
break;
case IOption.ENUMERATED:
if(value instanceof String){
String val = (String)value;
String enumId = option.getEnumeratedId(val);
- if(rcConfig != null) {
- newOption = rcConfig.setOption(holder, option,
- (enumId != null && enumId.length() > 0) ? enumId : val);
- } else {
- newOption = config.setOption(holder, option,
- (enumId != null && enumId.length() > 0) ? enumId : val);
- }
-
+ newOption = rcInfo.setOption(holder, option,
+ (enumId != null && enumId.length() > 0) ? enumId : val);
}
break;
case IOption.INCLUDE_PATH:
@@ -406,13 +277,13 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
case IOption.OBJECTS:
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
if(value instanceof String){
String val[] = parseString((String)value);
- if (rcConfig != null) {
- newOption = rcConfig.setOption(holder,option,val);
- } else {
- newOption = config.setOption(holder,option,val);
- }
+ newOption = rcInfo.setOption(holder,option,val);
}
break;
default:
@@ -447,5 +318,24 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
return path.toString();
}
+ private IResourceInfo get(ICResourceDescription cfgd) {
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgd.getConfiguration());
+ if (cfgd.getType() == ICSettingBase.SETTING_PROJECT ||
+ cfgd.getType() == ICSettingBase.SETTING_CONFIGURATION)
+ return cfg.getRootFolderInfo();
+
+ IPath p = cfgd.getPath();
+ IResourceInfo ri = cfg.getResourceInfo(p, true);
+ if (ri != null && p.equals(ri.getPath())) {
+ return ri;
+ }
+
+ if (cfgd.getType() == ICSettingBase.SETTING_FILE) {
+ ri = cfg.createFileInfo(p);
+ } else if (cfgd.getType() == ICSettingBase.SETTING_FOLDER) {
+ ri = cfg.createFolderInfo(p);
+ }
+ return ri;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSettingsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSettingsTab.java
new file mode 100644
index 00000000000..b2d98ed0e38
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/ToolSettingsTab.java
@@ -0,0 +1,644 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.newui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPreferencePageContainer {
+ /*
+ * String constants
+ */
+ //private static final String PREFIX = "ToolsSettingsBlock"; //$NON-NLS-1$
+ //private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ //private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
+ //private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
+ //private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
+ private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
+
+ /*
+ * Dialog widgets
+ */
+ private TreeViewer optionList;
+ private SashForm sashForm;
+ private Composite settingsPageContainer;
+ private ScrolledComposite containerSC;
+
+ /*
+ * Bookeeping variables
+ */
+ private Map configToPageListMap;
+ private IPreferenceStore settingsStore;
+ private AbstractToolSettingUI currentSettingsPage;
+ private ToolListElement selectedElement;
+ private ToolListContentProvider listprovider;
+ private Object propertyObject;
+
+ private boolean defaultNeeded;
+
+ private IResourceInfo fInfo;
+
+
+ public void createControls(Composite par) {
+ super.createControls(par);
+ usercomp.setLayout(new GridLayout());
+
+ configToPageListMap = new HashMap();
+ settingsStore = ToolSettingsPrefStore.getDefault();
+
+ // Create the sash form
+ sashForm = new SashForm(usercomp, SWT.NONE);
+ sashForm.setOrientation(SWT.HORIZONTAL);
+ sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ sashForm.setLayout(layout);
+ createSelectionArea(sashForm);
+ createEditArea(sashForm);
+ sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
+
+ propertyObject = page.getElement();
+ setValues();
+// WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
+ }
+
+ protected void createSelectionArea (Composite parent) {
+ // Create a label and list viewer
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ optionList = new TreeViewer(composite, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
+ optionList.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleOptionSelection();
+ }
+ });
+ optionList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ optionList.setLabelProvider(new ToolListLabelProvider());
+ optionList.addFilter(new ViewerFilter() {
+ public boolean select(Viewer viewer,
+ Object parent,
+ Object element) {
+ if(parent instanceof IResourceConfiguration && element instanceof ITool) {
+ return !((ITool)element).getCustomBuildStep();
+ } else {
+ return true;
+ }
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * Method displayOptionsForCategory
+ * @param category
+ */
+ private void displayOptionsForCategory(ToolListElement toolListElement) {
+
+ selectedElement = toolListElement;
+ IOptionCategory category = toolListElement.getOptionCategory();
+ IHoldsOptions optionHolder = toolListElement.getHoldOptions();
+
+ AbstractToolSettingUI oldPage = currentSettingsPage;
+ currentSettingsPage = null;
+
+ // Create a new settings page if necessary
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+
+ while (iter.hasNext()) {
+ AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next();
+ if (page.isFor(optionHolder, category)) {
+ currentSettingsPage = page;
+ break;
+ }
+ }
+ if (currentSettingsPage == null) {
+ currentSettingsPage = new BuildOptionSettingsUI(this, fInfo, optionHolder, category);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(this);
+ if (currentSettingsPage.getControl() == null) {
+ currentSettingsPage.createControl(settingsPageContainer);
+ }
+ }
+
+ // Make all the other pages invisible
+ Control[] children = settingsPageContainer.getChildren();
+ Control currentControl = currentSettingsPage.getControl();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != currentControl)
+ children[i].setVisible(false);
+ }
+ currentSettingsPage.setVisible(true);
+ currentSettingsPage.updateFields();
+
+ if (oldPage != null && oldPage != currentSettingsPage)
+ oldPage.setVisible(false);
+
+ // Set the size of the scrolled area
+ containerSC.setMinSize(currentSettingsPage.computeSize());
+ settingsPageContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * Method displayOptionsForTool
+ * @param tool
+ */
+ private void displayOptionsForTool(ToolListElement toolListElement) {
+ selectedElement = toolListElement;
+ ITool tool = toolListElement.getTool();
+
+ // Cache the current build setting page
+ AbstractToolSettingUI oldPage = currentSettingsPage;
+ currentSettingsPage = null;
+
+ // Create a new page if we need one
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next();
+ if (page.isFor(tool, null)) {
+ currentSettingsPage = page;
+ break;
+ }
+ }
+
+ if (currentSettingsPage == null) {
+ currentSettingsPage = new BuildToolSettingUI(this, fInfo, tool);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(this);
+ if (currentSettingsPage.getControl() == null) {
+ currentSettingsPage.createControl(settingsPageContainer);
+ }
+ }
+ // Make all the other pages invisible
+ Control[] children = settingsPageContainer.getChildren();
+ Control currentControl = currentSettingsPage.getControl();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != currentControl)
+ children[i].setVisible(false);
+ }
+
+ // Make the current page visible
+ currentSettingsPage.setVisible(true);
+
+ // Save the last page build options.
+ if (oldPage != null && oldPage != currentSettingsPage){
+ oldPage.storeSettings();
+ }
+ currentSettingsPage.setValues();
+
+ if (oldPage != null && oldPage != currentSettingsPage)
+ oldPage.setVisible(false);
+
+ // Set the size of the scrolled area
+ containerSC.setMinSize(currentSettingsPage.computeSize());
+ settingsPageContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * Add the tabs relevant to the project to edit area tab folder.
+ */
+ protected void createEditArea(Composite parent) {
+ containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ containerSC.setExpandHorizontal(true);
+ containerSC.setExpandVertical(true);
+
+ // Add a container for the build settings page
+ settingsPageContainer = new Composite(containerSC, SWT.NULL);
+ settingsPageContainer.setLayout(new PageLayout());
+
+ containerSC.setContent(settingsPageContainer);
+ containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ settingsPageContainer.layout();
+ }
+
+ public void setVisible(boolean visible){
+ if(visible){
+ selectedElement = null;
+ handleOptionSelection();
+ }
+ super.setVisible(visible);
+ }
+
+ protected void setValues() {
+ /*
+ * This method updates the context of the build property pages
+ * - Which configuration/resource configuration is selected
+ * - Which tool/option category is selected
+ *
+ * It is called:
+ * - When a property page becomes visible
+ * - When the user changes the configuration selection
+ * - When the user changes the "exclude" setting for a resource
+ */
+
+ // Create the Tree Viewer content provider if first time
+ if (listprovider == null) {
+ IResource resource = (IResource) propertyObject;
+ listprovider = new ToolListContentProvider(resource.getType());
+ optionList.setContentProvider(listprovider);
+ }
+
+ // Update the selected configuration and the Tree Viewer
+ ToolListElement[] newElements;
+
+ optionList.setInput(fInfo);
+ newElements = (ToolListElement[])listprovider.getElements(fInfo);
+ optionList.expandAll();
+
+ // Determine what the selection in the tree should be
+ // If the saved selection is not null, try to match the saved selection
+ // with an object in the new element list.
+ // Otherwise, select the first tool in the tree
+ Object primaryObject = null;
+ if (selectedElement != null) {
+ selectedElement = matchSelectionElement(selectedElement, newElements);
+ }
+
+ if (selectedElement == null) {
+ selectedElement = (ToolListElement)(newElements != null && newElements.length > 0 ? newElements[0] : null);
+ }
+
+ if (selectedElement != null) {
+ primaryObject = selectedElement.getTool();
+ if (primaryObject == null) {
+ primaryObject = selectedElement.getOptionCategory();
+ }
+ if (primaryObject != null) {
+ if (primaryObject instanceof IOptionCategory) {
+ ((ToolSettingsPrefStore)settingsStore).setSelection(getResDesc(), selectedElement, (IOptionCategory)primaryObject);
+ }
+ optionList.setSelection(new StructuredSelection(selectedElement), true);
+ }
+ }
+ }
+
+ private ToolListElement matchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
+ // First, look for an exact match
+ ToolListElement match = exactMatchSelectionElement(currentElement, elements);
+ if (match == null)
+ // Else, look for the same tool/category in the new set of elements
+ match = equivalentMatchSelectionElement(currentElement, elements);
+ return match;
+ }
+
+ private ToolListElement exactMatchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
+ for (int i=0; i<elements.length; i++) {
+ ToolListElement e = elements[i];
+ if (e == currentElement) {
+ return currentElement;
+ }
+ e = exactMatchSelectionElement(currentElement, e.getChildElements());
+ if (e != null) return e;
+ }
+ return null;
+ }
+
+ private ToolListElement equivalentMatchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
+ for (int i=0; i<elements.length; i++) {
+ ToolListElement e = elements[i];
+ if (e.isEquivalentTo(currentElement)) {
+ return e;
+ }
+ e = equivalentMatchSelectionElement(currentElement, e.getChildElements());
+ if (e != null) return e;
+ }
+ return null;
+ }
+
+ public void removeValues(String id) {
+ }
+
+ private void handleOptionSelection() {
+ // Get the selection from the tree list
+ if (optionList == null) return;
+ IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
+
+ // Set the option page based on the selection
+ ToolListElement toolListElement = (ToolListElement)selection.getFirstElement();
+ if (toolListElement != null) {
+ IOptionCategory cat = toolListElement.getOptionCategory();
+ if (cat == null)
+ cat = (IOptionCategory)toolListElement.getTool();
+ if (cat != null)
+ ((ToolSettingsPrefStore)settingsStore).setSelection(getResDesc(), toolListElement, cat);
+
+ cat = toolListElement.getOptionCategory();
+ if (cat != null) {
+ displayOptionsForCategory(toolListElement);
+ } else {
+ displayOptionsForTool(toolListElement);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+ */
+ public void performDefaults() {
+ if (page.isForProject()) {
+ ManagedBuildManager.resetConfiguration(page.getProject(), getCfg());
+ } else {
+// ManagedBuildManager.resetResourceConfiguration(provider.getProject(), );
+// ManagedBuildManager.performValueHandlerEvent(fInfo, IManagedOptionValueHandler.EVENT_SETDEFAULT);
+
+ }
+ ITool tools[];
+ if (page.isForProject())
+ tools = getCfg().getFilteredTools();
+ else
+ tools = getResCfg(getResDesc()).getTools();
+ for( int i = 0; i < tools.length; i++ ){
+ if(!tools[i].getCustomBuildStep()) {
+ tools[i].setToolCommand(null);
+ tools[i].setCommandLinePattern(null);
+ }
+ }
+ // Reset the category or tool selection and run selection event handler
+ selectedElement = null;
+ handleOptionSelection();
+ setDirty(true);
+ defaultNeeded = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ if(defaultNeeded){
+ if(propertyObject instanceof IFile)
+ ManagedBuildManager.resetResourceConfiguration(page.getProject(), getCfg().getResourceConfiguration(((IFile)propertyObject).getFullPath().toOSString()));
+ else
+ ManagedBuildManager.resetConfiguration(page.getProject(), getCfg());
+ defaultNeeded = false;
+ }
+ saveConfig();
+ setDirty(false);
+ }
+
+ private void saveHoldsOptions(IHoldsOptions holder){
+ if(holder instanceof ITool && ((ITool)holder).getCustomBuildStep())
+ return;
+ if(holder instanceof ITool) {
+ String currentValue = ((ITool)holder).getToolCommand();
+ if (!(currentValue.equals(((ITool)holder).getToolCommand()))) {
+ ((ITool)holder).setToolCommand(((ITool)holder).getToolCommand());
+ fInfo.setRebuildState(true);
+ }
+ currentValue = ((ITool)holder).getCommandLinePattern();
+ if (!(currentValue.equals(((ITool)holder).getCommandLinePattern()))) {
+ ((ITool)holder).setCommandLinePattern(((ITool)holder).getCommandLinePattern());
+ fInfo.setRebuildState(true);
+ }
+ }
+ IOption options[] = holder.getOptions();
+ for(int i = 0; i < options.length; i++) {
+ saveOption(options[i], holder);
+ }
+ }
+
+ private void saveOption(IOption option, IHoldsOptions holder){
+// IResourceInfo info = fCfg;
+ try {
+ IOption setOption = null;
+ // Transfer value from preference store to options
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = option.getBooleanValue();
+ setOption = ManagedBuildManager.setOption(fInfo, holder, option, boolVal);
+ break;
+ case IOption.ENUMERATED :
+ String enumVal = option.getStringValue();
+ String enumId = option.getEnumeratedId(enumVal);
+ String out = (enumId != null && enumId.length() > 0) ? enumId : enumVal;
+ setOption = ManagedBuildManager.setOption(fInfo, holder, option, out);
+ break;
+ case IOption.STRING :
+ setOption = ManagedBuildManager.setOption(fInfo, holder, option, option.getStringValue());
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ case IOption.INCLUDE_FILES:
+ case IOption.LIBRARY_PATHS:
+ case IOption.LIBRARY_FILES:
+ case IOption.MACRO_FILES:
+ String[] data = (String[])((List)option.getValue()).toArray(new String[0]);
+ setOption = ManagedBuildManager.setOption(fInfo, holder, option, data);
+ break;
+ default :
+ break;
+ }
+
+ // Call an MBS CallBack function to inform that Settings related to Apply/OK button
+ // press have been applied.
+ if (setOption == null) setOption = option;
+
+// if (setOption.getValueHandler().handleValue(
+// handler,
+// setOption.getOptionHolder(),
+// setOption,
+// setOption.getValueHandlerExtraArgument(),
+// IManagedOptionValueHandler.EVENT_APPLY)) {
+// // TODO : Event is handled successfully and returned true.
+// // May need to do something here say log a message.
+// } else {
+// // Event handling Failed.
+// }
+//
+ } catch (BuildException e) {
+ } catch (ClassCastException e) {
+ }
+
+ }
+
+ private void saveConfig(){
+ IToolChain tc = fInfo.getParent().getToolChain();
+ saveHoldsOptions(tc);
+
+ ITool tools[] = fInfo.getParent().getFilteredTools();
+ for(int i = 0; i < tools.length; i++){
+ saveHoldsOptions(tools[i]);
+ }
+ }
+
+ protected boolean containsDefaults(){
+ IConfiguration parentCfg = fInfo.getParent().getParent();
+ ITool tools[] = fInfo.getParent().getTools();
+ for(int i = 0; i < tools.length; i++){
+ ITool tool = tools[i];
+ if(!tool.getCustomBuildStep()){
+ ITool cfgTool = parentCfg.getToolChain().getTool(tool.getSuperClass().getId());
+ // Check for a non-default command or command-line-pattern
+ if(cfgTool != null){
+ if (!(tool.getToolCommand().equals(cfgTool.getToolCommand()))) return false;
+ if (!(tool.getCommandLinePattern().equals(cfgTool.getCommandLinePattern()))) return false;
+ }
+ // Check for a non-default option
+ IOption options[] = tool.getOptions();
+ for( int j = 0; j < options.length; j++){
+ IOption option = options[j];
+ if(option.getParent() == tool){
+ IOption ext = option;
+ do{
+ if(ext.isExtensionElement())
+ break;
+ } while((ext = ext.getSuperClass()) != null);
+
+ if(ext != null){
+ if(cfgTool != null){
+ IOption defaultOpt = cfgTool.getOptionBySuperClassId(ext.getId());
+ try {
+ if(defaultOpt != null && defaultOpt.getValueType() == option.getValueType()){
+ Object value = option.getValue();
+ Object defaultVal = defaultOpt.getValue();
+
+ if(value.equals(defaultVal))
+ continue;
+ //TODO: check list also
+ }
+ }catch (BuildException e) {
+ }
+ }
+ }
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * Answers the list of settings pages for the selected configuration
+ */
+ private List getPagesForConfig() {
+ if (getCfg() == null) return null;
+ List pages = (List) configToPageListMap.get(getCfg().getId());
+ if (pages == null) {
+ pages = new ArrayList();
+ configToPageListMap.put(getCfg().getId(), pages);
+ }
+ return pages;
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ return settingsStore;
+ }
+
+ /**
+ * Sets the "dirty" state
+ */
+ public void setDirty(boolean b) {
+ List pages = getPagesForConfig();
+ if (pages == null) return;
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next();
+ if (page == null) continue;
+ page.setDirty(b);
+ }
+ }
+
+ /**
+ * Returns the "dirty" state
+ */
+ public boolean isDirty() {
+ // Check each settings page
+ List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return false;
+ }
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ AbstractToolSettingUI page = (AbstractToolSettingUI) iter.next();
+ if (page == null) continue;
+ if (page.isDirty()) return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the build macro provider to be used for macro resolution
+ * In case the "Build Macros" tab is available, returns the BuildMacroProvider
+ * supplied by that tab.
+ * Unlike the default provider, that provider also contains
+ * the user-modified macros that are not applied yet
+ * If the "Build Macros" tab is not available, returns the default BuildMacroProvider
+ */
+ public BuildMacroProvider obtainMacroProvider(){
+ return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
+ }
+
+ public void updateData(ICResourceDescription cfgd) {
+ handleOptionSelection();
+ fInfo = getResCfg(cfgd);
+ setValues();
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+
+ }
+
+ // IPreferencePageContainer methods
+ public void updateButtons() {}
+ public void updateMessage() {}
+ public void updateTitle() {}
+
+ public boolean canBeVisible() {
+ return getCfg().getBuilder().isManagedBuildOn();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/messages.properties
new file mode 100644
index 00000000000..098991bb9e3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/messages.properties
@@ -0,0 +1,65 @@
+BuilderSettingsTab.0=Builder
+BuilderSettingsTab.1=Builder type
+BuilderSettingsTab.2=External builder
+BuilderSettingsTab.3=Internal builder
+BuilderSettingsTab.4=Use default build command
+BuilderSettingsTab.5=Build command:
+BuilderSettingsTab.6=Makefile generation
+BuilderSettingsTab.7=Generate Makefiles automatically
+BuilderSettingsTab.8=Expand Env. Variable Refs in Makefiles
+BuilderSettingsTab.9=Build settings
+BuilderSettingsTab.10=Stop on first build error
+BuilderSettingsTab.11=Use parallel build
+BuilderSettingsTab.12=Use optimal jobs number
+BuilderSettingsTab.13=Use parallel jobs:
+BuilderSettingsTab.14=Workbench Build Behaviour
+BuilderSettingsTab.15=Workbench build type:
+BuilderSettingsTab.16=Make build target:
+BuilderSettingsTab.17=Build on resource save (Auto build)
+BuilderSettingsTab.18=Note: See Workbench automatic build preference
+BuilderSettingsTab.19=Build (Incremental build)
+BuilderSettingsTab.20=Clean
+BuilderSettingsTab.21=Build location
+BuilderSettingsTab.22=Build directory
+BuildStepsTab.0=Command:
+BuildStepsTab.1=Description:
+BuildStepsTab.2=Pre-build steps
+BuildStepsTab.3=Post-build steps
+BuildStepsTab.4=Resource Custom Build Step
+BuildStepsTab.5=Additional input file name(s):
+BuildStepsTab.6=Output file name(s):
+BuildStepsTab.7=
+ArtifactTab.0=Artifact Type:
+ArtifactTab.1=Artifact name:
+ArtifactTab.2=Artifact extension:
+CPropertyVarsTab.0=Show system variables
+DiscoveryTab.0=Discovery profiles scope
+DiscoveryTab.1=Per Resource type
+DiscoveryTab.2=Configuration-wide
+DiscoveryTab.3=Unknown
+DiscoveryTab.6=No profiles found
+DiscoveryTab.10=org.eclipse.cdt.managedbuilder.ui
+DiscoveryTab.11=DiscoveryProfileUI
+DiscoveryTab.13=failed to create:
+DiscoveryTab.15=applyInfo:
+DiscoveryTab.16=applyInfo: context does not fit
+ToolSelectionDialog.0=Select tools
+ToolSelectionDialog.1=Available tools
+ToolSelectionDialog.2=Used tools
+ToolSelectionDialog.7=Tool conflict \!
+ToolSelectionDialog.8=Tool does not support managed build \!
+ToolSelectionDialog.9=Props not defined \!
+ToolSelectionDialog.10=Props not supported \!
+ToolSelectionDialog.11=Req. props not supported \!
+ToolSettingsPrefStore.0=org.eclipse.commandLinePatternId
+ToolChainEditTab.0=Display compatible toolchains only
+ToolChainEditTab.1=Current toolchain
+ToolChainEditTab.2=Current builder
+ToolChainEditTab.3=Used tools
+ToolChainEditTab.4=Select tools
+NewVarDialog.0=New variable
+NewVarDialog.1=Apply to all configurations
+NewCfgDialog.0=Existing configuration
+NewCfgDialog.1=Default configuration
+NewBuildConfigurationDialog.0=Cannot create config
+NewBuildConfigurationDialog.1=>>
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/AbstractBuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/AbstractBuildPropertyPage.java
deleted file mode 100644
index 2f416d7593a..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/AbstractBuildPropertyPage.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
-import org.eclipse.cdt.managedbuilder.internal.core.Tool;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public abstract class AbstractBuildPropertyPage extends PropertyPage {
-
- private Map clonedConfigMap;
-
- private Map getClonedConfigMap(){
- if(clonedConfigMap == null)
- clonedConfigMap = new HashMap();
- return clonedConfigMap;
- }
-
- public IConfiguration getClonedConfig(IConfiguration config){
- IConfiguration clonedCfg = (IConfiguration)getClonedConfigMap().get(config.getId());
- if(clonedCfg == null){
- clonedCfg = new Configuration((ManagedProject)config.getManagedProject(),
- (Configuration)config,
- ManagedBuildManager.calculateChildId(config.getId(), null),
- true,
- true);
- getClonedConfigMap().put(config.getId(),clonedCfg);
- }
- return clonedCfg;
- }
-
- public IConfiguration getRealConfig(IConfiguration config){
- Set set = getClonedConfigMap().entrySet();
- Iterator iter = set.iterator();
- while(iter.hasNext()){
- Map.Entry entry = (Map.Entry)iter.next();
- if(entry.getValue().equals(config))
- return config.getManagedProject().getConfiguration((String)entry.getKey());
- }
- return null;
- }
-
- public IToolChain getClonedToolChain(IToolChain toolChain){
- return getClonedConfig(toolChain.getParent()).getToolChain();
- }
-
- public IToolChain getRealToolChain(IToolChain toolChain){
- IConfiguration cfg = getRealConfig(toolChain.getParent());
- if(cfg != null)
- return cfg.getToolChain();
- return null;
- }
-
- public IHoldsOptions getClonedHoldsOptions(IHoldsOptions ho){
- if(ho instanceof IToolChain)
- return getClonedToolChain((IToolChain)ho);
- else if(ho instanceof ITool)
- return getClonedTool((ITool)ho);
- return null;
- }
-
- public IHoldsOptions getRealHoldsOptions(IHoldsOptions ho){
- if(ho instanceof IToolChain)
- return getRealToolChain((IToolChain)ho);
- else if(ho instanceof ITool)
- return getRealTool((ITool)ho);
- return null;
- }
-
- public IResourceConfiguration getClonedRcConfig(IResourceConfiguration rcCfg){
- return getClonedConfig(rcCfg.getParent()).getResourceConfiguration(rcCfg.getResourcePath());
- }
-
- public IResourceConfiguration getRealRcConfig(IResourceConfiguration rcCfg){
- IConfiguration cfg = getRealConfig(rcCfg.getParent());
- if(cfg != null)
- return cfg.getResourceConfiguration(rcCfg.getResourcePath());
- return null;
- }
-
- public ITool getClonedTool(ITool tool){
- IConfiguration cfg = getConfigurationFromTool(tool);
- if(cfg != null)
- return getToolForConfig(getClonedConfig(cfg),tool);
- return null;
- }
-
- public ITool getRealTool(ITool tool){
- IConfiguration cfg = getConfigurationFromTool(tool);
- if(cfg != null){
- cfg = getRealConfig(cfg);
- if(cfg != null)
- return getToolForConfig(cfg,tool);
- }
- return null;
- }
-
- protected ITool getToolForConfig(IConfiguration cfg, ITool tool){
- if(tool.getParent() instanceof IToolChain){
- ITool tools[] = cfg.getTools();
- for(int i = 0; i < tools.length; i++){
- if(tool.getSuperClass() != null){
- if(tools[i].getSuperClass() != null && tools[i].getSuperClass().getId().equals(
- tool.getSuperClass().getId()))
- return tools[i];
- }
- //TODO: shoud we handle this?
- }
- } else if (tool.getParent() instanceof IResourceConfiguration){
- IResourceConfiguration rcCfg = (IResourceConfiguration)tool.getParent();
- IResourceConfiguration otherRcCfg = cfg.getResourceConfiguration(rcCfg.getResourcePath());
- ITool tools[] = otherRcCfg.getTools();
- ITool superTool = tool.getSuperClass();
- if(superTool != null && (superTool = superTool.getSuperClass()) != null){
- for(int i = 0; i < tools.length; i++){
- ITool otherSuperTool = tools[i].getSuperClass();
- if(otherSuperTool != null
- && (otherSuperTool = otherSuperTool.getSuperClass()) != null
- && otherSuperTool.getId().equals(superTool.getId()))
- return tools[i];
- }
- }
- }
- return null;
- }
-
- public IConfiguration getConfigurationFromTool(ITool tool){
- IBuildObject bo = tool.getParent();
- if(bo instanceof IToolChain)
- return ((IToolChain)bo).getParent();
- else if(bo instanceof IResourceConfiguration)
- return ((IResourceConfiguration)bo).getParent();
- return null;
- }
-
- public IConfiguration getConfigurationFromHoldsOptions(IHoldsOptions ho){
- if(ho instanceof IToolChain)
- return ((IToolChain)ho).getParent();
- else if(ho instanceof ITool)
- return getConfigurationFromTool((ITool)ho);
- return null;
- }
-
- public IOption getClonedOption(IOption option, IHoldsOptions ho){
- IHoldsOptions clonedHo = getClonedHoldsOptions(ho);
- if(clonedHo != null)
- return getOptionForHoldsOptions(clonedHo,option);
- return null;
- }
-
- public IOption getRealOption(IOption option, IHoldsOptions ho){
- IHoldsOptions realHo = getRealHoldsOptions(ho);
- if(realHo != null)
- return getOptionForHoldsOptions(realHo,option);
- return null;
- }
-
- protected IOption getOptionForHoldsOptions(IHoldsOptions ho, IOption otherOption){
- IOption opt = null;
- if(otherOption.isExtensionElement())
- opt = ho.getOptionBySuperClassId(otherOption.getId());
- else if(otherOption.getSuperClass() != null)
- opt = ho.getOptionBySuperClassId(otherOption.getSuperClass().getId());
- if(opt != null)
- return opt;
- return otherOption;
- }
-
- public IOptionCategory getClonedOptionCategory(IOptionCategory optCategory){
- if(optCategory instanceof Tool)
- return (Tool)getClonedTool((Tool)optCategory);
- return optCategory;
- }
-
- public IOptionCategory getRealOptionCategory(IOptionCategory optCategory){
- if(optCategory instanceof Tool)
- return (Tool)getRealTool((Tool)optCategory);
- return optCategory;
- }
-
-/* protected String calculateId(String id){
- String version = ManagedBuildManager.getVersionFromIdAndVersion(id);
- int n = ManagedBuildManager.getRandomNumber();
- if ( version != null) // If the 'id' contains version information
- return ManagedBuildManager.getIdFromIdAndVersion(id) + "." + n + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
- return id + "." + n; //$NON-NLS-1$
- }
-*/
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BrowseEntryDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BrowseEntryDialog.java
deleted file mode 100644
index 91e88d2c1b0..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BrowseEntryDialog.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 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.ui.properties;
-
-
-import org.eclipse.cdt.internal.ui.dialogs.SelectionStatusDialog;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-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.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * The BrowseEntryDialog allows clients to prompt the user for a path location.
- * The dialog will contain a browse button to make it easy to lcate absolute
- * locations onthe target file system. The user will also be able to specify a
- * location using defined variables. The client must be able to deal with these
- * variables.
- */
-public class BrowseEntryDialog extends SelectionStatusDialog {
- // String constants
- private static final String PREFIX = "BuildPropertyCommon"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String BROWSE = LABEL + ".browse"; //$NON-NLS-1$
- private static final String HIDE = "hideAdvanced"; //$NON-NLS-1$
- private static final String SHOW = "showAdvanced"; //$NON-NLS-1$
- private static final String EMPTY = "NewFolderDialog.folderNameEmpty"; //$NON-NLS-1$
- private static final String ERROR_FOLDER_NAME_INVALID = PREFIX + ".error.Folder_name_invalid"; //$NON-NLS-1$
-
- /* (non-Javadoc)
- * The title of the dialog.
- */
- private String title = ""; //$NON-NLS-1$
-
- /* (non-Javadoc)
- * The message to display, or <code>null</code> if none.
- */
- private String message = ""; //$NON-NLS-1$
-
- /* (non-Javadoc)
- * The input value; the empty string by default.
- */
- private String folderName = ""; //$NON-NLS-1$
-
- /* (non-Javadoc)
- *
- */
- private int basicShellHeight;
-
- /* (non-Javadoc)
- *
- */
-// private CreateLinkedResourceGroup linkedResourceGroup;
-
- // Widgets
- private Button advancedButton = null;
- private Button browseButton = null;
- private Label errorMessageLabel;
- private Composite macroComposite;
- private Text text = null;
-
- /**
- * Creates an input dialog with OK, Cancel, a Browse button and a button to
- * reveal path macros.
- *
- * @param shell
- * the parent shell
- * @param dialogTitle
- * the title of the dialog or <code>null</code> if none
- * @param dialogMessage
- * the dialog message, or <code>null</code> if none
- * @param initialValue
- * the initial input value, or <code>null</code> if none
- * (equivalent to the empty string)
- */
- public BrowseEntryDialog(Shell shell, String dialogTitle, String dialogMessage, String initialValue) {
- super(shell);
- // We are editing the value argument if it is not an empty string
- if (dialogTitle != null) {
- title = dialogTitle;
- }
- // Cache the message to be shown in the label
- if (dialogMessage != null) {
- message = dialogMessage;
- }
- // Value for the text widget
- if (initialValue != null) {
- folderName = initialValue;
- }
- setStatusLineAboveButtons(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.dialogs.SelectionStatusDialog#computeResult()
- */
- protected void computeResult() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.dialogs.SelectionStatusDialog#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- // Set the display title the user has specified
- if (title != null) {
- shell.setText(title);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.dialogs.SelectionStatusDialog#create()
- */
- public void create() {
- // Disable the OK button to start
- super.create();
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
-
- /* (non-Javadoc)
- *
- * @param parent
- */
- private void createAdvancedBrowseArea(Composite parent) {
- // Instantiate the macros button
- advancedButton = new Button(parent, SWT.PUSH);
- applyDialogFont(advancedButton);
- advancedButton.setText(ManagedBuilderUIMessages.getResourceString(SHOW));
- setButtonLayoutData(advancedButton);
- GridData data = (GridData) advancedButton.getLayoutData();
- data.horizontalAlignment = GridData.BEGINNING;
- advancedButton.setLayoutData(data);
- advancedButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleAdvancedPressed();
- }
- });
- advancedButton.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- advancedButton = null;
- }
- });
-
-// linkedResourceGroup = new CreateLinkedResourceGroup(
-// IResource.FOLDER,
-// new Listener(){
-// public void handleEvent(Event event) {
-// // TODO Auto-generated method stub
-//
-// }
-// });
- }
-
- /* (non-Javadoc)
- *
- * @param parent
- */
- private void createBasicBrowseArea(Composite parent) {
- Composite basicGroup = new Composite(parent, SWT.NONE);
- basicGroup.setLayout(new GridLayout(2, false));
- basicGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridData data;
- // Create the label
- if (message != null) {
- Label label = new Label(basicGroup, SWT.WRAP);
- label.setText(message);
- data = new GridData(
- GridData.FILL_HORIZONTAL |
- GridData.GRAB_VERTICAL |
- GridData.VERTICAL_ALIGN_BEGINNING);
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
- applyDialogFont(label);
- }
-
- // Entry widget next
- text = new Text(basicGroup, SWT.SINGLE | SWT.BORDER);
- data = new GridData(GridData.FILL_BOTH);
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- text.setLayoutData(data);
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validateLocation();
- }
- });
- applyDialogFont(text);
-
- // Finally make the browse button
- browseButton = new Button(basicGroup, SWT.PUSH);
- applyDialogFont(browseButton);
- browseButton.setText(ManagedBuilderUIMessages.getResourceString(BROWSE));
- setButtonLayoutData(browseButton);
- data = (GridData) browseButton.getLayoutData();
- data.horizontalAlignment = GridData.BEGINNING;
- browseButton.setLayoutData(data);
- browseButton.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- handleBrowsePressed();
- }
- });
- browseButton.addDisposeListener(new DisposeListener () {
- public void widgetDisposed(DisposeEvent e) {
- browseButton = null;
- }
- });
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createBasicBrowseArea(composite);
- createAdvancedBrowseArea(composite);
-
- return composite;
- }
-
- /**
- * Answers the value the user has entered in the selection dialog.
- *
- * <p>The selection will be a folder location specified in the format appropriate
- * for the platform that Eclipse is running on, i.e. <code>C:\foo\mydir</code>
- * for Windows platforms and <code>/foo/mydir</code> on POSIX platforms.
- *
- * <p>The answer may also contain a path variable as a component of the location. It
- * is the responsibility of the client to properly handle this situation.
- *
- * @return String
- */
- public String getValue() {
- return folderName;
- }
-
- /* (non-Javadoc)
- * Shows/hides the path macro widgets.
- */
- protected void handleAdvancedPressed() {
- Shell shell = getShell();
- Point shellSize = shell.getSize();
-
- if (macroComposite == null) {
- basicShellHeight = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y;
- Composite composite = (Composite) getDialogArea();
-// macroComposite = linkedResourceGroup.createContents(composite);
- macroComposite = ControlFactory.createComposite(composite, 1);
- shellSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- shell.setSize(shellSize);
- advancedButton.setText(ManagedBuilderUIMessages.getResourceString(HIDE));
- } else if (macroComposite.getVisible()) {
- macroComposite.setVisible(false);
- shell.setSize(shellSize.x, basicShellHeight);
- advancedButton.setText(ManagedBuilderUIMessages.getResourceString(SHOW));
- } else {
- macroComposite.setVisible(true);
- shellSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- shell.setSize(shellSize);
- advancedButton.setText(ManagedBuilderUIMessages.getResourceString(HIDE));
- }
-
- }
-
- /* (non-Javadoc)
- *
- */
- protected void handleBrowsePressed() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * Utility method to send a status message to the status line of the dialog.
- *
- * @param severity
- * @param message
- */
- private void updateStatus(int severity, String message) {
- updateStatus(new Status(severity, ManagedBuilderCorePlugin.getUniqueIdentifier(), severity, message, null));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.dialogs.SelectionStatusDialog#updateStatus(org.eclipse.core.runtime.IStatus)
- */
- protected void updateStatus(IStatus status) {
- // TODO Auto-generated method stub
- super.updateStatus(status);
- }
-
- /**
- *
- */
- protected void validateLocation() {
- folderName = text.getText();
- // Empty or null string is invalid
- if (folderName == null || folderName.equals("")) { //$NON-NLS-1$
- updateStatus(IStatus.ERROR, ManagedBuilderUIMessages.getResourceString(EMPTY));
- return;
- } else {
- // Make sure that the specified location exists
- IPath path = new Path(folderName);
- if (!path.isValidPath(folderName)) {
- updateStatus(IStatus.ERROR, ManagedBuilderUIMessages.getResourceString(ERROR_FOLDER_NAME_INVALID)); //$NON-NLS-1$
- return;
- }
- }
- updateStatus(IStatus.OK, ""); //$NON-NLS-1$
- getButton(IDialogConstants.OK_ID).setEnabled(true);
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPreferencePage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPreferencePage.java
deleted file mode 100644
index 823d5224021..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPreferencePage.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-
-public class BuildPreferencePage extends PreferencePage
- implements IWorkbenchPreferencePage, ICOptionContainer{
-
- /*
- * String constants
- */
- private static final String PREFIX = "BuildPreferencePage"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
- private static final String REBUILD_JOB_NAME = PREFIX + ".job.rebuild"; //$NON-NLS-1$
- private static final String APPLY_INTARNAL_ERROR = PREFIX + ".apply.internal.error"; //$NON-NLS-1$
-
-
- /*
- * Bookeeping variables
- */
- protected ManagedBuildOptionBlock fOptionBlock;
- private boolean fRebuildNeeded = false;
-
- public BuildPreferencePage(){
- fOptionBlock = new ManagedBuildOptionBlock(this);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init()
- */
- public void init(IWorkbench workbench){
-
- }
-
- /*
- * specifies whether the rebuild of all managed projects is needed
- * @see setRebuildState()
- */
- protected boolean rebuildNeeded(){
- return fRebuildNeeded;
- }
-
- /*
- * sets the rebuild state
- * When the build settings apply operation is performed
- * the rebuild will not be initiated, but the rebuild state will be set to true.
- * The rebuild will be initiated only when closing the preference page.
- * In case the rebuild state is "true", the rebuild of all managed projects
- * will be initiated both for OK or Cancel operations
- */
- protected void setRebuildState(boolean rebuild){
- fRebuildNeeded = rebuild;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#createContents()
- */
- protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fOptionBlock.createContents(composite,ResourcesPlugin.getWorkspace());
-
- return composite;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#updateContainer()
- */
- public void updateContainer(){
- fOptionBlock.update();
- setValid(fOptionBlock.isValid());
- setErrorMessage(fOptionBlock.getErrorMessage());
- }
-
- public IProject getProject(){
- return null;
- }
-
- public Preferences getPreferences(){
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performApply()
- */
- protected void performApply() {
- applySettings();
- }
-
- protected void performDefaults() {
- fOptionBlock.performDefaults();
- super.performDefaults();
- }
-
- public ManagedBuildOptionBlock getOptionBlock(){
- return fOptionBlock;
- }
-
-
- /*
- * apply settings
- * when the Apply operation is performed, the user-modified settings are saved,
- * but the rebuild of all managed projects is not initiated.
- * The rebuild state is set to true instead.
- * Rebuild will initiated when closing the preference page
- */
- protected boolean applySettings(){
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- if(fOptionBlock.isDirty()){
- fOptionBlock.performApply(monitor);
- fOptionBlock.setDirty(false);
- // specify that the managed projects rebuild is needed
- // the rebuild will be initiated when closing the preference page
- // both in the case of OK and Cancel
- setRebuildState(true);
- }
- }
- };
-
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
-
- try {
- new ProgressMonitorDialog(getShell()).run(false, true, op);
- } catch (InvocationTargetException e) {
- Throwable e1 = e.getTargetException();
- ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString(APPLY_INTARNAL_ERROR),e1.toString(), e1); //$NON-NLS-1$
- return false;
- } catch (InterruptedException e) {
- // cancelled
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performCancel()
- */
- public boolean performCancel() {
- //the rebuild is needed in case the apply button was previousely pressed
- if(rebuildNeeded()){
- initiateRebuild();
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performOk()
- */
- public boolean performOk() {
-
- if(!applySettings())
- return false;
-
- if(rebuildNeeded())
- initiateRebuild();
-
- return true;
- }
-
- /*
- * initiate the rebuild for all managed projects
- */
- private void initiateRebuild(){
- setRebuildState(false);
- IWorkspace wsp = ResourcesPlugin.getWorkspace();
- IProject projects[] = wsp.getRoot().getProjects();
- List managedProjectList = new ArrayList();
- for(int i = 0; i < projects.length; i++){
- if(ManagedBuildManager.manages(projects[i])){
- managedProjectList.add(projects[i]);
- }
- }
- projects = (IProject[])managedProjectList.toArray(new IProject[managedProjectList.size()]);
- final IProject projectsToBuild[] = wsp.computeProjectOrder(projects).projects;
-
- WorkspaceJob rebuildJob = new WorkspaceJob(ManagedBuilderUIMessages.getResourceString(REBUILD_JOB_NAME)) {
- public boolean belongsTo(Object family) {
- return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
- }
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
-
- for(int i = 0; i < projectsToBuild.length; i++){
- if(ManagedBuildManager.manages(projectsToBuild [i])){
- IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(projectsToBuild [i]);
- if (bi != null & bi instanceof ManagedBuildInfo) {
- ((ManagedBuildInfo)bi).initializePathEntries();
- }
- }
- }
-
- for(int i = 0; i < projectsToBuild.length; i++){
- try{
- projectsToBuild[i].build(IncrementalProjectBuilder.FULL_BUILD,monitor);
- }catch(CoreException e){
- //TODO:
- }catch(OperationCanceledException e){
- throw e;
- }
- }
- return Status.OK_STATUS;
- }
- };
- rebuildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory()
- .buildRule());
- rebuildJob.setUser(true);
- rebuildJob.schedule();
-
- }
-
- /**
- * @see DialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- fOptionBlock.setVisible(visible);
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
deleted file mode 100644
index b38e936ab72..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
+++ /dev/null
@@ -1,649 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 Rational Software 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPropertyPage;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class BuildPropertyPage extends AbstractBuildPropertyPage implements IWorkbenchPropertyPage,
- IPreferencePageContainer, ICOptionContainer {
- /*
- * String constants
- */
- private static final String PREFIX = "BuildPropertyPage"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String PLATFORM_LABEL = LABEL + ".Platform"; //$NON-NLS-1$
- private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
- private static final String ALL_CONFS = PREFIX + ".selection.configuration.all"; //$NON-NLS-1$
- private static final String ACTIVE_LABEL = LABEL + ".Active"; //$NON-NLS-1$
- private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
- private static final String ADD_CONF = LABEL + ".AddConfButton"; //$NON-NLS-1$
- private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
- private static final String PLAT_TIP = TIP + ".platform"; //$NON-NLS-1$
- private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
- private static final String MANAGE_TIP = TIP + ".manageconf"; //$NON-NLS-1$
- private static final String MANAGE_TITLE = PREFIX + ".manage.title"; //$NON-NLS-1$
- private static final String MSG_CLOSEDPROJECT = "MngMakeProjectPropertyPage.closedproject"; //$NON-NLS-1$
-
- private static final String MSG_UNSUPPORTED_PROJ = PREFIX + ".unsupported.proj"; //$NON-NLS-1$
- private static final String MSG_UNSUPPORTED_CONFIG = PREFIX + ".unsupported.config"; //$NON-NLS-1$
- private static final String MSG_CONFIG_NOTSELECTED = PREFIX + ".config.notselected"; //$NON-NLS-1$
-
- /*
- * Dialog widgets
- */
- private Combo projectTypeSelector;
- private Combo configSelector;
- private Button manageConfigs;
-
- /*
- * Bookeeping variables
- */
- private IProjectType[] projectTypes;
- private IProjectType selectedProjectType;
- private IConfiguration[] configurations;
- private IConfiguration clonedConfiguration;
- private IConfiguration selectedConfiguration;
- private Point lastShellSize;
- protected ManagedBuildOptionBlock fOptionBlock;
- protected boolean displayedConfig = false;
- private boolean noContentOnPage = false;
-
- /**
- * Default constructor
- */
- public BuildPropertyPage() {
- super();
- }
-
- public void setContainer(IPreferencePageContainer preferencePageContainer) {
- super.setContainer(preferencePageContainer);
- if (fOptionBlock == null) {
- fOptionBlock = new ManagedBuildOptionBlock(this);
- }
- }
-
- public ManagedBuildOptionBlock getOptionBlock(){
- return fOptionBlock;
- }
-
-
- protected Control createContents(Composite parent) {
- // Create the container we return to the property page editor
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- GridLayout compositeLayout = new GridLayout();
- compositeLayout.numColumns = 1;
- compositeLayout.marginHeight = 0;
- compositeLayout.marginWidth = 0;
- composite.setLayout( compositeLayout );
-
- IProject project = getProject();
- if (!project.isOpen()) {
- contentForClosedProject(composite);
- } else {
- contentForCProject(composite);
- }
-
- return composite;
- }
-
- private void contentForCProject(Composite parent) {
- GridData gd;
-
- // Initialize the key data
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
- if (info.getVersion() == null) {
- // Display a message page instead of the properties control
- noContent(parent,ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.error.version_low")); //$NON-NLS-1$
- return;
- }
- projectTypes = getProjectTypes();
- IProjectType defaultProjectType = info.getManagedProject().getProjectType();
-
- // Add a config selection area
- Group configGroup = ControlFactory.createGroup(parent, ManagedBuilderUIMessages.getResourceString(ACTIVE_LABEL), 1);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.grabExcessHorizontalSpace = true;
- configGroup.setLayoutData(gd);
- // Use the form layout inside the group composite
- FormLayout form = new FormLayout();
- form.marginHeight = 5;
- form.marginWidth = 5;
- configGroup.setLayout(form);
-
- Label platformLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(PLATFORM_LABEL));
- projectTypeSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), defaultProjectType.getName());
- // Note: Changing the project type is not currently handled, so this widget is disabled
- projectTypeSelector.setEnabled(false);
- projectTypeSelector.addListener(SWT.Selection, new Listener () {
- public void handleEvent(Event e) {
- handleProjectTypeSelection();
- }
- });
- projectTypeSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(PLAT_TIP));
- Label configLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(CONFIG_LABEL));
- configSelector = new Combo(configGroup, SWT.READ_ONLY|SWT.DROP_DOWN);
- configSelector.addListener(SWT.Selection, new Listener () {
- public void handleEvent(Event e) {
- handleConfigSelection();
- }
- });
- configSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONF_TIP));
- manageConfigs = ControlFactory.createPushButton(configGroup, ManagedBuilderUIMessages.getResourceString(ADD_CONF));
- manageConfigs.setToolTipText(ManagedBuilderUIMessages.getResourceString(MANAGE_TIP));
- manageConfigs.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleManageConfig();
- }
- });
- // Now do the form layout for the widgets
- FormData fd = new FormData();
- // Anchor the labels in the centre of their respective combos
- fd.top = new FormAttachment(projectTypeSelector, 0, SWT.CENTER);
- platformLabel.setLayoutData(fd);
- fd = new FormData();
- fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
- configLabel.setLayoutData(fd);
- // Anchor platform combo left to the config selector
- fd = new FormData();
- fd.left = new FormAttachment(configSelector, 0, SWT.LEFT);
- fd.right = new FormAttachment(100, 0);
- projectTypeSelector.setLayoutData(fd);
- // Anchor button right to combo and left to group
- fd = new FormData();
- fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
- fd.right = new FormAttachment(100,0);
- manageConfigs.setLayoutData(fd);
- // Anchor config combo left 5 pixels from longest label, top 5% below the centre, and right to the button
- Label longestLabel = (platformLabel.getText().length()>configLabel.getText().length()?platformLabel:configLabel);
- fd = new FormData();
- fd.left = new FormAttachment(longestLabel, 5);
- fd.top = new FormAttachment(55,0);
- fd.right = new FormAttachment(manageConfigs, -5 , SWT.LEFT);
- configSelector.setLayoutData(fd);
-
- // Create the Tools Settings, Build Settings, ... Tabbed pane
- Group tabGroup = ControlFactory.createGroup(parent, ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL), 1);
- gd = new GridData(GridData.FILL_BOTH);
- tabGroup.setLayoutData(gd);
- fOptionBlock.createContents(tabGroup, getElement());
-
- // Do not call this until the widgets are constructed
- handleProjectTypeSelection();
-
- WorkbenchHelp.setHelp(parent, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
- }
-
- private IProjectType[] getProjectTypes() {
-
- IProjectType [] allProjectTypes = ManagedBuildManager.getDefinedProjectTypes();
- ArrayList types = new ArrayList();
-
- // The projectTypes that has 'convertToId' attribute is used only in conversion process,
- // These projectTypes should not be used during project creation or during the display of projectTypes
- // to the user. So we need to filter the projectTypes based on the 'convertToId' attribute.
- // Check if project type has 'convertToId' attribute. If so, then do not add it to the list.
-
-
- for (int i = 0; i < allProjectTypes.length; i++) {
- IProjectType projectType = allProjectTypes[i];
- if (!projectType.getConvertToId().equals(""))
- continue;
- types.add(projectType);
- }
- types.trimToSize();
-
- IProjectType [] tmpProjectTypes = new IProjectType[types.size()];
- ListIterator iter = types.listIterator();
- int index = 0;
- while (iter.hasNext()) {
- tmpProjectTypes[index++] = (IProjectType) iter.next();
- }
- return tmpProjectTypes;
-
- }
-
- private void contentForClosedProject(Composite parent) {
- noContent(parent, ManagedBuilderUIMessages.getResourceString(MSG_CLOSEDPROJECT));
- }
-
- protected void noContent(Composite composite, String message) {
- Label label = new Label(composite, SWT.LEFT);
- label.setText(message);
- label.setFont(composite.getFont());
-
- noContentOnPage = true;
- noDefaultAndApplyButton();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
-
- // If the user did not visit this page, then there is nothing to do.
- if (!displayedConfig || noContentOnPage) return true;
-
- if (!applyOptionBlock()) return false;
- if (!applyDefaultConfiguration()) return false;
- if (!writeBuildInfo()) return false;
- clonedConfiguration.setDirty(false);
-
- //check for the inexistent configurations environment data stored in project preferences
- EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
-
- return true;
- }
-
- public boolean performCancel() {
- if(noContentOnPage)
- return true;
-
- EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
-
- return true;
- }
-
- /**
- * Apply any changes that have been made in the managed build option block
- * (changes are stored in the managedbuildinfo object).
- */
- protected boolean applyOptionBlock() {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- fOptionBlock.performApply(monitor);
- }
- };
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
- try {
- new ProgressMonitorDialog(getShell()).run(false, true, op);
- } catch (InvocationTargetException e) {
- Throwable e1 = e.getTargetException();
- ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
- return false;
- } catch (InterruptedException e) {
- // cancelled
- return false;
- }
- return true;
- }
-
- /**
- * Make the currently selected configuration the default
- * (in the managedbuildinfo object).
- */
- protected boolean applyDefaultConfiguration() {
- ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
- return true;
- }
-
- /**
- * Save any changes applied to the managedbuildinfo object to disk.
- */
- protected boolean writeBuildInfo() {
- // Write out the build model info
- boolean saveBuildStatus = ManagedBuildManager.saveBuildInfo(getProject(), false);
- IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(getProject());
- if (bi != null & bi instanceof ManagedBuildInfo) {
- ((ManagedBuildInfo)bi).initializePathEntries();
- }
- return saveBuildStatus;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- if(noContentOnPage)
- return;
-
- fOptionBlock.performDefaults();
- super.performDefaults();
- }
-
- private String [] getPlatformNames() {
- String [] names = new String[projectTypes.length];
- for (int index = 0; index < projectTypes.length; ++index) {
- names[index] = projectTypes[index].getName();
- }
- return names;
- }
-
- /* (non-Javadoc)
- * @return
- */
- public IProjectType getSelectedProjectType() {
- return selectedProjectType;
- }
-
- private void populateConfigurations() {
- // If the config select widget is not there yet, just stop
- if (configSelector == null) return;
-
- // Find the configurations defined for the platform
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
- configurations = info.getManagedProject().getConfigurations();
- if (configurations.length == 0) return;
-
- // Clear and replace the contents of the selector widget
- configSelector.removeAll();
- configSelector.setItems(getConfigurationNamesAndDescriptions());
-
- // Make sure the active configuration is selected
- configSelector.select(0);
- IConfiguration defaultConfig = info.getDefaultConfiguration();
- setSelectedConfiguration(defaultConfig);
- }
-
- /* (non-Javadoc)
- * @return an array of names for the configurations defined for the chosen
- */
- private String [] getConfigurationNamesAndDescriptions () {
- String [] namesAndDescriptions = new String[configurations.length /*+ 1*/];
- for (int index = 0; index < configurations.length; ++index) {
- String description = configurations[index].getDescription();
- if ( (description == null) || (description.equals("")) ) //$NON-NLS-1$
- namesAndDescriptions[index] = configurations[index].getName(); //$NON-NLS-1$
- else
- namesAndDescriptions[index] = configurations[index].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-// names[names.length - 1] = ManagedBuilderUIPlugin.getResourceString(ALL_CONFS);
- return namesAndDescriptions;
- }
-
- /**
- * Sets the currently selected configuration and updates the UI to reflect
- * the current state of that configuration.
- */
- public void setSelectedConfiguration(IConfiguration config) {
- String nameAndDescription = new String();
- if ((config.getDescription() == null)
- || (config.getDescription().equals(""))) { //$NON-NLS-1$
- nameAndDescription = config.getName();
- } else {
- nameAndDescription = config.getName() + "( " //$NON-NLS-1$
- + config.getDescription() + " )"; //$NON-NLS-1$
- }
- configSelector.select(configSelector.indexOf(nameAndDescription));
- handleConfigSelection();
- }
-
- /**
- * Sets whether the control for selecting a configuration to edit should
- * be enabled.
- */
- public void enableConfigSelection (boolean enable) {
- configSelector.setEnabled(enable);
- }
-
- /**
- * Sets whether the control for managing the configurations should be
- * enabled.
- */
- public void enabledManageConfigs (boolean enable) {
- manageConfigs.setEnabled(false);
- }
-
- /* (non-Javadoc)
- * @return
- */
- public IConfiguration getSelectedConfiguration() {
- return selectedConfiguration;
- }
-
- public IConfiguration getSelectedConfigurationClone(){
- return clonedConfiguration;
- }
-
- /* (non-Javadoc)
- * @return
- */
- protected Point getLastShellSize() {
- if (lastShellSize == null) {
- Shell shell = getShell();
- if (shell != null)
- lastShellSize = shell.getSize();
- }
- return lastShellSize;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePageContainer#getPreferenceStore()
- */
- public IPreferenceStore getPreferenceStore()
- {
- return fOptionBlock.getPreferenceStore();
- }
-
- /* (non-Javadoc)
- * Return the IPreferenceStore of the Tool Settings block
- */
- public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore()
- {
- return fOptionBlock.getToolSettingsPreferenceStore();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialog.ICOptionContainer.getPreferences()
- */
- public Preferences getPreferences()
- {
- return null;
- }
-
- public IProject getProject() {
- Object element= getElement();
- if (element != null && element instanceof IProject) {
- return (IProject)element;
- }
- return null;
- }
-
- public void updateContainer() {
- fOptionBlock.update();
- setValid(fOptionBlock.isValid());
- setErrorMessage(fOptionBlock.getErrorMessage());
- }
-
- public boolean isValid() {
- updateContainer();
- return super.isValid();
- }
-
- /**
- * @see DialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- fOptionBlock.setVisible(visible);
- if (visible) {
- fOptionBlock.updateValues();
- displayedConfig = true;
- }
- }
-
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
- */
- public void updateButtons() {
- }
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
- */
- public void updateMessage() {
- }
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
- */
- public void updateTitle() {
- }
-
- /*
- * Event Handlers
- */
- private void handleConfigSelection () {
- // If there is nothing in config selection widget just bail
- if (configSelector.getItemCount() == 0) return;
-
- // TODO: Check if the user has selected the "all" configuration
- int selectionIndex = configSelector.getSelectionIndex();
- if (selectionIndex == -1) return;
- String configName = configSelector.getItem(selectionIndex);
- if (configName.equals(ManagedBuilderUIMessages.getResourceString(ALL_CONFS))) {
- // This is the all config
- return;
- } else {
- // Cache the selected config
- IConfiguration newConfig = configurations[selectionIndex];
- if (newConfig != selectedConfiguration) {
- // If the user has changed values, and is now switching configurations, prompt for saving
- if (selectedConfiguration != null) {
- if (fOptionBlock.isDirty()) {
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- boolean shouldApply = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("BuildPropertyPage.changes.save.question", //$NON-NLS-1$
- new String[] {selectedConfiguration.getName(), newConfig.getName()}));
- if (shouldApply) {
- if (performOk()) {
- fOptionBlock.setDirty(false);
- } else {
- MessageDialog.openWarning(shell,
- ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.error")); //$NON-NLS-1$
- }
- }
- }
- }
- // Set the new selected configuration
- selectedConfiguration = newConfig;
- ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
- clonedConfiguration = getClonedConfig(selectedConfiguration);
- // TODO: Set the appropriate error parsers...
- // TODO: Binary parsers too?
- fOptionBlock.updateValues();
-
- doUpdateMessage();
- }
- }
- }
-
- private void doUpdateMessage(){
- if(selectedProjectType != null && !selectedProjectType.isSupported()){
- setMessage(ManagedBuilderUIMessages.getResourceString(MSG_UNSUPPORTED_PROJ),IMessageProvider.WARNING);
- }
- else if(clonedConfiguration != null){
- if(clonedConfiguration.isSupported()){
- setMessage(null,IMessageProvider.NONE);
- }
- else{
- setMessage(ManagedBuilderUIMessages.getResourceString(MSG_UNSUPPORTED_CONFIG),IMessageProvider.WARNING);
- }
- }
- else
- setMessage(ManagedBuilderUIMessages.getResourceString(MSG_CONFIG_NOTSELECTED),IMessageProvider.WARNING);
- getContainer().updateMessage();
- }
-
- // Event handler for the manage configuration button event
- private void handleManageConfig() {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
- ManageConfigDialog manageDialog = new ManageConfigDialog(getShell(),
- ManagedBuilderUIMessages.getResourceString(MANAGE_TITLE), info
- .getManagedProject());
- if (manageDialog.open() == ManageConfigDialog.OK) {
- // Check to see if any configurations have to be deleted
- List deletedConfigs = manageDialog.getDeletedConfigIds();
- Iterator iter = deletedConfigs.listIterator();
- while (iter.hasNext()) {
- String id = (String) iter.next();
- // Remove any settings stores
- fOptionBlock.removeValues(id);
- }
- // Update the config lists
- configurations = info.getManagedProject().getConfigurations();
- configSelector.removeAll();
- configSelector.setItems(getConfigurationNamesAndDescriptions());
-
- IConfiguration tmpSelectedConfiguration = manageDialog.getSelectedConfiguration();
- setSelectedConfiguration(tmpSelectedConfiguration);
- }
- return;
- }
-
- private void handleProjectTypeSelection() {
- // Is there anything in the selector widget
- if (projectTypeSelector.getItemCount() == 0) {
- manageConfigs.setEnabled(false);
- return;
- }
-
- // Enable the manage button
- manageConfigs.setEnabled(true);
-
- // Cache the platform at the selection index
- selectedProjectType = projectTypes[projectTypeSelector.getSelectionIndex()];
- ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
-
- // Update the contents of the configuration widget
- populateConfigurations();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java
deleted file mode 100644
index c51f2a64e7d..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 Rational Software 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.jface.preference.FieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-public abstract class BuildSettingsPage extends FieldEditorPreferencePage {
- protected IConfiguration clonedConfig;
- protected IResourceConfiguration clonedResConfig;
-
- private boolean dirty = false;
-
- /**
- * @param style
- */
- protected BuildSettingsPage(IConfiguration clonedConfig) {
- // fix for PR 63973
- // If we use a grid layout then widgets that should be layed out horizontally,
- // e.g. StringButtonFieldEditor, will have their component widgets
- // arranged vertically. This looks terrible when you have for instance
- // a StringButtonFieldEditor, which has a label, an edit box, and a "modify" button
- // to the right because all three will be stacked vertically.
- super(FLAT);
- // end fix for 63973
- noDefaultAndApplyButton();
- this.clonedConfig = clonedConfig;
- }
-
- protected BuildSettingsPage(IResourceConfiguration clonedResConfig) {
- // fix for PR 63973
- // If we use a grid layout then widgets that should be layed out horizontally,
- // e.g. StringButtonFieldEditor, will have their component widgets
- // arranged vertically. This looks terrible when you have for instance
- // a StringButtonFieldEditor, which has a label, an edit box, and a "modify" button
- // to the right because all three will be stacked vertically.
- super(FLAT);
- // end fix for 63973
- noDefaultAndApplyButton();
-
- this.clonedResConfig = clonedResConfig;
- this.clonedConfig = clonedResConfig.getParent();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
- protected void createFieldEditors() {
- // Get the preference store for the build settings
- IPreferenceStore settings = getToolSettingsPreferenceStore();
- setPreferenceStore(settings);
- }
-
- /**
- * Return the tool settings preference store
- */
- protected BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore() {
- IPreferencePageContainer container = getContainer();
- if (container instanceof BuildPropertyPage) {
- return ((BuildPropertyPage)container).getToolSettingsPreferenceStore();
- } else if ( container instanceof ResourceBuildPropertyPage) {
- return ((ResourceBuildPropertyPage)container).getToolSettingsPreferenceStore();
- }
- return null;
- }
-
- /**
- * Method called when the value of a dialog field changes
- */
- public void propertyChange(PropertyChangeEvent event) {
- super.propertyChange(event);
- if (event.getProperty().equals(FieldEditor.VALUE)) {
- setDirty(true);
- }
- }
-
- /**
- * Sets the "dirty" state
- */
- public void setDirty(boolean b) {
- dirty = b;
- }
-
- /**
- * Returns the "dirty" state
- */
- public boolean isDirty() {
- return dirty;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java
deleted file mode 100644
index e7b12b169d3..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java
+++ /dev/null
@@ -1,677 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import java.util.ArrayList;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-public class ManageConfigDialog extends Dialog {
- // String constants
- private static final String CMN_PREFIX = "BuildPropertyCommon"; //$NON-NLS-1$
- private static final String CMN_LABEL = CMN_PREFIX + ".label"; //$NON-NLS-1$
- private static final String NEW = CMN_LABEL + ".new"; //$NON-NLS-1$
- private static final String REMOVE = CMN_LABEL + ".remove"; //$NON-NLS-1$
- private static final String PREFIX = "ManageConfig"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String CONVERSION_TARGET_LABEL = LABEL + ".conversionTargetLabel"; //$NON-NLS-1$
- private static final String CONVERT_TARGET = LABEL + ".convertTarget"; //$NON-NLS-1$
- private static final String RENAME = LABEL + ".rename"; //$NON-NLS-1$
- private static final String CONFIGS = LABEL + ".configs"; //$NON-NLS-1$
- private static final String CURRENT_CONFIGS = CONFIGS + ".current"; //$NON-NLS-1$
- private static final String DELETED_CONFIGS = CONFIGS + ".deleted"; //$NON-NLS-1$
- private static final String NEW_CONF_DLG = LABEL + ".new.config.dialog"; //$NON-NLS-1$
- private static final String RENAME_CONF_DLG = LABEL + ".rename.config.dialog"; //$NON-NLS-1$
-
- private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
- private static final String CONVERSION_TARGET_TIP = TIP + ".conversionTarget"; //$NON-NLS-1$
- private static final String CONVERT_TIP = TIP + ".convert"; //$NON-NLS-1$
-
- private static final String EMPTY_STRING = new String();
-
- // The list of configurations to delete
- private SortedMap deletedConfigs;
- // Map of configuration names and ids
- private SortedMap existingConfigs;
- // The target the configs belong to
- private IManagedProject managedProject;
-
- // selected Configuration
- IConfiguration selectedConfiguration;
-
- // The title of the dialog.
- private String title = ""; //$NON-NLS-1$
-
- private Combo conversionTargetSelector;
- private Button convertTargetBtn;
- private Composite conversionGroup;
-
- // The list of conversion targets for the selected configuration
- private SortedMap conversionTargets;
-
- // Widgets
- protected List currentConfigList;
-
- protected Button newBtn;
- protected Button okBtn;
- protected Button removeBtn;
- protected Button renameBtn;
-
-
- /**
- * @param parentShell
- */
- protected ManageConfigDialog(Shell parentShell, String title, IManagedProject proj) {
- super(parentShell);
- this.title = title;
- this.managedProject = proj;
-
- // Get the defined configurations from the target
- getExistingConfigs().clear();
- IConfiguration [] configs = managedProject.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- IConfiguration configuration = configs[i];
- String name = configuration.getName();
- String description = configuration.getDescription();
- String nameAndDescription = new String();
-
- if ( description == null || description.equals("") ) { //$NON-NLS-1$
- nameAndDescription = name;
- } else {
- nameAndDescription = name + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- getExistingConfigs().put(nameAndDescription, configuration);
- }
-
- // Set the selectedConfiguration to default configuration.
- selectedConfiguration = ManagedBuildManager.getSelectedConfiguration(getProject());
-
- // clear DeletedConfig list
- getDeletedConfigs().clear();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if (title != null)
- shell.setText(title);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- protected void createButtonsForButtonBar(Composite parent) {
- // create OK and Cancel buttons by default
- okBtn = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- // createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
-
- updateButtons();
- }
-
- /* (non-Javadoc)
- * Create and lays out the group with the configuration edit controls
- */
- private void createConfigListGroup(Composite parent) {
- // Create the config list group area
- final Group configListGroup = new Group(parent, SWT.NONE);
- configListGroup.setFont(parent.getFont());
- configListGroup.setText(ManagedBuilderUIMessages.getResourceString(CONFIGS));
- configListGroup.setLayout(new GridLayout(1, false));
- configListGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Create the current config List
- currentConfigList = new List(configListGroup, SWT.SINGLE|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER);
- currentConfigList.setFont(configListGroup.getFont());
- GridData data = new GridData(GridData.FILL_BOTH);
- data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH);
- currentConfigList.setLayoutData(data);
- currentConfigList.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- currentConfigList = null;
- }
- });
- currentConfigList.addListener(SWT.Selection, new Listener () {
- public void handleEvent(Event e) {
- handleConfigSelection();
- }
- });
-
-// Create a composite for the conversion target combo
-// final Composite conversionGroup = new Composite(configListGroup, SWT.NULL);
- conversionGroup = new Composite(configListGroup, SWT.NULL);
- conversionGroup.setFont(configListGroup.getFont());
- conversionGroup.setLayout(new GridLayout(2, true));
- conversionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Create the Tool chain conversion target list
- Label conversionTargetLabel = ControlFactory.createLabel(conversionGroup, ManagedBuilderUIMessages.getResourceString(CONVERSION_TARGET_LABEL));
-
- conversionTargetSelector = new Combo(conversionGroup, SWT.READ_ONLY|SWT.DROP_DOWN);
- conversionTargetSelector.addListener(SWT.Selection, new Listener () {
- public void handleEvent(Event e) {
- handleConversionTargetSelection();
- }
- });
- conversionTargetSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONVERSION_TARGET_TIP));
- conversionTargetSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Create a composite for the buttons
- final Composite buttonBar = new Composite(configListGroup, SWT.NULL);
- buttonBar.setFont(configListGroup.getFont());
- buttonBar.setLayout(new GridLayout(4, true));
- buttonBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- convertTargetBtn = ControlFactory.createPushButton(buttonBar, ManagedBuilderUIMessages.getResourceString(CONVERT_TARGET));
- convertTargetBtn.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONVERT_TIP));
- convertTargetBtn.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleConversionTargetSelection();
- }
- });
-
- newBtn = new Button(buttonBar, SWT.PUSH);
- newBtn.setFont(buttonBar.getFont());
- newBtn.setText(ManagedBuilderUIMessages.getResourceString(NEW));
- setButtonLayoutData(newBtn);
- newBtn.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- handleNewPressed();
- }
- });
- newBtn.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- newBtn = null;
- }
- });
-
- removeBtn = new Button(buttonBar, SWT.PUSH);
- removeBtn.setFont(buttonBar.getFont());
- removeBtn.setText(ManagedBuilderUIMessages.getResourceString(REMOVE));
- setButtonLayoutData(removeBtn);
- removeBtn.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- handleRemovePressed();
- }
- });
- removeBtn.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- removeBtn = null;
- }
- });
-
- renameBtn = new Button(buttonBar, SWT.PUSH);
- renameBtn.setFont(buttonBar.getFont());
- renameBtn.setText(ManagedBuilderUIMessages.getResourceString(RENAME));
- setButtonLayoutData(renameBtn);
- renameBtn.addSelectionListener(new SelectionAdapter () {
- public void widgetSelected(SelectionEvent e) {
- handleRenamePressed();
- }
- });
- renameBtn.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- renameBtn = null;
- }
- });
-
- }
-
- private void handleConversionTargetSelection() {
- IConfigurationElement element = null;
- String selectedConversionTargetName = null;
-
- // Determine which conversion target was selected
- int selectionIndex = conversionTargetSelector.getSelectionIndex();
- if (selectionIndex != -1) {
- // Get the converter based on selection
- selectedConversionTargetName = conversionTargetSelector.getItem(selectionIndex);
- element = (IConfigurationElement) getConversionTargets().get(selectedConversionTargetName);
-
- // Get the confirmation from the user
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- boolean shouldConvert = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("ConfigurationConvert.confirmdialog.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("ConfigurationConvert.confirmdialog.message", //$NON-NLS-1$
- new String[] {getSelectedConfiguration().getName(), getSelectedConfiguration().getToolChain().getName(), element.getAttribute("name")})); //$NON-NLS-1$
- if (shouldConvert) {
- IConvertManagedBuildObject convertBuildObject = null;
- try {
- convertBuildObject = (IConvertManagedBuildObject) element.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String fromId = element.getAttribute("fromId"); //$NON-NLS-1$
- String toId = element.getAttribute("toId"); //$NON-NLS-1$
-
- if(convertBuildObject != null ) {
- IConfiguration configuration = (IConfiguration) convertBuildObject.convert( getSelectedConfiguration().getToolChain(), fromId, toId, true);
-
-// Determine which configuration was selected
- int configSelectionIndex = currentConfigList.getSelectionIndex();
-
- // Update the currentConfigList and the existingConfigs variables.
- String selectedConfigNameAndDescription = currentConfigList.getItem(configSelectionIndex);
- getExistingConfigs().remove(selectedConfigNameAndDescription);
-
-// Set the selection to selectedConfiguration.
- String name = configuration.getName();
- String description = configuration.getDescription();
- String nameAndDescription = new String();
-
- if ( description == null || description.equals("") ) { //$NON-NLS-1$
- nameAndDescription = name;
- } else {
- nameAndDescription = name + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Set the selected Configuration to the newConfig
- setSelectedConfiguration(configuration);
- getExistingConfigs().put(nameAndDescription, configuration);
-
- // Update the Configuration combo list that is displayed to the user.
- currentConfigList.removeAll();
- currentConfigList.setItems(getConfigurationNamesAndDescriptions());
-
- currentConfigList.select( currentConfigList.indexOf(nameAndDescription));
-
-// As the selected configuration has changed after conversion, Update the conversion target list,
- updateConversionTargets(configuration);
- }
- }
-
- // Clean up the UI lists
- updateButtons();
-
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite comp = new Composite(parent, SWT.NULL);
- comp.setFont(parent.getFont());
- comp.setLayout(new GridLayout(1, true));
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Make the configuration management area
- createConfigListGroup(comp);
-
- // Do the final widget prep
- // Set the configuration items
- currentConfigList.setItems(getConfigurationNamesAndDescriptions());
-
-
- // Set the selection to selectedConfiguration.
- String name = getSelectedConfiguration().getName();
- String description = getSelectedConfiguration().getDescription();
- String nameAndDescription = new String();
-
- if ( description == null || description.equals("") ) { //$NON-NLS-1$
- nameAndDescription = name;
- } else {
- nameAndDescription = name + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- currentConfigList.select( currentConfigList.indexOf(nameAndDescription));
-
- // Set the conversion target list.
- updateConversionTargets(getSelectedConfiguration());
- newBtn.setFocus();
- return comp;
- }
-
- private String [] getConversionTargetList(IConfiguration config) {
-
- String []emptyList = new String[0];
-
- String fromId = null;
-
- // Get the id of the toolchain used in the given configuration.
- String id = config.getToolChain().getId();
-
- // Clear the conversionTargets list.
- getConversionTargets().clear();
-
- // Get the Converter Extension Point
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
- .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
- "projectConverter"); //$NON-NLS-1$
- if (extensionPoint != null) {
- // Get the extensions
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- // Get the configuration elements of each extension
- IConfigurationElement[] configElements = extensions[i]
- .getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
-
- IConfigurationElement element = configElements[j];
- if (element.getName().equals("converter")) { //$NON-NLS-1$
-
- fromId = element.getAttribute("fromId"); //$NON-NLS-1$
- // Check whether the current converter can be used for the selected configuration(toolchain)
- if (hasToolChainConverters(config.getToolChain(), fromId)) {
- // Add this converter to the display list
- getConversionTargets().put( element.getAttribute("name"), element); //$NON-NLS-1$
- }
- }
- }
- }
- }
- if ( getConversionTargets().isEmpty())
- return (String []) emptyList;
- else
- return (String []) getConversionTargets().keySet().toArray(new String[getConversionTargets().size()]);
- }
-
- private boolean hasToolChainConverters(IToolChain toolChain, String fromId) {
-
-// Check whether the converter's 'fromId' and the given toolChain 'id' are equal
- if(fromId == null)
- return false;
-
- while( toolChain != null) {
- String id = toolChain.getId();
-
- if (fromId.equals(id))
- return true;
- else
- toolChain = toolChain.getSuperClass();
- }
- return false;
- }
-
- private void updateConversionTargets(IConfiguration config) {
- conversionTargetSelector.setItems( getConversionTargetList(config));
- conversionTargetSelector.select(0);
- conversionGroup.setEnabled(conversionTargetSelector.getItemCount() > 0);
- convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 0);
- }
-
- private String [] getConfigurationNamesAndDescriptions() {
- String [] namesAndDescriptions = (String[]) getExistingConfigs().keySet().toArray(new String[getExistingConfigs().size()]);
-
- return namesAndDescriptions;
- }
-
- /* (non-javadoc)
- * Answers a <code>SortedMap</code> of <code>IConfiguration</code> names to unique IDs.
- *
- * @return
- */
- protected SortedMap getDeletedConfigs() {
- if (deletedConfigs == null) {
- deletedConfigs = new TreeMap();
- }
- return deletedConfigs;
- }
-
- /**
- * Answers a <code>List</code> of unique IDs corresponding to the <code>IConfigurations</code>
- * the user wishes to remove from the <code>ITarget</code>
- * @return
- */
- public ArrayList getDeletedConfigIds() {
- return new ArrayList(getDeletedConfigs().values());
- }
-
- protected SortedMap getExistingConfigs() {
- if (existingConfigs == null) {
- existingConfigs = new TreeMap();
- }
- return existingConfigs;
- }
-
-
- protected SortedMap getConversionTargets() {
- if (conversionTargets == null) {
- conversionTargets = new TreeMap();
- }
- return conversionTargets;
- }
-
- /*
- * @return the <code>IProject</code> associated with the managed project
- */
- private IProject getProject() {
- return (IProject)managedProject.getOwner();
- }
-
- /*
- * Event handler for the add button
- */
- protected void handleNewPressed() {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
- // Pop-up a dialog to properly handle the request
- NewConfigurationDialog dialog = new NewConfigurationDialog(getShell(),
- managedProject,
- ManagedBuilderUIMessages.getResourceString(NEW_CONF_DLG));
- if (dialog.open() == NewConfigurationDialog.OK) {
- // Get the new name & description and configuration to base the new config on
- String newConfigName = dialog.getNewName();
- String newConfigDescription = dialog.getNewDescription();
- IConfiguration parentConfig = dialog.getParentConfiguration();
-
- if (parentConfig != null) {
-
- IConfiguration newConfig = dialog.newConfiguration(info);
-
- // Add this new configuration to the existing list.
- String nameAndDescription = new String();
-
- if ( newConfigDescription == null || newConfigDescription.equals("") ) { //$NON-NLS-1$
- nameAndDescription = newConfigName;
- } else {
- nameAndDescription = newConfigName + "( " + newConfigDescription + " )"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Add the newConfig to the existing configurations
- getExistingConfigs().put(nameAndDescription, newConfig);
-
- // Set the selected Configuration to the newConfig
- setSelectedConfiguration(newConfig);
-
- // Update the Configuration combo list that is displayed to the user.
- currentConfigList.setItems(getConfigurationNamesAndDescriptions());
-
- // Get the index of selected configuration & set selection in config list.
- int configIndex = currentConfigList.indexOf(nameAndDescription);
- currentConfigList.setSelection(configIndex);
-
- // As the selected configuration has changed after creation of new configuration,
- // Update the conversion target list,
- updateConversionTargets(newConfig);
- }
- }
- // Update the buttons based on the choices
- updateButtons();
- }
-
- protected void handleRenamePressed() {
- IConfiguration selectedConfig = null;
- String selectedConfigNameAndDescription = null;
-
- // Determine which configuration was selected
- int selectionIndex = currentConfigList.getSelectionIndex();
- if (selectionIndex != -1) {
- selectedConfigNameAndDescription = currentConfigList
- .getItem(selectionIndex);
- selectedConfig = (IConfiguration) getExistingConfigs().get(
- selectedConfigNameAndDescription);
-
- // Pop-up a dialog to properly handle the request
- RenameConfigurationDialog dialog = new RenameConfigurationDialog(
- getShell(), managedProject, selectedConfig,
- ManagedBuilderUIMessages.getResourceString(RENAME_CONF_DLG));
- if (dialog.open() == RenameConfigurationDialog.OK) {
- // Get the new name & description for the selected configuration
- String newConfigName = dialog.getNewName();
-
- String newConfigDescription = dialog.getNewDescription();
-
- selectedConfig.setName(newConfigName);
- selectedConfig.setDescription(newConfigDescription);
-
- // Remove the old configuration from the list and add renamed
- // configuration to the list.
- getExistingConfigs().remove(selectedConfigNameAndDescription);
-
- String nameAndDescription = new String();
-
- if (newConfigDescription == null
- || newConfigDescription.equals("")) { //$NON-NLS-1$
- nameAndDescription = newConfigName;
- } else {
- nameAndDescription = newConfigName + "( " //$NON-NLS-1$
- + newConfigDescription + " )"; //$NON-NLS-1$
- }
- getExistingConfigs().put(nameAndDescription, selectedConfig);
-
- // Set the selected Configuration to the newConfig
- setSelectedConfiguration(selectedConfig);
-
- // Update the Configuration combo list that is displayed to the user.
- currentConfigList.setItems(getConfigurationNamesAndDescriptions());
-
- // Get the index of selected configuration & set selection in config list.
- int configIndex = currentConfigList.indexOf(nameAndDescription);
- currentConfigList.setSelection(configIndex);
-
- // Update the buttons based on the choices
- updateButtons();
- }
- }
- }
-
- /*
- * (non-javadoc) Event handler for the remove button
- */
- protected void handleRemovePressed() {
-
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
-
- // Determine which configuration was selected
- int selectionIndex = currentConfigList.getSelectionIndex();
- if (selectionIndex != -1){
- String selectedConfigNameAndDescription = currentConfigList.getItem(selectionIndex);
-
- // Get the confirmation from user before deleting the configuration
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- boolean shouldDelete = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("ManageConfig.deletedialog.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("ManageConfig.deletedialog.message", //$NON-NLS-1$
- new String[] {selectedConfigNameAndDescription}));
- if (shouldDelete) {
- IConfiguration selectedConfig = (IConfiguration) getExistingConfigs()
- .get(selectedConfigNameAndDescription);
- String selectedConfigId = (String) selectedConfig.getId();
- getDeletedConfigs().put(selectedConfigNameAndDescription,
- selectedConfigId);
-
- // Remove the configurations from the project & from list
- // configuration list
- info.getManagedProject().removeConfiguration(selectedConfigId);
- getExistingConfigs().remove(selectedConfigNameAndDescription);
-
- // Update the Configuration combo list that is displayed to the
- // user.
- currentConfigList
- .setItems(getConfigurationNamesAndDescriptions());
- currentConfigList
- .setSelection(currentConfigList.getItemCount() - 1);
-
- // Update selected configuration variable
- selectionIndex = currentConfigList.getSelectionIndex();
- if (selectionIndex != -1) {
- selectedConfigNameAndDescription = currentConfigList
- .getItem(selectionIndex);
- selectedConfig = (IConfiguration) getExistingConfigs().get(
- selectedConfigNameAndDescription);
- setSelectedConfiguration(selectedConfig);
- }
-
- // As the selected configuration has changed after removal of selected configuration,
- // Update the conversion target list,
- updateConversionTargets(selectedConfig);
-
- // Clean up the UI lists
- updateButtons();
- }
- }
- }
-
- private void updateButtons() {
- // Disable the remove button if there is only 1 configuration
- removeBtn.setEnabled(currentConfigList.getItemCount() > 1);
- convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 0);
- }
-
- private void handleConfigSelection() {
- // Determine which configuration was selected
- int selectionIndex = currentConfigList.getSelectionIndex();
-
- String selectedConfigNameAndDescription = currentConfigList
- .getItem(selectionIndex);
-
- IConfiguration selectedConfig = (IConfiguration) getExistingConfigs()
- .get(selectedConfigNameAndDescription);
- setSelectedConfiguration(selectedConfig);
-
- updateConversionTargets(selectedConfig);
- return;
- }
-
- public IConfiguration getSelectedConfiguration() {
- return selectedConfiguration;
- }
-
- public void setSelectedConfiguration(IConfiguration selectedConfiguration) {
- this.selectedConfiguration = selectedConfiguration;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java
deleted file mode 100644
index c6d5d138166..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java
+++ /dev/null
@@ -1,647 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 Intel 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPropertyPage;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-
-public class ResourceBuildPropertyPage extends AbstractBuildPropertyPage implements
- IWorkbenchPropertyPage, IPreferencePageContainer, ICOptionContainer {
- /*
- * String constants
- */
- private static final String PREFIX = "ResourceBuildPropertyPage"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String NAME_LABEL = LABEL + ".NameText"; //$NON-NLS-1$
- private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
- private static final String ALL_CONFS = PREFIX + ".selection.configuration.all"; //$NON-NLS-1$
- private static final String ACTIVE_RESOURCE_LABEL = LABEL + ".ActiveResource"; //$NON-NLS-1$
- private static final String RESOURCE_SETTINGS_LABEL = LABEL + ".ResourceSettings"; //$NON-NLS-1$
- private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
- private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
- private static final String NOTMBSFILE_LABEL = LABEL + ".NotMBSFile"; //$NON-NLS-1$
- private static final String EXCLUDE_CHECKBOX = LABEL + ".ExcludeCheckBox"; //$NON-NLS-1$
- private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
- private static final String RESOURCE_PLAT_TIP = TIP + ".ResourcePlatform"; //$NON-NLS-1$
- private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
- private static final String EXCLUDE_TIP = TIP + ".excludecheck"; //$NON-NLS-1$
- private static final String MANAGE_TITLE = PREFIX + ".manage.title"; //$NON-NLS-1$
- private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
- private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
- private static final String MSG_UNSUPPORTED_PROJ = PREFIX + ".unsupported.proj"; //$NON-NLS-1$
- private static final String MSG_UNSUPPORTED_CONFIG = PREFIX + ".unsupported.config"; //$NON-NLS-1$
- private static final String MSG_CONFIG_NOTSELECTED = PREFIX + ".config.notselected"; //$NON-NLS-1$
- private static final String MSG_RC_NON_BUILD = PREFIX + ".rc.non.build"; //$NON-NLS-1$
- private static final String MSG_RC_GENERATED = PREFIX + ".rc.generated"; //$NON-NLS-1$
-
- private static final boolean DEFAULT_EXCLUDE_VALUE = false;
- /*
- * Dialog widgets
- */
-
- private Combo configSelector;
-
-// private Point lastShellSize;
- private Button excludedCheckBox;
-
- /*
- * Bookeeping variables
- */
- private boolean noContentOnPage = false;
-
- private IConfiguration[] configurations;
- private IConfiguration selectedConfiguration;
- private IConfiguration clonedConfiguration;
- private IResourceConfiguration clonedResourceConfig;
- private Point lastShellSize;
- protected ManagedBuildOptionBlock fOptionBlock;
- protected boolean displayedConfig = false;
-
- /**
- * Default constructor
- */
- public ResourceBuildPropertyPage() {
- // super();
- }
-
- public void setContainer(IPreferencePageContainer preferencePageContainer) {
- super.setContainer(preferencePageContainer);
- if (fOptionBlock == null) {
- fOptionBlock = new ManagedBuildOptionBlock(this);
- }
- }
-
- protected Control createContents(Composite parent) {
- // Create the container we return to the property page editor
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- GridLayout compositeLayout = new GridLayout();
- compositeLayout.numColumns = 1;
- compositeLayout.marginHeight = 0;
- compositeLayout.marginWidth = 0;
- composite.setLayout( compositeLayout );
-
- // Check to see if we are dealing with a managed build project
- boolean openMBSProject;
- try {
- openMBSProject = (getProject().hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- } catch (CoreException e) {
- openMBSProject = false;
- }
-
- if (openMBSProject) {
- contentForMBSFile(composite);
- } else {
- noContent(composite,ManagedBuilderUIMessages.getResourceString(NOTMBSFILE_LABEL));
- }
-
- return composite;
- }
-
- protected void contentForMBSFile(Composite composite) {
- GridData gd;
-
- // Initialize the key data
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
- String error = null;
- if (info.getVersion() == null) {
- error = ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.error.version_low"); //$NON-NLS-1$
- } else {
- IFile file = (IFile)getElement();
- if(isGeneratedResource(file))
- error = ManagedBuilderUIMessages.getResourceString(MSG_RC_GENERATED);
- else if(file.isDerived())
- error = ManagedBuilderUIMessages.getResourceString(MSG_RC_NON_BUILD);
- }
-
- if(error != null){
- noContent(composite,error);
- return;
- }
-
- // Add a config selection area
- Group configGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(ACTIVE_RESOURCE_LABEL), 1);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.grabExcessHorizontalSpace = true;
- configGroup.setLayoutData(gd);
- // Use the form layout inside the group composite
- FormLayout form = new FormLayout();
- form.marginHeight = 5;
- form.marginWidth = 5;
- configGroup.setLayout(form);
-
- excludedCheckBox = ControlFactory.createCheckBox(configGroup, ManagedBuilderUIMessages.getResourceString(EXCLUDE_CHECKBOX));
- excludedCheckBox.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- handleIsExcluded();
- }
- });
- excludedCheckBox.setToolTipText(ManagedBuilderUIMessages.getResourceString(EXCLUDE_TIP));
-
- FormData fd = new FormData();
- fd.left = new FormAttachment(excludedCheckBox, 0, SWT.CENTER);
- excludedCheckBox.setLayoutData(fd);
-
- Label configLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(CONFIG_LABEL));
- configSelector = new Combo(configGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
- configSelector.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- handleConfigSelection();
- }
- });
- configSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONF_TIP));
-
- // Now do the form layout for the widgets
-
- fd = new FormData();
- fd.top = new FormAttachment(excludedCheckBox, 15, SWT.DEFAULT);
-
- configLabel.setLayoutData(fd);
-
- fd = new FormData();
- fd.top = new FormAttachment(excludedCheckBox, 15, SWT.DEFAULT);
- fd.left = new FormAttachment(configLabel, 5, SWT.DEFAULT);
- fd.right = new FormAttachment(80, -20);
- configSelector.setLayoutData(fd);
-
- // Create the Tools Settings, Build Settings, ... Tabbed pane
- Group tabGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(RESOURCE_SETTINGS_LABEL), 1);
- gd = new GridData(GridData.FILL_BOTH);
- tabGroup.setLayoutData(gd);
- // Update the contents of the configuration widget
- populateConfigurations();
- fOptionBlock.createContents(tabGroup, getElement());
-
- WorkbenchHelp.setHelp(composite,ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
- }
-
- protected void noContent(Composite composite, String message) {
- Label label = new Label(composite, SWT.LEFT);
- label.setText(message);
- label.setFont(composite.getFont());
-
- noContentOnPage = true;
- noDefaultAndApplyButton();
- }
-
- private void handleIsExcluded() {
-
- // Check whether the check box is selected or not.
- boolean isSelected = excludedCheckBox.getSelection();
- setExcluded(isSelected);
- }
-
- /*
- * (non-Javadoc) @return an array of names for the configurations defined
- * for the chosen
- */
- private String[] getConfigurationNames() {
- String[] names = new String[configurations.length];
- for (int index = 0; index < configurations.length; ++index) {
- names[index] = configurations[index].getName();
- }
- return names;
- }
-
- protected Point getLastShellSize() {
- if (lastShellSize == null) {
- Shell shell = getShell();
- if (shell != null)
- lastShellSize = shell.getSize();
- }
- return lastShellSize;
- }
-
- public IProject getProject() {
- Object element = getElement();
- if (element != null && element instanceof IFile) {
- IFile file = (IFile) element;
- return (IProject) file.getProject();
- }
- return null;
- }
-
- /*
- * (non-Javadoc) @return
- */
- public IConfiguration getSelectedConfiguration() {
- return selectedConfiguration;
- }
-
- /*
- * Event Handlers
- */
- private void handleConfigSelection() {
- // If there is nothing in config selection widget just bail
- if (configSelector.getItemCount() == 0)
- return;
-
- // Check if the user has selected the "all" configuration
- int selectionIndex = configSelector.getSelectionIndex();
- if (selectionIndex == -1)
- return;
- String configName = configSelector.getItem(selectionIndex);
- if (configName.equals(ManagedBuilderUIMessages
- .getResourceString(ALL_CONFS))) {
- // This is the all config
- return;
- } else {
- IConfiguration newConfig = configurations[selectionIndex];
- if (newConfig != selectedConfiguration) {
- // If the user has changed values, and is now switching configurations, prompt for saving
- if (selectedConfiguration != null) {
- if (fOptionBlock.isDirty()) {
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- boolean shouldApply = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("BuildPropertyPage.changes.save.question", //$NON-NLS-1$
- new String[] {selectedConfiguration.getName(), newConfig.getName()}));
- if (shouldApply) {
- if (performOk()) {
- fOptionBlock.setDirty(false);
- } else {
- MessageDialog.openWarning(shell,
- ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.error")); //$NON-NLS-1$
- }
- }
- }
- }
- // Set the new selected configuration
- selectedConfiguration = newConfig;
- ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
- clonedConfiguration = getClonedConfig(selectedConfiguration);
- // Set the current Resource Configuration
- clonedResourceConfig = getCurrentResourceConfig(clonedConfiguration,true);
-
- fOptionBlock.updateValues();
- excludedCheckBox.setSelection(isExcluded());
- }
- }
- return;
- }
-
-
- /*
- * This method updates the property page message
- */
- private void doUpdateMessage(){
- if(selectedConfiguration != null){
- if(selectedConfiguration.isSupported()){
- setMessage(null,IMessageProvider.NONE);
- }
- else{
- IManagedProject mngProj = selectedConfiguration.getManagedProject();
- IProjectType projType = mngProj != null ? mngProj.getProjectType() : null;
- if(projType != null && !projType.isSupported())
- setMessage(ManagedBuilderUIMessages.getResourceString(MSG_UNSUPPORTED_PROJ),IMessageProvider.WARNING);
- else
- setMessage(ManagedBuilderUIMessages.getResourceString(MSG_UNSUPPORTED_CONFIG),IMessageProvider.WARNING);
- }
- } else {
- setMessage(ManagedBuilderUIMessages.getResourceString(MSG_CONFIG_NOTSELECTED),IMessageProvider.WARNING);
- }
- getContainer().updateMessage();
- }
-
- /*
- * Returns true if the given resource is created by the buildfile generator
- */
- public boolean isGeneratedResource(IFile file){
- IConfiguration cfg = getSelectedConfiguration();
- IProject project = getProject();
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- if(cfg == null)
- cfg = info.getDefaultConfiguration();
-
- if(cfg != null && info != null){
- IManagedBuilderMakefileGenerator makeGen = ManagedBuildManager.getBuildfileGenerator(cfg);
- makeGen.initialize(project,info,null);
- return makeGen.isGeneratedResource(file);
- }
- return false;
- }
-
- /*
- * Returns true if the tool-chain used in the given configuration
- * can build the resource
- *
- * @param file
- * @param cfg
- * @return
- */
- public boolean isBuildResource(IFile file, IConfiguration cfg){
- IResourceConfiguration rcCfg = cfg.getResourceConfiguration(file.getFullPath().toString());
- if(rcCfg != null){
- ITool tools[] = rcCfg.getTools();
- if(tools == null || tools.length == 0)
- return false;
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- if (!tool.getCustomBuildStep() || tool.isExtensionElement())
- return true;
- }
- } else {
- String ext = file.getFileExtension();
- ITool[] tools = cfg.getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(ext))
- return true;
- }
- }
- return false;
- }
-
- /*
- * Returns true if the given resource can be built by at list one configuration
- * defined for the resource project
- */
- public boolean isBuildResource(IFile file){
- IProject project = file.getProject();
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- if(info != null){
- IManagedProject managedProject = info.getManagedProject();
- if(managedProject != null){
- IConfiguration cfgs[] = managedProject.getConfigurations();
- if(cfgs != null && cfgs.length > 0){
- for(int i = 0; i < cfgs.length; i++){
- if(isBuildResource(file,cfgs[i]))
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
-
-
- protected void performDefaults() {
- fOptionBlock.performDefaults();
- excludedCheckBox.setSelection(getCurrentResourceConfigClone().isExcluded());
- super.performDefaults();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
-
- boolean retStatus = true;
-
- // If there is no content on the page, then there is nothing to do
- if (noContentOnPage) return true;
-
- // If the user did not visit this page, then there is nothing to do.
- if (!displayedConfig) return true;
-
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- if(containsDefaults()){
- removeCurrentResourceConfig();
- return;
- }
-
- fOptionBlock.performApply(monitor);
- getCurrentResourceConfig(true).setExclude(getCurrentResourceConfigClone().isExcluded());
- }
- };
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
- try {
- new ProgressMonitorDialog(getShell()).run(false, true, op);
- } catch (InvocationTargetException e) {
- Throwable e1 = e.getTargetException();
- ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
- return false;
- } catch (InterruptedException e) {
- // cancelled
- return false;
- }
-
- // Write out the build model info
- ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
-
- if (getCurrentResourceConfigClone().isDirty()) {
-// selectedConfiguration.setRebuildState(true);
- getCurrentResourceConfigClone().setDirty(false);
- }
-
- retStatus = ManagedBuildManager.saveBuildInfo(getProject(), false);
-
- IManagedBuildInfo bi = ManagedBuildManager.getBuildInfo(getProject());
- if (bi != null & bi instanceof ManagedBuildInfo) {
- ((ManagedBuildInfo)bi).initializePathEntries();
- }
-
- EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
-
- return retStatus;
- }
-
- public boolean containsDefaults(){
- // Check for a non-default "excluded" value
- if(getCurrentResourceConfigClone().isExcluded() != DEFAULT_EXCLUDE_VALUE)
- return false;
- return fOptionBlock.containsDefaults();
- }
-
- public boolean performCancel() {
- // If there is no content on the page, then there is nothing to do
- if (noContentOnPage) return true;
-
- EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
-
- return true;
- }
-
-
- private void populateConfigurations() {
-
- ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
- // If the config select widget is not there yet, just stop
- if (configSelector == null)
- return;
-
- // Find the configurations defined for the platform
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
- configurations = info.getManagedProject().getConfigurations();
- if (configurations.length == 0)
- return;
-
- // Clear and replace the contents of the selector widget
- configSelector.removeAll();
- configSelector.setItems(getConfigurationNames());
-
- // Make sure the active configuration is selected
- IConfiguration defaultConfig = info.getDefaultConfiguration();
- int index = configSelector.indexOf(defaultConfig.getName());
- configSelector.select(index == -1 ? 0 : index);
- handleConfigSelection();
-
- }
-
-
- /**
- * @return Returns the currentResourceConfig.
- */
- public IResourceConfiguration getCurrentResourceConfigClone() {
- return clonedResourceConfig;
- }
-
- public IResourceConfiguration getCurrentResourceConfig(boolean create) {
- return getCurrentResourceConfig(selectedConfiguration,create);
- }
-
-
- private IResourceConfiguration getCurrentResourceConfig(IConfiguration cfg, boolean create){
- IResourceConfiguration rcCfg = cfg.getResourceConfiguration(((IFile)getElement()).getFullPath().toString());
- if(rcCfg == null && create)
- rcCfg = cfg.createResourceConfiguration((IFile)getElement());
- return rcCfg;
- }
-
- public boolean removeCurrentResourceConfig(){
- IResourceConfiguration rcCfg = getCurrentResourceConfig(false);
- if(rcCfg != null){
- selectedConfiguration.removeResourceConfiguration(rcCfg);
- return true;
- }
- return false;
- }
-
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
- */
- public void updateButtons() {
- }
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
- */
- public void updateMessage() {
- }
- /**
- * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
- */
- public void updateTitle() {
- }
-
- public void updateContainer() {
- fOptionBlock.update();
- setValid(fOptionBlock.isValid());
- setErrorMessage(fOptionBlock.getErrorMessage());
- }
-
- public boolean isValid() {
- updateContainer();
- return super.isValid();
- }
-
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- fOptionBlock.setVisible(visible);
- if (visible) {
- fOptionBlock.updateValues();
- displayedConfig = true;
- }
- }
-
- public IPreferenceStore getPreferenceStore()
- {
- return fOptionBlock.getPreferenceStore();
- }
-
- /* (non-Javadoc)
- * Return the IPreferenceStore of the Tool Settings block
- */
- public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore()
- {
- return fOptionBlock.getToolSettingsPreferenceStore();
- }
-
- public Preferences getPreferences()
- {
- return null;
- }
- public void enableConfigSelection (boolean enable) {
- configSelector.setEnabled(enable);
- }
- /**
- * @return Returns the isExcluded.
- */
- public boolean isExcluded(){
- return getCurrentResourceConfigClone().isExcluded();
- }
-
- /**
- * @param isExcluded The isExcluded to set.
- */
- public void setExcluded(boolean isExcluded) {
- getCurrentResourceConfigClone().setExclude(isExcluded);
- fOptionBlock.updateValues();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/AbstractCWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/AbstractCWizard.java
new file mode 100644
index 00000000000..88189574e8e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/AbstractCWizard.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.ui.newui.ManagedBuilderUIImages;
+import org.eclipse.cdt.utils.Platform;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+public abstract class AbstractCWizard implements ICNewWizard {
+
+ private static final String os = Platform.getOS();
+ private static final String arch = Platform.getOSArch();
+ private static final String ALL = "all"; //$NON-NLS-1$
+
+ protected static final Image IMG0 = CPluginImages.get(CPluginImages.IMG_OBJS_CFOLDER);
+ protected static final Image IMG1 = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_CAT);
+ protected static final Image IMG2 = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_TOOL);
+
+ protected Composite parent;
+ protected IToolChainListListener listener;
+
+ public void setDependentControl(Composite _parent, IToolChainListListener _listener) {
+ parent = _parent;
+ listener = _listener;
+ }
+
+ protected boolean isValid(IToolChain tc) {
+ if (tc == null || !tc.isSupported() || tc.isAbstract() || tc.isSystemObject())
+ return false;
+ ITargetPlatform tp = tc.getTargetPlatform();
+ if (tp != null) {
+ List osList = Arrays.asList(tc.getOSList());
+ if (osList.contains(ALL) || osList.contains(os)) {
+ List archList = Arrays.asList(tc.getArchList());
+ if (archList.contains(ALL) || archList.contains(arch))
+ return true; // OS and ARCH fits
+ }
+ return false; // OS or ARCH does not fit
+ }
+ return true; // No platform: nothing to check
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CCProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CCProjectWizard.java
new file mode 100644
index 00000000000..ad1d847bfdb
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CCProjectWizard.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+public class CCProjectWizard extends NewModelProjectWizard {
+
+ public CCProjectWizard() {
+ super(IDEWorkbenchMessages.getString("NewModelProjectWizard.2"), IDEWorkbenchMessages.getString("NewModelProjectWizard.3")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ protected String[] getNatures() {
+ return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID };
+ }
+
+ protected IProject continueCreation(IProject prj) {
+ try {
+ CProjectNature.addCNature(prj, new NullProgressMonitor());
+ CCProjectNature.addCCNature(prj, new NullProgressMonitor());
+ } catch (CoreException e) {}
+ return prj;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CConfigWizardPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CConfigWizardPage.java
new file mode 100644
index 00000000000..c0c54f984c3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CConfigWizardPage.java
@@ -0,0 +1,317 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.ui.newui.ManagedBuilderUIImages;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class CConfigWizardPage extends MBSCustomPage {
+
+ public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.CConfigWizardPage"; //$NON-NLS-1$
+
+ private static final Image IMG = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_CONFIG);
+ private static final String TITLE = IDEWorkbenchMessages.getString("CConfigWizardPage.0"); //$NON-NLS-1$
+ private static final String MESSAGE = IDEWorkbenchMessages.getString("CConfigWizardPage.1"); //$NON-NLS-1$
+ private static final String DELIMITER = "_with_"; //$NON-NLS-1$
+ private static final String EMPTY_STR = ""; //$NON-NLS-1$
+
+ ICWizardHandler handler;
+ Table table;
+ CheckboxTableViewer tv;
+ Label l_projtype;
+ Label l_chains;
+
+ Composite parent;
+ String errorMessage = null;
+ String message = MESSAGE;
+ boolean isVisible = false;
+ Button propButton;
+
+ public CConfigWizardPage() { pageID = PAGE_ID; }
+
+ private CfgItem[] getCfgItems(boolean getDefault) {
+ if (handler == null) return null;
+ CfgItem[] its;
+ if (getDefault)
+ its = cfgItems(getDefaultCfgs(handler));
+ else {
+ ArrayList out = new ArrayList(table.getItemCount());
+ TableItem[] tis = table.getItems();
+ for (int i=0; i < tis.length; i++) {
+ if (tis[i].getChecked())
+ out.add(tis[i].getData());
+ }
+ its = (CfgItem[])out.toArray(new CfgItem[out.size()]);
+ }
+ return its;
+ }
+
+ public IConfiguration[] getConfigurations(boolean getDefault) {
+ CfgItem[] its = getCfgItems(getDefault);
+ if (its == null) return new IConfiguration[0];
+ IConfiguration[] cfgs = new IConfiguration[its.length];
+ for (int i=0; i<its.length; i++) cfgs[i] = its[i].cfg;
+ return cfgs;
+ }
+
+ public String[] getNames(boolean getDefault) {
+ CfgItem[] its = getCfgItems(getDefault);
+ if (its == null) return new String[0];
+ String [] names = new String[its.length];
+ for (int i=0; i<its.length; i++) names[i] = its[i].name;
+ return names;
+ }
+
+ public void createControl(Composite p) {
+ parent = new Composite(p, SWT.NONE);
+ parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ parent.setLayout(new GridLayout(3, false));
+
+ setupLabel(parent, IDEWorkbenchMessages.getString("CConfigWizardPage.4"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ l_projtype = setupLabel(parent, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
+ setupLabel(parent, IDEWorkbenchMessages.getString("CConfigWizardPage.5"), 1, GridData.BEGINNING); //$NON-NLS-1$
+ l_chains = setupLabel(parent, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
+ setupLabel(parent, IDEWorkbenchMessages.getString("CConfigWizardPage.6"), 3, GridData.BEGINNING); //$NON-NLS-1$
+
+ table = new Table(parent, SWT.BORDER | SWT.CHECK);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ table.setLayoutData(gd);
+
+ tv = new CheckboxTableViewer(table);
+ tv.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return (Object[])inputElement;
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+ tv.setLabelProvider(new LabelProvider() {
+ public String getText(Object element) {
+ return element == null ? EMPTY_STR : ((CfgItem)element).name;//$NON-NLS-1$
+ }
+ public Image getImage(Object element) { return IMG; }
+ });
+ tv.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ isCustomPageComplete();
+ update();
+ }});
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ c.setLayout(new GridLayout(1, false));
+
+ Button b1 = new Button(c, SWT.PUSH);
+ b1.setText(IDEWorkbenchMessages.getString("CConfigWizardPage.7")); //$NON-NLS-1$
+ b1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b1.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ tv.setAllChecked(true);
+ isCustomPageComplete();
+ update();
+ }});
+
+ Button b2 = new Button(c, SWT.PUSH);
+ b2.setText(IDEWorkbenchMessages.getString("CConfigWizardPage.8")); //$NON-NLS-1$
+ b2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b2.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ tv.setAllChecked(false);
+ isCustomPageComplete();
+ update();
+ }});
+ propButton = new Button(parent, SWT.CHECK);
+ gd = new GridData(GridData.BEGINNING);
+ gd.horizontalSpan = 3;
+ propButton.setLayoutData(gd);
+ propButton.setText(IDEWorkbenchMessages.getString("CConfigWizardPage.9")); //$NON-NLS-1$
+ propButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handler.setShowProperties(((Button)e.widget).getSelection());
+ }});
+ }
+
+ /**
+ *
+ * @param handler
+ * @return
+ */
+ static public IConfiguration[] getDefaultCfgs(ICWizardHandler handler) {
+ IToolChain[] tcs = handler.getSelectedToolChains();
+ String id = handler.getPropertyId();
+ IProjectType pt = handler.getProjectType();
+ ArrayList out = new ArrayList(tcs.length * 2);
+ for (int i=0; i < tcs.length; i++) {
+ IConfiguration[] cfgs = null;
+ if (id != null)
+ cfgs = ManagedBuildManager.getExtensionConfigurations(tcs[i], ICWizardHandler.ARTIFACT, id);
+ else if (pt != null)
+ cfgs = ManagedBuildManager.getExtensionConfigurations(tcs[i], pt);
+ if (cfgs == null) return null;
+
+ for (int j=0; j<cfgs.length; j++) {
+ if (cfgs[j].isSystemObject() || (handler.supportedOnly() && !cfgs[j].isSupported())) continue;
+ out.add(cfgs[j]);
+ }
+ }
+ return (IConfiguration[])out.toArray(new IConfiguration[out.size()]);
+ }
+
+ /**
+ * Returns whether this page's controls currently all contain valid
+ * values.
+ *
+ * @return <code>true</code> if all controls are valid, and
+ * <code>false</code> if at least one is invalid
+ */
+ public boolean isCustomPageComplete() {
+ if (!isVisible) return true;
+
+ if (table.getItemCount() == 0) {
+ errorMessage = IDEWorkbenchMessages.getString("CConfigWizardPage.10"); //$NON-NLS-1$
+ message = errorMessage;
+ return false;
+ }
+ if (tv.getCheckedElements().length == 0) {
+ errorMessage = IDEWorkbenchMessages.getString("CConfigWizardPage.11"); //$NON-NLS-1$
+ message = errorMessage;
+ return false;
+ }
+ errorMessage = null;
+ message = MESSAGE;
+ return true;
+ }
+
+ /**
+ *
+ */
+ public void setVisible(boolean visible) {
+ isVisible = visible;
+ if (handler != null) {
+ if (handler.needsConfig()) {
+ tv.setInput(cfgItems(getDefaultCfgs(handler)));
+ tv.setAllChecked(true);
+// setPageComplete(validatePage());
+ if (visible) {
+ String s = EMPTY_STR;
+ IToolChain[] tc = handler.getSelectedToolChains();
+ for (int i=0; i < tc.length; i++) {
+ s = s + tc[i].getName();
+ if (i < tc.length - 1) s = s + ", "; //$NON-NLS-1$
+ }
+ l_chains.setText(s);
+ l_projtype.setText(handler.getName());
+ }
+ }
+ }
+ propButton.setSelection(handler.showProperties());
+ parent.setVisible(visible);
+ if (visible) update();
+ }
+
+ class CfgItem {
+ String name;
+ IConfiguration cfg;
+ CfgItem(IConfiguration _cfg) {
+ cfg = _cfg;
+ name = cfg.getName();
+ }
+ }
+
+ private boolean hasDoubles(CfgItem[] its) {
+ for (int i=0; i<its.length; i++) {
+ String s = its[i].name;
+ for (int j=0; j<its.length; j++) {
+ if (i == j) continue;
+ if (s.equals(its[j].name))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private CfgItem[] cfgItems(IConfiguration[] cfgs) {
+ CfgItem[] its = new CfgItem[cfgs.length];
+ for (int i=0; i<cfgs.length; i++)
+ its[i] = new CfgItem(cfgs[i]);
+
+ // if names are not unique, add toolchain name
+ if (hasDoubles(its)) {
+ for (int k=0; k<its.length; k++) {
+ its[k].name = its[k].name + DELIMITER + its[k].cfg.getToolChain().getName();
+ }
+ }
+ // if names are still not unique, add index
+ if (hasDoubles(its)) {
+ for (int k=0; k<its.length; k++) {
+ its[k].name = its[k].name + k;
+ }
+ }
+ return its;
+ }
+
+ //------------------------
+ private Label setupLabel(Composite c, String name, int span, int mode) {
+ Label l = new Label(c, SWT.NONE);
+ l.setText(name);
+ GridData gd = new GridData(mode);
+ gd.horizontalSpan = span;
+ l.setLayoutData(gd);
+ Composite p = l.getParent();
+ l.setFont(p.getFont());
+ return l;
+ }
+
+ public void setHandler(ICWizardHandler h) { handler = h; }
+
+ public String getName() { return TITLE; }
+ public void dispose() {}
+ public Control getControl() { return parent; }
+ public String getDescription() { return null; }
+ public String getErrorMessage() { return errorMessage; }
+ public Image getImage() { return wizard.getDefaultPageImage(); }
+ public String getMessage() { return message; }
+ public String getTitle() { return TITLE; }
+ public void performHelp() {}
+ public void setDescription(String description) {}
+ public void setImageDescriptor(ImageDescriptor image) {}
+ public void setTitle(String _title) {}
+
+ protected void update() {
+ wizard.getContainer().updateButtons();
+ wizard.getContainer().updateMessage();
+ wizard.getContainer().updateTitleBar();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTProjectWizard.java
new file mode 100644
index 00000000000..8b87504e80d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTProjectWizard.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+
+public class CDTProjectWizard extends NewModelProjectWizard {
+
+ public CDTProjectWizard() {
+ super(IDEWorkbenchMessages.getString("NewModelProjectWizard.0"), IDEWorkbenchMessages.getString("NewModelProjectWizard.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ protected String[] getNatures() {
+ return new String[0];
+ }
+
+ protected IProject continueCreation(IProject prj) {
+ return prj;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CMainWizardPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CMainWizardPage.java
new file mode 100644
index 00000000000..9449b5f2877
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CMainWizardPage.java
@@ -0,0 +1,505 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+ import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.ui.newui.PageLayout;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
+import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea;
+import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter;
+
+ public class CMainWizardPage extends WizardPage implements IToolChainListListener {
+
+ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.managedbuilder.ui.CDTWizard"; //$NON-NLS-1$
+ public static final String ELEMENT_NAME = "wizard"; //$NON-NLS-1$
+ public static final String CLASS_NAME = "class"; //$NON-NLS-1$
+
+ public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.NewModelProjectWizardPage"; //$NON-NLS-1$
+
+ // initial value stores
+ private String initialProjectFieldValue;
+
+ // widgets
+ private Text projectNameField;
+ private Tree tree;
+ private Composite right;
+ private Button show_sup;
+ private Label right_label;
+ private Button propButton;
+
+ private CConfigWizardPage next;
+ protected ICWizardHandler h_selected = null;
+
+ private Listener nameModifyListener = new Listener() {
+ public void handleEvent(Event e) {
+ setLocationForSelection();
+ setPageComplete(validatePage());
+ }
+ };
+
+ private ProjectContentsLocationArea locationArea;
+
+ // constants
+ private static final int SIZING_TEXT_FIELD_WIDTH = 250;
+
+ /**
+ * Creates a new project creation wizard page.
+ *
+ * @param pageName the name of this page
+ */
+ public CMainWizardPage(String pageName, CConfigWizardPage _next) {
+ super(pageName);
+ setPageComplete(false);
+ next = _next;
+ }
+
+ /** (non-Javadoc)
+ * Method declared on IDialogPage.
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+
+ initializeDialogUnits(parent);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
+ IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE);
+
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createProjectNameGroup(composite);
+ locationArea = new ProjectContentsLocationArea(getErrorReporter(), composite);
+ if(initialProjectFieldValue != null) {
+ locationArea.updateProjectName(initialProjectFieldValue);
+ }
+
+ // Scale the button based on the rest of the dialog
+ setButtonLayoutData(locationArea.getBrowseButton());
+
+ createDynamicGroup(composite);
+
+ updateData();
+
+ setPageComplete(validatePage());
+ // Show description on opening
+ setErrorMessage(null);
+ setMessage(null);
+ setControl(composite);
+ }
+
+ private void createDynamicGroup(Composite parent) {
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayoutData(new GridData(GridData.FILL_BOTH));
+ c.setLayout(new GridLayout(2, true));
+
+ Label l1 = new Label(c, SWT.NONE);
+ l1.setText(org.eclipse.cdt.managedbuilder.ui.wizards.IDEWorkbenchMessages.getString("CMainWizardPage.0")); //$NON-NLS-1$
+ l1.setFont(parent.getFont());
+ l1.setLayoutData(new GridData(GridData.BEGINNING));
+
+ right_label = new Label(c, SWT.NONE);
+ right_label.setFont(parent.getFont());
+ right_label.setLayoutData(new GridData(GridData.BEGINNING));
+
+ tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
+ tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+ tree.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TreeItem[] tis = tree.getSelection();
+ if (tis == null || tis.length == 0) return;
+ switchTo((ICWizardHandler)tis[0].getData());
+ setPageComplete(validatePage());
+ }});
+
+ right = new Composite(c, SWT.NONE);
+ right.setLayoutData(new GridData(GridData.FILL_BOTH));
+ right.setLayout(new PageLayout());
+
+ show_sup = new Button(c, SWT.CHECK);
+ show_sup.setSelection(true);
+ show_sup.setText(org.eclipse.cdt.managedbuilder.ui.wizards.IDEWorkbenchMessages.getString("CMainWizardPage.1")); //$NON-NLS-1$
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ show_sup.setLayoutData(gd);
+ show_sup.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (h_selected != null)
+ h_selected.setSupportedOnly(show_sup.getSelection());
+ updateData();
+ }} );
+ propButton = new Button(c, SWT.CHECK);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ propButton.setLayoutData(gd);
+ propButton.setText(org.eclipse.cdt.managedbuilder.ui.wizards.IDEWorkbenchMessages.getString("CMainWizardPage.2")); //$NON-NLS-1$
+ propButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (h_selected != null)
+ h_selected.setShowProperties(propButton.getSelection());
+ }});
+ }
+
+ private void setPropertyCheck(ICWizardHandler h) {
+ if (h != null) {
+ propButton.setSelection(h.showProperties());
+ propButton.setEnabled(true);
+ } else {
+ propButton.setEnabled(false);
+ }
+ }
+
+ /**
+ * Get an error reporter for the receiver.
+ * @return IErrorMessageReporter
+ */
+ private IErrorMessageReporter getErrorReporter() {
+ return new IErrorMessageReporter(){
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter#reportError(java.lang.String)
+ */
+ public void reportError(String errorMessage) {
+ setErrorMessage(errorMessage);
+ boolean valid = errorMessage == null;
+ if(valid) {
+ valid = validatePage();
+ }
+
+ setPageComplete(valid);
+ }
+ };
+ }
+
+ public IWizardPage getNextPage() {
+ if (h_selected == null || h_selected.isDummy()) // cannot continue
+ return null;
+
+ if (h_selected.needsConfig()) { // show config page
+ MBSCustomPageManager.setPageHideStatus(next.pageID, false);
+ return next;
+ } else { // skip config page
+ MBSCustomPageManager.setPageHideStatus(next.pageID, true);
+ return MBSCustomPageManager.getNextPage(next.pageID);
+ }
+ }
+ /**
+ * Creates the project name specification controls.
+ *
+ * @param parent the parent composite
+ */
+ private final void createProjectNameGroup(Composite parent) {
+ // project specification group
+ Composite projectGroup = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ projectGroup.setLayout(layout);
+ projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // new project label
+ Label projectLabel = new Label(projectGroup, SWT.NONE);
+ projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
+ projectLabel.setFont(parent.getFont());
+
+ // new project name entry field
+ projectNameField = new Text(projectGroup, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ projectNameField.setLayoutData(data);
+ projectNameField.setFont(parent.getFont());
+
+ // Set the initial value first before listener
+ // to avoid handling an event during the creation.
+ if (initialProjectFieldValue != null) {
+ projectNameField.setText(initialProjectFieldValue);
+ }
+ projectNameField.addListener(SWT.Modify, nameModifyListener);
+ }
+
+ /**
+ * Creates a project resource handle for the current project name field value.
+ * <p>
+ * This method does not create the project resource; this is the responsibility
+ * of <code>IProject::create</code> invoked by the new project resource wizard.
+ * </p>
+ *
+ * @return the new project resource handle
+ */
+ public IProject getProjectHandle() {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
+ }
+
+ /**
+ * Returns the current project name as entered by the user, or its anticipated
+ * initial value.
+ *
+ * @return the project name, its anticipated initial value, or <code>null</code>
+ * if no project name is known
+ */
+
+ public String getProjectName() {
+ if (projectNameField == null) {
+ return initialProjectFieldValue;
+ }
+ return getProjectNameFieldValue();
+ }
+
+ public IPath getProjectLocation() {
+ return new Path(locationArea.getProjectLocation());
+ }
+
+ /**
+ * Returns the value of the project name field
+ * with leading and trailing spaces removed.
+ *
+ * @return the project name in the field
+ */
+ private String getProjectNameFieldValue() {
+ if (projectNameField == null) {
+ return ""; //$NON-NLS-1$
+ }
+
+ return projectNameField.getText().trim();
+ }
+
+ /**
+ * Sets the initial project name that this page will use when
+ * created. The name is ignored if the createControl(Composite)
+ * method has already been called. Leading and trailing spaces
+ * in the name are ignored.
+ * Providing the name of an existing project will not necessarily
+ * cause the wizard to warn the user. Callers of this method
+ * should first check if the project name passed already exists
+ * in the workspace.
+ *
+ * @param name initial project name for this page
+ *
+ * @see IWorkspace#validateName(String, int)
+ *
+ */
+ public void setInitialProjectName(String name) {
+ if (name == null) {
+ initialProjectFieldValue = null;
+ } else {
+ initialProjectFieldValue = name.trim();
+ if(locationArea != null) {
+ locationArea.updateProjectName(name.trim());
+ }
+ }
+ }
+
+ /**
+ * Set the location to the default location if we are set to useDefaults.
+ */
+ void setLocationForSelection() {
+ locationArea.updateProjectName(getProjectNameFieldValue());
+ }
+
+
+ /**
+ * Returns whether this page's controls currently all contain valid
+ * values.
+ *
+ * @return <code>true</code> if all controls are valid, and
+ * <code>false</code> if at least one is invalid
+ */
+ protected boolean validatePage() {
+ IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
+ setMessage(null);
+
+ String projectFieldContents = getProjectNameFieldValue();
+ if (projectFieldContents.equals("")) { //$NON-NLS-1$
+ setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty);
+ return false;
+ }
+
+ IStatus nameStatus = workspace.validateName(projectFieldContents,
+ IResource.PROJECT);
+ if (!nameStatus.isOK()) {
+ setErrorMessage(nameStatus.getMessage());
+ return false;
+ }
+
+ IProject handle = getProjectHandle();
+ if (handle.exists()) {
+ setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage);
+ return false;
+ }
+
+ if (!locationArea.isDefault()) {
+ IStatus locationStatus = workspace.validateProjectLocationURI(handle,
+ locationArea.getProjectLocationURI());
+ if (!locationStatus.isOK()) {
+ setErrorMessage(locationStatus.getMessage());
+ return false;
+ }
+ }
+
+ if (tree.getItemCount() == 0) {
+ setErrorMessage(org.eclipse.cdt.managedbuilder.ui.wizards.IDEWorkbenchMessages.getString("CMainWizardPage.3")); //$NON-NLS-1$
+ return false;
+ }
+
+ // it is not an error, but we cannot continue
+ if (h_selected == null || h_selected.isDummy()) {
+ setErrorMessage(null);
+ return false;
+ }
+
+ if ( ! h_selected.canCreateWithoutToolchain()) {
+ IToolChain tcs[] = h_selected.getSelectedToolChains();
+ int cnt = tcs != null ? tcs.length : 0;
+ if (cnt == 0) {
+ setErrorMessage(org.eclipse.cdt.managedbuilder.ui.wizards.IDEWorkbenchMessages.getString("CMainWizardPage.4")); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ setErrorMessage(null);
+ return true;
+ }
+
+ /*
+ * see @DialogPage.setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ setPropertyCheck(h_selected);
+ if (visible) {
+ projectNameField.setFocus();
+ }
+ }
+
+ /**
+ * Returns the useDefaults.
+ * @return boolean
+ */
+ public boolean useDefaults() {
+ return locationArea.isDefault();
+ }
+
+ void updateData() {
+ // remember selected item
+ TreeItem[] sel = tree.getSelection();
+ String savedStr = (sel.length > 0) ? sel[0].getText() : null;
+
+ tree.removeAll();
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint == null) return;
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions == null) return;
+ for (int i = 0; i < extensions.length; ++i) {
+ IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+ for (int k = 0; k < elements.length; k++) {
+ if (elements[k].getName().equals(ELEMENT_NAME)) {
+ ICNewWizard w = null;
+ try {
+ w = (ICNewWizard) elements[k].createExecutableExtension(CLASS_NAME);
+ } catch (CoreException e) {
+ System.out.println(org.eclipse.cdt.managedbuilder.ui.wizards.IDEWorkbenchMessages.getString("CMainWizardPage.5") + e.getLocalizedMessage()); //$NON-NLS-1$
+ return;
+ }
+ if (w == null) return;
+
+ w.setDependentControl(right, this);
+ w.createItems(tree, show_sup.getSelection());
+ }
+ }
+ }
+ if (tree.getItemCount() > 0) {
+ TreeItem target = tree.getItem(0);
+ // try to search item which was selected before
+ if (savedStr != null) {
+ TreeItem[] all = tree.getItems();
+ for (int i=0; i<all.length; i++) {
+ if (savedStr.equals(all[i].getText())) {
+ target = all[i];
+ break;
+ }
+ }
+ }
+ tree.setSelection(target);
+ switchTo((ICWizardHandler)target.getData());
+ }
+ }
+
+ /**
+ * @param h - new handler
+ */
+ private void switchTo(ICWizardHandler h) {
+ setPropertyCheck(h);
+ if (h == null) return;
+ if (h_selected != null) h_selected.handleUnSelection();
+ h_selected = h;
+ right_label.setText(h_selected.getHeader());
+ h_selected.handleSelection();
+ next.setHandler(h_selected);
+ h_selected.setSupportedOnly(show_sup.getSelection());
+ setCustomPagesFilter();
+ }
+
+ private void setCustomPagesFilter() {
+ // Set up Manager's filters
+ if (h_selected.getProjectType() != null) {
+ MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, h_selected.getProjectType().getId());
+ } else {
+ MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, null);
+ }
+
+ IToolChain[] tcs = h_selected.getSelectedToolChains();
+ int n = (tcs == null) ? 0 : tcs.length;
+ Set x = new TreeSet();
+ for (int i=0; i<n; i++) {
+ x.add(tcs[i]);
+ }
+ MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.TOOLCHAIN, x);
+ }
+
+ public void toolChainListChanged(int count) {
+ if ( !h_selected.canCreateWithoutToolchain())
+ setPageComplete(validatePage());
+ }
+
+ public boolean isCurrent() { return isCurrentPage(); }
+}
+
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CNewWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CNewWizard.java
new file mode 100644
index 00000000000..9658a3883df
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CNewWizard.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import java.util.Iterator;
+import java.util.SortedMap;
+
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyManager;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ *
+ */
+public class CNewWizard extends AbstractCWizard {
+ /**
+ * Creates and returns an array of
+ */
+ public void createItems(Tree tree, boolean supportedOnly) {
+ IBuildPropertyManager bpm = ManagedBuildManager.getBuildPropertyManager();
+ IBuildPropertyType bpt = bpm.getPropertyType(ICWizardHandler.ARTIFACT);
+ IBuildPropertyValue[] vs = bpt.getSupportedValues();
+
+ // new style project types
+ for (int i=0; i<vs.length; i++) {
+ IToolChain[] tcs = ManagedBuildManager.getExtensionsToolChains(ICWizardHandler.ARTIFACT, vs[i].getId());
+ if (tcs == null || tcs.length == 0) continue;
+ CWizardHandler h = new CWizardHandler(vs[i], IMG1, parent, listener);
+ for (int j=0; j<tcs.length; j++) {
+ if (!supportedOnly || isValid(tcs[j])) h.addTc(tcs[j]);
+ }
+ if (h.getToolChainsCount() > 0) {
+ TreeItem ti = new TreeItem(tree, SWT.NONE);
+ ti.setText(h.getName());
+ ti.setData(h);
+ ti.setImage(h.getIcon());
+ }
+ }
+
+ // old style project types
+ TreeItem oldsRoot = null;
+ SortedMap sm = ManagedBuildManager.getExtensionProjectTypeMap();
+ Iterator it = sm.keySet().iterator();
+ while(it.hasNext()) {
+ String s = (String)it.next();
+ IProjectType pt = (IProjectType)sm.get(s);
+ if (pt.isAbstract() || pt.isTestProjectType()) continue;
+ if (supportedOnly && !pt.isSupported()) continue; // not supported
+ String nattr = pt.getNameAttribute();
+ if (nattr == null || nattr.length() == 0) continue; // new proj style
+ CWizardHandler h = new CWizardHandler(pt.getName(), pt, IMG2, parent, listener);
+ IConfiguration[] cfgs = pt.getConfigurations();
+ if (cfgs == null || cfgs.length == 0) continue;
+ IToolChain tc = null;
+ for (int i=0; i<cfgs.length; i++) {
+ if (cfgs[i].isSystemObject()) continue;
+ IToolChain t = cfgs[i].getToolChain();
+ if (!supportedOnly || isValid(t)) {
+ tc = t;
+ break;
+ }
+ }
+ if (tc == null) continue;
+ h.addTc(tc);
+
+ if (oldsRoot == null) {
+ oldsRoot = new TreeItem(tree, SWT.NONE);
+ oldsRoot.setText(IDEWorkbenchMessages.getString("CNewWizard.0")); //$NON-NLS-1$
+ oldsRoot.setData(new DummyHandler(parent));
+ oldsRoot.setImage(IMG0);
+ }
+ TreeItem ti = new TreeItem(oldsRoot, SWT.NONE);
+ ti.setText(h.getName());
+ ti.setData(h);
+ ti.setImage(h.getIcon());
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
deleted file mode 100644
index dfe518d0650..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
+++ /dev/null
@@ -1,598 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
-import org.eclipse.cdt.utils.Platform;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-//import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-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.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Class that implements the project type and configuration selection page in the new
- * project wizard for managed builder projects.
- *
- * @since 1.2
- */
-public class CProjectPlatformPage extends WizardPage {
- /*
- * Dialog variables and string constants
- */
- private static final String PREFIX = "PlatformBlock"; //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
- private static final String CONFIG_LABEL = LABEL + ".configs"; //$NON-NLS-1$
- private static final String SELECT_ALL_LABEL = LABEL + ".selectAll"; //$NON-NLS-1$
- private static final String DESELECT_ALL_LABEL = LABEL + ".deselectAll"; //$NON-NLS-1$
- private static final String SHOWALL_LABEL = LABEL + ".showall"; //$NON-NLS-1$
- private static final String SHOWALL_CONFIG_LABEL = LABEL + ".showall.config"; //$NON-NLS-1$
- private static final String TARGET_LABEL = LABEL + ".platform"; //$NON-NLS-1$
- private static final String TARGET_TIP = TIP + ".platform"; //$NON-NLS-1$
- private static final String FORCEDCONFIG_TIP = TIP + ".forcedconfigs"; //$NON-NLS-1$
-
- // support for exporting data to custom wizard pages
- public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.platformPage"; //$NON-NLS-1$
- public static final String PROJECT_TYPE = "projectType"; //$NON-NLS-1$
- public static final String TOOLCHAIN = "toolchain"; //$NON-NLS-1$
- public static final String NATURE = "nature"; //$NON-NLS-1$
-
- protected NewManagedProjectWizard parentWizard;
- protected Combo platformSelection;
- private ArrayList selectedConfigurations;
- private IProjectType defaultProjectType;
- protected IProjectType selectedProjectType;
- protected Button showAllProjTypes;
- protected Button showAllConfigs;
- protected boolean showAllConfigsForced;
- protected CheckboxTableViewer tableViewer;
- protected String[] projectTypeNames;
- protected ArrayList projectTypes;
- protected IConfiguration configurations[];
- protected boolean pageHasBeenVisible;
-
- /**
- * Constructor.
- * @param pageName
- * @param wizard
- */
- public CProjectPlatformPage(String pageName, NewManagedProjectWizard parentWizard) {
- super(pageName);
- setPageComplete(false);
- selectedProjectType = null;
- selectedConfigurations = new ArrayList(0);
- this.parentWizard = parentWizard;
- showAllConfigsForced = false;
- }
-
- /**
- * @see org.eclipse.jface.wizard.IWizardPage#canFlipToNextPage()
- */
- public boolean canFlipToNextPage() {
- return validatePage();
- }
-
- private void createConfigSelectionGroup (Composite parent) {
- // Create the group composite
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
-
- // Create a check box table of valid configurations
- final Label configLabel = new Label(composite, SWT.LEFT);
- configLabel.setFont(composite.getFont());
- configLabel.setText(ManagedBuilderUIMessages.getResourceString(CONFIG_LABEL));
-
- // Create the Table/Select group
- Composite composite1 = new Composite(parent, SWT.NULL);
- composite1.setFont(parent.getFont());
- composite1.setLayout(new GridLayout(2, false));
- composite1.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Table table = new Table(composite1, SWT.CHECK | SWT.BORDER | SWT.MULTI
- | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
- table.setHeaderVisible(true);
- table.setLinesVisible(false);
-
- // Add a table layout to the table
- TableLayout tableLayout = new TableLayout();
- table.setHeaderVisible(false);
- table.setLayout(tableLayout);
-
- // Add the viewer
- tableViewer = new CheckboxTableViewer(table);
- tableViewer.setLabelProvider(new ConfigurationLabelProvider());
- tableViewer.setContentProvider(new ConfigurationContentProvider());
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent e) {
- // will default to false until a selection is made
- handleConfigurationSelectionChange();
- }
- });
-
- // Create the select/deselect all group composite
- Composite composite2 = new Composite(composite1, SWT.NULL);
- composite2.setFont(parent.getFont());
- composite2.setLayout(new GridLayout());
- composite2.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, true));
-
- Button selectAll = new Button(composite2, SWT.NONE);
- selectAll.setLayoutData(new GridData(GridData.FILL_BOTH));
- selectAll.setText(ManagedBuilderUIMessages.getResourceString(SELECT_ALL_LABEL));
- selectAll.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- tableViewer.setAllChecked(true);
- }
- public void widgetSelected(SelectionEvent e) {
- tableViewer.setAllChecked(true);
- }
- });
-
- Button deselectAll = new Button(composite2, SWT.NONE);
- deselectAll.setLayoutData(new GridData(GridData.FILL_BOTH));
- deselectAll.setText(ManagedBuilderUIMessages.getResourceString(DESELECT_ALL_LABEL));
- deselectAll.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- tableViewer.setAllChecked(false);
- }
- public void widgetSelected(SelectionEvent e) {
- tableViewer.setAllChecked(false);
- }
- });
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- // Create the composite control for the tab
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Setup the help information
- WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_PLATFORM_HELP);
-
- // Create the widgets
- createTypeSelectGroup(composite);
- createConfigSelectionGroup(composite);
- createShowAllGroup(composite);
-
- // Select the first project type in the list
- populateTypes();
- IProjectType type = (defaultProjectType != null)
- ? defaultProjectType
- : (IProjectType) projectTypes.get(0);
- setProjectType(type);
-
- // Do the nasty
- setErrorMessage(null);
- setMessage(null);
- setControl(composite);
- }
-
- private void createShowAllGroup(Composite parent) {
- // Create the group composite
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- showAllProjTypes = new Button(composite, SWT.CHECK | SWT.LEFT);
- showAllProjTypes.setFont(composite.getFont());
- showAllProjTypes.setText(ManagedBuilderUIMessages.getResourceString(SHOWALL_LABEL));
- showAllProjTypes.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- populateTypes();
- IProjectType type = projectTypes.contains(selectedProjectType)
- ? selectedProjectType
- : (IProjectType) projectTypes.get(0);
- setSelectedProjectType(type);
- }
- });
- showAllProjTypes.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- showAllProjTypes = null;
- }
- });
-
- showAllConfigs = new Button(composite, SWT.CHECK | SWT.LEFT);
- showAllConfigs.setFont(composite.getFont());
- showAllConfigs.setText(ManagedBuilderUIMessages.getResourceString(SHOWALL_CONFIG_LABEL));
- showAllConfigs.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- populateConfigurations(true);
- }
- });
- showAllConfigs.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- showAllConfigs = null;
- }
- });
- }
-
- private void createTypeSelectGroup(Composite parent) {
- // Create the group composite
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Create the platform selection label and combo widgets
- final Label platformLabel = new Label(composite, SWT.LEFT);
- platformLabel.setFont(composite.getFont());
- platformLabel.setText(ManagedBuilderUIMessages.getResourceString(TARGET_LABEL));
-
- platformSelection = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
- platformSelection.setFont(composite.getFont());
- platformSelection.setToolTipText(ManagedBuilderUIMessages.getResourceString(TARGET_TIP));
- platformSelection.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- handleTypeSelection();
- }
- });
- platformSelection.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- platformSelection = null;
- }
- });
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- // Make this the same as NewCProjectWizardPage.SIZING_TEXT_FIELD_WIDTH
- gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50;
- platformSelection.setLayoutData(gd);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
- */
- public IProject getProject() {
- return ((NewCProjectWizard)getWizard()).getNewProject();
- }
-
- /**
- * @return
- */
- public IConfiguration[] getSelectedConfigurations() {
- return (IConfiguration[]) selectedConfigurations.toArray(new IConfiguration[selectedConfigurations.size()]);
- }
-
- /**
- * Returns the selected project type.
- *
- * @return IProjectType Selected type or <code>null</code> if an invalid selection
- * has been made.
- */
- public IProjectType getSelectedProjectType() {
- return selectedProjectType;
- }
-
- /**
- * Sets the selected project type.
- * <p>If createControl(...) has been called, the selection will be set
- * immediately. Otherwise the selection will be set during the
- * createControl(...) invocation.
- * </p>
- * @param type a IProjectType instance, or <tt>null</tt> to select the
- * the first available project type
- * @see #createControl(Composite)
- */
- public void setSelectedProjectType(IProjectType type) {
- if (projectTypeNames != null && platformSelection != null) {
- // set project type now
- setProjectType(type);
- } else {
- // set project during createControl(Control)
- defaultProjectType = type;
- }
- }
-
- private void setProjectType(IProjectType type) {
- String name = (type != null) ? type.getName() : projectTypeNames[0];
- boolean found = false;
- for (int i = 0; !found && i < projectTypeNames.length; i++) {
- if (name.equals(projectTypeNames[i])) {
- platformSelection.select(i);
- handleTypeSelection();
- found = true;
- }
- }
- if (!found) {
- log("Could not find project-type with name: " + name); //$NON-NLS-1$
- }
- }
-
- private void handleConfigurationSelectionChange() {
- // Get the selections from the table viewer
- selectedConfigurations.clear();
- selectedConfigurations.addAll(Arrays.asList(tableViewer.getCheckedElements()));
-
- // support for publishing the toolchains for the selected configs so that custom wizard
- // pages will know which toolchains have been selected
-
- // get the toolchains from the selected configs and put them into a set
- Set toolchainSet = new LinkedHashSet();
- for(int k = 0; k < selectedConfigurations.size(); k++)
- {
- IConfiguration config = (IConfiguration) selectedConfigurations.get(k);
- IToolChain toolchain = config.getToolChain();
- toolchainSet.add(toolchain);
- }
-
- // publish the set of selected toolchains with the custom page manager
- MBSCustomPageManager.addPageProperty(PAGE_ID, TOOLCHAIN, toolchainSet);
-
- setPageComplete(validatePage());
- }
-
- /**
- * Returns whether this page's controls currently all contain valid
- * values.
- *
- * @return <code>true</code> if all controls are valid, and
- * <code>false</code> if at least one is invalid
- */
- protected void handleTypeSelection() {
- /*
- * The index in the combo is the offset into the project type list
- */
- int index;
- if (platformSelection != null
- && (index = platformSelection.getSelectionIndex()) != -1) {
- if (selectedProjectType != (IProjectType) projectTypes.get(index)) {
- selectedProjectType = (IProjectType) projectTypes.get(index);
- parentWizard.updateProjectTypeProperties();
-
- // publish which project type has been chosen with the custom wizard page manager
- MBSCustomPageManager.addPageProperty(PAGE_ID, PROJECT_TYPE, selectedProjectType.getId());
- }
- }
- populateConfigurations(false);
- setPageComplete(validatePage());
- }
-
- /**
- * Populate the table viewer with either all known configurations
- * or only with the supported configurations depending on whether a user
- * has chosen to display unsupported configurations or not
- * By default, only supported configurations are selected.
- */
- private void populateConfigurations(boolean showallconfigsevent) {
- if (selectedProjectType == null)
- return;
- boolean showAll = showAllConfigs != null ? showAllConfigs.getSelection() : false;
- IConfiguration selected[] = null;
-
- if (showAll) {
- configurations = selectedProjectType.getConfigurations();
- selected = filterSupportedConfigurations(configurations);
- }
- else {
- configurations = filterSupportedConfigurations(selectedProjectType.getConfigurations());
- selected = configurations;
- }
-
- // Check for buildable configs on this platform
- if (selected.length == 0) {
- // No buildable configs on this platform
- if (showallconfigsevent) {
- // "Show All Configurations" button pressed by user
- if (showAll) {
- // "Show All Configurations" check box "checked" by user
- // For a project with no buildable configs, all available
- // configs should be displayed and checked
- configurations = selectedProjectType.getConfigurations();
- selected = configurations;
- }
- if (showAllConfigsForced) {
- // The previous setting of this check box was done automatically when a project type
- // with no buildable configs was encountered; undo this state now and honor the
- // user's button click
- setMessage(null, NONE);
- showAllConfigsForced = false;
- }
- }
- else {
- configurations = selectedProjectType.getConfigurations();
- selected = configurations;
- if (!showAll) {
- showAllConfigsForced = true;
- showAllConfigs.setSelection(true);
- }
- }
- // Indicate that there are no buildable configurations on this platform for this project
- // type and that all configurations will be selected
- setMessage(ManagedBuilderUIMessages.getResourceString(FORCEDCONFIG_TIP), WARNING);
- }
- else {
- setMessage(null, NONE);
- if (showAllConfigsForced) {
- showAllConfigsForced = false;
- showAllConfigs.setSelection(false);
- // Redo filtering in light of reset of "show all configs" to false
- configurations = filterSupportedConfigurations(selectedProjectType.getConfigurations());
- selected = configurations;
- }
- }
-
- if (configurations.length > 10) {
- Table table = tableViewer.getTable();
- int heightHint = table.getItemHeight() * 10 + table.getGridLineWidth() * 2;
- ((GridData)table.getLayoutData()).heightHint = heightHint;
- }
- tableViewer.setInput(configurations);
- tableViewer.setCheckedElements(selected);
- handleConfigurationSelectionChange();
- }
-
- /**
- * Returns the array of supported configurations found in the configurations
- * passed to this method
- */
- IConfiguration[] filterSupportedConfigurations(IConfiguration cfgs[]){
- ArrayList supported = new ArrayList();
- String os = Platform.getOS();
- String arch = Platform.getOSArch();
-
- for (int i = 0; i < cfgs.length; i++) {
- // First, filter on supported state
- if (cfgs[i].isSupported()) {
-
- IToolChain tc = cfgs[i].getToolChain();
- // Determine if the tool-chain has 'convertToId' attribute, If so
- // do not add this configuration to the list.
- if (!tc.getConvertToId().equals(""))
- continue;
-
- // Now, apply the OS and ARCH filters to determine if the configuration should be shown
- // Determine if the configuration's tool-chain supports this OS & Architecture.
- List osList = Arrays.asList(tc.getOSList());
- if (osList.contains("all") || osList.contains(os)) { //$NON-NLS-1$
- List archList = Arrays.asList(tc.getArchList());
- if (archList.contains("all") || archList.contains(arch)) { //$NON-NLS-1$
- supported.add(cfgs[i]);
- }
- }
- }
- }
- return (IConfiguration[])supported.toArray(new IConfiguration[supported.size()]);
- }
-
- /* (non-Javadoc)
- * Extracts the names from the project types that are valid for the wizard
- * session and populates the combo widget with them.
- */
- private void populateTypeNames() {
- projectTypeNames = new String[projectTypes.size()];
- ListIterator iter = projectTypes.listIterator();
- int index = 0;
- while (iter.hasNext()) {
- projectTypeNames[index++] = ((IProjectType) iter.next()).getName();
- }
-
- // Now setup the combo
- platformSelection.removeAll();
- platformSelection.setItems(projectTypeNames);
- }
-
- /* (non-Javadoc)
- * Collects all the valid project types for the platform Eclipse is running on
- */
- private void populateTypes() {
- // Get a list of platforms defined by plugins
- IProjectType[] allProjectTypes = ManagedBuildManager.getDefinedProjectTypes();
- projectTypes = new ArrayList();
- String os = Platform.getOS();
- String arch = Platform.getOSArch();
- // Add all of the concrete project types to the list
- for (int index = 0; index < allProjectTypes.length; ++index) {
- IProjectType type = allProjectTypes[index];
- if (!type.isAbstract() && !type.isTestProjectType()) {
-
- // As we do not want to display the unsupported project types
- // that has 'convertToId' attribute, check if project type has
- // 'convertToId' attribute. If so, then do not add it to the list.
- if (!type.getConvertToId().equals(""))
- continue;
-
- // If the check box is selected show all the targets
- if (showAllProjTypes != null && showAllProjTypes.getSelection() == true) {
- projectTypes.add(type);
- } else if (type.isSupported()) {
- // Apply the OS and ARCH filters to determine if the target should be shown
- // Determine if the project type has any configuration with a tool-chain
- // that supports this OS & Architecture.
- IConfiguration[] configs = type.getConfigurations();
- for (int j = 0; j < configs.length; ++j) {
- IToolChain tc = configs[j].getToolChain();
- List osList = Arrays.asList(tc.getOSList());
- if (osList.contains("all") || osList.contains(os)) { //$NON-NLS-1$
- List archList = Arrays.asList(tc.getArchList());
- if (archList.contains("all") || archList.contains(arch)) { //$NON-NLS-1$
- projectTypes.add(type);
- break;
- }
- }
- }
- }
- }
- }
- projectTypes.trimToSize();
- populateTypeNames();
- }
-
- /**
- * @return
- */
- private boolean validatePage() {
- if(!pageHasBeenVisible)
- return false;
-
- // TODO some validation ... maybe
- if ((tableViewer.getCheckedElements()).length > 0) {
- setErrorMessage(null);
- return true;
- } else {
- setErrorMessage(ManagedBuilderUIMessages.getResourceString("PlatformBlock.message.error.noconfigs")); //$NON-NLS-1$
- return false;
- }
- }
-
- private void log(String msg) {
- String id = ManagedBuilderUIPlugin.getUniqueIdentifier();
- IStatus status = new Status(IStatus.WARNING, id, 0, msg, null);
- ManagedBuilderUIPlugin.log(status);
- }
-
- public void setVisible(boolean visible) {
- pageHasBeenVisible = true;
- setPageComplete(validatePage());
- super.setVisible(visible);
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectWizard.java
new file mode 100644
index 00000000000..2f666a2bf68
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectWizard.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+public class CProjectWizard extends NewModelProjectWizard {
+
+ public CProjectWizard() {
+ super(IDEWorkbenchMessages.getString("NewModelProjectWizard.4"), //$NON-NLS-1$
+ IDEWorkbenchMessages.getString("NewModelProjectWizard.5")); //$NON-NLS-1$
+ }
+
+ protected String[] getNatures() {
+ return new String[] { CProjectNature.C_NATURE_ID };
+ }
+
+ protected IProject continueCreation(IProject prj) {
+ try {
+ CProjectNature.addCNature(prj, new NullProgressMonitor());
+ } catch (CoreException e) {}
+ return prj;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CWizardHandler.java
new file mode 100644
index 00000000000..941cc01635a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CWizardHandler.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import java.util.Iterator;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * This object is created per each Project type
+ *
+ * It is responsible for:
+ * - corresponding line in left pane of 1st wizard page
+ * - whole view of right pane, including
+ *
+ */
+public class CWizardHandler implements ICWizardHandler {
+ static final private String head = IDEWorkbenchMessages.getString("CWizardHandler.0"); //$NON-NLS-1$
+ static final private String tooltip =
+ IDEWorkbenchMessages.getString("CWizardHandler.1")+ //$NON-NLS-1$
+ IDEWorkbenchMessages.getString("CWizardHandler.2") + //$NON-NLS-1$
+ IDEWorkbenchMessages.getString("CWizardHandler.3") + //$NON-NLS-1$
+ IDEWorkbenchMessages.getString("CWizardHandler.4") + //$NON-NLS-1$
+ IDEWorkbenchMessages.getString("CWizardHandler.5"); //$NON-NLS-1$
+
+ protected SortedMap tcs;
+ private String name;
+ private Image image;
+ private Composite parent;
+ private Table table;
+ private String propertyId = null;
+ private IProjectType pt = null;
+ private boolean showProps = false;
+ private IToolChainListListener listener;
+ private boolean supportedOnly = true;
+
+ public CWizardHandler(String _name, IProjectType _pt, Image _image, Composite p, IToolChainListListener _listener) {
+ tcs = new TreeMap();
+ name = _name;
+ image = _image;
+ parent = p;
+ pt = _pt;
+ listener = _listener;
+ }
+
+ public CWizardHandler(IBuildPropertyValue val, Image _image, Composite p, IToolChainListListener _listener) {
+ tcs = new TreeMap();
+ name = val.getName();
+ propertyId = val.getId();
+ image = _image;
+ parent = p;
+ listener = _listener;
+ }
+
+ public void handleSelection() {
+ if (table == null) {
+ table = new Table(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
+ table.setToolTipText(tooltip);
+ Iterator it = tcs.keySet().iterator();
+ while (it.hasNext()) {
+ TableItem ti = new TableItem(table, SWT.NONE);
+ String s = (String)it.next();
+ Object obj = tcs.get(s);
+ if (obj instanceof IToolChain) {
+ IToolChain tc = (IToolChain)obj;
+ //TODO: add version
+ ti.setText(tc.getUniqueRealName());
+ ti.setData(tc);
+ } else {
+ ti.setText(s);
+ }
+ }
+ if (tcs.size() > 0) table.select(0);
+
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (listener != null)
+ listener.toolChainListChanged(table.getSelectionCount());
+ }});
+ }
+ table.setVisible(true);
+ parent.layout();
+ }
+
+ public void handleUnSelection() {
+ if (table != null) {
+ table.setVisible(false);
+ }
+ }
+
+ protected void addTc(IToolChain tc) {
+ if (tc.isAbstract() || tc.isSystemObject()) return;
+ IConfiguration[] cfgs = null;
+ // New style managed project type. Configurations are referenced via propertyId.
+ if (propertyId != null) {
+ cfgs = ManagedBuildManager.getExtensionConfigurations(tc, ARTIFACT, propertyId);
+ // Old style managewd project type. Configs are obtained via projectType
+ } else if (pt != null) {
+ cfgs = ManagedBuildManager.getExtensionConfigurations(tc, pt);
+ }
+ if (cfgs == null || cfgs.length == 0) return;
+ tcs.put(tc.getUniqueRealName(), tc);
+ }
+
+ public IToolChain[] getSelectedToolChains() {
+ if (tcs.size() == 0)
+ return null;
+ else {
+ TableItem[] sel = table.getSelection();
+ IToolChain[] out = new IToolChain[sel.length];
+ for (int i=0; i< sel.length; i++)
+ out[i] = (IToolChain)sel[i].getData();
+ return out;
+ }
+ }
+
+ public void createProject(IProject project, IConfiguration[] cfgs, String[] names) throws CoreException {
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescription des = coreModel.getProjectDescription(project);
+ des = coreModel.createProjectDescription(project, true);
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+
+ if (cfgs == null || cfgs.length == 0)
+ cfgs = CConfigWizardPage.getDefaultCfgs(this);
+
+ ManagedProject mProj = new ManagedProject(project, cfgs[0].getProjectType());
+ info.setManagedProject(mProj);
+
+ for(int i = 0; i < cfgs.length; i++){
+ String id = ManagedBuildManager.calculateChildId(cfgs[i].getId(), null);
+ Configuration config = new Configuration(mProj, (Configuration)cfgs[i], id, false, true);
+ CConfigurationData data = config.getConfigurationData();
+ ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ config.setConfigurationDescription(cfgDes);
+ config.exportArtifactInfo();
+
+ IBuilder bld = config.getEditableBuilder();
+ if (bld != null) { bld.setManagedBuildOn(true); }
+
+ String s = project.getName();
+ config.setName(names[i]);
+ config.setArtifactName(s);
+ }
+ coreModel.setProjectDescription(project, des);
+ }
+
+// interface methods
+
+ public String getHeader() { return head; }
+ public String getName() { return name; }
+ public Image getIcon() { return image; }
+ public boolean isDummy() { return false; }
+ public boolean needsConfig() { return true; }
+ public int getToolChainsCount() { return tcs.size(); }
+
+ public void setShowProperties(boolean show) { showProps = show; }
+ public boolean showProperties() { return showProps; }
+ public IProjectType getProjectType() { return pt; }
+ public String getPropertyId() { return propertyId; }
+ public boolean canCreateWithoutToolchain() { return false; }
+
+ public void setSupportedOnly(boolean supp) { supportedOnly = supp;}
+ public boolean supportedOnly() { return supportedOnly; }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
deleted file mode 100644
index 64975e1e73f..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public class ConfigurationContentProvider implements IStructuredContentProvider {
- // The contents of the parent of the table is a list of configurations
- public Object[] getElements(Object parent) {
- // The content is an array of configurations
- Object array[] = (Object[])parent;
- return (array == null || array.length == 0) ? new Object[0] : array;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(
- Viewer viewer,
- Object oldInput,
- Object newInput) {
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationLabelProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationLabelProvider.java
deleted file mode 100644
index 8e9b59c1aeb..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationLabelProvider.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 Rational Software 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class ConfigurationLabelProvider extends LabelProvider implements ITableLabelProvider {
- private final Image IMG_CFG =
- ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_CONFIG);
-
- //
- public String getColumnText(Object obj, int index) {
- if (obj instanceof IConfiguration) {
- IConfiguration tmpConfig = (IConfiguration) obj;
-
- if( (tmpConfig.getDescription() == null)|| (tmpConfig.getDescription().equals("")) ) //$NON-NLS-1$
- return ((IConfiguration) obj).getName();
- else
- return ( tmpConfig.getName() + " ( " + tmpConfig.getDescription() + " )"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return new String();
- }
-
- public Image getColumnImage(Object obj, int index) {
- return IMG_CFG;
- }
-}
-
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/DummyHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/DummyHandler.java
new file mode 100644
index 00000000000..0ed8ad694f0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/DummyHandler.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This object is created per each Project type
+ *
+ * It is responsible for:
+ * - corresponding line in left pane of 1st wizard page
+ * - whole view of right pane, including
+ *
+ */
+public class DummyHandler implements ICWizardHandler {
+ private static final String DUMMY = ""; //$NON-NLS-1$
+ Composite parent;
+
+ public DummyHandler(Composite p) {
+ parent = p;
+ }
+
+// interface methods
+ public String getHeader() { return DUMMY; }
+ public String getName() { return DUMMY; }
+ public Image getIcon() { return null; }
+ public void handleSelection() {}
+ public void handleUnSelection() {}
+ public IWizardPage getNextPage() { return null; }
+ public void createProject(IProject project, IConfiguration[] cfgs, String[] names) throws CoreException {}
+ public boolean isDummy() { return true; }
+ public boolean needsConfig() { return false; }
+ public IToolChain[] getSelectedToolChains() {return null;}
+ public int getToolChainsCount() { return 0; }
+ public void setShowProperties(boolean show) {}
+ public boolean showProperties() { return false; }
+ public IProjectType getProjectType() { return null; }
+ public String getPropertyId() { return null; }
+ public boolean canCreateWithoutToolchain() { return false; }
+ public void setSupportedOnly(boolean supp) {}
+ public boolean supportedOnly() { return true; }
+ public boolean isFirstPageSelected() { return false; }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICNewWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICNewWizard.java
new file mode 100644
index 00000000000..bd8bf0ac5f0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICNewWizard.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+
+/**
+ * Interface to be used by extension point:
+ * org.eclipse.cdt.managedbuilder.ui.CDTWizard
+ *
+ * Implementors should provide 1 or more
+ * items in "Project types" list (left pane on
+ * the 1st page in any CDT new project wizard)
+ */
+public interface ICNewWizard {
+ /**
+ * Creates tree items to be displayed in left pane.
+ *
+ * Method should add 1 or more tree items,
+ * each of them should have data object attached,
+ * data should be lt;ICProjectTypeHandler&gt;
+ *
+ * @param tree - parent tree object
+ * @param supportedOnly - whether display supported types only
+ */
+ void createItems(Tree tree, boolean supportedOnly);
+
+ /**
+ * Implementor will be informed about widget where additional
+ * data should be displayed. Normally, it is right pane in the
+ * 1st Wizard page.
+ *
+ * @param parent - composite where widgets are to be created
+ * @param page - reference to object which will be informed
+ * about changes (usually 1st page in Wizard)
+ * May be null if notification is not required
+ * or implementor does not really support it.
+ */
+ void setDependentControl(Composite parent, IToolChainListListener page);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICWizardHandler.java
new file mode 100644
index 00000000000..1bc0339054a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ICWizardHandler.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.graphics.Image;
+
+
+public interface ICWizardHandler {
+ static final String ARTIFACT = "org.eclipse.cdt.build.core.buildArtefactType"; //$NON-NLS-1$
+
+ void handleSelection();
+ void handleUnSelection();
+ String getName();
+ Image getIcon();
+ String getHeader();
+ void createProject(IProject proj, IConfiguration[] cfgs, String[] names) throws CoreException;
+ boolean isDummy();
+ boolean needsConfig();
+
+ public IToolChain[] getSelectedToolChains();
+ public int getToolChainsCount();
+ public IProjectType getProjectType();
+ public void setShowProperties(boolean show);
+ public boolean showProperties();
+ public String getPropertyId();
+ public boolean supportedOnly();
+ public void setSupportedOnly(boolean supp);
+ /**
+ * @return true if project can be created with zero toolchains selected
+ */
+ public boolean canCreateWithoutToolchain();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IDEWorkbenchMessages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IDEWorkbenchMessages.java
new file mode 100644
index 00000000000..0583bd327d8
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IDEWorkbenchMessages.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class IDEWorkbenchMessages {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.ui.wizards.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private IDEWorkbenchMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IToolChainListListener.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IToolChainListListener.java
new file mode 100644
index 00000000000..fda49045661
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/IToolChainListListener.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+/**
+ * Interface should be implemented by some visible object
+ * (usually - 1st page in CDT New Project wizard)
+ * to be informed about changes in tool chains selection
+ * performed by ICNewWizard implementors.
+ */
+public interface IToolChainListListener {
+ /**
+ * Called by ICNewWizard instance when
+ * user has changed tool chains selection
+ *
+ * @param count - number of selected toolchains.
+ */
+ void toolChainListChanged(int count);
+
+ /**
+ * @return true if this page is visible
+ */
+ boolean isCurrent();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java
index 365c2f745c6..c1014eb8f16 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java
@@ -136,19 +136,32 @@ public final class MBSCustomPageData
* org.eclipse.cdt.core.cnature and org.eclipse.cdt.core.ccnature
* @return true if the page should be visible when the project has the given nature, false otherwise.
* @since 3.0
+ *
+ * Nature can be either string (old mode) or Set (new mode) or null.
+ * New mode allows to take into account several natures per project.
+ * Accepting null allows to process projects w/o nature
+ * @since 4.0
*/
- public boolean shouldBeVisibleForNature(String nature)
+ public boolean shouldBeVisibleForNature(Object nature)
{
- if (natureSet == null)
- return true;
-
- return hasNature(nature);
+ if (natureSet == null) return true;
+ if (nature == null) return false;
+
+ if (nature instanceof String) // old style
+ return hasNature((String)nature);
+ else if (nature instanceof Set) {
+ Iterator it = ((Set)nature).iterator();
+ while (it.hasNext()) {
+ String s = it.next().toString();
+ if (hasNature(s)) return true;
+ }
+ }
+ return false; // no one nature fits or bad data
}
private boolean hasNature(String nature)
{
return natureSet.contains(nature);
-
}
/**
@@ -309,16 +322,28 @@ public final class MBSCustomPageData
* @param projectType The unique ID of the project type to check.
* @return true if this page should be visible if the given project type is selected, false otherwise.
* @since 3.0
+ *
+ * Type can be either string (old mode) or Set (new mode) or null.
+ * New mode allows to take into account several types per project,
+ * or types absence in some cases
+ * @since 4.0
*/
- public boolean shouldBeVisibleForProjectType(String projectType)
+ public boolean shouldBeVisibleForProjectType(Object projectType)
{
- if (projectTypeSet == null)
- return true;
-
- if (projectTypeSet.contains(projectType))
- return true;
-
- return false;
+ if (projectTypeSet == null) return true;
+ if (projectType == null) return false;
+
+ if (projectType instanceof String)
+ return projectTypeSet.contains(projectType);
+ else if (projectType instanceof Set) {
+ Iterator it = ((Set)projectType).iterator();
+ while (it.hasNext()) {
+ String s = it.next().toString();
+ if (projectTypeSet.contains(s))
+ return true;
+ }
+ }
+ return false; // no one type fits
}
/**
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java
index 6fc624c0f93..abe56b89f3a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Texas Instruments Incorporated and others.
+ * Copyright (c) 2005, 2007 Texas Instruments Incorporated 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
@@ -7,25 +7,29 @@
*
* Contributors:
* Texas Instruments - initial API and implementation
+ * Intel Corporation - adaptation to new project model
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.wizards;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import java.util.TreeMap;
+
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.wizard.IWizardPage;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Set;
-import java.util.LinkedHashSet;
-import java.util.Iterator;
-import java.util.Stack;
-import org.eclipse.core.runtime.CoreException;
/**
* This class is responsible for managing the use of custom pages in the Managed Build System's
@@ -35,6 +39,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public final class MBSCustomPageManager
{
+ public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.platformPage"; //$NON-NLS-1$
/**
* ID attribute of nature element
@@ -109,6 +114,8 @@ public final class MBSCustomPageManager
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.managedbuilder.ui.newWizardPages"; //$NON-NLS-1$
+
+ private static List hiddenList;
/**
*
* Looks for contributions to the extension point org.eclipse.cdt.managedbuilder.ui.newWizardPages and adds all pages to the manager.
@@ -160,9 +167,9 @@ public final class MBSCustomPageManager
{
// there are currently no other supported element types
// so throw an exception
- throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error0") //$NON-NLS-1$
+ throw new BuildException(NewUIMessages.getResourceString("MBSCustomPageManager.error0") //$NON-NLS-1$
+ element.getName()
- + ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error1") //$NON-NLS-1$
+ + NewUIMessages.getResourceString("MBSCustomPageManager.error1") //$NON-NLS-1$
+ EXTENSION_POINT_ID);
}
}
@@ -179,7 +186,7 @@ public final class MBSCustomPageManager
// get the ID and wizard page
String id = element.getAttribute(ID);
- String operationClassName = element.getAttribute(OPERATION_CLASS); // optional element so may be null
+// String operationClassName = element.getAttribute(OPERATION_CLASS); // optional element so may be null
IWizardPage wizardPage = null;
Runnable operation = null;
@@ -237,9 +244,9 @@ public final class MBSCustomPageManager
// no other types supported... throw an exception
// there are currently no other supported element types
// so throw an exception
- throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error2") //$NON-NLS-1$
+ throw new BuildException(NewUIMessages.getResourceString("MBSCustomPageManager.error2") //$NON-NLS-1$
+ element.getName()
- + ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error3") //$NON-NLS-1$
+ + NewUIMessages.getResourceString("MBSCustomPageManager.error3") //$NON-NLS-1$
+ EXTENSION_POINT_ID);
}
}
@@ -255,7 +262,7 @@ public final class MBSCustomPageManager
if (projectType != null)
currentPageData.addProjectType(projectType);
else
- throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error4")); //$NON-NLS-1$
+ throw new BuildException(NewUIMessages.getResourceString("MBSCustomPageManager.error4")); //$NON-NLS-1$
}
private static void loadToolchain(IConfigurationElement element,
@@ -279,7 +286,7 @@ public final class MBSCustomPageManager
currentPageData.addToolchain(toolchainID, versionsSupported);
}
else
- throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error5")); //$NON-NLS-1$
+ throw new BuildException(NewUIMessages.getResourceString("MBSCustomPageManager.error5")); //$NON-NLS-1$
}
private static void loadNature(IConfigurationElement element,
@@ -290,7 +297,7 @@ public final class MBSCustomPageManager
if (nature != null)
currentPageData.addNature(nature);
else
- throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error6")); //$NON-NLS-1$
+ throw new BuildException(NewUIMessages.getResourceString("MBSCustomPageManager.error6")); //$NON-NLS-1$
}
/**
@@ -319,15 +326,14 @@ public final class MBSCustomPageManager
if(page == null)
return false;
+ if (getPageHideStatus(pageID)) return false;
// first, find out what project type, toolchain, and nature have been set
- Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(CProjectPlatformPage.PAGE_ID);
-
- String projectType = pagePropertiesMap.get(CProjectPlatformPage.PROJECT_TYPE).toString();
+ Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(PAGE_ID);
- Set toolchainSet = (Set) pagePropertiesMap.get(CProjectPlatformPage.TOOLCHAIN);
-
- String nature = pagePropertiesMap.get(CProjectPlatformPage.NATURE).toString();
+ Object projectType = pagePropertiesMap.get(PROJECT_TYPE);
+ Set toolchainSet = (Set) pagePropertiesMap.get(TOOLCHAIN);
+ Object nature = pagePropertiesMap.get(NATURE);
// does the page follow nature and project type constraints?
if (page.shouldBeVisibleForNature(nature)
@@ -352,20 +358,19 @@ public final class MBSCustomPageManager
while (toolchainIterator.hasNext())
{
IToolChain toolchain = (IToolChain) toolchainIterator.next();
- String id = ManagedBuildManager.getIdFromIdAndVersion(toolchain.getId());
- String version = ManagedBuildManager.getVersionFromIdAndVersion(toolchain.getId());
-
- // check the ID and version
- if (page.shouldBeVisibleForToolchain(id, version))
- {
- return true;
+ if(toolchain != null){
+ String id = ManagedBuildManager.getIdFromIdAndVersion(toolchain.getId());
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(toolchain.getId());
+
+ // check the ID and version
+ if (page.shouldBeVisibleForToolchain(id, version))
+ {
+ return true;
+ }
}
}
-
}
-
}
-
return false;
}
@@ -465,13 +470,13 @@ public final class MBSCustomPageManager
// look for the next page that satisfies all project type, toolchain, and nature criteria
// first, find out what project type, toolchain, and nature have been set
- Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(CProjectPlatformPage.PAGE_ID);
+// Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(PAGE_ID);
- String projectType = pagePropertiesMap.get(CProjectPlatformPage.PROJECT_TYPE).toString();
+// String projectType = pagePropertiesMap.get(PROJECT_TYPE).toString();
- Set toolchainSet = (Set) pagePropertiesMap.get(CProjectPlatformPage.TOOLCHAIN);
+// Set toolchainSet = (Set) pagePropertiesMap.get(TOOLCHAIN);
- String nature = pagePropertiesMap.get(CProjectPlatformPage.NATURE).toString();
+// String nature = pagePropertiesMap.get(NATURE).toString();
IWizardPage nextPage = null;
@@ -555,13 +560,13 @@ public final class MBSCustomPageManager
// look for the previous page that satisfies all project type, toolchain, and nature criteria
// first, find out what project type, toolchain, and nature have been set
- Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(CProjectPlatformPage.PAGE_ID);
+// Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(PAGE_ID);
- String projectType = pagePropertiesMap.get(CProjectPlatformPage.PROJECT_TYPE).toString();
+// String projectType = pagePropertiesMap.get(PROJECT_TYPE).toString();
- Set toolchainSet = (Set) pagePropertiesMap.get(CProjectPlatformPage.TOOLCHAIN);
+// Set toolchainSet = (Set) pagePropertiesMap.get(TOOLCHAIN);
- String nature = pagePropertiesMap.get(CProjectPlatformPage.NATURE).toString();
+// String nature = pagePropertiesMap.get(NATURE).toString();
IWizardPage prevPage = null;
@@ -714,6 +719,7 @@ public final class MBSCustomPageManager
idToPageDataMap = new TreeMap();
pageIDtoPagePropertiesMap = new TreeMap();
pageSet = new LinkedHashSet();
+ hiddenList = new ArrayList();
}
// singleton class - do not use
@@ -721,4 +727,23 @@ public final class MBSCustomPageManager
{
}
+
+ /**
+ * Ability to hide pages explicitly,
+ * not depending of nature/projecttype filter
+ *
+ * @param p - page to hide
+ * @param status - true means hidden
+ */
+ public static void setPageHideStatus(String Id, boolean status) {
+ if (hiddenList.contains(Id)) {
+ if (!status) hiddenList.remove(Id);
+ } else {
+ if (status) hiddenList.add(Id);
+ }
+ }
+
+ public static boolean getPageHideStatus(String Id) {
+ return hiddenList.contains(Id);
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/Messages.java
new file mode 100644
index 00000000000..eb6c28b1a68
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/Messages.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.ui.wizards.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java
deleted file mode 100644
index 2800d8e9ac4..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 Rational Software 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.wizard.IWizardPage;
-
-public class NewManagedCCProjectWizard extends NewManagedProjectWizard {
- private static final String WZ_TITLE = "MngCCWizard.title"; //$NON-NLS-1$
- private static final String WZ_DESC = "MngCCWizard.description"; //$NON-NLS-1$
- private static final String SETTINGS_TITLE = "MngCCWizardSettings.title"; //$NON-NLS-1$
- private static final String SETTINGS_DESC = "MngCCWizardSettings.description"; //$NON-NLS-1$
- private static final String MSG_CREATE = "MngCCWizard.message.creating"; //$NON-NLS-1$
-
- public NewManagedCCProjectWizard() {
- this(ManagedBuilderUIMessages.getResourceString(WZ_TITLE), ManagedBuilderUIMessages.getResourceString(WZ_DESC));
-
- }
-
- public NewManagedCCProjectWizard(String title, String desc) {
- super(title, desc);
-
- }
-
- public void addPages() {
- // Add the default page for all new managed projects
- super.addPages();
-
- // support for custom wizard pages
- // publish our nature with the page manager
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, CCProjectNature.CC_NATURE_ID);
-
- // load all pages specified via extensions
- try
- {
- MBSCustomPageManager.loadExtensions();
- }
- catch (BuildException e)
- {
- e.printStackTrace();
- }
-
- IWizardPage[] customPages = MBSCustomPageManager.getCustomPages();
-
- if (customPages != null)
- {
- for (int k = 0; k < customPages.length; k++)
- {
- addPage(customPages[k]);
- }
- }
- }
-
- protected void doRun(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(ManagedBuilderUIMessages.getResourceString(MSG_CREATE), 8); //$NON-NLS-1$
- super.doRun(new SubProgressMonitor(monitor, 7));
- // Add C++ Nature.
- if (newProject != null) {
- // Add C++ Nature to the newly created project.
- CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, new SubProgressMonitor(monitor, 1));
- }
- monitor.done();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java
deleted file mode 100644
index efd86210dc2..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 Rational Software 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
-
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.jface.wizard.IWizardPage;
-
-public class NewManagedCProjectWizard extends NewManagedProjectWizard {
- // String constants
- private static final String WZ_TITLE = "MngCWizard.title"; //$NON-NLS-1$
- private static final String WZ_DESC = "MngCWizard.description"; //$NON-NLS-1$
- private static final String SETTINGS_TITLE= "MngCWizardSettings.title"; //$NON-NLS-1$
- private static final String SETTINGS_DESC= "MngCWizardSettings.description"; //$NON-NLS-1$
-
- public NewManagedCProjectWizard() {
- this(ManagedBuilderUIMessages.getResourceString(WZ_TITLE), ManagedBuilderUIMessages.getResourceString(WZ_DESC));
- }
-
- public NewManagedCProjectWizard(String title, String description) {
- super(title, description);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#addPages()
- */
- public void addPages() {
- // Add the default page for all new managed projects
- super.addPages();
-
- // support for custom wizard pages
- // publish our nature with the page manager
- MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, CProjectNature.C_NATURE_ID);
-
- // load all pages specified via extensions
- try
- {
- MBSCustomPageManager.loadExtensions();
- }
- catch (BuildException e)
- {
- e.printStackTrace();
- }
-
-
- IWizardPage[] customPages = MBSCustomPageManager.getCustomPages();
-
- if (customPages != null)
- {
- for (int k = 0; k < customPages.length; k++)
- {
- addPage(customPages[k]);
- }
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
deleted file mode 100644
index f899ea2f52b..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.internal.ui.ErrorParserBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedProjectOptionBlock;
-import org.eclipse.cdt.ui.dialogs.ICOptionPage;
-import org.eclipse.cdt.ui.dialogs.IndexerBlock;
-import org.eclipse.cdt.ui.dialogs.ReferenceBlock;
-import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
-import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
-import org.eclipse.cdt.ui.wizards.NewCProjectWizardOptionPage;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.jface.wizard.IWizardPage;
-
-public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
-
- public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.projectOptionsPage"; //$NON-NLS-1$
-
- public class ManagedWizardOptionBlock extends ManagedProjectOptionBlock {
-
- NewManagedProjectOptionPage parent;
- ErrorParserBlock errorParsers;
- IndexerBlock indexBlock;
-
-
- public ManagedWizardOptionBlock(NewManagedProjectOptionPage parentPage) {
- super(parentPage);
- parent = parentPage;
- }
-
- public void updateProjectTypeProperties() {
- // Update the error parser list
- if (errorParsers != null) {
- errorParsers.updateValues();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
- */
- protected void addTabs() {
- addTab(new ReferenceBlock());
- // NOTE: The setting of error parsers is commented out here
- // because they need to be set per-configuration.
- // The other tabs on this page are per-project.
- // Error parsers can be selected per configuration in the
- // project properties
- //errorParsers = new ErrorParserBlock();
- //addTab(errorParsers);
- addTab(indexBlock = new IndexerBlock());
- }
-
- public void setupHelpContextIds(){
- List pages = getOptionPages();
-
- Iterator iter = pages.iterator();
- for( int i = 0; i < 3 && iter.hasNext(); i++ ) {
- ICOptionPage page = (ICOptionPage) iter.next();
-
- String id = null;
- if (page instanceof ReferenceBlock) {
- id = ManagedBuilderHelpContextIds.MAN_PROJ_WIZ_PROJECTS_TAB;
- } else if (page instanceof ErrorParserBlock) {
- id = ManagedBuilderHelpContextIds.MAN_PROJ_WIZ_ERRORPARSERS_TAB;
- } else if (page instanceof IndexerBlock) {
- id = ManagedBuilderHelpContextIds.MAN_PROJ_WIZ_INDEXER_TAB;
- }
- WorkbenchHelp.setHelp(page.getControl(), id);
-
- }
- }
- }
-
- protected ManagedWizardOptionBlock optionBlock;
- protected NewManagedProjectWizard parentWizard;
-
- /**
- * @param pageName
- */
- public NewManagedProjectOptionPage(String pageName, NewManagedProjectWizard parentWizard) {
- super(pageName);
- this.parentWizard = parentWizard;
- optionBlock = new ManagedWizardOptionBlock(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.NewCProjectWizardOptionPage#createOptionBlock()
- */
- protected TabFolderOptionBlock createOptionBlock() {
- return optionBlock;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
- */
- public IProject getProject() {
- return ((NewCProjectWizard)getWizard()).getNewProject();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferenceStore()
- */
- public Preferences getPreferences() {
- return ManagedBuilderUIPlugin.getDefault().getPluginPreferences();
- }
-
- public void updateProjectTypeProperties() {
- // Update the error parser list
- optionBlock.updateProjectTypeProperties();
- }
-
- public void setupHelpContextIds(){
- optionBlock.setupHelpContextIds();
- }
-
- public IWizardPage getNextPage()
- {
- return MBSCustomPageManager.getNextPage(PAGE_ID); // get first custom page, if any
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
deleted file mode 100644
index d920081f810..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
-import org.eclipse.cdt.ui.wizards.NewCProjectWizardPage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-
-public class NewManagedProjectWizard extends NewCProjectWizard {
-
- /* (non-Javadoc)
- * String constants
- */
- protected static final String PREFIX = "MngMakeProjectWizard"; //$NON-NLS-1$
- protected static final String OP_ERROR = PREFIX + ".op_error"; //$NON-NLS-1$
- protected static final String WZ_TITLE = PREFIX + ".title"; //$NON-NLS-1$
- protected static final String WZ_DESC = PREFIX + ".description"; //$NON-NLS-1$
- protected static final String CONF_TITLE = PREFIX + ".config.title"; //$NON-NLS-1$
- protected static final String CONF_DESC = PREFIX + ".config.desc"; //$NON-NLS-1$
- protected static final String OPTIONS_TITLE = PREFIX + ".options.title"; //$NON-NLS-1$
- protected static final String OPTIONS_DESC = PREFIX + ".options.desc"; //$NON-NLS-1$
- protected static final String MSG_ADD_NATURE = PREFIX + ".message.add_nature"; //$NON-NLS-1$
- protected static final String MSG_ADD_BUILDER = PREFIX + ".message.add_builder"; //$NON-NLS-1$
- protected static final String MSG_SAVE = PREFIX + ".message.save"; //$NON-NLS-1$
- protected static final String SETTINGS_TITLE = "MngMakeWizardSettings.title"; //$NON-NLS-1$
- protected static final String SETTINGS_DESC = "MngMakeWizardSettings.description"; //$NON-NLS-1$
-
- // Wizard pages
- protected CProjectPlatformPage projectConfigurationPage;
- protected NewManagedProjectOptionPage optionPage;
-
- public NewManagedProjectWizard() {
- this(ManagedBuilderUIMessages.getResourceString(WZ_TITLE), ManagedBuilderUIMessages.getResourceString(WZ_DESC));
-
- }
-
- public NewManagedProjectWizard(String title, String description) {
- super(title, description);
- }
-
- public void addPages() {
- // Add the default page for all new projects
- super.addPages();
-
- // Add the configuration selection page
- projectConfigurationPage = new CProjectPlatformPage(PREFIX, this);
- projectConfigurationPage.setTitle(ManagedBuilderUIMessages.getResourceString(CONF_TITLE));
- projectConfigurationPage.setDescription(ManagedBuilderUIMessages.getResourceString(CONF_DESC));
- addPage(projectConfigurationPage);
-
- // Add the options (tabbed) page
- optionPage = new NewManagedProjectOptionPage(PREFIX, this);
- optionPage.setTitle(ManagedBuilderUIMessages.getResourceString(OPTIONS_TITLE));
- optionPage.setDescription(ManagedBuilderUIMessages.getResourceString(OPTIONS_DESC));
- addPage(optionPage);
-
- // add custom pages
- MBSCustomPageManager.init();
-
- // add stock pages
- MBSCustomPageManager.addStockPage(fMainPage, NewCProjectWizardPage.PAGE_ID);
- MBSCustomPageManager.addStockPage(projectConfigurationPage, CProjectPlatformPage.PAGE_ID);
- MBSCustomPageManager.addStockPage(optionPage, NewManagedProjectOptionPage.PAGE_ID);
-
- }
-
- public void createPageControls(Composite pageContainer) {
- super.createPageControls( pageContainer );
-
- IWizardPage [] pages = getPages();
-
- if (pages != null) {
- for (int i = 0; i < pages.length; i++) {
- IWizardPage page = pages[i];
- if (page instanceof NewCProjectWizardPage) {
- WorkbenchHelp.setHelp(page.getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_WIZ_NAME_PAGE);
- }
- else if (page instanceof NewManagedProjectOptionPage) {
- NewManagedProjectOptionPage optionPage = (NewManagedProjectOptionPage) page;
- optionPage.setupHelpContextIds();
- }
- // The other built-in page is the CProjectPlatformPage which already has a help id.
- }
- }
- }
-
- public void updateProjectTypeProperties() {
- // Update the error parser list
- optionPage.updateProjectTypeProperties();
- }
-
- protected void addNature(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 2);
- monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_NATURE));
- ManagedCProjectNature.addManagedNature(newProject, new SubProgressMonitor(monitor, 1));
- monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_BUILDER));
- ManagedCProjectNature.addManagedBuilder(newProject, new SubProgressMonitor(monitor, 1));
- monitor.done();
- }
-
- protected void doRun(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- // super.doRun() just creates the project and does not assign a builder to it.
- super.doRun(new SubProgressMonitor(monitor, 5));
-
- // Add the managed build nature and builder
- try {
- addNature(new SubProgressMonitor(monitor, 2));
- } catch (CoreException e) {
- ManagedBuilderUIPlugin.log(e);
- }
-
- // Add the ManagedProject to the project
- IManagedProject newManagedProject = null;
- IManagedBuildInfo info = null;
- try {
- info = ManagedBuildManager.createBuildInfo(newProject);
- IProjectType parent = getSelectedProjectType();
- newManagedProject = ManagedBuildManager.createManagedProject(newProject, parent);
- if (newManagedProject != null) {
- IConfiguration [] selectedConfigs = getSelectedConfigurations();
- for (int i = 0; i < selectedConfigs.length; i++) {
- IConfiguration config = selectedConfigs[i];
- int id = ManagedBuildManager.getRandomNumber();
- IConfiguration newConfig = newManagedProject.createConfiguration(config, config.getId() + "." + id); //$NON-NLS-1$
- newConfig.setArtifactName(newManagedProject.getDefaultArtifactName());
- }
- // Now add the first supported config in the list as the default
- IConfiguration defaultCfg = null;
- IConfiguration[] newConfigs = newManagedProject.getConfigurations();
- for(int i = 0; i < newConfigs.length; i++) {
- if(newConfigs[i].isSupported()){
- defaultCfg = newConfigs[i];
- break;
- }
- }
-
- if(defaultCfg == null && newConfigs.length > 0)
- defaultCfg = newConfigs[0];
-
- if(defaultCfg != null) {
- ManagedBuildManager.setDefaultConfiguration(newProject, defaultCfg);
- ManagedBuildManager.setSelectedConfiguration(newProject, defaultCfg);
- }
- ManagedBuildManager.setNewProjectVersion(newProject);
- ICDescriptor desc = null;
- try {
- desc = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
- desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
- // TODO: The binary parser setting is currently per-project in the rest of CDT.
- // In the MBS, it is per-coonfiguration. For now, select the binary parsers of the
- // first configuration.
- if (newConfigs.length > 0) {
- IToolChain tc = newConfigs[0].getToolChain();
- ITargetPlatform targetPlatform = tc.getTargetPlatform();
- }
- } catch (CoreException e) {
- ManagedBuilderUIPlugin.log(e);
- }
- }
- } catch (BuildException e) {
- ManagedBuilderUIPlugin.log(e);
- }
-
- // Modify the project settings
- if (newProject != null) {
- optionPage.performApply(new SubProgressMonitor(monitor, 2));
- }
-
- // Save the build options
- monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_SAVE));
- if (info != null) {
- info.setValid(true);
- ManagedBuildManager.saveBuildInfo(newProject, true);
- }
- monitor.done();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void doRunPrologue(IProgressMonitor monitor) {
- // Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void doRunEpilogue(IProgressMonitor monitor) {
- // Get my initializer to run
- if(newProject == null)
- return;
-
- IStatus initResult = ManagedBuildManager.initBuildInfoContainer(newProject);
- if (initResult.getCode() != IStatus.OK) {
- // At this point, I can live with a failure
- ManagedBuilderUIPlugin.log(initResult);
- }
-
- // execute any operations specified by custom pages
- Runnable operations[] = MBSCustomPageManager.getOperations();
-
- if(operations != null)
- {
- for(int k = 0; k < operations.length; k++)
- {
- operations[k].run();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#getProjectID()
- */
- public String getProjectID() {
-// return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$
- return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID;
- }
-
- public IProjectType getSelectedProjectType() {
- return projectConfigurationPage.getSelectedProjectType();
- }
-
- public IConfiguration[] getSelectedConfigurations() {
- return projectConfigurationPage.getSelectedConfigurations();
- }
-
- /**
- * Sets the selected project type.
- * <p>The addPages() method must have been invoked, before this method can
- * be used.</p>
- * @param type a IProjectType instance, or <tt>null</tt> to select the
- * the first available project type
- */
- public void setSelectedProjectType(IProjectType type) {
- projectConfigurationPage.setSelectedProjectType(type);
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewModelProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewModelProjectWizard.java
new file mode 100644
index 00000000000..32f042170e2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewModelProjectWizard.java
@@ -0,0 +1,318 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2005 Rational Software 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 Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.ui.newui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.dialogs.PropertyDialog;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+public abstract class NewModelProjectWizard extends BasicNewResourceWizard implements IExecutableExtension
+//extends NewManagedProjectWizard
+{
+ private static final String MSG_CREATE = "MngCCWizard.message.creating"; //$NON-NLS-1$
+ private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
+ private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$
+ private static final String OP_DESC= "CProjectWizard.op_description"; //$NON-NLS-1$
+
+ protected IConfigurationElement fConfigElement;
+ protected CMainWizardPage fMainPage;
+ protected CConfigWizardPage fConfigPage;
+
+ protected IProject newProject;
+ private String wz_title;
+ private String wz_desc;
+ private String propertyId;
+
+ protected List localPages = new ArrayList(); // replacing Wizard.pages since we have to delete them
+
+ public NewModelProjectWizard() {
+ this(IDEWorkbenchMessages.getString("NewModelProjectWizard.0"),IDEWorkbenchMessages.getString("NewModelProjectWizard.1")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public NewModelProjectWizard(String title, String desc) {
+ super();
+ setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+ setNeedsProgressMonitor(true);
+ wz_title = title;
+ wz_desc = desc;
+ }
+
+ public void addPages() {
+ fConfigPage = new CConfigWizardPage();
+ fMainPage= new CMainWizardPage(CUIPlugin.getResourceString(PREFIX), fConfigPage);
+ fMainPage.setTitle(wz_title);
+ fMainPage.setDescription(wz_desc);
+ addPage(fMainPage);
+ addPage(fConfigPage);
+
+ // support for custom wizard pages
+ MBSCustomPageManager.init();
+ MBSCustomPageManager.addStockPage(fMainPage, CMainWizardPage.PAGE_ID);
+ MBSCustomPageManager.addStockPage(fConfigPage, CConfigWizardPage.PAGE_ID);
+
+ // Set up custom page manager to current natures settings
+ String[] natures = getNatures();
+ if (natures == null || natures.length == 0)
+ MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, null);
+ else if (natures.length == 1)
+ MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, natures[0]);
+ else {
+ Set x = new TreeSet();
+ for (int i=0; i<natures.length; i++) x.add(natures[i]);
+ MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, x);
+ }
+
+ // load all custom pages specified via extensions
+ try {
+ MBSCustomPageManager.loadExtensions();
+ } catch (BuildException e) { e.printStackTrace(); }
+
+ IWizardPage[] customPages = MBSCustomPageManager.getCustomPages();
+ if (customPages != null) {
+ for (int k = 0; k < customPages.length; k++) {
+ addPage(customPages[k]);
+ }
+ }
+ }
+
+ protected void doRun(IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(NewUIMessages.getResourceString(MSG_CREATE), 8); //$NON-NLS-1$
+
+ newProject = createIProject(fMainPage.getProjectName(), null);
+ // fMainPage.getProjectLocation());
+ if (newProject != null) {
+ if (fMainPage.h_selected.needsConfig()) {
+ boolean def = fMainPage.isCurrent();
+ fMainPage.h_selected.createProject(newProject, fConfigPage.getConfigurations(def), fConfigPage.getNames(def));
+ } else
+ fMainPage.h_selected.createProject(newProject, null, null);
+ }
+ monitor.done();
+ }
+
+ protected IProject getProjectHandle() throws UnsupportedOperationException {
+ if (null == fMainPage)
+ throw new UnsupportedOperationException();
+ return fMainPage.getProjectHandle();
+ }
+
+ protected boolean invokeRunnable(IRunnableWithProgress runnable) {
+ IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
+ try {
+ getContainer().run(true, true, op);
+ } catch (InvocationTargetException e) {
+ Shell shell= getShell();
+ String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
+ String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
+
+ Throwable th= e.getTargetException();
+ CUIPlugin.errorDialog(shell, title, message, th, false);
+ try {
+ getProjectHandle().delete(false, false, null);
+ } catch (CoreException ignore) {
+ } catch (UnsupportedOperationException ignore) {
+ }
+ return false;
+ } catch (InterruptedException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean performFinish() {
+ if (!invokeRunnable(getRunnable())) {
+ return false;
+ }
+
+ BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
+ IResource resource = newProject;
+ selectAndReveal(resource);
+ if (resource != null && resource.getType() == IResource.FILE) {
+ IFile file = (IFile)resource;
+ // Open editor on new file.
+ IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
+ if (dw != null) {
+ try {
+ IWorkbenchPage page = dw.getActivePage();
+ if (page != null)
+ IDE.openEditor(page, file, true);
+ } catch (PartInitException e) {
+ MessageDialog.openError(dw.getShell(),
+ CUIPlugin.getResourceString(OP_ERROR), e.getMessage());
+ }
+ }
+ }
+ // run properties dialog if required
+ if (fMainPage.h_selected.showProperties()) {
+ PropertyDialog.createDialogOn(getShell(), propertyId, newProject).open();
+ }
+ return true;
+ }
+
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ fConfigElement= config;
+ }
+
+ public IRunnableWithProgress getRunnable() {
+ return new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+ public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
+ final Exception except[] = new Exception[1];
+ // ugly, need to make the wizard page run in a non ui thread so that this can go away!!!
+ getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ final IProgressMonitor fMonitor;
+ if (monitor == null) {
+ fMonitor= new NullProgressMonitor();
+ } else {
+ fMonitor = monitor;
+ }
+ fMonitor.beginTask(CUIPlugin.getResourceString(OP_DESC), 3);
+ doRunPrologue(new SubProgressMonitor(fMonitor, 1));
+ try {
+ doRun(new SubProgressMonitor(fMonitor, 1));
+ }
+ catch (CoreException e) {
+ except[0] = e;
+ }
+ doRunEpilogue(new SubProgressMonitor(fMonitor, 1));
+ fMonitor.done();
+ }
+ });
+ try {
+ getContainer().run(false, true, op);
+ } catch (InvocationTargetException e) {
+ except[0] = e;
+ } catch (InterruptedException e) {
+ except[0] = e;
+ }
+ }
+ });
+ if (except[0] != null) {
+ if (except[0] instanceof InvocationTargetException) {
+ throw (InvocationTargetException)except[0];
+ }
+ if (except[0] instanceof InterruptedException) {
+ throw (InterruptedException)except[0];
+ }
+ throw new InvocationTargetException(except[0]);
+ }
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void doRunPrologue(IProgressMonitor monitor) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void doRunEpilogue(IProgressMonitor monitor) {
+ if(newProject == null) return;
+
+ IStatus initResult = ManagedBuildManager.initBuildInfoContainer(newProject);
+ if (initResult.getCode() != IStatus.OK) {
+ ManagedBuilderUIPlugin.log(initResult);
+ }
+
+ // execute any operations specified by custom pages
+ Runnable operations[] = MBSCustomPageManager.getOperations();
+ if(operations != null)
+ for(int k = 0; k < operations.length; k++)
+ operations[k].run();
+ }
+
+ /**
+ *
+ */
+ public IProject createIProject(final String name, final IPath location) throws CoreException{
+ if (newProject != null)
+ return newProject;
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ final IProject newProjectHandle = root.getProject(name);
+
+ if (!newProjectHandle.exists()) {
+ IWorkspaceDescription workspaceDesc = workspace.getDescription();
+ workspaceDesc.setAutoBuilding(false);
+ workspace.setDescription(workspaceDesc);
+ IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
+ if(location != null)
+ description.setLocation(location);
+ newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new NullProgressMonitor());
+ } else {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+ };
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor);
+ newProject = newProjectHandle;
+ }
+
+ // Open the project if we have to
+ if (!newProject.isOpen()) {
+ newProject.open(new NullProgressMonitor());
+ }
+ return continueCreation(newProject);
+ }
+
+ protected abstract IProject continueCreation(IProject prj);
+ protected abstract String[] getNatures();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdBuildWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdBuildWizard.java
new file mode 100644
index 00000000000..7793ffde4d8
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdBuildWizard.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class StdBuildWizard extends AbstractCWizard {
+
+ public void createItems(Tree tree, boolean supportedOnly) {
+ StdProjectTypeHandler h = new StdProjectTypeHandler(IDEWorkbenchMessages.getString("StdBuildWizard.0"), IMG0, parent); //$NON-NLS-1$
+ h.addTc(null); // add default toolchain
+ IToolChain[] tcs = ManagedBuildManager.getRealToolChains();
+ for (int i=0; i<tcs.length; i++)
+ if (!supportedOnly || isValid(tcs[i])) h.addTc(tcs[i]);
+ TreeItem ti = new TreeItem(tree, SWT.NONE);
+ ti.setText(h.getName());
+ ti.setData(h);
+ ti.setImage(h.getIcon());
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdProjectTypeHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdProjectTypeHandler.java
new file mode 100644
index 00000000000..510013b4ef7
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/StdProjectTypeHandler.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+public class StdProjectTypeHandler extends CWizardHandler {
+
+ public StdProjectTypeHandler(String _name, Image _image, Composite p) {
+ super(_name, null, _image, p, null);
+ }
+
+ protected void addTc(IToolChain tc) {
+ if (tc == null) {
+ tcs.put(IDEWorkbenchMessages.getString("StdProjectTypeHandler.0"), null); //$NON-NLS-1$
+ } else {
+ if (tc.isAbstract() || tc.isSystemObject()) return;
+ // unlike CWizardHandler, we don't check for configs
+ tcs.put(tc.getUniqueRealName(), tc);
+ }
+ }
+
+ /**
+ * Note that configurations parameter is ignored
+ */
+ public void createProject(IProject project, IConfiguration[] cfgs, String[] names) throws CoreException {
+ IToolChain[] tcs = getSelectedToolChains();
+ if (tcs == null || tcs.length == 0) {
+ tcs = new IToolChain[1]; // null value
+ }
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescription des = coreModel.getProjectDescription(project);
+ des = coreModel.createProjectDescription(project, true);
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ ManagedProject mProj = new ManagedProject(des);
+ info.setManagedProject(mProj);
+
+ for (int i=0; i<tcs.length; i++) {
+ String s = "0"; //$NON-NLS-1$
+ String name = IDEWorkbenchMessages.getString("StdProjectTypeHandler.2"); //$NON-NLS-1$
+ if (tcs[i] != null) {
+ s = tcs[i].getId();
+ name = tcs[i].getName();
+ }
+
+ Configuration cfg = new Configuration(mProj, (ToolChain)tcs[i], ManagedBuildManager.calculateChildId(s, null), name);
+ IBuilder bld = cfg.getEditableBuilder();
+ if (bld != null) {
+ bld.setManagedBuildOn(false);
+ } else {
+ System.out.println(IDEWorkbenchMessages.getString("StdProjectTypeHandler.3")); //$NON-NLS-1$
+ }
+ cfg.setArtifactName(project.getName());
+ CConfigurationData data = cfg.getConfigurationData();
+ des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ }
+ coreModel.setProjectDescription(project, des);
+ }
+
+ public boolean needsConfig() { return false; }
+ public boolean canCreateWithoutToolchain() { return true; }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/messages.properties
new file mode 100644
index 00000000000..82e04d34f5a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/messages.properties
@@ -0,0 +1,36 @@
+StdProjectTypeHandler.0=-- No toolchain --
+StdProjectTypeHandler.2=Default
+StdProjectTypeHandler.3=creation Make project: IBuilder is null
+CConfigWizardPage.0=Select Configurations
+CConfigWizardPage.1=Select platforms and configurations you wish to deploy on
+CConfigWizardPage.4=Project type:
+CConfigWizardPage.5=Tool-chains:
+CConfigWizardPage.6=Configurations:
+CConfigWizardPage.7=Select all
+CConfigWizardPage.8=Deselect all
+CConfigWizardPage.9=Edit properties after project creation
+CConfigWizardPage.10=At least one configuration should be available. Project cannot be created.
+CConfigWizardPage.11=At least one configuration should be selected. Please check needed configurations.
+CMainWizardPage.0=Project types:
+CMainWizardPage.1=Show project types and toolchains only if they are supported on the platform
+CMainWizardPage.2=Edit properties after project creation
+CMainWizardPage.3=No project types available. Project cannot be created
+CMainWizardPage.4=At least one toolchain should be selected \!
+CMainWizardPage.5=Cannot create ICProjectTypeHandler :
+WizardNewProjectCreationPage_nameLabel=
+WizardNewProjectCreationPage_projectNameEmpty=
+WizardNewProjectCreationPage_projectExistsMessage=
+CNewWizard.0=Others
+CWizardHandler.0=Toolchain:
+CWizardHandler.1=Tool chain is a set of tools\n
+CWizardHandler.2=(compiler, linker, assembler)\n
+CWizardHandler.3=intended to build your project.\n
+CWizardHandler.4=Additional tools, like debugger,\n
+CWizardHandler.5=can be assotiated with tool chain.
+NewModelProjectWizard.0=CDT project (exprimental)
+NewModelProjectWizard.1=Create CDT project of selected type
+NewModelProjectWizard.2=C++ project (exprimental)
+NewModelProjectWizard.3=Create C++ project of selected type
+NewModelProjectWizard.4=C project (exprimental)
+NewModelProjectWizard.5=Create C project of selected type
+StdBuildWizard.0=Makefile project
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 0cee4029aad..2e9bd56e217 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -8,6 +8,11 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.browser,
+ org.eclipse.cdt.core.cdtvariables,
+ org.eclipse.cdt.utils.cdtvariables,
+ org.eclipse.cdt.utils.envvar,
+ org.eclipse.cdt.internal.core.cdtvariables,
+ org.eclipse.cdt.internal.core.envvar,
org.eclipse.cdt.core.dom,
org.eclipse.cdt.core.dom.ast,
org.eclipse.cdt.core.dom.ast.c,
@@ -15,6 +20,7 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.dom.ast.gnu,
org.eclipse.cdt.core.dom.ast.gnu.c,
org.eclipse.cdt.core.dom.ast.gnu.cpp,
+ org.eclipse.cdt.core.envvar,
org.eclipse.cdt.core.formatter,
org.eclipse.cdt.core.index,
org.eclipse.cdt.core.model,
@@ -25,6 +31,10 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.parser.extension,
org.eclipse.cdt.core.parser.util,
org.eclipse.cdt.core.resources,
+ org.eclipse.cdt.core.settings.model,
+ org.eclipse.cdt.core.settings.model.extension,
+ org.eclipse.cdt.core.settings.model.extension.impl,
+ org.eclipse.cdt.core.settings.model.util,
org.eclipse.cdt.internal.core;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.browser.util;x-internal:=true,
org.eclipse.cdt.internal.core.dom;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.refactoring",
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
index 17fae237536..7b0130c11d2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -16,6 +16,9 @@ import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.internal.core.model.APathEntry;
import org.eclipse.cdt.internal.core.model.BatchOperation;
import org.eclipse.cdt.internal.core.model.CModel;
@@ -30,6 +33,7 @@ import org.eclipse.cdt.internal.core.model.OutputEntry;
import org.eclipse.cdt.internal.core.model.PathEntryManager;
import org.eclipse.cdt.internal.core.model.ProjectEntry;
import org.eclipse.cdt.internal.core.model.SourceEntry;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -49,6 +53,8 @@ public class CoreModel {
private static CoreModel cmodel = null;
private static CModelManager manager = CModelManager.getDefault();
private static PathEntryManager pathEntryManager = PathEntryManager.getDefault();
+ private static CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
+
// private static String FILE_EXT_PATTERN = "*."; //$NON-NLS-1$
// private static int FILE_EXT_PATTERN_LENGTH = FILE_EXT_PATTERN.length();
@@ -1264,5 +1270,80 @@ public class CoreModel {
}
return rc;
}
+
+ /**
+ * the method creates and returns a writable project description
+ *
+ * @param project project for which the project description is requested
+ * @param loadIfExists if true the method first tries to load and return the project description
+ * from the settings file (.cproject)
+ * if false, the stored settings are ignored and the new (empty) project description is created
+ * NOTE: changes made to the returned project description will not be applied untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
+ * @return {@link ICProjectDescription}
+ * @throws CoreException
+ */
+ public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException{
+ return descriptionManager.createProjectDescription(project, loadIfExists);
+ }
+
+ /**
+ * returns the project description associated with this project
+ * this is a convenience method fully equivalent to getProjectDescription(project, true)
+ * see {@link #getProjectDescription(IProject, boolean)} for more detail
+ * @param project
+ * @return a writable copy of the ICProjectDescription or null if the project does not contain the
+ * CDT data associated with it.
+ * Note: changes to the project description will not be reflected/used by the core
+ * untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
+ *
+ * @see #getProjectDescription(IProject, boolean)
+ */
+ public ICProjectDescription getProjectDescription(IProject project){
+ return descriptionManager.getProjectDescription(project);
+ }
+
+ /**
+ * this method is called to save/apply the project description
+ * the method should be called to apply changes made to the project description
+ * returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)}
+ *
+ * @param project
+ * @param des
+ * @throws CoreException
+ *
+ * @see {@link #getProjectDescription(IProject, boolean)}
+ * @see #createProjectDescription(IProject, boolean)
+ */
+ public void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException {
+ descriptionManager.setProjectDescription(project, des);
+ }
+ /**
+ * returns the project description associated with this project
+ *
+ * @param project project for which the description is requested
+ * @param write if true, the writable description copy is returned.
+ * If false the cached read-only description is returned.
+ *
+ * CDT core maintains the cached project description settings. If only read access is needed to description,
+ * then the read-only project description should be obtained.
+ * This description always operates with cached data and thus it is better to use it for performance reasons
+ * All set* calls to the read-only description result in the {@link WriteAccessException}
+ *
+ * When the writable description is requested, the description copy is created.
+ * Changes to this description will not be reflected/used by the core and Build System untill the
+ * {@link #setProjectDescription(IProject, ICProjectDescription)} is called
+ *
+ * Each getProjectDescription(project, true) returns a new copy of the project description
+ *
+ * The writable description uses the cached data untill the first set call
+ * after that the description communicates directly to the Build System
+ * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension
+ * This ensures the Core<->Build System settings integrity
+ *
+ * @return {@link ICProjectDescription}
+ */
+ public ICProjectDescription getProjectDescription(IProject project, boolean write){
+ return descriptionManager.getProjectDescription(project, write);
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguageDescriptor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguageDescriptor.java
new file mode 100644
index 00000000000..572b06af4fb
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguageDescriptor.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.model;
+
+import org.eclipse.cdt.core.ICExtensionDescriptor;
+import org.eclipse.core.runtime.content.IContentType;
+
+public interface ILanguageDescriptor extends ICExtensionDescriptor {
+ ILanguage getLanguage();
+
+ String[] getContentTypeIds();
+
+ IContentType[] getContentTypes();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java
index add6fae6581..ac0d2f3e150 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java
@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -24,6 +25,7 @@ import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.internal.core.CContentTypes;
import org.eclipse.cdt.internal.core.language.LanguageMappingConfiguration;
import org.eclipse.cdt.internal.core.language.LanguageMappingStore;
+import org.eclipse.cdt.internal.core.model.LanguageDescriptor;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.core.resources.IFile;
@@ -58,12 +60,92 @@ public class LanguageManager {
private Map fContentTypeToLanguageCache= new HashMap();
private Map fLanguageConfigurationCache = new HashMap();
private boolean fIsFullyCached;
-
+ private HashMap fIdToLanguageDescriptorCache;//= new HashMap();
+ private HashMap fContentTypeToDescriptorListCache;
+
public static LanguageManager getInstance() {
if (instance == null)
instance = new LanguageManager();
return instance;
}
+
+ public ILanguageDescriptor getLanguageDescriptor(String id) {
+ Map map = getDescriptorCache();
+ return (ILanguageDescriptor)map.get(id);
+ }
+
+ private HashMap getDescriptorCache(){
+ if(fIdToLanguageDescriptorCache == null){
+ fIdToLanguageDescriptorCache = createDescriptorCache();
+ }
+ return fIdToLanguageDescriptorCache;
+ }
+
+ public ILanguageDescriptor[] getLanguageDescriptors(){
+ HashMap map = getDescriptorCache();
+ return (ILanguageDescriptor[])map.values().toArray(new ILanguageDescriptor[map.size()]);
+ }
+
+ private HashMap createDescriptorCache(){
+ HashMap map = new HashMap();
+ IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
+ for (int j = 0; j < configs.length; ++j) {
+ final IConfigurationElement languageElem = configs[j];
+ if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
+ LanguageDescriptor lDes = new LanguageDescriptor(languageElem);
+ map.put(lDes.getId(), lDes);
+ }
+ }
+ return map;
+ }
+
+ private HashMap getContentTypeToDescriptorCache(){
+ if(fContentTypeToDescriptorListCache == null){
+ fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache();
+ }
+ return fContentTypeToDescriptorListCache;
+ }
+
+ public Map getContentTypeIdToLanguageDescriptionsMap(){
+ HashMap map = (HashMap)getContentTypeToDescriptorCache().clone();
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ List list = (List)entry.getValue();
+ if(list.size() > 0){
+ ILanguageDescriptor[] dess = (ILanguageDescriptor[])list.toArray(new ILanguageDescriptor[list.size()]);
+ entry.setValue(dess);
+ } else {
+ iter.remove();
+ }
+ }
+
+ return map;
+ }
+
+
+ private HashMap createContentTypeToDescriptorCache(){
+ HashMap map = new HashMap();
+ Map dc = getDescriptorCache();
+
+ List list;
+ IContentType type;
+ String id;
+ for(Iterator iter = dc.values().iterator(); iter.hasNext();){
+ ILanguageDescriptor des = (ILanguageDescriptor)iter.next();
+ IContentType types[] = des.getContentTypes();
+ for(int i = 0; i < types.length; i++){
+ type = types[i];
+ id = type.getId();
+ list = (List)map.get(id);
+ if(list == null){
+ list = new ArrayList();
+ map.put(id, list);
+ }
+ list.add(des);
+ }
+ }
+ return map;
+ }
public ILanguage getLanguage(String id) {
ILanguage language = (ILanguage)fLanguageCache.get(id);
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java
new file mode 100644
index 00000000000..5ed90ac7306
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACLanguageSettingPathEntry;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+
+public final class CIncludeFileEntry extends ACLanguageSettingPathEntry implements
+ ICIncludeFileEntry {
+
+ public CIncludeFileEntry(String value, int flags) {
+ super(value, flags);
+ }
+
+ public CIncludeFileEntry(IPath location, int flags) {
+ super(location, flags);
+ }
+
+ public CIncludeFileEntry(IFile rc, int flags) {
+ super(rc, flags);
+ }
+
+ public final int getKind() {
+ return INCLUDE_FILE;
+ }
+
+ public final boolean isFile() {
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java
new file mode 100644
index 00000000000..3a409fc4cf1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACLanguageSettingPathEntry;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IPath;
+
+public final class CIncludePathEntry extends ACLanguageSettingPathEntry implements ICIncludePathEntry{
+
+ public CIncludePathEntry(String value, int flags) {
+ super(value, flags);
+ }
+
+ public CIncludePathEntry(IPath location, int flags) {
+ super(location, flags);
+ }
+
+ public CIncludePathEntry(IFolder rc, int flags) {
+ super(rc, flags);
+ }
+
+ public boolean isLocal() {
+ return checkFlags(LOCAL);
+ }
+
+ public final int getKind() {
+ return INCLUDE_PATH;
+ }
+
+ public final boolean isFile() {
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java
new file mode 100644
index 00000000000..18789ac77c1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACLanguageSettingPathEntry;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+
+public final class CLibraryFileEntry extends ACLanguageSettingPathEntry implements
+ ICLibraryFileEntry {
+
+ public CLibraryFileEntry(String value, int flags) {
+ super(value, flags);
+ }
+
+ public CLibraryFileEntry(IPath location, int flags) {
+ super(location, flags);
+ }
+
+ public CLibraryFileEntry(IFile rc, int flags) {
+ super(rc, flags);
+ }
+
+ public final int getKind() {
+ return LIBRARY_FILE;
+ }
+
+ public final boolean isFile() {
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java
new file mode 100644
index 00000000000..1106dd9c4f9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACLanguageSettingPathEntry;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IPath;
+
+public final class CLibraryPathEntry extends ACLanguageSettingPathEntry implements
+ ICLibraryPathEntry {
+
+ public CLibraryPathEntry(String value, int flags) {
+ super(value, flags);
+ }
+
+ public CLibraryPathEntry(IPath location, int flags) {
+ super(location, flags);
+ }
+
+ public CLibraryPathEntry(IFolder rc, int flags) {
+ super(rc, flags);
+ }
+
+ public final int getKind() {
+ return LIBRARY_PATH;
+ }
+
+ public final boolean isFile() {
+ return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java
new file mode 100644
index 00000000000..099ccd909e1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACLanguageSettingEntry;
+
+
+public final class CMacroEntry extends ACLanguageSettingEntry implements ICMacroEntry{
+ private String fValue;
+
+ public CMacroEntry(String name, String value, int flags) {
+ super(name, flags);
+ fValue = value;
+ if(fValue == null)
+ fValue = "";
+ }
+
+ public String getValue() {
+ return fValue;
+ }
+
+ public final int getKind() {
+ return MACRO;
+ }
+
+ public boolean equals(Object other) {
+ if(!super.equals(other))
+ return false;
+ return fValue.equals(((CMacroEntry)other).fValue);
+ }
+
+ public int hashCode() {
+ return super.hashCode() + fValue.hashCode();
+ }
+
+ public boolean equalsByContents(ICLanguageSettingEntry entry) {
+ if(!super.equalsByContents(entry))
+ return false;
+
+ return fValue.equals(((CMacroEntry)entry).fValue);
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java
new file mode 100644
index 00000000000..dd28143843b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACLanguageSettingPathEntry;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+
+public final class CMacroFileEntry extends ACLanguageSettingPathEntry implements
+ ICMacroFileEntry {
+
+ public CMacroFileEntry(String value, int flags) {
+ super(value, flags);
+ }
+
+ public CMacroFileEntry(IPath location, int flags) {
+ super(location, flags);
+ }
+
+ public CMacroFileEntry(IFile rc, int flags) {
+ super(rc, flags);
+ }
+
+ public final int getKind() {
+ return MACRO_FILE;
+ }
+
+ public final boolean isFile() {
+ return true;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java
new file mode 100644
index 00000000000..7a1d01dfba8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACExclusionFilterEntry;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IPath;
+
+public final class COutputEntry extends ACExclusionFilterEntry implements ICOutputEntry {
+
+ public COutputEntry(IPath path, IPath exclusionPatterns[], int flags) {
+ super(path, exclusionPatterns, flags);
+ }
+
+ public COutputEntry(IFolder folder, IPath exclusionPatterns[], int flags) {
+ super(folder, exclusionPatterns, flags);
+ }
+
+ public COutputEntry(String value, IPath exclusionPatterns[], int flags) {
+ super(value, exclusionPatterns, flags);
+ }
+
+ public final int getKind() {
+ return OUTPUT_PATH;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java
new file mode 100644
index 00000000000..fe959731cfc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.internal.core.settings.model.ACExclusionFilterEntry;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IPath;
+
+public final class CSourceEntry extends ACExclusionFilterEntry implements ICSourceEntry {
+
+ public CSourceEntry(IPath path, IPath exclusionPatterns[], int flags) {
+ super(path, exclusionPatterns, flags | VALUE_WORKSPACE_PATH);
+ }
+
+ public CSourceEntry(IFolder rc, IPath exclusionPatterns[], int flags) {
+ super(rc, exclusionPatterns, flags);
+ }
+
+ public CSourceEntry(String value, IPath exclusionPatterns[], int flags) {
+ super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH);
+ }
+
+ public final int getKind() {
+ return SOURCE_PATH;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICBuildSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICBuildSetting.java
new file mode 100644
index 00000000000..910d99a174b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICBuildSetting.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.model.IOutputEntry;
+import org.eclipse.core.runtime.IPath;
+
+public interface ICBuildSetting extends ICSettingObject {
+ IPath getBuilderCWD();
+
+ void setBuilderCWD(IPath path);
+
+ ICOutputEntry[] getOutputDirectories();
+
+ void setOutputDirectories(ICOutputEntry[] entries);
+
+ String[] getErrorParserIDs();
+
+ void setErrorParserIDs(String[] ids);
+
+ IEnvironmentContributor getBuildEnvironmentContributor();
+// IEnvironment getBuildEnvironment();
+
+// void setBuildEnvironment(IEnvironment environment);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java
new file mode 100644
index 00000000000..bba7f827c97
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java
@@ -0,0 +1,61 @@
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public interface ICConfigExtensionReference {
+ /**
+ * Return the extension point of this reference.
+ *
+ * @return String
+ */
+ public String getExtensionPoint();
+
+ /**
+ * Return the extension ID of this reference.
+ *
+ * @return String
+ */
+ public String getID();
+
+ /**
+ * Sets a name/value data pair on this reference in the .cdtproject file
+ */
+ public void setExtensionData(String key, String value) throws CoreException;
+
+ /**
+ * Gets a value of the key from the .cdtproject file set by
+ * setExtensionData()
+ */
+ public String getExtensionData(String key);
+
+ /**
+ * Returns the project descriptor which this extension reference belongs to.
+ * @return the ICDescriptor
+ */
+ public ICConfigurationDescription getConfiguration();
+
+ /**
+ * Returns all configuration elements that are children of the
+ * cextension element. Returns an empty array if this configuration
+ * element has no children.
+ * <p>
+ * Each child corresponds to a nested XML element in the configuration
+ * markup. For example, the configuration markup
+ *
+ * <pre>
+ * &lt;view&gt;
+ * &amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&lt;verticalHint&gt;top&lt;/verticalHint&gt;
+ * &amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&lt;horizontalHint&gt;left&lt;/horizontalHint&gt;
+ * &lt;/view&gt;
+ * </pre>
+ *
+ * corresponds to a configuration element, named <code>"view"</code>,
+ * with two children.
+ * </p>
+ *
+ * @return the child configuration elements
+ */
+// public IConfigurationElement[] getExtensionElements() throws CoreException;
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java
new file mode 100644
index 00000000000..9b6d8082d2f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java
@@ -0,0 +1,355 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
+
+/**
+ * this is the element representing configuration and thus this is the root element
+ * for configuration-specific settings
+ *
+ */
+public interface ICConfigurationDescription extends ICSettingContainer, ICSettingObject, ICSettingsStorage{
+ /**
+ * Returns whether or not this is an active configuration.
+ * Active configuratiuon is the one that is built by default.
+ * This configuration is returned by the {@link ICProjectDescription#getActiveConfiguration()} call
+ *
+ * @return boolean
+ */
+ boolean isActive();
+
+ /**
+ * returns the human-readable configuration description
+ *
+ * @return
+ */
+ String getDescription();
+
+ /**
+ * sets the configuration description
+ *
+ * @param des
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void setDescription(String des) throws WriteAccessException;
+
+ /**
+ * returns the project description this configuration belongsa to
+ * @return
+ */
+ ICProjectDescription getProjectDescription();
+
+ /**
+ * returns the "root" folder description
+ * The root folder description is the default one used for the project root folder
+ * The root folder description can not be null
+ * @return
+ */
+ ICFolderDescription getRootFolderDescription();
+
+ /**
+ * returns the complete set of folder descriptions defined for this configuration
+ * The folder description is the settings holder for the specified folder
+ * @see ICFolderDescription
+ * @return
+ */
+ ICFolderDescription[] getFolderDescriptions();
+
+ /**
+ * returns the complete set of file descriptions defined for this configuration
+ * The file description is the settings holder for the specified file
+ * @see ICFileDescription
+ * @return
+ */
+ ICFileDescription[] getFileDescriptions();
+
+ /**
+ * returns the complete set of file and folder descriptions (resource descriptions) defined for this configuration
+ * The resource description is the settings holder for the specified resource
+ * @see ICResourceDescription
+ * @see ICFileDescription
+ * @see ICFolderDescription
+ * @return
+ */
+ ICResourceDescription[] getResourceDescriptions();
+
+ /**
+ * Returns the resource description for the given path
+ *
+ * @param path - project-relative workspace resource path
+ * @param exactPath - when true the resource description of the given path is searched and if not found null is returned,
+ * if false, the resource description applicable for the given path is returned,
+ * i.e. if the configuration contains resource descriptions of the following paths "" and "a/"
+ * getResourceDescription(new Path("a/b"), true) returns null
+ * getResourceDescription(new Path("a/b"), false) returns the "a" folder description
+ * @return {@link ICResourceDescription} that is either a {@link ICFolderDescription} or an {@link ICFileDescription}
+ */
+ ICResourceDescription getResourceDescription(IPath path, boolean exactPath);
+
+ /**
+ * removes the given resource description from the configuration
+ *
+ * @param des
+ * @throws CoreException
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ *
+ */
+ void removeResourceDescription(ICResourceDescription des) throws CoreException, WriteAccessException;
+
+ /**
+ * creates a new file description for the specified path
+ * @param path project-relative file workspace path
+ * @param base resource description from which settings will be coppied/inheritted
+ * @return
+ * @throws CoreException
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException;
+
+ /**
+ * creates a new folder description for the specified path
+ * @param path project-relative folder workspace path
+ * @param base resource description from which settings will be coppied/inheritted
+ * @return
+ * @throws CoreException
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException;
+
+ /**
+ * returns the ID of the build system used with this configuration
+ * i.e. the id of extension contributing to the org.eclipse.cdt.core.CConfigurationDataProvider extension point
+ * used with this configuration
+ *
+ * @return String
+ */
+ String getBuildSystemId();
+
+ /**
+ * This method should be used by the build system only for gettings
+ * the build-system contributed CConfigurationData
+ * @see org.eclipse.cdt.core.CConfigurationDataProvider extension point
+ * @see CConfigurationDataProvider
+ * @return
+ */
+ CConfigurationData getConfigurationData();
+
+ /**
+ * sets this cinfiguration as active
+ * this call is equivalent to {@link ICProjectDescription#setActiveConfiguration(ICConfigurationDescription)}
+ * Active configuratiuon is the one that is built by default.
+ * This configuration is returned by the {@link ICProjectDescription#getActiveConfiguration()} call
+ *
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void setActive() throws WriteAccessException;
+
+ /**
+ * This method should be used by the build system only for updating
+ * the build-system contributed CConfigurationData
+ *
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ *
+ * @see org.eclipse.cdt.core.CConfigurationDataProvider extension point
+ * @see CConfigurationDataProvider
+ */
+ void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException;
+
+ /**
+ * returns whether or not the configuration description was modified
+ *
+ * @return
+ */
+ boolean isModified();
+
+ /**
+ * returns the target platform settings for this configuration
+ * @see ICTargetPlatformSetting
+ *
+ * @return
+ */
+ ICTargetPlatformSetting getTargetPlatformSetting();
+
+ /**
+ * returns the source entries for this configuration
+ * @see iCSourceEntry
+ * @return
+ */
+ ICSourceEntry[] getSourceEntries();
+
+ /**
+ * sets the source entries for this configuration
+ *
+ * @param entries
+ *
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException;
+
+ /**
+ * returns the reference information for this configuration, i.e. the information on the projects/configurations
+ * this configuration references
+ * the map contains the project_name<->configuration_id associations
+ * if the current configuration does not reference any other configurations,
+ * empty map is returned
+ *
+ * @return
+ */
+ Map getReferenceInfo();
+
+ /**
+ * sets the reference information for this configuration, i.e. the information on the projects/configurations
+ * this configuration references
+ * the map should contain the project_name<->configuration_id associations
+ *
+ * @param refs
+ *
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void setReferenceInfo(Map refs) throws WriteAccessException;
+
+ /**
+ * returns an array of settings exported by this configuration
+ * in case some configurations refer (depend on) this configuration
+ * exported settings of this configuration get applied to those configurations
+ * @see ICExternalSetting
+ * @see #getReferenceInfo()
+ * @see #setReferenceInfo(Map)
+ * @return
+ */
+ ICExternalSetting[] getExternalSettings();
+
+ /**
+ * creates/adds external setting to this configuration
+ * in case some configurations refer (depend on) this configuration
+ * exported settings of this configuration get applied to those configurations
+ * @see ICExternalSetting
+ * @see #getReferenceInfo()
+ * @see #setReferenceInfo(Map)
+ * @see #getExternalSettings()
+ *
+ * @param languageIDs
+ * @param contentTypeIds
+ * @param extensions
+ * @param entries
+ * @return
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ ICExternalSetting createExternalSetting(String languageIDs[],
+ String contentTypeIds[],
+ String extensions[],
+ ICLanguageSettingEntry entries[]) throws WriteAccessException;
+
+ /**
+ * removes external setting from this configuration
+ * in case some configurations refer (depend on) this configuration
+ * exported settings of this configuration get applied to those configurations
+ * @see ICExternalSetting
+ * @see #getReferenceInfo()
+ * @see #setReferenceInfo(Map)
+ * @see #getExternalSettings()
+ *
+ * @param setting
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException;
+
+ /**
+ * removes all external settings from this configuration
+ * in case some configurations refer (depend on) this configuration
+ * exported settings of this configuration get applied to those configurations
+ * @see ICExternalSetting
+ * @see #getReferenceInfo()
+ * @see #setReferenceInfo(Map)
+ * @see #getExternalSettings()
+ *
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void removeExternalSettings() throws WriteAccessException;
+
+ /**
+ * returns the build setting for this configuration
+ *
+ * @return
+ *
+ * @see ICBuildSetting
+ */
+ ICBuildSetting getBuildSetting();
+
+ /**
+ * returns the Cdt variable contributor that represent infomration on the
+ * CDT variables (Build Macros) contributed/usew with this contiguration
+ * @return
+ *
+ * @see ICdtVariablesContributor
+ */
+ ICdtVariablesContributor getBuildVariablesContributor();
+
+ /**
+ * the get/setSettionsProperty methods allow to associate the session properties mechanism on the configuration level
+ * session properties are not persisted and are not restored on the next eclipse session
+ * the scope of configuration session properties is the current configuration description,
+ * i.e. modifications to the properties are not applied untill the setProjectDescription call
+ *
+ * @param name
+ * @return
+ */
+ Object getSessionProperty(QualifiedName name);
+
+ /**
+ * the get/setSettionsProperty methods allow to associate the session properties mechanism on the configuration level
+ * session properties are not persisted and are not restored on the next eclipse session
+ * the scope of configuration session properties is the current configuration description,
+ * i.e. modifications to the properties are not applied untill the setProjectDescription call
+ *
+ * @param name
+ * @param value
+ */
+ void setSessionProperty(QualifiedName name, Object value);
+
+ /**
+ * sets the name for this configuration
+ *
+ * @param name
+ * @throws WriteAccessException when the configuration description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void setName(String name) throws WriteAccessException;
+
+ ICConfigExtensionReference[] get(String extensionPointID);
+
+ ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException;
+
+ void remove(ICConfigExtensionReference ext) throws CoreException;
+
+ void remove(String extensionPoint) throws CoreException;
+
+ boolean isPreferenceConfiguration();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExclusionPatternPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExclusionPatternPathEntry.java
new file mode 100644
index 00000000000..bd828c63b00
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExclusionPatternPathEntry.java
@@ -0,0 +1,17 @@
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface ICExclusionPatternPathEntry extends ICPathEntry {
+ /**
+ * Returns an array of inclusion paths affecting the
+ * source folder when looking for files recursively.
+ * @return IPath
+ */
+ IPath[] getExclusionPatterns();
+
+ /**
+ * Returns a char based representation of the exclusions patterns full path.
+ */
+ public char[][] fullExclusionPatternChars();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExternalSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExternalSetting.java
new file mode 100644
index 00000000000..aef92dfc5ce
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICExternalSetting.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICExternalSetting {
+ String[] getCompatibleLanguageIds();
+
+ String[] getCompatibleContentTypeIds();
+
+ String[] getCompatibleExtensions();
+
+ ICLanguageSettingEntry[] getEntries(int kind);
+
+ ICLanguageSettingEntry[] getEntries();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java
new file mode 100644
index 00000000000..8a4c6555383
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICFileDescription extends ICResourceDescription{
+ ICLanguageSetting getLanguageSetting();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFolderDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFolderDescription.java
new file mode 100644
index 00000000000..19286bb983c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFolderDescription.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public interface ICFolderDescription extends ICResourceDescription, ICSettingContainer {
+ ICResourceDescription getNestedResourceDescription(IPath relPath, boolean exactPath);
+
+ ICResourceDescription[] getNestedResourceDescriptions(int kind);
+
+ ICResourceDescription[] getNestedResourceDescriptions();
+
+ ICLanguageSetting[] getLanguageSettings();
+
+ ICLanguageSetting getLanguageSettingForFile(String fileName);
+
+ ICLanguageSetting createLanguageSettingForContentTypes(String languageId, String cTypeIds[]) throws CoreException;
+
+ ICLanguageSetting createLanguageSettingForExtensions(String languageId, String extensions[]) throws CoreException;
+
+ boolean isRoot();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludeFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludeFileEntry.java
new file mode 100644
index 00000000000..d8cac43b9f2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludeFileEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICIncludeFileEntry extends ICLanguageSettingPathEntry {
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludePathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludePathEntry.java
new file mode 100644
index 00000000000..07d3efef7ff
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICIncludePathEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICIncludePathEntry extends ICLanguageSettingPathEntry {
+ boolean isLocal();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java
new file mode 100644
index 00000000000..812ee3d246e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSetting.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import java.util.List;
+
+public interface ICLanguageSetting extends ICSettingObject {
+ String[] getSourceContentTypeIds();
+
+ String[] getSourceExtensions();
+
+// IContentType getHeaderContentType();
+
+// String[] getHeaderExtensions();
+
+ String getLanguageId();
+
+// ICLanguageSettingEntry[] getSettingEntries();
+
+// void removeEntry(ICLanguageSettingEntry entry);
+
+// void addEntry(ICLanguageSettingEntry entry, int position);
+
+ ICLanguageSettingEntry[] getSettingEntries(int kind);
+
+ List getSettingEntriesList(int kind);
+
+// ICLanguageSettingEntry[] getResolvedSettingEntries();
+
+ ICLanguageSettingEntry[] getResolvedSettingEntries(int kind);
+
+ void setSettingEntries(int kind, ICLanguageSettingEntry[] entries);
+
+ void setSettingEntries(int kind, List entriesList);
+
+// void changeEntries(ICLanguageSettingEntryInfo[] added, ICLanguageSettingEntry[] removed);
+
+ int getSupportedEntryKinds();
+
+ boolean supportsEntryKind(int kind);
+
+ void setLanguageId(String id);
+
+ void setSourceContentTypeIds(String ids[]);
+
+ void setSourceExtensions(String exts[]);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingEntry.java
new file mode 100644
index 00000000000..8e577021ce5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingEntry.java
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICLanguageSettingEntry extends ICSettingEntry{
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingPathEntry.java
new file mode 100644
index 00000000000..1cb928b244a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLanguageSettingPathEntry.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.core.runtime.IPath;
+
+
+public interface ICLanguageSettingPathEntry extends ICLanguageSettingEntry, ICPathEntry {
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryFileEntry.java
new file mode 100644
index 00000000000..1cbcf750a15
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryFileEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICLibraryFileEntry extends ICLanguageSettingPathEntry {
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryPathEntry.java
new file mode 100644
index 00000000000..0aa6a7dc40e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICLibraryPathEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICLibraryPathEntry extends ICLanguageSettingPathEntry {
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java
new file mode 100644
index 00000000000..30ca542f252
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICMacroEntry extends ICLanguageSettingEntry {
+ String getValue();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroFileEntry.java
new file mode 100644
index 00000000000..2c777bdfb66
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroFileEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICMacroFileEntry extends ICLanguageSettingPathEntry {
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICOutputEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICOutputEntry.java
new file mode 100644
index 00000000000..b815aeb484a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICOutputEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+
+public interface ICOutputEntry extends ICExclusionPatternPathEntry{
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICPathEntry.java
new file mode 100644
index 00000000000..ab656ed8931
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICPathEntry.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface ICPathEntry extends ICSettingEntry {
+ IPath getFullPath();
+
+ IPath getLocation();
+
+ boolean isValueWorkspacePath();
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java
new file mode 100644
index 00000000000..f8a05e7dfab
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+
+/**
+ * The ICProjectDescription is the roo element for obtaining the CDT project settings
+ * it can be obtained by the {@link CoreModel#getProjectDescription(IProject, boolean)} call
+ * @see CoreModel#getProjectDescription(IProject)
+ * @see CoreModel#getProjectDescription(IProject, boolean)
+ *
+ */
+public interface ICProjectDescription extends ICSettingContainer, ICSettingObject, ICSettingsStorage{
+ /**
+ * returns an array of configurations available for this project
+ *
+ * @return
+ */
+ ICConfigurationDescription[] getConfigurations();
+
+ /**
+ * returns active configuration
+ * Active configuratiuon is the one that is built by default.
+ *
+ * @return
+ */
+ ICConfigurationDescription getActiveConfiguration();
+
+ /**
+ * sets active configuration for this project description
+ *
+ * @param cfg
+ *
+ * @throws WriteAccessException when the project description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void setActiveConfiguration(ICConfigurationDescription cfg) throws WriteAccessException;
+
+ /**
+ * creates/adds a new configuration for this project description
+ *
+ * @param id configuration id
+ * @param name configuration name
+ * @param base the configuration description from which the settings are to be copied
+ * @return
+ * @throws CoreException
+ * @throws WriteAccessException when the project description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ *
+ */
+ ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException, WriteAccessException;
+
+ /**
+ * creates/adds a new configuration for this project description
+ * This method is typically used by the Build System-specific code for creating new configurations
+ *
+ * @param buildSystemId build system id, i.e. the extension id contributing to the
+ * org.eclipse.cdt.core.CConfigurationDataProvider extension point
+ * @param data CConfigurationData to be associated with this configuration
+ * @return the created configuration
+ * @throws CoreException
+ * @throws WriteAccessException when the project description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException, WriteAccessException;
+
+ /**
+ * returns Configuration of the given name or null if not found
+ * @param name
+ * @return
+ */
+ ICConfigurationDescription getConfigurationByName(String name);
+
+ /**
+ * returns Configuration of the given id or null if not found
+ * @param id
+ * @return
+ */
+ ICConfigurationDescription getConfigurationById(String id);
+
+ /**
+ * removes Configuration of the given name from the project description
+ * @param name
+ * @throws WriteAccessException when the project description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void removeConfiguration(String name) throws WriteAccessException;
+
+ /**
+ * removed the given configuration from the project description
+ * @param cfg
+ * @throws WriteAccessException when the project description is read-only
+ * the description is read only if it was queried/returned by the {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)} call
+ */
+ void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException;
+
+ /**
+ * IProject this project description is associated with
+ * @return
+ */
+ IProject getProject();
+
+ /**
+ * returns true if the project description was modified
+ * false otherwise
+ * @return
+ */
+ boolean isModified();
+
+ /**
+ * the get/setSettionsProperty methods allow to associate the session properties with the given project description
+ * session properties are not persisted and are not restored on the next eclipse session
+ * the scope of project description session properties is the current project description,
+ * i.e. modifications to the properties are not applied untill the setProjectDescription call
+ *
+ * @param name
+ */
+ Object getSessionProperty(QualifiedName name);
+
+ /**
+ * the get/setSettionsProperty methods allow to associate the session properties with the given project description
+ * session properties are not persisted and are not restored on the next eclipse session
+ * the scope of project description session properties is the current project description,
+ * i.e. modifications to the properties are not applied untill the setProjectDescription call
+ *
+ * @param name
+ * @param value
+ */
+ void setSessionProperty(QualifiedName name, Object value);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICResourceDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICResourceDescription.java
new file mode 100644
index 00000000000..689e40a66c0
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICResourceDescription.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface ICResourceDescription extends ICSettingContainer, ICSettingObject{
+ IPath getPath();
+
+// IPath getLocation();
+
+ boolean isExcluded();
+
+ void setExcluded(boolean excluded) throws WriteAccessException ;
+
+ void setPath(IPath path) throws WriteAccessException ;
+
+ ICFolderDescription getParentFolderDescription();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingBase.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingBase.java
new file mode 100644
index 00000000000..bc73b6caa1e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingBase.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICSettingBase {
+ public static final int SETTING_PROJECT = 1;
+ public static final int SETTING_CONFIGURATION = 1 << 1;
+ public static final int SETTING_FOLDER = 1 << 2;
+ public static final int SETTING_FILE = 1 << 3;
+ public static final int SETTING_LANGUAGE = 1 << 4;
+ public static final int SETTING_TARGET_PLATFORM = 1 << 5;
+ public static final int SETTING_BUILD = 1 << 6;
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingContainer.java
new file mode 100644
index 00000000000..013964598ae
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingContainer.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICSettingContainer {
+ ICSettingObject[] getChildSettings();
+
+// ICSettingObject getChildSettingById(String id);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java
new file mode 100644
index 00000000000..bf381bc35f3
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICSettingEntry {
+ int BUILTIN = 1;
+ int READONLY = 1 << 1;
+ int LOCAL = 1 << 2;
+ int VALUE_WORKSPACE_PATH = 1 << 3;
+ int RESOLVED = 1 << 4;
+
+ int INCLUDE_PATH = 1;
+ int INCLUDE_FILE = 1 << 1;
+ int MACRO = 1 << 2;
+ int MACRO_FILE = 1 << 3;
+ int LIBRARY_PATH = 1 << 4;
+ int LIBRARY_FILE = 1 << 5;
+ int OUTPUT_PATH = 1 << 6;
+ int SOURCE_PATH = 1 << 7;
+ int ALL = ~0;
+
+ boolean isReadOnly();
+
+ int getKind();
+
+ String getName();
+
+ String getValue();
+
+ boolean isBuiltIn();
+
+// boolean isResolved();
+
+ boolean equalsByName(ICLanguageSettingEntry entry);
+
+ boolean equalsByContents(ICLanguageSettingEntry entry);
+
+ int getFlags();
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingObject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingObject.java
new file mode 100644
index 00000000000..3033ee6f2a3
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingObject.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+/**
+ * this is the common super-class for all ICProjectDescription model elements
+ *
+ */
+public interface ICSettingObject extends ICSettingBase{
+ /**
+ *
+ * @return the unique id of this element
+ */
+ String getId();
+
+ /**
+ *
+ * @return the name of this element
+ */
+ String getName();
+
+ /**
+ *
+ * @return constant representing the setting type
+ * can be one of the following:
+ * {@link ICSettingBase#SETTING_PROJECT}
+ * {@link ICSettingBase#SETTING_CONFIGURATION}
+ * {@link ICSettingBase#SETTING_FOLDER}
+ * {@link ICSettingBase#SETTING_FILE}
+ * {@link ICSettingBase#SETTING_LANGUAGE}
+ * {@link ICSettingBase#SETTING_TARGET_PLATFORM}
+ * {@link ICSettingBase#SETTING_BUILD}
+ */
+ int getType();
+
+ /**
+ *
+ * @return true if the given object is valid, false - otherwise
+ *
+ * the object can be invalid, e.g. in case it was removed
+ */
+ boolean isValid();
+
+ /**
+ *
+ * @return the configuration description this object belongs to
+ */
+ ICConfigurationDescription getConfiguration();
+
+ /**
+ *
+ * @return the object parent
+ */
+ ICSettingContainer getParent();
+
+ /**
+ *
+ * @return true if the object is read-only, false - otherwise
+ */
+ boolean isReadOnly();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingsStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingsStorage.java
new file mode 100644
index 00000000000..8a72863f39e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingsStorage.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * this interface represents the settings storage that can be used for storing
+ * data in the tree-like format of name-value holder elements
+ *
+ * Both {@link ICProjectDescription} and {@link ICConfigurationDescription} implement this
+ * interface thus providing the capabilities to store custom project-wide and configuration-specific
+ * data in the storage file (.cproject)
+ *
+ * These capabilities could be used, e.g. by the Build System
+ * (org.eclipse.cdt.core.CConfigurationDataProvider extension implementer)
+ * for loadding/storing data on the {@link CConfigurationDataProvider#loadConfiguration(ICConfigurationDescription)}
+ * and {@link CConfigurationDataProvider#applyConfiguration(ICConfigurationDescription, org.eclipse.cdt.core.settings.model.extension.CConfigurationData)}
+ * requests
+ *
+ */
+public interface ICSettingsStorage {
+ /**
+ * returns the storage of the specified id
+ * @param id any custom string value uniquely representing the storage
+ * @return {@link ICStorageElement} if the settings storage does not contain the information of
+ * the specified id an empty storage is created and returned
+ * @throws CoreException
+ *
+ * @see {@link ICStorageElement}
+ */
+ ICStorageElement getStorage(String id, boolean create) throws CoreException;
+
+// /**
+// *
+// * @param id any custom string value uniquely representing the storage
+// * @return true if the setting storage contains storage of the specified id and false - otherwise
+// * @throws CoreException
+// */
+// boolean containsStorage(String id) throws CoreException;
+
+ void removeStorage(String id) throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java
new file mode 100644
index 00000000000..aa31c387666
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+
+public interface ICSourceEntry extends ICExclusionPatternPathEntry{
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java
new file mode 100644
index 00000000000..9d4136aeb08
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+
+/**
+ *
+ * this interface represents the abstract storage that can be used for storing
+ * data in the tree-like format of name-value holder elements
+ *
+ * This abstract storage mechanism is used, e.g. with the {@link ICProjectDescription} and {@link ICConfigurationDescription}
+ * for storing custom data in the settings file (.cproject)
+ *
+ * @see ICSettingsStorage
+ * @see ICProjectDescription
+ * @see ICConfigurationDescription
+ *
+ */
+public interface ICStorageElement {
+ ICStorageElement[] getChildren();
+
+ String getAttribute(String name);
+
+ ICStorageElement getParent();
+
+ void setAttribute(String name, String value);
+
+ void removeAttribute(String name);
+
+ ICStorageElement createChild(String name);
+
+ void clear();
+
+ String getName();
+
+// void remove();
+
+ void removeChild(ICStorageElement el);
+
+ String getValue();
+
+ void setValue(String value);
+
+ ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException;
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICTargetPlatformSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICTargetPlatformSetting.java
new file mode 100644
index 00000000000..dd8e0f9dcb0
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICTargetPlatformSetting.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICTargetPlatformSetting extends ICSettingObject {
+ String[] getBinaryParserIds();
+
+ void setBinaryParserIds(String[] ids);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/WriteAccessException.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/WriteAccessException.java
new file mode 100644
index 00000000000..87cf202dcfc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/WriteAccessException.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model;
+
+public class WriteAccessException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4231477296650158708L;
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java
new file mode 100644
index 00000000000..65e0b8924e4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.model.IOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.core.runtime.IPath;
+
+public abstract class CBuildData extends CDataObject {
+ public final int getType() {
+ return ICSettingBase.SETTING_BUILD;
+ }
+
+ public abstract IPath getBuilderCWD();
+
+ public abstract void setBuilderCWD(IPath path);
+
+ public abstract ICOutputEntry[] getOutputDirectories();
+
+ public abstract void setOutputDirectories(ICOutputEntry[] entries);
+
+ public abstract String[] getErrorParserIDs();
+
+ public abstract void setErrorParserIDs(String[] ids);
+
+ public abstract IEnvironmentContributor getBuildEnvironmentContributor();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationData.java
new file mode 100644
index 00000000000..0276c4ec97e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationData.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+
+public abstract class CConfigurationData extends CDataObject {
+
+ protected CConfigurationData() {
+ }
+
+ public final int getType(){
+ return SETTING_CONFIGURATION;
+ }
+
+ public abstract CFolderData getRootFolderData();
+
+ public abstract CResourceData[] getResourceDatas();
+
+// public abstract CResourceData getResourceData(IPath path);
+
+ public abstract String getDescription();
+
+ public abstract void setDescription(String description);
+
+ public abstract void removeResourceData(CResourceData data) throws CoreException;
+
+ public abstract CFolderData createFolderData(IPath path, CFolderData base) throws CoreException;
+
+ public abstract CFileData createFileData(IPath path, CFileData base) throws CoreException;
+
+ public abstract CFileData createFileData(IPath path, CFolderData base, CLanguageData langData) throws CoreException;
+
+// public abstract CDataObject[] getChildrenOfKind(int kind);
+
+// public abstract CDataObject getChildById(String id);
+
+ public abstract CTargetPlatformData getTargetPlatformData();
+
+ public abstract IPath[] getSourcePaths();
+
+ public abstract void setSourcePaths(IPath[] paths);
+
+ public abstract CBuildData getBuildData();
+
+ public abstract ICdtVariablesContributor getBuildVariablesContributor();
+
+ public abstract void setName(String name);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java
new file mode 100644
index 00000000000..432698a0f25
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * the class is to be implemented by the Configuration data provider contributed via
+ * a org.eclipse.cdt.core.CConfigurationDataProvider extension point
+ *
+ */
+public abstract class CConfigurationDataProvider {
+ /**
+ * requests the Configuration Data to be loadded for the given ConfigurationDescription
+ */
+ public abstract CConfigurationData loadConfiguration(ICConfigurationDescription des) throws CoreException;
+
+ /**
+ * requests the Configuration Data to be created for the given ConfigurationDescription
+ * The method can be called in several caces:
+ * 1. When the new configuration is being created based upon the already existing one via
+ * theICProjectDescription.createConfiguration method call
+ * 2. When the configuration copy (clone) is being created for the copy description
+
+ * @param des
+ * @param base
+ * @param clone true indicates that the configuration copy (clone) is being created for
+ * the copy description.
+ * false indicates that the new configuration is being created based upon the already existing one via
+ * theICProjectDescription.createConfiguration method call
+ * @return
+ * @throws CoreException
+ */
+ public abstract CConfigurationData createConfiguration(ICConfigurationDescription des, CConfigurationData base, boolean clone) throws CoreException;
+
+ /**
+ * called to notify the provider that the configuration is removed
+ *
+ * @param des
+ * @param data
+ */
+ public abstract void removeConfiguration(ICConfigurationDescription des, CConfigurationData data);
+
+ /**
+ * called during the setProjectDescription operation to notify the provider that the configuration data
+ * is being applied.
+ * Provider would typically store all the necessary data configuration during this call.
+ *
+ * @param des
+ * @param base
+ * @return
+ * @throws CoreException
+ */
+ public abstract CConfigurationData applyConfiguration(ICConfigurationDescription des, CConfigurationData base) throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CDataObject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CDataObject.java
new file mode 100644
index 00000000000..81788143be5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CDataObject.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+
+public abstract class CDataObject implements ICSettingBase{
+ CDataObject(){
+ }
+
+ public abstract String getId();
+
+ public abstract String getName();
+
+ public abstract boolean isValid();
+/*
+ public CConfigurationData getConfiguration(){
+ return fConfiguration;
+ }
+
+ void setConfiguration(CConfigurationData cfg){
+ fConfiguration = cfg;
+ }
+*/
+ public abstract int getType();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFileData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFileData.java
new file mode 100644
index 00000000000..c1534424de7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFileData.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+
+public abstract class CFileData extends CResourceData {
+
+ public CFileData() {
+
+ }
+
+ public final int getType(){
+ return ICSettingBase.SETTING_FILE;
+ }
+
+ public abstract CLanguageData getLanguageData();
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFolderData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFolderData.java
new file mode 100644
index 00000000000..652411d52c9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CFolderData.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+
+public abstract class CFolderData extends CResourceData {
+
+ protected CFolderData() {
+
+ }
+
+ public final int getType(){
+ return ICSettingBase.SETTING_FOLDER;
+ }
+
+// public abstract CResourceData[] getNestedResourceDatas(int kind);
+
+// public abstract CResourceData getNestedResourceData(IPath path);
+
+// public abstract CDataObject[] getChildrenOfKind(int kind);
+
+// public abstract CDataObject getChildById(String id);
+
+ public abstract CLanguageData[] getLanguageDatas();
+
+ public abstract CLanguageData createLanguageDataForContentTypes(String languageId, String cTypesIds[]);
+
+ public abstract CLanguageData createLanguageDataForExtensions(String languageId, String extensions[]);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java
new file mode 100644
index 00000000000..f1c3ba6030f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public abstract class CLanguageData extends CDataObject {
+ protected CLanguageData() {
+
+ }
+
+// public abstract CDataObject[] getChildrenOfKind(int kind);
+
+// public abstract CDataObject getChildById(String id);
+
+ public final int getType() {
+ return SETTING_LANGUAGE;
+ }
+
+ public abstract String getLanguageId();
+
+ public abstract void setLanguageId(String id);
+
+ public abstract String[] getSourceContentTypeIds();
+
+ public abstract String[] getSourceExtensions();
+
+// public abstract IContentType getHeaderContentType();
+
+// public abstract String[] getHeaderExtensions();
+
+// public abstract void removeEntry(ICLanguageSettingEntry entry);
+
+// public abstract void addEntry(ICLanguageSettingEntry entry, int position);
+
+ public abstract ICLanguageSettingEntry[] getEntries(int kind);
+
+ public abstract void setEntries(int kind, ICLanguageSettingEntry entries[]);
+
+ public abstract int getSupportedEntryKinds();
+
+ public abstract void setSourceContentTypeIds(String ids[]);
+
+ public abstract void setSourceExtensions(String exts[]);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CResourceData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CResourceData.java
new file mode 100644
index 00000000000..cf65ec148dc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CResourceData.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.core.runtime.IPath;
+
+public abstract class CResourceData extends CDataObject {
+
+ CResourceData() {
+ }
+
+ public abstract IPath getPath();
+
+ public abstract boolean isExcluded();
+
+ public abstract void setPath(IPath path) ;
+
+ public abstract void setExcluded(boolean excluded);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CTargetPlatformData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CTargetPlatformData.java
new file mode 100644
index 00000000000..f83c73e0481
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CTargetPlatformData.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+
+public abstract class CTargetPlatformData extends CDataObject {
+ public final int getType(){
+ return ICSettingBase.SETTING_TARGET_PLATFORM;
+ }
+
+ public abstract String[] getBinaryParserIds();
+
+ public abstract void setBinaryParserIds(String[] ids);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/ICProjectConverter.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/ICProjectConverter.java
new file mode 100644
index 00000000000..a00781988a6
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/ICProjectConverter.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension;
+
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+
+public interface ICProjectConverter {
+ ICProjectDescription convertProject(IProject project, IProjectDescription eclipseProjDes, String oldOwnerId, ICProjectDescription des) throws CoreException;
+
+ boolean canConvertProject(IProject project, String oldOwnerId, ICProjectDescription des);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java
new file mode 100644
index 00000000000..8197091d1d1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDataFacroty.java
@@ -0,0 +1,116 @@
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.core.runtime.IPath;
+
+public class CDataFacroty {
+ public CConfigurationData createConfigurationdata(String id,
+ String name,
+ CConfigurationData base,
+ boolean clone){
+ if(clone){
+ id = base.getId();
+ } else if(id == null){
+ id = CDataUtil.genId(null);
+ }
+
+ return new CDefaultConfigurationData(id, name, base, this, clone);
+ }
+
+ public CFolderData createFolderData(CConfigurationData cfg,
+ CFolderData base,
+ boolean clone,
+ IPath path){
+ String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ return new CDefaultFolderData(id, path, base, cfg, this, clone);
+ }
+
+ public CFileData createFileData(CConfigurationData cfg,
+ CResourceData base,
+ CLanguageData lBase,
+ boolean clone,
+ IPath path){
+ String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ if(base.getType() == ICSettingBase.SETTING_FILE)
+ return new CDefaultFileData(id, path, (CFileData)base, cfg, this, clone);
+ return new CDefaultFileData(id, path, (CFolderData)base, lBase, cfg, this);
+ }
+
+ public CLanguageData createLanguageData(CConfigurationData cfg,
+ CResourceData rcBase,
+ CLanguageData base,
+ boolean clone){
+ String id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
+ return new CDefaultLanguageData(id, base);
+ }
+
+ public CLanguageData createLanguageData(CConfigurationData cfg,
+ CResourceData rcBase,
+ String languageId,
+ String[] rcTypes,
+ boolean isContentTypes){
+ String id = CDataUtil.genId(rcBase.getId());
+ return new CDefaultLanguageData(id, languageId, rcTypes, isContentTypes);
+ }
+
+ public CBuildData createBuildData(CConfigurationData cfg, CBuildData base, boolean clone){
+ String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ return new CDefaultBuildData(id, base);
+ }
+
+ public CTargetPlatformData createTargetPlatformData(CConfigurationData cfg, CTargetPlatformData base, boolean clone){
+ String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ return new CDefaultTargetPlatformData(id, base);
+ }
+
+ public boolean isModified(CDataObject data){
+ switch (data.getType()) {
+ case ICSettingBase.SETTING_CONFIGURATION:
+ return ((CDefaultConfigurationData)data).isModified();
+ case ICSettingBase.SETTING_FOLDER:
+ return ((CDefaultFolderData)data).isModified();
+ case ICSettingBase.SETTING_FILE:
+ return ((CDefaultFileData)data).isModified();
+ case ICSettingBase.SETTING_LANGUAGE:
+ return ((CDefaultLanguageData)data).isModified();
+ case ICSettingBase.SETTING_TARGET_PLATFORM:
+ return ((CDefaultTargetPlatformData)data).isModified();
+ case ICSettingBase.SETTING_BUILD:
+ return ((CDefaultBuildData)data).isModified();
+ }
+ return false;
+ }
+
+ public void setModified(CDataObject data, boolean modified){
+ switch (data.getType()) {
+ case ICSettingBase.SETTING_CONFIGURATION:
+ ((CDefaultConfigurationData)data).setModified(modified);
+ break;
+ case ICSettingBase.SETTING_FOLDER:
+ ((CDefaultFolderData)data).setModified(modified);
+ break;
+ case ICSettingBase.SETTING_FILE:
+ ((CDefaultFileData)data).setModified(modified);
+ break;
+ case ICSettingBase.SETTING_LANGUAGE:
+ ((CDefaultLanguageData)data).setModified(modified);
+ break;
+ case ICSettingBase.SETTING_TARGET_PLATFORM:
+ ((CDefaultTargetPlatformData)data).setModified(modified);
+ break;
+ case ICSettingBase.SETTING_BUILD:
+ ((CDefaultBuildData)data).setModified(modified);
+ break;
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultBuildData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultBuildData.java
new file mode 100644
index 00000000000..28d0c2eae9a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultBuildData.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import java.util.Arrays;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.core.runtime.IPath;
+
+public class CDefaultBuildData extends CBuildData {
+ protected IPath fCWD;
+ protected String[] fErrorParserIDs;
+ protected ICOutputEntry fOutputEntries[];
+ protected static final String[] EMPTY_STRING_ARRAY = new String[0];
+ protected static final ICOutputEntry[] EMPTY_OUTPUT_ENTRIES_ARRAY = new ICOutputEntry[0];
+ protected String fName;
+ protected String fId;
+ protected boolean fIsModified;
+// protected CConfigurationData fCfg;
+// private CDataFacroty fFactory;
+
+
+// public CDefaultBuildData(CConfigurationData cfg, CDataFacroty factory) {
+// fCfg = cfg;
+// if(factory == null)
+// factory = new CDataFacroty();
+// fFactory = factory;
+// }
+
+ public CDefaultBuildData(){
+
+ }
+
+ public CDefaultBuildData(String id, CBuildData base) {
+ fId = id;
+
+ copySettingsFrom(base);
+ }
+
+ protected void copySettingsFrom(CBuildData data){
+ if(data != null){
+ fName = data.getName();
+ fCWD = data.getBuilderCWD();
+ fErrorParserIDs = data.getErrorParserIDs();
+ fOutputEntries = data.getOutputDirectories();
+ }
+ }
+
+ public IPath getBuilderCWD() {
+ return fCWD;
+ }
+
+ public String[] getErrorParserIDs() {
+ if(fErrorParserIDs != null && fErrorParserIDs.length != 0)
+ return (String[])fErrorParserIDs.clone();
+ return EMPTY_STRING_ARRAY;
+ }
+
+ public ICOutputEntry[] getOutputDirectories() {
+ if(fOutputEntries != null && fOutputEntries.length != 0)
+ return (ICOutputEntry[])fOutputEntries.clone();
+ return EMPTY_OUTPUT_ENTRIES_ARRAY;
+ }
+
+ public void setBuilderCWD(IPath path) {
+ if(CDataUtil.objectsEqual(path, fCWD))
+ return;
+
+ fCWD = path;
+
+ setModified(true);
+ }
+
+ public void setErrorParserIDs(String[] ids) {
+ if(Arrays.equals(ids, fErrorParserIDs))
+ return;
+ if(ids != null && ids.length != 0)
+ fErrorParserIDs = (String[])ids.clone();
+ else
+ fErrorParserIDs = ids;
+
+ setModified(true);
+ }
+
+ public void setOutputDirectories(ICOutputEntry[] entries) {
+ if(Arrays.equals(entries, fOutputEntries))
+ return;
+
+ if(entries != null && entries.length != 0)
+ fOutputEntries = (ICOutputEntry[])entries.clone();
+ else
+ fOutputEntries = entries;
+
+ setModified(true);
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public boolean isValid() {
+ return getId() != null;
+ }
+
+ public IEnvironmentContributor getBuildEnvironmentContributor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isModified(){
+ return fIsModified;
+ }
+
+ public void setModified(boolean modified){
+ fIsModified = modified;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java
new file mode 100644
index 00000000000..445ae085d7f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultConfigurationData.java
@@ -0,0 +1,303 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import java.util.Arrays;
+import java.util.HashMap;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class CDefaultConfigurationData extends CConfigurationData {
+ protected String fDescription;
+ private HashMap fResourceDataMap = new HashMap();
+ protected CFolderData fRootFolderData;
+ protected String fName;
+ protected String fId;
+ protected CTargetPlatformData fTargetPlatformData;
+ protected CBuildData fBuildData;
+ protected IPath[] fSourcePaths;
+ private CDataFacroty fFactory;
+ protected boolean fIsModified;
+
+ protected CDefaultConfigurationData(CDataFacroty factory){
+ if(factory == null)
+ factory = new CDataFacroty();
+ fFactory = factory;
+ }
+
+// public CDefaultConfigurationData(String id, String name) {
+// this(id, name, (CDataFacroty)null);
+// }
+
+ public CDataFacroty getFactory(){
+ return fFactory;
+ }
+
+ public CDefaultConfigurationData(String id, String name, CDataFacroty factory) {
+ fId = id;
+ fName = name;
+ if(factory == null)
+ factory = new CDataFacroty();
+ fFactory = factory;
+ }
+
+// public CDefaultConfigurationData(String id, String name, CConfigurationData base) {
+// this(id, name, base, null);
+// }
+
+ public CDefaultConfigurationData(String id, String name, CConfigurationData base, CDataFacroty facroty, boolean clone) {
+ this(id, name, facroty);
+
+ copySettingsFrom(base, clone);
+ }
+
+ protected IPath standardizePath(IPath path){
+ return path.makeRelative().setDevice(null);
+ }
+
+ protected void addRcData(CResourceData data){
+ IPath path = standardizePath(data.getPath());
+ if(path.segmentCount() == 0){
+ if(data.getType() == ICSettingBase.SETTING_FOLDER)
+ fRootFolderData = (CFolderData)data;
+ else
+ return;
+ }
+ fResourceDataMap.put(path, data);
+ }
+
+ protected void removeRcData(IPath path){
+ path = standardizePath(path);
+ fResourceDataMap.remove(path);
+ if(path.segmentCount() == 0)
+ fRootFolderData = null;
+ }
+
+ protected void copySettingsFrom(CConfigurationData base, boolean clone){
+ if(base == null)
+ return;
+ fDescription = base.getDescription();
+ CResourceData[] rcDatas = base.getResourceDatas();
+
+ fTargetPlatformData = copyTargetPlatformData(base.getTargetPlatformData(), clone);
+ fSourcePaths = base.getSourcePaths();
+ fBuildData = copyBuildData(base.getBuildData(), clone);
+
+ CFolderData baseRootFolderData = base.getRootFolderData();
+ fRootFolderData = copyFolderData(baseRootFolderData.getPath(), baseRootFolderData, clone);
+ addRcData(fRootFolderData);
+
+ for(int i = 0; i < rcDatas.length; i++){
+ CResourceData rcData = rcDatas[i];
+ if(baseRootFolderData == rcData)
+ continue;
+
+ if(rcData instanceof CFolderData)
+ addRcData(copyFolderData(rcData.getPath(), (CFolderData)rcData, clone));
+ else if(rcData instanceof CFileData)
+ addRcData(copyFileData(rcData.getPath(), (CFileData)rcData, clone));
+ }
+ }
+
+ protected CFolderData copyFolderData(IPath path, CFolderData base, boolean clone){
+ return fFactory.createFolderData(this, base, clone, path);
+ }
+
+
+
+ protected CFileData copyFileData(IPath path, CFileData base, boolean clone){
+ return fFactory.createFileData(this, base, null, clone, path);
+ }
+
+ protected CFileData copyFileData(IPath path, CFolderData base, CLanguageData langData){
+ return fFactory.createFileData(this, base, langData, false, path);
+ }
+
+ protected CTargetPlatformData copyTargetPlatformData(CTargetPlatformData base, boolean clone){
+ return fFactory.createTargetPlatformData(this, base, clone);
+ }
+
+ protected CBuildData copyBuildData(CBuildData data, boolean clone){
+ return fFactory.createBuildData(this, data, clone);
+ }
+
+ public CFolderData createFolderData(IPath path, CFolderData base) throws CoreException{
+ CFolderData data = copyFolderData(path, base, false);
+ addRcData(data);
+
+ setModified(true);
+
+ return data;
+ }
+
+ public CFileData createFileData(IPath path, CFileData base) throws CoreException{
+ CFileData data = copyFileData(path, base, false);
+ addRcData(data);
+
+ setModified(true);
+
+ return data;
+ }
+
+ public CFileData createFileData(IPath path, CFolderData base, CLanguageData langData) throws CoreException{
+ CFileData data = copyFileData(path, base, langData);
+ addRcData(data);
+
+ setModified(true);
+
+ return data;
+ }
+
+ public String getDescription() {
+ return fDescription;
+ }
+
+ public void setDescription(String description) {
+ if(CDataUtil.objectsEqual(description, fDescription))
+ return;
+ fDescription = description;
+
+ setModified(true);
+ }
+
+ public CResourceData[] getResourceDatas() {
+ return (CResourceData[])fResourceDataMap.values().toArray(new CResourceData[fResourceDataMap.size()]);
+ }
+
+ public CFolderData getRootFolderData() {
+ return fRootFolderData;
+ }
+
+ public CFolderData createRootFolderData() throws CoreException{
+ if(fRootFolderData == null){
+ createFolderData(new Path(""), null);
+ }
+ return fRootFolderData;
+ }
+
+ public void removeResourceData(CResourceData data) throws CoreException {
+ if(data == getResourceData(data.getPath())){
+ IPath path = standardizePath(data.getPath());
+ removeRcData(path);
+
+ setModified(true);
+ }
+ }
+
+ public CResourceData getResourceData(IPath path){
+ path = standardizePath(path);
+ return (CResourceData)fResourceDataMap.get(path);
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public void setName(String name) {
+ if(CDataUtil.objectsEqual(name, fName))
+ return;
+ fName = name;
+ setModified(true);
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public boolean isValid() {
+ return getId() != null;
+ }
+
+ public CTargetPlatformData getTargetPlatformData() {
+ return fTargetPlatformData;
+ }
+
+ public IPath[] getSourcePaths() {
+ return fSourcePaths != null ? (IPath[])fSourcePaths.clone() : null;
+ }
+
+ public void setSourcePaths(IPath[] paths) {
+ if(Arrays.equals(paths, fSourcePaths))
+ return;
+
+ fSourcePaths = paths != null ? (IPath[])paths.clone() : null;
+ setModified(true);
+ }
+
+ public CBuildData getBuildData() {
+ return fBuildData;
+ }
+
+ public void initEmptyData() throws CoreException{
+ if(getRootFolderData() == null)
+ createRootFolderData();
+
+ if(getTargetPlatformData() == null)
+ createTargetPlatformData();
+
+ if(getBuildData() == null)
+ createBuildData();
+ }
+
+ public CTargetPlatformData createTargetPlatformData(){
+ fTargetPlatformData = copyTargetPlatformData(null, false);
+ setModified(true);
+ return fTargetPlatformData;
+ }
+
+ public CBuildData createBuildData(){
+ fBuildData = copyBuildData(null, false);
+ setModified(true);
+ return fBuildData;
+ }
+
+ public ICdtVariablesContributor getBuildVariablesContributor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isModified(){
+ if(fIsModified)
+ return true;
+
+ CResourceData[] rcDatas = getResourceDatas();
+ for(int i = 0; i < rcDatas.length; i++){
+ if(fFactory.isModified(rcDatas[i]))
+ return true;
+ }
+
+ return false;
+ }
+
+ public void setModified(boolean modified){
+ fIsModified = modified;
+
+ if(!modified){
+ CResourceData[] rcDatas = getResourceDatas();
+ for(int i = 0; i < rcDatas.length; i++){
+ fFactory.setModified(rcDatas[i], false);
+ }
+ }
+
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java
new file mode 100644
index 00000000000..60151869ece
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFileData.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.core.runtime.IPath;
+
+public class CDefaultFileData extends CFileData {
+ protected IPath fPath;
+ protected boolean fIsExcluded;
+ protected String fName;
+ protected String fId;
+ protected CLanguageData fLanguageData;
+ protected CConfigurationData fCfg;
+ private CDataFacroty fFactory;
+ protected boolean fIsModified;
+
+ public CDefaultFileData(CConfigurationData cfg, CDataFacroty factory) {
+ fCfg = cfg;
+ if(factory == null)
+ factory = new CDataFacroty();
+ fFactory = factory;
+ }
+
+ public CDefaultFileData(String id, IPath path, CConfigurationData cfg, CDataFacroty factory) {
+ this(cfg, factory);
+ fId = id;
+ fName = path.toString();
+ fPath = path;
+ }
+
+ public CDefaultFileData(String id, IPath path, CFileData base, CConfigurationData cfg, CDataFacroty factory, boolean clone) {
+ this(id, path, cfg, factory);
+
+ copyDataFrom(base, clone);
+ }
+
+ public CDefaultFileData(String id, IPath path, CFolderData base, CLanguageData baseLangData, CConfigurationData cfg, CDataFacroty factory) {
+ this(id, path, cfg, factory);
+
+ copyDataFrom(base, baseLangData);
+ }
+
+ protected void copyDataFrom(CFileData base, boolean clone){
+ fIsExcluded = base.isExcluded();
+ CLanguageData baseLanguageData = base.getLanguageData();
+ if(baseLanguageData != null)
+ fLanguageData = copyLanguageData(baseLanguageData, clone);
+ }
+
+ protected void copyDataFrom(CFolderData base, CLanguageData baseLanguageData){
+ fIsExcluded = base.isExcluded();
+ if(baseLanguageData != null)
+ fLanguageData = copyLanguageData(baseLanguageData, false);
+ }
+
+ protected CLanguageData copyLanguageData(CLanguageData data, boolean clone){
+ return fFactory.createLanguageData(fCfg, this, data, clone);
+ }
+
+
+ public IPath getPath() {
+ return fPath;
+ }
+
+ public boolean isExcluded() {
+ return fIsExcluded;
+ }
+
+ public void setExcluded(boolean excluded) {
+ if(excluded == fIsExcluded)
+ return;
+
+ fIsExcluded = excluded;
+ }
+
+ public void setPath(IPath path) {
+ fPath = path;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public void setName(String name) {
+ fName = name;
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public boolean isValid() {
+ return getId() != null;
+ }
+
+ public CLanguageData getLanguageData() {
+ return fLanguageData;
+ }
+
+ public boolean isModified(){
+ if(fIsModified)
+ return true;
+
+ return fFactory.isModified(fLanguageData);
+ }
+
+ public void setModified(boolean modified){
+ fIsModified = modified;
+
+ if(!modified)
+ fFactory.setModified(fLanguageData, false);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java
new file mode 100644
index 00000000000..e534cb54e45
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultFolderData.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.core.runtime.IPath;
+
+public class CDefaultFolderData extends CFolderData {
+ protected IPath fPath;
+ protected boolean fIsExcluded;
+ protected List fLanguageDatas = new ArrayList();
+ protected String fName;
+ protected String fId;
+ protected CConfigurationData fCfg;
+ private CDataFacroty fFactory;
+ protected boolean fIsModified;
+
+ public CDefaultFolderData(CConfigurationData cfg, CDataFacroty factory) {
+ fCfg = cfg;
+ if(factory == null)
+ factory = new CDataFacroty();
+ fFactory = factory;
+ }
+
+ public CDefaultFolderData(String id, IPath path, CConfigurationData cfg, CDataFacroty factory) {
+ this(cfg, factory);
+ fId = id;
+ fName = path.toString();
+ fPath = path;
+ }
+
+ public CDefaultFolderData(String id, IPath path, CFolderData base, CConfigurationData cfg, CDataFacroty factory, boolean clone) {
+ this(id, path, cfg, factory);
+
+ copyDataFrom(base, clone);
+ }
+
+ protected void copyDataFrom(CFolderData base, boolean clone){
+ if(base != null){
+ fIsExcluded = base.isExcluded();
+
+ CLanguageData lDatas[] = base.getLanguageDatas();
+ for(int i = 0; i < lDatas.length; i++){
+ fLanguageDatas.add(copyLanguageData(lDatas[i], clone));
+ }
+ }
+ }
+
+ protected CLanguageData copyLanguageData(CLanguageData base, boolean clone){
+ return fFactory.createLanguageData(fCfg, this, base, clone);
+ }
+
+ public CLanguageData[] getLanguageDatas() {
+ return (CLanguageData[])fLanguageDatas.toArray(new CLanguageData[fLanguageDatas.size()]);
+ }
+
+ public IPath getPath() {
+ return fPath;
+ }
+
+ public boolean isExcluded() {
+ return fIsExcluded;
+ }
+
+ public void setExcluded(boolean excluded) {
+ if(excluded == fIsExcluded)
+ return;
+
+ fIsExcluded = excluded;
+ setModified(true);
+ }
+
+ public void setPath(IPath path) {
+ if(CDataUtil.objectsEqual(path, fPath))
+ return;
+
+ fPath = path;
+ setModified(true);
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public boolean isValid() {
+ return getId() != null;
+ }
+
+ protected CLanguageData doCreateLanguageDataForContentTypes(String languageId,
+ String[] typesIds) {
+ return fFactory.createLanguageData(fCfg, this, languageId, typesIds, true);
+ }
+
+ protected CLanguageData doCreateLanguageDataForExtensions(String languageId,
+ String[] extensions) {
+ return fFactory.createLanguageData(fCfg, this, languageId, extensions, false);
+ }
+
+ public CLanguageData createLanguageDataForContentTypes(String languageId,
+ String[] typesIds) {
+ CLanguageData data = doCreateLanguageDataForContentTypes(languageId, typesIds);
+ if(data != null){
+ fLanguageDatas.add(data);
+ setModified(true);
+ }
+ return data;
+ }
+
+ public CLanguageData createLanguageDataForExtensions(String languageId,
+ String[] extensions) {
+ CLanguageData data = doCreateLanguageDataForExtensions(languageId, extensions);
+ if(data != null){
+ fLanguageDatas.add(data);
+ setModified(true);
+ }
+ return data;
+ }
+
+ public boolean isModified(){
+ if(fIsModified)
+ return true;
+
+ CLanguageData lDatas[] = getLanguageDatas();
+ for(int i = 0; i < lDatas.length; i++){
+ if(fFactory.isModified(lDatas[i]))
+ return true;
+ }
+
+ return false;
+ }
+
+ public void setModified(boolean modified){
+ fIsModified = modified;
+
+ if(!modified){
+ CLanguageData lDatas[] = getLanguageDatas();
+ for(int i = 0; i < lDatas.length; i++){
+ fFactory.setModified(lDatas[i], false);
+ }
+ }
+
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java
new file mode 100644
index 00000000000..137e4e5353d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultLanguageData.java
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import java.util.Arrays;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.EntryStore;
+import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
+
+public class CDefaultLanguageData extends CLanguageData {
+ protected String fName;
+ protected String fId;
+ protected String fLanguageId;
+ protected int fSupportedKinds;
+ protected String fSourceContentTypeIds[];
+ protected String fSourceExts[];
+// protected IContentType fHeaderContentType;
+// protected String fHeaderExts[];
+ protected EntryStore fStore;
+ public final static String[] EMPTY_STRING_ARRAY = new String[0];
+// protected CConfigurationData fCfg;
+// protected CResourceData fRcData;
+// private CDataFacroty fFactory;
+ protected boolean fIsModified;
+
+
+// public CDefaultLanguageData(CConfigurationData cfg, CResourceData rcData, CDataFacroty factory) {
+// fCfg = cfg;
+// fRcData = rcData;
+// if(factory == null)
+// factory = new CDataFacroty();
+// fFactory = factory;
+// }
+
+ protected CDefaultLanguageData(){
+ fStore = createStore();
+ }
+
+ public CDefaultLanguageData(String id,
+ String languageId,
+ String ids[],
+ boolean isContentTypes) {
+ fId = id;
+ fLanguageId = languageId;
+
+ if(isContentTypes)
+ fSourceContentTypeIds = (String[])ids.clone();
+ else
+ fSourceExts = (String[])ids.clone();
+
+ fStore = createStore();
+ }
+
+
+ public CDefaultLanguageData(String id, CLanguageData base) {
+ fId = id;
+ copySettingsFrom(base);
+ }
+
+ protected void copySettingsFrom(CLanguageData data){
+ fName = data.getName();
+ fLanguageId = data.getLanguageId();
+ fSupportedKinds = data.getSupportedEntryKinds();
+ fSourceContentTypeIds = data.getSourceContentTypeIds();
+ fSourceExts = data.getSourceExtensions();
+// fHeaderContentType = data.getHeaderContentType();
+// fHeaderExts = data.getHeaderExtensions();
+ fStore = createStore(data);
+ }
+
+ protected EntryStore createStore(CLanguageData data){
+ EntryStore store = createStore();
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ for(int i = 0; i < kinds.length; i++){
+ ICLanguageSettingEntry entries[] = data.getEntries(kinds[i]);
+ store.storeEntries(kinds[i], entries);
+ }
+ return store;
+ }
+
+ protected EntryStore createStore(){
+ return new EntryStore(true);
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public boolean isValid() {
+ return getId() != null;
+ }
+
+ public String getLanguageId() {
+ return fLanguageId;
+ }
+
+ public void setLanguageId(String id) {
+ if(CDataUtil.objectsEqual(id, fLanguageId))
+ return;
+
+ fLanguageId = id;
+
+ setModified(true);
+ }
+
+// public IContentType getHeaderContentType() {
+// return fHeaderContentType;
+// }
+
+// public String[] getHeaderExtensions() {
+// return fHeaderExts;
+// }
+/*
+ public ICLanguageSettingEntry[] getSettingEntries(int kind) {
+ return fStore.getEntries(kind);
+ List list = new ArrayList();
+
+ if((kinds & ICLanguageSettingEntry.INCLUDE_PATH) != 0) {
+ addLanguageEntries(ICLanguageSettingEntry.INCLUDE_PATH, list);
+ } else if((kinds & ICLanguageSettingEntry.INCLUDE_FILE) != 0) {
+ addLanguageEntries(ICLanguageSettingEntry.INCLUDE_FILE, list);
+ } else if((kinds & ICLanguageSettingEntry.MACRO) != 0) {
+ addLanguageEntries(ICLanguageSettingEntry.MACRO, list);
+ } else if((kinds & ICLanguageSettingEntry.MACRO_FILE) != 0) {
+ addLanguageEntries(ICLanguageSettingEntry.MACRO_FILE, list);
+ } else if((kinds & ICLanguageSettingEntry.LIBRARY_PATH) != 0) {
+ addLanguageEntries(ICLanguageSettingEntry.LIBRARY_PATH, list);
+ } else if((kinds & ICLanguageSettingEntry.LIBRARY_FILE) != 0) {
+ addLanguageEntries(ICLanguageSettingEntry.LIBRARY_FILE, list);
+ }
+
+ return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+
+ }
+
+ private List addLanguageEntries(int kind, List list){
+ ICLanguageSettingEntry entries[] = fStore.getEntries(kind);
+ for(int i = 0; i < entries.length; i++){
+ list.add(entries[i]);
+ }
+ return list;
+ }
+*/
+
+ public String[] getSourceContentTypeIds() {
+ if(fSourceContentTypeIds != null)
+ return fSourceContentTypeIds;
+ return EMPTY_STRING_ARRAY;
+ }
+
+ public String[] getSourceExtensions() {
+ if(fSourceExts != null)
+ return fSourceExts;
+ return EMPTY_STRING_ARRAY;
+ }
+
+ public int getSupportedEntryKinds() {
+ return fSupportedKinds;
+ }
+
+ public void setEntries(int kind, ICLanguageSettingEntry entries[]) {
+ fStore.storeEntries(kind, entries);
+
+ setModified(true);
+ }
+
+ public ICLanguageSettingEntry[] getEntries(int kind) {
+ return fStore.getEntries(kind);
+ }
+
+ public void setSourceContentTypeIds(String[] ids) {
+ if(Arrays.equals(ids, fSourceContentTypeIds))
+ return;
+
+ fSourceContentTypeIds = ids != null ?
+ (String[])ids.clone() : null;
+
+ setModified(true);
+ }
+
+ public void setSourceExtensions(String[] exts) {
+ if(Arrays.equals(exts, fSourceExts))
+ return;
+
+ fSourceExts = exts != null ?
+ (String[])exts.clone() : null;
+
+ setModified(true);
+ }
+
+ public boolean isModified(){
+ return fIsModified;
+ }
+
+ public void setModified(boolean modified){
+ fIsModified = modified;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultTargetPlatformData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultTargetPlatformData.java
new file mode 100644
index 00000000000..9875760c562
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CDefaultTargetPlatformData.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import java.util.Arrays;
+
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+
+public class CDefaultTargetPlatformData extends CTargetPlatformData {
+ protected String fName;
+ protected String fId;
+ protected String[] fBinaryParserIds;
+// protected CConfigurationData fCfg;
+// private CDataFacroty fFactory;
+ protected boolean fIsModified;
+
+// public CDefaultTargetPlatformData(CConfigurationData cfg, CDataFacroty factory) {
+// fCfg = cfg;
+// if(factory == null)
+// factory = new CDataFacroty();
+// fFactory = factory;
+// }
+
+ protected CDefaultTargetPlatformData(){
+
+ }
+
+ public CDefaultTargetPlatformData(String id, String name) {
+ fId = id;
+ fName = name;
+ }
+
+ public CDefaultTargetPlatformData(String id, CTargetPlatformData base) {
+ fId = id;
+
+ copyDataFrom(base);
+ }
+
+ protected void copyDataFrom(CTargetPlatformData base){
+ if(base != null){
+ fName = base.getName();
+
+ fBinaryParserIds = base.getBinaryParserIds();
+ }
+ }
+
+ public String[] getBinaryParserIds() {
+ if(fBinaryParserIds != null)
+ return (String[])fBinaryParserIds.clone();
+ return new String[0];
+ }
+
+ public void setBinaryParserIds(String[] ids) {
+ if(Arrays.equals(ids, fBinaryParserIds))
+ return;
+
+ if(ids != null)
+ fBinaryParserIds = (String[])ids.clone();
+ else
+ fBinaryParserIds = null;
+
+ setModified(true);
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public boolean isValid() {
+ return getId() != null;
+ }
+
+ public boolean isModified(){
+ return fIsModified;
+ }
+
+ public void setModified(boolean modified){
+ fIsModified = modified;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CResourceDataContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CResourceDataContainer.java
new file mode 100644
index 00000000000..87d3540c135
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/impl/CResourceDataContainer.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.extension.impl;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.runtime.IPath;
+
+public class CResourceDataContainer {
+ private PathSettingsContainer fRcDataContainer;
+ private boolean fIncludeCurrent;
+
+ public CResourceDataContainer(PathSettingsContainer pathSettings, boolean includeCurrent){
+ fRcDataContainer = pathSettings;
+ fIncludeCurrent = includeCurrent;
+ }
+
+ public void changeCurrentPath(IPath path, boolean moveChildren){
+ fRcDataContainer.setPath(path, moveChildren);
+ }
+
+ public IPath getCurrentPath(){
+ return fRcDataContainer.getPath();
+ }
+
+ public CResourceData getCurrentResourceData(){
+ return (CResourceData)fRcDataContainer.getValue();
+ }
+
+ public CResourceData getResourceData(IPath path, boolean exactPath) {
+ PathSettingsContainer cr = fRcDataContainer.getChildContainer(path, false, exactPath);
+ if(cr != null)
+ return (CResourceData)cr.getValue();
+ return null;
+ }
+
+ public CResourceData[] getResourceDatas() {
+ return getResourceDatas(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER);
+ }
+
+ public CResourceData[] getResourceDatas(final int kind) {
+ return getResourceDatas(kind, CResourceData.class);
+ }
+
+ public CResourceData[] getResourceDatas(int kind, Class clazz){
+ List list = getRcDataList(kind);
+
+ CResourceData datas[] = (CResourceData[])Array.newInstance(clazz, list.size());
+
+ return (CResourceData[])list.toArray(datas);
+ }
+
+ public List getRcDataList(final int kind){
+ final List list = new ArrayList();
+ fRcDataContainer.accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ if(fIncludeCurrent || container != fRcDataContainer){
+ CResourceData data = (CResourceData)container.getValue();
+ if((data.getType() & kind) == data.getType())
+ list.add(data);
+ }
+ return true;
+ }
+ });
+
+ return list;
+ }
+
+ public CResourceData getResourceData(IPath path, boolean exactPath, int kind){
+ CResourceData data = getResourceData(path, exactPath);
+ if(data != null && (data.getType() & kind) == data.getType())
+ return data;
+ return null;
+ }
+
+ public void removeResourceData(IPath path) {
+ fRcDataContainer.removeChildContainer(path);
+ }
+
+ public void addResourceData(CResourceData data){
+ PathSettingsContainer cr = fRcDataContainer.getChildContainer(data.getPath(), true, true);
+ cr.setValue(data);
+ }
+
+ public CFileData getFileData(IPath path){
+ return (CFileData)getResourceData(path, true, ICSettingBase.SETTING_FILE);
+ }
+
+ public CFolderData getFolderData(IPath path){
+ return (CFolderData)getResourceData(path, true, ICSettingBase.SETTING_FOLDER);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
new file mode 100644
index 00000000000..240c64bf1e7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.StringTokenizer;
+
+public class CDataUtil {
+ private static Random randomNumber;
+ public static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ public static int genRandomNumber(){
+ if (randomNumber == null) {
+ // Set the random number seed
+ randomNumber = new Random();
+ randomNumber.setSeed(System.currentTimeMillis());
+ }
+ int i = randomNumber.nextInt();
+ if (i < 0) {
+ i *= -1;
+ }
+ return i;
+ }
+
+ public static String genId(String baseId){
+ String suffix = new Integer(genRandomNumber()).toString();
+ return baseId != null ?
+ new StringBuffer(baseId).append(".").append(suffix).toString() //$NON-NLS-1$
+ : suffix;
+ }
+
+ public static boolean objectsEqual(Object o1, Object o2){
+ if(o1 == null)
+ return o2 == null;
+ return o1.equals(o2);
+ }
+
+ public static String arrayToString(String[] array, String separator){
+ if(array == null)
+ return null;
+ if(array.length == 0)
+ return "";
+ if(array.length == 1)
+ return array[0];
+ StringBuffer buf = new StringBuffer();
+ buf.append(array[0]);
+ for(int i = 1; i < array.length; i++){
+ buf.append(separator).append(array[i]);
+ }
+
+ return buf.toString();
+ }
+
+ public static String[] stringToArray(String string, String separator){
+ if(string == null)
+ return null;
+ if(string.length() == 0)
+ return EMPTY_STRING_ARRAY;
+ StringTokenizer t = new StringTokenizer(string, separator);
+ List list = new ArrayList(t.countTokens());
+ while (t.hasMoreElements()) {
+ list.add(t.nextToken());
+ }
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java
new file mode 100644
index 00000000000..0a47af8f568
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CEntriesSet.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class CEntriesSet {
+ private HashMap fEntriesMap = new HashMap();
+
+ public CEntriesSet(){
+ }
+
+ public CEntriesSet(List list){
+ setEntries(list);
+ }
+
+ public CEntriesSet(ICLanguageSettingEntry entries[]){
+ setEntries(entries);
+ }
+
+ public int size() {
+ return fEntriesMap.size();
+ }
+
+/* public ICLanguageSettingEntry removeEntry(String name) {
+ ICLanguageSettingEntry entry = (ICLanguageSettingEntry)fMap.remove(name);
+ if(entry != null)
+ fList.remove(entry);
+ return entry;
+ }
+*/
+ public ICLanguageSettingEntry[] toArray() {
+ return (ICLanguageSettingEntry[])fEntriesMap.values().toArray(new ICLanguageSettingEntry[fEntriesMap.size()]);
+ }
+
+ protected Object getKey(ICLanguageSettingEntry entry){
+ return entry;
+ }
+
+ public ICLanguageSettingEntry addEntry(ICLanguageSettingEntry entry) {
+ return (ICLanguageSettingEntry)fEntriesMap.put(getKey(entry), entry);
+ }
+
+ public void clear() {
+ fEntriesMap.clear();
+ }
+
+ public void setEntries(List list) {
+ clear();
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ Object obj = iter.next();
+ if(obj instanceof ICLanguageSettingEntry){
+ ICLanguageSettingEntry entry = (ICLanguageSettingEntry)obj;
+ addEntry(entry);
+ }
+ }
+ }
+
+ public void setEntries(ICLanguageSettingEntry[] entries) {
+ clear();
+ for(int i = 0; i < entries.length; i++){
+ ICLanguageSettingEntry entry = entries[i];
+ if(entry != null){
+ addEntry(entry);
+ }
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CExtensionUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CExtensionUtil.java
new file mode 100644
index 00000000000..3d83e90ad42
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CExtensionUtil.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+
+public class CExtensionUtil {
+ public static IConfigurationElement getFirstConfigurationElement(ICConfigExtensionReference ref, String name, boolean caseSensitive) throws CoreException {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ref.getExtensionPoint());
+ IExtension extension = extensionPoint.getExtension(ref.getID());
+ if (extension == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+ CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound"), null)); //$NON-NLS-1$
+ }
+ IConfigurationElement element[] = extension.getConfigurationElements();
+ for (int i = 0; i < element.length; i++) {
+ if (caseSensitive ? element[i].getName().equals(name) :
+ element[i].getName().equalsIgnoreCase(name)) {
+ return element[i];
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/Comparator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/Comparator.java
new file mode 100644
index 00000000000..62ec65396b7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/Comparator.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+public class Comparator {
+
+ public boolean equal(Object o1, Object o2){
+ if(o1 == null)
+ return o2 == null;
+ return o1.equals(o2);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryNameKey.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryNameKey.java
new file mode 100644
index 00000000000..c8b8a81ad1f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryNameKey.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.internal.core.settings.model.ACLanguageSettingEntry;
+
+public class EntryNameKey {
+ ICLanguageSettingEntry fEntry;
+
+ public EntryNameKey(ICLanguageSettingEntry entry){
+ fEntry = entry;
+ }
+
+ public boolean equals(Object obj) {
+ if(this == obj)
+ return true;
+
+ if(!(obj instanceof EntryNameKey))
+ return false;
+ return fEntry.equalsByName(((EntryNameKey)obj).fEntry);
+ }
+
+ public int hashCode() {
+ return ((ACLanguageSettingEntry)fEntry).codeForNameKey();
+ }
+
+ public ICLanguageSettingEntry getEntry(){
+ return fEntry;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java
new file mode 100644
index 00000000000..b2ff499358e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/EntryStore.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.ICIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.ICMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICMacroFileEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+public class EntryStore {
+ private KindBasedStore fStore = new KindBasedStore();
+ private boolean fPreserveReadOnly;
+
+ public EntryStore(){
+ this(false);
+ }
+
+ public EntryStore(boolean preserveReadOnly){
+ fPreserveReadOnly = preserveReadOnly;
+ }
+
+ public EntryStore(EntryStore base, boolean preserveReadOnly){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ ArrayList list = (ArrayList)fStore.get(kind);
+ if(list != null)
+ fStore.put(kind, (ArrayList)list.clone());
+ }
+ fPreserveReadOnly = preserveReadOnly;
+ }
+
+ public ICLanguageSettingEntry[] getEntries(){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ List result = new ArrayList();
+ List list;
+ for(int i = 0; i < kinds.length; i++){
+ list = (List)fStore.get(kinds[i]);
+ if(list != null)
+ result.addAll(list);
+ }
+
+ return (ICLanguageSettingEntry[])result.toArray(new ICLanguageSettingEntry[result.size()]);
+ }
+
+ public ICLanguageSettingEntry[] getEntries(int kind){
+ List list = getEntriesList(kind);
+// if(list != null){
+ if(list == null)
+ list = new ArrayList(0);
+ switch(kind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ return (ICLanguageSettingEntry[])list.toArray(new ICIncludePathEntry[list.size()]);
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return (ICLanguageSettingEntry[])list.toArray(new ICIncludeFileEntry[list.size()]);
+ case ICLanguageSettingEntry.MACRO:
+ return (ICLanguageSettingEntry[])list.toArray(new ICMacroEntry[list.size()]);
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return (ICLanguageSettingEntry[])list.toArray(new ICMacroFileEntry[list.size()]);
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ return (ICLanguageSettingEntry[])list.toArray(new ICLibraryPathEntry[list.size()]);
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ return (ICLanguageSettingEntry[])list.toArray(new ICLibraryFileEntry[list.size()]);
+ default:
+ throw new IllegalArgumentException();
+ }
+// }
+// return null;
+ }
+
+ public List getEntriesList(int kind){
+ List list = getEntriesList(kind, false);
+ if(list != null)
+ return new ArrayList(list);
+ return new ArrayList(0);
+ }
+
+ private void setEntriesList(int kind, List list){
+ fStore.put(kind, list);
+ }
+
+ private List getEntriesList(int kind, boolean create){
+ List list = (List)fStore.get(kind);
+ if(list == null && create){
+ fStore.put(kind, list = new ArrayList());
+ }
+ return list;
+ }
+
+// public void storeEntries(int kind, List list){
+// fStore.put(kind, list);
+// }
+
+ public void addEntry(int pos, ICLanguageSettingEntry entry){
+ List list = getEntriesList(entry.getKind(), true);
+ if(pos >= list.size())
+ list.add(entry);
+ else
+ list.add(pos ,entry);
+ }
+
+ public void storeEntries(int kind, ICLanguageSettingEntry[] entries){
+ List newList = new ArrayList();
+ newList.addAll(Arrays.asList(entries));
+ if(fPreserveReadOnly){
+ List oldList = getEntriesList(kind, false);
+ if(oldList != null){
+ Set ro = getReadOnlySet(oldList);
+ ro.removeAll(newList);
+ for(Iterator iter = oldList.iterator(); iter.hasNext();){
+ Object o = iter.next();
+ if(ro.contains(o))
+ newList.add(o);
+ }
+ }
+ }
+ setEntriesList(kind, newList);
+ }
+
+ private Set getReadOnlySet(List entries){
+ Set set = new HashSet();
+ for(Iterator iter = entries.iterator(); iter.hasNext();){
+ ICSettingEntry entry = (ICSettingEntry)iter.next();
+ if(entry.isReadOnly())
+ set.add(entry);
+ }
+ return set;
+ }
+
+ public void addEntry(ICLanguageSettingEntry entry){
+ List list = getEntriesList(entry.getKind(), true);
+ list.add(entry);
+ }
+
+ public void trimToSize(){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ for(int i = 0; i < kinds.length; i++){
+ ArrayList list = (ArrayList)fStore.get(kinds[i]);
+ if(list != null)
+ list.trimToSize();
+ }
+ }
+
+/* public void addEntries(int kind, ICLanguageSettingEntry[] entries){
+ List list = getEntriesList(kind, true);
+ if(list.size() == 0){
+ for(int i = 0; i < entries.length; i++){
+ list.add(entries[i]);
+ }
+ } else {
+ Map map = createNameToEntryMap(list);
+ for(int i = 0; i < entries.length; i++){
+ rtrtrtrrtrt;
+ }
+ }
+
+ }
+
+ private Map createNameToEntryMap(List entries){
+ Map map = new HashMap();
+
+ for(Iterator iter = entries.iterator(); iter.hasNext();){
+ ICLanguageSettingEntry entry = (ICLanguageSettingEntry)iter.next();
+ map.put(entry.getName(), entry);
+ }
+ return map;
+ }
+*/
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IKindBasedInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IKindBasedInfo.java
new file mode 100644
index 00000000000..161ae4b9ecb
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IKindBasedInfo.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+public interface IKindBasedInfo {
+ int getKind();
+
+ Object getInfo();
+
+ Object setInfo(Object newInfo);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerListener.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerListener.java
new file mode 100644
index 00000000000..88e79942335
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerListener.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface IPathSettingsContainerListener {
+ void containerAdded(PathSettingsContainer container);
+
+ void aboutToRemove(PathSettingsContainer container);
+
+ void containerValueChanged(PathSettingsContainer container, Object oldValue);
+
+ void containerPathChanged(PathSettingsContainer container, IPath oldPath, boolean childrenMoved);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerVisitor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerVisitor.java
new file mode 100644
index 00000000000..e4a90eddda1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/IPathSettingsContainerVisitor.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+public interface IPathSettingsContainerVisitor {
+ boolean visit(PathSettingsContainer container);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java
new file mode 100644
index 00000000000..af985b55760
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+public class KindBasedStore implements Cloneable {
+ private static final int INDEX_INCLUDE_PATH = 0;
+ private static final int INDEX_INCLUDE_FILE = 1;
+ private static final int INDEX_MACRO = 2;
+ private static final int INDEX_MACRO_FILE = 3;
+ private static final int INDEX_LIBRARY_PATH = 4;
+ private static final int INDEX_LIBRARY_FILE = 5;
+ private static final int LANG_STORAGE_SIZE = 6;
+
+ private static final int INDEX_SOURCE_PATH = 6;
+ private static final int INDEX_OUPUT_PATH = 7;
+ private static final int ALL_STORAGE_SIZE = 8;
+
+ private static final int LANG_ENTRY_KINDS[] = new int[]{
+ ICLanguageSettingEntry.INCLUDE_PATH,
+ ICLanguageSettingEntry.INCLUDE_FILE,
+ ICLanguageSettingEntry.MACRO,
+ ICLanguageSettingEntry.MACRO_FILE,
+ ICLanguageSettingEntry.LIBRARY_PATH,
+ ICLanguageSettingEntry.LIBRARY_FILE,
+ };
+
+// private static final int INEXISTENT_INDEX = -1;
+
+ private Object[] fEntryStorage;
+
+ public KindBasedStore(){
+ this(true);
+ }
+
+ public KindBasedStore(boolean langOnly){
+ if(langOnly)
+ fEntryStorage = new Object[LANG_STORAGE_SIZE];
+ else
+ fEntryStorage = new Object[ALL_STORAGE_SIZE];
+ }
+
+ private int kindToIndex(int kind){
+ switch (kind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ return INDEX_INCLUDE_PATH;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return INDEX_INCLUDE_FILE;
+ case ICLanguageSettingEntry.MACRO:
+ return INDEX_MACRO;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return INDEX_MACRO_FILE;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ return INDEX_LIBRARY_PATH;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ return INDEX_LIBRARY_FILE;
+ case ICSettingEntry.SOURCE_PATH:
+ if(INDEX_SOURCE_PATH < fEntryStorage.length)
+ return INDEX_SOURCE_PATH;
+ break;
+ case ICSettingEntry.OUTPUT_PATH:
+ if(INDEX_OUPUT_PATH < fEntryStorage.length)
+ return INDEX_OUPUT_PATH;
+ break;
+ }
+ throw new IllegalArgumentException("illegal kind");
+ }
+
+ public static int[] getLanguageEntryKinds(){
+ return (int[])LANG_ENTRY_KINDS.clone();
+ }
+
+ private int indexToKind(int index){
+ switch (index){
+ case INDEX_INCLUDE_PATH:
+ return ICLanguageSettingEntry.INCLUDE_PATH;
+ case INDEX_INCLUDE_FILE:
+ return ICLanguageSettingEntry.INCLUDE_FILE;
+ case INDEX_MACRO:
+ return ICLanguageSettingEntry.MACRO;
+ case INDEX_MACRO_FILE:
+ return ICLanguageSettingEntry.MACRO_FILE;
+ case INDEX_LIBRARY_PATH:
+ return ICLanguageSettingEntry.LIBRARY_PATH;
+ case INDEX_LIBRARY_FILE:
+ return ICLanguageSettingEntry.LIBRARY_FILE;
+ case INDEX_SOURCE_PATH:
+ return ICSettingEntry.SOURCE_PATH;
+ case INDEX_OUPUT_PATH:
+ return ICSettingEntry.OUTPUT_PATH;
+ }
+ throw new IllegalArgumentException("illegal kind");
+ }
+ public Object get(int kind){
+ return fEntryStorage[kindToIndex(kind)];
+ }
+
+ public Object put(int kind, Object object){
+ int index = kindToIndex(kind);
+ Object old = fEntryStorage[index];
+ fEntryStorage[index] = object;
+ return old;
+ }
+
+ private class KindBasedInfo implements IKindBasedInfo {
+ int fIdex;
+ int fKind;
+
+ KindBasedInfo(int num, boolean isKind){
+ if(isKind){
+ fIdex = kindToIndex(num);
+ fKind = num;
+ } else {
+ fIdex = num;
+ fKind = indexToKind(num);
+ }
+ }
+
+ public Object getInfo() {
+ return fEntryStorage[fIdex];
+ }
+
+ public int getKind() {
+ return fKind;
+ }
+
+ public Object setInfo(Object newInfo) {
+ Object old = fEntryStorage[fIdex];
+ fEntryStorage[fIdex] = newInfo;
+ return old;
+ }
+
+ }
+
+ public IKindBasedInfo[] getContents(){
+ IKindBasedInfo infos[] = new IKindBasedInfo[fEntryStorage.length];
+ for(int i = 0; i < fEntryStorage.length; i++){
+ infos[i] = new KindBasedInfo(i, false);
+ }
+ return infos;
+ }
+
+ public IKindBasedInfo getInfo(int kind){
+ return new KindBasedInfo(kind, true);
+ }
+
+ public void clear(){
+ for(int i = 0; i < fEntryStorage.length; i++){
+ fEntryStorage[i] = null;
+ }
+ }
+
+ public Object clone() {
+ try {
+ KindBasedStore clone = (KindBasedStore)super.clone();
+ clone.fEntryStorage = (Object[])fEntryStorage.clone();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ }
+ return null;
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java
new file mode 100644
index 00000000000..b2770fd1173
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
+import org.eclipse.cdt.core.settings.model.COutputEntry;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class LanguageSettingEntriesSerializer {
+ public static final String ELEMENT_ENTRY = "entry";
+ public static final String ATTRIBUTE_KIND = "kind";
+ public static final String ATTRIBUTE_NAME = "name";
+ public static final String ATTRIBUTE_VALUE = "value";
+ public static final String ATTRIBUTE_FLAGS = "flags";
+ public static final String ATTRIBUTE_EXCLUDING = "excluding";
+
+// public static final String ATTRIBUTE_FULL_PATH = "fullPath";
+// public static final String ATTRIBUTE_LOCATION = "location";
+
+
+ public static final String INCLUDE_PATH = "includePath";
+ public static final String INCLUDE_FILE = "includeFile";
+ public static final String MACRO = "macro";
+ public static final String MACRO_FILE = "macroFile";
+ public static final String LIBRARY_PATH = "libraryPath";
+ public static final String LIBRARY_FILE = "libraryFile";
+ public static final String SOURCE_PATH = "sourcePath";
+ public static final String OUTPUT_PATH = "outputPath";
+
+ public static final String BUILTIN = "BUILTIN";
+ public static final String READONLY = "READONLY";
+ public static final String LOCAL = "LOCAL";
+ public static final String VALUE_WORKSPACE_PATH = "VALUE_WORKSPACE_PATH";
+ public static final String RESOLVED = "RESOLVED";
+
+ public static final String FLAGS_SEPARATOR = "|";
+
+ public static ICLanguageSettingEntry[] loadEntries(ICStorageElement el){
+ List list = loadEntriesList(el);
+ return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ }
+
+ public static List loadEntriesList(ICStorageElement el){
+ ICStorageElement children[] = el.getChildren();
+ ICStorageElement child;
+ List list = new ArrayList();
+ ICLanguageSettingEntry entry;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ if(ELEMENT_ENTRY.equals(child.getName())){
+ entry = loadEntry(child);
+ if(entry != null)
+ list.add(entry);
+ }
+ }
+ return list;
+ }
+
+ public static ICLanguageSettingEntry loadEntry(ICStorageElement el){
+ int kind = stringToKind(el.getAttribute(ATTRIBUTE_KIND));
+ if(kind == 0)
+ return null;
+
+ int flags = composeFlags(el.getAttribute(ATTRIBUTE_FLAGS));
+ String name = el.getAttribute(ATTRIBUTE_NAME);
+
+
+ switch(kind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ return new CIncludePathEntry(name, flags);
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return new CIncludeFileEntry(name, flags);
+ case ICLanguageSettingEntry.MACRO:
+ String value = el.getAttribute(ATTRIBUTE_VALUE);
+ return new CMacroEntry(name, value, flags);
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return new CMacroFileEntry(name, flags);
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ return new CLibraryPathEntry(name, flags);
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ return new CLibraryFileEntry(name, flags);
+ case ICLanguageSettingEntry.OUTPUT_PATH:
+ return new COutputEntry(name, loadExclusions(el), flags);
+ case ICLanguageSettingEntry.SOURCE_PATH:
+ return new CSourceEntry(name, loadExclusions(el), flags);
+ }
+ return null;
+ }
+
+ private static IPath[] loadExclusions(ICStorageElement el){
+ String attr = el.getAttribute(ATTRIBUTE_EXCLUDING);
+ if(attr != null){
+ String[] strs = CDataUtil.stringToArray(attr, FLAGS_SEPARATOR);
+ IPath[] paths = new IPath[strs.length];
+ for(int i = 0; i < strs.length; i++){
+ paths[i] = new Path(strs[i]);
+ }
+ return paths;
+ }
+ return null;
+ }
+
+ private static void storeExclusions(ICStorageElement el, IPath[] paths){
+ if(paths == null || paths.length == 0)
+ return;
+
+ String[] strs = new String[paths.length];
+ for(int i = 0; i < strs.length; i++){
+ strs[i] = paths[i].toString();
+ }
+
+ String attr = CDataUtil.arrayToString(strs, FLAGS_SEPARATOR);
+ el.setAttribute(ATTRIBUTE_EXCLUDING, attr);
+ }
+
+ public static void serializeEntries(ICSettingEntry entries[], ICStorageElement element){
+ ICStorageElement child;
+ for(int i = 0; i < entries.length; i++){
+ child = element.createChild(ELEMENT_ENTRY);
+ serializeEntry(entries[i], child);
+ }
+ }
+
+ public static void serializeEntry(ICSettingEntry entry, ICStorageElement element){
+ String kind = kindToString(entry.getKind());
+ String flags = composeFlagsString(entry.getFlags());
+ String name = entry.getName();
+ element.setAttribute(ATTRIBUTE_KIND, kind);
+ element.setAttribute(ATTRIBUTE_FLAGS, flags);
+ element.setAttribute(ATTRIBUTE_NAME, name);
+ switch(entry.getKind()){
+ case ICLanguageSettingEntry.MACRO:
+ String value = entry.getValue();
+ element.setAttribute(ATTRIBUTE_VALUE, value);
+ break;
+ case ICLanguageSettingEntry.SOURCE_PATH:
+ case ICLanguageSettingEntry.OUTPUT_PATH:
+ IPath paths[] = ((ICExclusionPatternPathEntry)entry).getExclusionPatterns();
+ storeExclusions(element, paths);
+ break;
+ }
+ }
+
+ static String kindToString(int kind){
+ switch(kind){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ return INCLUDE_PATH;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return INCLUDE_FILE;
+ case ICLanguageSettingEntry.MACRO:
+ return MACRO;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return MACRO_FILE;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ return LIBRARY_PATH;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ return LIBRARY_FILE;
+ case ICLanguageSettingEntry.SOURCE_PATH:
+ return SOURCE_PATH;
+ case ICLanguageSettingEntry.OUTPUT_PATH:
+ return OUTPUT_PATH;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ static int stringToKind(String kind){
+ if(INCLUDE_PATH.equals(kind))
+ return ICLanguageSettingEntry.INCLUDE_PATH;
+ if(INCLUDE_FILE.equals(kind))
+ return ICLanguageSettingEntry.INCLUDE_FILE;
+ if(MACRO.equals(kind))
+ return ICLanguageSettingEntry.MACRO;
+ if(MACRO_FILE.equals(kind))
+ return ICLanguageSettingEntry.MACRO_FILE;
+ if(LIBRARY_PATH.equals(kind))
+ return ICLanguageSettingEntry.LIBRARY_PATH;
+ if(LIBRARY_FILE.equals(kind))
+ return ICLanguageSettingEntry.LIBRARY_FILE;
+ if(SOURCE_PATH.equals(kind))
+ return ICLanguageSettingEntry.SOURCE_PATH;
+ if(OUTPUT_PATH.equals(kind))
+ return ICLanguageSettingEntry.OUTPUT_PATH;
+ return 0;
+// throw new UnsupportedOperationException();
+ }
+
+ private static String composeFlagsString(int flags){
+ StringBuffer buf = new StringBuffer();
+ if((flags & ICLanguageSettingEntry.BUILTIN) != 0){
+ buf.append(BUILTIN);
+ }
+ if((flags & ICLanguageSettingEntry.READONLY) != 0){
+ if(buf.length() != 0)
+ buf.append(FLAGS_SEPARATOR);
+
+ buf.append(READONLY);
+ }
+ if((flags & ICLanguageSettingEntry.LOCAL) != 0){
+ if(buf.length() != 0)
+ buf.append(FLAGS_SEPARATOR);
+
+ buf.append(LOCAL);
+ }
+ if((flags & ICLanguageSettingEntry.VALUE_WORKSPACE_PATH) != 0){
+ if(buf.length() != 0)
+ buf.append(FLAGS_SEPARATOR);
+
+ buf.append(VALUE_WORKSPACE_PATH);
+ }
+ if((flags & ICLanguageSettingEntry.RESOLVED) != 0){
+ if(buf.length() != 0)
+ buf.append(FLAGS_SEPARATOR);
+
+ buf.append(RESOLVED);
+ }
+ return buf.toString();
+ }
+
+ private static int composeFlags(String flagsString){
+ if(flagsString == null || flagsString.length() == 0)
+ return 0;
+
+ StringTokenizer tokenizer = new StringTokenizer(flagsString, FLAGS_SEPARATOR);
+ int flags = 0;
+ String f;
+ while(tokenizer.hasMoreElements()){
+ f = tokenizer.nextToken();
+ if(BUILTIN.equals(f))
+ flags |= ICLanguageSettingEntry.BUILTIN;
+ if(READONLY.equals(f))
+ flags |= ICLanguageSettingEntry.READONLY;
+ if(LOCAL.equals(f))
+ flags |= ICLanguageSettingEntry.LOCAL;
+ if(VALUE_WORKSPACE_PATH.equals(f))
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ if(RESOLVED.equals(f))
+ flags |= ICLanguageSettingEntry.RESOLVED;
+ }
+
+ return flags;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ListComparator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ListComparator.java
new file mode 100644
index 00000000000..7d4f24c4020
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ListComparator.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class ListComparator {
+ private static Comparator fDefaultComparator;
+
+ public static Comparator getDefaultComparator(){
+ if(fDefaultComparator == null)
+ fDefaultComparator = new Comparator();
+ return fDefaultComparator;
+
+ }
+ public static List[] compare(Object a1[], Object a2[]){
+ return compare(a1, a2, getDefaultComparator());
+ }
+
+ public static List[] compare(Object a1[], Object a2[], Comparator c){
+ List added = getAdded(a1, a2, c);
+ List removed = getAdded(a2, a1, c);
+
+ if(added == null && removed == null)
+ return null;
+
+ return new List[]{added, removed};
+ }
+
+ public static List getAdded(Object a1[], Object a2[]){
+ return getAdded(a1, a2, getDefaultComparator());
+ }
+
+ public static List getAdded(Object a1[], Object a2[], Comparator c){
+ if(a1 == null || a1.length == 0)
+ return null;
+ if(a2 == null || a2.length == 0){
+ List list = new ArrayList(a1.length);
+ for(int i = 0; i < a1.length; i++){
+ list.add(a1[i]);
+ }
+ return list;
+ }
+
+ List list = new ArrayList(a1.length);
+ Object o1;
+ for(int i = 0; i < a1.length; i++){
+ o1 = a1[i];
+ for(int j = 0; j < a2.length; j++){
+ if(!c.equal(o1, a2[j]))
+ list.add(o1);
+ }
+ }
+
+ return list.size() != 0 ? list : null;
+ }
+
+ public static boolean match(Object a1[], Object a2[], Comparator c){
+ if(a1 == null)
+ return a2 == null;
+
+ if(a2 == null)
+ return false;
+
+ if(a1.length != a2.length)
+ return false;
+
+ int size = a1.length;
+ List list = new ArrayList(Arrays.asList(a1));
+ List otherList = new ArrayList(Arrays.asList(a2));
+ for(int i = size - 1; i >= 0; i--){
+ Object o1 = list.remove(i);
+ int j = i;
+ for(; j >= 0; j--){
+ if(c.equal(o1, otherList.get(j))){
+ otherList.remove(j);
+ break;
+ }
+ }
+
+ if(j < 0)
+ return false;
+ }
+
+ return true;
+ }
+
+ public static int indexOf(Object o, Object[] a){
+ return indexOf(o, a, getDefaultComparator());
+ }
+
+ public static int indexOf(Object o, Object[] a, Comparator c){
+ for(int i = 0; i < a.length; i++){
+ if(c.equal(a[i], o))
+ return i;
+ }
+ return -1;
+ }
+
+ public static boolean haveMatches(Object[] a1 , Object[] a2){
+ return haveMatches(a1, a2, getDefaultComparator());
+ }
+
+ public static boolean haveMatches(Object[] a1 , Object[] a2, Comparator c){
+ for(int i = 0; i < a1.length; i++){
+ if(indexOf(a1[i], a2, c) != -1)
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfo.java
new file mode 100644
index 00000000000..e2fbfbf90e0
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfo.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.List;
+
+public class PathEntryResolveInfo {
+ private PathEntryResolveInfoElement[] fElements;
+
+ public PathEntryResolveInfo(List list){
+ if(list != null){
+ fElements = (PathEntryResolveInfoElement[])list.toArray(new PathEntryResolveInfoElement[list.size()]);
+ } else {
+ fElements = new PathEntryResolveInfoElement[0];
+ }
+ }
+
+ public PathEntryResolveInfoElement[] getElements(){
+ return (PathEntryResolveInfoElement[])fElements.clone();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfoElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfoElement.java
new file mode 100644
index 00000000000..4f5c50ee6d1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryResolveInfoElement.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.IPathEntry;
+
+public class PathEntryResolveInfoElement {
+ private IPathEntry fRawEntry;
+ private IPathEntry[] fResolvedEntries;
+
+ public PathEntryResolveInfoElement(IPathEntry rawEntry, IPathEntry resolvedEntry){
+ fRawEntry = rawEntry;
+ if(resolvedEntry != null)
+ fResolvedEntries = new IPathEntry[]{resolvedEntry};
+ else
+ fResolvedEntries = new IPathEntry[0];
+ }
+
+ public PathEntryResolveInfoElement(IPathEntry rawEntry, List resolvedList){
+ fRawEntry = rawEntry;
+ if(resolvedList != null){
+ fResolvedEntries = new IPathEntry[resolvedList.size()];
+ resolvedList.toArray(fResolvedEntries);
+ }
+ }
+
+ public IPathEntry getRawEntry(){
+ return fRawEntry;
+ }
+
+ public IPathEntry[] getResolvedEntries(){
+ if(fResolvedEntries == null)
+ return new IPathEntry[0];
+ return (IPathEntry[])fResolvedEntries.clone();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java
new file mode 100644
index 00000000000..e0b440e023c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java
@@ -0,0 +1,2231 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.cdt.core.model.IIncludeEntry;
+import org.eclipse.cdt.core.model.IIncludeFileEntry;
+import org.eclipse.cdt.core.model.ILibraryEntry;
+import org.eclipse.cdt.core.model.IMacroEntry;
+import org.eclipse.cdt.core.model.IMacroFileEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.internal.core.CharOperation;
+import org.eclipse.cdt.internal.core.model.APathEntry;
+import org.eclipse.cdt.internal.core.model.CModelStatus;
+import org.eclipse.cdt.internal.core.model.PathEntry;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
+import org.eclipse.cdt.internal.core.settings.model.CExternalSetting;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
+import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+
+public class PathEntryTranslator {
+ public static final int OP_ADD = 1;
+ public static final int OP_REMOVE = 2;
+ public static final int OP_REPLACE = 3;
+
+ public static final int INCLUDE_BUILT_INS = 1;
+ public static final int INCLUDE_USER = 1 << 1;
+ public static final int INCLUDE_ALL = INCLUDE_BUILT_INS | INCLUDE_USER;
+
+
+ static String PATH_ENTRY = "pathentry"; //$NON-NLS-1$
+ static String ATTRIBUTE_KIND = "kind"; //$NON-NLS-1$
+ static String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$
+ static String ATTRIBUTE_BASE_PATH = "base-path"; //$NON-NLS-1$
+ static String ATTRIBUTE_BASE_REF = "base-ref"; //$NON-NLS-1$
+ static String ATTRIBUTE_EXPORTED = "exported"; //$NON-NLS-1$
+ static String ATTRIBUTE_SOURCEPATH = "sourcepath"; //$NON-NLS-1$
+ static String ATTRIBUTE_ROOTPATH = "roopath"; //$NON-NLS-1$
+ static String ATTRIBUTE_PREFIXMAPPING = "prefixmapping"; //$NON-NLS-1$
+ static String ATTRIBUTE_EXCLUDING = "excluding"; //$NON-NLS-1$
+ static String ATTRIBUTE_INCLUDE = "include"; //$NON-NLS-1$
+ static String ATTRIBUTE_INCLUDE_FILE= "include-file"; //$NON-NLS-1$
+ static String ATTRIBUTE_LIBRARY = "library"; //$NON-NLS-1$
+ static String ATTRIBUTE_SYSTEM = "system"; //$NON-NLS-1$
+ static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
+ static String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
+ static String ATTRIBUTE_MACRO_FILE = "macro-file"; //$NON-NLS-1$
+ static String VALUE_TRUE = "true"; //$NON-NLS-1$
+
+ static final IPathEntry[] NO_PATHENTRIES = new IPathEntry[0];
+
+ private static final char[] SPEC_CHARS = new char[]{'*', '?'};
+ private PathSettingsContainer fRcDataHolder;
+ private IProject fProject;
+ private CConfigurationData fCfgData;
+ private PathSettingsContainer fTranslatedFilters;
+ private Map fResourceMap = new HashMap();
+ private IWorkspaceRoot fRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+ public static final class ReferenceSettingsInfo{
+ private IPath[] fRefProjPaths;
+ private ICExternalSetting[] fExtSettings;
+
+ public ReferenceSettingsInfo(ICConfigurationDescription des){
+ fExtSettings = des.getExternalSettings();
+ Map map = des.getReferenceInfo();
+ fRefProjPaths = new IPath[map.size()];
+ int num = 0;
+ for(Iterator iter = map.keySet().iterator(); iter.hasNext();){
+ String proj = (String)iter.next();
+ fRefProjPaths[num++] = new Path(proj).makeAbsolute();
+ }
+ }
+
+ public ReferenceSettingsInfo(IPath[] projPaths, ICExternalSetting extSettings[]){
+ if(projPaths != null)
+ fRefProjPaths = (IPath[])projPaths.clone();
+ if(extSettings != null)
+ fExtSettings = (ICExternalSetting[])extSettings.clone();
+ }
+
+ public IPath[] getReferencedProjectsPaths(){
+ if(fRefProjPaths != null)
+ return (IPath[])fRefProjPaths.clone();
+ return new IPath[0];
+ }
+
+ public Map getRefProjectsMap(){
+ if(fRefProjPaths != null && fRefProjPaths.length != 0){
+ Map map = new HashMap(fRefProjPaths.length);
+ for(int i = 0; i < fRefProjPaths.length; i++){
+ map.put(fRefProjPaths[i].segment(0), ""); //$NON-NLS-1$
+ }
+ return map;
+ }
+ return new HashMap(0);
+ }
+
+ public ICExternalSetting[] getExternalSettings(){
+ if(fExtSettings != null)
+ return (ICExternalSetting[])fExtSettings.clone();
+ return new ICExternalSetting[0];
+ }
+ }
+
+ private static class PathEntryKyndStore {
+ private static final int INDEX_CDT_LIBRARY = 0;
+ private static final int INDEX_CDT_PROJECT = 1;
+ private static final int INDEX_CDT_SOURCE = 2;
+ private static final int INDEX_CDT_INCLUDE = 3;
+ private static final int INDEX_CDT_CONTAINER = 4;
+ private static final int INDEX_CDT_MACRO = 5;
+ private static final int INDEX_CDT_OUTPUT = 6;
+ private static final int INDEX_CDT_INCLUDE_FILE = 7;
+ private static final int INDEX_CDT_MACRO_FILE = 8;
+
+ private static final int STORAGE_SIZE = 9;
+
+ private static final int ENTRY_KINDS[] = new int[]{
+ IPathEntry.CDT_LIBRARY,
+ IPathEntry.CDT_PROJECT,
+ IPathEntry.CDT_SOURCE,
+ IPathEntry.CDT_INCLUDE,
+ IPathEntry.CDT_CONTAINER,
+ IPathEntry.CDT_MACRO,
+ IPathEntry.CDT_OUTPUT,
+ IPathEntry.CDT_INCLUDE_FILE,
+ IPathEntry.CDT_MACRO_FILE,
+ };
+// private static final int INEXISTENT_INDEX = -1;
+
+ private Object[] fEntryStorage = new Object[STORAGE_SIZE];
+
+ private int kindToIndex(int kind){
+ switch (kind){
+ case IPathEntry.CDT_LIBRARY:
+ return INDEX_CDT_LIBRARY;
+ case IPathEntry.CDT_PROJECT:
+ return INDEX_CDT_PROJECT;
+ case IPathEntry.CDT_SOURCE:
+ return INDEX_CDT_SOURCE;
+ case IPathEntry.CDT_INCLUDE:
+ return INDEX_CDT_INCLUDE;
+ case IPathEntry.CDT_CONTAINER:
+ return INDEX_CDT_CONTAINER;
+ case IPathEntry.CDT_MACRO:
+ return INDEX_CDT_MACRO;
+ case IPathEntry.CDT_OUTPUT:
+ return INDEX_CDT_OUTPUT;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ return INDEX_CDT_INCLUDE_FILE;
+ case IPathEntry.CDT_MACRO_FILE:
+ return INDEX_CDT_MACRO_FILE;
+ }
+ throw new IllegalArgumentException("illegal kind");
+ }
+
+ public static int[] getSupportedKinds(){
+ return (int[])ENTRY_KINDS.clone();
+ }
+
+ private int indexToKind(int index){
+ switch (index){
+ case INDEX_CDT_LIBRARY:
+ return IPathEntry.CDT_LIBRARY;
+ case INDEX_CDT_PROJECT:
+ return IPathEntry.CDT_PROJECT;
+ case INDEX_CDT_SOURCE:
+ return IPathEntry.CDT_SOURCE;
+ case INDEX_CDT_INCLUDE:
+ return IPathEntry.CDT_INCLUDE;
+ case INDEX_CDT_CONTAINER:
+ return IPathEntry.CDT_CONTAINER;
+ case INDEX_CDT_MACRO:
+ return IPathEntry.CDT_MACRO;
+ case INDEX_CDT_OUTPUT:
+ return IPathEntry.CDT_OUTPUT;
+ case INDEX_CDT_INCLUDE_FILE:
+ return IPathEntry.CDT_INCLUDE_FILE;
+ case INDEX_CDT_MACRO_FILE:
+ return IPathEntry.CDT_MACRO_FILE;
+ }
+ throw new IllegalArgumentException("illegal kind");
+ }
+ public Object get(int kind){
+ return fEntryStorage[kindToIndex(kind)];
+ }
+
+ public Object put(int kind, Object object){
+ int index = kindToIndex(kind);
+ Object old = fEntryStorage[index];
+ fEntryStorage[index] = object;
+ return old;
+ }
+
+ private class KindBasedInfo implements IKindBasedInfo {
+ int fIdex;
+ int fKind;
+
+ KindBasedInfo(int num, boolean isKind){
+ if(isKind){
+ fIdex = kindToIndex(num);
+ fKind = num;
+ } else {
+ fIdex = num;
+ fKind = indexToKind(num);
+ }
+ }
+
+ public Object getInfo() {
+ return fEntryStorage[fIdex];
+ }
+
+ public int getKind() {
+ return fKind;
+ }
+
+ public Object setInfo(Object newInfo) {
+ Object old = fEntryStorage[fIdex];
+ fEntryStorage[fIdex] = newInfo;
+ return old;
+ }
+
+ }
+
+ public IKindBasedInfo[] getContents(){
+ IKindBasedInfo infos[] = new IKindBasedInfo[STORAGE_SIZE];
+ for(int i = 0; i < STORAGE_SIZE; i++){
+ infos[i] = new KindBasedInfo(i, false);
+ }
+ return infos;
+ }
+
+ public IKindBasedInfo getInfo(int kind){
+ return new KindBasedInfo(kind, true);
+ }
+
+ public void clear(){
+ for(int i = 0; i < STORAGE_SIZE; i++){
+ fEntryStorage[i] = null;
+ }
+ }
+ }
+
+ private static class LangEntryInfo {
+ ICLanguageSettingEntry fLangEntry;
+ ResolvedEntry fResolvedEntry;
+
+ public LangEntryInfo(ICLanguageSettingEntry lEntry, ResolvedEntry re){
+ fLangEntry = lEntry;
+ fResolvedEntry = re;
+ }
+ }
+
+ private class RcDesInfo {
+ ResourceInfo fRcInfo;
+ List fResolvedEntries;
+ KindBasedStore fLangEntries;
+ boolean fIsExcluded;
+
+ private RcDesInfo(ResourceInfo rcInfo){
+ this.fRcInfo = rcInfo;
+ fResolvedEntries = new ArrayList();
+ fLangEntries = new KindBasedStore();
+ }
+
+ public boolean isExcluded(){
+ return fIsExcluded;
+ }
+
+ public void setExcluded(boolean excluded){
+ fIsExcluded = excluded;
+ }
+
+ public ResolvedEntry[] getResolvedEntries(){
+ return (ResolvedEntry[])fResolvedEntries.toArray(new ResolvedEntry[fResolvedEntries.size()]);
+ }
+
+ public void add(LangEntryInfo info){
+ List list = (List)fLangEntries.get(info.fLangEntry.getKind());
+ if(list == null){
+ list = new ArrayList();
+ fLangEntries.put(info.fLangEntry.getKind(), list);
+ }
+ list.add(info);
+ }
+
+// public ICLanguageSettingEntry addLangInfo(ResolvedEntry entry){
+// ICLanguageSettingEntry le = createLangEntry(entry);
+// if(le != null){
+// List list = (List)fLangEntries.get(le.getKind());
+// if(list == null){
+// list = new ArrayList();
+// fLangEntries.put(le.getKind(), list);
+// }
+// list.add(new LangEntryInfo(le, entry));
+// }
+// return le;
+// }
+
+ public ICLanguageSettingEntry[] getEntries(int kind){
+ List list = (List)fLangEntries.get(kind);
+ if(list != null){
+ ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[list.size()];
+ for(int i = 0; i < entries.length; i++){
+ LangEntryInfo info = (LangEntryInfo)list.get(i);
+ entries[i] = info.fLangEntry;
+ }
+ return entries;
+ }
+ return new ICLanguageSettingEntry[0];
+
+
+ }
+
+// private void initThisEntries
+
+ }
+
+ private static ICLanguageSettingEntry createLangEntry(ResolvedEntry entry){
+ PathEntryValueInfo value = entry.getResolvedValue();
+ int flags = ICLanguageSettingEntry.RESOLVED;
+ if(entry.isReadOnly())
+ flags |= ICLanguageSettingEntry.READONLY;
+ if(entry.isBuiltIn())
+ flags |= ICLanguageSettingEntry.BUILTIN;
+
+ switch(entry.fEntry.getEntryKind()){
+ case IPathEntry.CDT_LIBRARY:{
+ IPath path = value.getFullPath();
+ if(path != null){
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ } else {
+ path = value.getLocation();
+ }
+
+ if(path != null){
+ return new CLibraryFileEntry(path, flags);
+ }
+ break;
+ }
+// case IPathEntry.CDT_PROJECT:
+// return ICLanguageSettingEntry;
+// case IPathEntry.CDT_SOURCE:
+// return INDEX_CDT_SOURCE;
+ case IPathEntry.CDT_INCLUDE:{
+ IPath path = value.getFullPath();
+ if(path != null){
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ } else {
+ path = value.getLocation();
+ }
+
+ if(path != null){
+ return new CIncludePathEntry(path, flags);
+ }
+ break;
+ }
+// case IPathEntry.CDT_CONTAINER:
+// return INDEX_CDT_CONTAINER;
+ case IPathEntry.CDT_MACRO:
+ String name = value.getName();
+ if(name.length() != 0){
+ String mValue = value.getValue();
+ return new CMacroEntry(name, mValue, flags);
+ }
+ break;
+// case IPathEntry.CDT_OUTPUT:
+// return INDEX_CDT_OUTPUT;
+ case IPathEntry.CDT_INCLUDE_FILE:{
+ IPath path = value.getFullPath();
+ if(path != null){
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ } else {
+ path = value.getLocation();
+ }
+
+ if(path != null){
+ return new CIncludeFileEntry(path, flags);
+ }
+ break;
+ }
+ case IPathEntry.CDT_MACRO_FILE:{
+ IPath path = value.getFullPath();
+ if(path != null){
+ flags |= ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ } else {
+ path = value.getLocation();
+ }
+
+ if(path != null){
+ return new CMacroFileEntry(path, flags);
+ }
+ break;
+ }
+ }
+ return null;
+ }
+
+ private class ResourceInfo {
+ IResource fRc;
+ boolean fExists;
+
+ public ResourceInfo(IResource rc, boolean exists) {
+ fRc = rc;
+ fExists = exists;
+ }
+ }
+
+ private class PathEntryValueInfo {
+ private ResourceInfo fResourceInfo;
+// private IPath fFullPath;
+ private IPath fLocation;
+ private String fName;
+ private String fValue;
+ private ResolvedEntry fResolvedEntry;
+
+ private PathEntryValueInfo(ResolvedEntry rEntry){
+ fResolvedEntry = rEntry;
+
+ init();
+ }
+
+ public IPath getFullPath(){
+ if(fResourceInfo != null)
+ return fResourceInfo.fRc.getFullPath();
+ return null;
+ }
+
+ public IPath getLocation(){
+ if(fResourceInfo != null)
+ return fResourceInfo.fRc.getLocation();
+ return fLocation;
+ }
+
+ public String getName(){
+ if(fName != null)
+ return fName;
+ return ""; //$NON-NLS-1$
+ }
+
+ public String getValue(){
+ if(fValue != null)
+ return fValue;
+ return ""; //$NON-NLS-1$
+ }
+
+ private void init() {
+ IPathEntry entry = fResolvedEntry.fEntry;
+ int peKind = entry.getEntryKind();
+ IPath basePath = null, valuePath = null;
+ boolean isFile = false;
+ boolean calcPath = false;
+ switch(peKind){
+ case IPathEntry.CDT_MACRO:
+ IMacroEntry me = (IMacroEntry)entry;
+ fName = me.getMacroName();
+ fValue = me.getMacroValue();
+ break;
+ case IPathEntry.CDT_LIBRARY:
+ isFile = true;
+ calcPath = true;
+ ILibraryEntry le = (ILibraryEntry)entry;
+ basePath = le.getBasePath();
+ valuePath = le.getLibraryPath();
+ break;
+ case IPathEntry.CDT_INCLUDE:
+ isFile = false;
+ calcPath = true;
+ IIncludeEntry ie = (IIncludeEntry)entry;
+ basePath = ie.getBasePath();
+ valuePath = ie.getIncludePath();
+ break;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ isFile = true;
+ calcPath = true;
+ IIncludeFileEntry ife = (IIncludeFileEntry)entry;
+ basePath = ife.getBasePath();
+ valuePath = ife.getIncludeFilePath();
+ break;
+ case IPathEntry.CDT_MACRO_FILE:
+ isFile = true;
+ calcPath = true;
+ IMacroFileEntry mfe = (IMacroFileEntry)entry;
+ basePath = mfe.getBasePath();
+ valuePath = mfe.getMacroFilePath();
+ break;
+ case IPathEntry.CDT_PROJECT:
+ case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_CONTAINER:
+ case IPathEntry.CDT_OUTPUT:
+ fResourceInfo = fResolvedEntry.getResourceInfo();
+// fFullPath = fResourceInfo.fRc.getFullPath();
+// fLocation = fResourceInfo.fRc.getLocation();
+
+// fName = fValuePath.toString();
+// fValue = fValuePath.toString();
+ break;
+ }
+
+ if(calcPath){
+ do{
+ // IPath p;
+ // IPath inc = getIncludePath();
+ if (!basePath.isEmpty()) {
+ IPath loc = basePath;
+ if (!loc.isAbsolute()) {
+ ResourceInfo rcInfo = findResourceInfo(fRoot, loc.append(valuePath), !isFile);
+ if (rcInfo.fExists) {
+ fResourceInfo = rcInfo;
+// fFullPath = fResourceInfo.fRc.getFullPath();
+// fLocation = fResourceInfo.fRc.getLocation();
+// fName = fValuePath.toString();
+// fValue = fValuePath.toString();
+ break;
+ }
+ }
+ fLocation = loc.append(valuePath);
+// fName = fValuePath.toString();
+// fValue = fValuePath.toString();
+ break;
+ }
+
+// p = inc;
+
+ if (!valuePath.isAbsolute()) {
+ ResourceInfo rcInfo = fResolvedEntry.getResourceInfo();
+//
+// IPath resPath = getPath();
+// IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath);
+ if (rcInfo.fExists) {
+ if (rcInfo.fRc.getType() == IResource.FILE) {
+ rcInfo = findResourceInfo(fRoot, rcInfo.fRc.getFullPath().removeLastSegments(1), true);
+ }
+ IPath location = rcInfo.fRc.getLocation();
+ if (location != null && rcInfo.fRc.getType() != IResource.FILE) {
+ rcInfo = findResourceInfo((IContainer)rcInfo.fRc, valuePath, !isFile);
+ fResourceInfo = rcInfo;
+// fFullPath = fResourceInfo.fRc.getFullPath();
+// fLocation = fResourceInfo.fRc.getLocation();
+ }
+ }
+ } else {
+ fLocation = valuePath;
+ }
+ }while(false);
+ }
+ }
+
+ public boolean isWorkspacePath(){
+ return fResourceInfo != null;
+ }
+
+
+ }
+
+ private class ResolvedEntry {
+ private IPathEntry fEntry;
+ private ResourceInfo fResourceInfo;
+ private ResourceInfo[] fFilterInfos;
+ private PathEntryValueInfo fResolvedValue;
+ private PathEntryResolveInfoElement fResolveElement;
+ private boolean fIsReadOnly;
+ private boolean fIsBuiltIn;
+
+ public ResolvedEntry(IPathEntry entry, PathEntryResolveInfoElement resolveElement) {
+ fEntry = entry;
+ fResolveElement = resolveElement;
+ fIsReadOnly = areEntriesReadOnly(fResolveElement);
+ fIsBuiltIn = fIsReadOnly;
+ }
+
+ public ResolvedEntry(IPathEntry entry, boolean isReadOnly) {
+ fEntry = entry;
+ fIsReadOnly = isReadOnly;
+ }
+
+ public boolean isReadOnly(){
+ return fIsReadOnly;
+ }
+
+ public boolean isBuiltIn(){
+ return fIsBuiltIn;
+ }
+
+ public PathEntryResolveInfoElement getResolveInfoElement(){
+ return fResolveElement;
+ }
+
+ public ResourceInfo getResourceInfo(){
+ if(fResourceInfo == null){
+ fResourceInfo = findResourceInfo(fRoot, getEntryFullPath(fEntry), true);
+ }
+ return fResourceInfo;
+ }
+
+ public ResourceInfo[] getFilterInfos(){
+ if(fFilterInfos == null){
+ IPath[] paths = obtainFilters(fEntry);
+ if(paths.length == 0){
+ fFilterInfos = new ResourceInfo[0];
+ } else {
+ ResourceInfo rcInfo = getResourceInfo();
+ if(rcInfo.fExists){
+ if(rcInfo.fRc.getType() == IResource.FILE){
+ fFilterInfos = new ResourceInfo[0];
+ } else {
+ List list = new ArrayList();
+ for(int i = 0; i < paths.length; i++){
+ list.addAll(Arrays.asList(processFilter((IContainer)rcInfo.fRc, paths[i])));
+ }
+ fFilterInfos = new ResourceInfo[list.size()];
+ list.toArray(fFilterInfos);
+ }
+ } else {
+ fFilterInfos = new ResourceInfo[paths.length];
+ for(int i = 0; i < paths.length; i++){
+ fFilterInfos[i] = processInexistingResourceFilter((IContainer)rcInfo.fRc, paths[i]);
+ }
+ }
+ }
+ }
+ return fFilterInfos;
+ }
+
+ private ResourceInfo[] processFilter(IContainer container, IPath path){
+ return resolveFilter(container, path);
+ }
+
+ private ResourceInfo processInexistingResourceFilter(IContainer container, IPath path){
+ IFolder f = container.getFolder(path);
+ ResourceInfo rcInfo = new ResourceInfo(f, false);
+ addRcInfoToMap(rcInfo);
+
+ addResolvedFilterToMap(container.getFullPath(), new ResourceInfo[]{rcInfo}, true);
+ return rcInfo;
+ }
+
+ public IPathEntry getEntry(){
+ return fEntry;
+ }
+
+ public PathEntryValueInfo getResolvedValue(){
+ if(fResolvedValue == null){
+ fResolvedValue = new PathEntryValueInfo(this);
+ }
+ return fResolvedValue;
+ }
+
+
+ }
+
+ private static class PathEntryComposer {
+ private IPath fPath;
+ private ICSettingEntry fLangEntry;
+ private Set fFiltersSet;
+ private boolean fIsExported;
+ private IProject fProject;
+
+ PathEntryComposer(String projName, IProject project){
+ this(new Path(projName), project);
+ }
+
+ PathEntryComposer(IPath path, IProject project){
+ fPath = toProjectPath(path);
+ fProject = project;
+ }
+
+ private static IPath toProjectPath(IPath path){
+ if(path.segmentCount() > 1)
+ path = new Path(path.segment(0));
+
+ return path.makeAbsolute();
+ }
+
+ PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project){
+ fPath = new Path(entry.getValue());
+ fLangEntry = entry;
+ fProject = project;
+ IPath[] exclusions = entry.getExclusionPatterns();
+ if(exclusions.length != 0){
+ fFiltersSet = new HashSet(exclusions.length);
+ fFiltersSet.addAll(Arrays.asList(entry.getExclusionPatterns()));
+ }
+ }
+
+ PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project){
+ fPath = path;
+ fLangEntry = entry;
+ fIsExported = exported;
+ fProject = project;
+ }
+
+ public void addFilter(IPath path){
+ if(fFiltersSet == null)
+ fFiltersSet = new HashSet();
+
+ fFiltersSet.add(path);
+ }
+
+ public ICSettingEntry getSettingEntry(){
+ return fLangEntry;
+ }
+
+ public IPath getPath(){
+ return fPath;
+ }
+
+ public IPath[] getExclusionPatterns(){
+ if(fFiltersSet != null)
+ return (IPath[])fFiltersSet.toArray(new IPath[fFiltersSet.size()]);
+ return new IPath[0];
+ }
+
+ private IPath getEntryPath(ICSettingEntry entry){
+ return valueToEntryPath(entry.getName(), (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0);
+ }
+
+ private IPath valueToEntryPath(String value, boolean isWsp){
+ IPath path = new Path(value);
+ if(isWsp){
+ if(!path.isAbsolute()){
+ path = fProject.getFullPath().append(path);
+ }
+ path = path.makeRelative();
+ } else {
+ if(!path.isAbsolute()){
+ IPath location = fProject.getLocation();
+ if(location != null)
+ path = location.append(path);
+ }
+ }
+
+ return path;
+ }
+
+ public IPathEntry toPathEntry(){
+ if(fLangEntry != null){
+ switch(fLangEntry.getKind()){
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return CoreModel.newIncludeFileEntry(fPath, null, null, getEntryPath(fLangEntry), getExclusionPatterns(), fIsExported);
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ ICIncludePathEntry ipe = (ICIncludePathEntry)fLangEntry;
+ return CoreModel.newIncludeEntry(fPath, null, getEntryPath(fLangEntry), !ipe.isLocal(), getExclusionPatterns(), fIsExported);
+ case ICLanguageSettingEntry.MACRO:
+ return CoreModel.newMacroEntry(fPath, fLangEntry.getName(), fLangEntry.getValue(), getExclusionPatterns(), fIsExported);
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return CoreModel.newMacroFileEntry(fPath, null, null, getEntryPath(fLangEntry), getExclusionPatterns(), fIsExported);
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ return null;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ return CoreModel.newLibraryEntry(fPath, null, getEntryPath(fLangEntry), null, null, null, fIsExported);
+ case ICLanguageSettingEntry.OUTPUT_PATH:
+ return CoreModel.newOutputEntry(fPath, getExclusionPatterns());
+ case ICLanguageSettingEntry.SOURCE_PATH:
+ return CoreModel.newSourceEntry(fPath, getExclusionPatterns());
+ default:
+ return null;
+ }
+ } else if(fPath != null){
+ return CoreModel.newProjectEntry(fPath, fIsExported);
+ }
+ return null;
+ }
+ }
+
+ public static class PathEntryCollector {
+ private PathSettingsContainer fStorage;
+ private KindBasedStore fStore;
+ private LinkedHashMap fRefProjMap;
+ private IProject fProject;
+
+ private PathEntryCollector(IProject project){
+ fStorage = PathSettingsContainer.createRootContainer();
+ fStorage.setValue(this);
+ fStore = new KindBasedStore(false);
+ fProject = project;
+ }
+
+ private PathEntryCollector(PathSettingsContainer container, KindBasedStore store, IProject project){
+ fStorage = container;
+ fStore = store;
+ fProject = project;
+ }
+
+ public void setSourceOutputEntries(int kind, ICExclusionPatternPathEntry entries[]){
+ Map map = getEntriesMap(kind, true);
+ for(int i = 0; i < entries.length; i++){
+ map.put(entries[i], new PathEntryComposer(entries[i], fProject));
+ }
+ }
+
+ public void setRefProjects(IPath []paths){
+ if(paths == null || paths.length == 0)
+ fRefProjMap = null;
+ else {
+ fRefProjMap = new LinkedHashMap();
+ for(int i = 0; i < paths.length; i++){
+ PathEntryComposer cs = new PathEntryComposer(paths[i], fProject);
+ IPath path = cs.getPath();
+ fRefProjMap.put(path, cs);
+ }
+ }
+ }
+
+ public PathEntryCollector createChild(IPath path){
+ if(path.segmentCount() == 0)
+ return this;
+
+ PathEntryCollector cr = (PathEntryCollector)fStorage.getChildContainer(path, false, false).getValue();
+ if(cr != this){
+ IPath basePath = cr.getPath();
+ path = path.removeFirstSegments(basePath.segmentCount());
+ return cr.createChild(path);
+ }
+
+ PathSettingsContainer newContainer = fStorage.getChildContainer(path, true, true);
+ KindBasedStore cloneStore = (KindBasedStore)fStore.clone();
+ IKindBasedInfo info[] = cloneStore.getContents();
+ for(int i = 0; i < info.length; i++){
+ LinkedHashMap map = (LinkedHashMap)info[i].getInfo();
+ if(map != null){
+ info[i].setInfo((LinkedHashMap)map.clone());
+ }
+ }
+ PathEntryCollector newCr = new PathEntryCollector(newContainer, cloneStore, fProject);
+ newContainer.setValue(newCr);
+ return newCr;
+ }
+
+ public IPath getPath(){
+ return fStorage.getPath();
+ }
+
+ public void setEntries(int kind, ICLanguageSettingEntry entries[], Set exportedEntries){
+ IPath path = getPath();
+ HashSet parentSet = getEntriesSetCopy(kind);
+ HashSet removedParentSet = (HashSet)parentSet.clone();
+ HashSet addedThisSet = new HashSet(Arrays.asList(entries));
+ removedParentSet.removeAll(addedThisSet);
+ addedThisSet.removeAll(parentSet);
+
+
+ if(removedParentSet.size() != 0){
+ PathEntryCollector parent = getParent();
+ if(parent != null){
+ parent.addFilter(kind, path, removedParentSet);
+ }
+
+ Map map = getEntriesMap(kind, true);
+ for(Iterator iter = removedParentSet.iterator(); iter.hasNext();){
+ map.remove(iter.next());
+ }
+ }
+
+ if(addedThisSet.size() != 0){
+ Map map = getEntriesMap(kind, true);
+
+ for(int i = 0; i < entries.length; i++){
+ if(!addedThisSet.remove(entries[i]))
+ continue;
+
+ ICLanguageSettingEntry entry = entries[i];
+ map.put(entry, new PathEntryComposer(path, entry, exportedEntries.contains(entry), fProject));
+ }
+ }
+ }
+
+ private LinkedHashMap getEntriesMap(int kind, boolean create){
+ LinkedHashMap map = (LinkedHashMap)fStore.get(kind);
+ if(map == null && create){
+ map = new LinkedHashMap();
+ fStore.put(kind, map);
+ }
+ return map;
+ }
+
+ private void addFilter(int kind, IPath path, Set entriesSet){
+ if(entriesSet.size() == 0)
+ return;
+
+ Map map = (Map)fStore.get(kind);
+ for(Iterator iter = entriesSet.iterator(); iter.hasNext();){
+ PathEntryComposer cs = (PathEntryComposer)map.get(iter.next());
+ cs.addFilter(path);
+ }
+ }
+
+ public PathEntryCollector getParent(){
+ if(fStorage.isRoot())
+ return null;
+ PathSettingsContainer cr = fStorage.getParentContainer();
+ return (PathEntryCollector)cr.getValue();
+ }
+
+ private HashSet getEntriesSetCopy(int kind){
+ Map map = getEntriesMap(kind, false);
+ if(map != null){
+ return new HashSet(map.keySet());
+ }
+ return new HashSet(0);
+ }
+
+ private List getCollectedEntriesList(final int kind){
+ final List list = new ArrayList();
+ final Set set = new HashSet();
+ fStorage.accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ PathEntryCollector clr = (PathEntryCollector)container.getValue();
+ clr.getLocalCollectedEntries(kind, list, set);
+ return true;
+ }
+
+ });
+
+ return list;
+ }
+
+ private void getLocalCollectedEntries(int kind, List list, Set addedEntries){
+ Map map = getEntriesMap(kind, false);
+ if(map == null)
+ return;
+
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ Object o = iter.next();
+
+ if(addedEntries.add(o)){
+ list.add(o);
+ }
+ }
+ }
+
+ public List getEntries(int peKind, List list, int flags){
+ if(list == null){
+ list = new ArrayList();
+ }
+
+ int sKind = peKindToSettingKind(peKind);
+ List composerList = null;
+ if(sKind != 0){
+ composerList = getCollectedEntriesList(sKind);
+ } else if(peKind == IPathEntry.CDT_PROJECT){
+ if(fRefProjMap != null && fRefProjMap.size() != 0){
+ composerList = new ArrayList(fRefProjMap.values());
+ }
+ }
+ if(composerList != null){
+ for(Iterator iter = composerList.iterator(); iter.hasNext();){
+ PathEntryComposer cs = (PathEntryComposer)iter.next();
+ ICSettingEntry entry = cs.getSettingEntry();
+ if(checkFilter(entry, flags)){
+ IPathEntry pe = cs.toPathEntry();
+ if(pe != null)
+ list.add(pe);
+ }
+ }
+ }
+
+ return list;
+ }
+
+ private static boolean checkFilter(ICSettingEntry entry, int flags){
+ boolean builtIn = entry != null ?
+ entry.isBuiltIn() || entry.isReadOnly() : false;
+ if((flags & INCLUDE_BUILT_INS) != 0 && builtIn)
+ return true;
+ if((flags & INCLUDE_USER) != 0 && !builtIn)
+ return true;
+ return false;
+ }
+
+
+ public List getEntries(List list, int flags){
+ if(list == null)
+ list = new ArrayList();
+ int peKinds[] = PathEntryKyndStore.getSupportedKinds();
+ for(int i = 0; i < peKinds.length; i++){
+ getEntries(peKinds[i], list, flags);
+ }
+
+ return list;
+ }
+
+ public IPathEntry[] getEntries(int flags){
+ List list = getEntries(null, flags);
+ IPathEntry[] entries = (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
+ return entries;
+ }
+
+
+// public IPathEntry[] getRawEntries(String containerId){
+// List list = getEntries(null, false, false);
+// if(containerId != null)
+// list.add(CoreModel.newContainerEntry(new Path(containerId)));
+// IPathEntry[] entries = (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
+// return entries;
+// }
+//
+// public IPathEntry[] getResolvedEntries(){
+// List list = getEntries(null, true, true);
+// IPathEntry[] entries = (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
+// return entries;
+// }
+ }
+
+ private static LangEntryInfo createLangEntryInfo(ResolvedEntry entry){
+ ICLanguageSettingEntry le = createLangEntry(entry);
+ if(le != null){
+ return new LangEntryInfo(le, entry);
+ }
+ return null;
+ }
+
+
+ private static boolean areEntriesReadOnly(PathEntryResolveInfoElement el){
+ switch(el.getRawEntry().getEntryKind()){
+ case IPathEntry.CDT_LIBRARY:
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO_FILE:
+ case IPathEntry.CDT_SOURCE:
+ case IPathEntry.CDT_OUTPUT:
+ return false;
+// case IPathEntry.CDT_PROJECT:
+// case IPathEntry.CDT_CONTAINER:
+ }
+ return true;
+ }
+
+
+ private IPath getEntryFullPath(IPathEntry entry){
+ IPath path = entry.getPath();
+ if(path == null)
+ return fProject.getFullPath();
+ else if(path.isAbsolute())
+ return path;
+ return fProject.getFullPath().append(path);
+
+ }
+
+ private IPath[] obtainFilters(IPathEntry entry){
+ switch (entry.getEntryKind()) {
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_OUTPUT:
+ case IPathEntry.CDT_SOURCE:
+ return ((APathEntry)entry).getExclusionPatterns();
+ }
+ return new IPath[0];
+ }
+
+ public PathEntryTranslator(IProject project, CConfigurationData data){
+ fProject = project;
+ fCfgData = data;
+ fRcDataHolder = createRcDataHolder(data);
+ fTranslatedFilters = PathSettingsContainer.createRootContainer();
+ fTranslatedFilters.setValue(new ResourceInfo[]{new ResourceInfo(fRoot, true)});
+ }
+
+ private static PathSettingsContainer createRcDataHolder(CConfigurationData data){
+ PathSettingsContainer h = PathSettingsContainer.createRootContainer();
+
+ h.setValue(data.getRootFolderData());
+ CResourceData[] rcDatas = data.getResourceDatas();
+ CResourceData rcData;
+ PathSettingsContainer child;
+ for(int i = 0; i < rcDatas.length; i++){
+ rcData = rcDatas[i];
+ child = h.getChildContainer(rcData.getPath(), true, true);
+ child.setValue(rcData);
+ }
+ return h;
+ }
+
+ public ReferenceSettingsInfo applyPathEntries(PathEntryResolveInfo info, int op){
+ ResolvedEntry[] rEntries = getResolvedEntries(info);
+ return addPathEntries(rEntries, op);
+ }
+
+ public static ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, PathSettingsContainer rcDatas, IPath paths[]){
+ if(paths == null || paths.length == 0)
+ paths = new IPath[]{new Path("")};
+
+// Set set = new HashSet(paths.length);
+ PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
+ IPath pi, pj;
+ List entriesList = new ArrayList(paths.length);
+ IPath projPath = project != null ? project.getFullPath() : null;
+
+ for(int i = 0; i < paths.length; i++){
+ pi = paths[i];
+// set.clear();
+ cr.removeChildren();
+ cr.setValue(null);
+ for(int j = 0; j < paths.length; j++){
+ pj = paths[j];
+ if(pi != pj && pi.isPrefixOf(pj)){
+// set.add(pj);
+ cr.getChildContainer(pj, true, true);
+ }
+ }
+
+ PathSettingsContainer children[] = rcDatas.getDirectChildrenForPath(pi);
+ for(int k = 0; k < children.length; k++){
+ PathSettingsContainer child = children[k];
+ IPath childPath = child.getPath();
+ PathSettingsContainer parentExclusion = cr.getChildContainer(childPath, false, false);
+ IPath parentExclusionPath = parentExclusion.getPath();
+ if(parentExclusionPath.segmentCount() > 0 && !parentExclusionPath.equals(childPath) && parentExclusionPath.isPrefixOf(childPath))
+ continue;
+
+ CResourceData rcData = (CResourceData)child.getValue();
+ if(rcData.isExcluded()){
+// set.add(rcDes.getPath());
+ cr.getChildContainer(childPath, true, true);
+ }
+ }
+
+ PathSettingsContainer exclusions[] = cr.getChildren(false);
+// IPath exlusionPaths[] = new IPath[set.size()];
+ IPath exlusionPaths[] = new IPath[exclusions.length];
+// int k = 0;
+ int segCount = pi.segmentCount();
+// for(Iterator iter = set.iterator(); iter.hasNext(); k++) {
+// IPath path = (IPath)iter.next();
+// exlusionPaths[k] = path.removeFirstSegments(segCount).makeRelative();
+// }
+ for(int k = 0; k < exlusionPaths.length; k++) {
+ exlusionPaths[k] = exclusions[k].getPath().removeFirstSegments(segCount).makeRelative();
+ }
+ if(projPath != null)
+ pi = projPath.append(pi);
+ entriesList.add(new CSourceEntry(pi, exlusionPaths, 0));
+ }
+
+ return (ICSourceEntry[])entriesList.toArray(new ICSourceEntry[entriesList.size()]);
+ }
+
+ private IPath[] setSourceEntries(PathSettingsContainer crontainer, List res) {
+// ICSourceEntry entry;
+ IPath entryPath;
+// IPath paths[];
+ Set srcPathSet = new HashSet();
+ IPath projPath = fProject != null ? fProject.getFullPath() : null;
+ PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
+
+// Map exclusionMap = new HashMap();
+
+// HashSet pathSet = new HashSet();
+ for(Iterator iter = res.iterator(); iter.hasNext();){
+ ResolvedEntry re = (ResolvedEntry)iter.next();
+ ResourceInfo rcInfo = re.getResourceInfo();
+ entryPath = rcInfo.fRc.getFullPath();
+ if(projPath != null){
+ if(projPath.isPrefixOf(entryPath)){
+ entryPath = entryPath.removeFirstSegments(projPath.segmentCount());
+ } else {
+ continue;
+ }
+ }
+// else {
+// if(entryPath.segmentCount() > 0)
+// entryPath = entryPath.removeFirstSegments(1);
+// else
+// continue;
+// }
+ if(srcPathSet.add(entryPath)){
+ // exclusionMap.put(entryPath, Boolean.TRUE);
+ PathSettingsContainer entryCr = cr.getChildContainer(entryPath, true, true);
+ entryCr.setValue(Boolean.TRUE);
+
+ ResourceInfo[] filters = re.getFilterInfos();
+
+// paths = entry.getExclusionPatterns();
+
+ for(int j = 0; j < filters.length; j++){
+ IPath path = filters[j].fRc.getFullPath();
+ path = path.removeFirstSegments(entryPath.segmentCount());
+ PathSettingsContainer exclusion = entryCr.getChildContainer(path, true, true);
+ if(exclusion.getValue() == null)
+ exclusion.setValue(Boolean.FALSE);
+ // if(null == exclusionMap.get(path))
+ // exclusionMap.put(path, Boolean.FALSE);
+ }
+ }
+ }
+
+// CConfigurationData data = getConfigurationData(true);
+// data.setSourcePaths((IPath[])srcPathSet.toArray(new IPath[srcPathSet.size()]));
+// ICResourceDescription rcDess[] = getResourceDescriptions();
+// ICResourceDescription rcDes;
+ Set pathSet = new HashSet();
+ PathSettingsContainer children[] = crontainer.getChildren(true);
+
+ for(int i = 0; i < children.length; i++){
+ PathSettingsContainer child = children[i];
+ RcDesInfo rcDesInfo = (RcDesInfo)child.getValue();
+// rcDes = rcDess[i];
+ IPath path = child.getPath();
+ pathSet.add(path);
+// Boolean b = (Boolean)exclusionMap.remove(path);
+ Boolean b = (Boolean)cr.getChildContainer(path, false, false).getValue();
+ assert (b != null);
+ if(Boolean.TRUE == b) {
+ if(rcDesInfo.isExcluded())
+ rcDesInfo.setExcluded(false);
+ } else {
+ if(path.segmentCount() != 0)
+ rcDesInfo.setExcluded(true);
+ }
+ }
+
+ PathSettingsContainer crs[] = cr.getChildren(true);
+ for(int i= 0; i < crs.length; i++){
+ PathSettingsContainer c = crs[i];
+ IPath path = c.getPath();
+ if(!pathSet.remove(path)){
+ Boolean b = (Boolean)c.getValue();
+ assert (b != null);
+ PathSettingsContainer baseCr = crontainer.getChildContainer(path, false, false);
+ RcDesInfo baseInfo = (RcDesInfo)baseCr.getValue();
+ if(b == Boolean.TRUE){
+ if(baseInfo.isExcluded()){
+ RcDesInfo newInfo = new RcDesInfo(findResourceInfo(fProject, path, true));
+ PathSettingsContainer newCr = crontainer.getChildContainer(path, true, true);
+ newCr.setValue(newInfo);
+// if(newInfo == null){
+// ICResourceDescription fo = getResourceDescription(path, false);
+// if(fo.getType() == ICSettingBase.SETTING_FILE){
+// fo = getResourceDescription(path.removeLastSegments(1), false);
+// }
+// newDes = createFolderDescription(path, (ICFolderDescription)fo);
+// }
+ newInfo.setExcluded(false);
+ }
+ } else {
+ if(!baseInfo.isExcluded()){
+// ICResourceDescription newDes = createResourceDescription(path, base);
+ RcDesInfo newInfo = new RcDesInfo(findResourceInfo(fProject, path, true));
+ PathSettingsContainer newCr = crontainer.getChildContainer(path, true, true);
+ newCr.setValue(newInfo);
+
+// if(newDes == null){
+// ICResourceDescription fo = getResourceDescription(path, false);
+// if(fo.getType() == ICSettingBase.SETTING_FILE){
+// fo = getResourceDescription(path.removeLastSegments(1), false);
+// }
+// newDes = createFolderDescription(path, (ICFolderDescription)fo);
+// }
+ newInfo.setExcluded(true);
+ }
+ }
+ }
+ }
+ return (IPath[])pathSet.toArray(new IPath[pathSet.size()]);
+ }
+
+ private ReferenceSettingsInfo addPathEntries(ResolvedEntry[] rEntries, int op){
+ PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
+ cr.setValue(new RcDesInfo(new ResourceInfo(fProject, true)));
+ List srcList = new ArrayList();
+ List outList = new ArrayList();
+ List projList = new ArrayList();
+ List exportSettingsList = new ArrayList();
+ IPath srcPaths[] = null;
+ PathSettingsContainer child;
+ ResolvedEntry rEntry;
+ IPath projPath;
+ IResource rc;
+ ResourceInfo rcInfo;
+ for(int i = 0; i < rEntries.length; i++){
+ rEntry = rEntries[i];
+ if(toLanguageEntryKind(rEntry.fEntry.getEntryKind()) == 0){
+ switch(rEntry.fEntry.getEntryKind()){
+ case IPathEntry.CDT_SOURCE:
+ srcList.add(rEntry);
+ break;
+ case IPathEntry.CDT_OUTPUT:
+ outList.add(rEntry);
+ break;
+ case IPathEntry.CDT_PROJECT:
+ projList.add(rEntry);
+ break;
+ }
+ continue;
+ }
+
+ if(rEntry.getEntry().isExported()){
+ exportSettingsList.add(rEntry);
+ }
+ rcInfo = rEntry.getResourceInfo();
+ rc = rcInfo.fRc;
+ projPath = rc.getProjectRelativePath();
+ child = cr.getChildContainer(projPath, true, true);
+ RcDesInfo rcDes = (RcDesInfo)child.getValue();
+ if(rcDes == null){
+ rcDes = new RcDesInfo(rcInfo);
+ child.setValue(rcDes);
+ }
+
+ rcDes.fResolvedEntries.add(rEntry);
+ }
+
+ if(srcList.size() != 0){
+ srcPaths = setSourceEntries(cr, srcList);
+ } else {
+// srcPaths = new IPath[]{new Path("")}; //$NON-NLS-1$
+ }
+
+// cr.accept(new IPathSettingsContainerVisitor(){
+//
+// public boolean visit(PathSettingsContainer container) {
+// RcDesInfo info = (RcDesInfo)container.getValue();
+// if(info != null){
+// if(info.fResolvedEntries.size() != 0){
+// for(Iterator iter = info.fResolvedEntries.iterator(); iter.hasNext();){
+// ResolvedEntry entry = (ResolvedEntry)iter.next();
+// info.addLangInfo(entry);
+// }
+// }
+// }
+// return true;
+// }
+// });
+
+ propagateValues(cr, new ArrayList(0));
+
+ //applying settings
+
+ applySourcePaths(srcPaths, op);
+ applyLangSettings(cr, op);
+
+ IPath refProjPaths[] = new IPath[projList.size()];
+ for(int i = 0; i < refProjPaths.length; i++){
+ ResolvedEntry e = (ResolvedEntry)projList.get(i);
+ refProjPaths[i] = e.getResourceInfo().fRc.getFullPath();
+ }
+
+ ICExternalSetting extSettings[];
+ if(exportSettingsList.size() != 0){
+ extSettings = new ICExternalSetting[1];
+ List list = new ArrayList(exportSettingsList.size());
+ for(int i = 0; i < exportSettingsList.size(); i++){
+ ResolvedEntry re = (ResolvedEntry)exportSettingsList.get(i);
+ ICLanguageSettingEntry le = createLangEntry(re);
+ if(le != null)
+ list.add(le);
+ }
+ ICLanguageSettingEntry expEntries[] = (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ extSettings[0] = new CExternalSetting(null, null, null, expEntries);
+ } else {
+ extSettings = new ICExternalSetting[0];
+ }
+
+ return new ReferenceSettingsInfo(refProjPaths, extSettings);
+ }
+
+ private void applySourcePaths(IPath srcPaths[], int op){
+ switch (op) {
+ case OP_ADD:
+ if(srcPaths != null){
+ IPath curPaths[] = fCfgData.getSourcePaths();
+ Set set = new HashSet();
+ set.addAll(Arrays.asList(curPaths));
+ set.addAll(Arrays.asList(srcPaths));
+ fCfgData.setSourcePaths((IPath[])set.toArray(new IPath[set.size()]));
+ }
+ break;
+ case OP_REMOVE:
+ if(srcPaths != null){
+ IPath curPaths[] = fCfgData.getSourcePaths();
+ Set set = new HashSet();
+ set.addAll(Arrays.asList(curPaths));
+ set.removeAll(Arrays.asList(srcPaths));
+ fCfgData.setSourcePaths((IPath[])set.toArray(new IPath[set.size()]));
+ }
+ break;
+ case OP_REPLACE:
+ default:
+ if(srcPaths != null){
+ fCfgData.setSourcePaths(srcPaths);
+ } else {
+ fCfgData.setSourcePaths(new IPath[0]);
+ }
+ break;
+ }
+ }
+
+ private void applyLangSettings(PathSettingsContainer cr, int op){
+ PathSettingsContainer crs[] = cr.getChildren(true);
+ for(int i = 0; i < crs.length; i++){
+ PathSettingsContainer cur = crs[i];
+ RcDesInfo desInfo = (RcDesInfo)cur.getValue();
+ try {
+ CResourceData rcData = getResourceData(cur.getPath(), true, true);
+ applyEntries(rcData, desInfo, op);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+
+ CResourceData[] rcDatas = getResourceDatas();
+ for(int i = 0; i < rcDatas.length; i++){
+ CResourceData rcData = rcDatas[i];
+ PathSettingsContainer c = cr.getChildContainer(rcData.getPath(), false, false);
+ if(cr.getPath().makeRelative().equals(rcData.getPath().makeRelative())){
+ continue;
+ }
+
+ RcDesInfo desInfo = (RcDesInfo)c.getValue();
+ rcData.setExcluded(desInfo.isExcluded());
+
+ applyEntries(rcData, desInfo, op);
+ }
+ }
+
+ private CResourceData[] getResourceDatas(){
+ PathSettingsContainer crs[] = fRcDataHolder.getChildren(true);
+ List list = new ArrayList(crs.length);
+ for(int i = 0; i < crs.length; i++){
+ list.add(crs[i].getValue());
+ }
+ return (CResourceData[])list.toArray(new CResourceData[list.size()]);
+ }
+
+ private CResourceData getResourceData(IPath path, boolean create, boolean exactPath) throws CoreException{
+ PathSettingsContainer rcDataH = fRcDataHolder.getChildContainer(path, false, exactPath);
+ if(rcDataH != null){
+ return (CResourceData)rcDataH.getValue();
+ } else if (create) {
+ ResourceInfo rcInfo = findResourceInfo(fProject, path, true);
+ CResourceData base = getResourceData(path, false, false);
+
+ CResourceData newRcData;
+ if(rcInfo.fRc.getType() == IResource.FILE){
+ if(base.getType() == ICSettingBase.SETTING_FILE){
+ newRcData = fCfgData.createFileData(path, (CFileData)base);
+ } else {
+ CFolderData folderData = (CFolderData)base;
+ CLanguageData lDatas[] = folderData.getLanguageDatas();
+ CLanguageData baseLData = CProjectDescriptionManager.getInstance().findLanguagDataForFile(rcInfo.fRc.getFullPath().lastSegment(), fProject, lDatas);
+ newRcData = fCfgData.createFileData(path, folderData, baseLData);
+ }
+ } else {
+ while(base.getType() == ICSettingBase.SETTING_FILE){
+ base = getResourceData(base.getPath().removeLastSegments(1), false, false);
+ }
+
+ newRcData = fCfgData.createFolderData(path, (CFolderData)base);
+ }
+
+ fRcDataHolder.getChildContainer(path, true, true).setValue(newRcData);
+ return newRcData;
+ }
+ return null;
+ }
+
+ private void applyEntries(CResourceData data, RcDesInfo info, int op){
+ CLanguageData lDatas[] = data.getType() == ICSettingBase.SETTING_FILE ?
+ new CLanguageData[]{((CFileData)data).getLanguageData()}
+ : ((CFolderData)data).getLanguageDatas();
+
+ for(int i = 0; i < lDatas.length; i++){
+ CLanguageData lData = lDatas[i];
+ if(lData == null)
+ continue;
+
+ applyEntries(lData, info, op);
+ }
+ }
+
+
+ private void applyEntries(CLanguageData lData, RcDesInfo info, int op){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int supported = lData.getSupportedEntryKinds();
+ for(int i = 0; i < kinds.length; i++){
+ int kind = kinds[i];
+ if((supported & kind) == 0)
+ continue;
+
+ ICLanguageSettingEntry opEntries[] = info.getEntries(kind);
+ ICLanguageSettingEntry oldEntries[] = op != OP_REPLACE ? lData.getEntries(kind) : null;
+ ICLanguageSettingEntry result[] = composeNewEntries(oldEntries, opEntries, op);
+ lData.setEntries(kind, result);
+ }
+ }
+
+ private ICLanguageSettingEntry[] composeNewEntries(ICLanguageSettingEntry oldEntries[],
+ ICLanguageSettingEntry newEntries[],
+ int op){
+ ICLanguageSettingEntry result[];
+ switch(op){
+ case OP_ADD:{
+ Set oldSet = new HashSet(Arrays.asList(oldEntries));
+ Set newSet = new HashSet(Arrays.asList(newEntries));
+ newSet.removeAll(oldSet);
+ if(newSet.size() == 0){
+ result = oldEntries;
+ } else {
+ result = new ICLanguageSettingEntry[oldEntries.length + newSet.size()];
+ newSet.toArray(result);
+ System.arraycopy(oldEntries, 0, result, newSet.size(), oldEntries.length);
+ }
+ break;
+ }
+ case OP_REMOVE:{
+ Set oldSet = new HashSet(Arrays.asList(oldEntries));
+ Set newSet = new HashSet(Arrays.asList(newEntries));
+ oldSet.removeAll(newSet);
+ if(oldSet.size() == 0){
+ result = new ICLanguageSettingEntry[0];
+ } else {
+ result = new ICLanguageSettingEntry[oldSet.size()];
+ oldSet.toArray(result);
+ }
+ break;
+ }
+ case OP_REPLACE:
+ default:
+ result = newEntries;
+ break;
+ }
+
+ return result;
+ }
+
+ private PathEntryKyndStore sort(ResolvedEntry[] rEntries, PathEntryKyndStore store){
+ if(store == null){
+ store = new PathEntryKyndStore();
+ }
+
+ ResolvedEntry rEntry;
+ for(int i = 0; i < rEntries.length; i++){
+ rEntry = rEntries[i];
+ List list = (List)store.get(rEntry.fEntry.getEntryKind());
+ if(list == null){
+ list = new ArrayList();
+ store.put(rEntry.fEntry.getEntryKind(), list);
+ }
+ list.add(rEntry);
+ }
+
+ return store;
+ }
+
+// private void listStoreToArrayStore(PathEntryKyndStore store, boolean nullAsEmptyArray){
+// int[]kinds = store.getSupportedKinds();
+// int kind;
+//
+// for(int i = 0; i < kinds.length; i++){
+// kind = kinds[i];
+// ResolvedE
+// List list = (List)store.get(kind);
+// if(list == null && nullAsEmptyArray){
+//
+// }
+// }
+// }
+
+
+ public ReferenceSettingsInfo applyPathEntries(IPathEntry[] usrEntries, IPathEntry[] sysEntries, int op){
+ ResolvedEntry[] rEntries = getResolvedEntries(usrEntries, sysEntries);
+ return addPathEntries(rEntries, op);
+ }
+
+ private void propagateValues(PathSettingsContainer cr, List langEntryInfoList){
+
+ RcDesInfo rcDes = (RcDesInfo)cr.getValue();
+ if(rcDes != null){
+ List rEntries = rcDes.fResolvedEntries;
+ List curLanfInfos = new ArrayList(rEntries.size() + langEntryInfoList.size());
+ for(Iterator iter = rEntries.iterator(); iter.hasNext();){
+ ResolvedEntry re = (ResolvedEntry)iter.next();
+ LangEntryInfo li = createLangEntryInfo(re);
+ if(li != null){
+ curLanfInfos.add(li);
+ }
+ }
+
+ curLanfInfos.addAll(langEntryInfoList);
+ langEntryInfoList = curLanfInfos;
+ }
+
+ for(Iterator iter = langEntryInfoList.iterator(); iter.hasNext();){
+ LangEntryInfo li = (LangEntryInfo)iter.next();
+ rcDes.add(li);
+ }
+
+ PathSettingsContainer directChildren[] = cr.getDirectChildren();
+ for(int i = 0; i < directChildren.length; i++){
+ filterAndPropagate(directChildren[i], langEntryInfoList);
+ }
+ }
+
+ private void filterAndPropagate(PathSettingsContainer cr, List list){
+ list = new ArrayList(list);
+ IPath path = cr.getPath();
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ LangEntryInfo li = (LangEntryInfo)iter.next();
+ ResolvedEntry re = li.fResolvedEntry;
+ ResourceInfo[] filters = re.getFilterInfos();
+ for(int i = 0; i < filters.length; i++){
+ IResource rc = filters[i].fRc;
+ IPath projPath = rc.getProjectRelativePath();
+ if(projPath.isPrefixOf(path)){
+ iter.remove();
+ break;
+ }
+ }
+ }
+
+ propagateValues(cr, list);
+ }
+
+// private void propagateValues(PathSettingsContainer cr){
+// RcDesInfo rcDes = (RcDesInfo)cr.getValue();
+// if(rcDes == null)
+// return;
+//
+// final List rEntries = rcDes.fResolvedEntries;
+//
+// int size = rEntries.size();
+// if(size == 0)
+// return;
+//
+// ArrayList[] skipLists = new ArrayList[size];
+// ArrayList skipList;
+// ResolvedEntry rEntry;
+// ResourceInfo[] filters;
+// ResourceInfo filter;
+// for(int i = 0; i < size; i++){
+// rEntry = (ResolvedEntry)rEntries.get(i);
+// filters = rEntry.getFilterInfos();
+// if(filters.length != 0){
+//
+// }
+// }
+//
+// cr.accept(new IPathSettingsContainerVisitor(){
+//
+// public boolean visit(PathSettingsContainer container) {
+// if(container == cr){
+//
+// } else {
+// for(Iterator iter = rEntries.iterator(); iter.hasNext();){
+// ResolvedEntry re = (ResolvedEntry)iter.next();
+// ResourceInfo filters[] = re.getFilterInfos();
+//
+// }
+// }
+// return true;
+// }
+//
+// });
+// }
+
+ private int toLanguageEntryKind(int peKind){
+ switch(peKind){
+ case IPathEntry.CDT_LIBRARY:
+ return ICLanguageSettingEntry.LIBRARY_FILE;
+// case IPathEntry.CDT_PROJECT:
+// return ICLanguageSettingEntry;
+// case IPathEntry.CDT_SOURCE:
+// return INDEX_CDT_SOURCE;
+ case IPathEntry.CDT_INCLUDE:
+ return ICLanguageSettingEntry.INCLUDE_PATH;
+// case IPathEntry.CDT_CONTAINER:
+// return INDEX_CDT_CONTAINER;
+ case IPathEntry.CDT_MACRO:
+ return ICLanguageSettingEntry.MACRO;
+// case IPathEntry.CDT_OUTPUT:
+// return INDEX_CDT_OUTPUT;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ return ICLanguageSettingEntry.INCLUDE_FILE;
+ case IPathEntry.CDT_MACRO_FILE:
+ return ICLanguageSettingEntry.MACRO_FILE;
+ }
+ return 0;
+ }
+
+ private static int peKindToSettingKind(int peKind){
+ switch(peKind){
+ case IPathEntry.CDT_LIBRARY:
+ return ICLanguageSettingEntry.LIBRARY_FILE;
+// case IPathEntry.CDT_PROJECT:
+// return ICLanguageSettingEntry;
+ case IPathEntry.CDT_SOURCE:
+ return ICLanguageSettingEntry.SOURCE_PATH;
+ case IPathEntry.CDT_INCLUDE:
+ return ICLanguageSettingEntry.INCLUDE_PATH;
+// case IPathEntry.CDT_CONTAINER:
+// return INDEX_CDT_CONTAINER;
+ case IPathEntry.CDT_MACRO:
+ return ICLanguageSettingEntry.MACRO;
+ case IPathEntry.CDT_OUTPUT:
+ return ICLanguageSettingEntry.OUTPUT_PATH;
+ case IPathEntry.CDT_INCLUDE_FILE:
+ return ICLanguageSettingEntry.INCLUDE_FILE;
+ case IPathEntry.CDT_MACRO_FILE:
+ return ICLanguageSettingEntry.MACRO_FILE;
+ }
+ return 0;
+ }
+
+ private ResolvedEntry[] getResolvedEntries(PathEntryResolveInfo info){
+ PathEntryResolveInfoElement els[] = info.getElements();
+ List list = new ArrayList();
+ for(int i = 0; i < els.length; i++){
+ getResolvedEntries(els[i], list);
+ }
+ return (ResolvedEntry[])list.toArray(new ResolvedEntry[list.size()]);
+ }
+
+ private List getResolvedEntries(PathEntryResolveInfoElement el, List list){
+ if(list == null)
+ list = new ArrayList();
+
+ IPathEntry[] rpEntries = el.getResolvedEntries();
+ IPathEntry rpEntry;
+ ResolvedEntry resolvedE;
+ IPathEntry rawEntry = el.getRawEntry();
+ if(rawEntry.getEntryKind() == IPathEntry.CDT_PROJECT){
+ resolvedE = createResolvedEntry(rawEntry, el);
+ if(resolvedE != null)
+ list.add(resolvedE);
+ }
+ for(int i = 0; i < rpEntries.length; i++){
+ rpEntry = rpEntries[i];
+ resolvedE = createResolvedEntry(rpEntry, el);
+ if(resolvedE != null)
+ list.add(resolvedE);
+ }
+ return list;
+ }
+
+ private ResolvedEntry createResolvedEntry(IPathEntry entry, PathEntryResolveInfoElement el){
+ switch(entry.getEntryKind()){
+// case IPathEntry.CDT_PROJECT:
+// //should not be here
+ case IPathEntry.CDT_CONTAINER:
+ //the case of extension path entry container
+ return null;
+ }
+ return new ResolvedEntry(entry, el);
+ }
+
+
+ private ResolvedEntry[] getResolvedEntries(IPathEntry[] usrEntries, IPathEntry[] sysEntries){
+ int length = usrEntries != null ? usrEntries.length : 0;
+ if(sysEntries != null)
+ length += sysEntries.length;
+ ResolvedEntry[] rEntries = new ResolvedEntry[length];
+ int num = 0;
+ if(usrEntries != null){
+ for(int i = 0; i < usrEntries.length; i++){
+ rEntries[num++] = new ResolvedEntry(usrEntries[i], false);
+ }
+ }
+
+ if(sysEntries != null){
+ for(int i = 0; i < sysEntries.length; i++){
+ rEntries[num++] = new ResolvedEntry(sysEntries[i], true);
+ }
+ }
+ return rEntries;
+ }
+
+ private ResourceInfo[] resolveFilter(IContainer container, IPath path){
+ IPath containerFullPath = container.getFullPath();
+ IPath fullPath = containerFullPath.append(path);
+ PathSettingsContainer cr = fTranslatedFilters.getChildContainer(fullPath, false, false);
+ ResourceInfo[] baseInfos = (ResourceInfo[])cr.getValue();
+ ResourceInfo[] result;
+ if(!baseInfos[0].fExists){
+ //resource does not exis, always create new rc info and not add it to map
+ ResourceInfo inexistent = new ResourceInfo(container.getFolder(path), false);
+ result = new ResourceInfo[]{inexistent};
+ } else {
+ //base exists
+ IPath baseTranslatedPath = cr.getPath();
+ if(baseTranslatedPath.equals(fullPath)){
+ result = baseInfos;
+ } else if(containerFullPath.isPrefixOf(baseTranslatedPath)){
+ IPath filterToTranslate = fullPath.removeFirstSegments(baseTranslatedPath.segmentCount());
+ result = performTranslation(baseTranslatedPath, baseInfos, filterToTranslate);
+ } else {
+ //should never be here
+ throw new IllegalStateException();
+ }
+ }
+
+ return result;
+ }
+
+ private ResourceInfo[] performTranslation(IPath basePath, ResourceInfo baseInfos[], IPath filter){
+ ResourceInfo result[];
+ int segCount = filter.segmentCount();
+ String seg;
+ int i = 0;
+ for(; i < segCount; i++){
+ if(!baseInfos[0].fExists)
+ break;
+ seg = filter.segment(0);
+ baseInfos = performTranslation(basePath, baseInfos, seg);
+ basePath = basePath.append(seg);
+ filter = filter.removeFirstSegments(1);
+ }
+
+ if(i < segCount){
+ result = new ResourceInfo[baseInfos.length];
+ ResourceInfo baseInfo;
+ IFolder rc;
+
+ for(int k = 0; k < baseInfos.length; k++){
+ baseInfo = baseInfos[k];
+ rc = (IFolder)baseInfo.fRc;
+ rc = rc.getFolder(filter);
+ result[k] = new ResourceInfo(rc, false);
+ }
+ } else {
+ result = baseInfos;
+ }
+
+ return result;
+ }
+
+ private ResourceInfo[] performTranslation(IPath basePath, ResourceInfo[] baseInfos, String seg){
+ IPath filterFullPath = basePath.append(seg);
+ boolean needsParsing = hasSpecChars(seg);
+ ResourceInfo baseInfo;
+ List list = new ArrayList();
+ char[] segChars = seg.toCharArray();
+ IResource baseRc;
+ for(int i = 0; i < baseInfos.length; i++){
+ baseInfo = baseInfos[i];
+ baseRc = baseInfo.fRc;
+ if(baseRc.getType() == IResource.FILE){
+ continue;
+ } else {
+ IContainer baseCr = (IContainer)baseRc;
+ IResource rc = baseCr.findMember(seg);
+ if(rc != null){
+ ResourceInfo rcInfo = new ResourceInfo(rc, true);
+ addRcInfoToMap(rcInfo);
+ list.add(rcInfo);
+ } else if (needsParsing){
+ try {
+ IResource children[] = baseCr.members();
+ ResourceInfo rcInfo;
+ for(int k = 0; k < children.length; k++){
+ if(CoreModelUtil.match(segChars, children[i].getName().toCharArray(), true)){
+ rcInfo = new ResourceInfo(children[i], true);
+ addRcInfoToMap(rcInfo);
+ list.add(rcInfo);
+ }
+ }
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ }
+ }
+
+ if(list.size() == 0){
+ IFolder f = fRoot.getFolder(filterFullPath);
+ ResourceInfo rcInfo = new ResourceInfo(f, false);
+ addRcInfoToMap(rcInfo);
+ list.add(rcInfo);
+ }
+
+ ResourceInfo[] result = new ResourceInfo[list.size()];
+ list.toArray(result);
+ addResolvedFilterToMap(filterFullPath, result, false);
+ return result;
+ }
+
+ private boolean hasSpecChars(String str){
+ for(int i = 0; i < SPEC_CHARS.length; i++){
+ if(str.indexOf(SPEC_CHARS[i]) != -1)
+ return true;
+ }
+ return false;
+ }
+
+ private void addResolvedFilterToMap(IPath fullFilterPath ,ResourceInfo[] resolved, boolean check){
+ if(check){
+ PathSettingsContainer cr = fTranslatedFilters.getChildContainer(fullFilterPath, false, false);
+ ResourceInfo[] infos = (ResourceInfo[])cr.getValue();
+ if(!infos[0].fExists)
+ return;
+ }
+
+ PathSettingsContainer cr = fTranslatedFilters.getChildContainer(fullFilterPath, true, true);
+ cr.setValue(resolved);
+ }
+
+ private ResourceInfo findResourceInfo(IContainer container, IPath relPath, boolean folderIfNotExist){
+ IPath fullPath = container.getFullPath().append(relPath);
+ ResourceInfo rcInfo = (ResourceInfo)fResourceMap.get(fullPath);
+
+ if(rcInfo == null){
+ IResource rc = container.findMember(relPath);
+ boolean exists = true;
+ if(rc == null){
+ exists = false;
+ if(container.getType() == IResource.ROOT && relPath.segmentCount() == 1){
+ rc = fRoot.getProject(relPath.segment(0));
+ } else if(folderIfNotExist) {
+ rc = container.getFolder(relPath);
+ } else {
+ rc = container.getFile(relPath);
+ }
+ }
+
+ rcInfo = new ResourceInfo(rc, exists);
+ addRcInfoToMap(rcInfo);
+ }
+ return rcInfo;
+ }
+
+ private void addRcInfoToMap(ResourceInfo rcInfo){
+ IPath fullPath = rcInfo.fRc.getFullPath();
+ fResourceMap.put(fullPath, rcInfo);
+ addResolvedFilterToMap(fullPath, new ResourceInfo[]{rcInfo}, true);
+ }
+
+ public static IPathEntry[] decodePathEntries(IProject project, ICStorageElement el){
+ ArrayList pathEntries = new ArrayList();
+ ICStorageElement children[] = el.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ ICStorageElement child = children[i];
+ if (child.getName().equals(PATH_ENTRY)) {
+ try {
+ pathEntries.add(decodePathEntry(project, child));
+ } catch (CModelException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ }
+ IPathEntry[] entries = new IPathEntry[pathEntries.size()];
+ pathEntries.toArray(entries);
+ return entries;
+ }
+
+ private static String getAttribute(ICStorageElement el, String attr){
+ String v = el.getAttribute(attr);
+ if(v != null)
+ return v;
+ return "";
+ }
+
+ static IPathEntry decodePathEntry(IProject project, ICStorageElement element) throws CModelException {
+ IPath projectPath = project.getFullPath();
+
+ // kind
+ String kindAttr = getAttribute(element, ATTRIBUTE_KIND);
+ int kind = PathEntry.kindFromString(kindAttr);
+
+ // exported flag
+ boolean isExported = false;
+ if (element.getAttribute(ATTRIBUTE_EXPORTED) != null) {
+ isExported = element.getAttribute(ATTRIBUTE_EXPORTED).equals(VALUE_TRUE);
+ }
+
+ // get path and ensure it is absolute
+ IPath path;
+ if (element.getAttribute(ATTRIBUTE_PATH) != null) {
+ path = new Path(element.getAttribute(ATTRIBUTE_PATH));
+ } else {
+ path = new Path(""); //$NON-NLS-1$
+ }
+ if (!path.isAbsolute()) {
+ path = projectPath.append(path);
+ }
+
+ // check fo the base path
+ IPath basePath = new Path(getAttribute(element, ATTRIBUTE_BASE_PATH));
+
+ // get the base ref
+ IPath baseRef = new Path(getAttribute(element, ATTRIBUTE_BASE_REF));
+
+ // exclusion patterns (optional)
+ String exclusion = getAttribute(element, ATTRIBUTE_EXCLUDING);
+ IPath[] exclusionPatterns = APathEntry.NO_EXCLUSION_PATTERNS;
+ if (exclusion != null && exclusion.length() > 0) {
+ char[][] patterns = CharOperation.splitOn('|', exclusion.toCharArray());
+ int patternCount;
+ if ((patternCount = patterns.length) > 0) {
+ exclusionPatterns = new IPath[patternCount];
+ for (int j = 0; j < patterns.length; j++) {
+ exclusionPatterns[j] = new Path(new String(patterns[j]));
+ }
+ }
+ }
+
+ // recreate the entry
+ switch (kind) {
+ case IPathEntry.CDT_PROJECT :
+ return CoreModel.newProjectEntry(path, isExported);
+ case IPathEntry.CDT_LIBRARY : {
+ IPath libraryPath = new Path(getAttribute(element, ATTRIBUTE_LIBRARY));
+ // source attachment info (optional)
+ IPath sourceAttachmentPath = element.getAttribute(ATTRIBUTE_SOURCEPATH) != null ? new Path(
+ element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
+ IPath sourceAttachmentRootPath = element.getAttribute(ATTRIBUTE_ROOTPATH) != null ? new Path(
+ element.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
+ IPath sourceAttachmentPrefixMapping = element.getAttribute(ATTRIBUTE_PREFIXMAPPING) != null ? new Path(
+ element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
+
+ if (baseRef != null && !baseRef.isEmpty()) {
+ return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath);
+ }
+ return CoreModel.newLibraryEntry(path, basePath, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath,
+ sourceAttachmentPrefixMapping, isExported);
+ }
+ case IPathEntry.CDT_SOURCE : {
+ // must be an entry in this project or specify another
+ // project
+ String projSegment = path.segment(0);
+ if (projSegment != null && projSegment.equals(project.getName())) { // this
+ // project
+ return CoreModel.newSourceEntry(path, exclusionPatterns);
+ }
+ // another project
+ return CoreModel.newProjectEntry(path, isExported);
+ }
+ case IPathEntry.CDT_OUTPUT :
+ return CoreModel.newOutputEntry(path, exclusionPatterns);
+ case IPathEntry.CDT_INCLUDE : {
+ // include path info
+ IPath includePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE));
+ // isSysteminclude
+ boolean isSystemInclude = false;
+ if (element.getAttribute(ATTRIBUTE_SYSTEM) != null) {
+ isSystemInclude = getAttribute(element, ATTRIBUTE_SYSTEM).equals(VALUE_TRUE);
+ }
+ if (baseRef != null && !baseRef.isEmpty()) {
+ return CoreModel.newIncludeRefEntry(path, baseRef, includePath);
+ }
+ return CoreModel.newIncludeEntry(path, basePath, includePath, isSystemInclude, exclusionPatterns, isExported);
+ }
+ case IPathEntry.CDT_INCLUDE_FILE: {
+ // include path info
+ IPath includeFilePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE_FILE));
+ return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, isExported);
+ }
+ case IPathEntry.CDT_MACRO : {
+ String macroName = getAttribute(element, ATTRIBUTE_NAME);
+ String macroValue = getAttribute(element, ATTRIBUTE_VALUE);
+ if (baseRef != null && !baseRef.isEmpty()) {
+ return CoreModel.newMacroRefEntry(path, baseRef, macroName);
+ }
+ return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns, isExported);
+ }
+ case IPathEntry.CDT_MACRO_FILE : {
+ IPath macroFilePath = new Path(getAttribute(element, ATTRIBUTE_MACRO_FILE));
+ return CoreModel.newMacroFileEntry(path, basePath, baseRef, macroFilePath, exclusionPatterns, isExported);
+ }
+ case IPathEntry.CDT_CONTAINER : {
+ IPath id = new Path(getAttribute(element, ATTRIBUTE_PATH));
+ return CoreModel.newContainerEntry(id, isExported);
+ }
+ default : {
+ ICModelStatus status = new CModelStatus(IStatus.ERROR, "PathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new CModelException(status);
+ }
+ }
+ }
+
+ public static PathEntryCollector collectEntries(IProject project, ICConfigurationDescription des){
+ CConfigurationData data = des instanceof CConfigurationDescriptionCache ?
+ (CConfigurationData)des : ((IInternalCCfgInfo)des).getConfigurationData(false);
+
+ ReferenceSettingsInfo info = new ReferenceSettingsInfo(des);
+
+ return collectEntries(project, data, info);
+ }
+
+ public static PathEntryCollector collectEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo){
+ final PathEntryCollector cr = new PathEntryCollector(project);
+ PathSettingsContainer rcDatas = createRcDataHolder(data);
+ IPath srcPaths[] = data.getSourcePaths();
+ ICSourceEntry sEntries[] = calculateSourceEntriesFromPaths(project, rcDatas, srcPaths);
+ if(sEntries != null && sEntries.length != 0){
+ cr.setSourceOutputEntries(ICSettingEntry.SOURCE_PATH, sEntries);
+ }
+ CBuildData bData = data.getBuildData();
+ if(bData != null){
+ ICOutputEntry oEntries[] = bData.getOutputDirectories();
+ if(oEntries != null && oEntries.length != 0){
+ cr.setSourceOutputEntries(ICSettingEntry.OUTPUT_PATH, oEntries);
+ }
+ }
+ final HashSet exportedSettings = new HashSet();
+ if(refInfo != null){
+ cr.setRefProjects(refInfo.getReferencedProjectsPaths());
+ ICExternalSetting[] settings = refInfo.getExternalSettings();
+ for(int i = 0; i < settings.length; i++){
+ exportedSettings.addAll(Arrays.asList(settings[i].getEntries()));
+ }
+ }
+
+ final int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ rcDatas.accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ CResourceData data = (CResourceData)container.getValue();
+ PathEntryCollector child = cr.createChild(container.getPath());
+ for(int i = 0; i < kinds.length; i++){
+ List list = new ArrayList();
+ if(collectEntries(kinds[i], data, list)){
+ ICLanguageSettingEntry[] entries = (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ child.setEntries(kinds[i], entries, exportedSettings);
+ }
+ }
+ return true;
+ }
+
+ });
+ return cr;
+ }
+
+ private static boolean collectEntries(int kind, CResourceData data, List list){
+ if(data.getType() == ICSettingBase.SETTING_FOLDER){
+ return collectEntries(kind, (CFolderData)data, list);
+ }
+ return collectEntries(kind, (CFileData)data, list);
+ }
+
+ private static boolean collectEntries(int kind, CFolderData data, List list){
+
+ CLanguageData lDatas[] = data.getLanguageDatas();
+ boolean supported = false;
+ if(lDatas != null && lDatas.length != 0){
+ for(int i = 0; i < lDatas.length; i++){
+ if(collectEntries(kind, lDatas[i], list))
+ supported = true;
+ }
+ }
+ return supported;
+ }
+
+ private static boolean collectEntries(int kind, CFileData data, List list){
+
+ CLanguageData lData = data.getLanguageData();
+ if(lData != null){
+ return collectEntries(kind, lData, list);
+ }
+ return false;
+ }
+
+ private static boolean collectEntries(int kind, CLanguageData lData, List list){
+// if(list == null)
+// list = new ArrayList();
+
+ if((kind & lData.getSupportedEntryKinds()) != 0){
+ ICLanguageSettingEntry[] entries = lData.getEntries(kind);
+ if(entries != null && entries.length != 0){
+ list.addAll(Arrays.asList(entries));
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ public static IPathEntry[] getPathEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo, int flags){
+ PathEntryCollector cr = collectEntries(project, data, refInfo);
+ return cr.getEntries(flags);
+ }
+//
+// private
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java
new file mode 100644
index 00000000000..55eb7367e64
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java
@@ -0,0 +1,411 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class PathSettingsContainer {
+ private static final Object INEXISTENT_VALUE = new Object();
+ private static final int INIT_CHILDREN_MAP_CAPACITY = 2;
+
+ private Map fChildrenMap;
+ private Object fValue;
+ private IPath fPath;
+ private String fName;
+ private PathSettingsContainer fRootContainer;
+ private PathSettingsContainer fDirectParentContainer;
+ private List fListeners;
+
+ private static final int ADDED = 1;
+ private static final int REMOVED = 2;
+ private static final int VALUE_CHANGED = 3;
+ private static final int PATH_CHANGED = 4;
+
+
+ public static PathSettingsContainer createRootContainer(){
+ return new PathSettingsContainer();
+ }
+
+ private PathSettingsContainer(){
+ this(null, null, new String());
+ }
+
+ private PathSettingsContainer(PathSettingsContainer root, PathSettingsContainer parent, String name){
+ fRootContainer = root;
+ fDirectParentContainer = parent;
+ fName = name;
+ if(fRootContainer == null){
+ fRootContainer = this;
+// fPath = new Path(name);
+ } else {
+ fValue = INEXISTENT_VALUE;
+ }
+ }
+
+ private Map getChildrenMap(boolean create){
+ if(fChildrenMap == null && create)
+ fChildrenMap = new HashMap(INIT_CHILDREN_MAP_CAPACITY);
+ return fChildrenMap;
+ }
+
+ private PathSettingsContainer getChild(String name, boolean create){
+ Map map = getChildrenMap(create);
+ if(map != null){
+ PathSettingsContainer child = (PathSettingsContainer)map.get(name);
+ if(child == null && create){
+ child = new PathSettingsContainer(fRootContainer, this, name);
+ connectChild(child);
+ }
+ return child;
+ }
+ return null;
+ }
+
+ private void notifyChange(PathSettingsContainer container, int type, Object oldValue, boolean childrenAffected){
+ List list = getListenersList(false);
+ if(list != null && list.size() > 0){
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ switch(type){
+ case ADDED:
+ ((IPathSettingsContainerListener)iter.next()).containerAdded(container);
+ break;
+ case REMOVED:
+ ((IPathSettingsContainerListener)iter.next()).aboutToRemove(container);
+ break;
+ case VALUE_CHANGED:
+ ((IPathSettingsContainerListener)iter.next()).containerValueChanged(container, oldValue);
+ break;
+ case PATH_CHANGED:
+ ((IPathSettingsContainerListener)iter.next()).containerPathChanged(container, (IPath)oldValue, childrenAffected);
+ break;
+ }
+
+ }
+ }
+ PathSettingsContainer parent = getParentContainer();
+ if(parent != null)
+ parent.notifyChange(container, type, oldValue, childrenAffected);
+ }
+
+ private List getListenersList(boolean create){
+ if(fListeners == null && create)
+ fListeners = new ArrayList();
+ return fListeners;
+ }
+
+ private boolean hasChildren(){
+ Map map = getChildrenMap(false);
+ return map != null && map.size() != 0;
+ }
+
+ public PathSettingsContainer getChildContainer(IPath path, boolean create, boolean exactPath){
+ PathSettingsContainer container = findContainer(path, create, exactPath);
+ if(container != null && container.internalGetValue() == INEXISTENT_VALUE){
+ if(create){
+ container.internalSetValue(null);
+ notifyChange(container, ADDED, null, false);
+ } else if(!exactPath){
+ for(;
+ container.internalGetValue() == INEXISTENT_VALUE;
+ container = container.getDirectParentContainer());
+ } else if(container.internalGetValue() == INEXISTENT_VALUE){
+ container = null;
+ }
+
+ }
+ return container;
+ }
+
+ public PathSettingsContainer[] getChildren(final boolean includeThis){
+ final List list = new ArrayList();
+ accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ if(container != PathSettingsContainer.this || includeThis)
+ list.add(container);
+ return true;
+ }
+ });
+
+ return (PathSettingsContainer[])list.toArray(new PathSettingsContainer[list.size()]);
+ }
+
+ public PathSettingsContainer[] getChildrenForPath(IPath path, boolean includePath){
+ PathSettingsContainer cr = findContainer(path, false, true);
+ if(cr != null)
+ return cr.getChildren(includePath);
+ return new PathSettingsContainer[0];
+ }
+
+ public PathSettingsContainer[] getDirectChildrenForPath(IPath path){
+ PathSettingsContainer cr = findContainer(path, false, true);
+ if(cr != null)
+ return cr.getDirectChildren();
+ return new PathSettingsContainer[0];
+ }
+
+ public PathSettingsContainer[] getDirectChildren(){
+ List list = doGetDirectChildren(null);
+ if(list == null || list.size() == 0)
+ return new PathSettingsContainer[0];
+ return (PathSettingsContainer[])list.toArray(new PathSettingsContainer[list.size()]);
+ }
+
+ private List doGetDirectChildren(List list){
+ Map map = getChildrenMap(false);
+ if(map != null){
+ if(list == null)
+ list = new ArrayList();
+ for(Iterator iter = map.values().iterator(); iter.hasNext(); ){
+ PathSettingsContainer cr = (PathSettingsContainer)iter.next();
+ if(cr.fValue == INEXISTENT_VALUE){
+ cr.doGetDirectChildren(list);
+ } else {
+ list.add(cr);
+ }
+ }
+ }
+ return list;
+ }
+
+ public Object[] getValues(final boolean includeThis){
+ final List list = new ArrayList();
+ accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ if(container != PathSettingsContainer.this || includeThis)
+ list.add(container.getValue());
+ return true;
+ }
+ });
+
+ return list.toArray();
+ }
+
+ public PathSettingsContainer getParentContainer(){
+ if(fDirectParentContainer != null)
+ return fDirectParentContainer.getValidContainer();
+ return null;
+ }
+
+ private PathSettingsContainer getValidContainer(){
+ if(internalGetValue() == INEXISTENT_VALUE)
+ return getDirectParentContainer().getValidContainer();
+ return this;
+ }
+
+ public Object removeChildContainer(IPath path){
+ PathSettingsContainer container = getChildContainer(path, false, true);
+ Object value = null;
+ if(container != null){
+ value = container.getValue();
+ container.remove();
+ }
+ return value;
+ }
+
+ public void remove(){
+ if(!isValid())
+ return;
+
+ if(fValue != INEXISTENT_VALUE){
+ notifyChange(this, REMOVED, null, false);
+ internalSetValue(INEXISTENT_VALUE);
+ }
+ if(!hasChildren()) {
+ getDirectParentContainer().deleteChild(this);
+ fDirectParentContainer.checkRemove();
+ fDirectParentContainer = null;
+ fRootContainer = null;
+ }
+ }
+
+ private void checkRemove(){
+ if(fValue == INEXISTENT_VALUE && !hasChildren())
+ remove();
+ }
+
+ private void disconnectChild(PathSettingsContainer child){
+ getChildrenMap(true).remove(child.getName());
+ }
+
+ private void connectChild(PathSettingsContainer child){
+ getChildrenMap(true).put(child.getName(), child);
+ }
+
+ public boolean isValid(){
+ return fValue != INEXISTENT_VALUE && fRootContainer != null;
+ }
+
+ public void removeChildren(){
+ Map map = getChildrenMap(false);
+ if(map == null || map.size() == 0)
+ return;
+
+
+ Collection c = map.values();
+ PathSettingsContainer childContainers[] = (PathSettingsContainer[])c.toArray(new PathSettingsContainer[c.size()]);
+
+ for(int i = 0; i < childContainers.length; i++){
+ childContainers[i].removeChildren();
+ childContainers[i].remove();
+ }
+ }
+
+ private void deleteChild(PathSettingsContainer child){
+ getChildrenMap(false).remove(child.getName());
+ }
+
+ private String getName(){
+ return fName;
+ }
+
+ private PathSettingsContainer findContainer(IPath path, boolean create, boolean exactPath){
+ PathSettingsContainer container = null;
+ if(path.segmentCount() == 0)
+ container = this;
+ else {
+ PathSettingsContainer child = getChild(path.segment(0), create);
+ if(child != null)
+ container = child.findContainer(path.removeFirstSegments(1), create, exactPath);
+ else if(!exactPath)
+ container = this;
+ }
+ return container;
+ }
+
+ public void accept(IPathSettingsContainerVisitor visitor){
+ doAccept(visitor);
+ }
+
+ private boolean doAccept(IPathSettingsContainerVisitor visitor){
+ if(fValue != INEXISTENT_VALUE && !visitor.visit(this))
+ return false;
+
+ Map map = getChildrenMap(false);
+ if(map != null){
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ PathSettingsContainer child = (PathSettingsContainer)iter.next();
+ if(!child.doAccept(visitor))
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ public IPath getPath(){
+ if(fPath == null){
+ if(fDirectParentContainer != null)
+ fPath = fDirectParentContainer.getPath().append(fName);
+ else
+ fPath = new Path("/");
+ }
+ return fPath;
+ }
+
+ public void setPath(IPath path, boolean moveChildren){
+ if(path == null || isRoot() || path.equals(getPath()) || path.segmentCount() == 0)
+ return;
+
+ IPath oldPath = getPath();
+
+ fDirectParentContainer.disconnectChild(this);
+
+ if(!moveChildren){
+ if(hasChildren()){
+ PathSettingsContainer cr = new PathSettingsContainer(fRootContainer, fDirectParentContainer, fName);
+ for(Iterator iter = fChildrenMap.values().iterator(); iter.hasNext();){
+ PathSettingsContainer child = (PathSettingsContainer)iter.next();
+ iter.remove();
+ child.setParent(cr);
+ cr.connectChild(child);
+ }
+ }
+ } else {
+
+ }
+
+ PathSettingsContainer newParent = fRootContainer.findContainer(path.removeLastSegments(1), true, true);
+ PathSettingsContainer oldParent = fDirectParentContainer;
+ fName = path.segment(path.segmentCount()-1);
+ fPath = path;
+
+ setParent(newParent);
+ newParent.connectChild(this);
+
+ oldParent.checkRemove();
+ notifyChange(this, PATH_CHANGED, oldPath, moveChildren);
+ }
+
+ private Object internalGetValue(){
+ return fValue;
+ }
+
+ public boolean isRoot(){
+ return fRootContainer == this;
+ }
+
+ private Object internalSetValue(Object value){
+ Object oldValue = fValue;
+ fValue = value;
+ if(oldValue == INEXISTENT_VALUE){
+ oldValue = null;
+ } else if(fValue != INEXISTENT_VALUE){
+ notifyChange(this, VALUE_CHANGED, oldValue, false);
+ }
+ return oldValue;
+ }
+
+ public Object setValue(Object value){
+ if(fValue == INEXISTENT_VALUE)
+ throw new IllegalStateException();
+ return internalSetValue(value);
+ }
+
+ public Object getValue(){
+ if(fValue == INEXISTENT_VALUE)
+ throw new IllegalStateException();
+ return fValue;
+ }
+
+ public PathSettingsContainer getRootContainer(){
+ return fRootContainer;
+ }
+
+ private PathSettingsContainer getDirectParentContainer(){
+ return fDirectParentContainer;
+ }
+
+ public void addContainerListener(IPathSettingsContainerListener listenet){
+ List list = getListenersList(true);
+ list.add(listenet);
+ }
+
+ public void removeContainerListener(IPathSettingsContainerListener listenet){
+ List list = getListenersList(false);
+ if(list != null)
+ list.remove(listenet);
+ }
+
+ private void setParent(PathSettingsContainer parent){
+ fDirectParentContainer = parent;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java
new file mode 100644
index 00000000000..fb4408405e2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.settings.model.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+public class XmlStorageElement implements ICStorageElement {
+
+ Element fElement;
+ private ICStorageElement fParent;
+ private List fChildList = new ArrayList();
+ private boolean fChildrenCreated;
+ private String[] fAttributeFilters;
+ private String[] fChildFilters;
+ private boolean fParentRefAlowed;
+
+ public XmlStorageElement(Element element){
+ this(element, null, false);
+ }
+
+ public XmlStorageElement(Element element, ICStorageElement parent, boolean alowReferencingParent){
+ this(element, parent, alowReferencingParent, null, null);
+ }
+
+ public XmlStorageElement(Element element,
+ ICStorageElement parent,
+ boolean alowReferencingParent,
+ String[] attributeFilters,
+ String[] childFilters){
+ fElement = element;
+ fParent = parent;
+ fParentRefAlowed = alowReferencingParent;
+
+ if(attributeFilters != null && attributeFilters.length != 0)
+ fAttributeFilters = (String[])attributeFilters.clone();
+
+ if(childFilters != null && childFilters.length != 0)
+ fChildFilters = (String[])childFilters.clone();
+ }
+
+// public String[] getAttributeFilters(){
+// if(fAttributeFilters != null)
+// return (String[])fAttributeFilters.clone();
+// return null;
+// }
+
+// public String[] getChildFilters(){
+// if(fChildFilters != null)
+// return (String[])fChildFilters.clone();
+// return null;
+// }
+//
+// public boolean isParentRefAlowed(){
+// return fParentRefAlowed;
+// }
+
+ private void createChildren(){
+ if(fChildrenCreated)
+ return;
+
+ fChildrenCreated = true;
+ NodeList list = fElement.getChildNodes();
+ int size = list.getLength();
+ for(int i = 0; i < size; i++){
+ Node node = list.item(i);
+ if(node.getNodeType() == Node.ELEMENT_NODE
+ && isChildAlowed(node.getNodeName())){
+ createAddChild((Element)node, true, null, null);
+ }
+ }
+ }
+
+ private XmlStorageElement createAddChild(Element element,
+ boolean alowReferencingParent,
+ String[] attributeFilters,
+ String[] childFilters){
+ XmlStorageElement child = createChild(element, alowReferencingParent, attributeFilters, childFilters);
+ fChildList.add(child);
+ return child;
+ }
+
+ protected XmlStorageElement createChild(Element element,
+ boolean alowReferencingParent,
+ String[] attributeFilters,
+ String[] childFilters){
+ return new XmlStorageElement(element, this, alowReferencingParent, attributeFilters, childFilters);
+ }
+
+ public ICStorageElement[] getChildren() {
+ return getChildren(XmlStorageElement.class);
+ }
+
+ protected ICStorageElement[] getChildren(Class clazz){
+ createChildren();
+
+ ICStorageElement[] children = (ICStorageElement[])java.lang.reflect.Array.newInstance(
+ clazz, fChildList.size());
+
+ return (ICStorageElement[])fChildList.toArray(children);
+ }
+
+ public ICStorageElement getParent() {
+ return fParentRefAlowed ? fParent : null;
+ }
+
+ public String getAttribute(String name) {
+ if(isPropertyAlowed(name) && fElement.hasAttribute(name))
+ return fElement.getAttribute(name);
+ return null;
+ }
+
+ private boolean isPropertyAlowed(String name){
+ if(fAttributeFilters != null){
+ return checkString(name, fAttributeFilters);
+ }
+ return true;
+ }
+
+ private boolean isChildAlowed(String name){
+ if(fChildFilters != null){
+ return checkString(name, fChildFilters);
+ }
+ return true;
+ }
+
+ private boolean checkString(String name, String array[]){
+ if(array.length > 0){
+ for(int i = 0; i < array.length; i++){
+ if(name.equals(array[i]))
+ return false;
+ }
+ }
+ return true;
+ }
+
+// protected void childRemoved(ICStorageElement child) {
+// fChildList.remove(child);
+// }
+
+ protected void removed(){
+// fElement.getParentNode().removeChild(fElement);
+ fElement = null;
+// if(fParent != null)
+// ((XmlStorageElement)fParent).childRemoved(this);
+ }
+
+
+ public void removeChild(ICStorageElement el) {
+ if(el instanceof XmlStorageElement){
+ ICStorageElement[] children = getChildren();
+ for(int i = 0; i < children.length; i++){
+ if(children[i] == el){
+ XmlStorageElement xmlEl = (XmlStorageElement)el;
+ fElement.removeChild(xmlEl.fElement);
+ fChildList.remove(el);
+ xmlEl.removed();
+ }
+ }
+ }
+
+ }
+
+ public void removeAttribute(String name) {
+ if(isPropertyAlowed(name))
+ fElement.removeAttribute(name);
+ }
+
+ public void setAttribute(String name, String value) {
+ if(isPropertyAlowed(name))
+ fElement.setAttribute(name, value);
+ }
+
+ public void clear(){
+ createChildren();
+
+ ICStorageElement children[] = (ICStorageElement[])fChildList.toArray(new ICStorageElement[fChildList.size()]);
+ for(int i = 0; i < children.length; i++){
+ removeChild(children[i]);
+ }
+
+ NamedNodeMap map = fElement.getAttributes();
+ for(int i = 0; i < map.getLength(); i++){
+ Node attr = map.item(i);
+ if(isPropertyAlowed(attr.getNodeName()))
+ map.removeNamedItem(attr.getNodeName());
+ }
+ }
+
+ public ICStorageElement createChild(String name,
+ boolean alowReferencingParent,
+ String[] attributeFilters,
+ String[] childFilters) {
+ if(!isChildAlowed(name))
+ return null;
+ Element childElement = fElement.getOwnerDocument().createElement(name);
+ fElement.appendChild(childElement);
+ return createAddChild(childElement, alowReferencingParent, attributeFilters, childFilters);
+ }
+
+ public String getName() {
+ return fElement.getNodeName();
+ }
+
+ public ICStorageElement createChild(String name) {
+ return createChild(name, true, null, null);
+ }
+
+ public String getValue() {
+ Text text = getTextChild();
+ if(text != null)
+ return text.getData();
+ return null;
+ }
+
+ public void setValue(String value) {
+ Text text = getTextChild();
+ if(value != null){
+ if(text == null){
+ text = fElement.getOwnerDocument().createTextNode(value);
+ fElement.appendChild(text);
+ } else {
+ text.setData(value);
+ }
+ } else {
+ if(text != null){
+ fElement.removeChild(text);
+ }
+ }
+ }
+
+ private Text getTextChild(){
+ NodeList nodes = fElement.getChildNodes();
+ Text text = null;
+ for(int i = 0; i < nodes.getLength(); i++){
+ Node node = nodes.item(i);
+ if(node.getNodeType() == Node.TEXT_NODE){
+ text = (Text)node;
+ break;
+ }
+ }
+
+ return text;
+ }
+
+ public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException {
+ return addChild(el, true, null, null);
+ }
+
+ public ICStorageElement addChild(ICStorageElement el,
+ boolean alowReferencingParent,
+ String[] attributeFilters,
+ String[] childFilters) throws UnsupportedOperationException {
+
+ if(!isChildAlowed(el.getName()))
+ return null;
+
+ if(el instanceof XmlStorageElement){
+ XmlStorageElement xmlStEl = (XmlStorageElement)el;
+ Element xmlEl = xmlStEl.fElement;
+ Document thisDoc = fElement.getOwnerDocument();
+ Document otherDoc = xmlEl.getOwnerDocument();
+ if(!thisDoc.equals(otherDoc)){
+ xmlEl = (Element)thisDoc.importNode(xmlEl, true);
+ } else {
+ xmlEl = (Element)xmlEl.cloneNode(true);
+ }
+
+ xmlEl = (Element)fElement.appendChild(xmlEl);
+ return createAddChild(xmlEl, alowReferencingParent, attributeFilters, childFilters);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public String[] getAttributeFilters(){
+ if(fAttributeFilters != null)
+ return (String[])fAttributeFilters.clone();
+ return new String[0];
+ }
+
+ public String[] getChildFilters(){
+ if(fChildFilters != null)
+ return (String[])fChildFilters.clone();
+ return new String[0];
+ }
+
+ public boolean isParentRefAlowed(){
+ return fParentRefAlowed;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java
index 0f0b031c006..c674f1f1999 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -16,9 +16,12 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
-import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -65,7 +68,16 @@ public class CContainerInfo extends OpenableInfo {
resources = container.members(false);
}
- IPathEntry[] entries = cproject.getResolvedPathEntries();
+// IPathEntry[] entries = cproject.getResolvedPathEntries();
+ ICSourceEntry[] entries = null;
+ CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(cproject.getProject());
+ if(des != null){
+ ICConfigurationDescription cfg = des.getIndexConfiguration();
+ if(cfg != null){
+ entries = cfg.getSourceEntries();
+ }
+ }
+
if (resources != null) {
for (int i = 0; i < resources.length; i++) {
IResource member = resources[i];
@@ -112,15 +124,18 @@ public class CContainerInfo extends OpenableInfo {
nonCResources = resources;
}
- private static boolean isSourceEntry(IPath resourcePath, IPathEntry[] entries) {
+ private static boolean isSourceEntry(IPath resourcePath, ICSourceEntry[] entries) {
+ if(entries == null)
+ return false;
+
for (int k = 0; k < entries.length; k++) {
- IPathEntry entry = entries[k];
- if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
- IPath sourcePath = entry.getPath();
+ ICSourceEntry entry = entries[k];
+// if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
+ IPath sourcePath = entry.getFullPath();
if (resourcePath.equals(sourcePath)) {
return true;
}
- }
+// }
}
return false;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java
index 908defd94cf..880f00c5466 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -42,6 +42,11 @@ import org.eclipse.cdt.core.model.IOutputEntry;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -418,8 +423,12 @@ public class CProject extends Openable implements ICProject {
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoot(org.eclipse.cdt.core.model.ISourceEntry)
*/
public ISourceRoot getSourceRoot(ISourceEntry entry) throws CModelException {
+ return getSourceRoot(new CSourceEntry(entry.getPath(), entry.getExclusionPatterns(), 0));
+ }
+
+ public ISourceRoot getSourceRoot(ICSourceEntry entry) throws CModelException {
IPath p = getPath();
- IPath sp = entry.getPath();
+ IPath sp = entry.getFullPath();
if (p.isPrefixOf(sp)) {
int count = sp.matchingFirstSegments(p);
sp = sp.removeFirstSegments(count);
@@ -592,18 +601,29 @@ public class CProject extends Openable implements ICProject {
}
protected List computeSourceRoots() throws CModelException {
- IPathEntry[] entries = getResolvedPathEntries();
- ArrayList list = new ArrayList(entries.length);
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getEntryKind() == IPathEntry.CDT_SOURCE) {
- ISourceEntry sourceEntry = (ISourceEntry)entries[i];
- ISourceRoot root = getSourceRoot(sourceEntry);
- if (root != null) {
- list.add(root);
- }
+ //IPathEntry[] entries = getResolvedPathEntries();
+ ICSourceEntry[] entries = null;
+ CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false);
+ if(des != null){
+ ICConfigurationDescription cfg = des.getIndexConfiguration();
+ if(cfg != null)
+ entries = cfg.getSourceEntries();
+ }
+
+ if(entries != null){
+ ArrayList list = new ArrayList(entries.length);
+ for (int i = 0; i < entries.length; i++) {
+// if (entries[i].getEntryKind() == IPathEntry.CDT_SOURCE) {
+ ICSourceEntry sourceEntry = (ICSourceEntry)entries[i];
+ ISourceRoot root = getSourceRoot(sourceEntry);
+ if (root != null) {
+ list.add(root);
+ }
+// }
}
+ return list;
}
- return list;
+ return new ArrayList(0);
}
protected boolean computeSourceRoots(OpenableInfo info, IResource res) throws CModelException {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java
index d5c3703d2ed..15a5e268997 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -22,11 +22,15 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.core.model.ILibraryReference;
import org.eclipse.cdt.core.model.IOutputEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -77,25 +81,36 @@ class CProjectInfo extends OpenableInfo {
// determine if src == project
boolean srcIsProject = false;
- IPathEntry[] entries = null;
+ ICSourceEntry[] entries = null;
ICProject cproject = getElement().getCProject();
- IPath projectPath = cproject.getProject().getFullPath();
+ IProject project = cproject.getProject();
+ IPath projectPath = project.getFullPath();
char[][] exclusionPatterns = null;
- try {
- entries = cproject.getResolvedPathEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getEntryKind() == IPathEntry.CDT_SOURCE) {
- ISourceEntry entry = (ISourceEntry)entries[i];
- if (projectPath.equals(entry.getPath())) {
- srcIsProject = true;
- exclusionPatterns = entry.fullExclusionPatternChars();
- break;
- }
+// try {
+// entries = cproject.getResolvedPathEntries();
+ CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(project);
+ if(des != null){
+ ICConfigurationDescription cfg = des.getIndexConfiguration();
+ if(cfg != null){
+ entries = cfg.getSourceEntries();
}
}
- } catch (CModelException e) {
+
+ if(entries != null){
+ for (int i = 0; i < entries.length; i++) {
+// if (entries[i].getEntryKind() == IPathEntry.CDT_SOURCE) {
+ ICSourceEntry entry = /*(ISourceEntry)*/entries[i];
+ if (projectPath.equals(entry.getFullPath())) {
+ srcIsProject = true;
+ exclusionPatterns = entry.fullExclusionPatternChars();
+ break;
+ }
+// }
+ }
+ }
+// } catch (CModelException e) {
// ignore
- }
+// }
ArrayList notChildren = new ArrayList();
try {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java
index bdba86f9b4d..37b51b24237 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java
@@ -374,7 +374,8 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent)
*/
public void descriptorChanged(CDescriptorEvent event) {
- if (event.getType() == CDescriptorEvent.CDTPROJECT_CHANGED) {
+ if (event.getType() == CDescriptorEvent.CDTPROJECT_CHANGED
+ /*|| event.getType() == CDescriptorEvent.CDTPROJECT_ADDED*/) {
ICDescriptor cdesc = event.getDescriptor();
if (cdesc != null && cdesc.getProject() == fProject){
// Call the listeners.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java
new file mode 100644
index 00000000000..7ef35019e41
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.model;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ILanguageDescriptor;
+import org.eclipse.cdt.internal.core.CExtensionDescriptor;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+
+public class LanguageDescriptor extends CExtensionDescriptor implements
+ ILanguageDescriptor {
+ private static final String ATTRIBUTE_CLASS = "class";
+ private static final String ELEMENT_CONTENT_TYPE = "contentType";
+ private static final String NAMESPACE_SEPARATOR = "."; //$NON-NLS-1$
+
+ private ILanguage fLanguage;
+ private String fContentTypeIds[];
+ private String fId;
+ private IContentType[] fContentTypes;
+
+
+ public LanguageDescriptor(IConfigurationElement el) {
+ super(el);
+ }
+
+ public ILanguage getLanguage() {
+ if(fLanguage == null){
+ SafeRunner.run(new ISafeRunnable(){
+ public void handleException(Throwable exception) {
+ CCorePlugin.log(exception);
+ }
+
+ public void run() throws Exception {
+ fLanguage = (ILanguage)getConfigurationElement().createExecutableExtension(ATTRIBUTE_CLASS);
+ }
+ });
+ }
+ return fLanguage;
+ }
+
+ public String[] getContentTypeIds() {
+ if(fContentTypeIds == null){
+ fContentTypeIds = calculateCintentTypeIds();
+ }
+ return fContentTypeIds;
+ }
+
+ private String[] calculateCintentTypeIds(){
+ IConfigurationElement el = getConfigurationElement();
+ IConfigurationElement children[] = el.getChildren();
+ String ids[] = new String[children.length];
+ int num = 0;
+ String tmp;
+ if(children.length > 0){
+ for(int i = 0; i < children.length; i++){
+ if(ELEMENT_CONTENT_TYPE.equals(children[i].getName())){
+ tmp = children[i].getAttribute(ATTRIBUTE_ID);
+ if(tmp != null)
+ ids[num++] = tmp;
+ }
+ }
+
+ if(num < children.length){
+ String t[] = new String[num];
+ System.arraycopy(ids, 0, t, 0, num);
+ ids = t;
+ }
+ }
+
+ return ids;
+ }
+
+ public String getId(){
+ if(fId == null)
+ fId = getConfigurationElement().getNamespaceIdentifier() + NAMESPACE_SEPARATOR + super.getId();
+ return fId;
+ }
+
+ public IContentType[] getContentTypes() {
+ if(fContentTypes == null){
+ fContentTypes = calculateContentTypes(getContentTypeIds());
+ }
+ return fContentTypes;
+ }
+
+ private IContentType[] calculateContentTypes(String ids[]){
+ IContentType cTypes[] = new IContentType[ids.length];
+
+ if(ids.length > 0){
+ int num = 0;
+ IContentTypeManager manager = Platform.getContentTypeManager();
+
+ for (int k = 0; k < ids.length; ++k) {
+ IContentType langContType = manager.getContentType(ids[k]);
+ if(langContType != null)
+ cTypes[num++] = langContType;
+ }
+
+ if(num < ids.length){
+ IContentType tmp[] = new IContentType[num];
+ System.arraycopy(cTypes, 0, tmp, 0, num);
+ cTypes = tmp;
+ }
+ }
+ return cTypes;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java
index 61552be4f00..4ad3d7afe7d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java
@@ -73,7 +73,7 @@ public class PathEntry implements IPathEntry {
/**
* Returns the kind from its <code>String</code> form.
*/
- static int kindFromString(String kindStr) {
+ public static int kindFromString(String kindStr) {
if (kindStr.equalsIgnoreCase("prj")) //$NON-NLS-1$
return IPathEntry.CDT_PROJECT;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
index 7dd85703813..5547301f50e 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
@@ -20,8 +20,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
@@ -52,6 +50,8 @@ import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
import org.eclipse.cdt.core.resources.IPathEntryStore;
import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.util.PathEntryResolveInfo;
+import org.eclipse.cdt.core.settings.model.util.PathEntryResolveInfoElement;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -108,6 +108,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
// Synchronized the access of the cache entries.
protected Map resolvedMap = new Hashtable();
+ private Map resolvedInfoMap = new Hashtable();
// Accessing the map is synch with the class
private Map storeMap = new HashMap();
@@ -403,9 +404,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}
return null;
}
+
+ public PathEntryResolveInfo getResolveInfo(ICProject cproject) throws CModelException{
+ PathEntryResolveInfo info = (PathEntryResolveInfo)resolvedInfoMap.get(cproject);
+ if(info == null){
+ getResolvedPathEntries(cproject);
+ info = (PathEntryResolveInfo)resolvedInfoMap.get(cproject);
+ }
+ return info;
+ }
protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) {
ArrayList resolvedListEntries = (ArrayList)resolvedMap.remove(cproject);
+ resolvedInfoMap.remove(cproject);
if (resolvedListEntries != null) {
try {
return getCachedResolvedPathEntries(resolvedListEntries, cproject);
@@ -471,6 +482,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
private ArrayList getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
ArrayList resolvedEntries = (ArrayList)resolvedMap.get(cproject);
if (resolvedEntries == null) {
+ List resolveInfoList = new ArrayList();
IPath projectPath = cproject.getPath();
IPathEntry[] rawEntries = getRawPathEntries(cproject);
resolvedEntries = new ArrayList();
@@ -485,14 +497,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
// are not IPathEntryContainerExtension.
if (!(container instanceof IPathEntryContainerExtension)) {
IPathEntry[] containerEntries = container.getPathEntries();
+ List resolvedList = new ArrayList();
if (containerEntries != null) {
for (int j = 0; j < containerEntries.length; j++) {
IPathEntry newEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, containerEntries[j]);
resolvedEntries.add(newEntry);
+ resolvedList.add(newEntry);
}
}
+ resolveInfoList.add(new PathEntryResolveInfoElement(centry, resolvedList));
} else {
- resolvedEntries.add(PathEntryUtil.cloneEntryAndExpand(projectPath, entry));
+ IPathEntry resolved = PathEntryUtil.cloneEntryAndExpand(projectPath, entry);
+ resolvedEntries.add(resolved);
+ resolveInfoList.add(new PathEntryResolveInfoElement(entry, resolved));
}
}
} else {
@@ -501,6 +518,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
if (e != null) {
resolvedEntries.add(e);
}
+ resolveInfoList.add(new PathEntryResolveInfoElement(entry, e));
}
}
resolvedEntries.trimToSize();
@@ -539,6 +557,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}
resolvedMap.put(cproject, resolvedEntries);
+ resolvedInfoMap.put(cproject, new PathEntryResolveInfo(resolveInfoList));
}
return resolvedEntries;
}
@@ -1148,33 +1167,41 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}
public IPathEntryStore createPathEntryStore(IProject project) throws CoreException {
- IPathEntryStore store = null;
- if (project != null) {
- try {
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
- if (cdesc != null) {
- ICExtensionReference[] cextensions = cdesc.get(PATHENTRY_STORE_UNIQ_ID, true);
- if (cextensions.length > 0) {
- for (int i = 0; i < cextensions.length; i++) {
- try {
- store = (IPathEntryStore)cextensions[i].createExtension();
- break;
- } catch (ClassCastException e) {
- //
- CCorePlugin.log(e);
- }
- }
- }
- }
- } catch (CoreException e) {
- // ignore since we fall back to a default....
- }
- }
- if (store == null) {
- store = new DefaultPathEntryStore(project);
- }
- return store;
+ return new PathEntryStoreProxy(project);
+// IPathEntryStore store = null;
+// if (project != null) {
+// try {
+// ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
+// if (cdesc != null) {
+// ICExtensionReference[] cextensions = cdesc.get(PATHENTRY_STORE_UNIQ_ID, true);
+// if (cextensions.length > 0) {
+// for (int i = 0; i < cextensions.length; i++) {
+// try {
+// store = (IPathEntryStore)cextensions[i].createExtension();
+// break;
+// } catch (ClassCastException e) {
+// //
+// CCorePlugin.log(e);
+// }
+// }
+// }
+// }
+// } catch (CoreException e) {
+// // ignore since we fall back to a default....
+// }
+// }
+// if (store == null) {
+// store = createDefaultStore(project);
+// }
+// return store;
}
+
+// private IPathEntryStore createDefaultStore(IProject project){
+// if(CProjectDescriptionManager.getInstance().isNewStyleIndexCfg(project)){
+// return new ConfigBasedPathEntryStore(project);
+// }
+// return new DefaultPathEntryStore(project);
+// }
/*
* (non-Javadoc)
@@ -1204,6 +1231,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
}
} else {
resolvedMap.remove(cproject);
+ resolvedInfoMap.remove(cproject);
containerRemove(cproject);
}
}
@@ -1269,6 +1297,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} finally {
if (store == null) {
resolvedMap.remove(cproject);
+ resolvedInfoMap.remove(cproject);
containerRemove(cproject);
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreChangedOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreChangedOperation.java
index 29714ad0ca3..f4e4516f3df 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreChangedOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreChangedOperation.java
@@ -15,6 +15,10 @@ import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.internal.core.settings.model.ConfigBasedPathEntryStore;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
public class PathEntryStoreChangedOperation extends CModelOperation {
@@ -37,13 +41,24 @@ public class PathEntryStoreChangedOperation extends CModelOperation {
// Clear the old cache entries.
IPathEntry[] oldResolvedEntries = manager.removeCachedResolvedPathEntries(cproject);
IPathEntry[] newResolvedEntries = manager.getResolvedPathEntries(cproject);
- ICElementDelta[] deltas = manager.generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
- if (deltas.length > 0) {
- cproject.close();
- for (int i = 0; i < deltas.length; i++) {
- addDelta(deltas[i]);
+ if(needDelta(cproject.getProject())){
+ ICElementDelta[] deltas = manager.generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
+ if (deltas.length > 0) {
+ cproject.close();
+ for (int i = 0; i < deltas.length; i++) {
+ addDelta(deltas[i]);
+ }
}
}
}
+
+ private boolean needDelta(IProject project){
+ try {
+ PathEntryStoreProxy store = (PathEntryStoreProxy)PathEntryManager.getDefault().getPathEntryStore(project, false);
+ return !(store.getStore() instanceof ConfigBasedPathEntryStore);
+ } catch (CoreException e) {
+ }
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java
new file mode 100644
index 00000000000..20b22f18238
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.internal.core.settings.model.AbstractCExtensionProxy;
+import org.eclipse.cdt.internal.core.settings.model.ConfigBasedPathEntryStore;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+
+public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener {
+ private List fListeners;
+ private IPathEntryStore fStore;
+
+ public PathEntryStoreProxy(IProject project){
+ super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
+ fListeners = Collections.synchronizedList(new ArrayList());
+ }
+
+ public IPathEntryStore getStore(){
+ providerRequested();
+ return fStore;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
+ */
+ public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
+ fListeners.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
+ */
+ public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
+ fListeners.remove(listener);
+ }
+
+ private void fireContentChangedEvent(IProject project) {
+ PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
+ notifyListeners(evt);
+ }
+
+ private void notifyListeners(PathEntryStoreChangedEvent evt){
+ IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
+ fListeners.toArray(observers);
+ for (int i = 0; i < observers.length; i++) {
+ observers[i].pathEntryStoreChanged(evt);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject)
+ */
+ public void close() {
+ super.close();
+ PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, getProject(), PathEntryStoreChangedEvent.STORE_CLOSED);
+ IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
+ fListeners.toArray(observers);
+ for (int i = 0; i < observers.length; i++) {
+ observers[i].pathEntryStoreChanged(evt);
+ }
+ }
+
+ public IProject getProject() {
+ return super.getProject();
+ }
+
+ public ICExtensionReference getExtensionReference() {
+ //TODO: calculate
+ return null;
+ }
+
+ public IPathEntry[] getRawPathEntries() throws CoreException {
+ providerRequested();
+ return fStore.getRawPathEntries();
+ }
+
+ public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
+ providerRequested();
+ fStore.setRawPathEntries(entries);
+
+ }
+
+ public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+ notifyListeners(event);
+ }
+
+ protected Object createDefaultProvider(ICConfigurationDescription cfgDes,
+ boolean newStile) {
+ if(newStile){
+ return new ConfigBasedPathEntryStore(getProject());
+ }
+ return new DefaultPathEntryStore(getProject());
+ }
+
+ protected void deinitializeProvider(Object o) {
+ IPathEntryStore store = (IPathEntryStore)o;
+ store.removePathEntryStoreListener(this);
+ store.close();
+ }
+
+ protected void initializeProvider(Object o) {
+ IPathEntryStore store = (IPathEntryStore)o;
+ fStore = store;
+ store.addPathEntryStoreListener(this);
+ }
+
+ protected boolean isValidProvider(Object o) {
+ return o instanceof IPathEntryStore;
+ }
+
+ protected void postProcessProviderChange(Object newProvider,
+ Object oldProvider) {
+ if(oldProvider != null)
+ fireContentChangedEvent(getProject());
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java
index 9fe55b2cd80..fe68b1b9a39 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
@@ -24,13 +25,13 @@ import org.eclipse.core.runtime.IPath;
*/
public class SourceRoot extends CContainer implements ISourceRoot {
- ISourceEntry sourceEntry;
+ ICSourceEntry sourceEntry;
/**
* @param parent
* @param res
*/
- public SourceRoot(ICElement parent, IResource res, ISourceEntry entry) {
+ public SourceRoot(ICElement parent, IResource res, ICSourceEntry entry) {
super(parent, res);
sourceEntry = entry;
IPath path = getPath();
@@ -41,7 +42,7 @@ public class SourceRoot extends CContainer implements ISourceRoot {
}
}
- public ISourceEntry getSourceEntry() {
+ public ICSourceEntry getSourceEntry() {
return sourceEntry;
}
@@ -62,7 +63,7 @@ public class SourceRoot extends CContainer implements ISourceRoot {
}
public boolean isOnSourceEntry(IPath path) {
- if (sourceEntry.getPath().isPrefixOf(path)
+ if (sourceEntry.getFullPath().isPrefixOf(path)
&& !CoreModelUtil.isExcluded(path, sourceEntry.fullExclusionPatternChars())) {
return true;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACExclusionFilterEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACExclusionFilterEntry.java
new file mode 100644
index 00000000000..d5ea6a49748
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACExclusionFilterEntry.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.Arrays;
+
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IPath;
+
+public abstract class ACExclusionFilterEntry extends ACLanguageSettingPathEntry implements ICExclusionPatternPathEntry {
+ private IPath[] exclusionPatterns;
+ private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
+ char[][]fullCharExclusionPatterns = UNINIT_PATTERNS;
+
+
+ public ACExclusionFilterEntry(IPath path, IPath exclusionPatterns[] , int flags) {
+ super(path, flags);
+ this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0];
+ }
+
+ public ACExclusionFilterEntry(IFolder rc, IPath exclusionPatterns[], int flags) {
+ super(rc, flags);
+ this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0];
+ }
+
+ public ACExclusionFilterEntry(String value, IPath exclusionPatterns[], int flags) {
+ super(value, flags);
+ this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0];
+ }
+
+ protected final boolean isFile() {
+ return false;
+ }
+
+ /**
+ * Returns the exclusion patterns
+ * @return IPath[]
+ */
+ public IPath[] getExclusionPatterns() {
+ return exclusionPatterns;
+ }
+
+ /**
+ * Returns a char based representation of the exclusions patterns full path.
+ */
+ public char[][] fullExclusionPatternChars() {
+ if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) {
+ int length = this.exclusionPatterns.length;
+ this.fullCharExclusionPatterns = new char[length][];
+ IPath path = getFullPath();
+ if(path == null)
+ path = getLocation();
+ IPath prefixPath = path.removeTrailingSeparator();
+ for (int i = 0; i < length; i++) {
+ this.fullCharExclusionPatterns[i] =
+ prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray();
+ }
+ }
+ return this.fullCharExclusionPatterns;
+ }
+
+ public boolean equals(Object other) {
+ if(!super.equals(other))
+ return false;
+
+ ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other;
+ return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
+ }
+
+ public int hashCode() {
+ return super.hashCode() + exclusionPatterns.hashCode();
+ }
+
+ public boolean equalsByContents(ICLanguageSettingEntry entry) {
+ if(!super.equalsByContents(entry))
+ return false;
+
+ ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry;
+ return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingEntry.java
new file mode 100644
index 00000000000..f9de3701a6e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingEntry.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+
+public abstract class ACLanguageSettingEntry implements ICLanguageSettingEntry {
+ int fFlags;
+ String fName;
+
+ public ACLanguageSettingEntry(String name, int flags){
+ fName = name;
+ fFlags = flags;
+ }
+
+ public boolean isBuiltIn() {
+ return checkFlags(BUILTIN);
+ }
+
+ public boolean isReadOnly() {
+ return checkFlags(READONLY);
+ }
+
+ protected boolean checkFlags(int flags){
+ return (fFlags & flags) == flags;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public String getValue() {
+ //name and value differ only for macro entry and have the same contents
+ //for all other entries
+ return fName;
+ }
+
+ public boolean isResolved() {
+ return checkFlags(RESOLVED);
+ }
+
+ public boolean equals(Object other){
+ if(other == this)
+ return true;
+
+ if(!(other instanceof ACLanguageSettingEntry))
+ return false;
+
+ ACLanguageSettingEntry e = (ACLanguageSettingEntry)other;
+
+ if(getKind() != e.getKind())
+ return false;
+
+ if(fFlags != e.fFlags)
+ return false;
+
+ if(!fName.equals(e.fName))
+ return false;
+
+ return true;
+ }
+
+ public int hashCode(){
+ return getKind() + fFlags + fName.hashCode();
+ }
+
+ public int getFlags() {
+ return fFlags;
+ }
+
+ public boolean equalsByContents(ICLanguageSettingEntry entry) {
+ return equalsByName(entry);
+ }
+
+ protected int getByNameMatchFlags(){
+ return (fFlags & (~ (BUILTIN | READONLY)));
+ }
+
+ public final boolean equalsByName(ICLanguageSettingEntry entry) {
+ if(entry == this)
+ return true;
+
+ if(!(entry instanceof ACLanguageSettingEntry))
+ return false;
+
+ ACLanguageSettingEntry e = (ACLanguageSettingEntry)entry;
+
+ if(getKind() != e.getKind())
+ return false;
+
+ if(getByNameMatchFlags()
+ != e.getByNameMatchFlags())
+ return false;
+
+ if(!fName.equals(e.fName))
+ return false;
+
+ return true;
+ }
+
+ public int codeForNameKey(){
+ return getKind() + getByNameMatchFlags() + fName.hashCode();
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingPathEntry.java
new file mode 100644
index 00000000000..d796d8c85c2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ACLanguageSettingPathEntry.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public abstract class ACLanguageSettingPathEntry extends ACLanguageSettingEntry
+ implements ICLanguageSettingPathEntry {
+ IPath fFullPath;
+ IPath fLocation;
+// private IPath fPath;
+
+ public ACLanguageSettingPathEntry(IResource rc, int flags) {
+ super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH);
+ fFullPath = rc.getFullPath();
+// fPath = rc.getFullPath();
+ fLocation = rc.getLocation();
+ }
+
+/* public ACLanguageSettingPathEntry(IPath fullPath, IPath location, int flags) {
+ super(flags);
+ fLocation = location;
+ fFullPath = fullPath;
+ }
+*/
+ public ACLanguageSettingPathEntry(String value, int flags) {
+ super(value, flags);
+ }
+
+ public ACLanguageSettingPathEntry(IPath path, int flags) {
+ super(path.toString(), flags | RESOLVED);
+// fPath = path;
+// if(isValueWorkspacePath())
+// fFullPath = path;
+// else
+// fLocation = path;
+ }
+
+ public IPath getFullPath() {
+ if(fFullPath == null && isResolved()){
+ if(isValueWorkspacePath()){
+ fFullPath = new Path(getValue());
+ } else {
+ fLocation = new Path(getValue());
+ fFullPath = fullPathForLocation(fLocation);
+ }
+ }
+ return fFullPath;
+ }
+
+ protected IPath fullPathForLocation(IPath location){
+ IResource rcs[] = isFile() ?
+ (IResource[])ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location)
+ : (IResource[])ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location);
+
+ if(rcs.length > 0)
+ return rcs[0].getFullPath();
+ return null;
+ }
+
+ protected abstract boolean isFile();
+
+ public IPath getLocation() {
+ if(fLocation == null && isResolved()){
+ if(isValueWorkspacePath()){
+ fFullPath = new Path(getValue());
+ IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(fFullPath);
+ if(rc != null)
+ fLocation = rc.getLocation();
+ } else {
+ fLocation = new Path(getValue());
+ }
+ }
+ return fLocation;
+ }
+
+ public boolean isValueWorkspacePath() {
+ return checkFlags(VALUE_WORKSPACE_PATH);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java
new file mode 100644
index 00000000000..02236cd8432
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.internal.core.CConfigBasedDescriptor;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+
+public abstract class AbstractCExtensionProxy implements ICProjectDescriptionListener{
+ private IProject fProject;
+ private String fExtId;
+ private boolean fIsNewStyle;
+ private boolean fInited;
+ private String fExtPointId;
+ private Object fProvider;
+
+ public AbstractCExtensionProxy(IProject project, String extPointId) {
+ fProject = project;
+ fExtPointId = extPointId;
+ CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED);
+ }
+
+ protected final void providerRequested(){
+ if(!fInited)
+ checkUpdateProvider(CProjectDescriptionManager.getInstance().getProjectDescription(fProject, false), false, false);
+ }
+
+
+ private ICExtensionReference getRef(ICConfigurationDescription cfg, boolean update){
+ if(fExtPointId != null){
+ try {
+ CConfigBasedDescriptor dr = new CConfigBasedDescriptor(cfg);
+ ICExtensionReference[] cextensions = dr.get(fExtPointId, update);
+ if (cextensions.length > 0) {
+ return cextensions[0];
+ }
+ } catch (CoreException e) {
+ }
+ }
+ return null;
+ }
+
+ protected IProject getProject(){
+ return fProject;
+ }
+
+ private void checkUpdateProvider(ICProjectDescription des, boolean recreate, boolean rescan){
+ Object newProvider = null;
+ Object oldProvider = null;
+
+ synchronized(this){
+ if(recreate || rescan || !fInited){
+ fInited = true;
+ ICExtensionReference ref = null;
+ boolean newStile = true;
+ ICConfigurationDescription cfg = null;
+ if(des != null){
+ cfg = ((CProjectDescription)des).getIndexConfiguration();
+ if(cfg != null){
+ ref = getRef(cfg, false);
+ newStile = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfg);
+ }
+ }
+
+ if(ref != null){
+ if(recreate || !ref.getID().equals(fExtId)){
+ try {
+ newProvider = ref.createExtension();
+ if(!isValidProvider(newProvider))
+ newProvider = null;
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ if(newProvider == null){
+ if(recreate || fProvider == null || newStile != fIsNewStyle){
+ newStile = isNewStyleCfg(cfg);
+ newProvider = createDefaultProvider(cfg, newStile);
+ }
+ }
+
+ if(newProvider != null){
+ if(fProvider != null){
+ deinitializeProvider(fProvider);
+ oldProvider = fProvider;
+ }
+
+ fProvider = newProvider;
+ if(ref != null)
+ fExtId = ref.getID();
+
+ fIsNewStyle = newStile;
+
+ initializeProvider(fProvider);
+ }
+ }
+ }
+
+ if(newProvider != null)
+ postProcessProviderChange(newProvider, oldProvider);
+ }
+
+ protected boolean isNewStyleCfg(ICConfigurationDescription des){
+ return CProjectDescriptionManager.getInstance().isNewStyleCfg(des);
+ }
+
+ protected abstract boolean isValidProvider(Object o);
+
+ protected abstract void initializeProvider(Object o);
+
+ protected abstract void deinitializeProvider(Object o);
+
+ protected abstract Object createDefaultProvider(ICConfigurationDescription cfgDes, boolean newStile);
+
+ protected void postProcessProviderChange(Object newProvider, Object oldProvider){
+ }
+
+ public void close(){
+ CProjectDescriptionManager.getInstance().removeListener(this);
+ if(fProvider != null){
+ deinitializeProvider(fProvider);
+ }
+ }
+
+ public void handleEvent(CProjectDescriptionEvent event) {
+ if(!fProject.equals(event.getProject()))
+ return;
+
+ boolean force = false;
+ switch(event.getEventType()){
+ case CProjectDescriptionEvent.LOADDED:
+ force = true;
+ case CProjectDescriptionEvent.APPLIED:
+ ICProjectDescription des = event.getNewCProjectDescription();
+ if(des != null)
+ checkUpdateProvider(des, force, true);
+ break;
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java
new file mode 100644
index 00000000000..f64f30e5df5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.model.IOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICBuildSetting;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.core.runtime.IPath;
+
+public class CBuildSetting extends CDataProxy implements ICBuildSetting {
+
+ CBuildSetting(CBuildData data, CConfigurationDescription cfg) {
+ super(data, cfg, cfg);
+ }
+
+ public IPath getBuilderCWD() {
+ CBuildData data = getBuildData(false);
+ return data.getBuilderCWD();
+ }
+
+ private CBuildData getBuildData(boolean write){
+ return (CBuildData)getData(write);
+ }
+
+ public String[] getErrorParserIDs() {
+ CBuildData data = getBuildData(false);
+ return data.getErrorParserIDs();
+ }
+
+ public ICOutputEntry[] getOutputDirectories() {
+ CBuildData data = getBuildData(false);
+ return data.getOutputDirectories();
+ }
+
+ public void setBuilderCWD(IPath path) {
+ CBuildData data = getBuildData(true);
+ data.setBuilderCWD(path);
+ }
+
+ public void setErrorParserIDs(String[] ids) {
+ CBuildData data = getBuildData(true);
+ data.setErrorParserIDs(ids);
+ }
+
+ public void setOutputDirectories(ICOutputEntry[] entries) {
+ CBuildData data = getBuildData(true);
+ data.setOutputDirectories(entries);
+ }
+
+ public final int getType() {
+ return ICSettingBase.SETTING_BUILD;
+ }
+
+ public IEnvironmentContributor getBuildEnvironmentContributor() {
+ CBuildData data = getBuildData(false);
+ return data.getBuildEnvironmentContributor();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java
new file mode 100644
index 00000000000..19df06d6300
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.settings.model.ICBuildSetting;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultBuildData;
+import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
+import org.eclipse.cdt.utils.envvar.StorableEnvironment;
+import org.eclipse.core.runtime.IPath;
+
+public class CBuildSettingCache extends CDefaultBuildData implements
+ ICBuildSetting, ICachedData {
+ private CConfigurationDescriptionCache fCfgCache;
+ private StorableEnvironment fEnvironment;
+ private StorableEnvironment fResolvedEnvironment;
+
+ CBuildSettingCache(CBuildData base, CConfigurationDescriptionCache cfgCache){
+ super(base.getId(), base);
+
+ fCfgCache = cfgCache;
+
+ fCfgCache.addBuildSetting(this);
+
+ }
+
+ void initEnvironmentCache(){
+ fEnvironment = new StorableEnvironment(
+ EnvironmentVariableManager.getDefault().getVariables(fCfgCache, false),
+ true);
+ }
+
+ public StorableEnvironment getCachedEnvironment(){
+ return fEnvironment;
+ }
+
+ public StorableEnvironment getResolvedEnvironment(){
+ if(fResolvedEnvironment == null){
+ fResolvedEnvironment = new StorableEnvironment(
+ EnvironmentVariableManager.getDefault().getVariables(fCfgCache, true),
+ true);
+ }
+ return fResolvedEnvironment;
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return fCfgCache;
+ }
+
+ public ICSettingContainer getParent() {
+ return fCfgCache;
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ public void setBuilderCWD(IPath path) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setErrorParserIDs(String[] ids) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setName(String name) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setOutputDirectories(ICOutputEntry[] entries) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public IEnvironmentContributor getBuildEnvironmentContributor() {
+ return fCfgCache.getConfigurationData().getBuildData().getBuildEnvironmentContributor();
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java
new file mode 100644
index 00000000000..858ac49aef9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.internal.core.CExtensionInfo;
+import org.eclipse.core.runtime.CoreException;
+
+public class CConfigExtensionReference implements ICConfigExtensionReference {
+
+ private CConfigurationSpecSettings fCfgSettings;
+ private String fExtPoint;
+ private String fId;
+
+ public CConfigExtensionReference(CConfigurationSpecSettings cfg, String extPoint, String id) {
+ fCfgSettings = cfg;
+ fExtPoint = extPoint;
+ fId = id;
+ }
+
+ public CConfigExtensionReference(CConfigurationSpecSettings cfg, CConfigExtensionReference base) {
+ fCfgSettings = cfg;
+ fExtPoint = base.fExtPoint;
+ fId = base.fId;
+ }
+
+ public String getExtensionPoint() {
+ return fExtPoint;
+ }
+
+ public String getID() {
+ return fId;
+ }
+
+ private CExtensionInfo getInfo() {
+ return fCfgSettings.getInfo(this);
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj instanceof CConfigExtensionReference) {
+ CConfigExtensionReference ext = (CConfigExtensionReference)obj;
+ if (ext.fExtPoint.equals(fExtPoint) && ext.fId.equals(fId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return fExtPoint.hashCode() + fId.hashCode();
+ }
+
+ public void setExtensionData(String key, String value) throws CoreException {
+ getInfo().setAttribute(key, value);
+ fCfgSettings.setModified();
+ }
+
+ public String getExtensionData(String key) {
+ return getInfo().getAttribute(key);
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return fCfgSettings.getConfigurarion();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDataProviderDescriptor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDataProviderDescriptor.java
new file mode 100644
index 00000000000..f40281d63b6
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDataProviderDescriptor.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+
+public class CConfigurationDataProviderDescriptor {
+ final static String DATA_PROVIDER_EXTPOINT_ID = CCorePlugin.PLUGIN_ID + "." + "CConfigurationDataProvider"; //$NON-NLS-1$ //$NON-NLS-2$
+ final static String DATA_PROVIDER = "provider"; //$NON-NLS-1$
+ final static String CLASS = "class"; //$NON-NLS-1$
+ final static String NATURES = "natures"; //$NON-NLS-1$
+ final static String ECLIPSE_BUILDERS = "eclipseBuilders"; //$NON-NLS-1$
+ final static String DELIMITER = ";";
+
+
+ private String fId;
+ private CConfigurationDataProvider fProvider;
+ private IExtension fExtension;
+ private IConfigurationElement fProviderElement;
+// private String[] fBuilderIds;
+ private String[] fNatureIds;
+
+ CConfigurationDataProviderDescriptor(IExtension extension){
+ fId = extension.getUniqueIdentifier();
+ fExtension = extension;
+ fProviderElement = getProviderElement(extension);
+ if(fProviderElement != null){
+ fNatureIds = toArray(fProviderElement.getAttribute(NATURES));
+// fBuilderIds = toArray(fProviderElement.getAttribute(ECLIPSE_BUILDERS));
+ } else {
+ //fBuilderIds =
+ fNatureIds = new String[0];
+ }
+ }
+
+ private static String[] toArray(String value){
+ if(value == null)
+ return new String[0];
+
+ StringTokenizer t = new StringTokenizer(value, DELIMITER);
+ int num = t.countTokens();
+ List list = new ArrayList(num);
+ for(int i = 0; i < num; i++){
+ String v = t.nextToken().trim();
+ if(v.length() != 0)
+ list.add(v);
+ }
+
+ return (String[])list.toArray(new String[list.size()]);
+
+ }
+
+ public CConfigurationDataProvider getProvider() throws CoreException{
+ if(fProvider == null) {
+ fProvider = createProvider(fExtension);
+ }
+ return fProvider;
+ }
+
+ private static IConfigurationElement getProviderElement(IExtension ext){
+ IConfigurationElement elements[] = ext.getConfigurationElements();
+ for(int i = 0; i < elements.length; i++){
+ IConfigurationElement element = elements[i];
+ if(DATA_PROVIDER.equals(element.getName())){
+ return element;
+ }
+ }
+ return null;
+ }
+
+ private static CConfigurationDataProvider createProvider(IExtension ext) throws CoreException{
+ IConfigurationElement elements[] = ext.getConfigurationElements();
+ for(int i = 0; i < elements.length; i++){
+ IConfigurationElement element = elements[i];
+ if(DATA_PROVIDER.equals(element.getName())){
+ Object obj = element.createExecutableExtension(CLASS);
+ if(obj instanceof CConfigurationDataProvider){
+ return (CConfigurationDataProvider)obj;
+ } else
+ throw ExceptionFactory.createCoreException("illegal provider implementation");
+ }
+ }
+ throw ExceptionFactory.createCoreException("no provider defined");
+ }
+
+ public String getId(){
+ return fId;
+ }
+
+ public String[] getNatureIds(){
+ return (String[])fNatureIds.clone();
+ }
+
+/* public String[] getBuilderIds(){
+ return (String[])fBuilderIds.clone();
+ }
+*/
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java
new file mode 100644
index 00000000000..7a7ea0e0c5e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java
@@ -0,0 +1,708 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICBuildSetting;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+
+public class CConfigurationDescription extends CDataProxyContainer implements ICConfigurationDescription, IProxyFactory, IInternalCCfgInfo {
+ private CfgProxyCache fCache;
+// private ProxyProvider fFileProxyProvider;
+// private ProxyProvider fFolderProxyProvider;
+// private ProxyProvider fRcProxyProvider;
+ private PathSettingsContainer fPathContainer;
+ private ResourceDescriptionHolder fRcHolder;
+ private CConfigurationSpecSettings fCfgSpecSettings;
+ private CConfigurationDescriptionCache fCfgCache;
+ private boolean fIsPreference = false;
+
+ CConfigurationDescription(CConfigurationData data, ICDataProxyContainer cr) throws CoreException {
+ this(data, null, cr);
+ }
+
+ CConfigurationDescription(CConfigurationData data, String buildSystemId, ICDataProxyContainer cr) throws CoreException {
+ super(data, cr, null);
+ if(!(cr instanceof ICProjectDescription))
+ fIsPreference = true;
+
+ if(data instanceof CConfigurationDescriptionCache)
+ fCfgCache = (CConfigurationDescriptionCache)data;
+
+ setConfiguration(this);
+ if(buildSystemId != null)
+ getSpecSettings().setBuildSystemId(buildSystemId);
+
+ }
+
+ /**
+ * creating a new configuration
+ *
+ * @param id
+ * @param name
+ * @param base
+ * @param projectDes
+ * @throws CoreException
+ */
+ CConfigurationDescription(String id, String name, ICConfigurationDescription base, CProjectDescription projectDes) throws CoreException {
+ super(null, projectDes, null);
+
+ setConfiguration(this);
+ fCfgSpecSettings = new CConfigurationSpecSettings(this, ((CConfigurationDescription)base).getSpecSettings());
+ fCfgSpecSettings.setId(id);
+ fCfgSpecSettings.setName(name);
+ CConfigurationData baseData = ((IInternalCCfgInfo)base).getConfigurationData(false);
+ if(baseData instanceof CConfigurationDescriptionCache){
+ baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
+ }
+ setData(CProjectDescriptionManager.getInstance().createData(this, baseData, false));
+ }
+
+ /*
+ * conveter cnfig constructor
+ */
+ CConfigurationDescription(String id, String name, ICStorageElement el, CProjectDescription projectDes) throws CoreException {
+ super(null, projectDes, null);
+
+ setConfiguration(this);
+
+ ICStorageElement storage = CProjectDescriptionManager.getInstance().createStorage(projectDes, id);
+ fCfgSpecSettings = new CConfigurationSpecSettings(this, storage, el);
+ fCfgSpecSettings.setId(id);
+ fCfgSpecSettings.setName(name);
+ fCfgSpecSettings.setBuildSystemId(CProjectDescriptionManager.DEFAULT_PROVIDER_ID);
+ CConfigurationData data = CProjectDescriptionManager.getInstance().createDefaultConfigData(projectDes.getProject(), id, name, PathEntryConfigurationDataProvider.getDataFactory());
+ setData(data);
+ }
+
+ /*
+ * preference config constructor
+ */
+ CConfigurationDescription(String id, String name, String bsId, ICStorageElement el, ICDataProxyContainer cr) throws CoreException {
+ super(null, cr, null);
+ fIsPreference = true;
+
+ setConfiguration(this);
+
+ fCfgSpecSettings = new CConfigurationSpecSettings(this, el);
+ fCfgSpecSettings.setId(id);
+ fCfgSpecSettings.setName(name);
+ fCfgSpecSettings.setBuildSystemId(bsId);
+ setData(CProjectDescriptionManager.getInstance().loadData(this));
+ }
+
+ void doWritable() throws CoreException{
+ CConfigurationData data = getConfigurationData(false);
+ if(data instanceof CConfigurationDescriptionCache){
+ data = ((CConfigurationDescriptionCache)data).getConfigurationData();
+ setData(CProjectDescriptionManager.getInstance().createData(this, data, true));
+ }
+ }
+
+ public CConfigurationDescriptionCache getCache(){
+ return fCfgCache;
+ }
+
+ public String getId() {
+ String id = super.getId();
+ if(id == null){
+ try {
+ id = getSpecSettings().getId();
+ } catch (CoreException e) {
+ //TODO: log
+ }
+ }
+ return id;
+ }
+
+ public String getName() {
+ String name = super.getName();
+ if(name == null){
+ try {
+ name = getSpecSettings().getName();
+ } catch (CoreException e) {
+ //TODO: log
+ }
+ }
+ return name;
+ }
+
+ public String getDescription() {
+ CConfigurationData data = getConfigurationData(false);
+ return data.getDescription();
+ }
+
+ public CConfigurationData getConfigurationData(boolean write){
+ CConfigurationData data = (CConfigurationData)getData(write);
+ if(data == null)
+ throw new IllegalStateException();
+ return data;
+ }
+
+ public ICProjectDescription getProjectDescription() {
+ if(fIsPreference)
+ return null;
+ return (ICProjectDescription)getParent();
+ }
+
+ public ICResourceDescription[] getResourceDescriptions(int kind) {
+ return getRcHolder().getResourceDescriptions(kind);
+ }
+
+ public ICFolderDescription getRootFolderDescription() {
+ return (ICFolderDescription)getRcHolder().getCurrentResourceDescription();
+ }
+
+ public boolean isActive() {
+ if(fIsPreference)
+ return false;
+ return getProjectDescription().getActiveConfiguration() == this;
+ }
+
+ public void setActive() throws WriteAccessException{
+ if(fIsPreference)
+ return;
+ getProjectDescription().setActiveConfiguration(this);
+ }
+
+ public void removeResourceDescription(ICResourceDescription des)
+ throws CoreException {
+ CConfigurationData data = getConfigurationData(true);
+ IPath path = des.getPath();
+ getRcHolder().removeResurceDescription(path);
+ data.removeResourceData((CResourceData)((CDataProxy)des).getData(false));
+ }
+
+ public final int getType() {
+ return ICSettingBase.SETTING_CONFIGURATION;
+ }
+
+ public CDataProxy createProxy(CDataObject data) {
+ switch(data.getType()){
+ case ICSettingBase.SETTING_FOLDER:
+ return new CFolderDescription((CFolderData)data, this);
+ case ICSettingBase.SETTING_FILE:
+ return new CFileDescription((CFileData)data, this);
+ case ICSettingBase.SETTING_TARGET_PLATFORM:
+ return new CTargetPlatformSetting((CTargetPlatformData)data, this);
+ case ICSettingBase.SETTING_BUILD:
+ return new CBuildSetting((CBuildData)data, this);
+
+ }
+ return null;
+ }
+
+ protected IProxyProvider createChildProxyProvider() {
+ ICDataScope scope = new ICDataScope(){
+
+ public CDataObject[] getChildren() {
+ CConfigurationData data = getConfigurationData(false);
+ List list = new ArrayList();
+ CResourceData rcDatas[] = data.getResourceDatas();
+ for(int i = 0; i < rcDatas.length; i++){
+ list.add(rcDatas[i]);
+ }
+ CTargetPlatformData tpData = data.getTargetPlatformData();
+ list.add(tpData);
+ CBuildData buildData = data.getBuildData();
+ list.add(buildData);
+ // TODO add other data types
+ return (CDataObject[])list.toArray(new CDataObject[list.size()]);
+ }
+
+ public boolean isStatic() {
+ return !containsWritableData();
+ }
+
+ };
+ IProxyCache cache = getCfgProxyCache();
+
+ return new ProxyProvider(scope, cache, this);
+ }
+
+ protected ResourceDescriptionHolder createHolder(CFolderDescription des){
+ PathSettingsContainer container = des.getPathContainer();
+ if(container == null){
+ container = getPathContainer().getChildContainer(des.getPath(), true, true);
+ des.setPathContainer(container);
+ }
+ //TODO: check
+ return new ProviderBasedRcDesHolder(getChildrenProxyProvider(), container, false);
+ }
+
+ protected ResourceDescriptionHolder createHolder(CFileDescription des){
+ PathSettingsContainer container = des.getPathContainer();
+ if(container == null){
+ container = getPathContainer().getChildContainer(des.getPath(), true, true);
+ des.setPathContainer(container);
+ }
+ //TODO: check
+ return new ProviderBasedRcDesHolder(getChildrenProxyProvider(), container, false);
+ }
+
+ private CfgProxyCache getCfgProxyCache(){
+ if(fCache == null)
+ fCache = new CfgProxyCache(getPathContainer());
+ return fCache;
+ }
+
+ private PathSettingsContainer getPathContainer(){
+ if(fPathContainer == null)
+ fPathContainer = PathSettingsContainer.createRootContainer();
+ return fPathContainer;
+ }
+
+ private ResourceDescriptionHolder getRcHolder(){
+ if(fRcHolder == null)
+ fRcHolder = new ProviderBasedRcDesHolder(getChildrenProxyProvider(),
+ getPathContainer(),
+ true);
+ return fRcHolder;
+ }
+
+
+ public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) {
+ return getRcHolder().getResourceDescription(path, exactPath);
+ }
+
+ public void setDescription(String des) throws WriteAccessException {
+ getConfigurationData(true).setDescription(des);
+ }
+
+ public ICResourceDescription[] getResourceDescriptions() {
+ return getResourceDescriptions(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER);
+ }
+
+ public ICStorageElement getStorage(String id, boolean create) throws CoreException {
+ return getSpecSettings().getStorage(id, create);
+ }
+
+ public void removeStorage(String id) throws CoreException {
+ getSpecSettings().removeStorage(id);
+ }
+
+ public boolean containsStorage(String id) throws CoreException {
+ return getSpecSettings().containsStorage(id);
+ }
+
+ public CConfigurationSpecSettings getSpecSettings() throws CoreException{
+ if(fCfgSpecSettings == null){
+ if(fCfgCache != null){
+ fCfgSpecSettings = new CConfigurationSpecSettings(this, fCfgCache.getSpecSettings());
+ } else {
+ fCfgSpecSettings = new CConfigurationSpecSettings(this, (ICStorageElement)null);
+ }
+
+// fCfgSpecSettings = CProjectDescriptionManager.getInstance().createConfigurationSpecSettings(this);
+ }
+ return fCfgSpecSettings;
+ }
+
+ public String getBuildSystemId() {
+ try {
+ return getSpecSettings().getBuildSystemId();
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ public CConfigurationData getConfigurationData() {
+ return getConfigurationData(true);
+ }
+
+ public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException {
+ String oldId = getId();
+ setData(data);
+ if(!fIsPreference){
+ ((CProjectDescription)getProjectDescription()).updateMap(this, oldId);
+ }
+ try {
+ CConfigurationSpecSettings settings = getSpecSettings();
+ settings.setId(getId());
+ settings.setName(getName());
+ settings.setBuildSystemId(buildSystemId);
+ } catch (CoreException e) {
+ }
+ }
+
+ public boolean isModified() {
+ try {
+ CConfigurationSpecSettings settings = getSpecSettings();
+ if(settings.isModified())
+ return true;
+ } catch (CoreException e) {
+ }
+ return !(getConfigurationData(false) instanceof CConfigurationDescriptionCache);
+ }
+
+ void removeConfiguration(){
+// CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
+// CConfigurationData data = getConfigurationData(true);//fCfgCache.getBaseData();
+//
+// try {
+// mngr.removeData(this, data);
+// } catch (CoreException e) {
+// }
+
+ ((CProjectDescription)getProjectDescription()).configurationRemoved(this);
+ remove();
+ }
+
+ public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException {
+ CConfigurationData data = getConfigurationData(true);
+ CResourceData baseRcData = (CResourceData)((CDataProxy)base).getData(true);
+ CFileData createdData = null;
+ if(base instanceof ICFileDescription){
+ createdData = data.createFileData(path, (CFileData)baseRcData);
+ } else {
+ ICFolderDescription baseFo = (ICFolderDescription)base;
+ String fileName = path.lastSegment();
+ CLanguageSetting baseLang = (CLanguageSetting)baseFo.getLanguageSettingForFile(fileName);
+// if(baseLang == null){
+// ICLanguageSetting allSettings[] = baseFo.getLanguageSettings();
+// if(allSettings.length != 0)
+// baseLang = (CLanguageSetting)allSettings[0];
+// }
+ CLanguageData baseLangData = baseLang != null ? (CLanguageData)baseLang.getData(false) : null;
+ createdData = data.createFileData(path, (CFolderData)baseRcData, baseLangData);
+ }
+
+
+ if(createdData == null)
+ throw ExceptionFactory.createCoreException("data was not created");
+
+ CDataProxy proxy = getChildrenProxyProvider().getProxy(createdData);
+ if(!(proxy instanceof ICFileDescription))
+ throw ExceptionFactory.createCoreException("expected proxy of type ICFileDescription, but was " + proxy.getClass().getName());
+
+ return (ICFileDescription)proxy;
+ }
+
+ public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException {
+ CConfigurationData data = getConfigurationData(true);
+ CFolderData baseRcData = (CFolderData)((CDataProxy)base).getData(true);
+ CFolderData createdData = data.createFolderData(path, baseRcData);
+
+ if(createdData == null)
+ throw ExceptionFactory.createCoreException("data was not created");
+
+ CDataProxy proxy = getChildrenProxyProvider().getProxy(createdData);
+ if(!(proxy instanceof ICFolderDescription))
+ throw ExceptionFactory.createCoreException("expected proxy of type ICFolderDescription, but was " + proxy.getClass().getName());
+
+ return (ICFolderDescription)proxy;
+ }
+
+ public ICTargetPlatformSetting getTargetPlatformSetting() {
+ CConfigurationData data = getConfigurationData(false);
+ return (ICTargetPlatformSetting)getChildrenProxyProvider().getProxy(data.getTargetPlatformData());
+ }
+
+ public ICFileDescription[] getFileDescriptions() {
+ return (ICFileDescription[])getRcHolder().getResourceDescriptions(ICSettingBase.SETTING_FILE);
+ }
+
+ public ICFolderDescription[] getFolderDescriptions() {
+ return (ICFolderDescription[])getRcHolder().getResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ }
+
+ public ICSourceEntry[] getSourceEntries() {
+ CConfigurationData data = getConfigurationData(false);
+ IPath[] srcPaths = data.getSourcePaths();
+ IProject proj = fIsPreference ? null : getProjectDescription().getProject();
+ return getRcHolder().calculateSourceEntriesFromPaths(proj, srcPaths);
+ }
+
+ public void setSourceEntries(ICSourceEntry[] entries) throws CoreException {
+ ICSourceEntry entry;
+ IPath entryPath;
+ IPath paths[];
+ PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
+ Set srcPathSet = new HashSet();
+ IProject project = fIsPreference ? null : getProjectDescription().getProject();
+ IPath projPath = project != null ? project.getFullPath() : null;
+// Map exclusionMap = new HashMap();
+
+// HashSet pathSet = new HashSet();
+
+ if(entries == null){
+ IPath pasePath = projPath != null ? projPath : Path.EMPTY;
+ entries = new ICSourceEntry[]{new CSourceEntry(pasePath, null, ICLanguageSettingEntry.RESOLVED | ICLanguageSettingEntry.VALUE_WORKSPACE_PATH)};
+ }
+
+ for(int i = 0 ; i < entries.length; i++){
+ entry = entries[i];
+ entryPath = entry.getFullPath();
+ if(projPath != null){
+ if(projPath.isPrefixOf(entryPath)){
+ entryPath = entryPath.removeFirstSegments(projPath.segmentCount());
+ } else {
+ continue;
+ }
+ }
+// else {
+// if(entryPath.segmentCount() > 0)
+// entryPath = entryPath.removeFirstSegments(1);
+// else
+// continue;
+// }
+ if(srcPathSet.add(entryPath)){
+ // exclusionMap.put(entryPath, Boolean.TRUE);
+ PathSettingsContainer entryCr = cr.getChildContainer(entryPath, true, true);
+ entryCr.setValue(Boolean.TRUE);
+
+
+ paths = entry.getExclusionPatterns();
+
+
+ for(int j = 0; j < paths.length; j++){
+ IPath path = paths[j];
+ PathSettingsContainer exclusion = entryCr.getChildContainer(path, true, true);
+ if(exclusion.getValue() == null)
+ exclusion.setValue(Boolean.FALSE);
+ // if(null == exclusionMap.get(path))
+ // exclusionMap.put(path, Boolean.FALSE);
+ }
+ }
+ }
+
+ CConfigurationData data = getConfigurationData(true);
+ data.setSourcePaths((IPath[])srcPathSet.toArray(new IPath[srcPathSet.size()]));
+ ICResourceDescription rcDess[] = getResourceDescriptions();
+ ICResourceDescription rcDes;
+ Set pathSet = new HashSet();
+
+ for(int i = 0; i < rcDess.length; i++){
+ rcDes = rcDess[i];
+ IPath path = rcDes.getPath();
+ pathSet.add(path);
+// Boolean b = (Boolean)exclusionMap.remove(path);
+ Boolean b = (Boolean)cr.getChildContainer(path, false, false).getValue();
+ assert (b != null);
+ if(Boolean.TRUE == b) {
+ if(rcDes.isExcluded())
+ rcDes.setExcluded(false);
+ } else {
+ if((rcDes.getType() == ICSettingBase.SETTING_FILE
+ || !((ICFolderDescription)rcDes).isRoot())
+ && !rcDes.isExcluded())
+ rcDes.setExcluded(true);
+ }
+ }
+
+ PathSettingsContainer crs[] = cr.getChildren(true);
+ for(int i= 0; i < crs.length; i++){
+ PathSettingsContainer c = crs[i];
+ IPath path = c.getPath();
+ if(!pathSet.remove(path)){
+ Boolean b = (Boolean)c.getValue();
+ assert (b != null);
+ ICResourceDescription base = getResourceDescription(path, false);
+ if(b == Boolean.TRUE){
+ if(base.isExcluded()){
+ ICResourceDescription newDes = createResourceDescription(path, base);
+ if(newDes == null){
+ ICResourceDescription fo = getResourceDescription(path, false);
+ if(fo.getType() == ICSettingBase.SETTING_FILE){
+ fo = getResourceDescription(path.removeLastSegments(1), false);
+ }
+ newDes = createFolderDescription(path, (ICFolderDescription)fo);
+ }
+ newDes.setExcluded(false);
+ }
+ } else {
+ if(!base.isExcluded()){
+ ICResourceDescription newDes = createResourceDescription(path, base);
+ if(newDes == null){
+ ICResourceDescription fo = getResourceDescription(path, false);
+ if(fo.getType() == ICSettingBase.SETTING_FILE){
+ fo = getResourceDescription(path.removeLastSegments(1), false);
+ }
+ newDes = createFolderDescription(path, (ICFolderDescription)fo);
+ }
+ newDes.setExcluded(true);
+ }
+ }
+ }
+ }
+
+ }
+
+ private ICResourceDescription createResourceDescription(IPath path, ICResourceDescription base){
+ if(fIsPreference)
+ return null;
+ IProject project = getProjectDescription().getProject();
+ IResource rc = project.findMember(path);
+ ICResourceDescription des = null;
+ if(rc != null){
+ if(rc.getType() == IResource.FILE) {
+ try {
+ des = createFileDescription(path, base);
+ } catch (WriteAccessException e) {
+ } catch (CoreException e) {
+ }
+ } else if (rc.getType() == IResource.FOLDER) {
+ try {
+ des = createFolderDescription(path, (ICFolderDescription)base);
+ } catch (WriteAccessException e) {
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ return des;
+ }
+
+ public Map getReferenceInfo() {
+ try {
+ CConfigurationSpecSettings specs = getSpecSettings();
+ return specs.getReferenceInfo();
+ } catch (CoreException e) {
+ }
+ return new HashMap(0);
+ }
+
+ public void setReferenceInfo(Map refs) {
+ try {
+ ExternalSettingsManager.getInstance().updateReferenceInfo(this, refs);
+ } catch (CoreException e) {
+ }
+ }
+
+ public ICExternalSetting createExternalSetting(String[] languageIDs,
+ String[] contentTypeIDs, String[] extensions,
+ ICLanguageSettingEntry[] entries) {
+ try {
+ return getSpecSettings().createExternalSetting(languageIDs, contentTypeIDs, extensions, entries);
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ public ICExternalSetting[] getExternalSettings() {
+ try {
+ return getSpecSettings().getExternalSettings();
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ public void removeExternalSetting(ICExternalSetting setting) {
+ try {
+ getSpecSettings().removeExternalSetting(setting);
+ } catch (CoreException e) {
+ }
+ }
+
+ public void removeExternalSettings() {
+ try {
+ getSpecSettings().removeExternalSettings();
+ } catch (CoreException e) {
+ }
+ }
+
+ public ICBuildSetting getBuildSetting() {
+ CConfigurationData data = getConfigurationData(false);
+ return (ICBuildSetting)getChildrenProxyProvider().getProxy(data.getBuildData());
+ }
+
+ public void setSessionProperty(QualifiedName name, Object value){
+ try {
+ getSpecSettings().setSettionProperty(name, value);
+ } catch (CoreException e) {
+ }
+ }
+
+ public Object getSessionProperty(QualifiedName name) {
+ try {
+ return getSpecSettings().getSettionProperty(name);
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ public ICdtVariablesContributor getBuildVariablesContributor() {
+ CConfigurationData data = getConfigurationData(false);
+ return data.getBuildVariablesContributor();
+ }
+
+ public void setName(String name) {
+ if(name.equals(getName()))
+ return;
+
+ getConfigurationData(true).setName(name);
+ try {
+ getSpecSettings().setName(name);
+ } catch (CoreException e) {
+ }
+ }
+
+ public ICConfigExtensionReference create(String extensionPoint,
+ String extension) throws CoreException {
+ return getSpecSettings().create(extensionPoint, extension);
+ }
+
+ public ICConfigExtensionReference[] get(String extensionPointID) {
+ try {
+ return getSpecSettings().get(extensionPointID);
+ } catch (CoreException e) {
+ }
+ return new ICConfigExtensionReference[0];
+ }
+
+ public void remove(ICConfigExtensionReference ext) throws CoreException {
+ getSpecSettings().remove(ext);
+ }
+
+ public void remove(String extensionPoint) throws CoreException {
+ getSpecSettings().remove(extensionPoint);
+ }
+
+ public boolean isPreferenceConfiguration() {
+ return fIsPreference;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java
new file mode 100644
index 00000000000..11014fbe82f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.cdt.core.settings.model.ICBuildSetting;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
+import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
+
+public class CConfigurationDescriptionCache extends CDefaultConfigurationData
+ implements ICConfigurationDescription, IInternalCCfgInfo, ICachedData {
+ private CProjectDescription fParent;
+ private PathSettingsContainer fPathSettingContainer = PathSettingsContainer.createRootContainer();
+ private ResourceDescriptionHolder fRcHolder = new ResourceDescriptionHolder(fPathSettingContainer, true);
+ private List fChildList = new ArrayList();
+ private CConfigurationSpecSettings fSpecSettings;
+ private CConfigurationData fData;
+ private ICSourceEntry fSourceEntries[];
+ private StorableCdtVariables fMacros;
+ private boolean fDataLoadded;
+ private boolean fInitializing;
+
+ CConfigurationDescriptionCache(ICStorageElement storage, CProjectDescription parent) throws CoreException{
+ super(null);
+ fInitializing = true;
+ fParent = parent;
+ fSpecSettings = new CConfigurationSpecSettings(this, storage);
+
+ fId = fSpecSettings.getId();
+ fName = fSpecSettings.getName();
+
+// loadData();
+ }
+
+ void loadData() throws CoreException{
+ if(fDataLoadded)
+ return;
+
+ fDataLoadded = true;
+
+ fData = CProjectDescriptionManager.getInstance().loadData(this);
+ copySettingsFrom(fData, true);
+
+ ((CBuildSettingCache)fBuildData).initEnvironmentCache();
+ ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
+ fMacros = new StorableCdtVariables(vars, true);
+ fInitializing = false;
+ }
+
+ CConfigurationDescriptionCache(CConfigurationData base, CConfigurationSpecSettings settingsBase, CProjectDescription parent, ICStorageElement rootEl, boolean saving) throws CoreException {
+ super(base.getId(), base.getName(), null);
+ fInitializing = true;
+ fParent = parent;
+ fSpecSettings = new CConfigurationSpecSettings(this, settingsBase, rootEl);
+
+ if(base instanceof CConfigurationDescriptionCache){
+ fData = ((CConfigurationDescriptionCache)base).getConfigurationData();
+ fData = CProjectDescriptionManager.getInstance().applyData(this, fData);
+ } else {
+ base = CProjectDescriptionManager.getInstance().applyData(this, base);
+ fData = base;
+ }
+ fDataLoadded = true;
+ fName = fData.getName();
+ fId = fData.getId();
+
+ copySettingsFrom(base, true);
+
+ ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
+ fMacros = new StorableCdtVariables(vars, true);
+ if(saving)
+ fSpecSettings.serialize();
+
+ fInitializing = false;
+ }
+
+ public StorableCdtVariables getCachedVariables(){
+ return fMacros;
+ }
+
+ protected void setId(String id) throws CoreException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public CFileData copyFileData(IPath path, CFileData base, boolean clone) {
+ return new CFileDescriptionCache(base, this);
+ }
+
+ protected CFileData copyFileData(IPath path, CFolderData base,
+ CLanguageData langData) {
+ //should never be here
+ throw new UnsupportedOperationException();
+ }
+
+ public CFolderData copyFolderData(IPath path, CFolderData base, boolean clone) {
+ return new CFolderDescriptionCache(base, this);
+ }
+
+ protected CBuildData copyBuildData(CBuildData data, boolean clone) {
+ return new CBuildSettingCache(data, this);
+ }
+
+ void addResourceDescription(ICResourceDescription des){
+ fRcHolder.addResourceDescription(des.getPath(), des);
+ fChildList.add(des);
+ }
+
+ void addTargetPlatformSetting(ICTargetPlatformSetting tpS){
+ fChildList.add(tpS);
+ }
+
+ void addBuildSetting(ICBuildSetting bs){
+ fChildList.add(bs);
+ }
+
+ public ICProjectDescription getProjectDescription() {
+ return fParent;
+ }
+
+ public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) {
+ return fRcHolder.getResourceDescription(path, exactPath);
+ }
+
+ public ICResourceDescription[] getResourceDescriptions(int kind) {
+ return fRcHolder.getResourceDescriptions(kind);
+ }
+
+ public ICFolderDescription getRootFolderDescription() {
+ return (ICFolderDescription)fRootFolderData;
+ }
+
+ public boolean isActive() {
+ if(isPreferenceConfiguration())
+ return false;
+ return fParent.getActiveConfiguration() == this;
+ }
+
+ public void removeResourceDescription(ICResourceDescription des)
+ throws CoreException {
+ throw new CoreException(new DescriptionStatus("description is read only"));
+ }
+
+ public CFileData createFileData(IPath path, CFileData base) throws CoreException{
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public CFileData createFileData(IPath path, CFolderData base, CLanguageData baseLangData) throws CoreException{
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public CFolderData createFolderData(IPath path, CFolderData base) throws CoreException{
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void removeResourceData(CResourceData data)throws CoreException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setDescription(String description) throws WriteAccessException{
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setName(String name) throws WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICSettingObject[] getChildSettings() {
+ return (ICSettingObject[])fChildList.toArray(new ICSettingObject[fChildList.size()]);
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return this;
+ }
+
+ public ICSettingContainer getParent() {
+ return fParent;
+ }
+
+ public ICResourceDescription[] getResourceDescriptions() {
+ return fRcHolder.getResourceDescriptions();
+ }
+
+ public ICStorageElement getStorage(String id, boolean create) throws CoreException {
+ return getSpecSettings().getStorage(id, create);
+ }
+
+ public void removeStorage(String id) throws CoreException {
+ getSpecSettings().removeStorage(id);
+ }
+
+ public boolean containsStorage(String id) throws CoreException {
+ return getSpecSettings().containsStorage(id);
+ }
+
+ public CConfigurationSpecSettings getSpecSettings() /*throws CoreException*/{
+ return fSpecSettings;
+ }
+
+ public String getBuildSystemId() {
+ return fSpecSettings.getBuildSystemId();
+ }
+
+ public CConfigurationData getConfigurationData() {
+ return fData;
+ }
+
+ public void setConfigurationData(String bsId, CConfigurationData data) throws WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public boolean isModified() {
+ return false;
+ }
+
+ public CConfigurationData getConfigurationData(boolean write) throws WriteAccessException {
+ if(write)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ return this;
+ }
+
+ public void setActive() throws WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+/* public CConfigurationData getBaseData(){
+ return fData;
+ }
+*/
+ public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ ResourceDescriptionHolder createHolderForRc(IPath path){
+ return new ResourceDescriptionHolder(fPathSettingContainer.getChildContainer(path, true, true), false);
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ public ICTargetPlatformSetting getTargetPlatformSetting() {
+ return (ICTargetPlatformSetting)getTargetPlatformData();
+ }
+
+ protected CTargetPlatformData copyTargetPlatformData(CTargetPlatformData base, boolean clone) {
+ return new CTargetPlatformSettingCache(base, this);
+ }
+
+ public ICFileDescription[] getFileDescriptions() {
+ return (ICFileDescription[])fRcHolder.getResourceDescriptions(ICSettingBase.SETTING_FILE);
+ }
+
+ public ICFolderDescription[] getFolderDescriptions() {
+ return (ICFolderDescription[])fRcHolder.getResourceDescriptions(ICSettingBase.SETTING_FOLDER);
+ }
+
+ public void setSourcePaths(IPath[] paths) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICSourceEntry[] getSourceEntries() {
+ if(fSourceEntries == null){
+ IPath[] paths = getSourcePaths();
+ fSourceEntries = fRcHolder.calculateSourceEntriesFromPaths(getProjectDescription().getProject(), paths);
+ }
+ return fSourceEntries;
+ }
+
+ public void setSourceEntries(ICSourceEntry[] entries) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public Map getReferenceInfo() {
+ return getSpecSettings().getReferenceInfo();
+ }
+
+ public void setReferenceInfo(Map refs) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICExternalSetting createExternalSetting(String[] languageIDs,
+ String[] contentTypeIds, String[] extensions,
+ ICLanguageSettingEntry[] entries) {
+ if(!fInitializing)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ return fSpecSettings.createExternalSetting(languageIDs, contentTypeIds, extensions, entries);
+ }
+
+ public ICExternalSetting[] getExternalSettings() {
+ return fSpecSettings.getExternalSettings();
+ }
+
+ public void removeExternalSetting(ICExternalSetting setting) {
+ if(!fInitializing)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ fSpecSettings.removeExternalSetting(setting);
+ }
+
+ public void removeExternalSettings() {
+ if(!fInitializing)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ fSpecSettings.removeExternalSettings();
+ }
+
+ public ICBuildSetting getBuildSetting() {
+ return (ICBuildSetting)getBuildData();
+ }
+
+ public void setSessionProperty(QualifiedName name, Object value) {
+ fSpecSettings.setSettionProperty(name, value);
+ //throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public Object getSessionProperty(QualifiedName name) {
+ return fSpecSettings.getSettionProperty(name);
+ }
+
+ public ICdtVariablesContributor getBuildVariablesContributor() {
+ return fData.getBuildVariablesContributor();
+ }
+
+ public ICConfigExtensionReference create(String extensionPoint,
+ String extension) throws CoreException {
+ if(!fInitializing)
+ throw ExceptionFactory.createIsReadOnlyException();
+ return fSpecSettings.create(extensionPoint, extension);
+ }
+
+ public ICConfigExtensionReference[] get(String extensionPointID) {
+ return fSpecSettings.get(extensionPointID);
+ }
+
+ public void remove(ICConfigExtensionReference ext) throws CoreException {
+ if(!fInitializing)
+ throw ExceptionFactory.createIsReadOnlyException();
+ fSpecSettings.remove(ext);
+ }
+
+ public void remove(String extensionPoint) throws CoreException {
+ if(!fInitializing)
+ throw ExceptionFactory.createIsReadOnlyException();
+ fSpecSettings.remove(extensionPoint);
+ }
+
+ public boolean isPreferenceConfiguration() {
+ return getProjectDescription() == null;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java
new file mode 100644
index 00000000000..822d4cc32a7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java
@@ -0,0 +1,744 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager;
+import org.eclipse.cdt.internal.core.CExtensionInfo;
+import org.eclipse.cdt.internal.core.COwner;
+import org.eclipse.cdt.internal.core.COwnerConfiguration;
+import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
+import org.eclipse.cdt.utils.envvar.StorableEnvironment;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+
+public class CConfigurationSpecSettings implements ICSettingsStorage{
+ static final String BUILD_SYSTEM_ID = "buildSystemId"; //$NON-NLS-1$
+ private final static String ELEMENT_REFERENCES = "references"; //$NON-NLS-1$
+ private static final String PROJECT_EXTENSION_ATTR_POINT = "point"; //$NON-NLS-1$
+ private static final String PROJECT_EXTENSION_ATTR_ID = "id"; //$NON-NLS-1$
+ private static final String PROJECT_EXTENSION_ATTRIBUTE = "attribute"; //$NON-NLS-1$
+ private static final String PROJECT_EXTENSION_ATTRIBUTE_KEY = "key"; //$NON-NLS-1$
+ private static final String PROJECT_EXTENSION_ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
+ private static final String PROJECT_EXTENSION = "extension"; //$NON-NLS-1$
+ private static final String PROJECT_DATA = "data"; //$NON-NLS-1$
+ private static final String PROJECT_DATA_ITEM = "item"; //$NON-NLS-1$
+ private static final String PROJECT_DATA_ID = "id"; //$NON-NLS-1$
+ private static final String PROJECT_EXTENSIONS = "extensions"; //$NON-NLS-1$
+ private static final String OWNER_ID = "owner"; //$NON-NLS-1$
+ private static final String OLD_OWNER_ID = "id"; //$NON-NLS-1$
+
+ private final static String EMPTY_STRING = new String();
+ static final String ID = "id"; //$NON-NLS-1$
+ static final String NAME = "name"; //$NON-NLS-1$
+ private ICConfigurationDescription fCfg;
+ private ICStorageElement fRootStorageElement;
+ private ICStorageElement fSettingsStorageElement;
+ private CStorage fStorage;
+ private String fBuildSystemId;
+ private String fName;
+ private String fId;
+ private StorableCdtVariables fMacros;
+ private StorableEnvironment fEnvironment;
+ private HashMap fRefInfoMap;
+ private CExternalSettingProvider fExtSettingsProvider = new CExternalSettingProvider();
+ private boolean fIsModified;
+ private HashMap fSessionPropertiesMap;
+ private HashMap fExtMap;
+ private HashMap fExtInfoMap = new HashMap();
+ private String fOwnerId;
+ private COwner fOwner;
+// private Map fExternalSettingsProviderMap;
+
+ public CConfigurationSpecSettings(ICConfigurationDescription des, ICStorageElement storage) throws CoreException{
+ fCfg = des;
+ fRootStorageElement = storage;
+ ICStorageElement settings = getSettingsStorageElement();
+
+ fBuildSystemId = settings.getAttribute(BUILD_SYSTEM_ID);
+ fName = settings.getAttribute(NAME);
+ fId = settings.getAttribute(ID);
+
+ setCOwner(settings.getAttribute(OWNER_ID));
+
+ ICStorageElement children[] = settings.getChildren();
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ String name = child.getName();
+
+ if(StorableCdtVariables.MACROS_ELEMENT_NAME.equals(name)){
+ fMacros = new StorableCdtVariables(child, fCfg.isReadOnly());
+ } else if(ELEMENT_REFERENCES.equals(name)){
+ loadReferences(child);
+ } else if (CExternalSettingProvider.ELEMENT_EXT_SETTINGS_CONTAINER.equals(name)){
+ fExtSettingsProvider = new CExternalSettingProvider(child);
+ } else if(StorableEnvironment.ENVIRONMENT_ELEMENT_NAME.equals(name)){
+ fEnvironment = new StorableEnvironment(child, fCfg.isReadOnly());
+ } else if(PROJECT_EXTENSIONS.equals(name)){
+ loadExtensionInfo(child, false);
+ }
+ }
+
+// if(fMacros == null)
+// fMacros = new StorableMacros(des.isReadOnly());
+
+
+ }
+
+ public CConfigurationSpecSettings(ICConfigurationDescription des, ICStorageElement storage, ICStorageElement oldInfo) throws CoreException{
+ fCfg = des;
+ fRootStorageElement = storage;
+
+ loadOldStileDescription(oldInfo);
+
+ }
+ private void loadOldStileDescription(ICStorageElement storage) throws CoreException{
+ setCOwner(storage.getAttribute(OLD_OWNER_ID));
+
+ loadExtensionInfo(storage, true);
+ }
+ public CConfigurationSpecSettings(ICConfigurationDescription des, CConfigurationSpecSettings base){
+ this(des, base, null);
+ }
+
+ public CConfigurationSpecSettings(ICConfigurationDescription des, CConfigurationSpecSettings base, ICStorageElement rootEl){
+ fCfg = des;
+ fRootStorageElement = rootEl;
+ fBuildSystemId = base.fBuildSystemId;
+ fName = base.fName;
+ fId = base.fId;
+
+ copyRefInfos(base.fRefInfoMap);
+
+ if(base.fMacros != null)
+ fMacros = new StorableCdtVariables(base.fMacros, des.isReadOnly());
+
+ if(base.fExtSettingsProvider != null)
+ fExtSettingsProvider = new CExternalSettingProvider(base.fExtSettingsProvider);
+
+ if(base.fSessionPropertiesMap != null)
+ fSessionPropertiesMap = (HashMap)base.fSessionPropertiesMap.clone();
+
+ if(base.fEnvironment != null)
+ fEnvironment = new StorableEnvironment(base.fEnvironment, des.isReadOnly());
+
+ fOwnerId = base.fOwnerId;
+ fOwner = base.fOwner;
+
+ copyExtensionInfo(base);
+ }
+
+ private void copyRefInfos(Map infosMap){
+ if(infosMap == null || infosMap.size() == 0){
+ fRefInfoMap = null;
+ return;
+ }
+
+ fRefInfoMap = new HashMap(infosMap.size());
+ for(Iterator iter = infosMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String projName = (String)entry.getKey();
+ ProjectRefInfo info = (ProjectRefInfo)entry.getValue();
+ fRefInfoMap.put(projName, new ProjectRefInfo(info));
+ }
+ }
+
+ public void setCOwner(String ownerId) throws CoreException{
+ if(ownerId == null)
+ ownerId = CConfigBasedDescriptorManager.NULL_OWNER_ID;
+
+ if(ownerId.equals(fOwnerId))
+ return;
+
+ fOwnerId = ownerId;
+ COwnerConfiguration cfg = CProjectDescriptionManager.getInstance().getDescriptorManager().getOwnerConfiguration(fOwnerId);
+ fOwner = new COwner(cfg);
+ }
+
+ private void loadReferences(ICStorageElement el){
+ fRefInfoMap = new HashMap();
+ ICStorageElement children[] = el.getChildren();
+
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ String name = child.getName();
+
+ if(ProjectRefInfo.ELEMENT_REFERENCE.equals(name)){
+ ProjectRefInfo info = new ProjectRefInfo(child);
+ fRefInfoMap.put(info.getProjectName(), info);
+ }
+ }
+
+ if(fRefInfoMap.size() == 0)
+ fRefInfoMap = null;
+ }
+
+ private Map normalizeRefs(Map ref){
+ for(Iterator iter = ref.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object projObj = entry.getKey();
+ Object cfgObj = entry.getValue();
+ if(projObj instanceof String && (cfgObj == null || cfgObj instanceof String)){
+ String proj = ((String)projObj).trim();
+ String cfg = (String)cfgObj;
+ if(cfg == null)
+ cfg = EMPTY_STRING;
+ else
+ cfg = cfg.trim();
+
+ if(proj.length() > 0){
+ entry.setValue(cfg);
+ } else {
+ iter.remove();
+ }
+ }
+ }
+ return ref;
+ }
+
+ private String[] normalizeRef(String projName, String cfgId){
+ if(projName == null || (projName = projName.trim()).length() == 0)
+ return null;
+ if(cfgId == null)
+ cfgId = EMPTY_STRING;
+ else
+ cfgId = cfgId.trim();
+
+ return new String[] {projName, cfgId};
+ }
+
+ private ICStorageElement getSettingsStorageElement() throws CoreException{
+ if(fSettingsStorageElement == null)
+ fSettingsStorageElement =getStorage(CProjectDescriptionManager.MODULE_ID, true);
+ return fSettingsStorageElement;
+ }
+
+ public ICStorageElement getStorage(String id,boolean create) throws CoreException {
+ return getStorageBase().getStorage(id, create);
+ }
+
+ public void removeStorage(String id) throws CoreException {
+ getStorageBase().removeStorage(id);
+ }
+
+ public boolean containsStorage(String id) throws CoreException {
+ return getStorageBase().containsStorage(id);
+ }
+
+ ICStorageElement getRootStorageElement() throws CoreException{
+ if(fRootStorageElement == null){
+ if(fCfg.isPreferenceConfiguration()){
+ fRootStorageElement = CProjectDescriptionManager.getInstance().getBuildSystemConfigPreferenceStorage(fBuildSystemId);
+ } else {
+ fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fCfg.getProjectDescription(), fCfg.getId());
+ }
+ }
+ return fRootStorageElement;
+ }
+
+ private CStorage getStorageBase() throws CoreException{
+ if(fStorage == null)
+ fStorage = new CStorage((InternalXmlStorageElement)getRootStorageElement());
+ return fStorage;
+ }
+
+ public String getBuildSystemId(){
+ return fBuildSystemId;
+ }
+
+ public ICConfigurationDescription getConfigurarion(){
+ return fCfg;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public void setName(String name){
+ if(isReadOnly())
+ throw ExceptionFactory.createIsReadOnlyException();
+ if(!CDataUtil.objectsEqual(fName, name)){
+ fName = name;
+ fIsModified = true;
+ }
+ }
+
+ public String getId() {
+ return fId;
+ }
+
+ public void setId(String id){
+ if(isReadOnly())
+ throw ExceptionFactory.createIsReadOnlyException();
+ if(!CDataUtil.objectsEqual(fId, id)){
+ fId = id;
+ fIsModified = true;
+ }
+ }
+
+ void setBuildSystemId(String id){
+ if(isReadOnly())
+ throw ExceptionFactory.createIsReadOnlyException();
+ if(!CDataUtil.objectsEqual(fBuildSystemId, id)){
+ fBuildSystemId = id;
+ fIsModified = true;
+ }
+ }
+
+ void serialize() throws CoreException {
+ fId = fCfg.getId();
+ fName = fCfg.getName();
+ ICStorageElement settings = getSettingsStorageElement();
+ settings.clear();
+
+ settings.setAttribute(ID, fId);
+ settings.setAttribute(NAME, fName);
+ settings.setAttribute(BUILD_SYSTEM_ID, fBuildSystemId);
+
+ if(fMacros != null && !fMacros.isEmpty()){
+ ICStorageElement macrosEl = settings.createChild(StorableCdtVariables.MACROS_ELEMENT_NAME);
+ fMacros.serialize(macrosEl);
+ }
+
+ if(fExtSettingsProvider != null){
+ ICStorageElement child = settings.createChild(CExternalSettingProvider.ELEMENT_EXT_SETTINGS_CONTAINER);
+ fExtSettingsProvider.serialize(child);
+ }
+
+ if(fRefInfoMap != null && fRefInfoMap.size() != 0){
+ ICStorageElement el = settings.createChild(ELEMENT_REFERENCES);
+ for(Iterator iter = fRefInfoMap.values().iterator(); iter.hasNext();){
+ ProjectRefInfo info = (ProjectRefInfo)iter.next();
+ ICStorageElement child = el.createChild(ProjectRefInfo.ELEMENT_REFERENCE);
+ info.serialize(child);
+ }
+ }
+
+ ICStorageElement extEl = settings.createChild(PROJECT_EXTENSIONS);
+ encodeProjectExtensions(extEl);
+ }
+
+ public boolean isReadOnly(){
+ return fCfg.isReadOnly();
+ }
+
+ public StorableCdtVariables getMacros(){
+ if(fMacros == null)
+ fMacros = new StorableCdtVariables(isReadOnly());
+ return fMacros;
+ }
+
+ public StorableEnvironment getEnvironment(){
+ return fEnvironment;
+ }
+
+ public void setEnvironment(StorableEnvironment environment){
+ fEnvironment = environment;
+ }
+
+ public Map getReferenceInfo(){
+ if(fRefInfoMap == null || fRefInfoMap.size() == 0)
+ return new HashMap(0);
+
+ Map map = (HashMap)fRefInfoMap.clone();
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ ProjectRefInfo info = (ProjectRefInfo)entry.getValue();
+ entry.setValue(info.getCfgId());
+ }
+ return map;
+ }
+
+ public Map getProjectRefInfoMap(){
+ if(fRefInfoMap == null || fRefInfoMap.size() == 0)
+ return new HashMap(0);
+
+ return (Map)fRefInfoMap.clone();
+ }
+
+ public void setProjectRefInfoMap(Map map){
+ if(map == null && map.size() == 0)
+ fRefInfoMap = null;
+
+ fRefInfoMap = new HashMap(map);
+ fIsModified = true;
+ }
+
+/* public void setReferenceInfo(Map ref){
+ if(isReadOnly())
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ List removed = null, added = null;
+ if(fRefInfos != null){
+ for(int i = 0; i < fRefInfos.length; i++){
+ String cfgId
+ }
+ }
+ if(ref != null && CProjectDescriptionManager.getInstance().normalizeRefs(ref).size() != 0){
+ fReferenceInfo = new HashMap(ref);
+ } else {
+ fReferenceInfo = null;
+ }
+ }
+*/
+/*
+ private Map getExternalSettingsProviderMap(boolean create){
+ if(fExternalSettingsProviderMap == null && create)
+ fExternalSettingsProviderMap = new HashMap();
+ return fExternalSettingsProviderMap;
+ }
+
+ public ExternalSettingInfo getExternalSettingsProviderInfo(String id){
+ Map map = getExternalSettingsProviderMap(false);
+ if(map != null)
+ return (ExternalSettingInfo)map.get(id);
+ return null;
+ }
+
+ public void setExternalSettingsProviderInfo(ExternalSettingInfo info){
+ getExternalSettingsProviderMap(true).put(info.fProvider.getId(), info.fProvider);
+ }
+*/
+ public ICExternalSetting[] getExternalSettings(){
+ return fExtSettingsProvider.getExternalSettings();
+ }
+
+ public ICExternalSetting createExternalSetting(String[] languageIDs,
+ String[] contentTypeIDs, String[] extensions,
+ ICLanguageSettingEntry[] entries) {
+ return fExtSettingsProvider.createExternalSetting(languageIDs, contentTypeIDs, extensions, entries);
+ }
+
+ public void removeExternalSetting(ICExternalSetting setting) {
+ fExtSettingsProvider.removeExternalSetting(setting);
+ }
+
+ public void removeExternalSettings() {
+ fExtSettingsProvider.removeExternalSettings();
+ }
+
+ public boolean isModified(){
+ if(fIsModified)
+ return true;
+
+ return fExtSettingsProvider.isModified();
+ }
+
+ void setModified(){
+ if(isReadOnly())
+ throw ExceptionFactory.createIsReadOnlyException();
+ fIsModified = true;
+ }
+
+ private Map getSessionPropertiesMap(boolean create){
+ if(fSessionPropertiesMap == null && create)
+ fSessionPropertiesMap = new HashMap();
+ return fSessionPropertiesMap;
+ }
+
+ public Object getSettionProperty(QualifiedName name){
+ Map map = getSessionPropertiesMap(false);
+ return map != null ? map.get(name) : null;
+ }
+
+ public void setSettionProperty(QualifiedName name, Object value){
+// if(isReadOnly())
+// throw ExceptionFactory.createIsReadOnlyException();
+ Map map = getSessionPropertiesMap(true);
+ if(value != null)
+ map.put(name, value);
+ else
+ map.remove(name);
+ fIsModified = true;
+ }
+
+
+ //extension reference info
+ private HashMap getExtMap(){
+ if(fExtMap == null)
+ fExtMap = new HashMap();
+ return fExtMap;
+ }
+
+ public Map getExtensionMapCopy(){
+ return (HashMap)getExtMap().clone();
+ }
+
+ public ICConfigExtensionReference[] get(String extensionPointID) {
+ CConfigExtensionReference[] refs = (CConfigExtensionReference[])getExtMap().get(extensionPointID);
+ if (refs == null)
+ return new ICConfigExtensionReference[0];
+ return (ICConfigExtensionReference[])refs.clone();
+ }
+
+// synchronized private ICConfigExtensionReference[] get(String extensionID, boolean update) throws CoreException {
+// ICConfigExtensionReference[] refs = get(extensionID);
+// if (refs.length == 0 && update) {
+// boolean oldIsInitializing = isInitializing;
+// isInitializing = true;
+// fOwner.update(fProject, this, extensionID);
+// isInitializing = oldIsInitializing;
+// updateIfDirty();
+// refs = get(extensionID);
+// }
+// return refs;
+// }
+
+ private CConfigExtensionReference createRef(String extensionPoint, String extension) {
+ CConfigExtensionReference extensions[] = (CConfigExtensionReference[])getExtMap().get(extensionPoint);
+ if (extensions == null) {
+ extensions = new CConfigExtensionReference[1];
+ getExtMap().put(extensionPoint, extensions);
+ } else {
+ CConfigExtensionReference[] newExtensions = new CConfigExtensionReference[extensions.length + 1];
+ System.arraycopy(extensions, 0, newExtensions, 0, extensions.length);
+ extensions = newExtensions;
+ getExtMap().put(extensionPoint, extensions);
+ }
+ extensions[extensions.length - 1] = new CConfigExtensionReference(this, extensionPoint, extension);
+ return extensions[extensions.length - 1];
+ }
+
+ public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException {
+// boolean fireEvent = false;
+ CConfigExtensionReference extRef;
+// synchronized (this) {
+ extRef = createRef(extensionPoint, extension);
+// updateOnDisk();
+// if (!isInitializing) {
+// fireEvent = true;
+// }
+// }
+// if (fireEvent) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
+// }
+ return extRef;
+ }
+
+ public void remove(ICConfigExtensionReference ext) throws CoreException {
+// boolean fireEvent = false;
+// synchronized (this) {
+ CConfigExtensionReference extensions[] = (CConfigExtensionReference[])getExtMap().get(ext.getExtensionPoint());
+ for (int i = 0; i < extensions.length; i++) {
+ if (extensions[i] == ext) {
+// System.arraycopy(extensions, i, extensions, i + 1, extensions.length - 1 - i);
+ System.arraycopy(extensions, i + 1, extensions, i, extensions.length - 1 - i);
+ if (extensions.length > 1) {
+ CConfigExtensionReference[] newExtensions = new CConfigExtensionReference[extensions.length - 1];
+ System.arraycopy(extensions, 0, newExtensions, 0, newExtensions.length);
+ getExtMap().put(ext.getExtensionPoint(), newExtensions);
+ } else {
+ getExtMap().remove(ext.getExtensionPoint());
+ }
+// updateOnDisk();
+// if (!isInitializing) {
+// fireEvent = true;
+// }
+ }
+ }
+// }
+// if (fireEvent) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
+// }
+ }
+
+ public void remove(String extensionPoint) throws CoreException {
+// boolean fireEvent = false;
+// synchronized (this) {
+ CConfigExtensionReference extensions[] = (CConfigExtensionReference[])getExtMap().get(extensionPoint);
+ if (extensions != null) {
+ getExtMap().remove(extensionPoint);
+// updateOnDisk();
+// if (!isInitializing) {
+// fireEvent = true;
+// }
+ }
+// }
+// if (fireEvent) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
+// }
+ }
+
+ CExtensionInfo getInfo(CConfigExtensionReference cProjectExtension) {
+ CExtensionInfo info = (CExtensionInfo)fExtInfoMap.get(cProjectExtension);
+ if (info == null) {
+ info = new CExtensionInfo();
+ fExtInfoMap.put(cProjectExtension, info);
+ }
+ return info;
+ }
+
+ private void loadExtensionInfo(ICStorageElement node, boolean oldData) {
+ ICStorageElement childNode;
+ ICStorageElement list[] = node.getChildren();
+ for (int i = 0; i < list.length; i++) {
+ childNode = list[i];
+// if (childNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (childNode.getName().equals(PROJECT_EXTENSION)) {
+ try {
+ decodeProjectExtension(childNode);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ } else if (oldData && childNode.getName().equals(PROJECT_DATA)) {
+ try {
+ decodeProjectData(childNode);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+// }
+ }
+ }
+
+ private void decodeProjectExtension(ICStorageElement element) throws CoreException {
+ String point = element.getAttribute(PROJECT_EXTENSION_ATTR_POINT);
+ String id = element.getAttribute(PROJECT_EXTENSION_ATTR_ID);
+ CConfigExtensionReference ext = createRef(point, id);
+ ICStorageElement extAttrib[] = element.getChildren();
+ for (int j = 0; j < extAttrib.length; j++) {
+ if (extAttrib[j].getName().equals(PROJECT_EXTENSION_ATTRIBUTE)) {
+// NamedNodeMap attrib = extAttrib.item(j).getAttributes();
+ getInfo(ext).setAttribute(extAttrib[j].getAttribute(PROJECT_EXTENSION_ATTRIBUTE_KEY),
+ extAttrib[j].getAttribute(PROJECT_EXTENSION_ATTRIBUTE_VALUE));
+ }
+ }
+ }
+
+ private void encodeProjectExtensions(ICStorageElement configRootElement) {
+ ICStorageElement element;
+ Iterator extIterator = getExtMap().values().iterator();
+ while (extIterator.hasNext()) {
+ CConfigExtensionReference extension[] = (CConfigExtensionReference[])extIterator.next();
+ for (int i = 0; i < extension.length; i++) {
+ element = configRootElement.createChild(PROJECT_EXTENSION);
+ element.setAttribute(PROJECT_EXTENSION_ATTR_POINT, extension[i].getExtensionPoint());
+ element.setAttribute(PROJECT_EXTENSION_ATTR_ID, extension[i].getID());
+ CExtensionInfo info = (CExtensionInfo)fExtInfoMap.get(extension[i]);
+ if (info != null) {
+ Iterator attribIterator = info.getAttributes().entrySet().iterator();
+ while (attribIterator.hasNext()) {
+ Entry entry = (Entry)attribIterator.next();
+ ICStorageElement extAttributes = element.createChild(PROJECT_EXTENSION_ATTRIBUTE);
+ extAttributes.setAttribute(PROJECT_EXTENSION_ATTRIBUTE_KEY, (String)entry.getKey());
+ extAttributes.setAttribute(PROJECT_EXTENSION_ATTRIBUTE_VALUE, (String)entry.getValue());
+ }
+ }
+ }
+ }
+ }
+
+// private ICExtension createExtensions(ICExtensionReference ext) throws CoreException {
+// InternalCExtension cExtension = null;
+// IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+// IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ext.getExtension());
+// IExtension extension = extensionPoint.getExtension(ext.getID());
+// if (extension == null) {
+// throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+// CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound") + ":" + ext.getID(), null)); //$NON-NLS-1$ //$NON-NLS-2$
+// }
+// IConfigurationElement element[] = extension.getConfigurationElements();
+// for (int i = 0; i < element.length; i++) {
+// if (element[i].getName().equalsIgnoreCase(CEXTENSION_NAME)) {
+// cExtension = (InternalCExtension)element[i].createExecutableExtension("run"); //$NON-NLS-1$
+// cExtension.setExtensionReference(ext);
+// cExtension.setProject(fProject);
+// break;
+// }
+// }
+// return (ICExtension)cExtension;
+// }
+//
+// private IConfigurationElement[] getConfigurationElement(ICConfigExtensionReference ext) throws CoreException {
+// IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+// IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ext.getExtensionPoint());
+// IExtension extension = extensionPoint.getExtension(ext.getID());
+// if (extension == null) {
+// throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+// CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound"), null)); //$NON-NLS-1$
+// }
+// IConfigurationElement element[] = extension.getConfigurationElements();
+// for (int i = 0; i < element.length; i++) {
+// if (element[i].getName().equalsIgnoreCase(CEXTENSION_NAME)) {
+// return element[i].getChildren();
+// }
+// }
+// return new IConfigurationElement[0];
+// }
+
+ private void decodeProjectData(ICStorageElement data) throws CoreException {
+ ICStorageElement[] nodes = data.getChildren();
+ for (int i = 0; i < nodes.length; ++i) {
+ if(PROJECT_DATA_ITEM.equals(nodes[i].getName())){
+ ICStorageElement element = nodes[i];
+ String dataId = element.getAttribute(PROJECT_DATA_ID);
+ if (dataId != null){
+ element.removeAttribute(PROJECT_DATA_ID);
+ try {
+ importStorage(dataId, element);
+ } catch(CoreException e){
+ }
+ }
+ }
+ }
+ }
+
+ public void importStorage(String id, ICStorageElement el) throws CoreException{
+ CStorage storage = getStorageBase();
+
+ storage.importStorage(id, el);
+ }
+
+ private void copyExtensionInfo(CConfigurationSpecSettings other){
+ if(other.fExtMap != null && other.fExtMap.size() != 0){
+ fExtMap = (HashMap)other.fExtMap.clone();
+ for(Iterator iter = fExtMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ CConfigExtensionReference refs[] = (CConfigExtensionReference[])entry.getValue();
+ refs = (CConfigExtensionReference[])refs.clone();
+ for(int i = 0; i < refs.length; i++){
+ refs[i] = new CConfigExtensionReference(this, refs[i]);
+ }
+ entry.setValue(refs);
+ }
+ }
+
+ if(other.fExtInfoMap != null && other.fExtInfoMap.size() != 0){
+ fExtInfoMap = (HashMap)other.fExtInfoMap.clone();
+ for(Iterator iter = fExtInfoMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ CExtensionInfo info = (CExtensionInfo)entry.getValue();
+ info = new CExtensionInfo(info);
+ entry.setValue(info);
+ }
+ }
+ }
+
+ public COwner getCOwner(){
+ return fOwner;
+ }
+
+ public String getCOwnerId(){
+ return fOwnerId;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java
new file mode 100644
index 00000000000..959fad180c3
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+public abstract class CDataProxy implements ICSettingObject {
+ protected ICDataProxyContainer fParent;
+ private CDataObject fData;
+ private int fFlags;
+ private CConfigurationDescription fConfiguration;
+ private String fId;
+
+ private static final int F_RESCAN = 1;
+// private static final int F_WRITABLE = 1 << 1;
+
+ CDataProxy(CDataObject data, ICDataProxyContainer parent, CConfigurationDescription cfg) {
+ fData = data;
+ if(fData != null)
+ fId = fData.getId();
+ fParent = parent;
+ fConfiguration = cfg;
+ }
+
+ public ICSettingContainer getParent() {
+ return fParent;
+ }
+
+ protected void setRescan(boolean rescan){
+ if(isRescan() == rescan)
+ return;
+
+ if(rescan)
+ addFlags(F_RESCAN);
+ else
+ clearFlags(F_RESCAN);
+ }
+
+ protected boolean isRescan(){
+ if(checkFlags(F_RESCAN))
+ return true;
+ return false;//fData == null ? true : !fData.isValid();
+ }
+
+ private boolean checkFlags(int flags){
+ return (fFlags & flags) == flags;
+ }
+
+ private void addFlags(int flags){
+ fFlags |= flags;
+ }
+
+ private void clearFlags(int flags){
+ fFlags &= (~flags);
+ }
+
+ protected CDataObject getData(boolean write){
+ checkUpdate(write);
+ return fData;
+ }
+
+ protected CDataObject doGetData(){
+ return fData;
+ }
+
+ protected boolean containsWritableData(){
+ return !(fData instanceof ICachedData);
+ }
+
+/* protected void setWritable(boolean writable){
+ if(writable == isWritable())
+ return;
+ if(writable)
+ addFlags(F_WRITABLE);
+ else
+ clearFlags(F_WRITABLE);
+ }
+*/
+/* void setData(CDataObject data, boolean write){
+ fData = data;
+ setWritable(write);
+ setRescan(false);
+ }
+*/
+
+/* void updateData(CDataObject data){
+ fData = data;
+ setRescan(false);
+ }
+*/
+ void setData(CDataObject data){
+ fId = data.getId();
+ fData = data;
+ }
+
+ protected void checkUpdate(boolean write){
+ if((write && !containsWritableData())
+ || isRescan())
+ fParent.updateChild(this, write);
+ }
+
+ void remove(){
+ fData = null;
+ fParent = null;
+ }
+
+ public boolean isValid(){
+ checkUpdate(false);
+ return fData != null ? fData.isValid() : false;
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return fConfiguration;
+ }
+
+ public String getId() {
+ return fId;
+// CDataObject data = getData(false);
+// return data != null ? data.getId() : null;
+ }
+
+/* public int getKind() {
+ CDataObject data = getData(false);
+ return data != null ? data.getKind() : 0;
+ }
+*/
+ public String getName() {
+ CDataObject data = getData(false);
+ return data != null ? data.getName() : null;
+ }
+
+ void setConfiguration(CConfigurationDescription cfg){
+ fConfiguration = cfg;
+ }
+
+ public boolean isReadOnly() {
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java
new file mode 100644
index 00000000000..17e6b11a379
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+public abstract class CDataProxyContainer extends CDataProxy implements ICDataProxyContainer{
+ private IProxyProvider fChildProxyProvider;
+
+ CDataProxyContainer(CDataObject data, ICDataProxyContainer parent, CConfigurationDescription cfg) {
+ super(data, parent, cfg);
+ }
+
+/* protected class ChildrenDataScope implements ICDataScope{
+ public boolean isStatic() {
+ return isWritable();
+ }
+
+ public CDataObject[] getChildren() {
+ ICDataParent data = (ICDataParent)CDataProxyContainer.this.getData(false);
+ return data.getChildren();
+ }
+ }
+*/
+
+ public ICSettingObject getChildById(String id){
+ IProxyProvider provider = getChildrenProxyProvider();
+
+ if(provider == null)
+ throw new IllegalStateException();
+
+ return provider.getProxy(id);
+ }
+
+ public ICSettingObject[] getChildrenOfKind(int kind){
+ IProxyProvider provider = getChildrenProxyProvider();
+
+ if(provider == null)
+ throw new IllegalStateException();
+
+ return provider.getProxiesOfKind(kind);
+ }
+
+
+ protected IProxyProvider getChildrenProxyProvider(){
+ if(fChildProxyProvider == null)
+ fChildProxyProvider = createChildProxyProvider();
+ return fChildProxyProvider;
+ }
+
+ protected abstract IProxyProvider createChildProxyProvider();
+
+ public ICSettingObject[] getChildSettings() {
+ IProxyProvider provider = getChildrenProxyProvider();
+
+ if(provider == null)
+ throw new IllegalStateException();
+
+ return provider.getProxies();
+ }
+
+ public void updateChild(CDataProxy child, boolean write){
+ getData(write);
+ getChildrenProxyProvider().cacheValues();
+ }
+
+ protected void setRescan(boolean rescan){
+ if(isRescan() == rescan)
+ return;
+
+ super.setRescan(rescan);
+
+ if(rescan){
+ setRescanChildren();
+ }
+ }
+
+ void setData(CDataObject data) {
+ super.setData(data);
+ setRescanChildren();
+ }
+
+ protected void setRescanChildren(){
+ IProxyProvider provider = getChildrenProxyProvider();
+ if(provider == null)
+ throw new IllegalStateException();
+
+ CDataProxy proxies[] = provider.getCachedProxies();
+ for(int i = 0; i < proxies.length; i++){
+ proxies[i].setRescan(true);
+ }
+ }
+
+ public ICSettingObject getChildSettingById(String id) {
+ return getChildrenProxyProvider().getProxy(id);
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSetting.java
new file mode 100644
index 00000000000..256e0c4a42c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSetting.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.util.CEntriesSet;
+import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
+import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer;
+
+public class CExternalSetting implements ICExternalSetting {
+ static final String ELEMENT_SETTING_INFO = "externalSetting";
+// private static final String ATTRIBUTE_ID = "id";
+ private static final String ATTRIBUTE_EXTENSIONS = "extensions";
+ private static final String ATTRIBUTE_CONTENT_TYPE_IDS = "contentTypes";
+ private static final String ATTRIBUTE_LANGUAGE_IDS = "languages";
+// private static final String[] EMPTY_STRING_ARRAY = new String[0];
+ private static final String SEPARATOR = ":";
+
+// private EntryStore fEntryStore = new EntryStore();
+ private KindBasedStore fStore = new KindBasedStore();
+ private String[] fContentTypeIds;
+ private String[] fLanguageIds;
+ private String[] fExtensions;
+// private String fId;
+
+ public CExternalSetting(ICStorageElement element){
+// fId = element.getAttribute(ATTRIBUTE_ID);
+ String tmp = element.getAttribute(ATTRIBUTE_LANGUAGE_IDS);
+ if(tmp != null)
+ fLanguageIds = tmp.split(SEPARATOR);
+
+ tmp = element.getAttribute(ATTRIBUTE_CONTENT_TYPE_IDS);
+ if(tmp != null)
+ fContentTypeIds = tmp.split(SEPARATOR);
+
+ tmp = element.getAttribute(ATTRIBUTE_EXTENSIONS);
+ if(tmp != null)
+ fExtensions = tmp.split(ATTRIBUTE_EXTENSIONS);
+
+ ICLanguageSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(element);
+
+ initEntryStore(entries);
+ }
+
+ public CExternalSetting(ICExternalSetting base){
+ fLanguageIds = base.getCompatibleLanguageIds();
+ fContentTypeIds = base.getCompatibleContentTypeIds();
+ fExtensions = base.getCompatibleExtensions();
+
+// fEntryStore = new EntryStore();
+ initEntryStore(base.getEntries());
+ }
+
+ public CExternalSetting(ICExternalSetting base, ICLanguageSettingEntry entries[]){
+ this(base);
+
+ initEntryStore(entries);
+ }
+
+ public CExternalSetting(String[] languageIDs,
+ String[] contentTypeIds, String[] extensions,
+ ICLanguageSettingEntry[] entries){
+ if(languageIDs != null)
+ fLanguageIds = (String[])languageIDs.clone();
+ if(contentTypeIds != null)
+ fContentTypeIds = (String[])contentTypeIds.clone();
+ if(extensions != null)
+ fExtensions = (String[])extensions.clone();
+
+ initEntryStore(entries);
+ }
+
+ private void initEntryStore(ICLanguageSettingEntry entries[]){
+ ICLanguageSettingEntry entry;
+ for(int i = 0; i < entries.length; i++){
+ entry = entries[i];
+
+ addEntry(entry);
+ }
+
+// trimToSize();
+ }
+
+ private void addEntry(ICLanguageSettingEntry entry){
+ getEntriesSet(entry.getKind(), true).addEntry(entry);
+ }
+
+/* private void trimToSize(){
+ int kinds[] = KindBasedStore.getSupportedKinds();
+ for(int i = 0; i < kinds.length; i++){
+ CEntriesSet set = getEntriesSet(kinds[i], false);
+ if(set != null)
+ set.trimToSize();
+ }
+ }
+*/
+ private CEntriesSet getEntriesSet(int kind, boolean create){
+ CEntriesSet set = (CEntriesSet)fStore.get(kind);
+ if(set == null && create){
+ set = new CEntriesSet();
+ fStore.put(kind, set);
+ }
+ return set;
+ }
+
+ public String[] getCompatibleContentTypeIds() {
+ if(fContentTypeIds != null)
+ return (String[])fContentTypeIds.clone();
+ return null;
+ }
+
+ public String[] getCompatibleExtensions() {
+ if(fExtensions != null)
+ return (String[])fExtensions.clone();
+ return null;
+ }
+
+ public String[] getCompatibleLanguageIds() {
+ if(fLanguageIds != null)
+ return (String[])fLanguageIds.clone();
+ return null;
+ }
+
+ public ICLanguageSettingEntry[] getEntries(int kind) {
+ CEntriesSet set = getEntriesSet(kind, false);
+ if(set != null)
+ return set.toArray();
+ return new ICLanguageSettingEntry[0];
+ }
+
+// public String getId(){
+// return fId;
+// }
+
+ public ICLanguageSettingEntry[] getEntries() {
+ List result = new ArrayList();
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ for(int i = 0; i < kinds.length; i++){
+ CEntriesSet list = getEntriesSet(kinds[i], false);
+ if(list != null)
+ result.addAll(Arrays.asList(list.toArray()));
+ }
+
+ return (ICLanguageSettingEntry[])result.toArray(new ICLanguageSettingEntry[result.size()]);
+ }
+
+
+ private String composeString(String array[]){
+ StringBuffer buf = new StringBuffer(array[0]);
+ for(int i = 1; i < array.length; i++){
+ buf.append(SEPARATOR).append(array[i]);
+ }
+ return buf.toString();
+ }
+
+ public void serialize(ICStorageElement el){
+ if(fLanguageIds != null && fLanguageIds.length != 0)
+ el.setAttribute(ATTRIBUTE_LANGUAGE_IDS, composeString(fLanguageIds));
+
+ if(fContentTypeIds != null && fContentTypeIds.length != 0)
+ el.setAttribute(ATTRIBUTE_CONTENT_TYPE_IDS, composeString(fContentTypeIds));
+
+
+ if(fExtensions != null && fExtensions.length != 0)
+ el.setAttribute(ATTRIBUTE_EXTENSIONS, composeString(fExtensions));
+
+ LanguageSettingEntriesSerializer.serializeEntries(getEntries(), el);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingProvider.java
new file mode 100644
index 00000000000..ca89a967cfe
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingProvider.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.internal.core.settings.model.ExternalSettingsManager.ExtSettingMapKey;
+
+public class CExternalSettingProvider {
+ private Map fSettingsMap;;
+ static final String ELEMENT_EXT_SETTINGS_CONTAINER = "externalSettings";
+ static final CExternalSetting[] EMPTY_EXT_SETTINGS_ARRAY = new CExternalSetting[0];
+
+ private boolean fIsModified;
+
+ CExternalSettingProvider(){
+
+ }
+
+ CExternalSettingProvider(ICStorageElement element){
+ ICStorageElement children[] = element.getChildren();
+ List externalSettingList = null;
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ String name = child.getName();
+
+ if(CExternalSetting.ELEMENT_SETTING_INFO.equals(name)){
+ if(externalSettingList == null)
+ externalSettingList = new ArrayList();
+
+ CExternalSetting setting = new CExternalSetting(child);
+ externalSettingList.add(setting);
+ }
+ }
+
+ if(externalSettingList != null && externalSettingList.size() != 0){
+ for(int i = 0; i < externalSettingList.size(); i++){
+ ICExternalSetting setting = (ICExternalSetting)externalSettingList.get(i);
+ createExternalSetting(setting.getCompatibleLanguageIds(),
+ setting.getCompatibleContentTypeIds(),
+ setting.getCompatibleExtensions(),
+ setting.getEntries());
+ }
+ }
+ }
+
+ CExternalSettingProvider(CExternalSettingProvider base){
+ if(base.fSettingsMap != null)
+ fSettingsMap = new HashMap(base.fSettingsMap);
+ }
+
+ public ICExternalSetting[] getExternalSettings(){
+ if(fSettingsMap != null)
+ return (ICExternalSetting[])fSettingsMap.values().toArray(new ICExternalSetting[fSettingsMap.size()]);
+ return EMPTY_EXT_SETTINGS_ARRAY;
+ }
+
+ void setExternallSetting(ICExternalSetting[] settings){
+ removeExternalSettings();
+
+ for(int i = 0; i < settings.length; i++){
+ ICExternalSetting setting = settings[i];
+ createExternalSetting(setting.getCompatibleLanguageIds(),
+ setting.getCompatibleContentTypeIds(),
+ setting.getCompatibleExtensions(),
+ setting.getEntries());
+ }
+ fIsModified = true;
+ }
+
+ public ICExternalSetting createExternalSetting(String[] languageIDs,
+ String[] contentTypeIDs, String[] extensions,
+ ICLanguageSettingEntry[] entries) {
+ return createExternalSetting(new CExternalSetting(languageIDs, contentTypeIDs, extensions, entries));
+ }
+
+ private ICExternalSetting createExternalSetting(ICExternalSetting setting){
+ ExtSettingMapKey key = new ExtSettingMapKey(setting);
+ if(fSettingsMap != null){
+ CExternalSetting newSetting = (CExternalSetting)fSettingsMap.get(key);
+ if(newSetting == null){
+ newSetting = new CExternalSetting(setting);
+ } else {
+ newSetting = new CExternalSetting(newSetting, setting.getEntries());
+ }
+
+ fSettingsMap.put(key, newSetting);
+ } else {
+ CExternalSetting newSetting = new CExternalSetting(setting);
+ fSettingsMap = new HashMap();
+ fSettingsMap.put(key, newSetting);
+ }
+ fIsModified = true;
+ return setting;
+
+ }
+
+ public void removeExternalSetting(ICExternalSetting setting) {
+ if(fSettingsMap != null){
+
+ ExtSettingMapKey key = new ExtSettingMapKey(setting);
+ ICExternalSetting settingToRemove = (ICExternalSetting)fSettingsMap.get(key);
+ if(setting.equals(settingToRemove)){
+ fSettingsMap.remove(key);
+ fIsModified = true;
+ }
+ }
+ }
+
+ public void removeExternalSettings() {
+ if(fSettingsMap != null){
+ fSettingsMap.clear();
+ fSettingsMap = null;
+ fIsModified = true;
+ }
+ }
+
+ public void serialize(ICStorageElement el){
+ if(fSettingsMap != null && fSettingsMap.size() != 0){
+ for(Iterator iter = fSettingsMap.values().iterator(); iter.hasNext();){
+ CExternalSetting setting = (CExternalSetting)iter.next();
+ ICStorageElement child = el.createChild(CExternalSetting.ELEMENT_SETTING_INFO);
+ setting.serialize(child);
+ }
+ }
+ }
+
+ public boolean isModified(){
+ return fIsModified;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java
new file mode 100644
index 00000000000..4daad08bfd2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.runtime.IPath;
+
+public class CFileDescription extends CDataProxyContainer implements
+ ICFileDescription, IProxyFactory, IInternalResourceDescription {
+ private PathSettingsContainer fCache;
+ private ResourceDescriptionHolder fRcHolder;
+
+
+ CFileDescription(CFileData data, CConfigurationDescription cfg) {
+ super(data, cfg, cfg);
+ }
+
+ public IPath getPath() {
+ CResourceData data = (CResourceData)getData(false);
+ return data.getPath();
+ }
+
+ public boolean isExcluded() {
+ CResourceData data = (CResourceData)getData(false);
+ return data.isExcluded();
+ }
+
+ public void setExcluded(boolean excluded) {
+ if(isExcluded() == excluded)
+ return;
+
+ CResourceData data = (CResourceData)getData(true);
+ data.setExcluded(excluded);
+ }
+
+ public void setPath(IPath path) {
+ CResourceData data = (CResourceData)getData(true);
+ data.setPath(path);
+ }
+
+ void setData(CDataObject data) {
+ super.setData(data);
+ IPath cachedPath = getCachedPath();
+ IPath newPath = ((CResourceData)data).getPath();
+ if(cachedPath != null && !cachedPath.equals(newPath)){
+ fCache.setPath(newPath, true);
+ }
+ }
+
+ public IPath getCachedPath() {
+ if(fCache != null)
+ return fCache.getPath();
+ return null;
+ }
+
+ public final int getType() {
+ return ICSettingBase.SETTING_FILE;
+ }
+
+ public void setPathContainer(PathSettingsContainer cr) {
+ fCache = cr;
+ }
+
+ public ICLanguageSetting getLanguageSetting() {
+ CFileData data = getFileData(false);
+ IProxyProvider provider = getChildrenProxyProvider();
+ CLanguageData lData = data.getLanguageData();
+ if(lData != null)
+ return (ICLanguageSetting)provider.getProxy(lData);
+ return null;
+ }
+
+ protected CFileData getFileData(boolean write){
+ return (CFileData)getData(write);
+ }
+
+ protected IProxyProvider createChildProxyProvider() {
+ ICDataScope scope = new ICDataScope(){
+
+ public CDataObject[] getChildren() {
+ return new CLanguageData[]{getFileData(false).getLanguageData()};
+ }
+
+ public boolean isStatic() {
+ return !containsWritableData();
+ }
+
+ };
+ IProxyCache cache = new MapProxyCache();
+
+ return new ProxyProvider(scope, cache, this);
+ }
+
+ public CDataProxy createProxy(CDataObject data) {
+ if(data instanceof CLanguageData)
+ return new CLanguageSetting((CLanguageData)data, this, (CConfigurationDescription)getConfiguration());
+ return null;
+ }
+
+ private ResourceDescriptionHolder getRcHolder(){
+ if(fRcHolder == null){
+ fRcHolder = ((CConfigurationDescription)getConfiguration()).createHolder(this);
+ }
+ return fRcHolder;
+ }
+
+ public ICFolderDescription getParentFolderDescription() {
+ return getRcHolder().getParentFolderDescription();
+ }
+
+ public PathSettingsContainer getPathContainer() {
+ return fCache;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java
new file mode 100644
index 00000000000..dd35780cf94
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFileData;
+import org.eclipse.core.runtime.IPath;
+
+public class CFileDescriptionCache extends CDefaultFileData implements
+ ICFileDescription, ICachedData {
+ private CConfigurationDescriptionCache fCfg;
+ private ResourceDescriptionHolder fRcDesHolder;
+
+ public CFileDescriptionCache(CFileData base, CConfigurationDescriptionCache cfg) {
+ super(base.getId(), base.getPath(), base, cfg, null, true);
+ fCfg = cfg;
+ fCfg.addResourceDescription(this);
+ }
+
+ protected CLanguageData copyLanguageData(CLanguageData data, boolean clone) {
+ return new CLanguageSettingCache(data, this);
+ }
+
+ public void setExcluded(boolean excluded) throws WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setName(String name) throws WriteAccessException{
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+
+ public void setPath(IPath path) throws WriteAccessException{
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return fCfg;
+ }
+
+ public ICSettingContainer getParent() {
+ return fCfg;
+ }
+
+ public ICLanguageSetting getLanguageSetting() {
+ return (ICLanguageSetting)fLanguageData;
+ }
+
+ public ICSettingObject[] getChildSettings() {
+ return new ICSettingObject[]{(ICSettingObject)fLanguageData};
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ private ResourceDescriptionHolder getRcDesHolder(){
+ if(fRcDesHolder == null)
+ fRcDesHolder = fCfg.createHolderForRc(getPath());
+ return fRcDesHolder;
+ }
+
+
+ public ICFolderDescription getParentFolderDescription() {
+ return getRcDesHolder().getParentFolderDescription();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java
new file mode 100644
index 00000000000..a9d57f75c36
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public class CFolderDescription extends CDataProxyContainer implements
+ ICFolderDescription, IProxyFactory, IInternalResourceDescription {
+ private ResourceDescriptionHolder fRcHolder;
+ private PathSettingsContainer fCache;
+
+ CFolderDescription(CFolderData data, CConfigurationDescription cfg) {
+ super(data, cfg, cfg);
+ }
+
+
+ public IPath getPath() {
+ CResourceData data = (CResourceData)getData(false);
+ return data.getPath();
+ }
+
+ public boolean isExcluded() {
+ CResourceData data = (CResourceData)getData(false);
+ return data.isExcluded();
+ }
+
+ public void setExcluded(boolean excluded){
+ if(isExcluded() == excluded)
+ return;
+
+ CResourceData data = (CResourceData)getData(true);
+ data.setExcluded(excluded);
+ }
+
+ public void setPath(IPath path) {
+ CResourceData data = (CResourceData)getData(true);
+ data.setPath(path);
+ }
+
+ protected CFolderData getFolderData(boolean write){
+ return (CFolderData)getData(write);
+ }
+
+ protected IProxyProvider createChildProxyProvider() {
+ ICDataScope scope = new ICDataScope(){
+
+ public CDataObject[] getChildren() {
+ return getFolderData(false).getLanguageDatas();
+ }
+
+ public boolean isStatic() {
+ return !containsWritableData();
+ }
+
+ };
+ IProxyCache cache = new MapProxyCache();
+
+ return new ProxyProvider(scope, cache, this);
+ }
+
+
+ public ICResourceDescription getNestedResourceDescription(IPath relPath, boolean exactPath) {
+ return getRcHolder().getResourceDescription(relPath, exactPath);
+ }
+
+
+ public ICResourceDescription[] getNestedResourceDescriptions(int kind) {
+ return getRcHolder().getResourceDescriptions(kind);
+ }
+
+
+ public ICLanguageSetting getLanguageSettingForFile(String fileName) {
+ IProject project = getConfiguration().getProjectDescription().getProject();
+ return CProjectDescriptionManager.getInstance().findLanguagSettingForFile(fileName, project, getLanguageSettings());
+ }
+
+ public ICLanguageSetting[] getLanguageSettings() {
+ IProxyProvider provider = getChildrenProxyProvider();
+ CFolderData data = (CFolderData)getData(false);
+ CLanguageData lDatas[] = data.getLanguageDatas();
+ ICLanguageSetting settings[] = new ICLanguageSetting[lDatas.length];
+ for(int i = 0; i < lDatas.length; i++){
+ settings[i] = (ICLanguageSetting)provider.getProxy(lDatas[i]);
+ }
+ return settings;
+ }
+
+
+ public CDataProxy createProxy(CDataObject data) {
+ if(data instanceof CLanguageData)
+ return new CLanguageSetting((CLanguageData)data, this, (CConfigurationDescription)getConfiguration());
+ return null;
+ }
+
+ private ResourceDescriptionHolder getRcHolder(){
+ if(fRcHolder == null){
+ fRcHolder = ((CConfigurationDescription)getConfiguration()).createHolder(this);
+ }
+ return fRcHolder;
+ }
+
+ void setData(CDataObject data) {
+ super.setData(data);
+ IPath cachedPath = getCachedPath();
+ IPath newPath = ((CResourceData)data).getPath();
+ if(cachedPath != null && !cachedPath.equals(newPath)){
+ fCache.setPath(newPath, true);
+ }
+ }
+
+ public IPath getCachedPath() {
+ if(fCache != null)
+ return fCache.getPath();
+ return null;
+ }
+
+ public final int getType() {
+ return ICSettingBase.SETTING_FOLDER;
+ }
+
+ public void setPathContainer(PathSettingsContainer cr) {
+ fCache = cr;
+ }
+
+ public PathSettingsContainer getPathContainer(){
+ return fCache;
+ }
+
+
+ public ICResourceDescription[] getNestedResourceDescriptions() {
+ return getNestedResourceDescriptions(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER);
+ }
+
+
+ public ICFolderDescription getParentFolderDescription() {
+ return getRcHolder().getParentFolderDescription();
+ }
+
+
+ public ICLanguageSetting createLanguageSettingForContentTypes(
+ String languageId, String[] typeIds) throws CoreException {
+ CFolderData data = getFolderData(true);
+
+ CLanguageData lData = data.createLanguageDataForContentTypes(languageId, typeIds);
+ if(lData == null)
+ throw ExceptionFactory.createCoreException("data was not created");
+
+ CDataProxy proxy = getChildrenProxyProvider().getProxy(lData);
+ if(!(proxy instanceof ICLanguageSetting))
+ throw ExceptionFactory.createCoreException("expected proxy of type ICLanguageSetting, but was " + proxy.getClass().getName());
+
+ return (ICLanguageSetting)proxy;
+ }
+
+
+ public ICLanguageSetting createLanguageSettingForExtensions(
+ String languageId, String[] extensions) throws CoreException {
+ CFolderData data = getFolderData(true);
+
+ CLanguageData lData = data.createLanguageDataForExtensions(languageId, extensions);
+ if(lData == null)
+ throw ExceptionFactory.createCoreException("data was not created");
+
+ CDataProxy proxy = getChildrenProxyProvider().getProxy(lData);
+ if(!(proxy instanceof ICLanguageSetting))
+ throw ExceptionFactory.createCoreException("expected proxy of type ICLanguageSetting, but was " + proxy.getClass().getName());
+
+ return (ICLanguageSetting)proxy;
+ }
+
+
+ public boolean isRoot() {
+ return getPath().segmentCount() == 0;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java
new file mode 100644
index 00000000000..3eb60ddb2e7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFolderData;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.content.IContentType;
+
+public class CFolderDescriptionCache extends CDefaultFolderData implements
+ ICFolderDescription, ICachedData {
+ private CConfigurationDescriptionCache fCfg;
+ private ResourceDescriptionHolder fRcDesHolder;
+
+ public CFolderDescriptionCache(CFolderData base, CConfigurationDescriptionCache cfg) {
+ super(base.getId(), base.getPath(), base, cfg, null, true);
+ fCfg = cfg;
+ fCfg.addResourceDescription(this);
+ }
+
+ public ICLanguageSetting getLanguageSettingForFile(String fileName) {
+ IProject project = getConfiguration().getProjectDescription().getProject();
+ return CProjectDescriptionManager.getInstance().findLanguagSettingForFile(fileName, project, getLanguageSettings());
+ }
+
+ public ICLanguageSetting[] getLanguageSettings() {
+ return (CLanguageSettingCache[])fLanguageDatas.toArray(new CLanguageSettingCache[fLanguageDatas.size()]);
+ }
+
+ public ICResourceDescription getNestedResourceDescription(IPath relPath, boolean exactPath) {
+ return getRcDesHolder().getResourceDescription(relPath, exactPath);
+ }
+
+ public ICResourceDescription[] getNestedResourceDescriptions(int kind) {
+ return getRcDesHolder().getResourceDescriptions(kind);
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return fCfg;
+ }
+
+ public ICSettingContainer getParent() {
+ return fCfg;
+ }
+
+ public ICSettingObject[] getChildSettings() {
+ return getLanguageSettings();
+ }
+
+ protected CLanguageData copyLanguageData(CLanguageData base, boolean clone) {
+ return new CLanguageSettingCache(base, this);
+ }
+
+ public void setExcluded(boolean excluded) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setPath(IPath path) throws WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setName(String name) throws WriteAccessException {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICResourceDescription[] getNestedResourceDescriptions() {
+ return getNestedResourceDescriptions(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER);
+ }
+
+ private ResourceDescriptionHolder getRcDesHolder(){
+ if(fRcDesHolder == null)
+ fRcDesHolder = fCfg.createHolderForRc(getPath());
+ return fRcDesHolder;
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ public ICFolderDescription getParentFolderDescription() {
+ return getRcDesHolder().getParentFolderDescription();
+ }
+
+ public ICLanguageSetting createLanguageSetting(IContentType srcType) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICLanguageSetting createLanguageSettingForContentTypes(
+ String languageId, String[] typeIds) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public ICLanguageSetting createLanguageSettingForExtensions(
+ String languageId, String[] extensions) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public CLanguageData createLanguageDataForContentTypes(String languageId,
+ String[] typesIds) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public CLanguageData createLanguageDataForExtensions(String languageId,
+ String[] extensions) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public boolean isRoot() {
+ return getPath().segmentCount() == 0;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java
new file mode 100644
index 00000000000..4469d99c6f8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java
@@ -0,0 +1,399 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
+import org.eclipse.cdt.core.settings.model.util.EntryStore;
+import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.runtime.content.IContentTypeSettings;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+
+public class CLanguageSetting extends CDataProxy implements
+ ICLanguageSetting {
+
+ CLanguageSetting(CLanguageData data, CDataProxyContainer parent, CConfigurationDescription cfg) {
+ super(data, parent, cfg);
+ }
+
+ public final int getType() {
+ return ICSettingBase.SETTING_LANGUAGE;
+ }
+
+// public IContentType getHeaderContentType() {
+// CLanguageData data = getCLanguageData(false);
+// return data.getHeaderContentType();
+// }
+
+ public String getLanguageId() {
+ CLanguageData data = getCLanguageData(false);
+ return data.getLanguageId();
+ }
+
+ public void setLanguageId(String id){
+ CLanguageData data = getCLanguageData(true);
+ data.setLanguageId(id);
+ }
+
+ private CLanguageData getCLanguageData(boolean write){
+ return (CLanguageData)getData(write);
+ }
+
+//TODO: public ICLanguageSettingEntry[] getSettingEntries() {
+// return getSettingEntries(ICLanguageSettingEntry.ALL);
+// }
+
+ public ICLanguageSettingEntry[] getSettingEntries(int kind) {
+ CLanguageData data = getCLanguageData(false);
+ return data.getEntries(kind);
+ }
+
+ public List getSettingEntriesList(int kind) {
+ CLanguageData data = getCLanguageData(false);
+ ICLanguageSettingEntry entries[] = data.getEntries(kind);
+ int size = entries != null ? entries.length : 0;
+ List arrayList = new ArrayList(size);
+ for(int i = 0; i < size; i++){
+ arrayList.add(entries[i]);
+ }
+ return arrayList;
+ }
+
+ public String[] getSourceContentTypeIds() {
+ CLanguageData data = getCLanguageData(false);
+ String ids[] = data.getSourceContentTypeIds();
+ if(ids != null)
+ return ids;
+ return CDefaultLanguageData.EMPTY_STRING_ARRAY;
+ }
+
+ public int getSupportedEntryKinds() {
+ CLanguageData data = getCLanguageData(false);
+ return data.getSupportedEntryKinds();
+ }
+
+ public boolean supportsEntryKind(int kind) {
+ return (getSupportedEntryKinds() & kind) == kind;
+ }
+
+ public String[] getContentTypeFileSpecs (IContentType type) {
+ String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ IContentTypeSettings settings = null;
+ IProject project = getProject();
+ if (project != null) {
+ IScopeContext projectScope = new ProjectScope(project);
+ try {
+ settings = type.getSettings(projectScope);
+ } catch (Exception e) {}
+ if (settings != null) {
+ String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ if (specs.length > 0) {
+ int total = globalSpecs.length + specs.length;
+ String[] projSpecs = new String[total];
+ int i=0;
+ for (int j=0; j<specs.length; j++) {
+ projSpecs[i] = specs[j];
+ i++;
+ }
+ for (int j=0; j<globalSpecs.length; j++) {
+ projSpecs[i] = globalSpecs[j];
+ i++;
+ }
+ return projSpecs;
+ }
+ }
+ }
+ return globalSpecs;
+ }
+
+ private IProject getProject(){
+ return getConfiguration().getProjectDescription().getProject();
+ }
+
+/* public String[] getHeaderExtensions() {
+ CLanguageData data = getCLanguageData(false);
+ IContentType type = data.getHeaderContentType();
+ String[] exts;
+ if(type != null) {
+ exts = getContentTypeFileSpecs(type);
+ } else {
+ exts = data.getHeaderExtensions();
+ if(exts != null)
+ exts = (String[])exts.clone();
+ else
+ exts = new String[0];
+ }
+
+ return exts;
+ }
+*/
+ public String[] getSourceExtensions() {
+ CLanguageData data = getCLanguageData(false);
+ String[] exts = null;
+ String[] typeIds = data.getSourceContentTypeIds();
+ if(typeIds != null && typeIds.length != 0){
+ IContentTypeManager manager = Platform.getContentTypeManager();
+ IContentType type;
+ if(typeIds.length == 1){
+ type = manager.getContentType(typeIds[0]);
+ if(type != null)
+ exts = getContentTypeFileSpecs(type);
+ } else {
+ List list = new ArrayList();
+ for(int i = 0; i < typeIds.length; i++){
+ type = manager.getContentType(typeIds[i]);
+ if(type != null) {
+ list.addAll(Arrays.asList(getContentTypeFileSpecs(type)));
+ }
+ }
+ exts = (String[])list.toArray(new String[list.size()]);
+ }
+ } else {
+ exts = data.getSourceExtensions();
+ if(exts != null)
+ exts = (String[])exts.clone();
+ else
+ exts = new String[0];
+ }
+
+ if(exts == null)
+ exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
+ return exts;
+ }
+
+/*
+ private Map fillNameToEntryMap(ICLanguageSettingEntry entries[], Map map){
+ if(map == null)
+ map = new HashMap();
+
+ for(int i = 0; i < entries.length; i++){
+ ICLanguageSettingEntry entry = entries[i];
+ map.put(entry.getName(), entry);
+ }
+ return map;
+ }
+
+
+ private class SettingChangeInfo implements ICSettingsChangeInfo {
+ CLanguageData fData;
+ ICLanguageSettingEntry fNewEntries[];
+ int fKind;
+ ICLanguageSettingEntryInfo fAddedInfo[];
+ ICLanguageSettingEntry fRemoved[];
+
+ SettingChangeInfo(int kind, ICLanguageSettingEntry newEntries[], CLanguageData data){
+ fNewEntries = newEntries;
+ fData = data;
+ fKind = kind;
+ }
+
+ SettingChangeInfo(int kind, ICLanguageSettingEntryInfo addedEntriesInfo[], ICLanguageSettingEntry removed[], CLanguageData data){
+ fAddedInfo = addedEntriesInfo;
+ fRemoved = removed;
+ fData = data;
+ fKind = kind;
+ }
+
+ public ICLanguageSettingEntryInfo[] getAddedEntriesInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ICLanguageSettingEntry[] getEntries() {
+ if(fNewEntries == null){
+ ICLanguageSettingEntry oldEntries[] = fData.getSettingEntries(fKind);
+ List list = new ArrayList();
+ for(int i = 0; i < oldEntries.length; i++){
+ ICLanguageSettingEntry entry = oldEntries[i];
+ if(entry.getKind() != fKind)
+ continue;
+
+ list.add(entry);
+ }
+
+
+ }
+ return fNewEntries;
+ }
+
+ public int getKind() {
+ return fKind;
+ }
+
+ public ICLanguageSettingEntry[] getRemovedEntries() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+
+ public void changeEntries(ICLanguageSettingEntryInfo[] added, ICLanguageSettingEntry[] removed) {
+ CLanguageData data = getCLanguageData(true);
+ Map map = null;
+ if(added != null && added.length > 0){
+ map = sortEntries(added, true, map);
+ }
+ if(removed != null && removed.length > 0){
+ map = sortEntries(removed, false, map);
+ }
+
+ if(map != null){
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ int kind = ((Integer)entry.getKey()).intValue();
+ List lists[] = (List[])entry.getValue();
+ List aList = lists[0];
+ List rList = lists[1];
+ ICLanguageSettingEntry sortedAdded[] = aList != null ?
+ (ICLanguageSettingEntry[])aList.toArray(new ICLanguageSettingEntry[aList.size()])
+ : null;
+ ICLanguageSettingEntry sortedRemoved[] = rList != null ?
+ (ICLanguageSettingEntry[])rList.toArray(new ICLanguageSettingEntry[rList.size()])
+ : null;
+
+ data.changeEntries(kind, sortedAdded, sortedRemoved);
+ }
+ }
+ }
+
+ private Map sortEntries(ICLanguageSettingEntry entries[], boolean added, Map map){
+ if(map == null)
+ map = new HashMap();
+
+ int index = added ? 0 : 1;
+ for(int i = 0; i < entries.length; i++){
+ ICLanguageSettingEntry entry = entries[i];
+ if(entry != null){
+ Integer iKind = new Integer(entry.getKind());
+ List[] addedRemovedListArr = (List[])map.get(iKind);
+ if(addedRemovedListArr == null){
+ addedRemovedListArr = new List[2];
+ map.put(iKind, addedRemovedListArr);
+ }
+ List list = addedRemovedListArr[index];
+ if(list == null){
+ list = new ArrayList();
+ addedRemovedListArr[index] = list;
+ }
+ list.add(entry);
+ }
+ }
+ return map;
+ }
+*/
+ public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) {
+ CLanguageData data = getCLanguageData(true);
+ EntryStore store = new EntryStore();
+// KindBasedStore nameSetStore = new KindBasedStore();
+ int eKind;
+ if(entries != null){
+ for(int i = 0; i < entries.length; i++){
+ ICLanguageSettingEntry entry = entries[i];
+ eKind = entry.getKind();
+ if((kind & eKind) != 0 && (data.getSupportedEntryKinds() & eKind) != 0){
+ store.addEntry(entry);
+ }
+ }
+ }
+
+ setSettingEntries(kind, data, store);
+ }
+
+ private int[] flagsToArray(int flags){
+ int arr[] = new int[32];
+ int num = 0;
+ for(int i = 1; i != 0; i = i << 1){
+ if((flags & i) != 0)
+ arr[num++] = i;
+ }
+ if(num == arr.length)
+ return arr;
+ else if(num == 0)
+ return new int[0];
+ int result[] = new int[num];
+ System.arraycopy(arr, 0, result, 0, num);
+ return result;
+ }
+
+ public void setSettingEntries(int kind, List list) {
+ CLanguageData data = getCLanguageData(true);
+ EntryStore store = new EntryStore();
+// KindBasedStore nameSetStore = new KindBasedStore();
+ int eKind;
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ ICLanguageSettingEntry entry = (ICLanguageSettingEntry)iter.next();
+ eKind = entry.getKind();
+ if((kind & eKind) != 0 && (data.getSupportedEntryKinds() & eKind) != 0){
+ store.addEntry(entry);
+ }
+ }
+
+ setSettingEntries(kind, data, store);
+ }
+
+ private void setSettingEntries(int kind, CLanguageData data, EntryStore store){
+ int oredk = getSupportedEntryKinds();
+ int kinds[] = flagsToArray(oredk);
+
+// int kinds[] = KindBasedStore.getSupportedKinds();
+ for(int i = 0; i < kinds.length; i++){
+ ICLanguageSettingEntry sortedEntries[] = store.getEntries(kinds[i]);
+ if((kind & kinds[i]) != 0)
+ data.setEntries(kinds[i], sortedEntries);
+ }
+ }
+
+/* private boolean shouldAdd(ICLanguageSettingEntry entry){
+ int kind = entry.getKind();
+ Set set = (Set)store.get(kind);
+ if(set == null){
+ set = new HashSet();
+ store.put(kind, set);
+ }
+ return set.add(entry.getName());
+ }
+*/
+//TODO: public ICLanguageSettingEntry[] getResolvedSettingEntries() {
+ // TODO Auto-generated method stub
+// return getSettingEntries();
+// }
+
+ public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) {
+ // TODO Auto-generated method stub
+ return getSettingEntries(kind);
+ }
+
+ public void setSourceContentTypeIds(String[] ids) {
+ CLanguageData data = getCLanguageData(true);
+
+ data.setSourceContentTypeIds(ids);
+ }
+
+ public void setSourceExtensions(String[] exts) {
+ CLanguageData data = getCLanguageData(true);
+
+ data.setSourceExtensions(exts);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java
new file mode 100644
index 00000000000..bf05580b7c5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
+
+public class CLanguageSettingCache extends CDefaultLanguageData implements
+ ICLanguageSetting, ICachedData {
+ private ICResourceDescription fParent;
+ public CLanguageSettingCache(CLanguageData base, CFolderDescriptionCache folderCache) {
+ fId = base.getId();
+ fParent = folderCache;
+ copySettingsFrom(base);
+ }
+
+ public CLanguageSettingCache(CLanguageData base, CFileDescriptionCache fileCache) {
+ fId = base.getId();
+ fParent = fileCache;
+ copySettingsFrom(base);
+ }
+
+/* public ICLanguageSettingEntry[] getResolvedSettingEntries() {
+ // TODO Auto-generated method stub
+ return getSettingEntries();
+ }
+*/
+ public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) {
+ // TODO Auto-generated method stub
+ return getSettingEntries(kind);
+ }
+
+ public ICLanguageSettingEntry[] getSettingEntries(int kind) {
+// int kinds[] = KindBasedStore.getSupportedKinds();
+// List list = new ArrayList();
+// for(int i = 0; i < kinds.length; i++){
+// ICLanguageSettingEntry entries[] = fStore.getEntries(kinds[i]);
+// for(int j = 0; j < entries.length; j++){
+// list.add(entries[j]);
+// }
+// }
+// return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ return fStore.getEntries(kind);
+ }
+
+ public List getSettingEntriesList(int kind) {
+// int kinds[] = KindBasedStore.getSupportedKinds();
+// List list = new ArrayList();
+// for(int i = 0; i < kinds.length; i++){
+// ICLanguageSettingEntry entries[] = fStore.getEntries(kinds[i]);
+// for(int j = 0; j < entries.length; j++){
+// list.add(entries[j]);
+// }
+// }
+// return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
+ return fStore.getEntriesList(kind);
+ }
+
+
+ public void setLanguageId(String id) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setName(String name) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setSettingEntries(int kind, List entriesList) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setEntries(int kind, ICLanguageSettingEntry[] entries) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public boolean supportsEntryKind(int kind) {
+ return (getSupportedEntryKinds() & kind) == kind;
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return fParent.getConfiguration();
+ }
+
+ public ICSettingContainer getParent() {
+ return fParent;
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectConverterDesciptor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectConverterDesciptor.java
new file mode 100644
index 00000000000..772ceaa80ec
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectConverterDesciptor.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+
+public class CProjectConverterDesciptor {
+ final static String PROJECT_CONVERTER_EXTPOINT_ID = CCorePlugin.PLUGIN_ID + "." + "projectConverter"; //$NON-NLS-1$ //$NON-NLS-2$
+ final static String CONVERTER = "converter"; //$NON-NLS-1$
+ final static String CLASS = "class"; //$NON-NLS-1$
+
+ private String fId;
+ private ICProjectConverter fConverter;
+ private IExtension fExtension;
+
+ CProjectConverterDesciptor(IExtension extension){
+ fId = extension.getUniqueIdentifier();
+ fExtension = extension;
+ }
+
+ public ICProjectConverter getConverter() throws CoreException{
+ if(fConverter == null) {
+ fConverter = createConverter(fExtension);
+ }
+ return fConverter;
+ }
+
+ private static ICProjectConverter createConverter(IExtension ext) throws CoreException{
+ IConfigurationElement elements[] = ext.getConfigurationElements();
+ for(int i = 0; i < elements.length; i++){
+ IConfigurationElement element = elements[i];
+ if(CONVERTER.equals(element.getName())){
+ Object obj = element.createExecutableExtension(CLASS);
+ if(obj instanceof ICProjectConverter){
+ return (ICProjectConverter)obj;
+ } else
+ throw ExceptionFactory.createCoreException("illegal provider implementation");
+ }
+ }
+ throw ExceptionFactory.createCoreException("no provider defined");
+ }
+
+ public String getId(){
+ return fId;
+ }
+
+ public boolean canConvertProject(IProject project, String oldOwnerId, ICProjectDescription des){
+ try {
+ ICProjectConverter converter = getConverter();
+ return converter.canConvertProject(project, oldOwnerId, des);
+ } catch (CoreException e) {
+ }
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java
new file mode 100644
index 00000000000..608ba276eca
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java
@@ -0,0 +1,384 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+
+public class CProjectDescription implements ICProjectDescription, ICDataProxyContainer {
+
+ private ICConfigurationDescription fActiveCfg;
+ private String fActiveCfgId;
+ private ICConfigurationDescription fIndexCfg;
+ private String fIndexCfgId;
+ private IProject fProject;
+ private ICSettingsStorage fStorage;
+ private ICStorageElement fRootStorageElement;
+ private Map fCfgMap = new HashMap();
+ private boolean fIsReadOnly;
+ private boolean fIsModified;
+ private HashMap fPropertiesMap;
+ private boolean fNeedsActiveCfgIdPersistence;
+ private boolean fIsLoadding;
+
+ CProjectDescription(IProject project, ICStorageElement element, boolean loadding) throws CoreException {
+ fProject = project;
+ fRootStorageElement = element;
+ fIsReadOnly = loadding;
+ fIsLoadding = loadding;
+
+ if(loadding){
+ CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
+ Map cfgStorMap = mngr.createCfgStorages(this);
+
+ for(Iterator iter = cfgStorMap.values().iterator(); iter.hasNext();){
+ CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICStorageElement)iter.next(), this);
+ configurationCreated(cache);
+ }
+ }
+ fPropertiesMap = new HashMap();
+// loadActiveCfgId();
+ }
+
+ void loadDatas(){
+ if(!fIsReadOnly || !fIsLoadding)
+ return;
+
+ fIsLoadding = false;
+ for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
+ CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
+ try {
+ cache.loadData();
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ iter.remove();
+ }
+ }
+ }
+
+ public boolean isLoadding(){
+ return fIsLoadding;
+ }
+
+/* CProjectDescription(IProject project) throws CoreException {
+ this(project, CProjectDescriptionManager.getInstance().createStorage(project, true, false));
+ }
+*/
+ public CProjectDescription(CProjectDescription base, boolean saving, ICStorageElement el) {
+ fActiveCfgId = base.fActiveCfgId;
+ fProject = base.fProject;
+ fRootStorageElement = el;
+ fIsReadOnly = saving;
+ fIsLoadding = base.fIsLoadding;
+
+
+
+ for(Iterator iter = base.fCfgMap.values().iterator(); iter.hasNext();){
+ try {
+ IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next();
+ if(fIsReadOnly){
+ CConfigurationData baseData = cfgDes.getConfigurationData(false);
+ if(baseData instanceof CConfigurationDescriptionCache){
+ baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
+ }
+ CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(baseData, cfgDes.getSpecSettings(), this, null, saving);
+ configurationCreated(cache);
+ } else {
+ CConfigurationData baseData = cfgDes.getConfigurationData(false);
+ CConfigurationDescription cfg = new CConfigurationDescription(baseData, this);
+ configurationCreated(cfg);
+ }
+ } catch (CoreException e){
+ //TODO: log
+ }
+ }
+
+ fPropertiesMap = (HashMap)base.fPropertiesMap.clone();
+ }
+
+ void configurationCreated(ICConfigurationDescription des){
+ fCfgMap.put(des.getId(), des);
+ }
+
+ public ICConfigurationDescription createConfiguration(String id, String name,
+ ICConfigurationDescription base) throws CoreException{
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this);
+ configurationCreated(cfg);
+ return cfg;
+ }
+
+ public ICConfigurationDescription getActiveConfiguration() {
+ if(fActiveCfg == null){
+ String id = getActiveConfigurationId();
+ if(id != null){
+ fActiveCfg = getConfigurationById(id);
+ if(fActiveCfg == null){
+ fActiveCfgId = getFirstCfgId();
+ if(fActiveCfgId != null){
+ fActiveCfg = getConfigurationById(fActiveCfgId);
+ fNeedsActiveCfgIdPersistence = true;
+// storeActiveCfgId(fActiveCfgId);
+ }
+ }
+ }
+ }
+ return fActiveCfg;
+ }
+
+ private String getActiveConfigurationId(){
+ if(fActiveCfgId == null){
+ fActiveCfgId = CProjectDescriptionManager.getInstance().loadActiveCfgId(this);
+ if(fActiveCfgId == null){
+ fActiveCfgId = getFirstCfgId();
+ if(fActiveCfgId != null){
+ fNeedsActiveCfgIdPersistence = true;
+// storeActiveCfgId(fActiveCfgId);
+ }
+ }
+ }
+ return fActiveCfgId;
+ }
+
+ boolean needsActiveCfgIdPersistence(){
+ return fNeedsActiveCfgIdPersistence;
+ }
+
+ private String getFirstCfgId(){
+ if(!fCfgMap.isEmpty()){
+ return (String)fCfgMap.keySet().iterator().next();
+ }
+ return null;
+ }
+
+ public ICConfigurationDescription getConfigurationById(String id) {
+ return (ICConfigurationDescription)fCfgMap.get(id);
+ }
+
+ public ICConfigurationDescription getConfigurationByName(String name) {
+ for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
+ ICConfigurationDescription cfg = (ICConfigurationDescription)iter.next();
+ if(name.equals(cfg.getName()))
+ return cfg;
+ }
+ return null;
+ }
+
+ public ICConfigurationDescription[] getConfigurations() {
+ return (ICConfigurationDescription[])fCfgMap.values().toArray(new ICConfigurationDescription[fCfgMap.size()]);
+ }
+
+ public void removeConfiguration(String name) throws WriteAccessException {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+
+ CConfigurationDescription cfgDes = (CConfigurationDescription)getConfigurationByName(name);
+ if(cfgDes != null){
+ cfgDes.removeConfiguration();
+ }
+
+ }
+
+ void configurationRemoved(CConfigurationDescription des){
+ boolean wasActive = des.isActive();
+ fCfgMap.remove(des.getId());
+ fIsModified = true;
+
+ if(wasActive){
+ fActiveCfg = null;
+// fActiveCfgId = null;
+ getActiveConfiguration();
+ }
+ }
+
+ public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ ((CConfigurationDescription)cfg).removeConfiguration();
+ }
+
+ public void setActiveConfiguration(
+ ICConfigurationDescription cfg) throws WriteAccessException {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ if(cfg == null)
+ throw new NullPointerException();
+
+ if(getActiveConfiguration() != cfg){
+ fActiveCfgId = cfg.getId();
+ fActiveCfg = cfg;
+ fIsModified = true;
+// storeActiveCfgId(fActiveCfgId);
+ }
+ }
+
+ public IProject getProject() {
+ return fProject;
+ }
+
+ public ICStorageElement getStorage(String moduleId, boolean create) throws CoreException {
+ return getStorageBase().getStorage(moduleId, create);
+ }
+
+// public boolean containsStorage(String id) throws CoreException {
+// return getStorageBase().containsStorage(id);
+// }
+
+ public ICSettingObject[] getChildSettings() {
+ return getConfigurations();
+ }
+
+ public ICConfigurationDescription getConfiguration() {
+ return null;
+ }
+
+ public String getId() {
+ //TODO:
+ return null;
+ }
+
+ public final int getType() {
+ return ICSettingBase.SETTING_PROJECT;
+ }
+
+ public String getName() {
+ return fProject.getName();
+ }
+
+ public ICSettingContainer getParent() {
+ return null;
+ }
+
+ public boolean isValid() {
+ return fProject.exists() && fCfgMap.size() > 0;
+ }
+
+ public void updateChild(CDataProxy child, boolean write) {
+ if(write){
+ try {
+ String oldId = child.getId();
+ CConfigurationDescription cfgDes = ((CConfigurationDescription)child);
+ cfgDes.doWritable();
+ updateMap(cfgDes, oldId);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ }
+
+ void updateMap(CConfigurationDescription des, String oldId){
+ if(!oldId.equals(des.getId())){
+ fCfgMap.remove(oldId);
+ fCfgMap.put(des.getId(), des);
+ }
+ }
+
+ ICStorageElement getRootStorageElement() throws CoreException{
+ if(fRootStorageElement == null){
+ fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, fIsReadOnly);
+ }
+ return fRootStorageElement;
+ }
+
+ private ICSettingsStorage getStorageBase() throws CoreException{
+ if(fStorage == null)
+ fStorage = new CStorage((InternalXmlStorageElement)getRootStorageElement());
+ return fStorage;
+ }
+
+ public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this);
+ configurationCreated(cfg);
+ return cfg;
+ }
+
+ public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this);
+ configurationCreated(cfg);
+ return cfg;
+ }
+
+ public boolean isModified() {
+ if(fIsModified)
+ return true;
+
+ if(fRootStorageElement != null
+ && ((InternalXmlStorageElement)fRootStorageElement).isDirty())
+ return true;
+
+ for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
+ if(((ICConfigurationDescription)iter.next()).isModified())
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isReadOnly() {
+ return fIsReadOnly;
+ }
+
+ public ICSettingObject getChildSettingById(String id) {
+ return getConfigurationById(id);
+ }
+
+ public ICConfigurationDescription getIndexConfiguration(){
+ if(fIndexCfg == null){
+ String id = getIndexConfigurationId();
+ fIndexCfg = getConfigurationById(id);
+ }
+ return fIndexCfg;
+ }
+
+ private String getIndexConfigurationId(){
+ if(fIndexCfgId == null)
+ fIndexCfgId = getActiveConfigurationId();
+ return fIndexCfgId;
+ }
+
+ void setIndexConfiguration(ICConfigurationDescription cfg){
+ fIndexCfg = cfg;
+ fIndexCfgId = cfg.getId();
+ }
+
+ public Object getSessionProperty(QualifiedName name) {
+ return fPropertiesMap.get(name);
+ }
+
+ public void setSessionProperty(QualifiedName name, Object value) {
+ fPropertiesMap.put(name, value);
+ }
+
+ public void removeStorage(String id) throws CoreException {
+ getStorageBase().removeStorage(id);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java
new file mode 100644
index 00000000000..90e85093485
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.internal.core.settings.model.ExternalSettingsManager.ExtSettingsDelta;
+
+class CProjectDescriptionDelta implements ICDescriptionDelta {
+ private List fChildList = new ArrayList();
+ private CProjectDescriptionDelta fParent;
+ private ICSettingObject fSetting;
+ private ICSettingObject fOldSetting;
+ private ICSettingObject fNewSetting;
+ private int fStatus;
+ private int fAddedLanguageEntriesKinds;
+ private int fRemovedLanguageEntriesKinds;
+ private int fReorderedLanguageEntriesKinds;
+ private ExtSettingsDelta[] fExtSettingsDeltas;
+
+ private static final int KIND_MASK = 3;
+ private static final int FLAGS_OFFSET = 2;
+
+ CProjectDescriptionDelta(ICSettingObject newSetting, ICSettingObject oldSetting){
+ fNewSetting = newSetting;
+ fOldSetting = oldSetting;
+ if(newSetting != null){
+ fSetting = newSetting;
+ if(oldSetting != null)
+ setDeltaKind(CHANGED);
+ else
+ setDeltaKind(ADDED);
+ } else {
+ fSetting = oldSetting;
+ setDeltaKind(REMOVED);
+ }
+ }
+
+ void addChild(CProjectDescriptionDelta child){
+ fChildList.add(child);
+ child.setParent(this);
+ }
+
+ private void setParent(CProjectDescriptionDelta parent){
+ fParent = parent;
+ }
+
+ public ICDescriptionDelta[] getChildren() {
+ return (CProjectDescriptionDelta[])fChildList.toArray(new CProjectDescriptionDelta[fChildList.size()]);
+ }
+
+ public ICSettingObject getOldSetting() {
+ return fOldSetting;
+ }
+
+ public ICSettingObject getSetting() {
+ return fSetting;
+ }
+
+ public int getSettingType() {
+ return fSetting.getType();
+ }
+
+ public ICDescriptionDelta getParent() {
+ return fParent;
+ }
+
+ public boolean isEmpty(){
+ return fChildList.size() == 0
+ && getDeltaKind() == CHANGED
+ && getChangeFlags() == 0;
+ }
+
+ public int getChangeFlags() {
+ return (fStatus & (~KIND_MASK)) >> FLAGS_OFFSET;
+ }
+
+ void addChangeFlags(int flags){
+ flags |= getChangeFlags();
+ setChangeFlags(flags);
+ }
+
+ void removeChangeFlags(int flags){
+ flags = (getChangeFlags() & (~flags));
+ setChangeFlags(flags);
+ }
+
+ void setChangeFlags(int flags){
+ fStatus = (fStatus & KIND_MASK) | (flags << FLAGS_OFFSET);
+ }
+
+ void setDeltaKind(int kind){
+ fStatus = (fStatus & (~KIND_MASK)) | (kind & KIND_MASK);
+ }
+
+ public int getDeltaKind() {
+ return fStatus & KIND_MASK;
+ }
+
+ public ICSettingObject getNewSetting() {
+ return fNewSetting;
+ }
+
+ void setAddedLanguageEntriesKinds(int kinds){
+ fAddedLanguageEntriesKinds = kinds;
+ checkSettingEntriesChangeFlag();
+ }
+
+ public int getAddedEntriesKinds() {
+ return fAddedLanguageEntriesKinds;
+ }
+
+ public int getRemovedEntriesKinds() {
+ return fRemovedLanguageEntriesKinds;
+ }
+
+ public int getReorderedEntriesKinds() {
+ return fReorderedLanguageEntriesKinds;
+ }
+
+ void setRemovedLanguageEntriesKinds(int kinds){
+ fRemovedLanguageEntriesKinds = kinds;
+ checkSettingEntriesChangeFlag();
+ }
+
+ void setReorderedLanguageEntriesKinds(int kinds){
+ fReorderedLanguageEntriesKinds = kinds;
+ checkSettingEntriesChangeFlag();
+ }
+
+ private void checkSettingEntriesChangeFlag(){
+ if(fAddedLanguageEntriesKinds != 0
+ || fRemovedLanguageEntriesKinds != 0
+ || fReorderedLanguageEntriesKinds != 0)
+ addChangeFlags(SETTING_ENTRIES);
+ else
+ removeChangeFlags(SETTING_ENTRIES);
+ }
+
+ public ExtSettingsDelta[] getExtSettingsDeltas(){
+ return fExtSettingsDeltas;
+ }
+
+ public void setExtSettingsDeltas(ExtSettingsDelta[] deltas){
+ fExtSettingsDeltas = deltas;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionEvent.java
new file mode 100644
index 00000000000..a087d7c7b36
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionEvent.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.core.resources.IProject;
+
+public final class CProjectDescriptionEvent {
+ public static final int LOADDED = 1;
+ public static final int ABOUT_TO_APPLY = 1 << 1;
+ public static final int APPLIED = 1 << 2;
+ public static final int COPY_CREATED = 1 << 3;
+ public static final int ALL = LOADDED | ABOUT_TO_APPLY | APPLIED | COPY_CREATED;
+
+ private int fType;
+ private ICProjectDescription fNewDescription;
+ private ICProjectDescription fOldDescription;
+ private ICProjectDescription fAppliedDescription;
+ private ICDescriptionDelta fProjDelta;
+ private ICDescriptionDelta fActiveCfgDelta;
+ private ICDescriptionDelta fIndexCfgDelta;
+ private IProject fProject;
+
+ public CProjectDescriptionEvent(int type,
+ ICDescriptionDelta delta,
+ ICProjectDescription newDes,
+ ICProjectDescription oldDes,
+ ICProjectDescription appliedDes){
+ fType = type;
+ fProjDelta = delta;
+ fNewDescription = newDes;
+ fOldDescription = oldDes;
+ fAppliedDescription = appliedDes;
+ if(fNewDescription != null){
+ fProject = fNewDescription.getProject();
+ } else if(fOldDescription != null){
+ fProject = fOldDescription.getProject();
+ }
+ }
+
+ public IProject getProject(){
+ return fProject;
+ }
+
+ public int getEventType(){
+ return fType;
+ }
+
+ public ICDescriptionDelta getProjectDelta(){
+ return fProjDelta;
+ }
+
+ public ICDescriptionDelta getActiveCfgDelta(){
+ if(fActiveCfgDelta == null){
+ fActiveCfgDelta = getDelta(true);
+ }
+ return fActiveCfgDelta;
+ }
+
+ public ICDescriptionDelta getIndexCfgDelta(){
+ if(fIndexCfgDelta == null){
+ fIndexCfgDelta = getDelta(false);
+ }
+ return fIndexCfgDelta;
+ }
+
+ private ICDescriptionDelta getDelta(boolean active){
+ ICDescriptionDelta delta = null;
+ switch(getEventType()){
+ case LOADDED:
+ case ABOUT_TO_APPLY:
+ case APPLIED:
+ if(fProjDelta != null){
+ ICProjectDescription oldDes = getOldCProjectDescription();
+ ICProjectDescription newDes = getNewCProjectDescription();
+ if(oldDes == null){
+ ICConfigurationDescription cfg = getCfg(newDes, active);
+ if(cfg != null){
+ delta = findCfgDelta(fProjDelta, cfg.getId());
+ }
+ } else if(newDes == null){
+ ICConfigurationDescription cfg = getCfg(oldDes, active);
+ if(cfg != null){
+ delta = findCfgDelta(fProjDelta, cfg.getId());
+ }
+ } else {
+ ICConfigurationDescription newCfg = getCfg(newDes, active);
+ ICConfigurationDescription oldCfg = getCfg(oldDes, active);
+ if(oldCfg == null){
+ if(newCfg != null){
+ delta = new CProjectDescriptionDelta(newCfg, null);
+ }
+ } else if (newCfg == null){
+ delta = new CProjectDescriptionDelta(null, oldCfg);
+ } else {
+ if(newCfg.getId().equals(oldCfg.getId())){
+ delta = findCfgDelta(fProjDelta, newCfg.getId());
+ } else {
+ delta = CProjectDescriptionManager.getInstance().createDelta(newCfg, oldCfg);
+ }
+ }
+ }
+ }
+ case COPY_CREATED:
+ break;
+ }
+ return delta;
+ }
+
+ private ICConfigurationDescription getCfg(ICProjectDescription des, boolean active){
+ return active ? des.getActiveConfiguration() : ((CProjectDescription)des).getIndexConfiguration();
+ }
+
+ private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){
+ if(delta == null)
+ return null;
+ ICDescriptionDelta children[] = delta.getChildren();
+ for(int i = 0; i < children.length; i++){
+ ICSettingObject s = children[i].getNewSetting();
+ if(s != null && id.equals(s.getId()))
+ return children[i];
+ }
+ return null;
+ }
+
+ public ICProjectDescription getOldCProjectDescription(){
+ return fOldDescription;
+ }
+
+ public ICProjectDescription getNewCProjectDescription(){
+ return fNewDescription;
+ }
+
+ public ICProjectDescription getAppliedCProjectDescription(){
+ return fAppliedDescription;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
new file mode 100644
index 00000000000..1e6361b7885
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
@@ -0,0 +1,2630 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILanguageDescriptor;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
+import org.eclipse.cdt.core.settings.model.util.ListComparator;
+import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager;
+import org.eclipse.cdt.internal.core.envvar.ContributedEnvironment;
+import org.eclipse.cdt.internal.core.model.CElementDelta;
+import org.eclipse.cdt.internal.core.model.CModelManager;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.osgi.framework.Version;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.xml.sax.SAXException;
+
+public class CProjectDescriptionManager {
+ private static final String ACTIVE_CFG = "activeConfiguration";
+ private static final QualifiedName ACTIVE_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, ACTIVE_CFG);
+
+ private static final String OLD_PROJECT_DESCRIPTION = "cdtproject"; //$NON-NLS-1$
+ private static final String OLD_CDTPROJECT_FILE_NAME = ".cdtproject"; //$NON-NLS-1$
+ private static final String OLD_PROJECT_OWNER_ID = "id"; //$NON-NLS-1$
+ private static final String CONVERTED_CFG_NAME = "convertedConfig"; //$NON-NLS-1$
+ private static final String CONVERTED_CFG_ID_PREFIX = "converted.config"; //$NON-NLS-1$
+
+ private static final String STORAGE_FILE_NAME = ".cproject"; //$NON-NLS-1$
+ private static final QualifiedName PROJECT_DESCRCIPTION_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "projectDescription"); //$NON-NLS-1$
+ private static final String ROOT_ELEMENT_NAME = "cproject"; //$NON-NLS-1$
+ private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$
+ public static final Version DESCRIPTION_VERSION = new Version("4.0"); //$NON-NLS-1$
+ final static String MODULE_ID = "org.eclipse.cdt.core.settings"; //$NON-NLS-1$
+ static final String CONFIGURATION = "cconfiguration"; //$NON-NLS-1$
+ private static final ICLanguageSettingEntry[] EMPTY_LANGUAGE_SETTINGS_ENTRIES_ARRAY = new ICLanguageSettingEntry[0];
+ private static final ICElementDelta[] EMPTY_CELEMENT_DELTA = new ICElementDelta[0];
+ private static final ICLanguageSetting[] EMPTY_LANGUAGE_SETTINGS_ARRAY = new ICLanguageSetting[0];
+ private static final String PREFERENCES_STORAGE = "preferences"; //$NON-NLS-1$
+ private static final String PREFERENCE_BUILD_SYSTEM_ELEMENT = "buildSystem"; //$NON-NLS-1$
+ private static final String ID = "id"; //$NON-NLS-1$
+ private static final String PREFERENCE_CFG_ID_PREFIX = "preference."; //$NON-NLS-1$
+ private static final String PREFERENCE_CFG_NAME = "Preference Configuration"; //$NON-NLS-1$
+ private static final String ROOT_PREFERENCE_ELEMENT = "preferences"; //$NON-NLS-1$
+ public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$
+ private static final String DEFAULT_CFG_ID_PREFIX = CCorePlugin.PLUGIN_ID + ".default.config"; //$NON-NLS-1$
+ private static final String DEFAULT_CFG_NAME = "Configuration"; //$NON-NLS-1$
+
+ private class CompositeSafeRunnable implements ISafeRunnable {
+ private List fRunnables = new ArrayList();
+ private boolean fStopOnErr;
+
+ public void add(ISafeRunnable runnable){
+ fRunnables.add(runnable);
+ }
+
+ public void handleException(Throwable exception) {
+ }
+
+ public void run() throws Exception {
+ for(Iterator iter = fRunnables.iterator(); iter.hasNext();){
+ ISafeRunnable r = (ISafeRunnable)iter.next();
+ try {
+ r.run();
+ } catch (Exception e){
+ r.handleException(e);
+ if(fStopOnErr)
+ throw e;
+ }
+ }
+ }
+ }
+
+ private class DesSerializationRunnable implements ISafeRunnable {
+ private ICProjectDescription fDes;
+ private ICStorageElement fElement;
+
+ public DesSerializationRunnable(ICProjectDescription des, ICStorageElement el) {
+ fDes = des;
+ fElement = el;
+ }
+
+ public void handleException(Throwable exception) {
+ }
+
+ public void run() throws Exception {
+ serialize(fDes.getProject(), STORAGE_FILE_NAME, fElement);
+ ((ContributedEnvironment)CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
+ }
+
+ }
+ private class ProjectInfoHolder{
+ ICProjectDescription fDescription;
+ ScannerInfoProviderProxy fSIProvider;
+ }
+
+ private class ListenerDescriptor{
+ ICProjectDescriptionListener fListener;
+ int fEventTypes;
+
+ public ListenerDescriptor(ICProjectDescriptionListener listener, int eventTypes) {
+ fListener = listener;
+ fEventTypes = eventTypes;
+ }
+
+ public boolean handlesEvent(int eventType){
+ return (eventType & fEventTypes) != 0;
+ }
+ }
+
+ private Map fProviderMap;
+ private CProjectConverterDesciptor fConverters[];
+ private List fListeners = new ArrayList();
+ private Map fPreferenceMap = new HashMap();
+ private CConfigBasedDescriptorManager fDescriptorManager;
+ private ThreadLocal fLoaddingDescriptions = new ThreadLocal();
+
+// private CStorage fPrefCfgStorage;
+ private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer(){
+
+
+ public void updateChild(CDataProxy child, boolean write) {
+ if(write){
+ try {
+ ((CConfigurationDescription)child).doWritable();
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ }
+
+ public ICSettingObject[] getChildSettings() {
+ return (ICSettingObject[])fPreferenceMap.values().toArray(new CConfigurationDescriptionCache[fPreferenceMap.size()]);
+ }
+ };
+
+// Map fDescriptionMap = new HashMap();
+ private static CProjectDescriptionManager fInstance;
+
+ private CProjectDescriptionManager(){
+
+ }
+
+ public static CProjectDescriptionManager getInstance(){
+ if(fInstance == null)
+ fInstance = new CProjectDescriptionManager();
+ return fInstance;
+ }
+
+ public void startup(){
+ if(fDescriptorManager == null){
+ fDescriptorManager = CConfigBasedDescriptorManager.getInstance();
+ fDescriptorManager.startup();
+ }
+ }
+
+ public void shutdown(){
+ if(fDescriptorManager != null){
+ fDescriptorManager.shutdown();
+ }
+ }
+
+ private ICProjectDescription getDescriptionLoadding(IProject project){
+ Map map = getDescriptionLoaddingMap(false);
+ if(map != null)
+ return (ICProjectDescription)map.get(project);
+ return null;
+ }
+
+ private void setDescriptionLoadding(IProject project, ICProjectDescription des){
+ Map map = getDescriptionLoaddingMap(true);
+ map.put(project, des);
+ }
+
+ private void clearDescriptionLoadding(IProject project){
+ Map map = getDescriptionLoaddingMap(false);
+ if(map != null)
+ map.remove(project);
+ }
+
+ private Map getDescriptionLoaddingMap(boolean create){
+ Map map = (Map)fLoaddingDescriptions.get();
+ if(map == null && create){
+ map = new HashMap();
+ fLoaddingDescriptions.set(map);
+ }
+ return map;
+ }
+
+ public ICProjectDescription getProjectDescription(IProject project, boolean write){
+ ICProjectDescription des = null;
+ des = getLoaddedDescription(project);
+ IProjectDescription eDes = null;
+
+ if(des == null)
+ des = getDescriptionLoadding(project);
+
+ if(des == null){
+ try {
+ des = loadProjectDescription(project);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ if(des == null){
+ //TODO: check if conversion needed
+ try {
+ eDes = project.getDescription();
+ des = getConvertedDescription(project, eDes);
+ } catch (CoreException e) {
+ }
+ }
+
+ if(des != null){
+ if(setLoaddedDescription(project, des, false)){
+
+ if(eDes != null)
+ saveConversion(project, eDes, (CProjectDescription)des, new NullProgressMonitor());
+
+ CProjectDescriptionEvent event = createLoaddedEvent(des);
+ notifyListeners(event);
+
+ des = getLoaddedDescription(project);
+
+ ICProjectDescription updatedDes = ExternalSettingsManager.getInstance().updateReferencedSettings(des);
+ if(updatedDes != des){
+ try {
+ setProjectDescription(project, updatedDes);
+ } catch (CoreException e) {
+ }
+ }
+ }
+ }
+ }
+
+ if(des != null && write){
+ CProjectDescription cache = (CProjectDescription)des;
+ ICStorageElement el = null;
+ try {
+ el = cache.getRootStorageElement();
+ el = copyElement((InternalXmlStorageElement)el, false);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+
+ des = new CProjectDescription((CProjectDescription)des, false, el);
+ CProjectDescriptionEvent event = createCopyCreatedEvent(des, cache);
+ notifyListeners(event);
+ }
+ return des;
+ }
+
+ private CProjectDescriptionEvent createLoaddedEvent(ICProjectDescription des){
+ return new CProjectDescriptionEvent(CProjectDescriptionEvent.LOADDED,
+ null,
+ des,
+ null,
+ null);
+ }
+
+ private CProjectDescriptionEvent createCopyCreatedEvent(ICProjectDescription newDes, ICProjectDescription oldDes){
+ return new CProjectDescriptionEvent(CProjectDescriptionEvent.COPY_CREATED,
+ null,
+ newDes,
+ oldDes,
+ null);
+ }
+
+ CProjectDescriptionEvent createAboutToApplyEvent(ICProjectDescription newDes, ICProjectDescription oldDes){
+ return new CProjectDescriptionEvent(CProjectDescriptionEvent.ABOUT_TO_APPLY,
+ null,
+ newDes,
+ oldDes,
+ null);
+ }
+
+ CProjectDescriptionEvent createAppliedEvent(ICProjectDescription newDes, ICProjectDescription oldDes, ICProjectDescription appliedDes, ICDescriptionDelta delta){
+ return new CProjectDescriptionEvent(CProjectDescriptionEvent.APPLIED,
+ delta,
+ newDes,
+ oldDes,
+ appliedDes);
+ }
+
+ private Object[] loadProjectDescriptionFromOldstyleStorage(IProject project) throws CoreException {
+ ICStorageElement rootEl = readOldCDTProjectFile(project);
+ if(rootEl != null){
+ String ownerId = rootEl.getAttribute(OLD_PROJECT_OWNER_ID);
+ CProjectDescription des = (CProjectDescription)createProjectDescription(project, false);
+ String id = CDataUtil.genId(CONVERTED_CFG_ID_PREFIX);
+ des.createConvertedConfiguration(id, CONVERTED_CFG_NAME, rootEl);
+ return new Object[]{ownerId, des};
+ }
+ return null;
+ }
+
+ private ICProjectDescription getConvertedDescription(IProject project, IProjectDescription eDes) throws CoreException{
+ Object info[] = loadProjectDescriptionFromOldstyleStorage(project);
+ CProjectDescription des;
+ String ownerId;
+ try {
+ if(info != null){
+ ownerId = (String)info[0];
+ des = (CProjectDescription)info[1];
+ setDescriptionLoadding(project, des);
+ } else {
+ ownerId = null;
+ des = null;
+ }
+
+ ICProjectConverter converter = getConverter(project, ownerId, des);
+ if(converter != null){
+ CProjectDescription convertedDes = (CProjectDescription)converter.convertProject(project, eDes, ownerId, des);
+ if(convertedDes != null){
+ ICConfigurationDescription activeCfg = convertedDes.getActiveConfiguration();
+ if(activeCfg != null){
+ checkBuildSystemChange(project, eDes, activeCfg.getBuildSystemId(), null, new NullProgressMonitor());
+ // if(convertedDes != null)
+ des = convertedDes;
+ }
+ }
+ } else {
+// des;
+ }
+
+ if(des != null && des.isValid()){
+ //TODO: should be set via the CModel operation?
+ InternalXmlStorageElement el = null;
+ try {
+ el = copyElement((InternalXmlStorageElement)des.getRootStorageElement(), false);
+ } catch (CoreException e2) {
+ }
+
+ des = new CProjectDescription(des, true, el);
+
+ try {
+ ((InternalXmlStorageElement)des.getRootStorageElement()).setReadOnly(true);
+ } catch (CoreException e1) {
+ }
+ }
+ }finally{
+ clearDescriptionLoadding(project);
+ }
+ return des;
+ }
+
+ private void saveConversion(final IProject proj,
+ final IProjectDescription eDes,
+ CProjectDescription des,
+ final IProgressMonitor monitor) {
+
+ CompositeSafeRunnable r = new CompositeSafeRunnable();
+ r.add(new ISafeRunnable(){
+
+ public void handleException(Throwable exception) {
+ }
+
+ public void run() throws Exception {
+ proj.setDescription(eDes, monitor);
+ }
+ });
+
+ try {
+ r.add(createDesSerializationRunnable(des));
+ } catch (CoreException e1) {
+ CCorePlugin.log(e1);
+ }
+
+ runWspModification(r, monitor);
+ }
+
+ private void runWspModification(final ISafeRunnable runnable, IProgressMonitor monitor){
+ IWorkspace wsp = ResourcesPlugin.getWorkspace();
+ boolean scheduleRule = true;
+ if(!wsp.isTreeLocked()) {
+ ISchedulingRule rule = wsp.getRoot();
+ IJobManager mngr = Job.getJobManager();
+ try{
+ mngr.beginRule(rule, monitor);
+ scheduleRule = false;
+ try {
+ runnable.run();
+ } catch (Exception e){
+ runnable.handleException(e);
+ }
+ } catch (Exception e) {
+ } finally {
+ mngr.endRule(rule);
+ }
+ }
+
+ if(scheduleRule){
+ Job job = new Job("info serialization"){
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ runnable.run();
+ } catch (Exception e) {
+ runnable.handleException(e);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.setRule(wsp.getRoot());
+ job.setSystem(true);
+ job.schedule();
+ }
+ }
+
+ private ICProjectConverter getConverter(IProject project, String oldOwnerId, ICProjectDescription des){
+ CProjectConverterDesciptor[] converterDess = getConverterDescriptors();
+ ICProjectConverter converter = null;
+ for(int i = 0; i < converterDess.length; i++){
+ if(converterDess[i].canConvertProject(project, oldOwnerId, des)){
+ try {
+ converter = converterDess[i].getConverter();
+ } catch (CoreException e) {
+ }
+ if(converter != null)
+ break;
+ }
+ }
+ return converter;
+ }
+
+ private CProjectConverterDesciptor[] getConverterDescriptors(){
+ if(fConverters == null){
+ initConverterInfoSynch();
+ }
+ return fConverters;
+ }
+
+ private synchronized void initConverterInfoSynch(){
+ if(fConverters != null)
+ return;
+
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CProjectConverterDesciptor.PROJECT_CONVERTER_EXTPOINT_ID);
+ IExtension exts[] = extensionPoint.getExtensions();
+ fConverters = new CProjectConverterDesciptor[exts.length];
+
+ for(int i = 0; i < exts.length; i++){
+ fConverters[i] = new CProjectConverterDesciptor(exts[i]);
+ }
+ }
+
+
+ public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException{
+ ICProjectDescription des = loadIfExists ? getProjectDescription(project) : null;
+
+ if(des == null){
+ ICStorageElement element = createStorage(project, false, true, false);
+ des = new CProjectDescription(project, element, false);
+ }
+ return des;
+ }
+
+ private ICProjectDescription getLoaddedDescription(IProject project){
+ try {
+ ProjectInfoHolder holder = getInfoHolder(project);
+ if(holder != null)
+ return holder.fDescription;
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+
+ private ProjectInfoHolder getInfoHolder(final IProject project) throws CoreException{
+ return (ProjectInfoHolder)project.getSessionProperty(PROJECT_DESCRCIPTION_PROPERTY);
+ }
+
+ public synchronized ScannerInfoProviderProxy getScannerInfoProviderProxy(IProject project){
+ ProjectInfoHolder holder = null;
+ try {
+ holder = getInfoHolder(project);
+ } catch (CoreException e) {
+ holder = new ProjectInfoHolder();
+ }
+ boolean needSet = false;
+ if(holder == null){
+ holder = new ProjectInfoHolder();
+ needSet = true;
+ }
+
+ ScannerInfoProviderProxy provider = holder.fSIProvider;
+ if(provider == null){
+ provider = new ScannerInfoProviderProxy(project);
+ holder.fSIProvider = provider;
+ }
+
+ if(needSet)
+ setInfoHolder(project, holder);
+
+ return provider;
+ }
+
+ private void setInfoHolder(final IProject project, final ProjectInfoHolder holder){
+ try {
+ project.setSessionProperty(PROJECT_DESCRCIPTION_PROPERTY, holder);
+ } catch (CoreException e){
+ //TODO: externalize
+ final ProjectInfoHolder f = holder;
+ Job setDesJob = new Job("Set loadded description job"){ //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor){
+ try {
+ project.setSessionProperty(PROJECT_DESCRCIPTION_PROPERTY, f);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ setDesJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ setDesJob.setPriority(Job.INTERACTIVE);
+ setDesJob.setSystem(true);
+ setDesJob.schedule();
+ }
+ }
+
+ synchronized boolean setLoaddedDescription(final IProject project, ICProjectDescription des, boolean overwriteIfExists){
+ try {
+ ProjectInfoHolder holder = getInfoHolder(project);
+ boolean needSet = false;
+ if(holder == null){
+ holder = new ProjectInfoHolder();
+ needSet = true;
+ }
+
+ boolean shouldOverwrite = overwriteIfExists || holder.fDescription == null;
+ if(shouldOverwrite){
+ holder.fDescription = des;
+ if(needSet){
+ setInfoHolder(project, holder);
+ }
+ }
+ return shouldOverwrite;
+ } catch (CoreException e) {
+ }
+ return false;
+ }
+
+ private ICProjectDescription loadProjectDescription(IProject project) throws CoreException{
+ ICStorageElement storage = CProjectDescriptionManager.getInstance().createStorage(project, true, false, true);
+ CProjectDescription des = new CProjectDescription(project, storage, true);
+ if(des != null){
+ try {
+ setDescriptionLoadding(project, des);
+ des.loadDatas();
+ }finally{
+ clearDescriptionLoadding(project);
+ }
+ }
+ return des;
+ }
+
+ public ICProjectDescription getProjectDescription(IProject project){
+ return getProjectDescription(project, true);
+ }
+
+ private void storeActiveCfgId(ICProjectDescription des, String id){
+ try {
+ des.getProject().setPersistentProperty(ACTIVE_CFG_PROPERTY, id);
+ } catch (CoreException e) {
+ // Hitting this error just means the default config is not set
+ }
+ }
+
+ void checkActiveCfgChange(CProjectDescription newDes, CProjectDescription oldDes, IProgressMonitor monitor){
+ if(newDes == null)
+ return;
+ ICConfigurationDescription newCfg = newDes.getActiveConfiguration();
+ if(newCfg == null)
+ return;
+
+
+ ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null;
+
+ String newId = newCfg.getId();
+ String oldId = oldCfg != null ? oldCfg.getId() : null;
+
+ if(newDes.needsActiveCfgIdPersistence() || !newId.equals(oldId)){
+ storeActiveCfgId(newDes, newId);
+ }
+
+ String newBsId = newCfg.getBuildSystemId();
+ String oldBsId = oldCfg != null ? oldCfg.getBuildSystemId() : null;
+
+ try {
+ checkBuildSystemChange(newDes.getProject(), newBsId, oldBsId, monitor);
+ } catch (CoreException e) {
+ }
+ }
+
+ String loadActiveCfgId(ICProjectDescription des){
+ try {
+ return des.getProject().getPersistentProperty(ACTIVE_CFG_PROPERTY);
+ } catch (CoreException e) {
+ // Hitting this error just means the default config is not set
+ }
+ return null;
+ }
+
+
+ private void checkBuildSystemChange(IProject project, String newBsId, String oldBsId, IProgressMonitor monitor) throws CoreException{
+ checkBuildSystemChange(project, null, newBsId, oldBsId, monitor);
+ }
+
+ private void checkBuildSystemChange(IProject project, IProjectDescription des, String newBsId, String oldBsId, IProgressMonitor monitor) throws CoreException{
+ CConfigurationDataProviderDescriptor newDr = newBsId != null ? getCfgProviderDescriptor(newBsId) : null;
+ CConfigurationDataProviderDescriptor oldDr = oldBsId != null ? getCfgProviderDescriptor(oldBsId) : null;
+
+ String newNatures[] = newDr != null ? newDr.getNatureIds() : null;
+ String oldNatures[] = oldDr != null ? oldDr.getNatureIds() : null;
+ List[] natureDiff = ListComparator.compare(newNatures, oldNatures);
+
+// String newBuilderIds[] = newDr.getBuilderIds();
+// String oldBuilderIds[] = oldDr.getBuilderIds();
+// List[] builderDiff = ListComparator.compare(newBuilderIds, oldBuilderIds);
+
+ if(natureDiff != null /*|| builderDiff != null*/){
+ boolean applyDes = false;
+ if(des == null){
+ des = project.getDescription();
+ applyDes = true;
+ }
+
+ String natureIds[] = des.getNatureIds();
+ if(natureDiff[1] != null){
+ List remaining = ListComparator.getAdded(natureIds, natureDiff[1].toArray());
+ if(remaining != null){
+ natureIds = (String[])remaining.toArray(new String[remaining.size()]);
+ }
+ }
+
+ if(natureDiff[0] != null){
+ Set set = new HashSet();
+ set.addAll(Arrays.asList(natureIds));
+ set.addAll(natureDiff[0]);
+ natureIds = (String[])set.toArray(new String[set.size()]);
+ }
+// if(builderDiff != null){
+//
+// }
+
+ if(natureDiff != null)
+ des.setNatureIds(natureIds);
+
+ if(applyDes)
+ project.setDescription(des, monitor);
+ }
+ }
+
+
+ public void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException {
+ if(!des.isModified())
+ return;
+
+ if(((CProjectDescription)des).isLoadding())
+ throw ExceptionFactory.createCoreException("description is being loadded");
+
+ CModelManager manager = CModelManager.getDefault();
+ ICProject cproject = manager.create(project);
+
+ SetCProjectDescriptionOperation op = new SetCProjectDescriptionOperation(cproject, (CProjectDescription)des);
+ op.runOperation(new NullProgressMonitor());
+
+
+// CProjectDescription newDes = new CProjectDescription((CProjectDescription)des, true);
+
+/*TODO: calculate delta, etc.
+ ICProjectDescription previousDes = getProjecDescription(project, false);
+
+ if(des != previousDes){
+ ICConfigurationDescription cfgDess[] = des.getConfigurations();
+ }
+*/
+// ICProjectDescription oldDes = getProjectDescription(project, false);
+// setLoaddedDescription(newDes.getProject(), newDes);
+
+// ICProjectDescriptionDelta delta = createDelta(newDes, oldDes);
+ //TODO: notify listeners
+
+// ICStorageElement element = newDes.getRootStorageElement();
+
+// serialize(newDes.getProject(), STORAGE_FILE_NAME, element);
+
+// serialize(newDes);
+ }
+
+ private ISafeRunnable createDesSerializationRunnable(CProjectDescription des) throws CoreException{
+ final ICStorageElement element = des.getRootStorageElement();
+
+ ISafeRunnable r = new DesSerializationRunnable(des, element);
+ return r;
+ }
+ void serialize(final CProjectDescription des) throws CoreException{
+ ISafeRunnable r = createDesSerializationRunnable(des);
+ runWspModification(r, new NullProgressMonitor());
+
+// IWorkspace wsp = ResourcesPlugin.getWorkspace();
+//
+// if(wsp.isTreeLocked()){
+// Job job = new Job("info serialization"){
+// protected IStatus run(IProgressMonitor monitor) {
+// try {
+// serialize(des.getProject(), STORAGE_FILE_NAME, element);
+// ((ContributedEnvironment)CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(des);
+// } catch (CoreException e) {
+// return e.getStatus();
+// }
+// return Status.OK_STATUS;
+// }
+// };
+//
+// job.setRule(wsp.getRoot());
+// job.setSystem(true);
+// job.schedule();
+// } else {
+// serialize(des.getProject(), STORAGE_FILE_NAME, element);
+// ((ContributedEnvironment)CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(des);
+// }
+
+// serialize(des.getProject(), STORAGE_FILE_NAME, element);
+ }
+
+ private void serializePreference(String key, ICStorageElement element) throws CoreException{
+ Document doc = getDocument(element);
+
+ // Transform the document to something we can save in a file
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ FileOutputStream fileStream = null;
+ try {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+ DOMSource source = new DOMSource(doc);
+ StreamResult result = new StreamResult(stream);
+ transformer.transform(source, result);
+
+ // Save the document
+ File file = getPreferenceFile(key);
+ String utfString = stream.toString("UTF-8"); //$NON-NLS-1$
+
+ if (file.exists()) {
+// if (projectFile.isReadOnly()) {
+//
+// // Inform Eclipse that we are intending to modify this file
+// // This will provide the user the opportunity, via UI prompts, to fetch the file from source code control
+// // reset a read-only file protection to write etc.
+// // If there is no shell, i.e. shell is null, then there will be no user UI interaction
+//
+// //TODO
+// //IStatus status = projectFile.getWorkspace().validateEdit(new IFile[]{projectFile}, shell);
+//
+// // If the file is still read-only, then we should not attempt the write, since it will
+// // just fail - just throw an exception, to be caught below, and inform the user
+// // For other non-successful status, we take our chances, attempt the write, and pass
+// // along any exception thrown
+//
+// //if (!status.isOK()) {
+// // if (status.getCode() == IResourceStatus.READ_ONLY_LOCAL) {
+// // stream.close();
+// // throw new CoreException(status);
+// //}
+// //}
+// }
+// projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
+ } else {
+ file.createNewFile();
+ }
+ fileStream = new FileOutputStream(file);
+ fileStream.write(utfString.getBytes());
+ fileStream.close();
+ // Close the streams
+ stream.close();
+ } catch (TransformerConfigurationException e){
+ throw ExceptionFactory.createCoreException(e);
+ } catch (TransformerException e) {
+ throw ExceptionFactory.createCoreException(e);
+ } catch (IOException e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+ }
+
+
+ private void serialize(IProject project, String file, ICStorageElement element) throws CoreException{
+ Document doc = getDocument(element);
+
+ // Transform the document to something we can save in a file
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ try {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+ DOMSource source = new DOMSource(doc);
+ StreamResult result = new StreamResult(stream);
+ transformer.transform(source, result);
+
+ // Save the document
+ IFile projectFile = project.getFile(file);
+ String utfString = stream.toString("UTF-8"); //$NON-NLS-1$
+
+ if (projectFile.exists()) {
+ if (projectFile.isReadOnly()) {
+
+ // Inform Eclipse that we are intending to modify this file
+ // This will provide the user the opportunity, via UI prompts, to fetch the file from source code control
+ // reset a read-only file protection to write etc.
+ // If there is no shell, i.e. shell is null, then there will be no user UI interaction
+
+ //TODO
+ //IStatus status = projectFile.getWorkspace().validateEdit(new IFile[]{projectFile}, shell);
+
+ // If the file is still read-only, then we should not attempt the write, since it will
+ // just fail - just throw an exception, to be caught below, and inform the user
+ // For other non-successful status, we take our chances, attempt the write, and pass
+ // along any exception thrown
+
+ //if (!status.isOK()) {
+ // if (status.getCode() == IResourceStatus.READ_ONLY_LOCAL) {
+ // stream.close();
+ // throw new CoreException(status);
+ //}
+ //}
+ }
+ projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
+ } else {
+ projectFile.create(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
+ }
+ // Close the streams
+ stream.close();
+ } catch (TransformerConfigurationException e){
+ throw ExceptionFactory.createCoreException(e);
+ } catch (TransformerException e) {
+ throw ExceptionFactory.createCoreException(e);
+ } catch (IOException e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+ }
+
+ private Document getDocument(ICStorageElement element){
+ return ((InternalXmlStorageElement)element).fElement.getOwnerDocument();
+ }
+
+ Map createCfgStorages(ICProjectDescription des) throws CoreException{
+ Map map = new HashMap();
+ ICStorageElement rootElement = des.getStorage(MODULE_ID, false);
+ if(rootElement != null){
+ ICStorageElement children[] = rootElement.getChildren();
+
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement el = children[i];
+ if(CONFIGURATION.equals(el.getName())){
+ String id = el.getAttribute(CConfigurationSpecSettings.ID);
+ if(id != null)
+ map.put(id, el);
+ }
+ }
+ }
+ return map;
+ }
+
+ ICLanguageSetting findLanguagSettingForFile(String fileName, IProject project, ICLanguageSetting settings[]){
+ // if(cType != null){
+ // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, true);
+ // if(setting == null)
+ // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, false);
+ // }
+ ICLanguageSetting setting = null;
+ int index = fileName.lastIndexOf('.');
+ if(index > 0){
+ String ext = fileName.substring(index + 1).trim();
+ if(ext.length() > 0){
+ setting = findLanguageSettingForExtension(ext, settings);
+ }
+ }
+ return setting;
+ }
+
+ public CLanguageData findLanguagDataForFile(String fileName, IProject project, CLanguageData datas[]){
+ // if(cType != null){
+ // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, true);
+ // if(setting == null)
+ // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, false);
+ // }
+ CLanguageData data = null;
+ int index = fileName.lastIndexOf('.');
+ if(index > 0){
+ String ext = fileName.substring(index + 1).trim();
+ if(ext.length() > 0){
+ data = findLanguageDataForExtension(ext, datas);
+ }
+ }
+ return data;
+ }
+
+ public CLanguageData findLanguageDataForExtension(String ext, CLanguageData datas[]/*, boolean src*/){
+ CLanguageData data;
+ for(int i = 0; i < datas.length; i++){
+ data = datas[i];
+ String exts[] = data.getSourceExtensions();
+/* if(src){
+ if(setting.getSourceContentType() == null){
+ exts = setting.getSourceExtensions();
+ }
+ } else {
+ if(setting.getHeaderContentType() == null){
+ exts = setting.getHeaderExtensions();
+ }
+ }
+*/
+ if(exts != null && exts.length != 0){
+ for(int j = 0; j < exts.length; j++){
+ if(ext.equals(exts[j]))
+ return data;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ public ICLanguageSetting findLanguageSettingForContentTypeId(String id, ICLanguageSetting settings[]/*, boolean src*/){
+ for(int i = 0; i < settings.length; i++){
+ String ids[] = settings[i].getSourceContentTypeIds();
+ if(ListComparator.indexOf(id, ids) != -1)
+ return settings[i];
+ }
+ return null;
+ }
+
+ public ICLanguageSetting[] findCompatibleSettingsForContentTypeId(String id, ICLanguageSetting[] settings/*, boolean src*/){
+ IContentTypeManager manager = Platform.getContentTypeManager();
+ IContentType cType = manager.getContentType(id);
+ if(cType != null){
+ String [] exts = cType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ if(exts != null && exts.length != 0){
+ List list = new ArrayList();
+ ICLanguageSetting setting;
+ for(int i = 0; i < exts.length; i++){
+ setting = findLanguageSettingForExtension(exts[i], settings/*, src*/);
+ if(setting != null)
+ list.add(setting);
+ }
+ return (ICLanguageSetting[])list.toArray(new ICLanguageSetting[list.size()]);
+ }
+ }
+ return EMPTY_LANGUAGE_SETTINGS_ARRAY;
+ }
+
+ public ICLanguageSetting findLanguageSettingForExtension(String ext, ICLanguageSetting settings[]/*, boolean src*/){
+ ICLanguageSetting setting;
+ for(int i = 0; i < settings.length; i++){
+ setting = settings[i];
+ String exts[] = setting.getSourceExtensions();
+/* if(src){
+ if(setting.getSourceContentType() == null){
+ exts = setting.getSourceExtensions();
+ }
+ } else {
+ if(setting.getHeaderContentType() == null){
+ exts = setting.getHeaderExtensions();
+ }
+ }
+*/
+ if(exts != null && exts.length != 0){
+ for(int j = 0; j < exts.length; j++){
+ if(ext.equals(exts[j]))
+ return setting;
+ }
+ }
+ }
+ return null;
+ }
+
+ ICStorageElement createStorage(ICSettingsStorage storage, String cfgId) throws CoreException{
+ ICStorageElement rootElement = storage.getStorage(MODULE_ID, true);
+ ICStorageElement children[] = rootElement.getChildren();
+ ICStorageElement element = null;
+
+ for(int i = 0; i < children.length; i++){
+ if(CONFIGURATION.equals(children[i].getName())
+ && cfgId.equals(children[i].getAttribute(CConfigurationSpecSettings.ID))){
+ element = children[i];
+ break;
+ }
+ }
+
+ if(element == null){
+ element = rootElement.createChild(CONFIGURATION);
+ element.setAttribute(CConfigurationSpecSettings.ID, cfgId);
+ }
+
+ return element;
+ }
+
+ CConfigurationData loadData(ICConfigurationDescription des) throws CoreException{
+ CConfigurationDataProvider provider = getProvider(des);
+ return provider.loadConfiguration(des);
+ }
+
+ CConfigurationData applyData(ICConfigurationDescription des, CConfigurationData base) throws CoreException {
+ CConfigurationDataProvider provider = getProvider(des);
+ return provider.applyConfiguration(des, base);
+ }
+
+ void removeData(ICConfigurationDescription des, CConfigurationData data) throws CoreException{
+ CConfigurationDataProvider provider = getProvider(des);
+ provider.removeConfiguration(des, data);
+ }
+
+ CConfigurationData createData(ICConfigurationDescription des, CConfigurationData base, boolean clone) throws CoreException{
+ CConfigurationDataProvider provider = getProvider(des);
+ return provider.createConfiguration(des, base, clone);
+ }
+
+ private CConfigurationDataProvider getProvider(ICConfigurationDescription des) throws CoreException{
+ CConfigurationDataProviderDescriptor providerDes = getCfgProviderDescriptor(des);
+ if(providerDes == null)
+ throw ExceptionFactory.createCoreException("required build system is not installed");
+
+ return providerDes.getProvider();
+ }
+
+ private CConfigurationDataProviderDescriptor getCfgProviderDescriptor(ICConfigurationDescription des){
+ return getCfgProviderDescriptor(des.getBuildSystemId());
+ }
+
+ private CConfigurationDataProviderDescriptor getCfgProviderDescriptor(String id){
+ initProviderInfo();
+
+ return (CConfigurationDataProviderDescriptor)fProviderMap.get(id);
+ }
+
+ private synchronized void initProviderInfo(){
+ if(fProviderMap != null)
+ return;
+
+ initProviderInfoSynch();
+ }
+
+ private synchronized void initProviderInfoSynch(){
+ if(fProviderMap != null)
+ return;
+
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CConfigurationDataProviderDescriptor.DATA_PROVIDER_EXTPOINT_ID);
+ IExtension exts[] = extensionPoint.getExtensions();
+ fProviderMap = new HashMap(exts.length);
+
+ for(int i = 0; i < exts.length; i++){
+ CConfigurationDataProviderDescriptor des = new CConfigurationDataProviderDescriptor(exts[i]);
+ fProviderMap.put(des.getId(), des);
+ }
+ }
+
+
+
+/* CConfigurationSpecSettings createConfigurationSpecSettings(ICConfigurationDescription cfg) throws CoreException{
+ CConfigurationSpecSettings settings = null;
+ if(cfg instanceof CConfigurationDescriptionCache){
+ settings = new CConfigurationSpecSettings(cfg, createStorage(cfg.getProjectDescription(), cfg.getId()));
+ } else {
+ ICProjectDescription des = getProjecDescription(cfg.getProjectDescription().getProject(), false);
+ CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)des.getConfigurationById(cfg.getId());
+ if(cache != null){
+ settings = new CConfigurationSpecSettings(cfg, cache.getSpecSettings());
+ } else {
+ settings = new CConfigurationSpecSettings(cfg, createStorage(cfg.getProjectDescription(), cfg.getId()));
+ }
+ }
+ return settings;
+ }
+*/
+
+ private ICStorageElement readOldCDTProjectFile(IProject project) throws CoreException {
+ ICStorageElement storage = null;
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = null;
+ InputStream stream = getSharedProperty(project, OLD_CDTPROJECT_FILE_NAME);
+ if(stream != null){
+ doc = builder.parse(stream);
+ NodeList nodeList = doc.getElementsByTagName(OLD_PROJECT_DESCRIPTION);
+
+ if (nodeList != null && nodeList.getLength() > 0) {
+ Node node = nodeList.item(0);
+ storage = new InternalXmlStorageElement((Element)node, false);
+ }
+ }
+ } catch(ParserConfigurationException e){
+ throw ExceptionFactory.createCoreException(e);
+ } catch (SAXException e) {
+ throw ExceptionFactory.createCoreException(e);
+ } catch (IOException e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+ return storage;
+ }
+
+ public ICStorageElement createPreferenceStorage(String key, boolean createEmptyIfNotFound, boolean readOnly) throws CoreException{
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = null;
+ Element element = null;
+ InputStream stream = null;
+
+ try{
+ stream = getPreferenceProperty(key);
+ if(stream != null){
+ doc = builder.parse(stream);
+
+ // Get the first element in the project file
+ Node rootElement = doc.getFirstChild();
+
+ if (rootElement.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) {
+ throw ExceptionFactory.createCoreException("invalid project file format: no PROCESSING_INSTRUCTION_NODE defined");
+ } else {
+ // Make sure that the version is compatible with the manager
+ String fileVersion = rootElement.getNodeValue();
+ Version version = new Version(fileVersion);
+ if (DESCRIPTION_VERSION.compareTo(version) != 0) {
+ throw ExceptionFactory.createCoreException("incompatible preference file format: versions do not match");
+ }
+ }
+
+ // Now get the project root element (there should be only one)
+ NodeList nodes = doc.getElementsByTagName(ROOT_PREFERENCE_ELEMENT);
+ if (nodes.getLength() == 0)
+ throw ExceptionFactory.createCoreException("invalid preference file format");
+ Node node = nodes.item(0);
+ if(node.getNodeType() != Node.ELEMENT_NODE)
+ throw ExceptionFactory.createCoreException("invalid preference file format");
+ element = (Element)node;
+ } else if(!createEmptyIfNotFound){
+ throw ExceptionFactory.createCoreException("storage file not found");
+ }
+ } catch (FactoryConfigurationError e) {
+ if(!createEmptyIfNotFound)
+ throw ExceptionFactory.createCoreException(e.getLocalizedMessage());
+ } catch (SAXException e) {
+ if(!createEmptyIfNotFound)
+ throw ExceptionFactory.createCoreException(e);
+ } catch (IOException e) {
+ if(!createEmptyIfNotFound)
+ throw ExceptionFactory.createCoreException(e);
+ } finally {
+ if(stream != null){
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ if(element == null) {
+ doc = builder.newDocument();
+ ProcessingInstruction instruction = doc.createProcessingInstruction(VERSION_ELEMENT_NAME, DESCRIPTION_VERSION.toString());
+ doc.appendChild(instruction);
+ element = doc.createElement(ROOT_PREFERENCE_ELEMENT);
+ doc.appendChild(element);
+ }
+ return new InternalXmlStorageElement(element, null, false, readOnly);
+ } catch (ParserConfigurationException e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+ }
+
+ private InputStream getPreferenceProperty(String key) {
+ InputStream stream = null;
+ File file = getPreferenceFile(key);
+ if (file.exists()) {
+ try {
+ stream = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ return stream;
+ }
+
+ private File getPreferenceFile(String key){
+ IPath path = CCorePlugin.getDefault().getStateLocation();
+ path = path.append(key);
+ return path.toFile();
+ }
+
+
+ ICStorageElement createStorage(IProject project, boolean reCreate, boolean createEmptyIfNotFound, boolean readOnly) throws CoreException{
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = null;
+ Element element = null;
+ InputStream stream = null;
+ if(reCreate){
+ try{
+ stream = getSharedProperty(project, STORAGE_FILE_NAME);
+ if(stream != null){
+ doc = builder.parse(stream);
+
+ // Get the first element in the project file
+ Node rootElement = doc.getFirstChild();
+
+ if (rootElement.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) {
+ throw ExceptionFactory.createCoreException("invalid project file format: no PROCESSING_INSTRUCTION_NODE defined");
+ } else {
+ // Make sure that the version is compatible with the manager
+ String fileVersion = rootElement.getNodeValue();
+ Version version = new Version(fileVersion);
+ if (DESCRIPTION_VERSION.compareTo(version) != 0) {
+ throw ExceptionFactory.createCoreException("incompatible project file format: versions do not match");
+ }
+ }
+
+ // Now get the project root element (there should be only one)
+ NodeList nodes = doc.getElementsByTagName(ROOT_ELEMENT_NAME);
+ if (nodes.getLength() == 0)
+ throw ExceptionFactory.createCoreException("invalid project file format");
+ Node node = nodes.item(0);
+ if(node.getNodeType() != Node.ELEMENT_NODE)
+ throw ExceptionFactory.createCoreException("invalid project file format");
+ element = (Element)node;
+ } else if(!createEmptyIfNotFound){
+ throw ExceptionFactory.createCoreException("storage file not found");
+ }
+ } catch (FactoryConfigurationError e) {
+ if(!createEmptyIfNotFound)
+ throw ExceptionFactory.createCoreException(e.getLocalizedMessage());
+ } catch (SAXException e) {
+ if(!createEmptyIfNotFound)
+ throw ExceptionFactory.createCoreException(e);
+ } catch (IOException e) {
+ if(!createEmptyIfNotFound)
+ throw ExceptionFactory.createCoreException(e);
+ } finally {
+ if(stream != null){
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ if(element == null) {
+ doc = builder.newDocument();
+ ProcessingInstruction instruction = doc.createProcessingInstruction(VERSION_ELEMENT_NAME, DESCRIPTION_VERSION.toString());
+ doc.appendChild(instruction);
+ element = doc.createElement(ROOT_ELEMENT_NAME);
+ doc.appendChild(element);
+ }
+
+ return new InternalXmlStorageElement(element, null, false, readOnly);
+ } catch (ParserConfigurationException e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+ }
+
+
+ public static File toLocalFile(URI uri, IProgressMonitor monitor) throws CoreException {
+ IFileStore fileStore = EFS.getStore(uri);
+ File localFile = fileStore.toLocalFile(EFS.NONE, monitor);
+ if (localFile ==null)
+ // non local file system
+ localFile= fileStore.toLocalFile(EFS.CACHE, monitor);
+ return localFile;
+ }
+
+ public InputStream getSharedProperty(IProject project, String key) throws CoreException {
+
+ InputStream stream = null;
+ IFile rscFile = project.getFile(key);
+ if (rscFile.exists()) {
+ stream = rscFile.getContents();
+ } else {
+ // when a project is imported, we get a first delta for the addition of the .project, but the .classpath is not accessible
+ // so default to using java.io.File
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96258
+ URI location = rscFile.getLocationURI();
+ if (location != null) {
+ File file = toLocalFile(location, null/*no progress monitor available*/);
+ if (file != null && file.exists()) {
+ try {
+ stream = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+ }
+ }
+ }
+ return stream;
+ }
+
+/* public IScannerInfoProvider getScannerInfoProvider(IProject project){
+
+ return ScannerProvider.getInstance();
+ }
+*/
+ ICDescriptionDelta createDelta(ICProjectDescription newDescription, ICProjectDescription oldDescription){
+ CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newDescription, oldDescription);
+
+ if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
+ ICConfigurationDescription[] cfgs = newDescription.getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ ICConfigurationDescription oldCfg = oldDescription.getConfigurationById(cfgs[i].getId());
+ CProjectDescriptionDelta cfgDelta = createDelta(cfgs[i], oldCfg);
+ if(cfgDelta != null){
+ delta.addChild(cfgDelta);
+ }
+ }
+
+ cfgs = oldDescription.getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ ICConfigurationDescription newCfg = newDescription.getConfigurationById(cfgs[i].getId());
+ if(newCfg == null)
+ delta.addChild(createDelta(null, cfgs[i]));
+ }
+
+ if(checkCfgChange(newDescription, oldDescription, true))
+ delta.addChangeFlags(ICDescriptionDelta.ACTIVE_CFG);
+
+ if(checkCfgChange(newDescription, oldDescription, false))
+ delta.addChangeFlags(ICDescriptionDelta.INDEX_CFG);
+
+ }
+ return delta.isEmpty() ? null : delta;
+ }
+
+ private boolean checkCfgChange(ICProjectDescription newDes, ICProjectDescription oldDes, boolean active){
+ ICConfigurationDescription newCfg, oldCfg;
+
+ if(active){
+ newCfg = newDes.getActiveConfiguration();
+ oldCfg = oldDes.getActiveConfiguration();
+ } else {
+ newCfg = ((CProjectDescription)newDes).getIndexConfiguration();
+ oldCfg = ((CProjectDescription)oldDes).getIndexConfiguration();
+ }
+
+ if(newCfg == null){
+ return oldCfg != null;
+ } else if (oldCfg == null){
+ return true;
+ }
+ return !newCfg.getId().equals(oldCfg.getId());
+ }
+
+/* void postProcessNewDescriptionCache(CProjectDescription des, ICProjectDescriptionDelta delta){
+ if(delta == null && delta.getDeltaKind() != ICProjectDescriptionDelta.CHANGED)
+ return;
+
+ ICConfigurationDescription indexCfg = des.getIndexConfiguration();
+ ICConfigurationDescription activeCfg = des.getActiveConfiguration();
+ ICProjectDescriptionDelta activeCfgDelta = findDelta(activeCfg.getId(), delta);
+ if(indexCfg != activeCfg){
+ switch(activeCfgDelta.getDeltaKind()){
+ case ICProjectDescriptionDelta.CHANGED:
+ des.setIndexConfiguration(activeCfg);
+ }
+ }
+
+
+ }
+*/
+ private ICDescriptionDelta findDelta(String id, ICDescriptionDelta delta){
+ ICDescriptionDelta children[] = delta.getChildren();
+ ICSettingObject obj;
+ for(int i = 0; i < children.length; i++){
+ obj = children[i].getSetting();
+ if(obj.getId().equals(id))
+ return children[i];
+ }
+ return null;
+ }
+
+ public int calculateDescriptorFlags(ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg){
+ try {
+ int flags = 0;
+ CConfigurationSpecSettings newSettings = ((IInternalCCfgInfo)newCfg).getSpecSettings();
+ CConfigurationSpecSettings oldSettings = ((IInternalCCfgInfo)oldCfg).getSpecSettings();
+ String newId = newSettings.getCOwnerId();
+ String oldId = oldSettings.getCOwnerId();
+ if(!CDataUtil.objectsEqual(newId, oldId))
+ flags |= ICDescriptionDelta.OWNER;
+
+ Map newMap = newSettings.getExtensionMapCopy();
+ Map oldMap = oldSettings.getExtensionMapCopy();
+
+ for(Iterator iter = newMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ iter.remove();
+ CConfigExtensionReference[] oldRefs = (CConfigExtensionReference[])oldMap.remove(entry.getKey());
+ if(oldRefs == null){
+ flags |= ICDescriptionDelta.EXT_REF;
+ break;
+ }
+
+ CConfigExtensionReference[] newRefs = (CConfigExtensionReference[])entry.getValue();
+ if(newRefs.length != oldRefs.length){
+ flags |= ICDescriptionDelta.EXT_REF;
+ break;
+ }
+
+ Set newSet = new HashSet(Arrays.asList(newRefs));
+ Set oldSet = new HashSet(Arrays.asList(oldRefs));
+ if(newSet.size() != oldSet.size()){
+ flags |= ICDescriptionDelta.EXT_REF;
+ break;
+ }
+
+ newSet.removeAll(oldSet);
+ if(newSet.size() != 0){
+ flags |= ICDescriptionDelta.EXT_REF;
+ break;
+ }
+ }
+
+ return flags;
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ return 0;
+ }
+
+ public CProjectDescriptionDelta createDelta(ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg){
+ CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newCfg, oldCfg);
+
+ if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
+ ICFolderDescription[] foDess = newCfg.getFolderDescriptions();
+ for(int i = 0; i < foDess.length; i++){
+ ICResourceDescription oldDes = oldCfg.getResourceDescription(foDess[i].getPath(), true);
+ if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FOLDER){
+ CProjectDescriptionDelta foDelta = createDelta(foDess[i], (ICFolderDescription)oldDes);
+ if(foDelta != null)
+ delta.addChild(foDelta);
+ } else {
+ delta.addChild(createDelta(foDess[i], null));
+ }
+ }
+
+ foDess = oldCfg.getFolderDescriptions();
+ for(int i = 0; i < foDess.length; i++){
+ ICResourceDescription newDes = newCfg.getResourceDescription(foDess[i].getPath(), true);
+ if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FOLDER){
+ delta.addChild(createDelta(null, foDess[i]));
+ }
+ }
+
+ ICFileDescription[] fiDess = newCfg.getFileDescriptions();
+ for(int i = 0; i < fiDess.length; i++){
+ ICResourceDescription oldDes = oldCfg.getResourceDescription(fiDess[i].getPath(), true);
+ if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FILE){
+ CProjectDescriptionDelta fiDelta = createDelta(fiDess[i], (ICFileDescription)oldDes);
+ if(fiDelta != null)
+ delta.addChild(fiDelta);
+ } else {
+ delta.addChild(createDelta(fiDess[i], null));
+ }
+ }
+
+ fiDess = oldCfg.getFileDescriptions();
+ for(int i = 0; i < fiDess.length; i++){
+ ICResourceDescription newDes = newCfg.getResourceDescription(fiDess[i].getPath(), true);
+ if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FILE){
+ delta.addChild(createDelta(null, fiDess[i]));
+ }
+ }
+
+ CProjectDescriptionDelta tpsDelta = createDelta(newCfg.getTargetPlatformSetting(), oldCfg.getTargetPlatformSetting());
+ if(tpsDelta != null)
+ delta.addChild(tpsDelta);
+
+ if(!newCfg.getName().equals(oldCfg.getName())){
+ delta.addChangeFlags(ICDescriptionDelta.NAME);
+ }
+
+ ICSourceEntry newEntries[] = newCfg.getSourceEntries();
+ ICSourceEntry oldEntries[] = oldCfg.getSourceEntries();
+
+ if(newEntries.length > oldEntries.length){
+ delta.addChangeFlags(ICDescriptionDelta.SOURCE_ADDED);
+ } else {
+ ICSourceEntry newEntry;
+ for(int i = 0; i < newEntries.length; i++){
+ boolean found = false;
+ newEntry = newEntries[i];
+ for(int j = 0; j < oldEntries.length; j++){
+ if(newEntry.equals(oldEntries[j])){
+ found = true;
+ break;
+ }
+ }
+
+ if(!found){
+ delta.addChangeFlags(ICDescriptionDelta.SOURCE_ADDED);
+ break;
+ }
+ }
+ }
+
+ if(oldEntries.length > newEntries.length){
+ delta.addChangeFlags(ICDescriptionDelta.SOURCE_REMOVED);
+ } else {
+ ICSourceEntry oldEntry;
+ for(int i = 0; i < oldEntries.length; i++){
+ boolean found = false;
+ oldEntry = oldEntries[i];
+ for(int j = 0; j < newEntries.length; j++){
+ if(oldEntry.equals(newEntries[j])){
+ found = true;
+ break;
+ }
+ }
+
+ if(!found){
+ delta.addChangeFlags(ICDescriptionDelta.SOURCE_REMOVED);
+ break;
+ }
+ }
+ }
+
+ ExternalSettingsManager.getInstance().calculateCfgExtSettingsDelta(delta);
+
+ int drFlags = calculateDescriptorFlags(newCfg, oldCfg);
+ if(drFlags != 0)
+ delta.addChangeFlags(drFlags);
+ }
+
+ return delta.isEmpty() ? null : delta;
+ }
+
+ private CProjectDescriptionDelta createDelta(ICFolderDescription newFo, ICFolderDescription oldFo){
+ CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newFo, oldFo);
+
+ if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
+ ICLanguageSetting newLss[] = newFo.getLanguageSettings();
+ ICLanguageSetting oldLss[] = oldFo.getLanguageSettings();
+ List newList = new ArrayList(Arrays.asList(newLss));
+ List oldList = new ArrayList(Arrays.asList(oldLss));
+ List matched = sortSettings(newList, oldList);
+
+ for(Iterator iter = matched.iterator(); iter.hasNext();){
+ ICLanguageSetting[] match = (ICLanguageSetting[])iter.next();
+ CProjectDescriptionDelta lsDelta = createDelta(match[0], match[1]);
+ if(lsDelta != null)
+ delta.addChild(lsDelta);
+ }
+
+ for(Iterator iter = newList.iterator(); iter.hasNext();){
+ ICLanguageSetting added = (ICLanguageSetting)iter.next();
+ delta.addChild(createDelta(added, null));
+ }
+
+ for(Iterator iter = oldList.iterator(); iter.hasNext();){
+ ICLanguageSetting removed = (ICLanguageSetting)iter.next();
+ delta.addChild(createDelta(null, removed));
+ }
+
+// HashMap oldMap = new HashMap();
+// for(int i = 0; i < oldLss.length; i++){
+// oldMap.put(oldLss[i].getId(), oldLss[i]);
+// }
+
+// for(int i = 0; i < newLss.length; i++){
+// ICLanguageSetting oldLs = (ICLanguageSetting)oldMap.remove(newLss[i].getId());
+// CProjectDescriptionDelta lsDelta = createDelta(newLss[i], oldLs);
+// if(lsDelta != null)
+// delta.addChild(lsDelta);
+// }
+
+// if(!oldMap.isEmpty()){
+// for(Iterator iter = oldMap.values().iterator(); iter.hasNext();){
+// delta.addChild(createDelta(null, (ICLanguageSetting)iter.next()));
+// }
+// }
+
+// if(!newFo.getPath().equals(oldFo.getPath()))
+// delta.addChangeFlags(ICProjectDescriptionDelta.PATH);
+
+ if(newFo.isExcluded() != oldFo.isExcluded())
+ delta.addChangeFlags(ICDescriptionDelta.EXCLUDE);
+ }
+
+ return delta.isEmpty() ? null : delta;
+ }
+
+ private List sortSettings(List settings1,
+ List settings2){
+ ICLanguageSetting setting1;
+ ICLanguageSetting setting2;
+ List result = new ArrayList();
+ for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){
+ setting1 = (ICLanguageSetting)iter1.next();
+ for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){
+ setting2 = (ICLanguageSetting)iter2.next();
+
+ if(setting2.getId().equals(setting1.getId())){
+ iter1.remove();
+ iter2.remove();
+ ICLanguageSetting [] match = new ICLanguageSetting[2];
+ match[0] = setting1;
+ match[1] = setting2;
+ result.add(match);
+ break;
+ }
+ }
+ }
+
+ for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){
+ setting1 = (ICLanguageSetting)iter1.next();
+ String lId = setting1.getLanguageId();
+ if(lId != null){
+ for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){
+ setting2 = (ICLanguageSetting)iter2.next();
+
+ if(lId.equals(setting2.getLanguageId())){
+ iter1.remove();
+ iter2.remove();
+ ICLanguageSetting [] match = new ICLanguageSetting[2];
+ match[0] = setting1;
+ match[1] = setting2;
+ result.add(match);
+ break;
+ }
+ }
+ }
+ }
+
+ for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){
+ setting1 = (ICLanguageSetting)iter1.next();
+ String cTypeIds1[] = setting1.getSourceContentTypeIds();
+ if(cTypeIds1.length != 0){
+ for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){
+ setting2 = (ICLanguageSetting)iter2.next();
+ if(Arrays.equals(cTypeIds1, setting2.getSourceContentTypeIds())){
+ iter1.remove();
+ iter2.remove();
+ ICLanguageSetting [] match = new ICLanguageSetting[2];
+ match[0] = setting1;
+ match[1] = setting2;
+ result.add(match);
+ break;
+ }
+ }
+ }
+ }
+
+ for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){
+ setting1 = (ICLanguageSetting)iter1.next();
+ if(setting1.getSourceContentTypeIds().length == 0){
+ String srcExts[] = setting1.getSourceExtensions();
+ if(srcExts.length != 0){
+ for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){
+ setting2 = (ICLanguageSetting)iter2.next();
+ if(setting2.getSourceContentTypeIds().length == 0){
+ if(Arrays.equals(srcExts, setting2.getSourceExtensions())){
+ iter1.remove();
+ iter2.remove();
+ ICLanguageSetting [] match = new ICLanguageSetting[2];
+ match[0] = setting1;
+ match[1] = setting2;
+ result.add(match);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ private CProjectDescriptionDelta createDelta(ICFileDescription newFi, ICFileDescription oldFi){
+ CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newFi, oldFi);
+
+ if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
+ CProjectDescriptionDelta lsDelta = createDelta(newFi.getLanguageSetting(), oldFi.getLanguageSetting());
+ if(lsDelta != null)
+ delta.addChild(lsDelta);
+
+// if(!newFi.getPath().equals(oldFi.getPath()))
+// delta.addChangeFlags(ICProjectDescriptionDelta.PATH);
+
+ if(newFi.isExcluded() != oldFi.isExcluded())
+ delta.addChangeFlags(ICDescriptionDelta.EXCLUDE);
+ }
+
+ return delta.isEmpty() ? null : delta;
+ }
+
+ private CProjectDescriptionDelta createDelta(ICLanguageSetting newLs, ICLanguageSetting oldLs){
+ CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newLs, oldLs);
+
+ if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ int addedKinds = 0;
+ int removedKinds = 0;
+ int reorderedKinds = 0;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ ICLanguageSettingEntry newEntries[] = newLs.getSettingEntries(kind);
+ ICLanguageSettingEntry oldEntries[] = oldLs.getSettingEntries(kind);
+ boolean[] change = calculateSettingsChanges(newEntries, oldEntries);
+
+ if(change[0])
+ addedKinds |= kind;
+ if(change[1])
+ removedKinds |= kind;
+ if(change[2])
+ reorderedKinds |= kind;
+ }
+ delta.setAddedLanguageEntriesKinds(addedKinds);
+ delta.setRemovedLanguageEntriesKinds(removedKinds);
+ delta.setReorderedLanguageEntriesKinds(reorderedKinds);
+
+ String[] newCtIds = newLs.getSourceContentTypeIds();
+ String[] oldCtIds = oldLs.getSourceContentTypeIds();
+
+ if(!Arrays.equals(newCtIds, oldCtIds))
+ delta.addChangeFlags(ICDescriptionDelta.SOURCE_CONTENT_TYPE);
+
+
+ String[] newExts = newLs.getSourceExtensions();
+ String[] oldExts = oldLs.getSourceExtensions();
+ if(!Arrays.equals(newExts, oldExts))
+ delta.addChangeFlags(ICDescriptionDelta.SOURCE_ENTENSIONS);
+
+
+// newCt = newLs.getHeaderContentType();
+// oldCt = oldLs.getHeaderContentType();
+
+// if(!compare(newCt, oldCt))
+// delta.addChangeFlags(ICDescriptionDelta.HEADER_CONTENT_TYPE);
+
+// newExts = newLs.getHeaderExtensions();
+// oldExts = oldLs.getHeaderExtensions();
+// if(!Arrays.equals(newExts, oldExts))
+// delta.addChangeFlags(ICDescriptionDelta.HEADER_ENTENSIONS);
+ }
+
+ return delta.isEmpty() ? null : delta;
+ }
+
+ private boolean[] calculateSettingsChanges(ICLanguageSettingEntry newEntries[], ICLanguageSettingEntry oldEntries[]) {
+ boolean result[] = new boolean[3];
+
+ // if nothing was known before do not generate any deltas.
+ if (oldEntries == null) {
+ return result;
+ }
+ // Sanity checks
+ if (newEntries == null) {
+ newEntries = EMPTY_LANGUAGE_SETTINGS_ENTRIES_ARRAY;
+ }
+
+ // Check the removed entries.
+ for (int i = 0; i < oldEntries.length; i++) {
+ boolean found = false;
+ for (int j = 0; j < newEntries.length; j++) {
+ if (oldEntries[i].equals(newEntries[j])) {
+ found = true;
+ break;
+ }
+ }
+ if(!found){
+ result[1] = true;
+ break;
+ }
+ }
+
+ // Check the new entries.
+ for (int i = 0; i < newEntries.length; i++) {
+ boolean found = false;
+ for (int j = 0; j < oldEntries.length; j++) {
+ if (newEntries[i].equals(oldEntries[j])) {
+ found = true;
+ break;
+ }
+ }
+ if(!found){
+ result[0] = true;
+ break;
+ }
+ }
+
+ // Check for reorder
+ if (!result[0] && !result[1] && oldEntries.length == newEntries.length) {
+ for (int i = 0; i < newEntries.length; i++) {
+ if (!newEntries[i].equals(oldEntries[i])) {
+ result[2] = true;
+ break;
+ }
+ }
+ }
+ // They may have remove some duplications, catch here .. consider it as reordering.
+ if (!result[0] && !result[1] && oldEntries.length != newEntries.length) {
+ result[2] = true;
+ }
+
+ return result;
+ }
+
+
+ private boolean compare(Object o1, Object o2){
+ if(o1 != null)
+ return o1.equals(o2);
+ return o2 == null;
+ }
+
+/* public boolean entriesEqual(ICLanguageSettingEntry entries1[], ICLanguageSettingEntry entries2[]){
+ if(entries1.length != entries2.length)
+ return false;
+
+ for(int i = 0; i < entries1.length; i++){
+ if(!entries1[i].equals(entries2[i]))
+ return false;
+ }
+
+ return true;
+ }
+*/
+ private CProjectDescriptionDelta createDelta(ICTargetPlatformSetting newTPS, ICTargetPlatformSetting oldTPS){
+ CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newTPS, oldTPS);
+ if(!Arrays.equals(newTPS.getBinaryParserIds(), oldTPS.getBinaryParserIds()))
+ delta.addChangeFlags(ICDescriptionDelta.BINARY_PARSER_IDS);
+
+ return delta.isEmpty() ? null : delta;
+ }
+
+ ICElementDelta[] generateCElementDeltas(ICProject cProject, ICDescriptionDelta projDesDelta){
+ if(projDesDelta == null)
+ return EMPTY_CELEMENT_DELTA;
+
+ int kind = projDesDelta.getDeltaKind();
+ switch(kind){
+ case ICDescriptionDelta.CHANGED:
+ CProjectDescription newDes = (CProjectDescription)projDesDelta.getNewSetting();
+ CProjectDescription oldDes = (CProjectDescription)projDesDelta.getOldSetting();
+// int flags = projDesDelta.getChangeFlags();
+ ICConfigurationDescription activeCfg = newDes.getActiveConfiguration();
+ ICConfigurationDescription indexCfg = newDes.getIndexConfiguration();
+ if(indexCfg != activeCfg){
+ ICDescriptionDelta delta = findDelta(activeCfg.getId(), projDesDelta);
+ if(delta != null && delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
+ indexCfg = activeCfg;
+ newDes.setIndexConfiguration(activeCfg);
+ }
+ }
+ ICConfigurationDescription oldIndexCfg = oldDes.getIndexConfiguration();
+ ICDescriptionDelta indexDelta;
+ if(oldIndexCfg.getId().equals(indexCfg.getId())){
+ indexDelta = findDelta(indexCfg.getId(), projDesDelta);
+ } else {
+ indexDelta = createDelta(indexCfg, oldIndexCfg);
+ }
+ if(indexDelta != null){
+ List list = new ArrayList();
+ generateCElementDeltasFromCfgDelta(cProject, indexDelta, list);
+ return (ICElementDelta[])list.toArray(new ICElementDelta[list.size()]);
+ }
+ return EMPTY_CELEMENT_DELTA;
+ case ICDescriptionDelta.ADDED:
+ case ICDescriptionDelta.REMOVED:
+ break;
+ }
+ return EMPTY_CELEMENT_DELTA;
+ }
+
+ private List generateCElementDeltasFromCfgDelta(ICProject cProject, ICDescriptionDelta cfgDelta, List list){
+ int kind = cfgDelta.getDeltaKind();
+ switch(kind){
+ case ICDescriptionDelta.CHANGED:
+ int descriptionFlags = cfgDelta.getChangeFlags();
+ int celementFlags = 0;
+ if((descriptionFlags & ICDescriptionDelta.SOURCE_ADDED) != 0)
+ celementFlags |= ICElementDelta.F_ADDED_PATHENTRY_SOURCE;
+ if((descriptionFlags & ICDescriptionDelta.SOURCE_REMOVED) != 0)
+ celementFlags |= ICElementDelta.F_REMOVED_PATHENTRY_SOURCE;
+
+ if(celementFlags != 0){
+ CElementDelta cElDelta = new CElementDelta(cProject.getCModel());
+ cElDelta.changed(cProject, celementFlags);
+ list.add(cElDelta);
+ }
+
+ ICDescriptionDelta children[] = cfgDelta.getChildren();
+ ICDescriptionDelta child;
+ int type;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ type = child.getSettingType();
+ if(type == ICSettingBase.SETTING_FILE || type == ICSettingBase.SETTING_FOLDER){
+ generateCElementDeltasFromResourceDelta(cProject, child, list);
+ }
+ }
+ case ICDescriptionDelta.ADDED:
+ case ICDescriptionDelta.REMOVED:
+ break;
+ }
+ return list;
+ }
+
+ private List generateCElementDeltasFromResourceDelta(ICProject cProject, ICDescriptionDelta delta, List list){
+ int kind = delta.getDeltaKind();
+ ICDescriptionDelta parentDelta = delta.getParent();
+ ICElement el;
+// IProject project = cProject.getProject();
+ IResource rc = null;
+
+ ICResourceDescription oldRcDes;
+ ICResourceDescription newRcDes;
+ IPath path;
+ switch(kind){
+ case ICDescriptionDelta.REMOVED:
+ oldRcDes = (ICResourceDescription)delta.getOldSetting();
+ path = oldRcDes.getPath();
+ newRcDes = ((ICConfigurationDescription)parentDelta.getNewSetting()).getResourceDescription(path, false);
+ break;
+ case ICDescriptionDelta.CHANGED:
+// if((delta.getChangeFlags() & ICProjectDescriptionDelta.PATH) == 0){
+ newRcDes = (ICResourceDescription)delta.getNewSetting();
+ path = newRcDes.getPath();
+ oldRcDes = (ICResourceDescription)delta.getOldSetting();
+ break;
+// }
+ //if path changed treat as added
+ case ICDescriptionDelta.ADDED:
+ default:
+ newRcDes = (ICResourceDescription)delta.getNewSetting();
+ path = newRcDes.getPath();
+ oldRcDes = ((ICConfigurationDescription)parentDelta.getOldSetting()).getResourceDescription(path, false);
+ break;
+ }
+ path = path.makeRelative();
+ el = null;
+ try {
+ el = cProject.findElement(path);
+ rc = el.getResource();
+ } catch (CModelException e) {
+// int i = 0;
+ }
+// rc = ResourcesPlugin.getWorkspace().getRoot().findMember(project.getFullPath().append(path));
+ if(rc != null){
+ if(rc.getType() == IResource.FILE){
+ String fileName = path.lastSegment();
+ ICLanguageSetting newLS = getLanguageSetting(newRcDes, fileName);
+ ICLanguageSetting oldLS = getLanguageSetting(oldRcDes, fileName);
+ ICDescriptionDelta ld = createDelta(newLS, oldLS);
+ generateCElementDeltasFromLanguageDelta(el, ld, list);
+ } else {
+ if(newRcDes.getType() == ICSettingBase.SETTING_FOLDER){
+ ICFolderDescription oldFoDes = oldRcDes.getType() == ICSettingBase.SETTING_FOLDER ?
+ (ICFolderDescription)oldRcDes : null;
+ ICDescriptionDelta folderDelta = createDelta((ICFolderDescription)newRcDes, oldFoDes);
+ if(folderDelta != null){
+ ICDescriptionDelta children[] = folderDelta.getChildren();
+ ICDescriptionDelta child;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ if(child.getSettingType() == ICSettingBase.SETTING_LANGUAGE){
+ generateCElementDeltasFromLanguageDelta(el, child, list);
+ }
+ }
+ }
+ } else {
+ //ERROR?
+ }
+
+ }
+ }
+ return list;
+ }
+
+ private ICLanguageSetting getLanguageSetting(ICResourceDescription rcDes, String fileName){
+ if(rcDes.getType() == ICSettingBase.SETTING_FILE){
+ return ((ICFileDescription)rcDes).getLanguageSetting();
+ }
+ return ((ICFolderDescription)rcDes).getLanguageSettingForFile(fileName);
+ }
+
+ private List generateCElementDeltasFromLanguageDelta(ICElement el, ICDescriptionDelta delta, List list){
+ if(delta == null)
+ return list;
+
+ int flags = 0;
+ flags |= calculateEntriesFlags(delta.getAddedEntriesKinds(), true);
+ flags |= calculateEntriesFlags(delta.getRemovedEntriesKinds(), false);
+ flags |= calculateEntriesFlags(delta.getReorderedEntriesKinds(), true);
+ if(flags != 0){
+ CElementDelta cElDelta = new CElementDelta(el.getCModel());
+ cElDelta.changed(el, flags);
+ list.add(cElDelta);
+ }
+ return list;
+ }
+
+ private int calculateEntriesFlags(int languageDeltaKinds, boolean added){
+ int flags = 0;
+ int kindsArray[] = kindsToArray(languageDeltaKinds);
+
+ for(int i = 0; i < kindsArray.length; i++){
+ switch(kindsArray[i]){
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ flags |= ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
+ break;
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ flags |= ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
+ break;
+ case ICLanguageSettingEntry.MACRO:
+ flags |= ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
+ break;
+ case ICLanguageSettingEntry.MACRO_FILE:
+ flags |= ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
+ break;
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ flags |= added ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY
+ : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
+ break;
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ flags |= added ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY
+ : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
+ break;
+ }
+ }
+ return flags;
+ }
+
+ int[] kindsToArray(int kinds){
+ int allKinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kindsArray[] = new int[allKinds.length];
+ int num = 0;
+ for(int i = 0; i < allKinds.length; i++){
+ if((allKinds[i] & kinds) != 0){
+ kindsArray[num++] = allKinds[i];
+ }
+ }
+
+ if(num < allKinds.length){
+ int tmp[] = new int[num];
+ if(num > 0)
+ System.arraycopy(kindsArray, 0, tmp, 0, num);
+ kindsArray = tmp;
+ }
+ return kindsArray;
+ }
+
+ public void addListener(ICProjectDescriptionListener listener, int eventTypes){
+ synchronized(this){
+ fListeners.add(new ListenerDescriptor(listener, eventTypes));
+ }
+ }
+
+ public void removeListener(ICProjectDescriptionListener listener){
+ synchronized(this){
+ int size = fListeners.size();
+ ListenerDescriptor des;
+ for(int i = 0; i < size; i++){
+ des = (ListenerDescriptor)fListeners.get(i);
+ if(des.fListener == listener){
+ fListeners.remove(des);
+ break;
+ }
+ }
+ }
+ }
+
+ private ListenerDescriptor[] getListeners(){
+ synchronized(this){
+ return (ListenerDescriptor[])fListeners.toArray(new ListenerDescriptor[fListeners.size()]);
+ }
+ }
+
+ void notifyListeners(CProjectDescriptionEvent event){
+ ListenerDescriptor[] listeners = getListeners();
+ int eventType = event.getEventType();
+ for(int i = 0; i < listeners.length; i++){
+ if(listeners[i].handlesEvent(eventType)){
+ listeners[i].fListener.handleEvent(event);
+ }
+ }
+ }
+
+ public Element createXmlElementCopy(InternalXmlStorageElement el) throws CoreException{
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.newDocument();
+ Element newXmlEl = null;
+ if(el.fElement.getParentNode().getNodeType() == Node.DOCUMENT_NODE){
+ Document baseDoc = el.fElement.getOwnerDocument();
+ NodeList list = baseDoc.getChildNodes();
+ for(int i = 0; i < list.getLength(); i++){
+ Node node = list.item(i);
+ node = importAddNode(doc, node);
+ if(node.getNodeType() == Node.ELEMENT_NODE && newXmlEl == null){
+ newXmlEl = (Element)node;
+ }
+ }
+
+ } else {
+ newXmlEl = (Element)importAddNode(doc, el.fElement);
+ }
+// Document baseDoc = el.fElement.getOwnerDocument();
+// Element baseEl = baseDoc.getDocumentElement();
+// Element newXmlEl = (Element)doc.importNode(baseEl, true);
+
+
+// doc.appendChild(newXmlEl);
+ return newXmlEl;
+ } catch (ParserConfigurationException e) {
+ throw ExceptionFactory.createCoreException(e);
+ } catch (FactoryConfigurationError e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+
+ }
+
+ InternalXmlStorageElement copyElement(InternalXmlStorageElement el, boolean readOnly) throws CoreException {
+// try {
+// DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+// Document doc = builder.newDocument();
+// Element newXmlEl = null;
+// if(el.fElement.getParentNode().getNodeType() == Node.DOCUMENT_NODE){
+// Document baseDoc = el.fElement.getOwnerDocument();
+// NodeList list = baseDoc.getChildNodes();
+// for(int i = 0; i < list.getLength(); i++){
+// Node node = list.item(i);
+// node = importAddNode(doc, node);
+// if(node.getNodeType() == Node.ELEMENT_NODE && newXmlEl == null){
+// newXmlEl = (Element)node;
+// }
+// }
+//
+// }
+//
+//
+//// = (Element)doc.importNode(el.fElement, true);
+//
+//// Document baseDoc = el.fElement.getOwnerDocument();
+//// Element baseEl = baseDoc.getDocumentElement();
+//// Element newXmlEl = (Element)doc.importNode(baseEl, true);
+//
+//
+//// doc.appendChild(newXmlEl);
+// return new InternalXmlStorageElement(newXmlEl, el.getParent(),
+// el.isParentRefAlowed(), el.getAttributeFilters(),
+// el.getChildFilters(), readOnly);
+// } catch (ParserConfigurationException e) {
+// throw ExceptionFactory.createCoreException(e);
+// } catch (FactoryConfigurationError e) {
+// throw ExceptionFactory.createCoreException(e);
+// }
+ Element newXmlEl = createXmlElementCopy(el);
+ return new InternalXmlStorageElement(newXmlEl, el.getParent(),
+ el.isParentRefAlowed(), el.getAttributeFilters(),
+ el.getChildFilters(), readOnly);
+ }
+
+ private Node importAddNode(Document doc, Node node){
+ if(node.getOwnerDocument().equals(doc)){
+ node = node.cloneNode(true);
+ } else {
+ node = doc.importNode(node, true);
+ }
+
+ return doc.appendChild(node);
+ }
+
+ CStorage copyStorage(CStorage el, boolean readOnly) throws CoreException {
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.newDocument();
+ Element newXmlEl = (Element)doc.importNode(el.fElement, true);
+
+// Document baseDoc = el.fElement.getOwnerDocument();
+// Element baseEl = baseDoc.getDocumentElement();
+// Element newXmlEl = (Element)doc.importNode(baseEl, true);
+
+
+ doc.appendChild(newXmlEl);
+ return new CStorage(newXmlEl, readOnly);
+ } catch (ParserConfigurationException e) {
+ throw ExceptionFactory.createCoreException(e);
+ } catch (FactoryConfigurationError e) {
+ throw ExceptionFactory.createCoreException(e);
+ }
+
+ }
+ void checkRemovedConfigurations(ICDescriptionDelta delta){
+ if(delta == null)
+ return;
+
+ ICDescriptionDelta cfgDeltas[] = delta.getChildren();
+ for(int i = 0; i < cfgDeltas.length; i++){
+ if(cfgDeltas[i].getDeltaKind() == ICDescriptionDelta.REMOVED){
+ CConfigurationDescriptionCache des = (CConfigurationDescriptionCache)cfgDeltas[i].getOldSetting();
+ CConfigurationData data = des.getConfigurationData();
+ try {
+ removeData(des, data);
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ }
+
+ public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId) throws CoreException {
+ return getPreferenceConfiguration(buildSystemId, true);
+ }
+
+ public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) throws CoreException {
+ ICConfigurationDescription des = getLoaddedPreference(buildSystemId);
+ if(des == null){
+ try {
+ des = loadPreference(buildSystemId);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+
+ if(des == null){
+ try {
+ des = createNewPreference(buildSystemId);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+
+ setLoaddedPreference(buildSystemId, (CConfigurationDescriptionCache)des);
+ }
+ if(des != null && write){
+ try {
+ des = createWritablePreference((CConfigurationDescriptionCache)des);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ return des;
+ }
+
+ public void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws CoreException{
+ if(!needSavePreference(buildSystemId, des))
+ return;
+
+ CConfigurationDescriptionCache cache = createPreferenceCache(des);
+
+ savePreferenceConfiguration(buildSystemId, cache);
+
+ setLoaddedPreference(buildSystemId, cache);
+ }
+
+ private void savePreferenceConfiguration(String buildStystemId, CConfigurationDescriptionCache cache) throws CoreException{
+ ICStorageElement el = cache.getSpecSettings().getRootStorageElement();
+ saveBuildSystemConfigPreferenceStorage(buildStystemId, el);
+ }
+
+ private void saveBuildSystemConfigPreferenceStorage(String buildSystemId, ICStorageElement el) throws CoreException{
+ ICStorageElement cur = getBuildSystemConfigPreferenceStorage(buildSystemId);
+ ICStorageElement parent = cur.getParent();
+ parent.removeChild(cur);
+ parent.importChild(el);
+ savePreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, parent);
+ }
+
+ private boolean needSavePreference(String buildSystemId, ICConfigurationDescription des){
+ if(des.isModified()
+ || !des.isPreferenceConfiguration()
+ || !des.getBuildSystemId().equals(buildSystemId))
+ return true;
+
+ return false;
+ }
+
+ private ICConfigurationDescription createWritablePreference(CConfigurationDescriptionCache cache) throws CoreException{
+ return new CConfigurationDescription(cache, fPrefUpdater);
+ }
+
+ private CConfigurationDescriptionCache createPreferenceCache(ICConfigurationDescription des) throws CoreException{
+ IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)des;
+ CConfigurationData baseData = cfgDes.getConfigurationData(false);
+ if(baseData instanceof CConfigurationDescriptionCache){
+ baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
+ }
+ CConfigurationSpecSettings settings = cfgDes.getSpecSettings();
+ ICStorageElement rootEl = getBuildSystemConfigPreferenceStorage(des.getBuildSystemId(), true, false);
+ ICStorageElement rootParent = rootEl.getParent();
+ rootParent.removeChild(rootEl);
+ ICStorageElement baseRootEl = settings.getRootStorageElement();
+ rootEl = rootParent.importChild(baseRootEl);
+ CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(baseData, cfgDes.getSpecSettings(), null, rootEl, true);
+
+ return cache;
+ }
+
+ private ICConfigurationDescription createNewPreference(String buildSystemId) throws CoreException {
+ ICStorageElement cfgEl = getBuildSystemConfigPreferenceStorage(buildSystemId, true, false);
+
+ String id = PREFERENCE_CFG_ID_PREFIX + buildSystemId;
+ CConfigurationDescription des = new CConfigurationDescription(id, PREFERENCE_CFG_NAME, buildSystemId, cfgEl, fPrefUpdater);
+
+ return createPreferenceCache(des);
+ }
+
+// private CStorage createBuildSystemCfgPrefStore() throws CoreException{
+// ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, true, false);
+//
+// CStorage store = new CStorage((InternalXmlStorageElement)el);
+//
+// return store;
+// }
+//
+// ICSettingsStorage getBuildSystemCfgPrefStore() throws CoreException{
+// if(fPrefCfgStorage == null){
+// fPrefCfgStorage = createBuildSystemCfgPrefStore();
+// }
+//
+// return copyStorage(fPrefCfgStorage, false);
+// }
+
+ ICStorageElement getBuildSystemConfigPreferenceStorage(String buildSystemId) throws CoreException{
+ return getBuildSystemConfigPreferenceStorage(buildSystemId, true, false);
+ }
+
+ private ICStorageElement getBuildSystemConfigPreferenceStorage(String buildSystemId, boolean createIfNotDound, boolean readOnly) throws CoreException{
+ ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, createIfNotDound, readOnly);
+ ICStorageElement cfgEl = null;
+
+ if(el != null){
+ ICStorageElement children[] = el.getChildren();
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){
+ if(buildSystemId.equals(child.getAttribute(ID))){
+ cfgEl = child;
+ break;
+ }
+ }
+
+ }
+
+ if(cfgEl == null){
+ cfgEl = el.createChild(PREFERENCE_BUILD_SYSTEM_ELEMENT);
+ cfgEl.setAttribute(ID, buildSystemId);
+ }
+
+ }
+
+ return cfgEl;
+ }
+
+ private ICConfigurationDescription loadPreference(String buildSystemId) throws CoreException{
+ ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, false, false);
+
+ ICStorageElement children[] = el.getChildren();
+ ICStorageElement cfgEl = null;
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){
+ if(buildSystemId.equals(child.getAttribute(ID))){
+ cfgEl = child;
+ break;
+ }
+ }
+
+ }
+ CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgEl, null);
+ cache.loadData();
+ return cache;
+ }
+
+ public ICStorageElement getPreferenceStorage(String prefKey, String storageId, boolean createIfNotDound, boolean readOnly) throws CoreException{
+ CStorage store = getPreferenceStore(prefKey, createIfNotDound, readOnly);
+
+ return store.getStorage(storageId, createIfNotDound);
+ }
+
+ private CStorage getPreferenceStore(String prefKey, boolean createIfNotDound, boolean readOnly) throws CoreException{
+ ICStorageElement el = createPreferenceStorage(prefKey, createIfNotDound, readOnly);
+
+ CStorage store = new CStorage((InternalXmlStorageElement)el);
+
+ return store;
+ }
+
+ public void savePreferenceStorage(String prefKey, String storageId, ICStorageElement el) throws CoreException{
+ CStorage store = getPreferenceStore(prefKey, true, false);
+ store.importStorage(storageId, el);
+
+ ICStorageElement rootEl = new InternalXmlStorageElement(store.fElement, store.isReadOnly());
+ serializePreference(prefKey, rootEl);
+ }
+
+ private CConfigurationDescriptionCache getLoaddedPreference(String buildSystemId){
+ return (CConfigurationDescriptionCache)fPreferenceMap.get(buildSystemId);
+ }
+
+ private void setLoaddedPreference(String buildSystemId, CConfigurationDescriptionCache des){
+ fPreferenceMap.put(buildSystemId, des);
+ }
+
+ public CConfigBasedDescriptorManager getDescriptorManager(){
+ return fDescriptorManager;
+ }
+
+ public CConfigurationData createDefaultConfigData(IProject project, CDataFacroty factory) throws CoreException{
+ return createDefaultConfigData(project, CDataUtil.genId(DEFAULT_CFG_ID_PREFIX), DEFAULT_CFG_NAME, factory);
+ }
+
+ public CConfigurationData createDefaultConfigData(IProject project, String id, String name, CDataFacroty factory) throws CoreException{
+ if(factory == null)
+ factory = new CDataFacroty();
+
+ CDefaultConfigurationData data = (CDefaultConfigurationData)factory.createConfigurationdata(id, name, null, false);
+ data.initEmptyData();
+ adjustDefaultConfig(data);
+
+ data.setModified(false);
+ return data;
+ }
+
+ public CConfigurationData adjustDefaultConfig(CConfigurationData cfg){
+ LanguageManager mngr = LanguageManager.getInstance();
+ ILanguageDescriptor dess[] = mngr.getLanguageDescriptors();
+ Map map = mngr.getContentTypeIdToLanguageDescriptionsMap();
+
+ CResourceData[] rcDatas = cfg.getResourceDatas();
+ for(int i = 0; i < rcDatas.length; i++){
+ if(rcDatas[i].getType() == ICSettingBase.SETTING_FOLDER){
+ adjustFolderData((CFolderData)rcDatas[i], dess, new HashMap(map));
+ }
+ }
+
+ return cfg;
+ }
+
+
+ private static void adjustFolderData(CFolderData data, ILanguageDescriptor dess[], HashMap map){
+ Map langMap = new HashMap();
+ for(int i = 0; i < dess.length; i++){
+ langMap.put(dess[i].getId(), dess[i]);
+ }
+ CLanguageData lDatas[] = data.getLanguageDatas();
+ for(int i = 0; i < lDatas.length; i++){
+ CLanguageData lData = (CLanguageData)lDatas[i];
+ String langId = lData.getLanguageId();
+ if(langId != null){
+ ILanguageDescriptor des = (ILanguageDescriptor)langMap.remove(langId);
+ adjustLanguageData(data, lData, des);
+ continue;
+ } else {
+ String[] cTypeIds = lData.getSourceContentTypeIds();
+ for(int c = 0; c < cTypeIds.length; c++){
+ String cTypeId = cTypeIds[c];
+ ILanguageDescriptor[] langs = (ILanguageDescriptor[])map.remove(cTypeId);
+ if(langs != null && langs.length != 0){
+ for(int q = 0; q < langs.length; q++){
+ langMap.remove(langs[q].getId());
+ }
+
+ adjustLanguageData(data, lData, langs[0]);
+ }
+ }
+ }
+ }
+
+ if(!langMap.isEmpty()){
+ addLangs(data, langMap, map);
+ }
+
+ }
+
+ private static CLanguageData adjustLanguageData(CFolderData data, CLanguageData lData, ILanguageDescriptor des){
+ String [] cTypeIds = des.getContentTypeIds();
+ String srcIds[] = lData.getSourceContentTypeIds();
+
+ Set landTypes = new HashSet(Arrays.asList(cTypeIds));
+ landTypes.removeAll(Arrays.asList(srcIds));
+
+ if(landTypes.size() != 0){
+ List srcList = new ArrayList();
+ srcList.addAll(landTypes);
+ lData.setSourceContentTypeIds((String[])srcList.toArray(new String[srcList.size()]));
+ }
+
+ if(!des.getId().equals(lData.getLanguageId())){
+ lData.setLanguageId(des.getId());
+ }
+ return lData;
+ }
+
+ private static void addLangs(CFolderData data, Map langMap, Map cTypeToLangMap){
+ List list = new ArrayList(langMap.values());
+ ILanguageDescriptor des;
+ while(list.size() != 0){
+ des = (ILanguageDescriptor)list.remove(list.size() - 1);
+ String[] ctypeIds = des.getContentTypeIds();
+ boolean addLang = false;
+ for(int i = 0; i < ctypeIds.length; i++){
+ ILanguageDescriptor[] langs = (ILanguageDescriptor[])cTypeToLangMap.remove(ctypeIds[i]);
+ if(langs != null && langs.length != 0){
+ addLang = true;
+ for(int q = 0; q < langs.length; q++){
+ list.remove(langs[q]);
+ }
+ }
+ }
+
+ if(addLang){
+ data.createLanguageDataForContentTypes(des.getId(), ctypeIds);
+ }
+ }
+ }
+
+ public boolean isNewStyleIndexCfg(IProject project){
+ ICProjectDescription des = getProjectDescription(project, false);
+ if(des != null)
+ return isNewStyleIndexCfg(des);
+ return false;
+ }
+
+ public boolean isNewStyleIndexCfg(ICProjectDescription des){
+ ICConfigurationDescription cfgDes = ((CProjectDescription)des).getIndexConfiguration();
+ if(cfgDes != null)
+ return isNewStyleCfg(cfgDes);
+ return false;
+ }
+
+ public boolean isNewStyleCfg(ICConfigurationDescription cfgDes){
+ if(cfgDes == null)
+ return false;
+
+ CConfigurationData data = ((IInternalCCfgInfo)cfgDes).getConfigurationData(false);
+ if(data instanceof CConfigurationDescriptionCache){
+ data = ((CConfigurationDescriptionCache)data).getConfigurationData();
+ }
+
+ return data != null && !PathEntryConfigurationDataProvider.isPathEntryData(data);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CStorage.java
new file mode 100644
index 00000000000..797d913658d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CStorage.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.naming.OperationNotSupportedException;
+
+import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.core.runtime.CoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class CStorage implements ICSettingsStorage{
+ private static final String MODULE_ELEMENT_NAME = "storageModule"; //$NON-NLS-1$
+ private static final String MODULE_ID_ATTRIBUTE = "moduleId"; //$NON-NLS-1$
+ Element fElement;
+ private Map fStorageElementMap = new HashMap();
+ private boolean fChildrenInited;
+ private boolean fIsReadOnly;
+ private boolean fIsDirty;
+
+ public CStorage(Element element, boolean isReadOnly){
+ fElement = element;
+ fIsReadOnly = isReadOnly;
+ }
+
+ public CStorage(InternalXmlStorageElement element){
+ fElement = element.fElement;
+ fIsReadOnly = element.isReadOnly();
+ element.storageCreated(this);
+ }
+
+ public boolean isReadOnly(){
+ return fIsReadOnly;
+ }
+
+ private void initChildren(){
+ if(fChildrenInited)
+ return;
+ fChildrenInited = true;
+
+ NodeList children = fElement.getChildNodes();
+ int size = children.getLength();
+ for(int i = 0; i < size; i++){
+ Node node = children.item(i);
+ if(node.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+ if(!MODULE_ELEMENT_NAME.equals(node.getNodeName()))
+ continue;
+
+ Element element = (Element)node;
+ String moduleId = element.getAttribute(MODULE_ID_ATTRIBUTE).trim();
+ if(moduleId.length() == 0)
+ continue;
+
+ createAddStorageElement(moduleId, element);
+ }
+ }
+
+ private InternalXmlStorageElement createAddStorageElement(String id, Element element){
+ InternalXmlStorageElement se = new InternalXmlStorageElement(element, null, false, new String[]{MODULE_ID_ATTRIBUTE}, null, fIsReadOnly);
+ fStorageElementMap.put(id, se);
+ return se;
+ }
+
+// public ICStorageElement getStorage(String id){
+// return getStorage(id, true);
+// }
+
+
+ public boolean containsStorage(String id) throws CoreException {
+ return getStorage(id, false) != null;
+ }
+
+ public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ removeStorage(id);
+
+ InternalXmlStorageElement xmlStEl = (InternalXmlStorageElement)el;
+ Element xmlEl = xmlStEl.fElement;
+ Document thisDoc = fElement.getOwnerDocument();
+ Document otherDoc = xmlEl.getOwnerDocument();
+ if(!thisDoc.equals(otherDoc)){
+ xmlEl = (Element)thisDoc.importNode(xmlEl, true);
+ }
+
+ Element newEl = thisDoc.createElement(MODULE_ELEMENT_NAME);
+ NodeList nl = xmlEl.getChildNodes();
+ for(int i = 0; i < nl.getLength(); i++){
+ Node child = nl.item(i).cloneNode(true);
+ newEl.appendChild(child);
+ }
+
+ xmlEl = newEl;
+
+ xmlEl = (Element)fElement.appendChild(xmlEl);
+ xmlEl.setAttribute(MODULE_ID_ATTRIBUTE, id);
+ return createAddStorageElement(id, xmlEl);
+ }
+
+ public ICStorageElement getStorage(String id, boolean create){
+ initChildren();
+
+ InternalXmlStorageElement se = (InternalXmlStorageElement)fStorageElementMap.get(id);
+ if(se == null && create){
+// if(fIsReadOnly)
+// throw ExceptionFactory.createIsReadOnlyException();
+
+ fIsDirty = true;
+ Document doc = fElement.getOwnerDocument();
+ Element child = doc.createElement(MODULE_ELEMENT_NAME);
+ child.setAttribute(MODULE_ID_ATTRIBUTE, id);
+ fElement.appendChild(child);
+ se = createAddStorageElement(id, child);
+ }
+ return se;
+ }
+
+ public void removeStorage(String id){
+ initChildren();
+ InternalXmlStorageElement se = (InternalXmlStorageElement)fStorageElementMap.remove(id);
+
+ if(se != null){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ fIsDirty = true;
+ fElement.removeChild(se.fElement);
+ se.removed();
+ }
+ }
+
+ public boolean isDirty(){
+ if(fIsDirty)
+ return true;
+
+ for(Iterator iter = fStorageElementMap.values().iterator(); iter.hasNext();){
+ InternalXmlStorageElement el = (InternalXmlStorageElement)iter.next();
+ if(el.isDirty())
+ return true;
+ }
+
+ return false;
+ }
+
+ public void setDirty(boolean isDirty){
+ fIsDirty = isDirty;
+
+ if(!fIsDirty){
+ for(Iterator iter = fStorageElementMap.values().iterator(); iter.hasNext();){
+ InternalXmlStorageElement el = (InternalXmlStorageElement)iter.next();
+ el.setDirty(false);
+ }
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java
new file mode 100644
index 00000000000..1efb5adccab
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+
+public class CTargetPlatformSetting extends CDataProxy implements
+ ICTargetPlatformSetting {
+
+ CTargetPlatformSetting(CTargetPlatformData data, CConfigurationDescription cfg) {
+ super(data, cfg, cfg);
+ }
+
+ public final int getType() {
+ return SETTING_TARGET_PLATFORM;
+ }
+
+ public String[] getBinaryParserIds() {
+ CTargetPlatformData data = getTargetPlatformData(false);
+ return data.getBinaryParserIds();
+ }
+
+ public void setBinaryParserIds(String[] ids) {
+ CTargetPlatformData data = getTargetPlatformData(true);
+ data.setBinaryParserIds(ids);
+ }
+
+ private CTargetPlatformData getTargetPlatformData(boolean write){
+ return (CTargetPlatformData)getData(write);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java
new file mode 100644
index 00000000000..e9709bbd9d1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultTargetPlatformData;
+
+public class CTargetPlatformSettingCache extends CDefaultTargetPlatformData
+ implements ICTargetPlatformSetting, ICachedData {
+ private CConfigurationDescriptionCache fCfgCache;
+ CTargetPlatformSettingCache(CTargetPlatformData base, CConfigurationDescriptionCache cfgCache){
+ fId = base.getId();
+
+ fCfgCache = cfgCache;
+
+ fCfgCache.addTargetPlatformSetting(this);
+ }
+
+
+ public ICConfigurationDescription getConfiguration() {
+ return fCfgCache;
+ }
+
+ public ICSettingContainer getParent() {
+ return fCfgCache;
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ public void setBinaryParserIds(String[] ids) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+
+ public void setName(String name) {
+ throw ExceptionFactory.createIsReadOnlyException();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java
new file mode 100644
index 00000000000..e2ae6be757d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerListener;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.runtime.IPath;
+
+public class CfgProxyCache implements IProxyCache {
+ private HashMap fProxyMap = new HashMap();
+ private PathSettingsContainer fPathContainer;
+
+ CfgProxyCache(PathSettingsContainer pathDesContainer){
+ fPathContainer = pathDesContainer;
+ fPathContainer.addContainerListener(new IPathSettingsContainerListener(){
+ public void aboutToRemove(PathSettingsContainer container) {
+ CDataProxy proxy = (CDataProxy)container.getValue();
+ if(proxy != null)
+ fProxyMap.remove(proxy.getId());
+ }
+
+ public void containerAdded(PathSettingsContainer container) {
+ }
+
+ public void containerValueChanged(PathSettingsContainer container, Object oldValue) {
+ CDataProxy proxy = (CDataProxy)container.getValue();
+ if(proxy != null)
+ fProxyMap.put(proxy.getId(),proxy);
+ else if(oldValue != null){
+ fProxyMap.remove((CDataProxy)oldValue);
+ }
+ }
+
+ public void containerPathChanged(PathSettingsContainer container, IPath oldPath, boolean childrenMoved) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+
+ public void addCachedProxy(CDataProxy proxy) {
+ if(proxy instanceof IInternalResourceDescription){
+ IInternalResourceDescription des = (IInternalResourceDescription)proxy;
+ IPath path = des.getPath();
+ PathSettingsContainer cr = fPathContainer.getChildContainer(path, true, true);
+ cr.setValue(des);
+ des.setPathContainer(cr);
+ } else {
+ fProxyMap.put(proxy.getId(), proxy);
+ }
+ }
+
+ public void clear() {
+ fPathContainer.removeChildren();
+ fProxyMap.clear();
+ }
+
+ public CDataProxy[] getCachedProxies() {
+ Collection c = fProxyMap.values();
+ return (CDataProxy[])c.toArray(new CDataProxy[c.size()]);
+ }
+
+ public CDataProxy getCachedProxy(String id) {
+ return (CDataProxy)fProxyMap.get(id);
+ }
+
+ public void removeCachedProxy(String id) {
+ CDataProxy proxy = (CDataProxy)fProxyMap.get(id);
+ removeCachedProxy(proxy);
+ }
+
+ public Map getCachedProxiesMap() {
+ return (Map)fProxyMap.clone();
+ }
+
+ public CDataProxy getCachedProxy(CDataObject data) {
+ return getCachedProxy(data.getId());
+ }
+
+ public void removeCachedProxy(CDataProxy proxy) {
+ if(proxy instanceof IInternalResourceDescription){
+ fPathContainer.removeChildContainer(((IInternalResourceDescription)proxy).getCachedPath());
+ } else {
+ fProxyMap.remove(proxy.getId());
+ }
+ }
+
+// public Map reuseProxies(List dataList, Map freeProxyMap) {
+// Collection proxies = freeProxyMap.values();
+// CDataProxy proxy;
+// CDataObject data;
+// Map result;
+// for(Iterator dataIter = dataList.iterator(); dataIter.hasNext();){
+// data = (CDataObject)dataIter.next();
+// for(Iterator proxyIter = proxies.iterator(); proxyIter.hasNext();){
+// proxy = (CDataProxy)proxyIter.next();
+// if(data.getType() != proxy.getType())
+// continue;
+//
+// switch(data.getType()){
+// case ICSettingBase.SETTING_TARGET_PLATFORM:
+// case ICSettingBase.SETTING_FILE:
+// case ICSettingBase.SETTING_FOLDER:
+//// if(((CResourceData)data).getPath().equals(((CResourceDescription)proxy).getPath()))
+// }
+//
+// if(result == null)
+// result = new HashMap();
+//
+//
+// }
+// }
+// }
+}
+
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedEntriesContainerInitializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedEntriesContainerInitializer.java
new file mode 100644
index 00000000000..df1c052fc2c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedEntriesContainerInitializer.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public class ConfigBasedEntriesContainerInitializer extends
+ PathEntryContainerInitializer {
+
+ public void initialize(IPath containerPath, ICProject project)
+ throws CoreException {
+ IPathEntry[] entries = ConfigBasedPathEntryStore.getContainerEntries(project.getProject());
+ ConfigBasedPathEntryContainer container = new ConfigBasedPathEntryContainer(entries);
+ CoreModel.setPathEntryContainer(new ICProject[]{project}, container, null);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java
new file mode 100644
index 00000000000..19934f15c4e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java
@@ -0,0 +1,28 @@
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IPathEntryContainer;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class ConfigBasedPathEntryContainer implements IPathEntryContainer {
+ public static final IPath CONTAINER_PATH = new Path("org.eclipse.cdt.core.CFG_BASED_CONTAINER"); //$NON-NLS-1$
+ private IPathEntry[] fEntries;
+
+ public ConfigBasedPathEntryContainer(IPathEntry entries[]){
+ this.fEntries = (IPathEntry[])entries.clone();
+ }
+
+ public String getDescription() {
+ return "Configuration Description info container"; //$NON-NLS-1$
+ }
+
+ public IPath getPath() {
+ return CONTAINER_PATH;
+ }
+
+ public IPathEntry[] getPathEntries() {
+ return (IPathEntry[])fEntries.clone();
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java
new file mode 100644
index 00000000000..cd23e8d0136
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator;
+import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.PathEntryCollector;
+import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.ReferenceSettingsInfo;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+
+public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDescriptionListener {
+ private List fListeners;
+ private IProject fProject;
+ static final QualifiedName PATH_ENTRY_COLLECTOR_PROPERTY_NAME = new QualifiedName(CCorePlugin.PLUGIN_ID, "PathEntryStoreCollector"); //$NON-NLS-1$
+
+ /**
+ *
+ */
+ public ConfigBasedPathEntryStore(IProject project) {
+ fProject = project;
+ fListeners = Collections.synchronizedList(new ArrayList());
+
+ CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
+ */
+ public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
+ fListeners.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
+ */
+ public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
+ fListeners.remove(listener);
+ }
+
+ private void fireContentChangedEvent(IProject project) {
+ PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
+ IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
+ fListeners.toArray(observers);
+ for (int i = 0; i < observers.length; i++) {
+ observers[i].pathEntryStoreChanged(evt);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject)
+ */
+ public void close() {
+ PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED);
+ IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
+ fListeners.toArray(observers);
+ for (int i = 0; i < observers.length; i++) {
+ observers[i].pathEntryStoreChanged(evt);
+ }
+ CProjectDescriptionManager.getInstance().removeListener(this);
+ }
+
+ public IProject getProject() {
+ return fProject;
+ }
+
+ public ICExtensionReference getExtensionReference() {
+ return null;
+ }
+
+ public IPathEntry[] getRawPathEntries() throws CoreException {
+ PathEntryCollector cr = getCollector(fProject);
+ if(cr != null){
+ List list = cr.getEntries(null, PathEntryTranslator.INCLUDE_USER);
+ list.add(CoreModel.newContainerEntry(ConfigBasedPathEntryContainer.CONTAINER_PATH));
+ return (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
+ }
+ return new IPathEntry[0];
+ }
+
+ public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
+ PathEntryCollector cr = getCollector(fProject);
+ if(cr != null){
+ List sysList = cr.getEntries(null, PathEntryTranslator.INCLUDE_BUILT_INS);
+ List usrList = new ArrayList(entries.length);
+ for(int i = 0; i < entries.length; i++){
+ if(entries[i].getEntryKind() != IPathEntry.CDT_CONTAINER)
+ usrList.add(entries[i]);
+ }
+
+ CProjectDescription des = (CProjectDescription)CoreModel.getDefault().getProjectDescription(fProject, true);
+ ICConfigurationDescription cfgDes = des.getIndexConfiguration();
+ CConfigurationData data = cfgDes.getConfigurationData();
+ PathEntryTranslator tr = new PathEntryTranslator(fProject, data);
+ IPathEntry[] usrEntries = (IPathEntry[])usrList.toArray(new IPathEntry[usrList.size()]);
+ IPathEntry[] sysEntries = (IPathEntry[])sysList.toArray(new IPathEntry[sysList.size()]);
+ ReferenceSettingsInfo rInfo = tr.applyPathEntries(usrEntries, sysEntries, PathEntryTranslator.OP_REPLACE);
+ cfgDes.removeExternalSettings();
+ ICExternalSetting extSettings[] = rInfo.getExternalSettings();
+ for(int i = 0; i < extSettings.length; i++){
+ ICExternalSetting setting = extSettings[i];
+ cfgDes.createExternalSetting(setting.getCompatibleLanguageIds(),
+ setting.getCompatibleContentTypeIds(),
+ setting.getCompatibleExtensions(),
+ setting.getEntries());
+ }
+ Map refMap = rInfo.getRefProjectsMap();
+ cfgDes.setReferenceInfo(refMap);
+
+ CoreModel.getDefault().setProjectDescription(fProject, des);
+ }
+ }
+
+ public void handleEvent(CProjectDescriptionEvent event) {
+ IProject project = event.getProject();
+ if(!fProject.equals(project))
+ return;
+
+ switch(event.getEventType()){
+ case CProjectDescriptionEvent.APPLIED:{
+ CProjectDescription des = (CProjectDescription)event.getNewCProjectDescription();
+ if(des != null){
+ //TODO: smart delta handling
+ ICConfigurationDescription[] cfgDess = des.getConfigurations();
+ for(int i = 0; i < cfgDess.length; i++){
+ setCachedCollector(cfgDess[i], null);
+ }
+// ICConfigurationDescription cfgDes = des.getIndexConfiguration();
+ }
+ fireContentChangedEvent(fProject);
+ break;
+ }
+ }
+ }
+
+ private static PathEntryCollector getCollector(ICProjectDescription des){
+ ICConfigurationDescription cfgDes = ((CProjectDescription)des).getIndexConfiguration();
+ if(cfgDes != null){
+ PathEntryCollector cr = getCachedCollector(cfgDes);
+ if(cr == null){
+ cr = PathEntryTranslator.collectEntries(des.getProject(), cfgDes);
+ setCachedCollector(cfgDes, cr);
+ }
+ return cr;
+ }
+ return null;
+ }
+
+ private static PathEntryCollector getCachedCollector(ICConfigurationDescription cfgDes){
+ return (PathEntryCollector)cfgDes.getSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME);
+ }
+
+ private static void setCachedCollector(ICConfigurationDescription cfgDes, PathEntryCollector cr){
+ cfgDes.setSessionProperty(PATH_ENTRY_COLLECTOR_PROPERTY_NAME, cr);
+ }
+
+ public static PathEntryCollector getCollector(IProject project){
+ ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
+ if(des != null)
+ return getCollector(des);
+ return null;
+ }
+
+ public static IPathEntry[] getContainerEntries(IProject project){
+ PathEntryCollector cr = getCollector(project);
+ if(cr != null)
+ return cr.getEntries(PathEntryTranslator.INCLUDE_BUILT_INS);
+ return new IPathEntry[0];
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java
new file mode 100644
index 00000000000..e273d99e2e8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
+import org.eclipse.core.runtime.CoreException;
+
+public class DefaultConfigurationDataProvider extends
+ CConfigurationDataProvider {
+
+ public CConfigurationData applyConfiguration(
+ ICConfigurationDescription des, CConfigurationData base)
+ throws CoreException {
+ //TODO: implement load/store
+ return base;
+ }
+
+ public CConfigurationData createConfiguration(
+ ICConfigurationDescription des, CConfigurationData base,
+ boolean clone) throws CoreException {
+ //TODO: implement load/store
+ CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), base, null, clone);
+ return data;
+ }
+
+ public CConfigurationData loadConfiguration(ICConfigurationDescription des)
+ throws CoreException {
+ //TODO: implement load/store
+ CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), null);
+ data.initEmptyData();
+ return data;
+ }
+
+ public void removeConfiguration(ICConfigurationDescription des,
+ CConfigurationData data) {
+ //TODO: implement load/store
+
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java
new file mode 100644
index 00000000000..2468b0c9b16
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.parser.ScannerInfo;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry;
+import org.eclipse.cdt.core.settings.model.ICMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICProjectDescriptionListener {
+ private IProject fProject;
+ private ICProjectDescription fProjDes;
+ private ICConfigurationDescription fCfgDes;
+ private Map fIdToLanguageSettingsMap = Collections.synchronizedMap(new HashMap());
+ private static final ScannerInfo INEXISTENT_SCANNER_INFO = new ScannerInfo();
+ private boolean fInited;
+
+ DescriptionScannerInfoProvider(IProject project){
+ fProject = project;
+
+ CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
+ }
+
+ private void updateProjCfgInfo(ICProjectDescription des){
+ fInited = true;
+ fProjDes = des;
+ if(fProjDes != null){
+ fCfgDes = ((CProjectDescription)des).getIndexConfiguration();
+ }
+
+ fIdToLanguageSettingsMap.clear();
+ }
+
+ public IProject getProject(){
+ return fProject;
+ }
+
+ public IScannerInfo getScannerInformation(IResource resource) {
+ if(!fInited)
+ updateProjCfgInfo(CProjectDescriptionManager.getInstance().getProjectDescription(fProject, false));
+
+ if(fCfgDes == null)
+ return INEXISTENT_SCANNER_INFO;
+
+ IPath rcPath = resource.getProjectRelativePath();
+ ICResourceDescription rcDes = fCfgDes.getResourceDescription(rcPath, false);
+ ICLanguageSetting setting = null;
+ if(rcDes.getType() == ICSettingBase.SETTING_FILE){
+ setting = ((ICFileDescription)rcDes).getLanguageSetting();
+ } else {
+ if(resource.getType() == IResource.FILE)
+ setting = ((ICFolderDescription)rcDes).getLanguageSettingForFile(rcPath.lastSegment());
+ else {
+ ICLanguageSetting settings[] = ((ICFolderDescription)rcDes).getLanguageSettings();
+ if(settings.length > 0)
+ setting = settings[0];
+ }
+ }
+ return getScannerInfo(setting);
+ }
+
+ private IScannerInfo getScannerInfo(ICLanguageSetting ls){
+ if(ls == null)
+ return INEXISTENT_SCANNER_INFO;
+
+ IScannerInfo info = (IScannerInfo)fIdToLanguageSettingsMap.get(ls.getId());
+ if(info == null){
+ info = createScannerInfo(ls);
+ fIdToLanguageSettingsMap.put(ls.getId(), info);
+ }
+ return info;
+ }
+
+
+ private IScannerInfo createScannerInfo(ICLanguageSetting ls){
+ ICLanguageSettingPathEntry pathEntries[] = (ICLanguageSettingPathEntry[])ls.getResolvedSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
+ String incs[] = getValues(pathEntries);
+
+ pathEntries = (ICLanguageSettingPathEntry[])ls.getResolvedSettingEntries(ICLanguageSettingEntry.INCLUDE_FILE);
+ String incFiles[] = getValues(pathEntries);
+
+ pathEntries = (ICLanguageSettingPathEntry[])ls.getResolvedSettingEntries(ICLanguageSettingEntry.MACRO_FILE);
+ String macroFiles[] = getValues(pathEntries);
+
+ ICMacroEntry macroEntries[] = (ICMacroEntry[])ls.getResolvedSettingEntries(ICLanguageSettingEntry.MACRO);
+ Map macrosMap = getValues(macroEntries);
+
+ return new ExtendedScannerInfo(macrosMap, incs, macroFiles, incFiles);
+ }
+
+ private Map getValues(ICMacroEntry macroEntries[]){
+ Map macrosMap = new HashMap(macroEntries.length);
+ String name;
+ String value;
+
+ for(int i = 0; i < macroEntries.length; i++){
+ name = macroEntries[i].getName();
+ value = macroEntries[i].getValue();
+ macrosMap.put(name, value);
+ }
+ return macrosMap;
+ }
+
+ private String[] getValues(ICLanguageSettingPathEntry pathEntries[]){
+ String values[] = new String[pathEntries.length];
+ IPath path;
+ int num = 0;
+ for(int i = 0; i < pathEntries.length; i++){
+ String p = pathEntries[i].getValue();
+ if(p == null)
+ continue;
+ //TODO: obtain location from pathEntries when entries are resolved
+ path = new Path(p);//pathEntries[i].getLocation();
+ if(pathEntries[i].isValueWorkspacePath()){
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource rc = root.findMember(path);
+ if(rc != null){
+ path = rc.getLocation();
+ }
+ }
+ if(path != null)
+ values[num++] = path.toOSString();
+ }
+
+ if(num < pathEntries.length){
+ String tmp[] = new String[num];
+ System.arraycopy(values, 0, tmp, 0, num);
+ values = tmp;
+ }
+
+ return values;
+ }
+
+ public void subscribe(IResource resource,
+ IScannerInfoChangeListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unsubscribe(IResource resource,
+ IScannerInfoChangeListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void close(){
+ CProjectDescriptionManager.getInstance().removeListener(this);
+ }
+
+ public void handleEvent(CProjectDescriptionEvent event) {
+ if(!event.getProject().equals(fProject))
+ return;
+
+ //TODO: check delta and notify listeners
+
+ updateProjCfgInfo(event.getNewCProjectDescription());
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionStatus.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionStatus.java
new file mode 100644
index 00000000000..666c2c51005
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionStatus.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.core.runtime.Status;
+
+public class DescriptionStatus extends Status {
+
+ public DescriptionStatus(String message) {
+ this(message, null);
+ }
+ public DescriptionStatus(String message, Throwable exception) {
+ this(OK, message, exception);
+ }
+
+ public DescriptionStatus(Throwable exception) {
+ this(exception.getLocalizedMessage(), exception);
+ }
+
+ public DescriptionStatus(int code, String message, Throwable exception) {
+ super(ERROR, CCorePlugin.PLUGIN_ID, code, message, exception);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/EntriesNamesContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/EntriesNamesContainer.java
new file mode 100644
index 00000000000..2a11c7802f6
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/EntriesNamesContainer.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.util.IKindBasedInfo;
+import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
+
+class EntriesNamesContainer {
+// private String fLanguageSettingsId;
+ private KindBasedStore fRemovedEntryNamesStore = new KindBasedStore();
+
+// EntriesNamesContainer(ICLanguageSetting setting) {
+// fLanguageSettingsId = setting.getId();
+// }
+
+ public EntriesNamesContainer() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public EntriesNamesContainer(EntriesNamesContainer base) {
+// fLanguageSettingsId = base.fLanguageSettingsId;
+ IKindBasedInfo infos[] = base.fRemovedEntryNamesStore.getContents();
+ for(int i = 0; i < infos.length; i++){
+ Set set = (Set)infos[i].getInfo();
+ if(set != null)
+ fRemovedEntryNamesStore.put(infos[i].getKind(), new HashSet(set));
+ }
+ }
+
+// public String getLanguageSettingId(){
+// return fLanguageSettingsId;
+//o }
+
+ private Set getRemovedNamesSet(int kind, boolean create){
+ Set set = (Set)fRemovedEntryNamesStore.get(kind);
+ if(set == null && create){
+ set = new HashSet();
+ fRemovedEntryNamesStore.put(kind, set);
+ }
+ return set;
+ }
+
+ public void clear(){
+ fRemovedEntryNamesStore.clear();
+ }
+
+ public void clear(int kind){
+ fRemovedEntryNamesStore.put(kind, null);
+ }
+
+ public boolean contains(int kind, String name){
+ Set set = getRemovedNamesSet(kind, false);
+ if(set != null)
+ return set.contains(name);
+ return false;
+ }
+
+ public boolean add(int kind, String name){
+ return getRemovedNamesSet(kind, true).add(name);
+ }
+
+ public boolean remove(int kind, String name){
+ Set set = getRemovedNamesSet(kind, false);
+ if(set != null)
+ return set.remove(name);
+ return false;
+ }
+
+ public void set(int kind, String names[]){
+ if(names == null || names.length == 0) {
+ clear(kind);
+ } else {
+ Set set = getRemovedNamesSet(kind, true);
+ set.clear();
+ add(set, names);
+ }
+ }
+
+ private static void add(Set set, String names[]){
+ for(int i = 0; i < names.length; i++){
+ set.add(names[i]);
+ }
+ }
+
+ public void add(int kind, String names[]){
+ if(names == null || names.length == 0) {
+ return;
+ } else {
+ Set set = getRemovedNamesSet(kind, true);
+ add(set, names);
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExceptionFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExceptionFactory.java
new file mode 100644
index 00000000000..98d4848b8cc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExceptionFactory.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.core.runtime.CoreException;
+
+public class ExceptionFactory {
+ public static WriteAccessException createIsReadOnlyException(){
+ return new WriteAccessException();
+ }
+
+ public static CoreException createCoreException(String message){
+ return new CoreException(new DescriptionStatus(message));
+ }
+
+ public static CoreException createCoreException(Throwable e){
+ return new CoreException(new DescriptionStatus(e));
+ }
+
+ public static CoreException createCoreException(String message, Exception exception){
+ return new CoreException(new DescriptionStatus(message, exception));
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExternalSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExternalSettingsManager.java
new file mode 100644
index 00000000000..9ff5ad588fe
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ExternalSettingsManager.java
@@ -0,0 +1,1072 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
+import org.eclipse.cdt.core.settings.model.util.ListComparator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+public class ExternalSettingsManager {
+ static private ExternalSettingsManager fInstance;
+
+ private ExternalSettingsManager(){
+ }
+
+ public static ExternalSettingsManager getInstance(){
+ if(fInstance == null)
+ fInstance = new ExternalSettingsManager();
+ return fInstance;
+ }
+
+/* private static class EntryComparator extends Comparator {
+
+ public boolean equal(Object o1, Object o2) {
+ ICLanguageSettingEntry entry1 = (ICLanguageSettingEntry)o1;
+ ICLanguageSettingEntry entry2 = (ICLanguageSettingEntry)o2;
+/* int kind = entry1.getKind();
+
+ if(entry2.getKind() != kind)
+ return false;
+
+ if(!entry1.getName().equals(entry2.getName()))
+ return false;
+
+ return kind == ICLanguageSettingEntry.MACRO ?
+ entry1.getValue().equals(entry2.getValue()) : true;
+*/
+/* return entry1.equalsByContents(entry2);
+ }
+
+ }
+*/
+ public void updateReferenceInfo(CConfigurationDescription des, Map newRefMap) throws CoreException{
+ CConfigurationSpecSettings settings = des.getSpecSettings();
+
+ if(settings == null)
+ return;
+
+ Map projRefInfoMap = settings.getProjectRefInfoMap();
+
+ Map[] delta = calculateReferenceDelta(newRefMap, new HashMap(projRefInfoMap));
+ if(delta != null){
+ Map removed = delta[1];
+ Map added = delta[0];
+
+ if(removed != null){
+ List removedInfos = handleProjReferenceAddRemove(des, removed, false);
+ for(Iterator iter = removedInfos.iterator(); iter.hasNext();){
+ ProjectRefInfo info = (ProjectRefInfo)iter.next();
+ projRefInfoMap.remove(info.getProjectName());
+ }
+ }
+
+ if(added != null){
+ List addedInfos = handleProjReferenceAddRemove(des, added, true);
+ for(Iterator iter = addedInfos.iterator(); iter.hasNext();){
+ ProjectRefInfo info = (ProjectRefInfo)iter.next();
+ projRefInfoMap.put(info.getProjectName(), info);
+ }
+ }
+
+ settings.setProjectRefInfoMap(projRefInfoMap);
+ }
+
+ }
+
+ private static void calculateDeltas(ICProjectDescription des, boolean added, Map deltaMap){
+ ICConfigurationDescription configs[] = des.getConfigurations();
+ for(int i = 0; i < configs.length; i++){
+ ExtSettingsDelta deltas[] = getSettingChange(configs[i], null);
+ if(deltas != null){
+ deltaMap.put(configs[i].getId(), deltas);
+ if(configs[i].isActive())
+ deltaMap.put("", deltas);
+ }
+ }
+ }
+
+/* private static ExtSettingsDelta[] calculateDeltas(ICDescriptionDelta projectDelta, String cfgId, ICExternalSetting oldSettings[]){
+ ICProjectDescription newDes = (ICProjectDescription)projectDelta.getNewSetting();
+// ICProjectDescription oldDes = (ICProjectDescription)projectDelta.getOldSetting();
+
+ switch(projectDelta.getDeltaKind()){
+ case ICDescriptionDelta.ADDED:{
+ ICConfigurationDescription newCfg = getConfigurationById(newDes, cfgId);
+ if(newCfg == null)
+ return null;
+ return getSettingChange(newCfg.getExternalSettings(), oldSettings);
+ }
+ case ICDescriptionDelta.REMOVED:{
+// ICConfigurationDescription oldCfg = getConfigurationById(oldDes, cfgId);
+// if(oldCfg == null)
+// return null;
+ return getSettingChange(null, oldSettings);
+ }
+ case ICDescriptionDelta.CHANGED:{
+// boolean activeCfgChanged = (projectDelta.getChangeFlags() | ICDescriptionDelta.ACTIVE_CFG) != 0;
+ ICConfigurationDescription newCfg = getConfigurationById(newDes, cfgId);
+// ICConfigurationDescription oldCfg = getConfigurationById(oldDes, cfgId);;
+ return getSettingChange(newCfg.getExternalSettings(), oldSettings);
+ }
+ }
+ return null;
+ }
+*/
+ private ICExternalSetting[][] getNewOldSettings(ICDescriptionDelta projectDelta, String cfgId){
+ ICExternalSetting[][] settings = new ICExternalSetting[2][];
+ ICProjectDescription newDes = (ICProjectDescription)projectDelta.getNewSetting();
+ ICProjectDescription oldDes = (ICProjectDescription)projectDelta.getOldSetting();
+
+ switch(projectDelta.getDeltaKind()){
+ case ICDescriptionDelta.ADDED:{
+ ICConfigurationDescription newCfg = getConfigurationById(newDes, cfgId);
+ if(newCfg != null){
+ settings[0] = newCfg.getExternalSettings();
+ }
+ break;
+ }
+ case ICDescriptionDelta.REMOVED:{
+ ICConfigurationDescription oldCfg = getConfigurationById(oldDes, cfgId);
+ if(oldCfg != null){
+ settings[1] = oldCfg.getExternalSettings();
+ }
+ break;
+ }
+ case ICDescriptionDelta.CHANGED:{
+// boolean activeCfgChanged = (projectDelta.getChangeFlags() | ICDescriptionDelta.ACTIVE_CFG) != 0;
+ ICConfigurationDescription newCfg = getConfigurationById(newDes, cfgId);
+ ICConfigurationDescription oldCfg = getConfigurationById(oldDes, cfgId);;
+
+ settings[0] = newCfg.getExternalSettings();
+ settings[1] = oldCfg.getExternalSettings();
+ break;
+ }
+ }
+ return settings;
+ }
+
+/* private static ExtSettingsDelta[] calculateDeltas(ICDescriptionDelta projectDelta, String cfgId){
+ ICProjectDescription newDes = (ICProjectDescription)projectDelta.getNewSetting();
+ ICProjectDescription oldDes = (ICProjectDescription)projectDelta.getOldSetting();
+
+ switch(projectDelta.getDeltaKind()){
+ case ICDescriptionDelta.ADDED:{
+ ICConfigurationDescription newCfg = getConfigurationById(newDes, cfgId);
+ if(newCfg == null)
+ return null;
+ return getSettingChange(newCfg, null);
+ }
+ case ICDescriptionDelta.REMOVED:{
+ ICConfigurationDescription oldCfg = getConfigurationById(oldDes, cfgId);
+ if(oldCfg == null)
+ return null;
+ return getSettingChange(null, oldCfg);
+ }
+ case ICDescriptionDelta.CHANGED:{
+// boolean activeCfgChanged = (projectDelta.getChangeFlags() | ICDescriptionDelta.ACTIVE_CFG) != 0;
+ ICConfigurationDescription newCfg = getConfigurationById(newDes, cfgId);
+ ICConfigurationDescription oldCfg = getConfigurationById(oldDes, cfgId);;
+ return getSettingChange(newCfg, oldCfg);
+ }
+ }
+ return null;
+ }
+*/
+ private static ICConfigurationDescription getConfigurationById(ICProjectDescription des, String id){
+ return id.length() != 0 ?
+ des.getConfigurationById(id) :
+ des.getActiveConfiguration();
+ }
+
+ public ICProjectDescription updateReferencedSettings(ICProjectDescription des){
+ CfgDesIterator cfgIter = new CfgDesIterator(des);
+ while(cfgIter.hasNext()){
+ CConfigurationSpecSettings specSettings;
+ try {
+ specSettings = ((IInternalCCfgInfo)cfgIter.next(false)).getSpecSettings();
+ } catch (CoreException e) {
+ continue;
+ }
+ Map map = specSettings.getProjectRefInfoMap();
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ ProjectRefInfo info = (ProjectRefInfo)iter.next();
+ ICConfigurationDescription refDes = getConfiguration(info.getProjectName(), info.getCfgId(), false);
+ if(refDes != null){
+ ICExternalSetting extSettings[] = refDes.getExternalSettings();
+ updateReferencedSettings(cfgIter, info, (ICExternalSetting[])extSettings, null);
+ }
+ }
+
+ }
+ return cfgIter.getProjectDescription();
+ }
+
+ private static ICConfigurationDescription getConfiguration(String projName, String cfgId, boolean write){
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ CoreModel model = CoreModel.getDefault();
+
+ IProject project = root.getProject(projName);
+ if(!project.exists())
+ return null;
+
+ ICProjectDescription des = model.getProjectDescription(project, write);
+ if(des == null)
+ return null;
+
+ return des.getConfigurationById(cfgId);
+}
+
+ private static void updateReferencedSettings(ICfgContainer cr, ProjectRefInfo refInfo, ICExternalSetting newSettings[], ExtSettingsDelta[] deltas){
+ if(!refInfo.isSynchronized()){
+ CExternalSettingProvider provider = refInfo.getProvider();
+ ICExternalSetting oldSettings[] = provider.getExternalSettings();
+ deltas = getSettingChange(newSettings, oldSettings);
+ }
+
+ String refProjName = refInfo.getProjectName();
+ String refCfgId = refInfo.getCfgId();
+// provider.setExternallSetting((CExternalSetting[])newOldSettings[0]);
+
+ refInfo.setSynchronized(true);
+ if(deltas != null && deltas.length != 0){
+
+ CConfigurationDescription writableCfg = (CConfigurationDescription)cr.getConfguration(true);
+ if(writableCfg != null){
+ try {
+ CConfigurationSpecSettings settings = writableCfg.getSpecSettings();
+
+ refInfo = (ProjectRefInfo)settings.getProjectRefInfoMap().get(refProjName);
+ if(refInfo != null && refInfo.getCfgId().equals(refCfgId)){
+ applyDelta(writableCfg, deltas);
+ refInfo.getProvider().setExternallSetting(newSettings);
+ refInfo.setSynchronized(true);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ }
+
+/* private static ICProjectDescription updateReferencedSettings(ICConfigurationDescription des){
+ Map map = des.getReferenceInfo();
+ ICConfigurationDescription refs[] = getReferencedConfigs(map, false);
+ if(refs.length != 0){
+ for(int i = 0; i < refs.length; i++){
+ ICConfigurationDescription ref = refs[i];
+ }
+ }
+ }
+
+ private static ICConfigurationDescription[] getReferencedConfigs(Map map, boolean write){
+ if(map.size() != 0){
+ List list = new ArrayList(map.size());
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String projName = (String)entry.getKey();
+ String cfgId = (String)entry.getValue();
+
+ ICConfigurationDescription refCfgDes = getConfiguration(projName, cfgId, write);
+ if(refCfgDes == null)
+ continue;
+
+ list.add(refCfgDes);
+ }
+
+ if(list.size() != 0){
+ return (ICConfigurationDescription[])list.toArray(new ICConfigurationDescription[list.size()]);
+ }
+ }
+
+ return new ICConfigurationDescription[0];
+ }
+*/
+ private interface ICfgContainer {
+ ICConfigurationDescription getConfguration(boolean write);
+ }
+
+ private static class CfgDesIterator implements ICfgContainer{
+ private ICProjectDescription fProjDes;
+ private ICConfigurationDescription fCurrentDes;
+ private List fCfgList;
+ private Set fProcessedSet = new HashSet();
+ private boolean fWriteStatusChanged;
+
+
+ public CfgDesIterator(ICProjectDescription des){
+ fProjDes = des;
+ fCfgList = new ArrayList(Arrays.asList(fProjDes.getConfigurations()));
+ }
+
+ public boolean isReadOnly(){
+ return fProjDes.isReadOnly();
+ }
+
+ public ICConfigurationDescription next(boolean write){
+ if(fCfgList.isEmpty())
+ throw new NoSuchElementException();
+
+ fCurrentDes = (ICConfigurationDescription)fCfgList.remove(fCfgList.size() - 1);
+ fProcessedSet.add(fCurrentDes.getId());
+ return current(write);
+ }
+
+ public ICConfigurationDescription current(boolean write){
+ if(fCurrentDes == null)
+ return next(write);
+
+ ICConfigurationDescription writableCfg = null;
+ if(write && fCurrentDes.isReadOnly()){
+ fWriteStatusChanged = true;
+ ICProjectDescription wDes = CoreModel.getDefault().getProjectDescription(fProjDes.getProject());
+ if(wDes != null){
+ writableCfg = wDes.getConfigurationById(fCurrentDes.getId());
+ if(writableCfg != null){
+ fCurrentDes = writableCfg;
+ fProjDes = wDes;
+ ICConfigurationDescription dess[] = fProjDes.getConfigurations();
+ fCfgList.clear();
+ for(int i = 0; i < dess.length; i++){
+ if(!fProcessedSet.contains(dess[i].getId())){
+ fCfgList.add(dess[i]);
+ }
+ }
+ }
+ }
+ return writableCfg;
+ }
+ return fCurrentDes;
+ }
+
+ public ICProjectDescription getProjectDescription(){
+ return fProjDes;
+ }
+
+ public boolean hasNext(){
+ return !fCfgList.isEmpty();
+ }
+
+ public boolean isWriteStatusChanged(){
+ return fWriteStatusChanged;
+ }
+
+ public ICConfigurationDescription getConfguration(boolean write) {
+ return current(write);
+ }
+ }
+
+ public void updateDepentents(ICDescriptionDelta projectDelta){
+ if(projectDelta == null)
+ return;
+
+ Map deltaMap = new HashMap();
+ ICProjectDescription newDes = (ICProjectDescription)projectDelta.getNewSetting();
+ ICProjectDescription oldDes = (ICProjectDescription)projectDelta.getOldSetting();
+
+ switch(projectDelta.getDeltaKind()){
+ case ICDescriptionDelta.ADDED:
+ calculateDeltas(newDes, true, deltaMap);
+ break;
+ case ICDescriptionDelta.REMOVED:
+ calculateDeltas(oldDes, false, deltaMap);
+ break;
+ case ICDescriptionDelta.CHANGED:
+ ICDescriptionDelta[] children = projectDelta.getChildren();
+ ICDescriptionDelta child;
+ boolean activeCfgChanged = (projectDelta.getChangeFlags() & ICDescriptionDelta.ACTIVE_CFG) != 0;
+ for(int i = 0; i < children.length; i++){
+ child = children[i];
+ ICConfigurationDescription newCfg = (ICConfigurationDescription)child.getNewSetting();
+// ICConfigurationDescription oldCfg = (ICConfigurationDescription)child.getOldSetting();
+ ExtSettingsDelta deltas[] = ((CProjectDescriptionDelta)child).getExtSettingsDeltas();//getSettingChange(newCfg, oldCfg);
+ if(deltas != null){
+ deltaMap.put(newCfg.getId(), deltas);
+ if(!activeCfgChanged && newCfg.isActive()){
+ deltaMap.put("", deltas);
+ }
+ }
+ }
+
+ if(activeCfgChanged){
+ ICConfigurationDescription newCfg = newDes.getActiveConfiguration();
+ ICConfigurationDescription oldCfg = oldDes.getActiveConfiguration();
+ ExtSettingsDelta deltas[] = getSettingChange(newCfg, oldCfg);
+ if(deltas != null)
+ deltaMap.put("", deltas);
+ }
+ }
+
+ if(deltaMap.size() == 0)
+ return;
+
+ IProject currentProject = ((ICProjectDescription)projectDelta.getSetting()).getProject();
+ String currentProjectName = currentProject.getName();
+ IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+
+ CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
+ for(int i = 0; i < projects.length; i++){
+ IProject proj = projects[i];
+ if(proj.equals(currentProject))
+ continue;
+
+ ICProjectDescription projDes = mngr.getProjectDescription(proj, false);
+ if(projDes == null)
+ continue;
+
+ CfgDesIterator cfgIter = new CfgDesIterator(projDes);
+ while(cfgIter.hasNext()){
+ ICConfigurationDescription cfg = cfgIter.next(false);
+ CConfigurationSpecSettings settings = null;
+ try {
+ settings = ((IInternalCCfgInfo)cfg).getSpecSettings();
+ } catch (CoreException e) {
+ }
+
+ if(settings == null)
+ continue;
+
+ Map map = settings.getProjectRefInfoMap();
+
+ ProjectRefInfo refInfo = (ProjectRefInfo)map.get(currentProjectName);
+ if(refInfo == null)
+ continue;
+
+ String cfgId = refInfo.getCfgId();
+ ExtSettingsDelta deltas[] = null;
+ ICExternalSetting[][] newOldSettings = getNewOldSettings(projectDelta, cfgId);
+ deltas = (ExtSettingsDelta[])deltaMap.get(cfgId);
+
+ updateReferencedSettings(cfgIter, refInfo, (CExternalSetting[])newOldSettings[0], deltas);
+ }
+
+ if(cfgIter.isWriteStatusChanged()){
+ try {
+ mngr.setProjectDescription(proj, cfgIter.getProjectDescription());
+ } catch (CoreException e) {
+ }
+ }
+ }
+ }
+
+
+
+ static class ExtSettingsDelta {
+ ICExternalSetting fSetting;
+ boolean fAdded;
+ KindBasedStore fEntryChangeStore;
+
+ ExtSettingsDelta(ICExternalSetting setting){
+ fSetting = setting;
+ }
+
+ ExtSettingsDelta(ICExternalSetting setting, boolean added){
+ fSetting = setting;
+ fAdded = added;
+ }
+
+ boolean isChange(){
+ return fEntryChangeStore != null;
+ }
+
+ boolean isAdded(){
+ return fAdded;
+ }
+
+ ICExternalSetting getSetting(){
+ return fSetting;
+ }
+
+ ICLanguageSettingEntry[][] getEntriesDelta(int kind){
+ if(fEntryChangeStore != null)
+ return (ICLanguageSettingEntry[][])fEntryChangeStore.get(kind);
+ ICLanguageSettingEntry [] entries = fSetting.getEntries(kind);
+ if(entries == null || entries.length == 0)
+ return null;
+
+ ICLanguageSettingEntry[][] delta = new ICLanguageSettingEntry[2][];
+ if(fAdded)
+ delta[0] = entries;
+ else
+ delta[1] = entries;
+
+ return delta;
+ }
+
+ ICLanguageSettingEntry[][] getEntriesDelta(){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ List added = new ArrayList();
+ List removed = new ArrayList();
+ for(int i = 0; i < kinds.length; i++){
+ ICLanguageSettingEntry[][] d = getEntriesDelta(kinds[i]);
+ if(d == null)
+ continue;
+
+ if(d[0] != null){
+ added.addAll(Arrays.asList(d[0]));
+ }
+ if(d[1] != null){
+ removed.addAll(Arrays.asList(d[1]));
+ }
+ }
+
+ ICLanguageSettingEntry[][] delta = new ICLanguageSettingEntry[2][];
+
+ if(added.size() != 0){
+ delta[0] = (ICLanguageSettingEntry[])added.toArray(new ICLanguageSettingEntry[added.size()]);
+ }
+ if(removed.size() != 0){
+ delta[1] = (ICLanguageSettingEntry[])removed.toArray(new ICLanguageSettingEntry[removed.size()]);
+ }
+
+ return delta;
+ }
+
+
+
+ }
+
+ static class ExtSettingMapKey {
+ private ICExternalSetting fSetting;
+ public ExtSettingMapKey(ICExternalSetting setting){
+ fSetting = setting;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+
+ if(!(obj instanceof ExtSettingMapKey))
+ return false;
+
+ ExtSettingMapKey other = (ExtSettingMapKey)obj;
+ return settingsMatch(fSetting, other.fSetting);
+ }
+ public int hashCode() {
+ return code(fSetting.getCompatibleLanguageIds())
+ + code(fSetting.getCompatibleContentTypeIds())
+ + code(fSetting.getCompatibleExtensions());
+ }
+
+ private int code(String[] arr){
+ if(arr == null || arr.length == 0)
+ return 0;
+
+ int code = 0;
+
+ for(int i = 0; i < arr.length; i++){
+ code += arr[i].hashCode();
+ }
+ return code;
+ }
+
+ public ICExternalSetting getSetting(){
+ return fSetting;
+ }
+
+ }
+/*
+ private static class ExtSettingsComparator extends Comparator{
+ private List fDeltaList = null;
+ private int fKinds[] = KindBasedStore.getSupportedKinds();
+ private Comparator fEntryComparator = new Comparator();
+
+ public boolean equal(Object o1, Object o2) {
+ ICExternalSetting setting1 = (ICExternalSetting)o1;
+ ICExternalSetting setting2 = (ICExternalSetting)o2;
+ if(settingsMatch(setting1, setting2)){
+ int kind;
+ ExtSettingsDelta extDelta = null;
+ for(int i = 0; i < fKinds.length; i++){
+ kind = fKinds[i];
+ ICLanguageSettingEntry entries1[] = setting1.getEntries(kind);
+ ICLanguageSettingEntry entries2[] = setting2.getEntries(kind);
+ List delta[] = ListComparator.compare(entries1, entries2, fEntryComparator);
+ if(delta == null)
+ continue;
+ ICLanguageSettingEntry entries[][] = new ICLanguageSettingEntry[2][];
+ if(delta[0] != null)
+ entries[0] = (ICLanguageSettingEntry[])delta[0].toArray(new ICLanguageSettingEntry[delta[0].size()]);
+ if(delta[1] != null)
+ entries[1] = (ICLanguageSettingEntry[])delta[1].toArray(new ICLanguageSettingEntry[delta[1].size()]);
+
+ if(extDelta == null){
+ extDelta = new ExtSettingsDelta(setting1);
+ extDelta.fEntryChangeStore = new KindBasedStore();
+ if(fDeltaList == null)
+ fDeltaList = new ArrayList();
+ fDeltaList.add(extDelta);
+ }
+
+ extDelta.fEntryChangeStore.put(kind, entries);
+ }
+
+ return true;
+ }
+ return false;
+ }
+ }
+*/
+ private static ExtSettingsDelta createDelta(ICExternalSetting setting1, ICExternalSetting setting2){
+
+ int kind;
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ ExtSettingsDelta extDelta = null;
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ ICLanguageSettingEntry entries1[] = setting1.getEntries(kind);
+ ICLanguageSettingEntry entries2[] = setting2.getEntries(kind);
+ List delta[] = ListComparator.compare(entries1, entries2);
+ if(delta == null)
+ continue;
+ ICLanguageSettingEntry entries[][] = new ICLanguageSettingEntry[2][];
+ if(delta[0] != null)
+ entries[0] = (ICLanguageSettingEntry[])delta[0].toArray(new ICLanguageSettingEntry[delta[0].size()]);
+ if(delta[1] != null)
+ entries[1] = (ICLanguageSettingEntry[])delta[1].toArray(new ICLanguageSettingEntry[delta[1].size()]);
+
+ if(extDelta == null){
+ extDelta = new ExtSettingsDelta(setting1);
+ extDelta.fEntryChangeStore = new KindBasedStore();
+ }
+
+ extDelta.fEntryChangeStore.put(kind, entries);
+ }
+
+ return extDelta;
+
+ }
+
+ static boolean settingsMatch(ICExternalSetting setting1, ICExternalSetting setting2) {
+ if(setting1.equals(setting2))
+ return true;
+
+ return settingsMatch(setting1,
+ setting2.getCompatibleLanguageIds(),
+ setting2.getCompatibleContentTypeIds(),
+ setting2.getCompatibleExtensions());
+ }
+
+ static boolean settingsMatch(ICExternalSetting setting,
+ String languageIDs[], String contentTypeIDs[], String extensions[]){
+ if(!Arrays.equals(setting.getCompatibleLanguageIds(), languageIDs))
+ return false;
+ if(!Arrays.equals(setting.getCompatibleContentTypeIds(), contentTypeIDs))
+ return false;
+ if(!Arrays.equals(setting.getCompatibleExtensions(), extensions))
+ return false;
+
+ return true;
+ }
+
+ private static ExtSettingsDelta[] getSettingChange(ICConfigurationDescription newDes, ICConfigurationDescription oldDes){
+ return getSettingChange(newDes != null ? newDes.getExternalSettings() : null,
+ oldDes != null ? oldDes.getExternalSettings() : null);
+ }
+
+ private static Map toSettingsKeyMap(ICExternalSetting[] settings){
+ Map map = new HashMap();
+ for(int i = 0; i < settings.length; i++){
+ if(map.put(new ExtSettingMapKey(settings[i]), settings[i]) != null)
+ throw new IllegalArgumentException();
+ }
+ return map;
+ }
+
+ private static ExtSettingsDelta[] getSettingChange(ICExternalSetting newSettings[],
+ ICExternalSetting oldSettings[]){
+
+
+ if(newSettings == null || newSettings.length == 0)
+ return createDeltas(oldSettings, false);
+ if(oldSettings == null || oldSettings.length == 0)
+ return createDeltas(newSettings, true);
+
+ List deltaList = new ArrayList();
+
+ Map newMap= toSettingsKeyMap(newSettings);
+ Map oldMap = toSettingsKeyMap(oldSettings);
+ for(Iterator iter = newMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ ICExternalSetting newSetting = (ICExternalSetting)entry.getValue();
+ ICExternalSetting oldSetting = (ICExternalSetting)oldMap.remove(entry.getKey());
+ if(oldSetting == null){
+ deltaList.add(new ExtSettingsDelta(newSetting, true));
+ } else {
+ ExtSettingsDelta delta = createDelta(newSetting, oldSetting);
+ if(delta != null)
+ deltaList.add(delta);
+ }
+ }
+
+ for(Iterator iter = oldMap.values().iterator(); iter.hasNext();){
+ ICExternalSetting oldSettng = (ICExternalSetting)iter.next();
+ deltaList.add(new ExtSettingsDelta(oldSettng, false));
+ }
+
+ if(deltaList.size() == 0)
+ return null;
+ return (ExtSettingsDelta[])deltaList.toArray(new ExtSettingsDelta[deltaList.size()]);
+ }
+
+ private static ExtSettingsDelta[] createDeltas(ICExternalSetting settings[], boolean added){
+ if(settings == null || settings.length == 0)
+ return null;
+
+ ExtSettingsDelta deltas[] = new ExtSettingsDelta[settings.length];
+ for(int i = 0; i < settings.length; i++){
+ deltas[i] = new ExtSettingsDelta(settings[i], added);
+ }
+
+ return deltas;
+ }
+
+ private static List handleProjReferenceAddRemove(CConfigurationDescription des, Map delta, boolean added){
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ List list = new ArrayList();
+ for(Iterator iter = delta.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String projName = (String)entry.getKey();
+ IProject project = (IProject)root.findMember(projName);
+ if(project != null){
+ ICExternalSetting settings[];
+ Object cfgInfo = entry.getValue();
+ ProjectRefInfo info;
+ if(cfgInfo instanceof String){
+ String cfgId = (String)cfgInfo;
+ settings = getExternalSettingsForProjCfg(project, cfgId);
+ info = new ProjectRefInfo(projName, cfgId);
+ info.getProvider().setExternallSetting(settings);
+ } else {
+ info = (ProjectRefInfo)cfgInfo;
+ settings = (info).getProvider().getExternalSettings();
+ }
+ list.add(info);
+ if(settings.length != 0){
+ ExtSettingsDelta deltas[] = new ExtSettingsDelta[settings.length];
+ for(int i = 0; i < deltas.length; i++){
+ deltas[i] = new ExtSettingsDelta(settings[i], added);
+ }
+
+ applyDelta(des, deltas);
+ }
+ }
+ }
+ return list;
+ }
+
+ private static void applyDelta(ICConfigurationDescription des, ExtSettingsDelta deltas[]){
+ ICResourceDescription rcDess[] = des.getResourceDescriptions();
+ for(int i = 0; i < rcDess.length; i++){
+ ICResourceDescription rcDes = rcDess[i];
+ if(rcDes.getType() == ICSettingBase.SETTING_FOLDER){
+ applyDelta((ICFolderDescription)rcDes, deltas);
+ } else {
+ applyDelta((ICFileDescription)rcDes, deltas);
+ }
+ }
+ }
+
+ private static void applyDelta(ICFileDescription des, ExtSettingsDelta deltas[]){
+ ICLanguageSetting setting = des.getLanguageSetting();
+ if(setting == null)
+ return;
+ for(int i = 0; i < deltas.length; i++){
+ if(isSettingCompatible(setting, deltas[i].fSetting)){
+ applyDelta(setting, deltas[i]);
+ }
+ }
+ }
+
+ private static void applyDelta(ICFolderDescription des, ExtSettingsDelta deltas[]){
+ ICLanguageSetting settings[] = des.getLanguageSettings();
+ if(settings == null || settings.length == 0)
+ return;
+
+ ICLanguageSetting setting;
+ for(int k = 0; k < settings.length; k++){
+ setting = settings[k];
+ for(int i = 0; i < deltas.length; i++){
+ if(isSettingCompatible(setting, deltas[i].fSetting)){
+ applyDelta(setting, deltas[i]);
+ }
+ }
+ }
+ }
+
+ private static void applyDelta(ICLanguageSetting setting, ExtSettingsDelta delta){
+ int kinds[] = KindBasedStore.getLanguageEntryKinds();
+ int kind;
+ ICLanguageSettingEntry entries[];
+ ICLanguageSettingEntry diff[][];
+ for(int i = 0; i < kinds.length; i++){
+ kind = kinds[i];
+ diff = delta.getEntriesDelta(kind);
+ if(diff == null)
+ continue;
+
+ entries = setting.getSettingEntries(kind);
+ List list = calculateUpdatedEntries(entries, diff[0], diff[1]);
+
+ if(list != null)
+ setting.setSettingEntries(kind, list);
+ }
+ }
+
+ private static List calculateUpdatedEntries(ICLanguageSettingEntry current[], ICLanguageSettingEntry added[], ICLanguageSettingEntry removed[]){
+ // EntryComparator comparator = new EntryComparator();
+ List toAdd = ListComparator.getAdded(added, current);
+ List toLeave = ListComparator.getAdded(current, removed);
+
+ List result;
+ if(toAdd != null){
+ result = toAdd;
+ if(toLeave != null){
+ toAdd.addAll(toLeave);
+ }
+ } else {
+ result = toLeave;
+ }
+
+ if(result == null)
+ result = new ArrayList(0);
+ return result;
+ }
+
+/* private static ICExternalSetting[] getExternalSettingsForRefMap(Map map){
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ List list = null;
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String projName = (String)entry.getKey();
+ IProject project = (IProject)root.findMember(projName);
+ if(project != null){
+ ICExternalSetting settings[] = getExternalSettingsForProjCfg(project, (String)entry.getValue());
+ if(settings.length != 0){
+ if(list == null)
+ list = new ArrayList();
+ for(int i = 0; i < settings.length; i++){
+ list.add(settings[i]);
+ }
+ }
+ }
+ }
+
+ if(list != null)
+ return (ICExternalSetting[])list.toArray(new ICExternalSetting[list.size()]);
+ return CConfigurationSpecSettings.EMPTY_EXT_SETTINGS_ARRAY;
+ }
+*/
+ private static ICExternalSetting[] getExternalSettingsForProjCfg(IProject project, String cfgId){
+ ICProjectDescription projDes = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ if(projDes != null){
+ ICConfigurationDescription refCfg = cfgId.length() != 0 ?
+ projDes.getConfigurationById(cfgId)
+ : projDes.getActiveConfiguration();
+
+ if(refCfg != null)
+ return refCfg.getExternalSettings();
+ }
+
+ return CExternalSettingProvider.EMPTY_EXT_SETTINGS_ARRAY;
+ }
+
+ private static Map[] calculateReferenceDelta(Map newRef, Map oldRef){
+ Map delta[] = new Map[2];
+ if(newRef != null && newRef.size() != 0){
+ if(oldRef != null && oldRef.size() != 0){
+ Map added = new HashMap();
+ Map removed = new HashMap();
+ for(Iterator iter = newRef.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String proj = (String)entry.getKey();
+ String cfg = (String)entry.getValue();
+ iter.remove();
+
+ ProjectRefInfo oldRefInfo = (ProjectRefInfo)oldRef.remove(proj);
+ if(oldRefInfo != null){
+ String oldCfgId = oldRefInfo.getCfgId();
+ if(!cfg.equals(oldCfgId)){
+ added.put(proj, cfg);
+ removed.put(proj, oldRefInfo);
+ }
+ } else {
+ added.put(proj, cfg);
+ }
+ }
+
+ if(oldRef.size() > 0){
+ for(Iterator iter = oldRef.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String proj = (String)entry.getKey();
+ ProjectRefInfo info = (ProjectRefInfo)entry.getValue();
+ removed.put(proj, info);
+ }
+ }
+
+ delta[0] = added;
+ delta[1] = removed;
+
+ } else {
+ delta[0] = new HashMap(newRef);
+ delta[1] = null;//new HashMap(0);
+ }
+ } else {
+ delta[0] = null;//new HashMap(0);
+ delta[1] = oldRef != null ? new HashMap(oldRef) : null;//new HashMap(0);
+ }
+
+ if(delta[0] != null && delta[0].size() == 0)
+ delta[0] = null;
+ if(delta[1] != null && delta[1].size() == 0)
+ delta[1] = null;
+
+ if(delta[0] == null && delta[1] == null)
+ delta = null;
+
+ return delta;
+ }
+
+ private static boolean isSettingCompatible(ICLanguageSetting setting, ICExternalSetting provider){
+ String ids[] = provider.getCompatibleLanguageIds();
+ String id;
+ if(ids != null && ids.length > 0){
+ id = setting.getLanguageId();
+ if(id != null){
+ if(contains(ids, id))
+ return true;
+ return false;
+ }
+ }
+
+ ids = provider.getCompatibleContentTypeIds();
+ if(ids != null && ids.length > 0){
+ String[] cTypeIds = setting.getSourceContentTypeIds();
+ if(cTypeIds.length != 0){
+ for(int i = 0; i < cTypeIds.length; i++){
+ id = cTypeIds[i];
+ if(contains(ids, id))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ ids = provider.getCompatibleExtensions();
+ if(ids != null && ids.length > 0){
+ String [] srcIds = setting.getSourceExtensions();
+ if(srcIds.length != 0){
+ for(int i = 0; i < srcIds.length; i++){
+ id = srcIds[i];
+ if(contains(ids, id))
+ return true;
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean contains(Object array[], Object value){
+ for(int i = 0; i < array.length; i++){
+ if(array[i].equals(value))
+ return true;
+ }
+ return false;
+ }
+
+ private static int calcRefChangeFlags(ICConfigurationDescription newDes, ICConfigurationDescription oldDes){
+ Map newMap = newDes != null ? newDes.getReferenceInfo() : null;
+ Map oldMap = oldDes != null ? oldDes.getReferenceInfo() : null;
+
+ int flags = 0;
+ if(newMap == null || newMap.size() == 0){
+ if(oldMap != null && oldMap.size() != 0){
+ flags = ICDescriptionDelta.CFG_REF_REMOVED;
+ }
+ } else {
+ if(oldMap == null || oldMap.size() == 0){
+ flags = ICDescriptionDelta.CFG_REF_ADDED;
+ } else {
+ boolean stop = false;
+ for(Iterator iter = newMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry newEntry = (Map.Entry)iter.next();
+ Object newProj = newEntry.getKey();
+ Object newCfg = newEntry.getValue();
+ Object oldCfg = oldMap.remove(newProj);
+ if(!newCfg.equals(oldCfg)){
+ flags |= ICDescriptionDelta.CFG_REF_ADDED;
+ if(oldCfg != null){
+ flags |= ICDescriptionDelta.CFG_REF_REMOVED;
+ stop = true;
+ }
+ if(stop)
+ break;
+ }
+ }
+
+ if(!oldMap.isEmpty())
+ flags |= ICDescriptionDelta.CFG_REF_REMOVED;
+ }
+ }
+
+ return flags;
+ }
+
+ void calculateCfgExtSettingsDelta(CProjectDescriptionDelta delta){
+ ICConfigurationDescription newDes = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription oldDes = (ICConfigurationDescription)delta.getOldSetting();
+ ExtSettingsDelta[] deltas = getSettingChange(newDes, oldDes);
+ int flags = 0;
+ int addedRemoved = ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED | ICDescriptionDelta.EXTERNAL_SETTINGS_REMOVED;
+ if(deltas != null ){
+ for(int i = 0; i < deltas.length; i++){
+ ICLanguageSettingEntry[][] d = deltas[i].getEntriesDelta();
+ if(d[0] != null)
+ flags |= ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED;
+ if(d[1] != null)
+ flags |= ICDescriptionDelta.EXTERNAL_SETTINGS_REMOVED;
+
+ if((flags & (addedRemoved)) == addedRemoved)
+ break;
+ }
+ delta.setExtSettingsDeltas(deltas);
+ if(flags != 0)
+ delta.addChangeFlags(flags);
+ }
+
+ int cfgRefFlags = calcRefChangeFlags(newDes, oldDes);
+ if(cfgRefFlags != 0)
+ delta.addChangeFlags(cfgRefFlags);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataProxyContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataProxyContainer.java
new file mode 100644
index 00000000000..7913aba7247
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataProxyContainer.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+
+interface ICDataProxyContainer extends ICSettingContainer {
+ void updateChild(CDataProxy child, boolean write);
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataScope.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataScope.java
new file mode 100644
index 00000000000..cf2ccebbd7f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDataScope.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+public interface ICDataScope{
+ CDataObject[] getChildren();
+
+ boolean isStatic();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDescriptionDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDescriptionDelta.java
new file mode 100644
index 00000000000..d86115f3499
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICDescriptionDelta.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+
+public interface ICDescriptionDelta {
+ int REMOVED = 1;
+ int ADDED = 2;
+ int CHANGED = 3;
+
+ int ACTIVE_CFG = 1;
+ int NAME = 1 << 1;
+ int DESCRIPTION = 1 << 2;
+// int PATH = 1 << 3;
+ int LANGUAGE_ID = 1 << 4;
+ int SOURCE_CONTENT_TYPE = 1 << 5;
+ int SOURCE_ENTENSIONS = 1 << 6;
+// int HEADER_CONTENT_TYPE = 1 << 7;
+// int HEADER_ENTENSIONS = 1 << 8;
+ int SETTING_ENTRIES = 1 << 9;
+ int BINARY_PARSER_IDS = 1 << 10;
+ int ERROR_PARSER_IDS = 1 << 11;
+ int EXCLUDE = 1 << 12;
+ int SOURCE_ADDED = 1 << 13;
+ int SOURCE_REMOVED = 1 << 14;
+ int EXTERNAL_SETTINGS_ADDED = 1 << 15;
+ int EXTERNAL_SETTINGS_REMOVED = 1 << 16;
+ int CFG_REF_ADDED = 1 << 17;
+ int CFG_REF_REMOVED = 1 << 18;
+ int EXT_REF = 1 << 19;
+ int OWNER = 1 << 20;
+ int INDEX_CFG = 1 << 21;
+
+
+ int getDeltaKind();
+
+ int getChangeFlags();
+
+ int getSettingType();
+
+ int getAddedEntriesKinds();
+
+ int getRemovedEntriesKinds();
+
+ int getReorderedEntriesKinds();
+
+ ICDescriptionDelta[] getChildren();
+
+ ICSettingObject getNewSetting();
+
+ ICSettingObject getSetting();
+
+ ICSettingObject getOldSetting();
+
+ ICDescriptionDelta getParent();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionListener.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionListener.java
new file mode 100644
index 00000000000..06ff6b3559f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionListener.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+public interface ICProjectDescriptionListener {
+ void handleEvent(CProjectDescriptionEvent event);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICachedData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICachedData.java
new file mode 100644
index 00000000000..349dff5356b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICachedData.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+interface ICachedData {
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IDataProvider.java
new file mode 100644
index 00000000000..11fd6c0c0f5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IDataProvider.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+public interface IDataProvider {
+ CDataObject getData(boolean write);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IExternalSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IExternalSettingsProvider.java
new file mode 100644
index 00000000000..e20b4903956
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IExternalSettingsProvider.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+
+
+
+public interface IExternalSettingsProvider {
+ String getId();
+
+ ICExternalSetting[] getExternalSettings(ICConfigurationDescription des);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalCCfgInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalCCfgInfo.java
new file mode 100644
index 00000000000..34c61d7a718
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalCCfgInfo.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.core.runtime.CoreException;
+
+public interface IInternalCCfgInfo {
+ CConfigurationSpecSettings getSpecSettings() throws CoreException;
+
+ CConfigurationData getConfigurationData(boolean write) throws WriteAccessException;
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalResourceDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalResourceDescription.java
new file mode 100644
index 00000000000..816039f2950
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IInternalResourceDescription.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.runtime.IPath;
+
+interface IInternalResourceDescription extends ICResourceDescription{
+ IPath getCachedPath();
+
+ void setPathContainer(PathSettingsContainer cr);
+
+ PathSettingsContainer getPathContainer();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyCache.java
new file mode 100644
index 00000000000..000e665d7ca
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyCache.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+public interface IProxyCache {
+ CDataProxy[] getCachedProxies();
+
+ Map getCachedProxiesMap();
+
+ CDataProxy getCachedProxy(String id);
+
+ CDataProxy getCachedProxy(CDataObject data);
+
+// Object addCachedProxy(CDataProxy proxy);
+
+ void addCachedProxy(CDataProxy proxy);
+
+ void removeCachedProxy(CDataProxy proxy);
+
+ void removeCachedProxy(String id);
+
+// void clearInvalidCachedProxies();
+
+ void clear();
+
+// Map reuseProxies(List dataList, Map freeProxyMap);
+
+// void cacheScope(IDataScope scope);
+// boolean presentsScope(IDataScope scope);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyFactory.java
new file mode 100644
index 00000000000..123d96a021a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyFactory.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+
+public interface IProxyFactory {
+ CDataProxy createProxy(CDataObject data);
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyProvider.java
new file mode 100644
index 00000000000..0679f9c43b8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/IProxyProvider.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+
+public interface IProxyProvider {
+ CDataProxy getProxy(String id);
+
+ CDataProxy getProxy(CDataObject data);
+
+ void removeCachedProxy(String id);
+
+ void removeCachedProxy(CDataProxy proxy);
+
+ CDataProxy[] getProxies();
+
+ CDataProxy[] getProxiesOfKind(int kind);
+
+ CDataProxy[] getCachedProxies();
+
+ void cacheValues();
+/*
+ CDataProxy[] getProxies(Class arrayElClass);
+
+ CDataProxy[] getProxiesOfKind(int kind, Class arrayElClass);
+
+ CDataProxy[] getCachedProxies(Class arrayElClass);
+*/
+// IDataProvider getDataProvider();
+
+// IProxyCache getProxyCache();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/InternalXmlStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/InternalXmlStorageElement.java
new file mode 100644
index 00000000000..8c7a37da770
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/InternalXmlStorageElement.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.util.XmlStorageElement;
+import org.w3c.dom.Element;
+
+public class InternalXmlStorageElement extends XmlStorageElement {
+ boolean fIsDirty;
+ Element fElement;
+ private boolean fIsReadOnly;
+ private List fStorageList;
+
+ public InternalXmlStorageElement(Element element, ICStorageElement parent,
+ boolean alowReferencingParent, String[] attributeFilters,
+ String[] childFilters, boolean readOnly) {
+ super(element, parent, alowReferencingParent, attributeFilters, childFilters);
+ fElement = element;
+ fIsReadOnly = readOnly;
+ }
+
+ public InternalXmlStorageElement(Element element, ICStorageElement parent,
+ boolean alowReferencingParent, boolean readOnly) {
+ super(element, parent, alowReferencingParent);
+ fElement = element;
+ fIsReadOnly = readOnly;
+ }
+
+ public InternalXmlStorageElement(Element element, boolean readOnly) {
+ super(element);
+ fElement = element;
+ fIsReadOnly = readOnly;
+ }
+
+ void storageCreated(CStorage storage){
+ List list = getStorageList(true);
+ list.add(storage);
+ }
+
+ private List getStorageList(boolean create){
+ if(fStorageList == null && create)
+ fStorageList = new ArrayList();
+ return fStorageList;
+ }
+
+ public boolean isReadOnly(){
+ return fIsReadOnly;
+ }
+
+ public void setReadOnly(boolean readOnly){
+ fIsReadOnly = readOnly;
+
+ ICStorageElement children[] = getChildren();
+ for(int i = 0; i < children.length; i++){
+ ((InternalXmlStorageElement)children[i]).setReadOnly(readOnly);
+ }
+
+ }
+
+ public boolean isDirty(){
+ if(fIsDirty)
+ return true;
+
+ List list = getStorageList(false);
+ if(list != null){
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ CStorage storage = (CStorage)iter.next();
+ if(storage.isDirty())
+ return true;
+ }
+ }
+
+ ICStorageElement children[] = getChildren();
+ for(int i = 0; i < children.length; i++){
+ if(((InternalXmlStorageElement)children[i]).isDirty())
+ return true;
+ }
+
+ return false;
+ }
+
+ public void setDirty(boolean dirty){
+ fIsDirty = dirty;
+
+ if(!dirty){
+ List list = getStorageList(false);
+ if(list != null){
+ for(Iterator iter = list.iterator(); iter.hasNext();){
+ CStorage storage = (CStorage)iter.next();
+ storage.setDirty(false);
+ }
+ }
+
+ ICStorageElement children[] = getChildren();
+ for(int i = 0; i < children.length; i++){
+ ((InternalXmlStorageElement)children[i]).setDirty(false);
+ }
+ }
+ }
+
+ public void clear() {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ super.clear();
+ fIsDirty = true;
+ }
+
+ protected XmlStorageElement createChild(Element element,
+ boolean alowReferencingParent, String[] attributeFilters,
+ String[] childFilters) {
+/* if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+*/
+ return new InternalXmlStorageElement(element, this, alowReferencingParent, attributeFilters, childFilters, fIsReadOnly);
+ }
+
+ public ICStorageElement createChild(String name,
+ boolean alowReferencingParent, String[] attributeFilters,
+ String[] childFilters) {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ fIsDirty = true;
+ return super.createChild(name, alowReferencingParent, attributeFilters,
+ childFilters);
+ }
+
+ public ICStorageElement createChild(String name) {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ fIsDirty = true;
+ return super.createChild(name);
+ }
+
+ public void removeAttribute(String name) {
+ fIsDirty = true;
+ super.removeAttribute(name);
+ }
+
+ public void setAttribute(String name, String value) {
+ fIsDirty = true;
+ super.setAttribute(name, value);
+ }
+
+ public void setValue(String value) {
+ fIsDirty = true;
+ super.setValue(value);
+ }
+
+ protected void removed() {
+ super.removed();
+ }
+
+ public ICStorageElement importChild(ICStorageElement el)
+ throws UnsupportedOperationException {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ fIsDirty = true;
+ return super.importChild(el);
+ }
+
+ public void removeChild(ICStorageElement el) {
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ fIsDirty = true;
+ super.removeChild(el);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java
new file mode 100644
index 00000000000..3bda8fc6e92
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+public class MapProxyCache implements IProxyCache {
+ private HashMap fMap;
+
+ private HashMap getMap(boolean create){
+ if(fMap == null && create)
+ fMap = new HashMap();
+ return fMap;
+ }
+
+ public CDataProxy[] getCachedProxies() {
+ Map map = getMap(false);
+ if(map != null){
+ Collection c = map.values();
+ return (CDataProxy[])c.toArray(new CDataProxy[c.size()]);
+ }
+ return new CDataProxy[0];
+ }
+
+ public CDataProxy getCachedProxy(String id) {
+ Map map = getMap(false);
+ if(map != null)
+ return (CDataProxy)map.get(id);
+ return null;
+ }
+
+ public void removeCachedProxy(String id) {
+ Map map = getMap(false);
+ if(map != null)
+ map.remove(id);
+ }
+
+ public void clear() {
+ fMap.clear();
+ }
+
+ public void addCachedProxy(CDataProxy proxy) {
+ getMap(true).put(proxy.getId(), proxy);
+ }
+
+ public Map getCachedProxiesMap() {
+ return (Map)getMap(true).clone();
+ }
+
+ public CDataProxy getCachedProxy(CDataObject data) {
+ return getCachedProxy(data.getId());
+ }
+
+ public void removeCachedProxy(CDataProxy proxy) {
+ removeCachedProxy(proxy.getId());
+ }
+
+ public void reuseProxies(List dataList, Map freeProxyMap) {
+ }
+}
+
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java
new file mode 100644
index 00000000000..eb543c22690
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java
@@ -0,0 +1,310 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.cdt.core.settings.model.extension.CFileData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFileData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFolderData;
+import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.EntryStore;
+import org.eclipse.cdt.core.settings.model.util.PathEntryResolveInfo;
+import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator;
+import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.ReferenceSettingsInfo;
+import org.eclipse.cdt.internal.core.model.CModelManager;
+import org.eclipse.cdt.internal.core.model.PathEntryManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+public class PathEntryConfigurationDataProvider extends
+ CConfigurationDataProvider {
+ private static PathEntryDataFactory fFactory;
+
+
+ public static CDataFacroty getDataFactory(){
+ if(fFactory == null){
+ fFactory = new PathEntryDataFactory();
+ }
+ return fFactory;
+ }
+
+ public PathEntryConfigurationDataProvider(){
+ getDataFactory();
+ }
+
+ private static class PathEntryFolderData extends CDefaultFolderData {
+ private EntryStore fStore;
+
+// public PathEntryFolderData(CConfigurationData cfg, CDataFacroty factory) {
+// super(cfg, factory);
+// }
+
+// public PathEntryFolderData(String id, IPath path,
+// CConfigurationData cfg, CDataFacroty factory) {
+// super(id, path, cfg, factory);
+// }
+
+ public PathEntryFolderData(String id, IPath path, PathEntryFolderData base,
+ CConfigurationData cfg, CDataFacroty factory, boolean clone) {
+ super(id, path, cfg, factory);
+
+ if(base != null)
+ fStore = new EntryStore(base.fStore, true);
+ else
+ fStore = new EntryStore(true);
+
+ copyDataFrom(base, clone);
+ }
+ }
+
+ private static class PathEntryFileData extends CDefaultFileData {
+ private EntryStore fStore;
+
+// public PathEntryFileData(CConfigurationData cfg, CDataFacroty factory) {
+// super(cfg, factory);
+// }
+
+// public PathEntryFileData(String id, IPath path, CConfigurationData cfg,
+// CDataFacroty factory) {
+// super(id, path, cfg, factory);
+// }
+
+ public PathEntryFileData(String id, IPath path, PathEntryFileData base,
+ CConfigurationData cfg, CDataFacroty factory, boolean clone) {
+ super(id, path, cfg, factory);
+
+ fStore = new EntryStore(base.fStore, true);
+
+ copyDataFrom(base, clone);
+ }
+
+ public PathEntryFileData(String id, IPath path, PathEntryFolderData base,
+ CLanguageData baseLangData, CConfigurationData cfg,
+ CDataFacroty factory) {
+ super(id, path, cfg, factory);
+
+ fStore = new EntryStore(base.fStore, true);
+
+ copyDataFrom(base, baseLangData);
+ }
+
+ }
+
+ private static class PathEntryLanguageData extends CDefaultLanguageData {
+
+ public PathEntryLanguageData(String id, CLanguageData base, EntryStore store) {
+ fId = id;
+ fStore = store;
+ copySettingsFrom(base);
+ }
+
+ public PathEntryLanguageData(String id, String languageId,
+ String[] ids, boolean isContentTypes, EntryStore store) {
+ super(id, languageId, ids, isContentTypes);
+ fStore = store;
+ }
+
+ protected EntryStore createStore() {
+ return fStore;
+ }
+
+ protected EntryStore createStore(CLanguageData data) {
+ return fStore;
+ }
+
+ }
+
+ private static class PathEntryDataFactory extends CDataFacroty {
+
+ public CConfigurationData createConfigurationdata(String id,
+ String name, CConfigurationData base, boolean clone) {
+ if(clone){
+ id = base.getId();
+ } else if(id == null){
+ id = CDataUtil.genId(null);
+ }
+
+ return new CfgData(id, name, base, clone);
+ }
+
+ public CFileData createFileData(CConfigurationData cfg,
+ CResourceData base, CLanguageData base2, boolean clone,
+ IPath path) {
+ String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ if(base.getType() == ICSettingBase.SETTING_FILE)
+ return new PathEntryFileData(id, path, (PathEntryFileData)base, cfg, this, clone);
+ return new PathEntryFileData(id, path, (PathEntryFolderData)base,
+ base2, cfg, this);
+ }
+
+ public CFolderData createFolderData(CConfigurationData cfg,
+ CFolderData base, boolean clone, IPath path) {
+ String id = clone ? base.getId() : CDataUtil.genId(cfg.getId());
+ return new PathEntryFolderData(id, path, (PathEntryFolderData)base, cfg, this, clone);
+ }
+
+ public CLanguageData createLanguageData(CConfigurationData cfg,
+ CResourceData rcBase, CLanguageData base, boolean clone) {
+ String id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
+ EntryStore store;
+ if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
+ store = ((PathEntryFolderData)rcBase).fStore;
+ else
+ store = ((PathEntryFileData)rcBase).fStore;
+ return new PathEntryLanguageData(id, base, store);
+ }
+
+ public CLanguageData createLanguageData(CConfigurationData cfg,
+ CResourceData rcBase, String languageId, String[] rcTypes,
+ boolean isContentTypes) {
+ EntryStore store;
+ if(rcBase.getType() == ICSettingBase.SETTING_FOLDER)
+ store = ((PathEntryFolderData)rcBase).fStore;
+ else
+ store = ((PathEntryFileData)rcBase).fStore;
+ return new PathEntryLanguageData(CDataUtil.genId(rcBase.getId()), languageId, rcTypes, isContentTypes, store);
+ }
+
+ }
+
+ private static class CfgData extends CDefaultConfigurationData {
+// private PathEntryResolveInfo fResolveInfo;
+
+ public CfgData(String id, String name, CConfigurationData base, boolean clone) {
+ super(id, name, base, fFactory, clone);
+ }
+
+ public CfgData(String id, String name) {
+ super(id, name, fFactory);
+ }
+
+// public PathEntryResolveInfo getResolveInfo(){
+// return fResolveInfo;
+// }
+//
+// public void setResolveInfo(PathEntryResolveInfo info){
+// fResolveInfo = info;
+// }
+ }
+
+ public static boolean isPathEntryData(CConfigurationData data){
+ return data instanceof CfgData;
+ }
+
+ public CConfigurationData applyConfiguration(
+ ICConfigurationDescription des, CConfigurationData base)
+ throws CoreException {
+ //TODO: check external/reference info here as well.
+ if(!fFactory.isModified(base))
+ return base;
+
+
+
+ IProject project = des.getProjectDescription().getProject();
+ ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des);
+ IPathEntry entries[] = PathEntryTranslator.getPathEntries(project, base, refInfo, PathEntryTranslator.INCLUDE_USER);
+ CModelManager manager = CModelManager.getDefault();
+ ICProject cproject = manager.create(project);
+ IPathEntry[] curRawEntries = PathEntryManager.getDefault().getRawPathEntries(cproject);
+
+ List list = new ArrayList();
+ list.addAll(Arrays.asList(entries));
+ for(int i = 0; i < curRawEntries.length; i++){
+ if(curRawEntries[i].getEntryKind() == IPathEntry.CDT_CONTAINER){
+ list.add(curRawEntries[i]);
+ }
+ }
+
+ IPathEntry[] newEntries = (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
+ PathEntryManager.getDefault().setRawPathEntries(cproject, newEntries, new NullProgressMonitor());
+ return createData(des);
+ }
+
+ public CConfigurationData createConfiguration(
+ ICConfigurationDescription des, CConfigurationData base,
+ boolean clone) throws CoreException {
+ CfgData copy = new CfgData(des.getId(), des.getName(), base, clone);
+ copy.setModified(false);
+ return copy;
+ }
+
+ private CfgData createData(ICConfigurationDescription des) throws CoreException{
+ IProject project = des.getProjectDescription().getProject();
+ CModelManager manager = CModelManager.getDefault();
+ ICProject cproject = manager.create(project);
+ PathEntryResolveInfo rInfo = PathEntryManager.getDefault().getResolveInfo(cproject);
+
+ CfgData data = new CfgData(des.getId(), des.getName());
+ data.initEmptyData();
+ CProjectDescriptionManager.getInstance().adjustDefaultConfig(data);
+
+// data.setResolveInfo(rInfo);
+ PathEntryTranslator tr = new PathEntryTranslator(project, data);
+ ReferenceSettingsInfo refInfo = tr.applyPathEntries(rInfo, PathEntryTranslator.OP_REPLACE);
+ ICExternalSetting extSettings[] = refInfo.getExternalSettings();
+ des.removeExternalSettings();
+ if(extSettings.length != 0){
+ ICExternalSetting setting;
+ for(int i = 0; i < extSettings.length; i++){
+ setting = extSettings[i];
+ des.createExternalSetting(setting.getCompatibleLanguageIds(),
+ setting.getCompatibleContentTypeIds(),
+ setting.getCompatibleExtensions(),
+ setting.getEntries());
+ }
+ }
+
+// IPath projPaths[] = refInfo.getReferencedProjectsPaths();
+// if(projPaths.length != 0){
+// Map map = new HashMap(projPaths.length);
+// for(int i = 0; i < projPaths.length; i++){
+// map.put(projPaths[i].segment(0), ""); //$NON-NLS-1$
+// }
+// des.setReferenceInfo(map);
+// }
+
+ cproject.close();
+
+ data.setModified(false);
+ return data;
+ }
+
+ public CConfigurationData loadConfiguration(ICConfigurationDescription des)
+ throws CoreException {
+ return createData(des);
+ }
+
+ public void removeConfiguration(ICConfigurationDescription des,
+ CConfigurationData data) {
+ //do nothing for now
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProjectRefInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProjectRefInfo.java
new file mode 100644
index 00000000000..241c43e31af
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProjectRefInfo.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+
+class ProjectRefInfo {
+ private final static String ATTRIBUTE_REF_PROJECT = "project"; //$NON-NLS-1$
+ private final static String ATTRIBUTE_REF_CFG_ID = "configuration"; //$NON-NLS-1$
+ final static String ELEMENT_REFERENCE = "reference"; //$NON-NLS-1$
+ private String fProjectName;
+ private String fCfgId;
+ private CExternalSettingProvider fProvider;
+ private boolean fIsSynchronized;
+
+ ProjectRefInfo(ICStorageElement el){
+ fProjectName = el.getAttribute(ATTRIBUTE_REF_PROJECT);
+ fCfgId = el.getAttribute(ATTRIBUTE_REF_CFG_ID);
+ if(fCfgId == null)
+ fCfgId = ""; //$NON-NLS-1$
+
+ ICStorageElement children[] = el.getChildren();
+ for(int i = 0; i < children.length; i++){
+ ICStorageElement child = children[i];
+ String name = child.getName();
+ if(CExternalSettingProvider.ELEMENT_EXT_SETTINGS_CONTAINER.equals(name)){
+ fProvider = new CExternalSettingProvider(child);
+ }
+ }
+ }
+
+ ProjectRefInfo(String projName, String cfgId){
+ fProjectName = projName;
+ fCfgId = cfgId;
+ }
+
+ ProjectRefInfo(ProjectRefInfo base){
+ fProjectName = base.fProjectName;
+ fCfgId = base.fCfgId;
+
+ if(base.fProvider != null)
+ fProvider = new CExternalSettingProvider(base.fProvider);
+
+ fIsSynchronized = base.fIsSynchronized;
+ }
+
+ void serialize(ICStorageElement element){
+ element.setAttribute(ATTRIBUTE_REF_PROJECT, fProjectName);
+ if(fCfgId.length() != 0)
+ element.setAttribute(ATTRIBUTE_REF_CFG_ID, fCfgId);
+
+ if(fProvider != null){
+ ICStorageElement child = element.createChild(CExternalSettingProvider.ELEMENT_EXT_SETTINGS_CONTAINER);
+ fProvider.serialize(child);
+ }
+ }
+
+ public String getProjectName() {
+ return fProjectName;
+ }
+
+ public String getCfgId() {
+ return fCfgId;
+ }
+
+ public CExternalSettingProvider getProvider() {
+ if(fProvider == null)
+ fProvider = new CExternalSettingProvider();
+ return fProvider;
+ }
+
+ public void setProvider(CExternalSettingProvider provider) {
+ fProvider = provider;
+ }
+
+ public boolean isSynchronized(){
+ return fIsSynchronized;
+ }
+
+ public void setSynchronized(boolean s){
+ fIsSynchronized = s;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProviderBasedRcDesHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProviderBasedRcDesHolder.java
new file mode 100644
index 00000000000..b762287824a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProviderBasedRcDesHolder.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+
+public class ProviderBasedRcDesHolder extends ResourceDescriptionHolder {
+ private IProxyProvider fProvider;
+
+ public ProviderBasedRcDesHolder(IProxyProvider provider, PathSettingsContainer pathContainer, boolean includeCurrent) {
+ super(pathContainer, includeCurrent);
+ fProvider = provider;
+ }
+
+ public ICResourceDescription getResourceDescription(IPath path, boolean exactPath){
+ fProvider.cacheValues();
+ return super.getResourceDescription(path, exactPath);
+ }
+
+ public void addResourceDescription(IPath path, ICResourceDescription des){
+ fProvider.cacheValues();
+ super.addResourceDescription(path, des);
+ }
+
+ public ICResourceDescription[] getResourceDescriptions(final int kind){
+ fProvider.cacheValues();
+ return super.getResourceDescriptions(kind);
+ }
+
+ public ICResourceDescription getCurrentResourceDescription() {
+ fProvider.cacheValues();
+ return super.getCurrentResourceDescription();
+ }
+
+ public ICResourceDescription[] getResourceDescriptions() {
+ fProvider.cacheValues();
+ return super.getResourceDescriptions();
+ }
+
+ public ICResourceDescription[] getDirectChildren() {
+ fProvider.cacheValues();
+ return super.getDirectChildren();
+ }
+
+ public ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, IPath[] paths) {
+ fProvider.cacheValues();
+ return super.calculateSourceEntriesFromPaths(project, paths);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProxyProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProxyProvider.java
new file mode 100644
index 00000000000..15ec1cd4c5c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ProxyProvider.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.extension.CDataObject;
+
+
+public class ProxyProvider implements IProxyProvider {
+ private IProxyCache fCache;
+ private ICDataScope fScope;
+ private IProxyFactory fFactory;
+ private boolean fProxiesCached;
+
+ public ProxyProvider(ICDataScope scope, IProxyCache cache, IProxyFactory factory){
+ fScope = scope;
+ fCache = cache;
+ fFactory = factory;
+ }
+
+ public CDataProxy[] getProxies() {
+ if(!fProxiesCached || !fScope.isStatic()){
+ fillCache();
+ fProxiesCached = true;
+ }
+ return fCache.getCachedProxies();
+ }
+/*
+ private void clearInvalidCachedProxies(){
+ CDataProxy proxies[] = fCache.getCachedProxies();
+ for(int i = 0; i < proxies.length; i++){
+ if(!proxies[i].isValid()){
+ fCache.removeCachedProxy(proxies[i]);
+ }
+ }
+ }
+*/
+ public CDataProxy getProxy(String id) {
+ if(!fProxiesCached || !fScope.isStatic()){
+ fillCache();
+ fProxiesCached = true;
+ }
+ return fCache.getCachedProxy(id);
+ }
+
+ protected void fillCache(){
+ Map map = fCache.getCachedProxiesMap();
+
+ CDataObject datas[] =fScope.getChildren();
+ for(int i = 0; i < datas.length; i++){
+ CDataObject data = datas[i];
+ CDataProxy proxy = fCache.getCachedProxy(data.getId());
+ if(proxy == null || proxy.getType() != data.getType()){
+ proxy = fFactory.createProxy(data);
+ if(proxy != null){
+ fCache.addCachedProxy(proxy);
+ }
+ } else {
+ proxy.setData(data);
+ map.remove(data.getId());
+ }
+ }
+
+ if(!map.isEmpty()){
+ for(Iterator iter = map.values().iterator(); iter.hasNext();){
+ fCache.removeCachedProxy((CDataProxy)iter.next());
+ }
+ }
+ }
+
+ public CDataProxy getProxy(CDataObject data) {
+ if(!fProxiesCached || !fScope.isStatic()){
+ fillCache();
+ fProxiesCached = true;
+ }
+ return fCache.getCachedProxy(data);
+ }
+
+ public void removeCachedProxy(String id) {
+ fCache.removeCachedProxy(id);
+ fProxiesCached = true;
+ }
+
+ public void removeCachedProxy(CDataProxy proxy) {
+ fCache.removeCachedProxy(proxy);
+ fProxiesCached = true;
+ }
+
+ public CDataProxy[] getCachedProxies() {
+ return fCache.getCachedProxies();
+ }
+
+ public CDataProxy[] getProxiesOfKind(int kind) {
+ CDataProxy[] proxies = getProxies();
+ if(proxies.length > 0){
+ CDataProxy[] tmp = new CDataProxy[proxies.length];
+ int num = 0;
+ for(int i = 0; i < proxies.length; i++){
+ CDataProxy proxy = proxies[i];
+ if((proxy.getType() & kind) == proxy.getType())
+ tmp[num++] = proxy;
+ }
+
+ if(num != proxies.length){
+ proxies = new CDataProxy[num];
+ System.arraycopy(tmp, 0, proxies, 0, num);
+ }
+ }
+ return proxies;
+ }
+
+ public void cacheValues() {
+ if(!fProxiesCached || !fScope.isStatic()){
+ fillCache();
+ fProxiesCached = true;
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java
new file mode 100644
index 00000000000..85faa088462
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
+import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+public class ResourceDescriptionHolder {
+ private PathSettingsContainer fPathSettingContainer;
+ private boolean fIncludeCurrent;
+
+ public ResourceDescriptionHolder(PathSettingsContainer pathContainer,
+ boolean includeCurrent){
+ fPathSettingContainer = pathContainer;
+ fIncludeCurrent = includeCurrent;
+ }
+
+ public ICResourceDescription getResourceDescription(IPath path, boolean exactPath){
+ PathSettingsContainer container = fPathSettingContainer.getChildContainer(path, false, exactPath);
+ if(container != null)
+ return (ICResourceDescription)container.getValue();
+ return null;
+ }
+
+ public IPath getCurrentPath(){
+ return fPathSettingContainer.getPath();
+ }
+
+ public void setCurrentPath(IPath path){
+ //TODO: do we need to move choldren here?
+ fPathSettingContainer.setPath(path, true);
+ }
+
+ public void addResourceDescription(IPath path, ICResourceDescription des){
+ PathSettingsContainer container = fPathSettingContainer.getChildContainer(path, true, true);
+ container.setValue(des);
+ }
+
+ public ICResourceDescription[] getResourceDescriptions(final int kind){
+ final List list = new ArrayList();
+ fPathSettingContainer.accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ ICResourceDescription des = (ICResourceDescription)container.getValue();
+ if((container != fPathSettingContainer || fIncludeCurrent)
+ && (kind & des.getType()) == des.getType()){
+ list.add(des);
+ }
+ return true;
+ }
+
+ });
+
+ if(kind == ICSettingBase.SETTING_FILE)
+ return (ICFileDescription[])list.toArray(new ICFileDescription[list.size()]);
+ else if(kind == ICSettingBase.SETTING_FOLDER)
+ return (ICFolderDescription[])list.toArray(new ICFolderDescription[list.size()]);
+
+ return (ICResourceDescription[])list.toArray(new ICResourceDescription[list.size()]);
+ }
+
+ public ICResourceDescription[] getResourceDescriptions(){
+ final List list = new ArrayList();
+ fPathSettingContainer.accept(new IPathSettingsContainerVisitor(){
+
+ public boolean visit(PathSettingsContainer container) {
+ list.add(container.getValue());
+ return true;
+ }
+
+ });
+ return (ICResourceDescription[])list.toArray(new ICResourceDescription[list.size()]);
+ }
+
+ public void removeResurceDescription(IPath path){
+ fPathSettingContainer.removeChildContainer(path);
+ }
+
+ public ICResourceDescription getCurrentResourceDescription(){
+ return (ICResourceDescription)fPathSettingContainer.getValue();
+ }
+
+ public ICResourceDescription[] getDirectChildren(){
+ PathSettingsContainer dc[] = fPathSettingContainer.getDirectChildren();
+ ICResourceDescription rcDess[] = new ICResourceDescription[dc.length];
+
+ for(int i = 0; i < dc.length; i++){
+ rcDess[i] = (ICResourceDescription)dc[i].getValue();
+ }
+
+ return rcDess;
+ }
+
+ public ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, IPath paths[]){
+ if(paths == null || paths.length == 0)
+ paths = new IPath[]{new Path("")};
+
+// Set set = new HashSet(paths.length);
+ PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
+ IPath pi, pj;
+ List entriesList = new ArrayList(paths.length);
+ IPath projPath = project != null ? project.getFullPath() : null;
+
+ for(int i = 0; i < paths.length; i++){
+ pi = paths[i];
+// set.clear();
+ cr.removeChildren();
+ cr.setValue(null);
+ for(int j = 0; j < paths.length; j++){
+ pj = paths[j];
+ if(pi != pj && pi.isPrefixOf(pj)){
+// set.add(pj);
+ cr.getChildContainer(pj, true, true);
+ }
+ }
+
+ PathSettingsContainer children[] = fPathSettingContainer.getDirectChildrenForPath(pi);
+ for(int k = 0; k < children.length; k++){
+ PathSettingsContainer child = children[k];
+ IPath childPath = child.getPath();
+ PathSettingsContainer parentExclusion = cr.getChildContainer(childPath, false, false);
+ IPath parentExclusionPath = parentExclusion.getPath();
+ if(parentExclusionPath.segmentCount() > 0 && !parentExclusionPath.equals(childPath) && parentExclusionPath.isPrefixOf(childPath))
+ continue;
+
+ ICResourceDescription rcDes = (ICResourceDescription)child.getValue();
+ if(rcDes.isExcluded()){
+// set.add(rcDes.getPath());
+ cr.getChildContainer(childPath, true, true);
+ }
+ }
+
+ PathSettingsContainer exclusions[] = cr.getChildren(false);
+// IPath exlusionPaths[] = new IPath[set.size()];
+ IPath exlusionPaths[] = new IPath[exclusions.length];
+// int k = 0;
+ int segCount = pi.segmentCount();
+// for(Iterator iter = set.iterator(); iter.hasNext(); k++) {
+// IPath path = (IPath)iter.next();
+// exlusionPaths[k] = path.removeFirstSegments(segCount).makeRelative();
+// }
+ for(int k = 0; k < exlusionPaths.length; k++) {
+ exlusionPaths[k] = exclusions[k].getPath().removeFirstSegments(segCount).makeRelative();
+ }
+ if(projPath != null)
+ pi = projPath.append(pi);
+ entriesList.add(new CSourceEntry(pi, exlusionPaths, 0));
+ }
+
+ return (ICSourceEntry[])entriesList.toArray(new ICSourceEntry[entriesList.size()]);
+ }
+
+ public ICFolderDescription getParentFolderDescription(){
+ PathSettingsContainer parent = fPathSettingContainer.getParentContainer();
+ if(parent != null)
+ return (ICFolderDescription)parent.getValue();
+ return null;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java
new file mode 100644
index 00000000000..35a18d23318
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.resources.ScannerProvider;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+
+public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements IScannerInfoProvider, IScannerInfoChangeListener{
+ private Map listeners;
+ private IScannerInfoProvider fProvider;
+
+
+ public ScannerInfoProviderProxy(IProject project) {
+ super(project, CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
+ CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED);
+ }
+
+ public IScannerInfo getScannerInformation(IResource resource) {
+ providerRequested();
+ return fProvider.getScannerInformation(resource);
+ }
+
+
+ /**
+ * @param project
+ * @param info
+ */
+ protected void notifyInfoListeners(IResource rc, IScannerInfo info) {
+ // Call in the cavalry
+ List listeners = (List)getListeners().get(rc);
+ if (listeners == null) {
+ return;
+ }
+ IScannerInfoChangeListener[] observers = new IScannerInfoChangeListener[listeners.size()];
+ listeners.toArray(observers);
+ for (int i = 0; i < observers.length; i++) {
+ observers[i].changeNotification(rc, info);
+ }
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.core.resources.IResource,
+ * org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
+ */
+ public synchronized void subscribe(IResource resource, IScannerInfoChangeListener listener) {
+ if (resource == null || listener == null) {
+ return;
+ }
+ IProject project = resource.getProject();
+ // Get listeners for this resource
+ Map map = getListeners();
+ List list = (List)map.get(project);
+ if (list == null) {
+ // Create a new list
+ list = new ArrayList();
+ map.put(project, list);
+ }
+ if (!list.contains(listener)) {
+ // Add the new listener for the resource
+ list.add(listener);
+ }
+ }
+
+ /*
+ * @return
+ */
+ private Map getListeners() {
+ if (listeners == null) {
+ listeners = new HashMap();
+ }
+ return listeners;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.core.resources.IResource,
+ * org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
+ */
+ public synchronized void unsubscribe(IResource resource, IScannerInfoChangeListener listener) {
+ if (resource == null || listener == null) {
+ return;
+ }
+ IProject project = resource.getProject();
+ // Remove the listener
+ Map map = getListeners();
+ List list = (List)map.get(project);
+ if (list != null && !list.isEmpty()) {
+ // The list is not empty so try to remove listener
+ list.remove(listener);
+ }
+ }
+
+ public void changeNotification(IResource rc, IScannerInfo info) {
+ notifyInfoListeners(rc, info);
+ }
+
+ protected Object createDefaultProvider(ICConfigurationDescription des, boolean newStile){
+ if(newStile)
+ return new DescriptionScannerInfoProvider(getProject());
+ return ScannerProvider.getInstance();
+ }
+
+ protected void deinitializeProvider(Object o) {
+ IScannerInfoProvider provider = (IScannerInfoProvider)o;
+ provider.unsubscribe(getProject(), this);
+ if(provider instanceof DescriptionScannerInfoProvider){
+ ((DescriptionScannerInfoProvider)provider).close();
+ }
+ }
+
+ protected void initializeProvider(Object o) {
+ IScannerInfoProvider provider = (IScannerInfoProvider)o;
+ fProvider = provider;
+ provider.subscribe(getProject(), this);
+ }
+
+ protected void postProcessProviderChange(Object newProvider,
+ Object oldProvider) {
+ if(oldProvider != null)
+ notifyInfoListeners(getProject(), getScannerInformation(getProject()));
+ }
+
+ protected boolean isValidProvider(Object o) {
+ return o instanceof IScannerInfoProvider;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java
new file mode 100644
index 00000000000..a7511b90026
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.settings.model;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.internal.core.model.CModelOperation;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+public class SetCProjectDescriptionOperation extends CModelOperation {
+// private IProject fProject;
+// private ICProject fCProject;
+ private CProjectDescription fSetDescription;
+// private CProjectDescription fNewDescriptionCache;
+// private ICProjectDescription fOldDescriptionCache;
+
+
+ SetCProjectDescriptionOperation(ICProject cProject, CProjectDescription description){
+ super(cProject);
+// fCProject = cProject;
+ fSetDescription = description;
+ }
+
+ protected void executeOperation() throws CModelException {
+ CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
+ ICProject cProject = (ICProject)getElementToProcess();
+ IProject project = cProject.getProject();
+ CProjectDescription fOldDescriptionCache = (CProjectDescription)mngr.getProjectDescription(project, false);
+
+ CProjectDescriptionEvent event = mngr.createAboutToApplyEvent(fSetDescription, fOldDescriptionCache);
+ mngr.notifyListeners(event);
+
+ InternalXmlStorageElement el = null;
+ try {
+ el = mngr.copyElement((InternalXmlStorageElement)fSetDescription.getRootStorageElement(), false);
+ } catch (CoreException e2) {
+ }
+
+ CProjectDescription fNewDescriptionCache = new CProjectDescription(fSetDescription, true, el);
+
+ ICDescriptionDelta delta = mngr.createDelta(fNewDescriptionCache, fOldDescriptionCache);
+ mngr.checkRemovedConfigurations(delta);
+
+
+ ICElementDelta cElementDeltas[] = mngr.generateCElementDeltas(cProject, delta);
+
+ if (cElementDeltas.length > 0) {
+ for (int i = 0; i < cElementDeltas.length; i++) {
+ addDelta(cElementDeltas[i]);
+ }
+ }
+
+ mngr.setLoaddedDescription(project, fNewDescriptionCache, true);
+ mngr.checkActiveCfgChange(fNewDescriptionCache, fOldDescriptionCache, new NullProgressMonitor());
+
+ event = mngr.createAppliedEvent(fNewDescriptionCache, fOldDescriptionCache, fSetDescription, delta);
+ mngr.notifyListeners(event);
+
+ cProject.close();
+
+ ExternalSettingsManager.getInstance().updateDepentents(delta);
+
+ try {
+ ((InternalXmlStorageElement)fNewDescriptionCache.getRootStorageElement()).setReadOnly(true);
+ } catch (CoreException e1) {
+ }
+
+ try {
+ mngr.serialize(fNewDescriptionCache);
+ } catch (CoreException e) {
+ throw new CModelException(e);
+ }
+ }
+
+ public boolean isReadOnly() {
+ return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index fa0afcafa04..2e5aa9908bd 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -44,6 +44,8 @@
<extension-point id="CodeFormatter" name="%CodeFormatter.name" schema="schema/CodeFormatter.exsd"/>
<extension-point id="CIndexer" name="%CIndexer.name" schema="schema/CIndexer.exsd"/>
<extension-point id="language" name="%language.name" schema="schema/language.exsd"/>
+ <extension-point id="CConfigurationDataProvider" name="CConfigurationData provider" schema="schema/CConfigurationDataProvider.exsd"/>
+ <extension-point id="projectConverter" name="project converter" schema="schema/projectConverter.exsd"/>
<!-- =================================================================================== -->
<!-- Define the list of the Binary Parser provided by the CDT -->
<!-- =================================================================================== -->
@@ -562,6 +564,22 @@
class="org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory"
id="C++"/>
</extension>
+ <extension
+ id="defaultConfigDataProvider"
+ name="Default Provider"
+ point="org.eclipse.cdt.core.CConfigurationDataProvider">
+ <provider
+ class="org.eclipse.cdt.internal.core.settings.model.PathEntryConfigurationDataProvider"
+ />
+ </extension>
+ <extension
+ point="org.eclipse.cdt.core.PathEntryContainerInitializer">
+ <pathEntryContainerInitializer
+ class="org.eclipse.cdt.internal.core.settings.model.ConfigBasedEntriesContainerInitializer"
+ id="org.eclipse.cdt.core.CFG_BASED_CONTAINER">
+ </pathEntryContainerInitializer>
+ </extension>
+
<!-- =================================================================================== -->
<!-- Dynamic Variables -->
<!-- =================================================================================== -->
diff --git a/core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd b/core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd
new file mode 100644
index 00000000000..15a87ea94c5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/schema/CConfigurationDataProvider.exsd
@@ -0,0 +1,87 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="CConfigurationDataProvider" name="CConfigurationData provider"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/core/org.eclipse.cdt.core/schema/projectConverter.exsd b/core/org.eclipse.cdt.core/schema/projectConverter.exsd
new file mode 100644
index 00000000000..cd575f74ddc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/schema/projectConverter.exsd
@@ -0,0 +1,87 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="projectConverter" name="project converter"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
index 8f853f60add..bd81cc91892 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -24,8 +24,10 @@ import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.IPDOMManager;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IWorkingCopy;
@@ -33,11 +35,16 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
import org.eclipse.cdt.core.resources.ScannerProvider;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager;
import org.eclipse.cdt.internal.core.CContentTypes;
import org.eclipse.cdt.internal.core.CDTLogWriter;
-import org.eclipse.cdt.internal.core.CDescriptorManager;
import org.eclipse.cdt.internal.core.PathEntryVariableManager;
import org.eclipse.cdt.internal.core.PositionTrackerManager;
+import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
+import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
import org.eclipse.cdt.internal.core.model.BufferManager;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.internal.core.model.DeltaProcessor;
@@ -45,6 +52,7 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
import org.eclipse.cdt.internal.core.pdom.indexer.fast.PDOMFastIndexer;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
@@ -171,7 +179,9 @@ public class CCorePlugin extends Plugin {
private static CCorePlugin fgCPlugin;
private static ResourceBundle fgResourceBundle;
- private CDescriptorManager fDescriptorManager = new CDescriptorManager();
+ private CConfigBasedDescriptorManager/*CDescriptorManager*/ fDescriptorManager;// = new CDescriptorManager();
+
+ private CProjectDescriptionManager fNewCProjectDescriptionManager = CProjectDescriptionManager.getInstance();
private CoreModel fCoreModel;
@@ -284,10 +294,10 @@ public class CCorePlugin extends Plugin {
try {
PositionTrackerManager.getInstance().uninstall();
- if (fDescriptorManager != null) {
- fDescriptorManager.shutdown();
- }
-
+// if (fDescriptorManager != null) {
+// fDescriptorManager.shutdown();
+// }
+
if (fCoreModel != null) {
fCoreModel.shutdown();
}
@@ -300,6 +310,9 @@ public class CCorePlugin extends Plugin {
fPathEntryVariableManager.shutdown();
}
+ fNewCProjectDescriptionManager.shutdown();
+ fDescriptorManager = null;
+
savePluginPreferences();
} finally {
super.stop(context);
@@ -311,7 +324,10 @@ public class CCorePlugin extends Plugin {
*/
public void start(BundleContext context) throws Exception {
super.start(context);
-
+
+ fNewCProjectDescriptionManager.startup();
+ fDescriptorManager = fNewCProjectDescriptionManager.getDescriptorManager();
+
// Start file type manager first !!
fPathEntryVariableManager = new PathEntryVariableManager();
fPathEntryVariableManager.startup();
@@ -321,7 +337,8 @@ public class CCorePlugin extends Plugin {
//Set debug tracing options
configurePluginDebugOptions();
- fDescriptorManager.startup();
+// fDescriptorManager.startup();
+// CProjectDescriptionManager.getInstance().startup();
// Fired up the model.
fCoreModel = CoreModel.getDefault();
@@ -711,6 +728,7 @@ public class CCorePlugin extends Plugin {
*
* @exception CoreException if the operation fails
* @exception OperationCanceledException if the operation is canceled
+ * @deprecated
*/
public IProject createCProject(
final IProjectDescription description,
@@ -737,7 +755,7 @@ public class CCorePlugin extends Plugin {
// Open first.
projectHandle.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1));
- mapCProjectOwner(projectHandle, projectID, false);
+// mapCProjectOwner(projectHandle, projectID, false);
// Add C Nature ... does not add duplicates
CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1));
@@ -749,6 +767,42 @@ public class CCorePlugin extends Plugin {
return projectHandle;
}
+ public IProject createCDTProject(
+ final IProjectDescription description,
+ final IProject projectHandle,
+ IProgressMonitor monitor)
+ throws CoreException, OperationCanceledException {
+
+ getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("Creating C Project...", 3); //$NON-NLS-1$
+ if (!projectHandle.exists()) {
+ projectHandle.create(description, new SubProgressMonitor(monitor, 1));
+ }
+
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
+ // Open first.
+ projectHandle.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1));
+
+// mapCProjectOwner(projectHandle, projectID, false);
+
+ // Add C Nature ... does not add duplicates
+ CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1));
+ } finally {
+ monitor.done();
+ }
+ }
+ }, getWorkspace().getRoot(), 0, monitor);
+ return projectHandle;
+ }
+
/**
* Method convertProjectFromCtoCC converts
* a C Project to a C++ Project
@@ -890,22 +944,29 @@ public class CCorePlugin extends Plugin {
}
public IScannerInfoProvider getScannerInfoProvider(IProject project) {
- IScannerInfoProvider provider = null;
- if (project != null) {
- try {
- ICDescriptor desc = getCProjectDescription(project);
- ICExtensionReference[] extensions = desc.get(BUILD_SCANNER_INFO_UNIQ_ID, true);
- if (extensions.length > 0)
- provider = (IScannerInfoProvider) extensions[0].createExtension();
- } catch (CoreException e) {
- // log(e);
- }
- if ( provider == null) {
- return ScannerProvider.getInstance();
- }
- }
- return provider;
+ return fNewCProjectDescriptionManager.getScannerInfoProviderProxy(project);
+// IScannerInfoProvider provider = null;
+// if (project != null) {
+// try {
+// ICDescriptor desc = getCProjectDescription(project);
+// ICExtensionReference[] extensions = desc.get(BUILD_SCANNER_INFO_UNIQ_ID, true);
+// if (extensions.length > 0)
+// provider = (IScannerInfoProvider) extensions[0].createExtension();
+// } catch (CoreException e) {
+// // log(e);
+// }
+// if ( provider == null) {
+// return getDefaultScannerInfoProvider(project);
+// }
+// }
+// return provider;
}
+
+// private IScannerInfoProvider getDefaultScannerInfoProvider(IProject project){
+// if(fNewCProjectDescriptionManager.isNewStyleIndexCfg(project))
+// return fNewCProjectDescriptionManager.getScannerInfoProvider(project);
+// return ScannerProvider.getInstance();
+// }
/**
* Helper function, returning the contenttype for a filename
@@ -993,4 +1054,100 @@ public class CCorePlugin extends Plugin {
return CDOM.getInstance();
}
-}
+ public ICdtVariableManager getCdtVariableManager(){
+ return CdtVariableManager.getDefault();
+ }
+
+ public IEnvironmentVariableManager getBuildEnvironmentManager(){
+ return EnvironmentVariableManager.getDefault();
+ }
+
+ public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId) throws CoreException{
+ return fNewCProjectDescriptionManager.getPreferenceConfiguration(buildSystemId);
+ }
+
+ public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) throws CoreException{
+ return fNewCProjectDescriptionManager.getPreferenceConfiguration(buildSystemId, write);
+ }
+
+ public void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws CoreException {
+ fNewCProjectDescriptionManager.setPreferenceConfiguration(buildSystemId, des);
+ }
+
+ /**
+ * the method creates and returns a writable project description
+ *
+ * @param project project for which the project description is requested
+ * @param loadIfExists if true the method first tries to load and return the project description
+ * from the settings file (.cproject)
+ * if false, the stored settings are ignored and the new (empty) project description is created
+ * NOTE: changes made to the returned project description will not be applied untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
+ * @return {@link ICProjectDescription}
+ * @throws CoreException
+ */
+ public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException{
+ return fNewCProjectDescriptionManager.createProjectDescription(project, loadIfExists);
+ }
+
+ /**
+ * returns the project description associated with this project
+ * this is a convenience method fully equivalent to getProjectDescription(project, true)
+ * see {@link #getProjectDescription(IProject, boolean)} for more detail
+ * @param project
+ * @return a writable copy of the ICProjectDescription or null if the project does not contain the
+ * CDT data associated with it.
+ * Note: changes to the project description will not be reflected/used by the core
+ * untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
+ *
+ * @see #getProjectDescription(IProject, boolean)
+ */
+ public ICProjectDescription getProjectDescription(IProject project){
+ return fNewCProjectDescriptionManager.getProjectDescription(project);
+ }
+
+ /**
+ * this method is called to save/apply the project description
+ * the method should be called to apply changes made to the project description
+ * returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)}
+ *
+ * @param project
+ * @param des
+ * @throws CoreException
+ *
+ * @see {@link #getProjectDescription(IProject, boolean)}
+ * @see #createProjectDescription(IProject, boolean)
+ */
+ public void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException {
+ fNewCProjectDescriptionManager.setProjectDescription(project, des);
+ }
+
+ /**
+ * returns the project description associated with this project
+ *
+ * @param project project for which the description is requested
+ * @param write if true, the writable description copy is returned.
+ * If false the cached read-only description is returned.
+ *
+ * CDT core maintains the cached project description settings. If only read access is needed to description,
+ * then the read-only project description should be obtained.
+ * This description always operates with cached data and thus it is better to use it for performance reasons
+ * All set* calls to the read-only description result in the {@link WriteAccessException}
+ *
+ * When the writable description is requested, the description copy is created.
+ * Changes to this description will not be reflected/used by the core and Build System untill the
+ * {@link #setProjectDescription(IProject, ICProjectDescription)} is called
+ *
+ * Each getProjectDescription(project, true) returns a new copy of the project description
+ *
+ * The writable description uses the cached data untill the first set call
+ * after that the description communicates directly to the Build System
+ * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension
+ * This ensures the Core<->Build System settings integrity
+ *
+ * @return {@link ICProjectDescription}
+ */
+ public ICProjectDescription getProjectDescription(IProject project, boolean write){
+ return fNewCProjectDescriptionManager.getProjectDescription(project, write);
+ }
+
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java
index cba07429f6e..3ea38c10b3e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptor.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.w3c.dom.Element;
@@ -28,4 +29,6 @@ public interface ICDescriptor {
public Element getProjectData(String id) throws CoreException;
public void saveProjectData() throws CoreException;
+
+ ICConfigurationDescription getConfigurationDescription();
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionDescriptor.java
new file mode 100644
index 00000000000..0d88e4a589f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionDescriptor.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core;
+
+public interface ICExtensionDescriptor {
+ String getName();
+
+ String getId();
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java
new file mode 100644
index 00000000000..a9f487f5869
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.cdtvariables;
+
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+
+/**
+ * This is the trivial implementation of the IBuildMacro used internaly by the MBS
+ *
+ * @since 3.0
+ */
+public class CdtVariable implements ICdtVariable {
+ protected String fName;
+ protected int fType;
+ protected String fStringValue;
+ protected String fStringListValue[];
+
+ protected CdtVariable(){
+
+ }
+
+ public CdtVariable(String name, int type, String value){
+ fName = name;
+ fType = type;
+ fStringValue = value;
+ }
+
+ public CdtVariable(String name, int type, String value[]){
+ fName = name;
+ fType = type;
+ fStringListValue = value;
+ }
+
+ public CdtVariable(ICdtVariable var){
+ fName = var.getName();
+ fType = var.getValueType();
+ try {
+ if(CdtVariableResolver.isStringListVariable(fType))
+ fStringListValue = var.getStringListValue();
+ else
+ fStringValue = var.getStringValue();
+ } catch (CdtVariableException e) {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getName()
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getMacroValueType()
+ */
+ public int getValueType() {
+ return fType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringValue()
+ */
+ public String getStringValue() throws CdtVariableException {
+ if(CdtVariableResolver.isStringListVariable(fType))
+ throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_NOT_STRING,fName,null,fName);
+
+ return fStringValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringListValue()
+ */
+ public String[] getStringListValue() throws CdtVariableException {
+ if(!CdtVariableResolver.isStringListVariable(fType))
+ throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_NOT_STRINGLIST,fName,null,fName);
+
+ return fStringListValue;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableException.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableException.java
new file mode 100644
index 00000000000..c60676a4136
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableException.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.cdtvariables;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * This exception is thrown in the case of some build macros-related operation failure
+ * The exception typically contains one or more IBuildMacroStatus statuses
+ *
+ * @since 3.0
+ */
+public class CdtVariableException extends CoreException {
+ /**
+ * All serializable objects should have a stable serialVersionUID
+ */
+ private static final long serialVersionUID = 3976741380246681395L;
+
+ /**
+ * Creates a new exception with the given status object.
+ *
+ * @param status the status object to be associated with this exception.
+ * Typically this is either the IBuildMacroStatus or the MultiStatus that holds
+ * the list of the IBuildMacroStatus statuses
+ */
+ public CdtVariableException(IStatus status) {
+ super(status);
+ }
+
+ /**
+ * Creates an exception containing a single IBuildMacroStatus status with the IStatus.ERROR severity
+ *
+ * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
+ * @param message message, can be null. In this case the default message will
+ * be generated base upon the other status info
+ * @param exception a low-level exception, or <code>null</code> if not
+ * applicable
+ * @param macroName the name of the build macro whose resolution caused this status creation or null if none
+ * @param expression the string whose resolutinon caused caused this status creation or null if none
+ * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
+ * @param contextType the context type used in the operation
+ * @param contextData the context data used in the operation
+ */
+ public CdtVariableException(int code,
+ String message,
+ Throwable exception,
+ String macroName,
+ String expression,
+ String referencedName//,
+ //int contextType,
+ //Object contextData
+ ) {
+ super(new CdtVariableStatus(code, message, exception, macroName, expression, referencedName/*, contextType, contextData*/));
+ }
+
+ /**
+ * Creates an exception containing a single IBuildMacroStatus status with the IStatus.ERROR severity and with the default message
+ *
+ * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
+ * @param exception a low-level exception, or <code>null</code> if not
+ * applicable
+ * @param macroName the name of the build macro whose resolution caused this status creation or null if none
+ * @param expression the string whose resolutinon caused caused this status creation or null if none
+ * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
+ * @param contextType the context type used in the operation
+ * @param contextData the context data used in the operation
+ */
+ public CdtVariableException(int code,
+ String macroName,
+ String expression,
+ String referencedName//,
+ //int contextType,
+ //Object contextData
+ ) {
+ super(new CdtVariableStatus(code, macroName, expression, referencedName/*, contextType, contextData*/));
+ }
+
+ /**
+ * Returns an array of the IBuildMacroStatus statuses this exception holds
+ *
+ * @return IBuildMacroStatus[]
+ */
+ public ICdtVariableStatus[] getVariableStatuses(){
+ IStatus status = getStatus();
+ if(status instanceof ICdtVariableStatus)
+ return new ICdtVariableStatus[]{(ICdtVariableStatus)status};
+ else if(status.isMultiStatus()){
+ IStatus children[] = status.getChildren();
+ ICdtVariableStatus result[] = new ICdtVariableStatus[children.length];
+ int num = 0;
+ for(int i = 0; i < children.length; i++){
+ if(children[i] instanceof ICdtVariableStatus)
+ result[num++]=(ICdtVariableStatus)children[i];
+ }
+ if(num != children.length){
+ ICdtVariableStatus tmp[] = new ICdtVariableStatus[num];
+ for(int i = 0; i < num; i++)
+ tmp[i] = result[i];
+ result = tmp;
+ }
+ return result;
+ }
+ return new ICdtVariableStatus[0];
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java
new file mode 100644
index 00000000000..8af3880b04f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.cdtvariables;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * This class implements the IBuildMacroStatus interface
+ *
+ * @since 3.0
+ */
+public class CdtVariableStatus extends Status implements ICdtVariableStatus {
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "BuildMacroStatus"; //$NON-NLS-1$
+ private static final String STATUS = PREFIX + ".status"; //$NON-NLS-1$
+ private static final String STATUS_MACRO_UNDEFINED = STATUS + ".macro.undefined"; //$NON-NLS-1$
+ private static final String STATUS_MACROS_REFERENCE_EACHOTHER = STATUS + ".reference.eachother"; //$NON-NLS-1$
+ private static final String STATUS_MACRO_REFERENCE_INCORRECT = STATUS + ".reference.incorrect"; //$NON-NLS-1$
+ private static final String STATUS_MACRO_NOT_STRING = STATUS + ".macro.not.string"; //$NON-NLS-1$
+ private static final String STATUS_MACRO_NOT_STRINGLIST = STATUS + ".macro.not.stringlist"; //$NON-NLS-1$
+ private static final String STATUS_ERROR = STATUS + ".error"; //$NON-NLS-1$
+ private static final String VALUE_UNDEFINED = PREFIX + ".value.undefined"; //$NON-NLS-1$
+
+ private String fMacroName;
+ private String fExpression;
+ private String fReferencedName;
+// private int fContextType;
+// private Object fContextData;
+// private Object fContext;
+
+ /**
+ *
+ * @param severity one of the IStatus.xxx severity statuses
+ * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
+ * @param message message, can be null. In this case the default message will
+ * be generated base upon the other status info
+ * @param exception a low-level exception, or <code>null</code> if not
+ * applicable
+ * @param macroName the name of the build macro whose resolution caused this status creation or null if none
+ * @param expression the string whose resolutinon caused caused this status creation or null if none
+ * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
+ * @param contextType the context type used in the operation
+ * @param contextData the context data used in the operation
+ */
+ public CdtVariableStatus(int severity,
+ int code,
+ String message,
+ Throwable exception,
+ String macroName,
+ String expression,
+ String referencedName//,
+// int contextType,
+// Object contextData
+// Object context
+ ) {
+ super(severity,CCorePlugin.PLUGIN_ID,code,message != null ? message : "",exception); //$NON-NLS-1$
+ fExpression = expression;
+ fReferencedName = referencedName;
+// fContextType = contextType;
+// fContextData = contextData;
+// fContext = context;
+ fMacroName = macroName;
+ if(message == null)
+ setMessage(generateMessage());
+ }
+
+ /**
+ * Creates status with the IStatus.ERROR severity
+ *
+ * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
+ * @param message message, can be null. In this case the default message will
+ * be generated base upon the other status info
+ * @param exception a low-level exception, or <code>null</code> if not
+ * applicable
+ * @param macroName the name of the build macro whose resolution caused this status creation or null if none
+ * @param expression the string whose resolutinon caused caused this status creation or null if none
+ * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
+ * @param contextType the context type used in the operation
+ * @param contextData the context data used in the operation
+ */
+ public CdtVariableStatus(
+ int code,
+ String message,
+ Throwable exception,
+ String macroName,
+ String expression,
+ String referencedName//,
+// int contextType,
+// Object contextData
+// Object context
+ ) {
+ this(IStatus.ERROR,code,message,exception,macroName,expression,referencedName/*,contextType,contextData*/);
+ }
+
+ /**
+ * Creates status with the IStatus.ERROR severity and with the default message
+ *
+ * @param code one of the IBuildMacroStatus.TYPE_xxx statusses
+ * @param exception a low-level exception, or <code>null</code> if not
+ * applicable
+ * @param macroName the name of the build macro whose resolution caused this status creation or null if none
+ * @param expression the string whose resolutinon caused caused this status creation or null if none
+ * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
+ * @param contextType the context type used in the operation
+ * @param contextData the context data used in the operation
+ */
+ public CdtVariableStatus(
+ int code,
+ String macroName,
+ String expression,
+ String referencedName//,
+// int contextType,
+// Object contextData
+ ) {
+ this(IStatus.ERROR,code,null,null,macroName,expression,referencedName/*,contextType,contextData*/);
+ }
+
+ /**
+ * generates and returns the default status message based upon then status data
+ *
+ * @return String
+ */
+ protected String generateMessage(){
+ String message = null;
+/* switch(getCode()){
+ case TYPE_MACRO_UNDEFINED:{
+ String refName = fReferencedName;
+ if(refName == null)
+ refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
+ message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_UNDEFINED,refName);
+ }
+ break;
+ case TYPE_MACROS_REFERENCE_EACHOTHER:{
+ String name = fMacroName;
+ String refName = fReferencedName;
+ if(name == null)
+ name = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
+ if(refName == null)
+ refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
+ message = ManagedMakeMessages.getFormattedString(STATUS_MACROS_REFERENCE_EACHOTHER,new String[]{name,refName});
+ }
+ break;
+ case TYPE_MACRO_REFERENCE_INCORRECT:{
+ String refName = fReferencedName;
+ if(refName == null)
+ refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
+ message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_REFERENCE_INCORRECT,refName);
+ }
+ break;
+ case TYPE_MACRO_NOT_STRING:{
+ String refName = fReferencedName;
+ if(refName == null)
+ refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
+ message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_NOT_STRING,refName);
+ }
+ break;
+ case TYPE_MACRO_NOT_STRINGLIST:{
+ String refName = fReferencedName;
+ if(refName == null)
+ refName = ManagedMakeMessages.getResourceString(VALUE_UNDEFINED);
+ message = ManagedMakeMessages.getFormattedString(STATUS_MACRO_NOT_STRINGLIST,refName);
+ }
+ break;
+ case TYPE_ERROR:
+ default:
+ message = ManagedMakeMessages.getResourceString(STATUS_ERROR);
+ }*/
+ return message;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getMacroName()
+ */
+ public String getVariableName() {
+ return fMacroName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getExpression()
+ */
+ public String getExpression() {
+ return fExpression;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getReferencedName()
+ */
+ public String getReferencedMacroName() {
+ return fReferencedName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getContextType()
+ */
+// public int getContextType() {
+// return fContextType;
+// }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getContextData()
+ */
+// public Object getContextData() {
+// return fContextData;
+// }
+
+
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariable.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariable.java
new file mode 100644
index 00000000000..9b7a157d159
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariable.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.cdtvariables;
+
+
+/**
+ * this interface represents the given build macro
+ * @since 3.0
+ */
+public interface ICdtVariable{
+ /**
+ * can hold any text string
+ */
+ public static final int VALUE_TEXT = 1;
+
+ /**
+ * can hold the array of text string values
+ */
+ public static final int VALUE_TEXT_LIST = 2;
+
+ /**
+ * can hold file path
+ */
+ public static final int VALUE_PATH_FILE = 3;
+
+ /**
+ * can hold the array of file path values
+ */
+ public static final int VALUE_PATH_FILE_LIST = 4;
+
+ /**
+ * can hold dir path
+ */
+ public static final int VALUE_PATH_DIR = 5;
+
+ /**
+ * can hold the array of dir path values
+ */
+ public static final int VALUE_PATH_DIR_LIST = 6;
+
+ /**
+ * can hold both file and dir path
+ */
+ public static final int VALUE_PATH_ANY = 7;
+
+ /**
+ * can hold the array of PATH_ANY values
+ */
+ public static final int VALUE_PATH_ANY_LIST = 8;
+
+ /**
+ * Returns the macro name
+ * @return
+ */
+ String getName();
+
+ /**
+ * @return IBuildMacro.VALUE_xxx
+ */
+ int getValueType();
+
+ /**
+ * @throws CdtVariableException if macro holds StringList-type value
+ */
+ String getStringValue() throws CdtVariableException;
+
+ /**
+ * @throws CdtVariableException if macro holds single String-type value
+ */
+ String[] getStringListValue() throws CdtVariableException;
+}
+
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java
new file mode 100644
index 00000000000..2f29b6eaa93
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.cdtvariables;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.core.variables.IStringVariable;
+
+/**
+ *
+ * @since 3.0
+ */
+public interface ICdtVariableManager{
+/* public final static int CONTEXT_FILE = 1;
+ public final static int CONTEXT_OPTION = 2;
+ public final static int CONTEXT_CONFIGURATION = 3;
+ public final static int CONTEXT_PROJECT = 4;
+ public final static int CONTEXT_WORKSPACE = 5;
+ public final static int CONTEXT_INSTALLATIONS = 6;
+ public final static int CONTEXT_ECLIPSEENV = 7;
+ public final static int CONTEXT_TOOL = 8;
+*/
+ /**
+ *
+ * Returns reference to the IBuildMacro interface representing Macro of the
+ * specified name or null if there is there is no such macro
+ * @param macroName macro name
+ * @param contextType represents the context type. Should be set to one of the the
+ * IBuildMacroProvider. CONTEXT_xxx constants
+ * @param contextData represents the additional data needed by the Build Macro Provider
+ * and Macro Suppliers in order to obtain the macro value. The type of the context data
+ * differs depending on the context type and can be one of the following:
+ * 1. IFileContextData interface � used to represent currently selected file context
+ * the IFileContextData interface is defined as follows:
+ * pulic interface IFileContextData{
+ * IFile getFile();
+ * IOption getOption();
+ * }
+ * NOTE: the IFileContextData is passed that represents the current file and the option
+ * for that file because Macro Value Provider needs to know what option should be used
+ * as a context in case macro is not found for �current file� context
+ * 2. IOptionContextData interface used to represent the currently selected option context
+ * 3. IConfiguration � used to represent the currently selected configuration context
+ * 4. IProject � used to represent current project context
+ * 5. IWorkspace � used to represent current workspace context
+ * 6. null � to represent the CDT and Eclipse installation context
+ * 7. null � to represent process environment context
+ * @param includeParentContext specifies whether lower-precedence context macros should
+ * be included
+ */
+ public ICdtVariable getVariable(String name, ICConfigurationDescription cfg);
+
+ /**
+ *
+ * @return the array of the IBuildMacro representing all available macros
+ */
+ public ICdtVariable[] getVariables(ICConfigurationDescription cfg);
+
+
+ /**
+ * This method is defined to be used primarily by the UI classes and should not be used by the
+ * tool-integrator
+ * @return the array of the provider-internal suppliers for the given context
+ */
+/* public IBuildMacroSupplier[] getSuppliers(int contextType,
+ Object contextData);
+*/
+
+ /**
+ *
+ * converts StringList value into String of the following format:
+ * "<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>"
+ */
+ public String convertStringListToString (String value[], String listDelimiter);
+
+ /**
+ *
+ * resolves all macros in the string.
+ * @param value the value to be resolved
+ * @param nonexistentMacrosValue specifies the value that inexistent macro references will be
+ * expanded to. If null the BuildMacroException is thrown in case the string to be resolved
+ * references inexistent macros
+ * @param listDelimiter if not null, StringList macros are expanded as
+ * �<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>�
+ * otherwise the BuildMacroException is thrown in case the string to be resolved references
+ * string-list macros
+ * @param contextType context from which the macro search should be started
+ * @param contextData context data
+ */
+ public String resolveValue(String value,
+ String nonexistentMacrosValue,
+ String listDelimiter,
+ ICConfigurationDescription cfg) throws CdtVariableException;
+
+ /**
+ *
+ * if the string contains a value that can be treated as a StringList resolves it to arrays of strings
+ * otherwise throws the BuildMacroException exception
+ * @see isStringListValue
+ */
+ public String[] resolveStringListValue(String value,
+ String nonexistentMacrosValue,
+ String listDelimiter,
+ ICConfigurationDescription cfg) throws CdtVariableException;
+
+ /**
+ *
+ * resolves macros in the array of string-list values
+ *
+ * @see isStringListValue
+ */
+ public String[] resolveStringListValues(String value[],
+ String nonexistentMacrosValue,
+ String listDelimiter,
+ ICConfigurationDescription cfg) throws CdtVariableException;
+
+ /**
+ *
+ * @return true if the specified expression can be treated as StringList
+ * 1. The string value is �${<some_StringList_Macro_name>}�
+ */
+ public boolean isStringListValue(String value, ICConfigurationDescription cfg)
+ throws CdtVariableException;
+
+ /**
+ *
+ * checks the integrity of the Macros
+ * If there are inconsistencies, such as when a macro value refers to a nonexistent macro
+ * or when two macros refer to each other, this method will throw the BuildMacroException exception
+ * The BuildMacroException will contain the human-readable string describing
+ * the inconsistency and the array of the IBuildMacro interfaces that will represent the macros that
+ * caused the inconsistency. This information will be used in the UI to notify the user about
+ * the macro inconsistencies (see also the �User interface for viewing and editing Build Macros�
+ * section of this design)
+ */
+ public void checkVariableIntegrity(ICConfigurationDescription cfg) throws CdtVariableException;
+
+ public boolean isEnvironmentVariable(ICdtVariable variable, ICConfigurationDescription cfg);
+
+ public boolean isUserVariable(ICdtVariable variable, ICConfigurationDescription cfg);
+
+ public IStringVariable toEclipseVariable(ICdtVariable variable, ICConfigurationDescription cfg);
+}
+
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableStatus.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableStatus.java
new file mode 100644
index 00000000000..13d366be192
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableStatus.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.cdtvariables;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * This interface represents the status of a build macro operation
+ *
+ * @since 3.0
+ */
+public interface ICdtVariableStatus extends IStatus {
+ /**
+ * This type is used to present that the inexistent macro reference
+ * is encountered while resolving macros in some expression
+ */
+ public static final int TYPE_MACRO_UNDEFINED = 1;
+
+ /**
+ * This type is used to present that two macros reference each other
+ */
+ public static final int TYPE_MACROS_REFERENCE_EACHOTHER = 2;
+
+ /**
+ * This type is used to present that the incorrect macro reference
+ * is encountered while resolving macros in some expression
+ */
+ public static final int TYPE_MACRO_REFERENCE_INCORRECT = 3;
+
+ /**
+ * The status of this type is created by the Build Macro of the String-List type
+ * when the String value is requested
+ */
+ public static final int TYPE_MACRO_NOT_STRING = 4;
+
+ /**
+ * The status of this type is created by the Build Macro of the String type
+ * when the String-List value is requested
+ */
+ public static final int TYPE_MACRO_NOT_STRINGLIST = 5;
+
+ /**
+ * This type is used to present that some error other than the one represented
+ * by other TYPE_xxx has occured
+ */
+ public static final int TYPE_ERROR = -1;
+
+ /**
+ * returns the name of the build macro whose resolution caused this status creation or null if none
+ * @return IBuildMacro
+ */
+ public String getVariableName();
+
+ /**
+ * returns the string whose resolutinon caused caused this status creation or null if none
+ * @return String
+ */
+ public String getExpression();
+
+ /**
+ * returns the macro name referenced in the resolution string that caused this this status creation or null if none
+ * @return String
+ */
+ public String getReferencedMacroName();
+
+ /**
+ * returns the context type used in the operation
+ * @return int
+ */
+// public int getContextType();
+
+ /**
+ * returns the context data used in the operation
+ * @return Object
+ */
+// public Object getContextData();
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariablesContributor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariablesContributor.java
new file mode 100644
index 00000000000..4d02040eb94
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariablesContributor.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.cdtvariables;
+
+
+
+public interface ICdtVariablesContributor {
+ ICdtVariable getVariable(String name, ICdtVariableManager provider);
+
+ ICdtVariable[] getVariables(ICdtVariableManager provider);
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvirinmentVariable.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvirinmentVariable.java
new file mode 100644
index 00000000000..06da5a9a75c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvirinmentVariable.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.envvar;
+
+
+
+/**
+ * a trivial implementation of the IBuildEnvironmentVariable
+ *
+ * @since 3.0
+ */
+public class EnvirinmentVariable implements IEnvironmentVariable, Cloneable {
+ protected String fName;
+ protected String fValue;
+ protected String fDelimiter;
+ protected int fOperation;
+
+ public EnvirinmentVariable(String name, String value, int op, String delimiter){
+ fName = name;
+ fOperation = op;
+ fValue = value;
+ fDelimiter = delimiter;
+ }
+
+ protected EnvirinmentVariable(){
+
+ }
+
+ public EnvirinmentVariable(String name){
+ this(name,null,ENVVAR_REPLACE,null);
+ }
+
+ public EnvirinmentVariable(String name, String value){
+ this(name,value,ENVVAR_REPLACE,null);
+ }
+
+ public EnvirinmentVariable(String name, String value, String delimiter){
+ this(name,value,ENVVAR_REPLACE,delimiter);
+ }
+
+ public EnvirinmentVariable(IEnvironmentVariable var){
+ this(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getName()
+ */
+ public String getName(){
+ return fName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getValue()
+ */
+ public String getValue(){
+ return fValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getOperation()
+ */
+ public int getOperation(){
+ return fOperation;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getDelimiter()
+ */
+ public String getDelimiter(){
+ return fDelimiter;
+ }
+
+ public Object clone(){
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ }
+ return null;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IContributedEnvironment.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IContributedEnvironment.java
new file mode 100644
index 00000000000..376e1c73427
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IContributedEnvironment.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.envvar;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+public interface IContributedEnvironment {
+ IEnvironmentVariable[] getVariables(ICConfigurationDescription des);
+
+ IEnvironmentVariable getVariable(String name, ICConfigurationDescription des);
+
+ boolean appendEnvironment(ICConfigurationDescription des);
+
+ void setAppendEnvironment(boolean append, ICConfigurationDescription des);
+
+ IEnvironmentVariable addVariable(String name,
+ String value,
+ int op,
+ String delimiter,
+ ICConfigurationDescription des);
+
+ IEnvironmentVariable removeVariable(String name, ICConfigurationDescription des);
+
+ void restoreDefaults(ICConfigurationDescription des);
+
+ boolean isUserVariable(ICConfigurationDescription des, IEnvironmentVariable var);
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentContributor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentContributor.java
new file mode 100644
index 00000000000..42bfe5ea036
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentContributor.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.envvar;
+
+public interface IEnvironmentContributor {
+ IEnvironmentVariable getVariable(String name, IEnvironmentVariableManager provider);
+
+ IEnvironmentVariable[] getVariables(IEnvironmentVariableManager provider);
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java
new file mode 100644
index 00000000000..28d2dfe4210
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.envvar;
+
+/**
+ * this interface represents the given environment variable
+ * @since 3.0
+ */
+public interface IEnvironmentVariable{
+ public static final int ENVVAR_REPLACE = 1;
+ public static final int ENVVAR_REMOVE = 2;
+ public static final int ENVVAR_PREPEND = 3;
+ public static final int ENVVAR_APPEND = 4;
+
+ /**
+ *
+ * @return the variable name
+ */
+ public String getName();
+
+ /**
+ *
+ * @return the variable value
+ */
+ public String getValue();
+
+ /**
+ * @return one of the IBuildEnvironmentVariable.ENVVAR_* operation types
+ */
+ public int getOperation();
+
+ /**
+ * @return if the variable can hold the list of values this method returns the String representing
+ * the delimiter that is used to separate values. This information is used for the following:
+ *
+ * 1. in append and prepend operations:
+ * If the variable already exists and contains some value the new
+ * value will be calculated in the following way:
+ * For the "prepend" operation:
+ * <New value> = <the value from the getValue() method><delimiter><Old value>
+ * For the "append" operation:
+ * <New value> = <Old value><delimiter><the value from the getValue() method>
+ *
+ * The Environment Variable Provider will also remove the duplicates of "sub-values"
+ * in the resulting value.
+ * For example:
+ * If the current value is "string1:string2:string3", the getDelimiter() method returns ":"
+ * and getValue() method returns "string4:string2" the new value will contain:
+ * For the "prepend" operation: "string4:string2:string1:string3"
+ * For the "append" operation: "string1:string3:string4:string2"
+ *
+ * 2. Since the environment variables are also treated as build macros the delimiter is also used
+ * by the BuildMacroProvider to determine the type of the macro used to represent the
+ * given environment variable. If the variable has the delimiter it is treated as the Text-List macro
+ * otherwise it is treated as the Text macro. (See Build Macro design for more details)
+ *
+ * To specify that no delimiter should be used, the getDelimiter() method should
+ * return null or an empty string
+ */
+ public String getDelimiter();
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java
new file mode 100644
index 00000000000..e76be1059a4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.envvar;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+
+
+/**
+ *
+ * this interface represent the environment variable provider - the main entry-point
+ * to be used for querying the build environment
+ *
+ * @since 3.0
+ */
+public interface IEnvironmentVariableManager{
+
+ /**
+ *
+ *
+ * @return the reference to the IBuildEnvironmentVariable interface representing
+ * the variable of a given name
+ * @param variableName environment variable name
+ * if environment variable names are case insensitive in the current OS,
+ * the environment variable provider will query the getVariable method of suppliers always
+ * passing it the uppercase variable name not depending on the case of the variableName
+ * passed to the IEnvironmentVariableProvider.getVariable() method. This will prevent the
+ * supplier from answering different values for the same variable given the names that differ
+ * only by case. E.g. if the current OS does not support case sensitive variables both of the
+ * calls below:
+ *
+ * provider.getVariable("FOO",level,includeParentContexts);
+ * provider.getVariable("foo",level,includeParentContexts);
+ *
+ * will result in asking suppliers for the "FOO" variable
+ *
+ * @param level could be one of the following:
+ * 1. IConfiguration to represent the configuration
+ * 2. IManagedProject to represent the managed project
+ * 3. IWorkspace to represent the workspace
+ * 4. null to represent the system environment passed to eclipse
+ */
+ public IEnvironmentVariable getVariable(String name, ICConfigurationDescription cfg, boolean resolveMacros);
+
+ /**
+ *
+ * if environment variable names are case insensitive in the current OS,
+ * the environment variable provider will remove the duplicates of the variables if their names
+ * differ only by case
+ *
+ * @return the array of IBuildEnvironmentVariable that represents the environment variables
+ */
+ public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros);
+
+ /**
+ *
+ * @return the String representing default system delimiter. That is the ":" for Unix-like
+ * systems and the ";" for Win32 systems. This method will be used by the
+ * tool-integrator provided variable supplier e.g. in order to concatenate the list of paths into the
+ * environment variable, etc.
+ */
+ public String getDefaultDelimiter();
+
+ /**
+ * @return true if the OS supports case sensitive variables (Unix-like systems) or false
+ * if it does not (Win32 systems)
+ */
+ public boolean isVariableCaseSensitive();
+
+ public IContributedEnvironment getContributedEnvironment();
+}
+
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java
new file mode 100644
index 00000000000..49577c134d2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java
@@ -0,0 +1,257 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICExtension;
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.core.ICOwnerInfo;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.util.CExtensionUtil;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
+import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
+import org.eclipse.cdt.internal.core.settings.model.InternalXmlStorageElement;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.w3c.dom.Element;
+
+public class CConfigBasedDescriptor implements ICDescriptor {
+ private static final String CEXTENSION_NAME = "cextension"; //$NON-NLS-1$
+
+ private ICConfigurationDescription fCfgDes;
+ private IProject fProject;
+ private COwner fOwner;
+ private HashMap fDesMap = new HashMap();
+ private HashMap fStorageDataElMap = new HashMap();
+ private boolean fApplyOnChange = true;
+ private boolean fIsDirty;
+
+ class CConfigBaseDescriptorExtensionReference implements ICExtensionReference{
+ private ICConfigExtensionReference fCfgExtRef;
+ CConfigBaseDescriptorExtensionReference(ICConfigExtensionReference cfgRef){
+ fCfgExtRef = cfgRef;
+ }
+
+ public ICExtension createExtension() throws CoreException {
+ InternalCExtension cExtension = null;
+ IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(fCfgExtRef, CEXTENSION_NAME, false);
+ cExtension = (InternalCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
+ cExtension.setExtensionReference(this);
+ cExtension.setProject(fProject);
+ return (ICExtension)cExtension;
+ }
+
+ public ICDescriptor getCDescriptor() {
+ return CConfigBasedDescriptor.this;
+ }
+
+ public String getExtension() {
+ return fCfgExtRef.getExtensionPoint();
+ }
+
+ public String getExtensionData(String key) {
+ return fCfgExtRef.getExtensionData(key);
+ }
+
+ public IConfigurationElement[] getExtensionElements()
+ throws CoreException {
+ IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(fCfgExtRef, CEXTENSION_NAME, false);
+ if(el != null)
+ return el.getChildren();
+ return new IConfigurationElement[0];
+ }
+
+ public String getID() {
+ return fCfgExtRef.getID();
+ }
+
+ public void setExtensionData(String key, String value)
+ throws CoreException {
+ fCfgExtRef.setExtensionData(key, value);
+ checkApply();
+ }
+ }
+
+ public CConfigBasedDescriptor(ICConfigurationDescription des) throws CoreException{
+ updateConfiguration(des);
+ }
+
+ public void setApplyOnChange(boolean apply){
+ if(fApplyOnChange == apply)
+ return;
+
+ fApplyOnChange = apply;
+ }
+
+ public boolean isApplyOnChange(){
+ return fApplyOnChange;
+ }
+
+ public void apply(boolean force) throws CoreException{
+ if(force || fIsDirty){
+ CProjectDescriptionManager.getInstance().setProjectDescription(fProject, fCfgDes.getProjectDescription());
+ fIsDirty = false;
+ }
+ }
+
+ private void checkApply() throws CoreException {
+ if(fApplyOnChange){
+ CProjectDescriptionManager.getInstance().setProjectDescription(fProject, fCfgDes.getProjectDescription());
+ fIsDirty = false;
+ } else {
+ fIsDirty = true;
+ }
+ }
+
+ public ICExtensionReference create(String extensionPoint, String id)
+ throws CoreException {
+ ICConfigExtensionReference ref = fCfgDes.create(extensionPoint, id);
+ ICExtensionReference r = create(ref);
+ checkApply();
+ return r;
+ }
+
+ public void updateConfiguration(ICConfigurationDescription des) throws CoreException{
+ fCfgDes = des;
+ fProject = fCfgDes.getProjectDescription().getProject();
+ fOwner = ((IInternalCCfgInfo)fCfgDes).getSpecSettings().getCOwner();
+ }
+
+ private CConfigBaseDescriptorExtensionReference create(ICConfigExtensionReference ref){
+ CConfigBaseDescriptorExtensionReference dr = new CConfigBaseDescriptorExtensionReference(ref);
+ ArrayList list = (ArrayList)fDesMap.get(ref.getExtensionPoint());
+ if(list == null){
+ list = new ArrayList(1);
+ fDesMap.put(ref.getExtensionPoint(), list);
+ } else {
+ list.ensureCapacity(list.size() + 1);
+ }
+ list.add(dr);
+ return dr;
+ }
+
+ public ICExtensionReference[] get(String extensionPoint) {
+ ICConfigExtensionReference cfgRefs[] = fCfgDes.get(extensionPoint);
+ if(cfgRefs.length == 0){
+ return new ICExtensionReference[0];
+ }
+
+ ICExtensionReference[] extRefs = new ICExtensionReference[cfgRefs.length];
+ ArrayList list = (ArrayList)fDesMap.get(extensionPoint);
+// if(list == null){
+// list = new ArrayList(cfgRefs.length);
+// fDesMap.put(extensionPoint, list);
+// }
+
+// list = (ArrayList)list.clone();
+//
+// CConfigBaseDescriptorExtensionReference[] refs = (CConfigBaseDescriptorExtensionReference[])list.
+// toArray(new CConfigBaseDescriptorExtensionReference[list.size()]);
+ int num = cfgRefs.length - 1;
+
+ for(int i = cfgRefs.length - 1; i >= 0; i--){
+ ICConfigExtensionReference ref = cfgRefs[i];
+ int k = list != null ? list.size() - 1 : -1;
+
+ for(; k >= 0; k--){
+ CConfigBaseDescriptorExtensionReference r = (CConfigBaseDescriptorExtensionReference)list.get(k);
+ if(r.fCfgExtRef == ref){
+ extRefs[num--] = r;
+ list.remove(k);
+ break;
+ }
+ }
+ if(k < 0){
+ extRefs[num--] = new CConfigBaseDescriptorExtensionReference(ref);
+ }
+ }
+
+ if(list == null){
+ list = new ArrayList(cfgRefs.length);
+ fDesMap.put(extensionPoint, list);
+ } else {
+ list.clear();
+ list.ensureCapacity(cfgRefs.length);
+ }
+
+ list.addAll(Arrays.asList(extRefs));
+ list.trimToSize();
+ return extRefs;
+ }
+
+ public ICExtensionReference[] get(String extensionPoint, boolean update)
+ throws CoreException {
+ if(update)
+ fOwner.update(fProject, this, extensionPoint);
+ return get(extensionPoint);
+ }
+
+ public String getPlatform() {
+ return fOwner.getPlatform();
+ }
+
+ public IProject getProject() {
+ return fProject;
+ }
+
+ public Element getProjectData(String id) throws CoreException {
+ Element el = (Element)fStorageDataElMap.get(id);
+ if(el == null){
+ InternalXmlStorageElement storageEl = (InternalXmlStorageElement)fCfgDes.getStorage(id, true);
+ el = CProjectDescriptionManager.getInstance().createXmlElementCopy(storageEl);
+ fStorageDataElMap.put(id, el);
+ }
+ return el;
+ }
+
+ public ICOwnerInfo getProjectOwner() {
+ return fOwner;
+ }
+
+ public void remove(ICExtensionReference extension) throws CoreException {
+ ICConfigExtensionReference ref =((CConfigBaseDescriptorExtensionReference)extension).fCfgExtRef;
+ fCfgDes.remove(ref);
+ checkApply();
+ }
+
+ public void remove(String extensionPoint) throws CoreException {
+ fCfgDes.remove(extensionPoint);
+ checkApply();
+ }
+
+ public void saveProjectData() throws CoreException {
+ CConfigurationSpecSettings specSettings = ((IInternalCCfgInfo)fCfgDes).getSpecSettings();
+ for(Iterator iter = fStorageDataElMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String id = (String)entry.getKey();
+ Element el = (Element)entry.getValue();
+ InternalXmlStorageElement storEl = new InternalXmlStorageElement(el, false);
+ specSettings.importStorage(id, storEl);
+ iter.remove();
+ }
+ checkApply();
+ }
+
+ public ICConfigurationDescription getConfigurationDescription() {
+ return fCfgDes;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java
new file mode 100644
index 00000000000..2d2526fc5b3
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java
@@ -0,0 +1,413 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CDescriptorEvent;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICDescriptorListener;
+import org.eclipse.cdt.core.ICDescriptorManager;
+import org.eclipse.cdt.core.ICDescriptorOperation;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionEvent;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
+import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
+import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta;
+import org.eclipse.cdt.internal.core.settings.model.ICProjectDescriptionListener;
+import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
+import org.eclipse.cdt.internal.core.settings.model.PathEntryConfigurationDataProvider;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
+
+public class CConfigBasedDescriptorManager implements ICDescriptorManager {
+ private static CConfigBasedDescriptorManager fInstance;
+ public static final String NULL_OWNER_ID = ""; //$NON-NLS-1$
+ private Map fOwnerConfigMap = null;
+ private ICProjectDescriptionListener fDescriptionListener;
+
+ private static final QualifiedName DESCRIPTOR_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "CDescriptor"); //$NON-NLS-1$
+
+ private List fListeners = Collections.synchronizedList(new Vector());
+
+
+ private CConfigBasedDescriptorManager(){
+ }
+
+ public static CConfigBasedDescriptorManager getInstance(){
+ if(fInstance == null){
+ fInstance = new CConfigBasedDescriptorManager();
+ }
+ return fInstance;
+ }
+
+ private static final COwnerConfiguration NULLCOwner = new COwnerConfiguration(NULL_OWNER_ID,
+ CCorePlugin.getResourceString("CDescriptorManager.internal_owner")); //$NON-NLS-1$
+
+ public void configure(IProject project, String id) throws CoreException {
+ CConfigBasedDescriptor dr;
+ if (id.equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
+ IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+ CCorePlugin.getResourceString("CDescriptorManager.exception.invalid_ownerID"), //$NON-NLS-1$
+ (Throwable)null);
+ throw new CoreException(status);
+ }
+ synchronized (this) {
+ dr = findDescriptor(project, false);
+ if (dr != null) {
+ if (dr.getProjectOwner().getID().equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
+ // non owned descriptors are simply configure to the new owner no questions ask!
+ dr = updateDescriptor(project, dr, id);
+ dr.apply(true);
+ } else if (!dr.getProjectOwner().getID().equals(id)) {
+ IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS,
+ CCorePlugin.getResourceString("CDescriptorManager.exception.alreadyConfigured"), //$NON-NLS-1$
+ (Throwable)null);
+ throw new CoreException(status);
+ } else {
+ return; // already configured with same owner.
+ }
+ } else {
+// try {
+ dr = findDescriptor(project, true);
+ dr = updateDescriptor(project, dr, id);
+ dr.apply(true);
+// } catch (CoreException e) { // if .cdtproject already exists we'll use that
+// IStatus status = e.getStatus();
+// if (status.getCode() == CCorePlugin.STATUS_CDTPROJECT_EXISTS) {
+// descriptor = new CDescriptor(this, project);
+// } else
+// throw e;
+// }
+ }
+ }
+ }
+
+ private CConfigBasedDescriptor updateDescriptor(IProject project, CConfigBasedDescriptor dr, String ownerId) throws CoreException{
+ ICConfigurationDescription cfgDes = dr.getConfigurationDescription();
+ ICProjectDescription projDes = cfgDes.getProjectDescription();
+ CConfigurationSpecSettings settings = ((IInternalCCfgInfo)cfgDes).getSpecSettings();
+ settings.setCOwner(ownerId);
+ COwner owner = settings.getCOwner();
+ setLoaddedDescriptor(projDes, null);
+ dr = findDescriptor(projDes);
+ dr.setApplyOnChange(false);
+ owner.configure(project, dr);
+ dr.setApplyOnChange(true);
+
+ return dr;
+ }
+
+ public void convert(IProject project, String id) throws CoreException {
+ CConfigBasedDescriptor dr = findDescriptor(project, false);
+ if(dr == null){
+ throw ExceptionFactory.createCoreException("the project is not a CDT project");
+ }
+
+
+
+// boolean applyOnChange = dr.isApplyOnChange();
+// CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(project);
+// if(des == null){
+// throw ExceptionFactory.createCoreException("the project is not a CDT project");
+// }
+// ICConfigurationDescription cfgDes = des.getIndexConfiguration();
+// if(cfgDes == null){
+// throw ExceptionFactory.createCoreException("the projecty does not contain valid configurations");
+// }
+
+ dr = updateDescriptor(project, dr, id);
+ dr.apply(true);
+ }
+
+ public ICDescriptor getDescriptor(IProject project) throws CoreException {
+ return getDescriptor(project, true);
+ }
+
+ public ICDescriptor getDescriptor(IProject project, boolean create)
+ throws CoreException {
+ return findDescriptor(project, create);
+ }
+
+ public void addDescriptorListener(ICDescriptorListener listener) {
+ fListeners.add(listener);
+ }
+
+ public void removeDescriptorListener(ICDescriptorListener listener) {
+ fListeners.remove(listener);
+ }
+
+ public void runDescriptorOperation(IProject project,
+ ICDescriptorOperation op, IProgressMonitor monitor)
+ throws CoreException {
+ CConfigBasedDescriptor dr = findDescriptor(project, true);
+ if (dr == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Failed to create descriptor", null)); //$NON-NLS-1$
+ }
+
+ synchronized (dr) {
+ dr.setApplyOnChange(false);
+ try {
+ op.execute(dr, monitor);
+ } finally {
+ dr.setApplyOnChange(true);
+ }
+ }
+
+ dr.apply(false);
+ }
+
+ private CConfigBasedDescriptor getLoaddedDescriptor(ICProjectDescription des){
+ return (CConfigBasedDescriptor)des.getSessionProperty(DESCRIPTOR_PROPERTY);
+ }
+
+ private void setLoaddedDescriptor(ICProjectDescription des, CConfigBasedDescriptor dr){
+ des.setSessionProperty(DESCRIPTOR_PROPERTY, dr);
+ }
+
+ private CConfigBasedDescriptor findDescriptor(IProject project, boolean create) throws CoreException{
+ ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ CConfigBasedDescriptor dr = null;
+ if(des == null && create){
+ des = createProjDescriptionForDescriptor(project);
+ }
+ if(des != null){
+ dr = findDescriptor(des);
+ }
+ return dr;
+ }
+
+ private CConfigBasedDescriptor findDescriptor(ICProjectDescription des) throws CoreException{
+ CConfigBasedDescriptor dr = getLoaddedDescriptor(des);
+ if(dr == null){
+ dr = loadDescriptor((CProjectDescription)des);
+ if(dr != null){
+ setLoaddedDescriptor(des, dr);
+ }
+ }
+ return dr;
+ }
+
+ private CProjectDescription createProjDescriptionForDescriptor(IProject project) throws CoreException{
+ CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
+ CProjectDescription des = (CProjectDescription)mngr.createProjectDescription(project, false);
+
+ CConfigurationData data = mngr.createDefaultConfigData(project, PathEntryConfigurationDataProvider.getDataFactory());
+ des.createConfiguration(CProjectDescriptionManager.DEFAULT_PROVIDER_ID, data);
+
+ return des;
+ }
+
+ private CConfigBasedDescriptor loadDescriptor(CProjectDescription des) throws CoreException{
+ CConfigBasedDescriptor dr = null;
+
+ if(des != null){
+ if(des.isReadOnly())
+ des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true);
+
+ ICConfigurationDescription cfgDes = des.getIndexConfiguration();
+
+
+ if(cfgDes != null){
+ dr = new CConfigBasedDescriptor((CConfigurationDescription)cfgDes);
+ } else {
+ throw ExceptionFactory.createCoreException("the project does not contain valid configurations");
+ }
+ }
+
+ return dr;
+ }
+
+ public COwnerConfiguration getOwnerConfiguration(String id) {
+ if (id.equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
+ return NULLCOwner;
+ }
+ if (fOwnerConfigMap == null) {
+ initializeOwnerConfiguration();
+ }
+ COwnerConfiguration config = (COwnerConfiguration)fOwnerConfigMap.get(id);
+ if (config == null) { // no install owner, lets create place holder config for it.
+ config = new COwnerConfiguration(id, CCorePlugin.getResourceString("CDescriptorManager.owner_not_Installed")); //$NON-NLS-1$
+ fOwnerConfigMap.put(id, config);
+ }
+ return config;
+ }
+
+ private void initializeOwnerConfiguration() {
+ IExtensionPoint extpoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CProject"); //$NON-NLS-1$
+ IExtension extension[] = extpoint.getExtensions();
+ fOwnerConfigMap = new HashMap(extension.length);
+ for (int i = 0; i < extension.length; i++) {
+ IConfigurationElement element[] = extension[i].getConfigurationElements();
+ for (int j = 0; j < element.length; j++) {
+ if (element[j].getName().equalsIgnoreCase("cproject")) { //$NON-NLS-1$
+ fOwnerConfigMap.put(extension[i].getUniqueIdentifier(), new COwnerConfiguration(element[j]));
+ break;
+ }
+ }
+ }
+ }
+
+ public void startup(){
+ if(fDescriptionListener == null){
+ fDescriptionListener = new ICProjectDescriptionListener(){
+
+ public void handleEvent(CProjectDescriptionEvent event) {
+ doHandleEvent(event);
+ }
+
+ };
+ CProjectDescriptionManager.getInstance().addListener(fDescriptionListener, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
+ }
+ }
+
+ public void shutdown(){
+ if(fDescriptionListener != null){
+ CProjectDescriptionManager.getInstance().removeListener(fDescriptionListener);
+ }
+ }
+
+ private void doHandleEvent(CProjectDescriptionEvent event){
+ try {
+ switch(event.getEventType()){
+ case CProjectDescriptionEvent.LOADDED:{
+ CProjectDescription des = (CProjectDescription)event.getNewCProjectDescription();
+ CConfigBasedDescriptor dr = getLoaddedDescriptor(des);
+ if(dr != null){
+ //the descriptor was requested while load process
+ des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true);
+ ICConfigurationDescription cfgDescription = des.getIndexConfiguration();
+ if(cfgDescription != null)
+ dr.updateConfiguration((CConfigurationDescription)cfgDescription);
+ else
+ setLoaddedDescriptor(des, null);
+ }
+ }
+ break;
+ case CProjectDescriptionEvent.APPLIED:
+ CProjectDescription newDes = (CProjectDescription)event.getNewCProjectDescription();
+ CProjectDescription oldDes = (CProjectDescription)event.getOldCProjectDescription();
+ CDescriptorEvent desEvent = null;
+ CConfigBasedDescriptor dr = null;
+ ICConfigurationDescription updatedCfg = null;
+ if(oldDes == null){
+ dr = findDescriptor(newDes);
+ updatedCfg = newDes.getIndexConfiguration();
+ if(dr != null){
+ desEvent = new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_ADDED, 0);
+ }
+ } else if(newDes == null) {
+ dr = findDescriptor(oldDes);
+ if(dr != null){
+ desEvent = new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_REMOVED, 0);
+ }
+ } else {
+ dr = findDescriptor(newDes);
+ updatedCfg = newDes.getIndexConfiguration();
+ if(dr != null){
+ ICConfigurationDescription newCfg = newDes.getIndexConfiguration();
+ ICConfigurationDescription oldCfg = oldDes.getIndexConfiguration();
+ int flags = 0;
+ if(newCfg.getId().equals(oldCfg.getId())){
+ ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
+ if(cfgDelta != null){
+ flags = cfgDelta.getChangeFlags() & (ICDescriptionDelta.EXT_REF | ICDescriptionDelta.OWNER);
+ }
+ } else {
+ flags = CProjectDescriptionManager.getInstance().calculateDescriptorFlags(newCfg, oldCfg);
+ }
+
+ int drEventFlags = descriptionFlagsToDescriptorFlags(flags);
+ if(drEventFlags != 0){
+ desEvent = new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_CHANGED, drEventFlags);
+ }
+ }
+ }
+
+ if(updatedCfg != null && dr != null){
+ CProjectDescription writableDes = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(event.getProject(), true);
+ ICConfigurationDescription indexCfg = writableDes.getIndexConfiguration();
+ dr.updateConfiguration((CConfigurationDescription)indexCfg);
+ }
+ if(desEvent != null){
+ notifyListeners(desEvent);
+ }
+ break;
+ }
+ } catch (CoreException e){
+ }
+ }
+
+ private int descriptionFlagsToDescriptorFlags(int flags){
+ int result = 0;
+ if((flags & ICDescriptionDelta.EXT_REF) != 0){
+ result |= CDescriptorEvent.EXTENSION_CHANGED;
+ }
+// if((flags & ICDescriptionDelta.OWNER) != 0){
+ result |= CDescriptorEvent.OWNER_CHANGED;
+// }
+ return result;
+ }
+ private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){
+ if(delta == null)
+ return null;
+ ICDescriptionDelta children[] = delta.getChildren();
+ for(int i = 0; i < children.length; i++){
+ ICSettingObject s = children[i].getNewSetting();
+ if(s != null && id.equals(s.getId()))
+ return children[i];
+ }
+ return null;
+ }
+
+ protected void notifyListeners(final CDescriptorEvent event) {
+ final ICDescriptorListener[] listeners;
+ synchronized (fListeners) {
+ listeners = (ICDescriptorListener[])fListeners.toArray(new ICDescriptorListener[fListeners.size()]);
+ }
+ for (int i = 0; i < listeners.length; i++) {
+ final int index = i;
+ Platform.run(new ISafeRunnable() {
+
+ public void handleException(Throwable exception) {
+ IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+ CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
+ CCorePlugin.log(status);
+ }
+
+ public void run() throws Exception {
+ listeners[index].descriptorChanged(event);
+ }
+ });
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java
index d9c98700356..701a0641a50 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptor.java
@@ -36,6 +36,7 @@ import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtension;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.ICOwnerInfo;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -61,582 +62,589 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;
-public class CDescriptor implements ICDescriptor {
-
- final CDescriptorManager fManager;
- final IProject fProject;
- private COwner fOwner;
-
- private HashMap extMap = new HashMap(4);
- private HashMap extInfoMap = new HashMap(4);
- private Document dataDoc;
-
- protected static final String DESCRIPTION_FILE_NAME = ".cdtproject"; //$NON-NLS-1$
-
- private static final String CEXTENSION_NAME = "cextension"; //$NON-NLS-1$
-
- private static final String PROJECT_DESCRIPTION = "cdtproject"; //$NON-NLS-1$
- private static final String PROJECT_OWNER_ID = "id"; //$NON-NLS-1$
- private static final String PROJECT_EXTENSION = "extension"; //$NON-NLS-1$
- private static final String PROJECT_EXTENSION_ATTR_POINT = "point"; //$NON-NLS-1$
- private static final String PROJECT_EXTENSION_ATTR_ID = "id"; //$NON-NLS-1$
- private static final String PROJECT_EXTENSION_ATTRIBUTE = "attribute"; //$NON-NLS-1$
- private static final String PROJECT_EXTENSION_ATTRIBUTE_KEY = "key"; //$NON-NLS-1$
- private static final String PROJECT_EXTENSION_ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
-
- private static final String PROJECT_DATA = "data"; //$NON-NLS-1$
- private static final String PROJECT_DATA_ITEM = "item"; //$NON-NLS-1$
- private static final String PROJECT_DATA_ID = "id"; //$NON-NLS-1$
-
- boolean fUpdating;
- boolean isInitializing = true;
- boolean bDirty = false;
-
- protected CDescriptor(CDescriptorManager manager, IProject project, String id) throws CoreException {
- fProject = project;
- fManager = manager;
- IPath projectLocation = project.getDescription().getLocation();
-
- if (projectLocation == null) {
- projectLocation = getProjectDefaultLocation(project);
- }
- IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
-
- if (descriptionPath.toFile().exists()) {
- IStatus status;
- String ownerID = readCDTProjectFile(descriptionPath);
- if (!ownerID.equals("")) { //$NON-NLS-1$
- if (ownerID.equals(id)) {
- status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS,
- CCorePlugin.getResourceString("CDescriptor.exception.projectAlreadyExists"), (Throwable)null); //$NON-NLS-1$
- } else {
- status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_MISMATCH,
- CCorePlugin.getResourceString("CDescriptor.exception.unmatchedOwnerId") + "<requested:" +id +"/ In file:" +ownerID+">", (Throwable)null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- throw new CoreException(status);
- }
- }
- fOwner = new COwner(manager.getOwnerConfiguration(id));
- fOwner.configure(project, this);
- isInitializing = false;
- save();
- }
-
- protected CDescriptor(CDescriptorManager manager, IProject project) throws CoreException {
- fProject = project;
- fManager = manager;
- IPath projectLocation = project.getDescription().getLocation();
-
- if (projectLocation == null) {
- projectLocation = getProjectDefaultLocation(project);
- }
- IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
-
- if (!descriptionPath.toFile().exists()) {
- fOwner = new COwner(manager.getOwnerConfiguration(project));
- fOwner.configure(project, this);
- fManager.updateDescriptor(this);
- } else {
- String ownerId = readCDTProjectFile(descriptionPath);
- fOwner = new COwner(manager.getOwnerConfiguration(ownerId));
- }
- isInitializing = false;
- }
-
- protected CDescriptor(CDescriptorManager manager, IProject project, COwner owner) throws CoreException {
- fProject = project;
- fManager = manager;
- IPath projectLocation = project.getDescription().getLocation();
-
- if (projectLocation == null) {
- projectLocation = getProjectDefaultLocation(project);
- }
- IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
-
- if (descriptionPath.toFile().exists()) {
- readCDTProjectFile(descriptionPath);
- }
- fOwner = owner;
- fOwner.configure(project, this);
- isInitializing = false;
- save();
- }
-
- private String readCDTProjectFile(IPath descriptionPath) throws CoreException {
- String ownerID = ""; //$NON-NLS-1$
- try {
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = parser.parse(descriptionPath.toFile());
- NodeList nodeList = document.getElementsByTagName(PROJECT_DESCRIPTION);
- if (nodeList != null && nodeList.getLength() > 0) {
- Node node = nodeList.item(0);
- if (node.hasAttributes()) {
- ownerID = node.getAttributes().getNamedItem(PROJECT_OWNER_ID).getNodeValue();
- }
- readProjectDescription(node);
- return ownerID;
- }
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
- CCorePlugin.getResourceString("CDescriptor.exception.missingElement"), null); //$NON-NLS-1$
- throw new CoreException(status);
- } catch (Exception e) {
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.toString(), e);
- throw new CoreException(status);
- }
- }
-
- private static IPath getProjectDefaultLocation(IProject project) {
- return Platform.getLocation().append(project.getFullPath());
- }
-
- public ICOwnerInfo getProjectOwner() {
- return fOwner;
- }
-
- public String getPlatform() {
- return fOwner.getPlatform();
- }
-
- public IProject getProject() {
- return fProject;
- }
-
- synchronized public ICExtensionReference[] get(String extensionID) {
- CExtensionReference[] refs = (CExtensionReference[])extMap.get(extensionID);
- if (refs == null)
- return new ICExtensionReference[0];
- return refs;
- }
-
- synchronized public ICExtensionReference[] get(String extensionID, boolean update) throws CoreException {
- ICExtensionReference[] refs = get(extensionID);
- if (refs.length == 0 && update) {
- boolean oldIsInitializing = isInitializing;
- isInitializing = true;
- fOwner.update(fProject, this, extensionID);
- isInitializing = oldIsInitializing;
- updateIfDirty();
- refs = get(extensionID);
- }
- return refs;
- }
-
- private CExtensionReference createRef(String extensionPoint, String extension) {
- CExtensionReference extensions[] = (CExtensionReference[])extMap.get(extensionPoint);
- if (extensions == null) {
- extensions = new CExtensionReference[1];
- extMap.put(extensionPoint, extensions);
- } else {
- CExtensionReference[] newExtensions = new CExtensionReference[extensions.length + 1];
- System.arraycopy(extensions, 0, newExtensions, 0, extensions.length);
- extensions = newExtensions;
- extMap.put(extensionPoint, extensions);
- }
- extensions[extensions.length - 1] = new CExtensionReference(this, extensionPoint, extension);
- return extensions[extensions.length - 1];
- }
-
- synchronized public ICExtensionReference create(String extensionPoint, String extension) throws CoreException {
- boolean fireEvent = false;
- CExtensionReference extRef;
- synchronized (this) {
- extRef = createRef(extensionPoint, extension);
- updateOnDisk();
- if (!isInitializing) {
- fireEvent = true;
- }
- }
- if (fireEvent) {
- fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
- }
- return extRef;
- }
-
- synchronized public void remove(ICExtensionReference ext) throws CoreException {
- boolean fireEvent = false;
- synchronized (this) {
- CExtensionReference extensions[] = (CExtensionReference[])extMap.get(ext.getExtension());
- for (int i = 0; i < extensions.length; i++) {
- if (extensions[i] == ext) {
- System.arraycopy(extensions, i, extensions, i + 1, extensions.length - 1 - i);
- if (extensions.length > 1) {
- CExtensionReference[] newExtensions = new CExtensionReference[extensions.length - 1];
- System.arraycopy(extensions, 0, newExtensions, 0, newExtensions.length);
- extMap.put(ext.getExtension(), newExtensions);
- } else {
- extMap.remove(ext.getExtension());
- }
- updateOnDisk();
- if (!isInitializing) {
- fireEvent = true;
- }
- }
- }
- }
- if (fireEvent) {
- fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
- }
- }
-
- public void remove(String extensionPoint) throws CoreException {
- boolean fireEvent = false;
- synchronized (this) {
- CExtensionReference extensions[] = (CExtensionReference[])extMap.get(extensionPoint);
- if (extensions != null) {
- extMap.remove(extensionPoint);
- updateOnDisk();
- if (!isInitializing) {
- fireEvent = true;
- }
- }
- }
- if (fireEvent) {
- fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
- }
- }
-
- synchronized CExtensionInfo getInfo(CExtensionReference cProjectExtension) {
- CExtensionInfo info = (CExtensionInfo)extInfoMap.get(cProjectExtension);
- if (info == null) {
- info = new CExtensionInfo();
- extInfoMap.put(cProjectExtension, info);
- }
- return info;
- }
-
- protected IFile getFile() {
- return getProject().getFile(DESCRIPTION_FILE_NAME);
- }
-
- void save() throws CoreException {
- IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
- ISchedulingRule rule;
- IFile rscFile = getFile();
- if (rscFile.exists()) {
- rule = ruleFactory.modifyRule(rscFile);
- } else {
- rule = ruleFactory.createRule(rscFile);
- }
- fManager.getWorkspace().run(new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor mon) throws CoreException {
- String xml;
- bDirty = false;
- if (!fProject.isAccessible()) {
- return;
- }
- fUpdating = true;
-
- try {
- xml = getAsXML();
- } catch (IOException e) {
- IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
- throw new CoreException(s);
- } catch (TransformerException e) {
- IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
- throw new CoreException(s);
- } catch (ParserConfigurationException e) {
- IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
- throw new CoreException(s);
- }
-
- IFile rscFile = getFile();
- InputStream inputStream;
- try {
- inputStream = new ByteArrayInputStream(xml.getBytes("UTF8")); //$NON-NLS-1$
- if (rscFile.exists()) {
- if (rscFile.isReadOnly()) {
- // provide opportunity to checkout read-only .cdtproject file
- fManager.getWorkspace().validateEdit(new IFile[]{rscFile}, null);
- }
- rscFile.setContents(inputStream, IResource.FORCE, null);
- } else {
- rscFile.create(inputStream, IResource.FORCE, null);
- }
- } catch (UnsupportedEncodingException e) {
- IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
- throw new CoreException(s);
- }
- fUpdating = false;
- }
- }, rule, IWorkspace.AVOID_UPDATE, null);
- }
-
- boolean isUpdating() {
- return fUpdating;
- }
-
- void updateIfDirty() {
- if ( bDirty ) {
- updateOnDisk();
- }
- }
-
- synchronized void updateOnDisk() {
- if (isUpdating()) {
- return;
- }
- if (isInitializing) {
- bDirty = true;
- return;
- }
- fUpdating = true;
- fManager.updateDescriptor(this);
- }
-
- void updateFromDisk() throws CoreException {
- COwner origOwner;
- HashMap origExtMap;
- HashMap origExtInfoMap;
- Document origDataDoc;
- synchronized (this) {
- IPath projectLocation = fProject.getDescription().getLocation();
-
- if (projectLocation == null) {
- projectLocation = getProjectDefaultLocation(fProject);
- }
- IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
- if (!descriptionPath.toFile().exists()) {
- updateOnDisk();
- return;
- }
-
- origOwner = fOwner;
- origExtMap = extMap;
- origExtInfoMap = extInfoMap;
- origDataDoc = dataDoc;
-
- extMap = new HashMap(4);
- extInfoMap = new HashMap(4);
- dataDoc = null;
-
- try {
- String ownerId = readCDTProjectFile(descriptionPath);
- fOwner = new COwner(fManager.getOwnerConfiguration(ownerId));
- } catch (CoreException e) {
- CCorePlugin.log(e);
- fOwner = origOwner;
- extMap = origExtMap;
- extInfoMap = origExtInfoMap;
- dataDoc = origDataDoc;
- }
- }
- if (!fOwner.equals(origOwner)) {
- fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
- } else {
- boolean extChanges = true;
- if (extMap.size() == origExtMap.size() && extInfoMap.size() == origExtInfoMap.size()) {
- extChanges = false;
- Iterator entries = extMap.entrySet().iterator();
- while (entries.hasNext()) {
- Entry entry = (Entry)entries.next();
- if (!origExtMap.containsKey(entry.getKey())) {
- extChanges = true;
- break;
- }
- CExtensionReference origExt[] = (CExtensionReference[])origExtMap.get(entry.getKey());
- CExtensionReference newExt[] = (CExtensionReference[])entry.getValue();
- if (!Arrays.equals(origExt, newExt)) {
- extChanges = true;
- break;
- }
- }
- }
- if (extChanges) {
- fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED,
- CDescriptorEvent.EXTENSION_CHANGED));
- } else {
- fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
- }
- }
- }
-
- private void readProjectDescription(Node node) {
- Node childNode;
- NodeList list = node.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- childNode = list.item(i);
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- if (childNode.getNodeName().equals(PROJECT_EXTENSION)) {
- try {
- decodeProjectExtension((Element)childNode);
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- } else if (childNode.getNodeName().equals(PROJECT_DATA)) {
- try {
- decodeProjectData((Element)childNode);
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- }
- }
- }
- }
-
- private void decodeProjectExtension(Element element) throws CoreException {
- String point = element.getAttribute(PROJECT_EXTENSION_ATTR_POINT);
- String id = element.getAttribute(PROJECT_EXTENSION_ATTR_ID);
- CExtensionReference ext = createRef(point, id);
- NodeList extAttrib = element.getChildNodes();
- for (int j = 0; j < extAttrib.getLength(); j++) {
- if (extAttrib.item(j).getNodeName().equals(PROJECT_EXTENSION_ATTRIBUTE)) {
- NamedNodeMap attrib = extAttrib.item(j).getAttributes();
- getInfo(ext).setAttribute(attrib.getNamedItem(PROJECT_EXTENSION_ATTRIBUTE_KEY).getNodeValue(),
- attrib.getNamedItem(PROJECT_EXTENSION_ATTRIBUTE_VALUE).getNodeValue());
- }
- }
- }
-
- private void encodeProjectExtensions(Document doc, Element configRootElement) {
- Element element;
- Iterator extIterator = extMap.values().iterator();
- while (extIterator.hasNext()) {
- CExtensionReference extension[] = (CExtensionReference[])extIterator.next();
- for (int i = 0; i < extension.length; i++) {
- configRootElement.appendChild(element = doc.createElement(PROJECT_EXTENSION));
- element.setAttribute(PROJECT_EXTENSION_ATTR_POINT, extension[i].getExtension());
- element.setAttribute(PROJECT_EXTENSION_ATTR_ID, extension[i].getID());
- CExtensionInfo info = (CExtensionInfo)extInfoMap.get(extension[i]);
- if (info != null) {
- Iterator attribIterator = info.getAttributes().entrySet().iterator();
- while (attribIterator.hasNext()) {
- Entry entry = (Entry)attribIterator.next();
- Element extAttributes = doc.createElement(PROJECT_EXTENSION_ATTRIBUTE);
- extAttributes.setAttribute(PROJECT_EXTENSION_ATTRIBUTE_KEY, (String)entry.getKey());
- extAttributes.setAttribute(PROJECT_EXTENSION_ATTRIBUTE_VALUE, (String)entry.getValue());
- element.appendChild(extAttributes);
- }
- }
- }
- }
- }
-
- String getAsXML() throws IOException, TransformerException, ParserConfigurationException {
- DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
- Document doc = docBuilder.newDocument();
- ProcessingInstruction version = doc.createProcessingInstruction("eclipse-cdt", "version=\"2.0\""); //$NON-NLS-1$ //$NON-NLS-2$
- doc.appendChild(version);
- Element configRootElement = doc.createElement(PROJECT_DESCRIPTION);
- doc.appendChild(configRootElement);
- if (fOwner.getID().length() > 0) {
- configRootElement.setAttribute(PROJECT_OWNER_ID, fOwner.getID());
- }
- encodeProjectExtensions(doc, configRootElement);
- encodeProjectData(doc, configRootElement);
- return serializeDocument(doc);
- }
-
- protected ICExtension createExtensions(ICExtensionReference ext) throws CoreException {
- InternalCExtension cExtension = null;
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ext.getExtension());
- IExtension extension = extensionPoint.getExtension(ext.getID());
- if (extension == null) {
- throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
- CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound") + ":" + ext.getID(), null)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- IConfigurationElement element[] = extension.getConfigurationElements();
- for (int i = 0; i < element.length; i++) {
- if (element[i].getName().equalsIgnoreCase(CEXTENSION_NAME)) {
- cExtension = (InternalCExtension)element[i].createExecutableExtension("run"); //$NON-NLS-1$
- cExtension.setExtensionReference(ext);
- cExtension.setProject(fProject);
- break;
- }
- }
- return (ICExtension)cExtension;
- }
-
- protected IConfigurationElement[] getConfigurationElement(ICExtensionReference ext) throws CoreException {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ext.getExtension());
- IExtension extension = extensionPoint.getExtension(ext.getID());
- if (extension == null) {
- throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
- CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound"), null)); //$NON-NLS-1$
- }
- IConfigurationElement element[] = extension.getConfigurationElements();
- for (int i = 0; i < element.length; i++) {
- if (element[i].getName().equalsIgnoreCase(CEXTENSION_NAME)) {
- return element[i].getChildren();
- }
- }
- return new IConfigurationElement[0];
- }
-
- public synchronized Element getProjectData(String id) throws CoreException {
- Document doc = getProjectDataDoc();
- NodeList nodes = doc.getDocumentElement().getElementsByTagName(PROJECT_DATA_ITEM);
- for (int i = 0; i < nodes.getLength(); ++i) {
- Element element = (Element)nodes.item(i);
- if (element != null && element.getAttribute(PROJECT_DATA_ID).equals(id))
- return element;
- }
-
- // Not found, make a new one
- Element element = doc.createElement(PROJECT_DATA_ITEM);
- element.setAttribute(PROJECT_DATA_ID, id);
- doc.getDocumentElement().appendChild(element);
- return element;
- }
-
- public void saveProjectData() throws CoreException {
- save();
- fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
- }
-
- // The project data allows for the storage of any structured information
- // into the cdtproject file.
- synchronized private Document getProjectDataDoc() throws CoreException {
- if (dataDoc == null) {
- try {
- dataDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- } catch (ParserConfigurationException e) {
- throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR,
- CCorePlugin.getResourceString("CDescriptor.extension.internalError"), e)); //$NON-NLS-1$
- }
- Element rootElem = dataDoc.createElement(PROJECT_DATA);
- dataDoc.appendChild(rootElem);
- }
- return dataDoc;
- }
-
- private void decodeProjectData(Element data) throws CoreException {
- Document doc = getProjectDataDoc();
- doc.replaceChild(doc.importNode(data, true), doc.getDocumentElement());
- }
-
- private void encodeProjectData(Document doc, Element root) {
- // Don't create or encode the doc if it isn't there already
- if (dataDoc != null) {
- Element dataElements = dataDoc.getDocumentElement();
- NodeList nodes = dataElements.getElementsByTagName(PROJECT_DATA_ITEM);
- for (int i = 0; i < nodes.getLength(); ++i) {
- Element item = (Element)nodes.item(i);
- if (!item.hasChildNodes()) { // remove any empty item tags
- dataElements.removeChild(item);
- i--; //nodeList is live.... removeal changes nodelist
- }
- }
- root.appendChild(doc.importNode(dataDoc.getDocumentElement(), true));
- }
- }
-
- private String serializeDocument(Document doc) throws IOException, TransformerException {
- ByteArrayOutputStream s = new ByteArrayOutputStream();
-
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
-
- DOMSource source = new DOMSource(doc);
- StreamResult outputTarget = new StreamResult(s);
- transformer.transform(source, outputTarget);
-
- return s.toString("UTF8"); //$NON-NLS-1$
- }
+public class CDescriptor /*implements ICDescriptor */{
+ private CDescriptor(){
+ }
+
+// final CDescriptorManager fManager;
+// final IProject fProject;
+// private COwner fOwner;
+//
+// private HashMap extMap = new HashMap(4);
+// private HashMap extInfoMap = new HashMap(4);
+// private Document dataDoc;
+//
+// protected static final String DESCRIPTION_FILE_NAME = ".cdtproject"; //$NON-NLS-1$
+//
+// private static final String CEXTENSION_NAME = "cextension"; //$NON-NLS-1$
+//
+// private static final String PROJECT_DESCRIPTION = "cdtproject"; //$NON-NLS-1$
+// private static final String PROJECT_OWNER_ID = "id"; //$NON-NLS-1$
+// private static final String PROJECT_EXTENSION = "extension"; //$NON-NLS-1$
+// private static final String PROJECT_EXTENSION_ATTR_POINT = "point"; //$NON-NLS-1$
+// private static final String PROJECT_EXTENSION_ATTR_ID = "id"; //$NON-NLS-1$
+// private static final String PROJECT_EXTENSION_ATTRIBUTE = "attribute"; //$NON-NLS-1$
+// private static final String PROJECT_EXTENSION_ATTRIBUTE_KEY = "key"; //$NON-NLS-1$
+// private static final String PROJECT_EXTENSION_ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
+//
+// private static final String PROJECT_DATA = "data"; //$NON-NLS-1$
+// private static final String PROJECT_DATA_ITEM = "item"; //$NON-NLS-1$
+// private static final String PROJECT_DATA_ID = "id"; //$NON-NLS-1$
+//
+// boolean fUpdating;
+// boolean isInitializing = true;
+// boolean bDirty = false;
+//
+// protected CDescriptor(CDescriptorManager manager, IProject project, String id) throws CoreException {
+// fProject = project;
+// fManager = manager;
+// IPath projectLocation = project.getDescription().getLocation();
+//
+// if (projectLocation == null) {
+// projectLocation = getProjectDefaultLocation(project);
+// }
+// IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
+//
+// if (descriptionPath.toFile().exists()) {
+// IStatus status;
+// String ownerID = readCDTProjectFile(descriptionPath);
+// if (!ownerID.equals("")) { //$NON-NLS-1$
+// if (ownerID.equals(id)) {
+// status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS,
+// CCorePlugin.getResourceString("CDescriptor.exception.projectAlreadyExists"), (Throwable)null); //$NON-NLS-1$
+// } else {
+// status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_MISMATCH,
+// CCorePlugin.getResourceString("CDescriptor.exception.unmatchedOwnerId") + "<requested:" +id +"/ In file:" +ownerID+">", (Throwable)null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+// }
+// throw new CoreException(status);
+// }
+// }
+// fOwner = new COwner(manager.getOwnerConfiguration(id));
+// fOwner.configure(project, this);
+// isInitializing = false;
+// save();
+// }
+//
+// protected CDescriptor(CDescriptorManager manager, IProject project) throws CoreException {
+// fProject = project;
+// fManager = manager;
+// IPath projectLocation = project.getDescription().getLocation();
+//
+// if (projectLocation == null) {
+// projectLocation = getProjectDefaultLocation(project);
+// }
+// IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
+//
+// if (!descriptionPath.toFile().exists()) {
+// fOwner = new COwner(manager.getOwnerConfiguration(project));
+// fOwner.configure(project, this);
+// fManager.updateDescriptor(this);
+// } else {
+// String ownerId = readCDTProjectFile(descriptionPath);
+// fOwner = new COwner(manager.getOwnerConfiguration(ownerId));
+// }
+// isInitializing = false;
+// }
+//
+// protected CDescriptor(CDescriptorManager manager, IProject project, COwner owner) throws CoreException {
+// fProject = project;
+// fManager = manager;
+// IPath projectLocation = project.getDescription().getLocation();
+//
+// if (projectLocation == null) {
+// projectLocation = getProjectDefaultLocation(project);
+// }
+// IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
+//
+// if (descriptionPath.toFile().exists()) {
+// readCDTProjectFile(descriptionPath);
+// }
+// fOwner = owner;
+// fOwner.configure(project, this);
+// isInitializing = false;
+// save();
+// }
+//
+// private String readCDTProjectFile(IPath descriptionPath) throws CoreException {
+// String ownerID = ""; //$NON-NLS-1$
+// try {
+// DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+// Document document = parser.parse(descriptionPath.toFile());
+// NodeList nodeList = document.getElementsByTagName(PROJECT_DESCRIPTION);
+// if (nodeList != null && nodeList.getLength() > 0) {
+// Node node = nodeList.item(0);
+// if (node.hasAttributes()) {
+// ownerID = node.getAttributes().getNamedItem(PROJECT_OWNER_ID).getNodeValue();
+// }
+// readProjectDescription(node);
+// return ownerID;
+// }
+// IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+// CCorePlugin.getResourceString("CDescriptor.exception.missingElement"), null); //$NON-NLS-1$
+// throw new CoreException(status);
+// } catch (Exception e) {
+// IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.toString(), e);
+// throw new CoreException(status);
+// }
+// }
+//
+// private static IPath getProjectDefaultLocation(IProject project) {
+// return Platform.getLocation().append(project.getFullPath());
+// }
+//
+// public ICOwnerInfo getProjectOwner() {
+// return fOwner;
+// }
+//
+// public String getPlatform() {
+// return fOwner.getPlatform();
+// }
+//
+// public IProject getProject() {
+// return fProject;
+// }
+//
+// synchronized public ICExtensionReference[] get(String extensionID) {
+// CExtensionReference[] refs = (CExtensionReference[])extMap.get(extensionID);
+// if (refs == null)
+// return new ICExtensionReference[0];
+// return refs;
+// }
+//
+// synchronized public ICExtensionReference[] get(String extensionID, boolean update) throws CoreException {
+// ICExtensionReference[] refs = get(extensionID);
+// if (refs.length == 0 && update) {
+// boolean oldIsInitializing = isInitializing;
+// isInitializing = true;
+// fOwner.update(fProject, this, extensionID);
+// isInitializing = oldIsInitializing;
+// updateIfDirty();
+// refs = get(extensionID);
+// }
+// return refs;
+// }
+//
+// private CExtensionReference createRef(String extensionPoint, String extension) {
+// CExtensionReference extensions[] = (CExtensionReference[])extMap.get(extensionPoint);
+// if (extensions == null) {
+// extensions = new CExtensionReference[1];
+// extMap.put(extensionPoint, extensions);
+// } else {
+// CExtensionReference[] newExtensions = new CExtensionReference[extensions.length + 1];
+// System.arraycopy(extensions, 0, newExtensions, 0, extensions.length);
+// extensions = newExtensions;
+// extMap.put(extensionPoint, extensions);
+// }
+// extensions[extensions.length - 1] = new CExtensionReference(this, extensionPoint, extension);
+// return extensions[extensions.length - 1];
+// }
+//
+// synchronized public ICExtensionReference create(String extensionPoint, String extension) throws CoreException {
+// boolean fireEvent = false;
+// CExtensionReference extRef;
+// synchronized (this) {
+// extRef = createRef(extensionPoint, extension);
+// updateOnDisk();
+// if (!isInitializing) {
+// fireEvent = true;
+// }
+// }
+// if (fireEvent) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
+// }
+// return extRef;
+// }
+//
+// synchronized public void remove(ICExtensionReference ext) throws CoreException {
+// boolean fireEvent = false;
+// synchronized (this) {
+// CExtensionReference extensions[] = (CExtensionReference[])extMap.get(ext.getExtension());
+// for (int i = 0; i < extensions.length; i++) {
+// if (extensions[i] == ext) {
+// System.arraycopy(extensions, i, extensions, i + 1, extensions.length - 1 - i);
+// if (extensions.length > 1) {
+// CExtensionReference[] newExtensions = new CExtensionReference[extensions.length - 1];
+// System.arraycopy(extensions, 0, newExtensions, 0, newExtensions.length);
+// extMap.put(ext.getExtension(), newExtensions);
+// } else {
+// extMap.remove(ext.getExtension());
+// }
+// updateOnDisk();
+// if (!isInitializing) {
+// fireEvent = true;
+// }
+// }
+// }
+// }
+// if (fireEvent) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
+// }
+// }
+//
+// public void remove(String extensionPoint) throws CoreException {
+// boolean fireEvent = false;
+// synchronized (this) {
+// CExtensionReference extensions[] = (CExtensionReference[])extMap.get(extensionPoint);
+// if (extensions != null) {
+// extMap.remove(extensionPoint);
+// updateOnDisk();
+// if (!isInitializing) {
+// fireEvent = true;
+// }
+// }
+// }
+// if (fireEvent) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
+// }
+// }
+//
+// synchronized CExtensionInfo getInfo(CExtensionReference cProjectExtension) {
+// CExtensionInfo info = (CExtensionInfo)extInfoMap.get(cProjectExtension);
+// if (info == null) {
+// info = new CExtensionInfo();
+// extInfoMap.put(cProjectExtension, info);
+// }
+// return info;
+// }
+//
+// protected IFile getFile() {
+// return getProject().getFile(DESCRIPTION_FILE_NAME);
+// }
+//
+// void save() throws CoreException {
+// IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
+// ISchedulingRule rule;
+// IFile rscFile = getFile();
+// if (rscFile.exists()) {
+// rule = ruleFactory.modifyRule(rscFile);
+// } else {
+// rule = ruleFactory.createRule(rscFile);
+// }
+// fManager.getWorkspace().run(new IWorkspaceRunnable() {
+//
+// public void run(IProgressMonitor mon) throws CoreException {
+// String xml;
+// bDirty = false;
+// if (!fProject.isAccessible()) {
+// return;
+// }
+// fUpdating = true;
+//
+// try {
+// xml = getAsXML();
+// } catch (IOException e) {
+// IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
+// throw new CoreException(s);
+// } catch (TransformerException e) {
+// IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
+// throw new CoreException(s);
+// } catch (ParserConfigurationException e) {
+// IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
+// throw new CoreException(s);
+// }
+//
+// IFile rscFile = getFile();
+// InputStream inputStream;
+// try {
+// inputStream = new ByteArrayInputStream(xml.getBytes("UTF8")); //$NON-NLS-1$
+// if (rscFile.exists()) {
+// if (rscFile.isReadOnly()) {
+// // provide opportunity to checkout read-only .cdtproject file
+// fManager.getWorkspace().validateEdit(new IFile[]{rscFile}, null);
+// }
+// rscFile.setContents(inputStream, IResource.FORCE, null);
+// } else {
+// rscFile.create(inputStream, IResource.FORCE, null);
+// }
+// } catch (UnsupportedEncodingException e) {
+// IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
+// throw new CoreException(s);
+// }
+// fUpdating = false;
+// }
+// }, rule, IWorkspace.AVOID_UPDATE, null);
+// }
+//
+// boolean isUpdating() {
+// return fUpdating;
+// }
+//
+// void updateIfDirty() {
+// if ( bDirty ) {
+// updateOnDisk();
+// }
+// }
+//
+// synchronized void updateOnDisk() {
+// if (isUpdating()) {
+// return;
+// }
+// if (isInitializing) {
+// bDirty = true;
+// return;
+// }
+// fUpdating = true;
+// fManager.updateDescriptor(this);
+// }
+//
+// void updateFromDisk() throws CoreException {
+// COwner origOwner;
+// HashMap origExtMap;
+// HashMap origExtInfoMap;
+// Document origDataDoc;
+// synchronized (this) {
+// IPath projectLocation = fProject.getDescription().getLocation();
+//
+// if (projectLocation == null) {
+// projectLocation = getProjectDefaultLocation(fProject);
+// }
+// IPath descriptionPath = projectLocation.append(DESCRIPTION_FILE_NAME);
+// if (!descriptionPath.toFile().exists()) {
+// updateOnDisk();
+// return;
+// }
+//
+// origOwner = fOwner;
+// origExtMap = extMap;
+// origExtInfoMap = extInfoMap;
+// origDataDoc = dataDoc;
+//
+// extMap = new HashMap(4);
+// extInfoMap = new HashMap(4);
+// dataDoc = null;
+//
+// try {
+// String ownerId = readCDTProjectFile(descriptionPath);
+// fOwner = new COwner(fManager.getOwnerConfiguration(ownerId));
+// } catch (CoreException e) {
+// CCorePlugin.log(e);
+// fOwner = origOwner;
+// extMap = origExtMap;
+// extInfoMap = origExtInfoMap;
+// dataDoc = origDataDoc;
+// }
+// }
+// if (!fOwner.equals(origOwner)) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
+// } else {
+// boolean extChanges = true;
+// if (extMap.size() == origExtMap.size() && extInfoMap.size() == origExtInfoMap.size()) {
+// extChanges = false;
+// Iterator entries = extMap.entrySet().iterator();
+// while (entries.hasNext()) {
+// Entry entry = (Entry)entries.next();
+// if (!origExtMap.containsKey(entry.getKey())) {
+// extChanges = true;
+// break;
+// }
+// CExtensionReference origExt[] = (CExtensionReference[])origExtMap.get(entry.getKey());
+// CExtensionReference newExt[] = (CExtensionReference[])entry.getValue();
+// if (!Arrays.equals(origExt, newExt)) {
+// extChanges = true;
+// break;
+// }
+// }
+// }
+// if (extChanges) {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED,
+// CDescriptorEvent.EXTENSION_CHANGED));
+// } else {
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
+// }
+// }
+// }
+//
+// private void readProjectDescription(Node node) {
+// Node childNode;
+// NodeList list = node.getChildNodes();
+// for (int i = 0; i < list.getLength(); i++) {
+// childNode = list.item(i);
+// if (childNode.getNodeType() == Node.ELEMENT_NODE) {
+// if (childNode.getNodeName().equals(PROJECT_EXTENSION)) {
+// try {
+// decodeProjectExtension((Element)childNode);
+// } catch (CoreException e) {
+// CCorePlugin.log(e);
+// }
+// } else if (childNode.getNodeName().equals(PROJECT_DATA)) {
+// try {
+// decodeProjectData((Element)childNode);
+// } catch (CoreException e) {
+// CCorePlugin.log(e);
+// }
+// }
+// }
+// }
+// }
+//
+// private void decodeProjectExtension(Element element) throws CoreException {
+// String point = element.getAttribute(PROJECT_EXTENSION_ATTR_POINT);
+// String id = element.getAttribute(PROJECT_EXTENSION_ATTR_ID);
+// CExtensionReference ext = createRef(point, id);
+// NodeList extAttrib = element.getChildNodes();
+// for (int j = 0; j < extAttrib.getLength(); j++) {
+// if (extAttrib.item(j).getNodeName().equals(PROJECT_EXTENSION_ATTRIBUTE)) {
+// NamedNodeMap attrib = extAttrib.item(j).getAttributes();
+// getInfo(ext).setAttribute(attrib.getNamedItem(PROJECT_EXTENSION_ATTRIBUTE_KEY).getNodeValue(),
+// attrib.getNamedItem(PROJECT_EXTENSION_ATTRIBUTE_VALUE).getNodeValue());
+// }
+// }
+// }
+//
+// private void encodeProjectExtensions(Document doc, Element configRootElement) {
+// Element element;
+// Iterator extIterator = extMap.values().iterator();
+// while (extIterator.hasNext()) {
+// CExtensionReference extension[] = (CExtensionReference[])extIterator.next();
+// for (int i = 0; i < extension.length; i++) {
+// configRootElement.appendChild(element = doc.createElement(PROJECT_EXTENSION));
+// element.setAttribute(PROJECT_EXTENSION_ATTR_POINT, extension[i].getExtension());
+// element.setAttribute(PROJECT_EXTENSION_ATTR_ID, extension[i].getID());
+// CExtensionInfo info = (CExtensionInfo)extInfoMap.get(extension[i]);
+// if (info != null) {
+// Iterator attribIterator = info.getAttributes().entrySet().iterator();
+// while (attribIterator.hasNext()) {
+// Entry entry = (Entry)attribIterator.next();
+// Element extAttributes = doc.createElement(PROJECT_EXTENSION_ATTRIBUTE);
+// extAttributes.setAttribute(PROJECT_EXTENSION_ATTRIBUTE_KEY, (String)entry.getKey());
+// extAttributes.setAttribute(PROJECT_EXTENSION_ATTRIBUTE_VALUE, (String)entry.getValue());
+// element.appendChild(extAttributes);
+// }
+// }
+// }
+// }
+// }
+//
+// String getAsXML() throws IOException, TransformerException, ParserConfigurationException {
+// DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+// DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
+// Document doc = docBuilder.newDocument();
+// ProcessingInstruction version = doc.createProcessingInstruction("eclipse-cdt", "version=\"2.0\""); //$NON-NLS-1$ //$NON-NLS-2$
+// doc.appendChild(version);
+// Element configRootElement = doc.createElement(PROJECT_DESCRIPTION);
+// doc.appendChild(configRootElement);
+// if (fOwner.getID().length() > 0) {
+// configRootElement.setAttribute(PROJECT_OWNER_ID, fOwner.getID());
+// }
+// encodeProjectExtensions(doc, configRootElement);
+// encodeProjectData(doc, configRootElement);
+// return serializeDocument(doc);
+// }
+//
+// protected ICExtension createExtensions(ICExtensionReference ext) throws CoreException {
+// InternalCExtension cExtension = null;
+// IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+// IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ext.getExtension());
+// IExtension extension = extensionPoint.getExtension(ext.getID());
+// if (extension == null) {
+// throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+// CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound") + ":" + ext.getID(), null)); //$NON-NLS-1$ //$NON-NLS-2$
+// }
+// IConfigurationElement element[] = extension.getConfigurationElements();
+// for (int i = 0; i < element.length; i++) {
+// if (element[i].getName().equalsIgnoreCase(CEXTENSION_NAME)) {
+// cExtension = (InternalCExtension)element[i].createExecutableExtension("run"); //$NON-NLS-1$
+// cExtension.setExtensionReference(ext);
+// cExtension.setProject(fProject);
+// break;
+// }
+// }
+// return (ICExtension)cExtension;
+// }
+//
+// protected IConfigurationElement[] getConfigurationElement(ICExtensionReference ext) throws CoreException {
+// IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+// IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ext.getExtension());
+// IExtension extension = extensionPoint.getExtension(ext.getID());
+// if (extension == null) {
+// throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+// CCorePlugin.getResourceString("CDescriptor.exception.providerNotFound"), null)); //$NON-NLS-1$
+// }
+// IConfigurationElement element[] = extension.getConfigurationElements();
+// for (int i = 0; i < element.length; i++) {
+// if (element[i].getName().equalsIgnoreCase(CEXTENSION_NAME)) {
+// return element[i].getChildren();
+// }
+// }
+// return new IConfigurationElement[0];
+// }
+//
+// public synchronized Element getProjectData(String id) throws CoreException {
+// Document doc = getProjectDataDoc();
+// NodeList nodes = doc.getDocumentElement().getElementsByTagName(PROJECT_DATA_ITEM);
+// for (int i = 0; i < nodes.getLength(); ++i) {
+// Element element = (Element)nodes.item(i);
+// if (element != null && element.getAttribute(PROJECT_DATA_ID).equals(id))
+// return element;
+// }
+//
+// // Not found, make a new one
+// Element element = doc.createElement(PROJECT_DATA_ITEM);
+// element.setAttribute(PROJECT_DATA_ID, id);
+// doc.getDocumentElement().appendChild(element);
+// return element;
+// }
+//
+// public void saveProjectData() throws CoreException {
+// save();
+// fManager.fireEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
+// }
+//
+// // The project data allows for the storage of any structured information
+// // into the cdtproject file.
+// synchronized private Document getProjectDataDoc() throws CoreException {
+// if (dataDoc == null) {
+// try {
+// dataDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+// } catch (ParserConfigurationException e) {
+// throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR,
+// CCorePlugin.getResourceString("CDescriptor.extension.internalError"), e)); //$NON-NLS-1$
+// }
+// Element rootElem = dataDoc.createElement(PROJECT_DATA);
+// dataDoc.appendChild(rootElem);
+// }
+// return dataDoc;
+// }
+//
+// private void decodeProjectData(Element data) throws CoreException {
+// Document doc = getProjectDataDoc();
+// doc.replaceChild(doc.importNode(data, true), doc.getDocumentElement());
+// }
+//
+// private void encodeProjectData(Document doc, Element root) {
+// // Don't create or encode the doc if it isn't there already
+// if (dataDoc != null) {
+// Element dataElements = dataDoc.getDocumentElement();
+// NodeList nodes = dataElements.getElementsByTagName(PROJECT_DATA_ITEM);
+// for (int i = 0; i < nodes.getLength(); ++i) {
+// Element item = (Element)nodes.item(i);
+// if (!item.hasChildNodes()) { // remove any empty item tags
+// dataElements.removeChild(item);
+// i--; //nodeList is live.... removeal changes nodelist
+// }
+// }
+// root.appendChild(doc.importNode(dataDoc.getDocumentElement(), true));
+// }
+// }
+//
+// private String serializeDocument(Document doc) throws IOException, TransformerException {
+// ByteArrayOutputStream s = new ByteArrayOutputStream();
+//
+// TransformerFactory factory = TransformerFactory.newInstance();
+// Transformer transformer = factory.newTransformer();
+// transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+// transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+// transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+//
+// DOMSource source = new DOMSource(doc);
+// StreamResult outputTarget = new StreamResult(s);
+// transformer.transform(source, outputTarget);
+//
+// return s.toString("UTF8"); //$NON-NLS-1$
+// }
+//
+// public ICConfigurationDescription getConfigurationDescription() {
+// // TODO Auto-generated method stub
+// return null;
+// }
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
index ef5d416c5d7..8cf785df4e2 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDescriptorManager.java
@@ -47,349 +47,353 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-public class CDescriptorManager implements ICDescriptorManager, IResourceChangeListener {
-
- Map fOperationMap = new HashMap(1);
- Map fDescriptorMap = new HashMap();
- Map fOwnerConfigMap = null;
- List listeners = Collections.synchronizedList(new Vector());
-
- private static final COwnerConfiguration NULLCOwner = new COwnerConfiguration("", //$NON-NLS-1$
- CCorePlugin.getResourceString("CDescriptorManager.internal_owner")); //$NON-NLS-1$
-
- class CDescriptorUpdater extends Job {
-
- CDescriptor fDescriptor;
-
- public CDescriptorUpdater(CDescriptor descriptor) {
- super(CCorePlugin.getResourceString("CDescriptorManager.async_updater")); //$NON-NLS-1$
- fDescriptor = descriptor;
- setPriority(Job.INTERACTIVE);
- setSystem(true);
- setRule(descriptor.getProject());
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- try {
- fDescriptor.save();
- } catch (CoreException e) {
- return e.getStatus();
- }
- return Status.OK_STATUS;
- }
-
- }
-
- IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- public void shutdown() {
- getWorkspace().removeResourceChangeListener(this);
- }
-
- public void startup() throws CoreException {
- getWorkspace().getRoot().accept(new IResourceVisitor() {
-
- public boolean visit(IResource resource) {
- if (resource.getType() == IResource.PROJECT) {
- IProject project = (IProject)resource;
- try { // seed in memory descriptor map
- if (project.isAccessible() && project.findMember(CDescriptor.DESCRIPTION_FILE_NAME) != null) {
- getDescriptor(project);
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- return false;
- }
- return resource.getType() == IResource.ROOT;
- }
- });
- getWorkspace().addResourceChangeListener(this,
- IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_CLOSE);
- }
-
- /**
- * Watch for changes/deletions of the .cdtproject file.
- *
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (event.getSource() instanceof IWorkspace) {
- IResource resource = event.getResource();
-
- switch (event.getType()) {
- case IResourceChangeEvent.PRE_DELETE :
- case IResourceChangeEvent.PRE_CLOSE :
- if (resource.getType() == IResource.PROJECT) {
- CDescriptor descriptor = (CDescriptor)fDescriptorMap.remove(resource);
- if (descriptor != null) {
- fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_REMOVED, 0));
- }
- }
- break;
- case IResourceChangeEvent.PRE_BUILD :
- IResourceDelta resDelta = event.getDelta();
- if (resDelta == null) {
- break;
- }
- try {
- resDelta.accept(new IResourceDeltaVisitor() {
-
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource dResource = delta.getResource();
- if (dResource.getType() == IResource.PROJECT) {
- if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
- IProject project = (IProject)dResource;
- if (project.isAccessible() && project.findMember(CDescriptor.DESCRIPTION_FILE_NAME) != null
- && fDescriptorMap.get(project) == null) {
- getDescriptor(project); // file on disk but not in memory...read
- } else {
- CDescriptor descriptor = (CDescriptor)fDescriptorMap.remove(project);
- if (descriptor != null) {
- fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_REMOVED, 0));
- }
- }
- return false;
- }
- return true;
- } else if (dResource.getType() == IResource.FILE) {
- if (dResource.getName().equals(CDescriptor.DESCRIPTION_FILE_NAME)) {
- CDescriptor descriptor = (CDescriptor)fDescriptorMap.get(dResource.getProject());
- if (descriptor != null) {
- if ( (delta.getKind() & IResourceDelta.REMOVED) != 0) {
- // the file got deleted lets try
- // and restore for memory.
- descriptor.updateOnDisk();
- } else if ( (delta.getFlags() & IResourceDelta.CONTENT) != 0) {
- // content change lets try to
- // read and update
- descriptor.updateFromDisk();
- }
- }
- return false;
- }
- return true;
- }
- return dResource.getType() == IResource.ROOT;
- }
- });
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- break;
- }
- }
- }
-
- private void initializeOwnerConfiguration() {
- IExtensionPoint extpoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CProject"); //$NON-NLS-1$
- IExtension extension[] = extpoint.getExtensions();
- fOwnerConfigMap = new HashMap(extension.length);
- for (int i = 0; i < extension.length; i++) {
- IConfigurationElement element[] = extension[i].getConfigurationElements();
- for (int j = 0; j < element.length; j++) {
- if (element[j].getName().equalsIgnoreCase("cproject")) { //$NON-NLS-1$
- fOwnerConfigMap.put(extension[i].getUniqueIdentifier(), new COwnerConfiguration(element[j]));
- break;
- }
- }
- }
- }
-
- COwnerConfiguration getOwnerConfiguration(String id) {
- if (id.equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
- return NULLCOwner;
- }
- if (fOwnerConfigMap == null) {
- initializeOwnerConfiguration();
- }
- COwnerConfiguration config = (COwnerConfiguration)fOwnerConfigMap.get(id);
- if (config == null) { // no install owner, lets create place holder config for it.
- config = new COwnerConfiguration(id, CCorePlugin.getResourceString("CDescriptorManager.owner_not_Installed")); //$NON-NLS-1$
- fOwnerConfigMap.put(id, config);
- }
- return config;
- }
-
- COwnerConfiguration getOwnerConfiguration(IProject project) throws CoreException {
- if (fOwnerConfigMap == null) {
- initializeOwnerConfiguration();
- }
- IProjectDescription description = project.getDescription();
- String natureIDs[] = description.getNatureIds();
- Iterator configs = fOwnerConfigMap.entrySet().iterator();
- while (configs.hasNext()) {
- Entry entry = (Entry)configs.next();
- COwnerConfiguration config = (COwnerConfiguration)entry.getValue();
- if (config.getNature() != null) {
- if (Arrays.asList(natureIDs).lastIndexOf(config.getNature()) != -1) {
- return config;
- }
- }
- }
- return NULLCOwner;
- }
-
- synchronized public ICDescriptor getDescriptor(IProject project) throws CoreException {
- return getDescriptor(project, true);
- }
+public class CDescriptorManager /*implements ICDescriptorManager, IResourceChangeListener */{
+ private CDescriptorManager(){
- synchronized public ICDescriptor getDescriptor(IProject project, boolean create) throws CoreException {
- CDescriptor descriptor = (CDescriptor)fDescriptorMap.get(project);
- if (descriptor == null) {
- if (create) {
- descriptor = new CDescriptor(this, project);
- fDescriptorMap.put(project, descriptor);
- } else {
- IPath projectLocation = project.getDescription().getLocation();
-
- if (projectLocation == null) {
- projectLocation = Platform.getLocation().append(project.getFullPath());
- }
- IPath descriptionPath = projectLocation.append(CDescriptor.DESCRIPTION_FILE_NAME);
-
- if (descriptionPath.toFile().exists()) {
- descriptor = new CDescriptor(this, project);
- fDescriptorMap.put(project, descriptor);
- }
- }
- }
- return descriptor;
- }
-
- public void configure(IProject project, String id) throws CoreException {
- CDescriptor descriptor;
- if (id.equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
- CCorePlugin.getResourceString("CDescriptorManager.exception.invalid_ownerID"), //$NON-NLS-1$
- (Throwable)null);
- throw new CoreException(status);
- }
- synchronized (this) {
- descriptor = (CDescriptor)fDescriptorMap.get(project);
- if (descriptor != null) {
- if (descriptor.getProjectOwner().getID().equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
- // non owned descriptors are simply configure to the new owner no questions ask!
- descriptor = new CDescriptor(this, project, new COwner(getOwnerConfiguration(id)));
- } else if (!descriptor.getProjectOwner().getID().equals(id)) {
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS,
- CCorePlugin.getResourceString("CDescriptorManager.exception.alreadyConfigured"), //$NON-NLS-1$
- (Throwable)null);
- throw new CoreException(status);
- } else {
- return; // already configured with same owner.
- }
- } else {
- try {
- descriptor = new CDescriptor(this, project, id);
- } catch (CoreException e) { // if .cdtproject already exists we'll use that
- IStatus status = e.getStatus();
- if (status.getCode() == CCorePlugin.STATUS_CDTPROJECT_EXISTS) {
- descriptor = new CDescriptor(this, project);
- } else
- throw e;
- }
- }
- fDescriptorMap.put(project, descriptor);
- }
- fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_ADDED, 0));
- }
-
- public void convert(IProject project, String id) throws CoreException {
- CDescriptor descriptor;
- synchronized (this) {
- descriptor = new CDescriptor(this, project, new COwner(getOwnerConfiguration(id)));
- fDescriptorMap.put(project, descriptor);
- }
- fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
- }
-
- public void addDescriptorListener(ICDescriptorListener listener) {
- listeners.add(listener);
- }
-
- public void removeDescriptorListener(ICDescriptorListener listener) {
- listeners.remove(listener);
- }
-
- protected void fireEvent(final CDescriptorEvent event) {
- if (fOperationMap.containsKey(event.getDescriptor())) {
- // lets just hold on to the important event in order of;
- // ADD/REMOVE should not receive the remove but....
- // OWNER_CHANGED
- // EXT_CHANGED
- // other
- if (event.getType() == CDescriptorEvent.CDTPROJECT_ADDED) {
- fOperationMap.put(event.getDescriptor(), event);
- } else if (event.getType() == CDescriptorEvent.CDTPROJECT_REMOVED) {
- fOperationMap.put(event.getDescriptor(), event);
- } else {
- CDescriptorEvent ev = (CDescriptorEvent)fOperationMap.get(event.getDescriptor());
- if (ev == null) {
- fOperationMap.put(event.getDescriptor(), event);
- } else if ( (ev.getFlags() & event.getFlags()) != event.getFlags()) {
- fOperationMap.put(event.getDescriptor(), new CDescriptorEvent(event.getDescriptor(), event.getType(),
- ev.getFlags() | event.getFlags()));
- }
- }
- return;
- }
- final ICDescriptorListener[] listener;
- synchronized (listeners) {
- listener = (ICDescriptorListener[])listeners.toArray(new ICDescriptorListener[listeners.size()]);
- }
- for (int i = 0; i < listener.length; i++) {
- final int index = i;
- Platform.run(new ISafeRunnable() {
-
- public void handleException(Throwable exception) {
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
- CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
- CCorePlugin.log(status);
- }
-
- public void run() throws Exception {
- listener[index].descriptorChanged(event);
- }
- });
- }
- }
-
- public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException {
- ICDescriptor descriptor = getDescriptor(project, true);
- if (descriptor == null) {
- throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Failed to create descriptor", null)); //$NON-NLS-1$
- }
- CDescriptorEvent event = null;
- synchronized (descriptor) {
- beginOperation(descriptor);
- try {
- op.execute(descriptor, monitor);
- } finally {
- event = endOperation(descriptor);
- }
- }
- if (event != null) {
- fireEvent(event);
- }
- }
-
- private void beginOperation(ICDescriptor descriptor) {
- fOperationMap.put(descriptor, null);
- }
-
- private CDescriptorEvent endOperation(ICDescriptor descriptor) {
- return (CDescriptorEvent)fOperationMap.remove(descriptor);
- }
-
- /*
- * Perform a update of the ondisk .cdtproject file. This is nessecary to avoid deadlocking when the descriptor has change from a
- * call to ICDescriptor.get(project, true) which may update the descriptor via the owner update method, while the workspace is
- * locked (ie during a resourceChange event).
- */
- protected void updateDescriptor(CDescriptor descriptor) {
- new CDescriptorUpdater(descriptor).schedule();
}
+//
+// Map fOperationMap = new HashMap(1);
+// Map fDescriptorMap = new HashMap();
+// Map fOwnerConfigMap = null;
+// List listeners = Collections.synchronizedList(new Vector());
+//
+// private static final COwnerConfiguration NULLCOwner = new COwnerConfiguration("", //$NON-NLS-1$
+// CCorePlugin.getResourceString("CDescriptorManager.internal_owner")); //$NON-NLS-1$
+//
+// class CDescriptorUpdater extends Job {
+//
+// CDescriptor fDescriptor;
+//
+// public CDescriptorUpdater(CDescriptor descriptor) {
+// super(CCorePlugin.getResourceString("CDescriptorManager.async_updater")); //$NON-NLS-1$
+// fDescriptor = descriptor;
+// setPriority(Job.INTERACTIVE);
+// setSystem(true);
+// setRule(descriptor.getProject());
+// }
+//
+// protected IStatus run(IProgressMonitor monitor) {
+// try {
+// fDescriptor.save();
+// } catch (CoreException e) {
+// return e.getStatus();
+// }
+// return Status.OK_STATUS;
+// }
+//
+// }
+//
+//
+// IWorkspace getWorkspace() {
+// return ResourcesPlugin.getWorkspace();
+// }
+//
+// public void shutdown() {
+// getWorkspace().removeResourceChangeListener(this);
+// }
+//
+// public void startup() throws CoreException {
+// getWorkspace().getRoot().accept(new IResourceVisitor() {
+//
+// public boolean visit(IResource resource) {
+// if (resource.getType() == IResource.PROJECT) {
+// IProject project = (IProject)resource;
+// try { // seed in memory descriptor map
+// if (project.isAccessible() && project.findMember(CDescriptor.DESCRIPTION_FILE_NAME) != null) {
+// getDescriptor(project);
+// }
+// } catch (CoreException e) {
+// CCorePlugin.log(e);
+// }
+// return false;
+// }
+// return resource.getType() == IResource.ROOT;
+// }
+// });
+// getWorkspace().addResourceChangeListener(this,
+// IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_CLOSE);
+// }
+//
+// /**
+// * Watch for changes/deletions of the .cdtproject file.
+// *
+// * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
+// */
+// public void resourceChanged(IResourceChangeEvent event) {
+// if (event.getSource() instanceof IWorkspace) {
+// IResource resource = event.getResource();
+//
+// switch (event.getType()) {
+// case IResourceChangeEvent.PRE_DELETE :
+// case IResourceChangeEvent.PRE_CLOSE :
+// if (resource.getType() == IResource.PROJECT) {
+// CDescriptor descriptor = (CDescriptor)fDescriptorMap.remove(resource);
+// if (descriptor != null) {
+// fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_REMOVED, 0));
+// }
+// }
+// break;
+// case IResourceChangeEvent.PRE_BUILD :
+// IResourceDelta resDelta = event.getDelta();
+// if (resDelta == null) {
+// break;
+// }
+// try {
+// resDelta.accept(new IResourceDeltaVisitor() {
+//
+// public boolean visit(IResourceDelta delta) throws CoreException {
+// IResource dResource = delta.getResource();
+// if (dResource.getType() == IResource.PROJECT) {
+// if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
+// IProject project = (IProject)dResource;
+// if (project.isAccessible() && project.findMember(CDescriptor.DESCRIPTION_FILE_NAME) != null
+// && fDescriptorMap.get(project) == null) {
+// getDescriptor(project); // file on disk but not in memory...read
+// } else {
+// CDescriptor descriptor = (CDescriptor)fDescriptorMap.remove(project);
+// if (descriptor != null) {
+// fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_REMOVED, 0));
+// }
+// }
+// return false;
+// }
+// return true;
+// } else if (dResource.getType() == IResource.FILE) {
+// if (dResource.getName().equals(CDescriptor.DESCRIPTION_FILE_NAME)) {
+// CDescriptor descriptor = (CDescriptor)fDescriptorMap.get(dResource.getProject());
+// if (descriptor != null) {
+// if ( (delta.getKind() & IResourceDelta.REMOVED) != 0) {
+// // the file got deleted lets try
+// // and restore for memory.
+// descriptor.updateOnDisk();
+// } else if ( (delta.getFlags() & IResourceDelta.CONTENT) != 0) {
+// // content change lets try to
+// // read and update
+// descriptor.updateFromDisk();
+// }
+// }
+// return false;
+// }
+// return true;
+// }
+// return dResource.getType() == IResource.ROOT;
+// }
+// });
+// } catch (CoreException e) {
+// CCorePlugin.log(e);
+// }
+// break;
+// }
+// }
+// }
+//
+// private void initializeOwnerConfiguration() {
+// IExtensionPoint extpoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CProject"); //$NON-NLS-1$
+// IExtension extension[] = extpoint.getExtensions();
+// fOwnerConfigMap = new HashMap(extension.length);
+// for (int i = 0; i < extension.length; i++) {
+// IConfigurationElement element[] = extension[i].getConfigurationElements();
+// for (int j = 0; j < element.length; j++) {
+// if (element[j].getName().equalsIgnoreCase("cproject")) { //$NON-NLS-1$
+// fOwnerConfigMap.put(extension[i].getUniqueIdentifier(), new COwnerConfiguration(element[j]));
+// break;
+// }
+// }
+// }
+// }
+//
+// COwnerConfiguration getOwnerConfiguration(String id) {
+// if (id.equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
+// return NULLCOwner;
+// }
+// if (fOwnerConfigMap == null) {
+// initializeOwnerConfiguration();
+// }
+// COwnerConfiguration config = (COwnerConfiguration)fOwnerConfigMap.get(id);
+// if (config == null) { // no install owner, lets create place holder config for it.
+// config = new COwnerConfiguration(id, CCorePlugin.getResourceString("CDescriptorManager.owner_not_Installed")); //$NON-NLS-1$
+// fOwnerConfigMap.put(id, config);
+// }
+// return config;
+// }
+//
+// COwnerConfiguration getOwnerConfiguration(IProject project) throws CoreException {
+// if (fOwnerConfigMap == null) {
+// initializeOwnerConfiguration();
+// }
+// IProjectDescription description = project.getDescription();
+// String natureIDs[] = description.getNatureIds();
+// Iterator configs = fOwnerConfigMap.entrySet().iterator();
+// while (configs.hasNext()) {
+// Entry entry = (Entry)configs.next();
+// COwnerConfiguration config = (COwnerConfiguration)entry.getValue();
+// if (config.getNature() != null) {
+// if (Arrays.asList(natureIDs).lastIndexOf(config.getNature()) != -1) {
+// return config;
+// }
+// }
+// }
+// return NULLCOwner;
+// }
+//
+// synchronized public ICDescriptor getDescriptor(IProject project) throws CoreException {
+// return getDescriptor(project, true);
+// }
+//
+// synchronized public ICDescriptor getDescriptor(IProject project, boolean create) throws CoreException {
+// CDescriptor descriptor = (CDescriptor)fDescriptorMap.get(project);
+// if (descriptor == null) {
+// if (create) {
+// descriptor = new CDescriptor(this, project);
+// fDescriptorMap.put(project, descriptor);
+// } else {
+// IPath projectLocation = project.getDescription().getLocation();
+//
+// if (projectLocation == null) {
+// projectLocation = Platform.getLocation().append(project.getFullPath());
+// }
+// IPath descriptionPath = projectLocation.append(CDescriptor.DESCRIPTION_FILE_NAME);
+//
+// if (descriptionPath.toFile().exists()) {
+// descriptor = new CDescriptor(this, project);
+// fDescriptorMap.put(project, descriptor);
+// }
+// }
+// }
+// return descriptor;
+// }
+//
+// public void configure(IProject project, String id) throws CoreException {
+// CDescriptor descriptor;
+// if (id.equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
+// IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+// CCorePlugin.getResourceString("CDescriptorManager.exception.invalid_ownerID"), //$NON-NLS-1$
+// (Throwable)null);
+// throw new CoreException(status);
+// }
+// synchronized (this) {
+// descriptor = (CDescriptor)fDescriptorMap.get(project);
+// if (descriptor != null) {
+// if (descriptor.getProjectOwner().getID().equals(NULLCOwner.getOwnerID())) { //$NON-NLS-1$
+// // non owned descriptors are simply configure to the new owner no questions ask!
+// descriptor = new CDescriptor(this, project, new COwner(getOwnerConfiguration(id)));
+// } else if (!descriptor.getProjectOwner().getID().equals(id)) {
+// IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_CDTPROJECT_EXISTS,
+// CCorePlugin.getResourceString("CDescriptorManager.exception.alreadyConfigured"), //$NON-NLS-1$
+// (Throwable)null);
+// throw new CoreException(status);
+// } else {
+// return; // already configured with same owner.
+// }
+// } else {
+// try {
+// descriptor = new CDescriptor(this, project, id);
+// } catch (CoreException e) { // if .cdtproject already exists we'll use that
+// IStatus status = e.getStatus();
+// if (status.getCode() == CCorePlugin.STATUS_CDTPROJECT_EXISTS) {
+// descriptor = new CDescriptor(this, project);
+// } else
+// throw e;
+// }
+// }
+// fDescriptorMap.put(project, descriptor);
+// }
+// fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_ADDED, 0));
+// }
+//
+// public void convert(IProject project, String id) throws CoreException {
+// CDescriptor descriptor;
+// synchronized (this) {
+// descriptor = new CDescriptor(this, project, new COwner(getOwnerConfiguration(id)));
+// fDescriptorMap.put(project, descriptor);
+// }
+// fireEvent(new CDescriptorEvent(descriptor, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
+// }
+//
+// public void addDescriptorListener(ICDescriptorListener listener) {
+// listeners.add(listener);
+// }
+//
+// public void removeDescriptorListener(ICDescriptorListener listener) {
+// listeners.remove(listener);
+// }
+//
+// protected void fireEvent(final CDescriptorEvent event) {
+// if (fOperationMap.containsKey(event.getDescriptor())) {
+// // lets just hold on to the important event in order of;
+// // ADD/REMOVE should not receive the remove but....
+// // OWNER_CHANGED
+// // EXT_CHANGED
+// // other
+// if (event.getType() == CDescriptorEvent.CDTPROJECT_ADDED) {
+// fOperationMap.put(event.getDescriptor(), event);
+// } else if (event.getType() == CDescriptorEvent.CDTPROJECT_REMOVED) {
+// fOperationMap.put(event.getDescriptor(), event);
+// } else {
+// CDescriptorEvent ev = (CDescriptorEvent)fOperationMap.get(event.getDescriptor());
+// if (ev == null) {
+// fOperationMap.put(event.getDescriptor(), event);
+// } else if ( (ev.getFlags() & event.getFlags()) != event.getFlags()) {
+// fOperationMap.put(event.getDescriptor(), new CDescriptorEvent(event.getDescriptor(), event.getType(),
+// ev.getFlags() | event.getFlags()));
+// }
+// }
+// return;
+// }
+// final ICDescriptorListener[] listener;
+// synchronized (listeners) {
+// listener = (ICDescriptorListener[])listeners.toArray(new ICDescriptorListener[listeners.size()]);
+// }
+// for (int i = 0; i < listener.length; i++) {
+// final int index = i;
+// Platform.run(new ISafeRunnable() {
+//
+// public void handleException(Throwable exception) {
+// IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
+// CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
+// CCorePlugin.log(status);
+// }
+//
+// public void run() throws Exception {
+// listener[index].descriptorChanged(event);
+// }
+// });
+// }
+// }
+//
+// public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException {
+// ICDescriptor descriptor = getDescriptor(project, true);
+// if (descriptor == null) {
+// throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Failed to create descriptor", null)); //$NON-NLS-1$
+// }
+// CDescriptorEvent event = null;
+// synchronized (descriptor) {
+// beginOperation(descriptor);
+// try {
+// op.execute(descriptor, monitor);
+// } finally {
+// event = endOperation(descriptor);
+// }
+// }
+// if (event != null) {
+// fireEvent(event);
+// }
+// }
+//
+// private void beginOperation(ICDescriptor descriptor) {
+// fOperationMap.put(descriptor, null);
+// }
+//
+// private CDescriptorEvent endOperation(ICDescriptor descriptor) {
+// return (CDescriptorEvent)fOperationMap.remove(descriptor);
+// }
+//
+// /*
+// * Perform a update of the ondisk .cdtproject file. This is nessecary to avoid deadlocking when the descriptor has change from a
+// * call to ICDescriptor.get(project, true) which may update the descriptor via the owner update method, while the workspace is
+// * locked (ie during a resourceChange event).
+// */
+// protected void updateDescriptor(CDescriptor descriptor) {
+// new CDescriptorUpdater(descriptor).schedule();
+// }
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java
new file mode 100644
index 00000000000..b1522dd40d2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core;
+
+import org.eclipse.cdt.core.ICExtensionDescriptor;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class CExtensionDescriptor implements ICExtensionDescriptor {
+ private IConfigurationElement fElement;
+ protected static final String ATTRIBUTE_ID = "id";
+ protected static final String ATTRIBUTE_NAME = "name";
+
+ public CExtensionDescriptor(IConfigurationElement el){
+ fElement = el;
+ }
+
+ public String getId() {
+ return fElement.getAttribute(ATTRIBUTE_ID);
+ }
+
+ public String getName() {
+ return fElement.getAttribute(ATTRIBUTE_NAME);
+ }
+
+ public IConfigurationElement getConfigurationElement(){
+ return fElement;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java
index 6eab17e37a7..4106666ebfb 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionInfo.java
@@ -16,7 +16,15 @@ public class CExtensionInfo {
protected HashMap attribMap = new HashMap(4);
- protected HashMap getAttributes() {
+ public CExtensionInfo(){
+
+ }
+
+ public CExtensionInfo(CExtensionInfo base){
+ attribMap.putAll(base.attribMap);
+ }
+
+ public HashMap getAttributes() {
return attribMap;
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java
index 8d32528b41a..2ea8fe45c4e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionReference.java
@@ -17,68 +17,71 @@ import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
-public class CExtensionReference implements ICExtensionReference {
-
- private CDescriptor fDescriptor;
- private String fExtPoint;
- private String fId;
-
- public CExtensionReference(CDescriptor descriptor, String extPoint, String id) {
- fDescriptor = descriptor;
- fExtPoint = extPoint;
- fId = id;
- }
-
- public String getExtension() {
- return fExtPoint;
- }
-
- public String getID() {
- return fId;
- }
-
- public ICDescriptor getCDescriptor() {
- return fDescriptor;
- }
-
- private CExtensionInfo getInfo() {
- return fDescriptor.getInfo(this);
- }
-
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (obj instanceof CExtensionReference) {
- CExtensionReference ext = (CExtensionReference)obj;
- if (ext.fExtPoint.equals(fExtPoint) && ext.fId.equals(fId)) {
- return true;
- }
- }
- return false;
- }
-
- public int hashCode() {
- return fExtPoint.hashCode() + fId.hashCode();
- }
-
- public void setExtensionData(String key, String value) throws CoreException {
- getInfo().setAttribute(key, value);
- fDescriptor.updateOnDisk();
- if (!fDescriptor.isInitializing) {
- fDescriptor.fManager.fireEvent(new CDescriptorEvent(fDescriptor, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
- }
- }
-
- public String getExtensionData(String key) {
- return getInfo().getAttribute(key);
- }
-
- public ICExtension createExtension() throws CoreException {
- return fDescriptor.createExtensions(this);
- }
-
- public IConfigurationElement[] getExtensionElements() throws CoreException {
- return fDescriptor.getConfigurationElement(this);
+public class CExtensionReference /*implements ICExtensionReference */{
+ private CExtensionReference(){
+
}
+//
+// private CDescriptor fDescriptor;
+// private String fExtPoint;
+// private String fId;
+//
+// public CExtensionReference(CDescriptor descriptor, String extPoint, String id) {
+// fDescriptor = descriptor;
+// fExtPoint = extPoint;
+// fId = id;
+// }
+//
+// public String getExtension() {
+// return fExtPoint;
+// }
+//
+// public String getID() {
+// return fId;
+// }
+//
+// public ICDescriptor getCDescriptor() {
+// return fDescriptor;
+// }
+//
+// private CExtensionInfo getInfo() {
+// return fDescriptor.getInfo(this);
+// }
+//
+// public boolean equals(Object obj) {
+// if (obj == this) {
+// return true;
+// }
+// if (obj instanceof CExtensionReference) {
+// CExtensionReference ext = (CExtensionReference)obj;
+// if (ext.fExtPoint.equals(fExtPoint) && ext.fId.equals(fId)) {
+// return true;
+// }
+// }
+// return false;
+// }
+//
+// public int hashCode() {
+// return fExtPoint.hashCode() + fId.hashCode();
+// }
+//
+// public void setExtensionData(String key, String value) throws CoreException {
+// getInfo().setAttribute(key, value);
+// fDescriptor.updateOnDisk();
+// if (!fDescriptor.isInitializing) {
+// fDescriptor.fManager.fireEvent(new CDescriptorEvent(fDescriptor, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
+// }
+// }
+//
+// public String getExtensionData(String key) {
+// return getInfo().getAttribute(key);
+// }
+//
+// public ICExtension createExtension() throws CoreException {
+// return fDescriptor.createExtensions(this);
+// }
+//
+// public IConfigurationElement[] getExtensionElements() throws CoreException {
+// return fDescriptor.getConfigurationElement(this);
+// }
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java
new file mode 100644
index 00000000000..ab3bd5b8c2a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
+
+public class BuildSystemVariableSupplier extends CoreMacroSupplierBase {
+
+ private class ExtensionMacroProvider extends CdtVariableManager{
+ private IVariableContextInfo fStartInfo;
+ private int fContextType;
+ private Object fContextData;
+ private boolean fStartInitialized;
+
+ public ExtensionMacroProvider(int contextType, Object contextData){
+ fContextType = contextType;
+ fContextData = contextData;
+ }
+
+ public IVariableContextInfo getMacroContextInfo(int contextType,Object contextData){
+ IVariableContextInfo startInfo = getStartInfo();
+ if(contextType == fContextType &&
+ contextData == fContextData)
+ return startInfo;
+
+ IVariableContextInfo info = super.getMacroContextInfo(contextType, contextData);
+ if(info == null)
+ return null;
+
+ if(SupplierBasedCdtVariableManager.checkParentContextRelation(startInfo,info))
+ return info;
+ return null;
+ }
+
+ protected IVariableContextInfo getStartInfo(){
+ if(fStartInfo == null && !fStartInitialized){
+ IVariableContextInfo info = super.getMacroContextInfo(fContextType,fContextData);
+ if(info != null){
+ ICdtVariableSupplier suppliers[] = info.getSuppliers();
+ suppliers = filterValidSuppliers(suppliers);
+ if(suppliers != null)
+ fStartInfo = new DefaultVariableContextInfo(fContextType,fContextData,suppliers);
+ else
+ fStartInfo = info.getNext();
+ fStartInitialized = true;
+ }
+ fStartInitialized = true;
+ }
+ return fStartInfo;
+ }
+
+ protected ICdtVariableSupplier[] filterValidSuppliers(ICdtVariableSupplier suppliers[]){
+ if(suppliers == null)
+ return null;
+
+ int i = 0, j = 0;
+ for(i = 0; i < suppliers.length; i++){
+ if(suppliers[i] == this)
+ break;
+ }
+
+
+ if(i >= suppliers.length)
+ return null;
+
+ int startNum = i + 1;
+
+ ICdtVariableSupplier validSuppliers[] =
+ new ICdtVariableSupplier[suppliers.length - startNum];
+
+ for(i = startNum, j = 0; i < suppliers.length; i++, j++)
+ validSuppliers[j] = suppliers[i];
+
+ return validSuppliers;
+ }
+ }
+
+ protected ICdtVariable getMacro(String name, int type, Object data) {
+ ICConfigurationDescription des = (ICConfigurationDescription)data;
+ return des.getBuildVariablesContributor().getVariable(name, new ExtensionMacroProvider(type, data));
+ }
+
+ protected ICdtVariable[] getMacros(int type, Object data) {
+ ICConfigurationDescription des = (ICConfigurationDescription)data;
+ return des.getBuildVariablesContributor().getVariables(new ExtensionMacroProvider(type, data));
+ }
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java
new file mode 100644
index 00000000000..f595b44ef6e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java
@@ -0,0 +1,495 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.CdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.utils.Platform;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.osgi.framework.Bundle;
+
+/**
+ * This supplier is used to suply MBS-predefined macros
+ *
+ * @since 3.0
+ */
+public class CdtMacroSupplier extends CoreMacroSupplierBase {
+ private static CdtMacroSupplier fInstance;
+ public final static String DOT = "."; //$NON-NLS-1$
+ public final static String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ private static final String fConfigurationMacros[] = new String[]{
+ "ConfigName", //$NON-NLS-1$
+ "ConfigDescription", //$NON-NLS-1$
+// "BuildArtifactFileName", //$NON-NLS-1$
+// "BuildArtifactFileExt", //$NON-NLS-1$
+// "BuildArtifactFileBaseName", //$NON-NLS-1$
+// "BuildArtifactFilePrefix", //$NON-NLS-1$
+// "TargetOsList", //$NON-NLS-1$
+// "TargetArchList", //$NON-NLS-1$
+ };
+
+ private static final String fWorkspaceMacros[] = new String[]{
+ "WorkspaceDirPath", //$NON-NLS-1$
+ "DirectoryDelimiter", //$NON-NLS-1$
+ "PathDelimiter", //$NON-NLS-1$
+ };
+
+ private static final String fCDTEclipseMacros[] = new String[]{
+ "EclipseVersion", //$NON-NLS-1$
+ "CDTVersion", //$NON-NLS-1$
+// "MBSVersion", //$NON-NLS-1$
+ "HostOsName", //$NON-NLS-1$
+ "HostArchName", //$NON-NLS-1$
+ "OsType", //$NON-NLS-1$
+ "ArchType", //$NON-NLS-1$
+ };
+
+
+/* private String getExplicitFileMacroValue(String name, IPath inputFileLocation, IPath outputFileLocation, IConfiguration cfg){
+ String value = null;
+ if("InputFileName".equals(name)){ //$NON-NLS-1$
+ if(inputFileLocation != null && inputFileLocation.segmentCount() > 0)
+ value = inputFileLocation.lastSegment();
+ }else if("InputFileExt".equals(name)){ //$NON-NLS-1$
+ if(inputFileLocation != null && inputFileLocation.segmentCount() > 0)
+ value = getExtension(inputFileLocation.lastSegment());
+ }else if("InputFileBaseName".equals(name)){ //$NON-NLS-1$
+ if(inputFileLocation != null && inputFileLocation.segmentCount() > 0)
+ value = getBaseName(inputFileLocation.lastSegment());
+ }else if("InputFileRelPath".equals(name)){ //$NON-NLS-1$
+ if(inputFileLocation != null && inputFileLocation.segmentCount() > 0){
+ IPath workingDirectory = getBuilderCWD(cfg);
+ if(workingDirectory != null){
+ IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, inputFileLocation);
+ if(filePath != null)
+ value = filePath.toOSString();
+ }
+ }
+ }
+ else if("InputDirRelPath".equals(name)){ //$NON-NLS-1$
+ if(inputFileLocation != null && inputFileLocation.segmentCount() > 0){
+ IPath workingDirectory = getBuilderCWD(cfg);
+ if(workingDirectory != null){
+ IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, inputFileLocation.removeLastSegments(1).addTrailingSeparator());
+ if(filePath != null)
+ value = filePath.toOSString();
+ }
+ }
+ }
+ else if("OutputFileName".equals(name)){ //$NON-NLS-1$
+ if(outputFileLocation != null && outputFileLocation.segmentCount() > 0)
+ value = outputFileLocation.lastSegment();
+ }else if("OutputFileExt".equals(name)){ //$NON-NLS-1$
+ if(outputFileLocation != null && outputFileLocation.segmentCount() > 0)
+ value = getExtension(outputFileLocation.lastSegment());
+ }else if("OutputFileBaseName".equals(name)){ //$NON-NLS-1$
+ if(outputFileLocation != null && outputFileLocation.segmentCount() > 0)
+ value = getBaseName(outputFileLocation.lastSegment());
+ }else if("OutputFileRelPath".equals(name)){ //$NON-NLS-1$
+ if(outputFileLocation != null && outputFileLocation.segmentCount() > 0){
+ IPath workingDirectory = getBuilderCWD(cfg);
+ if(workingDirectory != null){
+ IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, outputFileLocation);
+ if(filePath != null)
+ value = filePath.toOSString();
+ }
+ }
+ }else if("OutputDirRelPath".equals(name)){ //$NON-NLS-1$
+ if(outputFileLocation != null && outputFileLocation.segmentCount() > 0){
+ IPath workingDirectory = getBuilderCWD(cfg);
+ if(workingDirectory != null){
+ IPath filePath = ManagedBuildManager.calculateRelativePath(workingDirectory, outputFileLocation.removeLastSegments(1).addTrailingSeparator());
+ if(filePath != null)
+ value = filePath.toOSString();
+ }
+ }
+ }
+
+ return value;
+ }*/
+
+ public String[] getMacroNames(int contextType){
+ return getMacroNames(contextType,true);
+ }
+
+ private String[] getMacroNames(int contextType, boolean clone){
+ String names[] = null;
+ switch(contextType){
+ case DefaultVariableContextInfo.CONTEXT_CONFIGURATION:
+ names = fConfigurationMacros;
+ break;
+ case DefaultVariableContextInfo.CONTEXT_WORKSPACE:
+ names = fWorkspaceMacros;
+ break;
+ case DefaultVariableContextInfo.CONTEXT_INSTALLATIONS:
+ names = fCDTEclipseMacros;
+ break;
+ case DefaultVariableContextInfo.CONTEXT_ECLIPSEENV:
+ break;
+ }
+ if(names != null)
+ return clone ? (String[])names.clone() : names;
+ return null;
+ }
+
+ private CdtMacroSupplier(){
+
+ }
+
+ public static CdtMacroSupplier getInstance(){
+ if(fInstance == null)
+ fInstance = new CdtMacroSupplier();
+ return fInstance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
+ */
+ public ICdtVariable getMacro(String macroName, int contextType,
+ Object contextData) {
+ ICdtVariable macro = null;
+ switch(contextType){
+ case DefaultVariableContextInfo.CONTEXT_CONFIGURATION:
+ if(contextData instanceof ICConfigurationDescription){
+ macro = getMacro(macroName, (ICConfigurationDescription)contextData);
+ }
+ break;
+ case DefaultVariableContextInfo.CONTEXT_WORKSPACE:
+ if(contextData == null || contextData instanceof IWorkspace){
+ macro = getMacro(macroName, (IWorkspace)contextData);
+ }
+ break;
+ case DefaultVariableContextInfo.CONTEXT_INSTALLATIONS:
+ if(contextData == null){
+ macro = getMacro(macroName);
+ }
+ break;
+ case DefaultVariableContextInfo.CONTEXT_ECLIPSEENV:
+ break;
+ }
+
+ return macro;
+ }
+
+ public ICdtVariable getMacro(String macroName, ICConfigurationDescription cfg){
+ ICdtVariable macro = null;
+ if("ConfigName".equals(macroName)){ //$NON-NLS-1$
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,cfg.getName());
+ }
+ else if("ConfigDescription".equals(macroName)){ //$NON-NLS-1$
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,cfg.getDescription());
+ }
+/* else if("BuildArtifactFileName".equals(macroName)){ //$NON-NLS-1$
+ String name = cfg.getArtifactName();
+ String ext = cfg.getArtifactExtension();
+ if(ext != null && !EMPTY_STRING.equals(ext))
+ name = name + DOT + ext;
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,name);
+ }*/
+/* else if("BuildArtifactFileExt".equals(macroName)){ //$NON-NLS-1$
+ String ext = cfg.getArtifactExtension();
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,ext);
+ }*/
+/* else if("BuildArtifactFileBaseName".equals(macroName)){ //$NON-NLS-1$
+ String name = cfg.getArtifactName();
+ ITool targetTool = cfg.calculateTargetTool();
+ if(targetTool != null){
+ IOutputType pot = targetTool.getPrimaryOutputType();
+ String prefix = pot.getOutputPrefix();
+
+
+ // Resolve any macros in the outputPrefix
+ // Note that we cannot use file macros because if we do a clean
+ // we need to know the actual
+ // name of the file to clean, and cannot use any builder
+ // variables such as $@. Hence
+ // we use the next best thing, i.e. configuration context.
+
+ // figure out the configuration we're using
+ IBuildObject toolParent = targetTool.getParent();
+ IConfiguration config = null;
+ // if the parent is a config then we're done
+ if (toolParent instanceof IConfiguration)
+ config = (IConfiguration) toolParent;
+ else if (toolParent instanceof IToolChain) {
+ // must be a toolchain
+ config = (IConfiguration) ((IToolChain) toolParent)
+ .getParent();
+ }
+
+ else if (toolParent instanceof IResourceConfiguration) {
+ config = (IConfiguration) ((IResourceConfiguration) toolParent)
+ .getParent();
+ }
+
+ else {
+ // bad
+ throw new AssertionError(
+ "tool parent must be one of configuration, toolchain, or resource configuration");
+ }
+
+ if (config != null) {
+
+ try {
+ prefix = ManagedBuildManager
+ .getBuildMacroProvider()
+ .resolveValueToMakefileFormat(
+ prefix,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ config);
+ }
+
+ catch (BuildMacroException e) {
+ }
+
+ }
+
+
+ if(prefix != null && !EMPTY_STRING.equals(prefix))
+ name = prefix + name;
+ }
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,name);
+ }*/
+/* else if("BuildArtifactFilePrefix".equals(macroName)){ //$NON-NLS-1$
+ ITool targetTool = cfg.calculateTargetTool();
+ if(targetTool != null){
+ IOutputType pot = targetTool.getPrimaryOutputType();
+ String prefix = pot.getOutputPrefix();
+
+ // Resolve any macros in the outputPrefix
+ // Note that we cannot use file macros because if we do a clean
+ // we need to know the actual
+ // name of the file to clean, and cannot use any builder
+ // variables such as $@. Hence
+ // we use the next best thing, i.e. configuration context.
+
+ // figure out the configuration we're using
+ IBuildObject toolParent = targetTool.getParent();
+ IConfiguration config = null;
+ // if the parent is a config then we're done
+ if (toolParent instanceof IConfiguration)
+ config = (IConfiguration) toolParent;
+ else if (toolParent instanceof IToolChain) {
+ // must be a toolchain
+ config = (IConfiguration) ((IToolChain) toolParent)
+ .getParent();
+ }
+
+ else if (toolParent instanceof IResourceConfiguration) {
+ config = (IConfiguration) ((IResourceConfiguration) toolParent)
+ .getParent();
+ }
+
+ else {
+ // bad
+ throw new AssertionError(
+ "tool parent must be one of configuration, toolchain, or resource configuration");
+ }
+
+ if (config != null) {
+
+ try {
+ prefix = ManagedBuildManager
+ .getBuildMacroProvider()
+ .resolveValueToMakefileFormat(
+ prefix,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ config);
+ }
+
+ catch (BuildMacroException e) {
+ }
+
+ }
+
+ if(prefix == null)
+ prefix = EMPTY_STRING;
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,prefix);
+ }
+ }*/
+/* else if("TargetOsList".equals(macroName)){ //$NON-NLS-1$
+ IToolChain toolChain = cfg.getToolChain();
+ String osList[] = toolChain.getOSList();
+ if(osList == null)
+ osList = new String[0];
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT_LIST,osList);
+ }*/
+/* else if("TargetArchList".equals(macroName)){ //$NON-NLS-1$
+ IToolChain toolChain = cfg.getToolChain();
+ String archList[] = toolChain.getArchList();
+ if(archList == null)
+ archList = new String[0];
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT_LIST,archList);
+
+ }*/
+/* else if("ToolChainVersion".equals(macroName)){ //$NON-NLS-1$
+ if(cfg.getToolChain().getVersion() != null)
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,cfg.getToolChain().getVersion().toString());
+ }*/
+/* else if("BuilderVersion".equals(macroName)){ //$NON-NLS-1$
+ PluginVersionIdentifier version = cfg.getToolChain().getBuilder().getVersion();
+ if(version != null)
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,version.toString());
+ }*/
+ return macro;
+ }
+
+ private String getBaseName(String name){
+ String value = null;
+ int index = name.lastIndexOf('.');
+ if(index == -1)
+ value = name;
+ else
+ value = name.substring(0,index);
+ return value;
+ }
+
+ private String getExtension(String name){
+ String value = null;
+ int index = name.lastIndexOf('.');
+ if(index != -1)
+ value = name.substring(index+1);
+ return value;
+ }
+
+/* public IBuildMacro getMacro(String macroName, IManagedProject mngProj){
+ IBuildMacro macro = null;
+ if("ProjName".equals(macroName)){ //$NON-NLS-1$
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,mngProj.getOwner().getName());
+ }
+ else if("ProjDirPath".equals(macroName)){ //$NON-NLS-1$
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_PATH_DIR,mngProj.getOwner().getLocation().toOSString());
+ }
+ return macro;
+ }
+*/
+ public ICdtVariable getMacro(String macroName, IWorkspace wsp){
+ if(wsp == null)
+ wsp = ResourcesPlugin.getWorkspace();
+ ICdtVariable macro = null;
+ if("WorkspaceDirPath".equals(macroName)){ //$NON-NLS-1$
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_PATH_DIR,wsp.getRoot().getLocation().toOSString());
+ } else if("DirectoryDelimiter".equals(macroName)){ //$NON-NLS-1$
+ if(isWin32()){
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,"\\"); //$NON-NLS-1$
+ } else {
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,"/"); //$NON-NLS-1$
+ }
+ } else if("PathDelimiter".equals(macroName)){ //$NON-NLS-1$
+ if(isWin32()){
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,";"); //$NON-NLS-1$
+ } else {
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,":"); //$NON-NLS-1$
+ }
+ }
+ return macro;
+ }
+
+ private boolean isWin32(){
+ String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
+ if (os.startsWith("windows ")) //$NON-NLS-1$
+ return true;
+ return false;
+ }
+
+ public ICdtVariable getMacro(String macroName){
+ ICdtVariable macro = null;
+ if("EclipseVersion".equals(macroName)){ //$NON-NLS-1$
+ Bundle bundle = Platform.getBundle("org.eclipse.platform"); //$NON-NLS-1$
+ String version = bundle != null ?
+ (String)bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION) :
+ null;
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,version);
+ }
+ else if("CDTVersion".equals(macroName)){ //$NON-NLS-1$
+ String version = (String)CCorePlugin.getDefault().getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION);
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,version);
+ }
+/* else if("MBSVersion".equals(macroName)){ //$NON-NLS-1$
+ String version = ManagedBuildManager.getBuildInfoVersion().toString();
+ macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,version);
+ }*/
+ else if("HostOsName".equals(macroName)){ //$NON-NLS-1$
+ String os = System.getProperty("os.name"); //$NON-NLS-1$
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,os);
+ }
+ else if("HostArchName".equals(macroName)){ //$NON-NLS-1$
+ String arch = System.getProperty("os.arch"); //$NON-NLS-1$
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,arch);
+ }
+ else if("OsType".equals(macroName)){ //$NON-NLS-1$
+ String os = Platform.getOS();
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,os);
+ }
+ else if("ArchType".equals(macroName)){ //$NON-NLS-1$
+ String arch = Platform.getOSArch();
+ macro = new CdtVariable(macroName,ICdtVariable.VALUE_TEXT,arch);
+ }
+
+ return macro;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
+ */
+ public ICdtVariable[] getMacros(int contextType, Object contextData) {
+ String names[] = getMacroNames(contextType,false);
+
+ if(names != null){
+ ICdtVariable macros[] = new ICdtVariable[names.length];
+ int num = 0;
+ for(int i = 0; i < names.length; i++){
+ ICdtVariable macro = getMacro(names[i],contextType,contextData);
+ if(macro != null)
+ macros[num++] = macro;
+ }
+ if(macros.length != num){
+ ICdtVariable tmp[] = new ICdtVariable[num];
+ if(num > 0)
+ System.arraycopy(macros,0,tmp,0,num);
+ macros = tmp;
+ }
+ return macros;
+ }
+ return null;
+ }
+
+/* private IPath getBuilderCWD(IConfiguration cfg){
+ IPath workingDirectory = null;
+ IResource owner = cfg.getOwner();
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(owner);
+
+ if(info != null){
+ if(info.getDefaultConfiguration().equals(cfg)){
+ IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
+ generator.initialize((IProject)owner,info,null);
+
+ IPath topBuildDir = generator.getBuildWorkingDir();
+ if(topBuildDir == null)
+ topBuildDir = new Path(info.getConfigurationName());
+
+ IPath projectLocation = owner.getLocation();
+ workingDirectory = projectLocation.append(topBuildDir);
+ }
+ }
+ return workingDirectory;
+ }
+*/
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java
new file mode 100644
index 00000000000..fef7ea7dac7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.internal.core.cdtvariables.EclipseVariablesVariableSupplier.EclipseVarMacro;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
+import org.eclipse.core.variables.IStringVariable;
+
+/**
+ * The default IBuildMacroProvider implementation
+ * @since 3.0
+ */
+public class CdtVariableManager implements ICdtVariableManager {
+ static private CdtVariableManager fDefault;
+
+ public static UserDefinedVariableSupplier fUserDefinedMacroSupplier = UserDefinedVariableSupplier.getInstance();
+ public static EnvironmentVariableSupplier fEnvironmentMacroSupplier = EnvironmentVariableSupplier.getInstance();
+ public static CdtMacroSupplier fCdtMacroSupplier = CdtMacroSupplier.getInstance();
+ public static EclipseVariablesVariableSupplier fEclipseVariablesMacroSupplier = EclipseVariablesVariableSupplier.getInstance();
+
+ protected CdtVariableManager(){
+
+ }
+
+ public static CdtVariableManager getDefault(){
+ if(fDefault == null)
+ fDefault = new CdtVariableManager();
+ return fDefault;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#getMacro(java.lang.String, int, java.lang.Object, boolean)
+ */
+ public ICdtVariable getVariable(String macroName, ICConfigurationDescription cfg) {
+ if(cfg instanceof CConfigurationDescriptionCache){
+ StorableCdtVariables macros = ((CConfigurationDescriptionCache)cfg).getCachedVariables();
+ if(macros != null)
+ return macros.getMacro(macroName);
+ }
+ int type = getContextType(cfg);
+ return SupplierBasedCdtVariableManager.getVariable(macroName,
+ getMacroContextInfo(type,cfg),true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#getMacros(int, java.lang.Object, boolean)
+ */
+ public ICdtVariable[] getVariables(ICConfigurationDescription cfg) {
+ if(cfg instanceof CConfigurationDescriptionCache){
+ StorableCdtVariables macros = ((CConfigurationDescriptionCache)cfg).getCachedVariables();
+ if(macros != null)
+ return macros.getMacros();
+ }
+ int type = getContextType(cfg);
+ return SupplierBasedCdtVariableManager.getVariables(getMacroContextInfo(type,cfg),
+ true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#getSuppliers(int, java.lang.Object)
+ */
+ public ICdtVariableSupplier[] getSuppliers(int contextType,
+ Object contextData) {
+ IVariableContextInfo info = getMacroContextInfo(contextType,contextData);
+ if(info != null)
+ return info.getSuppliers();
+ return null;
+ }
+
+ /**
+ * @param contextType
+ * @param contextData
+ * @return
+ */
+ public IVariableContextInfo getMacroContextInfo(
+ int contextType,
+ Object contextData){
+ DefaultVariableContextInfo info = new DefaultVariableContextInfo(contextType,contextData);
+ if(info.getSuppliers() != null)
+ return info;
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#convertStringListToString(java.lang.String[], java.lang.String)
+ */
+ public String convertStringListToString(String[] value, String listDelimiter) {
+ return CdtVariableResolver.convertStringListToString(value,listDelimiter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveValue(java.lang.String, java.lang.String, java.lang.String, int, java.lang.Object)
+ */
+ public String resolveValue(String value, String nonexistentMacrosValue,
+ String listDelimiter, ICConfigurationDescription cfg)
+ throws CdtVariableException {
+
+ IVariableContextInfo info = getMacroContextInfo(getContextType(cfg),cfg);
+ if(info != null)
+ return CdtVariableResolver.resolveToString(value,
+ getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValue(java.lang.String, java.lang.String, int, java.lang.Object)
+ */
+ public String[] resolveStringListValue(String value,
+ String nonexistentMacrosValue, String listDelimiter,
+ ICConfigurationDescription cfg) throws CdtVariableException {
+
+ IVariableContextInfo info = getMacroContextInfo(getContextType(cfg),cfg);
+ if(info != null)
+ return CdtVariableResolver.resolveToStringList(value,getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter));
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#isStringListValue(java.lang.String)
+ */
+ public boolean isStringListValue(String value, ICConfigurationDescription cfg) throws CdtVariableException {
+ try {
+ CdtVariableResolver.resolveToStringList(value,getMacroSubstitutor(getMacroContextInfo(getContextType(cfg), cfg)," ",null)); //$NON-NLS-1$
+ }catch(CdtVariableException e){
+ return false;
+ }
+ return true;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#checkIntegrity(int, java.lang.Object)
+ */
+ public void checkVariableIntegrity(ICConfigurationDescription cfg)
+ throws CdtVariableException {
+
+ int type = getContextType(cfg);
+ IVariableContextInfo info = getMacroContextInfo(type,cfg);
+ IVariableSubstitutor subst = new CoreVariableSubstitutor(info,null,""){ //$NON-NLS-1$
+ protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException {
+ if(macro instanceof EclipseVariablesVariableSupplier.EclipseVarMacro)
+ return new ResolvedMacro(macro.getName(),""); //$NON-NLS-1$
+ return super.resolveMacro(macro);
+ }
+ };
+ if(info != null)
+ CdtVariableResolver.checkIntegrity(info,subst);
+ }
+
+ private int getContextType(ICConfigurationDescription des){
+ if(des != null)
+ return DefaultVariableContextInfo.CONTEXT_CONFIGURATION;
+ return DefaultVariableContextInfo.CONTEXT_WORKSPACE;
+ }
+
+ public IVariableSubstitutor getMacroSubstitutor(IVariableContextInfo info, String inexistentMacroValue, String listDelimiter){
+ return new CoreVariableSubstitutor(info, inexistentMacroValue, listDelimiter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValues(java.lang.String[], java.lang.String, java.lang.String, int, java.lang.Object)
+ */
+ public String[] resolveStringListValues(String[] value, String nonexistentMacrosValue, String listDelimiter, ICConfigurationDescription cfg) throws CdtVariableException {
+ IVariableContextInfo info = getMacroContextInfo(getContextType(cfg),cfg);
+ if(info != null)
+ return CdtVariableResolver.resolveStringListValues(value,
+ getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter), true);
+ return null;
+ }
+
+ public boolean isEnvironmentVariable(ICdtVariable variable,
+ ICConfigurationDescription cfg) {
+ return variable instanceof EnvironmentVariableSupplier.EnvVarMacro;
+ }
+
+ public IStringVariable toEclipseVariable(ICdtVariable variable,
+ ICConfigurationDescription cfg) {
+ if(variable instanceof EclipseVariablesVariableSupplier.EclipseVarMacro){
+ return ((EclipseVarMacro)variable).getVariable();
+ }
+ return null;
+ }
+
+ public boolean isUserVariable(ICdtVariable variable,
+ ICConfigurationDescription cfg) {
+ return variable instanceof StorableCdtVariable;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java
new file mode 100644
index 00000000000..78c5e7b32d8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+
+public abstract class CoreMacroSupplierBase implements ICdtVariableSupplier {
+
+ public ICdtVariable getVariable(String macroName, IVariableContextInfo context) {
+ if(context instanceof ICoreVariableContextInfo){
+ ICoreVariableContextInfo info = (ICoreVariableContextInfo)context;
+ return getMacro(macroName, info.getContextType(), info.getContextData());
+ }
+ return null;
+ }
+
+ protected abstract ICdtVariable getMacro(String name, int type, Object data);
+
+ public ICdtVariable[] getVariables(IVariableContextInfo context) {
+ if(context instanceof ICoreVariableContextInfo){
+ ICoreVariableContextInfo info = (ICoreVariableContextInfo)context;
+ return getMacros(info.getContextType(), info.getContextData());
+ }
+ return null;
+ }
+
+ protected abstract ICdtVariable[] getMacros(int type, Object data);
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreVariableSubstitutor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreVariableSubstitutor.java
new file mode 100644
index 00000000000..8b8f2af48ef
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreVariableSubstitutor.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+
+/**
+ * This substitutor resolves all macro references
+ *
+ * @see org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor
+ * @since 3.0
+ */
+public class CoreVariableSubstitutor extends SupplierBasedCdtVariableSubstitutor {
+
+
+ public CoreVariableSubstitutor(IVariableContextInfo contextInfo,
+ String inexistentMacroValue, String listDelimiter,
+ Map delimiterMap, String incorrectlyReferencedMacroValue) {
+ super(contextInfo, inexistentMacroValue, listDelimiter, delimiterMap,
+ incorrectlyReferencedMacroValue);
+ // TODO Auto-generated constructor stub
+ }
+
+ public CoreVariableSubstitutor(IVariableContextInfo contextInfo,
+ String inexistentMacroValue, String listDelimiter) {
+ super(contextInfo, inexistentMacroValue, listDelimiter);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#setMacroContextInfo(int, java.lang.Object)
+ */
+ public void setMacroContextInfo(int contextType, Object contextData) throws CdtVariableException{
+ setMacroContextInfo(getMacroContextInfo(contextType,contextData));
+ }
+
+ protected IVariableContextInfo getMacroContextInfo(int contextType, Object contextData){
+ return new DefaultVariableContextInfo(contextType, contextData);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java
new file mode 100644
index 00000000000..4309ee4068e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+/**
+ * This is the default implementation of the IMacroContextInfo
+ *
+ * @since 3.0
+ */
+public class DefaultVariableContextInfo implements ICoreVariableContextInfo {
+
+ private ICdtVariableSupplier fSuppliers[];
+ private int fType;
+ private Object fData;
+
+ public DefaultVariableContextInfo(int type, Object data){
+ fType = type;
+ fData = data;
+ }
+
+ protected DefaultVariableContextInfo(int type, Object data, ICdtVariableSupplier suppliers[]){
+ fType = type;
+ fData = data;
+ fSuppliers = suppliers;
+ }
+
+ protected ICdtVariableSupplier[] getSuppliers(int type, Object data){
+ switch(type){
+ case CONTEXT_CONFIGURATION:
+ if(data instanceof ICConfigurationDescription){
+ return new ICdtVariableSupplier[]{
+ CdtVariableManager.fUserDefinedMacroSupplier,
+ CdtVariableManager.fEnvironmentMacroSupplier,
+ CdtVariableManager.fCdtMacroSupplier
+ };
+ }
+ break;
+ case CONTEXT_WORKSPACE:
+ if(data == null || data instanceof IWorkspace){
+ return new ICdtVariableSupplier[]{
+ CdtVariableManager.fUserDefinedMacroSupplier,
+ CdtVariableManager.fEnvironmentMacroSupplier,
+ CdtVariableManager.fCdtMacroSupplier,
+ CdtVariableManager.fEclipseVariablesMacroSupplier
+ };
+ }
+ break;
+ case CONTEXT_INSTALLATIONS:
+ if(data == null){
+ return new ICdtVariableSupplier[]{
+ CdtVariableManager.fCdtMacroSupplier
+ };
+ }
+ break;
+ case CONTEXT_ECLIPSEENV:
+ if(data == null){
+ return new ICdtVariableSupplier[]{
+ CdtVariableManager.fEnvironmentMacroSupplier
+ };
+ }
+ break;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getContextType()
+ */
+ public int getContextType() {
+ return fType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getContextData()
+ */
+ public Object getContextData() {
+ return fData;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getSuppliers()
+ */
+ public ICdtVariableSupplier[] getSuppliers() {
+ if(fSuppliers == null)
+ fSuppliers = getSuppliers(fType, fData);
+ return fSuppliers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getNext()
+ */
+ public IVariableContextInfo getNext() {
+ switch(fType){
+ case CONTEXT_CONFIGURATION:
+ if(fData instanceof ICConfigurationDescription){
+ IWorkspace wsp = ResourcesPlugin.getWorkspace();
+ if(wsp != null)
+ return new DefaultVariableContextInfo(
+ CONTEXT_WORKSPACE,
+ wsp);
+ }
+ break;
+ case CONTEXT_WORKSPACE:
+ if(fData instanceof IWorkspace){
+ return new DefaultVariableContextInfo(
+ CONTEXT_INSTALLATIONS,
+ null);
+ }
+ break;
+ case CONTEXT_INSTALLATIONS:
+ if(fData == null){
+ return new DefaultVariableContextInfo(
+ CONTEXT_ECLIPSEENV,
+ null);
+ }
+ break;
+ case CONTEXT_ECLIPSEENV:
+ if(fData == null){
+ return null;
+ }
+ break;
+ }
+ return null;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/EclipseVariablesMacroSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EclipseVariablesVariableSupplier.java
index 4b057b413eb..b1e6beaa0d2 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/EclipseVariablesMacroSupplier.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EclipseVariablesVariableSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,17 +8,18 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
+package org.eclipse.cdt.internal.core.cdtvariables;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
+import org.eclipse.cdt.core.cdtvariables.CdtVariable;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.variables.IDynamicVariable;
import org.eclipse.core.variables.IStringVariable;
@@ -31,24 +32,24 @@ import org.eclipse.core.variables.VariablesPlugin;
*
* @since 3.0
*/
-public class EclipseVariablesMacroSupplier implements IBuildMacroSupplier {
+public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier {
private static final String VAR_PREFIX = "${"; //$NON-NLS-1$
private static final char VAR_SUFFIX = '}'; //$NON-NLS-1$
private static final char COLON = ':'; //$NON-NLS-1$
- private static EclipseVariablesMacroSupplier fInstance;
+ private static EclipseVariablesVariableSupplier fInstance;
- private EclipseVariablesMacroSupplier(){
+ private EclipseVariablesVariableSupplier(){
}
- public static EclipseVariablesMacroSupplier getInstance(){
+ public static EclipseVariablesVariableSupplier getInstance(){
if(fInstance == null)
- fInstance = new EclipseVariablesMacroSupplier();
+ fInstance = new EclipseVariablesVariableSupplier();
return fInstance;
}
- public class EclipseVarMacro extends BuildMacro {
+ public class EclipseVarMacro extends CdtVariable {
private IStringVariable fVariable;
private String fArgument;
private boolean fInitialized;
@@ -69,7 +70,7 @@ public class EclipseVariablesMacroSupplier implements IBuildMacroSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringValue()
*/
- public String getStringValue() throws BuildMacroException {
+ public String getStringValue() throws CdtVariableException {
if(!fInitialized){
loadValue(fVariable);
fInitialized = true;
@@ -106,10 +107,14 @@ public class EclipseVariablesMacroSupplier implements IBuildMacroSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
*/
- public IBuildMacro getMacro(String macroName, int contextType,
- Object contextData) {
- if(contextType != IBuildMacroProvider.CONTEXT_WORKSPACE)
- return null;
+ public ICdtVariable getVariable(String macroName, IVariableContextInfo info) {
+ return getVariable(macroName);
+ }
+
+ public ICdtVariable getVariable(String macroName) {
+
+// if(contextType != DefaultMacroContextInfo.CONTEXT_WORKSPACE)
+// return null;
if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
return null;
@@ -139,9 +144,13 @@ public class EclipseVariablesMacroSupplier implements IBuildMacroSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
*/
- public IBuildMacro[] getMacros(int contextType, Object contextData) {
- if(contextType != IBuildMacroProvider.CONTEXT_WORKSPACE)
- return null;
+ public ICdtVariable[] getVariables(IVariableContextInfo info) {
+ return getVariables();
+ }
+
+ public ICdtVariable[] getVariables() {
+// if(contextType != DefaultMacroContextInfo.CONTEXT_WORKSPACE)
+// return null;
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
IDynamicVariable vars[] = mngr.getDynamicVariables();
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EnvironmentVariableSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EnvironmentVariableSupplier.java
new file mode 100644
index 00000000000..6019b1924f7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EnvironmentVariableSupplier.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariable;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
+import org.eclipse.core.resources.IWorkspace;
+
+/**
+ * This supplier suplies the macros that represent the Managed Build environment variables
+ *
+ * @since 3.0
+ */
+public class EnvironmentVariableSupplier extends CoreMacroSupplierBase {
+ private static EnvironmentVariableSupplier fInstance;
+ private EnvironmentVariableManager fEnvironmentProvider;
+
+ public class EnvVarMacro extends CdtVariable{
+ private IEnvironmentVariable fVariable;
+ private EnvVarMacro(IEnvironmentVariable var){
+ fName = var.getName();
+ fVariable = var;
+ }
+
+ private void loadValue(IEnvironmentVariable var){
+ String delimiter = var.getDelimiter();
+ String value = var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE ?
+ var.getValue() : null;
+
+ if(delimiter != null && !"".equals(delimiter)){ //$NON-NLS-1$
+ fType = VALUE_TEXT_LIST;
+ if(value != null){
+ List list = EnvVarOperationProcessor.convertToList(value,delimiter);
+ fStringListValue = (String[])list.toArray(new String[list.size()]);
+ } else {
+ fStringListValue = null;
+ }
+ } else {
+ fType = VALUE_TEXT;
+ fStringValue = value;
+ }
+ }
+
+
+ public int getValueType() {
+ if(fVariable != null){
+ loadValue(fVariable);
+
+ //we do not need it any more, release clean the reference
+ fVariable = null;
+ }
+ return super.getValueType();
+ }
+
+ public String getStringValue() throws CdtVariableException {
+ if(fVariable != null){
+ loadValue(fVariable);
+
+ //we do not need it any more, release clean the reference
+ fVariable = null;
+ }
+ return super.getStringValue();
+ }
+
+ public String[] getStringListValue() throws CdtVariableException {
+ if(fVariable != null){
+ loadValue(fVariable);
+
+ //we do not need it any more, release clean the reference
+ fVariable = null;
+ }
+ return super.getStringListValue();
+ }
+ }
+
+ protected EnvironmentVariableSupplier(){
+ this(EnvironmentVariableManager.getDefault());
+ }
+
+ public EnvironmentVariableSupplier(EnvironmentVariableManager varProvider){
+ fEnvironmentProvider = varProvider;
+ }
+
+ public ICdtVariable createBuildMacro(IEnvironmentVariable var){
+ if(var != null)
+ return new EnvVarMacro(var);
+ return null;
+ }
+
+ public static EnvironmentVariableSupplier getInstance(){
+ if(fInstance == null)
+ fInstance = new EnvironmentVariableSupplier();
+ return fInstance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
+ */
+ public ICdtVariable getMacro(String macroName, int contextType,
+ Object contextData) {
+ if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
+ return null;
+
+ IEnvironmentVariable var = null;
+ switch(contextType){
+ case ICoreVariableContextInfo.CONTEXT_CONFIGURATION:
+ if(contextData instanceof ICConfigurationDescription){
+ var = fEnvironmentProvider.getVariable(macroName, (ICConfigurationDescription)contextData, false);
+ }
+ break;
+ case ICoreVariableContextInfo.CONTEXT_WORKSPACE:
+ if(contextData == null || contextData instanceof IWorkspace){
+ var = fEnvironmentProvider.getVariable(macroName, (ICConfigurationDescription)null, false);
+ }
+ break;
+// case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
+// if(contextData == null){
+// var = fEnvironmentProvider.getVariable(macroName,fEnvironmentProvider.getContextInfo(contextData),false);
+// }
+// break;
+ }
+ if(var != null && var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE)
+ return new EnvVarMacro(var);
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
+ */
+ public ICdtVariable[] getMacros(int contextType, Object contextData) {
+ IEnvironmentVariable vars[] = null;
+
+ switch(contextType){
+ case ICoreVariableContextInfo.CONTEXT_CONFIGURATION:
+ if(contextData instanceof ICConfigurationDescription){
+ vars = fEnvironmentProvider.getVariables((ICConfigurationDescription)contextData, false);
+ }
+ break;
+ case ICoreVariableContextInfo.CONTEXT_WORKSPACE:
+ if(contextData == null || contextData instanceof IWorkspace){
+ vars = fEnvironmentProvider.getVariables((ICConfigurationDescription)null, false);
+ }
+ break;
+// case IBuildMacroProvider.CONTEXT_ECLIPSEENV:
+// if(contextData == null){
+// vars = fEnvironmentProvider.getVariables(fEnvironmentProvider.getContextInfo(contextData),false).toArray(false);
+// }
+// break;
+ }
+
+ if(vars != null){
+ EnvVarMacro macros[] = new EnvVarMacro[vars.length];
+ for(int i = 0; i < macros.length; i++)
+ macros[i] = new EnvVarMacro(vars[i]);
+
+ return macros;
+ }
+
+ return null;
+ }
+/*
+ public EnvironmentVariableProvider getEnvironmentVariableProvider(){
+ return fEnvironmentProvider;
+ }
+*/
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/ICoreVariableContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/ICoreVariableContextInfo.java
new file mode 100644
index 00000000000..b0e7e4e333a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/ICoreVariableContextInfo.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.cdtvariables;
+
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+
+public interface ICoreVariableContextInfo extends IVariableContextInfo {
+// public final static int CONTEXT_FILE = 1;
+// public final static int CONTEXT_OPTION = 2;
+ public final static int CONTEXT_CONFIGURATION = 3;
+// public final static int CONTEXT_PROJECT = 4;
+ public final static int CONTEXT_WORKSPACE = 5;
+ public final static int CONTEXT_INSTALLATIONS = 6;
+ public final static int CONTEXT_ECLIPSEENV = 7;
+
+ /**
+ * returns the context type
+ *
+ * @return int
+ */
+ public int getContextType();
+
+ /**
+ * returns the context data
+ *
+ * @return Object
+ */
+ public Object getContextData();
+
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableBuildMacro.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariable.java
index e1a2d62eb8b..75bd0f30694 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableBuildMacro.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,15 +8,14 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
+package org.eclipse.cdt.internal.core.cdtvariables;
import java.util.ArrayList;
import java.util.List;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import org.eclipse.cdt.core.cdtvariables.CdtVariable;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
/**
* This class represents the Build Macro that could be loaded
@@ -25,7 +24,7 @@ import org.w3c.dom.NodeList;
* @since 3.0
*
*/
-public class StorableBuildMacro extends BuildMacro {
+public class StorableCdtVariable extends CdtVariable {
public static final String STRING_MACRO_ELEMENT_NAME = "stringMacro"; //$NON-NLS-1$
public static final String STRINGLIST_MACRO_ELEMENT_NAME = "stringListMacro"; //$NON-NLS-1$
public static final String NAME = "name"; //$NON-NLS-1$
@@ -44,32 +43,32 @@ public class StorableBuildMacro extends BuildMacro {
public static final String TYPE_PATH_ANY = "VALUE_PATH_ANY"; //$NON-NLS-1$
public static final String TYPE_PATH_ANY_LIST = "VALUE_PATH_ANY_LIST"; //$NON-NLS-1$
- public StorableBuildMacro(String name, int type, String value){
+ public StorableCdtVariable(String name, int type, String value){
super(name,type,value);
}
- public StorableBuildMacro(String name, int type, String value[]){
+ public StorableCdtVariable(String name, int type, String value[]){
super(name,type,value);
}
- public StorableBuildMacro(Element element){
+ public StorableCdtVariable(ICStorageElement element){
load(element);
}
- private void load(Element element){
+ private void load(ICStorageElement element){
fName = element.getAttribute(NAME);
fType = typeStringToInt(element.getAttribute(TYPE));
- if(!MacroResolver.isStringListMacro(fType))
+ if(!CdtVariableResolver.isStringListVariable(fType))
fStringValue = element.getAttribute(VALUE);
else {
- NodeList nodeList = element.getChildNodes();
+ ICStorageElement nodeList[] = element.getChildren();
List values = new ArrayList();
- for (int i = 0; i < nodeList.getLength(); ++i) {
- Node node = nodeList.item(i);
- if (node.getNodeName().equals(VALUE_ELEMENT_NAME)) {
- values.add(((Element)node).getAttribute(VALUE_ELEMENT_VALUE));
+ for (int i = 0; i < nodeList.length; ++i) {
+ ICStorageElement node = nodeList[i];
+ if (node.getName().equals(VALUE_ELEMENT_NAME)) {
+ values.add(node.getAttribute(VALUE_ELEMENT_VALUE));
}
}
fStringListValue = (String[])values.toArray(new String[values.size()]);
@@ -133,21 +132,20 @@ public class StorableBuildMacro extends BuildMacro {
return stringType;
}
- public void serialize(Document doc, Element element){
+ public void serialize(ICStorageElement element){
if(fName != null)
element.setAttribute(NAME,fName);
element.setAttribute(TYPE,typeIntToString(fType));
- if(!MacroResolver.isStringListMacro(fType)){
+ if(!CdtVariableResolver.isStringListVariable(fType)){
if(fStringValue != null)
element.setAttribute(VALUE,fStringValue);
}
else {
if(fStringListValue != null && fStringListValue.length > 0){
for(int i = 0; i < fStringListValue.length; i++){
- Element valEl = doc.createElement(VALUE_ELEMENT_NAME);
- element.appendChild(valEl);
+ ICStorageElement valEl = element.createChild(VALUE_ELEMENT_NAME);
if(fStringListValue[i] != null)
valEl.setAttribute(VALUE_ELEMENT_VALUE, fStringListValue[i]);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableMacros.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java
index 8b701cd7b9f..bdf269243d4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableMacros.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,19 +8,18 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
+package org.eclipse.cdt.internal.core.cdtvariables;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
/**
* This class represents the set of Build Macros that could be loaded
@@ -29,68 +28,82 @@ import org.w3c.dom.NodeList;
* @since 3.0
*
*/
-public class StorableMacros {
+public class StorableCdtVariables {
public static final String MACROS_ELEMENT_NAME = "macros"; //$NON-NLS-1$
- public static final String EXPAND_ENVIRONMENT_MACROS = "expandEnvironmentMacros"; //$NON-NLS-1$
- public static final String TRUE = "true"; //$NON-NLS-1$
- private Map fMacros;
- private boolean fExpandInMakefile = false;
+// public static final String EXPAND_ENVIRONMENT_MACROS = "expandEnvironmentMacros"; //$NON-NLS-1$
+// public static final String TRUE = "true"; //$NON-NLS-1$
+ private HashMap fMacros;
+// private boolean fExpandInMakefile = false;
private boolean fIsDirty = false;
private boolean fIsChanged = false;
+ private boolean fIsReadOnly;
- private Map getMap(){
+ private HashMap getMap(){
if(fMacros == null)
fMacros = new HashMap();
return fMacros;
}
- public StorableMacros() {
+ public StorableCdtVariables(boolean readOnly) {
+ fIsReadOnly = readOnly;
+ }
+
+ public StorableCdtVariables(StorableCdtVariables base, boolean readOnly) {
+ fMacros = (HashMap)base.getMap().clone();
+ fIsReadOnly = readOnly;
+ }
+ public StorableCdtVariables(ICdtVariable vars[], boolean readOnly) {
+ fMacros = new HashMap(vars.length);
+ for(int i = 0; i < vars.length; i++){
+ addMacro(vars[i]);
+ }
+ fIsReadOnly = readOnly;
}
- public StorableMacros(Element element) {
+ public StorableCdtVariables(ICStorageElement element, boolean readOnly) {
load(element);
+ fIsReadOnly = readOnly;
}
- private void load(Element element){
- fExpandInMakefile = TRUE.equals(element.getAttribute(EXPAND_ENVIRONMENT_MACROS));
+ private void load(ICStorageElement element){
+// fExpandInMakefile = TRUE.equals(element.getAttribute(EXPAND_ENVIRONMENT_MACROS));
- NodeList nodeList = element.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); ++i) {
- Node node = nodeList.item(i);
- String name = node.getNodeName();
- if (StorableBuildMacro.STRING_MACRO_ELEMENT_NAME.equals(name)) {
- addMacro(new StorableBuildMacro((Element)node));
+ ICStorageElement nodeList[] = element.getChildren();
+ for (int i = 0; i < nodeList.length; ++i) {
+ ICStorageElement node = nodeList[i];
+ String name = node.getName();
+ if (StorableCdtVariable.STRING_MACRO_ELEMENT_NAME.equals(name)) {
+ addMacro(new StorableCdtVariable(node));
}
- else if (StorableBuildMacro.STRINGLIST_MACRO_ELEMENT_NAME.equals(name)) {
- addMacro(new StorableBuildMacro((Element)node));
+ else if (StorableCdtVariable.STRINGLIST_MACRO_ELEMENT_NAME.equals(name)) {
+ addMacro(new StorableCdtVariable(node));
}
}
fIsDirty = false;
fIsChanged = false;
}
- public void serialize(Document doc, Element element){
- if(fExpandInMakefile)
- element.setAttribute(EXPAND_ENVIRONMENT_MACROS,TRUE);
+ public void serialize(ICStorageElement element){
+// if(fExpandInMakefile)
+// element.setAttribute(EXPAND_ENVIRONMENT_MACROS,TRUE);
if(fMacros != null){
Iterator iter = fMacros.values().iterator();
while(iter.hasNext()){
- StorableBuildMacro macro = (StorableBuildMacro)iter.next();
- Element macroEl;
- if(MacroResolver.isStringListMacro(macro.getMacroValueType()))
- macroEl = doc.createElement(StorableBuildMacro.STRINGLIST_MACRO_ELEMENT_NAME);
+ StorableCdtVariable macro = (StorableCdtVariable)iter.next();
+ ICStorageElement macroEl;
+ if(CdtVariableResolver.isStringListVariable(macro.getValueType()))
+ macroEl = element.createChild(StorableCdtVariable.STRINGLIST_MACRO_ELEMENT_NAME);
else
- macroEl = doc.createElement(StorableBuildMacro.STRING_MACRO_ELEMENT_NAME);
- element.appendChild(macroEl);
- macro.serialize(doc,macroEl);
+ macroEl = element.createChild(StorableCdtVariable.STRING_MACRO_ELEMENT_NAME);
+ macro.serialize(macroEl);
}
}
fIsDirty = false;
}
- private void addMacro(IBuildMacro macro){
+ private void addMacro(ICdtVariable macro){
String name = macro.getName();
if(name == null)
return;
@@ -98,13 +111,13 @@ public class StorableMacros {
getMap().put(name,macro);
}
- public IBuildMacro createMacro(String name, int type, String value){
- if(name == null || "".equals(name = name.trim()) || MacroResolver.isStringListMacro(type)) //$NON-NLS-1$
+ public ICdtVariable createMacro(String name, int type, String value){
+ if(name == null || "".equals(name = name.trim()) || CdtVariableResolver.isStringListVariable(type)) //$NON-NLS-1$
return null;
- IBuildMacro macro = checkMacro(name, type, value);
+ ICdtVariable macro = checkMacro(name, type, value);
if(macro == null){
- macro = new StorableBuildMacro(name, type, value);
+ macro = new StorableCdtVariable(name, type, value);
addMacro(macro);
fIsDirty = true;
fIsChanged = true;
@@ -112,11 +125,13 @@ public class StorableMacros {
return macro;
}
- public IBuildMacro checkMacro(String name, int type, String value){
- IBuildMacro macro = getMacro(name);
+ public ICdtVariable checkMacro(String name, int type, String value){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ ICdtVariable macro = getMacro(name);
if(macro != null){
if(macro.getName().equals(name)
- && macro.getMacroValueType() == type){
+ && macro.getValueType() == type){
try {
String val = macro.getStringValue();
if((val != null
@@ -124,18 +139,20 @@ public class StorableMacros {
|| val == value){
return macro;
}
- } catch (BuildMacroException e) {
+ } catch (CdtVariableException e) {
}
}
}
return null;
}
- public IBuildMacro checkMacro(String name, int type, String value[]){
- IBuildMacro macro = getMacro(name);
+ public ICdtVariable checkMacro(String name, int type, String value[]){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ ICdtVariable macro = getMacro(name);
if(macro != null){
if(macro.getName().equals(name)
- && macro.getMacroValueType() == type){
+ && macro.getValueType() == type){
try {
String val[] = macro.getStringListValue();
if(val != null){
@@ -151,7 +168,7 @@ public class StorableMacros {
} else if (value == val){
return macro;
}
- } catch (BuildMacroException e) {
+ } catch (CdtVariableException e) {
}
}
}
@@ -163,14 +180,16 @@ public class StorableMacros {
* all macros that are present in the store but not included in the given array
* will be removed
*/
- public void setMacros(IBuildMacro macros[]){
+ public void setMacros(ICdtVariable macros[]){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
if(macros == null || macros.length == 0)
deleteAll();
else{
if (getMap().size() != 0) {
Iterator iter = getMap().values().iterator();
while(iter.hasNext()){
- IBuildMacro m = (IBuildMacro)iter.next();
+ ICdtVariable m = (ICdtVariable)iter.next();
int i;
for(i = 0 ; i < macros.length; i++){
if(m.getName().equals(macros[i].getName()))
@@ -184,26 +203,34 @@ public class StorableMacros {
}
}
- public void createMacros(IBuildMacro macros[]){
+ public void createMacros(ICdtVariable macros[]){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
for(int i = 0; i < macros.length; i++){
createMacro(macros[i]);
}
}
+
+ public boolean isEmpty(){
+ return fMacros == null || fMacros.isEmpty();
+ }
- public IBuildMacro createMacro(IBuildMacro copy){
+ public ICdtVariable createMacro(ICdtVariable copy){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
String name = copy.getName();
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
return null;
- int type = copy.getMacroValueType();
+ int type = copy.getValueType();
- IBuildMacro macro = null;
+ ICdtVariable macro = null;
try{
- if(MacroResolver.isStringListMacro(type)){
+ if(CdtVariableResolver.isStringListVariable(type)){
String value[] = copy.getStringListValue();
macro = checkMacro(name, type, value);
if(macro == null){
- macro = new StorableBuildMacro(name, type, value);
+ macro = new StorableCdtVariable(name, type, value);
addMacro(macro);
fIsDirty = true;
fIsChanged = true;
@@ -213,25 +240,25 @@ public class StorableMacros {
String value = copy.getStringValue();
macro = checkMacro(name, type, value);
if(macro == null){
- macro = new StorableBuildMacro(name, type, value);
+ macro = new StorableCdtVariable(name, type, value);
addMacro(macro);
fIsDirty = true;
fIsChanged = true;
}
}
- }catch(BuildMacroException e){
+ }catch(CdtVariableException e){
}
return macro;
}
- public IBuildMacro createMacro(String name, int type, String value[]){
- if(name == null || "".equals(name = name.trim()) || !MacroResolver.isStringListMacro(type)) //$NON-NLS-1$
+ public ICdtVariable createMacro(String name, int type, String value[]){
+ if(name == null || "".equals(name = name.trim()) || !CdtVariableResolver.isStringListVariable(type)) //$NON-NLS-1$
return null;
- IBuildMacro macro = checkMacro(name, type, value);
+ ICdtVariable macro = checkMacro(name, type, value);
if(macro == null){
- macro = new StorableBuildMacro(name, type, value);
+ macro = new StorableCdtVariable(name, type, value);
addMacro(macro);
fIsDirty = true;
fIsChanged = true;
@@ -254,7 +281,7 @@ public class StorableMacros {
/**
* sets the "dirty" state for this set of macros.
- * @see org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros#isDirty()
+ * @see org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables#isDirty()
* @param dirty represents the new state
*/
public void setDirty(boolean dirty){
@@ -273,11 +300,11 @@ public class StorableMacros {
return fIsChanged;
}
- public boolean isExpanded(){
+/* public boolean isExpanded(){
return fExpandInMakefile;
}
-
- public void setExpanded(boolean expand){
+*/
+/* public void setExpanded(boolean expand){
if(fExpandInMakefile != expand){
fExpandInMakefile = expand;
fIsDirty = true;
@@ -285,34 +312,49 @@ public class StorableMacros {
fIsChanged = true;
}
}
-
+*/
/**
* sets the "change" state for this set of macros.
- * @see org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros#isChanged()
+ * @see org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables#isChanged()
* @param changed represents the new "change" state
*/
public void setChanged(boolean changed){
fIsChanged = changed;
}
- public IBuildMacro getMacro(String name){
+ public ICdtVariable getMacro(String name){
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
return null;
- return (IBuildMacro)getMap().get(name);
+ ICdtVariable var = (ICdtVariable)getMap().get(name);
+ if(var == null){
+ int indx = name.indexOf(':');
+ if(indx != -1){
+ String baseName = name.substring(0, indx);
+ ICdtVariable tmp = (ICdtVariable)getMap().get(baseName);
+ if(tmp != null
+ && CdtVariableManager.getDefault().toEclipseVariable(tmp, null) != null){
+ var = EclipseVariablesVariableSupplier.getInstance().getVariable(name);
+ }
+ }
+ }
+ return var;
}
- public IBuildMacro[] getMacros(){
+ public ICdtVariable[] getMacros(){
Collection macros = getMap().values();
- return (IBuildMacro[])macros.toArray(new IBuildMacro[macros.size()]);
+ return (ICdtVariable[])macros.toArray(new ICdtVariable[macros.size()]);
}
- public IBuildMacro deleteMacro(String name){
+ public ICdtVariable deleteMacro(String name){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
return null;
- IBuildMacro macro = (IBuildMacro)getMap().remove(name);
+ ICdtVariable macro = (ICdtVariable)getMap().remove(name);
if(macro != null){
fIsDirty = true;
fIsChanged = true;
@@ -322,6 +364,8 @@ public class StorableMacros {
}
public boolean deleteAll(){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
Map map = getMap();
if(map.size() > 0){
fIsDirty = true;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java
index cc1771bef4d..94bd5902e6c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,7 +8,7 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
+package org.eclipse.cdt.internal.core.cdtvariables;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -27,23 +27,16 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
-import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
-import org.eclipse.core.resources.IProject;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.util.XmlStorageElement;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
+import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
+import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -57,45 +50,29 @@ import org.xml.sax.SAXException;
*
* @since 3.0
*/
-public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
+public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
// public static final String MACROS_ELEMENT_NAME = "macros"; //$NON-NLS-1$
public static final String NODENAME = "macros"; //$NON-NLS-1$
public static final String PREFNAME_WORKSPACE = "workspace"; //$NON-NLS-1$
- private static UserDefinedMacroSupplier fInstance;
+ private static UserDefinedVariableSupplier fInstance;
- private StorableMacros fWorkspaceMacros;
+ private StorableCdtVariables fWorkspaceMacros;
- public boolean areMacrosExpanded(IConfiguration cfg){
- StorableMacros macros = getStorableMacros(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg);
- if(macros != null)
- return macros.isExpanded();
- return false;
- }
-
- public void setMacrosExpanded(IConfiguration cfg, boolean expanded){
- StorableMacros macros = getStorableMacros(IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg);
- if(macros != null)
- macros.setExpanded(expanded);
- }
-
- private StorableMacros getStorableMacros(int contextType, Object contextData){
- StorableMacros macros = null;
+ private StorableCdtVariables getStorableMacros(int contextType, Object contextData){
+ StorableCdtVariables macros = null;
switch(contextType){
- case IBuildMacroProvider.CONTEXT_CONFIGURATION:
- if(contextData instanceof IConfiguration){
- IToolChain toolChain = ((IConfiguration)contextData).getToolChain();
- if(toolChain instanceof ToolChain)
- macros = ((ToolChain)toolChain).getUserDefinedMacros();
- }
- break;
- case IBuildMacroProvider.CONTEXT_PROJECT:
- if(contextData instanceof ManagedProject){
- macros = ((ManagedProject)contextData).getUserDefinedMacros();
+ case ICoreVariableContextInfo.CONTEXT_CONFIGURATION:
+ if(contextData instanceof IInternalCCfgInfo){
+ try {
+ CConfigurationSpecSettings settings = ((IInternalCCfgInfo)contextData).getSpecSettings();
+ macros = settings.getMacros();
+ } catch (CoreException e) {
+ }
}
break;
- case IBuildMacroProvider.CONTEXT_WORKSPACE:
- if(contextData instanceof IWorkspace){
+ case ICoreVariableContextInfo.CONTEXT_WORKSPACE:
+ if(contextData == null || contextData instanceof IWorkspace){
if(fWorkspaceMacros == null)
fWorkspaceMacros = loadWorkspaceMacros();
macros = fWorkspaceMacros;
@@ -105,13 +82,13 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return macros;
}
- private UserDefinedMacroSupplier(){
+ private UserDefinedVariableSupplier(){
}
- public static UserDefinedMacroSupplier getInstance(){
+ public static UserDefinedVariableSupplier getInstance(){
if(fInstance == null)
- fInstance = new UserDefinedMacroSupplier();
+ fInstance = new UserDefinedVariableSupplier();
return fInstance;
}
@@ -119,12 +96,11 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
*/
- public IBuildMacro getMacro(String macroName, int contextType,
- Object contextData) {
+ public ICdtVariable getMacro(String macroName, int contextType, Object contextData) {
if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
return null;
- StorableMacros macros = getStorableMacros(contextType,contextData);
+ StorableCdtVariables macros = getStorableMacros(contextType,contextData);
if(macros != null)
return macros.getMacro(macroName);
return null;
@@ -133,25 +109,25 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object)
*/
- public IBuildMacro[] getMacros(int contextType, Object contextData) {
- StorableMacros macros = getStorableMacros(contextType,contextData);
+ public ICdtVariable[] getMacros(int contextType, Object contextData) {
+ StorableCdtVariables macros = getStorableMacros(contextType,contextData);
if(macros != null)
return macros.getMacros();
return null;
}
- public IBuildMacro createMacro(String macroName,
+ public ICdtVariable createMacro(String macroName,
int type,
String value,
int contextType,
Object contextData){
if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
return null;
- StorableMacros macros = getStorableMacros(contextType, contextData);
+ StorableCdtVariables macros = getStorableMacros(contextType, contextData);
if(macros == null)
return null;
- IBuildMacro macro = macros.createMacro(macroName,type,value);
+ ICdtVariable macro = macros.createMacro(macroName,type,value);
if(macros.isChanged()){
setRebuildStateForContext(contextType, contextData);
macros.setChanged(false);
@@ -161,18 +137,18 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
}
- public IBuildMacro createMacro(String macroName,
+ public ICdtVariable createMacro(String macroName,
int type,
String value[],
int contextType,
Object contextData){
if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
return null;
- StorableMacros macros = getStorableMacros(contextType, contextData);
+ StorableCdtVariables macros = getStorableMacros(contextType, contextData);
if(macros == null)
return null;
- IBuildMacro macro = macros.createMacro(macroName,type,value);
+ ICdtVariable macro = macros.createMacro(macroName,type,value);
if(macros.isChanged()){
setRebuildStateForContext(contextType, contextData);
macros.setChanged(false);
@@ -182,17 +158,17 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
}
- public IBuildMacro createMacro(IBuildMacro copy, int contextType, Object contextData){
+ public ICdtVariable createMacro(ICdtVariable copy, int contextType, Object contextData){
if(copy == null)
return null;
String macroName = copy.getName();
if(macroName == null || "".equals(macroName)) //$NON-NLS-1$
return null;
- StorableMacros macros = getStorableMacros(contextType, contextData);
+ StorableCdtVariables macros = getStorableMacros(contextType, contextData);
if(macros == null)
return null;
- IBuildMacro macro = macros.createMacro(copy);
+ ICdtVariable macro = macros.createMacro(copy);
if(macros.isChanged()){
setRebuildStateForContext(contextType, contextData);
macros.setChanged(false);
@@ -201,11 +177,11 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return macro;
}
- public IBuildMacro deleteMacro(String name, int contextType, Object contextData){
- StorableMacros macros = getStorableMacros(contextType,contextData);
+ public ICdtVariable deleteMacro(String name, int contextType, Object contextData){
+ StorableCdtVariables macros = getStorableMacros(contextType,contextData);
if(macros == null)
return null;
- IBuildMacro macro = macros.deleteMacro(name);
+ ICdtVariable macro = macros.deleteMacro(name);
if(macro != null)
setRebuildStateForContext(contextType, contextData);
@@ -213,7 +189,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
}
public void deleteAll(int contextType, Object contextData){
- StorableMacros macros = getStorableMacros(contextType, contextData);
+ StorableCdtVariables macros = getStorableMacros(contextType, contextData);
if(macros == null)
return;
@@ -221,8 +197,8 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
setRebuildStateForContext(contextType, contextData);
}
- public void setMacros(IBuildMacro m[], int contextType, Object contextData){
- StorableMacros macros = getStorableMacros(contextType, contextData);
+ public void setMacros(ICdtVariable m[], int contextType, Object contextData){
+ StorableCdtVariables macros = getStorableMacros(contextType, contextData);
if(macros == null)
return;
@@ -238,8 +214,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
* methods used for loadding/storing workspace macros from properties
*
*/
-
- public void serialize(boolean force){
+ public void storeWorkspaceVariables(boolean force){
try{
if(fWorkspaceMacros != null)
storeWorkspaceMacros(fWorkspaceMacros,force);
@@ -247,8 +222,19 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
}
}
+ public StorableCdtVariables getWorkspaceVariablesCopy(){
+ StorableCdtVariables vars = getStorableMacros(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null);
+ return new StorableCdtVariables(vars, false);
+ }
+
+ public void setWorkspaceVariables(StorableCdtVariables vars) throws CoreException{
+ fWorkspaceMacros = new StorableCdtVariables(vars, false);
+
+ storeWorkspaceVariables(true);
+ }
+
private Preferences getWorkspaceNode(){
- Preferences prefNode = new InstanceScope().getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
+ Preferences prefNode = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID);
if(prefNode == null)
return null;
@@ -259,17 +245,17 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
/*
* loads the stored workspace macros
*/
- protected StorableMacros loadWorkspaceMacros(){
+ protected StorableCdtVariables loadWorkspaceMacros(){
InputStream stream = loadInputStream(getWorkspaceNode(),PREFNAME_WORKSPACE);
if(stream == null)
- return new StorableMacros();
+ return new StorableCdtVariables(false);
return loadMacrosFromStream(stream);
}
/*
* stores the given macros
*/
- protected void storeWorkspaceMacros(StorableMacros macros, boolean force) throws CoreException{
+ protected void storeWorkspaceMacros(StorableCdtVariables macros, boolean force) throws CoreException{
if(!macros.isDirty() && !force)
return;
@@ -279,17 +265,17 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
storeOutputStream(stream,getWorkspaceNode(),PREFNAME_WORKSPACE);
}
- private StorableMacros loadMacrosFromStream(InputStream stream){
+ private StorableCdtVariables loadMacrosFromStream(InputStream stream){
try{
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource(stream);
Document document = parser.parse(inputSource);
Element rootElement = document.getDocumentElement();
- if(!StorableMacros.MACROS_ELEMENT_NAME.equals(rootElement.getNodeName()))
+ if(!StorableCdtVariables.MACROS_ELEMENT_NAME.equals(rootElement.getNodeName()))
return null;
- return new StorableMacros(rootElement);
+ return new StorableCdtVariables(new XmlStorageElement(rootElement), true);
}
catch(ParserConfigurationException e){
@@ -304,15 +290,16 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return null;
}
- private ByteArrayOutputStream storeMacrosToStream(StorableMacros macros) throws CoreException{
+ private ByteArrayOutputStream storeMacrosToStream(StorableCdtVariables macros) throws CoreException{
try{
DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
DocumentBuilder builder= factory.newDocumentBuilder();
Document document= builder.newDocument();
- Element rootElement = document.createElement(StorableMacros.MACROS_ELEMENT_NAME);
+ Element rootElement = document.createElement(StorableCdtVariables.MACROS_ELEMENT_NAME);
document.appendChild(rootElement);
- macros.serialize(document,rootElement);
+ ICStorageElement storageElement = new XmlStorageElement(rootElement);
+ macros.serialize(storageElement);
Transformer transformer=TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
@@ -327,25 +314,16 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return stream;
}
catch(ParserConfigurationException e){
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
- e.getMessage(),
- e));
+ throw ExceptionFactory.createCoreException(e.getMessage(),
+ e);
}
catch(TransformerConfigurationException e){
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
- e.getMessage(),
- e));
+ throw ExceptionFactory.createCoreException(e.getMessage(),
+ e);
}
catch(TransformerException e){
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
- e.getMessage(),
- e));
+ throw ExceptionFactory.createCoreException(e.getMessage(),
+ e);
}
}
@@ -369,11 +347,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
private void storeOutputStream(ByteArrayOutputStream stream, Preferences node, String key) throws CoreException{
if(stream == null || node == null || key == null)
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
- ManagedMakeMessages.getResourceString("UserDefinedMacroSupplier.storeOutputStream.wrong.arguments"), //$NON-NLS-1$
- null));
+ throw ExceptionFactory.createCoreException(new IllegalArgumentException());
byte[] bytes= stream.toByteArray();
String val = null;
@@ -389,31 +363,20 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
node.flush();
}
catch(BackingStoreException e){
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
- e.getMessage(),
- e));
+ throw ExceptionFactory.createCoreException(e.getMessage(),
+ e);
}
}
protected void setRebuildStateForContext(int contextType, Object contextData){
-
+/*
switch(contextType){
- case IBuildMacroProvider.CONTEXT_CONFIGURATION:
+ case DefaultMacroContextInfo.CONTEXT_CONFIGURATION:
if(contextData instanceof IConfiguration){
((IConfiguration)contextData).setRebuildState(true);
}
break;
- case IBuildMacroProvider.CONTEXT_PROJECT:
- if(contextData instanceof IManagedProject){
- IConfiguration cfgs[] = ((IManagedProject)contextData).getConfigurations();
- for(int i = 0; i < cfgs.length; i++){
- cfgs[i].setRebuildState(true);
- }
- }
- break;
- case IBuildMacroProvider.CONTEXT_WORKSPACE:
+ case DefaultMacroContextInfo.CONTEXT_WORKSPACE:
if(contextData instanceof IWorkspace){
IProject projects[] = ((IWorkspace)contextData).getRoot().getProjects();
for(int i = 0; i < projects.length; i++){
@@ -430,7 +393,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
}
}
-
+*/
}
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSustemEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSustemEnvironmentSupplier.java
new file mode 100644
index 00000000000..413aa7a5a7c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSustemEnvironmentSupplier.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.envvar;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
+import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo;
+import org.eclipse.cdt.internal.core.cdtvariables.EnvironmentVariableSupplier;
+import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
+
+/**
+ * This is the Environment Variable Supplier used to supply variables
+ * defined by the tool-integrator
+ *
+ * @since 3.0
+ */
+public class BuildSustemEnvironmentSupplier implements
+ ICoreEnvironmentVariableSupplier {
+
+ /**
+ * EnvironmentVariableProvider passed to the tool-integrator provided
+ * suppliers.
+ * Accepts only contexts lower than the one passed to a suppler
+ *
+ * @since 3.0
+ */
+ private class ExtensionEnvVarProvider extends EnvironmentVariableManager{
+ private IEnvironmentContextInfo fStartInfo;
+ private Object fStartLevel;
+ private boolean fStartInitialized;
+ private int fStartType;
+ private Object fStartData;
+ private IVariableContextInfo fStartMacroContextInfo;
+ private boolean fStartMacroInfoInitialized;
+
+ public ExtensionEnvVarProvider(Object level){
+ fStartLevel = level;
+ fStartType = getMacroContextTypeFromContext(level);
+ fStartData = level;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable(java.lang.String, java.lang.Object, boolean)
+ */
+ public IEnvironmentVariable getVariable(String variableName,
+ ICConfigurationDescription cfg, boolean resolveMacros) {
+ if((variableName = getValidName(variableName)) == null)
+ return null;
+ return super.getVariable(variableName,cfg,resolveMacros);
+ }
+
+ public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros) {
+ return filterVariables(super.getVariables(cfg,resolveMacros));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getContextInfo(java.lang.Object)
+ */
+ public IEnvironmentContextInfo getContextInfo(Object level){
+ IEnvironmentContextInfo startInfo = getStartInfo();
+ if(level == fStartLevel)
+ return startInfo;
+
+ IEnvironmentContextInfo info = super.getContextInfo(level);
+ if(info == null)
+ return null;
+
+ if(checkParentContextRelation(startInfo,info))
+ return info;
+ return null;
+ }
+
+ protected IEnvironmentContextInfo getStartInfo(){
+ if(fStartInfo == null && !fStartInitialized){
+ IEnvironmentContextInfo info = super.getContextInfo(fStartLevel);
+ if(info != null){
+ ICoreEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
+ suppliers = filterValidSuppliers(suppliers);
+ if(suppliers != null)
+ fStartInfo = new DefaultEnvironmentContextInfo(fStartLevel,suppliers);
+ else
+ fStartInfo = info.getNext();
+ fStartInitialized = true;
+ }
+ fStartInitialized = true;
+ }
+ return fStartInfo;
+ }
+
+ public IVariableSubstitutor getVariableSubstitutor(IVariableContextInfo info, String inexistentMacroValue, String listDelimiter){
+ return super.getVariableSubstitutor(getSubstitutorMacroContextInfo(info),inexistentMacroValue,listDelimiter);
+ }
+
+ protected IVariableContextInfo getSubstitutorMacroContextInfo(IVariableContextInfo info){
+ IVariableContextInfo startInfo = getStartMacroContextInfo();
+ if(info == null)
+ return null;
+
+ if(info instanceof ICoreVariableContextInfo){
+ ICoreVariableContextInfo coreInfo = (ICoreVariableContextInfo)info;
+ if(coreInfo.getContextType() == fStartType &&
+ coreInfo.getContextData() == fStartData)
+ return startInfo;
+ }
+
+ if(SupplierBasedCdtVariableManager.checkParentContextRelation(startInfo,info))
+ return info;
+ return null;
+ }
+
+ protected IVariableContextInfo getStartMacroContextInfo(){
+ if(fStartMacroContextInfo == null && !fStartMacroInfoInitialized){
+ final IVariableContextInfo info = getMacroContextInfoForContext(fStartLevel);
+ if(info != null){
+ fStartMacroContextInfo = new DefaultVariableContextInfo(fStartType,fStartData){
+ protected ICdtVariableSupplier[] getSuppliers(int type, Object data){
+ ICdtVariableSupplier suppliers[] = info.getSuppliers();
+ return filterValidMacroSuppliers(suppliers);
+ }
+
+ public IVariableContextInfo getNext() {
+ return info.getNext();
+ }
+ };
+ fStartInitialized = true;
+ }
+ fStartInitialized = true;
+ }
+ return fStartMacroContextInfo;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
+ */
+ public IEnvironmentVariable getVariable(String name, Object context) {
+ if(context == null)
+ return null;
+ if((name = getValidName(name)) == null)
+ return null;
+
+ if(context instanceof ICConfigurationDescription){
+ ICConfigurationDescription cfg = (ICConfigurationDescription)context;
+ IEnvironmentContributor supplier = cfg.getBuildSetting().getBuildEnvironmentContributor();
+ if(supplier == null)
+ return null;
+ return supplier.getVariable(name, new ExtensionEnvVarProvider(context));
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
+ */
+ public IEnvironmentVariable[] getVariables(Object context) {
+ if(context == null)
+ return null;
+ IEnvironmentVariable variables[] = null;
+ if(context instanceof ICConfigurationDescription){
+ ICConfigurationDescription cfg = (ICConfigurationDescription)context;
+ IEnvironmentContributor supplier = cfg.getBuildSetting().getBuildEnvironmentContributor();
+ if(supplier == null)
+ return null;
+ variables = supplier.getVariables(new ExtensionEnvVarProvider(context));
+ }
+
+ return filterVariables(variables);
+ }
+
+ protected ICoreEnvironmentVariableSupplier[] filterValidSuppliers(ICoreEnvironmentVariableSupplier suppliers[]){
+ if(suppliers == null)
+ return null;
+
+ int i = 0, j = 0;
+ for(i = 0; i < suppliers.length; i++){
+ if(suppliers[i] == this)
+ break;
+ }
+
+
+ if(i >= suppliers.length)
+ return null;
+
+ int startNum = i + 1;
+
+
+ ICoreEnvironmentVariableSupplier validSuppliers[] =
+ new ICoreEnvironmentVariableSupplier[suppliers.length - startNum];
+
+ for(i = startNum, j = 0; i < suppliers.length; i++, j++)
+ validSuppliers[j] = suppliers[i];
+
+ return validSuppliers;
+ }
+
+ protected String getValidName(String name){
+ name = EnvVarOperationProcessor.normalizeName(name);
+ if(name == null)
+ return null;
+ return name;
+ }
+
+ protected IEnvironmentVariable[] filterVariables(IEnvironmentVariable variables[]){
+ return EnvVarOperationProcessor.filterVariables(variables,null);
+ }
+
+ protected ICdtVariableSupplier[] filterValidMacroSuppliers(ICdtVariableSupplier suppliers[]){
+ if(suppliers == null)
+ return null;
+
+ int i = 0, j = 0;
+ for(i = 0; i < suppliers.length; i++){
+ if(suppliers[i] instanceof EnvironmentVariableSupplier)
+ break;
+ }
+
+
+ if(i >= suppliers.length)
+ return suppliers;
+
+ int startNum = i + 1;
+
+ ICdtVariableSupplier validSuppliers[] =
+ new ICdtVariableSupplier[suppliers.length - startNum];
+
+ for(i = startNum, j = 0; i < suppliers.length; i++, j++)
+ validSuppliers[j] = suppliers[i];
+
+ return validSuppliers;
+ }
+
+ public boolean appendEnvironment(Object context) {
+ // TODO
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java
new file mode 100644
index 00000000000..82b3560ec38
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.envvar;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.envvar.IContributedEnvironment;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+
+public class ContributedEnvironment implements IContributedEnvironment{
+ private EnvironmentVariableManager fMngr;
+ public ContributedEnvironment(EnvironmentVariableManager mngr){
+ fMngr = mngr;
+ }
+ private class ContributedEnvContextInfo extends DefaultEnvironmentContextInfo {
+ private IEnvironmentContextInfo fBaseInfo;
+ private ICoreEnvironmentVariableSupplier fSuppliers[];
+
+/* public ContributedEnvContextInfo(Object context,
+ ICoreEnvironmentVariableSupplier[] suppliers) {
+ super(context, suppliers);
+ }
+*/
+ public ContributedEnvContextInfo(IEnvironmentContextInfo info) {
+ super(info.getContext());
+ fBaseInfo = info;
+ }
+
+ public ICoreEnvironmentVariableSupplier[] getSuppliers() {
+ if(fSuppliers == null){
+ ICoreEnvironmentVariableSupplier[] suppliers = fBaseInfo.getSuppliers();
+ int i = 0;
+ for(; i < suppliers.length; i++){
+ if(suppliers[i] == EnvironmentVariableManager.fEclipseSupplier){
+ break;
+ }
+ }
+
+ if(i != suppliers.length){
+ ICoreEnvironmentVariableSupplier tmp[] = new ICoreEnvironmentVariableSupplier[suppliers.length - 1];
+ if(i != 0)
+ System.arraycopy(suppliers, 0, tmp, 0, i);
+ if(i != tmp.length)
+ System.arraycopy(suppliers, i+1, tmp, i, tmp.length - i);
+ suppliers = tmp;
+ }
+
+ fSuppliers = suppliers;
+ }
+ return fSuppliers;
+ }
+
+ public IEnvironmentContextInfo getNext() {
+ IEnvironmentContextInfo baseNext = fBaseInfo.getNext();
+ if(baseNext != null)
+ return new ContributedEnvContextInfo(baseNext);
+ return null;
+ }
+ }
+
+ public IEnvironmentContextInfo getContextInfo(Object context){
+ return new ContributedEnvContextInfo(fMngr.getDefaultContextInfo(context));
+ }
+
+ public IEnvironmentVariable[] getVariables(ICConfigurationDescription des){
+ EnvVarCollector cr = EnvironmentVariableManager.getVariables(getContextInfo(des), true);
+ if(cr != null){
+ EnvVarDescriptor collected[] = cr.toArray(true);
+ List vars = new ArrayList(collected.length);
+ IEnvironmentVariable var;
+ IEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(des);//getContextInfo(des);
+ for(int i = 0; i < collected.length; i++){
+ var = collected[i];
+ var = EnvironmentVariableManager.getVariable(var.getName(), info, true);
+ if(var != null)
+ vars.add(var);
+ }
+ return (EnvVarDescriptor[])vars.toArray(new EnvVarDescriptor[vars.size()]);
+ }
+ return new EnvVarDescriptor[0];
+ }
+
+ public IEnvironmentVariable getVariable(String name, ICConfigurationDescription des){
+ EnvVarDescriptor varDes = EnvironmentVariableManager.getVariable(name, getContextInfo(des), true);
+ if(varDes != null)
+ return EnvironmentVariableManager.getVariable(name, new DefaultEnvironmentContextInfo(des), true);
+ return null;
+ }
+
+ public boolean appendEnvironment(ICConfigurationDescription des){
+ return EnvironmentVariableManager.fUserSupplier.appendContributedEnvironment(des);
+ }
+
+ public void setAppendEnvironment(boolean append, ICConfigurationDescription des){
+ EnvironmentVariableManager.fUserSupplier.setAppendContributedEnvironment(append, des);
+ }
+
+ public IEnvironmentVariable addVariable(String name,
+ String value,
+ int op,
+ String delimiter,
+ ICConfigurationDescription des){
+ return new EnvVarDescriptor(
+ EnvironmentVariableManager.fUserSupplier.createVariable(name, value, op, delimiter, des),
+ null,
+ -1,
+ EnvironmentVariableManager.fUserSupplier);
+ }
+
+ public IEnvironmentVariable removeVariable(String name, ICConfigurationDescription des){
+ return EnvironmentVariableManager.fUserSupplier.deleteVariable(name, des);
+ }
+
+ public void restoreDefaults(ICConfigurationDescription des){
+ EnvironmentVariableManager.fUserSupplier.restoreDefaults(des);
+ }
+
+ public boolean isUserVariable(ICConfigurationDescription des, IEnvironmentVariable var){
+ if(var instanceof EnvVarDescriptor)
+ return ((EnvVarDescriptor)var).getSupplier() == EnvironmentVariableManager.fUserSupplier;
+ return false;
+ }
+
+ public void serialize(ICProjectDescription des){
+ EnvironmentVariableManager.fUserSupplier.storeProjectEnvironment(des, false);
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java
new file mode 100644
index 00000000000..2bf466a6ce4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.envvar;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+/**
+ * The default implementation of the IContextInfo used by the Environment Variable Provider
+ * Used to represent the Configuration, Project, Workspace and Eclipse environment contexts
+ *
+ * @since 3.0
+ */
+public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{
+ private Object fContextObject;
+ private ICoreEnvironmentVariableSupplier fContextSuppliers[];
+
+ /**
+ * This constructor is used to create the default context info given a context object
+ *
+ * @param context
+ */
+ public DefaultEnvironmentContextInfo(Object context){
+ fContextObject = context;
+ }
+
+ protected DefaultEnvironmentContextInfo(Object context, ICoreEnvironmentVariableSupplier suppliers[]){
+ fContextSuppliers = suppliers;
+ fContextObject = context;
+ }
+
+ /*
+ * answers the list of suppliers that should be used for the given context
+ */
+ protected ICoreEnvironmentVariableSupplier[] getSuppliers(Object context){
+ ICoreEnvironmentVariableSupplier suppliers[];
+ if(context instanceof ICConfigurationDescription)
+ suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier,EnvironmentVariableManager.fExternalSupplier};
+ else
+ suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier, EnvironmentVariableManager.fEclipseSupplier};
+ return suppliers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext()
+ */
+ public IEnvironmentContextInfo getNext(){
+ DefaultEnvironmentContextInfo next = null;
+ if(fContextObject == null)
+ next = null;
+ else if(fContextObject instanceof ICConfigurationDescription)
+ next = new DefaultEnvironmentContextInfo(null);
+
+ if(next != null && next.getSuppliers() == null)
+ next = null;
+ return next;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getSuppliers()
+ */
+ public ICoreEnvironmentVariableSupplier[] getSuppliers(){
+ if(fContextSuppliers == null)
+ fContextSuppliers = getSuppliers(fContextObject);
+ return fContextSuppliers;
+ }
+
+ protected void setSuppliers(ICoreEnvironmentVariableSupplier suppliers[]){
+ fContextSuppliers = suppliers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getContext()
+ */
+ public Object getContext(){
+ return fContextObject;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EclipseEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EclipseEnvironmentSupplier.java
index 387ce149f7b..df2a794c582 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EclipseEnvironmentSupplier.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EclipseEnvironmentSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,13 +8,13 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
+package org.eclipse.cdt.internal.core.envvar;
import java.util.Enumeration;
import java.util.Properties;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
+import org.eclipse.cdt.core.envvar.EnvirinmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
/**
@@ -23,17 +23,17 @@ import org.eclipse.cdt.utils.spawner.EnvironmentReader;
*
* @since 3.0
*/
-public class EclipseEnvironmentSupplier implements IEnvironmentVariableSupplier {
+public class EclipseEnvironmentSupplier implements ICoreEnvironmentVariableSupplier {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
*/
- public IBuildEnvironmentVariable getVariable(String name, Object context) {
+ public IEnvironmentVariable getVariable(String name, Object context) {
if(context == null){
String value = EnvironmentReader.getEnvVar(name);
if(value == null)
return null;
- return new BuildEnvVar(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
+ return new EnvirinmentVariable(name,value,IEnvironmentVariable.ENVVAR_REPLACE,null);
}
return null;
}
@@ -41,22 +41,26 @@ public class EclipseEnvironmentSupplier implements IEnvironmentVariableSupplier
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
*/
- public IBuildEnvironmentVariable[] getVariables(Object context) {
+ public IEnvironmentVariable[] getVariables(Object context) {
if(context == null){
Properties values = EnvironmentReader.getEnvVars();
if(values == null)
return null;
- IBuildEnvironmentVariable variables[] = new IBuildEnvironmentVariable[values.size()];
+ IEnvironmentVariable variables[] = new IEnvironmentVariable[values.size()];
Enumeration en = values.propertyNames();
for( int i = 0; i < variables.length ; i++){
String name = (String)en.nextElement();
String value = values.getProperty(name);
- variables[i] = new BuildEnvVar(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
+ variables[i] = new EnvirinmentVariable(name,value,IEnvironmentVariable.ENVVAR_REPLACE,null);
}
return variables;
}
return null;
}
+ public boolean appendEnvironment(Object context) {
+ return true;
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarCollector.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarCollector.java
index 8b458decb6f..c265e3f8877 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarCollector.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,7 +8,7 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
+package org.eclipse.cdt.internal.core.envvar;
import java.util.ArrayList;
import java.util.Collection;
@@ -17,7 +17,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
/**
* This class implements the "merging" functionality of environment variables
@@ -38,16 +39,16 @@ public class EnvVarCollector {
* performing environment variable operations
* @param vars
*/
- public void add(IBuildEnvironmentVariable vars[]){
- add(vars,null,-1);
+ public void add(IEnvironmentVariable vars[]){
+ add(vars,null,-1, null);
}
- public void add(IBuildEnvironmentVariable vars[], IContextInfo info, int num){
+ public void add(IEnvironmentVariable vars[], IEnvironmentContextInfo info, int num, ICoreEnvironmentVariableSupplier supplier){
if(vars == null)
return;
- boolean isCaseInsensitive = !EnvironmentVariableProvider.getDefault().isVariableCaseSensitive();
+ boolean isCaseInsensitive = !EnvironmentVariableManager.getDefault().isVariableCaseSensitive();
for(int i = 0; i < vars.length; i ++) {
- IBuildEnvironmentVariable var = vars[i];
+ IEnvironmentVariable var = vars[i];
String name = var.getName();
if(isCaseInsensitive)
name = name.toUpperCase();
@@ -61,7 +62,7 @@ public class EnvVarCollector {
EnvVarDescriptor des = null;
if(noCheck || (des = (EnvVarDescriptor)fMap.get(name)) == null){
- des = new EnvVarDescriptor(var,info,num);
+ des = new EnvVarDescriptor(var,info,num, supplier);
fMap.put(name,des);
}
else {
@@ -87,7 +88,7 @@ public class EnvVarCollector {
while(iter.hasNext()){
EnvVarDescriptor des = (EnvVarDescriptor)iter.next();
if(des != null &&
- (includeRemoved || des.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE))
+ (includeRemoved || des.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE))
list.add(des);
}
return (EnvVarDescriptor[])list.toArray(new EnvVarDescriptor[list.size()]);
@@ -103,7 +104,7 @@ public class EnvVarCollector {
if(fMap == null)
return null;
- if(!EnvironmentVariableProvider.getDefault().isVariableCaseSensitive())
+ if(!EnvironmentVariableManager.getDefault().isVariableCaseSensitive())
name = name.toUpperCase();
return (EnvVarDescriptor)fMap.get(name);
@@ -118,5 +119,10 @@ public class EnvVarCollector {
public EnvVarDescriptor[] getVariables(){
return toArray(true);
}
+
+ public void clear(){
+ if(fMap != null)
+ fMap.clear();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarDescriptor.java
index f69f57fa20a..ec620f2b3b5 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarDescriptor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,9 +8,10 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
+package org.eclipse.cdt.internal.core.envvar;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
/*
* this class represents the environment variable-relaed information.
@@ -18,18 +19,20 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
* that supplies the variable
*
*/
-public class EnvVarDescriptor implements IBuildEnvironmentVariable{
- private IBuildEnvironmentVariable fVariable;
- private IContextInfo fContextInfo;
+public class EnvVarDescriptor implements IEnvironmentVariable{
+ private IEnvironmentVariable fVariable;
+ private IEnvironmentContextInfo fContextInfo;
private int fSupplierNum;
+ private ICoreEnvironmentVariableSupplier fSupplier;
- public EnvVarDescriptor(IBuildEnvironmentVariable variable, IContextInfo contextInfo, int supplierNum){
+ public EnvVarDescriptor(IEnvironmentVariable variable, IEnvironmentContextInfo contextInfo, int supplierNum, ICoreEnvironmentVariableSupplier supplier){
fVariable = variable;
fContextInfo = contextInfo;
fSupplierNum = supplierNum;
+ fSupplier = supplier;
}
- public IContextInfo getContextInfo() {
+ public IEnvironmentContextInfo getContextInfo() {
return fContextInfo;
}
@@ -37,7 +40,7 @@ public class EnvVarDescriptor implements IBuildEnvironmentVariable{
return fSupplierNum;
}
- public IBuildEnvironmentVariable getOriginalVariable() {
+ public IEnvironmentVariable getOriginalVariable() {
return fVariable;
}
@@ -57,7 +60,7 @@ public class EnvVarDescriptor implements IBuildEnvironmentVariable{
return fVariable.getDelimiter();
}
- public void setContextInfo(IContextInfo contextInfo) {
+ public void setContextInfo(IEnvironmentContextInfo contextInfo) {
fContextInfo = contextInfo;
}
@@ -65,10 +68,14 @@ public class EnvVarDescriptor implements IBuildEnvironmentVariable{
fSupplierNum = supplierNum;
}
- public void setVariable(IBuildEnvironmentVariable variable) {
+ public void setVariable(IEnvironmentVariable variable) {
fVariable = variable;
}
+ public ICoreEnvironmentVariableSupplier getSupplier(){
+ return fSupplier;
+ }
+
/* public String getResolvedValue(int contextType, Object contextData){
String value = null;
if(getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE){
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java
new file mode 100644
index 00000000000..59492261564
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java
@@ -0,0 +1,426 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.envvar;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.envvar.EnvirinmentVariable;
+import org.eclipse.cdt.core.envvar.IContributedEnvironment;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo;
+import org.eclipse.cdt.internal.core.cdtvariables.EnvironmentVariableSupplier;
+import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
+
+
+/**
+ * This class implements the IEnvironmentVariableProvider interface and provides all
+ * build environment funvtionality to the MBS
+ *
+ * @since 3.0
+ *
+ */
+public class EnvironmentVariableManager implements
+ IEnvironmentVariableManager {
+
+ private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
+ private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
+
+ private static EnvironmentVariableManager fInstance = null;
+
+ private EnvVarVariableSubstitutor fVariableSubstitutor;
+
+ public static final UserDefinedEnvironmentSupplier fUserSupplier = new UserDefinedEnvironmentSupplier();
+ public static final BuildSustemEnvironmentSupplier fExternalSupplier = new BuildSustemEnvironmentSupplier();
+ public static final EclipseEnvironmentSupplier fEclipseSupplier = new EclipseEnvironmentSupplier();
+
+ private ContributedEnvironment fContributedEnvironment;
+
+ public class EnvVarVariableSubstitutor extends SupplierBasedCdtVariableSubstitutor {
+ private String fDefaultDelimiter;
+/* public EnvVarMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
+ super(contextType,contextData,inexistentMacroValue,listDelimiter);
+ fDefaultDelimiter = listDelimiter;
+ }
+*/
+ public EnvVarVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
+ super(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
+ fDefaultDelimiter = listDelimiter;
+ }
+
+ public IEnvironmentVariable resolveVariable(EnvVarDescriptor var) throws CdtVariableException {
+ String value;
+ if(var == null || (value = var.getValue()) == null || value.length() == 0 || var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
+ return var;
+
+ String listDelimiter = var.getDelimiter();
+ if(listDelimiter == null)
+ listDelimiter = fDefaultDelimiter;
+ setListDelimiter(listDelimiter);
+ ICdtVariable macro = EnvironmentVariableSupplier.getInstance().createBuildMacro(var);
+ IVariableContextInfo varMacroInfo = getVarMacroContextInfo(var);
+ int varSupplierNum = getVarMacroSupplierNum(var,varMacroInfo);
+ value = resolveToString(new MacroDescriptor(macro,varMacroInfo,varSupplierNum));
+ removeResolvedMacro(var.getName());
+ return new EnvirinmentVariable(var.getName(),value,var.getOperation(),var.getDelimiter());
+ }
+
+ protected IVariableContextInfo getVarMacroContextInfo(EnvVarDescriptor var){
+ IEnvironmentContextInfo info = var.getContextInfo();
+ if(info != null)
+ return getMacroContextInfoForContext(info.getContext());
+ return null;
+ }
+
+ protected int getVarMacroSupplierNum(EnvVarDescriptor var, IVariableContextInfo varMacroInfo){
+ int varSupplierNum = -1;
+ ICdtVariableSupplier macroSuppliers[] = varMacroInfo.getSuppliers();
+ for(int i = 0; i < macroSuppliers.length; i++){
+ if(macroSuppliers[i] instanceof EnvironmentVariableSupplier){
+ varSupplierNum = i;
+ break;
+ }
+ }
+ return varSupplierNum;
+ }
+ }
+
+ protected EnvironmentVariableManager(){
+ fContributedEnvironment = new ContributedEnvironment(this);
+ }
+
+ public static EnvironmentVariableManager getDefault(){
+ if(fInstance == null)
+ fInstance = new EnvironmentVariableManager();
+ return fInstance;
+ }
+
+ /*
+ * returns a variable of a given name or null
+ * the context information is taken from the contextInfo passed
+ * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
+ */
+ public static EnvVarDescriptor getVariable(String variableName,
+ IEnvironmentContextInfo contextInfo, boolean includeParentLevels){
+
+ if(contextInfo == null)
+ return null;
+ if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null) //$NON-NLS-1$
+ return null;
+
+
+ IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo);
+
+ if(!includeParentLevels){
+ ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
+ boolean bVarFound = false;
+ for(int i = 0; i < suppliers.length; i++){
+ if(suppliers[i].getVariable(variableName,infos[0].getContext()) != null){
+ bVarFound = true;
+ break;
+ }
+ }
+ if(!bVarFound)
+ return null;
+ }
+
+ IEnvironmentVariable variable = null;
+ IEnvironmentContextInfo varContextInfo = null;
+ int varSupplierNum = -1;
+ ICoreEnvironmentVariableSupplier varSupplier = null;
+
+ for(int i = infos.length-1 ; i >=0 ; i-- ) {
+ IEnvironmentContextInfo info = infos[i];
+ ICoreEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
+
+ for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
+ ICoreEnvironmentVariableSupplier supplier = suppliers[j];
+ IEnvironmentVariable var = supplier.getVariable(variableName,info.getContext());
+
+ if(var == null)
+ continue;
+
+ varContextInfo = info;
+ varSupplierNum = j;
+ varSupplier = supplier;
+
+ if(variable == null)
+ variable = var;
+ else
+ variable = EnvVarOperationProcessor.performOperation(variable,var);
+ }
+ }
+
+ if(variable != null){
+// if(variable.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
+// return null;
+ return new EnvVarDescriptor(variable,varContextInfo,varSupplierNum,varSupplier);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
+ */
+ public IEnvironmentVariable getVariable(String variableName,
+ ICConfigurationDescription cfg, boolean resolveMacros) {
+ if(variableName == null || "".equals(variableName)) //$NON-NLS-1$
+ return null;
+
+ IEnvironmentContextInfo info = getContextInfo(cfg);
+ EnvVarDescriptor var = getVariable(variableName,info,true);
+
+ if(var != null && var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE){
+ return resolveMacros ? calculateResolvedVariable(var,info) : var;
+ }
+ return null;
+ }
+
+ IEnvironmentContextInfo getDefaultContextInfo(Object level){
+ DefaultEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(level);
+ if(info.getSuppliers() == null)
+ return null;
+ return info;
+ }
+
+ /*
+ * returns the context info that should be used for the given level
+ * or null if the the given level is not supported
+ */
+ public IEnvironmentContextInfo getContextInfo(Object level){
+ if(level instanceof ICConfigurationDescription)
+ return fContributedEnvironment.appendEnvironment((ICConfigurationDescription)level) ?
+ getDefaultContextInfo(level) : fContributedEnvironment.getContextInfo(level);
+ return getDefaultContextInfo(level);
+ }
+
+ /*
+ * returns a list of defined variables.
+ * the context information is taken from the contextInfo passed
+ * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
+ */
+ public static EnvVarCollector getVariables(IEnvironmentContextInfo contextInfo,
+ boolean includeParentLevels) {
+ if(contextInfo == null)
+ return null;
+
+ IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo);
+ HashSet set = null;
+
+ if(!includeParentLevels){
+ ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
+ set = new HashSet();
+ for(int i = 0; i < suppliers.length; i++){
+ IEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
+ if(vars != null){
+ for(int j = 0; j < vars.length; j++){
+ String name = EnvVarOperationProcessor.normalizeName(vars[j].
+ getName());
+ if(name != null)
+ set.add(name);
+ }
+ }
+ if(!suppliers[i].appendEnvironment(infos[0].getContext()))
+ break;
+ }
+ if(set.size() == 0)
+ return new EnvVarCollector();
+ }
+
+ EnvVarCollector envVarSet = new EnvVarCollector();
+
+ for(int i = infos.length-1 ; i >=0 ; i-- ) {
+ IEnvironmentContextInfo info = infos[i];
+ ICoreEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
+
+ for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
+ ICoreEnvironmentVariableSupplier supplier = suppliers[j];
+ if(!supplier.appendEnvironment(info.getContext())){
+ envVarSet.clear();
+ }
+
+ IEnvironmentVariable vars[] = null;
+ if(set != null){
+ List varList = new ArrayList();
+ Iterator iter = set.iterator();
+
+ while(iter.hasNext()){
+ IEnvironmentVariable var = supplier.getVariable((String)iter.next(),info.getContext());
+ if(var != null)
+ varList.add(var);
+ }
+ vars = (IEnvironmentVariable[])varList.toArray(new IEnvironmentVariable[varList.size()]);
+ }
+ else{
+ vars = supplier.getVariables(info.getContext());
+ }
+ envVarSet.add(vars,info,j, supplier);
+ }
+ }
+
+ return envVarSet;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables()
+ */
+ public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros) {
+
+
+ IEnvironmentContextInfo info = getContextInfo(cfg);
+ EnvVarCollector varSet = getVariables(info,true);
+
+ EnvVarDescriptor vars[] = varSet != null ? varSet.toArray(false) : null;
+
+ if(vars != null){
+ if(!resolveMacros)
+ return vars;
+
+ IEnvironmentVariable resolved[] = new IEnvironmentVariable[vars.length];
+ for(int i = 0; i < vars.length; i++)
+ resolved[i] = calculateResolvedVariable(vars[i], info);
+ return resolved;
+ }
+ return new EnvVarDescriptor[0];
+ }
+
+ /*
+ * returns an array of the IContextInfo that holds the context informations
+ * starting from the one passed to this method and including all subsequent parents
+ */
+ public static IEnvironmentContextInfo[] getAllContextInfos(IEnvironmentContextInfo contextInfo){
+ if(contextInfo == null)
+ return null;
+
+ List list = new ArrayList();
+
+ list.add(contextInfo);
+
+ while((contextInfo = contextInfo.getNext()) != null)
+ list.add(contextInfo);
+
+ return (IEnvironmentContextInfo[])list.toArray(new IEnvironmentContextInfo[list.size()]);
+ }
+
+ private boolean isWin32(){
+ String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
+ if (os.startsWith("windows ")) //$NON-NLS-1$
+ return true;
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getDefaultDelimiter()
+ */
+ public String getDefaultDelimiter() {
+ return isWin32() ? DELIMITER_WIN32 : DELIMITER_UNIX;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#isVariableCaseSensitive()
+ */
+ public boolean isVariableCaseSensitive() {
+ return !isWin32();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getSuppliers()
+ */
+ public ICoreEnvironmentVariableSupplier[] getSuppliers(Object level) {
+ IEnvironmentContextInfo info = getContextInfo(level);
+ if(info != null)
+ return info.getSuppliers();
+ return null;
+ }
+
+ /*
+ * returns true if the first passed contextInfo is the child of the second one
+ */
+ public boolean checkParentContextRelation(IEnvironmentContextInfo child, IEnvironmentContextInfo parent){
+ if(child == null || parent == null)
+ return false;
+
+ IEnvironmentContextInfo enumInfo = child;
+ do{
+ if(parent.getContext() == enumInfo.getContext())
+ return true;
+ }while((enumInfo = enumInfo.getNext()) != null);
+ return false;
+ }
+
+ public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IEnvironmentContextInfo info){
+ if(des == null || info == null)
+ return null;
+
+ return calculateResolvedVariable(des,getVariableSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IVariableSubstitutor sub){
+ if(des == null)
+ return null;
+ IEnvironmentVariable var = des;
+
+ try{
+ if(sub instanceof EnvVarVariableSubstitutor)
+ var = ((EnvVarVariableSubstitutor)sub).resolveVariable(des);
+ else if(des.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE){
+ String name = des.getName();
+ var = new EnvirinmentVariable(name,sub.resolveToString(name),des.getOperation(),des.getDelimiter());
+ }
+ } catch (CdtVariableException e){
+ }
+ return var;
+
+ }
+
+ protected int getMacroContextTypeFromContext(Object context){
+ if(context instanceof ICConfigurationDescription)
+ return ICoreVariableContextInfo.CONTEXT_CONFIGURATION;
+ else
+ return ICoreVariableContextInfo.CONTEXT_WORKSPACE;
+ }
+
+ public ICoreVariableContextInfo getMacroContextInfoForContext(Object context){
+ return new DefaultVariableContextInfo(getMacroContextTypeFromContext(context),context);
+ }
+
+ public IVariableSubstitutor getVariableSubstitutor(IVariableContextInfo info, String inexistentMacroValue, String listDelimiter){
+ if(fVariableSubstitutor == null)
+ fVariableSubstitutor = new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
+ else {
+ try {
+ fVariableSubstitutor.setMacroContextInfo(info);
+ fVariableSubstitutor.setInexistentMacroValue(inexistentMacroValue);
+ fVariableSubstitutor.setListDelimiter(listDelimiter);
+ } catch (CdtVariableException e){
+ fVariableSubstitutor = new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter);
+ }
+ }
+ return fVariableSubstitutor;
+ }
+
+ public IContributedEnvironment getContributedEnvironment() {
+ return fContributedEnvironment;
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ICoreEnvironmentVariableSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ICoreEnvironmentVariableSupplier.java
new file mode 100644
index 00000000000..f6a642236d8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ICoreEnvironmentVariableSupplier.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.envvar;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+
+
+/**
+ *
+ * @since 3.0
+ */
+public interface ICoreEnvironmentVariableSupplier {
+
+ /**
+ *
+ * @param name the variable name
+ * @param context the context
+ * @return the reference to the IBuildEnvironmentVariable interface representing
+ * the variable of a given name
+ */
+ IEnvironmentVariable getVariable(String name, Object context);
+
+ /**
+ *
+ * @param context the context
+ * @return the array of IBuildEnvironmentVariable that represents the environment variables
+ */
+ IEnvironmentVariable[] getVariables(Object context);
+
+ boolean appendEnvironment(Object context);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/IContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/IEnvironmentContextInfo.java
index 26e0a6001fc..9a4ee57f6da 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/IContextInfo.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/IEnvironmentContextInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,9 +8,10 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
+package org.eclipse.cdt.internal.core.envvar;
+
+
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
/**
* This interface is used by the Environment Variable Provider to
@@ -18,20 +19,20 @@ import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
*
* @since 3.0
*/
-public interface IContextInfo {
+public interface IEnvironmentContextInfo {
/**
* Returns the next lower-precedence context
*
* @return IContextInfo
*/
- public IContextInfo getNext();
+ public IEnvironmentContextInfo getNext();
/**
* Returns the array of suppliers to be used for this context
*
* @return IEnvironmentVariableSupplier[]
*/
- public IEnvironmentVariableSupplier[] getSuppliers();
+ public ICoreEnvironmentVariableSupplier[] getSuppliers();
/**
* Returns the current context
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java
new file mode 100644
index 00000000000..493500a3d84
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.envvar;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
+import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
+import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor;
+import org.eclipse.cdt.utils.envvar.StorableEnvironment;
+import org.eclipse.cdt.utils.envvar.StorableEnvironmentLoader;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * This is the Environment Variable Supplier used to supply variables
+ * defined by a user
+ *
+ * @since 3.0
+ */
+public class UserDefinedEnvironmentSupplier extends
+ StorableEnvironmentLoader
+ implements ICoreEnvironmentVariableSupplier{
+
+ public static final String NODENAME = "environment"; //$NON-NLS-1$
+ public static final String PREFNAME_WORKSPACE = "workspace"; //$NON-NLS-1$
+ public static final String PREFNAME_PROJECT = "project"; //$NON-NLS-1$
+ public static final String NODENAME_CFG = "project"; //$NON-NLS-1$
+
+/* private static final String fNonOverloadableVariables[] = new String[]{
+ //users not allowed currently to override the "CWD" and "PWD" variables
+ EnvVarOperationProcessor.normalizeName("CWD"), //$NON-NLS-1$
+ EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$
+ };
+*/
+ private StorableEnvironment fWorkspaceVariables;
+
+ protected StorableEnvironment getEnvironment(Object context){
+ return getEnvironment(context,true);
+ }
+
+ protected StorableEnvironment getEnvironment(Object context, boolean forceLoad){
+// if(context == null)
+// return null;
+
+ StorableEnvironment env = null;
+ if(context instanceof IInternalCCfgInfo){
+ try {
+ CConfigurationSpecSettings settings = ((IInternalCCfgInfo)context).getSpecSettings();
+ env = settings.getEnvironment();
+ if(env == null && forceLoad){
+ env = loadEnvironment(context, settings.isReadOnly());
+ settings.setEnvironment(env);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ else if(context instanceof IWorkspace || context == null){
+ if(fWorkspaceVariables == null && forceLoad)
+ fWorkspaceVariables = loadEnvironment(context, false);
+ env = fWorkspaceVariables;
+ }
+
+ return env;
+ }
+
+ protected ISerializeInfo getSerializeInfo(Object context){
+ ISerializeInfo serializeInfo = null;
+
+ if(context instanceof ICConfigurationDescription){
+ ICConfigurationDescription cfg = (ICConfigurationDescription)context;
+
+ final Preferences prefs = getConfigurationNode(cfg.getProjectDescription());
+ final String name = cfg.getId();
+ if(prefs != null && name != null)
+ serializeInfo = new ISerializeInfo(){
+ public Preferences getNode(){
+ return prefs;
+ }
+
+ public String getPrefName(){
+ return name;
+ }
+ };
+ }
+ else if(context == null || context instanceof IWorkspace){
+ final Preferences prefs = getWorkspaceNode();
+ final String name = PREFNAME_WORKSPACE;
+ if(prefs != null && name != null)
+ serializeInfo = new ISerializeInfo(){
+ public Preferences getNode(){
+ return prefs;
+ }
+
+ public String getPrefName(){
+ return name;
+ }
+ };
+ }
+ return serializeInfo;
+ }
+
+ private Preferences getConfigurationNode(ICProjectDescription projDes){
+ Preferences prefNode = getProjectNode(projDes);
+ if(prefNode == null)
+ return null;
+
+ return prefNode.node(NODENAME_CFG);
+ }
+
+ private Preferences getProjectNode(ICProjectDescription projDes){
+ if(projDes == null)
+ return null;
+ IProject project = projDes.getProject();
+ if(!project.exists())
+ return null;
+
+ Preferences prefNode = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID);
+ if(prefNode == null)
+ return null;
+
+ return prefNode.node(NODENAME);
+ }
+
+ private Preferences getWorkspaceNode(){
+ Preferences prefNode = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID);
+ if(prefNode == null)
+ return null;
+
+ return prefNode.node(NODENAME);
+ }
+
+ public void checkInexistentConfigurations(ICProjectDescription projDes){
+ Preferences prefNode = getConfigurationNode(projDes);
+ if(prefNode == null)
+ return;
+
+ try{
+ String ids[] = prefNode.keys();
+ boolean found = false;
+ for( int i = 0; i < ids.length; i++){
+ if(projDes.getConfigurationById(ids[i]) == null){
+ prefNode.remove(ids[i]);
+ found = true;
+ }
+ }
+
+ if(found)
+ prefNode.flush();
+ }
+ catch(BackingStoreException e){
+ }
+ }
+
+ public void storeWorkspaceEnvironment(boolean force){
+ if(fWorkspaceVariables != null){
+ try{
+ storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force, true);
+ } catch(CoreException e){
+
+ }
+ }
+ }
+
+ public StorableEnvironment getWorkspaceEnvironmentCopy(){
+ StorableEnvironment envVar = getEnvironment(null);
+ return new StorableEnvironment(envVar, false);
+ }
+
+ public void setWorkspaceEnvironment(StorableEnvironment env){
+ fWorkspaceVariables = new StorableEnvironment(env, false);
+
+ storeWorkspaceEnvironment(true);
+ }
+
+ public void storeProjectEnvironment(ICProjectDescription des, boolean force){
+ ICConfigurationDescription cfgs[] = des.getConfigurations();
+ for(int i = 0; i < cfgs.length; i++){
+ storeEnvironment(cfgs[i], force, false);
+ }
+
+ Preferences node = getProjectNode(des);
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ }
+ }
+
+ private void storeEnvironment(Object context, boolean force, boolean flush){
+ StorableEnvironment env = getEnvironment(context, false);
+ if(env != null){
+ try {
+ storeEnvironment(env, context, force, flush);
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
+ */
+ public IEnvironmentVariable getVariable(String name, Object context) {
+ if(getValidName(name) == null)
+ return null;
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return null;
+ return env.getVariable(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
+ */
+ public IEnvironmentVariable[] getVariables(Object context) {
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return null;
+ return filterVariables(env.getVariables());
+ }
+
+ public IEnvironmentVariable createVariable(String name, String value, int op, String delimiter, Object context){
+ if(getValidName(name) == null)
+ return null;
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return null;
+ IEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
+ if(env.isChanged()){
+ setRebuildStateForContext(context);
+ env.setChanged(false);
+ }
+ return var;
+ }
+
+ public IEnvironmentVariable deleteVariable(String name, Object context){
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return null;
+ IEnvironmentVariable var = env.deleteVariable(name);
+ if(var != null)
+ setRebuildStateForContext(context);
+ return var;
+ }
+
+ public void deleteAll(Object context){
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return;
+
+ if(env.deleteAll())
+ setRebuildStateForContext(context);
+ }
+
+ public void setVariables(IEnvironmentVariable vars[], Object context){
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return;
+
+ env.setVariales(vars);
+ if(env.isChanged()){
+ setRebuildStateForContext(context);
+ env.setChanged(false);
+ }
+ }
+
+ protected void setRebuildStateForContext(Object context){
+/* if(context == null)
+ return;
+ if(context instanceof ICConfigurationDescription){
+ cfgVarsModified((ICConfigurationDescription)context);
+ } else if(context == null || context instanceof IWorkspace){
+ CoreModel model = CoreModel.getDefault();
+ IProject projects[] = ((IWorkspace)context).getRoot().getProjects();
+ for(int i = 0; i < projects.length; i++){
+ ICProjectDescription des = model.getProjectDescription(projects[i]);
+
+// if(ManagedBuildManager.manages(projects[i])){
+// IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i]);
+ if(des != null){
+ ICConfigurationDescription cfgs[] = des.getConfigurations();
+ for(int j = 0; j < cfgs.length; j++){
+ cfgVarsModified(cfgs[j]);
+ }
+ }
+// }
+ }
+ }
+*/
+ }
+
+// protected void cfgVarsModified(ICConfigurationDescription cfg){
+// cfg.setRebuildState(true);
+// EnvironmentVariableProvider.getDefault().checkBuildPathVariables(cfg);
+// }
+
+ protected String getValidName(String name){
+ if(name == null || (name = name.trim()).length() == 0)
+ return null;
+// if(fNonOverloadableVariables != null){
+// for(int i = 0; i < fNonOverloadableVariables.length; i++){
+// if(fNonOverloadableVariables[i].equals(EnvVarOperationProcessor.normalizeName(name)))
+// return null;
+// }
+// }
+ return name;
+ }
+
+ protected IEnvironmentVariable[] filterVariables(IEnvironmentVariable variables[]){
+ return EnvVarOperationProcessor.filterVariables(variables,null);
+ }
+
+ public boolean appendEnvironment(Object context) {
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return true;
+ return env.appendEnvironment();
+ }
+
+ public boolean appendContributedEnvironment(Object context){
+ StorableEnvironment env = getEnvironment(context);
+ if(env == null)
+ return true;
+ return env.appendContributedEnvironment();
+ }
+
+
+ public void setAppendEnvironment(boolean append, Object context) {
+ StorableEnvironment env = getEnvironment(context);
+ if(env != null){
+ env.setAppendEnvironment(append);
+ }
+ }
+
+ public void setAppendContributedEnvironment(boolean append, Object context){
+ StorableEnvironment env = getEnvironment(context);
+ if(env != null){
+ env.setAppendContributedEnvironment(append);
+ }
+ }
+
+ public void restoreDefaults(Object context){
+ StorableEnvironment env = getEnvironment(context);
+ if(env != null){
+ env.restoreDefaults();
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MacroResolver.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java
index 41cb1b37f4a..2561f6643ed 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MacroResolver.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,22 +8,15 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
+package org.eclipse.cdt.utils.cdtvariables;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.internal.core.Tool;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus;
/**
* This is the utility class used to resolve macro references and that provides
@@ -31,14 +24,13 @@ import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
*
* @since 3.0
*/
-public class MacroResolver {
+public class CdtVariableResolver {
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- public static final String MACRO_PREFIX = "${"; //$NON-NLS-1$
- public static final char MACRO_SUFFIX = '}'; //$NON-NLS-1$
- public static final char MACRO_ESCAPE_CHAR = '\\'; //$NON-NLS-1$
- private static final int MACRO_PREFIX_LENGTH = MACRO_PREFIX.length();
- private static final String PATTERN_MACRO_NAME = "="; //$NON-NLS-1$
+ public static final String VARIABLE_PREFIX = "${"; //$NON-NLS-1$
+ public static final char VARIABLE_SUFFIX = '}'; //$NON-NLS-1$
+ public static final char VARIABLE_ESCAPE_CHAR = '\\'; //$NON-NLS-1$
+ private static final int VARIABLE_PREFIX_LENGTH = VARIABLE_PREFIX.length();
static public String convertStringListToString(String value[], String listDelimiter) {
@@ -61,10 +53,10 @@ public class MacroResolver {
* @param substitutor
* @return resolved string
*
- * @throws BuildMacroException
+ * @throws CdtVariableException
*/
- static public String resolveToString(String string, IMacroSubstitutor substitutor)
- throws BuildMacroException{
+ static public String resolveToString(String string, IVariableSubstitutor substitutor)
+ throws CdtVariableException{
return (String)resolve(string,substitutor,false,false);
}
@@ -74,15 +66,15 @@ public class MacroResolver {
*
* @param string
* @param substitutor
- * @throws BuildMacroException
+ * @throws CdtVariableException
*/
- static public void checkMacros(String string, IMacroSubstitutor substitutor)
- throws BuildMacroException{
+ static public void checkVariables(String string, IVariableSubstitutor substitutor)
+ throws CdtVariableException{
resolve(string, substitutor, false, true);
}
- static private Object resolve(String string, IMacroSubstitutor substitutor, boolean asList, boolean checkOnly)
- throws BuildMacroException{
+ static private Object resolve(String string, IVariableSubstitutor substitutor, boolean asList, boolean checkOnly)
+ throws CdtVariableException{
if(string == null)
return EMPTY_STRING;
@@ -96,7 +88,7 @@ public class MacroResolver {
do{
//find macro prefix
- macroStart = string.indexOf(MACRO_PREFIX, macroEnd+1);
+ macroStart = string.indexOf(VARIABLE_PREFIX, macroEnd+1);
if(macroStart == -1){
if(buffer != null)
buffer.append(string.substring(processed,length));
@@ -104,7 +96,7 @@ public class MacroResolver {
}
//macro prefix found, find macro suffix
- macroEnd = string.indexOf(MACRO_SUFFIX, macroStart);
+ macroEnd = string.indexOf(VARIABLE_SUFFIX, macroStart);
if(macroEnd == -1){
if(buffer != null)
buffer.append(string.substring(processed,length));
@@ -115,9 +107,9 @@ public class MacroResolver {
listMode = true;
//check whether macro is prepended with the back-clash
- if(macroStart > 0 && MACRO_ESCAPE_CHAR == string.charAt(macroStart - 1)){
+ if(macroStart > 0 && VARIABLE_ESCAPE_CHAR == string.charAt(macroStart - 1)){
int num;
- for(num = macroStart-2; num >= 0 && MACRO_ESCAPE_CHAR == string.charAt(num); num--){}
+ for(num = macroStart-2; num >= 0 && VARIABLE_ESCAPE_CHAR == string.charAt(num); num--){}
//number of back-slashes
num = macroStart - num - 1;
@@ -137,18 +129,18 @@ public class MacroResolver {
if(macroStart > processed && buffer != null)
buffer.append(string.substring(processed,macroStart));
- String name = string.substring(macroStart + MACRO_PREFIX_LENGTH, macroEnd);
+ String name = string.substring(macroStart + VARIABLE_PREFIX_LENGTH, macroEnd);
if(!EMPTY_STRING.equals(name)){
if(listMode){
listValue = substitutor.resolveToStringList(name);
if(listValue == null)
- throw new BuildMacroException(IBuildMacroStatus.TYPE_MACRO_UNDEFINED,(String)null,string,name,0,null);
+ throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED,(String)null,string,name);
}
else{
String resolved = substitutor.resolveToString(name);
if(resolved == null)
- throw new BuildMacroException(IBuildMacroStatus.TYPE_MACRO_UNDEFINED,(String)null,string,name,0,null);
+ throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED,(String)null,string,name);
if(buffer != null)
buffer.append(resolved);
}
@@ -180,17 +172,17 @@ public class MacroResolver {
* @param substitutor
* @param ignoreErrors
* @return
- * @throws BuildMacroException
+ * @throws CdtVariableException
*/
- static public String[] resolveStringListValues(String values[], IMacroSubstitutor substitutor, boolean ignoreErrors)
- throws BuildMacroException {
+ static public String[] resolveStringListValues(String values[], IVariableSubstitutor substitutor, boolean ignoreErrors)
+ throws CdtVariableException {
String result[] = null;
if(values == null || values.length == 0)
result = values;
else if(values.length == 1)
try {
- result = MacroResolver.resolveToStringList(values[0], substitutor);
- } catch (BuildMacroException e) {
+ result = CdtVariableResolver.resolveToStringList(values[0], substitutor);
+ } catch (CdtVariableException e) {
if(!ignoreErrors)
throw e;
}
@@ -199,10 +191,10 @@ public class MacroResolver {
for(int i = 0; i < values.length; i++){
String resolved[];
try {
- resolved = MacroResolver.resolveToStringList(values[i], substitutor);
+ resolved = CdtVariableResolver.resolveToStringList(values[i], substitutor);
if(resolved != null && resolved.length > 0)
list.addAll(Arrays.asList(resolved));
- } catch (BuildMacroException e) {
+ } catch (CdtVariableException e) {
if(!ignoreErrors)
throw e;
}
@@ -219,10 +211,10 @@ public class MacroResolver {
* @param string
* @param substitutor
* @return
- * @throws BuildMacroException
+ * @throws CdtVariableException
*/
- static public String[] resolveToStringList(String string, IMacroSubstitutor substitutor)
- throws BuildMacroException{
+ static public String[] resolveToStringList(String string, IVariableSubstitutor substitutor)
+ throws CdtVariableException{
return (String[])resolve(string,substitutor,true,false);
}
@@ -232,12 +224,12 @@ public class MacroResolver {
* @param macroType
* @return
*/
- public static boolean isStringListMacro(int macroType){
+ public static boolean isStringListVariable(int macroType){
switch(macroType){
- case IBuildMacro.VALUE_TEXT_LIST:
- case IBuildMacro.VALUE_PATH_FILE_LIST:
- case IBuildMacro.VALUE_PATH_DIR_LIST:
- case IBuildMacro.VALUE_PATH_ANY_LIST:
+ case ICdtVariable.VALUE_TEXT_LIST:
+ case ICdtVariable.VALUE_PATH_FILE_LIST:
+ case ICdtVariable.VALUE_PATH_DIR_LIST:
+ case ICdtVariable.VALUE_PATH_ANY_LIST:
return true;
default:
return false;
@@ -250,18 +242,18 @@ public class MacroResolver {
* @param provider
* @param contextType
* @param contextData
- * @throws BuildMacroException
+ * @throws CdtVariableException
*/
public static void checkIntegrity(
- IMacroContextInfo info,
- IMacroSubstitutor substitutor) throws BuildMacroException{
+ IVariableContextInfo info,
+ IVariableSubstitutor substitutor) throws CdtVariableException{
if(info != null){
- IBuildMacro macros[] = BuildMacroProvider.getMacros(info,true);
+ ICdtVariable macros[] = SupplierBasedCdtVariableManager.getVariables(info,true);
if(macros != null){
for(int i = 0; i < macros.length; i++){
- IBuildMacro macro = macros[i];
- if(isStringListMacro(macro.getMacroValueType()))
+ ICdtVariable macro = macros[i];
+ if(isStringListVariable(macro.getValueType()))
substitutor.resolveToStringList(macro.getName());
else
substitutor.resolveToString(macro.getName());
@@ -277,97 +269,8 @@ public class MacroResolver {
* @param name
* @return String
*/
- public static String createMacroReference(String name){
- return MACRO_PREFIX + name + MACRO_SUFFIX;
- }
-
- /**
- * answers whether the builder used for the given configuration is capable
- * of handling macros in the buildfile
- *
- * @param cfg
- * @return
- */
- public static boolean canKeepMacrosInBuildfile(IConfiguration cfg){
- if(cfg != null){
- IToolChain toolChain = cfg.getToolChain();
- if(toolChain != null)
- return canKeepMacrosInBuildfile(toolChain.getBuilder());
- }
- return false;
- }
-
- /**
- * answers whether the given builder is capable
- * of handling macros in the buildfile
- *
- * @param builder
- * @return
- */
- public static boolean canKeepMacrosInBuildfile(IBuilder builder){
- if(builder != null){
- String pattern = builder.getBuilderVariablePattern();
- if(pattern != null && pattern.indexOf(PATTERN_MACRO_NAME) != -1)
- return true;
- }
- return false;
- }
-
- /**
- * creates a macro reference in the buildfile format for the given builder.
- * If the builder can not treat macros, returns null
- * @param name
- * @param builder
- * @return String
- */
- public static String createBuildfileMacroReference(String name, IBuilder builder){
- String ref = null;
- if(builder != null){
- String pattern = builder.getBuilderVariablePattern();
- if(pattern != null && pattern.indexOf(PATTERN_MACRO_NAME) != -1)
- ref = pattern.replaceAll(PATTERN_MACRO_NAME,name);
- }
- return ref;
- }
-
- /**
- * creates a macro reference in the buildfile format for the builder used for
- * the given configuration.
- * If the builder can not treat macros, returns null
- * @param name
- * @param cfg
- * @return String
- */
- public static String createBuildfileMacroReference(String name, IConfiguration cfg){
- String ref = null;
- if(cfg != null){
- IToolChain toolChain = cfg.getToolChain();
- if(toolChain != null)
- ref = createBuildfileMacroReference(name,toolChain.getBuilder());
- }
- return ref;
- }
-
- /**
- * Returns the array of the explicit file macros, referenced in the tool's options
- * (Explicit file macros are the file-specific macros, whose values are not provided
- * by the tool-integrator. As a result these macros contain explicit values, but not the values
- * specified in the format of the builder automatic variables and text functions)
- *
- * @param tool
- * @return
- */
- public static IBuildMacro[] getReferencedExplitFileMacros(ITool tool){
- if(tool instanceof Tool){
- Tool t = (Tool)tool;
- ExplicitFileMacroCollector collector = new ExplicitFileMacroCollector(tool);
- try {
- t.getToolCommandFlags(null,null,collector);
- } catch (BuildException e){
- }
- return collector.getExplicisFileMacros();
- }
- return new IBuildMacro[0];
+ public static String createVariableReference(String name){
+ return VARIABLE_PREFIX + name + VARIABLE_SUFFIX;
}
/**
@@ -381,7 +284,7 @@ public class MacroResolver {
* @param contextData
* @return
*/
- public static IBuildMacro[] getReferencedExplitFileMacros(String expression, int contextType, Object contextData){
+/* public static IBuildMacro[] getReferencedExplitFileMacros(String expression, int contextType, Object contextData){
ExplicitFileMacroCollector collector = new ExplicitFileMacroCollector(contextType,contextData);
try {
resolveToString(expression,collector);
@@ -389,16 +292,16 @@ public class MacroResolver {
}
return collector.getExplicisFileMacros();
}
-
- static public IBuildMacro[] filterMacros(IBuildMacro macros[], String remove[]){
+*/
+/* static public ICdtVariable[] filterMacros(ICdtVariable macros[], String remove[]){
if(macros == null || macros.length == 0)
return macros;
- IBuildMacro filtered[] = new IBuildMacro[macros.length];
+ ICdtVariable filtered[] = new ICdtVariable[macros.length];
int filteredNum = 0;
for(int i = 0; i < macros.length; i++){
- IBuildMacro var = macros[i];
+ ICdtVariable var = macros[i];
String name = null;
if(var != null && (name = EnvVarOperationProcessor.normalizeName(var.getName())) != null){
boolean skip = false;
@@ -423,5 +326,5 @@ public class MacroResolver {
}
return filtered;
}
-
+*/
}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/ICdtVariableSupplier.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/ICdtVariableSupplier.java
new file mode 100644
index 00000000000..c98a85b8d3f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/ICdtVariableSupplier.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.cdtvariables;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+
+/**
+ *
+ * @since 3.0
+ */
+public interface ICdtVariableSupplier {
+
+ /**
+ *
+ * @param macroName macro name
+ * @param contextType context type
+ * @param contextData context data
+ * @return IBuildMacro
+ */
+ public ICdtVariable getVariable(String macroName,
+ IVariableContextInfo context);
+
+ /**
+ *
+ * @param contextType context type
+ * @param contextData context data
+ * @return IBuildMacro[]
+ */
+ public ICdtVariable[] getVariables(IVariableContextInfo context);
+}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java
new file mode 100644
index 00000000000..354bd1f6e43
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.cdtvariables;
+
+
+
+/**
+ * This interface represents the context information.
+ *
+ * @since 3.0
+ */
+public interface IVariableContextInfo {
+
+ /**
+ * Returns suppliers to be used for this context
+ *
+ * @return IBuildMacroSupplier[]
+ */
+ public ICdtVariableSupplier[] getSuppliers();
+
+ /**
+ * Returns context info for the next lower-precedence context
+ *
+ * @return IMacroContextInfo
+ */
+ public IVariableContextInfo getNext();
+
+ public boolean equals(Object otherInfo);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroSubstitutor.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableSubstitutor.java
index 95e7a9fa4a3..3c011e2ad12 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/IMacroSubstitutor.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableSubstitutor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,10 +8,9 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
-
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
+package org.eclipse.cdt.utils.cdtvariables;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
/**
* This interface represents the logic of how macro references should be resolved
@@ -22,25 +21,25 @@ import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
*
* @since 3.0
*/
-public interface IMacroSubstitutor {
+public interface IVariableSubstitutor {
/**
* called to resolve to String the macro reference of the specified name
*
* @param macroName the macro name
* @return String
- * @throws BuildMacroException
+ * @throws CdtVariableException
*/
- public String resolveToString(String macroName) throws BuildMacroException;
+ public String resolveToString(String macroName) throws CdtVariableException;
/**
* called to resolve to String-List the macro reference of the specified name
*
* @param macroName the macro name
* @return String[]
- * @throws BuildMacroException
+ * @throws CdtVariableException
*/
- public String[] resolveToStringList(String macroName) throws BuildMacroException;
+ public String[] resolveToStringList(String macroName) throws CdtVariableException;
/**
* called to set the context type and context info to be used
@@ -49,12 +48,12 @@ public interface IMacroSubstitutor {
* @param contextData the context data
* @throws BuildMacroException
*/
- public void setMacroContextInfo(int contextType, Object contextData) throws BuildMacroException;
+// public void setMacroContextInfo(int contextType, Object contextData) throws BuildMacroException;
/**
* returns the macro conttext info used
* @return IMacroContextInfo
*/
- public IMacroContextInfo getMacroContextInfo();
+// public IMacroContextInfo getMacroContextInfo();
}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableManager.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableManager.java
new file mode 100644
index 00000000000..e9f5c218092
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableManager.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.cdtvariables;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+
+public class SupplierBasedCdtVariableManager {
+ /**
+ * @param macroName
+ * @param contextInfo
+ * @param includeParentContexts
+ * @return
+ */
+ static public ICdtVariable getVariable(String macroName, IVariableContextInfo contextInfo, boolean includeParentContexts) {
+ if(contextInfo == null || macroName == null)
+ return null;
+
+ do{
+ ICdtVariableSupplier suppliers[] = contextInfo.getSuppliers();
+ if(suppliers != null){
+ for(int i = 0; i < suppliers.length; i++){
+ ICdtVariable macro = suppliers[i].getVariable(macroName, contextInfo);
+ if(macro != null)
+ return macro;
+ }
+ }
+ }while(includeParentContexts && (contextInfo = contextInfo.getNext()) != null);
+
+ return null;
+ }
+
+ /**
+ * @param contextInfo
+ * @param includeParentContexts
+ * @return
+ */
+ static public ICdtVariable[] getVariables(IVariableContextInfo contextInfo,
+ boolean includeParentContexts) {
+ if(contextInfo == null)
+ return new ICdtVariable[0];
+
+ Map map = new HashMap();
+ IVariableContextInfo infos[] = includeParentContexts ?
+ getAllVariableContextInfos(contextInfo) :
+ new IVariableContextInfo[]{contextInfo};
+
+ for(int k = infos.length - 1; k >= 0; k--){
+ contextInfo = infos[k];
+ ICdtVariableSupplier suppliers[] = contextInfo.getSuppliers();
+ if(suppliers != null){
+ for(int i = suppliers.length - 1; i >= 0; i--){
+ ICdtVariable macros[] = suppliers[i].getVariables(contextInfo);
+ if(macros != null){
+ for(int j = 0; j < macros.length; j++){
+ map.put(macros[j].getName(),macros[j]);
+ }
+ }
+ }
+ }
+ }
+
+ Collection values = map.values();
+ return (ICdtVariable[])values.toArray(new ICdtVariable[values.size()]);
+ }
+
+ /*
+ * returns an array of the IMacroContextInfo that holds the context informations
+ * starting from the one passed to this method and including all subsequent parents
+ */
+ private static IVariableContextInfo[] getAllVariableContextInfos(IVariableContextInfo contextInfo){
+ if(contextInfo == null)
+ return null;
+
+ List list = new ArrayList();
+
+ list.add(contextInfo);
+
+ while((contextInfo = contextInfo.getNext()) != null)
+ list.add(contextInfo);
+
+ return (IVariableContextInfo[])list.toArray(new IVariableContextInfo[list.size()]);
+ }
+
+ /*
+ * returns true if the first passed contextInfo is the child of the second one
+ */
+ public static boolean checkParentContextRelation(IVariableContextInfo child, IVariableContextInfo parent){
+ if(child == null || parent == null)
+ return false;
+
+ IVariableContextInfo enumInfo = child;
+ do{
+ if(parent.equals(enumInfo))
+ return true;
+ }while((enumInfo = enumInfo.getNext()) != null);
+ return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableStatus.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableStatus.java
new file mode 100644
index 00000000000..3204786be7e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableStatus.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.cdtvariables;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariableStatus;
+
+public class SupplierBasedCdtVariableStatus extends CdtVariableStatus {
+ private IVariableContextInfo fContextInfo;
+
+ public SupplierBasedCdtVariableStatus(int severity, int code,
+ String message, Throwable exception, String macroName,
+ String expression, String referencedName, IVariableContextInfo info) {
+ super(severity, code, message, exception, macroName, expression, referencedName);
+
+ fContextInfo = info;
+ }
+
+ public SupplierBasedCdtVariableStatus(int code, String macroName,
+ String expression, String referencedName, IVariableContextInfo info) {
+ super(code, macroName, expression, referencedName);
+
+ fContextInfo = info;
+ }
+
+ public SupplierBasedCdtVariableStatus(int code, String message,
+ Throwable exception, String macroName, String expression,
+ String referencedName, IVariableContextInfo info) {
+ super(code, message, exception, macroName, expression, referencedName);
+
+ fContextInfo = info;
+ }
+
+ public IVariableContextInfo getVariableContextInfo(){
+ return fContextInfo;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroSubstitutor.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java
index 7bc8b3ffe74..18ccf10fc21 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/DefaultMacroSubstitutor.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2007 Intel 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
@@ -8,7 +8,7 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.macros;
+package org.eclipse.cdt.utils.cdtvariables;
import java.util.ArrayList;
import java.util.Arrays;
@@ -18,28 +18,22 @@ import java.util.List;
import java.util.Map;
import java.util.Stack;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
-
-/**
- * This substitutor resolves all macro references
- *
- * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor
- * @since 3.0
- */
-public class DefaultMacroSubstitutor implements IMacroSubstitutor {
+import org.eclipse.cdt.core.cdtvariables.CdtVariable;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus;
+import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo;
+
+public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor {
private static final Object UNDEFINED_MACRO_VALUE = new Object();
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private IMacroContextInfo fContextInfo;
+ private IVariableContextInfo fContextInfo;
private String fInexistentMacroValue;
private String fListDelimiter;
private String fIncorrectlyReferencedMacroValue;
private Map fDelimiterMap;
- protected class ResolvedMacro extends BuildMacro{
+ protected class ResolvedMacro extends CdtVariable{
private boolean fIsDefined;
private boolean fIsList;
@@ -69,7 +63,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringValue()
*/
- public String getStringValue() throws BuildMacroException {
+ public String getStringValue() throws CdtVariableException {
// if(!fIsDefined)
// throw new BuildMacroException(BuildMacroException.TYPE_MACROS_UNDEFINED,fName);
if(fIsList && fStringValue == null)
@@ -80,7 +74,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringListValue()
*/
- public String[] getStringListValue() throws BuildMacroException {
+ public String[] getStringListValue() throws CdtVariableException {
// if(!fIsDefined)
// throw new BuildMacroException(BuildMacroException.TYPE_MACROS_UNDEFINED,fName);
if(!fIsList && fStringListValue == null)
@@ -97,7 +91,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return fListDelimiter;
}
- protected String stringListToString(String values[]) throws BuildMacroException {
+ protected String stringListToString(String values[]) throws CdtVariableException {
String result = null;
String delimiter;
if(values == null)
@@ -115,12 +109,12 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
}
result = buffer.toString();
} else {
- throw new BuildMacroException(IBuildMacroStatus.TYPE_MACRO_NOT_STRING,
+ ICdtVariableStatus eStatus = new SupplierBasedCdtVariableStatus(ICdtVariableStatus.TYPE_MACRO_NOT_STRING,
null,
null,
fName,
- fContextInfo != null ? fContextInfo.getContextType() : 0,
- fContextInfo != null ? fContextInfo.getContextData() : null);
+ fContextInfo);
+ throw new CdtVariableException(eStatus);
}
return result;
@@ -141,24 +135,24 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
*/
protected class MacroDescriptor {
private String fName;
- private IMacroContextInfo fInfo;
- private IBuildMacro fMacro;
+ private IVariableContextInfo fInfo;
+ private ICdtVariable fMacro;
private boolean fInitialized;
private int fSupplierNum;
private int fEnvSupplierNum;
- public MacroDescriptor(String name, IMacroContextInfo info){
+ public MacroDescriptor(String name, IVariableContextInfo info){
fName = name;
fInfo = info;
}
- public MacroDescriptor(String name, IMacroContextInfo info, int supplierNum){
+ public MacroDescriptor(String name, IVariableContextInfo info, int supplierNum){
fName = name;
fInfo = info;
fSupplierNum = supplierNum;
}
- public MacroDescriptor(IBuildMacro macro, IMacroContextInfo info, int supplierNum){
+ public MacroDescriptor(ICdtVariable macro, IVariableContextInfo info, int supplierNum){
fName = macro.getName();
fInfo = info;
fMacro = macro;
@@ -180,10 +174,10 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return;
fInitialized = true;
for(; fInfo != null; fInfo = fInfo.getNext()){
- IBuildMacroSupplier suppliers[] = fInfo.getSuppliers();
+ ICdtVariableSupplier suppliers[] = fInfo.getSuppliers();
if(suppliers != null){
for(; fSupplierNum < suppliers.length; fSupplierNum++){
- if((fMacro = suppliers[fSupplierNum].getMacro(fName,fInfo.getContextType(),fInfo.getContextData())) != null){
+ if((fMacro = suppliers[fSupplierNum].getVariable(fName,fInfo)) != null){
return;
}
}
@@ -192,12 +186,12 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
}
}
- protected IMacroContextInfo getInfo(){
+ protected IVariableContextInfo getInfo(){
init();
return fInfo;
}
- public IBuildMacro getMacro(){
+ public ICdtVariable getMacro(){
init();
return fMacro;
}
@@ -208,19 +202,11 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
private HashSet fMacrosUnderResolution = new HashSet();
private Stack fMacroDescriptors = new Stack();
- public DefaultMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter, Map delimiterMap, String incorrectlyReferencedMacroValue){
- this(new DefaultMacroContextInfo(contextType,contextData),inexistentMacroValue,listDelimiter, delimiterMap, incorrectlyReferencedMacroValue);
- }
-
- public DefaultMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter){
- this(new DefaultMacroContextInfo(contextType,contextData),inexistentMacroValue,listDelimiter);
- }
-
- public DefaultMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
+ public SupplierBasedCdtVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
this(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
}
- public DefaultMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter, Map delimiterMap, String incorrectlyReferencedMacroValue){
+ public SupplierBasedCdtVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter, Map delimiterMap, String incorrectlyReferencedMacroValue){
fContextInfo = contextInfo;
fInexistentMacroValue = inexistentMacroValue;
fListDelimiter = listDelimiter;
@@ -228,7 +214,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
fIncorrectlyReferencedMacroValue = incorrectlyReferencedMacroValue;
}
- protected String resolveToString(MacroDescriptor des) throws BuildMacroException {
+ protected String resolveToString(MacroDescriptor des) throws CdtVariableException {
String result = null;
ResolvedMacro value = getResolvedMacro(des);
result = value.getStringValue();
@@ -236,7 +222,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return result;
}
- protected String[] resolveToStringList(MacroDescriptor des) throws BuildMacroException {
+ protected String[] resolveToStringList(MacroDescriptor des) throws CdtVariableException {
String result[] = null;
ResolvedMacro value = getResolvedMacro(des);
result = value.getStringListValue();
@@ -247,32 +233,21 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToString(java.lang.String)
*/
- public String resolveToString(String macroName) throws BuildMacroException {
+ public String resolveToString(String macroName) throws CdtVariableException {
return resolveToString(new MacroDescriptor(macroName,fContextInfo));
}
- public void setMacroContextInfo(IMacroContextInfo info)
- throws BuildMacroException{
+ public void setMacroContextInfo(IVariableContextInfo info)
+ throws CdtVariableException{
if(checkEqual(fContextInfo,info))
return;
reset();
fContextInfo = info;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#setMacroContextInfo(int, java.lang.Object)
- */
- public void setMacroContextInfo(int contextType, Object contextData) throws BuildMacroException{
- setMacroContextInfo(getMacroContextInfo(contextType,contextData));
- }
-
- protected IMacroContextInfo getMacroContextInfo(int contextType, Object contextData){
- return ((BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider()).getMacroContextInfo(contextType,contextData);
- }
protected ResolvedMacro getResolvedMacro(MacroDescriptor des)
- throws BuildMacroException {
+ throws CdtVariableException {
ResolvedMacro value = checkResolvingMacro(des);
if(value == null)
@@ -292,7 +267,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return value;
}
- protected ResolvedMacro resolveMacro(MacroDescriptor des) throws BuildMacroException{
+ protected ResolvedMacro resolveMacro(MacroDescriptor des) throws CdtVariableException{
return des.fMacro != null ? resolveMacro(des.fMacro) : resolveMacro(des.fName);
}
@@ -300,15 +275,15 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToStringList(java.lang.String)
*/
public String[] resolveToStringList(String macroName)
- throws BuildMacroException {
+ throws CdtVariableException {
return resolveToStringList(new MacroDescriptor(macroName,fContextInfo));
}
- protected ResolvedMacro resolveMacro(String macroName) throws BuildMacroException{
- return resolveMacro(BuildMacroProvider.getMacro(macroName,fContextInfo,true));
+ protected ResolvedMacro resolveMacro(String macroName) throws CdtVariableException{
+ return resolveMacro(SupplierBasedCdtVariableManager.getVariable(macroName,fContextInfo,true));
}
- protected ResolvedMacro resolveParentMacro(MacroDescriptor macroDes) throws BuildMacroException{
+ protected ResolvedMacro resolveParentMacro(MacroDescriptor macroDes) throws CdtVariableException{
MacroDescriptor des = macroDes.getNext();
ResolvedMacro macro = null;
@@ -324,16 +299,16 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return macro;
}
- protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
+ protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException{
if(macro == null)
return null;
String macroName = macro.getName();
- IMacroSubstitutor substitutor = this;
+ IVariableSubstitutor substitutor = this;
ResolvedMacro resolvedMacro = null;
- if(MacroResolver.isStringListMacro(macro.getMacroValueType())){
+ if(CdtVariableResolver.isStringListVariable(macro.getValueType())){
String result[] = null;
String unresolvedValues[] = macro.getStringListValue();
if(unresolvedValues == null || unresolvedValues.length == 0)
@@ -343,18 +318,18 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
for(int i = 0; i < unresolvedValues.length; i++){
try{
- resolvedValues[i] = MacroResolver.resolveToStringList(unresolvedValues[i],substitutor);
- } catch (BuildMacroException e) {
- IBuildMacroStatus statuses[] = e.getMacroStatuses();
+ resolvedValues[i] = CdtVariableResolver.resolveToStringList(unresolvedValues[i],substitutor);
+ } catch (CdtVariableException e) {
+ ICdtVariableStatus statuses[] = e.getVariableStatuses();
if(statuses != null && statuses.length == 1){
- IBuildMacroStatus status = statuses[0];
- if(status.getMacroName() == null){
- e = new BuildMacroException(status.getCode(),
+ ICdtVariableStatus status = statuses[0];
+ if(status.getVariableName() == null){
+ ICdtVariableStatus eStatus = new SupplierBasedCdtVariableStatus(status.getCode(),
macro.getName(),
status.getExpression(),
status.getReferencedMacroName(),
- fContextInfo != null ? fContextInfo.getContextType() : 0,
- fContextInfo != null ? fContextInfo.getContextData() : null);
+ fContextInfo);
+ e = new CdtVariableException(eStatus);
}
}
throw e;
@@ -374,18 +349,18 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
}
} else {
try{
- resolvedMacro = new ResolvedMacro(macroName,MacroResolver.resolveToString(macro.getStringValue(),substitutor));
- } catch (BuildMacroException e) {
- IBuildMacroStatus statuses[] = e.getMacroStatuses();
+ resolvedMacro = new ResolvedMacro(macroName,CdtVariableResolver.resolveToString(macro.getStringValue(),substitutor));
+ } catch (CdtVariableException e) {
+ ICdtVariableStatus statuses[] = e.getVariableStatuses();
if(statuses != null && statuses.length == 1){
- IBuildMacroStatus status = statuses[0];
- if(status.getMacroName() == null){
- e = new BuildMacroException(status.getCode(),
+ ICdtVariableStatus status = statuses[0];
+ if(status.getVariableName() == null){
+ ICdtVariableStatus eStatus = new SupplierBasedCdtVariableStatus(status.getCode(),
macro.getName(),
status.getExpression(),
status.getReferencedMacroName(),
- fContextInfo != null ? fContextInfo.getContextType() : 0,
- fContextInfo != null ? fContextInfo.getContextData() : null);
+ fContextInfo);
+ e = new CdtVariableException(eStatus);
}
}
throw e;
@@ -395,7 +370,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
}
private ResolvedMacro checkResolvingMacro(MacroDescriptor des)
- throws BuildMacroException{
+ throws CdtVariableException{
String name = des.fName;
ResolvedMacro value = (ResolvedMacro)fResolvedMacros.get(name);
if(value == null){
@@ -421,12 +396,12 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
}else if(fIncorrectlyReferencedMacroValue != null)
value = new ResolvedMacro(name,fIncorrectlyReferencedMacroValue,false);
else{
- throw new BuildMacroException(IBuildMacroStatus.TYPE_MACRO_REFERENCE_INCORRECT,
+ ICdtVariableStatus status = new SupplierBasedCdtVariableStatus(ICdtVariableStatus.TYPE_MACRO_REFERENCE_INCORRECT,
(String)null,
null,
name,
- fContextInfo != null ? fContextInfo.getContextType() : 0,
- fContextInfo != null ? fContextInfo.getContextData() : null);
+ fContextInfo);
+ throw new CdtVariableException(status);
}
}
}
@@ -448,13 +423,13 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#getMacroContextInfo()
*/
- public IMacroContextInfo getMacroContextInfo(){
+ public IVariableContextInfo getMacroContextInfo(){
return fContextInfo;
}
- public void reset() throws BuildMacroException{
+ public void reset() throws CdtVariableException{
if(fMacrosUnderResolution.size() != 0)
- throw new BuildMacroException(IBuildMacroStatus.TYPE_ERROR,(String)null,null,null,0,null);
+ throw new CdtVariableException(ICdtVariableStatus.TYPE_ERROR,(String)null,null,null);
fResolvedMacros.clear();
}
@@ -463,7 +438,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return fDelimiterMap;
}
- public void setDelimiterMap(Map delimiterMap) throws BuildMacroException {
+ public void setDelimiterMap(Map delimiterMap) throws CdtVariableException {
if(checkEqual(fDelimiterMap,delimiterMap))
return;
reset();
@@ -484,7 +459,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
}
public void setIncorrectlyReferencedMacroValue(
- String incorrectlyReferencedMacroValue) throws BuildMacroException {
+ String incorrectlyReferencedMacroValue) throws CdtVariableException {
if(checkEqual(fIncorrectlyReferencedMacroValue,incorrectlyReferencedMacroValue))
return;
reset();
@@ -495,7 +470,7 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return fInexistentMacroValue;
}
- public void setInexistentMacroValue(String inexistentMacroValue) throws BuildMacroException {
+ public void setInexistentMacroValue(String inexistentMacroValue) throws CdtVariableException {
if(checkEqual(fInexistentMacroValue,inexistentMacroValue))
return;
reset();
@@ -506,11 +481,10 @@ public class DefaultMacroSubstitutor implements IMacroSubstitutor {
return fListDelimiter;
}
- public void setListDelimiter(String listDelimiter) throws BuildMacroException {
+ public void setListDelimiter(String listDelimiter) throws CdtVariableException {
if(checkEqual(fListDelimiter,listDelimiter))
return;
reset();
fListDelimiter = listDelimiter;
}
-
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarOperationProcessor.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvVarOperationProcessor.java
index 62530c80f8c..64bd96fd03b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/EnvVarOperationProcessor.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvVarOperationProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,14 +8,16 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
+package org.eclipse.cdt.utils.envvar;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.EnvirinmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
+
/**
* This is an utility class that implements environment variable operations
@@ -24,8 +26,6 @@ import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
* @since 3.0
*/
public class EnvVarOperationProcessor {
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
/**
* performs the environment variable operation given an initial variable and
* a variable representing an operation to be performed
@@ -36,7 +36,7 @@ public class EnvVarOperationProcessor {
* initial variable value
* @return the new variable the represents the result of a performed operation
*/
- static public IBuildEnvironmentVariable performOperation(IBuildEnvironmentVariable initial, IBuildEnvironmentVariable added){
+ static public IEnvironmentVariable performOperation(IEnvironmentVariable initial, IEnvironmentVariable added){
if(initial == null){
return added;
}
@@ -46,25 +46,25 @@ public class EnvVarOperationProcessor {
String name = added.getName();
switch(added.getOperation()){
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
- return new BuildEnvVar(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
- case IBuildEnvironmentVariable.ENVVAR_APPEND:{
+ case IEnvironmentVariable.ENVVAR_REMOVE:
+ return new EnvirinmentVariable(name,null,IEnvironmentVariable.ENVVAR_REMOVE,null);
+ case IEnvironmentVariable.ENVVAR_APPEND:{
String delimiter = added.getDelimiter();
- return new BuildEnvVar(name,
+ return new EnvirinmentVariable(name,
performAppend(initial.getValue(),added.getValue(),delimiter),
// IBuildEnvironmentVariable.ENVVAR_APPEND,
delimiter);
}
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:{
+ case IEnvironmentVariable.ENVVAR_PREPEND:{
String delimiter = added.getDelimiter();
- return new BuildEnvVar(name,
+ return new EnvirinmentVariable(name,
performPrepend(initial.getValue(),added.getValue(),delimiter),
// IBuildEnvironmentVariable.ENVVAR_PREPEND,
delimiter);
}
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
+ case IEnvironmentVariable.ENVVAR_REPLACE:
default:
- return new BuildEnvVar(added.getName(),added.getValue(),added.getDelimiter());
+ return new EnvirinmentVariable(added.getName(),added.getValue(),added.getDelimiter());
}
}
@@ -135,13 +135,13 @@ public class EnvVarOperationProcessor {
*/
static public String performOperation(String initialValue, String newValue, String delimiter, int op){
switch(op){
- case IBuildEnvironmentVariable.ENVVAR_REMOVE:
+ case IEnvironmentVariable.ENVVAR_REMOVE:
return null;
- case IBuildEnvironmentVariable.ENVVAR_PREPEND:
+ case IEnvironmentVariable.ENVVAR_PREPEND:
return performPrepend(initialValue,newValue,delimiter);
- case IBuildEnvironmentVariable.ENVVAR_APPEND:
+ case IEnvironmentVariable.ENVVAR_APPEND:
return performAppend(initialValue,newValue,delimiter);
- case IBuildEnvironmentVariable.ENVVAR_REPLACE:
+ case IEnvironmentVariable.ENVVAR_REPLACE:
default:
return initialValue;
}
@@ -244,20 +244,20 @@ public class EnvVarOperationProcessor {
return null;
if("".equals(name = name.trim())) //$NON-NLS-1$
return null;
- if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
+ if(!EnvironmentVariableManager.getDefault().isVariableCaseSensitive())
name = name.toUpperCase();
return name;
}
- static public IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[], String remove[]){
+ static public IEnvironmentVariable[] filterVariables(IEnvironmentVariable variables[], String remove[]){
if(variables == null || variables.length == 0)
return variables;
- IBuildEnvironmentVariable filtered[] = new IBuildEnvironmentVariable[variables.length];
+ IEnvironmentVariable filtered[] = new IEnvironmentVariable[variables.length];
int filteredNum = 0;
for(int i = 0; i < variables.length; i++){
- IBuildEnvironmentVariable var = variables[i];
+ IEnvironmentVariable var = variables[i];
String name = null;
if(var != null && (name = normalizeName(var.getName())) != null){
boolean skip = false;
@@ -275,7 +275,7 @@ public class EnvVarOperationProcessor {
}
if(filteredNum != filtered.length){
- IBuildEnvironmentVariable vars[] = new IBuildEnvironmentVariable[filteredNum];
+ IEnvironmentVariable vars[] = new IEnvironmentVariable[filteredNum];
for(int i = 0; i < filteredNum; i++)
vars[i] = filtered[i];
filtered = vars;
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvironmentCollector.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvironmentCollector.java
new file mode 100644
index 00000000000..a59849803f8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvironmentCollector.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.envvar;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+
+public class EnvironmentCollector {
+ private Map fEnfironmentMap = new HashMap();
+
+ public IEnvironmentVariable addVariable(IEnvironmentVariable var){
+ if(var == null)
+ return null;
+
+ String name = var.getName();
+
+ name = EnvVarOperationProcessor.normalizeName(name);
+
+ if(name != null){
+ IEnvironmentVariable old = (IEnvironmentVariable)fEnfironmentMap.get(name);
+ if(old != null){
+ var = EnvVarOperationProcessor.performOperation(old, var);
+ }
+ fEnfironmentMap.put(name, var);
+ }
+
+ return var;
+ }
+
+ public void addVariables(IEnvironmentVariable[] vars){
+ if(vars == null)
+ return;
+ for(int i = 0; i < vars.length; i++){
+ addVariable(vars[i]);
+ }
+ }
+
+ public IEnvironmentVariable getVariable(String name){
+ name = EnvVarOperationProcessor.normalizeName(name);
+ if(name != null)
+ return (IEnvironmentVariable)fEnfironmentMap.get(name);
+ return null;
+ }
+
+ public IEnvironmentVariable[] getVariables(){
+ return (IEnvironmentVariable[])fEnfironmentMap.values().toArray(new IEnvironmentVariable[fEnfironmentMap.size()]);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvVar.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvVar.java
index c560898ff8c..168ab1c4208 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvVar.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvVar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,10 +8,10 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
+package org.eclipse.cdt.utils.envvar;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.eclipse.cdt.core.envvar.EnvirinmentVariable;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
/**
* This class represents the Environment variable that could be loaded
@@ -20,7 +20,7 @@ import org.w3c.dom.Element;
* @since 3.0
*
*/
-public class StorableEnvVar extends BuildEnvVar {
+public class StorableEnvVar extends EnvirinmentVariable {
public static final String VARIABLE_ELEMENT_NAME = "variable"; //$NON-NLS-1$
public static final String NAME = "name"; //$NON-NLS-1$
public static final String VALUE = "value"; //$NON-NLS-1$
@@ -48,11 +48,11 @@ public class StorableEnvVar extends BuildEnvVar {
this(name,value,ENVVAR_REPLACE,delimiter);
}
- public StorableEnvVar(Element element){
+ public StorableEnvVar(ICStorageElement element){
load(element);
}
- private void load(Element element){
+ private void load(ICStorageElement element){
fName = element.getAttribute(NAME);
fValue = element.getAttribute(VALUE);
@@ -94,7 +94,7 @@ public class StorableEnvVar extends BuildEnvVar {
return operation;
}
- public void serialize(Document doc, Element element){
+ public void serialize(ICStorageElement element){
if(fName != null)
element.setAttribute(NAME,fName);
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java
new file mode 100644
index 00000000000..0e0b62c6739
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java
@@ -0,0 +1,317 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.envvar;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
+import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
+
+/**
+ * This class represents the set of environment variables that could be loaded
+ * and stored in XML
+ *
+ * @since 3.0
+ *
+ */
+public class StorableEnvironment /*implements Cloneable*/{
+ public static final String ENVIRONMENT_ELEMENT_NAME = "environment"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_APPEND = "append"; //$NON-NLS-1$
+ private static final boolean DEFAULT_APPEND = true;
+ private HashMap fVariables;
+ private boolean fIsDirty = false;
+ private boolean fIsChanged = false;
+ private boolean fIsReadOnly;
+ private boolean fAppend = DEFAULT_APPEND;
+ private boolean fAppendContributedEnv = DEFAULT_APPEND;
+
+ private Map getMap(){
+ if(fVariables == null)
+ fVariables = new HashMap();
+ return fVariables;
+ }
+
+ public StorableEnvironment(IEnvironmentVariable variables[], boolean isReadOnly) {
+ setVariales(variables);
+ fIsReadOnly = isReadOnly;
+ }
+
+ public StorableEnvironment(boolean isReadOnly) {
+ fIsReadOnly = isReadOnly;
+ }
+
+ public StorableEnvironment(StorableEnvironment env, boolean isReadOnly) {
+ if(env.fVariables != null)
+ fVariables = (HashMap)env.fVariables.clone();
+ fAppend = env.fAppend;
+ fIsReadOnly = isReadOnly;
+ fIsDirty = env.isDirty();
+ }
+
+ public StorableEnvironment(ICStorageElement element, boolean isReadOnly) {
+ load(element);
+ fIsReadOnly = isReadOnly;
+ }
+
+ private void load(ICStorageElement element){
+ ICStorageElement children[] = element.getChildren();
+ for (int i = 0; i < children.length; ++i) {
+ ICStorageElement node = children[i];
+ if (node.getName().equals(StorableEnvVar.VARIABLE_ELEMENT_NAME)) {
+ addVariable(new StorableEnvVar(node));
+ }
+ }
+
+ String append = element.getAttribute(ATTRIBUTE_APPEND);
+ fAppend = append != null ? Boolean.valueOf(element.getAttribute(ATTRIBUTE_APPEND)).booleanValue()
+ : true;
+ fIsDirty = false;
+ fIsChanged = false;
+ }
+
+ public void serialize(ICStorageElement element){
+ element.setAttribute(ATTRIBUTE_APPEND, Boolean.valueOf(fAppend).toString());
+ if(fVariables != null){
+ Iterator iter = fVariables.values().iterator();
+ while(iter.hasNext()){
+ StorableEnvVar var = (StorableEnvVar)iter.next();
+ ICStorageElement varEl = element.createChild(StorableEnvVar.VARIABLE_ELEMENT_NAME);
+ var.serialize(varEl);
+ }
+ }
+ fIsDirty = false;
+ }
+
+ private void addVariable(IEnvironmentVariable var){
+ String name = var.getName();
+ if(name == null)
+ return;
+ IEnvironmentVariableManager provider = EnvironmentVariableManager.getDefault();
+ if(!provider.isVariableCaseSensitive())
+ name = name.toUpperCase();
+
+ getMap().put(name,var);
+ }
+
+ public IEnvironmentVariable createVariable(String name, String value, int op, String delimiter){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+
+ if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
+ return null;
+
+ IEnvironmentVariable var = checkVariable(name,value,op,delimiter);
+ if(var == null){
+ var = new StorableEnvVar(name, value, op, delimiter);
+ addVariable(var);
+ fIsDirty = true;
+ fIsChanged = true;
+ }
+ return var;
+ }
+
+ public IEnvironmentVariable createVariable(String name){
+ return createVariable(name,null,IEnvironmentVariable.ENVVAR_REPLACE,null);
+ }
+
+ public IEnvironmentVariable createVariable(String name, String value){
+ return createVariable(name,value,IEnvironmentVariable.ENVVAR_REPLACE,null);
+ }
+
+ public IEnvironmentVariable createVariable(String name, String value, String delimiter){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ return createVariable(name,value,IEnvironmentVariable.ENVVAR_REPLACE,delimiter);
+ }
+
+ public IEnvironmentVariable checkVariable(String name, String value, int op, String delimiter){
+ IEnvironmentVariable var = getVariable(name);
+ if(var != null
+ && checkStrings(var.getValue(),value)
+ && var.getOperation() == op
+ && checkStrings(var.getDelimiter(),delimiter))
+ return var;
+ return null;
+ }
+
+ private boolean checkStrings(String str1, String str2){
+ if(str1 != null &&
+ str1.equals(str2))
+ return true;
+ return str1 == str2;
+ }
+
+ /**
+ * Returns the "dirty" state of the environment.
+ * If the dirty state is <code>true</code>, that means that the environment
+ * is out of synch with the repository and the environment needs to be serialized.
+ * <br><br>
+ * The dirty state is automatically set to <code>false</code> when the environment is serialized
+ * by calling the serialize() method
+ * @return boolean
+ */
+ public boolean isDirty(){
+ return fIsDirty;
+ }
+
+ /**
+ * sets the "dirty" state of the environment
+ * @param dirty represents the new state
+ */
+ public void setDirty(boolean dirty){
+ fIsDirty = dirty;
+ }
+
+ /**
+ * Returns the "change" state of the environment.
+ * The "change" state represents whether the environment was changed or not.
+ * This state is not reset when the serialize() method is called
+ * Users can use this state to monitor whether the environment was changed or not.
+ * This state can be reset to <code>false</code> only by calling the setChanged(false) method
+ * @return boolean
+ */
+ public boolean isChanged(){
+ return fIsChanged;
+ }
+
+ /**
+ * sets the "change" state of the environment
+ * @param changed represents the new "change" state
+ */
+ public void setChanged(boolean changed){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ fIsChanged = changed;
+ }
+
+ public IEnvironmentVariable getVariable(String name){
+ if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
+ return null;
+ IEnvironmentVariableManager provider = EnvironmentVariableManager.getDefault();
+ if(!provider.isVariableCaseSensitive())
+ name = name.toUpperCase();
+
+ return (IEnvironmentVariable)getMap().get(name);
+ }
+
+ public void setVariales(IEnvironmentVariable vars[]){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ if(vars == null || vars.length == 0)
+ deleteAll();
+ else{
+ if (getMap().size() != 0) {
+ Iterator iter = getMap().values().iterator();
+ while(iter.hasNext()){
+ IEnvironmentVariable v = (IEnvironmentVariable)iter.next();
+ int i;
+ for(i = 0 ; i < vars.length; i++){
+ if(v.getName().equals(vars[i].getName()))
+ break;
+ }
+ if(i == vars.length)
+ deleteVariable(v.getName());
+ }
+ }
+ createVriables(vars);
+ }
+ }
+
+ public void createVriables(IEnvironmentVariable vars[]){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ for(int i = 0; i < vars.length; i++)
+ createVariable(vars[i].getName(),
+ vars[i].getValue(),
+ vars[i].getOperation(),
+ vars[i].getDelimiter());
+ }
+
+ public IEnvironmentVariable[] getVariables(){
+ Collection vars = getMap().values();
+
+ return (IEnvironmentVariable[])vars.toArray(new IEnvironmentVariable[vars.size()]);
+ }
+
+ public IEnvironmentVariable deleteVariable(String name){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
+ return null;
+ IEnvironmentVariableManager provider = EnvironmentVariableManager.getDefault();
+ if(!provider.isVariableCaseSensitive())
+ name = name.toUpperCase();
+
+ IEnvironmentVariable var = (IEnvironmentVariable)getMap().remove(name);
+ if(var != null){
+ fIsDirty = true;
+ fIsChanged = true;
+ }
+
+ return var;
+ }
+
+ public boolean deleteAll(){
+ if(fIsReadOnly)
+ throw ExceptionFactory.createIsReadOnlyException();
+ Map map = getMap();
+ if(map.size() > 0){
+ fIsDirty = true;
+ fIsChanged = true;
+ map.clear();
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean isReadOnly(){
+ return fIsReadOnly;
+ }
+
+ public boolean appendEnvironment(){
+ return fAppend;
+ }
+
+ public void setAppendEnvironment(boolean append){
+ fAppend = append;
+ }
+
+ public boolean appendContributedEnvironment(){
+ return fAppendContributedEnv;
+ }
+
+ public void setAppendContributedEnvironment(boolean append){
+ fAppendContributedEnv = append;
+ }
+
+ public void restoreDefaults(){
+ deleteAll();
+ fAppend = DEFAULT_APPEND;
+ fAppendContributedEnv = DEFAULT_APPEND;
+ }
+
+/* public Object clone(){
+ try {
+ StorableEnvironment env = (StorableEnvironment)super.clone();
+ env.fVariables = (HashMap)fVariables.clone();
+ } catch (CloneNotSupportedException e) {
+ }
+ return null;
+ }
+*/
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironmentLoader.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironmentLoader.java
index 71121d0d94f..f95475ce449 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironmentLoader.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironmentLoader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,7 +8,7 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.envvar;
+package org.eclipse.cdt.utils.envvar;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -27,8 +27,8 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.util.XmlStorageElement;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -53,7 +53,7 @@ public abstract class StorableEnvironmentLoader {
* that are used for holding the environment data
*
*/
- protected interface ISerializeInfo{
+ public interface ISerializeInfo{
Preferences getNode();
String getPrefName();
@@ -72,21 +72,21 @@ public abstract class StorableEnvironmentLoader {
/*
* loads the stored environment for the given context
*/
- protected StorableEnvironment loadEnvironment(Object context){
+ protected StorableEnvironment loadEnvironment(Object context, boolean readOnly){
ISerializeInfo serializeInfo = getSerializeInfo(context);
if(serializeInfo == null)
return null;
InputStream stream = loadInputStream(serializeInfo.getNode(),serializeInfo.getPrefName());
if(stream == null)
- return new StorableEnvironment();
- return loadEnvironmentFromStream(stream);
+ return new StorableEnvironment(readOnly);
+ return loadEnvironmentFromStream(stream, readOnly);
}
/*
* stores the given environment
*/
- protected void storeEnvironment(StorableEnvironment env, Object context, boolean force) throws CoreException{
+ protected void storeEnvironment(StorableEnvironment env, Object context, boolean force, boolean flush) throws CoreException{
if(!env.isDirty() && !force)
return;
@@ -97,20 +97,23 @@ public abstract class StorableEnvironmentLoader {
ByteArrayOutputStream stream = storeEnvironmentToStream(env);
if(stream == null)
return;
- storeOutputStream(stream,serializeInfo.getNode(),serializeInfo.getPrefName());
+ storeOutputStream(stream,serializeInfo.getNode(),serializeInfo.getPrefName(), flush);
+
+ env.setDirty(false);
}
- private StorableEnvironment loadEnvironmentFromStream(InputStream stream){
+ private StorableEnvironment loadEnvironmentFromStream(InputStream stream, boolean readOnly){
try{
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource(stream);
Document document = parser.parse(inputSource);
- Element rootElement = document.getDocumentElement();
+ Element el = document.getDocumentElement();
+ XmlStorageElement rootElement = new XmlStorageElement(el);
- if(!StorableEnvironment.ENVIRONMENT_ELEMENT_NAME.equals(rootElement.getNodeName()))
+ if(!StorableEnvironment.ENVIRONMENT_ELEMENT_NAME.equals(rootElement.getName()))
return null;
- return new StorableEnvironment(rootElement);
+ return new StorableEnvironment(rootElement, readOnly);
}
catch(ParserConfigurationException e){
@@ -131,9 +134,10 @@ public abstract class StorableEnvironmentLoader {
DocumentBuilder builder= factory.newDocumentBuilder();
Document document= builder.newDocument();
- Element rootElement = document.createElement(StorableEnvironment.ENVIRONMENT_ELEMENT_NAME);
- document.appendChild(rootElement);
- env.serialize(document,rootElement);
+ Element el = document.createElement(StorableEnvironment.ENVIRONMENT_ELEMENT_NAME);
+ document.appendChild(el);
+ XmlStorageElement rootElement = new XmlStorageElement(el);
+ env.serialize(rootElement);
Transformer transformer=TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
@@ -149,21 +153,21 @@ public abstract class StorableEnvironmentLoader {
}
catch(ParserConfigurationException e){
throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ CCorePlugin.PLUGIN_ID,
-1,
e.getMessage(),
e));
}
catch(TransformerConfigurationException e){
throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ CCorePlugin.PLUGIN_ID,
-1,
e.getMessage(),
e));
}
catch(TransformerException e){
throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ CCorePlugin.PLUGIN_ID,
-1,
e.getMessage(),
e));
@@ -188,12 +192,15 @@ public abstract class StorableEnvironmentLoader {
return new ByteArrayInputStream(bytes);
}
- private void storeOutputStream(ByteArrayOutputStream stream, Preferences node, String key) throws CoreException{
+ private void storeOutputStream(ByteArrayOutputStream stream, Preferences node, String key, boolean flush) throws CoreException{
if(stream == null || node == null || key == null)
throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ CCorePlugin.PLUGIN_ID,
-1,
- ManagedMakeMessages.getResourceString("StorableEnvironmentLoader.storeOutputStream.wrong.arguments"), //$NON-NLS-1$
+ //TODO:ManagedMakeMessages.getResourceString(
+ "StorableEnvironmentLoader.storeOutputStream.wrong.arguments"
+ //)
+ , //$NON-NLS-1$
null));
byte[] bytes= stream.toByteArray();
@@ -206,15 +213,17 @@ public abstract class StorableEnvironmentLoader {
node.put(key,val);
- try{
- node.flush();
- }
- catch(BackingStoreException e){
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
- e.getMessage(),
- e));
+ if(flush){
+ try{
+ node.flush();
+ }
+ catch(BackingStoreException e){
+ throw new CoreException(new Status(IStatus.ERROR,
+ CCorePlugin.PLUGIN_ID,
+ -1,
+ e.getMessage(),
+ e));
+ }
}
}
}
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 0f9b6c3b216..ea8151a5ee5 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -9,7 +9,7 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.internal.corext.template.c;x-internal:=true,
org.eclipse.cdt.internal.corext.util;x-internal:=true,
- org.eclipse.cdt.internal.ui;x-internal:=true,
+ org.eclipse.cdt.internal.ui,
org.eclipse.cdt.internal.ui.actions;x-internal:=true,
org.eclipse.cdt.internal.ui.browser.opentype;x-internal:=true,
org.eclipse.cdt.internal.ui.buildconsole;x-internal:=true,
@@ -54,7 +54,8 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.ui.text.folding,
org.eclipse.cdt.ui.wizards,
org.eclipse.cdt.ui.wizards.conversion,
- org.eclipse.cdt.utils.ui.controls
+ org.eclipse.cdt.utils.ui.controls,
+ org.eclipse.cdt.ui.newui
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.3.0,4.0.0)",
@@ -71,7 +72,8 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)",
org.eclipse.help;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
org.eclipse.cdt.refactoring;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)"
+ org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Import-Package: com.ibm.icu.text
diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gif
new file mode 100644
index 00000000000..179b657e2ac
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gif
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/config-tool.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/config-tool.gif
new file mode 100644
index 00000000000..c984fba7039
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/dlcl16/config-tool.gif
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/open_incl.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/open_incl.gif
new file mode 100644
index 00000000000..3503cfe3afa
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/dlcl16/open_incl.gif
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gif b/core/org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gif
new file mode 100644
index 00000000000..cc28a3a4201
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gif
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/config-tool.gif b/core/org.eclipse.cdt.ui/icons/elcl16/config-tool.gif
new file mode 100644
index 00000000000..c984fba7039
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/elcl16/config-tool.gif
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/open_incl.gif b/core/org.eclipse.cdt.ui/icons/elcl16/open_incl.gif
new file mode 100644
index 00000000000..3503cfe3afa
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/elcl16/open_incl.gif
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/obj16/environment.gif b/core/org.eclipse.cdt.ui/icons/obj16/environment.gif
new file mode 100644
index 00000000000..716df436f99
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/obj16/environment.gif
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/obj16/filesyst.GIF b/core/org.eclipse.cdt.ui/icons/obj16/filesyst.GIF
new file mode 100644
index 00000000000..13ce11b1490
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/obj16/filesyst.GIF
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/obj16/workspace.GIF b/core/org.eclipse.cdt.ui/icons/obj16/workspace.GIF
new file mode 100644
index 00000000000..eb7b90c7671
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/obj16/workspace.GIF
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 473fafdebab..17b646055b7 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -23,6 +23,7 @@ nature.name=C Nature
perspective.name=C/C++
viewsCategory.name=&C/C++
CView.name=C/C++ Projects
+cPropertyTabName=New CDT Model Property Tab
ToggleCommentAction.label= Togg&le Comment
@@ -39,6 +40,8 @@ newCWizardsCategory.name=C
# C++
newCCWizardsCategory.name=C++
+categoryCDT.name=CDT
+
#Project Conversion
ConversionWizard.name=Convert a project's nature
ConversionWizard.description=Convert a project's nature
@@ -151,6 +154,17 @@ DeleteTaskAction.label=Delete C/C++ Markers
DeleteIProblemMarkerAction.label=Delete IProblem Markers
OpenExternalProblemAction.label=Open external location
+# Build configuration actions
+BuildConfigActionSet.label=Build Configuration
+BuildConfigToolbarAction.label=Active Build Configuration
+BuildConfigMenuAction.label=Active Buil&d Configuration
+BuildConfigContextAction.label=Active Bui&ld Configuration
+BuildConfigAction.tooltip=Change active build configuration for the current project
+
+ManageConfigAction.label=Manage configurations
+DeleteRcConfigAction.label=Delete resource configs...
+BuildConfigurationActionSet.descr=Build configuration for the current project
+
# Common Editor ruler actions
AddTask.label=Add &Task...
AddTask.tooltip=Add Task...
@@ -343,6 +357,9 @@ completionProposalComputer=Completion Proposal Computer
# Indexer Preference Name
indexerPrefName=Indexer
+varsPrefName=CDT build variables
+envPrefName=Environment
+
# indexer names
CDTIndexer.domsourceindexer=Full C/C++ Indexer (complete parse)
CDTIndexer.nullindexer=No Indexer (search based features will not work correctly)
@@ -379,3 +396,5 @@ SpecificContentAssist.param= type
# CView context
cViewScope.name = In C/C++ Views
cViewScope.description = In C/C++ Views
+
+NewCfgDialog.name = newCfgDialog \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 858b334cd2f..65b49c10339 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -7,6 +7,8 @@
<extension-point id="BinaryParserPage" name="%binaryParserPage"/>
<extension-point id="PathContainerPage" name="%pathContainerPage" schema="schema/PathContainerPage.exsd"/>
<extension-point id="foldingStructureProviders" name="%foldingStructureProvidersExtensionPoint" schema="schema/foldingStructureProviders.exsd"/>
+ <extension-point id="cPropertyTab" name="%cPropertyTabName" schema="schema/cPropertyTab.exsd"/>
+
<!-- =========================================================================== -->
<!-- Extension point: org.eclipse.cdt.ui.textHovers -->
@@ -18,6 +20,7 @@
<extension-point id="completionContributors" name="%completionContributors" schema="schema/completionContributors.exsd"/>
<extension-point id="ProposalFilter" name="%proposalFilter.name" schema="schema/ProposalFilter.exsd"/>
<extension-point id="completionProposalComputer" name="%completionProposalComputer" schema="schema/completionProposalComputer.exsd"/>
+ <extension-point id="newCfgDialog" name="%NewCfgDialog.name" schema="schema/newCfgDialog.exsd"/>
<extension
point="org.eclipse.core.runtime.adapters">
@@ -221,6 +224,7 @@
<actionSet
id="org.eclipse.debug.ui.launchActionSet">
</actionSet>
+ <actionSet id="org.eclipse.cdt.ui.buildConfigActionSet"/>
<showInPart id="org.eclipse.cdt.ui.includeBrowser"/>
<showInPart id="org.eclipse.cdt.ui.CView"/>
<actionSet id="org.eclipse.ui.edit.text.actionSet.presentation"/>
@@ -323,6 +327,10 @@
<extension
point="org.eclipse.ui.newWizards">
<category
+ name="%categoryCDT.name"
+ id="org.eclipse.cdt.ui.newCDTWizards">
+ </category>
+ <category
name="%newCWizardsCategory.name"
id="org.eclipse.cdt.ui.newCWizards">
</category>
@@ -672,17 +680,27 @@
class="org.eclipse.cdt.internal.ui.preferences.AppearancePreferencePage"
id="org.eclipse.cdt.ui.preferences.AppearancePreferencePage">
</page>
- <page
+ <!--page
name="%pathEntryVariablesPrefName"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.PathEntryVariablePreferencePage"
id="org.eclipse.cdt.ui.preferences.PathEntryVariablePreferencePage">
- </page>
+ </page-->
<page
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage"
id="org.eclipse.cdt.ui.preferences.IndexerPreferencePage"
name="%indexerPrefName"/>
+ <page
+ category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+ class="org.eclipse.cdt.ui.newui.PrefPage_Env"
+ id="org.eclipse.cdt.ui.preferences.EnvironmentPrefPage"
+ name="%envPrefName"/>
+ <page
+ category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+ class="org.eclipse.cdt.ui.newui.PrefPage_Vars"
+ id="org.eclipse.cdt.ui.preferences.VariablesPrefPage"
+ name="%varsPrefName"/>
<!--page
name="%WorkInProgress.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
@@ -793,7 +811,45 @@
name="type"
value="org.eclipse.cdt.core.problem"/>
</objectContribution>
+ <objectContribution
+ adaptable="true"
+ id="org.eclipse.cdt.ui.buildConfigContribution"
+ objectClass="org.eclipse.core.resources.IResource">
+ <action
+ class="org.eclipse.cdt.ui.actions.ChangeBuildConfigContextAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.ui.buildConfigPulldownAction"
+ label="%BuildConfigContextAction.label"
+ menubarPath="buildGroup"
+ style="pulldown"
+ tooltip="%BuildConfigAction.tooltip"/>
+ <action
+ class="org.eclipse.cdt.ui.actions.ManageConfigsAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.ui.manageConfigsAction0"
+ label="%ManageConfigAction.label"
+ menubarPath="buildGroup"
+ />
+ <action
+ class="org.eclipse.cdt.ui.actions.DeleteResConfigsAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.ui.deleteConfigsAction0"
+ label="%DeleteRcConfigAction.label"
+ menubarPath="buildGroup"
+ />
+ </objectContribution>
+ <objectContribution
+ adaptable="true"
+ id="org.eclipse.cdt.ui.rebuildIndexContribution"
+ objectClass="org.eclipse.cdt.core.model.ICProject">
+ <action
+ class="org.eclipse.cdt.internal.ui.indexview.RebuildIndexActionDelegate"
+ id="org.eclipse.cdt.ui.rebuildIndexAction"
+ label="%RebuildIndex.name"
+ menubarPath="buildGroup"/>
+ </objectContribution>
</extension>
+
<extension
point="org.eclipse.compare.structureCreators">
<structureCreator
@@ -1263,7 +1319,56 @@
id="org.eclipse.search.menu">
</menu>
</actionSet>
+ <actionSet
+ description="%BuildConfigurationActionSet.descr"
+ id="org.eclipse.cdt.ui.buildConfigActionSet"
+ label="%BuildConfigActionSet.label"
+ visible="false">
+ <action
+ class="org.eclipse.cdt.ui.actions.ChangeBuildConfigMenuAction"
+ disabledIcon="icons/dlcl16/config-tool.gif"
+ enablesFor="+"
+ icon="icons/elcl16/config-tool.gif"
+ id="org.eclipse.cdt.ui.buildConfigToolbarAction"
+ label="%BuildConfigToolbarAction.label"
+ style="pulldown"
+ toolbarPath="buildConfig"
+ tooltip="%BuildConfigAction.tooltip"/>
+ <action
+ class="org.eclipse.cdt.ui.actions.ChangeBuildConfigMenuAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.ui.buildConfigMenuAction"
+ label="%BuildConfigMenuAction.label"
+ menubarPath="project/build"
+ style="pulldown"
+ tooltip="%BuildConfigAction.tooltip"/>
+
+ <action
+ class="org.eclipse.cdt.ui.actions.ManageConfigsAction"
+ disabledIcon="icons/dlcl16/action-editconfig.gif"
+ enablesFor="+"
+ icon="icons/elcl16/action-editconfig.gif"
+ id="org.eclipse.cdt.ui.manageConfigsAction1"
+ label="%ManageConfigAction.label"
+ toolbarPath="buildConfig"
+ />
+ <action
+ class="org.eclipse.cdt.ui.actions.ManageConfigsAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.ui.manageConfigsAction2"
+ label="%ManageConfigAction.label"
+ menubarPath="project/build"
+ />
+ <action
+ class="org.eclipse.cdt.ui.actions.DeleteResConfigsAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.ui.deleteConfigsAction2"
+ label="%DeleteRcConfigAction.label"
+ menubarPath="project/build"
+ />
+ </actionSet>
</extension>
+
<extension
point="org.eclipse.ui.actionSetPartAssociations">
<actionSetPartAssociation
@@ -1356,6 +1461,7 @@
id="org.eclipse.cdt.ui.pdomSearchViewPage"
searchResultClass="org.eclipse.cdt.internal.ui.search.PDOMSearchResult"/>
</extension>
+
<extension
point="org.eclipse.ui.propertyPages">
<page
@@ -1501,7 +1607,7 @@
class="org.eclipse.cdt.internal.ui.text.contentassist.PDOMCompletionContributor"
id="PDOM"
priority="3"/-->
- </extension>
+ </extension>
<extension
point="org.eclipse.cdt.ui.completionProposalComputer"
@@ -1704,7 +1810,7 @@
overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions">
<enablement>
<or>
- <instanceof value="org.eclipse.cdt.core.model.ICElement" />
+ <instanceof value="org.eclipse.cdt.core.model.ICElement" />
<instanceof value="org.eclipse.core.resources.IResource" />
</or>
</enablement>
@@ -1716,7 +1822,7 @@
wizardId="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
<enablement>
<or>
- <instanceof value="org.eclipse.cdt.core.model.ICElement" />
+ <instanceof value="org.eclipse.cdt.core.model.ICElement" />
<adapt type="org.eclipse.core.resources.IProject">
<test
property="org.eclipse.core.resources.projectNature"
@@ -1732,7 +1838,7 @@
wizardId="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
<enablement>
<or>
- <instanceof value="org.eclipse.cdt.core.model.ICElement" />
+ <instanceof value="org.eclipse.cdt.core.model.ICElement" />
<adapt type="org.eclipse.core.resources.IProject">
<test
property="org.eclipse.core.resources.projectNature"
@@ -1748,7 +1854,7 @@
wizardId="org.eclipse.cdt.ui.wizards.NewSourceFolderCreationWizard">
<enablement>
<or>
- <instanceof value="org.eclipse.cdt.core.model.ICElement" />
+ <instanceof value="org.eclipse.cdt.core.model.ICElement" />
<adapt type="org.eclipse.core.resources.IProject">
<test
property="org.eclipse.core.resources.projectNature"
@@ -1764,7 +1870,7 @@
wizardId="org.eclipse.cdt.ui.wizards.NewClassCreationWizard">
<enablement>
<or>
- <instanceof value="org.eclipse.cdt.core.model.ICElement" />
+ <instanceof value="org.eclipse.cdt.core.model.ICElement" />
<adapt type="org.eclipse.core.resources.IProject">
<test
property="org.eclipse.core.resources.projectNature"
@@ -1830,4 +1936,20 @@
viewerId="org.eclipse.ui.navigator.ProjectExplorer"/>
</extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ id="org.eclipse.cdt.Tester1"
+ class="org.eclipse.cdt.ui.newui.PropertyTester"
+ namespace="org.eclipse.cdt.ui"
+ properties="isSource"
+ type="org.eclipse.cdt.core.model.ITranslationUnit"/>
+ <propertyTester
+ id="org.eclipse.cdt.Tester2"
+ class="org.eclipse.cdt.ui.newui.PropertyTester"
+ namespace="org.eclipse.cdt.ui"
+ properties="isSource"
+ type="org.eclipse.core.resources.IFile"/>
+ </extension>
+
</plugin>
diff --git a/core/org.eclipse.cdt.ui/schema/cPropertyTab.exsd b/core/org.eclipse.cdt.ui/schema/cPropertyTab.exsd
new file mode 100644
index 00000000000..6845e596727
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/schema/cPropertyTab.exsd
@@ -0,0 +1,221 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.ui" id="cPropertyTab" name="cPropertyTab"/>
+ </appInfo>
+ <documentation>
+ Implementation of property/preference UI element.
+
+There&apos;re 2 ways to display property/preference data:
+either on pages with tabs, or on simple pages.
+
+In first case, each cPropertyTab extending class
+represents single tab in tabfolder.
+In second case, cPropertyTab extending class
+represents whole page contents (except header
+elements which are common for all pages).
+
+Note that cPropertyTab extending class (&quot;tabs&quot; below) do not
+distinguish these 2 cases, moreover, they may be shown both
+in multi-tab and single-tab mode. It&apos;s up to page to select
+displaying mode.
+
+In multi-tab page, tabs are displayed in order defined by
+their weights.
+
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="tab" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="tab">
+ <complexType>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+ Icon to be displayed for corresponding tab in tabfolder.
+Ignored for single-tab pages
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Class implementing org.eclipse.cdt.managedbuilder.ui.newproperties.ICPropertyTab
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.ui.newproperties.ICPropertyTab"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ Name of tab in tabfolder.
+Ignored for single-tab pages.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="parent" type="string" use="required">
+ <annotation>
+ <documentation>
+ Class name for container page.
+Usually pages are to be derived from
+org.eclipse.cdt.ui.newui.AbstractPage,
+but it is not obligatory.
+
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="tooltip" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="weight" type="string">
+ <annotation>
+ <documentation>
+ Abstract value to be used for sorting tabs inside of tab folder.
+Ignored for single-tab page.
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 4.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;extension
+ point=&quot;org.eclipse.cdt.ui.cPropertyTab&quot;&gt;
+ &lt;tab
+ class=&quot;org.eclipse.cdt.managedbuilder.ui.newui.DiscoveryTab&quot;
+ icon=&quot;icons/elcl16/discovery.gif&quot;
+ name=&quot;Discovery options&quot;
+ weight=&quot;100&quot;
+ parent=&quot;org.eclipse.cdt.ui.newui.Page_PathAndSymb&quot;/&gt;
+ &lt;/entension&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ Tabs must implement interface:
+org.eclipse.cdt.managedbuilder.ui.newproperties.ICPropertyTab
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ Implementors in org.eclipse.cdt.ui.newui:
+BinaryParsTab
+CLocationOutputTab
+CLocationSourceTab
+CLocationTab
+EnvironmentTab
+ErrorParsTab
+ExpIncludeTab
+ExpLibraryPathTab
+ExpLibraryTab
+ExpSymbolTab
+ICPropertyTab
+IncludeTab
+LanguagesTab
+LibraryPathTab
+LibraryTab
+RefsTab
+SDKsTab
+SymbolTab
+
+Implementors in org.eclipse.cdt.managedbuilder.ui.newui:
+ArtifactTab
+BuilderSettingsTab
+BuildStepsTab
+CBuildLocationOutputTab
+CPropertyVarsTab
+DiscoveryTab
+ToolChainEditTab
+ToolSettingsTab
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ /*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/core/org.eclipse.cdt.ui/schema/newCfgDialog.exsd b/core/org.eclipse.cdt.ui/schema/newCfgDialog.exsd
new file mode 100644
index 00000000000..da63547fd4e
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/schema/newCfgDialog.exsd
@@ -0,0 +1,143 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.ui" id="newCfgDialog" name="newCfgDialog"/>
+ </appInfo>
+ <documentation>
+ Contributions to this extension point define specific dialog for new configuration creation. This dialog will be called from &quot;Manage configurations&quot; screen instead of standard (independent of managed build system) dialog. &lt;br&gt;
+Contributed extension is usually provided with whole managed build system (MBS), so new dialog may be able to handle some MBS-specific features.&lt;br&gt;
+To disinguish numerous dialogs for separate MBSs, mbs_id element should be the same as corresponding MBS Id.
+
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="dialog" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="dialog">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ class - New configuration dialog class.&lt;br&gt;
+Should implement org.eclipse.cdt.ui.newui.INewCfgDialog interface
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.newui.INewCfgDialog"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="title" type="string" use="required">
+ <annotation>
+ <documentation>
+ title - initial title of New configuration dialog.
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="mbs_id" type="string" use="required">
+ <annotation>
+ <documentation>
+ This element should contain ID of corresponding managed buld system (MBS).&lt;br&gt;
+Dialog will be displayed only if MBS Id for current project equals to mbs_id.
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 4.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;extension
+ point=&quot;org.eclipse.cdt.ui.newCfgDialog&quot;&gt;
+ &lt;dialog
+ class=&quot;org.eclipse.cdt.managedbuilder.ui.newui.NewCfgDialog&quot;
+ mbs_id=&quot;org.eclipse.cdt.managedbuilder.core.configurationDataProvider&quot;
+ title=&quot;MBS: create configuration&quot;/&gt;
+ &lt;/extension&gt;
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ &quot;class&quot; element should implement org.eclipse.cdt.ui.newui.INewCfgDialog interface
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ org.eclipse.cdt.managedbuilder.ui.newui.NewCfgDialog
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ /*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
index 5dd80daf44b..3f3ac63aeb8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
@@ -145,7 +145,7 @@ public class CPluginImages {
public static final ImageDescriptor DESC_OBJS_PROTECTED_FIELD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_FIELD);
public static final ImageDescriptor DESC_OBJS_PRIVATE_FIELD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_FIELD);
public static final ImageDescriptor DESC_OBJS_KEYWORD= createManaged(T_OBJ, IMG_OBJS_KEYWORD);
-
+
public static final ImageDescriptor DESC_OBJS_CLASS_ALT= createManaged(T_OBJ, IMG_OBJS_CLASS_ALT);
public static final ImageDescriptor DESC_OBJS_STRUCT_ALT= createManaged(T_OBJ, IMG_OBJS_STRUCT_ALT);
public static final ImageDescriptor DESC_OBJS_UNION_ALT= createManaged(T_OBJ, IMG_OBJS_UNION_ALT);
@@ -233,6 +233,11 @@ public class CPluginImages {
public static final String IMG_LCL_SUPER_TYPE_HIERARCHY= NAME_PREFIX + "super_co.gif"; //$NON-NLS-1$
public static final String IMG_LCL_SHOW_INHERITED_MEMBERS= NAME_PREFIX + "inher_co.gif"; //$NON-NLS-1$
+ public static final String IMG_FILESYSTEM= NAME_PREFIX + "filesyst.gif"; //$NON-NLS-1$
+ public static final String IMG_WORKSPACE = NAME_PREFIX + "workspace.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_FILESYSTEM = createManaged(T_OBJ, IMG_FILESYSTEM);
+ public static final ImageDescriptor DESC_WORKSPACE = createManaged(T_OBJ, IMG_WORKSPACE);
+
public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif"); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
index df890d276d9..7f44003eaf4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
@@ -11,9 +11,11 @@
package org.eclipse.cdt.internal.ui.viewsupport;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IBaseLabelProvider;
@@ -28,10 +30,14 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -86,7 +92,8 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
private static final int ERRORTICK_WARNING= CElementImageDescriptor.WARNING;
private static final int ERRORTICK_ERROR= CElementImageDescriptor.ERROR;
-
+ private static final int TICK_CONFIGURATION = CElementImageDescriptor.SYSTEM_INCLUDE;
+
private ImageDescriptorRegistry fRegistry;
private boolean fUseNewRegistry= false;
private IProblemChangedListener fProblemChangedListener;
@@ -154,9 +161,9 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
switch (type) {
case ICElement.C_PROJECT:
case ICElement.C_CCONTAINER:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
+ return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null) | hasOwnConfig(element);
case ICElement.C_UNIT:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
+ return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null) | hasOwnConfig(element);
case ICElement.C_FUNCTION:
case ICElement.C_CLASS:
case ICElement.C_UNION:
@@ -351,11 +358,33 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
*/
public void decorate(Object element, IDecoration decoration) {
int adornmentFlags= computeAdornmentFlags(element);
+
+ if ((adornmentFlags & TICK_CONFIGURATION) != 0) {
+ decoration.addOverlay(CPluginImages.DESC_OVR_SYSTEM_INCLUDE);
+ adornmentFlags &= ~TICK_CONFIGURATION;
+ }
+
if (adornmentFlags == ERRORTICK_ERROR) {
decoration.addOverlay(CPluginImages.DESC_OVR_ERROR);
} else if (adornmentFlags == ERRORTICK_WARNING) {
decoration.addOverlay(CPluginImages.DESC_OVR_WARNING);
- }
+ }
}
+ private int hasOwnConfig (ICElement element) {
+ IResource r = element.getResource();
+ if (r == null || r instanceof IProject) return 0;
+ IPath path = r.getProjectRelativePath();
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(r.getProject(), false);
+ if (prjd != null) {
+ ICConfigurationDescription [] cf = prjd.getConfigurations();
+ if (cf == null) return 0;
+ for (int i=0; i<cf.length; i++) {
+ ICResourceDescription out = cf[i].getResourceDescription(path, true);
+ if (out != null) return TICK_CONFIGURATION;
+ }
+ }
+ return 0;
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java
index 17320307c72..0bdf0225c62 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java
@@ -255,16 +255,16 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
// x-= data.width;
// drawImage(data, x, size.y - data.height);
// }
- }
+ }
private void drawTopLeft() {
ImageData data= null;
if ((fFlags & DEFINES) != 0) {
data= CPluginImages.DESC_OVR_DEFINES.getImageData();
drawImage(data, 0, 0);
- }
+ }
}
-
+
private void drawBottomLeft() {
Point size= getSize();
int x= 0;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
index efab7985c47..65da9f7cff9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
@@ -199,7 +199,7 @@ public class CUIPlugin extends AbstractUIPlugin {
* @since 2.0
*/
public static final String ID_CELEMENT_CREATION_ACTION_SET= "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$
-
+
/**
* The id of the scope used by all the CDT views
* (value <code>"org.eclipse.cdt.ui.scope"</code>).
@@ -367,7 +367,7 @@ public class CUIPlugin extends AbstractUIPlugin {
public CUIPlugin() {
fgCPlugin = this;
fDocumentProvider = null;
- fTextTools = null;
+ fTextTools = null;
fBuildConsoleManagers = new HashMap();
}
@@ -426,7 +426,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public IBuildConsoleManager getConsoleManager() {
return getConsoleManager(getResourceString("BuildConsole.name"), BuildConsoleManager.DEFAULT_CONTEXT_MENU_ID); //$NON-NLS-1$
- }
+ }
/**
* Return a console manager specified by id.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
index 14ea99b153d..0f0ddce35a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.internal.ui.text.ICColorConstants;
* preference store programmatically.
*
* @since 2.0
- */
+ */
public class PreferenceConstants {
private PreferenceConstants() {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildConfigAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java
index e72eba8bd0b..a28ade6afb8 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/BuildConfigAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java
@@ -8,14 +8,19 @@
* Contributors:
* Intel Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.actions;
+package org.eclipse.cdt.ui.actions;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
-import org.eclipse.cdt.managedbuilder.core.*;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+
/**
* Action which changes active build configuration of the current project to
* the given one.
@@ -37,27 +42,25 @@ public class BuildConfigAction extends Action {
fConfigName = configName;
}
-
-
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
Iterator iter = fProjects.iterator();
while (iter.hasNext()) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)iter.next());
- if (info != null && info.isValid()) {
- IConfiguration[] configs = info.getManagedProject().getConfigurations();
- int i = 0;
- for (; i < configs.length; i++) {
+ IProject prj = (IProject)iter.next();
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, true);
+ ICConfigurationDescription[] configs = prjd.getConfigurations();
+ if (configs != null && configs.length > 0) {
+ for (int i = 0; i < configs.length; i++) {
if (configs[i].getName().equals(fConfigName)) {
+ configs[i].setActive();
+ try {
+ CoreModel.getDefault().setProjectDescription(prj, prjd);
+ } catch (CoreException e) { }
break;
}
}
- if (i != configs.length) {
- info.setDefaultConfiguration(configs[i]);
- info.setSelectedConfiguration(configs[i]);
- }
}
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigActionBase.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java
index 281648b8ffa..c6f395abdbb 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigActionBase.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Intel Corporation and others.
+ * Copyright (c) 2006, 2007 Intel 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
@@ -8,17 +8,26 @@
* Contributors:
* Intel Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.actions;
+package org.eclipse.cdt.ui.actions;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.TreeSet;
-import org.eclipse.cdt.core.model.*;
-import org.eclipse.cdt.managedbuilder.core.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
/**
* Base class for build configuration actions.
@@ -35,37 +44,34 @@ public class ChangeBuildConfigActionBase {
* @param menu The menu to fill
*/
protected void fillMenu(Menu menu) {
- if (menu == null) {
- // This should not happen
- return;
- }
-
+ // This should not happen
+ if (menu == null) return;
+
MenuItem[] items = menu.getItems();
- for (int i = 0; i < items.length; i++) {
- items[i].dispose();
- }
+ for (int i = 0; i < items.length; i++) items[i].dispose();
TreeSet configNames = new TreeSet();
Iterator projIter = fProjects.iterator();
String sCurrentConfig = null;
boolean bCurrentConfig = true;
while (projIter.hasNext()) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
- if (info != null && info.isValid()) {
- if (bCurrentConfig) {
- String sNewConfig = info.getDefaultConfiguration().getName();
- if (sCurrentConfig == null) {
- sCurrentConfig = sNewConfig;
- }
- else {
- if (!sCurrentConfig.equals(sNewConfig)) {
- bCurrentConfig = false;
- }
- }
- }
- IConfiguration[] configs = info.getManagedProject().getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- configNames.add(configs[i].getName());
+ ICConfigurationDescription[] cfgDescs = getCfgs((IProject)projIter.next());
+
+ String sActiveConfig = null;
+ // Store names and detect active configuration
+ for (int i=0; i<cfgDescs.length; i++) {
+ configNames.add(cfgDescs[i].getName());
+ if (cfgDescs[i].isActive())
+ sActiveConfig = cfgDescs[i].getName();
+ }
+
+ // Check whether all projects have the same active configuration
+ if (bCurrentConfig) {
+ if (sCurrentConfig == null)
+ sCurrentConfig = sActiveConfig;
+ else {
+ if (!sCurrentConfig.equals(sActiveConfig))
+ bCurrentConfig = false;
}
}
}
@@ -80,32 +86,29 @@ public class ChangeBuildConfigActionBase {
boolean commonDesc = true;
boolean firstProj = true;
while (projIter.hasNext()) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo((IProject)projIter.next());
- if (info != null && info.isValid()) {
- IConfiguration[] configs = info.getManagedProject().getConfigurations();
- int i = 0;
- for (; i < configs.length; i++) {
- if (configs[i].getName().equals(sName)) {
- String sNewDesc = configs[i].getDescription();
- if (sNewDesc.equals("")) { //$NON-NLS-1$
- sNewDesc = null;
- }
- if (commonDesc) {
- if (firstProj) {
- sDesc = sNewDesc;
- firstProj = false;
- } else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) {
- commonDesc = false;
- }
+ ICConfigurationDescription[] cfgDescs = getCfgs((IProject)projIter.next());
+ int i = 0;
+ for (; i < cfgDescs.length; i++) {
+ if (cfgDescs[i].getName().equals(sName)) {
+ String sNewDesc = cfgDescs[i].getDescription();
+ if (sNewDesc.equals("")) { //$NON-NLS-1$
+ sNewDesc = null;
+ }
+ if (commonDesc) {
+ if (firstProj) {
+ sDesc = sNewDesc;
+ firstProj = false;
+ } else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) {
+ commonDesc = false;
}
- break;
}
- }
- if (i == configs.length) {
- commonName = false;
break;
}
}
+ if (i == cfgDescs.length) {
+ commonName = false;
+ break;
+ }
}
if (commonName) {
StringBuffer builder = new StringBuffer(sName);
@@ -139,12 +142,10 @@ public class ChangeBuildConfigActionBase {
*/
protected void onSelectionChanged(IAction action, ISelection selection) {
fProjects.clear();
-
- if (!action.isEnabled()) {
- return;
- }
- boolean found = false;
+ if (!action.isEnabled()) return;
+
+ boolean badObject = false;
if (selection != null && selection instanceof IStructuredSelection) {
Iterator iter = ((IStructuredSelection)selection).iterator();
while (iter.hasNext()) {
@@ -152,52 +153,38 @@ public class ChangeBuildConfigActionBase {
IProject project = null;
if (selItem instanceof ICElement) {
ICProject cproject = ((ICElement)selItem).getCProject();
- if (cproject != null) {
- project = cproject.getProject();
- }
+ if (cproject != null) project = cproject.getProject();
}
else if (selItem instanceof IResource) {
project = ((IResource)selItem).getProject();
}
+ // Check whether the project is CDT project
if (project != null) {
- try {
- if (project != null && !project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
- project = null;
- }
- }
- catch (CoreException xE) {
- // do nothing
- }
+ ICConfigurationDescription[] tmp = getCfgs(project);
+ if (tmp == null || tmp.length == 0) project = null;
}
if (project != null) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- if (info != null && info.isValid()) {
- fProjects.add(project);
- }
+ fProjects.add(project);
} else {
- found = true;
+ badObject = true;
break;
}
}
}
boolean enable = false;
- if (!found && !fProjects.isEmpty()) {
+ if (!badObject && !fProjects.isEmpty()) {
Iterator iter = fProjects.iterator();
- IProject first = (IProject)iter.next();
- IConfiguration[] firstConfigs = ManagedBuildManager.getBuildInfo(first).getManagedProject().getConfigurations();
- for (int i = 0; i < firstConfigs.length; i++)
- {
+ ICConfigurationDescription[] firstConfigs = getCfgs((IProject)iter.next());
+ for (int i = 0; i < firstConfigs.length; i++) {
boolean common = true;
- iter = fProjects.iterator();
- while (iter.hasNext()) {
- IProject current = (IProject)iter.next();
- IConfiguration[] currentConfigs = ManagedBuildManager.getBuildInfo(current).getManagedProject().getConfigurations();
+ Iterator iter2 = fProjects.iterator();
+ while (iter2.hasNext()) {
+ ICConfigurationDescription[] currentConfigs = getCfgs((IProject)iter2.next());
int j = 0;
for (; j < currentConfigs.length; j++) {
- if (firstConfigs[i].getName().equals(currentConfigs[j].getName())) {
+ if (firstConfigs[i].getName().equals(currentConfigs[j].getName()))
break;
- }
}
if (j == currentConfigs.length) {
common = false;
@@ -212,4 +199,14 @@ public class ChangeBuildConfigActionBase {
}
action.setEnabled(enable);
}
+
+ private ICConfigurationDescription[] getCfgs(IProject prj) {
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
+ if (prjd == null) return null;
+ ICConfigurationDescription[] tmp = prjd.getConfigurations();
+ if (tmp == null) return null;
+ return prjd.getConfigurations();
+ }
+
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigContextAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java
index 99c8e607139..84a126c0567 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigContextAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java
@@ -8,13 +8,17 @@
* Contributors:
* Intel Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.actions;
+package org.eclipse.cdt.ui.actions;
-import org.eclipse.jface.action.*;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
/**
* This context menu action is used to change active build configuration for the project
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java
index e97fec062f2..20f4de2e550 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/ChangeBuildConfigMenuAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java
@@ -8,14 +8,16 @@
* Contributors:
* Intel Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.actions;
+package org.eclipse.cdt.ui.actions;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
/**
* Action which changes active build configuration of the current project
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java
new file mode 100644
index 00000000000..c4171e753c3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+import org.eclipse.ui.internal.WorkbenchPlugin;
+
+/**
+ * Action which changes active build configuration of the current project to
+ * the given one.
+ */
+public class DeleteResConfigsAction
+implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+
+ protected ArrayList objects = null;
+ private ArrayList outData = null;
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ objects = null;
+
+ if (!selection.isEmpty()) {
+ // case for context menu
+ if (selection instanceof IStructuredSelection) {
+ Object[] obs = ((IStructuredSelection)selection).toArray();
+ if (obs.length > 0) {
+ for (int i=0; i<obs.length; i++) {
+ IResource res = null;
+ // only folders and files may be affected by this action
+ if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit)
+ res = ((ICElement)obs[i]).getResource();
+ // project's configuration cannot be deleted
+ else if (obs[i] instanceof IResource && !(obs[i] instanceof IProject))
+ res = (IResource)obs[i];
+ if (res != null) {
+ IProject p = res.getProject();
+ if (!p.isOpen()) continue;
+ IPath path = res.getProjectRelativePath();
+ // getting description in read-only mode
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+ if (prjd == null) continue;
+ ICConfigurationDescription[] cfgds = prjd.getConfigurations();
+ if (cfgds == null || cfgds.length == 0) continue;
+ for (int j=0; j<cfgds.length; j++) {
+ ICResourceDescription rd = cfgds[j].getResourceDescription(path, true);
+ if (rd != null) {
+ if (objects == null) objects = new ArrayList();
+ objects.add(res);
+ break; // stop configurations scanning
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ action.setEnabled(objects != null);
+ }
+
+ public void run(IAction action) {
+ openDialog();
+ }
+
+
+ private void openDialog() {
+ if (objects == null || objects.size() == 0) return;
+ // create list of configurations to delete
+
+ ListSelectionDialog dialog = new ListSelectionDialog(
+ CUIPlugin.getActiveWorkbenchShell(),
+ objects,
+ createSelectionDialogContentProvider(),
+ new LabelProvider() {}, "Select configurations to delete"); //$NON-NLS-1$
+ dialog.setTitle("Delete resource configurations"); //$NON-NLS-1$
+ if (dialog.open() == Window.OK) {
+ Object[] selected = dialog.getResult();
+ if (selected != null && selected.length > 0) {
+ for (int i = 0; i < selected.length; i++) {
+ ((ResCfgData)selected[i]).delete();
+ }
+ WorkbenchPlugin.getDefault().getDecoratorManager().updateForEnablementChange();
+ }
+ }
+ }
+
+ // Stores data for resource description with its "parents".
+ class ResCfgData {
+ IResource res;
+ ICProjectDescription prjd;
+ ICConfigurationDescription cfgd;
+ ICResourceDescription rdesc;
+
+ public ResCfgData(IResource res2, ICProjectDescription prjd2,
+ ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) {
+ res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2;
+ }
+
+ // performs deletion
+ public void delete() {
+ try {
+ cfgd.removeResourceDescription(rdesc);
+ CoreModel.getDefault().setProjectDescription(res.getProject(), prjd);
+ } catch (CoreException e) {}
+ }
+ public String toString() {
+ return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+
+ private IStructuredContentProvider createSelectionDialogContentProvider() {
+ return new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (outData != null) return outData.toArray();
+
+ outData = new ArrayList();
+ List ls = (List)inputElement;
+ Iterator it = ls.iterator();
+ IProject proj = null;
+ ICProjectDescription prjd = null;
+ ICConfigurationDescription[] cfgds = null;
+
+ // creating list of all res descs for all objects
+ while (it.hasNext()) {
+ IResource res = (IResource)it.next();
+ IPath path = res.getProjectRelativePath();
+ if (res.getProject() != proj) {
+ proj = res.getProject();
+ prjd = CoreModel.getDefault().getProjectDescription(proj);
+ cfgds = prjd.getConfigurations();
+ }
+ for (int i=0; i< cfgds.length; i++) {
+ ICResourceDescription rd = cfgds[i].getResourceDescription(path, true);
+ if (rd != null)
+ outData.add(new ResCfgData(res, prjd, cfgds[i], rd));
+ }
+ }
+ return outData.toArray();
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ };
+ }
+
+ public void dispose() { objects = null; }
+
+ // doing nothing
+ public void init(IWorkbenchWindow window) { }
+ public Menu getMenu(Menu parent) { return null; }
+ public Menu getMenu(Control parent) { return null; }
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java
new file mode 100644
index 00000000000..7b1284ef14a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.newui.ManageConfigDialog;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+
+/**
+ * Action which changes active build configuration of the current project to
+ * the given one.
+ */
+public class ManageConfigsAction
+implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+
+ protected IProject project = null;
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ project = null;
+ if (!selection.isEmpty()) {
+ // case for context menu
+ if (selection instanceof StructuredSelection) {
+ Object[] obs = ((StructuredSelection)selection).toArray();
+ for (int i=0; i<obs.length; i++) {
+ if (!getProject(obs[i])) break;
+ }
+ }
+ }
+ action.setEnabled(project != null);
+ }
+
+ protected boolean getProject(Object ob) {
+ IProject prj = null;
+
+ // Extract project from selection
+ if (ob instanceof ICElement) { // for C/C++ view
+ prj = ((ICElement)ob).getCProject().getProject();
+ } else if (ob instanceof IResource) { // for other views
+ prj = ((IResource)ob).getProject();
+ }
+
+ if (prj != null) {
+ // 2 or more projects selected - cannot handle
+ if (project != null && project != prj) {
+ project = null;
+ return false;
+ }
+ // only New CDT model projects can be handled
+ if (isManaged(prj)) project = prj;
+ return true;
+ }
+ return false;
+ }
+
+ // Check for project type.
+ private boolean isManaged(IProject p) {
+ if (!p.isOpen()) return false;
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+ if (prjd != null) {
+ ICConfigurationDescription[] c = prjd.getConfigurations();
+ if (c != null && c.length > 0) return true;
+ }
+ return false;
+ }
+
+ public void run(IAction action) {
+ if (project != null)
+ ManageConfigDialog.manage(project);
+ }
+
+ public void dispose() { project = null; }
+
+ // doing nothing
+ public void init(IWorkbenchWindow window) { }
+ public Menu getMenu(Menu parent) { return null; }
+ public Menu getMenu(Control parent) { return null; }
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java
index 5324405f449..3f77bb013a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java
@@ -13,12 +13,6 @@ package org.eclipse.cdt.ui.dialogs;
import java.io.File;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.ICExtensionReference;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -41,6 +35,13 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
/**
* Abstract base binary parser page for GNU binutils based binary parsers
*/
@@ -69,8 +70,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage {
monitor.beginTask(CUIMessages.getString("BinaryParserPage.task.savingAttributes"), 1); //$NON-NLS-1$
IProject proj = getContainer().getProject();
if (proj != null) {
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
if (cext.length > 0) {
initializeParserId();
for (int i = 0; i < cext.length; i++) {
@@ -238,8 +238,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage {
IProject proj = getContainer().getProject();
if (proj != null) {
try {
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
if (cext.length > 0) {
initializeParserId();
for (int i = 0; i < cext.length; i++) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
index a026c157b9a..d56ce068869 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
@@ -18,21 +18,6 @@ import java.util.Map;
import java.util.StringTokenizer;
import java.util.Map.Entry;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.ICDescriptorOperation;
-import org.eclipse.cdt.core.ICExtensionReference;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.util.PixelConverter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -49,6 +34,23 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICDescriptorOperation;
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.util.PixelConverter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
public class BinaryParserBlock extends AbstractBinaryParserPage {
private static final int DEFAULT_HEIGHT = 160;
@@ -274,8 +276,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage {
if (getContainer().getProject() != null) {
try {
- ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(getContainer().getProject(), true);
- ICExtensionReference[] ref = desc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ ICExtensionReference[] ref = CCorePlugin.getDefault().getBinaryParserExtensions(getContainer().getProject());
initialSelected = new ArrayList(ref.length);
for (int i = 0; i < ref.length; i++) {
if (configMap.get(ref[i].getID()) != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
index cb51534df02..7d851698c3f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
@@ -13,12 +13,6 @@ package org.eclipse.cdt.ui.dialogs;
import java.io.File;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.ICExtensionReference;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -41,6 +35,13 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
/**
*/
public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
@@ -74,8 +75,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
IProject proj = getContainer().getProject();
if (proj != null) {
String parserID = ""; //$NON-NLS-1$
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
if (cext.length > 0) {
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
IConfigurationElement[] infos = point.getConfigurationElements();
@@ -328,8 +328,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
IProject proj = getContainer().getProject();
if (proj != null) {
try {
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
if (cext.length > 0) {
addr2line = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$;
cppfilt = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
index fb21d7411ea..b4cb8d8b227 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
@@ -20,7 +20,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -62,8 +61,7 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
}
if (proj != null) {
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
if (cext.length > 0) {
for (int i = 0; i < cext.length; i++) {
// String id = cext[i].getID();
@@ -141,8 +139,7 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
public void loadPersistedValues(IProject project) throws CoreException {
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(project);
if (cext.length > 0) {
for (int i = 0; i < cext.length; i++) {
// String id = cext[i].getID();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java
index af7c2d3df89..7eb2d8e826d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java
@@ -13,12 +13,6 @@ package org.eclipse.cdt.ui.dialogs;
import java.io.File;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.ICExtensionReference;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -41,6 +35,13 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
/**
*/
public class MachOBinaryParserPage extends AbstractCOptionPage {
@@ -65,8 +66,7 @@ public class MachOBinaryParserPage extends AbstractCOptionPage {
IProject proj = getContainer().getProject();
if (proj != null) {
String parserID = ""; //$NON-NLS-1$
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
if (cext.length > 0) {
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
IConfigurationElement[] infos = point.getConfigurationElements();
@@ -183,8 +183,7 @@ public class MachOBinaryParserPage extends AbstractCOptionPage {
IProject proj = getContainer().getProject();
if (proj != null) {
try {
- ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
if (cext.length > 0) {
cppfilt = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
new file mode 100644
index 00000000000..2ae650a0382
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
@@ -0,0 +1,488 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.dialogs.ListDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+
+/**
+ * It is a parent for all standard property tabs
+ * in new CDT model.
+ *
+ * Although it's enougth for new tabs to implement
+ * ICPropertyTab interface only, it would be better
+ * to extend them from this class.
+ *
+ * In this case, we'll able to use:
+ * - a lot of utility methods via "provider" link.
+ * In particular, it allows to get current project,
+ * configuration etc. See ICPropertyProvider interface.
+ * - a standard way to create buttons (ins/edit/del etc)
+ * and to handle their events (see buttonPressed(int))
+ * - several utility methods to create widgets in the
+ * uniform manner (setupLabel(), setupText() etc).
+ * - means to handle control messages which are the main
+ * communication way for new CDT model pages and tabs.
+ */
+public abstract class AbstractCPropertyTab implements ICPropertyTab {
+ public static final int BUTTON_WIDTH = 100; // used as hint for all push buttons
+
+ // commonly used button names
+ public static final String EMPTY_STR = ""; //$NON-NLS-1$
+ public static final String ADD_STR = NewUIMessages.getResourceString("FileListControl.add"); //$NON-NLS-1$
+ public static final String DEL_STR = NewUIMessages.getResourceString("FileListControl.delete"); //$NON-NLS-1$
+ public static final String EDIT_STR = NewUIMessages.getResourceString("FileListControl.edit"); //$NON-NLS-1$
+ public static final String MOVEUP_STR = NewUIMessages.getResourceString("FileListControl.moveup"); //$NON-NLS-1$
+ public static final String MOVEDOWN_STR = NewUIMessages.getResourceString("FileListControl.movedown"); //$NON-NLS-1$
+ public static final String WORKSPACEBUTTON_NAME = NewUIMessages.getResourceString("FileListControl.button.workspace"); //$NON-NLS-1$
+ public static final String FILESYSTEMBUTTON_NAME = NewUIMessages.getResourceString("FileListControl.button.fs"); //$NON-NLS-1$
+ public static final String VARIABLESBUTTON_NAME = "Variables..."; //$NON-NLS-1$
+ public static final String FILESYSTEM_DIR_DIALOG_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.fs.dir.dlg.msg"); //$NON-NLS-1$
+ public static final String FILESYSTEM_FILE_DIALOG_TITLE = ""; //$NON-NLS-1$
+ public static final String WORKSPACE_DIR_DIALOG_TITLE = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.dir.dlg.title"); //$NON-NLS-1$
+ public static final String WORKSPACE_FILE_DIALOG_TITLE = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.title"); //$NON-NLS-1$
+ public static final String WORKSPACE_DIR_DIALOG_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.dir.dlg.msg"); //$NON-NLS-1$
+ public static final String WORKSPACE_FILE_DIALOG_MSG = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.msg"); //$NON-NLS-1$
+ public static final String WORKSPACE_FILE_DIALOG_ERR = NewUIMessages.getResourceString("BrowseEntryDialog.wsp.file.dlg.err"); //$NON-NLS-1$
+
+ protected Composite usercomp; // space where user can create widgets
+ protected Composite buttoncomp; // space for buttons on the right
+ private Button[] buttons; // buttons in buttoncomp
+ public ICPropertyProvider page;
+ protected Image icon = null;
+
+ protected boolean visible;
+
+ public void createControls(Composite _parent, ICPropertyProvider _provider) {
+ page = _provider;
+ createControls(_parent);
+ }
+
+ /**
+ * Creates basic widgets for property tab.
+ * Descendants should, normally, override
+ * this method but call super.createControls().
+ *
+ * @param parent
+ */
+ protected void createControls(Composite parent) {
+ parent.setLayout(new GridLayout(2, false));
+ usercomp = new Composite(parent, SWT.NONE);
+ usercomp.setLayoutData(new GridData(GridData.FILL_BOTH));
+ buttoncomp = new Composite(parent, SWT.NONE);
+ GridData d = new GridData(GridData.END);
+ d.widthHint = 1;
+ buttoncomp.setLayoutData(d);
+ }
+
+ /**
+ * The common way to create buttons cluster
+ * on the right of tab workspace.
+ * @param names : array of button names
+ * null instead of name means "skip place"
+ */
+ protected void initButtons(String[] names) {
+ initButtons(buttoncomp, names, 80);
+ }
+ protected void initButtons(String[] names, int width) {
+ initButtons(buttoncomp, names, width);
+ }
+
+ /**
+ * Ability to create standard button on any composite.
+ * @param c
+ * @param names
+ */
+ protected void initButtons(Composite c, String[] names) {
+ initButtons(c, names, 80);
+ }
+ protected void initButtons(Composite c, String[] names, int width) {
+ if (names == null || names.length == 0) return;
+ c.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ c.setLayout(new GridLayout(1, false));
+ buttons = new Button[names.length];
+ for (int i=0; i<names.length; i++) {
+ buttons[i] = new Button(c, SWT.PUSH);
+ GridData gdb = new GridData(GridData.VERTICAL_ALIGN_CENTER);
+ gdb.grabExcessHorizontalSpace = false;
+ gdb.horizontalAlignment = SWT.FILL;
+ gdb.widthHint = width;
+
+ if (names[i] != null)
+ buttons[i].setText(names[i]);
+ else { // no button, but placeholder !
+ buttons[i].setVisible(false);
+ buttons[i].setEnabled(false);
+ gdb.heightHint = 10;
+ }
+
+ buttons[i].setLayoutData(gdb);
+ buttons[i].addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ buttonPressed(event);
+ }});
+ }
+ }
+
+ /**
+ * Called when user changes
+ * @param cfg - selected configuration
+ */
+ private void configChanged(ICResourceDescription cfg) {
+ if (visible) updateData(cfg);
+ }
+
+ /**
+ * Disposes the SWT resources allocated by this
+ * dialog page.
+ */
+ public void dispose() {}
+
+ /**
+ * Sets the visibility of this property tab.
+ *
+ * @param _visible <code>true</code> to make this tab visible,
+ * and <code>false</code> to hide it
+ */
+ public void setVisible(boolean _visible) {
+ visible = _visible;
+ if (visible) updateData(page.getResDesc());
+ }
+
+ /**
+ * Descendant tabs should implement this method so
+ * that it copies it's data from one description
+ * to another. Only data affected by given tab
+ * should be copied.
+ *
+ * @param src
+ * @param dst
+ */
+ protected abstract void performApply(ICResourceDescription src, ICResourceDescription dst);
+ protected abstract void performDefaults();
+ protected abstract void updateData(ICResourceDescription cfg);
+ protected void performCancel() {}
+ protected void performOK() {}
+
+ /**
+ *
+ * @param e - event to be handled
+ */
+ private void buttonPressed(SelectionEvent e) {
+ for (int i=0; i<buttons.length; i++) {
+ if (buttons[i].equals(e.widget)) {
+ buttonPressed(i);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Method should be rewritten to handle button presses
+ * @param i : number of button pressed
+ *
+ * Does nothing by default.
+ * May (but not must) be overridden.
+ */
+ protected void buttonPressed(int i) {}
+
+ protected boolean buttonIsEnabled(int i) {
+ if (buttons == null || buttons.length <= i )
+ return false;
+ else
+ return buttons[i].isEnabled();
+ }
+
+ protected void buttonSetEnabled(int i, boolean state) {
+ if (buttons == null || buttons.length <= i ) return;
+ buttons[i].setEnabled(state);
+ }
+
+ /**********************************************
+ * Utility methods for unified widget creation
+ **********************************************/
+ protected Label setupLabel(Composite c, String name, int span, int mode) {
+ Label l = new Label(c, SWT.NONE);
+ l.setText(name);
+ setupControl(l, span, mode);
+ return l;
+ }
+
+ protected Button setupButton(Composite c, String name, int span, int mode) {
+ Button b = new Button(c, SWT.PUSH);
+ b.setText(name);
+ setupControl(b, span, mode);
+ GridData g = (GridData)b.getLayoutData();
+ g.widthHint = BUTTON_WIDTH;
+ g.horizontalAlignment = SWT.RIGHT;
+ b.setLayoutData(g);
+ return b;
+ }
+
+ protected Text setupText(Composite c, int span, int mode) {
+ Text t = new Text(c, SWT.SINGLE | SWT.BORDER);
+ setupControl(t, span, mode);
+ return t;
+ }
+
+ protected Group setupGroup(Composite c, String name, int cols, int mode) {
+ Group g = new Group(c, SWT.NONE);
+ g.setText(name);
+ g.setLayout(new GridLayout(cols, false));
+ setupControl(g, 1, mode);
+ return g;
+ }
+
+ protected Button setupCheck(Composite c, String name, int span, int mode) {
+ Button b = new Button(c, SWT.CHECK);
+ b.setText(name);
+ setupControl(b, span, mode);
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ checkPressed(event);
+ }});
+ return b;
+ }
+
+ /**
+ * Selection handler for checkbox created by method "setupCheck()"
+ * Descendants should override this method if they use "setupCheck".
+ * Usually the method body will look like:
+ * {
+ * Button b = (Button)e.widget;
+ * if (b.equals(myFirstCheckbox) { ... }
+ * else if (b.equals(mySecondCheckbox) { ... }
+ * ... }
+ */
+ protected void checkPressed(SelectionEvent e) {}
+
+ protected void setupControl(Control c, int span, int mode) {
+ // although we use GridLayout usually,
+ // exceptions can occur: do nothing.
+ if (span != 0) {
+ GridData gd = new GridData(mode);
+ gd.horizontalSpan = span;
+ c.setLayoutData(gd);
+ }
+ Composite p = c.getParent();
+ if (c != null) {
+ c.setFont(p.getFont());
+ }
+ }
+
+ /*
+ * A set of methods providing selection dialogs for files or dirs.
+ */
+
+ public static String getFileSystemDirDialog(Shell shell, String text) {
+ DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN|SWT.APPLICATION_MODAL);
+ if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+ dialog.setMessage(FILESYSTEM_DIR_DIALOG_MSG);
+ return dialog.open();
+ }
+
+ public static String getFileSystemFileDialog(Shell shell, String text) {
+ FileDialog dialog = new FileDialog(shell);
+ if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+ dialog.setFilterExtensions(new String[] {"*.a;*.so;*.dll;*.lib"}); //$NON-NLS-1$
+ dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
+ return dialog.open();
+ }
+
+ public static String getVariableDialog(Shell shell, ICConfigurationDescription cfgd) {
+
+ ICdtVariableManager vm = CCorePlugin.getDefault().getCdtVariableManager();
+
+ ListDialog dialog = new ListDialog(shell);
+ dialog.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) { return (Object[])inputElement; }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+ dialog.setLabelProvider(new ILabelProvider() {
+ public Image getImage(Object element) { return null; }
+ public String getText(Object element) {
+ if (element instanceof ICdtVariable)
+ return ((ICdtVariable)element).getName();
+ return null;
+ }
+ public void addListener(ILabelProviderListener listener) {}
+ public void dispose() {}
+ public boolean isLabelProperty(Object element, String property) { return false; }
+ public void removeListener(ILabelProviderListener listener) {
+ }});
+
+ dialog.setInput(vm.getVariables(cfgd));
+ dialog.setHeightInChars(10);
+ dialog.setTitle(NewUIMessages.getResourceString("AbstractCPropertyTab.0")); //$NON-NLS-1$
+
+ if (dialog.open() == Window.OK) {
+ Object[] selected = dialog.getResult();
+ if (selected.length > 0) {
+ String s = ((ICdtVariable)selected[0]).getName();
+ return "${"+s.trim()+"}"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+ return null;
+ }
+
+ public static String getWorkspaceDirDialog(Shell shell, String text) {
+ return getWorkspaceDialog(shell, text, true, null);
+ }
+ public static String getWorkspaceFileDialog(Shell shell, String text) {
+ return getWorkspaceDialog(shell, text, false, null);
+ }
+
+ private static String getWorkspaceDialog(Shell shell, String text, boolean dir, IProject prj) {
+ String currentPathText;
+ IPath path;
+ currentPathText = text;
+ /* Remove double quotes */
+ currentPathText = currentPathText.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ path = new Path(currentPathText);
+
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
+ new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+
+ if (prj == null)
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ else
+ dialog.setInput(prj);
+ dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+ if (dir) {
+ IResource container = null;
+ if(path.isAbsolute()){
+ IContainer cs[] = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(path);
+ if(cs != null && cs.length > 0)
+ container = cs[0];
+ }
+ dialog.setInitialSelection(container);
+ dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE);
+ dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG);
+ } else {
+ IResource resource = null;
+ if(path.isAbsolute()){
+ IFile fs[] = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(path);
+ if(fs != null && fs.length > 0)
+ resource = fs[0];
+ }
+ dialog.setInitialSelection(resource);
+ dialog.setValidator(new ISelectionStatusValidator() {
+ public IStatus validate(Object[] selection) {
+ if (selection != null)
+ if (selection.length > 0)
+ if (!(selection[0] instanceof IFile))
+ return new StatusInfo(IStatus.ERROR, WORKSPACE_FILE_DIALOG_ERR);
+ return new StatusInfo();
+ }
+ });
+ dialog.setTitle(WORKSPACE_FILE_DIALOG_TITLE);
+ dialog.setMessage(WORKSPACE_FILE_DIALOG_MSG);
+ }
+ if (dialog.open() == Window.OK) {
+ IResource resource = (IResource) dialog.getFirstResult();
+ if (resource != null) {
+ StringBuffer buf = new StringBuffer();
+ return buf.append("${").append("workspace_loc:").append(resource.getFullPath()).append("}").toString(); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ // shortcut to frequently-used method
+ public ICResourceDescription getResDesc() {
+ return page.getResDesc();
+ }
+
+ /**
+ * Common event handler: called by parent for each tab
+ */
+ public void handleTabEvent (int kind, Object data) {
+ switch(kind) {
+ case ICPropertyTab.OK:
+ if (canBeVisible()) performOK();
+ break;
+ case ICPropertyTab.APPLY:
+ if (canBeVisible()) performApply(getResDesc(), (ICResourceDescription)data);
+ break;
+ case ICPropertyTab.CANCEL:
+ if (canBeVisible()) performCancel();
+ break;
+ case ICPropertyTab.DEFAULTS:
+ if (canBeVisible() && getResDesc() != null) {
+ updateData(getResDesc());
+ performDefaults();
+ }
+ break;
+ case ICPropertyTab.UPDATE:
+ if (canBeVisible()) configChanged((ICResourceDescription)data);
+ break;
+ case ICPropertyTab.DISPOSE:
+ break;
+ case ICPropertyTab.VISIBLE:
+ if (canBeVisible()) setVisible(data != null);
+ break;
+ case ICPropertyTab.SET_ICON:
+ icon = (Image)data;
+ break;
+ default:
+ break;
+ }
+ }
+
+ // By default, returns true (no visibility restriction)
+ // But several pages should rewrite this functionality.
+ public boolean canBeVisible() {
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java
new file mode 100644
index 00000000000..e171586dd66
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java
@@ -0,0 +1,443 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+public abstract class AbstractExportTab extends AbstractCPropertyTab {
+ protected Table table;
+ protected TableViewer tv;
+ protected ICConfigurationDescription cfg;
+ protected static final LanguageManager lm = LanguageManager.getInstance();
+ protected static final IContentTypeManager ctm = Platform.getContentTypeManager();
+
+// protected boolean showBI = false;
+// boolean savedShowBI = false;
+// List incs;
+
+ private static final String ALL = "[All]"; //$NON-NLS-1$
+ private static final String LIST = "[List]"; //$NON-NLS-1$
+ private static final Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM);
+ private static final Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE);
+ private static final Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
+ private static Map names_l = new HashMap();
+ private static Map names_t = new HashMap();
+ private static String[] names_ls;
+ private static String[] names_ts;
+ private List namesList;
+
+ static {
+ ILanguage[] ls = lm.getRegisteredLanguages();
+ names_ls = new String[ls.length];
+ for (int i=0; i<ls.length; i++) {
+ names_l.put(ls[i].getName(), ls[i].getId());
+ names_ls[i] = ls[i].getName();
+ }
+ String[] ids = lm.getRegisteredContentTypeIds();
+ names_ts = new String[ids.length];
+ for (int i=0; i<ids.length; i++) {
+ IContentType ct = ctm.getContentType(ids[i]);
+ names_t.put(ct.getName(), ct.getId());
+ names_ts[i] = ct.getName();
+ }
+
+ }
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(2, false));
+ table = new Table(usercomp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 255;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ tv = new TableViewer(table);
+
+ tv.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return (Object[])inputElement;
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+
+ tv.setLabelProvider(new RichLabelProvider());
+
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setButtons();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ if (buttonIsEnabled(1) && table.getSelectionIndex() != -1)
+ buttonPressed(1);
+ }
+ });
+ TableColumn c = new TableColumn(table, SWT.NONE);
+ c.setWidth(hasValues() ? 100 : 200);
+ c.setText(NewUIMessages.getResourceString("EnvDialog.0")); //$NON-NLS-1$
+ c = new TableColumn(table, SWT.NONE);
+ c.setWidth(hasValues() ? 100 : 0);
+ c.setText(NewUIMessages.getResourceString("EnvDialog.1")); //$NON-NLS-1$
+ c = new TableColumn(table, SWT.NONE);
+ c.setWidth(100);
+ c.setText(NewUIMessages.getResourceString("LanguagesTab.1")); //$NON-NLS-1$
+ c = new TableColumn(table, SWT.NONE);
+ c.setWidth(100);
+ c.setText(NewUIMessages.getResourceString("LanguagesTab.0")); //$NON-NLS-1$
+
+ initButtons(new String[] {ADD_STR, EDIT_STR, DEL_STR});
+ updateData(getResDesc());
+ }
+
+
+ /**
+ * Updates state of add/edit/delete buttons
+ * Called when table selection changes.
+ */
+ protected void setButtons() {
+ int i = table.getSelectionIndex();
+ boolean x = i != -1;
+ boolean y = x;
+ if (x) {
+ ICLanguageSettingEntry ent = ((ExtData)(table.getItem(i).getData())).entry;
+ if (ent.isReadOnly()) x = false;
+ if (ent.isBuiltIn() || ent.isReadOnly()) y = false;
+ }
+ buttonSetEnabled(1, x);
+ buttonSetEnabled(2, y);
+ }
+
+ /*
+ * Methods to be implemented in descendants
+ */
+ public abstract int getKind();
+ public abstract ICLanguageSettingEntry doAdd(String s1, String s2);
+ public abstract ICLanguageSettingEntry doEdit(String s1, String s2);
+ public abstract boolean hasValues();
+
+ /**
+ * Called when item added/edited/removed.
+ * Refreshes whole table contwnts
+ */
+ public void update() {
+ int x = table.getSelectionIndex();
+ if (x == -1) x = 0;
+
+ namesList = new ArrayList();
+ ArrayList lst = new ArrayList();
+ ICExternalSetting[] vals = cfg.getExternalSettings();
+ if (vals == null || vals.length == 0) {
+ tv.setInput(null);
+ return;
+ }
+ for (int i=0; i<vals.length; i++) {
+ ICLanguageSettingEntry[] ents = vals[i].getEntries(getKind());
+ if (ents == null || ents.length == 0) continue;
+ for (int j=0; j<ents.length; j++) {
+ lst.add(new ExtData(vals[i], ents[j]));
+ namesList.add(ents[j].getName());
+ }
+ }
+ Collections.sort(lst, CDTListComparator.getInstance());
+ tv.setInput(lst.toArray(new Object[lst.size()]));
+ if (table.getItemCount() > x) table.select(x);
+ else if (table.getItemCount() > 0) table.select(0);
+ setButtons();
+ }
+
+ /**
+ * Called when configuration changed
+ * Refreshes languages list and calls table refresh.
+ */
+ public void updateData(ICResourceDescription rcfg) {
+ if (rcfg == null) return;
+ cfg = rcfg.getConfiguration();
+ update();
+ }
+ /**
+ * Unified "Add/Edit/Delete" buttons handler
+ */
+ public void buttonPressed(int i) {
+ ICLanguageSettingEntry[] ent = new ICLanguageSettingEntry[1];
+ ExtData old;
+ ExpDialog dlg;
+ int n = table.getSelectionIndex();
+
+ switch (i) {
+ case 0: // add
+ dlg = new ExpDialog(usercomp.getShell(), true,
+ "Create", EMPTY_STR, EMPTY_STR, cfg, //$NON-NLS-1$
+ null, null, getKind(), names_ls, names_ts, namesList);
+ if (dlg.open()) {
+ ent[0] = doAdd(dlg.text1.trim(), dlg.text2.trim());
+ if (ent[0] != null)
+ if (dlg.check1) { // apply to all ?
+ ICConfigurationDescription[] cfgs = page.getCfgsEditable();
+ for (int k=0; k<cfgs.length; k++)
+ cfgs[k].createExternalSetting(name2id(dlg.sel_langs, names_l),
+ name2id(dlg.sel_types, names_t), null, ent);
+ } else {
+ cfg.createExternalSetting(name2id(dlg.sel_langs, names_l),
+ name2id(dlg.sel_types, names_t), null, ent);
+ }
+ update();
+ }
+ break;
+ case 1: // edit
+ if (n == -1) return;
+ old = (ExtData)(table.getItem(n).getData());
+ if (old.entry.isReadOnly()) return;
+ String s1, s2;
+ if (getKind() == ICSettingEntry.MACRO) {
+ s1 = old.getName();
+ s2 = old.getValue();
+ } else
+ s1 = s2 = old.getName();
+
+ dlg = new ExpDialog(usercomp.getShell(), false,
+ "Edit", s1, s2, cfg, //$NON-NLS-1$
+ id2name(old.setting.getCompatibleLanguageIds(), names_l),
+ id2name(old.setting.getCompatibleContentTypeIds(), names_t),
+ getKind(), names_ls, names_ts, null);
+ if (dlg.open()) {
+ ent[0] = doEdit(dlg.text1.trim(), dlg.text2.trim());
+ ICLanguageSettingEntry[] ls = old.setting.getEntries(getKind());
+ ICLanguageSettingEntry[] ls2 = new ICLanguageSettingEntry[ls.length];
+ for (int x=0; x<ls.length; x++)
+ if (ls[x].equals(old.entry)) ls2[x] = ent[0];
+ else ls2[x] = ls[x];
+ cfg.removeExternalSetting(old.setting);
+ cfg.createExternalSetting(name2id(dlg.sel_langs, names_l), name2id(dlg.sel_types, names_t), null, ls2);
+ update();
+
+ }
+ break;
+ case 2: // delete
+ if (n == -1) return;
+ TableItem[] its = table.getSelection();
+ boolean checked[] = new boolean[its.length];
+ for (int t=0; t<its.length; t++) {
+ if (checked[t] || its[t] == null) continue;
+ old = (ExtData)(its[t].getData());
+ if (old.entry.isReadOnly() || old.entry.isBuiltIn()) continue;
+ ICLanguageSettingEntry[] ls = old.setting.getEntries(getKind());
+ ArrayList lst = new ArrayList();
+outer:
+ for (int x=0; x<ls.length; x++) {
+ for (int y=t; y<its.length; y++) {
+ if (its[y] == null) break;
+ Object ob = its[y].getData();
+ if (ob != null && (ob instanceof ExtData)) {
+ ExtData ex = (ExtData)ob;
+ if (ls[x].equals(ex.entry)) {
+ checked[y] = true;
+ continue outer;
+ }
+ }
+ }
+ lst.add(ls[x]);
+ }
+ cfg.removeExternalSetting(old.setting);
+ cfg.createExternalSetting(old.setting.getCompatibleLanguageIds(),
+ old.setting.getCompatibleContentTypeIds(),
+ old.setting.getCompatibleExtensions(),
+ (ICLanguageSettingEntry[])lst.toArray(new ICLanguageSettingEntry[lst.size()]));
+ }
+ update();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ public static String[] name2id(String[] ein, Map names) {
+ if (ein != null)
+ for (int k=0; k<ein.length; k++) ein[k] = (String)names.get(ein[k]);
+ return ein;
+ }
+
+ public static String[] id2name(String[] ein, Map names) {
+ if (ein != null)
+ for (int i=0; i<ein.length; i++) {
+ Iterator it = names.keySet().iterator();
+ while (it.hasNext()) {
+ String s = (String) it.next();
+ if (ein[i].equals(names.get(s))) {
+ ein[i] = s;
+ break;
+ }
+ }
+ }
+ return ein;
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ ICConfigurationDescription c1 = src.getConfiguration();
+ ICConfigurationDescription c2 = dst.getConfiguration();
+ c2.removeExternalSettings();
+ ICExternalSetting[] v = c1.getExternalSettings();
+ for (int i=0; i<v.length; i++)
+ cfg.createExternalSetting(v[i].getCompatibleLanguageIds(),
+ v[i].getCompatibleContentTypeIds(),
+ v[i].getCompatibleExtensions(), v[i].getEntries());
+ }
+
+ protected void performDefaults() {
+ cfg.removeExternalSettings();
+ updateData(this.getResDesc());
+ }
+
+ // Extended label provider
+ private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
+ public RichLabelProvider(){}
+ public Image getImage(Object element) {
+ return getColumnImage(element, 0);
+ }
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex > 0) return null;
+ ExtData data = (ExtData)element;
+ if (data.entry.getKind() == ICSettingEntry.MACRO)
+ return IMG_MK;
+ if ((data.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0)
+ return IMG_WS;
+ else
+ return IMG_FS;
+ }
+ public String getText(Object element) {
+ return getColumnText(element, 0);
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ ExtData data = (ExtData)element;
+ switch (columnIndex) {
+ case 0:
+ return data.getName();
+ case 1:
+ return data.getValue();
+ case 2:
+ return data.getLangStr();
+ case 3:
+ return data.getTypeStr();
+ default:
+ return EMPTY_STR;
+ }
+ }
+
+ public Font getFont(Object element) {
+ ExtData data = (ExtData)element;
+ if (data.entry.isBuiltIn()) return null; // built in
+ if (data.entry.isReadOnly()) // read only
+ return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+ else // normal
+ return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+ }
+ }
+
+ public boolean canBeVisible() {
+ if (! page.isForProject() ) return false;
+
+ return true;
+ /*
+ if (getResDesc() == null) return true;
+ ICLanguageSetting [] ls = getLangSetting(getResDesc());
+ for (int i=0; i<ls.length; i++) {
+ if ((ls[i].getSupportedEntryKinds() & getKind()) != 0)
+ return true;
+ }
+ return false;
+ */
+ }
+
+ /**
+ *
+ */
+ static class ExtData {
+ ICExternalSetting setting;
+ ICLanguageSettingEntry entry;
+
+ ExtData(ICExternalSetting _s, ICLanguageSettingEntry _e) {
+ setting = _s;
+ entry = _e;
+ }
+ protected String getName() {
+ return entry.getName();
+ }
+ protected String getValue() {
+ if (entry.getKind() == ICSettingEntry.MACRO)
+ return entry.getValue();
+ else
+ return EMPTY_STR;
+ }
+ protected String getLangStr() {
+ return getLabel(setting.getCompatibleLanguageIds(), names_l);
+ }
+ protected String getTypeStr() {
+ return getLabel(setting.getCompatibleContentTypeIds(), names_t);
+ }
+ }
+
+ static protected String getLabel(String[] lst, Map names) {
+ if (lst == null || lst.length == 0) return ALL;
+ if (lst.length > 1) return LIST;
+ Iterator it = names.keySet().iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+ if (names.get(s).equals(lst[0]))
+ return s;
+ }
+ return lst[0];
+ }
+ static protected String getList(String[] lst) {
+ String s = EMPTY_STR;
+ for (int i=0; i<lst.length; i++) s = s + lst[i] + '\n';
+ return s;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java
new file mode 100644
index 00000000000..a4c5d7be8c9
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java
@@ -0,0 +1,405 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+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.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
+ protected Table table;
+ protected TableViewer tv;
+ protected Tree langTree;
+ protected TreeColumn langCol;
+ protected Button showBIButton;
+ protected boolean toAll = false;
+
+// protected boolean showBI = false;
+// boolean savedShowBI = false;
+ protected ICLanguageSetting lang;
+ protected List incs;
+ protected List exported;
+
+ private final static Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM);
+ private final static Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE);
+ private final static Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(2, false));
+ addTree(usercomp).setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ table = new Table(usercomp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 255;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ tv = new TableViewer(table);
+
+ tv.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return (Object[])inputElement;
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+
+ tv.setLabelProvider(new RichLabelProvider());
+
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ if (buttonIsEnabled(1) && table.getSelectionIndex() != -1)
+ buttonPressed(1);
+ }
+ });
+ setupLabel(usercomp, EMPTY_STR, 1, 0);
+ showBIButton = setupCheck(usercomp, NewUIMessages.getResourceString("AbstractLangsListTab.0"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ showBIButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ update();
+ }
+ });
+ additionalTableSet();
+ initButtons(new String[] {ADD_STR, EDIT_STR, DEL_STR, NewUIMessages.getResourceString("AbstractLangsListTab.2")}); //$NON-NLS-1$
+ updateData(getResDesc());
+ }
+
+
+ /**
+ * Updates state of add/edit/delete buttons
+ * Called when table selection changes.
+ */
+ public void updateButtons() {
+ int i = table.getSelectionIndex();
+ boolean x = i != -1;
+ boolean y = x;
+ if (x) {
+ ICLanguageSettingEntry ent = (ICLanguageSettingEntry)(table.getItem(i).getData());
+ if (ent.isReadOnly()) x = false;
+ if (ent.isBuiltIn() || ent.isReadOnly()) y = false;
+ }
+ buttonSetEnabled(0, langTree.getItemCount() > 0);
+ buttonSetEnabled(1, x);
+ buttonSetEnabled(2, y);
+ }
+
+ private Tree addTree(Composite comp) {
+ langTree = new Tree(comp, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
+ langTree.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ langTree.setHeaderVisible(true);
+
+ langTree.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TreeItem[] items = langTree.getSelection();
+ if (items.length > 0) {
+ ICLanguageSetting ls = (ICLanguageSetting)items[0].getData();
+ if (ls != null) {
+ lang = ls;
+ update();
+ }
+ }
+ }});
+ langTree.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ int x = langTree.getBounds().width - 5;
+ if (langCol.getWidth() != x)
+ langCol.setWidth(x);
+ }});
+
+ langCol = new TreeColumn(langTree, SWT.NONE);
+ langCol.setText(NewUIMessages.getResourceString("AbstractLangsListTab.1")); //$NON-NLS-1$
+ langCol.setResizable(false);
+ return langTree;
+ }
+
+ /*
+ * Methods to be implemented in descendants
+ */
+ public abstract int getKind();
+ public abstract ICLanguageSettingEntry doAdd();
+ public abstract ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent);
+ public void additionalTableSet() {} // may be not overwritten
+
+ /**
+ * Called when language changed or item added/edited/removed.
+ * Refreshes whole table contwnts
+ */
+ public void update() {
+ if (lang != null) {
+ int x = table.getSelectionIndex();
+ if (x == -1) x = 0;
+
+ ArrayList lst = new ArrayList();
+
+ incs = lang.getSettingEntriesList(getKind());
+ if (incs == null) incs = new ArrayList(0);
+ Iterator it = incs.iterator();
+ boolean userOnly = !showBIButton.getSelection();
+
+ while (it.hasNext()) {
+ ICLanguageSettingEntry ent = (ICLanguageSettingEntry)it.next();
+
+ if (ent.isBuiltIn() && userOnly)
+ continue; // do not show built-in values
+ lst.add(ent);
+ }
+ Collections.sort(lst, CDTListComparator.getInstance());
+ tv.setInput(lst.toArray(new Object[lst.size()]));
+
+ if (table.getItemCount() > x) table.select(x);
+ else if (table.getItemCount() > 0) table.select(0);
+ }
+ updateButtons();
+ }
+
+ /**
+ * Called when configuration changed
+ * Refreshes languages list and calls table refresh.
+ */
+ public void updateData(ICResourceDescription cfg) {
+ if (cfg == null) return;
+ updateExport();
+ ICLanguageSetting []ls = getLangSetting(cfg);
+ Arrays.sort(ls, CDTListComparator.getInstance());
+ langTree.removeAll();
+ TreeItem firstItem = null;
+ for (int i=0; i<ls.length; i++) {
+ if ((ls[i].getSupportedEntryKinds() & getKind()) != 0) {
+ TreeItem t = new TreeItem(langTree, SWT.NONE);
+ t.setText(0, ls[i].getName());
+ t.setData(ls[i]);
+ if (firstItem == null) {
+ firstItem = t;
+ lang = ls[i];
+ }
+ }
+ }
+
+ if (firstItem != null && table != null) {
+ langTree.setSelection(firstItem);
+ }
+ update();
+ }
+
+ private void updateExport() {
+ exported = new ArrayList();
+ ICExternalSetting[] vals = getResDesc().getConfiguration().getExternalSettings();
+ if (!(vals == null || vals.length == 0)) {
+ for (int i=0; i<vals.length; i++) {
+ ICLanguageSettingEntry[] ents = vals[i].getEntries(getKind());
+ if (ents == null || ents.length == 0) continue;
+ for (int j=0; j<ents.length; j++)
+ exported.add(ents[j]);
+ }
+ }
+ }
+ /**
+ * Unified "Add/Edit/Delete" buttons handler
+ */
+ public void buttonPressed(int i) {
+ ICLanguageSettingEntry ent;
+ ICLanguageSettingEntry old;
+ int n = table.getSelectionIndex();
+
+ switch (i) {
+ case 0: // add
+ toAll = false;
+ ent = doAdd();
+ if (ent != null) {
+ if (toAll) {
+ addToAll(ent);
+ } else {
+ incs.add(ent);
+ lang.setSettingEntries(getKind(), incs);
+ }
+ update();
+ }
+ break;
+ case 1: // edit
+ if (n == -1) return;
+ old = (ICLanguageSettingEntry)(table.getItem(n).getData());
+ if (old.isReadOnly()) return;
+ ent = doEdit(old);
+ if (ent != null) {
+ incs.remove(old);
+ incs.add(ent);
+ lang.setSettingEntries(getKind(), incs);
+ update();
+ }
+ break;
+ case 2: // delete
+ if (n == -1) return;
+ old = (ICLanguageSettingEntry)(table.getItem(n).getData());
+ if (old.isReadOnly() || old.isBuiltIn()) return;
+ incs.remove(old);
+ lang.setSettingEntries(getKind(), incs);
+ update();
+ break;
+ case 3: // export
+ if (n == -1) return;
+ old = (ICLanguageSettingEntry)(table.getItem(n).getData());
+ page.getResDesc().getConfiguration().createExternalSetting(new String[] {lang.getId()}, null, null, new ICLanguageSettingEntry[] {old});
+ updateExport();
+ update();
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Adds entry to all configurations
+ * @param ent - entry to add
+ */
+ private void addToAll(ICLanguageSettingEntry ent) {
+ ICConfigurationDescription[] cfgs = page.getCfgsEditable();
+ String id = lang.getName(); // getLanguageId() sometimes returns null.
+ for (int i = 0; i < cfgs.length; i++) {
+ ICResourceDescription rcfg = page.getResDesc(cfgs[i]);
+ if (rcfg == null) continue;
+ ICLanguageSetting [] ls = getLangSetting(rcfg);
+ for (int j = 0; j < ls.length; j++ ) {
+ if (id == ls[j].getName()) {
+ List lst = ls[j].getSettingEntriesList(getKind());
+ lst.add(ent);
+ ls[j].setSettingEntries(getKind(), lst);
+ }
+ }
+ }
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ ICLanguageSetting [] sr = getLangSetting(src);
+ ICLanguageSetting [] ds = getLangSetting(dst);
+ if (sr == null || ds == null || sr.length != ds.length) return;
+ for (int i=0; i<sr.length; i++) {
+ ds[i].setSettingEntries(getKind(), sr[i].getSettingEntries(getKind()));
+ }
+ }
+ protected void performDefaults() {
+ lang.setSettingEntries(getKind(), new ArrayList());
+ updateData(this.getResDesc());
+ }
+
+ // Extended label provider
+ private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
+ public RichLabelProvider(){}
+ public Image getImage(Object element) {
+ return getColumnImage(element, 0);
+ }
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex > 0) return null;
+ if (! (element instanceof ICLanguageSettingEntry)) return null;
+ ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
+ if (le.getKind() == ICSettingEntry.MACRO)
+ return IMG_MK;
+ if ((le.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0)
+ return IMG_WS;
+ else
+ return IMG_FS;
+ }
+ public String getText(Object element) {
+ return getColumnText(element, 0);
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ if (! (element instanceof ICLanguageSettingEntry)) {
+ return (columnIndex == 0) ? element.toString() : EMPTY_STR;
+ }
+ ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
+ if (columnIndex == 0) {
+ String s = le.getName();
+ if (exported.contains(le))
+ s = s + NewUIMessages.getResourceString("AbstractLangsListTab.3"); //$NON-NLS-1$
+ return s;
+ }
+ if (le.getKind() == ICSettingEntry.MACRO) {
+ switch (columnIndex) {
+ case 1: return le.getValue();
+ }
+ }
+ return EMPTY_STR;
+ }
+
+ public Font getFont(Object element) {
+ if (! (element instanceof ICLanguageSettingEntry)) return null;
+ ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
+ if (le.isBuiltIn()) return null; // built in
+ if (le.isReadOnly()) // read only
+ return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+ else // normal
+ return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+ }
+ }
+
+ public ICLanguageSetting[] getLangSetting(ICResourceDescription rcDes) {
+ switch (rcDes.getType()) {
+ case ICSettingBase.SETTING_PROJECT:
+ case ICSettingBase.SETTING_CONFIGURATION:
+ case ICSettingBase.SETTING_FOLDER:
+ ICFolderDescription foDes = (ICFolderDescription)rcDes;
+ return foDes.getLanguageSettings();
+ case ICSettingBase.SETTING_FILE:
+ ICFileDescription fiDes = (ICFileDescription)rcDes;
+ return new ICLanguageSetting[] { fiDes.getLanguageSetting() };
+ }
+ return null;
+ }
+
+ public boolean canBeVisible() {
+ if (getResDesc() == null) return true;
+ ICLanguageSetting [] ls = getLangSetting(getResDesc());
+ for (int i=0; i<ls.length; i++) {
+ if ((ls[i].getSupportedEntryKinds() & getKind()) != 0)
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java
new file mode 100644
index 00000000000..6268651d057
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java
@@ -0,0 +1,848 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+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.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+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.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.internal.WorkbenchPlugin;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+/**
+ * It is a parent for all standard CDT property pages
+ * in new CDT model.
+ *
+ * Although it is enougth for new page to implement
+ * "IWorkbenchPropertyPage" interface, it would be
+ * better to extend it from "AbstractPage".
+ *
+ * In this case, we'll able to use:
+ * - dynamic tabs support via cPropertyTab extension point
+ * - a lot of utility methods: see ICPropertyProvider interface
+ * - mechanism of messages sent to all pages and all tabs in them
+ *
+ * In fact, descendants of AbstractPage have to implement
+ * the only method:
+ * protected boolean isSingle();
+ * It it returns false, current page can contain multiple tabs
+ * (obtained through "cPropertyTab" extension point).
+ * If it returns true, only one content tab is possible. If
+ * more than 1 tabs refer to this pas as a parent, only 1st
+ * one would be taken into account, others will be ignored.
+ */
+public abstract class AbstractPage extends PropertyPage
+implements
+ IWorkbenchPropertyPage, // ext point
+ IPreferencePageContainer, // dynamic pages
+ ICPropertyProvider // utility methods for tabs
+{
+ // Toggle this constant to <false>
+ // to hide "Manage configurations" button.
+ // Corresponding menu items and toolbar button
+ // will not be affected by this change.
+ private static final boolean ENABLE_MANAGE = true;
+
+ private static ArrayList pages = new ArrayList(5);
+ private static ICResourceDescription resd = null;
+ private static ICConfigurationDescription[] cfgDescs = null;
+ private static ICProjectDescription prjd = null;
+ private static int cfgIndex = 0;
+ private static boolean doneOK = false;
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "CLanguagesPropertyPage"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
+ private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
+ private static final String ALL_CONFS = PREFIX + ".selection.configuration.all"; //$NON-NLS-1$
+ private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
+
+ // tabs
+ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.cPropertyTab"; //$NON-NLS-1$
+ public static final String ELEMENT_NAME = "tab"; //$NON-NLS-1$
+ public static final String CLASS_NAME = "class"; //$NON-NLS-1$
+ public static final String PARENT_NAME = "parent"; //$NON-NLS-1$
+ public static final String IMAGE_NAME = "icon"; //$NON-NLS-1$
+ public static final String TIP_NAME = "tooltip"; //$NON-NLS-1$
+ public static final String TEXT_NAME = "name"; //$NON-NLS-1$
+ public static final String WEIGHT_NAME = "weight"; //$NON-NLS-1$
+
+ private static final Object NOT_NULL = new Object();
+ public static final String EMPTY_STR = ""; //$NON-NLS-1$
+
+ /*
+ * Dialog widgets
+ */
+ private Combo configSelector;
+ private Button manageButton;
+ private Button excludeFromBuildCheck;
+ /*
+ * Bookeeping variables
+ */
+ private boolean noContentOnPage = false;
+ protected boolean displayedConfig = false;
+ protected boolean isDirty = false;
+
+ protected IResource internalElement = null;
+ protected boolean isProject = false;
+ protected boolean isFolder = false;
+ protected boolean isFile = false;
+
+ // tabs
+ TabFolder folder;
+ ArrayList itabs = new ArrayList();
+ ICPropertyTab currentTab;
+
+ class InternalTab {
+ Composite comp;
+ String text;
+ String tip;
+ Image image;
+ ICPropertyTab tab;
+
+ InternalTab(Composite _comp, String _text, Image _image, ICPropertyTab _tab, String _tip) {
+ comp = _comp;
+ text = _text;
+ image = _image;
+ tab = _tab;
+ tip = _tip;
+ }
+
+ public TabItem createOn(TabFolder f) {
+ if (tab.canBeVisible()) {
+ TabItem ti = new TabItem(f, SWT.NONE);
+ ti.setText(text);
+ if (tip != null) ti.setToolTipText(tip);
+ if (image != null) ti.setImage(image);
+ ti.setControl(comp);
+ ti.setData(tab);
+ return ti;
+ }
+ return null;
+ }
+ }
+
+
+ /**
+ * Default constructor
+ */
+ public AbstractPage() {
+ // reset static values before new session
+ if (pages.size() == 0) {
+ doneOK = false; // see "performOk()"
+ prjd = null; // force getting new descriptors
+ }
+ // register current page
+ if (!pages.contains(this)) pages.add(this);
+ }
+
+ protected Control createContents(Composite parent) {
+ // Create the container we return to the property page editor
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ GridLayout compositeLayout = new GridLayout();
+ compositeLayout.numColumns = 1;
+ compositeLayout.marginHeight = 0;
+ compositeLayout.marginWidth = 0;
+ composite.setLayout( compositeLayout );
+
+ String s = null;
+ if (!checkElement()) {
+ s = NewUIMessages.getResourceString("AbstractPage.0"); //$NON-NLS-1$
+ } else if (!isApplicable()) {
+ s = NewUIMessages.getResourceString("AbstractPage.1"); //$NON-NLS-1$
+ } else if (!isCDTProject(getProject())) {
+ s = NewUIMessages.getResourceString("AbstractPage.2"); //$NON-NLS-1$
+ }
+
+ if (s == null) {
+ contentForCDT(composite);
+ return composite;
+ }
+
+ // no contents
+ Label label = new Label(composite, SWT.LEFT);
+ label.setText(s);
+ label.setFont(composite.getFont());
+ noContentOnPage = true;
+ noDefaultAndApplyButton();
+ return composite;
+ }
+
+ protected void contentForCDT(Composite composite) {
+ GridData gd;
+
+ // Add a config selection area
+ Group configGroup = ControlFactory.createGroup(composite, EMPTY_STR, 1);
+// Composite configGroup = new Composite(composite, SWT.NONE);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.grabExcessHorizontalSpace = true;
+ configGroup.setLayoutData(gd);
+ // Use the form layout inside the group composite
+ GridLayout ff = new GridLayout(3, false);
+ configGroup.setLayout(ff);
+ Label configLabel = ControlFactory.createLabel(configGroup, NewUIMessages.getResourceString(CONFIG_LABEL));
+ configLabel.setLayoutData(new GridData(GridData.BEGINNING));
+
+ configSelector = new Combo(configGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
+ configSelector.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleConfigSelection();
+ }
+ });
+ configSelector.setToolTipText(NewUIMessages.getResourceString(CONF_TIP));
+ gd = new GridData(GridData.FILL);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.FILL;
+
+ configSelector.setLayoutData(gd);
+
+ if (ENABLE_MANAGE) {
+ manageButton = new Button(configGroup, SWT.PUSH);
+ manageButton.setText("Manage configurations"); //$NON-NLS-1$
+ gd = new GridData(GridData.END);
+ gd.widthHint = 150;
+ manageButton.setLayoutData(gd);
+ manageButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ performOk();
+ if (ManageConfigDialog.manage(getProject())) {
+ prjd = null;
+ cfgDescs = null;
+ populateConfigurations();
+ }
+ }
+ });
+ } else { // dummy object to avoid breaking layout
+ new Label(configGroup, SWT.NONE).setLayoutData(new GridData(GridData.END));
+ }
+
+ if (isForFolder() || isForFile()) {
+ excludeFromBuildCheck = new Button(configGroup, SWT.CHECK);
+ excludeFromBuildCheck.setText("Exclude resource from build"); //$NON-NLS-1$
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ excludeFromBuildCheck.setLayoutData(gd);
+ excludeFromBuildCheck.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getResDesc().setExcluded(excludeFromBuildCheck.getSelection());
+ }
+ });
+ }
+
+ // Update the contents of the configuration widget
+ populateConfigurations();
+
+ if (excludeFromBuildCheck != null) {
+ excludeFromBuildCheck.setSelection(getResDesc().isExcluded());
+ }
+ // Create the Specific objects for each page
+ createWidgets(composite);
+ }
+
+ public void createWidgets(Composite c) {
+ Composite comp = new Composite(c, SWT.NONE);
+ comp.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ itabs.clear();
+ if (!isSingle()) {
+ comp.setLayout(new FillLayout());
+ folder = new TabFolder(comp, SWT.NONE);
+ }
+ loadExtensionsSynchronized(comp);
+
+ // Set listener after data load, to avoid firing
+ // selection event on not-initialized tab items
+ if (folder != null) {
+ folder.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
+ if (folder.getSelection().length > 0 ) {
+ ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData();
+ if (newTab != null && currentTab != newTab) {
+ if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);
+ currentTab = newTab;
+ currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
+ }
+ }
+ }
+ });
+ if (folder.getItemCount() > 0) folder.setSelection(0);
+ }
+ }
+ /**
+ *
+ */
+ public IProject getProject() {
+ Object element = getElement();
+ if (element != null) {
+ if (element instanceof IFile ||
+ element instanceof IProject ||
+ element instanceof IFolder)
+ {
+ IResource f = (IResource) element;
+ return f.getProject();
+ }
+ else if (element instanceof ICProject)
+ return ((ICProject)element).getProject();
+ }
+ return null;
+ }
+
+ /*
+ * Event Handlers
+ */
+ private void handleConfigSelection() {
+ // If there is nothing in config selection widget just bail
+ if (configSelector.getItemCount() == 0) return;
+ int selectionIndex = configSelector.getSelectionIndex();
+ if (selectionIndex == -1) return;
+ // Check if the user has selected the "all" configuration
+ String configName = configSelector.getItem(selectionIndex);
+ if (configName.equals(NewUIMessages.getResourceString(ALL_CONFS))) {
+ // This is the all config
+ return;
+ } else {
+ ICConfigurationDescription newConfig = cfgDescs[selectionIndex];
+ if (newConfig != getResDesc()) {
+ // If the user has changed values, and is now switching configurations, prompt for saving
+ if (getResDesc() != null) {
+ if (isDirty) {
+ Shell shell = CUIPlugin.getActiveWorkbenchShell();
+ boolean shouldApply = MessageDialog.openQuestion(shell,
+ NewUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ NewUIMessages.getFormattedString("BuildPropertyPage.changes.save.question", //$NON-NLS-1$
+ new String[] {getResDesc().getName(), newConfig.getName()}));
+ if (shouldApply) {
+ if (performOk()) {
+ isDirty = false;
+ } else {
+ MessageDialog.openWarning(shell,
+ NewUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ NewUIMessages.getResourceString("BuildPropertyPage.changes.save.error")); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ // Set the new selected configuration
+ cfgIndex = selectionIndex;
+ cfgChanged(newConfig);
+ }
+ }
+ return;
+ }
+
+ /**
+ * Saves ALL current changes in ALL affected configurations.
+ * Called after "OK" button pressed.
+ *
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+ if (doneOK || noContentOnPage || !displayedConfig) return true;
+ doneOK = true; // further pages need not to do anything
+ try {
+ CoreModel.getDefault().setProjectDescription(getProject(), prjd);
+ } catch (CoreException e) { }
+ // update views (in particular, display resource configurations)
+ WorkbenchPlugin.getDefault().getDecoratorManager().updateForEnablementChange();
+ return true;
+ }
+
+ /**
+ * Apply changes for all tabs but for given page & current cfg only.
+ * Called after "Apply" button pressed.
+ */
+ public void performApply() {
+ if (noContentOnPage || !displayedConfig) return;
+ // perform in separate thread
+ final ICProjectDescription local_prjd = CoreModel.getDefault().getProjectDescription(prjd.getProject());
+ ICConfigurationDescription c = local_prjd.getConfigurationById(resd.getConfiguration().getId());
+ final ICResourceDescription local_cfgd = getResDesc(c);
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ // ask all tabs to store changes in cfg
+ forEach(ICPropertyTab.APPLY, local_cfgd);
+ try {
+ CoreModel.getDefault().setProjectDescription(getProject(), local_prjd);
+ } catch (CoreException e) {
+ System.out.println("setProjectDescription: " + e.getLocalizedMessage()); //$NON-NLS-1$
+ }
+ // update views (in particular, display resource configurations)
+ WorkbenchPlugin.getDefault().getDecoratorManager().updateForEnablementChange();
+ }
+ };
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, true, op);
+ } catch (InvocationTargetException e) {
+ Throwable e1 = e.getTargetException();
+ CUIPlugin.errorDialog(getShell(), "Cannot apply", "Internal error", e1, true); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (InterruptedException e) {}
+ }
+
+ /**
+ * Inform all pages. Nothing to save
+ */
+ public boolean performCancel() {
+ if (! noContentOnPage && displayedConfig)
+ forEach(ICPropertyTab.CANCEL);
+ return true;
+ }
+
+ /**
+ * Ask all pages to set default values to current cfg
+ */
+ public void performDefaults() {
+ if (! noContentOnPage && displayedConfig)
+ forEach(ICPropertyTab.DEFAULTS);
+ }
+
+ private void populateConfigurations() {
+ // Do nothing if widget not created yet.
+ if (configSelector == null) return;
+
+ // if project changed, force re-read cfg.
+ ICProjectDescription _prjDesc = CoreModel.getDefault().getProjectDescription(getProject());
+ if (prjd == null || prjd.getProject() != _prjDesc.getProject()) {
+ prjd = _prjDesc;
+ cfgDescs = null;
+ cfgIndex = 0;
+ }
+ // Do not re-read if list already created by another page
+ if (cfgDescs == null) {
+ cfgDescs = prjd.getConfigurations();
+ if (cfgDescs == null || cfgDescs.length == 0) return;
+ }
+
+ // Clear and replace the contents of the selector widget
+ configSelector.removeAll();
+ for (int i = 0; i < cfgDescs.length; ++i) {
+ configSelector.add(cfgDescs[i].getName());
+ if (cfgDescs[i].isActive()) cfgIndex = i;
+ }
+ configSelector.select(cfgIndex);
+ handleConfigSelection();
+ }
+
+ public void updateButtons() {}
+ public void updateMessage() { }
+ public void updateTitle() { }
+ public void updateContainer() { }
+
+ public boolean isValid() {
+ updateContainer();
+ return super.isValid();
+ }
+
+ public void setVisible(boolean visible) {
+ /*
+ if (visible) {
+ Rectangle r = getControl().getBounds();
+ if (r.width > MAX_WIDTH) {
+ r.width = MAX_WIDTH;
+ getControl().setBounds(r);
+ }
+ }
+ */
+ super.setVisible(visible);
+ if (visible) displayedConfig = true;
+
+ if (itabs.size() < 1) return;
+
+ if (currentTab == null && folder.getItemCount() > 0) {
+ Object ob = folder.getItem(0).getData();
+ currentTab = (ICPropertyTab)ob;
+ }
+ if (currentTab != null)
+ currentTab.handleTabEvent(ICPropertyTab.VISIBLE, visible ? NOT_NULL : null);
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ return CUIPlugin.getDefault().getPreferenceStore();
+ }
+
+ public Preferences getPreferences() {
+ return CUIPlugin.getDefault().getPluginPreferences();
+ }
+
+ public void enableConfigSelection (boolean enable) {
+ if (configSelector != null) configSelector.setEnabled(enable);
+ if (manageButton != null) manageButton.setEnabled(enable);
+ }
+
+ /**
+ * Returns configuration descriptions for given project
+ */
+ public ICConfigurationDescription[] getCfgsReadOnly(IProject p) {
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+ if (prjd != null)
+ return prjd.getConfigurations();
+ return null;
+ }
+
+ /**
+ * Returns loaded configuration descriptions for current project
+ */
+ public ICConfigurationDescription[] getCfgsEditable() {
+ return cfgDescs;
+ }
+
+ /** Checks whether project is new CDT project
+ *
+ * @param p - project to check
+ * @returns true if it's new-style project.
+ */
+ public boolean isCDTProject(IProject p) {
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+ if (prjd == null) return false;
+ ICConfigurationDescription[] cfgs = prjd.getConfigurations();
+ return (cfgs != null && cfgs.length > 0);
+ }
+
+ public ICResourceDescription getResDesc() {
+ if (resd == null) {
+ if (cfgDescs == null) {
+ populateConfigurations();
+ if (cfgDescs == null || cfgDescs.length == 0) return null;
+ }
+ resd = getResDesc(cfgDescs[cfgIndex]);
+ }
+ return resd;
+ }
+
+ public ICResourceDescription getResDesc(ICConfigurationDescription cf) {
+ IAdaptable ad = getElement();
+
+ if (isForProject())
+ return cf.getRootFolderDescription();
+ ICResourceDescription out = null;
+ IResource res = (IResource)ad;
+ IPath p = res.getProjectRelativePath();
+ if (isForFolder() || isForFile()) {
+ out = cf.getResourceDescription(p, false);
+ if (! p.equals(out.getPath()) ) {
+ try {
+ if (isForFolder())
+ out = cf.createFolderDescription(p, (ICFolderDescription)out);
+ else
+ out = cf.createFileDescription(p, out);
+ } catch (CoreException e) {
+ System.out.println("Cannot create resource configuration for " + //$NON-NLS-1$
+ p.toOSString() + "\n" + e.getLocalizedMessage()); //$NON-NLS-1$
+ }
+ }
+ }
+ return out;
+ }
+
+ public void cfgChanged(ICConfigurationDescription _cfgd) {
+ resd = getResDesc(_cfgd);
+ for (int i=0; i<pages.size(); i++) {
+ AbstractPage ap = (AbstractPage)pages.get(i);
+ if (ap.displayedConfig)
+ ap.forEach(ICPropertyTab.UPDATE,getResDesc());
+ }
+ }
+
+ public void dispose() {
+ if (displayedConfig) forEach(ICPropertyTab.DISPOSE);
+ if (pages.contains(this)) pages.remove(this);
+ }
+
+ /**
+ * The only method to be redefined in descendants
+ * @return
+ * true if single page is required
+ * false if multiple pages are possible
+ */
+ abstract protected boolean isSingle();
+
+ /**
+ * Apply specified method to all tabs
+ */
+ protected void forEach(int m) { forEach(m, null); }
+ protected void forEach(int m, Object pars) {
+ Iterator it = itabs.iterator();
+ while(it.hasNext()) {
+ InternalTab tab = (InternalTab)it.next();
+ if (tab != null) tab.tab.handleTabEvent(m, pars);
+ }
+ }
+
+ // redefine page width
+ /*
+ public Point computeSize() {
+ Point p = super.computeSize();
+ if (p.x > MAX_WIDTH) p.x = MAX_WIDTH;
+ return p;
+ }
+ */
+
+ public static String getWeight(IConfigurationElement e) {
+ String s = e.getAttribute(WEIGHT_NAME);
+ return (s == null) ? EMPTY_STR : s;
+ }
+
+ private synchronized void loadExtensionsSynchronized(Composite parent)
+ {
+ // Get the extensions
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint == null) return;
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions == null) return;
+
+ for (int i = 0; i < extensions.length; ++i) {
+ IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+
+ Arrays.sort(elements, CDTListComparator.getInstance());
+
+ for (int k = 0; k < elements.length; k++) {
+ if (elements[k].getName().equals(ELEMENT_NAME)) {
+ if (loadTab(elements[k], parent)) return;
+ } else {
+ System.out.println("Cannot load " + elements[k].getName()); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param element
+ * @param parent
+ * @return true if we should exit (no more loadings)
+ * false if we should continue extensions scan.
+ * @throws BuildException
+ */
+ private boolean loadTab(IConfigurationElement element, Composite parent) {
+ // MBSCustomPageData currentPageData;
+ // Check whether it's our tab
+ if (!this.getClass().getName().equals(element.getAttribute(PARENT_NAME))) return false;
+
+ ICPropertyTab page = null;
+ try {
+ page = (ICPropertyTab) element.createExecutableExtension(CLASS_NAME);
+ } catch (CoreException e) {
+ System.out.println("Cannot create page: " + e.getLocalizedMessage()); //$NON-NLS-1$
+ return false;
+ }
+ if (page == null) return false;
+
+ Image _img = getIcon(element);
+ if (_img != null) page.handleTabEvent(ICPropertyTab.SET_ICON, _img);
+
+ if (isSingle()) {
+ // note that name, image and tooltip
+ // are ignored for single page.
+ page.createControls(parent, this);
+ InternalTab itab = new InternalTab(parent, EMPTY_STR, null, page, null);
+ itabs.add(itab);
+ currentTab = page;
+ return true; // don't load other tabs
+ } else { // tabbed page
+ String _name = element.getAttribute(TEXT_NAME);
+ String _tip = element.getAttribute(TIP_NAME);
+
+ Composite _comp = new Composite(folder, SWT.NONE);
+ page.createControls(_comp, this);
+ InternalTab itab = new InternalTab(_comp, _name, _img, page, _tip);
+ itab.createOn(folder);
+ itabs.add(itab);
+ return false;
+ }
+ }
+
+ private Image getIcon(IConfigurationElement config) {
+ ImageDescriptor idesc = null;
+ try {
+ String iconName = config.getAttribute(IMAGE_NAME);
+ if (iconName != null) {
+ URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
+ idesc = ImageDescriptor.createFromURL(new URL(pluginInstallUrl, iconName));
+ }
+ } catch (MalformedURLException exception) {}
+ return (idesc == null) ? null : idesc.createImage();
+ }
+
+ public void informAll(int code, Object data) {
+ for (int i=0; i<pages.size(); i++) {
+ AbstractPage ap = (AbstractPage)pages.get(i);
+ ap.forEach(code, data);
+ }
+ }
+
+ public void informPages(int code, Object data) {
+ for (int i=0; i<pages.size(); i++) {
+ AbstractPage ap = (AbstractPage)pages.get(i);
+ ap.handleMessage(code, data);
+ }
+ }
+
+ public void handleMessage(int code, Object data) {
+ switch (code) {
+ // First re-check visibility of all tabs.
+ // While tab deletion can be made on the fly,
+ // tabs adding will be made by re-creation
+ // of all elements, to preserve their order
+ case ICPropertyTab.MANAGEDBUILDSTATE:
+ // generally, single-tabbed pages are not intended to handle this message
+ if (folder == null) return;
+
+ boolean willAdd = false;
+ TabItem[] ts = folder.getItems();
+ int x = folder.getSelectionIndex();
+ String currHeader = (x == -1) ? null : ts[x].getText();
+ for (int i=0; i<itabs.size(); i++) {
+ InternalTab itab = (InternalTab)itabs.get(i);
+ TabItem ti = null;
+ for (int j=0; j<ts.length; j++) {
+ if (ts[j].isDisposed()) continue;
+ if (ts[j].getData() == itab.tab) {
+ ti = ts[j];
+ break;
+ }
+ }
+ if (itab.tab.canBeVisible()) {
+ if (ti == null) {
+ willAdd = true;
+ break;
+ }
+ } else {
+ if (ti != null) ti.dispose();
+ }
+ }
+ // in case of new tab added,
+ // we have to dispose and re-create all tabs
+ if (willAdd) {
+ for (int j=0; j<ts.length; j++)
+ if (ts[j] != null && !ts[j].isDisposed())
+ ts[j].dispose();
+ TabItem ti = null;
+ for (int i=0; i<itabs.size(); i++) {
+ InternalTab itab = (InternalTab)itabs.get(i);
+ if (itab.tab.canBeVisible()) {
+ TabItem currTI = itab.createOn(folder);
+ if (currHeader != null && currHeader.equals(itab.text))
+ ti = currTI;
+ }
+ }
+ if (ti != null) folder.setSelection(ti);
+ }
+ break;
+ }
+ }
+
+ /**
+ * Performs conversion of incoming element to internal representation.
+ */
+ protected boolean checkElement() {
+ IAdaptable el = super.getElement();
+ if (el instanceof ICElement)
+ internalElement = ((ICElement)el).getResource();
+ else if (el instanceof IResource)
+ internalElement = (IResource)el;
+ if (internalElement == null) return false;
+ isProject = internalElement instanceof IProject;
+ isFolder = internalElement instanceof IFolder;
+ isFile = internalElement instanceof IFile;
+ return true;
+ }
+
+ // override parent's method to use proper class
+ public IAdaptable getElement() {
+ if (internalElement == null && !checkElement())
+ throw (new NullPointerException("element not initialized !")); //$NON-NLS-1$
+ return internalElement;
+ }
+
+ public boolean isForProject() { return isProject; }
+ public boolean isForFolder() { return isFolder; }
+ public boolean isForFile() { return isFile; }
+ public boolean isForPrefs() { return false; }
+
+ /**
+ * Checks whether CDT property pages can be open for given object.
+ * In particular, header files and text files are not allowed.
+ *
+ * Note, that org.eclipse.cdt.ui.plugin.xml contains appropriate
+ * filters to avoid displaying CDT pages for unwanted objects.
+ * So this check is only backup, it would prevent from NullPointer
+ * exceptions in case when xml filters were modified somehow.
+ *
+ * @return - true if element is applicable to CDT pages.
+ */
+ public boolean isApplicable() {
+ if (internalElement == null && !checkElement())
+ return false; // unknown element
+ if (isForFile()) // only source files are applicable
+ return CoreModel.isValidSourceUnitName(getProject(), internalElement.getName());
+ else
+ return true; // Projects and folders are always applicable
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java
new file mode 100644
index 00000000000..33cbe7d8f3a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+/**
+ * Abstract page to be used as base for preference pages
+ */
+public abstract class AbstractPrefPage extends AbstractPage
+ implements IWorkbenchPreferencePage {
+
+ public Label titleLabel;
+
+ protected Control createContents(Composite parent) {
+ // Create the container we return to the property page editor
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ GridLayout compositeLayout = new GridLayout();
+ compositeLayout.numColumns = 1;
+ compositeLayout.marginHeight = 0;
+ compositeLayout.marginWidth = 0;
+ composite.setLayout( compositeLayout );
+
+ Group configGroup = ControlFactory.createGroup(composite, EMPTY_STR, 1);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.grabExcessHorizontalSpace = true;
+ configGroup.setLayoutData(gd);
+ titleLabel = ControlFactory.createLabel(configGroup,
+ NewUIMessages.getResourceString("AbstractPrefPage.0") + //$NON-NLS-1$
+ NewUIMessages.getResourceString("AbstractPrefPage.1")); //$NON-NLS-1$
+
+ createWidgets(composite);
+ return composite;
+ }
+
+ protected boolean checkElement() { return true; }
+ public boolean isForPrefs() { return true; }
+ public void init(IWorkbench workbench) {}
+ public ICResourceDescription getResDesc() { return null; }
+ public void performApply() { performOk(); }
+
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java
new file mode 100644
index 00000000000..ce0568f8d54
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+//import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class AbstractPropertyDialog extends Dialog {
+ private final static String WSP_BEG = "${workspace_loc:"; //$NON-NLS-1$
+ private final static String WSP_END = "}"; //$NON-NLS-1$
+ protected final static String EMPTY_STR = ""; //$NON-NLS-1$
+
+ protected Shell shell;
+ public boolean result = false;
+
+ public Object data = null;
+ public boolean check1 = false;
+ public boolean check2 = false;
+ public String text1;
+ public String text2;
+ private Shell parent;
+
+ public AbstractPropertyDialog(Shell _parent, String title) {
+ super(_parent, 0);
+ parent = _parent;
+ this.setText(title);
+ }
+
+ abstract public void buttonPressed(SelectionEvent e);
+ abstract protected Control createDialogArea(Composite c);
+
+ protected Button setupButton(Composite c, String text) {
+ Button b = new Button(c, SWT.PUSH);
+ b.setText(text);
+ b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ buttonPressed(event);
+ }});
+ return b;
+ }
+
+ public boolean open () {
+ shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+ shell.setText(getText());
+ createDialogArea(shell);
+
+ // center window
+ Rectangle r1 = shell.getDisplay().getBounds();
+ Rectangle r2 = shell.getBounds();
+ int x = r1.width / 2 - r2.width / 2;
+ int y = r1.height / 2 - r2.height / 2;
+ shell.setBounds(x, y, r2.width, r2.height);
+
+ shell.open();
+ Display display = parent.getDisplay();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ return result;
+ }
+ protected static String strip_wsp(String s) {
+ s = s.trim();
+ if (s.startsWith(WSP_BEG) && s.endsWith(WSP_END)) {
+ int x = s.length() - WSP_END.length();
+ s = s.substring(WSP_BEG.length(), x);
+ }
+ return s;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java
new file mode 100644
index 00000000000..170ce6389bd
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java
@@ -0,0 +1,354 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.dialogs.ICOptionPage;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.util.PixelConverter;
+
+public class BinaryParsTab extends AbstractCPropertyTab {
+
+ /* Settings from binary parser pages are NOT saved by prior CDT version.
+ * So existing binary parsers _always_ use default values.
+ * Moreover, obsolete interface is used while attempting to save.
+ *
+ * We have to affect both parsers and pages
+ * to teach them to save data really.
+ *
+ * It will be done in next versions. Currently pages are disabled.
+ */
+
+ private static final int DEFAULT_HEIGHT = 160;
+ private static final String ATTR_FILTER = "filter"; //$NON-NLS-1$
+ private static final String ATTR_NAME = "name"; //$NON-NLS-1$
+ private static final String ATTR_NAME_VISIBILITY = "visibility"; //$NON-NLS-1$
+ private static final String ATTR_VALUE = "value"; //$NON-NLS-1$
+ private static final String ATTR_VALUE_PRIVATE = "private"; //$NON-NLS-1$
+
+ protected Map configMap;
+ protected Map fParserPageMap = null;
+ protected Table table;
+ protected CheckboxTableViewer tv;
+ protected Composite parserGroup;
+
+ private ICTargetPlatformSetting tps;
+
+ protected class BinaryParserConfiguration {
+ IExtension fExtension;
+ public BinaryParserConfiguration(IExtension extension) { fExtension = extension; }
+ public String getID() { return fExtension.getUniqueIdentifier();}
+ public String getName() { return fExtension.getLabel(); }
+ public String toString() { return fExtension.getUniqueIdentifier(); }
+ public boolean equals(Object obj) {
+ if (obj instanceof BinaryParserConfiguration) {
+ return this.getID().equals(((BinaryParserConfiguration) obj).getID());
+ }
+ return super.equals(obj);
+ }
+ }
+
+ protected class BinaryParserPageConfiguration {
+ ICOptionPage dynamicPage;
+ IConfigurationElement fElement;
+ public BinaryParserPageConfiguration(IConfigurationElement element) {
+ fElement = element;
+ }
+ public ICOptionPage getPage() throws CoreException {
+ if (dynamicPage == null) {
+ dynamicPage = (ICOptionPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ return dynamicPage;
+ }
+ }
+
+ protected String getParserId() {
+ return CCorePlugin.BINARY_PARSER_SIMPLE_ID;
+ }
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(usercomp, ICHelpContextIds.BINARY_PARSER_PAGE);
+
+ usercomp.setLayout(new GridLayout(2, false));
+ setupLabel(usercomp, "Binary parser :", 2, GridData.FILL_HORIZONTAL); //$NON-NLS-1$
+ table = new Table(usercomp, SWT.BORDER | SWT.CHECK | SWT.SINGLE);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBinaryParserChanged();
+ updateButtons();
+ }});
+ tv = new CheckboxTableViewer(table);
+ tv.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return (Object[])inputElement;
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+ tv.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent e) {
+ saveChecked();
+ }});
+
+ // get "standard" buttons on my own place
+ Composite c = new Composite(usercomp, SWT.NONE);
+ c.setLayoutData(new GridData(GridData.END));
+ initButtons(c, new String[] {MOVEUP_STR, MOVEDOWN_STR});
+
+ parserGroup = new Composite(usercomp, SWT.NULL);
+ GridData gd = new GridData();
+ parserGroup.setLayout(new TabFolderLayout());
+
+ PixelConverter converter = new PixelConverter(parent);
+ gd.heightHint = converter.convertHorizontalDLUsToPixels(DEFAULT_HEIGHT);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalSpan = 2;
+ parserGroup.setLayoutData(gd);
+ initializeParserList();
+ initializeParserPageMap();
+ handleBinaryParserChanged();
+ }
+
+ public void setVisible(boolean _visible) {
+ super.setVisible(_visible);
+ page.enableConfigSelection(!_visible);
+ }
+
+ public void updateData(ICResourceDescription cfgd) {
+ tps = cfgd.getConfiguration().getTargetPlatformSetting();
+ String[] ids = tps.getBinaryParserIds();
+ Object[] data = new Object[configMap.size()];
+ HashMap clone = new HashMap(configMap);
+ // add checked elements
+ int i;
+ for (i=0; i<ids.length; i++) {
+ data[i] = clone.get(ids[i]);
+ clone.remove(ids[i]);
+ }
+ // add remaining parsers (unchecked)
+ Iterator it = clone.keySet().iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+ data[i++] = clone.get(s);
+ }
+ tv.setInput(data);
+ // set check marks
+ for (i=0; i<ids.length; i++) {
+ if (configMap.containsKey(ids[i])) {
+ tv.setChecked(configMap.get(ids[i]), true);
+ }
+ }
+ updateButtons();
+ }
+
+ private void initializeParserList() {
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
+ if (point != null) {
+ IExtension[] exts = point.getExtensions();
+ configMap = new HashMap(exts.length);
+ for (int i = 0; i < exts.length; i++) {
+ if (isExtensionVisible(exts[i])) {
+ configMap.put(exts[i].getUniqueIdentifier(), new BinaryParserConfiguration(exts[i]));
+ }
+ }
+ }
+ }
+
+ private void initializeParserPageMap() {
+ fParserPageMap = new HashMap(5);
+
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+ IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
+ for (int i = 0; i < infos.length; i++) {
+ if (infos[i].getName().equals("parserPage")) { //$NON-NLS-1$
+ String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
+ fParserPageMap.put(id, new BinaryParserPageConfiguration(infos[i]));
+ }
+ }
+ }
+
+ private boolean isExtensionVisible(IExtension ext) {
+ IConfigurationElement[] elements = ext.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement[] children = elements[i].getChildren(ATTR_FILTER);
+ for (int j = 0; j < children.length; j++) {
+ String name = children[j].getAttribute(ATTR_NAME);
+ if (name != null && name.equals(ATTR_NAME_VISIBILITY)) {
+ String value = children[j].getAttribute(ATTR_VALUE);
+ if (value != null && value.equals(ATTR_VALUE_PRIVATE)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ return false; // invalid extension definition (must have at least cextension elements)
+ }
+
+ public void updateButtons() {
+ int cnt = table.getItemCount();
+ int pos = table.getSelectionIndex();
+ buttonSetEnabled(0, pos > 0);
+ buttonSetEnabled(1, pos != -1 && pos < (cnt - 1));
+ }
+ protected void handleBinaryParserChanged() {
+ String[] enabled = getBinaryParserIDs();
+ ICOptionPage dynamicPage;
+ for (int i = 0; i < enabled.length; i++) { // create all enabled pages
+ dynamicPage = getBinaryParserPage(enabled[i]);
+
+ if (dynamicPage != null) {
+ if (dynamicPage.getControl() == null) {
+ dynamicPage.setContainer(page);
+ dynamicPage.createControl(parserGroup);
+ }
+ dynamicPage.setVisible(false);
+ }
+ }
+ // Retrieve the dynamic UI for the current parser
+ String parserID = getCurrentBinaryParserID();
+ dynamicPage = getBinaryParserPage(parserID);
+ if (dynamicPage != null) { dynamicPage.setVisible(true); }
+ }
+
+ protected String[] getBinaryParserIDs() {
+ return (String[]) configMap.keySet().toArray(new String[configMap.keySet().size()]);
+ }
+
+ protected ICOptionPage getBinaryParserPage(String parserID) {
+ BinaryParserPageConfiguration configElement = (BinaryParserPageConfiguration) fParserPageMap.get(parserID);
+ if (configElement != null) {
+ try {
+ return configElement.getPage();
+ } catch (CoreException e) {}
+ }
+ return null;
+ }
+
+ protected String getCurrentBinaryParserID() {
+ int x = table.getSelectionIndex();
+ if (x < 0) return null;
+ return ((BinaryParserConfiguration)table.getItem(x).getData()).getID();
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ ICTargetPlatformSetting tps1 = src.getConfiguration().getTargetPlatformSetting();
+ ICTargetPlatformSetting tps2 = dst.getConfiguration().getTargetPlatformSetting();
+ if (tps1 != null && tps2 != null) { // temporary
+ tps2.setBinaryParserIds(tps1.getBinaryParserIds());
+ }
+ }
+
+ protected void performDefaults() {
+ tps.setBinaryParserIds(null);
+ informPages(false);
+ updateData(getResDesc());
+ }
+
+ private void informPages(boolean apply) {
+ IProgressMonitor mon = new NullProgressMonitor();
+ Iterator it = fParserPageMap.values().iterator();
+
+
+ while (it.hasNext()) {
+ try {
+ ICOptionPage dynamicPage = ((BinaryParserPageConfiguration)it.next()).getPage();
+ if (dynamicPage.isValid() && dynamicPage.getControl() != null) {
+ if (apply)
+ dynamicPage.performApply(mon);
+ else
+ dynamicPage.performDefaults();
+ }
+ } catch (CoreException e) {}
+ }
+ }
+
+ public void buttonPressed(int i) {
+ switch (i) {
+ case 0:
+ moveItem(true);
+ break;
+ case 1:
+ moveItem(false);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Move item up / down
+ private void moveItem(boolean up) {
+ int n = table.getSelectionIndex();
+ if (n < 0 ||
+ (up && n == 0) ||
+ (!up && n+1 == table.getItemCount()))
+ return;
+ Object d = tv.getElementAt(n);
+ boolean checked = tv.getChecked(d);
+ tv.remove(d);
+ n = up ? n - 1 : n + 1;
+ tv.insert(d, n);
+ tv.setChecked(d, checked);
+ table.setSelection(n);
+ saveChecked();
+ }
+
+ private void saveChecked() {
+ Object[] objs = tv.getCheckedElements();
+ String[] ids = null;
+ if (objs != null) {
+ ids = new String[objs.length];
+ for (int i=0; i<objs.length; i++) {
+ ids[i] = ((BinaryParserConfiguration)objs[i]).getID();
+ }
+ }
+ if (tps != null) tps.setBinaryParserIds(ids);
+ }
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject() || page.isForPrefs();
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTListComparator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTListComparator.java
new file mode 100644
index 00000000000..6b4ced6203d
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTListComparator.java
@@ -0,0 +1,58 @@
+package org.eclipse.cdt.ui.newui;
+
+import java.util.Comparator;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.ui.newui.AbstractExportTab.ExtData;
+
+public class CDTListComparator implements Comparator {
+ private static CDTListComparator comparator = null;
+
+ public static CDTListComparator getInstance() {
+ if (comparator == null)
+ comparator = new CDTListComparator();
+ return comparator;
+ }
+ public int compare(Object a, Object b) {
+ if (a == null || b == null)
+ return 0;
+ if (a instanceof ICLanguageSetting) {
+ ICLanguageSetting c1 = (ICLanguageSetting)a;
+ ICLanguageSetting c2 = (ICLanguageSetting)b;
+ return c1.getName().compareToIgnoreCase(c2.getName());
+ }
+ if (a instanceof ICLanguageSettingEntry) {
+ ICLanguageSettingEntry c1 = (ICLanguageSettingEntry)a;
+ ICLanguageSettingEntry c2 = (ICLanguageSettingEntry)b;
+ return c1.getName().compareToIgnoreCase(c2.getName());
+ }
+ if (a instanceof ICConfigurationDescription) {
+ ICConfigurationDescription c1 = (ICConfigurationDescription)a;
+ ICConfigurationDescription c2 = (ICConfigurationDescription)b;
+ return c1.getName().compareToIgnoreCase(c2.getName());
+ }
+ if (a instanceof ExtData) {
+ ExtData c1 = (ExtData)a;
+ ExtData c2 = (ExtData)b;
+ return c1.getName().compareToIgnoreCase(c2.getName());
+ }
+ if (a instanceof ICdtVariable) {
+ ICdtVariable c1 = (ICdtVariable) a;
+ ICdtVariable c2 = (ICdtVariable) b;
+ return c1.getName().compareToIgnoreCase(c2.getName());
+ }
+ if (a instanceof IConfigurationElement) {
+ IConfigurationElement e1 = (IConfigurationElement)a;
+ IConfigurationElement e2 = (IConfigurationElement)b;
+ return AbstractPage.getWeight(e1).compareTo(AbstractPage.getWeight(e2));
+ }
+
+ return a.toString().compareTo(b.toString());
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java
new file mode 100644
index 00000000000..c2e4b670345
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.settings.model.COutputEntry;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+
+public class CLocationOutputTab extends CLocationTab {
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ label.setText("Output folders folders on build path:"); //$NON-NLS-1$
+ }
+
+ public ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd) {
+ return cfgd.getConfiguration().getBuildSetting().getOutputDirectories();
+ }
+ public void setEntries(ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data) {
+ ICOutputEntry[] out = null;
+ if (data != null) {
+ out = new ICOutputEntry[data.length];
+ for (int i=0; i<out.length; i++) out[i] = (ICOutputEntry)data[i];
+ }
+ cfgd.getConfiguration().getBuildSetting().setOutputDirectories(out);
+ }
+ public ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean isWorkspacePath) {
+ return new COutputEntry(p, ex, isWorkspacePath ? ICLanguageSettingEntry.VALUE_WORKSPACE_PATH : 0);
+ }
+ public ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean isWorkspacePath) {
+ return new COutputEntry(f, ex, isWorkspacePath ? ICLanguageSettingEntry.VALUE_WORKSPACE_PATH : 0);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java
new file mode 100644
index 00000000000..bacdcc7b464
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+
+public class CLocationSourceTab extends CLocationTab {
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ label.setText("Source folders on build path:"); //$NON-NLS-1$
+ }
+
+ public ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean isWorkspacePath) {
+ return new CSourceEntry(p, ex, isWorkspacePath ? ICLanguageSettingEntry.VALUE_WORKSPACE_PATH : 0);
+ }
+ public ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean isWorkspacePath) {
+ return new CSourceEntry(f, ex, isWorkspacePath ? ICLanguageSettingEntry.VALUE_WORKSPACE_PATH : 0);
+ }
+ public ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd) {
+ return cfgd.getConfiguration().getSourceEntries();
+ }
+ public void setEntries(ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data) {
+ ICSourceEntry[] out = null;
+ if (data != null) {
+ out = new ICSourceEntry[data.length];
+ for (int i=0; i<out.length; i++) out[i] = (ICSourceEntry)data[i];
+ }
+ try {
+ cfgd.getConfiguration().setSourceEntries(out);
+ } catch (CoreException e) {}
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java
new file mode 100644
index 00000000000..2cfe4863071
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java
@@ -0,0 +1,294 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.NewFolderDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+public abstract class CLocationTab extends AbstractCPropertyTab {
+
+ private final Image IMG_EN = CPluginImages.get(CPluginImages.IMG_OBJS_CFOLDER);
+ private final Image IMG_FI = CPluginImages.get(CPluginImages.IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
+
+ Label label;
+ TreeViewer tree;
+ ArrayList src;
+ ICResourceDescription cfgd;
+ ICProject cprj;
+
+ class _Filter {
+ _Entry entry;
+ _Filter(_Entry _entry) { entry = _entry; }
+
+ public IPath[] getExtPaths() {
+ IPath[] p = null;
+ p = entry.ent.getExclusionPatterns();
+ return p;
+ }
+
+ public String[] getExts() {
+ IPath[] p = getExtPaths();
+ if (p == null || p.length == 0) return new String[0];
+ String[] s = new String[p.length];
+ for (int i=0; i<p.length; i++) s[i] = p[i].toOSString();
+ return s;
+ }
+
+ public String toString() {
+ String[] s = getExts();
+ if (s.length == 0) return NewUIMessages.getResourceString("CLocationTab.0"); //$NON-NLS-1$
+ String x = NewUIMessages.getResourceString("CLocationTab.1"); //$NON-NLS-1$
+ for (int i=0; i< s.length; i++) x = x + s[i] + NewUIMessages.getResourceString("CLocationTab.2"); //$NON-NLS-1$
+ x = x.substring(0, x.length() - 2) + NewUIMessages.getResourceString("CLocationTab.3"); //$NON-NLS-1$
+ return x;
+ }
+ }
+
+ class _Entry {
+ ICExclusionPatternPathEntry ent;
+ _Filter[] f = new _Filter[1];
+ _Entry(ICExclusionPatternPathEntry _ent) {
+ ent = _ent;
+ f[0] = new _Filter(this);
+ }
+ public String toString() { return getPath().toString(); }
+
+ public IPath getPath() { return ent.isValueWorkspacePath() ? ent.getFullPath() : ent.getLocation(); }
+
+ }
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(1, false));
+ label = new Label(usercomp, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.BEGINNING));
+ tree = new TreeViewer(usercomp);
+ tree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ tree.getTree().addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }});
+
+ initButtons(new String[] {NewUIMessages.getResourceString("CLocationTab.4"),NewUIMessages.getResourceString("CLocationTab.5"), NewUIMessages.getResourceString("CLocationTab.6"), NewUIMessages.getResourceString("CLocationTab.7")}, 150); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ tree.setContentProvider(new ITreeContentProvider() {
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof _Entry)
+ return ((_Entry)parentElement).f;
+ return null;
+ }
+ public Object getParent(Object element) {
+ if (element instanceof _Filter)
+ return ((_Filter)element).entry;
+ return null;
+ }
+ public boolean hasChildren(Object element) {
+ return (element instanceof _Entry);
+ }
+ public Object[] getElements(Object inputElement) {
+ return src.toArray(new _Entry[src.size()]);
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }});
+
+ tree.setLabelProvider(new LabelProvider() {
+ public Image getImage(Object element) {
+ if (element instanceof _Entry)
+ return IMG_EN;
+ else if (element instanceof _Filter)
+ return IMG_FI;
+ else
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Add, Create/Link: always enabled
+ * Edit: enabled if 1 element selected (entry or filter)
+ * Delete: enabled if selected element is entry
+ */
+ private void updateButtons() {
+ TreeItem[] sel = tree.getTree().getSelection();
+ buttonSetEnabled(2, sel.length == 1);
+ buttonSetEnabled(3, sel.length > 0 && sel[0].getData() instanceof _Entry);
+ }
+
+ public void buttonPressed(int x) {
+ String s;
+ Shell shell = usercomp.getShell();
+ TreeItem[] sel = tree.getTree().getSelection();
+ switch (x) {
+ // add
+ case 0:
+ s = getProjectDialog(shell, EMPTY_STR);
+ if (s != null) {
+ src.add(new _Entry(newEntry(new Path(s), new IPath[0], true)));
+ saveData();
+ }
+ break;
+ // create / link
+ case 1:
+ NewFolderDialog d = new NewFolderDialog(shell, page.getProject());
+ if (d.open() == Window.OK) {
+ IFolder f = (IFolder)d.getFirstResult();
+ src.add(new _Entry(newEntry(f, new IPath[0], !f.isLinked())));
+ saveData();
+ }
+ // edit filter
+ case 2:
+ if (sel.length == 0) return;
+ Object data = sel[0].getData();
+ _Entry entry = null;
+ if (data instanceof _Entry)
+ entry = (_Entry)data;
+ else if (data instanceof _Filter)
+ entry = ((_Filter)data).entry;
+ else return;
+ ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(), entry.getPath(), page.getProject());
+ if (dialog.open() == Window.OK) {
+ IPath[] ps = dialog.getExclusionPattern();
+ IPath path = entry.getPath();
+ boolean isWsp = entry.ent.isValueWorkspacePath();
+ entry.ent = newEntry(path, ps, isWsp);
+ saveData();
+ }
+ break;
+ case 3:
+ if (sel.length == 0) return;
+ for (int i = 0; i < sel.length; i++) {
+ if (sel[i].getData() instanceof _Entry) src.remove(sel[i].getData());
+ }
+ saveData();
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void saveData() {
+ ICExclusionPatternPathEntry[] p = new ICExclusionPatternPathEntry[src.size()];
+ Iterator it = src.iterator();
+ int i=0;
+ while(it.hasNext()) { p[i++] = ((_Entry)it.next()).ent; }
+ setEntries(cfgd, p);
+ tree.setInput(cfgd);
+ updateData(cfgd);
+ }
+
+ public void updateData(ICResourceDescription _cfgd) {
+ cfgd = _cfgd;
+ ICExclusionPatternPathEntry[] ent = getEntries(cfgd);
+ src = new ArrayList(ent.length);
+ for (int i=0; i<ent.length; i++) {
+ src.add(new _Entry(ent[i]));
+ }
+ tree.setInput(src);
+ // get CProject
+ IAdaptable ad = page.getElement();
+ if (ad instanceof ICProject)
+ cprj = (ICProject)ad;
+
+ updateButtons();
+ }
+
+ protected abstract ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd);
+ protected abstract void setEntries (ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data);
+ protected abstract ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean workspacePath);
+ protected abstract ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean workspacePath);
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ setEntries(dst, getEntries(src));
+ }
+
+ protected void performDefaults() {
+ setEntries(cfgd, null);
+ updateData(cfgd);
+ }
+
+
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject();
+ }
+
+ private String getProjectDialog(Shell shell, String text) {
+ IPath path = new Path(text);
+
+ LocDialog dialog = new LocDialog(shell);
+ dialog.setInput(page.getProject());
+
+ IResource container = null;
+ if(path.isAbsolute()){
+ IContainer cs[] = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(path);
+ if(cs != null && cs.length > 0)
+ container = cs[0];
+ }
+ dialog.setInitialSelection(container);
+ dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE);
+ dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG);
+ if (dialog.open() == Window.OK) {
+ IResource resource = (IResource) dialog.getFirstResult();
+ if (resource != null) {
+ return resource.getFullPath().toString();
+ }
+ }
+ return null;
+ }
+
+ class LocDialog extends ElementTreeSelectionDialog {
+ public LocDialog(Shell parent) {
+ super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ addFilter(new ViewerFilter () {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return element instanceof IFolder;
+ }});
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
new file mode 100644
index 00000000000..1d1647734d1
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+public class EnvDialog extends Dialog {
+ IEnvironmentVariable var;
+ Button b_add2all;
+ private Text text1;
+ private Text text2;
+ boolean newAction;
+ Shell shell;
+ ICConfigurationDescription cfgd;
+ public String t1 = AbstractCPropertyTab.EMPTY_STR;
+ public String t2 = AbstractCPropertyTab.EMPTY_STR;
+ public boolean toAll = false;
+
+ public EnvDialog(Shell parent,
+ IEnvironmentVariable _var,
+ String title, boolean _newAction,
+ ICConfigurationDescription _cfgd) {
+ super(parent);
+ shell = parent;
+ var = _var;
+ newAction = _newAction;
+ cfgd = _cfgd;
+ }
+
+ /**
+ * Method is overridden to disable "OK" button at start
+ */
+ protected Control createContents(Composite parent) {
+ Control out = super.createContents(parent);
+ setButtons();
+ return out;
+ }
+
+ protected Control createDialogArea(Composite c) {
+ c.setLayout(new GridLayout(3, false));
+ GridData gd;
+
+ Label l1 = new Label(c, SWT.NONE);
+ l1.setText(NewUIMessages.getResourceString("EnvDialog.0")); //$NON-NLS-1$
+ l1.setLayoutData(new GridData(GridData.BEGINNING));
+
+ text1 = new Text(c, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ text1.setLayoutData(gd);
+ text1.addModifyListener(new ModifyListener () {
+ public void modifyText(ModifyEvent e) { setButtons(); }});
+
+ Label l2 = new Label(c, SWT.NONE);
+ l2.setText(NewUIMessages.getResourceString("EnvDialog.1")); //$NON-NLS-1$
+ l2.setLayoutData(new GridData(GridData.BEGINNING));
+
+ text2 = new Text(c, SWT.SINGLE | SWT.BORDER);
+ text2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ text2.addModifyListener(new ModifyListener () {
+ public void modifyText(ModifyEvent e) { setButtons(); }});
+
+ final Button b = new Button(c, SWT.PUSH);
+ b.setText(NewUIMessages.getResourceString("EnvDialog.2")); //$NON-NLS-1$
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ String x = AbstractCPropertyTab.getVariableDialog(b.getShell(), cfgd);
+ if (x != null) {
+ text2.insert(x);
+ setButtons();
+ }
+ }});
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
+ b.setLayoutData(gd);
+
+ b_add2all = new Button(c, SWT.CHECK);
+ b_add2all.setText(NewUIMessages.getResourceString("EnvDialog.3")); //$NON-NLS-1$
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ if (cfgd == null)
+ b_add2all.setVisible(false);
+ else
+ b_add2all.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ toAll = b_add2all.getSelection();
+ }});
+
+ if (!newAction) {
+ gd.heightHint = 1;
+ b_add2all.setVisible(false);
+
+ text1.setText(var.getName());
+ text1.setEnabled(false); // don't change name
+ text2.setText(var.getValue());
+ }
+
+ gd.horizontalSpan = 3;
+ b_add2all.setLayoutData(gd);
+ setButtons();
+ return c;
+ }
+
+ private void setButtons() {
+ t1 = text1.getText();
+ t2 = text2.getText();
+ Button b = getButton(IDialogConstants.OK_ID);
+ if (b != null)
+ b.setEnabled(t1.trim().length() > 0);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java
new file mode 100644
index 00000000000..5171c409ad6
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java
@@ -0,0 +1,441 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IContributedEnvironment;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.utils.envvar.StorableEnvironment;
+import org.eclipse.cdt.utils.spawner.EnvironmentReader;
+
+import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
+import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier;
+
+
+public class EnvironmentTab extends AbstractCPropertyTab {
+ private static final String PREFIX = "EnvironmentBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String VALUE_UNDEF = LABEL + ".value.undef"; //$NON-NLS-1$
+ private static final String SEMI = ";"; //$NON-NLS-1$
+ private static final String LBR = " ["; //$NON-NLS-1$
+ private static final String RBR = "]"; //$NON-NLS-1$
+ private static final UserDefinedEnvironmentSupplier fUserSupplier = EnvironmentVariableManager.fUserSupplier;
+
+
+ private Table table;
+ private TableViewer tv;
+ private ArrayList data = new ArrayList();
+ private Button b1, b2;
+
+ private static final IContributedEnvironment ce = CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment();
+ private ICConfigurationDescription cfgd = null;
+ private StorableEnvironment vars = null;
+
+ private class TabData {
+ IEnvironmentVariable var;
+ boolean changed;
+ TabData(IEnvironmentVariable _var, boolean _changed) {
+ var = _var;
+ changed = _changed;
+ }
+ }
+
+ private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
+ public EnvironmentLabelProvider(boolean user){
+ }
+ public Image getImage(Object element) {
+ return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
+ }
+ public String getText(Object element) {
+ return getColumnText(element, 0);
+ }
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ TabData td = (TabData)element;
+ switch(columnIndex){
+ case 0:
+ return td.var.getName();
+ case 1:
+ if(td.var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
+ return NewUIMessages.getResourceString(VALUE_UNDEF);
+ return td.var.getValue();
+ }
+ return EMPTY_STR;
+ }
+
+ public Font getFont(Object element) {
+ return getFont(element, 0);
+ }
+
+ public Font getFont(Object element, int columnIndex) {
+ TabData td = (TabData)element;
+ Font f = null;
+ if (cfgd == null || ce.isUserVariable(cfgd, td.var))
+ f = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+
+ switch(columnIndex){
+ case 0:
+ break;
+ case 1:
+ if(td.var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
+ f = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+ break;
+ }
+ return f;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element){
+ return null;
+ }
+ public Color getBackground(Object element){
+ return null;
+ }
+ }
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout(1, false));
+ Label l1 = new Label(usercomp, SWT.LEFT);
+ l1.setText(NewUIMessages.getResourceString("EnvironmentTab.0")); //$NON-NLS-1$
+ l1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ table = new Table(usercomp, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }});
+
+ tv = new TableViewer(table);
+ tv.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement != null && inputElement instanceof ArrayList) {
+ ArrayList ar = (ArrayList)inputElement;
+ return ar.toArray(new TabData[0]);
+ }
+ return null;
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+ tv.setLabelProvider(new EnvironmentLabelProvider(true));
+ // add headers
+ TableColumn tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(NewUIMessages.getResourceString("EnvironmentTab.1")); //$NON-NLS-1$
+ tc.setWidth(200);
+ tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(NewUIMessages.getResourceString("EnvironmentTab.2")); //$NON-NLS-1$
+ tc.setWidth(200);
+
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ b1 = new Button(usercomp, SWT.RADIO);
+ b1.setText(NewUIMessages.getResourceString("EnvironmentTab.3")); //$NON-NLS-1$
+ b1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b1.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (cfgd != null)
+ ce.setAppendEnvironment(true, cfgd);
+ else
+ vars.setAppendContributedEnvironment(true);
+ updateData();
+ }});
+
+ b2 = new Button(usercomp, SWT.RADIO);
+ b2.setText(NewUIMessages.getResourceString("EnvironmentTab.4")); //$NON-NLS-1$
+ b2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b2.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (cfgd != null)
+ ce.setAppendEnvironment(false, cfgd);
+ else
+ vars.setAppendContributedEnvironment(false);
+ updateData();
+ }});
+
+ initButtons(new String[] {NewUIMessages.getResourceString("EnvironmentTab.5"),NewUIMessages.getResourceString("EnvironmentTab.6"),NewUIMessages.getResourceString("EnvironmentTab.7"),NewUIMessages.getResourceString("EnvironmentTab.8"),NewUIMessages.getResourceString("EnvironmentTab.9")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
+ public void buttonPressed(int i) {
+ IEnvironmentVariable var = null;
+ EnvDialog dlg;
+ int n = table.getSelectionIndex();
+ int[] idx;
+ switch (i) {
+ case 0:
+ dlg = new EnvDialog(usercomp.getShell(), var, NewUIMessages.getResourceString("EnvironmentTab.10"), true, cfgd); //$NON-NLS-1$
+ if (dlg.open() == Window.OK) {
+ if (dlg.t1.trim().length() > 0) {
+ ICConfigurationDescription[] cfgs;
+ if (dlg.toAll)
+ cfgs = page.getCfgsEditable();
+ else
+ cfgs = new ICConfigurationDescription[] {cfgd};
+ if (cfgd == null)
+ vars.createVariable(dlg.t1.trim(), dlg.t2.trim(),
+ IEnvironmentVariable.ENVVAR_APPEND, SEMI);
+ else
+ for (int x=0; x<cfgs.length; x++) {
+ ce.addVariable(dlg.t1.trim(), dlg.t2.trim(),
+ IEnvironmentVariable.ENVVAR_APPEND,
+ SEMI, cfgs[x]);
+ }
+ updateData();
+ }
+ }
+ break;
+ case 1: // select
+ handleEnvSelectButtonSelected();
+ updateData();
+ break;
+ case 2: // edit
+ if (n == -1) return;
+ var = ((TabData)tv.getElementAt(n)).var;
+ dlg = new EnvDialog(usercomp.getShell(), var, NewUIMessages.getResourceString("EnvironmentTab.11"), false, cfgd); //$NON-NLS-1$
+ if (dlg.open() == Window.OK) {
+ if (cfgd != null)
+ ce.addVariable( dlg.t1.trim(), dlg.t2.trim(),
+ IEnvironmentVariable.ENVVAR_REPLACE,
+ var.getDelimiter(), cfgd);
+ else
+ vars.createVariable(dlg.t1.trim(), dlg.t2.trim(),
+ IEnvironmentVariable.ENVVAR_REPLACE, var.getDelimiter());
+ updateData();
+ }
+ break;
+ case 3: // remove
+ if (n == -1) return;
+ idx = table.getSelectionIndices();
+ for (int j=0; j<idx.length; j++) {
+ var = ((TabData)tv.getElementAt(idx[j])).var;
+ if (cfgd == null)
+ vars.deleteVariable(var.getName());
+ else
+ ce.removeVariable(var.getName(), cfgd);
+ }
+ updateData();
+ break;
+ case 4: // Undefine
+ if (n == -1) return;
+ idx = table.getSelectionIndices();
+ for (int j=0; j<idx.length; j++) {
+ var = ((TabData)tv.getElementAt(idx[j])).var;
+ if (cfgd == null)
+ vars.createVariable(
+ var.getName(),
+ null,
+ IEnvironmentVariable.ENVVAR_REMOVE,
+ var.getDelimiter());
+ else
+ ce.addVariable(
+ var.getName(),
+ null,
+ IEnvironmentVariable.ENVVAR_REMOVE,
+ var.getDelimiter(), cfgd);
+ }
+ updateData();
+ break;
+ }
+ updateButtons();
+ }
+
+ public void updateButtons() {
+ if (table == null || table.isDisposed()) return;
+
+ int pos = table.getSelectionIndex();
+ buttonSetEnabled(2, pos != -1);
+ buttonSetEnabled(3, pos != -1);
+ buttonSetEnabled(4, pos != -1);
+ }
+
+ public void updateData(ICResourceDescription _cfgd) {
+ // null means preference configuration
+ cfgd = (_cfgd != null) ? _cfgd.getConfiguration() : null;
+ if (cfgd == null && vars == null)
+ vars = fUserSupplier.getWorkspaceEnvironmentCopy();
+ updateData();
+ }
+ private void updateData() {
+ IEnvironmentVariable[] _vars = null;
+ if (cfgd != null) {
+ b1.setSelection(ce.appendEnvironment(cfgd));
+ b2.setSelection(!ce.appendEnvironment(cfgd));
+ _vars = ce.getVariables(cfgd);
+ } else {
+ b1.setSelection(vars.appendContributedEnvironment());
+ b2.setSelection(!vars.appendContributedEnvironment());
+ _vars = vars.getVariables() ;
+ }
+ data.clear();
+ if (_vars != null) {
+ for (int i=0; i<_vars.length; i++) {
+ data.add(new TabData(_vars[i], false));
+ }
+ }
+ tv.setInput(data);
+ updateButtons();
+ }
+
+ public void performApply(ICResourceDescription _src, ICResourceDescription _dst) {
+ ICConfigurationDescription src = _src.getConfiguration();
+ ICConfigurationDescription dst = _dst.getConfiguration();
+
+ ce.setAppendEnvironment(ce.appendEnvironment(src), dst);
+ IEnvironmentVariable[] v = ce.getVariables(dst);
+ for (int i=0; i<v.length; i++) ce.removeVariable(v[i].getName(), dst);
+ v = ce.getVariables(src);
+ for (int i=0; i<v.length; i++)
+ ce.addVariable(v[i].getName(), v[i].getValue(),
+ v[i].getOperation(), v[i].getDelimiter(), dst);
+ }
+
+ /**
+ *
+ */
+ private class MyListSelectionDialog extends ListSelectionDialog {
+ public boolean toAll = false;
+ public MyListSelectionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider) {
+ super(parentShell, input, contentProvider, new LabelProvider() {}, NewUIMessages.getResourceString("EnvironmentTab.12")); //$NON-NLS-1$
+ }
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ Button b = new Button(composite, SWT.CHECK);
+ b.setText(NewUIMessages.getResourceString("EnvironmentTab.13")); //$NON-NLS-1$
+ b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ if (cfgd == null)
+ b.setVisible(false);
+ else
+ b.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ toAll = ((Button)e.widget).getSelection();
+ }});
+ return composite;
+ }
+ }
+
+ private void handleEnvSelectButtonSelected() {
+ // get Environment Variables from the OS
+ Map v = EnvironmentReader.getEnvVars();
+ MyListSelectionDialog dialog = new MyListSelectionDialog(usercomp.getShell(), v, createSelectionDialogContentProvider());
+
+ dialog.setTitle("Select variables"); //$NON-NLS-1$
+ if (dialog.open() == Window.OK) {
+ Object[] selected = dialog.getResult();
+ ICConfigurationDescription[] cfgs;
+ if (dialog.toAll)
+ cfgs = page.getCfgsEditable();
+ else
+ cfgs = new ICConfigurationDescription[] {cfgd};
+
+ for (int i = 0; i < selected.length; i++) {
+ String name = (String)selected[i];
+ String value = EMPTY_STR;
+ int x = name.indexOf(LBR);
+ if (x >= 0) {
+ value = name.substring(x + 2, name.length() - 1);
+ name = name.substring(0, x);
+ }
+
+ if (cfgd == null)
+ vars.createVariable(name, value);
+ else
+ for (int y=0; y<cfgs.length; y++) {
+ ce.addVariable(
+ name, value,
+ IEnvironmentVariable.ENVVAR_APPEND,
+ SEMI, cfgs[y]);
+ }
+ }
+ }
+ }
+
+ private IStructuredContentProvider createSelectionDialogContentProvider() {
+ return new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ String[] els = null;
+ if (inputElement instanceof Map) {
+ Map m = (Map)inputElement;
+ els = new String[m.size()];
+ int index = 0;
+ for (Iterator iterator = m.keySet().iterator(); iterator.hasNext(); index++) {
+ String k = (String)iterator.next();
+ els[index] = k + LBR + (String)m.get(k) + RBR;
+ }
+ }
+ return els;
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ };
+ }
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject() || page.isForPrefs();
+ }
+
+ protected void performOK() {
+ if (vars != null)
+ fUserSupplier.setWorkspaceEnvironment(vars);
+ vars = null;
+ super.performOK();
+ }
+
+ protected void performCancel() {
+ vars = null;
+ super.performCancel();
+ }
+
+ protected void performDefaults() {
+ ce.restoreDefaults(cfgd); // both for proj & prefs
+ vars = null;
+ updateData();
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java
new file mode 100644
index 00000000000..37dd76c6999
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+
+public class ErrorParsTab extends AbstractCPropertyTab {
+ protected HashMap mapParsers = new HashMap();
+ protected Table table;
+ protected CheckboxTableViewer tv;
+ ICConfigurationDescription cfgd;
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new FillLayout());
+ table = new Table(usercomp, SWT.BORDER | SWT.CHECK | SWT.SINGLE);
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }});
+ tv = new CheckboxTableViewer(table);
+ tv.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return (Object[])inputElement;
+ }
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ });
+
+ tv.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent e) {
+ saveChecked();
+ }
+ });
+
+ initButtons(new String[] {
+ MOVEUP_STR, MOVEDOWN_STR, null,
+ "Check all", "Uncheck all" //$NON-NLS-1$//$NON-NLS-2$
+ });
+ initMapParsers();
+ }
+
+ protected void initMapParsers() {
+ mapParsers.clear();
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(
+ CCorePlugin.PLUGIN_ID,
+ CCorePlugin.ERROR_PARSER_SIMPLE_ID
+ );
+ if (point != null) {
+ IExtension[] exts = point.getExtensions();
+ for (int i = 0; i < exts.length; i++) {
+ if (exts[i].getConfigurationElements().length > 0) {
+ mapParsers.put(exts[i].getUniqueIdentifier(), exts[i].getLabel());
+ }
+ }
+ }
+ }
+
+ public void buttonPressed (int n) {
+ switch (n) {
+ case 0: // up
+ moveItem(true);
+ break;
+ case 1: // down
+ moveItem(false);
+ break;
+ case 2: // do nothing - it's not a button
+ break;
+
+ case 3: // check all
+ tv.setAllChecked(true);
+ break;
+ case 4: // uncheck all
+ tv.setAllChecked(false);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Move item up / down
+ private void moveItem(boolean up) {
+ int n = table.getSelectionIndex();
+ if (n < 0 ||
+ (up && n == 0) ||
+ (!up && n+1 == table.getItemCount()))
+ return;
+ TableData d = (TableData)tv.getElementAt(n);
+ boolean checked = tv.getChecked(d);
+ tv.remove(d);
+ n = up ? n - 1 : n + 1;
+ tv.insert(d, n);
+ tv.setChecked(d, checked);
+ table.setSelection(n);
+ saveChecked();
+ }
+
+ class TableData {
+ String key;
+ String value;
+ public TableData (String _key, String _value) {
+ key = _key;
+ value = _value;
+ }
+ public String toString() { return value; }
+ }
+
+ public void updateData(ICResourceDescription _cfgd) {
+ cfgd = _cfgd.getConfiguration();
+ if (mapParsers == null) return;
+ String[] ss = cfgd.getBuildSetting().getErrorParserIDs();
+
+ ArrayList data = new ArrayList(mapParsers.size());
+ ArrayList checked = new ArrayList(ss.length);
+ HashMap cloneMap = new HashMap(mapParsers);
+ // add checked elements
+ for (int i=0; i<ss.length; i++) {
+ String s = (String)cloneMap.get(ss[i]);
+ if (s != null) {
+ TableData d = new TableData(ss[i],s);
+ data.add(d);
+ checked.add(d);
+ cloneMap.remove(ss[i]);
+ }
+ }
+ // add remaining parsers (unchecked)
+ Iterator it = cloneMap.keySet().iterator();
+ while (it.hasNext()) {
+ String s = (String)it.next();
+ data.add(new TableData(s, (String)cloneMap.get(s)));
+ }
+ tv.setInput(data.toArray());
+ tv.setCheckedElements(checked.toArray());
+ updateButtons();
+ }
+
+ public void updateButtons() {
+ int cnt = table.getItemCount();
+ int pos = table.getSelectionIndex();
+ buttonSetEnabled(0, pos > 0);
+ buttonSetEnabled(1, pos != -1 && pos < (cnt - 1));
+ buttonSetEnabled(3, cnt > 0);
+ buttonSetEnabled(4, cnt > 0);
+ }
+
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ String[] s1 = src.getConfiguration().getBuildSetting().getErrorParserIDs();
+ dst.getConfiguration().getBuildSetting().setErrorParserIDs(s1);
+ }
+
+ private void saveChecked() {
+ Object[] objs = tv.getCheckedElements();
+ ArrayList lst = new ArrayList();
+ if (objs != null) {
+ for (int i=0; i<objs.length; i++)
+ lst.add(((TableData)objs[i]).key);
+ }
+ cfgd.getBuildSetting().setErrorParserIDs((String[])lst.toArray(new String[lst.size()]));
+ }
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject() || page.isForPrefs();
+ }
+
+ protected void performDefaults() {
+ cfgd.getConfiguration().getBuildSetting().setErrorParserIDs(null);
+ updateData(getResDesc());
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java
new file mode 100644
index 00000000000..db01de0d24e
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+public class ExPatternDialog extends StatusDialog {
+
+ private static class ExPatternLabelProvider extends LabelProvider {
+
+ public Image getImage(Object element) {
+ ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry();
+ return registry.get(CPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB);
+ }
+
+ public String getText(Object element) {
+ return (String) element;
+ }
+
+ }
+
+ private ListDialogField fExclusionPatternList;
+ private IProject fCurrProject;
+ private IPath[] pattern;
+ private IPath path;
+ private IContainer fCurrSourceFolder;
+
+ private static final int IDX_ADD= 0;
+ private static final int IDX_ADD_MULTIPLE= 1;
+ private static final int IDX_EDIT= 2;
+ private static final int IDX_REMOVE= 4;
+
+
+ public ExPatternDialog(Shell parent, IPath[] _data, IPath _path, IProject proj) {
+ super(parent);
+ fCurrProject = proj;
+ pattern = _data;
+ path = _path;
+ setTitle(CPathEntryMessages.getString("ExclusionPatternDialog.title")); //$NON-NLS-1$
+
+ String label= CPathEntryMessages.getFormattedString("ExclusionPatternDialog.pattern.label", path.makeRelative().toString()); //$NON-NLS-1$
+
+ String[] buttonLabels= new String[] {
+ /* IDX_ADD */ CPathEntryMessages.getString("ExclusionPatternDialog.pattern.add"), //$NON-NLS-1$
+ /* IDX_ADD_MULTIPLE */ CPathEntryMessages.getString("ExclusionPatternDialog.pattern.add.multiple"), //$NON-NLS-1$
+ /* IDX_EDIT */ CPathEntryMessages.getString("ExclusionPatternDialog.pattern.edit"), //$NON-NLS-1$
+ null,
+ /* IDX_REMOVE */ CPathEntryMessages.getString("ExclusionPatternDialog.pattern.remove") //$NON-NLS-1$
+ };
+
+ ExclusionPatternAdapter adapter= new ExclusionPatternAdapter();
+
+ fExclusionPatternList= new ListDialogField(adapter, buttonLabels, new ExPatternLabelProvider());
+ fExclusionPatternList.setDialogFieldListener(adapter);
+ fExclusionPatternList.setLabelText(label);
+ fExclusionPatternList.setRemoveButtonIndex(IDX_REMOVE);
+ fExclusionPatternList.enableButton(IDX_EDIT, false);
+
+ IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot();
+ IResource res= root.findMember(path);
+ if (res instanceof IContainer) {
+ fCurrSourceFolder= (IContainer) res;
+ }
+
+ ArrayList elements= new ArrayList(pattern.length);
+ for (int i= 0; i < pattern.length; i++) {
+ elements.add(pattern[i].toString());
+ }
+ fExclusionPatternList.setElements(elements);
+ fExclusionPatternList.selectFirstElement();
+ fExclusionPatternList.enableButton(IDX_ADD_MULTIPLE, fCurrSourceFolder != null);
+ }
+
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite= (Composite)super.createDialogArea(parent);
+
+ Composite inner= new Composite(composite, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ inner.setLayout(layout);
+
+ fExclusionPatternList.doFillIntoGrid(inner, 3);
+ LayoutUtil.setHorizontalSpan(fExclusionPatternList.getLabelControl(null), 2);
+
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ protected void doCustomButtonPressed(ListDialogField field, int index) {
+ if (index == IDX_ADD) {
+ addEntry();
+ } else if (index == IDX_EDIT) {
+ editEntry();
+ } else if (index == IDX_ADD_MULTIPLE) {
+ addMultipleEntries();
+ }
+ }
+
+ protected void doDoubleClicked(ListDialogField field) {
+ editEntry();
+ }
+
+ protected void doSelectionChanged(ListDialogField field) {
+ List selected= field.getSelectedElements();
+ fExclusionPatternList.enableButton(IDX_EDIT, canEdit(selected));
+ }
+
+ private boolean canEdit(List selected) {
+ return selected.size() == 1;
+ }
+
+ private void editEntry() {
+
+ List selElements= fExclusionPatternList.getSelectedElements();
+ if (selElements.size() != 1) {
+ return;
+ }
+ List existing= fExclusionPatternList.getElements();
+ String entry= (String) selElements.get(0);
+ ExPatternEntryDialog dialog= new ExPatternEntryDialog(getShell(), entry, existing, fCurrProject, path);
+ if (dialog.open() == Window.OK) {
+ fExclusionPatternList.replaceElement(entry, dialog.getExclusionPattern());
+ }
+ }
+
+ private void addEntry() {
+ List existing= fExclusionPatternList.getElements();
+ ExPatternEntryDialog dialog= new ExPatternEntryDialog(getShell(), null, existing, fCurrProject, path);
+ if (dialog.open() == Window.OK) {
+ fExclusionPatternList.addElement(dialog.getExclusionPattern());
+ }
+ }
+
+
+
+ // -------- ExclusionPatternAdapter --------
+
+ private class ExclusionPatternAdapter implements IListAdapter, IDialogFieldListener {
+ public void customButtonPressed(ListDialogField field, int index) {
+ doCustomButtonPressed(field, index);
+ }
+
+ public void selectionChanged(ListDialogField field) {
+ doSelectionChanged(field);
+ }
+
+ public void doubleClicked(ListDialogField field) {
+ doDoubleClicked(field);
+ }
+
+ public void dialogFieldChanged(DialogField field) {
+ }
+
+ }
+
+ protected void doStatusLineUpdate() {
+ }
+
+ protected void checkIfPatternValid() {
+ }
+
+
+ public IPath[] getExclusionPattern() {
+ IPath[] res= new IPath[fExclusionPatternList.getSize()];
+ for (int i= 0; i < res.length; i++) {
+ String entry= (String) fExclusionPatternList.getElement(i);
+ res[i]= new Path(entry);
+ }
+ return res;
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+// WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+ }
+
+ private void addMultipleEntries() {
+ Class[] acceptedClasses= new Class[] { IFolder.class, IFile.class };
+ ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
+ ViewerFilter filter= new TypedViewerFilter(acceptedClasses);
+
+ ILabelProvider lp= new WorkbenchLabelProvider();
+ ITreeContentProvider cp= new WorkbenchContentProvider();
+
+ IResource initialElement= null;
+
+ ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+ dialog.setTitle(CPathEntryMessages.getString("ExclusionPatternDialog.ChooseExclusionPattern.title")); //$NON-NLS-1$
+ dialog.setValidator(validator);
+ dialog.setMessage(CPathEntryMessages.getString("ExclusionPatternDialog.ChooseExclusionPattern.description")); //$NON-NLS-1$
+ dialog.addFilter(filter);
+ dialog.setInput(fCurrSourceFolder);
+ dialog.setInitialSelection(initialElement);
+ dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+ if (dialog.open() == Window.OK) {
+ Object[] objects= dialog.getResult();
+ int existingSegments= fCurrSourceFolder.getFullPath().segmentCount();
+
+ for (int i= 0; i < objects.length; i++) {
+ IResource curr= (IResource) objects[i];
+ IPath path= curr.getFullPath().removeFirstSegments(existingSegments).makeRelative();
+ String res;
+ if (curr instanceof IContainer) {
+ res= path.addTrailingSeparator().toString();
+ } else {
+ res= path.toString();
+ }
+ fExclusionPatternList.addElement(res);
+ }
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java
new file mode 100644
index 00000000000..b0c41b661cf
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+
+public class ExPatternEntryDialog extends StatusDialog {
+
+ private StringButtonDialogField fExclusionPatternDialog;
+ private StatusInfo fExclusionPatternStatus;
+
+ private IContainer fCurrSourceFolder;
+ private String fExclusionPattern;
+ private List fExistingPatterns;
+
+ public ExPatternEntryDialog(Shell parent, String patternToEdit, List existingPatterns, IProject proj, IPath path) {
+ super(parent);
+ fExistingPatterns = existingPatterns;
+ if (patternToEdit == null) {
+ setTitle(CPathEntryMessages.getString("ExclusionPatternEntryDialog.add.title")); //$NON-NLS-1$
+ } else {
+ setTitle(CPathEntryMessages.getString("ExclusionPatternEntryDialog.edit.title")); //$NON-NLS-1$
+ fExistingPatterns.remove(patternToEdit);
+ }
+
+ IWorkspaceRoot root = proj.getWorkspace().getRoot();
+ IResource res = root.findMember(path);
+ if (res instanceof IContainer) {
+ fCurrSourceFolder = (IContainer) res;
+ }
+
+ fExclusionPatternStatus = new StatusInfo();
+
+ String label = CPathEntryMessages.getFormattedString("ExclusionPatternEntryDialog.pattern.label", //$NON-NLS-1$
+ path.makeRelative().toString());
+
+ ExPatternAdapter adapter = new ExPatternAdapter();
+ fExclusionPatternDialog = new StringButtonDialogField(adapter);
+ fExclusionPatternDialog.setLabelText(label);
+ fExclusionPatternDialog.setButtonLabel(CPathEntryMessages.getString("ExclusionPatternEntryDialog.pattern.button")); //$NON-NLS-1$
+ fExclusionPatternDialog.setDialogFieldListener(adapter);
+ fExclusionPatternDialog.enableButton(fCurrSourceFolder != null);
+
+ if (patternToEdit == null) {
+ fExclusionPatternDialog.setText(""); //$NON-NLS-1$
+ } else {
+ fExclusionPatternDialog.setText(patternToEdit.toString());
+ }
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ int widthHint = convertWidthInCharsToPixels(60);
+
+ Composite inner = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ inner.setLayout(layout);
+
+ Label description = new Label(inner, SWT.WRAP);
+ description.setText(CPathEntryMessages.getString("ExclusionPatternEntryDialog.description")); //$NON-NLS-1$
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = convertWidthInCharsToPixels(80);
+ description.setLayoutData(gd);
+
+ fExclusionPatternDialog.doFillIntoGrid(inner, 3);
+
+ LayoutUtil.setWidthHint(fExclusionPatternDialog.getLabelControl(null), widthHint);
+ LayoutUtil.setHorizontalSpan(fExclusionPatternDialog.getLabelControl(null), 2);
+
+ LayoutUtil.setWidthHint(fExclusionPatternDialog.getTextControl(null), widthHint);
+ LayoutUtil.setHorizontalGrabbing(fExclusionPatternDialog.getTextControl(null));
+
+ fExclusionPatternDialog.postSetFocusOnDialogField(parent.getDisplay());
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ // -------- ExclusionPatternAdapter --------
+
+ private class ExPatternAdapter implements IDialogFieldListener, IStringButtonAdapter {
+
+ // -------- IDialogFieldListener
+
+ public void dialogFieldChanged(DialogField field) {
+ doStatusLineUpdate();
+ }
+
+ public void changeControlPressed(DialogField field) {
+ doChangeControlPressed();
+ }
+ }
+
+ protected void doChangeControlPressed() {
+ IPath pattern = chooseExclusionPattern();
+ if (pattern != null) {
+ fExclusionPatternDialog.setText(pattern.toString());
+ }
+ }
+
+ protected void doStatusLineUpdate() {
+ checkIfPatternValid();
+ updateStatus(fExclusionPatternStatus);
+ }
+
+ protected void checkIfPatternValid() {
+ String pattern = fExclusionPatternDialog.getText().trim();
+ if (pattern.length() == 0) {
+ fExclusionPatternStatus.setError(CPathEntryMessages.getString("ExclusionPatternEntryDialog.error.empty")); //$NON-NLS-1$
+ return;
+ }
+ IPath path = new Path(pattern);
+ if (path.isAbsolute() || path.getDevice() != null) {
+ fExclusionPatternStatus.setError(CPathEntryMessages.getString("ExclusionPatternEntryDialog.error.notrelative")); //$NON-NLS-1$
+ return;
+ }
+ if (fExistingPatterns.contains(pattern)) {
+ fExclusionPatternStatus.setError(CPathEntryMessages.getString("ExclusionPatternEntryDialog.error.exists")); //$NON-NLS-1$
+ return;
+ }
+
+ fExclusionPattern = pattern;
+ fExclusionPatternStatus.setOK();
+ }
+
+ public String getExclusionPattern() {
+ return fExclusionPattern;
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ // WorkbenchHelp.setHelp(newShell,
+ // ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+ }
+
+ // ---------- util method ------------
+
+ private IPath chooseExclusionPattern() {
+ Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class};
+ ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new WorkbenchContentProvider();
+
+ IPath initialPath = new Path(fExclusionPatternDialog.getText());
+ IResource initialElement = null;
+ IContainer curr = fCurrSourceFolder;
+ int nSegments = initialPath.segmentCount();
+ for (int i = 0; i < nSegments; i++) {
+ IResource elem = curr.findMember(initialPath.segment(i));
+ if (elem != null) {
+ initialElement = elem;
+ }
+ if (elem instanceof IContainer) {
+ curr = (IContainer) elem;
+ } else {
+ break;
+ }
+ }
+
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
+ dialog.setTitle(CPathEntryMessages.getString("ExclusionPatternEntryDialog.ChooseExclusionPattern.title")); //$NON-NLS-1$
+ dialog.setValidator(validator);
+ dialog.setMessage(CPathEntryMessages.getString("ExclusionPatternEntryDialog.ChooseExclusionPattern.description")); //$NON-NLS-1$
+ dialog.addFilter(filter);
+ dialog.setInput(fCurrSourceFolder);
+ dialog.setInitialSelection(initialElement);
+ dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+ if (dialog.open() == Window.OK) {
+ IResource res = (IResource) dialog.getFirstResult();
+ IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount()).makeRelative();
+ if (res instanceof IContainer) {
+ return path.addTrailingSeparator();
+ }
+ return path;
+ }
+ return null;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java
new file mode 100644
index 00000000000..0ebdf46e43a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+//import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+public class ExpDialog extends AbstractPropertyDialog {
+
+ protected static final String TO_ALL = "Apply to all"; //$NON-NLS-1$
+
+ public String[] sel_types = null;
+ public String[] sel_langs = null;
+ private Text txt1;
+ private Text txt2;
+ private List langs;
+ private List types;
+ private Label message;
+ private Button c_langs;
+ private Button c_types;
+ private Button c_all;
+
+ private Button b_vars;
+ private Button b_work;
+ private Button b_file;
+ private Button b_ok;
+ private Button b_ko;
+ private boolean newAction;
+ private int kind;
+ private ICConfigurationDescription cfgd;
+ private String[] names_l, names_t;
+ private java.util.List existing;
+
+ public ExpDialog(Shell parent, boolean _newAction,
+ String title, String _data1, String _data2,
+ ICConfigurationDescription _cfgd,
+ String[] _langs, String[] _types,
+ int _kind, String[] _names_l, String[] _names_t,
+ java.util.List _existing) {
+ super(parent, title);
+ super.text1 = (_data1 == null) ? EMPTY_STR : _data1;
+ super.text2 = (_data2 == null) ? EMPTY_STR : _data2;
+ newAction = _newAction;
+ cfgd = _cfgd;
+ sel_langs = _langs;
+ sel_types = _types;
+ kind = _kind;
+ names_l = _names_l;
+ names_t = _names_t;
+ existing = _existing;
+ }
+
+ protected Control createDialogArea(Composite c) {
+ c.setLayout(new GridLayout(4, true));
+ GridData gd;
+
+ Label l1 = new Label(c, SWT.NONE);
+ l1.setText("Name:"); //$NON-NLS-1$
+ l1.setLayoutData(new GridData(GridData.BEGINNING));
+
+ txt1 = new Text(c, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ txt1.setLayoutData(gd);
+ txt1.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }});
+
+ Label l2 = new Label(c, SWT.NONE);
+ l2.setText("Value:"); //$NON-NLS-1$
+ l2.setLayoutData(new GridData(GridData.BEGINNING));
+
+ txt2 = new Text(c, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ txt2.setLayoutData(gd);
+ txt2.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }});
+
+ if (kind != ICSettingEntry.MACRO) {
+ l1.setVisible(false);
+ txt1.setVisible(false);
+ txt2.setText(super.text1); // note that name edited by 2nd text widget
+ } else {
+ txt1.setText(super.text1);
+ txt2.setText(super.text1);
+ if (!newAction) txt1.setEnabled(false); // macro name
+ }
+
+ b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME);
+
+ c_all = new Button(c, SWT.CHECK);
+ c_all.setText(NewUIMessages.getResourceString("ExpDialog.0")); //$NON-NLS-1$
+ gd = new GridData(GridData.BEGINNING);
+ gd.horizontalSpan = 2;
+ c_all.setLayoutData(gd);
+ c_all.setVisible(newAction);
+
+ b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME);
+ b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME);
+ if (kind == ICSettingEntry.MACRO) {
+ b_work.setVisible(false);
+ b_file.setVisible(false);
+ }
+
+ Group dest = new Group(c, SWT.NONE);
+ dest.setText(NewUIMessages.getResourceString("ExpDialog.1")); //$NON-NLS-1$
+ dest.setLayout(new GridLayout(2, true));
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 4;
+ dest.setLayoutData(gd);
+
+ Label l = new Label(dest, SWT.NONE);
+ l.setText(NewUIMessages.getResourceString("ExpDialog.2")); //$NON-NLS-1$
+ l.setLayoutData(new GridData(GridData.BEGINNING));
+
+ l = new Label(dest, SWT.NONE);
+ l.setText(NewUIMessages.getResourceString("ExpDialog.3")); //$NON-NLS-1$
+ l.setLayoutData(new GridData(GridData.BEGINNING));
+
+ c_langs = new Button(dest, SWT.CHECK);
+ c_langs.setText(TO_ALL);
+ c_langs.setLayoutData(new GridData(GridData.BEGINNING));
+ c_langs.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ langs.setEnabled(!c_langs.getSelection());
+ }});
+
+ c_types = new Button(dest, SWT.CHECK);
+ c_types.setText(TO_ALL);
+ c_types.setLayoutData(new GridData(GridData.BEGINNING));
+ c_types.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ types.setEnabled(!c_types.getSelection());
+ }});
+
+ langs = new List(dest, SWT.BORDER | SWT.MULTI);
+ langs.setLayoutData(new GridData(GridData.FILL_BOTH));
+ langs.setItems(names_l);
+ setSelections(sel_langs, langs, c_langs);
+
+ types = new List(dest, SWT.BORDER | SWT.MULTI);
+ types.setLayoutData(new GridData(GridData.FILL_BOTH));
+ types.setItems(names_t);
+ setSelections(sel_types, types, c_types);
+
+ message = new Label(c, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 4;
+ message.setLayoutData(gd);
+ message.setForeground(c.getDisplay().getSystemColor(SWT.COLOR_RED));
+
+ // DUMMY PLACEHOLDER
+ new Label(c, 0).setLayoutData(new GridData(GridData.BEGINNING));
+ b_ok = setupButton(c, IDialogConstants.OK_LABEL);
+ b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL);
+
+ c.getShell().setDefaultButton(b_ok);
+ c.pack();
+ Rectangle r = shell.getBounds();
+ r.width = 400;
+ shell.setBounds(r);
+ setButtons();
+ return c;
+ }
+
+ private void setButtons() {
+ if (b_ok == null) return; // while init only
+ message.setText(EMPTY_STR);
+ String name;
+ boolean enabled = true;
+ if (kind == ICSettingEntry.MACRO)
+ name = txt1.getText().trim();
+ else
+ name = txt2.getText().trim();
+ if (name.length() == 0) {
+ enabled = false;
+ message.setText("Name cannot be empty !"); //$NON-NLS-1$
+ }
+ if (enabled && existing != null && existing.contains(name)) {
+ message.setText("The same name already exists !"); //$NON-NLS-1$
+ enabled = false;
+ }
+ b_ok.setEnabled(enabled);
+ }
+
+ public void buttonPressed(SelectionEvent e) {
+ String s;
+ if (e.widget.equals(b_ok)) {
+ if (kind == ICSettingEntry.MACRO)
+ super.text1 = txt1.getText();
+ super.text2 = txt2.getText();
+ super.check1 = c_all.getSelection();
+ sel_langs = (c_langs.getSelection()) ? null : langs.getSelection();
+ sel_types = (c_types.getSelection()) ? null : types.getSelection();
+ result = true;
+ shell.dispose();
+ } else if (e.widget.equals(b_ko)) {
+ shell.dispose();
+ } else if (e.widget.equals(b_vars)) {
+ s = AbstractCPropertyTab.getVariableDialog(shell, cfgd);
+ if (s != null) txt2.insert(s);
+ } else if (e.widget.equals(b_work)) {
+ if (kind == ICSettingEntry.INCLUDE_PATH ||
+ kind == ICSettingEntry.LIBRARY_PATH)
+ s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, txt2.getText());
+ else
+ s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, txt2.getText());
+ if (s != null) {
+ s = strip_wsp(s);
+ txt2.setText(s);
+ text1 = s; // to be compared with final text
+ }
+ } else if (e.widget.equals(b_file)) {
+ if (kind == ICSettingEntry.INCLUDE_PATH ||
+ kind == ICSettingEntry.LIBRARY_PATH)
+ s = AbstractCPropertyTab.getFileSystemDirDialog(shell, txt2.getText());
+ else
+ s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText());
+ if (s != null) txt2.setText(s);
+ }
+ }
+
+ protected void setSelections(String[] sel, List lst, Button check) {
+ if (sel == null) {
+ lst.setEnabled(false);
+ check.setSelection(true);
+ } else {
+ lst.setEnabled(true);
+ check.setSelection(false);
+ if (sel.length == 0) return;
+ int cnt = 0;
+ String[] items = lst.getItems();
+
+ int[] indices = new int[items.length];
+ for (int i=0; i<indices.length; i++) indices[i] = -1;
+
+ for (int i=0; i<items.length; i++) {
+ for (int j=0; j<sel.length; j++) {
+ if (items[i].equals(sel[j])) {
+ indices[cnt++] = i;
+ break;
+ }
+ }
+ }
+ lst.setSelection(indices);
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java
new file mode 100644
index 00000000000..c88b2b0e895
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class ExpIncludeTab extends AbstractExportTab {
+
+ public ICLanguageSettingEntry doAdd(String s1, String s2) {
+ int flags = 0;
+ if (s1.equals(s2))
+ flags = ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CIncludePathEntry(s2, flags);
+ }
+
+ public ICLanguageSettingEntry doEdit(String s1, String s2) {
+ return doAdd(s1, s2);
+ }
+
+ public int getKind() { return ICLanguageSettingEntry.INCLUDE_PATH; }
+ public boolean hasValues() { return false; }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryPathTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryPathTab.java
new file mode 100644
index 00000000000..1b69727b3b0
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryPathTab.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class ExpLibraryPathTab extends AbstractExportTab implements IPathEntryStoreListener {
+ IPathEntryStore fStore;
+
+ public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+ updateData(getResDesc());
+ }
+
+ public ICLanguageSettingEntry doAdd(String s1, String s2) {
+ int flags = 0;
+ if (s1.equals(s2)) flags = ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CLibraryPathEntry(s2, flags);
+ }
+
+ public ICLanguageSettingEntry doEdit(String s1, String s2) {
+ return doAdd(s1, s2);
+ }
+
+ public int getKind() { return ICLanguageSettingEntry.LIBRARY_PATH; }
+ public boolean hasValues() { return false; }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java
new file mode 100644
index 00000000000..9377ce4ba6b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class ExpLibraryTab extends AbstractExportTab implements IPathEntryStoreListener {
+ IPathEntryStore fStore;
+
+ public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+ updateData(getResDesc());
+ }
+
+ public ICLanguageSettingEntry doAdd(String s1, String s2) {
+ int flags = 0;
+ if (s1.equals(s2)) flags = ICLanguageSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CLibraryFileEntry(s2, flags);
+ }
+
+ public ICLanguageSettingEntry doEdit(String s1, String s2) {
+ return doAdd(s1, s2);
+ }
+
+ public int getKind() { return ICLanguageSettingEntry.LIBRARY_FILE; }
+ public boolean hasValues() { return false; }
+}
+
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java
new file mode 100644
index 00000000000..4621d99bc16
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class ExpSymbolTab extends AbstractExportTab {
+
+ public ICLanguageSettingEntry doAdd(String s1, String s2) {
+ return new CMacroEntry(s1, s2, 0);
+ }
+
+ public ICLanguageSettingEntry doEdit(String s1, String s2) {
+ return doAdd(s1, s2);
+ }
+
+ public int getKind() { return ICLanguageSettingEntry.MACRO; }
+ public boolean hasValues() { return true; }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java
new file mode 100644
index 00000000000..cb65aaa48bc
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+
+/**
+ * Interface provides a set of utility methods
+ * provided by new CDT model property page.
+ * Property tabs associated to this page receive
+ * link to this interface and, so, can access
+ * required data, such as project, config etc.
+ *
+ * In addition, some methods allow to send
+ * control messages to other pages / tabs.
+ */
+
+public interface ICPropertyProvider extends ICOptionContainer {
+
+ // new list of config descriptions for given project
+ ICConfigurationDescription[] getCfgsReadOnly(IProject p);
+ // list of loaded config descriptions for current project
+ ICConfigurationDescription[] getCfgsEditable();
+ // Resource description for given object in current cfg
+ ICResourceDescription getResDesc();
+ // Resource description for given object, in given cfg
+ ICResourceDescription getResDesc(ICConfigurationDescription cfgd);
+ // get Affected object (project, folder, file)
+ IAdaptable getElement();
+ // ask page to enable or disable config selection
+ void enableConfigSelection (boolean enable);
+
+ //
+ // set of methods intended to handle messages
+ //
+ // 1. send message to all tabs in all pages
+ void informAll(int code, Object data);
+ // 2. send message to all pages.
+ void informPages(int code, Object data);
+ // 3. send message only to current page
+ void handleMessage(int code, Object data);
+
+ //
+ // set of methods for object kind check
+ //
+ boolean isForProject();
+ boolean isForFolder();
+ boolean isForFile();
+ boolean isForPrefs();
+
+ // Checks whether a project is new CDT model-style
+ boolean isCDTProject(IProject p);
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java
new file mode 100644
index 00000000000..054181868c3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Interface for tabs in new CDT model.
+ * All tabs available via extension point
+ * "org.eclipse.cdt.managedbuilder.ui.cPropertyTab"
+ * should implement this interface.
+ */
+public interface ICPropertyTab {
+
+ // kinds of message to be sent (and appropriate data class)
+ public static final int OK = 0; // perform OK (null)
+ public static final int APPLY = 1; // apply changes (IResourceDescription)
+ public static final int CANCEL = 2; // cancel changes (null)
+ public static final int DEFAULTS = 3; // set defaults (null)
+ public static final int UPDATE = 4; // re-read cfg (IConfiguration)
+ public static final int VISIBLE = 5; // set visible (not-null means true)
+ public static final int DISPOSE = 6; // dispose (null)
+ public static final int SET_ICON = 7; // inform tab about its icon (Image)
+
+ public static final int MAXCOMMON = 100; // values below are common
+ // values above are private
+ // Informs other tabs about changes in managed build settings.
+ // It may result in hiding/showing some tabs or changing their
+ // contents. Data field is not used (null).
+ public static final int MANAGEDBUILDSTATE = MAXCOMMON + 1;
+
+ /**
+ * Creation of all visible elements
+ * @param parent - composite where widgets should be created
+ * @param provider - underlying page
+ */
+ public void createControls(Composite parent, ICPropertyProvider provider);
+
+ /**
+ * Handle events sent by another tabs or pages
+ * Most of them are processed in <link>AbstractCPropertyTab</link>
+ * but this functionality can be overridden partially or fully.
+ * @param kind - message ID (see <link>AbstractCPropertyTab</link>)
+ * @param data - additional info, depanding of message kind.
+ */
+ public void handleTabEvent (int kind, Object data);
+
+ /**
+ * Returns true (by default) if page's contents is correct
+ * Returns false if page cannot be shown because it does
+ * not fit to other settings (for example, managed build
+ * settings are not possible when managed build is off).
+ */
+ public boolean canBeVisible();
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java
new file mode 100644
index 00000000000..fb7af68c518
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java
@@ -0,0 +1,27 @@
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+
+/**
+ * Represents class which is able to display
+ * "New configuration" dialog instead of standard one
+ * and, if user pressed OK, create new configuration
+ * on a basis of its internal data
+ *
+ * used by extension point:
+ * "org.eclipse.cdt.ui.newCfgDialog"
+ */
+public interface INewCfgDialog {
+ // Project to work with (set before open() !)
+ void setProject(ICProjectDescription prj);
+ // Title of dialog box (set before open() !)
+ void setTitle(String title);
+ // Shell to create dialog (set before open() !)
+ void setShell(Shell shell);
+ // Opens dialog and (after user presses OK)
+ // creates new configuration.
+ // Returns Windows.OK on success.
+ int open();
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java
new file mode 100644
index 00000000000..d0a9b34766b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+//import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+public class IncludeDialog extends AbstractPropertyDialog {
+ public String sdata;
+ public Button b_add2all;
+ public Text text;
+ private Button b_work;
+ private Button b_file;
+ private Button b_vars;
+ private Button b_ok;
+ private Button b_ko;
+ private int mode;
+ private ICConfigurationDescription cfgd;
+
+ static final int NEW_FILE = 0;
+ static final int NEW_DIR = 1;
+ static final int OLD_FILE = 2;
+ static final int OLD_DIR = 3;
+
+ static final int DIR_MASK = 1;
+ static final int OLD_MASK = 2;
+
+ public IncludeDialog(Shell parent, int _mode,
+ String title, String _data, ICConfigurationDescription _cfgd, int flags) {
+ super(parent, title);
+ mode = _mode;
+ sdata = _data;
+ cfgd = _cfgd;
+ if (flags == ICSettingEntry.VALUE_WORKSPACE_PATH)
+ text2 = sdata; // preserve "workspace" state
+ }
+
+ protected Control createDialogArea(Composite c) {
+ c.setLayout(new GridLayout(5, true));
+ GridData gd;
+
+ Label l1 = new Label(c, SWT.NONE);
+ if ((mode & DIR_MASK) == DIR_MASK)
+ l1.setText("Directory :"); //$NON-NLS-1$
+ else
+ l1.setText("File :"); //$NON-NLS-1$
+ gd = new GridData(GridData.BEGINNING);
+ gd.horizontalSpan = 5;
+ l1.setLayoutData(gd);
+
+ text = new Text(c, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 5;
+ gd.widthHint = 400;
+ text.setLayoutData(gd);
+ if ((mode & OLD_MASK) == OLD_MASK) { text.setText(sdata); }
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }});
+ b_add2all = new Button(c, SWT.CHECK);
+ b_add2all.setText("Add to all configurations"); //$NON-NLS-1$
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 4;
+ if ((mode & OLD_MASK) == OLD_MASK) {
+ gd.heightHint = 1;
+ b_add2all.setVisible(false);
+ }
+ b_add2all.setLayoutData(gd);
+
+ b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME);
+ new Label(c, 0).setLayoutData(new GridData()); // placeholder
+ b_ok = setupButton(c, IDialogConstants.OK_LABEL);
+ b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL);
+ b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME);
+ b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME);
+
+ c.getShell().setDefaultButton(b_ok);
+ c.pack();
+ setButtons();
+ return c;
+ }
+
+ private void setButtons() {
+ b_ok.setEnabled(text.getText().trim().length() > 0);
+ }
+
+ public void buttonPressed(SelectionEvent e) {
+ String s;
+ if (e.widget.equals(b_ok)) {
+ text1 = text.getText();
+ check1 = b_add2all.getSelection();
+ result = true;
+ shell.dispose();
+ } else if (e.widget.equals(b_ko)) {
+ shell.dispose();
+ } else if (e.widget.equals(b_work)) {
+ if ((mode & DIR_MASK)== DIR_MASK)
+ s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, text.getText());
+ else
+ s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, text.getText());
+ if (s != null) {
+ s = strip_wsp(s);
+ text.setText(s);
+ text2 = s; // to be compared with final text
+ }
+ } else if (e.widget.equals(b_file)) {
+ if ((mode & DIR_MASK)== DIR_MASK)
+ s = AbstractCPropertyTab.getFileSystemDirDialog(shell, text.getText());
+ else
+ s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText());
+ if (s != null) text.setText(s);
+ } else if (e.widget.equals(b_vars)) {
+ s = AbstractCPropertyTab.getVariableDialog(shell, cfgd);
+ if (s != null) text.insert(s);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java
new file mode 100644
index 00000000000..c8b14c5d430
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+public class IncludeTab extends AbstractLangsListTab {
+
+ public void additionalTableSet() {
+ TableColumn c = new TableColumn(table, SWT.NONE);
+ c.setWidth(210);
+ c.setText(NewUIMessages.getResourceString("IncludeTab.0")); //$NON-NLS-1$
+ showBIButton.setSelection(true);
+ }
+
+ public ICLanguageSettingEntry doAdd() {
+ IncludeDialog dlg = new IncludeDialog(
+ usercomp.getShell(), IncludeDialog.NEW_DIR,
+ NewUIMessages.getResourceString("IncludeTab.1"), //$NON-NLS-1$
+ EMPTY_STR, getResDesc().getConfiguration(), 0);
+ if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ toAll = dlg.check1;
+ int flags = 0;
+ if (dlg.text1.equals(dlg.text2)) { // see IncludeDialog why.
+ flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ }
+ return new CIncludePathEntry(dlg.text1, flags);
+ } else
+ return null;
+ }
+
+ public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+ IncludeDialog dlg = new IncludeDialog(
+ usercomp.getShell(), IncludeDialog.OLD_DIR,
+ NewUIMessages.getResourceString("IncludeTab.2"), //$NON-NLS-1$
+ ent.getValue(), getResDesc().getConfiguration(),
+ (ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
+ if (dlg.open()) {
+ int flags = 0;
+ if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CIncludePathEntry(dlg.text1, flags);
+ } else
+ return null;
+ }
+
+ public int getKind() { return ICSettingEntry.INCLUDE_PATH; }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LanguagesTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LanguagesTab.java
new file mode 100644
index 00000000000..a6bab080ffa
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LanguagesTab.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.model.ILanguageDescriptor;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+/**
+ *
+ * Functionality temporary commented
+ * because of changes in Languages manager.
+ *
+ *
+ */
+
+public class LanguagesTab extends AbstractCPropertyTab {
+
+ Table table;
+ LanguageManager lm = LanguageManager.getInstance();
+ IContentTypeManager ctm = Platform.getContentTypeManager();
+ IResource cr;
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ cr = (IResource)page.getElement();
+
+ usercomp.setLayout(new GridLayout(2, false));
+
+ table = new Table(usercomp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ String[] headers = new String[] {NewUIMessages.getResourceString("LanguagesTab.0"), NewUIMessages.getResourceString("LanguagesTab.1"), }; //$NON-NLS-1$ //$NON-NLS-2$
+
+ for (int i = 0; i < headers.length; i++) {
+ TableColumn tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(headers[i]);
+ tc.setWidth(200);
+ }
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ table.setLayoutData(gd);
+
+ }
+
+ class ComboDataHolder {
+ String id;
+ ILanguageDescriptor[] des;
+
+ ComboDataHolder(String _id, ILanguageDescriptor[] _des) {
+ id = _id;
+ des = _des;
+ }
+ }
+
+ public void updateData(ICResourceDescription cfgd2) {
+ /*
+ table.removeAll();
+ String[] ids = lm.getRegisteredContentTypeIds();
+ for (int i=0; i< ids.length; i++) {
+ IContentType ct = ctm.getContentType(ids[i]);
+ ILanguageDescriptor[] des = null;
+ boolean needForFile = true;
+ if (cr instanceof IFile) {
+ needForFile = ct.isAssociatedWith(cr.getName());
+ }
+ if (needForFile) {
+ des = lm.getDescriptorsForContentTypeId(ids[i]);
+ }
+ if (des != null && des.length > 0) {
+ TableItem t = new TableItem(table, SWT.NONE);
+ t.setText(0, ct.getName());
+ t.setData(ct);
+
+ TableEditor editor = new TableEditor(table);
+ CCombo combo = new CCombo(table, SWT.NONE);
+ combo.setData(new ComboDataHolder(ct.getId(), des));
+ int pos = 0;
+
+ ILanguageDescriptor curr = lm.getLanguageForContentTypeId(cr.getProject(), cr.getFullPath().removeFirstSegments(1), ids[i]);
+ for (int j=0; j<des.length; j++) {
+ combo.add(des[j].getName());
+ if (des[j].equals(curr)) pos = j; // selected language
+ }
+ combo.select(pos);
+ combo.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetSelected(SelectionEvent e) {
+ int n = ((CCombo)e.widget).getSelectionIndex();
+ ComboDataHolder h = (ComboDataHolder)e.widget.getData();
+ try {
+ lm.setLanguageForContentTypeId(cr.getProject(), cr.getFullPath().removeFirstSegments(1), h.id, h.des[n]);
+ } catch (CoreException e2) {}
+ }});
+ editor.grabHorizontal = true;
+ editor.setEditor(combo, t, 1);
+ }
+ }
+ */
+ }
+
+ public void setVisible(boolean _visible) {
+ super.setVisible(_visible);
+ page.enableConfigSelection(!_visible);
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+// ICProjectDescription p1 = src.getConfiguration().getProjectDescription();
+// ICProjectDescription p2 = dst.getConfiguration().getProjectDescription();
+
+ }
+
+ protected void performDefaults() {
+ /*
+ String[] ids = lm.getRegisteredContentTypeIds();
+ for (int i=0; i< ids.length; i++) {
+ IContentType ct = ctm.getContentType(ids[i]);
+ ILanguageDescriptor curr = lm.getDefaultLanguageDescriptor(ct);
+ try {
+ lm.setLanguageForContentTypeId(cr.getProject(), cr.getFullPath().removeFirstSegments(1), ids[i], curr);
+ } catch (CoreException e) {}
+ }
+ updateData(getResDesc());
+ */
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java
new file mode 100644
index 00000000000..0e26e671fd3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+public class LibraryPathTab extends AbstractLangsListTab implements IPathEntryStoreListener {
+ IPathEntryStore fStore;
+
+ public void additionalTableSet() {
+ TableColumn c = new TableColumn(table, SWT.NONE);
+ c.setWidth(300);
+ c.setText(NewUIMessages.getResourceString("LibraryPathTab.0")); //$NON-NLS-1$
+ }
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ ((GridData)langTree.getLayoutData()).widthHint = 0;
+ langTree.setVisible(false);
+ }
+
+ public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+ updateData(getResDesc());
+ }
+
+ public ICLanguageSettingEntry doAdd() {
+ IncludeDialog dlg = new IncludeDialog(
+ usercomp.getShell(), IncludeDialog.NEW_DIR,
+ NewUIMessages.getResourceString("LibraryPathTab.1"), //$NON-NLS-1$
+ EMPTY_STR, getResDesc().getConfiguration(), 0);
+ if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ int flags = 0;
+ if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CLibraryPathEntry(dlg.text1, flags);
+ }
+ return null;
+ }
+
+ public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+ IncludeDialog dlg = new IncludeDialog(
+ usercomp.getShell(), IncludeDialog.OLD_DIR,
+ NewUIMessages.getResourceString("LibraryPathTab.2"), //$NON-NLS-1$
+ ent.getValue(), getResDesc().getConfiguration(),
+ (ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
+ if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ int flags = 0;
+ if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CLibraryPathEntry(dlg.text1, flags);
+ }
+ return null;
+ }
+
+ public int getKind() { return ICSettingEntry.LIBRARY_PATH; }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java
new file mode 100644
index 00000000000..d8111a312c7
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreListener {
+ IPathEntryStore fStore;
+
+ public void additionalTableSet() {
+ TableColumn c = new TableColumn(table, SWT.NONE);
+ c.setWidth(300);
+ c.setText(NewUIMessages.getResourceString("LibraryTab.0")); //$NON-NLS-1$
+ }
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ ((GridData)langTree.getLayoutData()).widthHint = 0;
+ langTree.setVisible(false);
+ }
+
+ public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+ updateData(getResDesc());
+ }
+
+ public ICLanguageSettingEntry doAdd() {
+ IncludeDialog dlg = new IncludeDialog(
+ usercomp.getShell(), IncludeDialog.NEW_FILE,
+ NewUIMessages.getResourceString("LibraryTab.1"), //$NON-NLS-1$
+ EMPTY_STR, getResDesc().getConfiguration(), 0);
+ if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ int flags = 0;
+ if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CLibraryFileEntry(dlg.text1, flags);
+ }
+ return null;
+ }
+
+ public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+ IncludeDialog dlg = new IncludeDialog(
+ usercomp.getShell(), IncludeDialog.OLD_FILE,
+ NewUIMessages.getResourceString("LibraryTab.2"), //$NON-NLS-1$
+ ent.getValue(), getResDesc().getConfiguration(),
+ (ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
+ if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ int flags = 0;
+ if (dlg.text1.equals(dlg.text2)) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+ return new CLibraryFileEntry(dlg.text1, flags);
+ }
+ return null;
+ }
+
+ public int getKind() { return ICSettingEntry.LIBRARY_FILE; }
+
+}
+
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java
new file mode 100644
index 00000000000..dc09ad88dc9
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java
@@ -0,0 +1,288 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 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 Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class ManageConfigDialog extends Dialog {
+ public static final String MANAGE_TITLE = NewUIMessages.getResourceString("ManageConfigDialog.0"); //$NON-NLS-1$
+ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.newCfgDialog"; //$NON-NLS-1$
+ public static final String ELEMENT_NAME = "dialog"; //$NON-NLS-1$
+ public static final String CLASS_NAME = "class"; //$NON-NLS-1$
+ public static final String TITLE_NAME = "title"; //$NON-NLS-1$
+ public static final String ID_NAME = "mbs_id"; //$NON-NLS-1$
+
+ // String constants
+ private static final String CMN_PREFIX = "BuildPropertyCommon"; //$NON-NLS-1$
+ private static final String CMN_LABEL = CMN_PREFIX + ".label"; //$NON-NLS-1$
+ private static final String NEW = CMN_LABEL + ".new"; //$NON-NLS-1$
+ private static final String REMOVE = CMN_LABEL + ".remove"; //$NON-NLS-1$
+ private static final String PREFIX = "ManageConfig"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String RENAME = LABEL + ".rename"; //$NON-NLS-1$
+ private static final String NEW_CONF_DLG = LABEL + ".new.config.dialog"; //$NON-NLS-1$
+ private static final String RENAME_CONF_DLG = LABEL + ".rename.config.dialog"; //$NON-NLS-1$
+
+ // The list of configurations to delete
+// private IManagedProject mp;
+ ICProjectDescription des;
+ private String title;
+ private String mbs_id;
+ protected Table table;
+
+ protected Button actBtn;
+ protected Button newBtn;
+ protected Button renBtn;
+ protected Button delBtn;
+
+ public static boolean manage(IProject prj) {
+ ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj);
+ ManageConfigDialog d = new ManageConfigDialog(CUIPlugin.getActiveWorkbenchShell(),
+ prj.getName()+ " : " + MANAGE_TITLE, prjd); //$NON-NLS-1$
+ if (d.open() == OK) {
+ try {
+ CoreModel.getDefault().setProjectDescription(prj, prjd);
+ } catch (CoreException e) { return false; }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param parentShell
+ */
+ public ManageConfigDialog(Shell parentShell, String _title, ICProjectDescription prjd) {
+ super(parentShell);
+ title = _title;
+ des = prjd;
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null) shell.setText(title);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout(4, true));
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+
+ // Create the current config table
+ table = new Table(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
+ GridData gd = new GridData(GridData.FILL);
+ gd.horizontalSpan = 4;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn col = new TableColumn(table, SWT.NONE);
+ col.setText(NewUIMessages.getResourceString("ManageConfigDialog.1")); //$NON-NLS-1$
+ col.setWidth(100);
+ col = new TableColumn(table, SWT.NONE);
+ col.setText(NewUIMessages.getResourceString("ManageConfigDialog.2")); //$NON-NLS-1$
+ col.setWidth(120);
+ col = new TableColumn(table, SWT.NONE);
+ col.setText(NewUIMessages.getResourceString("ManageConfigDialog.3")); //$NON-NLS-1$
+ col.setWidth(80);
+
+ actBtn = new Button(composite, SWT.PUSH);
+ actBtn.setText(NewUIMessages.getResourceString("ManageConfigDialog.4")); //$NON-NLS-1$
+ actBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ actBtn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] tis = table.getSelection();
+ if (tis == null || tis.length != 1) return;
+ ICConfigurationDescription cfgd = (ICConfigurationDescription)tis[0].getData();
+// cfgd.setActive();
+ des.setActiveConfiguration(cfgd);
+ updateData();
+ }} );
+
+ newBtn = new Button(composite, SWT.PUSH);
+ newBtn.setText(NewUIMessages.getResourceString(NEW));
+ newBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ newBtn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleNewPressed();
+ }} );
+
+ delBtn = new Button(composite, SWT.PUSH);
+ delBtn.setText(NewUIMessages.getResourceString(REMOVE));
+ delBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ delBtn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleRemovePressed();
+ }} );
+
+ renBtn = new Button(composite, SWT.PUSH);
+ renBtn.setText(NewUIMessages.getResourceString(RENAME));
+ renBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ renBtn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleRenamePressed();
+ }} );
+
+ updateData();
+ return composite;
+ }
+ /*
+ * Event handler for the add button
+ */
+ protected void handleNewPressed() {
+ INewCfgDialog dialog = handleSpecificMBS(mbs_id);
+ if (dialog == null) { // default (core) implementation.
+ dialog = new NewConfigurationDialog(getShell());
+ dialog.setTitle(NewUIMessages.getResourceString(NEW_CONF_DLG));
+ }
+ dialog.setProject(des);
+ if (dialog.open() == OK) updateData();
+ }
+
+ /**
+ * Tries to load MBS-specific creation dialog a
+ * @return false if there's no such feature
+ */
+ protected INewCfgDialog handleSpecificMBS(String id) {
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint == null) return null;
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions == null) return null;
+ for (int i = 0; i < extensions.length; ++i) {
+ IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+ for (int k = 0; k < elements.length; k++) {
+ if (elements[k].getName().equals(ELEMENT_NAME)) {
+ if (! id.equals(elements[k].getAttribute(ID_NAME)))
+ continue;
+ INewCfgDialog dialog = null;
+ try {
+ dialog = (INewCfgDialog) elements[k].createExecutableExtension(CLASS_NAME);
+ dialog.setTitle(elements[k].getAttribute(TITLE_NAME));
+ dialog.setShell(getShell());
+ return dialog;
+ } catch (CoreException e) {
+ System.out.println("Cannot create dialog: " + e.getLocalizedMessage()); //$NON-NLS-1$
+ return null;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-javadoc) Event handler for the rename button
+ */
+ protected void handleRenamePressed() {
+ int sel = table.getSelectionIndex();
+ if (sel != -1) {
+ ICConfigurationDescription cfgd = (ICConfigurationDescription) table.getItem(sel).getData();
+ RenameConfigurationDialog dialog = new RenameConfigurationDialog(
+ getShell(), cfgd, des.getConfigurations(),
+ NewUIMessages.getResourceString(RENAME_CONF_DLG));
+ if (dialog.open() == OK) {
+ cfgd.setName(dialog.getNewName());
+ cfgd.setDescription(dialog.getNewDescription());
+ updateData();
+ }
+ }
+ }
+
+ /*
+ * (non-javadoc) Event handler for the remove button
+ */
+ protected void handleRemovePressed() {
+ TableItem[] tis = table.getSelection();
+ if (tis == null || tis.length < 1) return;
+ String[] names = new String[tis.length];
+ for (int i=0; i<tis.length; i++)
+ names[i] = tis[i].getText(0);
+ // Get the confirmation from user before deleting the configuration
+ Shell shell = CUIPlugin.getActiveWorkbenchShell();
+ boolean shouldDelete = MessageDialog.openQuestion(shell,
+ NewUIMessages.getResourceString("ManageConfig.deletedialog.title"), //$NON-NLS-1$
+ NewUIMessages.getFormattedString("ManageConfig.deletedialog.message", //$NON-NLS-1$
+ names));
+ if (shouldDelete) {
+ boolean wasActive = false;
+ for (int j=0; j<tis.length; j++) {
+ ICConfigurationDescription cfgd = (ICConfigurationDescription)tis[j].getData();
+ if (cfgd.isActive()) wasActive = true;
+ des.removeConfiguration(cfgd);
+
+ }
+ ICConfigurationDescription[] cfgds = des.getConfigurations();
+ if (wasActive && cfgds.length > 0) {
+ cfgds[0].setActive();
+ des.setActiveConfiguration(cfgds[0]);
+ }
+ updateData();
+ }
+ }
+
+ private void updateButtons() {
+ int sel = table.getSelectionCount();
+ delBtn.setEnabled(sel > 0 & sel < table.getItemCount());
+ renBtn.setEnabled(sel == 1);
+ actBtn.setEnabled(sel == 1);
+ }
+
+ /**
+ * refresh configs table after changes
+ */
+ private void updateData() {
+ table.removeAll();
+ ICConfigurationDescription[] cfgds = des.getConfigurations();
+ mbs_id = cfgds[0].getBuildSystemId();
+ Arrays.sort(cfgds, CDTListComparator.getInstance());
+ for (int i=0; i<cfgds.length; i++ ) {
+ TableItem t = new TableItem(table, 0);
+ t.setText(0, cfgds[i].getName());
+ t.setText(1, cfgds[i].getDescription());
+ t.setText(2, cfgds[i].isActive() ? NewUIMessages.getResourceString("ManageConfigDialog.5") : ""); //$NON-NLS-1$ //$NON-NLS-2$
+ t.setData(cfgds[i]);
+ }
+ if (table.getItemCount() > 0) table.select(0);
+ table.setFocus();
+ updateButtons();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManagedBuilderHelpContextIds.java
index 4ec7773cf11..081951536e6 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderHelpContextIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManagedBuilderHelpContextIds.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
+ * Copyright (c) 2002, 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
+package org.eclipse.cdt.ui.newui;
import org.eclipse.cdt.ui.CUIPlugin;
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/MultiLineTextFieldEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java
index 8da214c39d7..a840626ac0f 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/MultiLineTextFieldEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 BitMethods Inc and others.
+ * Copyright (c) 2004, 2007 BitMethods Inc 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
@@ -8,12 +8,11 @@
* Contributors:
* BitMethods Inc - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.ui.newui;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.FieldEditor;
-import org.eclipse.jface.util.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@@ -76,11 +75,6 @@ public class MultiLineTextFieldEditor extends FieldEditor {
private Text textField;
/**
- * Width of text field in characters; initially unlimited.
- */
- private int widthInChars = UNLIMITED;
-
- /**
* Text limit of text field in characters; initially unlimited.
*/
private int textLimit = UNLIMITED;
@@ -127,10 +121,9 @@ public class MultiLineTextFieldEditor extends FieldEditor {
int strategy,
Composite parent) {
init(name, labelText);
- widthInChars = width;
setValidateStrategy(strategy);
isValid = false;
- errorMessage = ManagedBuilderUIMessages.getResourceString(ERROR_MESSAGE);
+ errorMessage = NewUIMessages.getResourceString(ERROR_MESSAGE);
createControl(parent);
}
@@ -320,8 +313,6 @@ public class MultiLineTextFieldEditor extends FieldEditor {
/**
* Returns this field editor's text control.
- *
- * @param parent the parent
* @return the text control, or <code>null</code> if no
* text field is created yet
*/
@@ -379,7 +370,6 @@ public class MultiLineTextFieldEditor extends FieldEditor {
});
break;
default :
- Assert.isTrue(false, "Unknown validate strategy"); //$NON-NLS-1$
}
textField.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
@@ -432,7 +422,6 @@ public class MultiLineTextFieldEditor extends FieldEditor {
* nothing. Subclasses wishing to perform validation should override
* both this method and <code>isValid</code>.
* </p>
- * @see #isValid
*/
protected void refreshValidState() {
isValid = checkState();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java
new file mode 100644
index 00000000000..a989ca7023b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java
@@ -0,0 +1,369 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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 Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+
+public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
+ // String constants
+ private static final String PREFIX = "NewConfiguration"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String ERROR = PREFIX + ".error"; //$NON-NLS-1$
+ private static final String NAME = LABEL + ".name"; //$NON-NLS-1$
+ private static final String GROUP = LABEL + ".group"; //$NON-NLS-1$
+ private static final String DUPLICATE = ERROR + ".duplicateName"; //$NON-NLS-1$
+ private static final String CASE = ERROR + ".caseName"; //$NON-NLS-1$
+ private static final String INVALID = ERROR + ".invalidName"; //$NON-NLS-1$
+ private static final String DESCRIPTION = LABEL + ".description"; //$NON-NLS-1$
+
+ // Widgets
+ private Text configName;
+ private Text configDescription;
+ private Combo cloneConfigSelector;
+ private Label statusLabel;
+
+ /** Default configurations defined in the toolchain description */
+ private ICProjectDescription des;
+ private ICConfigurationDescription[] cfgds;
+ private ICConfigurationDescription parentConfig;
+ private String newName;
+ private String newDescription;
+ private String title;
+
+
+ /**
+ */
+ protected NewConfigurationDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(getShellStyle()|SWT.RESIZE);
+ newName = new String();
+ newDescription = new String();
+ }
+
+ public void setProject(ICProjectDescription prj) {
+ des = prj;
+ cfgds = des.getConfigurations();
+ }
+
+ public void setTitle(String _title) {
+ title = _title;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog. Cache the name and base config selections.
+ * We don't have to worry that the index or name is wrong because we
+ * enable the OK button IFF those conditions are met.
+ */
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+ String description = new String();
+ String nameAndDescription = new String();
+ String baseConfigNameAndDescription = new String();
+
+ newName = configName.getText().trim();
+ newDescription = configDescription.getText().trim();
+
+ baseConfigNameAndDescription = cloneConfigSelector.getItem(cloneConfigSelector.getSelectionIndex());
+ for (int i = 0; i < cfgds.length; i++) {
+ description = cfgds[i].getDescription();
+
+ if( (description == null) || (description.equals("")) ){ //$NON-NLS-1$
+ nameAndDescription = cfgds[i].getName();
+ } else {
+ nameAndDescription = cfgds[i].getName() + "( " + description + " )"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (nameAndDescription.equals(baseConfigNameAndDescription)) {
+ parentConfig = cfgds[i];
+ break;
+ }
+ }
+ newConfiguration();
+ } else {
+ newName = null;
+ newDescription = null;
+ parentConfig = null;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null)
+ shell.setText(title);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ configName.setFocus();
+ if (configName != null) {
+ configName.setText(newName);
+ }
+ validateState();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Create a group for the name & description
+
+ final Group group1 = new Group(composite, SWT.NONE);
+ group1.setFont(composite.getFont());
+ GridLayout layout1 = new GridLayout(3, false);
+ group1.setLayout(layout1);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ group1.setLayoutData(gd);
+
+ // Add a label and a text widget for Configuration's name
+ final Label nameLabel = new Label(group1, SWT.LEFT);
+ nameLabel.setFont(parent.getFont());
+ nameLabel.setText(NewUIMessages.getResourceString(NAME));
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ gd.grabExcessHorizontalSpace = false;
+ nameLabel.setLayoutData(gd);
+
+ configName = new Text(group1, SWT.SINGLE | SWT.BORDER);
+ configName.setFont(group1.getFont());
+ configName.setText(getNewName());
+ configName.setFocus();
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ configName.setLayoutData(gd);
+ configName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateState();
+ }
+ });
+
+// Add a label and a text widget for Configuration's description
+ final Label descriptionLabel = new Label(group1, SWT.LEFT);
+ descriptionLabel.setFont(parent.getFont());
+ descriptionLabel.setText(NewUIMessages.getResourceString(DESCRIPTION));
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 1;
+ gd.grabExcessHorizontalSpace = false;
+ descriptionLabel.setLayoutData(gd);
+ configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
+ configDescription.setFont(group1.getFont());
+ configDescription.setText(getNewDescription());
+ configDescription.setFocus();
+
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ configDescription.setLayoutData(gd);
+
+ final Group group = new Group(composite, SWT.NONE);
+ group.setFont(composite.getFont());
+ group.setText(NewUIMessages.getResourceString(GROUP));
+ GridLayout layout = new GridLayout(1, false);
+ group.setLayout(layout);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ group.setLayoutData(gd);
+
+ cloneConfigSelector = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+ cloneConfigSelector.setFont(group.getFont());
+ cloneConfigSelector.setItems(getDefinedConfigNamesAndDescriptions());
+ int index = cloneConfigSelector.indexOf(newName);
+ cloneConfigSelector.select(index < 0 ? 0 : index);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ cloneConfigSelector.setLayoutData(gd);
+ cloneConfigSelector.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ validateState();
+ }
+ });
+
+ statusLabel = new Label(composite, SWT.CENTER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ statusLabel.setLayoutData(gd);
+ statusLabel.setFont(composite.getFont());
+ statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
+
+ return composite;
+ }
+
+
+ /*
+ * Returns the array of configuration names defined for this managed project.
+ * This list will be used to populate the list of configurations to
+ * clone.
+ */
+ private String [] getDefinedConfigNamesAndDescriptions() {
+ String [] namesAndDescriptions = new String[cfgds.length];
+ for (int i = 0; i < cfgds.length; ++i) {
+ if ( (cfgds[i].getDescription() == null) || cfgds[i].getDescription().equals("")) //$NON-NLS-1$
+ namesAndDescriptions[i] = cfgds[i].getName();
+ else
+ namesAndDescriptions[i] = cfgds[i].getName() + "( " + cfgds[i].getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return namesAndDescriptions;
+ }
+
+ /**
+ * @return <code>String</code> containing the name chosen by the user for the
+ * new configuration.
+ */
+ public String getNewName() {
+ return newName;
+ }
+
+ protected boolean isDuplicateName(String newName) {
+ for (int i = 0; i < cfgds.length; i++) {
+ if (cfgds[i].getName().equals(newName))
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean isSimilarName(String newName) {
+ for (int i = 0; i < cfgds.length; i++) {
+ if (cfgds[i].getName().equalsIgnoreCase(newName))
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * Checks the argument for leading whitespaces and invalid directory name characters.
+ * @param name
+ * @return <I>true</i> is the name is a valid directory name with no whitespaces
+ */
+ private boolean validateName(String name) {
+ // Names must be at least one character in length
+ if (name.trim().length() == 0)
+ return false;
+
+ // Iterate over the name checking for bad characters
+ char[] chars = name.toCharArray();
+ // No whitespaces at the start of a name
+ if (Character.isWhitespace(chars[0])) {
+ return false;
+ }
+ for (int index = 0; index < chars.length; ++index) {
+ // Config name must be a valid dir name too, so we ban "\ / : * ? " < >" in the names
+ if (!Character.isLetterOrDigit(chars[index])) {
+ switch (chars[index]) {
+ case '/':
+ case '\\':
+ case ':':
+ case '*':
+ case '?':
+ case '\"':
+ case '<':
+ case '>':
+ return false;
+ default:
+ break;
+ }
+ }
+ }
+ return true;
+ }
+ /* (non-Javadoc)
+ * Update the status message and button state based on the input selected
+ * by the user
+ *
+ */
+ private void validateState() {
+ String s = null;
+ String currentName = configName.getText();
+ // Trim trailing whitespace
+ while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
+ currentName = currentName.substring(0, currentName.length()-1);
+ }
+ // Make sure that the name is at least one character in length
+ if (currentName.length() == 0) {
+ // No error message, but cannot select OK
+ s = ""; //$NON-NLS-1$
+ } else if (cfgds.length == 0) {
+ s = ""; //$NON-NLS-1$
+ // Make sure the name is not a duplicate
+ } else if (isDuplicateName(currentName)) {
+ s = NewUIMessages.getFormattedString(DUPLICATE, currentName);
+ } else if (isSimilarName(currentName)) {
+ s = NewUIMessages.getFormattedString(CASE, currentName);
+ } else if (!validateName(currentName)) {
+ // TODO Create a decent I18N string to describe this problem
+ s = NewUIMessages.getFormattedString(INVALID, currentName);
+ }
+ if (statusLabel == null) return;
+ Button b = getButton(IDialogConstants.OK_ID);
+ if (s != null) {
+ statusLabel.setText(s);
+ statusLabel.setVisible(true);
+ if (b != null) b.setEnabled(false);
+ } else {
+ statusLabel.setVisible(false);
+ if (b != null) b.setEnabled(true);
+ }
+ return;
+ }
+ public String getNewDescription() {
+ return newDescription;
+ }
+
+ /**
+ * Create a new configuration, using the values currently set in
+ * the dialog.
+ */
+ private void newConfiguration() {
+ String id = CDataUtil.genId(parentConfig.getId());
+ try {
+ ICConfigurationDescription newcfg = des.createConfiguration(id, newName, parentConfig);
+ newcfg.setDescription(newDescription);
+ } catch (CoreException e) {
+ System.out.println("Cannot create config\n"+ e.getLocalizedMessage()); //$NON-NLS-1$
+ }
+ }
+
+ // useless in our case
+ public void setShell(Shell shell) {}
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewUIMessages.java
index 6b6aa066588..cdbb5e8099b 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuilderUIMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewUIMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui;
+package org.eclipse.cdt.ui.newui;
import java.text.MessageFormat;
import java.util.MissingResourceException;
@@ -17,9 +17,9 @@ import java.util.ResourceBundle;
/**
* @since 2.0
*/
-public class ManagedBuilderUIMessages {
+public class NewUIMessages {
// Bundle ID
- private static final String BUNDLE_ID = "org.eclipse.cdt.managedbuilder.internal.ui.PluginResources"; //$NON-NLS-1$
+ private static final String BUNDLE_ID = "org.eclipse.cdt.ui.newui.PluginResources"; //$NON-NLS-1$
//Resource bundle.
private static ResourceBundle resourceBundle;
@@ -49,7 +49,7 @@ public class ManagedBuilderUIMessages {
}
}
- private ManagedBuilderUIMessages() {
+ private NewUIMessages() {
// No constructor
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_BuildSettings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_BuildSettings.java
new file mode 100644
index 00000000000..85f5ac5f3be
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_BuildSettings.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+
+/**
+ * The class have the same functionality as superclass.
+ * The only need to create it is distinguishing tabs.
+ *
+ * @author okrasiln
+ *
+ */
+public class Page_BuildSettings extends AbstractPage {
+ protected boolean isSingle() { return false; }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ExpPathAndSymb.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ExpPathAndSymb.java
new file mode 100644
index 00000000000..956f2f93c2a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ExpPathAndSymb.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+
+/**
+ * The class have the same functionality as superclass.
+ * The only need to create it is distinguishing tabs.
+ *
+ */
+public class Page_ExpPathAndSymb extends AbstractPage {
+
+ protected boolean isSingle() {return false; }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Languages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Languages.java
new file mode 100644
index 00000000000..27102c65182
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Languages.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+public class Page_Languages extends AbstractPage {
+ protected boolean isSingle() { return true; }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ConvertStartup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_PathAndSymb.java
index 95b91f4859a..7da44a0baf3 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ConvertStartup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_PathAndSymb.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2007 Intel 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
@@ -8,22 +8,18 @@
* Contributors:
* Intel Corporation - initial API and implementation
*******************************************************************************/
+package org.eclipse.cdt.ui.newui;
-package org.eclipse.cdt.managedbuilder.internal.ui;
-import org.eclipse.cdt.managedbuilder.ui.actions.ConvertTargetAction;
-import org.eclipse.ui.IStartup;
-
-
-public class ConvertStartup implements IStartup {
+/**
+ * The class have the same functionality as superclass.
+ * The only need to create it is distinguishing tabs.
+ *
+ */
+public class Page_PathAndSymb extends AbstractPage {
- /* (non-Javadoc)
- * @see org.eclipse.ui.IStartup#earlyStartup()
- */
- /*
- * This code is needed incase we want to add cascading menu for project converters in UI.
- */
- public void earlyStartup() {
- ConvertTargetAction.initStartup();
+ protected boolean isSingle() {
+ return false;
}
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ToolChain.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ToolChain.java
new file mode 100644
index 00000000000..486564f0a3a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_ToolChain.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+
+public class Page_ToolChain extends AbstractPage {
+ protected boolean isSingle() { return true; }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Variables.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Variables.java
new file mode 100644
index 00000000000..0988f94e7f8
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_Variables.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+
+public class Page_Variables extends AbstractPage {
+ protected boolean isSingle() { return true; }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties
index d3cef4a727f..1a8f270a229 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
+# Copyright (c) 2000, 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
@@ -310,6 +310,12 @@ ManageConfig.label.rename.config.dialog=Rename configuration
ManageConfig.deletedialog.message=Are you sure you want to delete the "{0}" configuration?
ManageConfig.deletedialog.title=Confirm Delete
ManageConfig.tip.convert=Converts the selected configuration to use a tool chain selected in the conversion target list
+ManageConfigDialog.1=Configuration
+ManageConfigDialog.2=Description
+ManageConfigDialog.3=Status
+ManageConfigDialog.4=Set Active
+ManageConfigDialog.5=Active
+ManageConfigDialog.0=Manage configurations...
ManageConfig.tip.conversionTarget=A list of conversion targets available for the selected configuration
# Toolchain Conversion Target confirmation Dialog
@@ -374,4 +380,103 @@ ProjectConvert.noConverterErrordialog.message=There are no converters available
ProjectConvert.title=Project Converters for {0}
ProjectConvert.convertersList=Converters List
- \ No newline at end of file
+
+ScannerConfigOptionsDialog.title=Discovery Options
+ScannerConfigOptionsDialog.description=Set the scanner configuration discovery options for this project
+ScannerConfigOptionsDialog.scGroup.label=Automated discovery of paths and symbols
+ScannerConfigOptionsDialog.scGroup.enabled.button=Automate discovery of paths and symbols
+ScannerConfigOptionsDialog.scGroup.problemReporting.enabled.button=Report path detection problems
+ScannerConfigOptionsDialog.scGroup.selectedProfile.combo=Discovery profile:
+ScannerConfigOptionsDialog.profile.group.label=Discovery profile options
+ScannerConfigOptionsDialog.boProvider.parser.enabled.button=Enable build output scanner info discovery
+ScannerConfigOptionsDialog.boProvider.open.label=Load build output from file
+ScannerConfigOptionsDialog.boProvider.browse.button=Browse...
+ScannerConfigOptionsDialog.boProvider.browse.openFileDialog=Build output file:
+ScannerConfigOptionsDialog.boProvider.load.button=Load
+ScannerConfigOptionsDialog.siProvider.parser.enabled.button=Enable generate scanner info command
+ScannerConfigOptionsDialog.siProvider.command.label=Compiler invocation command
+ScannerConfigOptionsDialog.siProvider.browse.button=Browse...
+ScannerConfigOptionsDialog.siProvider.browse.runCommandDialog='gcc' command:
+ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
+ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
+ScannerConfigOptionsDialog.common.variables.button=Variables...
+
+ScannerConfigOptionsDialog.unsavedchanges.title=Setting C/C++ Make Project Discovery Options
+ScannerConfigOptionsDialog.unsavedchanges.message=The C/C++ Make Project Discovery Options property page contains unsaved modifications. Do you want to save changes so that other discovery related settings can be updated?
+ScannerConfigOptionsDialog.unsavedchanges.button.save=Apply
+ScannerConfigOptionsDialog.unsavedchanges.button.cancel=Cancel
+
+ScannerConfigOptionsDialog.error.title=Error Setting Project Discovery options
+ScannerConfigOptionsDialog.error.message=An error occurred while setting the project discovery options
+
+# --- DiscoveredScannerConfigurationContainerPage ---
+DiscoveredScannerConfigurationContainerPage.title=Edit container
+DiscoveredScannerConfigurationContainerPage.description=Manage discovered scanner configuration
+DiscoveredScannerConfigurationContainerPage.list.title=Discovered include paths and symbol definitions
+DiscoveredScannerConfigurationContainerPage.initialization.error.message=Error initializing Discovered paths container
+
+# new strings
+
+AbstractCPropertyTab.0=Select build variable
+AbstractPage.0=Unknown element selected
+AbstractPage.1=This file has no properties to display
+AbstractPage.2=This project is not a CDT project
+AbstractPage.4=[ All configurations ]
+AbstractPage.5=[ Multiple configurations...]
+
+AbstractLangsListTab.0=Show built-in values
+AbstractLangsListTab.1=Languages
+AbstractLangsListTab.2=Export
+AbstractLangsListTab.3=\ [exp]
+AbstractPrefPage.0=Preference settings will be applied to new projects\n
+AbstractPrefPage.1=only in case when there was no toolchains selected.
+CLocationTab.0=Filter (empty)
+CLocationTab.1=Filter (
+CLocationTab.2=,
+CLocationTab.3=)
+CLocationTab.4=Add workspace folder
+CLocationTab.5=Create / link folder
+CLocationTab.6=Edit filter data
+CLocationTab.7=Delete folder
+EnvDialog.0=Name:
+EnvDialog.1=Value:
+EnvDialog.2=Variables
+EnvDialog.3=Add to all configurations
+EnvironmentTab.0=Environment variables to set
+EnvironmentTab.1=Variable
+EnvironmentTab.2=Value
+EnvironmentTab.3=Append variables to native environment
+EnvironmentTab.4=Replace native environment with specified one
+EnvironmentTab.5=New...
+EnvironmentTab.6=Select...
+EnvironmentTab.7=Edit...
+EnvironmentTab.8=Remove
+EnvironmentTab.9=Undefine
+EnvironmentTab.10=New variable
+EnvironmentTab.11=Edit variable
+EnvironmentTab.12=Variables list
+EnvironmentTab.13=Add to all configurations
+IncludeTab.0=Include paths
+IncludeTab.1=Add directory path
+IncludeTab.2=Change directory path
+LanguagesTab.0=Content type
+LanguagesTab.1=Language
+LibraryPathTab.0=Library paths
+LibraryPathTab.1=Add library path
+LibraryPathTab.2=Change library path
+LibraryTab.0=Libraries
+LibraryTab.1=Add library
+LibraryTab.2=Change library name
+RefsTab.0=Expand all
+RefsTab.1=Show checked
+RefsTab.2=Collapse all
+SymbolTab.0=Symbol
+SymbolTab.1=Value
+SymbolTab.2=Add symbol
+SymbolTab.3=Change symbol
+ExpDialog.0=To all configurations
+ExpDialog.1=Save to:
+ExpDialog.2=Languages
+ExpDialog.3=Content types
+ConfigMultiSelectionDialog.0=Select configurations
+ConfigMultiSelectionDialog.1=At least 2 configurations should be selected
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java
new file mode 100644
index 00000000000..e097d2e2ea2
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Env.java
@@ -0,0 +1,12 @@
+package org.eclipse.cdt.ui.newui;
+
+public class PrefPage_Env extends AbstractPrefPage {
+
+ protected boolean isSingle() { return true; }
+
+ // Tabs themselves should save data
+ public boolean performOk() {
+ forEach(ICPropertyTab.OK, null);
+ return true;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java
new file mode 100644
index 00000000000..b492e6850fe
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Vars.java
@@ -0,0 +1,12 @@
+package org.eclipse.cdt.ui.newui;
+
+public class PrefPage_Vars extends AbstractPrefPage {
+
+ protected boolean isSingle() { return true; }
+
+ // Tabs themselves should save data
+ public boolean performOk() {
+ forEach(ICPropertyTab.OK, null);
+ return true;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java
new file mode 100644
index 00000000000..d0af9dda528
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IFile;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Checks whether given object is a source file.
+ */
+public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
+ private static final String KEY = "isSource"; //$NON-NLS-1$
+
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue) {
+ if (!KEY.equals(property)) return false;
+
+ if (receiver instanceof ITranslationUnit) {
+ return ((ITranslationUnit)receiver).isSourceUnit();
+ }
+ else if (receiver instanceof IFile) {
+ IFile file = (IFile)receiver;
+ return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
+ }
+ else return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java
new file mode 100644
index 00000000000..f68695eabd0
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+public class RefsTab extends AbstractCPropertyTab {
+
+ TreeViewer tv;
+ public Composite comp;
+ Tree tree;
+
+ static private final String ACTIVE = "[Active]"; //$NON-NLS-1$
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ initButtons(new String[] {NewUIMessages.getResourceString("RefsTab.0"), NewUIMessages.getResourceString("RefsTab.1"), NewUIMessages.getResourceString("RefsTab.2")}, 120); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ usercomp.setLayout(new GridLayout(1, false));
+
+ tree = new Tree(usercomp, SWT.SINGLE | SWT.CHECK | SWT.BORDER);
+ tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+ initData();
+ tree.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if ((e.detail & SWT.CHECK) == SWT.CHECK && e.item != null && (e.item instanceof TreeItem)) {
+ TreeItem sel = (TreeItem)e.item;
+ Object x = sel.getData();
+ if (x instanceof IProject) {
+ TreeItem[] objs = sel.getItems();
+ if (sel.getChecked()) {
+ sel.setExpanded(true);
+ objs[0].setChecked(true);
+ } else {
+ for (int i=0; i<objs.length; i++)
+ objs[i].setChecked(false);
+ }
+ } else {
+ TreeItem parent = sel.getParentItem();
+ TreeItem[] objs = parent.getItems();
+ if (sel.getChecked()) {
+ if (parent.getChecked()) {
+ for (int i=0; i<objs.length; i++) {
+ // if (!sel.equals(objs[i]))
+ objs[i].setChecked(false);
+ }
+ sel.setChecked(true);
+ } else
+ parent.setChecked(true);
+ } else {
+ parent.setChecked(false);
+ }
+ }
+ saveChecked();
+ }
+ }
+ });
+ }
+
+ // Class which represents "Active" configuration
+ class ActiveCfg {
+ IProject project;
+ public ActiveCfg(IProject _project) {
+ project = _project;
+ }
+ public String toString() {
+ return ACTIVE;
+ }
+ }
+
+ public void buttonPressed(int n) {
+ TreeItem[] items = tree.getItems();
+ switch (n) {
+ case 0: // expand
+ case 1: // expand selected
+ case 2: // collapse
+ for (int i=0; i<items.length; i++)
+ items[i].setExpanded(n==0 || (n==1 && items[i].getChecked()));
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void updateData(ICResourceDescription cfgd) {
+ initData();
+ }
+
+ private void saveChecked() {
+ TreeItem[] tr = tree.getItems();
+ Map refs = new HashMap();
+ for (int i=0; i<tr.length; i++) {
+ if (tr[i].getChecked()) {
+ TreeItem[] cfgs = tr[i].getItems();
+ for (int j=0; j<cfgs.length; j++) {
+ if (cfgs[j].getChecked()) {
+ String cfgId = EMPTY_STR;
+ if (j > 0) { // cfgs[0] is "Active": has no cfg Id
+ Object ob = cfgs[j].getData();
+ if (ob instanceof ICConfigurationDescription) {
+ cfgId = ((ICConfigurationDescription)ob).getId();
+ }
+ }
+ refs.put(tr[i].getText(), cfgId);
+ break;
+ }
+ }
+ }
+ }
+ getResDesc().getConfiguration().setReferenceInfo(refs);
+ }
+
+ public void initData() {
+ tree.removeAll();
+ IProject p = page.getProject();
+ if (p == null) return;
+ IProject[] ps = p.getWorkspace().getRoot().getProjects();
+
+ Map refs = getResDesc().getConfiguration().getReferenceInfo();
+
+
+ TreeItem ti, ti1;
+ for (int i=0; i<ps.length; i++) {
+
+ if (!p.equals(ps[i])) {
+
+ ICConfigurationDescription[] cfgs = page.getCfgsReadOnly(ps[i]);
+ if (cfgs == null || cfgs.length == 0) continue;
+
+ String name = ps[i].getName();
+ String ref = null;
+ ti = new TreeItem(tree, SWT.NONE);
+ ti.setText(name);
+ ti.setData(ps[i]);
+ if (refs.containsKey(name)) {
+ ref = (String)refs.get(name);
+ ti.setChecked(true);
+ }
+ ti1 = new TreeItem(ti, SWT.NONE);
+ ti1.setText(ACTIVE);
+ ti1.setData(new ActiveCfg(ps[i]));
+ if (EMPTY_STR.equals(ref))
+ ti1.setChecked(true);
+ for (int j=0; j<cfgs.length; j++) {
+ ti1 = new TreeItem(ti, SWT.NONE);
+ ti1.setText(cfgs[j].getName());
+ ti1.setData(cfgs[j]);
+ if (cfgs[j].getId().equals(ref)) {
+ ti1.setChecked(true);
+ }
+ }
+ }
+ }
+ }
+
+ public void performApply(ICResourceDescription src, ICResourceDescription dst) {
+ dst.getConfiguration().setReferenceInfo(src.getConfiguration().getReferenceInfo());
+ }
+
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject();
+ }
+
+ protected void performDefaults() {
+ getResDesc().getConfiguration().setReferenceInfo(new HashMap());
+ initData();
+ }
+}
+
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java
index 4664f2dcd03..63545da3684 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/RenameConfigurationDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 Intel Corporation and others.
+ * Copyright (c) 2005, 2007 Intel 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
@@ -8,21 +8,19 @@
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
+package org.eclipse.cdt.ui.newui;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
@@ -30,7 +28,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-public class RenameConfigurationDialog extends StatusDialog {
+public class RenameConfigurationDialog extends Dialog {
// String constants
private static final String PREFIX = "RenameConfiguration"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
@@ -46,45 +44,30 @@ public class RenameConfigurationDialog extends StatusDialog {
private Text configName;
private Text configDescription;
- private IConfiguration[] definedConfigs;
- private IConfiguration renameConfig;
- private IManagedProject managedProject;
+ private ICConfigurationDescription[] cfgds;
+ private ICConfigurationDescription renameConfig;
private String newName;
private String newDescription;
+ private Label statusLabel;
private String originalName;
- /** A list containing config names that have been defined but not added to the target */
- final private ArrayList reservedNames;
final private String title;
-
-
/**
- * @param parentShell
- * @param managedTarget
- * @param renameConfig
- * @param title
*/
- protected RenameConfigurationDialog(Shell parentShell, IManagedProject managedProject, IConfiguration renameConfig, String title) {
+ protected RenameConfigurationDialog(Shell parentShell,
+ ICConfigurationDescription _renameConfig,
+ ICConfigurationDescription[] _cfgds,
+ String _title) {
super(parentShell);
- this.title = title;
- this.renameConfig = renameConfig;
+ title = _title;
+ renameConfig = _renameConfig;
+ cfgds = _cfgds;
+
setShellStyle(getShellStyle()|SWT.RESIZE);
newName = renameConfig.getName();
newDescription = renameConfig.getDescription();
- if(newDescription == null)
- newDescription = new String();
-
- // Store the original name
- setOriginalName(renameConfig.getName());
-
- this.managedProject = managedProject;
- reservedNames = new ArrayList();
-
- definedConfigs = managedProject.getConfigurations();
-// Get the defined configuration names
- for (int i = 0; i < definedConfigs.length; i++) {
- reservedNames.add(definedConfigs[i].getName());
- }
+ if(newDescription == null) newDescription = new String();
+ originalName = renameConfig.getName();
}
/* (non-Javadoc)
@@ -105,8 +88,7 @@ public class RenameConfigurationDialog extends StatusDialog {
*/
protected void configureShell(Shell shell) {
super.configureShell(shell);
- if (title != null)
- shell.setText(title);
+ if (title != null) shell.setText(title);
}
/* (non-Javadoc)
@@ -141,7 +123,7 @@ public class RenameConfigurationDialog extends StatusDialog {
// Add a label and a text widget for Configuration's name
final Label nameLabel = new Label(group1, SWT.LEFT);
nameLabel.setFont(parent.getFont());
- nameLabel.setText(ManagedBuilderUIMessages.getResourceString(NAME));
+ nameLabel.setText(NewUIMessages.getResourceString(NAME));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
@@ -165,7 +147,7 @@ public class RenameConfigurationDialog extends StatusDialog {
// Add a label and a text widget for Configuration's description
final Label descriptionLabel = new Label(group1, SWT.LEFT);
descriptionLabel.setFont(parent.getFont());
- descriptionLabel.setText(ManagedBuilderUIMessages.getResourceString(DESCRIPTION));
+ descriptionLabel.setText(NewUIMessages.getResourceString(DESCRIPTION));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
@@ -180,64 +162,30 @@ public class RenameConfigurationDialog extends StatusDialog {
gd.horizontalSpan = 2;
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
configDescription.setLayoutData(gd);
+
+ statusLabel = new Label(parent, SWT.CENTER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ statusLabel.setLayoutData(gd);
+ statusLabel.setFont(composite.getFont());
+ statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
return composite;
-
-
}
- /* (non-Javadoc)
- * Answers <code>true</code> if the name entered by the user clashes
- * with an existing configuration name.
- *
- * @param newName
- * @return
- */
protected boolean isDuplicateName(String newName) {
- // First check whether the 'newName' is same as original name, if so return false.
- // This is needed in case user wants to keep same name but change the description of configuration
-
- if(newName.equals(getOriginalName()))
- return false;
-
+ if(newName.equals(originalName)) return false;
// Return true if there is already a config of that name defined
- for (int index = 0; index < definedConfigs.length; index++) {
- IConfiguration configuration = definedConfigs[index];
- if (configuration.getName().equals(newName)) {
- return true;
- }
- }
- if (reservedNames.contains(newName)) {
- return true;
+ for (int i = 0; i < cfgds.length; i++) {
+ if (cfgds[i].getName().equals(newName)) return true;
}
return false;
}
- /* (non-Javadoc)
- * Answers <code>true</code> if the name entered by the user differs
- * only in case from an existing name.
- *
- * @param newName
- * @return
- */
protected boolean isSimilarName(String newName) {
- // First check whether the 'newName' is similar to original name, if so return false.
- // This is needed in case user wants to keep similar name
-
- if(newName.equalsIgnoreCase(getOriginalName()))
- return false;
-
+ if(newName.equalsIgnoreCase(originalName)) return false;
// Return true if there is already a config of that name defined on the target
- for (int index = 0; index < definedConfigs.length; index++) {
- IConfiguration configuration = definedConfigs[index];
- if (configuration.getName().equalsIgnoreCase(newName)) {
- return true;
- }
- }
- Iterator iter = reservedNames.listIterator();
- while (iter.hasNext()) {
- if (((String)iter.next()).equalsIgnoreCase(newName)) {
- return true;
- }
+ for (int i = 0; i < cfgds.length; i++) {
+ if (cfgds[i].getName().equalsIgnoreCase(newName)) return true;
}
return false;
}
@@ -248,10 +196,6 @@ public class RenameConfigurationDialog extends StatusDialog {
* @return <I>true</i> is the name is a valid directory name with no whitespaces
*/
private boolean validateName(String name) {
- // Names must be at least one character in length
- if (name.trim().length() == 0)
- return false;
-
// Iterate over the name checking for bad characters
char[] chars = name.toCharArray();
// No whitespaces at the start of a name
@@ -284,50 +228,31 @@ public class RenameConfigurationDialog extends StatusDialog {
*
*/
private void validateState() {
- StatusInfo status= new StatusInfo();
- String currentName = configName.getText();
- // Trim trailing whitespace
- while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
- currentName = currentName.substring(0, currentName.length()-1);
- }
+ String s = null;
+ String currentName = configName.getText().trim();
// Make sure that the name is at least one character in length
if (currentName.length() == 0) {
- // No error message, but cannot select OK
- status.setError(""); //$NON-NLS-1$
+ s = ""; //$NON-NLS-1$
// Make sure the name is not a duplicate
} else if (isDuplicateName(currentName)) {
- status.setError(ManagedBuilderUIMessages.getFormattedString(DUPLICATE, currentName));
+ s = NewUIMessages.getFormattedString(DUPLICATE, currentName);
} else if (isSimilarName(currentName)) {
- status.setError(ManagedBuilderUIMessages.getFormattedString(CASE, currentName));
+ s = NewUIMessages.getFormattedString(CASE, currentName);
} else if (!validateName(currentName)) {
- // TODO Create a decent I18N string to describe this problem
- status.setError(ManagedBuilderUIMessages.getFormattedString(INVALID, currentName));
- }
- updateStatus(status);
+ s = NewUIMessages.getFormattedString(INVALID, currentName);
+ }
+ Button b = getButton(IDialogConstants.OK_ID);
+ if (s != null) {
+ statusLabel.setText(s);
+ statusLabel.setVisible(true);
+ if (b != null) b.setEnabled(false);
+ } else {
+ statusLabel.setVisible(false);
+ if (b != null) b.setEnabled(true);
+ }
return;
}
- public String getNewName() {
- return newName;
- }
-
- public String getNewDescription() {
- return newDescription;
- }
-
- public void setNewDescription(String newDescription) {
- this.newDescription = newDescription;
- }
-
- public void setNewName(String newName) {
- this.newName = newName;
- }
-
- public String getOriginalName() {
- return originalName;
- }
-
- public void setOriginalName(String originalName) {
- this.originalName = originalName;
- }
+ public String getNewName() { return newName; }
+ public String getNewDescription() { return newDescription; }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SDKsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SDKsTab.java
new file mode 100644
index 00000000000..1c0e40f1cfe
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SDKsTab.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+public class SDKsTab extends AbstractCPropertyTab {
+
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ usercomp.setLayout(new GridLayout());
+ Label l = new Label(usercomp, SWT.NONE);
+ l.setLayoutData(new GridData(GridData.BEGINNING));
+ }
+
+ public void updateData(ICResourceDescription cfg) {
+ }
+ public void performApply(ICResourceDescription src,ICResourceDescription dst) {
+ }
+ protected void performDefaults() {
+ }
+
+ // This page can be displayed for project only
+ public boolean canBeVisible() {
+ return page.isForProject();
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java
new file mode 100644
index 00000000000..281300925c0
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+//import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+public class SymbolDialog extends AbstractPropertyDialog {
+ String data1;
+ String data2;
+ Button b_add2all;
+ Text txt1;
+ Text txt2;
+ Button b_vars;
+ Button b_ok;
+ Button b_ko;
+ boolean newAction;
+ ICResourceDescription cfgd;
+
+ public SymbolDialog(Shell parent, boolean _newAction,
+ String title, String _data1, String _data2,
+ ICResourceDescription _cfgd) {
+ super(parent, title);
+ data1 = _data1;
+ data2 = _data2;
+ newAction = _newAction;
+ cfgd = _cfgd;
+ }
+
+ protected Control createDialogArea(Composite c) {
+ c.setLayout(new GridLayout(4, true));
+ GridData gd;
+
+ Label l1 = new Label(c, SWT.NONE);
+ l1.setText("Name:"); //$NON-NLS-1$
+ l1.setLayoutData(new GridData(GridData.BEGINNING));
+
+ txt1 = new Text(c, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ txt1.setLayoutData(gd);
+ txt1.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }});
+
+ Label l2 = new Label(c, SWT.NONE);
+ l2.setText("Value:"); //$NON-NLS-1$
+ l2.setLayoutData(new GridData(GridData.BEGINNING));
+
+ txt2 = new Text(c, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ txt2.setLayoutData(gd);
+ txt2.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setButtons();
+ }});
+
+ b_vars = setupButton(c, "Variables..."); //$NON-NLS-1$
+
+ b_add2all = new Button(c, SWT.CHECK);
+ b_add2all.setText("Add to all configurations"); //$NON-NLS-1$
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 4;
+ if (!newAction) {
+ gd.heightHint = 1;
+ b_add2all.setVisible(false);
+ txt1.setText(data1);
+ txt1.setEnabled(false); // don't change name
+ txt2.setText(data2);
+ }
+ b_add2all.setLayoutData(gd);
+
+ // add 2 placeholders
+ new Label(c, 0).setLayoutData(new GridData());
+ new Label(c, 0).setLayoutData(new GridData());
+ b_ok = setupButton(c, IDialogConstants.OK_LABEL);
+ b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL);
+
+ c.getShell().setDefaultButton(b_ok);
+ c.pack();
+ Rectangle r = shell.getBounds();
+ r.width = 400;
+ shell.setBounds(r);
+
+ setButtons();
+ return c;
+ }
+
+ private void setButtons() {
+ b_ok.setEnabled(
+ (txt1.getText().trim().length() > 0) &&
+ (txt2.getText().trim().length() > 0));
+ }
+
+
+ public void buttonPressed(SelectionEvent e) {
+ if (e.widget.equals(b_ok)) {
+ super.text1 = txt1.getText();
+ super.text2 = txt2.getText();
+ check1 = b_add2all.getSelection();
+ result = true;
+ shell.dispose();
+ } else if (e.widget.equals(b_ko)) {
+ shell.dispose();
+ } else if (e.widget.equals(b_vars)) {
+ String s = AbstractCPropertyTab.getVariableDialog(shell, cfgd.getConfiguration());
+ if (s != null) txt2.insert(s);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java
new file mode 100644
index 00000000000..3484ccaa232
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+public class SymbolTab extends AbstractLangsListTab {
+
+ public void additionalTableSet() {
+ TableColumn tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(NewUIMessages.getResourceString("SymbolTab.0")); //$NON-NLS-1$
+ tc.setWidth(80);
+ tc = new TableColumn(table, SWT.LEFT);
+ tc.setText(NewUIMessages.getResourceString("SymbolTab.1")); //$NON-NLS-1$
+ tc.setWidth(130);
+ }
+
+ public ICLanguageSettingEntry doAdd() {
+ SymbolDialog dlg = new SymbolDialog(
+ usercomp.getShell(), true,
+ NewUIMessages.getResourceString("SymbolTab.2"), EMPTY_STR, EMPTY_STR, getResDesc()); //$NON-NLS-1$
+ if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+ toAll = dlg.check1;
+ return new CMacroEntry(dlg.text1, dlg.text2, 0);
+ } else
+ return null;
+ }
+
+ public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+ SymbolDialog dlg = new SymbolDialog(
+ usercomp.getShell(), false,
+ NewUIMessages.getResourceString("SymbolTab.3"), ent.getName(), //$NON-NLS-1$
+ ent.getValue(), getResDesc());
+ if (dlg.open())
+ return new CMacroEntry(dlg.text1, dlg.text2, 0);
+ else
+ return null;
+ }
+
+ public int getKind() { return ICLanguageSettingEntry.MACRO; }
+}

Back to the top