### Eclipse Workspace Patch 1.0 #P org.eclipse.jst.common.frameworks Index: src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java,v retrieving revision 1.20 diff -u -r1.20 JavaFacetInstallDataModelProvider.java --- src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java 9 Jun 2009 18:43:47 -0000 1.20 +++ src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java 6 Jan 2010 23:41:22 -0000 @@ -16,10 +16,10 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jst.common.project.facet.core.JavaFacet; import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig; import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.ChangeEvent; import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; import org.eclipse.wst.common.project.facet.core.util.IEventListener; @@ -54,7 +54,7 @@ final IDataModel dm = getDataModel(); - dm.setProperty( FACET_ID, IModuleConstants.JST_JAVA ); + dm.setProperty( FACET_ID, JavaFacet.ID ); dm.setProperty( JAVA_FACET_INSTALL_CONFIG, this.installConfig ); String sourceFolderName = null; Index: src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java,v retrieving revision 1.10 diff -u -r1.10 JavaFacetUtils.java --- src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java 3 Mar 2008 22:50:15 -0000 1.10 +++ src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java 6 Jan 2010 23:41:22 -0000 @@ -19,16 +19,20 @@ import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; /** + * This class is deprecated. JavaFacet class should be used instead. + * * @author Konstantin Komissarchik */ +@Deprecated + public final class JavaFacetUtils { public static final IProjectFacet JAVA_FACET = JavaFacet.FACET; - public static final IProjectFacetVersion JAVA_13 = JavaFacet.JAVA_13; - public static final IProjectFacetVersion JAVA_14 = JavaFacet.JAVA_14; - public static final IProjectFacetVersion JAVA_50 = JavaFacet.JAVA_50; - public static final IProjectFacetVersion JAVA_60 = JavaFacet.JAVA_60; + public static final IProjectFacetVersion JAVA_13 = JavaFacet.VERSION_1_3; + public static final IProjectFacetVersion JAVA_14 = JavaFacet.VERSION_1_4; + public static final IProjectFacetVersion JAVA_50 = JavaFacet.VERSION_1_5; + public static final IProjectFacetVersion JAVA_60 = JavaFacet.VERSION_1_6; public static String getCompilerLevel() { @@ -75,12 +79,12 @@ public static IProjectFacetVersion compilerLevelToFacet( final String ver ) { - return JavaFacetUtil.compilerLevelToFacet( ver ); + return JavaFacet.FACET.getVersion( ver ); } public static String facetToCompilerLevel( final IProjectFacetVersion fv ) { - return JavaFacetUtil.facetToCompilerLevel( fv ); + return fv.getVersionString(); } } Index: src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java,v retrieving revision 1.5 diff -u -r1.5 JavaProjectFacetCreationDataModelProvider.java --- src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java 9 Jun 2009 18:43:47 -0000 1.5 +++ src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java 6 Jan 2010 23:41:22 -0000 @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collection; +import org.eclipse.jst.common.project.facet.core.JavaFacet; import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; public class JavaProjectFacetCreationDataModelProvider extends FacetProjectCreationDataModelProvider { @@ -26,7 +27,7 @@ super.init(); Collection requiredFacets = new ArrayList(); - requiredFacets.add(JavaFacetUtils.JAVA_FACET); + requiredFacets.add(JavaFacet.FACET); setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); } #P org.eclipse.jst.common.project.facet.core Index: plugin.properties =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.jst.common.project.facet.core/plugin.properties,v retrieving revision 1.9 diff -u -r1.9 plugin.properties --- plugin.properties 22 May 2009 03:27:26 -0000 1.9 +++ plugin.properties 6 Jan 2010 23:41:23 -0000 @@ -1,7 +1,7 @@ pluginName = Eclipse Faceted Project Framework JDT Enablement providerName = Eclipse Web Tools Platform -jstJavaFacetLabel = Java -jstJavaFacetDescription = Adds support for writing applications using Java programming language. +javaFacetLabel = Java +javaFacetDescription = Adds support for writing applications using Java programming language. javaVersionMismatchMarkerName = Faceted Project Problem (Java Version Mismatch) libraryProvidersExtensionPointName = Library Providers Extension Point legacyLibraryProviderDetectorsExtensionPointName = Legacy Library Provider Detectors Extension Point Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.jst.common.project.facet.core/plugin.xml,v retrieving revision 1.19 diff -u -r1.19 plugin.xml --- plugin.xml 22 Dec 2009 08:01:02 -0000 1.19 +++ plugin.xml 6 Jan 2010 23:41:23 -0000 @@ -22,29 +22,35 @@ - - + + + - + - + - - + + - - + + + + + + + @@ -55,47 +61,53 @@ - - - %jstJavaFacetDescription + + + %javaFacetDescription - + + + + + + + - + - + - + - + - + - + @@ -110,7 +122,7 @@ - + @@ -118,6 +130,12 @@ + + + + + + properties = new HashMap(); Index: src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetDefaultVersionProvider.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetDefaultVersionProvider.java,v retrieving revision 1.4 diff -u -r1.4 JavaFacetDefaultVersionProvider.java --- src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetDefaultVersionProvider.java 22 Dec 2009 08:16:00 -0000 1.4 +++ src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetDefaultVersionProvider.java 6 Jan 2010 23:41:23 -0000 @@ -11,6 +11,8 @@ package org.eclipse.jst.common.project.facet.core.internal; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jst.common.project.facet.core.JavaFacet; import org.eclipse.wst.common.project.facet.core.IDefaultVersionProvider; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; @@ -29,6 +31,23 @@ public IProjectFacetVersion getDefaultVersion() { final String compilerLevel = JavaFacetUtil.getCompilerLevel(); - return JavaFacetUtil.compilerLevelToFacet( compilerLevel ); + + if( JavaFacet.FACET.hasVersion( compilerLevel ) ) + { + return JavaFacet.FACET.getVersion( compilerLevel ); + } + else + { + try + { + return JavaFacet.FACET.getLatestVersion(); + } + catch( CoreException e ) + { + // Not expected for this facet. + + throw new RuntimeException( e ); + } + } } } Index: src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java,v retrieving revision 1.5 diff -u -r1.5 JavaFacetUtil.java --- src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java 22 Dec 2009 08:16:00 -0000 1.5 +++ src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java 6 Jan 2010 23:41:23 -0000 @@ -12,13 +12,14 @@ package org.eclipse.jst.common.project.facet.core.internal; import java.util.Collections; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -28,20 +29,15 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.core.JavaProject; import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jst.common.project.facet.core.ClasspathHelper; import org.eclipse.jst.common.project.facet.core.JavaFacet; import org.eclipse.osgi.util.NLS; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.osgi.service.prefs.BackingStoreException; /** * @author Konstantin Komissarchik @@ -49,18 +45,30 @@ public final class JavaFacetUtil { - public static final String FILE_CLASSPATH = JavaProject.CLASSPATH_FILENAME; + public static final String FILE_CLASSPATH = ".classpath"; //$NON-NLS-1$ public static final String FILE_JDT_CORE_PREFS = ".settings/org.eclipse.jdt.core.prefs"; //$NON-NLS-1$ + private static final IPath CPE_PREFIX_FOR_EXEC_ENV + = new Path( "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType" ); //$NON-NLS-1$ + + private static final Map FACET_VER_TO_EXEC_ENV = new HashMap(); + + static + { + FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_3, "J2SE-1.3" ); //$NON-NLS-1$ + FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_4, "J2SE-1.4" ); //$NON-NLS-1$ + FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_5, "J2SE-1.5" ); //$NON-NLS-1$ + FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_6, "JavaSE-1.6" ); //$NON-NLS-1$ + FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_7, "JavaSE-1.7" ); //$NON-NLS-1$ + } + public static String getCompilerLevel() { - final IScopeContext context = new InstanceScope(); - final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID ); - String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null ); + String level = JavaCore.getOption( JavaCore.COMPILER_COMPLIANCE ); if( level == null ) { - final Hashtable defaults = JavaCore.getDefaultOptions(); + final Hashtable defaults = JavaCore.getDefaultOptions(); level = (String) defaults.get( JavaCore.COMPILER_COMPLIANCE ); } @@ -69,9 +77,8 @@ public static String getCompilerLevel( final IProject project ) { - final IScopeContext context = new ProjectScope( project ); - final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID ); - String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null ); + final IJavaProject jproj = JavaCore.create( project ); + String level = jproj.getOption( JavaCore.COMPILER_COMPLIANCE, false ); if( level == null ) { @@ -87,7 +94,7 @@ throws CoreException { - setCompilerLevel( project, facetToCompilerLevel( fv ) ); + setCompilerLevel( project, fv.getVersionString() ); } public static void setCompilerLevel( final IProject project, @@ -96,56 +103,10 @@ throws CoreException { - final IScopeContext context = new ProjectScope( project ); - - final IEclipsePreferences prefs - = context.getNode( JavaCore.PLUGIN_ID ); - - if( level.equals( JavaCore.VERSION_1_3 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE ); - } - else if( level.equals( JavaCore.VERSION_1_4 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING ); - } - else if( level.equals( JavaCore.VERSION_1_5 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR ); - } - else if( level.equals( JavaCore.VERSION_1_6 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR ); - } - else - { - throw new IllegalStateException(); - } - - try - { - prefs.flush(); - } - catch( BackingStoreException e ) - { - // TODO: Handle this. - } + final IJavaProject jproj = JavaCore.create( project ); + final Map options = jproj.getOptions( false ); + JavaCore.setComplianceOptions( level, options ); + jproj.setOptions( options ); } public static void scheduleFullBuild( final IProject project ) @@ -219,14 +180,9 @@ if( vm != null ) { - IPath path = new Path( JavaRuntime.JRE_CONTAINER ); - path = path.append( vm.getVMInstallType().getId() ); - path = path.append( vm.getName() ); - - final IClasspathEntry cpe - = JavaCore.newContainerEntry( path ); - - final List entries = Collections.singletonList( cpe ); + final IPath path = CPE_PREFIX_FOR_EXEC_ENV.append( getCorrespondingExecutionEnvironment( newver ) ); + final IClasspathEntry cpe = JavaCore.newContainerEntry( path ); + final List entries = Collections.singletonList( cpe ); ClasspathHelper.addClasspathEntries( project, newver, entries ); } @@ -269,36 +225,16 @@ jproj.setRawClasspath( newcp, null ); } - public static IProjectFacetVersion compilerLevelToFacet( final String ver ) + public static String getCorrespondingExecutionEnvironment( final IProjectFacetVersion fv ) { - if( ver.equals( "1.5" ) ) //$NON-NLS-1$ - { - return JavaFacet.JAVA_50; - } - else if( ver.equals( "1.6" ) ) //$NON-NLS-1$ - { - return JavaFacet.JAVA_60; - } - else - { - return JavaFacet.FACET.getVersion( ver ); - } - } - - public static String facetToCompilerLevel( final IProjectFacetVersion fv ) - { - if( fv == JavaFacet.JAVA_50 ) - { - return JavaCore.VERSION_1_5; - } - else if( fv == JavaFacet.JAVA_60 ) - { - return JavaCore.VERSION_1_6; - } - else + final String res = FACET_VER_TO_EXEC_ENV.get( fv ); + + if( res == null ) { - return fv.getVersionString(); + throw new IllegalArgumentException( fv.toString() ); } + + return res; } private static final class Resources Index: src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetValidator.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetValidator.java,v retrieving revision 1.4 diff -u -r1.4 JavaFacetValidator.java --- src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetValidator.java 22 Dec 2009 08:16:00 -0000 1.4 +++ src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetValidator.java 6 Jan 2010 23:41:23 -0000 @@ -44,7 +44,7 @@ final IProjectFacetVersion fv = fproj.getInstalledVersion( JavaFacet.FACET ); - if( JavaFacetUtil.compilerLevelToFacet( level ) != fv ) + if( ! JavaFacet.FACET.hasVersion( level ) || JavaFacet.FACET.getVersion( level ) != fv ) { final IMarker marker = fproj.createErrorMarker( MARKER_ID, Resources.versionsDontMatch ); #P org.eclipse.jst.common.project.facet.ui Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.jst.common.project.facet.ui/plugin.xml,v retrieving revision 1.6 diff -u -r1.6 plugin.xml --- plugin.xml 3 Feb 2009 02:13:01 -0000 1.6 +++ plugin.xml 6 Jan 2010 23:41:25 -0000 @@ -30,12 +30,12 @@ - + Index: src/org/eclipse/jst/common/project/facet/ui/internal/JavaVersionMismatchMarkerResolutions.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.jst.common.project.facet.ui/src/org/eclipse/jst/common/project/facet/ui/internal/JavaVersionMismatchMarkerResolutions.java,v retrieving revision 1.3 diff -u -r1.3 JavaVersionMismatchMarkerResolutions.java --- src/org/eclipse/jst/common/project/facet/ui/internal/JavaVersionMismatchMarkerResolutions.java 22 Dec 2009 08:15:47 -0000 1.3 +++ src/org/eclipse/jst/common/project/facet/ui/internal/JavaVersionMismatchMarkerResolutions.java 6 Jan 2010 23:41:25 -0000 @@ -92,7 +92,7 @@ final String level = this.marker.getAttribute( JavaFacetValidator.ATTR_COMPILER_LEVEL, null ); - return JavaFacetUtil.compilerLevelToFacet( level ); + return JavaFacet.FACET.getVersion( level ); } } @@ -134,12 +134,7 @@ private String getCompilerLevel() { - final String fvstr - = this.marker.getAttribute( JavaFacetValidator.ATTR_FACET_VERSION, null); - - final IProjectFacetVersion fv = JavaFacet.FACET.getVersion( fvstr ); - - return JavaFacetUtil.facetToCompilerLevel( fv ); + return this.marker.getAttribute( JavaFacetValidator.ATTR_FACET_VERSION, null); } } #P org.eclipse.wst.common.modulecore Index: modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java,v retrieving revision 1.42 diff -u -r1.42 FacetProjectCreationDataModelProvider.java --- modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java 9 Nov 2009 21:51:22 -0000 1.42 +++ modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java 6 Jan 2010 23:41:26 -0000 @@ -359,7 +359,14 @@ config = Platform.getAdapterManager().getAdapter( config, IDataModel.class ); } - facetDmMap.add( (IDataModel) config ); + final IDataModel dm = (IDataModel) config; + + facetDmMap.put( facet.getId(), dm ); + + for( String alias : facet.getAliases() ) + { + facetDmMap.put( alias, dm ); + } } } return super.propertySet(propertyName, propertyValue); #P org.eclipse.wst.common.project.facet.core Index: plugin.properties =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/plugin.properties,v retrieving revision 1.9 diff -u -r1.9 plugin.properties --- plugin.properties 22 Dec 2009 08:00:54 -0000 1.9 +++ plugin.properties 6 Jan 2010 23:41:27 -0000 @@ -4,4 +4,5 @@ validationMarkerName = Faceted Project Problem extPointListeners = Faceted Project Listeners Extension Point extPointPresets = Faceted Project Presets Extension Point -extPointDetectors = Project Facet Detectors Extension Point \ No newline at end of file +extPointDetectors = Project Facet Detectors Extension Point +extPointAliases = Project Facet Aliases Extension Point Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/plugin.xml,v retrieving revision 1.21 diff -u -r1.21 plugin.xml --- plugin.xml 22 Dec 2009 08:00:54 -0000 1.21 +++ plugin.xml 6 Jan 2010 23:41:27 -0000 @@ -43,6 +43,11 @@ name="%extPointDetectors" schema="schemas/detectors.exsd"/> + + Index: schemas/aliases.exsd =================================================================== RCS file: schemas/aliases.exsd diff -N schemas/aliases.exsd --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ schemas/aliases.exsd 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,139 @@ + + + + + + + + + Used as part of a migration strategy in order to maintain backwards compatibility when changing the id or the version of a facet. Allows one or more aliases to be defined for facet id or version. Once an alias is defined, it will resolve to the actual facet when it appears in project metadata or is referenced in an API call. + + + + + + + + + + + + + + + + + + A fully qualified identifier of the target extension point. + + + + + + + An optional identifier of the extension instance. + + + + + + + An optional name of the extension instance. + + + + + + + + + + Specifies a single facet alias. + + + + + + + The id of an existing facet. + + + + + + + + + + The alias to assign to the specified facet. + + + + + + + + + + Specifies a single facet version alias. + + + + + + + The id of an existing facet. + + + + + + + + + + The facet version to alias. + + + + + + + The alias to assign to the specified facet version. + + + + + + + + + + + + + <pre> +<extension point="org.eclipse.wst.common.project.facet.core.aliases"> + <facet-alias facet="mytech" alias="formgen"/> + <facet-version-alias facet="mytech" version="1.5" alias="2.0"/> +</extension> +</pre> + + + + + + + + + + + Copyright (c) 2010 Oracle and others.<br> +All rights reserved. This program and the accompanying materials are made +available under the terms of the Eclipse Public License v1.0 which accompanies +this distribution, and is available at <a +href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + + + + Index: src/org/eclipse/wst/common/project/facet/core/IProjectFacet.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/IProjectFacet.java,v retrieving revision 1.17 diff -u -r1.17 IProjectFacet.java --- src/org/eclipse/wst/common/project/facet/core/IProjectFacet.java 22 Dec 2009 08:15:11 -0000 1.17 +++ src/org/eclipse/wst/common/project/facet/core/IProjectFacet.java 6 Jan 2010 23:41:28 -0000 @@ -52,6 +52,15 @@ String getId(); /** + * Returns the alternate identifiers that are associated with this facet. Aliases are specified + * via the aliases extension point. + * + * @return the alternate identifiers that are associated with this facet, if any + */ + + Set getAliases(); + + /** * Returns the id of the plugin that defines this project facet. This method * will return null if this facet is not defined. * Index: src/org/eclipse/wst/common/project/facet/core/internal/Category.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/Category.java,v retrieving revision 1.8 diff -u -r1.8 Category.java --- src/org/eclipse/wst/common/project/facet/core/internal/Category.java 22 Dec 2009 08:15:12 -0000 1.8 +++ src/org/eclipse/wst/common/project/facet/core/internal/Category.java 6 Jan 2010 23:41:28 -0000 @@ -96,6 +96,8 @@ this.facets.remove( f ); } + @SuppressWarnings( "rawtypes" ) + public Object getAdapter( final Class type ) { return Platform.getAdapterManager().loadAdapter( this, type.getName() ); Index: src/org/eclipse/wst/common/project/facet/core/internal/FacetedProject.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/FacetedProject.java,v retrieving revision 1.48 diff -u -r1.48 FacetedProject.java --- src/org/eclipse/wst/common/project/facet/core/internal/FacetedProject.java 22 Dec 2009 08:15:12 -0000 1.48 +++ src/org/eclipse/wst/common/project/facet/core/internal/FacetedProject.java 6 Jan 2010 23:41:28 -0000 @@ -566,16 +566,15 @@ * @deprecated */ - @SuppressWarnings( "unchecked" ) public void setRuntime( final IRuntime runtime, final IProgressMonitor monitor ) throws CoreException { - final Set runtimes + final Set runtimes = runtime == null - ? Collections.EMPTY_SET : Collections.singleton( runtime ); + ? Collections.emptySet() : Collections.singleton( runtime ); setTargetedRuntimes( runtimes, monitor ); } Index: src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectAdapter.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectAdapter.java,v retrieving revision 1.7 diff -u -r1.7 FacetedProjectAdapter.java --- src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectAdapter.java 22 Dec 2009 08:15:12 -0000 1.7 +++ src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectAdapter.java 6 Jan 2010 23:41:28 -0000 @@ -23,6 +23,8 @@ * @author Konstantin Komissarchik */ +@SuppressWarnings( "rawtypes" ) + public final class FacetedProjectAdapter implements IAdapterFactory Index: src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java,v retrieving revision 1.21 diff -u -r1.21 FacetedProjectFrameworkImpl.java --- src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java 22 Dec 2009 08:15:12 -0000 1.21 +++ src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java 6 Jan 2010 23:41:28 -0000 @@ -218,7 +218,7 @@ public Set getProjectFacets() { - return this.facets.getUnmodifiable(); + return this.facets.getItemSet(); } public boolean isProjectFacetDefined( final String id ) @@ -228,7 +228,7 @@ public IProjectFacet getProjectFacet( final String id ) { - final IProjectFacet f = this.facets.get( id ); + final IProjectFacet f = this.facets.getItemByKey( id ); if( f == null ) { @@ -241,7 +241,7 @@ public Set getActionDefinitions() { - return this.actions.getUnmodifiable(); + return this.actions.getItemSet(); } public boolean isActionDefined( final String id ) @@ -251,7 +251,7 @@ public IActionDefinition getActionDefinition( final String id ) { - final IActionDefinition adef = this.actions.get( id ); + final IActionDefinition adef = this.actions.getItemByKey( id ); if( adef == null ) { @@ -264,7 +264,7 @@ public Set getCategories() { - return this.categories.getUnmodifiable(); + return this.categories.getItemSet(); } public boolean isCategoryDefined( final String id ) @@ -274,7 +274,7 @@ public ICategory getCategory( final String id ) { - final ICategory category = this.categories.get( id ); + final ICategory category = this.categories.getItemByKey( id ); if( category == null ) { @@ -290,7 +290,7 @@ synchronized( this.presets ) { initializePresets(); - return this.presets.getUnmodifiable(); + return this.presets.getItemSet(); } } @@ -309,7 +309,7 @@ { initializePresets(); - final IPreset preset = this.presets.get( id ); + final IPreset preset = this.presets.getItemByKey( id ); if( preset == null ) { @@ -364,7 +364,7 @@ = new UserPreset( id, name, description == null ? "" : description, //$NON-NLS-1$ facets ); - this.presets.add( id, preset ); + this.presets.addItemWithKey( id, preset ); if( save ) { @@ -388,7 +388,7 @@ return false; } - deleted = this.presets.delete( preset.getId() ); + deleted = this.presets.removeItemByKey( preset.getId() ); if( deleted ) { @@ -415,7 +415,7 @@ { for( IPreset preset : PresetsExtensionPoint.getPresets() ) { - this.presets.add( preset.getId(), preset ); + this.presets.addItemWithKey( preset.getId(), preset ); } readUserPresets(); @@ -438,7 +438,7 @@ root.node( children[ i ] ).removeNode(); } - for( IPreset preset : this.presets ) + for( IPreset preset : this.presets.getItemSet() ) { if( preset.getType() == IPreset.Type.USER_DEFINED ) { @@ -576,7 +576,7 @@ public Set getGroups() { - return this.groups.getUnmodifiable(); + return this.groups.getItemSet(); } public boolean isGroupDefined( final String id ) @@ -586,7 +586,7 @@ public IGroup getGroup( final String id ) { - final IGroup group = this.groups.get( id ); + final IGroup group = this.groups.getItemByKey( id ); if( group == null ) { @@ -1449,7 +1449,7 @@ final IConfigurationElement elDesc = findOptionalElement( config, EL_DESCRIPTION ); category.setDescription( getElementValue( elDesc, DEFAULT_DESCRIPTION ) ); - this.categories.add( category.getId(), category ); + this.categories.addItemWithKey( category.getId(), category ); } private void readProjectFacet( final IConfigurationElement config ) @@ -1548,7 +1548,14 @@ } } - this.facets.add( f.getId(), f ); + this.facets.addItem( f ); + this.facets.addKey( f.getId(), f ); + + for( String alias : ProjectFacetAliasesExtensionPoint.getAliases( f ) ) + { + this.facets.addKey( alias, f ); + f.addAlias( alias ); + } } private void readProjectFacetVersion( final IConfigurationElement config, @@ -1571,7 +1578,7 @@ return; } - final ProjectFacet f = (ProjectFacet) this.facets.get( fid ); + final ProjectFacet f = (ProjectFacet) this.facets.getItemByKey( fid ); if( f == null ) { @@ -1610,14 +1617,14 @@ return; } - Group group = (Group) this.groups.get( id ); + Group group = (Group) this.groups.getItemByKey( id ); if( group == null ) { group = new Group(); group.setId( id ); - this.groups.add( id, group ); + this.groups.addItemWithKey( id, group ); } group.addMember( fv ); @@ -1676,7 +1683,7 @@ { final List badFacets = new ArrayList(); - for( IProjectFacet f : this.facets ) + for( IProjectFacet f : this.facets.getItemSet() ) { try { @@ -1734,7 +1741,7 @@ for( IProjectFacet f : badFacets ) { - this.facets.remove( f ); + this.facets.removeItem( f ); final Category category = (Category) f.getCategory(); @@ -1835,7 +1842,7 @@ return; } - final ProjectFacet f = (ProjectFacet) this.facets.get( fid ); + final ProjectFacet f = (ProjectFacet) this.facets.getItemByKey( fid ); if( f == null ) { @@ -2011,7 +2018,7 @@ } else { - this.actions.add( def.getId(), def ); + this.actions.addItemWithKey( def.getId(), def ); f.addActionDefinition( def ); } } @@ -2026,7 +2033,7 @@ return; } - final ProjectFacet f = (ProjectFacet) this.facets.get( fid ); + final ProjectFacet f = (ProjectFacet) this.facets.getItemByKey( fid ); if( f == null ) { Index: src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectTemplatesExtensionPoint.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectTemplatesExtensionPoint.java,v retrieving revision 1.6 diff -u -r1.6 FacetedProjectTemplatesExtensionPoint.java --- src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectTemplatesExtensionPoint.java 22 Dec 2009 08:15:12 -0000 1.6 +++ src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectTemplatesExtensionPoint.java 6 Jan 2010 23:41:28 -0000 @@ -50,13 +50,13 @@ public static Set getTemplates() { readExtensions(); - return templates.getUnmodifiable(); + return templates.getItemSet(); } public static IFacetedProjectTemplate getTemplate( final String id ) { readExtensions(); - return templates.get( id ); + return templates.getItemByKey( id ); } private static synchronized void readExtensions() @@ -135,7 +135,7 @@ } } - templates.add( template.getId(), template ); + templates.addItemWithKey( template.getId(), template ); } private static final class Resources Index: src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectValidationBuilder.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectValidationBuilder.java,v retrieving revision 1.10 diff -u -r1.10 FacetedProjectValidationBuilder.java --- src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectValidationBuilder.java 22 Dec 2009 08:15:12 -0000 1.10 +++ src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectValidationBuilder.java 6 Jan 2010 23:41:28 -0000 @@ -63,6 +63,8 @@ readExtensions(); } + @SuppressWarnings( "rawtypes" ) + protected IProject[] build( final int kind, final Map args, final IProgressMonitor monitor ) Index: src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectWorkingCopy.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectWorkingCopy.java,v retrieving revision 1.22 diff -u -r1.22 FacetedProjectWorkingCopy.java --- src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectWorkingCopy.java 22 Dec 2009 08:15:12 -0000 1.22 +++ src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectWorkingCopy.java 6 Jan 2010 23:41:29 -0000 @@ -668,7 +668,7 @@ { synchronized( this.lock ) { - return this.facets.getUnmodifiable(); + return this.facets.getItemSet(); } } @@ -676,7 +676,7 @@ { synchronized( this.lock ) { - return this.facets.get( f ); + return this.facets.getItemByKey( f ); } } @@ -692,7 +692,7 @@ { synchronized( this.lock ) { - return this.facets.contains( fv ); + return this.facets.containsItem( fv ); } } @@ -709,17 +709,17 @@ for( IProjectFacetVersion fv : facets ) { - newProjectFacets.add( fv.getProjectFacet(), fv ); + newProjectFacets.addItemWithKey( fv.getProjectFacet(), fv ); } final Set addedFacets = new HashSet(); final Set removedFacets = new HashSet(); final Set changedVersions = new HashSet(); - for( IProjectFacetVersion fv : newProjectFacets ) + for( IProjectFacetVersion fv : newProjectFacets.getItemSet() ) { final IProjectFacetVersion currentFacetVersion - = this.facets.get( fv.getProjectFacet() ); + = this.facets.getItemByKey( fv.getProjectFacet() ); if( currentFacetVersion == null ) { @@ -734,7 +734,7 @@ } } - for( IProjectFacetVersion fv : this.facets ) + for( IProjectFacetVersion fv : this.facets.getItemSet() ) { if( ! newProjectFacets.containsKey( fv.getProjectFacet() ) ) { @@ -780,14 +780,14 @@ synchronized( this.lock ) { final IProjectFacetVersion existingVersion - = this.facets.get( fv.getProjectFacet() ); + = this.facets.getItemByKey( fv.getProjectFacet() ); if( existingVersion == null ) { final Set newProjectFacets = new HashSet(); - newProjectFacets.addAll( this.facets ); + newProjectFacets.addAll( this.facets.getItemSet() ); newProjectFacets.add( fv ); setProjectFacets( newProjectFacets ); @@ -840,7 +840,7 @@ synchronized( this.lock ) { final IProjectFacetVersion existingVersion - = this.facets.get( fv.getProjectFacet() ); + = this.facets.getItemByKey( fv.getProjectFacet() ); if( existingVersion == null ) { @@ -851,7 +851,7 @@ final Set newProjectFacets = new HashSet(); - newProjectFacets.addAll( this.facets ); + newProjectFacets.addAll( this.facets.getItemSet() ); newProjectFacets.remove( fv ); setProjectFacets( newProjectFacets ); @@ -878,7 +878,7 @@ synchronized( this.lock ) { final IProjectFacetVersion existingVersion - = this.facets.get( fv.getProjectFacet() ); + = this.facets.getItemByKey( fv.getProjectFacet() ); if( existingVersion == null ) { @@ -894,7 +894,7 @@ final Set newProjectFacets = new HashSet(); - newProjectFacets.addAll( this.facets ); + newProjectFacets.addAll( this.facets.getItemSet() ); newProjectFacets.remove( existingVersion ); newProjectFacets.add( fv ); @@ -924,7 +924,7 @@ { synchronized( this.lock ) { - return this.availablePresets.getUnmodifiable(); + return this.availablePresets.getItemSet(); } } @@ -1002,7 +1002,7 @@ if( applicable ) { - newAvailablePresets.add( preset.getId(), preset ); + newAvailablePresets.addItemWithKey( preset.getId(), preset ); } } @@ -1031,7 +1031,7 @@ { if( this.selectedPresetId != null ) { - return this.availablePresets.get( this.selectedPresetId ); + return this.availablePresets.getItemByKey( this.selectedPresetId ); } else { @@ -1054,7 +1054,7 @@ throw new IllegalArgumentException( msg ); } - final IPreset preset = this.availablePresets.get( presetId ); + final IPreset preset = this.availablePresets.getItemByKey( presetId ); if( ! equals( this.selectedPresetId, presetId ) || ( preset != null && ! equals( preset.getProjectFacets(), getProjectFacets() ) ) ) @@ -1088,7 +1088,7 @@ { synchronized( this.lock ) { - return this.availablePresets.get( DefaultConfigurationPresetFactory.PRESET_ID ); + return this.availablePresets.getItemByKey( DefaultConfigurationPresetFactory.PRESET_ID ); } } @@ -1096,7 +1096,7 @@ { synchronized( this.lock ) { - return this.availablePresets.get( MinimalConfigurationPresetFactory.PRESET_ID ); + return this.availablePresets.getItemByKey( MinimalConfigurationPresetFactory.PRESET_ID ); } } @@ -1139,7 +1139,7 @@ { ok = true; - for( IProjectFacetVersion fv : this.facets ) + for( IProjectFacetVersion fv : this.facets.getItemSet() ) { if( ! r.supports( fv ) ) { Index: src/org/eclipse/wst/common/project/facet/core/internal/PresetsExtensionPoint.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/PresetsExtensionPoint.java,v retrieving revision 1.7 diff -u -r1.7 PresetsExtensionPoint.java --- src/org/eclipse/wst/common/project/facet/core/internal/PresetsExtensionPoint.java 22 Dec 2009 08:15:12 -0000 1.7 +++ src/org/eclipse/wst/common/project/facet/core/internal/PresetsExtensionPoint.java 6 Jan 2010 23:41:29 -0000 @@ -70,13 +70,13 @@ public static Set getPresets() { readExtensions(); - return presets.getUnmodifiable(); + return presets.getItemSet(); } public static IPreset getPreset( final String id ) { readExtensions(); - return presets.get( id ); + return presets.getItemByKey( id ); } private static synchronized void readExtensions() @@ -136,11 +136,11 @@ // Resolve the base presets. Make sure that no presets are extending presets that do not // exist, check for circular references, etc. - Set copy = new HashSet( presets ); + Set copy = new HashSet( presets.getItemSet() ); for( IPreset preset : copy ) { - if( presets.contains( preset ) ) + if( presets.containsItem( preset ) ) { resolveBasePreset( preset, new HashSet() ); } @@ -155,7 +155,7 @@ { doAnotherPass = false; - for( IPreset preset : presets ) + for( IPreset preset : presets.getItemSet() ) { if( preset.getType() == IPreset.Type.STATIC ) { @@ -176,7 +176,8 @@ stPreset.getBasePresetId(), stPreset.getProjectFacets() ); - presets.add( stPresetNew.getId(), stPresetNew ); + presets.removeItem( stPreset ); + presets.addItemWithKey( stPresetNew.getId(), stPresetNew ); doAnotherPass = true; break; @@ -256,7 +257,7 @@ final StaticPreset preset = new StaticPreset( id, pluginId, label, description, basePreset, facets ); - presets.add( id, preset ); + presets.addItemWithKey( id, preset ); } private static void readDynamicPreset( final IConfigurationElement el ) @@ -270,7 +271,7 @@ final String factoryClassName = findRequiredAttribute( elFactory, ATTR_CLASS ); final DynamicPreset preset = new DynamicPreset( id, pluginId, factoryClassName ); - presets.add( id, preset ); + presets.addItemWithKey( id, preset ); } private static boolean resolveBasePreset( final IPreset preset, @@ -338,7 +339,7 @@ if( problem ) { - PresetsExtensionPoint.presets.delete( preset.getId() ); + PresetsExtensionPoint.presets.removeItemByKey( preset.getId() ); return false; } } Index: src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacet.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacet.java,v retrieving revision 1.18 diff -u -r1.18 ProjectFacet.java --- src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacet.java 22 Dec 2009 08:15:12 -0000 1.18 +++ src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacet.java 6 Jan 2010 23:41:29 -0000 @@ -44,6 +44,8 @@ { private String id; + private final Set aliases; + private final Set aliasesReadOnly; private String plugin; private String label; private String description; @@ -56,6 +58,8 @@ ProjectFacet() { + this.aliases = new HashSet(); + this.aliasesReadOnly = Collections.unmodifiableSet( this.aliases ); this.actionDefinitions = new ArrayList(); this.properties = new HashMap(); this.propertiesReadOnly = Collections.unmodifiableMap( this.properties ); @@ -71,6 +75,16 @@ this.id = id; } + public Set getAliases() + { + return this.aliasesReadOnly; + } + + void addAlias( final String alias ) + { + this.aliases.add( alias ); + } + public String getPluginId() { return this.plugin; @@ -111,9 +125,15 @@ this.category = category; } - void addVersion( final IProjectFacetVersion ver ) + void addVersion( final IProjectFacetVersion fv ) { - this.versions.add( ver.getVersionString(), ver ); + this.versions.addItem( fv ); + this.versions.addKey( fv.getVersionString(), fv ); + + for( String alias : ProjectFacetAliasesExtensionPoint.getAliases( fv ) ) + { + this.versions.addKey( alias, fv ); + } } public IProjectFacetVersion getLatestSupportedVersion( final IRuntime r ) @@ -183,6 +203,8 @@ this.defaultVersionProvider = provider; } + @SuppressWarnings( "rawtypes" ) + public Object getAdapter( final Class type ) { return Platform.getAdapterManager().loadAdapter( this, type.getName() ); @@ -212,7 +234,7 @@ public boolean isVersionHidden() { - return ( this.versions.size() == 1 && + return ( this.versions.getItemSet().size() == 1 && equal( getProperty( PROP_HIDE_VERSION ), true ) ); } Index: src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetAliasesExtensionPoint.java =================================================================== RCS file: src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetAliasesExtensionPoint.java diff -N src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetAliasesExtensionPoint.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetAliasesExtensionPoint.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,154 @@ +/****************************************************************************** + * Copyright (c) 2010 Oracle + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Konstantin Komissarchik - initial implementation and ongoing maintenance + ******************************************************************************/ + +package org.eclipse.wst.common.project.facet.core.internal; + +import static org.eclipse.wst.common.project.facet.core.internal.FacetCorePlugin.PLUGIN_ID; +import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findExtensions; +import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findRequiredAttribute; +import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.getTopLevelElements; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.wst.common.project.facet.core.IProjectFacet; +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; +import org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.InvalidExtensionException; + +/** + * Contains the logic for processing the aliases extension point. + * + * @author Konstantin Komissarchik + */ + +public final class ProjectFacetAliasesExtensionPoint +{ + public static final String EXTENSION_POINT_ID = "aliases"; //$NON-NLS-1$ + + private static final String EL_FACET_ALIAS = "facet-alias"; //$NON-NLS-1$ + private static final String EL_FACET_VERSION_ALIAS = "facet-version-alias"; //$NON-NLS-1$ + private static final String ATTR_ALIAS = "alias"; //$NON-NLS-1$ + private static final String ATTR_FACET = "facet"; //$NON-NLS-1$ + private static final String ATTR_VERSION = "version"; //$NON-NLS-1$ + + /* + * Note that the facetAliases and facetVersionAliases data structures hold strings rather + * than more specific IProjectFacet and IProjectFacetVersion objects. This is done this + * way as this class is called during initialization of FacetedProjectFramework and we need + * to avoid circular calls (this class cannot call back to FacetedProjectFramework). + */ + + private static Map> facetAliases = null; + private static Map>> facetVersionAliases = null; + + public static Set getAliases( final IProjectFacet f ) + { + readExtensions(); + + final Set aliases = facetAliases.get( f.getId() ); + + if( aliases != null ) + { + return aliases; + } + + return Collections.emptySet(); + } + + public static Set getAliases( final IProjectFacetVersion fv ) + { + readExtensions(); + + final Map> versionToAliasesMap = facetVersionAliases.get( fv.getProjectFacet().getId() ); + + if( versionToAliasesMap != null ) + { + final Set aliases = versionToAliasesMap.get( fv.getVersionString() ); + + if( aliases != null ) + { + return aliases; + } + } + + return Collections.emptySet(); + } + + private static synchronized void readExtensions() + { + if( facetAliases != null ) + { + return; + } + + facetAliases = new HashMap>(); + facetVersionAliases = new HashMap>>(); + + for( IConfigurationElement element + : getTopLevelElements( findExtensions( PLUGIN_ID, EXTENSION_POINT_ID ) ) ) + { + final String elname = element.getName(); + + try + { + if( elname.equals( EL_FACET_ALIAS ) || elname.equals( EL_FACET_VERSION_ALIAS ) ) + { + final String fid = findRequiredAttribute( element, ATTR_FACET ); + final String alias = findRequiredAttribute( element, ATTR_ALIAS ); + + if( elname.equals( EL_FACET_ALIAS ) ) + { + Set aliases = facetAliases.get( fid ); + + if( aliases == null ) + { + aliases = new HashSet(); + facetAliases.put( fid, aliases ); + } + + aliases.add( alias ); + } + else + { + final String fvstr = findRequiredAttribute( element, ATTR_VERSION ); + + Map> versionToAliasesMap = facetVersionAliases.get( fid ); + + if( versionToAliasesMap == null ) + { + versionToAliasesMap = new HashMap>(); + facetVersionAliases.put( fid, versionToAliasesMap ); + } + + Set aliases = versionToAliasesMap.get( fvstr ); + + if( aliases == null ) + { + aliases = new HashSet(); + versionToAliasesMap.put( fvstr, aliases ); + } + + aliases.add( alias ); + } + } + } + catch( InvalidExtensionException e ) + { + // Continue. The problem has been reported to the user via the log. + } + } + } + +} Index: src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetVersion.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetVersion.java,v retrieving revision 1.21 diff -u -r1.21 ProjectFacetVersion.java --- src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetVersion.java 22 Dec 2009 08:15:12 -0000 1.21 +++ src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetVersion.java 6 Jan 2010 23:41:30 -0000 @@ -241,13 +241,12 @@ * @deprecated */ - @SuppressWarnings( "unchecked" ) public IActionDefinition getActionDefinition( final Action.Type type ) throws CoreException { - final Set definitions = getActionDefinitions( type ); + final Set definitions = getActionDefinitions( type ); if( definitions.size() == 0 ) { @@ -255,7 +254,7 @@ } else { - return (IActionDefinition) definitions.iterator().next(); + return definitions.iterator().next(); } } Index: src/org/eclipse/wst/common/project/facet/core/runtime/internal/AbstractRuntime.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/runtime/internal/AbstractRuntime.java,v retrieving revision 1.13 diff -u -r1.13 AbstractRuntime.java --- src/org/eclipse/wst/common/project/facet/core/runtime/internal/AbstractRuntime.java 22 Dec 2009 08:15:18 -0000 1.13 +++ src/org/eclipse/wst/common/project/facet/core/runtime/internal/AbstractRuntime.java 6 Jan 2010 23:41:30 -0000 @@ -150,6 +150,8 @@ return getProperties().get( key ); } + @SuppressWarnings( "rawtypes" ) + public final Object getAdapter( final Class adapter ) { final String t = adapter.getName(); Index: src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponent.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponent.java,v retrieving revision 1.11 diff -u -r1.11 RuntimeComponent.java --- src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponent.java 22 Dec 2009 08:15:18 -0000 1.11 +++ src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponent.java 6 Jan 2010 23:41:30 -0000 @@ -103,6 +103,8 @@ this.properties.put( key, value ); } + @SuppressWarnings( "rawtypes" ) + public Object getAdapter( final Class type ) { final IAdapterManager manager = Platform.getAdapterManager(); Index: src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentType.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentType.java,v retrieving revision 1.14 diff -u -r1.14 RuntimeComponentType.java --- src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentType.java 22 Dec 2009 08:15:18 -0000 1.14 +++ src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentType.java 6 Jan 2010 23:41:30 -0000 @@ -52,10 +52,11 @@ void addVersion( final IRuntimeComponentVersion ver ) { - this.versions.add( ver.getVersionString(), ver ); + this.versions.addItemWithKey( ver.getVersionString(), ver ); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings( "rawtypes" ) + public Object getAdapter( final Class type ) { return Platform.getAdapterManager().loadAdapter( this, type.getName() ); Index: src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentVersion.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentVersion.java,v retrieving revision 1.16 diff -u -r1.16 RuntimeComponentVersion.java --- src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentVersion.java 22 Dec 2009 08:15:18 -0000 1.16 +++ src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentVersion.java 6 Jan 2010 23:41:30 -0000 @@ -140,7 +140,7 @@ return this.compTable.get( rcv ).intValue(); } - else if( obj instanceof UnknownVersion ) + else if( obj instanceof UnknownVersion ) { try { @@ -159,7 +159,8 @@ } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings( "rawtypes" ) + public Object getAdapter( final Class type ) { return Platform.getAdapterManager().loadAdapter( this, type.getName() ); Index: src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeManagerImpl.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeManagerImpl.java,v retrieving revision 1.30 diff -u -r1.30 RuntimeManagerImpl.java --- src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeManagerImpl.java 22 Dec 2009 08:15:18 -0000 1.30 +++ src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeManagerImpl.java 6 Jan 2010 23:41:31 -0000 @@ -103,7 +103,7 @@ public static Set getRuntimeComponentTypes() { - return runtimeComponentTypes.getUnmodifiable(); + return runtimeComponentTypes.getItemSet(); } public static boolean isRuntimeComponentTypeDefined( final String id ) @@ -113,7 +113,7 @@ public static IRuntimeComponentType getRuntimeComponentType( final String id ) { - final IRuntimeComponentType rc = runtimeComponentTypes.get( id ); + final IRuntimeComponentType rc = runtimeComponentTypes.getItemByKey( id ); if( rc == null ) { @@ -149,7 +149,7 @@ synchronized( runtimes ) { bridge(); - return new HashSet( runtimes ); + return new HashSet( runtimes.getItemSet() ); } } @@ -161,7 +161,7 @@ final Set result = new HashSet(); - for( IRuntime r : runtimes ) + for( IRuntime r : runtimes.getItemSet() ) { boolean supports = true; @@ -199,7 +199,7 @@ { bridge(); - final IRuntime runtime = runtimes.get( name ); + final IRuntime runtime = runtimes.getItemByKey( name ); if( runtime == null ) { @@ -234,7 +234,7 @@ } } - runtimes.add( r.getName(), r ); + runtimes.addItemWithKey( r.getName(), r ); notifyRuntimeListeners(); @@ -246,7 +246,7 @@ { synchronized( runtimes ) { - if( runtimes.delete( runtime.getName() ) ) + if( runtimes.removeItemByKey( runtime.getName() ) ) { notifyRuntimeListeners(); } @@ -353,7 +353,7 @@ final Map existing = new HashMap(); - for( IRuntime r : runtimes ) + for( IRuntime r : runtimes.getItemSet() ) { if( r instanceof BridgedRuntime ) { @@ -380,7 +380,7 @@ for( BridgedRuntime r : existing.values() ) { - runtimes.remove( r.getName() ); + runtimes.removeItemByKey( r.getName() ); modified = true; } @@ -393,7 +393,7 @@ { if( ! exported.contains( r.getNativeRuntimeId() ) ) { - runtimes.delete( r.getName() ); + runtimes.removeItemByKey( r.getName() ); modified = true; } } @@ -413,7 +413,7 @@ r.setName( createUniqueRuntimeName( id ) ); - runtimes.add( r.getName(), r ); + runtimes.addItemWithKey( r.getName(), r ); modified = true; } catch( CoreException e ) @@ -535,7 +535,7 @@ } } - runtimeComponentTypes.add( id, rct ); + runtimeComponentTypes.addItemWithKey( id, rct ); } private static void readRuntimeComponentVersion( final IConfigurationElement config ) @@ -557,7 +557,7 @@ } final RuntimeComponentType rct - = (RuntimeComponentType) runtimeComponentTypes.get( type ); + = (RuntimeComponentType) runtimeComponentTypes.getItemByKey( type ); if( rct == null ) { @@ -592,7 +592,7 @@ final List badRuntimeComponentTypes = new ArrayList(); - for( IRuntimeComponentType rct : runtimeComponentTypes ) + for( IRuntimeComponentType rct : runtimeComponentTypes.getItemSet() ) { try { @@ -651,7 +651,7 @@ for( IRuntimeComponentType rct : badRuntimeComponentTypes ) { - runtimeComponentTypes.remove( rct ); + runtimeComponentTypes.removeItem( rct ); } } Index: src/org/eclipse/wst/common/project/facet/core/util/internal/CollectionsUtil.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/util/internal/CollectionsUtil.java,v retrieving revision 1.2 diff -u -r1.2 CollectionsUtil.java --- src/org/eclipse/wst/common/project/facet/core/util/internal/CollectionsUtil.java 22 Dec 2009 08:15:09 -0000 1.2 +++ src/org/eclipse/wst/common/project/facet/core/util/internal/CollectionsUtil.java 6 Jan 2010 23:41:31 -0000 @@ -26,7 +26,8 @@ { private CollectionsUtil() {} - @SuppressWarnings( "unchecked" ) + @SuppressWarnings( "rawtypes" ) + private static final Comparator> INVERTING_COMPARATOR = new Comparator>() { @@ -45,7 +46,8 @@ * @return an inverting comparator */ - @SuppressWarnings( "unchecked" ) + @SuppressWarnings( { "unchecked", "rawtypes" } ) + public static Comparator getInvertingComparator() { return (Comparator) INVERTING_COMPARATOR; Index: src/org/eclipse/wst/common/project/facet/core/util/internal/IndexedSet.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/util/internal/IndexedSet.java,v retrieving revision 1.4 diff -u -r1.4 IndexedSet.java --- src/org/eclipse/wst/common/project/facet/core/util/internal/IndexedSet.java 22 Dec 2009 08:15:09 -0000 1.4 +++ src/org/eclipse/wst/common/project/facet/core/util/internal/IndexedSet.java 6 Jan 2010 23:41:31 -0000 @@ -14,6 +14,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -22,56 +23,101 @@ */ public final class IndexedSet - - extends HashSet - { - private static final long serialVersionUID = 1L; + private final Set set; private final Set unmodifiable; private final Map index; public IndexedSet() { - this.unmodifiable = Collections.unmodifiableSet( this ); + this.set = new HashSet(); + this.unmodifiable = Collections.unmodifiableSet( this.set ); this.index = new HashMap(); } - public void add( final K key, - final V value ) + public Set getItemSet() { - remove( this.index.get( key ) ); - add( value ); - this.index.put( key, value ); + return this.unmodifiable; + } + + public V getItemByKey( final K key ) + { + return this.index.get( key ); } - public boolean delete( final K key ) + public boolean containsKey( final K key ) { - final Object value = this.index.get( key ); - - if( value == null ) - { - return false; - } - else + return this.index.containsKey( key ); + } + + public boolean containsItem( final V item ) + { + return this.set.contains( item ); + } + + public void addItem( final V item ) + { + if( item == null ) { - remove( value ); - this.index.remove( key ); - return true; + throw new IllegalArgumentException(); } + + this.set.add( item ); } - public V get( final K key ) + public void addItemWithKey( final K key, + final V item ) { - return this.index.get( key ); + addItem( item ); + addKey( key, item ); } - public boolean containsKey( final K key ) + public void addKey( final K key, + final V item ) { - return this.index.containsKey( key ); + if( key == null || item == null ) + { + throw new IllegalArgumentException(); + } + + if( ! this.set.contains( item ) ) + { + throw new IllegalArgumentException(); + } + + this.index.put( key, item ); } - public Set getUnmodifiable() + public boolean removeItem( final V item ) { - return this.unmodifiable; + if( this.set.remove( item ) ) + { + for( Iterator> itr = this.index.entrySet().iterator(); itr.hasNext(); ) + { + final Map.Entry entry = itr.next(); + + if( entry.getValue() == item ) + { + itr.remove(); + } + } + + return true; + } + + return false; + } + + public boolean removeItemByKey( final K key ) + { + final V item = this.index.get( key ); + + if( item != null ) + { + return removeItem( item ); + } + + return false; } + } \ No newline at end of file Index: src/org/eclipse/wst/common/project/facet/core/util/internal/PluginUtil.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/util/internal/PluginUtil.java,v retrieving revision 1.5 diff -u -r1.5 PluginUtil.java --- src/org/eclipse/wst/common/project/facet/core/util/internal/PluginUtil.java 22 Dec 2009 08:15:09 -0000 1.5 +++ src/org/eclipse/wst/common/project/facet/core/util/internal/PluginUtil.java 6 Jan 2010 23:41:31 -0000 @@ -184,12 +184,13 @@ } @SuppressWarnings( "unchecked" ) + public static Class loadClass( final String pluginId, final String clname, final Class interfc ) { final Bundle bundle = Platform.getBundle( pluginId ); - final Class cl; + final Class cl; try { @@ -216,7 +217,7 @@ return null; } - return cl; + return (Class) cl; } public static T instantiate( final String pluginId, Index: src/org/eclipse/wst/common/project/facet/core/util/internal/Versionable.java =================================================================== RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.project.facet.core/src/org/eclipse/wst/common/project/facet/core/util/internal/Versionable.java,v retrieving revision 1.9 diff -u -r1.9 Versionable.java --- src/org/eclipse/wst/common/project/facet/core/util/internal/Versionable.java 22 Dec 2009 08:15:09 -0000 1.9 +++ src/org/eclipse/wst/common/project/facet/core/util/internal/Versionable.java 6 Jan 2010 23:41:31 -0000 @@ -49,7 +49,7 @@ public Set getVersions() { - return this.versions.getUnmodifiable(); + return this.versions.getItemSet(); } public Set getVersions( final String expr ) @@ -60,7 +60,7 @@ final VersionExpr prepared = new VersionExpr( this, expr, null ); final Set result = new HashSet(); - for( T ver : this.versions ) + for( T ver : this.versions.getItemSet() ) { if( prepared.check( ver ) ) { @@ -73,7 +73,7 @@ public T getVersion( final String version ) { - final T ver = this.versions.get( version ); + final T ver = this.versions.getItemByKey( version ); if( ver == null ) { @@ -87,10 +87,9 @@ public T getLatestVersion() { - if( this.versions.size() > 0 ) + if( this.versions.getItemSet().size() > 0 ) { - // [263113] Versionable no longer compiles as of I20090125-2000 - return (T) Collections.max( this.versions ); + return (T) Collections.max( this.versions.getItemSet() ); } else { @@ -124,13 +123,14 @@ }; } - final List list = new ArrayList( this.versions ); + final List list = new ArrayList( this.versions.getItemSet() ); Collections.sort( list, comp ); return list; } @SuppressWarnings( "unchecked" ) + public Comparator getVersionComparator() throws CoreException @@ -150,9 +150,7 @@ try { - final Class cl - = bundle.loadClass( this.versionComparatorClass ); - + final Class cl = bundle.loadClass( this.versionComparatorClass ); this.versionComparator = (Comparator) cl.newInstance(); } catch( Exception e )