[150547] Default Java facet is 6.0?
diff --git a/plugins/org.eclipse.jst.common.frameworks/plugin.xml b/plugins/org.eclipse.jst.common.frameworks/plugin.xml index 4aef042..0ca7e71 100644 --- a/plugins/org.eclipse.jst.common.frameworks/plugin.xml +++ b/plugins/org.eclipse.jst.common.frameworks/plugin.xml
@@ -36,6 +36,7 @@ <project-facet id="jst.java"> <label>Java</label> <description>%jstJavaFacetDescription</description> + <default-version provider="org.eclipse.jst.common.project.facet.JavaFacetDefaultVersionProvider"/> </project-facet> <project-facet-version facet="jst.java" version="1.3">
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetDefaultVersionProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetDefaultVersionProvider.java new file mode 100644 index 0000000..4dd8501 --- /dev/null +++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetDefaultVersionProvider.java
@@ -0,0 +1,34 @@ +/****************************************************************************** + * Copyright (c) 2006 BEA Systems, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Konstantin Komissarchik - initial API and implementation + ******************************************************************************/ + +package org.eclipse.jst.common.project.facet; + +import org.eclipse.wst.common.project.facet.core.IDefaultVersionProvider; +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; + +/** + * Defaults the java facet version to align with workspace java compiler + * level settings. + * + * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> + */ + +public final class JavaFacetDefaultVersionProvider + + implements IDefaultVersionProvider + +{ + public IProjectFacetVersion getDefaultVersion() + { + final String compilerLevel = JavaFacetUtils.getCompilerLevel(); + return JavaFacetUtils.compilerLevelToFacet( compilerLevel ); + } +}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java index 2a8be90..78e24f2 100644 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java +++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java
@@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. + * Copyright (c) 2005, 2006 BEA Systems, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -64,28 +64,35 @@ public static final IProjectFacetVersion JAVA_60 = JAVA_FACET.getVersion( "6.0" ); //$NON-NLS-1$ - - public static String getCompilerLevel( final IProject project ) + + public static String getCompilerLevel() { - IScopeContext context = new ProjectScope( project ); - IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID ); + final IScopeContext context = new InstanceScope(); + final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID ); String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null ); if( level == null ) { - context = new InstanceScope(); - prefs = context.getNode( JavaCore.PLUGIN_ID ); - level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null ); - } - - if( level == null ) - { final Hashtable defaults = JavaCore.getDefaultOptions(); level = (String) defaults.get( JavaCore.COMPILER_COMPLIANCE ); } return level; } + + public static String getCompilerLevel( final IProject project ) + { + final IScopeContext context = new ProjectScope( project ); + final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID ); + String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null ); + + if( level == null ) + { + level = getCompilerLevel(); + } + + return level; + } public static void setCompilerLevel( final IProject project, final IProjectFacetVersion fv )