Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125711 Details for
Bug 176516
[build path] Compiler Compliance should follow Execution Environment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix
176516_patch.txt (text/plain), 85.81 KB, created by
Markus Keller
on 2009-02-14 02:56:22 EST
(
hide
)
Description:
Fix
Filename:
MIME Type:
Creator:
Markus Keller
Created:
2009-02-14 02:56:22 EST
Size:
85.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties,v >retrieving revision 1.482 >diff -u -r1.482 PreferencesMessages.properties >--- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 3 Feb 2009 17:12:21 -0000 1.482 >+++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 14 Feb 2009 07:55:51 -0000 >@@ -22,7 +22,7 @@ > BuildPathsPropertyPage_closed_project_message=Java information is not available for a closed project. > > BuildPathsPropertyPage_unsavedchanges_title=Setting Java Build Path >-BuildPathsPropertyPage_unsavedchanges_message=The Java Build path property page contains unsaved modifications. Do you want to save changes so that other build path related property pages can be updated? >+BuildPathsPropertyPage_unsavedchanges_message=The Java Build Path property page contains unsaved modifications. Do you want to save changes so that other build path related property pages can be updated? > BuildPathsPropertyPage_unsavedchanges_button_save=Apply > BuildPathsPropertyPage_unsavedchanges_button_discard=Discard > BuildPathsPropertyPage_unsavedchanges_button_ignore=Apply Later >@@ -553,6 +553,7 @@ > ComplianceConfigurationBlock_codegen_targetplatform_label=Ge&nerated .class files compatibility: > ComplianceConfigurationBlock_pb_assert_as_identifier_label=Disallow identifie&rs called 'assert': > ComplianceConfigurationBlock_pb_enum_as_identifier_label=Disallo&w identifiers called 'enum': >+ComplianceConfigurationBlock_compliance_follows_EE_label=Use compliance from Execution Environment on the <a>Java Build Path</a> > ComplianceConfigurationBlock_compliance_group_label=JDK Compliance > ComplianceConfigurationBlock_classfiles_group_label=Classfile Generation > ComplianceConfigurationBlock_classfile_greater_compliance=Classfile compatibility must be equal or less than compliance level. >@@ -560,7 +561,7 @@ > > ComplianceConfigurationBlock_jrecompliance_info=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (currently {1}). <a href="1" >Configure...</a> > ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14=CLDC 1.1 requires source level 1.3 and compliance 1.4 or less >-ComplianceConfigurationBlock_jrecompliance_info_project=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (currently {1}). Configure the <a href="1" >Installed JREs</a> or change the JRE on the <a href="2" >Java build path</a>. >+ComplianceConfigurationBlock_jrecompliance_info_project=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (currently {1}). Configure the <a href="1" >Installed JREs</a> and <a href="2" >Execution Environments</a>, or change the JRE on the <a href="3" >Java build path</a>. > > OptionsConfigurationBlock_job_title=Rebuilding > >Index: ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java,v >retrieving revision 1.76 >diff -u -r1.76 OptionsConfigurationBlock.java >--- ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java 2 Feb 2009 13:22:55 -0000 1.76 >+++ ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java 14 Feb 2009 07:55:50 -0000 >@@ -136,7 +136,7 @@ > } > > /** >- * Key that is only managed locally ans not part of preference store. >+ * Key that is only managed locally and not part of preference store. > */ > private static class LocalKey extends Key { > private HashMap fValues; >@@ -384,8 +384,7 @@ > > makeScrollableCompositeAware(checkBox); > >- String currValue= getValue(key); >- checkBox.setSelection(data.getSelection(currValue) == 0); >+ updateCheckBox(checkBox); > > fCheckBoxes.add(checkBox); > >@@ -440,6 +439,7 @@ > checkBox.setSelection(!checkBox.getSelection()); > checkBox.setFocus(); > linkSelected[0]= false; >+ controlChanged(checkBox); > } > } > }); >@@ -447,8 +447,7 @@ > makeScrollableCompositeAware(link); > makeScrollableCompositeAware(checkBox); > >- String currValue= getValue(key); >- checkBox.setSelection(data.getSelection(currValue) == 0); >+ updateCheckBox(checkBox); > > fCheckBoxes.add(checkBox); > >@@ -509,8 +508,7 @@ > > makeScrollableCompositeAware(comboBox); > >- String currValue= getValue(key); >- comboBox.select(data.getSelection(currValue)); >+ updateCombo(comboBox); > > fComboBoxes.add(comboBox); > return comboBox; >@@ -530,10 +528,8 @@ > > fLabels.put(textBox, labelControl); > >- String currValue= getValue(key); >- if (currValue != null) { >- textBox.setText(currValue); >- } >+ updateText(textBox); >+ > textBox.addModifyListener(getTextModifyListener()); > > GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL); >@@ -663,10 +659,23 @@ > validateSettings(key, oldValue, number); > } > >+ /** >+ * Checks a setting. >+ * >+ * @param key a key >+ * @param value an assumed value for the key >+ * @return <code>true</code> iff the given key's value is equal to the given value >+ */ > protected boolean checkValue(Key key, String value) { > return value.equals(getValue(key)); > } > >+ /** >+ * Returns the value for the key. >+ * >+ * @param key the key >+ * @return the stored value >+ */ > protected String getValue(Key key) { > if (fDisabledProjectSettings != null) { > return (String) fDisabledProjectSettings.get(key); >@@ -679,6 +688,19 @@ > return Boolean.valueOf(getValue(key)).booleanValue(); > } > >+ /** >+ * Sets the option <code>key</code> to the value <code>value</code>. >+ * Note that callers have to make sure the corresponding controls are updated afterwards. >+ * >+ * @param key the option key >+ * @param value the new value >+ * @return the old value >+ * >+ * @see #updateControls() >+ * @see #updateCheckBox(Button) >+ * @see #updateCombo(Combo) >+ * @see #updateText(Text) >+ */ > protected String setValue(Key key, String value) { > if (fDisabledProjectSettings != null) { > return (String) fDisabledProjectSettings.put(key, value); >@@ -688,27 +710,69 @@ > return oldValue; > } > >+ /** >+ * Sets the option <code>key</code> to the value <code>value</code>. >+ * Note that callers have to make sure the corresponding controls are updated afterwards. >+ * >+ * @param key the option key >+ * @param value the new value >+ * @return the old value >+ * >+ * @see #updateControls() >+ * @see #updateCheckBox(Button) >+ * @see #updateCombo(Combo) >+ * @see #updateText(Text) >+ */ > protected String setValue(Key key, boolean value) { > return setValue(key, String.valueOf(value)); > } > > protected final void setDefaultValue(Key key, String value) { >- key.setStoredValue(fLookupOrder[fLookupOrder.length - 1], value, fManager); >+ IScopeContext instanceScope= fLookupOrder[fLookupOrder.length - 1]; >+ key.setStoredValue(instanceScope, value, fManager); > } > > /** >- * Returns the value as actually stored in the preference store. >+ * Returns the value as stored in the preference store. > * > * @param key the key >- * @return the value as actually stored in the preference store. >+ * @return the value > */ > protected String getStoredValue(Key key) { > return key.getStoredValue(fLookupOrder, false, fManager); > } >+ >+ /** >+ * Returns the value as actually stored in the preference store, without considering >+ * the working copy store. >+ * >+ * @param key the key >+ * @return the value as actually stored in the preference store >+ */ >+ protected String getOriginalStoredValue(Key key) { >+ return key.getStoredValue(fLookupOrder, false, null); >+ } >+ >+ /** >+ * Reverts the given options to the stored values. >+ * >+ * @param keys the options to revert >+ * @since 3.5 >+ */ >+ protected void revertValues(Key[] keys) { >+ for (int i= 0; i < keys.length; i++) { >+ Key curr= keys[i]; >+ String origValue= curr.getStoredValue(fLookupOrder, false, null); >+ setValue(curr, origValue); >+ } >+ } > >- /* (non-javadoc) >- * Update fields and validate. >- * @param changedKey Key that changed, or null, if all changed. >+ /** >+ * Updates fields and validates settings. >+ * >+ * @param changedKey key that changed, or <code>null</code>, if all changed. >+ * @param oldValue old value or <code>null</code> >+ * @param newValue new value or <code>null</code> > */ > protected abstract void validateSettings(Key changedKey, String oldValue, String newValue); > >@@ -855,11 +919,7 @@ > * @since 3.1 > */ > public void performRevert() { >- for (int i= 0; i < fAllKeys.length; i++) { >- Key curr= fAllKeys[i]; >- String origValue= curr.getStoredValue(fLookupOrder, false, null); >- setValue(curr, origValue); >- } >+ revertValues(fAllKeys); > > settingsUpdated(); > updateControls(); >@@ -869,8 +929,11 @@ > public void dispose() { > } > >+ /** >+ * Updates the UI from the current settings. Must be called whenever a setting has been changed >+ * by code. >+ */ > protected void updateControls() { >- // update the UI > for (int i= fCheckBoxes.size() - 1; i >= 0; i--) { > updateCheckBox((Button) fCheckBoxes.get(i)); > } >Index: ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java,v >retrieving revision 1.48 >diff -u -r1.48 BuildPathsPropertyPage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java 11 Sep 2008 11:59:31 -0000 1.48 >+++ ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java 14 Feb 2009 07:55:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -107,31 +107,39 @@ > return pageSettings; > } > >+ /* >+ * @see org.eclipse.jface.preference.PreferencePage#okToLeave() >+ * @since 3.5 >+ */ >+ public boolean okToLeave() { >+ if (fBuildPathsBlock != null && fBuildPathsBlock.hasChangesInDialog()) { >+ String title= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_title; >+ String message= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_message; >+ String[] buttonLabels= new String[] { >+ PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_save, >+ PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_discard, >+ PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_ignore >+ }; >+ MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0); >+ int res= dialog.open(); >+ if (res == 0) { //save >+ fBlockOnApply= true; >+ performOk(); >+ } else if (res == 1) { // discard >+ fBuildPathsBlock.init(JavaCore.create(getProject()), null, null); >+ } else { >+ // keep unsaved >+ } >+ } >+ return super.okToLeave(); >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean) > */ > public void setVisible(boolean visible) { > if (fBuildPathsBlock != null) { >- if (!visible) { >- if (fBuildPathsBlock.hasChangesInDialog()) { >- String title= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_title; >- String message= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_message; >- String[] buttonLabels= new String[] { >- PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_save, >- PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_discard, >- PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_ignore >- }; >- MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0); >- int res= dialog.open(); >- if (res == 0) { >- performOk(); >- } else if (res == 1) { >- fBuildPathsBlock.init(JavaCore.create(getProject()), null, null); >- } else { >- // keep unsaved >- } >- } >- } else { >+ if (visible) { > if (!fBuildPathsBlock.hasChangesInDialog() && fBuildPathsBlock.hasChangesInClasspathFile()) { > fBuildPathsBlock.init(JavaCore.create(getProject()), null, null); > } >Index: ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java,v >retrieving revision 1.31 >diff -u -r1.31 ComplianceConfigurationBlock.java >--- ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java 11 Sep 2008 11:59:32 -0000 1.31 >+++ ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java 14 Feb 2009 07:55:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -13,9 +13,11 @@ > import java.util.ArrayList; > import java.util.Arrays; > import java.util.HashMap; >+import java.util.List; > import java.util.Map; > > import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.GridData; >@@ -37,6 +39,7 @@ > import org.eclipse.ui.dialogs.PreferencesUtil; > import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; > >+import org.eclipse.jdt.core.IClasspathEntry; > import org.eclipse.jdt.core.JavaCore; > > import org.eclipse.jdt.internal.corext.util.JavaModelUtil; >@@ -45,6 +48,7 @@ > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.IVMInstall2; > import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.environments.IExecutionEnvironment; > > import org.eclipse.jdt.internal.ui.JavaPlugin; > import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; >@@ -54,24 +58,42 @@ > import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; > > /** >- */ >+ * Configuration block for the 'Java Compiler' page. >+ */ > public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { > >+ /** >+ * Key for the "Compiler compliance follows EE" setting. >+ * <br>Only applicable if <code>fProject != null</code>. >+ * <p>Values are { {@link #DEFAULT_CONF}, {@link #USER_CONF}, or {@link #DISABLED} }. >+ */ >+ private static final Key INTR_COMPLIANCE_FOLLOWS_EE= getLocalKey("internal.compliance.follows.ee"); //$NON-NLS-1$ >+ >+ /** >+ * Key for the "Use default compliance" setting. >+ * <p>Values are { {@link #DEFAULT_CONF}, {@link #USER_CONF} }. >+ */ >+ private static final Key INTR_DEFAULT_COMPLIANCE= getLocalKey("internal.default.compliance"); //$NON-NLS-1$ >+ > // Preference store keys, see JavaCore.getOptions >+ private static final Key PREF_PB_ASSERT_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER); >+ private static final Key PREF_PB_ENUM_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ENUM_IDENTIFIER); >+ private static final Key PREF_SOURCE_COMPATIBILITY= getJDTCoreKey(JavaCore.COMPILER_SOURCE); >+ private static final Key PREF_CODEGEN_TARGET_PLATFORM= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); >+ private static final Key PREF_COMPLIANCE= getJDTCoreKey(JavaCore.COMPILER_COMPLIANCE); >+ >+ /* see also BuildPathSupport#PREFS_COMPLIANCE */ >+ private static final Key[] PREFS_COMPLIANCE= new Key[] { PREF_COMPLIANCE, >+ PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_ENUM_AS_IDENTIFIER, >+ PREF_SOURCE_COMPATIBILITY, PREF_CODEGEN_TARGET_PLATFORM }; >+ >+ private static final Key PREF_CODEGEN_INLINE_JSR_BYTECODE= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE); >+ > private static final Key PREF_LOCAL_VARIABLE_ATTR= getJDTCoreKey(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR); > private static final Key PREF_LINE_NUMBER_ATTR= getJDTCoreKey(JavaCore.COMPILER_LINE_NUMBER_ATTR); > private static final Key PREF_SOURCE_FILE_ATTR= getJDTCoreKey(JavaCore.COMPILER_SOURCE_FILE_ATTR); > private static final Key PREF_CODEGEN_UNUSED_LOCAL= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL); >- private static final Key PREF_CODEGEN_TARGET_PLATFORM= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); >- private static final Key PREF_CODEGEN_INLINE_JSR_BYTECODE= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE); >- >- private static final Key PREF_SOURCE_COMPATIBILITY= getJDTCoreKey(JavaCore.COMPILER_SOURCE); >- private static final Key PREF_COMPLIANCE= getJDTCoreKey(JavaCore.COMPILER_COMPLIANCE); >- private static final Key PREF_PB_ASSERT_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER); >- private static final Key PREF_PB_ENUM_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ENUM_IDENTIFIER); >- >- private static final Key INTR_DEFAULT_COMPLIANCE= getLocalKey("internal.default.compliance"); //$NON-NLS-1$ >- >+ > // values > private static final String GENERATE= JavaCore.GENERATE; > private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE; >@@ -94,14 +116,37 @@ > private static final String ENABLED= JavaCore.ENABLED; > private static final String DISABLED= JavaCore.DISABLED; > >- > private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$ > private static final String USER_CONF= "user"; //$NON-NLS-1$ > >+ private ArrayList fComplianceFollowsEEControls; > private ArrayList fComplianceControls; >+ private ArrayList fComplianceChildControls; > private PixelConverter fPixelConverter; > >+ /** >+ * Remembered user compliance (stored when {@link #INTR_DEFAULT_COMPLIANCE} is switched to {@link #DEFAULT_CONF}). >+ * Elements are identified by <code>IDX_*</code> constants. >+ * @see #IDX_ASSERT_AS_IDENTIFIER >+ * @see #IDX_ENUM_AS_IDENTIFIER >+ * @see #IDX_SOURCE_COMPATIBILITY >+ * @see #IDX_CODEGEN_TARGET_PLATFORM >+ * @see #IDX_COMPLIANCE >+ * @see #IDX_INLINE_JSR_BYTECODE >+ */ > private String[] fRememberedUserCompliance; >+ >+ /** >+ * Stored compliance settings that were active when the page was first shown. May be <code>null</code>. >+ * Elements are identified by <code>IDX_*</code> constants. >+ * @see #IDX_ASSERT_AS_IDENTIFIER >+ * @see #IDX_ENUM_AS_IDENTIFIER >+ * @see #IDX_SOURCE_COMPATIBILITY >+ * @see #IDX_CODEGEN_TARGET_PLATFORM >+ * @see #IDX_COMPLIANCE >+ * @see #IDX_INLINE_JSR_BYTECODE >+ */ >+ private String[] fOriginalStoredCompliance; > > private static final int IDX_ASSERT_AS_IDENTIFIER= 0; > private static final int IDX_ENUM_AS_IDENTIFIER= 1; >@@ -117,11 +162,13 @@ > private ControlEnableState fBlockEnableState; > > public ComplianceConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) { >- super(context, project, getKeys(), container); >+ super(context, project, getKeys(project != null), container); > setDefaultCompilerComplianceValues(); > > fBlockEnableState= null; >+ fComplianceFollowsEEControls= new ArrayList(); > fComplianceControls= new ArrayList(); >+ fComplianceChildControls= new ArrayList(); > > fComplianceStatus= new StatusInfo(); > >@@ -135,12 +182,21 @@ > }; > } > >- private static Key[] getKeys() { >- return new Key[] { >+ private static Key[] getKeys(boolean projectSpecific) { >+ Key[] keys= new Key[] { > PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL, PREF_CODEGEN_INLINE_JSR_BYTECODE, INTR_DEFAULT_COMPLIANCE, > PREF_COMPLIANCE, PREF_SOURCE_COMPATIBILITY, > PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_ENUM_AS_IDENTIFIER > }; >+ >+ if (projectSpecific) { >+ Key[] allKeys = new Key[keys.length + 1]; >+ System.arraycopy(keys, 0, allKeys, 0, keys.length); >+ allKeys[keys.length]= INTR_COMPLIANCE_FOLLOWS_EE; >+ return allKeys; >+ } >+ >+ return keys; > } > > /* (non-Javadoc) >@@ -148,6 +204,7 @@ > */ > protected void settingsUpdated() { > setValue(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance()); >+ updateComplianceFollowsEE(); > super.settingsUpdated(); > } > >@@ -220,14 +277,38 @@ > group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); > group.setLayout(layout); > >+ String[] defaultUserValues= new String[] { DEFAULT_CONF, USER_CONF }; >+ >+ Control[] otherChildren= group.getChildren(); >+ if (fProject != null) { >+ String label= PreferencesMessages.ComplianceConfigurationBlock_compliance_follows_EE_label; >+ int widthHint= fPixelConverter.convertWidthInCharsToPixels(40); >+ addCheckBoxWithLink(group, label, INTR_COMPLIANCE_FOLLOWS_EE, defaultUserValues, 0, widthHint, new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ openBuildPathPropertyPage(); >+ } >+ }); >+ } >+ >+ Control[] allChildren= group.getChildren(); >+ fComplianceFollowsEEControls.addAll(Arrays.asList(allChildren)); >+ fComplianceFollowsEEControls.removeAll(Arrays.asList(otherChildren)); >+ otherChildren= allChildren; >+ >+ > String label= PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label; > addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0); > > label= PreferencesMessages.ComplianceConfigurationBlock_default_settings_label; >- addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String[] { DEFAULT_CONF, USER_CONF }, 0); >+ addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0); > >+ allChildren= group.getChildren(); >+ fComplianceControls.addAll(Arrays.asList(allChildren)); >+ fComplianceControls.removeAll(Arrays.asList(otherChildren)); >+ otherChildren= allChildren; >+ >+ > int indent= fPixelConverter.convertWidthInCharsToPixels(2); >- Control[] otherChildren= group.getChildren(); > > String[] versions= new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6 }; > String[] versionsLabels= new String[] { >@@ -260,10 +341,10 @@ > label= PreferencesMessages.ComplianceConfigurationBlock_pb_enum_as_identifier_label; > addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent); > >- >- Control[] allChildren= group.getChildren(); >- fComplianceControls.addAll(Arrays.asList(allChildren)); >- fComplianceControls.removeAll(Arrays.asList(otherChildren)); >+ allChildren= group.getChildren(); >+ fComplianceChildControls.addAll(Arrays.asList(allChildren)); >+ fComplianceChildControls.removeAll(Arrays.asList(otherChildren)); >+ > > layout= new GridLayout(); > layout.numColumns= nColumns; >@@ -300,7 +381,9 @@ > fJRE50InfoText.addSelectionListener(new SelectionListener() { > public void widgetDefaultSelected(SelectionEvent e) { > if ("1".equals(e.text)) { //$NON-NLS-1$ >- openJREInstallPreferencePage(); >+ openJREInstallPreferencePage(false); >+ } else if ("2".equals(e.text)) { //$NON-NLS-1$ >+ openJREInstallPreferencePage(true); > } else { > openBuildPathPropertyPage(); > } >@@ -326,19 +409,20 @@ > validateComplianceStatus(); > } > >- protected final void openJREInstallPreferencePage() { >+ protected final void openJREInstallPreferencePage(boolean openEE) { > String jreID= BuildPathSupport.JRE_PREF_PAGE_ID; >+ String eeID= BuildPathSupport.EE_PREF_PAGE_ID; >+ String pageId= openEE ? eeID : jreID; > if (fProject == null && getPreferenceContainer() != null) { >- getPreferenceContainer().openPage(jreID, null); >+ getPreferenceContainer().openPage(pageId, null); > } else { >- PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID }, null).open(); >+ PreferencesUtil.createPreferenceDialogOn(getShell(), pageId, new String[] { jreID, eeID }, null).open(); > } > validateComplianceStatus(); > } > >- /* (non-javadoc) >- * Update fields and validate. >- * @param changedKey Key that changed, or null, if all changed. >+ /** >+ * {@inheritDoc} > */ > protected void validateSettings(Key changedKey, String oldValue, String newValue) { > if (!areSettingsEnabled()) { >@@ -349,17 +433,24 @@ > updateComplianceEnableState(); > updateComplianceDefaultSettings(true, null); > fComplianceStatus= validateCompliance(); >+ } else if (INTR_COMPLIANCE_FOLLOWS_EE.equals(changedKey)) { >+ setValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); >+ updateComplianceEnableState(); >+ updateComplianceDefaultSettings(true, null); >+ updateControls(); >+ fComplianceStatus= validateCompliance(); >+ validateComplianceStatus(); > } else if (PREF_COMPLIANCE.equals(changedKey)) { > // set compliance settings to default > Object oldDefault= getValue(INTR_DEFAULT_COMPLIANCE); >- updateComplianceDefaultSettings(USER_CONF.equals(oldDefault), oldValue); >+ boolean rememberOld= USER_CONF.equals(oldDefault); >+ updateComplianceDefaultSettings(rememberOld, oldValue); > fComplianceStatus= validateCompliance(); > validateComplianceStatus(); > } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey)) { > updateAssertEnumAsIdentifierEnableState(); > fComplianceStatus= validateCompliance(); > } else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey)) { >- updateInlineJSREnableState(); > if (VERSION_CLDC_1_1.equals(newValue) && !oldValue.equals(newValue)) { > String compliance= getValue(PREF_COMPLIANCE); > String source= getValue(PREF_SOURCE_COMPATIBILITY); >@@ -381,6 +472,8 @@ > return; > } > } else { >+ updateComplianceFollowsEE(); >+ updateControls(); > updateComplianceEnableState(); > updateAssertEnumAsIdentifierEnableState(); > updateInlineJSREnableState(); >@@ -389,8 +482,52 @@ > } > fContext.statusChanged(fComplianceStatus); > } >+ >+ public void refreshComplianceSettings() { >+ if (fProject != null) { >+ if (fOriginalStoredCompliance == null) { >+ fOriginalStoredCompliance= new String[] { // caution: order depends on IDX_* constants >+ getOriginalStoredValue(PREF_PB_ASSERT_AS_IDENTIFIER), >+ getOriginalStoredValue(PREF_PB_ENUM_AS_IDENTIFIER), >+ getOriginalStoredValue(PREF_SOURCE_COMPATIBILITY), >+ getOriginalStoredValue(PREF_CODEGEN_TARGET_PLATFORM), >+ getOriginalStoredValue(PREF_COMPLIANCE), >+ getOriginalStoredValue(PREF_CODEGEN_INLINE_JSR_BYTECODE), >+ }; >+ >+ } else { >+ String[] storedCompliance= new String[] { >+ getOriginalStoredValue(PREF_PB_ASSERT_AS_IDENTIFIER), >+ getOriginalStoredValue(PREF_PB_ENUM_AS_IDENTIFIER), >+ getOriginalStoredValue(PREF_SOURCE_COMPATIBILITY), >+ getOriginalStoredValue(PREF_CODEGEN_TARGET_PLATFORM), >+ getOriginalStoredValue(PREF_COMPLIANCE), >+ getOriginalStoredValue(PREF_CODEGEN_INLINE_JSR_BYTECODE), >+ }; >+ if (!Arrays.equals(fOriginalStoredCompliance, storedCompliance)) { >+ // compliance changed on disk -> override user modifications >+ >+ fOriginalStoredCompliance= storedCompliance; >+ >+ setValue(PREF_PB_ASSERT_AS_IDENTIFIER, storedCompliance[IDX_ASSERT_AS_IDENTIFIER]); >+ setValue(PREF_PB_ENUM_AS_IDENTIFIER, storedCompliance[IDX_ENUM_AS_IDENTIFIER]); >+ setValue(PREF_SOURCE_COMPATIBILITY, storedCompliance[IDX_SOURCE_COMPATIBILITY]); >+ setValue(PREF_CODEGEN_TARGET_PLATFORM, storedCompliance[IDX_CODEGEN_TARGET_PLATFORM]); >+ setValue(PREF_COMPLIANCE, storedCompliance[IDX_COMPLIANCE]); >+ setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, storedCompliance[IDX_INLINE_JSR_BYTECODE]); >+ >+ } >+ >+ updateComplianceFollowsEE(); >+ updateControls(); >+ updateComplianceEnableState(); >+ validateComplianceStatus(); >+ } >+ } >+ } > > private void validateComplianceStatus() { >+ //TODO: updated VM in .classpath is not resolved yet! > if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) { > boolean isVisible= false; > String compliance= getStoredValue(PREF_COMPLIANCE); // get actual value >@@ -467,14 +604,40 @@ > validateComplianceStatus(); > } > >- /* >- * Update the compliance controls' enable state >- */ >+ private void updateComplianceFollowsEE() { >+ if (fProject != null) { >+ String complianceFollowsEE= DISABLED; >+ IExecutionEnvironment ee= getEE(); >+ if (ee != null) { >+ complianceFollowsEE= getComplianceFollowsEE(ee); >+ } >+ setValue(INTR_COMPLIANCE_FOLLOWS_EE, complianceFollowsEE); >+ } >+ } >+ > private void updateComplianceEnableState() { >- boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF); >- for (int i= fComplianceControls.size() - 1; i >= 0; i--) { >- Control curr= (Control) fComplianceControls.get(i); >- curr.setEnabled(enabled); >+ boolean enableComplianceControls= true; >+ if (fProject != null) { >+ String complianceFollowsEE= getValue(INTR_COMPLIANCE_FOLLOWS_EE); >+ updateCheckBox(getCheckBox(INTR_COMPLIANCE_FOLLOWS_EE)); >+ boolean enableComplianceFollowsEE= ! DISABLED.equals(complianceFollowsEE); // is default or user >+ updateControlsEnableState(fComplianceFollowsEEControls, enableComplianceFollowsEE); >+ >+ enableComplianceControls= ! DEFAULT_CONF.equals(complianceFollowsEE); // is disabled or user >+ updateControlsEnableState(fComplianceControls, enableComplianceControls); >+ } >+ >+ boolean enableComplianceChildren= enableComplianceControls && checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF); >+ updateControlsEnableState(fComplianceChildControls, enableComplianceChildren); >+ } >+ >+ private void updateControlsEnableState(List controls, boolean enable) { >+ for (int i= controls.size() - 1; i >= 0; i--) { >+ Control curr= (Control) controls.get(i); >+ if (curr instanceof Composite) { >+ updateControlsEnableState(Arrays.asList(((Composite)curr).getChildren()), enable); >+ } >+ curr.setEnabled(enable); > } > } > >@@ -534,15 +697,21 @@ > } > } > >- /* >- * Set the default compliance values derived from the chosen level >+ /** >+ * Sets the default compliance values derived from the chosen level or restores the user >+ * compliance settings. >+ * >+ * @param rememberOld if <code>true</code>, the current compliance settings are remembered as >+ * user settings. If <code>false</code>, overwrite the current settings. >+ * @param oldComplianceLevel the previous compliance level > */ > private void updateComplianceDefaultSettings(boolean rememberOld, String oldComplianceLevel) { > String assertAsId, enumAsId, source, target; > boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); >+ boolean isFollowEE= checkValue(INTR_COMPLIANCE_FOLLOWS_EE, DEFAULT_CONF); > String complianceLevel= getValue(PREF_COMPLIANCE); > >- if (isDefault) { >+ if (isDefault || isFollowEE) { > if (rememberOld) { > if (oldComplianceLevel == null) { > oldComplianceLevel= complianceLevel; >@@ -554,27 +723,47 @@ > fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM]= getValue(PREF_CODEGEN_TARGET_PLATFORM); > fRememberedUserCompliance[IDX_COMPLIANCE]= oldComplianceLevel; > } >- >- if (VERSION_1_4.equals(complianceLevel)) { >- assertAsId= WARNING; >- enumAsId= WARNING; >- source= VERSION_1_3; >- target= VERSION_1_2; >- } else if (VERSION_1_5.equals(complianceLevel)) { >- assertAsId= ERROR; >- enumAsId= ERROR; >- source= VERSION_1_5; >- target= VERSION_1_5; >- } else if (VERSION_1_6.equals(complianceLevel)) { >- assertAsId= ERROR; >- enumAsId= ERROR; >- source= VERSION_1_6; >- target= VERSION_1_6; >+ >+ if (isFollowEE) { >+ IExecutionEnvironment ee= getEE(); >+ Map eeOptions= BuildPathSupport.getEEOptions(ee); >+ if (eeOptions == null) >+ return; >+ >+ assertAsId= (String)eeOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName()); >+ enumAsId= (String)eeOptions.get(PREF_PB_ENUM_AS_IDENTIFIER.getName()); >+ source= (String)eeOptions.get(PREF_SOURCE_COMPATIBILITY.getName()); >+ target= (String)eeOptions.get(PREF_CODEGEN_TARGET_PLATFORM.getName()); >+ >+ setValue(PREF_COMPLIANCE, (String)eeOptions.get(PREF_COMPLIANCE.getName())); >+ String inlineJSR= (String)eeOptions.get(PREF_CODEGEN_INLINE_JSR_BYTECODE.getName()); >+ if (inlineJSR != null) { >+ setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, inlineJSR); >+ } >+ > } else { >- assertAsId= IGNORE; >- enumAsId= IGNORE; >- source= VERSION_1_3; >- target= VERSION_1_1; >+ //TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel); >+ if (VERSION_1_4.equals(complianceLevel)) { >+ assertAsId= WARNING; >+ enumAsId= WARNING; >+ source= VERSION_1_3; >+ target= VERSION_1_2; >+ } else if (VERSION_1_5.equals(complianceLevel)) { >+ assertAsId= ERROR; >+ enumAsId= ERROR; >+ source= VERSION_1_5; >+ target= VERSION_1_5; >+ } else if (VERSION_1_6.equals(complianceLevel)) { >+ assertAsId= ERROR; >+ enumAsId= ERROR; >+ source= VERSION_1_6; >+ target= VERSION_1_6; >+ } else { >+ assertAsId= IGNORE; >+ enumAsId= IGNORE; >+ source= VERSION_1_3; >+ target= VERSION_1_1; >+ } > } > } else { > if (rememberOld && complianceLevel.equals(fRememberedUserCompliance[IDX_COMPLIANCE])) { >@@ -597,11 +786,14 @@ > updateAssertEnumAsIdentifierEnableState(); > } > >- /* >- * Evaluate if the current compliance setting correspond to a default setting >+ /** >+ * Evaluate if the current compliance setting correspond to a default setting. >+ * >+ * @return {@link #DEFAULT_CONF} or {@link #USER_CONF} > */ > private String getCurrentCompliance() { > Object complianceLevel= getValue(PREF_COMPLIANCE); >+ //TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel); > if ((VERSION_1_3.equals(complianceLevel) > && IGNORE.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER)) > && IGNORE.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER)) >@@ -627,7 +819,53 @@ > return USER_CONF; > } > >+ private IExecutionEnvironment getEE() { >+ if (fProject == null) >+ return null; >+ >+ try { >+ IClasspathEntry[] entries= JavaCore.create(fProject).getRawClasspath(); >+ for (int i= 0; i < entries.length; i++) { >+ IClasspathEntry entry= entries[i]; >+ if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { >+ String eeId= JavaRuntime.getExecutionEnvironmentId(entry.getPath()); >+ if (eeId != null) { >+ return JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId); >+ } >+ } >+ } >+ } catch (CoreException e) { >+ JavaPlugin.log(e); >+ } >+ return null; >+ } > >+ /** >+ * Evaluate if the builds path contains an execution environment and the current compliance >+ * settings follow the EE options. >+ * >+ * @param ee the EE, or <code>null</code> if none available >+ * @return {@link #DEFAULT_CONF} if the compliance follows the EE, or {@link #USER_CONF} if the >+ * settings differ, or {@link #DISABLED} if there's no EE at all >+ */ >+ private String getComplianceFollowsEE(IExecutionEnvironment ee) { >+ Map options= BuildPathSupport.getEEOptions(ee); >+ if (options == null) >+ return DISABLED; >+ >+ return checkDefaults(PREFS_COMPLIANCE, options); >+ } >+ >+ private String checkDefaults(Key[] keys, Map options) { >+ for (int i= 0; i < keys.length; i++) { >+ Key key= keys[i]; >+ Object option= options.get(key.getName()); >+ if (!checkValue(key, (String)option)) >+ return USER_CONF; >+ } >+ return DEFAULT_CONF; >+ } >+ > protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { > String title= PreferencesMessages.ComplianceConfigurationBlock_needsbuild_title; > String message; >@@ -639,6 +877,11 @@ > return new String[] { title, message }; > } > >+ /** >+ * Sets the default compiler compliance options based on the current default JRE in the workspace. >+ * >+ * @since 3.5 >+ */ > private void setDefaultCompilerComplianceValues() { > IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall(); > if (defaultVMInstall instanceof IVMInstall2) { >@@ -647,7 +890,7 @@ > JavaModelUtil.setComplianceOptions(complianceOptions, complianceLevel); > setDefaultValue(PREF_COMPLIANCE, (String)complianceOptions.get(PREF_COMPLIANCE.getName())); > setDefaultValue(PREF_PB_ASSERT_AS_IDENTIFIER, (String)complianceOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName())); >- setDefaultValue(PREF_PB_ENUM_AS_IDENTIFIER, (String)complianceOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName())); >+ setDefaultValue(PREF_PB_ENUM_AS_IDENTIFIER, (String)complianceOptions.get(PREF_PB_ENUM_AS_IDENTIFIER.getName())); > setDefaultValue(PREF_SOURCE_COMPATIBILITY, (String)complianceOptions.get(PREF_SOURCE_COMPATIBILITY.getName())); > setDefaultValue(PREF_CODEGEN_TARGET_PLATFORM, (String)complianceOptions.get(PREF_CODEGEN_TARGET_PLATFORM.getName())); > } >Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java,v >retrieving revision 1.114 >diff -u -r1.114 PreferencesMessages.java >--- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 24 Nov 2008 19:32:09 -0000 1.114 >+++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 14 Feb 2009 07:55:51 -0000 >@@ -500,6 +500,7 @@ > public static String ComplianceConfigurationBlock_codegen_targetplatform_label; > public static String ComplianceConfigurationBlock_pb_assert_as_identifier_label; > public static String ComplianceConfigurationBlock_pb_enum_as_identifier_label; >+ public static String ComplianceConfigurationBlock_compliance_follows_EE_label; > public static String ComplianceConfigurationBlock_compliance_group_label; > public static String ComplianceConfigurationBlock_classfiles_group_label; > public static String OptionsConfigurationBlock_job_title; >Index: ui/org/eclipse/jdt/internal/ui/preferences/CompliancePreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CompliancePreferencePage.java,v >retrieving revision 1.15 >diff -u -r1.15 CompliancePreferencePage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/CompliancePreferencePage.java 31 Dec 2008 21:13:12 -0000 1.15 >+++ ui/org/eclipse/jdt/internal/ui/preferences/CompliancePreferencePage.java 14 Feb 2009 07:55:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -110,6 +110,17 @@ > fConfigurationBlock.enablePreferenceContent(enable); > } > } >+ >+ /* >+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) >+ * @since 3.5 >+ */ >+ public void setVisible(boolean visible) { >+ super.setVisible(visible); >+ if (visible && fConfigurationBlock != null) { >+ fConfigurationBlock.refreshComplianceSettings(); >+ } >+ } > > /* > * @see org.eclipse.jface.preference.IPreferencePage#performDefaults() >Index: ui/org/eclipse/jdt/internal/ui/preferences/ClasspathContainerPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ClasspathContainerPreferencePage.java,v >retrieving revision 1.5 >diff -u -r1.5 ClasspathContainerPreferencePage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/ClasspathContainerPreferencePage.java 10 Oct 2007 09:33:57 -0000 1.5 >+++ ui/org/eclipse/jdt/internal/ui/preferences/ClasspathContainerPreferencePage.java 14 Feb 2009 07:55:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -14,6 +14,7 @@ > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; > > import org.eclipse.jface.dialogs.ProgressMonitorDialog; >@@ -28,9 +29,12 @@ > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.JavaModelException; > >+import org.eclipse.jdt.launching.JavaRuntime; >+ > import org.eclipse.jdt.internal.ui.actions.ActionMessages; > import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer; > import org.eclipse.jdt.internal.ui.util.ExceptionHandler; >+import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; > import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard; > > /** >@@ -84,7 +88,7 @@ > if (created == null || created.length != 1) > return; > >- IClasspathEntry result= created[0]; >+ final IClasspathEntry result= created[0]; > if (result == null || result.equals(fEntry)) > return; > >@@ -104,6 +108,13 @@ > context.run(true, true, new IRunnableWithProgress() { > public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { > try { >+ if (result.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { >+ IPath path= result.getPath(); >+ String eeID= JavaRuntime.getExecutionEnvironmentId(path); >+ if (eeID != null) { >+ BuildPathSupport.setEEComplianceOptions(fJavaProject, eeID, null); >+ } >+ } > fJavaProject.setRawClasspath(newEntries, fJavaProject.getOutputLocation(), monitor); > } catch (CoreException e) { > throw new InvocationTargetException(e); >Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java,v >retrieving revision 1.164 >diff -u -r1.164 BuildPathsBlock.java >--- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java 11 Sep 2008 11:59:19 -0000 1.164 >+++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,8 +12,11 @@ > > import java.net.URI; > import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Collections; > import java.util.Iterator; > import java.util.List; >+import java.util.Map; > > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; >@@ -71,8 +74,11 @@ > import org.eclipse.jdt.core.JavaConventions; > import org.eclipse.jdt.core.JavaCore; > >+import org.eclipse.jdt.internal.corext.util.JavaModelUtil; > import org.eclipse.jdt.internal.corext.util.Messages; > >+import org.eclipse.jdt.launching.JavaRuntime; >+ > import org.eclipse.jdt.ui.PreferenceConstants; > > import org.eclipse.jdt.internal.ui.JavaPlugin; >@@ -105,7 +111,7 @@ > * @param removeLocation true if the folder at oldOutputLocation should be removed, false if only its content > * @param oldOutputLocation The old output location > * @return Returns true if .class files should be removed. >- * @throws OperationCanceledException >+ * @throws OperationCanceledException if the operation was canceled > */ > boolean doQuery(boolean removeLocation, IPath oldOutputLocation) throws OperationCanceledException; > >@@ -302,12 +308,14 @@ > List newClassPath= null; > IProject project= fCurrJProject.getProject(); > projectExists= (project.exists() && project.getFile(".classpath").exists()); //$NON-NLS-1$ >+ IClasspathEntry[] existingEntries= null; > if (projectExists) { > if (outputLocation == null) { > outputLocation= fCurrJProject.readOutputLocation(); > } >+ existingEntries= fCurrJProject.readRawClasspath(); > if (classpathEntries == null) { >- classpathEntries= fCurrJProject.readRawClasspath(); >+ classpathEntries= existingEntries; > } > } > if (outputLocation == null) { >@@ -315,7 +323,7 @@ > } > > if (classpathEntries != null) { >- newClassPath= getExistingEntries(classpathEntries); >+ newClassPath= getCPListElements(classpathEntries, existingEntries); > } > if (newClassPath == null) { > newClassPath= getDefaultClassPath(jproject); >@@ -406,11 +414,12 @@ > fUserSettingsTimeStamp= getEncodedSettings(); > } > >- private ArrayList getExistingEntries(IClasspathEntry[] classpathEntries) { >+ private ArrayList getCPListElements(IClasspathEntry[] classpathEntries, IClasspathEntry[] existingEntries) { >+ List existing= existingEntries == null ? Collections.EMPTY_LIST : Arrays.asList(existingEntries); > ArrayList newClassPath= new ArrayList(); > for (int i= 0; i < classpathEntries.length; i++) { > IClasspathEntry curr= classpathEntries[i]; >- newClassPath.add(CPListElement.createFromExisting(curr, fCurrJProject)); >+ newClassPath.add(CPListElement.create(curr, ! existing.contains(curr), fCurrJProject)); > } > return newClassPath; > } >@@ -468,7 +477,7 @@ > list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE, srcFolder.getFullPath(), srcFolder)); > > IClasspathEntry[] jreEntries= PreferenceConstants.getDefaultJRELibrary(); >- list.addAll(getExistingEntries(jreEntries)); >+ list.addAll(getCPListElements(jreEntries, null)); > return list; > } > >@@ -719,18 +728,32 @@ > } > > public void configureJavaProject(IProgressMonitor monitor) throws CoreException, OperationCanceledException { >- >- flush(fClassPathList.getElements(), getOutputLocation(), getJavaProject(), monitor); >+ configureJavaProject(null, monitor); >+ } >+ >+ public void configureJavaProject(String newProjectCompliance, IProgressMonitor monitor) throws CoreException, OperationCanceledException { >+ flush(fClassPathList.getElements(), getOutputLocation(), getJavaProject(), newProjectCompliance, monitor); > initializeTimeStamps(); > > updateUI(); > } > >- /* >- * Creates the Java project and sets the configured build path and output location. >- * If the project already exists only build paths are updated. >+ /** >+ * Sets the configured build path and output location to the given Java project. >+ * If the project already exists, only build paths are updated. >+ * <p> >+ * If the classpath contains an Execution Environment entry, the EE's compiler compliance options >+ * are used as project-specific options (unless the classpath already contained the same Execution Environment) >+ * >+ * @param classPathEntries the new classpath entries (list of {@link CPListElement}) >+ * @param outputLocation the output location >+ * @param javaProject the Java project >+ * @param newProjectCompliance compliance to set for a new project, can be <code>null</code> >+ * @param monitor a progress monitor, or <code>null</code> >+ * @throws CoreException if flushing failed >+ * @throws OperationCanceledException if flushing has been cancelled > */ >- public static void flush(List classPathEntries, IPath outputLocation, IJavaProject javaProject, IProgressMonitor monitor) throws CoreException, OperationCanceledException { >+ public static void flush(List classPathEntries, IPath outputLocation, IJavaProject javaProject, String newProjectCompliance, IProgressMonitor monitor) throws CoreException, OperationCanceledException { > if (monitor == null) { > monitor= new NullProgressMonitor(); > } >@@ -862,6 +885,22 @@ > } > } > } else { >+ if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { >+ IPath path= entry.getPath(); >+ if (! path.equals(entry.getOrginalPath())) { >+ String eeID= JavaRuntime.getExecutionEnvironmentId(path); >+ if (eeID != null) { >+ BuildPathSupport.setEEComplianceOptions(javaProject, eeID, newProjectCompliance); >+ newProjectCompliance= null; // don't set it again below >+ } >+ } >+ if (newProjectCompliance != null) { >+ Map options= javaProject.getOptions(false); >+ JavaModelUtil.setComplianceOptions(options, newProjectCompliance); >+ JavaModelUtil.setDefaultClassfileOptions(options, newProjectCompliance); // complete compliance options >+ javaProject.setOptions(options); >+ } >+ } > monitor.worked(3); > } > if (monitor.isCanceled()) { >@@ -1002,13 +1041,29 @@ > } > > private CPListElement findElement(IClasspathEntry entry) { >+ CPListElement prefixMatch= null; >+ int entryKind= entry.getEntryKind(); > for (int i= 0, len= fClassPathList.getSize(); i < len; i++) { > CPListElement curr= (CPListElement) fClassPathList.getElement(i); >- if (curr.getEntryKind() == entry.getEntryKind() && curr.getPath().equals(entry.getPath())) { >- return curr; >+ if (curr.getEntryKind() == entryKind) { >+ IPath entryPath= entry.getPath(); >+ IPath currPath= curr.getPath(); >+ if (currPath.equals(entryPath)) { >+ return curr; >+ } >+ // in case there's no full match, look for a similar container (same ID segment): >+ if (prefixMatch == null && entryKind == IClasspathEntry.CPE_CONTAINER) { >+ int n= entryPath.segmentCount(); >+ if (n > 0) { >+ IPath genericContainerPath= n == 1 ? entryPath : entryPath.removeLastSegments(n - 1); >+ if (n > 1 && genericContainerPath.isPrefixOf(currPath)) { >+ prefixMatch= curr; >+ } >+ } >+ } > } > } >- return null; >+ return prefixMatch; > } > > public void setElementToReveal(IClasspathEntry entry, String attributeKey) { >@@ -1044,7 +1099,7 @@ > > Object page= fTabFolder.getItem(pageIndex).getData(); > if (page instanceof LibrariesWorkbookPage) { >- CPListElement element= CPListElement.createFromExisting(entry, fCurrJProject); >+ CPListElement element= CPListElement.create(entry, true, fCurrJProject); > ((LibrariesWorkbookPage) page).addElement(element); > } > } >Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java,v >retrieving revision 1.135 >diff -u -r1.135 LibrariesWorkbookPage.java >--- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java 2 Oct 2008 12:26:58 -0000 1.135 >+++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -868,14 +868,15 @@ > if (created != null) { > CPListElement[] res= new CPListElement[created.length]; > for (int i= 0; i < res.length; i++) { >- res[i]= CPListElement.createFromExisting(created[i], fCurrJProject); >+ res[i]= CPListElement.create(created[i], true, fCurrJProject); > } > return res; > } > } else { >- IClasspathEntry created= BuildPathDialogAccess.configureContainerEntry(getShell(), existing.getClasspathEntry(), fCurrJProject, getRawClasspath()); >+ IClasspathEntry existingEntry= existing.getClasspathEntry(); >+ IClasspathEntry created= BuildPathDialogAccess.configureContainerEntry(getShell(), existingEntry, fCurrJProject, getRawClasspath()); > if (created != null) { >- CPListElement elem= new CPListElement(fCurrJProject, IClasspathEntry.CPE_CONTAINER, created.getPath(), null); >+ CPListElement elem= new CPListElement(null, fCurrJProject, IClasspathEntry.CPE_CONTAINER, created.getPath(), ! created.equals(existingEntry), null, null); > return new CPListElement[] { elem }; > } > } >Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathWizard.java,v >retrieving revision 1.7 >diff -u -r1.7 BuildPathWizard.java >--- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathWizard.java 31 Dec 2008 21:13:23 -0000 1.7 >+++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathWizard.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -58,7 +58,7 @@ > if (fDoFlushChange) { > IJavaProject javaProject= getEntryToEdit().getJavaProject(); > >- BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, monitor); >+ BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, null, monitor); > > IProject project= javaProject.getProject(); > IPath path= getEntryToEdit().getPath(); >Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java,v >retrieving revision 1.23 >diff -u -r1.23 BuildPathSupport.java >--- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java 11 Sep 2008 11:59:19 -0000 1.23 >+++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,6 +11,10 @@ > package org.eclipse.jdt.internal.ui.wizards.buildpaths; > > import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; > > import org.eclipse.swt.widgets.Shell; > >@@ -33,8 +37,12 @@ > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; > >+import org.eclipse.jdt.internal.corext.util.JavaModelUtil; > import org.eclipse.jdt.internal.corext.util.Messages; > >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.environments.IExecutionEnvironment; >+ > import org.eclipse.jdt.ui.JavaUI; > > import org.eclipse.jdt.internal.ui.JavaPlugin; >@@ -46,6 +54,14 @@ > public class BuildPathSupport { > > public static final String JRE_PREF_PAGE_ID= "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; //$NON-NLS-1$ >+ public static final String EE_PREF_PAGE_ID= "org.eclipse.jdt.debug.ui.jreProfiles"; //$NON-NLS-1$ >+ >+ /* see also ComplianceConfigurationBlock#PREFS_COMPLIANCE */ >+ private static final String[] PREFS_COMPLIANCE= new String[] { >+ JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.COMPILER_PB_ENUM_IDENTIFIER, >+ JavaCore.COMPILER_SOURCE, JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, >+ JavaCore.COMPILER_COMPLIANCE >+ }; > > > private BuildPathSupport() { >@@ -173,11 +189,11 @@ > * Apply a modified classpath entry to the classpath. The classpath entry can also be from a classpath container. > * @param shell If not null and the entry could not be found on the projects classpath, a dialog will ask to put the entry on the classpath > * @param newEntry The modified entry. The entry's kind or path must be unchanged. >- * @param changedAttributes The attibutes that have changed. See {@link CPListElement} for constants values. >+ * @param changedAttributes The attributes that have changed. See {@link CPListElement} for constants values. > * @param jproject Project where the entry belongs to > * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container > * @param monitor The progress monitor to use >- * @throws CoreException >+ * @throws CoreException if the update failed > */ > public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, String[] changedAttributes, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException { > if (containerPath != null) { >@@ -195,7 +211,7 @@ > * @param jproject Project where the entry belongs to > * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container > * @param monitor The progress monitor to use >- * @throws CoreException >+ * @throws CoreException if the update failed > */ > public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException { > modifyClasspathEntry(shell, newEntry, null, jproject, containerPath, monitor); >@@ -236,9 +252,9 @@ > /** > * Request a container update. > * @param jproject The project of the container >- * @param container The container to requesta change to >+ * @param container The container to request a change to > * @param newEntries The updated entries >- * @throws CoreException >+ * @throws CoreException if the request failed > */ > public static void requestContainerUpdate(IJavaProject jproject, IClasspathContainer container, IClasspathEntry[] newEntries) throws CoreException { > IPath containerPath= container.getPath(); >@@ -292,4 +308,104 @@ > }); > return result[0]; > } >+ >+ /** >+ * Sets the default compiler compliance options iff <code>modifiedClassPathEntries</code> >+ * contains a classpath container entry that is modified or new and that points to an execution >+ * environment. Does nothing if the EE or the options could not be resolved. >+ * >+ * @param javaProject the Java project >+ * @param modifiedClassPathEntries a list of {@link CPListElement} >+ * >+ * @see #getEEOptions(IExecutionEnvironment) >+ * >+ * @since 3.5 >+ */ >+ public static void setEEComplianceOptions(IJavaProject javaProject, List modifiedClassPathEntries) { >+ for (Iterator iter= modifiedClassPathEntries.iterator(); iter.hasNext();) { >+ CPListElement entry= (CPListElement)iter.next(); >+ if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { >+ IPath path= entry.getPath(); >+ if (! path.equals(entry.getOrginalPath())) { >+ String eeID= JavaRuntime.getExecutionEnvironmentId(path); >+ if (eeID != null) { >+ setEEComplianceOptions(javaProject, eeID, null); >+ return; >+ } >+ } >+ } >+ } >+ } >+ >+ /** >+ * Sets the default compiler compliance options based on the given execution environment. >+ * Does nothing if the EE or the options could not be resolved. >+ * >+ * @param javaProject the Java project >+ * @param eeID the execution environment ID >+ * @param newProjectCompliance compliance to set for a new project, can be <code>null</code> >+ * >+ * @see #getEEOptions(IExecutionEnvironment) >+ * >+ * @since 3.5 >+ */ >+ public static void setEEComplianceOptions(IJavaProject javaProject, String eeID, String newProjectCompliance) { >+ IExecutionEnvironment ee= JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeID); >+ if (ee != null) { >+ Map options= javaProject.getOptions(false); >+ Map eeOptions= getEEOptions(ee); >+ if (eeOptions != null) { >+ for (int i= 0; i < PREFS_COMPLIANCE.length; i++) { >+ String option= PREFS_COMPLIANCE[i]; >+ options.put(option, eeOptions.get(option)); >+ } >+ >+ if (newProjectCompliance != null) { >+ JavaModelUtil.setDefaultClassfileOptions(options, newProjectCompliance); // complete compliance options >+ } >+ >+ String option= JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE; >+ String inlineJSR= (String)eeOptions.get(option); >+ if (inlineJSR != null) { >+ options.put(option, inlineJSR); >+ } >+ >+ javaProject.setOptions(options); >+ } >+ } >+ } >+ >+ /** >+ * Returns the compliance options from the given EE. If the result is not <code>null</code>, >+ * it contains at least these core options: >+ * <ul> >+ * <li>{@link JavaCore#COMPILER_COMPLIANCE}</li> >+ * <li>{@link JavaCore#COMPILER_SOURCE}</li> >+ * <li>{@link JavaCore#COMPILER_CODEGEN_TARGET_PLATFORM}</li> >+ * <li>{@link JavaCore#COMPILER_PB_ASSERT_IDENTIFIER}</li> >+ * <li>{@link JavaCore#COMPILER_PB_ENUM_IDENTIFIER}</li> >+ * <li>{@link JavaCore#COMPILER_CODEGEN_INLINE_JSR_BYTECODE} for compliance levels 1.5 and greater</li> >+ * </ul> >+ * >+ * @param ee the EE, can be <code>null</code> >+ * @return the options, or <code>null</code> if none >+ * @since 3.5 >+ */ >+ public static Map getEEOptions(IExecutionEnvironment ee) { >+ if (ee == null) >+ return null; >+ Map eeOptions= ee.getComplianceOptions(); >+ if (eeOptions == null) >+ return null; >+ >+ Object complianceOption= eeOptions.get(JavaCore.COMPILER_COMPLIANCE); >+ if (!(complianceOption instanceof String)) >+ return null; >+ >+ // eeOptions can miss some options, make sure they are complete: >+ HashMap options= new HashMap(); >+ JavaModelUtil.setComplianceOptions(options, (String)complianceOption); >+ options.putAll(eeOptions); >+ return options; >+ } > } >Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java,v >retrieving revision 1.78 >diff -u -r1.78 CPListElement.java >--- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java 16 Oct 2008 07:31:40 -0000 1.78 >+++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -85,11 +85,15 @@ > } > > public CPListElement(Object parent, IJavaProject project, int entryKind, IPath path, IResource res, IPath linkTarget) { >+ this(parent, project, entryKind, path, false, res, linkTarget); >+ } >+ >+ public CPListElement(Object parent, IJavaProject project, int entryKind, IPath path, boolean newElement, IResource res, IPath linkTarget) { > fProject= project; > > fEntryKind= entryKind; > fPath= path; >- fOrginalPath= path; >+ fOrginalPath= newElement ? null : path; > fLinkTarget= linkTarget; > fOrginalLinkTarget= linkTarget; > fChildren= new ArrayList(); >@@ -125,7 +129,7 @@ > IClasspathContainer container= JavaCore.getClasspathContainer(fPath, fProject); > if (container != null) { > IClasspathEntry[] entries= container.getClasspathEntries(); >- if (entries != null) { // invalid container implementation >+ if (entries != null) { // catch invalid container implementation > for (int i= 0; i < entries.length; i++) { > IClasspathEntry entry= entries[i]; > if (entry != null) { >@@ -541,10 +545,20 @@ > } > > public static CPListElement createFromExisting(IClasspathEntry curr, IJavaProject project) { >- return createFromExisting(null, curr, project); >+ //Note: Some old clients of this method could actually mean create(curr, true, project) >+ return create(curr, false, project); > } > > public static CPListElement createFromExisting(Object parent, IClasspathEntry curr, IJavaProject project) { >+ //Note: Some old clients of this method could actually mean create(parent, curr, true, project) >+ return create(parent, curr, false, project); >+ } >+ >+ public static CPListElement create(IClasspathEntry curr, boolean newElement, IJavaProject project) { >+ return create(null, curr, newElement, project); >+ } >+ >+ public static CPListElement create(Object parent, IClasspathEntry curr, boolean newElement, IJavaProject project) { > IPath path= curr.getPath(); > IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); > >@@ -603,7 +617,7 @@ > isMissing= (res == null); > break; > } >- CPListElement elem= new CPListElement(parent, project, curr.getEntryKind(), path, res, linkTarget); >+ CPListElement elem= new CPListElement(parent, project, curr.getEntryKind(), path, newElement, res, linkTarget); > elem.setExported(curr.isExported()); > elem.setAttribute(SOURCEATTACHMENT, curr.getSourceAttachmentPath()); > elem.setAttribute(OUTPUT, curr.getOutputLocation()); >Index: core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java,v >retrieving revision 1.148 >diff -u -r1.148 JavaModelUtil.java >--- core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java 11 Sep 2008 11:59:45 -0000 1.148 >+++ core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java 14 Feb 2009 07:55:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -662,7 +662,7 @@ > /** > * @param version1 the first version > * @param version2 the second version >- * @return returns if version 1 is less than version 2. >+ * @return <code>true</code> iff version1 is less than version2 > */ > public static boolean isVersionLessThan(String version1, String version2) { > if (JavaCore.VERSION_CLDC_1_1.equals(version1)) { >@@ -736,12 +736,22 @@ > } > > public static String getExecutionEnvironmentCompliance(IExecutionEnvironment executionEnvironment) { >+ Map complianceOptions= executionEnvironment.getComplianceOptions(); >+ if (complianceOptions != null) { >+ Object compliance= complianceOptions.get(JavaCore.COMPILER_COMPLIANCE); >+ if (compliance instanceof String) >+ return (String)compliance; >+ } >+ >+ // fallback: > String desc= executionEnvironment.getId(); >- if (desc.indexOf("1.6") != -1) { //$NON-NLS-1$ >+ if (desc.indexOf(JavaCore.VERSION_1_6) != -1) { >+ return JavaCore.VERSION_1_6; >+ } else if (desc.indexOf(JavaCore.VERSION_1_6) != -1) { > return JavaCore.VERSION_1_6; >- } else if (desc.indexOf("1.5") != -1) { //$NON-NLS-1$ >+ } else if (desc.indexOf(JavaCore.VERSION_1_5) != -1) { > return JavaCore.VERSION_1_5; >- } else if (desc.indexOf("1.4") != -1) { //$NON-NLS-1$ >+ } else if (desc.indexOf(JavaCore.VERSION_1_4) != -1) { > return JavaCore.VERSION_1_4; > } > return JavaCore.VERSION_1_3; >Index: ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/AddLibraryToBuildpathAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/AddLibraryToBuildpathAction.java,v >retrieving revision 1.14 >diff -u -r1.14 AddLibraryToBuildpathAction.java >--- ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/AddLibraryToBuildpathAction.java 11 Sep 2008 11:59:12 -0000 1.14 >+++ ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/AddLibraryToBuildpathAction.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -132,7 +132,7 @@ > > List addedEntries= new ArrayList(); > for (int i= 0; i < selected.length; i++) { >- addedEntries.add(CPListElement.createFromExisting(selected[i], project)); >+ addedEntries.add(CPListElement.create(selected[i], true, project)); > } > > pm.worked(1); >Index: ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageTwo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageTwo.java,v >retrieving revision 1.9 >diff -u -r1.9 NewJavaProjectWizardPageTwo.java >--- ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageTwo.java 11 Sep 2008 11:59:20 -0000 1.9 >+++ ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageTwo.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -24,7 +24,6 @@ > import java.util.HashSet; > import java.util.Iterator; > import java.util.List; >-import java.util.Map; > > import org.eclipse.core.filesystem.EFS; > import org.eclipse.core.filesystem.IFileInfo; >@@ -57,7 +56,6 @@ > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.JavaCore; > >-import org.eclipse.jdt.internal.corext.util.JavaModelUtil; > import org.eclipse.jdt.internal.corext.util.Messages; > > import org.eclipse.jdt.ui.JavaUI; >@@ -466,18 +464,9 @@ > if (fCurrProject == null) { > updateProject(new SubProgressMonitor(monitor, 1)); > } >- configureJavaProject(new SubProgressMonitor(monitor, 2)); >- >- if (!fKeepContent) { >- String compliance= fFirstPage.getCompilerCompliance(); >- if (compliance != null) { >- IJavaProject project= JavaCore.create(fCurrProject); >- Map options= project.getOptions(false); >- JavaModelUtil.setComplianceOptions(options, compliance); >- JavaModelUtil.setDefaultClassfileOptions(options, compliance); // complete compliance options >- project.setOptions(options); >- } >- } >+ String newProjectCompliance= fKeepContent ? null : fFirstPage.getCompilerCompliance(); >+ configureJavaProject(newProjectCompliance, new SubProgressMonitor(monitor, 2)); >+ > } finally { > monitor.done(); > fCurrProject= null; >Index: ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java,v >retrieving revision 1.15 >diff -u -r1.15 NewJavaProjectWizardPageOne.java >--- ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java 17 Nov 2008 15:26:57 -0000 1.15 >+++ ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -317,7 +317,7 @@ > /** > * Request a project layout. > */ >- private final class LayoutGroup implements Observer, SelectionListener, IDialogFieldListener { >+ private final class LayoutGroup implements Observer, SelectionListener { > > private final SelectionButtonDialogField fStdRadio, fSrcBinRadio; > private Group fGroup; >@@ -326,11 +326,9 @@ > public LayoutGroup() { > fStdRadio= new SelectionButtonDialogField(SWT.RADIO); > fStdRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_oneFolder); >- fStdRadio.setDialogFieldListener(this); > > fSrcBinRadio= new SelectionButtonDialogField(SWT.RADIO); > fSrcBinRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_separateFolders); >- fSrcBinRadio.setDialogFieldListener(this); > > boolean useSrcBin= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ); > fSrcBinRadio.setSelection(useSrcBin); >@@ -374,7 +372,7 @@ > fStdRadio.setEnabled(!detect); > fSrcBinRadio.setEnabled(!detect); > if (fPreferenceLink != null) { >- fPreferenceLink.setEnabled(!detect && fSrcBinRadio.isSelected()); >+ fPreferenceLink.setEnabled(!detect); > } > if (fGroup != null) { > fGroup.setEnabled(!detect); >@@ -406,22 +404,14 @@ > fDetectGroup.handlePossibleJVMChange(); > fJREGroup.handlePossibleJVMChange(); > } >- >- >- /* >- * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField) >- * @since 3.5 >- */ >- public void dialogFieldChanged(DialogField field) { >- updateEnableState(); >- } > } > > private final class JREGroup implements Observer, SelectionListener, IDialogFieldListener { > > private static final String LAST_SELECTED_EE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.execution.enviroment"; //$NON-NLS-1$ > private static final String LAST_SELECTED_JRE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.project.jre"; //$NON-NLS-1$ >- private static final String LAST_SELECTED_JRE_KIND= JavaUI.ID_PLUGIN + ".last.selected.jre.kind"; //$NON-NLS-1$ >+// private static final String LAST_SELECTED_JRE_KIND= JavaUI.ID_PLUGIN + ".last.selected.jre.kind"; // used before EE became default >+ private static final String LAST_SELECTED_JRE_KIND2= JavaUI.ID_PLUGIN + ".last.selected.jre.kind2"; //$NON-NLS-1$ > > private static final int DEFAULT_JRE= 0; > private static final int PROJECT_JRE= 1; >@@ -481,6 +471,14 @@ > fGroup.setLayout(initGridLayout(new GridLayout(2, false), true)); > fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_title); > >+ fUseEEJRE.doFillIntoGrid(fGroup, 1); >+ Combo eeComboControl= fEECombo.getComboControl(fGroup); >+ eeComboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); >+ >+ fUseProjectJRE.doFillIntoGrid(fGroup, 1); >+ Combo comboControl= fJRECombo.getComboControl(fGroup); >+ comboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); >+ > fUseDefaultJRE.doFillIntoGrid(fGroup, 1); > > fPreferenceLink= new Link(fGroup, SWT.NONE); >@@ -489,14 +487,6 @@ > fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); > fPreferenceLink.addSelectionListener(this); > >- fUseProjectJRE.doFillIntoGrid(fGroup, 1); >- Combo comboControl= fJRECombo.getComboControl(fGroup); >- comboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); >- >- fUseEEJRE.doFillIntoGrid(fGroup, 1); >- Combo eeComboControl= fEECombo.getComboControl(fGroup); >- eeComboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); >- > updateEnableState(); > return fGroup; > } >@@ -633,7 +623,7 @@ > return environments[i].getId(); > } > >- return "J2SE-1.5"; //$NON-NLS-1$ >+ return "J2SE-1.6"; //$NON-NLS-1$ > } > > private String getDefaultJVMLabel() { >@@ -652,7 +642,7 @@ > fJRECombo.setEnabled(!detect && fUseProjectJRE.isSelected()); > fEECombo.setEnabled(!detect && fUseEEJRE.isSelected()); > if (fPreferenceLink != null) { >- fPreferenceLink.setEnabled(!detect && fUseDefaultJRE.isSelected()); >+ fPreferenceLink.setEnabled(!detect); > } > if (fGroup != null) { > fGroup.setEnabled(!detect); >@@ -671,10 +661,11 @@ > */ > public void widgetDefaultSelected(SelectionEvent e) { > String jreID= BuildPathSupport.JRE_PREF_PAGE_ID; >+ String eeID= BuildPathSupport.EE_PREF_PAGE_ID; > String complianceId= CompliancePreferencePage.PREF_ID; > Map data= new HashMap(); > data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE); >- PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID, complianceId }, data).open(); >+ PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID, complianceId , eeID }, data).open(); > > handlePossibleJVMChange(); > fDetectGroup.handlePossibleJVMChange(); >@@ -702,19 +693,19 @@ > } > } else if (field == fUseDefaultJRE) { > if (fUseDefaultJRE.isSelected()) { >- JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND, DEFAULT_JRE); >+ JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND2, DEFAULT_JRE); > fUseProjectJRE.setSelection(false); > fUseEEJRE.setSelection(false); > } > } else if (field == fUseProjectJRE) { > if (fUseProjectJRE.isSelected()) { >- JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND, PROJECT_JRE); >+ JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND2, PROJECT_JRE); > fUseDefaultJRE.setSelection(false); > fUseEEJRE.setSelection(false); > } > } else if (field == fUseEEJRE) { > if (fUseEEJRE.isSelected()) { >- JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND, EE_JRE); >+ JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND2, EE_JRE); > fUseDefaultJRE.setSelection(false); > fUseProjectJRE.setSelection(false); > } >@@ -732,10 +723,10 @@ > > private int getLastSelectedJREKind() { > IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings(); >- if (settings.get(LAST_SELECTED_JRE_KIND) == null) >- return DEFAULT_JRE; >+ if (settings.get(LAST_SELECTED_JRE_KIND2) == null) >+ return EE_JRE; > >- return settings.getInt(LAST_SELECTED_JRE_KIND); >+ return settings.getInt(LAST_SELECTED_JRE_KIND2); > } > > private String getLastSelectedEE() { >@@ -962,11 +953,12 @@ > */ > public void widgetDefaultSelected(SelectionEvent e) { > String jreID= BuildPathSupport.JRE_PREF_PAGE_ID; >+ String eeID= BuildPathSupport.EE_PREF_PAGE_ID; > String complianceId= CompliancePreferencePage.PREF_ID; > Map data= new HashMap(); > data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE); > String id= "JRE".equals(e.text) ? jreID : complianceId; //$NON-NLS-1$ >- PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { jreID, complianceId }, data).open(); >+ PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { jreID, complianceId, eeID }, data).open(); > > fJREGroup.handlePossibleJVMChange(); > handlePossibleJVMChange(); >@@ -1324,18 +1316,11 @@ > * @return returns the default class path entries > */ > public IClasspathEntry[] getDefaultClasspathEntries() { >- IClasspathEntry[] defaultJRELibrary= PreferenceConstants.getDefaultJRELibrary(); >- String compliance= getCompilerCompliance(); >- IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER); >- if (compliance == null || defaultJRELibrary.length > 1 || !jreContainerPath.isPrefixOf(defaultJRELibrary[0].getPath())) { >- // use default >- return defaultJRELibrary; >- } > IPath newPath= fJREGroup.getJREContainerPath(); > if (newPath != null) { > return new IClasspathEntry[] { JavaCore.newContainerEntry(newPath) }; > } >- return defaultJRELibrary; >+ return PreferenceConstants.getDefaultJRELibrary(); > } > > /** >Index: ui/org/eclipse/jdt/ui/wizards/JavaCapabilityConfigurationPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/JavaCapabilityConfigurationPage.java,v >retrieving revision 1.41 >diff -u -r1.41 JavaCapabilityConfigurationPage.java >--- ui/org/eclipse/jdt/ui/wizards/JavaCapabilityConfigurationPage.java 31 Dec 2008 21:13:16 -0000 1.41 >+++ ui/org/eclipse/jdt/ui/wizards/JavaCapabilityConfigurationPage.java 14 Feb 2009 07:55:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -260,6 +260,20 @@ > * @throws InterruptedException Thrown when the operation has been canceled. > */ > public void configureJavaProject(IProgressMonitor monitor) throws CoreException, InterruptedException { >+ configureJavaProject(null, monitor); >+ } >+ >+ /** >+ * Adds the Java nature to the project (if not set yet) and configures the build classpath. >+ * >+ * @param newProjectCompliance compliance to set for a new project, can be <code>null</code> >+ * @param monitor a progress monitor to report progress or <code>null</code> if >+ * progress reporting is not desired >+ * @throws CoreException Thrown when the configuring the Java project failed. >+ * @throws InterruptedException Thrown when the operation has been canceled. >+ * @since 3.5 >+ */ >+ public void configureJavaProject(String newProjectCompliance, IProgressMonitor monitor) throws CoreException, InterruptedException { > if (monitor == null) { > monitor= new NullProgressMonitor(); > } >@@ -270,7 +284,7 @@ > try { > IProject project= getJavaProject().getProject(); > BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(monitor, 1)); >- getBuildPathsBlock().configureJavaProject(new SubProgressMonitor(monitor, 5)); >+ getBuildPathsBlock().configureJavaProject(newProjectCompliance, new SubProgressMonitor(monitor, 5)); > } catch (OperationCanceledException e) { > throw new InterruptedException(); > } finally { >Index: core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java,v >retrieving revision 1.51 >diff -u -r1.51 ClasspathModifier.java >--- core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java 11 Sep 2008 11:59:57 -0000 1.51 >+++ core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java 14 Feb 2009 07:55:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -57,6 +57,7 @@ > import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; > import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; > import org.eclipse.jdt.internal.ui.wizards.buildpaths.ArchiveFileFilter; >+import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; > import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; > import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElementAttribute; > import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.OutputFolderValidator; >@@ -1038,7 +1039,8 @@ > IJavaModelStatus status= JavaConventions.validateClasspath(project, entries, outputLocation); > if (!status.isOK()) > throw new JavaModelException(status); >- >+ >+ BuildPathSupport.setEEComplianceOptions(project, newEntries); > project.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2)); > } finally { > monitor.done(); >@@ -1052,14 +1054,17 @@ > monitor.beginTask("", 2); //$NON-NLS-1$ > > try { >- IClasspathEntry[] entries= convert(cpProject.getCPListElements()); >+ List cpListElements= cpProject.getCPListElements(); >+ IClasspathEntry[] entries= convert(cpListElements); > IPath outputLocation= cpProject.getDefaultOutputLocation(); > >- IJavaModelStatus status= JavaConventions.validateClasspath(cpProject.getJavaProject(), entries, outputLocation); >+ IJavaProject javaProject= cpProject.getJavaProject(); >+ IJavaModelStatus status= JavaConventions.validateClasspath(javaProject, entries, outputLocation); > if (!status.isOK()) > throw new JavaModelException(status); > >- cpProject.getJavaProject().setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2)); >+ BuildPathSupport.setEEComplianceOptions(javaProject, cpListElements); >+ javaProject.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2)); > } finally { > monitor.done(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 176516
: 125711