Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 298905 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java (-2 / +2 lines)
Lines 16-25 Link Here
16
16
17
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IPath;
18
import org.eclipse.core.runtime.Path;
18
import org.eclipse.core.runtime.Path;
19
import org.eclipse.jst.common.project.facet.core.JavaFacet;
19
import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig;
20
import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig;
20
import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.ChangeEvent;
21
import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.ChangeEvent;
21
import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
22
import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
22
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
23
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
23
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
24
import org.eclipse.wst.common.project.facet.core.util.IEventListener;
24
import org.eclipse.wst.common.project.facet.core.util.IEventListener;
25
25
Lines 54-60 Link Here
54
        
54
        
55
        final IDataModel dm = getDataModel();
55
        final IDataModel dm = getDataModel();
56
        
56
        
57
        dm.setProperty( FACET_ID, IModuleConstants.JST_JAVA );
57
        dm.setProperty( FACET_ID, JavaFacet.ID );
58
        dm.setProperty( JAVA_FACET_INSTALL_CONFIG, this.installConfig );
58
        dm.setProperty( JAVA_FACET_INSTALL_CONFIG, this.installConfig );
59
        
59
        
60
        String sourceFolderName = null;
60
        String sourceFolderName = null;
(-)src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java (-6 / +10 lines)
Lines 19-34 Link Here
19
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
19
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
20
20
21
/**
21
/**
22
 * This class is deprecated. JavaFacet class should be used instead.
23
 * 
22
 * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
24
 * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
23
 */
25
 */
24
26
27
@Deprecated
28
25
public final class JavaFacetUtils
29
public final class JavaFacetUtils
26
{
30
{
27
    public static final IProjectFacet JAVA_FACET = JavaFacet.FACET;
31
    public static final IProjectFacet JAVA_FACET = JavaFacet.FACET;
28
    public static final IProjectFacetVersion JAVA_13 = JavaFacet.JAVA_13;
32
    public static final IProjectFacetVersion JAVA_13 = JavaFacet.VERSION_1_3;
29
    public static final IProjectFacetVersion JAVA_14 = JavaFacet.JAVA_14;
33
    public static final IProjectFacetVersion JAVA_14 = JavaFacet.VERSION_1_4;
30
    public static final IProjectFacetVersion JAVA_50 = JavaFacet.JAVA_50;
34
    public static final IProjectFacetVersion JAVA_50 = JavaFacet.VERSION_1_5;
31
    public static final IProjectFacetVersion JAVA_60 = JavaFacet.JAVA_60;
35
    public static final IProjectFacetVersion JAVA_60 = JavaFacet.VERSION_1_6;
32
    
36
    
33
    public static String getCompilerLevel()
37
    public static String getCompilerLevel()
34
    {
38
    {
Lines 75-86 Link Here
75
    
79
    
76
    public static IProjectFacetVersion compilerLevelToFacet( final String ver )
80
    public static IProjectFacetVersion compilerLevelToFacet( final String ver )
77
    {
81
    {
78
        return JavaFacetUtil.compilerLevelToFacet( ver );
82
        return JavaFacet.FACET.getVersion( ver );
79
    }
83
    }
80
84
81
    public static String facetToCompilerLevel( final IProjectFacetVersion fv )
85
    public static String facetToCompilerLevel( final IProjectFacetVersion fv )
82
    {
86
    {
83
        return JavaFacetUtil.facetToCompilerLevel( fv );
87
        return fv.getVersionString();
84
    }
88
    }
85
    
89
    
86
}
90
}
(-)src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java (-1 / +2 lines)
Lines 13-18 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Collection;
14
import java.util.Collection;
15
15
16
import org.eclipse.jst.common.project.facet.core.JavaFacet;
16
import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider;
17
import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider;
17
18
18
public class JavaProjectFacetCreationDataModelProvider extends FacetProjectCreationDataModelProvider {
19
public class JavaProjectFacetCreationDataModelProvider extends FacetProjectCreationDataModelProvider {
Lines 26-32 Link Here
26
		super.init();
27
		super.init();
27
28
28
        Collection requiredFacets = new ArrayList();
29
        Collection requiredFacets = new ArrayList();
29
        requiredFacets.add(JavaFacetUtils.JAVA_FACET);
30
        requiredFacets.add(JavaFacet.FACET);
30
        setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets);
31
        setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets);
31
	}
32
	}
32
33
(-)plugin.properties (-2 / +2 lines)
Lines 1-7 Link Here
1
pluginName = Eclipse Faceted Project Framework JDT Enablement
1
pluginName = Eclipse Faceted Project Framework JDT Enablement
2
providerName = Eclipse Web Tools Platform
2
providerName = Eclipse Web Tools Platform
3
jstJavaFacetLabel = Java
3
javaFacetLabel = Java
4
jstJavaFacetDescription = Adds support for writing applications using Java programming language.
4
javaFacetDescription = Adds support for writing applications using Java programming language.
5
javaVersionMismatchMarkerName = Faceted Project Problem (Java Version Mismatch)
5
javaVersionMismatchMarkerName = Faceted Project Problem (Java Version Mismatch)
6
libraryProvidersExtensionPointName = Library Providers Extension Point
6
libraryProvidersExtensionPointName = Library Providers Extension Point
7
legacyLibraryProviderDetectorsExtensionPointName = Legacy Library Provider Detectors Extension Point
7
legacyLibraryProviderDetectorsExtensionPointName = Legacy Library Provider Detectors Extension Point
(-)plugin.xml (-19 / +37 lines)
Lines 22-50 Link Here
22
    <runtime-component-type id="standard.jre"/>
22
    <runtime-component-type id="standard.jre"/>
23
    <runtime-component-version type="standard.jre" version="1.3"/>
23
    <runtime-component-version type="standard.jre" version="1.3"/>
24
    <runtime-component-version type="standard.jre" version="1.4"/>
24
    <runtime-component-version type="standard.jre" version="1.4"/>
25
    <runtime-component-version type="standard.jre" version="5.0"/>
25
    <runtime-component-version type="standard.jre" version="1.5"/>
26
    <runtime-component-version type="standard.jre" version="6.0"/>
26
    <runtime-component-version type="standard.jre" version="1.6"/>
27
    <runtime-component-version type="standard.jre" version="1.7"/>
27
28
28
    <supported>
29
    <supported>
29
      <facet id="jst.java" version="1.3"/>
30
      <facet id="java" version="1.3"/>
30
      <runtime-component id="standard.jre" version="[1.3"/>
31
      <runtime-component id="standard.jre" version="[1.3"/>
31
    </supported>
32
    </supported>
32
33
33
    <supported>
34
    <supported>
34
      <facet id="jst.java" version="1.4"/>
35
      <facet id="java" version="1.4"/>
35
      <runtime-component id="standard.jre" version="[1.4"/>
36
      <runtime-component id="standard.jre" version="[1.4"/>
36
    </supported>
37
    </supported>
37
38
38
    <supported>
39
    <supported>
39
      <facet id="jst.java" version="5.0"/>
40
      <facet id="java" version="1.5"/>
40
      <runtime-component id="standard.jre" version="[5.0"/>
41
      <runtime-component id="standard.jre" version="[1.5"/>
41
    </supported>
42
    </supported>
42
43
43
    <supported>
44
    <supported>
44
      <facet id="jst.java" version="6.0"/>
45
      <facet id="java" version="1.6"/>
45
      <runtime-component id="standard.jre" version="[6.0"/>
46
      <runtime-component id="standard.jre" version="[1.6"/>
46
    </supported>
47
    </supported>
47
    
48
    
49
    <supported>
50
      <facet id="java" version="1.7"/>
51
      <runtime-component id="standard.jre" version="[1.7"/>
52
    </supported>
53
48
    <adapter>
54
    <adapter>
49
      <runtime-component id="standard.jre"/>
55
      <runtime-component id="standard.jre"/>
50
      <factory class="org.eclipse.jst.common.project.facet.core.internal.StandardJreClasspathProvider$Factory"/>
56
      <factory class="org.eclipse.jst.common.project.facet.core.internal.StandardJreClasspathProvider$Factory"/>
Lines 55-101 Link Here
55
61
56
  <extension point="org.eclipse.wst.common.project.facet.core.facets">
62
  <extension point="org.eclipse.wst.common.project.facet.core.facets">
57
  
63
  
58
    <project-facet id="jst.java">
64
    <project-facet id="java">
59
      <label>%jstJavaFacetLabel</label>
65
      <label>%javaFacetLabel</label>
60
      <description>%jstJavaFacetDescription</description>
66
      <description>%javaFacetDescription</description>
61
      <default-version provider="org.eclipse.jst.common.project.facet.core.internal.JavaFacetDefaultVersionProvider"/>
67
      <default-version provider="org.eclipse.jst.common.project.facet.core.internal.JavaFacetDefaultVersionProvider"/>
62
    </project-facet>
68
    </project-facet>
63
69
64
    <project-facet-version facet="jst.java" version="1.3">
70
    <project-facet-version facet="java" version="1.3">
71
      <constraint>
72
        <conflicts facet="wst.web"/>
73
      </constraint>
74
    </project-facet-version>
75
76
    <project-facet-version facet="java" version="1.4">
65
      <constraint>
77
      <constraint>
66
        <conflicts facet="wst.web"/>
78
        <conflicts facet="wst.web"/>
67
      </constraint>
79
      </constraint>
68
    </project-facet-version>
80
    </project-facet-version>
69
81
70
    <project-facet-version facet="jst.java" version="1.4">
82
    <project-facet-version facet="java" version="1.5">
71
      <constraint>
83
      <constraint>
72
        <conflicts facet="wst.web"/>
84
        <conflicts facet="wst.web"/>
73
      </constraint>
85
      </constraint>
74
    </project-facet-version>
86
    </project-facet-version>
75
87
76
    <project-facet-version facet="jst.java" version="5.0">
88
    <project-facet-version facet="java" version="1.6">
77
      <constraint>
89
      <constraint>
78
        <conflicts facet="wst.web"/>
90
        <conflicts facet="wst.web"/>
79
      </constraint>
91
      </constraint>
80
    </project-facet-version>
92
    </project-facet-version>
81
93
82
    <project-facet-version facet="jst.java" version="6.0">
94
    <project-facet-version facet="java" version="1.7">
83
      <constraint>
95
      <constraint>
84
        <conflicts facet="wst.web"/>
96
        <conflicts facet="wst.web"/>
85
      </constraint>
97
      </constraint>
86
    </project-facet-version>
98
    </project-facet-version>
87
99
88
    <action facet="jst.java" type="install" id="jst.java.install">
100
    <action facet="java" type="install" id="java.install">
89
      <delegate class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetInstallDelegate"/>
101
      <delegate class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetInstallDelegate"/>
90
      <config-factory class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetInstallConfigFactory"/>
102
      <config-factory class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetInstallConfigFactory"/>
91
    </action>
103
    </action>
92
104
93
    <action facet="jst.java" type="uninstall">
105
    <action facet="java" type="uninstall">
94
      <delegate class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetUninstallDelegate"/>
106
      <delegate class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetUninstallDelegate"/>
95
      <config-factory class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetUninstallConfigFactory"/>
107
      <config-factory class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetUninstallConfigFactory"/>
96
    </action>
108
    </action>
97
109
98
    <action facet="jst.java" type="version-change">
110
    <action facet="java" type="version-change">
99
      <delegate class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetVersionChangeDelegate"/>
111
      <delegate class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetVersionChangeDelegate"/>
100
      <config-factory class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetVersionChangeConfigFactory"/>
112
      <config-factory class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetVersionChangeConfigFactory"/>
101
    </action>
113
    </action>
Lines 110-116 Link Here
110
  
122
  
111
  <extension point="org.eclipse.wst.common.project.facet.core.validators">
123
  <extension point="org.eclipse.wst.common.project.facet.core.validators">
112
    <validator class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetValidator">
124
    <validator class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetValidator">
113
      <facet id="jst.java"/>
125
      <facet id="java"/>
114
    </validator>
126
    </validator>
115
  </extension>    
127
  </extension>    
116
  
128
  
Lines 118-123 Link Here
118
    <detector class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetDetector"/>
130
    <detector class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetDetector"/>
119
  </extension>
131
  </extension>
120
132
133
  <extension point="org.eclipse.wst.common.project.facet.core.aliases">
134
    <facet-alias facet="java" alias="jst.java"/>
135
    <facet-version-alias facet="java" version="1.5" alias="5.0"/>
136
    <facet-version-alias facet="java" version="1.6" alias="6.0"/>
137
  </extension>
138
121
  <extension 
139
  <extension 
122
    point="org.eclipse.core.resources.markers"
140
    point="org.eclipse.core.resources.markers"
123
    id="javaVersionMismatch"
141
    id="javaVersionMismatch"
(-)src/org/eclipse/jst/common/project/facet/core/JavaFacet.java (-13 / +16 lines)
Lines 26-47 Link Here
26
26
27
public final class JavaFacet 
27
public final class JavaFacet 
28
{
28
{
29
    public static final String ID = "jst.java"; //$NON-NLS-1$
29
    public static final String ID = "java"; //$NON-NLS-1$
30
    
30
    public static final IProjectFacet FACET = ProjectFacetsManager.getProjectFacet( ID );
31
    public static final IProjectFacet FACET 
31
    public static final IProjectFacetVersion VERSION_1_3 = FACET.getVersion( "1.3" ); //$NON-NLS-1$
32
        = ProjectFacetsManager.getProjectFacet( ID );
32
    public static final IProjectFacetVersion VERSION_1_4 = FACET.getVersion( "1.4" ); //$NON-NLS-1$
33
    
33
    public static final IProjectFacetVersion VERSION_1_5 = FACET.getVersion( "1.5" ); //$NON-NLS-1$
34
    public static final IProjectFacetVersion JAVA_13
34
    public static final IProjectFacetVersion VERSION_1_6 = FACET.getVersion( "1.6" ); //$NON-NLS-1$
35
        = FACET.getVersion( "1.3" ); //$NON-NLS-1$
35
    public static final IProjectFacetVersion VERSION_1_7 = FACET.getVersion( "1.7" ); //$NON-NLS-1$
36
37
    @Deprecated
38
    public static final IProjectFacetVersion JAVA_13 = VERSION_1_3;
36
    
39
    
37
    public static final IProjectFacetVersion JAVA_14
40
    @Deprecated
38
        = FACET.getVersion( "1.4" ); //$NON-NLS-1$
41
    public static final IProjectFacetVersion JAVA_14 = VERSION_1_4;
39
    
42
    
40
    public static final IProjectFacetVersion JAVA_50
43
    @Deprecated
41
        = FACET.getVersion( "5.0" ); //$NON-NLS-1$
44
    public static final IProjectFacetVersion JAVA_50 = VERSION_1_5;
42
    
45
    
43
    public static final IProjectFacetVersion JAVA_60
46
    @Deprecated
44
        = FACET.getVersion( "6.0" ); //$NON-NLS-1$
47
    public static final IProjectFacetVersion JAVA_60 = VERSION_1_6;
45
48
46
    public static boolean isInstalled( final IProject project )
49
    public static boolean isInstalled( final IProject project )
47
    {
50
    {
(-)src/org/eclipse/jst/common/project/facet/core/StandardJreRuntimeComponent.java (-20 / +21 lines)
Lines 28-49 Link Here
28
public final class StandardJreRuntimeComponent 
28
public final class StandardJreRuntimeComponent 
29
{
29
{
30
    public static final String TYPE_ID = "standard.jre"; //$NON-NLS-1$
30
    public static final String TYPE_ID = "standard.jre"; //$NON-NLS-1$
31
    
31
    public static final IRuntimeComponentType TYPE = RuntimeManager.getRuntimeComponentType( TYPE_ID );
32
    public static final IRuntimeComponentType TYPE 
32
    public static final IRuntimeComponentVersion VERSION_1_3 = TYPE.getVersion( "1.3" ); //$NON-NLS-1$
33
        = RuntimeManager.getRuntimeComponentType( TYPE_ID );
33
    public static final IRuntimeComponentVersion VERSION_1_4 = TYPE.getVersion( "1.4" ); //$NON-NLS-1$
34
    
34
    public static final IRuntimeComponentVersion VERSION_1_5 = TYPE.getVersion( "1.5" ); //$NON-NLS-1$
35
    public static final IRuntimeComponentVersion VERSION_1_3
35
    public static final IRuntimeComponentVersion VERSION_1_6 = TYPE.getVersion( "1.6" ); //$NON-NLS-1$
36
        = TYPE.getVersion( "1.3" ); //$NON-NLS-1$
36
    public static final IRuntimeComponentVersion VERSION_1_7 = TYPE.getVersion( "1.7" ); //$NON-NLS-1$
37
    
38
    public static final IRuntimeComponentVersion VERSION_1_4
39
        = TYPE.getVersion( "1.4" ); //$NON-NLS-1$
40
37
41
    public static final IRuntimeComponentVersion VERSION_5_0
38
    @Deprecated
42
        = TYPE.getVersion( "5.0" ); //$NON-NLS-1$
39
    public static final IRuntimeComponentVersion VERSION_5_0 = VERSION_1_5;
43
    
44
    public static final IRuntimeComponentVersion VERSION_6_0
45
        = TYPE.getVersion( "6.0" ); //$NON-NLS-1$
46
    
40
    
41
    @Deprecated( )
42
    public static final IRuntimeComponentVersion VERSION_6_0 = VERSION_1_6;
43
47
    public static final String PROP_VM_INSTALL_TYPE = "vm-install-type"; //$NON-NLS-1$
44
    public static final String PROP_VM_INSTALL_TYPE = "vm-install-type"; //$NON-NLS-1$
48
    public static final String PROP_VM_INSTALL_ID = "vm-install-id"; //$NON-NLS-1$
45
    public static final String PROP_VM_INSTALL_ID = "vm-install-id"; //$NON-NLS-1$
49
    
46
    
Lines 61-67 Link Here
61
        
58
        
62
        if( jvmver == null ) 
59
        if( jvmver == null ) 
63
        {
60
        {
64
            rcv = StandardJreRuntimeComponent.VERSION_6_0;
61
            rcv = StandardJreRuntimeComponent.VERSION_1_7;
65
        } 
62
        } 
66
        else if( jvmver.startsWith( "1.3" ) ) //$NON-NLS-1$
63
        else if( jvmver.startsWith( "1.3" ) ) //$NON-NLS-1$
67
        {
64
        {
Lines 71-87 Link Here
71
        {
68
        {
72
            rcv = StandardJreRuntimeComponent.VERSION_1_4;
69
            rcv = StandardJreRuntimeComponent.VERSION_1_4;
73
        }
70
        }
74
        else if( jvmver.startsWith( "1.5" ) || jvmver.startsWith( "5.0" ) ) //$NON-NLS-1$ //$NON-NLS-2$
71
        else if( jvmver.startsWith( "1.5" ) ) //$NON-NLS-1$
72
        {
73
            rcv = StandardJreRuntimeComponent.VERSION_1_5;
74
        }
75
        else if( jvmver.startsWith( "1.6" ) ) //$NON-NLS-1$
75
        {
76
        {
76
            rcv = StandardJreRuntimeComponent.VERSION_5_0;
77
            rcv = StandardJreRuntimeComponent.VERSION_1_6;
77
        }
78
        }
78
        else if( jvmver.startsWith( "1.6" ) || jvmver.startsWith( "6.0" ) ) //$NON-NLS-1$ //$NON-NLS-2$
79
        else if( jvmver.startsWith( "1.7" ) ) //$NON-NLS-1$
79
        {
80
        {
80
            rcv = StandardJreRuntimeComponent.VERSION_6_0;
81
            rcv = StandardJreRuntimeComponent.VERSION_1_7;
81
        }
82
        }
82
        else 
83
        else 
83
        {
84
        {
84
            rcv = StandardJreRuntimeComponent.VERSION_6_0;
85
            rcv = StandardJreRuntimeComponent.VERSION_1_7;
85
        }
86
        }
86
        
87
        
87
        final Map<String,String> properties = new HashMap<String,String>();
88
        final Map<String,String> properties = new HashMap<String,String>();
(-)src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetDefaultVersionProvider.java (-1 / +20 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.jst.common.project.facet.core.internal;
12
package org.eclipse.jst.common.project.facet.core.internal;
13
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.jst.common.project.facet.core.JavaFacet;
14
import org.eclipse.wst.common.project.facet.core.IDefaultVersionProvider;
16
import org.eclipse.wst.common.project.facet.core.IDefaultVersionProvider;
15
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
17
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
16
18
Lines 29-34 Link Here
29
    public IProjectFacetVersion getDefaultVersion()
31
    public IProjectFacetVersion getDefaultVersion()
30
    {
32
    {
31
        final String compilerLevel = JavaFacetUtil.getCompilerLevel();
33
        final String compilerLevel = JavaFacetUtil.getCompilerLevel();
32
        return JavaFacetUtil.compilerLevelToFacet( compilerLevel );
34
        
35
        if( JavaFacet.FACET.hasVersion( compilerLevel ) )
36
        {
37
            return JavaFacet.FACET.getVersion( compilerLevel );
38
        }
39
        else
40
        {
41
            try
42
            {
43
                return JavaFacet.FACET.getLatestVersion();
44
            }
45
            catch( CoreException e )
46
            {
47
                // Not expected for this facet.
48
                
49
                throw new RuntimeException( e );
50
            }
51
        }
33
    }
52
    }
34
}
53
}
(-)src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java (-100 / +36 lines)
Lines 12-24 Link Here
12
package org.eclipse.jst.common.project.facet.core.internal;
12
package org.eclipse.jst.common.project.facet.core.internal;
13
13
14
import java.util.Collections;
14
import java.util.Collections;
15
import java.util.HashMap;
15
import java.util.Hashtable;
16
import java.util.Hashtable;
16
import java.util.List;
17
import java.util.List;
18
import java.util.Map;
17
19
18
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IWorkspace;
21
import org.eclipse.core.resources.IWorkspace;
20
import org.eclipse.core.resources.IncrementalProjectBuilder;
22
import org.eclipse.core.resources.IncrementalProjectBuilder;
21
import org.eclipse.core.resources.ProjectScope;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IPath;
25
import org.eclipse.core.runtime.IPath;
Lines 28-47 Link Here
28
import org.eclipse.core.runtime.Status;
29
import org.eclipse.core.runtime.Status;
29
import org.eclipse.core.runtime.SubProgressMonitor;
30
import org.eclipse.core.runtime.SubProgressMonitor;
30
import org.eclipse.core.runtime.jobs.Job;
31
import org.eclipse.core.runtime.jobs.Job;
31
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
32
import org.eclipse.core.runtime.preferences.IScopeContext;
33
import org.eclipse.core.runtime.preferences.InstanceScope;
34
import org.eclipse.jdt.core.IClasspathEntry;
32
import org.eclipse.jdt.core.IClasspathEntry;
35
import org.eclipse.jdt.core.IJavaProject;
33
import org.eclipse.jdt.core.IJavaProject;
36
import org.eclipse.jdt.core.JavaCore;
34
import org.eclipse.jdt.core.JavaCore;
37
import org.eclipse.jdt.internal.core.JavaProject;
38
import org.eclipse.jdt.launching.IVMInstall;
35
import org.eclipse.jdt.launching.IVMInstall;
39
import org.eclipse.jdt.launching.JavaRuntime;
36
import org.eclipse.jdt.launching.JavaRuntime;
40
import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
37
import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
41
import org.eclipse.jst.common.project.facet.core.JavaFacet;
38
import org.eclipse.jst.common.project.facet.core.JavaFacet;
42
import org.eclipse.osgi.util.NLS;
39
import org.eclipse.osgi.util.NLS;
43
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
40
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
44
import org.osgi.service.prefs.BackingStoreException;
45
41
46
/**
42
/**
47
 * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
43
 * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
Lines 49-66 Link Here
49
45
50
public final class JavaFacetUtil
46
public final class JavaFacetUtil
51
{
47
{
52
    public static final String FILE_CLASSPATH = JavaProject.CLASSPATH_FILENAME;
48
    public static final String FILE_CLASSPATH = ".classpath";  //$NON-NLS-1$
53
    public static final String FILE_JDT_CORE_PREFS = ".settings/org.eclipse.jdt.core.prefs"; //$NON-NLS-1$
49
    public static final String FILE_JDT_CORE_PREFS = ".settings/org.eclipse.jdt.core.prefs"; //$NON-NLS-1$
54
    
50
    
51
    private static final IPath CPE_PREFIX_FOR_EXEC_ENV 
52
        = new Path( "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType" ); //$NON-NLS-1$
53
    
54
    private static final Map<IProjectFacetVersion,String> FACET_VER_TO_EXEC_ENV = new HashMap<IProjectFacetVersion,String>();
55
    
56
    static
57
    {
58
        FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_3, "J2SE-1.3" ); //$NON-NLS-1$
59
        FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_4, "J2SE-1.4" ); //$NON-NLS-1$
60
        FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_5, "J2SE-1.5" ); //$NON-NLS-1$
61
        FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_6, "JavaSE-1.6" ); //$NON-NLS-1$
62
        FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_7, "JavaSE-1.7" ); //$NON-NLS-1$
63
    }
64
    
55
    public static String getCompilerLevel()
65
    public static String getCompilerLevel()
56
    {
66
    {
57
        final IScopeContext context = new InstanceScope();
67
        String level = JavaCore.getOption( JavaCore.COMPILER_COMPLIANCE );
58
        final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID );
59
        String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null );
60
        
68
        
61
        if( level == null )
69
        if( level == null )
62
        {
70
        {
63
            final Hashtable defaults = JavaCore.getDefaultOptions();
71
            final Hashtable<?,?> defaults = JavaCore.getDefaultOptions();
64
            level = (String) defaults.get( JavaCore.COMPILER_COMPLIANCE );
72
            level = (String) defaults.get( JavaCore.COMPILER_COMPLIANCE );
65
        }
73
        }
66
        
74
        
Lines 69-77 Link Here
69
77
70
    public static String getCompilerLevel( final IProject project )
78
    public static String getCompilerLevel( final IProject project )
71
    {
79
    {
72
        final IScopeContext context = new ProjectScope( project );
80
        final IJavaProject jproj = JavaCore.create( project );
73
        final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID );
81
        String level = jproj.getOption( JavaCore.COMPILER_COMPLIANCE, false );
74
        String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null );
75
        
82
        
76
        if( level == null )
83
        if( level == null )
77
        {
84
        {
Lines 87-93 Link Here
87
        throws CoreException
94
        throws CoreException
88
        
95
        
89
    {
96
    {
90
        setCompilerLevel( project, facetToCompilerLevel( fv ) );
97
        setCompilerLevel( project, fv.getVersionString() );
91
    }
98
    }
92
99
93
    public static void setCompilerLevel( final IProject project,
100
    public static void setCompilerLevel( final IProject project,
Lines 96-151 Link Here
96
        throws CoreException
103
        throws CoreException
97
        
104
        
98
    {
105
    {
99
        final IScopeContext context = new ProjectScope( project );
106
        final IJavaProject jproj = JavaCore.create( project );
100
        
107
        final Map<?,?> options = jproj.getOptions( false );
101
        final IEclipsePreferences prefs 
108
        JavaCore.setComplianceOptions( level, options );
102
            = context.getNode( JavaCore.PLUGIN_ID );
109
        jproj.setOptions( options );
103
        
104
        if( level.equals( JavaCore.VERSION_1_3 ) )
105
        {
106
            prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3 );
107
            prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1 );
108
            prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3 );
109
            prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE );
110
            prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE );
111
        }
112
        else if( level.equals( JavaCore.VERSION_1_4 ) )
113
        {
114
            prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4 );
115
            prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2 );
116
            prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3 );
117
            prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING );
118
            prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING );
119
        }
120
        else if( level.equals( JavaCore.VERSION_1_5 ) )
121
        {
122
            prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5 );
123
            prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5 );
124
            prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5 );
125
            prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR );
126
            prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR );
127
        }
128
        else if( level.equals( JavaCore.VERSION_1_6 ) )
129
        {
130
            prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6 );
131
            prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6 );
132
            prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6 );
133
            prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR );
134
            prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR );
135
        }
136
        else
137
        {
138
            throw new IllegalStateException();
139
        }
140
141
        try
142
        {
143
            prefs.flush();
144
        }
145
        catch( BackingStoreException e )
146
        {
147
            // TODO: Handle this.
148
        }
149
    }
110
    }
150
    
111
    
151
    public static void scheduleFullBuild( final IProject project )
112
    public static void scheduleFullBuild( final IProject project )
Lines 219-232 Link Here
219
            
180
            
220
            if( vm != null )
181
            if( vm != null )
221
            {
182
            {
222
                IPath path = new Path( JavaRuntime.JRE_CONTAINER );
183
                final IPath path = CPE_PREFIX_FOR_EXEC_ENV.append( getCorrespondingExecutionEnvironment( newver ) );
223
                path = path.append( vm.getVMInstallType().getId() );
184
                final IClasspathEntry cpe = JavaCore.newContainerEntry( path );
224
                path = path.append( vm.getName() );
185
                final List<IClasspathEntry> entries = Collections.singletonList( cpe );
225
                
226
                final IClasspathEntry cpe 
227
                    = JavaCore.newContainerEntry( path );
228
                
229
                final List entries = Collections.singletonList( cpe );
230
                
186
                
231
                ClasspathHelper.addClasspathEntries( project, newver, entries );
187
                ClasspathHelper.addClasspathEntries( project, newver, entries );
232
            }
188
            }
Lines 269-304 Link Here
269
        jproj.setRawClasspath( newcp, null );
225
        jproj.setRawClasspath( newcp, null );
270
    }
226
    }
271
    
227
    
272
    public static IProjectFacetVersion compilerLevelToFacet( final String ver )
228
    public static String getCorrespondingExecutionEnvironment( final IProjectFacetVersion fv )
273
    {
229
    {
274
        if( ver.equals( "1.5" ) ) //$NON-NLS-1$
230
        final String res = FACET_VER_TO_EXEC_ENV.get( fv );
275
        {
231
        
276
            return JavaFacet.JAVA_50;
232
        if( res == null )
277
        }
278
        else if( ver.equals(  "1.6" ) ) //$NON-NLS-1$
279
        {
280
            return JavaFacet.JAVA_60;
281
        }
282
        else
283
        {
284
            return JavaFacet.FACET.getVersion( ver );
285
        }
286
    }
287
288
    public static String facetToCompilerLevel( final IProjectFacetVersion fv )
289
    {
290
        if( fv == JavaFacet.JAVA_50 )
291
        {
292
            return JavaCore.VERSION_1_5;
293
        }
294
        else if( fv == JavaFacet.JAVA_60 )
295
        {
296
            return JavaCore.VERSION_1_6;
297
        }
298
        else
299
        {
233
        {
300
            return fv.getVersionString();
234
            throw new IllegalArgumentException( fv.toString() );
301
        }
235
        }
236
        
237
        return res;
302
    }
238
    }
303
    
239
    
304
    private static final class Resources
240
    private static final class Resources
(-)src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetValidator.java (-1 / +1 lines)
Lines 44-50 Link Here
44
        
44
        
45
        final IProjectFacetVersion fv = fproj.getInstalledVersion( JavaFacet.FACET );
45
        final IProjectFacetVersion fv = fproj.getInstalledVersion( JavaFacet.FACET );
46
        
46
        
47
        if( JavaFacetUtil.compilerLevelToFacet( level ) != fv )
47
        if( ! JavaFacet.FACET.hasVersion( level ) || JavaFacet.FACET.getVersion( level ) != fv )
48
        {
48
        {
49
            final IMarker marker
49
            final IMarker marker
50
                = fproj.createErrorMarker( MARKER_ID, Resources.versionsDontMatch );
50
                = fproj.createErrorMarker( MARKER_ID, Resources.versionsDontMatch );
(-)plugin.xml (-2 / +2 lines)
Lines 30-41 Link Here
30
         
30
         
31
  <extension point="org.eclipse.wst.common.project.facet.ui.images">
31
  <extension point="org.eclipse.wst.common.project.facet.ui.images">
32
    <image 
32
    <image 
33
      facet="jst.java" 
33
      facet="java" 
34
      path="images/java-facet.gif"/>
34
      path="images/java-facet.gif"/>
35
  </extension>
35
  </extension>
36
36
37
  <extension point="org.eclipse.wst.common.project.facet.ui.wizardPages">
37
  <extension point="org.eclipse.wst.common.project.facet.ui.wizardPages">
38
    <wizard-pages action="jst.java.install">
38
    <wizard-pages action="java.install">
39
      <page class="org.eclipse.jst.common.project.facet.ui.internal.JavaFacetInstallPage"/>
39
      <page class="org.eclipse.jst.common.project.facet.ui.internal.JavaFacetInstallPage"/>
40
    </wizard-pages>
40
    </wizard-pages>
41
  </extension>
41
  </extension>
(-)src/org/eclipse/jst/common/project/facet/ui/internal/JavaVersionMismatchMarkerResolutions.java (-7 / +2 lines)
Lines 92-98 Link Here
92
            final String level 
92
            final String level 
93
                = this.marker.getAttribute( JavaFacetValidator.ATTR_COMPILER_LEVEL, null );
93
                = this.marker.getAttribute( JavaFacetValidator.ATTR_COMPILER_LEVEL, null );
94
            
94
            
95
            return JavaFacetUtil.compilerLevelToFacet( level );
95
            return JavaFacet.FACET.getVersion( level );
96
        }
96
        }
97
    }
97
    }
98
98
Lines 134-145 Link Here
134
        
134
        
135
        private String getCompilerLevel()
135
        private String getCompilerLevel()
136
        {
136
        {
137
            final String fvstr
137
            return this.marker.getAttribute( JavaFacetValidator.ATTR_FACET_VERSION, null);
138
                = this.marker.getAttribute( JavaFacetValidator.ATTR_FACET_VERSION, null);
139
            
140
            final IProjectFacetVersion fv = JavaFacet.FACET.getVersion( fvstr );
141
            
142
            return JavaFacetUtil.facetToCompilerLevel( fv );
143
        }
138
        }
144
    }
139
    }
145
    
140
    
(-)modulecore-src/org/eclipse/wst/common/componentcore/datamodel/FacetProjectCreationDataModelProvider.java (-1 / +8 lines)
Lines 359-365 Link Here
359
	                config = Platform.getAdapterManager().getAdapter( config, IDataModel.class );
359
	                config = Platform.getAdapterManager().getAdapter( config, IDataModel.class );
360
	            }
360
	            }
361
	            
361
	            
362
	            facetDmMap.add( (IDataModel) config );
362
	            final IDataModel dm = (IDataModel) config;
363
	            
364
	            facetDmMap.put( facet.getId(), dm );
365
	            
366
	            for( String alias : facet.getAliases() )
367
	            {
368
	                facetDmMap.put( alias, dm );
369
	            }
363
	        }
370
	        }
364
		}
371
		}
365
		return super.propertySet(propertyName, propertyValue);
372
		return super.propertySet(propertyName, propertyValue);
(-)plugin.properties (-1 / +2 lines)
Lines 4-7 Link Here
4
validationMarkerName = Faceted Project Problem
4
validationMarkerName = Faceted Project Problem
5
extPointListeners = Faceted Project Listeners Extension Point
5
extPointListeners = Faceted Project Listeners Extension Point
6
extPointPresets = Faceted Project Presets Extension Point
6
extPointPresets = Faceted Project Presets Extension Point
7
extPointDetectors = Project Facet Detectors Extension Point
7
extPointDetectors = Project Facet Detectors Extension Point
8
extPointAliases = Project Facet Aliases Extension Point
(-)plugin.xml (+5 lines)
Lines 43-48 Link Here
43
    name="%extPointDetectors" 
43
    name="%extPointDetectors" 
44
    schema="schemas/detectors.exsd"/>
44
    schema="schemas/detectors.exsd"/>
45
  
45
  
46
  <extension-point 
47
    id="aliases" 
48
    name="%extPointAliases" 
49
    schema="schemas/aliases.exsd"/>
50
  
46
  <extension
51
  <extension
47
    id="nature"
52
    id="nature"
48
    point="org.eclipse.core.resources.natures">
53
    point="org.eclipse.core.resources.natures">
(-)schemas/aliases.exsd (+139 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.common.project.facet.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.wst.common.project.facet.core" id="aliases" name="Project Facet Aliases Extension Point"/>
7
      </appInfo>
8
      <documentation>
9
         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.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <choice minOccurs="1" maxOccurs="unbounded">
21
            <element ref="facet-alias"/>
22
            <element ref="facet-version-alias"/>
23
         </choice>
24
         <attribute name="point" type="string" use="required">
25
            <annotation>
26
               <documentation>
27
                  A fully qualified identifier of the target extension point.
28
               </documentation>
29
            </annotation>
30
         </attribute>
31
         <attribute name="id" type="string">
32
            <annotation>
33
               <documentation>
34
                  An optional identifier of the extension instance.
35
               </documentation>
36
            </annotation>
37
         </attribute>
38
         <attribute name="name" type="string">
39
            <annotation>
40
               <documentation>
41
                  An optional name of the extension instance.
42
               </documentation>
43
            </annotation>
44
         </attribute>
45
      </complexType>
46
   </element>
47
48
   <element name="facet-alias">
49
      <annotation>
50
         <documentation>
51
            Specifies a single facet alias.
52
         </documentation>
53
      </annotation>
54
      <complexType>
55
         <attribute name="facet" type="string" use="required">
56
            <annotation>
57
               <documentation>
58
                  The id of an existing facet.
59
               </documentation>
60
               <appInfo>
61
                  <meta.attribute kind="identifier" basedOn="org.eclipse.wst.common.project.facet.core.facets/project-facet/@id"/>
62
               </appInfo>
63
            </annotation>
64
         </attribute>
65
         <attribute name="alias" type="string" use="required">
66
            <annotation>
67
               <documentation>
68
                  The alias to assign to the specified facet.
69
               </documentation>
70
            </annotation>
71
         </attribute>
72
      </complexType>
73
   </element>
74
75
   <element name="facet-version-alias">
76
      <annotation>
77
         <documentation>
78
            Specifies a single facet version alias.
79
         </documentation>
80
      </annotation>
81
      <complexType>
82
         <attribute name="facet" type="string" use="required">
83
            <annotation>
84
               <documentation>
85
                  The id of an existing facet.
86
               </documentation>
87
               <appInfo>
88
                  <meta.attribute kind="identifier" basedOn="org.eclipse.wst.common.project.facet.core.facets/project-facet/@id"/>
89
               </appInfo>
90
            </annotation>
91
         </attribute>
92
         <attribute name="version" type="string" use="required">
93
            <annotation>
94
               <documentation>
95
                  The facet version to alias.
96
               </documentation>
97
            </annotation>
98
         </attribute>
99
         <attribute name="alias" type="string">
100
            <annotation>
101
               <documentation>
102
                  The alias to assign to the specified facet version.
103
               </documentation>
104
            </annotation>
105
         </attribute>
106
      </complexType>
107
   </element>
108
109
110
   <annotation>
111
      <appInfo>
112
         <meta.section type="examples"/>
113
      </appInfo>
114
      <documentation>
115
         &lt;pre&gt;
116
&lt;extension point=&quot;org.eclipse.wst.common.project.facet.core.aliases&quot;&gt;
117
  &lt;facet-alias facet=&quot;mytech&quot; alias=&quot;formgen&quot;/&gt;
118
  &lt;facet-version-alias facet=&quot;mytech&quot; version=&quot;1.5&quot; alias=&quot;2.0&quot;/&gt;
119
&lt;/extension&gt;
120
&lt;/pre&gt;
121
      </documentation>
122
   </annotation>
123
124
125
126
   <annotation>
127
      <appInfo>
128
         <meta.section type="copyright"/>
129
      </appInfo>
130
      <documentation>
131
         Copyright (c) 2010 Oracle and others.&lt;br&gt;
132
All rights reserved. This program and the accompanying materials are made 
133
available under the terms of the Eclipse Public License v1.0 which accompanies 
134
this distribution, and is available at &lt;a
135
href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
136
      </documentation>
137
   </annotation>
138
139
</schema>
(-)src/org/eclipse/wst/common/project/facet/core/IProjectFacet.java (+9 lines)
Lines 52-57 Link Here
52
    String getId();
52
    String getId();
53
    
53
    
54
    /**
54
    /**
55
     * Returns the alternate identifiers that are associated with this facet. Aliases are specified
56
     * via the <code>aliases</code> extension point.
57
     * 
58
     * @return the alternate identifiers that are associated with this facet, if any
59
     */
60
    
61
    Set<String> getAliases();
62
    
63
    /**
55
     * Returns the id of the plugin that defines this project facet. This method
64
     * Returns the id of the plugin that defines this project facet. This method
56
     * will return <code>null</code> if this facet is not defined. 
65
     * will return <code>null</code> if this facet is not defined. 
57
     * 
66
     * 
(-)src/org/eclipse/wst/common/project/facet/core/internal/Category.java (+2 lines)
Lines 96-101 Link Here
96
        this.facets.remove( f );
96
        this.facets.remove( f );
97
    }
97
    }
98
    
98
    
99
    @SuppressWarnings( "rawtypes" )
100
    
99
    public Object getAdapter( final Class type )
101
    public Object getAdapter( final Class type )
100
    {
102
    {
101
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
103
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
(-)src/org/eclipse/wst/common/project/facet/core/internal/FacetedProject.java (-3 / +2 lines)
Lines 566-581 Link Here
566
     * @deprecated
566
     * @deprecated
567
     */
567
     */
568
    
568
    
569
    @SuppressWarnings( "unchecked" )
570
    public void setRuntime( final IRuntime runtime,
569
    public void setRuntime( final IRuntime runtime,
571
                            final IProgressMonitor monitor )
570
                            final IProgressMonitor monitor )
572
    
571
    
573
        throws CoreException
572
        throws CoreException
574
        
573
        
575
    {
574
    {
576
        final Set runtimes
575
        final Set<IRuntime> runtimes
577
            = runtime == null 
576
            = runtime == null 
578
              ? Collections.EMPTY_SET : Collections.singleton( runtime );
577
              ? Collections.<IRuntime>emptySet() : Collections.singleton( runtime );
579
        
578
        
580
        setTargetedRuntimes( runtimes, monitor );
579
        setTargetedRuntimes( runtimes, monitor );
581
    }
580
    }
(-)src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectAdapter.java (+2 lines)
Lines 23-28 Link Here
23
 * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
23
 * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
24
 */
24
 */
25
25
26
@SuppressWarnings( "rawtypes" )
27
26
public final class FacetedProjectAdapter
28
public final class FacetedProjectAdapter
27
29
28
    implements IAdapterFactory
30
    implements IAdapterFactory
(-)src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectFrameworkImpl.java (-24 / +31 lines)
Lines 218-224 Link Here
218
    
218
    
219
    public Set<IProjectFacet> getProjectFacets()
219
    public Set<IProjectFacet> getProjectFacets()
220
    {
220
    {
221
        return this.facets.getUnmodifiable();
221
        return this.facets.getItemSet();
222
    }
222
    }
223
    
223
    
224
    public boolean isProjectFacetDefined( final String id )
224
    public boolean isProjectFacetDefined( final String id )
Lines 228-234 Link Here
228
    
228
    
229
    public IProjectFacet getProjectFacet( final String id )
229
    public IProjectFacet getProjectFacet( final String id )
230
    {
230
    {
231
        final IProjectFacet f = this.facets.get( id );
231
        final IProjectFacet f = this.facets.getItemByKey( id );
232
        
232
        
233
        if( f == null )
233
        if( f == null )
234
        {
234
        {
Lines 241-247 Link Here
241
    
241
    
242
    public Set<IActionDefinition> getActionDefinitions()
242
    public Set<IActionDefinition> getActionDefinitions()
243
    {
243
    {
244
        return this.actions.getUnmodifiable();
244
        return this.actions.getItemSet();
245
    }
245
    }
246
    
246
    
247
    public boolean isActionDefined( final String id )
247
    public boolean isActionDefined( final String id )
Lines 251-257 Link Here
251
    
251
    
252
    public IActionDefinition getActionDefinition( final String id )
252
    public IActionDefinition getActionDefinition( final String id )
253
    {
253
    {
254
        final IActionDefinition adef = this.actions.get( id );
254
        final IActionDefinition adef = this.actions.getItemByKey( id );
255
        
255
        
256
        if( adef == null )
256
        if( adef == null )
257
        {
257
        {
Lines 264-270 Link Here
264
    
264
    
265
    public Set<ICategory> getCategories()
265
    public Set<ICategory> getCategories()
266
    {
266
    {
267
        return this.categories.getUnmodifiable();
267
        return this.categories.getItemSet();
268
    }
268
    }
269
269
270
    public boolean isCategoryDefined( final String id )
270
    public boolean isCategoryDefined( final String id )
Lines 274-280 Link Here
274
    
274
    
275
    public ICategory getCategory( final String id )
275
    public ICategory getCategory( final String id )
276
    {
276
    {
277
        final ICategory category = this.categories.get( id );
277
        final ICategory category = this.categories.getItemByKey( id );
278
        
278
        
279
        if( category == null )
279
        if( category == null )
280
        {
280
        {
Lines 290-296 Link Here
290
        synchronized( this.presets )
290
        synchronized( this.presets )
291
        {
291
        {
292
            initializePresets();
292
            initializePresets();
293
            return this.presets.getUnmodifiable();
293
            return this.presets.getItemSet();
294
        }
294
        }
295
    }
295
    }
296
    
296
    
Lines 309-315 Link Here
309
        {
309
        {
310
            initializePresets();
310
            initializePresets();
311
            
311
            
312
            final IPreset preset = this.presets.get( id );
312
            final IPreset preset = this.presets.getItemByKey( id );
313
            
313
            
314
            if( preset == null )
314
            if( preset == null )
315
            {
315
            {
Lines 364-370 Link Here
364
                = new UserPreset( id, name, description == null ? "" : description,  //$NON-NLS-1$
364
                = new UserPreset( id, name, description == null ? "" : description,  //$NON-NLS-1$
365
                                  facets );
365
                                  facets );
366
            
366
            
367
            this.presets.add( id, preset );
367
            this.presets.addItemWithKey( id, preset );
368
            
368
            
369
            if( save )
369
            if( save )
370
            {
370
            {
Lines 388-394 Link Here
388
                return false;
388
                return false;
389
            }
389
            }
390
            
390
            
391
            deleted = this.presets.delete( preset.getId() );
391
            deleted = this.presets.removeItemByKey( preset.getId() );
392
            
392
            
393
            if( deleted )
393
            if( deleted )
394
            {
394
            {
Lines 415-421 Link Here
415
            {
415
            {
416
                for( IPreset preset : PresetsExtensionPoint.getPresets() )
416
                for( IPreset preset : PresetsExtensionPoint.getPresets() )
417
                {
417
                {
418
                    this.presets.add( preset.getId(), preset );
418
                    this.presets.addItemWithKey( preset.getId(), preset );
419
                }
419
                }
420
                
420
                
421
                readUserPresets();
421
                readUserPresets();
Lines 438-444 Link Here
438
                root.node( children[ i ] ).removeNode();
438
                root.node( children[ i ] ).removeNode();
439
            }
439
            }
440
            
440
            
441
            for( IPreset preset : this.presets )
441
            for( IPreset preset : this.presets.getItemSet() )
442
            {
442
            {
443
                if( preset.getType() == IPreset.Type.USER_DEFINED )
443
                if( preset.getType() == IPreset.Type.USER_DEFINED )
444
                {
444
                {
Lines 576-582 Link Here
576
    
576
    
577
    public Set<IGroup> getGroups()
577
    public Set<IGroup> getGroups()
578
    {
578
    {
579
        return this.groups.getUnmodifiable();
579
        return this.groups.getItemSet();
580
    }
580
    }
581
    
581
    
582
    public boolean isGroupDefined( final String id )
582
    public boolean isGroupDefined( final String id )
Lines 586-592 Link Here
586
    
586
    
587
    public IGroup getGroup( final String id )
587
    public IGroup getGroup( final String id )
588
    {
588
    {
589
        final IGroup group = this.groups.get( id );
589
        final IGroup group = this.groups.getItemByKey( id );
590
        
590
        
591
        if( group == null )
591
        if( group == null )
592
        {
592
        {
Lines 1449-1455 Link Here
1449
        final IConfigurationElement elDesc = findOptionalElement( config, EL_DESCRIPTION );
1449
        final IConfigurationElement elDesc = findOptionalElement( config, EL_DESCRIPTION );
1450
        category.setDescription( getElementValue( elDesc, DEFAULT_DESCRIPTION ) );
1450
        category.setDescription( getElementValue( elDesc, DEFAULT_DESCRIPTION ) );
1451
        
1451
        
1452
        this.categories.add( category.getId(), category );
1452
        this.categories.addItemWithKey( category.getId(), category );
1453
    }
1453
    }
1454
    
1454
    
1455
    private void readProjectFacet( final IConfigurationElement config )
1455
    private void readProjectFacet( final IConfigurationElement config )
Lines 1548-1554 Link Here
1548
            }
1548
            }
1549
        }
1549
        }
1550
        
1550
        
1551
        this.facets.add( f.getId(), f );
1551
        this.facets.addItem( f );
1552
        this.facets.addKey( f.getId(), f );
1553
        
1554
        for( String alias : ProjectFacetAliasesExtensionPoint.getAliases( f ) )
1555
        {
1556
            this.facets.addKey( alias, f );
1557
            f.addAlias( alias );
1558
        }
1552
    }
1559
    }
1553
    
1560
    
1554
    private void readProjectFacetVersion( final IConfigurationElement config,
1561
    private void readProjectFacetVersion( final IConfigurationElement config,
Lines 1571-1577 Link Here
1571
            return;
1578
            return;
1572
        }
1579
        }
1573
        
1580
        
1574
        final ProjectFacet f = (ProjectFacet) this.facets.get( fid );
1581
        final ProjectFacet f = (ProjectFacet) this.facets.getItemByKey( fid );
1575
        
1582
        
1576
        if( f == null )
1583
        if( f == null )
1577
        {
1584
        {
Lines 1610-1623 Link Here
1610
                    return;
1617
                    return;
1611
                }
1618
                }
1612
                
1619
                
1613
                Group group = (Group) this.groups.get( id );
1620
                Group group = (Group) this.groups.getItemByKey( id );
1614
                
1621
                
1615
                if( group == null )
1622
                if( group == null )
1616
                {
1623
                {
1617
                    group = new Group();
1624
                    group = new Group();
1618
                    group.setId( id );
1625
                    group.setId( id );
1619
                    
1626
                    
1620
                    this.groups.add( id, group );
1627
                    this.groups.addItemWithKey( id, group );
1621
                }
1628
                }
1622
                
1629
                
1623
                group.addMember( fv );
1630
                group.addMember( fv );
Lines 1676-1682 Link Here
1676
    {
1683
    {
1677
        final List<IProjectFacet> badFacets = new ArrayList<IProjectFacet>();
1684
        final List<IProjectFacet> badFacets = new ArrayList<IProjectFacet>();
1678
        
1685
        
1679
        for( IProjectFacet f : this.facets )
1686
        for( IProjectFacet f : this.facets.getItemSet() )
1680
        {
1687
        {
1681
            try
1688
            try
1682
            {
1689
            {
Lines 1734-1740 Link Here
1734
        
1741
        
1735
        for( IProjectFacet f : badFacets )
1742
        for( IProjectFacet f : badFacets )
1736
        {
1743
        {
1737
            this.facets.remove( f );
1744
            this.facets.removeItem( f );
1738
            
1745
            
1739
            final Category category = (Category) f.getCategory();
1746
            final Category category = (Category) f.getCategory();
1740
            
1747
            
Lines 1835-1841 Link Here
1835
            return;
1842
            return;
1836
        }
1843
        }
1837
        
1844
        
1838
        final ProjectFacet f = (ProjectFacet) this.facets.get( fid );
1845
        final ProjectFacet f = (ProjectFacet) this.facets.getItemByKey( fid );
1839
        
1846
        
1840
        if( f == null )
1847
        if( f == null )
1841
        {
1848
        {
Lines 2011-2017 Link Here
2011
        }
2018
        }
2012
        else
2019
        else
2013
        {
2020
        {
2014
            this.actions.add( def.getId(), def );
2021
            this.actions.addItemWithKey( def.getId(), def );
2015
            f.addActionDefinition( def );
2022
            f.addActionDefinition( def );
2016
        }
2023
        }
2017
    }
2024
    }
Lines 2026-2032 Link Here
2026
            return;
2033
            return;
2027
        }
2034
        }
2028
        
2035
        
2029
        final ProjectFacet f = (ProjectFacet) this.facets.get( fid );
2036
        final ProjectFacet f = (ProjectFacet) this.facets.getItemByKey( fid );
2030
        
2037
        
2031
        if( f == null )
2038
        if( f == null )
2032
        {
2039
        {
(-)src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectTemplatesExtensionPoint.java (-3 / +3 lines)
Lines 50-62 Link Here
50
    public static Set<IFacetedProjectTemplate> getTemplates()
50
    public static Set<IFacetedProjectTemplate> getTemplates()
51
    {
51
    {
52
        readExtensions();
52
        readExtensions();
53
        return templates.getUnmodifiable();
53
        return templates.getItemSet();
54
    }
54
    }
55
    
55
    
56
    public static IFacetedProjectTemplate getTemplate( final String id )
56
    public static IFacetedProjectTemplate getTemplate( final String id )
57
    {
57
    {
58
        readExtensions();
58
        readExtensions();
59
        return templates.get( id );
59
        return templates.getItemByKey( id );
60
    }
60
    }
61
    
61
    
62
    private static synchronized void readExtensions()
62
    private static synchronized void readExtensions()
Lines 135-141 Link Here
135
            }
135
            }
136
        }
136
        }
137
        
137
        
138
        templates.add( template.getId(), template );
138
        templates.addItemWithKey( template.getId(), template );
139
    }
139
    }
140
    
140
    
141
    private static final class Resources
141
    private static final class Resources
(-)src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectValidationBuilder.java (+2 lines)
Lines 63-68 Link Here
63
        readExtensions();
63
        readExtensions();
64
    }
64
    }
65
    
65
    
66
    @SuppressWarnings( "rawtypes" )
67
    
66
    protected IProject[] build( final int kind, 
68
    protected IProject[] build( final int kind, 
67
                                final Map args, 
69
                                final Map args, 
68
                                final IProgressMonitor monitor ) 
70
                                final IProgressMonitor monitor ) 
(-)src/org/eclipse/wst/common/project/facet/core/internal/FacetedProjectWorkingCopy.java (-20 / +20 lines)
Lines 668-674 Link Here
668
    {
668
    {
669
        synchronized( this.lock )
669
        synchronized( this.lock )
670
        {
670
        {
671
            return this.facets.getUnmodifiable();
671
            return this.facets.getItemSet();
672
        }
672
        }
673
    }
673
    }
674
    
674
    
Lines 676-682 Link Here
676
    {
676
    {
677
        synchronized( this.lock )
677
        synchronized( this.lock )
678
        {
678
        {
679
            return this.facets.get( f );
679
            return this.facets.getItemByKey( f );
680
        }
680
        }
681
    }
681
    }
682
    
682
    
Lines 692-698 Link Here
692
    {
692
    {
693
        synchronized( this.lock )
693
        synchronized( this.lock )
694
        {
694
        {
695
            return this.facets.contains( fv );
695
            return this.facets.containsItem( fv );
696
        }
696
        }
697
    }
697
    }
698
    
698
    
Lines 709-725 Link Here
709
                
709
                
710
                for( IProjectFacetVersion fv : facets )
710
                for( IProjectFacetVersion fv : facets )
711
                {
711
                {
712
                    newProjectFacets.add( fv.getProjectFacet(), fv );
712
                    newProjectFacets.addItemWithKey( fv.getProjectFacet(), fv );
713
                }
713
                }
714
                
714
                
715
                final Set<IProjectFacetVersion> addedFacets = new HashSet<IProjectFacetVersion>();
715
                final Set<IProjectFacetVersion> addedFacets = new HashSet<IProjectFacetVersion>();
716
                final Set<IProjectFacetVersion> removedFacets = new HashSet<IProjectFacetVersion>();
716
                final Set<IProjectFacetVersion> removedFacets = new HashSet<IProjectFacetVersion>();
717
                final Set<IProjectFacetVersion> changedVersions = new HashSet<IProjectFacetVersion>();
717
                final Set<IProjectFacetVersion> changedVersions = new HashSet<IProjectFacetVersion>();
718
                
718
                
719
                for( IProjectFacetVersion fv : newProjectFacets )
719
                for( IProjectFacetVersion fv : newProjectFacets.getItemSet() )
720
                {
720
                {
721
                    final IProjectFacetVersion currentFacetVersion 
721
                    final IProjectFacetVersion currentFacetVersion 
722
                        = this.facets.get( fv.getProjectFacet() );
722
                        = this.facets.getItemByKey( fv.getProjectFacet() );
723
                    
723
                    
724
                    if( currentFacetVersion == null )
724
                    if( currentFacetVersion == null )
725
                    {
725
                    {
Lines 734-740 Link Here
734
                    }
734
                    }
735
                }
735
                }
736
                
736
                
737
                for( IProjectFacetVersion fv : this.facets )
737
                for( IProjectFacetVersion fv : this.facets.getItemSet() )
738
                {
738
                {
739
                    if( ! newProjectFacets.containsKey( fv.getProjectFacet() ) )
739
                    if( ! newProjectFacets.containsKey( fv.getProjectFacet() ) )
740
                    {
740
                    {
Lines 780-793 Link Here
780
            synchronized( this.lock )
780
            synchronized( this.lock )
781
            {
781
            {
782
                final IProjectFacetVersion existingVersion 
782
                final IProjectFacetVersion existingVersion 
783
                    = this.facets.get( fv.getProjectFacet() );
783
                    = this.facets.getItemByKey( fv.getProjectFacet() );
784
                
784
                
785
                if( existingVersion == null )
785
                if( existingVersion == null )
786
                {
786
                {
787
                    final Set<IProjectFacetVersion> newProjectFacets 
787
                    final Set<IProjectFacetVersion> newProjectFacets 
788
                        = new HashSet<IProjectFacetVersion>();
788
                        = new HashSet<IProjectFacetVersion>();
789
        
789
        
790
                    newProjectFacets.addAll( this.facets );
790
                    newProjectFacets.addAll( this.facets.getItemSet() );
791
                    newProjectFacets.add( fv );
791
                    newProjectFacets.add( fv );
792
                    
792
                    
793
                    setProjectFacets( newProjectFacets );
793
                    setProjectFacets( newProjectFacets );
Lines 840-846 Link Here
840
            synchronized( this.lock )
840
            synchronized( this.lock )
841
            {
841
            {
842
                final IProjectFacetVersion existingVersion 
842
                final IProjectFacetVersion existingVersion 
843
                    = this.facets.get( fv.getProjectFacet() );
843
                    = this.facets.getItemByKey( fv.getProjectFacet() );
844
                
844
                
845
                if( existingVersion == null )
845
                if( existingVersion == null )
846
                {
846
                {
Lines 851-857 Link Here
851
                    final Set<IProjectFacetVersion> newProjectFacets 
851
                    final Set<IProjectFacetVersion> newProjectFacets 
852
                        = new HashSet<IProjectFacetVersion>();
852
                        = new HashSet<IProjectFacetVersion>();
853
        
853
        
854
                    newProjectFacets.addAll( this.facets );
854
                    newProjectFacets.addAll( this.facets.getItemSet() );
855
                    newProjectFacets.remove( fv );
855
                    newProjectFacets.remove( fv );
856
                    
856
                    
857
                    setProjectFacets( newProjectFacets );
857
                    setProjectFacets( newProjectFacets );
Lines 878-884 Link Here
878
            synchronized( this.lock )
878
            synchronized( this.lock )
879
            {
879
            {
880
                final IProjectFacetVersion existingVersion 
880
                final IProjectFacetVersion existingVersion 
881
                    = this.facets.get( fv.getProjectFacet() );
881
                    = this.facets.getItemByKey( fv.getProjectFacet() );
882
                
882
                
883
                if( existingVersion == null )
883
                if( existingVersion == null )
884
                {
884
                {
Lines 894-900 Link Here
894
                    final Set<IProjectFacetVersion> newProjectFacets 
894
                    final Set<IProjectFacetVersion> newProjectFacets 
895
                        = new HashSet<IProjectFacetVersion>();
895
                        = new HashSet<IProjectFacetVersion>();
896
        
896
        
897
                    newProjectFacets.addAll( this.facets );
897
                    newProjectFacets.addAll( this.facets.getItemSet() );
898
                    newProjectFacets.remove( existingVersion );
898
                    newProjectFacets.remove( existingVersion );
899
                    newProjectFacets.add( fv );
899
                    newProjectFacets.add( fv );
900
                    
900
                    
Lines 924-930 Link Here
924
    {
924
    {
925
        synchronized( this.lock )
925
        synchronized( this.lock )
926
        {
926
        {
927
            return this.availablePresets.getUnmodifiable();
927
            return this.availablePresets.getItemSet();
928
        }
928
        }
929
    }
929
    }
930
    
930
    
Lines 1002-1008 Link Here
1002
                    
1002
                    
1003
                    if( applicable )
1003
                    if( applicable )
1004
                    {
1004
                    {
1005
                        newAvailablePresets.add( preset.getId(), preset );
1005
                        newAvailablePresets.addItemWithKey( preset.getId(), preset );
1006
                    }
1006
                    }
1007
                }
1007
                }
1008
                
1008
                
Lines 1031-1037 Link Here
1031
        {
1031
        {
1032
            if( this.selectedPresetId != null )
1032
            if( this.selectedPresetId != null )
1033
            {
1033
            {
1034
                return this.availablePresets.get( this.selectedPresetId );
1034
                return this.availablePresets.getItemByKey( this.selectedPresetId );
1035
            }
1035
            }
1036
            else
1036
            else
1037
            {
1037
            {
Lines 1054-1060 Link Here
1054
                    throw new IllegalArgumentException( msg );
1054
                    throw new IllegalArgumentException( msg );
1055
                }
1055
                }
1056
                
1056
                
1057
                final IPreset preset = this.availablePresets.get( presetId );
1057
                final IPreset preset = this.availablePresets.getItemByKey( presetId );
1058
                
1058
                
1059
                if( ! equals( this.selectedPresetId, presetId ) || 
1059
                if( ! equals( this.selectedPresetId, presetId ) || 
1060
                    ( preset != null && ! equals( preset.getProjectFacets(), getProjectFacets() ) ) )
1060
                    ( preset != null && ! equals( preset.getProjectFacets(), getProjectFacets() ) ) )
Lines 1088-1094 Link Here
1088
    {
1088
    {
1089
        synchronized( this.lock )
1089
        synchronized( this.lock )
1090
        {
1090
        {
1091
            return this.availablePresets.get( DefaultConfigurationPresetFactory.PRESET_ID );
1091
            return this.availablePresets.getItemByKey( DefaultConfigurationPresetFactory.PRESET_ID );
1092
        }
1092
        }
1093
    }
1093
    }
1094
1094
Lines 1096-1102 Link Here
1096
    {
1096
    {
1097
        synchronized( this.lock )
1097
        synchronized( this.lock )
1098
        {
1098
        {
1099
            return this.availablePresets.get( MinimalConfigurationPresetFactory.PRESET_ID );
1099
            return this.availablePresets.getItemByKey( MinimalConfigurationPresetFactory.PRESET_ID );
1100
        }
1100
        }
1101
    }
1101
    }
1102
1102
Lines 1139-1145 Link Here
1139
                    {
1139
                    {
1140
                        ok = true;
1140
                        ok = true;
1141
                        
1141
                        
1142
                        for( IProjectFacetVersion fv : this.facets )
1142
                        for( IProjectFacetVersion fv : this.facets.getItemSet() )
1143
                        {
1143
                        {
1144
                            if( ! r.supports( fv ) )
1144
                            if( ! r.supports( fv ) )
1145
                            {
1145
                            {
(-)src/org/eclipse/wst/common/project/facet/core/internal/PresetsExtensionPoint.java (-9 / +10 lines)
Lines 70-82 Link Here
70
    public static Set<IPreset> getPresets()
70
    public static Set<IPreset> getPresets()
71
    {
71
    {
72
        readExtensions();
72
        readExtensions();
73
        return presets.getUnmodifiable();
73
        return presets.getItemSet();
74
    }
74
    }
75
    
75
    
76
    public static IPreset getPreset( final String id )
76
    public static IPreset getPreset( final String id )
77
    {
77
    {
78
        readExtensions();
78
        readExtensions();
79
        return presets.get( id );
79
        return presets.getItemByKey( id );
80
    }
80
    }
81
    
81
    
82
    private static synchronized void readExtensions()
82
    private static synchronized void readExtensions()
Lines 136-146 Link Here
136
        // Resolve the base presets. Make sure that no presets are extending presets that do not
136
        // Resolve the base presets. Make sure that no presets are extending presets that do not
137
        // exist, check for circular references, etc.
137
        // exist, check for circular references, etc.
138
        
138
        
139
        Set<IPreset> copy = new HashSet<IPreset>( presets ); 
139
        Set<IPreset> copy = new HashSet<IPreset>( presets.getItemSet() ); 
140
        
140
        
141
        for( IPreset preset : copy )
141
        for( IPreset preset : copy )
142
        {
142
        {
143
            if( presets.contains( preset ) )
143
            if( presets.containsItem( preset ) )
144
            {
144
            {
145
                resolveBasePreset( preset, new HashSet<IPreset>() );
145
                resolveBasePreset( preset, new HashSet<IPreset>() );
146
            }
146
            }
Lines 155-161 Link Here
155
        {
155
        {
156
            doAnotherPass = false;
156
            doAnotherPass = false;
157
            
157
            
158
            for( IPreset preset : presets )
158
            for( IPreset preset : presets.getItemSet() )
159
            {
159
            {
160
                if( preset.getType() == IPreset.Type.STATIC )
160
                if( preset.getType() == IPreset.Type.STATIC )
161
                {
161
                {
Lines 176-182 Link Here
176
                                                                    stPreset.getBasePresetId(),
176
                                                                    stPreset.getBasePresetId(),
177
                                                                    stPreset.getProjectFacets() );
177
                                                                    stPreset.getProjectFacets() );
178
                            
178
                            
179
                            presets.add( stPresetNew.getId(), stPresetNew );
179
                            presets.removeItem( stPreset );
180
                            presets.addItemWithKey( stPresetNew.getId(), stPresetNew );
180
181
181
                            doAnotherPass = true;
182
                            doAnotherPass = true;
182
                            break;
183
                            break;
Lines 256-262 Link Here
256
        final StaticPreset preset 
257
        final StaticPreset preset 
257
            = new StaticPreset( id, pluginId, label, description, basePreset, facets );
258
            = new StaticPreset( id, pluginId, label, description, basePreset, facets );
258
        
259
        
259
        presets.add( id, preset );
260
        presets.addItemWithKey( id, preset );
260
    }
261
    }
261
262
262
    private static void readDynamicPreset( final IConfigurationElement el )
263
    private static void readDynamicPreset( final IConfigurationElement el )
Lines 270-276 Link Here
270
        final String factoryClassName = findRequiredAttribute( elFactory, ATTR_CLASS );
271
        final String factoryClassName = findRequiredAttribute( elFactory, ATTR_CLASS );
271
        
272
        
272
        final DynamicPreset preset = new DynamicPreset( id, pluginId, factoryClassName );
273
        final DynamicPreset preset = new DynamicPreset( id, pluginId, factoryClassName );
273
        presets.add( id, preset );
274
        presets.addItemWithKey( id, preset );
274
    }
275
    }
275
    
276
    
276
    private static boolean resolveBasePreset( final IPreset preset,
277
    private static boolean resolveBasePreset( final IPreset preset,
Lines 338-344 Link Here
338
339
339
                if( problem )
340
                if( problem )
340
                {
341
                {
341
                    PresetsExtensionPoint.presets.delete( preset.getId() );
342
                    PresetsExtensionPoint.presets.removeItemByKey( preset.getId() );
342
                    return false;
343
                    return false;
343
                }
344
                }
344
            }
345
            }
(-)src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacet.java (-3 / +25 lines)
Lines 44-49 Link Here
44
    
44
    
45
{
45
{
46
    private String id;
46
    private String id;
47
    private final Set<String> aliases;
48
    private final Set<String> aliasesReadOnly;
47
    private String plugin;
49
    private String plugin;
48
    private String label;
50
    private String label;
49
    private String description;
51
    private String description;
Lines 56-61 Link Here
56
    
58
    
57
    ProjectFacet() 
59
    ProjectFacet() 
58
    {
60
    {
61
        this.aliases = new HashSet<String>();
62
        this.aliasesReadOnly = Collections.unmodifiableSet( this.aliases );
59
        this.actionDefinitions = new ArrayList<IActionDefinition>();
63
        this.actionDefinitions = new ArrayList<IActionDefinition>();
60
        this.properties = new HashMap<String,Object>();
64
        this.properties = new HashMap<String,Object>();
61
        this.propertiesReadOnly = Collections.unmodifiableMap( this.properties );
65
        this.propertiesReadOnly = Collections.unmodifiableMap( this.properties );
Lines 71-76 Link Here
71
        this.id = id;
75
        this.id = id;
72
    }
76
    }
73
    
77
    
78
    public Set<String> getAliases()
79
    {
80
        return this.aliasesReadOnly;
81
    }
82
    
83
    void addAlias( final String alias )
84
    {
85
        this.aliases.add( alias );
86
    }
87
    
74
    public String getPluginId()
88
    public String getPluginId()
75
    {
89
    {
76
        return this.plugin;
90
        return this.plugin;
Lines 111-119 Link Here
111
        this.category = category;
125
        this.category = category;
112
    }
126
    }
113
    
127
    
114
    void addVersion( final IProjectFacetVersion ver )
128
    void addVersion( final IProjectFacetVersion fv )
115
    {
129
    {
116
        this.versions.add( ver.getVersionString(), ver );
130
        this.versions.addItem( fv );
131
        this.versions.addKey( fv.getVersionString(), fv );
132
        
133
        for( String alias : ProjectFacetAliasesExtensionPoint.getAliases( fv ) )
134
        {
135
            this.versions.addKey( alias, fv );
136
        }
117
    }
137
    }
118
    
138
    
119
    public IProjectFacetVersion getLatestSupportedVersion( final IRuntime r )
139
    public IProjectFacetVersion getLatestSupportedVersion( final IRuntime r )
Lines 183-188 Link Here
183
        this.defaultVersionProvider = provider;
203
        this.defaultVersionProvider = provider;
184
    }
204
    }
185
    
205
    
206
    @SuppressWarnings( "rawtypes" )
207
    
186
    public Object getAdapter( final Class type )
208
    public Object getAdapter( final Class type )
187
    {
209
    {
188
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
210
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
Lines 212-218 Link Here
212
    
234
    
213
    public boolean isVersionHidden()
235
    public boolean isVersionHidden()
214
    {
236
    {
215
        return ( this.versions.size() == 1 &&
237
        return ( this.versions.getItemSet().size() == 1 &&
216
                 equal( getProperty( PROP_HIDE_VERSION ), true ) );
238
                 equal( getProperty( PROP_HIDE_VERSION ), true ) );
217
    }
239
    }
218
    
240
    
(-)src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetAliasesExtensionPoint.java (+154 lines)
Added Link Here
1
/******************************************************************************
2
 * Copyright (c) 2010 Oracle
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Konstantin Komissarchik - initial implementation and ongoing maintenance
10
 ******************************************************************************/
11
12
package org.eclipse.wst.common.project.facet.core.internal;
13
14
import static org.eclipse.wst.common.project.facet.core.internal.FacetCorePlugin.PLUGIN_ID;
15
import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findExtensions;
16
import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.findRequiredAttribute;
17
import static org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.getTopLevelElements;
18
19
import java.util.Collections;
20
import java.util.HashMap;
21
import java.util.HashSet;
22
import java.util.Map;
23
import java.util.Set;
24
25
import org.eclipse.core.runtime.IConfigurationElement;
26
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
27
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
28
import org.eclipse.wst.common.project.facet.core.util.internal.PluginUtil.InvalidExtensionException;
29
30
/**
31
 * Contains the logic for processing the <code>aliases</code> extension point. 
32
 * 
33
 * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
34
 */
35
36
public final class ProjectFacetAliasesExtensionPoint
37
{
38
    public static final String EXTENSION_POINT_ID = "aliases"; //$NON-NLS-1$
39
    
40
    private static final String EL_FACET_ALIAS = "facet-alias"; //$NON-NLS-1$
41
    private static final String EL_FACET_VERSION_ALIAS = "facet-version-alias"; //$NON-NLS-1$
42
    private static final String ATTR_ALIAS = "alias"; //$NON-NLS-1$
43
    private static final String ATTR_FACET = "facet"; //$NON-NLS-1$
44
    private static final String ATTR_VERSION = "version"; //$NON-NLS-1$
45
    
46
    /*
47
     * Note that the facetAliases and facetVersionAliases data structures hold strings rather
48
     * than more specific IProjectFacet and IProjectFacetVersion objects. This is done this
49
     * way as this class is called during initialization of FacetedProjectFramework and we need
50
     * to avoid circular calls (this class cannot call back to FacetedProjectFramework).
51
     */
52
    
53
    private static Map<String,Set<String>> facetAliases = null;
54
    private static Map<String,Map<String,Set<String>>> facetVersionAliases = null;
55
    
56
    public static Set<String> getAliases( final IProjectFacet f )
57
    {
58
        readExtensions();
59
        
60
        final Set<String> aliases = facetAliases.get( f.getId() );
61
        
62
        if( aliases != null )
63
        {
64
            return aliases; 
65
        }
66
        
67
        return Collections.emptySet();
68
    }
69
    
70
    public static Set<String> getAliases( final IProjectFacetVersion fv )
71
    {
72
        readExtensions();
73
        
74
        final Map<String,Set<String>> versionToAliasesMap = facetVersionAliases.get( fv.getProjectFacet().getId() );
75
        
76
        if( versionToAliasesMap != null )
77
        {
78
            final Set<String> aliases = versionToAliasesMap.get( fv.getVersionString() );
79
            
80
            if( aliases != null )
81
            {
82
                return aliases;
83
            }
84
        }
85
        
86
        return Collections.emptySet();
87
    }
88
    
89
    private static synchronized void readExtensions()
90
    {
91
        if( facetAliases != null )
92
        {
93
            return;
94
        }
95
        
96
        facetAliases = new HashMap<String,Set<String>>();
97
        facetVersionAliases = new HashMap<String,Map<String,Set<String>>>();
98
        
99
        for( IConfigurationElement element 
100
             : getTopLevelElements( findExtensions( PLUGIN_ID, EXTENSION_POINT_ID ) ) )
101
        {
102
            final String elname = element.getName();
103
            
104
            try
105
            {
106
                if( elname.equals( EL_FACET_ALIAS ) || elname.equals( EL_FACET_VERSION_ALIAS ) )
107
                {
108
                    final String fid = findRequiredAttribute( element, ATTR_FACET );
109
                    final String alias = findRequiredAttribute( element, ATTR_ALIAS );
110
111
                    if( elname.equals( EL_FACET_ALIAS ) )
112
                    {
113
                        Set<String> aliases = facetAliases.get( fid );
114
                        
115
                        if( aliases == null )
116
                        {
117
                            aliases = new HashSet<String>();
118
                            facetAliases.put( fid, aliases );
119
                        }
120
                        
121
                        aliases.add( alias );
122
                    }
123
                    else
124
                    {
125
                        final String fvstr = findRequiredAttribute( element, ATTR_VERSION );
126
                        
127
                        Map<String,Set<String>> versionToAliasesMap = facetVersionAliases.get( fid );
128
                        
129
                        if( versionToAliasesMap == null )
130
                        {
131
                            versionToAliasesMap = new HashMap<String,Set<String>>();
132
                            facetVersionAliases.put( fid, versionToAliasesMap );
133
                        }
134
                        
135
                        Set<String> aliases = versionToAliasesMap.get( fvstr );
136
                        
137
                        if( aliases == null )
138
                        {
139
                            aliases = new HashSet<String>();
140
                            versionToAliasesMap.put( fvstr, aliases );
141
                        }
142
                        
143
                        aliases.add( alias );
144
                    }
145
                }
146
            }
147
            catch( InvalidExtensionException e )
148
            {
149
                // Continue. The problem has been reported to the user via the log.
150
            }
151
        }
152
    }
153
    
154
}
(-)src/org/eclipse/wst/common/project/facet/core/internal/ProjectFacetVersion.java (-3 / +2 lines)
Lines 241-253 Link Here
241
     * @deprecated
241
     * @deprecated
242
     */
242
     */
243
    
243
    
244
    @SuppressWarnings( "unchecked" )
245
    public IActionDefinition getActionDefinition( final Action.Type type )
244
    public IActionDefinition getActionDefinition( final Action.Type type )
246
    
245
    
247
        throws CoreException
246
        throws CoreException
248
        
247
        
249
    {
248
    {
250
        final Set definitions = getActionDefinitions( type );
249
        final Set<IActionDefinition> definitions = getActionDefinitions( type );
251
        
250
        
252
        if( definitions.size() == 0 )
251
        if( definitions.size() == 0 )
253
        {
252
        {
Lines 255-261 Link Here
255
        }
254
        }
256
        else
255
        else
257
        {
256
        {
258
            return (IActionDefinition) definitions.iterator().next();
257
            return definitions.iterator().next();
259
        }
258
        }
260
    }
259
    }
261
    
260
    
(-)src/org/eclipse/wst/common/project/facet/core/runtime/internal/AbstractRuntime.java (+2 lines)
Lines 150-155 Link Here
150
        return getProperties().get( key );
150
        return getProperties().get( key );
151
    }
151
    }
152
    
152
    
153
    @SuppressWarnings( "rawtypes" )
154
    
153
    public final Object getAdapter( final Class adapter )
155
    public final Object getAdapter( final Class adapter )
154
    {
156
    {
155
        final String t = adapter.getName();
157
        final String t = adapter.getName();
(-)src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponent.java (+2 lines)
Lines 103-108 Link Here
103
        this.properties.put( key, value );
103
        this.properties.put( key, value );
104
    }
104
    }
105
105
106
    @SuppressWarnings( "rawtypes" )
107
    
106
    public Object getAdapter( final Class type )
108
    public Object getAdapter( final Class type )
107
    {
109
    {
108
        final IAdapterManager manager = Platform.getAdapterManager();
110
        final IAdapterManager manager = Platform.getAdapterManager();
(-)src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentType.java (-2 / +3 lines)
Lines 52-61 Link Here
52
    
52
    
53
    void addVersion( final IRuntimeComponentVersion ver )
53
    void addVersion( final IRuntimeComponentVersion ver )
54
    {
54
    {
55
        this.versions.add( ver.getVersionString(), ver );
55
        this.versions.addItemWithKey( ver.getVersionString(), ver );
56
    }
56
    }
57
    
57
    
58
    @SuppressWarnings( "unchecked" )
58
    @SuppressWarnings( "rawtypes" )
59
    
59
    public Object getAdapter( final Class type )
60
    public Object getAdapter( final Class type )
60
    {
61
    {
61
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
62
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
(-)src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeComponentVersion.java (-2 / +3 lines)
Lines 140-146 Link Here
140
            
140
            
141
            return this.compTable.get( rcv ).intValue();
141
            return this.compTable.get( rcv ).intValue();
142
        }
142
        }
143
        else if( obj instanceof UnknownVersion )
143
        else if( obj instanceof UnknownVersion<?> )
144
        {
144
        {
145
            try
145
            try
146
            {
146
            {
Lines 159-165 Link Here
159
        
159
        
160
    }
160
    }
161
    
161
    
162
    @SuppressWarnings( "unchecked" )
162
    @SuppressWarnings( "rawtypes" )
163
    
163
    public Object getAdapter( final Class type )
164
    public Object getAdapter( final Class type )
164
    {
165
    {
165
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
166
        return Platform.getAdapterManager().loadAdapter( this, type.getName() );
(-)src/org/eclipse/wst/common/project/facet/core/runtime/internal/RuntimeManagerImpl.java (-15 / +15 lines)
Lines 103-109 Link Here
103
    
103
    
104
    public static Set<IRuntimeComponentType> getRuntimeComponentTypes()
104
    public static Set<IRuntimeComponentType> getRuntimeComponentTypes()
105
    {
105
    {
106
        return runtimeComponentTypes.getUnmodifiable();
106
        return runtimeComponentTypes.getItemSet();
107
    }
107
    }
108
    
108
    
109
    public static boolean isRuntimeComponentTypeDefined( final String id )
109
    public static boolean isRuntimeComponentTypeDefined( final String id )
Lines 113-119 Link Here
113
    
113
    
114
    public static IRuntimeComponentType getRuntimeComponentType( final String id )
114
    public static IRuntimeComponentType getRuntimeComponentType( final String id )
115
    {
115
    {
116
        final IRuntimeComponentType rc = runtimeComponentTypes.get( id );
116
        final IRuntimeComponentType rc = runtimeComponentTypes.getItemByKey( id );
117
        
117
        
118
        if( rc == null )
118
        if( rc == null )
119
        {
119
        {
Lines 149-155 Link Here
149
        synchronized( runtimes )
149
        synchronized( runtimes )
150
        {
150
        {
151
            bridge();
151
            bridge();
152
            return new HashSet<IRuntime>( runtimes );
152
            return new HashSet<IRuntime>( runtimes.getItemSet() );
153
        }
153
        }
154
    }
154
    }
155
    
155
    
Lines 161-167 Link Here
161
            
161
            
162
            final Set<IRuntime> result = new HashSet<IRuntime>();
162
            final Set<IRuntime> result = new HashSet<IRuntime>();
163
            
163
            
164
            for( IRuntime r : runtimes )
164
            for( IRuntime r : runtimes.getItemSet() )
165
            {
165
            {
166
                boolean supports = true;
166
                boolean supports = true;
167
                
167
                
Lines 199-205 Link Here
199
        {
199
        {
200
            bridge();
200
            bridge();
201
            
201
            
202
            final IRuntime runtime = runtimes.get( name );
202
            final IRuntime runtime = runtimes.getItemByKey( name );
203
            
203
            
204
            if( runtime == null )
204
            if( runtime == null )
205
            {
205
            {
Lines 234-240 Link Here
234
                }
234
                }
235
            }
235
            }
236
            
236
            
237
            runtimes.add( r.getName(), r );
237
            runtimes.addItemWithKey( r.getName(), r );
238
            
238
            
239
            notifyRuntimeListeners();
239
            notifyRuntimeListeners();
240
            
240
            
Lines 246-252 Link Here
246
    {
246
    {
247
        synchronized( runtimes )
247
        synchronized( runtimes )
248
        {
248
        {
249
            if( runtimes.delete( runtime.getName() ) )
249
            if( runtimes.removeItemByKey( runtime.getName() ) )
250
            {
250
            {
251
                notifyRuntimeListeners();
251
                notifyRuntimeListeners();
252
            }
252
            }
Lines 353-359 Link Here
353
            
353
            
354
            final Map<String,BridgedRuntime> existing = new HashMap<String,BridgedRuntime>();
354
            final Map<String,BridgedRuntime> existing = new HashMap<String,BridgedRuntime>();
355
            
355
            
356
            for( IRuntime r : runtimes )
356
            for( IRuntime r : runtimes.getItemSet() )
357
            {
357
            {
358
                if( r instanceof BridgedRuntime )
358
                if( r instanceof BridgedRuntime )
359
                {
359
                {
Lines 380-386 Link Here
380
                
380
                
381
                for( BridgedRuntime r : existing.values() )
381
                for( BridgedRuntime r : existing.values() )
382
                {
382
                {
383
                    runtimes.remove( r.getName() );
383
                    runtimes.removeItemByKey( r.getName() );
384
                    modified = true;
384
                    modified = true;
385
                }
385
                }
386
                
386
                
Lines 393-399 Link Here
393
            {
393
            {
394
                if( ! exported.contains( r.getNativeRuntimeId() ) )
394
                if( ! exported.contains( r.getNativeRuntimeId() ) )
395
                {
395
                {
396
                    runtimes.delete( r.getName() );
396
                    runtimes.removeItemByKey( r.getName() );
397
                    modified = true;
397
                    modified = true;
398
                }
398
                }
399
            }
399
            }
Lines 413-419 Link Here
413
                        
413
                        
414
                        r.setName( createUniqueRuntimeName( id ) );
414
                        r.setName( createUniqueRuntimeName( id ) );
415
                        
415
                        
416
                        runtimes.add( r.getName(), r );
416
                        runtimes.addItemWithKey( r.getName(), r );
417
                        modified = true;
417
                        modified = true;
418
                    }
418
                    }
419
                    catch( CoreException e )
419
                    catch( CoreException e )
Lines 535-541 Link Here
535
            }
535
            }
536
        }
536
        }
537
        
537
        
538
        runtimeComponentTypes.add( id, rct );
538
        runtimeComponentTypes.addItemWithKey( id, rct );
539
    }
539
    }
540
    
540
    
541
    private static void readRuntimeComponentVersion( final IConfigurationElement config )
541
    private static void readRuntimeComponentVersion( final IConfigurationElement config )
Lines 557-563 Link Here
557
        }
557
        }
558
        
558
        
559
        final RuntimeComponentType rct 
559
        final RuntimeComponentType rct 
560
            = (RuntimeComponentType) runtimeComponentTypes.get( type );
560
            = (RuntimeComponentType) runtimeComponentTypes.getItemByKey( type );
561
        
561
        
562
        if( rct == null )
562
        if( rct == null )
563
        {
563
        {
Lines 592-598 Link Here
592
        final List<IRuntimeComponentType> badRuntimeComponentTypes 
592
        final List<IRuntimeComponentType> badRuntimeComponentTypes 
593
            = new ArrayList<IRuntimeComponentType>();
593
            = new ArrayList<IRuntimeComponentType>();
594
        
594
        
595
        for( IRuntimeComponentType rct : runtimeComponentTypes )
595
        for( IRuntimeComponentType rct : runtimeComponentTypes.getItemSet() )
596
        {
596
        {
597
            try
597
            try
598
            {
598
            {
Lines 651-657 Link Here
651
        
651
        
652
        for( IRuntimeComponentType rct : badRuntimeComponentTypes )
652
        for( IRuntimeComponentType rct : badRuntimeComponentTypes )
653
        {
653
        {
654
            runtimeComponentTypes.remove( rct );
654
            runtimeComponentTypes.removeItem( rct );
655
        }
655
        }
656
    }
656
    }
657
    
657
    
(-)src/org/eclipse/wst/common/project/facet/core/util/internal/CollectionsUtil.java (-2 / +4 lines)
Lines 26-32 Link Here
26
{
26
{
27
    private CollectionsUtil() {}
27
    private CollectionsUtil() {}
28
    
28
    
29
    @SuppressWarnings( "unchecked" )
29
    @SuppressWarnings( "rawtypes" )
30
    
30
    private static final Comparator<Comparable<? super Comparable>> INVERTING_COMPARATOR 
31
    private static final Comparator<Comparable<? super Comparable>> INVERTING_COMPARATOR 
31
        = new Comparator<Comparable<? super Comparable>>()
32
        = new Comparator<Comparable<? super Comparable>>()
32
    {
33
    {
Lines 45-51 Link Here
45
     * @return an inverting comparator
46
     * @return an inverting comparator
46
     */
47
     */
47
    
48
    
48
    @SuppressWarnings( "unchecked" )
49
    @SuppressWarnings( { "unchecked", "rawtypes" } )
50
    
49
    public static <T extends Comparable> Comparator<T> getInvertingComparator()
51
    public static <T extends Comparable> Comparator<T> getInvertingComparator()
50
    {
52
    {
51
        return (Comparator<T>) INVERTING_COMPARATOR;
53
        return (Comparator<T>) INVERTING_COMPARATOR;
(-)src/org/eclipse/wst/common/project/facet/core/util/internal/IndexedSet.java (-27 / +73 lines)
Lines 14-19 Link Here
14
import java.util.Collections;
14
import java.util.Collections;
15
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.HashSet;
16
import java.util.HashSet;
17
import java.util.Iterator;
17
import java.util.Map;
18
import java.util.Map;
18
import java.util.Set;
19
import java.util.Set;
19
20
Lines 22-77 Link Here
22
 */
23
 */
23
24
24
public final class IndexedSet<K,V>
25
public final class IndexedSet<K,V>
25
26
    extends HashSet<V>
27
    
28
{
26
{
29
    private static final long serialVersionUID = 1L;
27
    private final Set<V> set;
30
    private final Set<V> unmodifiable;
28
    private final Set<V> unmodifiable;
31
    private final Map<K,V> index;
29
    private final Map<K,V> index;
32
    
30
    
33
    public IndexedSet()
31
    public IndexedSet()
34
    {
32
    {
35
        this.unmodifiable = Collections.unmodifiableSet( this );
33
        this.set = new HashSet<V>();
34
        this.unmodifiable = Collections.unmodifiableSet( this.set );
36
        this.index = new HashMap<K,V>();
35
        this.index = new HashMap<K,V>();
37
    }
36
    }
38
    
37
    
39
    public void add( final K key,
38
    public Set<V> getItemSet()
40
                     final V value )
41
    {
39
    {
42
        remove( this.index.get( key ) );
40
        return this.unmodifiable;
43
        add( value );
41
    }
44
        this.index.put( key, value );
42
43
    public V getItemByKey( final K key )
44
    {
45
        return this.index.get( key );
45
    }
46
    }
46
    
47
    
47
    public boolean delete( final K key )
48
    public boolean containsKey( final K key )
48
    {
49
    {
49
        final Object value = this.index.get( key );
50
        return this.index.containsKey( key );
50
        
51
    }
51
        if( value == null )
52
52
        {
53
    public boolean containsItem( final V item )
53
            return false;
54
    {
54
        }
55
        return this.set.contains( item );
55
        else
56
    }
57
58
    public void addItem( final V item )
59
    {
60
        if( item == null )
56
        {
61
        {
57
            remove( value );
62
            throw new IllegalArgumentException();
58
            this.index.remove( key );
59
            return true;
60
        }
63
        }
64
        
65
        this.set.add( item );
61
    }
66
    }
62
    
67
    
63
    public V get( final K key )
68
    public void addItemWithKey( final K key,
69
                                final V item )
64
    {
70
    {
65
        return this.index.get( key );
71
        addItem( item );
72
        addKey( key, item );
66
    }
73
    }
67
    
74
    
68
    public boolean containsKey( final K key )
75
    public void addKey( final K key,
76
                        final V item )
69
    {
77
    {
70
        return this.index.containsKey( key );
78
        if( key == null || item == null )
79
        {
80
            throw new IllegalArgumentException();
81
        }
82
        
83
        if( ! this.set.contains( item ) )
84
        {
85
            throw new IllegalArgumentException();
86
        }
87
        
88
        this.index.put( key, item );
71
    }
89
    }
72
    
90
    
73
    public Set<V> getUnmodifiable()
91
    public boolean removeItem( final V item )
74
    {
92
    {
75
        return this.unmodifiable;
93
        if( this.set.remove( item ) )
94
        {
95
            for( Iterator<Map.Entry<K,V>> itr = this.index.entrySet().iterator(); itr.hasNext(); )
96
            {
97
                final Map.Entry<K,V> entry = itr.next();
98
                
99
                if( entry.getValue() == item )
100
                {
101
                    itr.remove();
102
                }
103
            }
104
        
105
            return true;
106
        }
107
        
108
        return false;
109
    }
110
111
    public boolean removeItemByKey( final K key )
112
    {
113
        final V item = this.index.get( key );
114
        
115
        if( item != null )
116
        {
117
            return removeItem( item );
118
        }
119
        
120
        return false;
76
    }
121
    }
122
    
77
}
123
}
(-)src/org/eclipse/wst/common/project/facet/core/util/internal/PluginUtil.java (-2 / +3 lines)
Lines 184-195 Link Here
184
    }
184
    }
185
185
186
    @SuppressWarnings( "unchecked" )
186
    @SuppressWarnings( "unchecked" )
187
    
187
    public static <T> Class<T> loadClass( final String pluginId,
188
    public static <T> Class<T> loadClass( final String pluginId,
188
                                          final String clname,
189
                                          final String clname,
189
                                          final Class<T> interfc )
190
                                          final Class<T> interfc )
190
    {
191
    {
191
        final Bundle bundle = Platform.getBundle( pluginId );
192
        final Bundle bundle = Platform.getBundle( pluginId );
192
        final Class cl;
193
        final Class<?> cl;
193
194
194
        try
195
        try
195
        {
196
        {
Lines 216-222 Link Here
216
            return null;
217
            return null;
217
        }
218
        }
218
219
219
        return cl;
220
        return (Class<T>) cl;
220
    }
221
    }
221
222
222
    public static <T> T instantiate( final String pluginId,
223
    public static <T> T instantiate( final String pluginId,
(-)src/org/eclipse/wst/common/project/facet/core/util/internal/Versionable.java (-10 / +8 lines)
Lines 49-55 Link Here
49
    
49
    
50
    public Set<T> getVersions()
50
    public Set<T> getVersions()
51
    {
51
    {
52
        return this.versions.getUnmodifiable();
52
        return this.versions.getItemSet();
53
    }
53
    }
54
    
54
    
55
    public Set<T> getVersions( final String expr )
55
    public Set<T> getVersions( final String expr )
Lines 60-66 Link Here
60
        final VersionExpr<T> prepared = new VersionExpr<T>( this, expr, null );
60
        final VersionExpr<T> prepared = new VersionExpr<T>( this, expr, null );
61
        final Set<T> result = new HashSet<T>();
61
        final Set<T> result = new HashSet<T>();
62
         
62
         
63
        for( T ver : this.versions )
63
        for( T ver : this.versions.getItemSet() )
64
        {
64
        {
65
            if( prepared.check( ver ) )
65
            if( prepared.check( ver ) )
66
            {
66
            {
Lines 73-79 Link Here
73
    
73
    
74
    public T getVersion( final String version )
74
    public T getVersion( final String version )
75
    {
75
    {
76
        final T ver = this.versions.get( version );
76
        final T ver = this.versions.getItemByKey( version );
77
        
77
        
78
        if( ver == null )
78
        if( ver == null )
79
        {
79
        {
Lines 87-96 Link Here
87
    
87
    
88
    public T getLatestVersion()
88
    public T getLatestVersion()
89
    {
89
    {
90
        if( this.versions.size() > 0 )
90
        if( this.versions.getItemSet().size() > 0 )
91
        {
91
        {
92
        	// [263113] Versionable no longer compiles as of I20090125-2000
92
            return (T) Collections.max( this.versions.getItemSet() );
93
            return (T) Collections.max( this.versions );
94
        }
93
        }
95
        else
94
        else
96
        {
95
        {
Lines 124-136 Link Here
124
            };
123
            };
125
        }
124
        }
126
125
127
        final List<T> list = new ArrayList<T>( this.versions );
126
        final List<T> list = new ArrayList<T>( this.versions.getItemSet() );
128
        Collections.sort( list, comp );
127
        Collections.sort( list, comp );
129
        
128
        
130
        return list;
129
        return list;
131
    }
130
    }
132
    
131
    
133
    @SuppressWarnings( "unchecked" )
132
    @SuppressWarnings( "unchecked" )
133
    
134
    public Comparator<String> getVersionComparator()
134
    public Comparator<String> getVersionComparator()
135
    
135
    
136
        throws CoreException
136
        throws CoreException
Lines 150-158 Link Here
150
                
150
                
151
                try
151
                try
152
                {
152
                {
153
                    final Class cl 
153
                    final Class<?> cl = bundle.loadClass( this.versionComparatorClass );
154
                        = bundle.loadClass( this.versionComparatorClass );
155
                    
156
                    this.versionComparator = (Comparator<String>) cl.newInstance();
154
                    this.versionComparator = (Comparator<String>) cl.newInstance();
157
                }
155
                }
158
                catch( Exception e )
156
                catch( Exception e )

Return to bug 298905