View | Details | Raw Unified | Return to bug 176516
Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties (-2 / +3 lines)
Lines 22-28 Link Here
22
BuildPathsPropertyPage_closed_project_message=Java information is not available for a closed project.
22
BuildPathsPropertyPage_closed_project_message=Java information is not available for a closed project.
23
23
24
BuildPathsPropertyPage_unsavedchanges_title=Setting Java Build Path
24
BuildPathsPropertyPage_unsavedchanges_title=Setting Java Build Path
25
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?
25
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?
26
BuildPathsPropertyPage_unsavedchanges_button_save=Apply
26
BuildPathsPropertyPage_unsavedchanges_button_save=Apply
27
BuildPathsPropertyPage_unsavedchanges_button_discard=Discard
27
BuildPathsPropertyPage_unsavedchanges_button_discard=Discard
28
BuildPathsPropertyPage_unsavedchanges_button_ignore=Apply Later
28
BuildPathsPropertyPage_unsavedchanges_button_ignore=Apply Later
Lines 553-558 Link Here
553
ComplianceConfigurationBlock_codegen_targetplatform_label=Ge&nerated .class files compatibility:
553
ComplianceConfigurationBlock_codegen_targetplatform_label=Ge&nerated .class files compatibility:
554
ComplianceConfigurationBlock_pb_assert_as_identifier_label=Disallow identifie&rs called 'assert':
554
ComplianceConfigurationBlock_pb_assert_as_identifier_label=Disallow identifie&rs called 'assert':
555
ComplianceConfigurationBlock_pb_enum_as_identifier_label=Disallo&w identifiers called 'enum':
555
ComplianceConfigurationBlock_pb_enum_as_identifier_label=Disallo&w identifiers called 'enum':
556
ComplianceConfigurationBlock_compliance_follows_EE_label=Use compliance from Execution Environment on the <a>Java Build Path</a>
556
ComplianceConfigurationBlock_compliance_group_label=JDK Compliance
557
ComplianceConfigurationBlock_compliance_group_label=JDK Compliance
557
ComplianceConfigurationBlock_classfiles_group_label=Classfile Generation
558
ComplianceConfigurationBlock_classfiles_group_label=Classfile Generation
558
ComplianceConfigurationBlock_classfile_greater_compliance=Classfile compatibility must be equal or less than compliance level.
559
ComplianceConfigurationBlock_classfile_greater_compliance=Classfile compatibility must be equal or less than compliance level.
Lines 560-566 Link Here
560
561
561
ComplianceConfigurationBlock_jrecompliance_info=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (currently {1}). <a href="1" >Configure...</a>
562
ComplianceConfigurationBlock_jrecompliance_info=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (currently {1}). <a href="1" >Configure...</a>
562
ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14=CLDC 1.1 requires source level 1.3 and compliance 1.4 or less
563
ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14=CLDC 1.1 requires source level 1.3 and compliance 1.4 or less
563
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>.
564
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>.
564
565
565
OptionsConfigurationBlock_job_title=Rebuilding
566
OptionsConfigurationBlock_job_title=Rebuilding
566
567
(-)ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java (-23 / +86 lines)
Lines 136-142 Link Here
136
	}
136
	}
137
137
138
	/**
138
	/**
139
	 * Key that is only managed locally ans not part of preference store.
139
	 * Key that is only managed locally and not part of preference store.
140
	 */
140
	 */
141
	private static class LocalKey extends Key {
141
	private static class LocalKey extends Key {
142
		private HashMap fValues;
142
		private HashMap fValues;
Lines 384-391 Link Here
384
384
385
		makeScrollableCompositeAware(checkBox);
385
		makeScrollableCompositeAware(checkBox);
386
386
387
		String currValue= getValue(key);
387
		updateCheckBox(checkBox);
388
		checkBox.setSelection(data.getSelection(currValue) == 0);
389
388
390
		fCheckBoxes.add(checkBox);
389
		fCheckBoxes.add(checkBox);
391
390
Lines 440-445 Link Here
440
					checkBox.setSelection(!checkBox.getSelection());
439
					checkBox.setSelection(!checkBox.getSelection());
441
					checkBox.setFocus();
440
					checkBox.setFocus();
442
					linkSelected[0]= false;
441
					linkSelected[0]= false;
442
					controlChanged(checkBox);
443
				}
443
				}
444
			}
444
			}
445
		});
445
		});
Lines 447-454 Link Here
447
		makeScrollableCompositeAware(link);
447
		makeScrollableCompositeAware(link);
448
		makeScrollableCompositeAware(checkBox);
448
		makeScrollableCompositeAware(checkBox);
449
449
450
		String currValue= getValue(key);
450
		updateCheckBox(checkBox);
451
		checkBox.setSelection(data.getSelection(currValue) == 0);
452
451
453
		fCheckBoxes.add(checkBox);
452
		fCheckBoxes.add(checkBox);
454
453
Lines 509-516 Link Here
509
508
510
		makeScrollableCompositeAware(comboBox);
509
		makeScrollableCompositeAware(comboBox);
511
510
512
		String currValue= getValue(key);
511
		updateCombo(comboBox);
513
		comboBox.select(data.getSelection(currValue));
514
512
515
		fComboBoxes.add(comboBox);
513
		fComboBoxes.add(comboBox);
516
		return comboBox;
514
		return comboBox;
Lines 530-539 Link Here
530
528
531
		fLabels.put(textBox, labelControl);
529
		fLabels.put(textBox, labelControl);
532
530
533
		String currValue= getValue(key);
531
		updateText(textBox);
534
		if (currValue != null) {
532
		
535
			textBox.setText(currValue);
536
		}
537
		textBox.addModifyListener(getTextModifyListener());
533
		textBox.addModifyListener(getTextModifyListener());
538
534
539
		GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
535
		GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
Lines 663-672 Link Here
663
		validateSettings(key, oldValue, number);
659
		validateSettings(key, oldValue, number);
664
	}
660
	}
665
661
662
	/**
663
	 * Checks a setting.
664
	 * 
665
	 * @param key a key
666
	 * @param value an assumed value for the key
667
	 * @return <code>true</code> iff the given key's value is equal to the given value
668
	 */
666
	protected boolean checkValue(Key key, String value) {
669
	protected boolean checkValue(Key key, String value) {
667
		return value.equals(getValue(key));
670
		return value.equals(getValue(key));
668
	}
671
	}
669
672
673
	/**
674
	 * Returns the value for the key.
675
	 * 
676
	 * @param key the key
677
	 * @return the stored value
678
	 */
670
	protected String getValue(Key key) {
679
	protected String getValue(Key key) {
671
		if (fDisabledProjectSettings != null) {
680
		if (fDisabledProjectSettings != null) {
672
			return (String) fDisabledProjectSettings.get(key);
681
			return (String) fDisabledProjectSettings.get(key);
Lines 679-684 Link Here
679
		return Boolean.valueOf(getValue(key)).booleanValue();
688
		return Boolean.valueOf(getValue(key)).booleanValue();
680
	}
689
	}
681
690
691
	/**
692
	 * Sets the option <code>key</code> to the value <code>value</code>.
693
	 * Note that callers have to make sure the corresponding controls are updated afterwards.
694
	 * 
695
	 * @param key the option key
696
	 * @param value the new value
697
	 * @return the old value
698
	 * 
699
	 * @see #updateControls()
700
	 * @see #updateCheckBox(Button)
701
	 * @see #updateCombo(Combo)
702
	 * @see #updateText(Text)
703
	 */
682
	protected String setValue(Key key, String value) {
704
	protected String setValue(Key key, String value) {
683
		if (fDisabledProjectSettings != null) {
705
		if (fDisabledProjectSettings != null) {
684
			return (String) fDisabledProjectSettings.put(key, value);
706
			return (String) fDisabledProjectSettings.put(key, value);
Lines 688-714 Link Here
688
		return oldValue;
710
		return oldValue;
689
	}
711
	}
690
712
713
	/**
714
	 * Sets the option <code>key</code> to the value <code>value</code>.
715
	 * Note that callers have to make sure the corresponding controls are updated afterwards.
716
	 * 
717
	 * @param key the option key
718
	 * @param value the new value
719
	 * @return the old value
720
	 * 
721
	 * @see #updateControls()
722
	 * @see #updateCheckBox(Button)
723
	 * @see #updateCombo(Combo)
724
	 * @see #updateText(Text)
725
	 */
691
	protected String setValue(Key key, boolean value) {
726
	protected String setValue(Key key, boolean value) {
692
		return setValue(key, String.valueOf(value));
727
		return setValue(key, String.valueOf(value));
693
	}
728
	}
694
729
695
	protected final void setDefaultValue(Key key, String value) {
730
	protected final void setDefaultValue(Key key, String value) {
696
		key.setStoredValue(fLookupOrder[fLookupOrder.length - 1], value, fManager);
731
		IScopeContext instanceScope= fLookupOrder[fLookupOrder.length - 1];
732
		key.setStoredValue(instanceScope, value, fManager);
697
	}
733
	}
698
734
699
	/**
735
	/**
700
	 * Returns the value as actually stored in the preference store.
736
	 * Returns the value as stored in the preference store.
701
	 *
737
	 *
702
	 * @param key the key
738
	 * @param key the key
703
	 * @return the value as actually stored in the preference store.
739
	 * @return the value
704
	 */
740
	 */
705
	protected String getStoredValue(Key key) {
741
	protected String getStoredValue(Key key) {
706
		return key.getStoredValue(fLookupOrder, false, fManager);
742
		return key.getStoredValue(fLookupOrder, false, fManager);
707
	}
743
	}
744
	
745
	/**
746
	 * Returns the value as actually stored in the preference store, without considering
747
	 * the working copy store.
748
	 *
749
	 * @param key the key
750
	 * @return the value as actually stored in the preference store
751
	 */
752
	protected String getOriginalStoredValue(Key key) {
753
		return key.getStoredValue(fLookupOrder, false, null);
754
	}
755
756
	/**
757
	 * Reverts the given options to the stored values.
758
	 * 
759
	 * @param keys the options to revert
760
	 * @since 3.5
761
	 */
762
	protected void revertValues(Key[] keys) {
763
		for (int i= 0; i < keys.length; i++) {
764
			Key curr= keys[i];
765
			String origValue= curr.getStoredValue(fLookupOrder, false, null);
766
			setValue(curr, origValue);
767
		}
768
	}
708
769
709
	/* (non-javadoc)
770
	/**
710
	 * Update fields and validate.
771
	 * Updates fields and validates settings.
711
	 * @param changedKey Key that changed, or null, if all changed.
772
	 * 
773
	 * @param changedKey key that changed, or <code>null</code>, if all changed.
774
	 * @param oldValue old value or <code>null</code>
775
	 * @param newValue new value or <code>null</code>
712
	 */
776
	 */
713
	protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
777
	protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
714
778
Lines 855-865 Link Here
855
	 * @since 3.1
919
	 * @since 3.1
856
	 */
920
	 */
857
	public void performRevert() {
921
	public void performRevert() {
858
		for (int i= 0; i < fAllKeys.length; i++) {
922
		revertValues(fAllKeys);
859
			Key curr= fAllKeys[i];
860
			String origValue= curr.getStoredValue(fLookupOrder, false, null);
861
			setValue(curr, origValue);
862
		}
863
923
864
		settingsUpdated();
924
		settingsUpdated();
865
		updateControls();
925
		updateControls();
Lines 869-876 Link Here
869
	public void dispose() {
929
	public void dispose() {
870
	}
930
	}
871
931
932
	/**
933
	 * Updates the UI from the current settings. Must be called whenever a setting has been changed
934
	 * by code.
935
	 */
872
	protected void updateControls() {
936
	protected void updateControls() {
873
		// update the UI
874
		for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
937
		for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
875
			updateCheckBox((Button) fCheckBoxes.get(i));
938
			updateCheckBox((Button) fCheckBoxes.get(i));
876
		}
939
		}
(-)ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java (-21 / +29 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 107-137 Link Here
107
		return pageSettings;
107
		return pageSettings;
108
	}
108
	}
109
109
110
	/*
111
	 * @see org.eclipse.jface.preference.PreferencePage#okToLeave()
112
	 * @since 3.5
113
	 */
114
	public boolean okToLeave() {
115
		if (fBuildPathsBlock != null && fBuildPathsBlock.hasChangesInDialog()) {
116
			String title= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_title;
117
			String message= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_message;
118
			String[] buttonLabels= new String[] {
119
					PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_save,
120
					PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_discard,
121
					PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_ignore
122
			};
123
			MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
124
			int res= dialog.open();
125
			if (res == 0) { //save
126
				fBlockOnApply= true;
127
				performOk();
128
			} else if (res == 1) { // discard
129
				fBuildPathsBlock.init(JavaCore.create(getProject()), null, null);
130
			} else {
131
				// keep unsaved
132
			}
133
		}
134
		return super.okToLeave();
135
	}
136
	
110
	/* (non-Javadoc)
137
	/* (non-Javadoc)
111
	 * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
138
	 * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
112
	 */
139
	 */
113
	public void setVisible(boolean visible) {
140
	public void setVisible(boolean visible) {
114
		if (fBuildPathsBlock != null) {
141
		if (fBuildPathsBlock != null) {
115
			if (!visible) {
142
			if (visible) {
116
				if (fBuildPathsBlock.hasChangesInDialog()) {
117
					String title= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_title;
118
					String message= PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_message;
119
					String[] buttonLabels= new String[] {
120
							PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_save,
121
							PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_discard,
122
							PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_ignore
123
					};
124
					MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
125
					int res= dialog.open();
126
					if (res == 0) {
127
						performOk();
128
					} else if (res == 1) {
129
						fBuildPathsBlock.init(JavaCore.create(getProject()), null, null);
130
					} else {
131
						// keep unsaved
132
					}
133
				}
134
			} else {
135
				if (!fBuildPathsBlock.hasChangesInDialog() && fBuildPathsBlock.hasChangesInClasspathFile()) {
143
				if (!fBuildPathsBlock.hasChangesInDialog() && fBuildPathsBlock.hasChangesInClasspathFile()) {
136
					fBuildPathsBlock.init(JavaCore.create(getProject()), null, null);
144
					fBuildPathsBlock.init(JavaCore.create(getProject()), null, null);
137
				}
145
				}
(-)ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java (-64 / +307 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-21 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Arrays;
14
import java.util.Arrays;
15
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.List;
16
import java.util.Map;
17
import java.util.Map;
17
18
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.events.SelectionAdapter;
19
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.events.SelectionEvent;
20
import org.eclipse.swt.events.SelectionListener;
22
import org.eclipse.swt.events.SelectionListener;
21
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.layout.GridData;
Lines 37-42 Link Here
37
import org.eclipse.ui.dialogs.PreferencesUtil;
39
import org.eclipse.ui.dialogs.PreferencesUtil;
38
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
40
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
39
41
42
import org.eclipse.jdt.core.IClasspathEntry;
40
import org.eclipse.jdt.core.JavaCore;
43
import org.eclipse.jdt.core.JavaCore;
41
44
42
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
45
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
Lines 45-50 Link Here
45
import org.eclipse.jdt.launching.IVMInstall;
48
import org.eclipse.jdt.launching.IVMInstall;
46
import org.eclipse.jdt.launching.IVMInstall2;
49
import org.eclipse.jdt.launching.IVMInstall2;
47
import org.eclipse.jdt.launching.JavaRuntime;
50
import org.eclipse.jdt.launching.JavaRuntime;
51
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
48
52
49
import org.eclipse.jdt.internal.ui.JavaPlugin;
53
import org.eclipse.jdt.internal.ui.JavaPlugin;
50
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
54
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
Lines 54-77 Link Here
54
import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport;
58
import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport;
55
59
56
/**
60
/**
57
  */
61
 * Configuration block for the 'Java Compiler' page.
62
 */
58
public class ComplianceConfigurationBlock extends OptionsConfigurationBlock {
63
public class ComplianceConfigurationBlock extends OptionsConfigurationBlock {
59
64
65
	/**
66
	 * Key for the "Compiler compliance follows EE" setting.
67
	 * <br>Only applicable if <code>fProject != null</code>. 
68
	 * <p>Values are { {@link #DEFAULT_CONF}, {@link #USER_CONF}, or {@link #DISABLED} }.
69
	 */
70
	private static final Key INTR_COMPLIANCE_FOLLOWS_EE= getLocalKey("internal.compliance.follows.ee"); //$NON-NLS-1$
71
	
72
	/**
73
	 * Key for the "Use default compliance" setting.
74
	 * <p>Values are { {@link #DEFAULT_CONF}, {@link #USER_CONF} }.
75
	 */
76
	private static final Key INTR_DEFAULT_COMPLIANCE= getLocalKey("internal.default.compliance"); //$NON-NLS-1$
77
	
60
	// Preference store keys, see JavaCore.getOptions
78
	// Preference store keys, see JavaCore.getOptions
79
	private static final Key PREF_PB_ASSERT_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER);
80
	private static final Key PREF_PB_ENUM_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ENUM_IDENTIFIER);
81
	private static final Key PREF_SOURCE_COMPATIBILITY= getJDTCoreKey(JavaCore.COMPILER_SOURCE);
82
	private static final Key PREF_CODEGEN_TARGET_PLATFORM= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM);
83
	private static final Key PREF_COMPLIANCE= getJDTCoreKey(JavaCore.COMPILER_COMPLIANCE);
84
	
85
	/* see also BuildPathSupport#PREFS_COMPLIANCE */
86
	private static final Key[] PREFS_COMPLIANCE= new Key[] { PREF_COMPLIANCE,
87
		PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_ENUM_AS_IDENTIFIER,
88
		PREF_SOURCE_COMPATIBILITY, PREF_CODEGEN_TARGET_PLATFORM };
89
	
90
	private static final Key PREF_CODEGEN_INLINE_JSR_BYTECODE= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE);
91
	
61
	private static final Key PREF_LOCAL_VARIABLE_ATTR=  getJDTCoreKey(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR);
92
	private static final Key PREF_LOCAL_VARIABLE_ATTR=  getJDTCoreKey(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR);
62
	private static final Key PREF_LINE_NUMBER_ATTR= getJDTCoreKey(JavaCore.COMPILER_LINE_NUMBER_ATTR);
93
	private static final Key PREF_LINE_NUMBER_ATTR= getJDTCoreKey(JavaCore.COMPILER_LINE_NUMBER_ATTR);
63
	private static final Key PREF_SOURCE_FILE_ATTR= getJDTCoreKey(JavaCore.COMPILER_SOURCE_FILE_ATTR);
94
	private static final Key PREF_SOURCE_FILE_ATTR= getJDTCoreKey(JavaCore.COMPILER_SOURCE_FILE_ATTR);
64
	private static final Key PREF_CODEGEN_UNUSED_LOCAL= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL);
95
	private static final Key PREF_CODEGEN_UNUSED_LOCAL= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL);
65
	private static final Key PREF_CODEGEN_TARGET_PLATFORM= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM);
96
	
66
	private static final Key PREF_CODEGEN_INLINE_JSR_BYTECODE= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE);
67
68
	private static final Key PREF_SOURCE_COMPATIBILITY= getJDTCoreKey(JavaCore.COMPILER_SOURCE);
69
	private static final Key PREF_COMPLIANCE= getJDTCoreKey(JavaCore.COMPILER_COMPLIANCE);
70
	private static final Key PREF_PB_ASSERT_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER);
71
	private static final Key PREF_PB_ENUM_AS_IDENTIFIER= getJDTCoreKey(JavaCore.COMPILER_PB_ENUM_IDENTIFIER);
72
73
	private static final Key INTR_DEFAULT_COMPLIANCE= getLocalKey("internal.default.compliance"); //$NON-NLS-1$
74
75
	// values
97
	// values
76
	private static final String GENERATE= JavaCore.GENERATE;
98
	private static final String GENERATE= JavaCore.GENERATE;
77
	private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE;
99
	private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE;
Lines 94-107 Link Here
94
	private static final String ENABLED= JavaCore.ENABLED;
116
	private static final String ENABLED= JavaCore.ENABLED;
95
	private static final String DISABLED= JavaCore.DISABLED;
117
	private static final String DISABLED= JavaCore.DISABLED;
96
118
97
98
	private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$
119
	private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$
99
	private static final String USER_CONF= "user";	 //$NON-NLS-1$
120
	private static final String USER_CONF= "user";	 //$NON-NLS-1$
100
121
122
	private ArrayList fComplianceFollowsEEControls;
101
	private ArrayList fComplianceControls;
123
	private ArrayList fComplianceControls;
124
	private ArrayList fComplianceChildControls;
102
	private PixelConverter fPixelConverter;
125
	private PixelConverter fPixelConverter;
103
126
127
	/**
128
	 * Remembered user compliance (stored when {@link #INTR_DEFAULT_COMPLIANCE} is switched to {@link #DEFAULT_CONF}).
129
	 * Elements are identified by <code>IDX_*</code> constants.
130
	 * @see #IDX_ASSERT_AS_IDENTIFIER
131
	 * @see #IDX_ENUM_AS_IDENTIFIER
132
	 * @see #IDX_SOURCE_COMPATIBILITY
133
	 * @see #IDX_CODEGEN_TARGET_PLATFORM
134
	 * @see #IDX_COMPLIANCE
135
	 * @see #IDX_INLINE_JSR_BYTECODE
136
	 */
104
	private String[] fRememberedUserCompliance;
137
	private String[] fRememberedUserCompliance;
138
	
139
	/**
140
	 * Stored compliance settings that were active when the page was first shown. May be <code>null</code>.
141
	 * Elements are identified by <code>IDX_*</code> constants.
142
	 * @see #IDX_ASSERT_AS_IDENTIFIER
143
	 * @see #IDX_ENUM_AS_IDENTIFIER
144
	 * @see #IDX_SOURCE_COMPATIBILITY
145
	 * @see #IDX_CODEGEN_TARGET_PLATFORM
146
	 * @see #IDX_COMPLIANCE
147
	 * @see #IDX_INLINE_JSR_BYTECODE
148
	 */
149
	private String[] fOriginalStoredCompliance;
105
150
106
	private static final int IDX_ASSERT_AS_IDENTIFIER= 0;
151
	private static final int IDX_ASSERT_AS_IDENTIFIER= 0;
107
	private static final int IDX_ENUM_AS_IDENTIFIER= 1;
152
	private static final int IDX_ENUM_AS_IDENTIFIER= 1;
Lines 117-127 Link Here
117
	private ControlEnableState fBlockEnableState;
162
	private ControlEnableState fBlockEnableState;
118
163
119
	public ComplianceConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
164
	public ComplianceConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
120
		super(context, project, getKeys(), container);
165
		super(context, project, getKeys(project != null), container);
121
		setDefaultCompilerComplianceValues();
166
		setDefaultCompilerComplianceValues();
122
167
123
		fBlockEnableState= null;
168
		fBlockEnableState= null;
169
		fComplianceFollowsEEControls= new ArrayList();
124
		fComplianceControls= new ArrayList();
170
		fComplianceControls= new ArrayList();
171
		fComplianceChildControls= new ArrayList();
125
172
126
		fComplianceStatus= new StatusInfo();
173
		fComplianceStatus= new StatusInfo();
127
174
Lines 135-146 Link Here
135
		};
182
		};
136
	}
183
	}
137
184
138
	private static Key[] getKeys() {
185
	private static Key[] getKeys(boolean projectSpecific) {
139
		return new Key[] {
186
		Key[] keys= new Key[] {
140
				PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL, PREF_CODEGEN_INLINE_JSR_BYTECODE, INTR_DEFAULT_COMPLIANCE,
187
				PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL, PREF_CODEGEN_INLINE_JSR_BYTECODE, INTR_DEFAULT_COMPLIANCE,
141
				PREF_COMPLIANCE, PREF_SOURCE_COMPATIBILITY,
188
				PREF_COMPLIANCE, PREF_SOURCE_COMPATIBILITY,
142
				PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_ENUM_AS_IDENTIFIER
189
				PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_ENUM_AS_IDENTIFIER
143
			};
190
			};
191
		
192
		if (projectSpecific) {
193
			Key[] allKeys = new Key[keys.length + 1];
194
			System.arraycopy(keys, 0, allKeys, 0, keys.length);
195
			allKeys[keys.length]= INTR_COMPLIANCE_FOLLOWS_EE;
196
			return allKeys;
197
		}
198
		
199
		return keys;
144
	}
200
	}
145
201
146
	/* (non-Javadoc)
202
	/* (non-Javadoc)
Lines 148-153 Link Here
148
	 */
204
	 */
149
	protected void settingsUpdated() {
205
	protected void settingsUpdated() {
150
		setValue(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance());
206
		setValue(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance());
207
		updateComplianceFollowsEE();
151
		super.settingsUpdated();
208
		super.settingsUpdated();
152
	}
209
	}
153
210
Lines 220-233 Link Here
220
		group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
277
		group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
221
		group.setLayout(layout);
278
		group.setLayout(layout);
222
279
280
		String[] defaultUserValues= new String[] { DEFAULT_CONF, USER_CONF };
281
		
282
		Control[] otherChildren= group.getChildren();
283
		if (fProject != null) {
284
			String label= PreferencesMessages.ComplianceConfigurationBlock_compliance_follows_EE_label;
285
			int widthHint= fPixelConverter.convertWidthInCharsToPixels(40);
286
			addCheckBoxWithLink(group, label, INTR_COMPLIANCE_FOLLOWS_EE, defaultUserValues, 0, widthHint, new SelectionAdapter() {
287
				public void widgetSelected(SelectionEvent e) {
288
					openBuildPathPropertyPage();
289
				}
290
			});
291
		}
292
		
293
		Control[] allChildren= group.getChildren();
294
		fComplianceFollowsEEControls.addAll(Arrays.asList(allChildren));
295
		fComplianceFollowsEEControls.removeAll(Arrays.asList(otherChildren));
296
		otherChildren= allChildren;
297
		
298
		
223
		String label= PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label;
299
		String label= PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label;
224
		addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0);
300
		addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0);
225
301
226
		label= PreferencesMessages.ComplianceConfigurationBlock_default_settings_label;
302
		label= PreferencesMessages.ComplianceConfigurationBlock_default_settings_label;
227
		addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String[] { DEFAULT_CONF, USER_CONF }, 0);
303
		addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0);
228
304
305
		allChildren= group.getChildren();
306
		fComplianceControls.addAll(Arrays.asList(allChildren));
307
		fComplianceControls.removeAll(Arrays.asList(otherChildren));
308
		otherChildren= allChildren;
309
		
310
		
229
		int indent= fPixelConverter.convertWidthInCharsToPixels(2);
311
		int indent= fPixelConverter.convertWidthInCharsToPixels(2);
230
		Control[] otherChildren= group.getChildren();
231
312
232
		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 };
313
		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 };
233
		String[] versionsLabels= new String[] {
314
		String[] versionsLabels= new String[] {
Lines 260-269 Link Here
260
		label= PreferencesMessages.ComplianceConfigurationBlock_pb_enum_as_identifier_label;
341
		label= PreferencesMessages.ComplianceConfigurationBlock_pb_enum_as_identifier_label;
261
		addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);
342
		addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);
262
343
263
344
		allChildren= group.getChildren();
264
		Control[] allChildren= group.getChildren();
345
		fComplianceChildControls.addAll(Arrays.asList(allChildren));
265
		fComplianceControls.addAll(Arrays.asList(allChildren));
346
		fComplianceChildControls.removeAll(Arrays.asList(otherChildren));
266
		fComplianceControls.removeAll(Arrays.asList(otherChildren));
347
		
267
348
268
		layout= new GridLayout();
349
		layout= new GridLayout();
269
		layout.numColumns= nColumns;
350
		layout.numColumns= nColumns;
Lines 300-306 Link Here
300
		fJRE50InfoText.addSelectionListener(new SelectionListener() {
381
		fJRE50InfoText.addSelectionListener(new SelectionListener() {
301
			public void widgetDefaultSelected(SelectionEvent e) {
382
			public void widgetDefaultSelected(SelectionEvent e) {
302
				if ("1".equals(e.text)) { //$NON-NLS-1$
383
				if ("1".equals(e.text)) { //$NON-NLS-1$
303
					openJREInstallPreferencePage();
384
					openJREInstallPreferencePage(false);
385
				} else if ("2".equals(e.text)) { //$NON-NLS-1$
386
					openJREInstallPreferencePage(true);
304
				} else {
387
				} else {
305
					openBuildPathPropertyPage();
388
					openBuildPathPropertyPage();
306
				}
389
				}
Lines 326-344 Link Here
326
		validateComplianceStatus();
409
		validateComplianceStatus();
327
	}
410
	}
328
411
329
	protected final void openJREInstallPreferencePage() {
412
	protected final void openJREInstallPreferencePage(boolean openEE) {
330
		String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
413
		String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
414
		String eeID= BuildPathSupport.EE_PREF_PAGE_ID;
415
		String pageId= openEE ? eeID : jreID;
331
		if (fProject == null && getPreferenceContainer() != null) {
416
		if (fProject == null && getPreferenceContainer() != null) {
332
			getPreferenceContainer().openPage(jreID, null);
417
			getPreferenceContainer().openPage(pageId, null);
333
		} else {
418
		} else {
334
			PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID }, null).open();
419
			PreferencesUtil.createPreferenceDialogOn(getShell(), pageId, new String[] { jreID, eeID }, null).open();
335
		}
420
		}
336
		validateComplianceStatus();
421
		validateComplianceStatus();
337
	}
422
	}
338
423
339
	/* (non-javadoc)
424
	/**
340
	 * Update fields and validate.
425
	 * {@inheritDoc}
341
	 * @param changedKey Key that changed, or null, if all changed.
342
	 */
426
	 */
343
	protected void validateSettings(Key changedKey, String oldValue, String newValue) {
427
	protected void validateSettings(Key changedKey, String oldValue, String newValue) {
344
		if (!areSettingsEnabled()) {
428
		if (!areSettingsEnabled()) {
Lines 349-365 Link Here
349
				updateComplianceEnableState();
433
				updateComplianceEnableState();
350
				updateComplianceDefaultSettings(true, null);
434
				updateComplianceDefaultSettings(true, null);
351
				fComplianceStatus= validateCompliance();
435
				fComplianceStatus= validateCompliance();
436
			} else if (INTR_COMPLIANCE_FOLLOWS_EE.equals(changedKey)) {
437
				setValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF);
438
				updateComplianceEnableState();
439
				updateComplianceDefaultSettings(true, null);
440
				updateControls();
441
				fComplianceStatus= validateCompliance();
442
				validateComplianceStatus();
352
			} else if (PREF_COMPLIANCE.equals(changedKey)) {
443
			} else if (PREF_COMPLIANCE.equals(changedKey)) {
353
			    // set compliance settings to default
444
			    // set compliance settings to default
354
			    Object oldDefault= getValue(INTR_DEFAULT_COMPLIANCE);
445
			    Object oldDefault= getValue(INTR_DEFAULT_COMPLIANCE);
355
				updateComplianceDefaultSettings(USER_CONF.equals(oldDefault), oldValue);
446
				boolean rememberOld= USER_CONF.equals(oldDefault);
447
				updateComplianceDefaultSettings(rememberOld, oldValue);
356
				fComplianceStatus= validateCompliance();
448
				fComplianceStatus= validateCompliance();
357
				validateComplianceStatus();
449
				validateComplianceStatus();
358
			} else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey)) {
450
			} else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey)) {
359
				updateAssertEnumAsIdentifierEnableState();
451
				updateAssertEnumAsIdentifierEnableState();
360
				fComplianceStatus= validateCompliance();
452
				fComplianceStatus= validateCompliance();
361
			} else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey)) {
453
			} else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey)) {
362
				updateInlineJSREnableState();
363
				if (VERSION_CLDC_1_1.equals(newValue) && !oldValue.equals(newValue)) {
454
				if (VERSION_CLDC_1_1.equals(newValue) && !oldValue.equals(newValue)) {
364
					String compliance= getValue(PREF_COMPLIANCE);
455
					String compliance= getValue(PREF_COMPLIANCE);
365
					String source= getValue(PREF_SOURCE_COMPATIBILITY);
456
					String source= getValue(PREF_SOURCE_COMPATIBILITY);
Lines 381-386 Link Here
381
				return;
472
				return;
382
			}
473
			}
383
		} else {
474
		} else {
475
			updateComplianceFollowsEE();
476
			updateControls();
384
			updateComplianceEnableState();
477
			updateComplianceEnableState();
385
			updateAssertEnumAsIdentifierEnableState();
478
			updateAssertEnumAsIdentifierEnableState();
386
			updateInlineJSREnableState();
479
			updateInlineJSREnableState();
Lines 389-396 Link Here
389
		}
482
		}
390
		fContext.statusChanged(fComplianceStatus);
483
		fContext.statusChanged(fComplianceStatus);
391
	}
484
	}
485
	
486
	public void refreshComplianceSettings() {
487
		if (fProject != null) {
488
			if (fOriginalStoredCompliance == null) {
489
				fOriginalStoredCompliance= new String[] { // caution: order depends on IDX_* constants
490
						getOriginalStoredValue(PREF_PB_ASSERT_AS_IDENTIFIER),
491
						getOriginalStoredValue(PREF_PB_ENUM_AS_IDENTIFIER),
492
						getOriginalStoredValue(PREF_SOURCE_COMPATIBILITY),
493
						getOriginalStoredValue(PREF_CODEGEN_TARGET_PLATFORM),
494
						getOriginalStoredValue(PREF_COMPLIANCE),
495
						getOriginalStoredValue(PREF_CODEGEN_INLINE_JSR_BYTECODE),
496
					};
497
				
498
			} else {
499
				String[] storedCompliance= new String[] {
500
						getOriginalStoredValue(PREF_PB_ASSERT_AS_IDENTIFIER),
501
						getOriginalStoredValue(PREF_PB_ENUM_AS_IDENTIFIER),
502
						getOriginalStoredValue(PREF_SOURCE_COMPATIBILITY),
503
						getOriginalStoredValue(PREF_CODEGEN_TARGET_PLATFORM),
504
						getOriginalStoredValue(PREF_COMPLIANCE),
505
						getOriginalStoredValue(PREF_CODEGEN_INLINE_JSR_BYTECODE),
506
					};
507
				if (!Arrays.equals(fOriginalStoredCompliance, storedCompliance)) {
508
					// compliance changed on disk -> override user modifications
509
					
510
					fOriginalStoredCompliance= storedCompliance;
511
					
512
					setValue(PREF_PB_ASSERT_AS_IDENTIFIER, storedCompliance[IDX_ASSERT_AS_IDENTIFIER]);
513
					setValue(PREF_PB_ENUM_AS_IDENTIFIER, storedCompliance[IDX_ENUM_AS_IDENTIFIER]);
514
					setValue(PREF_SOURCE_COMPATIBILITY, storedCompliance[IDX_SOURCE_COMPATIBILITY]);
515
					setValue(PREF_CODEGEN_TARGET_PLATFORM, storedCompliance[IDX_CODEGEN_TARGET_PLATFORM]);
516
					setValue(PREF_COMPLIANCE, storedCompliance[IDX_COMPLIANCE]);
517
					setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, storedCompliance[IDX_INLINE_JSR_BYTECODE]);
518
					
519
				}
520
				
521
				updateComplianceFollowsEE();
522
				updateControls();
523
				updateComplianceEnableState();
524
				validateComplianceStatus();
525
			}
526
		}			
527
	}
392
528
393
	private void validateComplianceStatus() {
529
	private void validateComplianceStatus() {
530
		//TODO: updated VM in .classpath is not resolved yet!
394
		if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) {
531
		if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) {
395
			boolean isVisible= false;
532
			boolean isVisible= false;
396
			String compliance= getStoredValue(PREF_COMPLIANCE); // get actual value
533
			String compliance= getStoredValue(PREF_COMPLIANCE); // get actual value
Lines 467-480 Link Here
467
		validateComplianceStatus();
604
		validateComplianceStatus();
468
	}
605
	}
469
606
470
	/*
607
	private void updateComplianceFollowsEE() {
471
	 * Update the compliance controls' enable state
608
		if (fProject != null) {
472
	 */
609
			String complianceFollowsEE= DISABLED;
610
			IExecutionEnvironment ee= getEE();
611
			if (ee != null) {
612
				complianceFollowsEE= getComplianceFollowsEE(ee);
613
			}
614
			setValue(INTR_COMPLIANCE_FOLLOWS_EE, complianceFollowsEE);
615
		}
616
	}
617
473
	private void updateComplianceEnableState() {
618
	private void updateComplianceEnableState() {
474
		boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF);
619
		boolean enableComplianceControls= true;
475
		for (int i= fComplianceControls.size() - 1; i >= 0; i--) {
620
		if (fProject != null) {
476
			Control curr= (Control) fComplianceControls.get(i);
621
			String complianceFollowsEE= getValue(INTR_COMPLIANCE_FOLLOWS_EE);
477
			curr.setEnabled(enabled);
622
			updateCheckBox(getCheckBox(INTR_COMPLIANCE_FOLLOWS_EE));
623
			boolean enableComplianceFollowsEE= ! DISABLED.equals(complianceFollowsEE); // is default or user
624
			updateControlsEnableState(fComplianceFollowsEEControls, enableComplianceFollowsEE);
625
		
626
			enableComplianceControls= ! DEFAULT_CONF.equals(complianceFollowsEE); // is disabled or user
627
			updateControlsEnableState(fComplianceControls, enableComplianceControls);
628
		}
629
		
630
		boolean enableComplianceChildren= enableComplianceControls && checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF);
631
		updateControlsEnableState(fComplianceChildControls, enableComplianceChildren);
632
	}
633
634
	private void updateControlsEnableState(List controls, boolean enable) {
635
		for (int i= controls.size() - 1; i >= 0; i--) {
636
			Control curr= (Control) controls.get(i);
637
			if (curr instanceof Composite) {
638
				updateControlsEnableState(Arrays.asList(((Composite)curr).getChildren()), enable);
639
			}
640
			curr.setEnabled(enable);
478
		}
641
		}
479
	}
642
	}
480
643
Lines 534-548 Link Here
534
		}
697
		}
535
	}
698
	}
536
699
537
	/*
700
	/**
538
	 * Set the default compliance values derived from the chosen level
701
	 * Sets the default compliance values derived from the chosen level or restores the user
702
	 * compliance settings.
703
	 * 
704
	 * @param rememberOld if <code>true</code>, the current compliance settings are remembered as
705
	 *            user settings. If <code>false</code>, overwrite the current settings.
706
	 * @param oldComplianceLevel the previous compliance level
539
	 */
707
	 */
540
	private void updateComplianceDefaultSettings(boolean rememberOld, String oldComplianceLevel) {
708
	private void updateComplianceDefaultSettings(boolean rememberOld, String oldComplianceLevel) {
541
		String assertAsId, enumAsId, source, target;
709
		String assertAsId, enumAsId, source, target;
542
		boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF);
710
		boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF);
711
		boolean isFollowEE= checkValue(INTR_COMPLIANCE_FOLLOWS_EE, DEFAULT_CONF);
543
		String complianceLevel= getValue(PREF_COMPLIANCE);
712
		String complianceLevel= getValue(PREF_COMPLIANCE);
544
713
545
		if (isDefault) {
714
		if (isDefault || isFollowEE) {
546
			if (rememberOld) {
715
			if (rememberOld) {
547
				if (oldComplianceLevel == null) {
716
				if (oldComplianceLevel == null) {
548
					oldComplianceLevel= complianceLevel;
717
					oldComplianceLevel= complianceLevel;
Lines 554-580 Link Here
554
				fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM]= getValue(PREF_CODEGEN_TARGET_PLATFORM);
723
				fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM]= getValue(PREF_CODEGEN_TARGET_PLATFORM);
555
				fRememberedUserCompliance[IDX_COMPLIANCE]= oldComplianceLevel;
724
				fRememberedUserCompliance[IDX_COMPLIANCE]= oldComplianceLevel;
556
			}
725
			}
557
726
			
558
			if (VERSION_1_4.equals(complianceLevel)) {
727
			if (isFollowEE) {
559
				assertAsId= WARNING;
728
				IExecutionEnvironment ee= getEE();
560
				enumAsId= WARNING;
729
				Map eeOptions= BuildPathSupport.getEEOptions(ee);
561
				source= VERSION_1_3;
730
				if (eeOptions == null)
562
				target= VERSION_1_2;
731
					return;
563
			} else if (VERSION_1_5.equals(complianceLevel)) {
732
				
564
				assertAsId= ERROR;
733
				assertAsId= (String)eeOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName());
565
				enumAsId= ERROR;
734
				enumAsId= (String)eeOptions.get(PREF_PB_ENUM_AS_IDENTIFIER.getName());
566
				source= VERSION_1_5;
735
				source= (String)eeOptions.get(PREF_SOURCE_COMPATIBILITY.getName());
567
				target= VERSION_1_5;
736
				target= (String)eeOptions.get(PREF_CODEGEN_TARGET_PLATFORM.getName());
568
			} else if (VERSION_1_6.equals(complianceLevel)) {
737
				
569
				assertAsId= ERROR;
738
				setValue(PREF_COMPLIANCE, (String)eeOptions.get(PREF_COMPLIANCE.getName()));
570
				enumAsId= ERROR;
739
				String inlineJSR= (String)eeOptions.get(PREF_CODEGEN_INLINE_JSR_BYTECODE.getName());
571
				source= VERSION_1_6;
740
				if (inlineJSR != null) {
572
				target= VERSION_1_6;
741
					setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, inlineJSR);
742
				}
743
				
573
			} else {
744
			} else {
574
				assertAsId= IGNORE;
745
				//TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel);
575
				enumAsId= IGNORE;
746
				if (VERSION_1_4.equals(complianceLevel)) {
576
				source= VERSION_1_3;
747
					assertAsId= WARNING;
577
				target= VERSION_1_1;
748
					enumAsId= WARNING;
749
					source= VERSION_1_3;
750
					target= VERSION_1_2;
751
				} else if (VERSION_1_5.equals(complianceLevel)) {
752
					assertAsId= ERROR;
753
					enumAsId= ERROR;
754
					source= VERSION_1_5;
755
					target= VERSION_1_5;
756
				} else if (VERSION_1_6.equals(complianceLevel)) {
757
					assertAsId= ERROR;
758
					enumAsId= ERROR;
759
					source= VERSION_1_6;
760
					target= VERSION_1_6;
761
				} else {
762
					assertAsId= IGNORE;
763
					enumAsId= IGNORE;
764
					source= VERSION_1_3;
765
					target= VERSION_1_1;
766
				}
578
			}
767
			}
579
		} else {
768
		} else {
580
			if (rememberOld && complianceLevel.equals(fRememberedUserCompliance[IDX_COMPLIANCE])) {
769
			if (rememberOld && complianceLevel.equals(fRememberedUserCompliance[IDX_COMPLIANCE])) {
Lines 597-607 Link Here
597
		updateAssertEnumAsIdentifierEnableState();
786
		updateAssertEnumAsIdentifierEnableState();
598
	}
787
	}
599
788
600
	/*
789
	/**
601
	 * Evaluate if the current compliance setting correspond to a default setting
790
	 * Evaluate if the current compliance setting correspond to a default setting.
791
	 * 
792
	 * @return {@link #DEFAULT_CONF} or {@link #USER_CONF}
602
	 */
793
	 */
603
	private String getCurrentCompliance() {
794
	private String getCurrentCompliance() {
604
		Object complianceLevel= getValue(PREF_COMPLIANCE);
795
		Object complianceLevel= getValue(PREF_COMPLIANCE);
796
		//TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel);
605
		if ((VERSION_1_3.equals(complianceLevel)
797
		if ((VERSION_1_3.equals(complianceLevel)
606
				&& IGNORE.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
798
				&& IGNORE.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
607
				&& IGNORE.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
799
				&& IGNORE.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
Lines 627-633 Link Here
627
		return USER_CONF;
819
		return USER_CONF;
628
	}
820
	}
629
821
822
	private IExecutionEnvironment getEE() {
823
		if (fProject == null)
824
			return null;
825
		
826
		try {
827
			IClasspathEntry[] entries= JavaCore.create(fProject).getRawClasspath();
828
			for (int i= 0; i < entries.length; i++) {
829
				IClasspathEntry entry= entries[i];
830
				if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
831
					String eeId= JavaRuntime.getExecutionEnvironmentId(entry.getPath());
832
					if (eeId != null) {
833
						return JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId);
834
					}
835
				}
836
			}
837
		} catch (CoreException e) {
838
			JavaPlugin.log(e);
839
		}
840
		return null;
841
	}
630
842
843
	/**
844
	 * Evaluate if the builds path contains an execution environment and the current compliance
845
	 * settings follow the EE options.
846
	 * 
847
	 * @param ee the EE, or <code>null</code> if none available
848
	 * @return {@link #DEFAULT_CONF} if the compliance follows the EE, or {@link #USER_CONF} if the
849
	 *         settings differ, or {@link #DISABLED} if there's no EE at all
850
	 */
851
	private String getComplianceFollowsEE(IExecutionEnvironment ee) {
852
		Map options= BuildPathSupport.getEEOptions(ee);
853
		if (options == null)
854
			return DISABLED;
855
		
856
		return checkDefaults(PREFS_COMPLIANCE, options);
857
	}
858
859
	private String checkDefaults(Key[] keys, Map options) {
860
		for (int i= 0; i < keys.length; i++) {
861
			Key key= keys[i];
862
			Object option= options.get(key.getName());
863
			if (!checkValue(key, (String)option))
864
				return USER_CONF;
865
		}
866
		return DEFAULT_CONF;
867
	}
868
	
631
	protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
869
	protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
632
		String title= PreferencesMessages.ComplianceConfigurationBlock_needsbuild_title;
870
		String title= PreferencesMessages.ComplianceConfigurationBlock_needsbuild_title;
633
		String message;
871
		String message;
Lines 639-644 Link Here
639
		return new String[] { title, message };
877
		return new String[] { title, message };
640
	}
878
	}
641
879
880
	/**
881
	 * Sets the default compiler compliance options based on the current default JRE in the workspace.
882
	 *  
883
	 * @since 3.5
884
	 */
642
	private void setDefaultCompilerComplianceValues() {
885
	private void setDefaultCompilerComplianceValues() {
643
		IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
886
		IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
644
		if (defaultVMInstall instanceof IVMInstall2) {
887
		if (defaultVMInstall instanceof IVMInstall2) {
Lines 647-653 Link Here
647
			JavaModelUtil.setComplianceOptions(complianceOptions, complianceLevel);
890
			JavaModelUtil.setComplianceOptions(complianceOptions, complianceLevel);
648
			setDefaultValue(PREF_COMPLIANCE, (String)complianceOptions.get(PREF_COMPLIANCE.getName()));
891
			setDefaultValue(PREF_COMPLIANCE, (String)complianceOptions.get(PREF_COMPLIANCE.getName()));
649
			setDefaultValue(PREF_PB_ASSERT_AS_IDENTIFIER, (String)complianceOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName()));
892
			setDefaultValue(PREF_PB_ASSERT_AS_IDENTIFIER, (String)complianceOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName()));
650
			setDefaultValue(PREF_PB_ENUM_AS_IDENTIFIER, (String)complianceOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName()));
893
			setDefaultValue(PREF_PB_ENUM_AS_IDENTIFIER, (String)complianceOptions.get(PREF_PB_ENUM_AS_IDENTIFIER.getName()));
651
			setDefaultValue(PREF_SOURCE_COMPATIBILITY, (String)complianceOptions.get(PREF_SOURCE_COMPATIBILITY.getName()));
894
			setDefaultValue(PREF_SOURCE_COMPATIBILITY, (String)complianceOptions.get(PREF_SOURCE_COMPATIBILITY.getName()));
652
			setDefaultValue(PREF_CODEGEN_TARGET_PLATFORM, (String)complianceOptions.get(PREF_CODEGEN_TARGET_PLATFORM.getName()));
895
			setDefaultValue(PREF_CODEGEN_TARGET_PLATFORM, (String)complianceOptions.get(PREF_CODEGEN_TARGET_PLATFORM.getName()));
653
		}
896
		}
(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java (+1 lines)
Lines 500-505 Link Here
500
	public static String ComplianceConfigurationBlock_codegen_targetplatform_label;
500
	public static String ComplianceConfigurationBlock_codegen_targetplatform_label;
501
	public static String ComplianceConfigurationBlock_pb_assert_as_identifier_label;
501
	public static String ComplianceConfigurationBlock_pb_assert_as_identifier_label;
502
	public static String ComplianceConfigurationBlock_pb_enum_as_identifier_label;
502
	public static String ComplianceConfigurationBlock_pb_enum_as_identifier_label;
503
	public static String ComplianceConfigurationBlock_compliance_follows_EE_label;
503
	public static String ComplianceConfigurationBlock_compliance_group_label;
504
	public static String ComplianceConfigurationBlock_compliance_group_label;
504
	public static String ComplianceConfigurationBlock_classfiles_group_label;
505
	public static String ComplianceConfigurationBlock_classfiles_group_label;
505
	public static String OptionsConfigurationBlock_job_title;
506
	public static String OptionsConfigurationBlock_job_title;
(-)ui/org/eclipse/jdt/internal/ui/preferences/CompliancePreferencePage.java (-1 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 110-115 Link Here
110
			fConfigurationBlock.enablePreferenceContent(enable);
110
			fConfigurationBlock.enablePreferenceContent(enable);
111
		}
111
		}
112
	}
112
	}
113
	
114
	/*
115
	 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
116
	 * @since 3.5
117
	 */
118
	public void setVisible(boolean visible) {
119
		super.setVisible(visible);
120
		if (visible && fConfigurationBlock != null) {
121
			fConfigurationBlock.refreshComplianceSettings();
122
		}
123
	}
113
124
114
	/*
125
	/*
115
	 * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
126
	 * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
(-)ui/org/eclipse/jdt/internal/ui/preferences/ClasspathContainerPreferencePage.java (-2 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
14
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.IAdaptable;
17
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IProgressMonitor;
18
19
19
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
20
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
Lines 28-36 Link Here
28
import org.eclipse.jdt.core.IJavaProject;
29
import org.eclipse.jdt.core.IJavaProject;
29
import org.eclipse.jdt.core.JavaModelException;
30
import org.eclipse.jdt.core.JavaModelException;
30
31
32
import org.eclipse.jdt.launching.JavaRuntime;
33
31
import org.eclipse.jdt.internal.ui.actions.ActionMessages;
34
import org.eclipse.jdt.internal.ui.actions.ActionMessages;
32
import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
35
import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
33
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
36
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
37
import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport;
34
import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard;
38
import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard;
35
39
36
/**
40
/**
Lines 84-90 Link Here
84
		if (created == null || created.length != 1)
88
		if (created == null || created.length != 1)
85
			return;
89
			return;
86
90
87
		IClasspathEntry result= created[0];
91
		final IClasspathEntry result= created[0];
88
		if (result == null || result.equals(fEntry))
92
		if (result == null || result.equals(fEntry))
89
			return;
93
			return;
90
94
Lines 104-109 Link Here
104
			context.run(true, true, new IRunnableWithProgress() {
108
			context.run(true, true, new IRunnableWithProgress() {
105
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
109
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
106
					try {
110
					try {
111
						if (result.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
112
							IPath path= result.getPath();
113
							String eeID= JavaRuntime.getExecutionEnvironmentId(path);
114
							if (eeID != null) {
115
								BuildPathSupport.setEEComplianceOptions(fJavaProject, eeID, null);
116
							}
117
						}
107
						fJavaProject.setRawClasspath(newEntries, fJavaProject.getOutputLocation(), monitor);
118
						fJavaProject.setRawClasspath(newEntries, fJavaProject.getOutputLocation(), monitor);
108
					} catch (CoreException e) {
119
					} catch (CoreException e) {
109
						throw new InvocationTargetException(e);
120
						throw new InvocationTargetException(e);
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java (-17 / +72 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-19 Link Here
12
12
13
import java.net.URI;
13
import java.net.URI;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.Collections;
15
import java.util.Iterator;
17
import java.util.Iterator;
16
import java.util.List;
18
import java.util.List;
19
import java.util.Map;
17
20
18
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.SelectionAdapter;
22
import org.eclipse.swt.events.SelectionAdapter;
Lines 71-78 Link Here
71
import org.eclipse.jdt.core.JavaConventions;
74
import org.eclipse.jdt.core.JavaConventions;
72
import org.eclipse.jdt.core.JavaCore;
75
import org.eclipse.jdt.core.JavaCore;
73
76
77
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
74
import org.eclipse.jdt.internal.corext.util.Messages;
78
import org.eclipse.jdt.internal.corext.util.Messages;
75
79
80
import org.eclipse.jdt.launching.JavaRuntime;
81
76
import org.eclipse.jdt.ui.PreferenceConstants;
82
import org.eclipse.jdt.ui.PreferenceConstants;
77
83
78
import org.eclipse.jdt.internal.ui.JavaPlugin;
84
import org.eclipse.jdt.internal.ui.JavaPlugin;
Lines 105-111 Link Here
105
		 * @param removeLocation true if the folder at oldOutputLocation should be removed, false if only its content
111
		 * @param removeLocation true if the folder at oldOutputLocation should be removed, false if only its content
106
		 * @param oldOutputLocation The old output location
112
		 * @param oldOutputLocation The old output location
107
		 * @return Returns true if .class files should be removed.
113
		 * @return Returns true if .class files should be removed.
108
		 * @throws OperationCanceledException
114
		 * @throws OperationCanceledException if the operation was canceled
109
		 */
115
		 */
110
		boolean doQuery(boolean removeLocation, IPath oldOutputLocation) throws OperationCanceledException;
116
		boolean doQuery(boolean removeLocation, IPath oldOutputLocation) throws OperationCanceledException;
111
117
Lines 302-313 Link Here
302
		List newClassPath= null;
308
		List newClassPath= null;
303
		IProject project= fCurrJProject.getProject();
309
		IProject project= fCurrJProject.getProject();
304
		projectExists= (project.exists() && project.getFile(".classpath").exists()); //$NON-NLS-1$
310
		projectExists= (project.exists() && project.getFile(".classpath").exists()); //$NON-NLS-1$
311
		IClasspathEntry[] existingEntries= null;
305
		if  (projectExists) {
312
		if  (projectExists) {
306
			if (outputLocation == null) {
313
			if (outputLocation == null) {
307
				outputLocation=  fCurrJProject.readOutputLocation();
314
				outputLocation=  fCurrJProject.readOutputLocation();
308
			}
315
			}
316
			existingEntries= fCurrJProject.readRawClasspath();
309
			if (classpathEntries == null) {
317
			if (classpathEntries == null) {
310
				classpathEntries=  fCurrJProject.readRawClasspath();
318
				classpathEntries= existingEntries;
311
			}
319
			}
312
		}
320
		}
313
		if (outputLocation == null) {
321
		if (outputLocation == null) {
Lines 315-321 Link Here
315
		}
323
		}
316
324
317
		if (classpathEntries != null) {
325
		if (classpathEntries != null) {
318
			newClassPath= getExistingEntries(classpathEntries);
326
			newClassPath= getCPListElements(classpathEntries, existingEntries);
319
		}
327
		}
320
		if (newClassPath == null) {
328
		if (newClassPath == null) {
321
			newClassPath= getDefaultClassPath(jproject);
329
			newClassPath= getDefaultClassPath(jproject);
Lines 406-416 Link Here
406
		fUserSettingsTimeStamp= getEncodedSettings();
414
		fUserSettingsTimeStamp= getEncodedSettings();
407
	}
415
	}
408
416
409
	private ArrayList getExistingEntries(IClasspathEntry[] classpathEntries) {
417
	private ArrayList getCPListElements(IClasspathEntry[] classpathEntries, IClasspathEntry[] existingEntries) {
418
		List existing= existingEntries == null ? Collections.EMPTY_LIST : Arrays.asList(existingEntries);
410
		ArrayList newClassPath= new ArrayList();
419
		ArrayList newClassPath= new ArrayList();
411
		for (int i= 0; i < classpathEntries.length; i++) {
420
		for (int i= 0; i < classpathEntries.length; i++) {
412
			IClasspathEntry curr= classpathEntries[i];
421
			IClasspathEntry curr= classpathEntries[i];
413
			newClassPath.add(CPListElement.createFromExisting(curr, fCurrJProject));
422
			newClassPath.add(CPListElement.create(curr, ! existing.contains(curr), fCurrJProject));
414
		}
423
		}
415
		return newClassPath;
424
		return newClassPath;
416
	}
425
	}
Lines 468-474 Link Here
468
		list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE, srcFolder.getFullPath(), srcFolder));
477
		list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE, srcFolder.getFullPath(), srcFolder));
469
478
470
		IClasspathEntry[] jreEntries= PreferenceConstants.getDefaultJRELibrary();
479
		IClasspathEntry[] jreEntries= PreferenceConstants.getDefaultJRELibrary();
471
		list.addAll(getExistingEntries(jreEntries));
480
		list.addAll(getCPListElements(jreEntries, null));
472
		return list;
481
		return list;
473
	}
482
	}
474
483
Lines 719-736 Link Here
719
	}
728
	}
720
729
721
	public void configureJavaProject(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
730
	public void configureJavaProject(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
722
731
		configureJavaProject(null, monitor);
723
		flush(fClassPathList.getElements(), getOutputLocation(), getJavaProject(), monitor);
732
	}
733
	
734
	public void configureJavaProject(String newProjectCompliance, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
735
		flush(fClassPathList.getElements(), getOutputLocation(), getJavaProject(), newProjectCompliance, monitor);
724
		initializeTimeStamps();
736
		initializeTimeStamps();
725
737
726
		updateUI();
738
		updateUI();
727
	}
739
	}
728
740
729
	/*
741
	/**
730
	 * Creates the Java project and sets the configured build path and output location.
742
	 * Sets the configured build path and output location to the given Java project.
731
	 * If the project already exists only build paths are updated.
743
	 * If the project already exists, only build paths are updated.
744
	 * <p>
745
	 * If the classpath contains an Execution Environment entry, the EE's compiler compliance options
746
	 * are used as project-specific options (unless the classpath already contained the same Execution Environment)
747
	 * 
748
	 * @param classPathEntries the new classpath entries (list of {@link CPListElement})
749
	 * @param outputLocation the output location
750
	 * @param javaProject the Java project 
751
	 * @param newProjectCompliance compliance to set for a new project, can be <code>null</code>
752
	 * @param monitor a progress monitor, or <code>null</code>
753
	 * @throws CoreException if flushing failed
754
	 * @throws OperationCanceledException if flushing has been cancelled
732
	 */
755
	 */
733
	public static void flush(List classPathEntries, IPath outputLocation, IJavaProject javaProject, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
756
	public static void flush(List classPathEntries, IPath outputLocation, IJavaProject javaProject, String newProjectCompliance, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
734
		if (monitor == null) {
757
		if (monitor == null) {
735
			monitor= new NullProgressMonitor();
758
			monitor= new NullProgressMonitor();
736
		}
759
		}
Lines 862-867 Link Here
862
						}
885
						}
863
					}
886
					}
864
				} else {
887
				} else {
888
					if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
889
						IPath path= entry.getPath();
890
						if (! path.equals(entry.getOrginalPath())) {
891
							String eeID= JavaRuntime.getExecutionEnvironmentId(path);
892
							if (eeID != null) {
893
								BuildPathSupport.setEEComplianceOptions(javaProject, eeID, newProjectCompliance);
894
								newProjectCompliance= null; // don't set it again below
895
							}
896
						}
897
						if (newProjectCompliance != null) {
898
							Map options= javaProject.getOptions(false);
899
							JavaModelUtil.setComplianceOptions(options, newProjectCompliance);
900
							JavaModelUtil.setDefaultClassfileOptions(options, newProjectCompliance); // complete compliance options
901
							javaProject.setOptions(options);
902
						}
903
					}
865
					monitor.worked(3);
904
					monitor.worked(3);
866
				}
905
				}
867
				if (monitor.isCanceled()) {
906
				if (monitor.isCanceled()) {
Lines 1002-1014 Link Here
1002
	}
1041
	}
1003
1042
1004
	private CPListElement findElement(IClasspathEntry entry) {
1043
	private CPListElement findElement(IClasspathEntry entry) {
1044
		CPListElement prefixMatch= null;
1045
		int entryKind= entry.getEntryKind();
1005
		for (int i= 0, len= fClassPathList.getSize(); i < len; i++) {
1046
		for (int i= 0, len= fClassPathList.getSize(); i < len; i++) {
1006
			CPListElement curr= (CPListElement) fClassPathList.getElement(i);
1047
			CPListElement curr= (CPListElement) fClassPathList.getElement(i);
1007
			if (curr.getEntryKind() == entry.getEntryKind() && curr.getPath().equals(entry.getPath())) {
1048
			if (curr.getEntryKind() == entryKind) {
1008
				return curr;
1049
				IPath entryPath= entry.getPath();
1050
				IPath currPath= curr.getPath();
1051
				if (currPath.equals(entryPath)) {
1052
					return curr;
1053
				}
1054
				// in case there's no full match, look for a similar container (same ID segment): 
1055
				if (prefixMatch == null && entryKind == IClasspathEntry.CPE_CONTAINER) {
1056
					int n= entryPath.segmentCount();
1057
					if (n > 0) {
1058
						IPath genericContainerPath= n == 1 ? entryPath : entryPath.removeLastSegments(n - 1);
1059
						if (n > 1 && genericContainerPath.isPrefixOf(currPath)) {
1060
							prefixMatch= curr;
1061
						}
1062
					}
1063
				}
1009
			}
1064
			}
1010
		}
1065
		}
1011
		return null;
1066
		return prefixMatch;
1012
	}
1067
	}
1013
1068
1014
	public void setElementToReveal(IClasspathEntry entry, String attributeKey) {
1069
	public void setElementToReveal(IClasspathEntry entry, String attributeKey) {
Lines 1044-1050 Link Here
1044
1099
1045
			Object page=  fTabFolder.getItem(pageIndex).getData();
1100
			Object page=  fTabFolder.getItem(pageIndex).getData();
1046
			if (page instanceof LibrariesWorkbookPage) {
1101
			if (page instanceof LibrariesWorkbookPage) {
1047
				CPListElement element= CPListElement.createFromExisting(entry, fCurrJProject);
1102
				CPListElement element= CPListElement.create(entry, true, fCurrJProject);
1048
				((LibrariesWorkbookPage) page).addElement(element);
1103
				((LibrariesWorkbookPage) page).addElement(element);
1049
			}
1104
			}
1050
		}
1105
		}
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java (-4 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 868-881 Link Here
868
			if (created != null) {
868
			if (created != null) {
869
				CPListElement[] res= new CPListElement[created.length];
869
				CPListElement[] res= new CPListElement[created.length];
870
				for (int i= 0; i < res.length; i++) {
870
				for (int i= 0; i < res.length; i++) {
871
					res[i]= CPListElement.createFromExisting(created[i], fCurrJProject);
871
					res[i]= CPListElement.create(created[i], true, fCurrJProject);
872
				}
872
				}
873
				return res;
873
				return res;
874
			}
874
			}
875
		} else {
875
		} else {
876
			IClasspathEntry created= BuildPathDialogAccess.configureContainerEntry(getShell(), existing.getClasspathEntry(), fCurrJProject, getRawClasspath());
876
			IClasspathEntry existingEntry= existing.getClasspathEntry();
877
			IClasspathEntry created= BuildPathDialogAccess.configureContainerEntry(getShell(), existingEntry, fCurrJProject, getRawClasspath());
877
			if (created != null) {
878
			if (created != null) {
878
				CPListElement elem= new CPListElement(fCurrJProject, IClasspathEntry.CPE_CONTAINER, created.getPath(), null);
879
				CPListElement elem= new CPListElement(null, fCurrJProject, IClasspathEntry.CPE_CONTAINER, created.getPath(), ! created.equals(existingEntry), null, null);
879
				return new CPListElement[] { elem };
880
				return new CPListElement[] { elem };
880
			}
881
			}
881
		}
882
		}
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathWizard.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 58-64 Link Here
58
		if (fDoFlushChange) {
58
		if (fDoFlushChange) {
59
			IJavaProject javaProject= getEntryToEdit().getJavaProject();
59
			IJavaProject javaProject= getEntryToEdit().getJavaProject();
60
60
61
			BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, monitor);
61
			BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, null, monitor);
62
62
63
			IProject project= javaProject.getProject();
63
			IProject project= javaProject.getProject();
64
			IPath path= getEntryToEdit().getPath();
64
			IPath path= getEntryToEdit().getPath();
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java (-6 / +122 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
11
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
12
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.List;
17
import java.util.Map;
14
18
15
import org.eclipse.swt.widgets.Shell;
19
import org.eclipse.swt.widgets.Shell;
16
20
Lines 33-40 Link Here
33
import org.eclipse.jdt.core.JavaCore;
37
import org.eclipse.jdt.core.JavaCore;
34
import org.eclipse.jdt.core.JavaModelException;
38
import org.eclipse.jdt.core.JavaModelException;
35
39
40
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
36
import org.eclipse.jdt.internal.corext.util.Messages;
41
import org.eclipse.jdt.internal.corext.util.Messages;
37
42
43
import org.eclipse.jdt.launching.JavaRuntime;
44
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
45
38
import org.eclipse.jdt.ui.JavaUI;
46
import org.eclipse.jdt.ui.JavaUI;
39
47
40
import org.eclipse.jdt.internal.ui.JavaPlugin;
48
import org.eclipse.jdt.internal.ui.JavaPlugin;
Lines 46-51 Link Here
46
public class BuildPathSupport {
54
public class BuildPathSupport {
47
55
48
	public static final String JRE_PREF_PAGE_ID= "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; //$NON-NLS-1$
56
	public static final String JRE_PREF_PAGE_ID= "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; //$NON-NLS-1$
57
	public static final String EE_PREF_PAGE_ID= "org.eclipse.jdt.debug.ui.jreProfiles"; //$NON-NLS-1$
58
	
59
	/* see also ComplianceConfigurationBlock#PREFS_COMPLIANCE */
60
	private static final String[] PREFS_COMPLIANCE= new String[] {
61
			JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.COMPILER_PB_ENUM_IDENTIFIER,
62
			JavaCore.COMPILER_SOURCE, JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM,
63
			JavaCore.COMPILER_COMPLIANCE
64
	};
49
65
50
66
51
	private BuildPathSupport() {
67
	private BuildPathSupport() {
Lines 173-183 Link Here
173
	 * Apply a modified classpath entry to the classpath. The classpath entry can also be from a classpath container.
189
	 * Apply a modified classpath entry to the classpath. The classpath entry can also be from a classpath container.
174
	 * @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
190
	 * @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
175
	 * @param newEntry The modified entry. The entry's kind or path must be unchanged.
191
	 * @param newEntry The modified entry. The entry's kind or path must be unchanged.
176
	 * @param changedAttributes The attibutes that have changed. See {@link CPListElement} for constants values.
192
	 * @param changedAttributes The attributes that have changed. See {@link CPListElement} for constants values.
177
	 * @param jproject Project where the entry belongs to
193
	 * @param jproject Project where the entry belongs to
178
	 * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container
194
	 * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container
179
	 * @param monitor The progress monitor to use
195
	 * @param monitor The progress monitor to use
180
	 * @throws CoreException
196
	 * @throws CoreException if the update failed
181
	 */
197
	 */
182
	public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, String[] changedAttributes, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException {
198
	public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, String[] changedAttributes, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException {
183
		if (containerPath != null) {
199
		if (containerPath != null) {
Lines 195-201 Link Here
195
	 * @param jproject Project where the entry belongs to
211
	 * @param jproject Project where the entry belongs to
196
	 * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container
212
	 * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container
197
	 * @param monitor The progress monitor to use
213
	 * @param monitor The progress monitor to use
198
	 * @throws CoreException
214
	 * @throws CoreException if the update failed
199
	 */
215
	 */
200
	public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException {
216
	public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException {
201
		modifyClasspathEntry(shell, newEntry, null, jproject, containerPath, monitor);
217
		modifyClasspathEntry(shell, newEntry, null, jproject, containerPath, monitor);
Lines 236-244 Link Here
236
	/**
252
	/**
237
	 * Request a container update.
253
	 * Request a container update.
238
	 * @param jproject The project of the container
254
	 * @param jproject The project of the container
239
	 * @param container The container to requesta  change to
255
	 * @param container The container to request a change to
240
	 * @param newEntries The updated entries
256
	 * @param newEntries The updated entries
241
	 * @throws CoreException
257
	 * @throws CoreException if the request failed
242
	 */
258
	 */
243
	public static void requestContainerUpdate(IJavaProject jproject, IClasspathContainer container, IClasspathEntry[] newEntries) throws CoreException {
259
	public static void requestContainerUpdate(IJavaProject jproject, IClasspathContainer container, IClasspathEntry[] newEntries) throws CoreException {
244
		IPath containerPath= container.getPath();
260
		IPath containerPath= container.getPath();
Lines 292-295 Link Here
292
		});
308
		});
293
		return result[0];
309
		return result[0];
294
	}
310
	}
311
312
	/**
313
	 * Sets the default compiler compliance options iff <code>modifiedClassPathEntries</code>
314
	 * contains a classpath container entry that is modified or new and that points to an execution
315
	 * environment. Does nothing if the EE or the options could not be resolved.
316
	 * 
317
	 * @param javaProject the Java project
318
	 * @param modifiedClassPathEntries a list of {@link CPListElement}
319
	 * 
320
	 * @see #getEEOptions(IExecutionEnvironment)
321
	 * 
322
	 * @since 3.5
323
	 */
324
	public static void setEEComplianceOptions(IJavaProject javaProject, List modifiedClassPathEntries) {
325
		for (Iterator iter= modifiedClassPathEntries.iterator(); iter.hasNext();) {
326
			CPListElement entry= (CPListElement)iter.next();
327
			if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
328
				IPath path= entry.getPath();
329
				if (! path.equals(entry.getOrginalPath())) {
330
					String eeID= JavaRuntime.getExecutionEnvironmentId(path);
331
					if (eeID != null) {
332
						setEEComplianceOptions(javaProject, eeID, null);
333
						return;
334
					}
335
				}
336
			}
337
		}
338
	}
339
340
	/**
341
	 * Sets the default compiler compliance options based on the given execution environment.
342
	 * Does nothing if the EE or the options could not be resolved.
343
	 * 
344
	 * @param javaProject the Java project
345
	 * @param eeID the execution environment ID
346
	 * @param newProjectCompliance compliance to set for a new project, can be <code>null</code>
347
	 * 
348
	 * @see #getEEOptions(IExecutionEnvironment)
349
	 * 
350
	 * @since 3.5
351
	 */
352
	public static void setEEComplianceOptions(IJavaProject javaProject, String eeID, String newProjectCompliance) {
353
		IExecutionEnvironment ee= JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeID);
354
		if (ee != null) {
355
			Map options= javaProject.getOptions(false);
356
			Map eeOptions= getEEOptions(ee);
357
			if (eeOptions != null) {
358
				for (int i= 0; i < PREFS_COMPLIANCE.length; i++) {
359
					String option= PREFS_COMPLIANCE[i];
360
					options.put(option, eeOptions.get(option));
361
				}
362
				
363
				if (newProjectCompliance != null) {
364
					JavaModelUtil.setDefaultClassfileOptions(options, newProjectCompliance); // complete compliance options
365
				}
366
				
367
				String option= JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE;
368
				String inlineJSR= (String)eeOptions.get(option);
369
				if (inlineJSR != null) {
370
					options.put(option, inlineJSR);
371
				}
372
				
373
				javaProject.setOptions(options);
374
			}
375
		}
376
	}
377
378
	/**
379
	 * Returns the compliance options from the given EE. If the result is not <code>null</code>,
380
	 * it contains at least these core options:
381
	 * <ul>
382
	 * <li>{@link JavaCore#COMPILER_COMPLIANCE}</li>
383
	 * <li>{@link JavaCore#COMPILER_SOURCE}</li>
384
	 * <li>{@link JavaCore#COMPILER_CODEGEN_TARGET_PLATFORM}</li>
385
	 * <li>{@link JavaCore#COMPILER_PB_ASSERT_IDENTIFIER}</li>
386
	 * <li>{@link JavaCore#COMPILER_PB_ENUM_IDENTIFIER}</li>
387
	 * <li>{@link JavaCore#COMPILER_CODEGEN_INLINE_JSR_BYTECODE} for compliance levels 1.5 and greater</li>
388
	 * </ul>
389
	 * 
390
	 * @param ee the EE, can be <code>null</code>
391
	 * @return the options, or <code>null</code> if none
392
	 * @since 3.5
393
	 */
394
	public static Map getEEOptions(IExecutionEnvironment ee) {
395
		if (ee == null)
396
			return null;
397
		Map eeOptions= ee.getComplianceOptions();
398
		if (eeOptions == null)
399
			return null;
400
		
401
		Object complianceOption= eeOptions.get(JavaCore.COMPILER_COMPLIANCE);
402
		if (!(complianceOption instanceof String))
403
			return null;
404
	
405
		// eeOptions can miss some options, make sure they are complete:
406
		HashMap options= new HashMap();
407
		JavaModelUtil.setComplianceOptions(options, (String)complianceOption);
408
		options.putAll(eeOptions);
409
		return options;
410
	}
295
}
411
}
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java (-5 / +19 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 85-95 Link Here
85
	}
85
	}
86
86
87
	public CPListElement(Object parent, IJavaProject project, int entryKind, IPath path, IResource res, IPath linkTarget) {
87
	public CPListElement(Object parent, IJavaProject project, int entryKind, IPath path, IResource res, IPath linkTarget) {
88
		this(parent, project, entryKind, path, false, res, linkTarget);
89
	}
90
	
91
	public CPListElement(Object parent, IJavaProject project, int entryKind, IPath path, boolean newElement, IResource res, IPath linkTarget) {
88
		fProject= project;
92
		fProject= project;
89
93
90
		fEntryKind= entryKind;
94
		fEntryKind= entryKind;
91
		fPath= path;
95
		fPath= path;
92
		fOrginalPath= path;
96
		fOrginalPath= newElement ? null : path;
93
		fLinkTarget= linkTarget;
97
		fLinkTarget= linkTarget;
94
		fOrginalLinkTarget= linkTarget;
98
		fOrginalLinkTarget= linkTarget;
95
		fChildren= new ArrayList();
99
		fChildren= new ArrayList();
Lines 125-131 Link Here
125
					IClasspathContainer container= JavaCore.getClasspathContainer(fPath, fProject);
129
					IClasspathContainer container= JavaCore.getClasspathContainer(fPath, fProject);
126
					if (container != null) {
130
					if (container != null) {
127
						IClasspathEntry[] entries= container.getClasspathEntries();
131
						IClasspathEntry[] entries= container.getClasspathEntries();
128
						if (entries != null) { // invalid container implementation
132
						if (entries != null) { // catch invalid container implementation
129
							for (int i= 0; i < entries.length; i++) {
133
							for (int i= 0; i < entries.length; i++) {
130
								IClasspathEntry entry= entries[i];
134
								IClasspathEntry entry= entries[i];
131
								if (entry != null) {
135
								if (entry != null) {
Lines 541-550 Link Here
541
	}
545
	}
542
546
543
	public static CPListElement createFromExisting(IClasspathEntry curr, IJavaProject project) {
547
	public static CPListElement createFromExisting(IClasspathEntry curr, IJavaProject project) {
544
		return createFromExisting(null, curr, project);
548
		//Note: Some old clients of this method could actually mean create(curr, true, project)
549
		return create(curr, false, project);
545
	}
550
	}
546
551
547
	public static CPListElement createFromExisting(Object parent, IClasspathEntry curr, IJavaProject project) {
552
	public static CPListElement createFromExisting(Object parent, IClasspathEntry curr, IJavaProject project) {
553
		//Note: Some old clients of this method could actually mean create(parent, curr, true, project)
554
		return create(parent, curr, false, project);
555
	}
556
	
557
	public static CPListElement create(IClasspathEntry curr, boolean newElement, IJavaProject project) {
558
		return create(null, curr, newElement, project);
559
	}
560
	
561
	public static CPListElement create(Object parent, IClasspathEntry curr, boolean newElement, IJavaProject project) {
548
		IPath path= curr.getPath();
562
		IPath path= curr.getPath();
549
		IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
563
		IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
550
564
Lines 603-609 Link Here
603
				isMissing= (res == null);
617
				isMissing= (res == null);
604
				break;
618
				break;
605
		}
619
		}
606
		CPListElement elem= new CPListElement(parent, project, curr.getEntryKind(), path, res, linkTarget);
620
		CPListElement elem= new CPListElement(parent, project, curr.getEntryKind(), path, newElement, res, linkTarget);
607
		elem.setExported(curr.isExported());
621
		elem.setExported(curr.isExported());
608
		elem.setAttribute(SOURCEATTACHMENT, curr.getSourceAttachmentPath());
622
		elem.setAttribute(SOURCEATTACHMENT, curr.getSourceAttachmentPath());
609
		elem.setAttribute(OUTPUT, curr.getOutputLocation());
623
		elem.setAttribute(OUTPUT, curr.getOutputLocation());
(-)core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java (-5 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 662-668 Link Here
662
	/**
662
	/**
663
	 * @param version1 the first version
663
	 * @param version1 the first version
664
	 * @param version2 the second version
664
	 * @param version2 the second version
665
	 * @return returns if version 1 is less than version 2.
665
	 * @return <code>true</code> iff version1 is less than version2
666
	 */
666
	 */
667
	public static boolean isVersionLessThan(String version1, String version2) {
667
	public static boolean isVersionLessThan(String version1, String version2) {
668
		if (JavaCore.VERSION_CLDC_1_1.equals(version1)) {
668
		if (JavaCore.VERSION_CLDC_1_1.equals(version1)) {
Lines 736-747 Link Here
736
	}
736
	}
737
737
738
	public static String getExecutionEnvironmentCompliance(IExecutionEnvironment executionEnvironment) {
738
	public static String getExecutionEnvironmentCompliance(IExecutionEnvironment executionEnvironment) {
739
		Map complianceOptions= executionEnvironment.getComplianceOptions();
740
		if (complianceOptions != null) {
741
			Object compliance= complianceOptions.get(JavaCore.COMPILER_COMPLIANCE);
742
			if (compliance instanceof String)
743
				return (String)compliance;
744
		}
745
		
746
		// fallback:
739
		String desc= executionEnvironment.getId();
747
		String desc= executionEnvironment.getId();
740
		if (desc.indexOf("1.6") != -1) { //$NON-NLS-1$
748
		if (desc.indexOf(JavaCore.VERSION_1_6) != -1) {
749
			return JavaCore.VERSION_1_6;
750
		} else if (desc.indexOf(JavaCore.VERSION_1_6) != -1) {
741
			return JavaCore.VERSION_1_6;
751
			return JavaCore.VERSION_1_6;
742
		} else if (desc.indexOf("1.5") != -1) { //$NON-NLS-1$
752
		} else if (desc.indexOf(JavaCore.VERSION_1_5) != -1) {
743
			return JavaCore.VERSION_1_5;
753
			return JavaCore.VERSION_1_5;
744
		} else if (desc.indexOf("1.4") != -1) { //$NON-NLS-1$
754
		} else if (desc.indexOf(JavaCore.VERSION_1_4) != -1) {
745
			return JavaCore.VERSION_1_4;
755
			return JavaCore.VERSION_1_4;
746
		}
756
		}
747
		return JavaCore.VERSION_1_3;
757
		return JavaCore.VERSION_1_3;
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/AddLibraryToBuildpathAction.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 132-138 Link Here
132
132
133
						List addedEntries= new ArrayList();
133
						List addedEntries= new ArrayList();
134
						for (int i= 0; i < selected.length; i++) {
134
						for (int i= 0; i < selected.length; i++) {
135
							addedEntries.add(CPListElement.createFromExisting(selected[i], project));
135
							addedEntries.add(CPListElement.create(selected[i], true, project));
136
						}
136
						}
137
137
138
						pm.worked(1);
138
						pm.worked(1);
(-)ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageTwo.java (-15 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-30 Link Here
24
import java.util.HashSet;
24
import java.util.HashSet;
25
import java.util.Iterator;
25
import java.util.Iterator;
26
import java.util.List;
26
import java.util.List;
27
import java.util.Map;
28
27
29
import org.eclipse.core.filesystem.EFS;
28
import org.eclipse.core.filesystem.EFS;
30
import org.eclipse.core.filesystem.IFileInfo;
29
import org.eclipse.core.filesystem.IFileInfo;
Lines 57-63 Link Here
57
import org.eclipse.jdt.core.IJavaProject;
56
import org.eclipse.jdt.core.IJavaProject;
58
import org.eclipse.jdt.core.JavaCore;
57
import org.eclipse.jdt.core.JavaCore;
59
58
60
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
61
import org.eclipse.jdt.internal.corext.util.Messages;
59
import org.eclipse.jdt.internal.corext.util.Messages;
62
60
63
import org.eclipse.jdt.ui.JavaUI;
61
import org.eclipse.jdt.ui.JavaUI;
Lines 466-483 Link Here
466
			if (fCurrProject == null) {
464
			if (fCurrProject == null) {
467
				updateProject(new SubProgressMonitor(monitor, 1));
465
				updateProject(new SubProgressMonitor(monitor, 1));
468
			}
466
			}
469
			configureJavaProject(new SubProgressMonitor(monitor, 2));
467
			String newProjectCompliance= fKeepContent ? null : fFirstPage.getCompilerCompliance();
470
468
			configureJavaProject(newProjectCompliance, new SubProgressMonitor(monitor, 2));
471
			if (!fKeepContent) {
469
			
472
				String compliance= fFirstPage.getCompilerCompliance();
473
				if (compliance != null) {
474
					IJavaProject project= JavaCore.create(fCurrProject);
475
					Map options= project.getOptions(false);
476
					JavaModelUtil.setComplianceOptions(options, compliance);
477
					JavaModelUtil.setDefaultClassfileOptions(options, compliance); // complete compliance options
478
					project.setOptions(options);
479
				}
480
			}
481
		} finally {
470
		} finally {
482
			monitor.done();
471
			monitor.done();
483
			fCurrProject= null;
472
			fCurrProject= null;
(-)ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java (-41 / +26 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 317-323 Link Here
317
	/**
317
	/**
318
	 * Request a project layout.
318
	 * Request a project layout.
319
	 */
319
	 */
320
	private final class LayoutGroup implements Observer, SelectionListener, IDialogFieldListener {
320
	private final class LayoutGroup implements Observer, SelectionListener {
321
321
322
		private final SelectionButtonDialogField fStdRadio, fSrcBinRadio;
322
		private final SelectionButtonDialogField fStdRadio, fSrcBinRadio;
323
		private Group fGroup;
323
		private Group fGroup;
Lines 326-336 Link Here
326
		public LayoutGroup() {
326
		public LayoutGroup() {
327
			fStdRadio= new SelectionButtonDialogField(SWT.RADIO);
327
			fStdRadio= new SelectionButtonDialogField(SWT.RADIO);
328
			fStdRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_oneFolder);
328
			fStdRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_oneFolder);
329
			fStdRadio.setDialogFieldListener(this);
330
329
331
			fSrcBinRadio= new SelectionButtonDialogField(SWT.RADIO);
330
			fSrcBinRadio= new SelectionButtonDialogField(SWT.RADIO);
332
			fSrcBinRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_separateFolders);
331
			fSrcBinRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_separateFolders);
333
			fSrcBinRadio.setDialogFieldListener(this);
334
332
335
			boolean useSrcBin= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ);
333
			boolean useSrcBin= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ);
336
			fSrcBinRadio.setSelection(useSrcBin);
334
			fSrcBinRadio.setSelection(useSrcBin);
Lines 374-380 Link Here
374
			fStdRadio.setEnabled(!detect);
372
			fStdRadio.setEnabled(!detect);
375
			fSrcBinRadio.setEnabled(!detect);
373
			fSrcBinRadio.setEnabled(!detect);
376
			if (fPreferenceLink != null) {
374
			if (fPreferenceLink != null) {
377
				fPreferenceLink.setEnabled(!detect && fSrcBinRadio.isSelected());
375
				fPreferenceLink.setEnabled(!detect);
378
			}
376
			}
379
			if (fGroup != null) {
377
			if (fGroup != null) {
380
				fGroup.setEnabled(!detect);
378
				fGroup.setEnabled(!detect);
Lines 406-427 Link Here
406
			fDetectGroup.handlePossibleJVMChange();
404
			fDetectGroup.handlePossibleJVMChange();
407
			fJREGroup.handlePossibleJVMChange();
405
			fJREGroup.handlePossibleJVMChange();
408
		}
406
		}
409
410
411
		/*
412
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
413
		 * @since 3.5
414
		 */
415
		public void dialogFieldChanged(DialogField field) {
416
			updateEnableState();
417
		}
418
	}
407
	}
419
408
420
	private final class JREGroup implements Observer, SelectionListener, IDialogFieldListener {
409
	private final class JREGroup implements Observer, SelectionListener, IDialogFieldListener {
421
410
422
		private static final String LAST_SELECTED_EE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.execution.enviroment"; //$NON-NLS-1$
411
		private static final String LAST_SELECTED_EE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.execution.enviroment"; //$NON-NLS-1$
423
		private static final String LAST_SELECTED_JRE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.project.jre"; //$NON-NLS-1$
412
		private static final String LAST_SELECTED_JRE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.project.jre"; //$NON-NLS-1$
424
		private static final String LAST_SELECTED_JRE_KIND= JavaUI.ID_PLUGIN + ".last.selected.jre.kind"; //$NON-NLS-1$
413
//		private static final String LAST_SELECTED_JRE_KIND= JavaUI.ID_PLUGIN + ".last.selected.jre.kind"; // used before EE became default
414
		private static final String LAST_SELECTED_JRE_KIND2= JavaUI.ID_PLUGIN + ".last.selected.jre.kind2"; //$NON-NLS-1$
425
415
426
		private static final int DEFAULT_JRE= 0;
416
		private static final int DEFAULT_JRE= 0;
427
		private static final int PROJECT_JRE= 1;
417
		private static final int PROJECT_JRE= 1;
Lines 481-486 Link Here
481
			fGroup.setLayout(initGridLayout(new GridLayout(2, false), true));
471
			fGroup.setLayout(initGridLayout(new GridLayout(2, false), true));
482
			fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_title);
472
			fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_title);
483
473
474
			fUseEEJRE.doFillIntoGrid(fGroup, 1);
475
			Combo eeComboControl= fEECombo.getComboControl(fGroup);
476
			eeComboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
477
			
478
			fUseProjectJRE.doFillIntoGrid(fGroup, 1);
479
			Combo comboControl= fJRECombo.getComboControl(fGroup);
480
			comboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
481
484
			fUseDefaultJRE.doFillIntoGrid(fGroup, 1);
482
			fUseDefaultJRE.doFillIntoGrid(fGroup, 1);
485
483
486
			fPreferenceLink= new Link(fGroup, SWT.NONE);
484
			fPreferenceLink= new Link(fGroup, SWT.NONE);
Lines 489-502 Link Here
489
			fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
487
			fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
490
			fPreferenceLink.addSelectionListener(this);
488
			fPreferenceLink.addSelectionListener(this);
491
489
492
			fUseProjectJRE.doFillIntoGrid(fGroup, 1);
493
			Combo comboControl= fJRECombo.getComboControl(fGroup);
494
			comboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
495
496
			fUseEEJRE.doFillIntoGrid(fGroup, 1);
497
			Combo eeComboControl= fEECombo.getComboControl(fGroup);
498
			eeComboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
499
500
			updateEnableState();
490
			updateEnableState();
501
			return fGroup;
491
			return fGroup;
502
		}
492
		}
Lines 633-639 Link Here
633
					return environments[i].getId();
623
					return environments[i].getId();
634
			}
624
			}
635
625
636
			return "J2SE-1.5"; //$NON-NLS-1$
626
			return "J2SE-1.6"; //$NON-NLS-1$
637
		}
627
		}
638
628
639
		private String getDefaultJVMLabel() {
629
		private String getDefaultJVMLabel() {
Lines 652-658 Link Here
652
			fJRECombo.setEnabled(!detect && fUseProjectJRE.isSelected());
642
			fJRECombo.setEnabled(!detect && fUseProjectJRE.isSelected());
653
			fEECombo.setEnabled(!detect && fUseEEJRE.isSelected());
643
			fEECombo.setEnabled(!detect && fUseEEJRE.isSelected());
654
			if (fPreferenceLink != null) {
644
			if (fPreferenceLink != null) {
655
				fPreferenceLink.setEnabled(!detect && fUseDefaultJRE.isSelected());
645
				fPreferenceLink.setEnabled(!detect);
656
			}
646
			}
657
			if (fGroup != null) {
647
			if (fGroup != null) {
658
				fGroup.setEnabled(!detect);
648
				fGroup.setEnabled(!detect);
Lines 671-680 Link Here
671
		 */
661
		 */
672
		public void widgetDefaultSelected(SelectionEvent e) {
662
		public void widgetDefaultSelected(SelectionEvent e) {
673
			String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
663
			String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
664
			String eeID= BuildPathSupport.EE_PREF_PAGE_ID;
674
			String complianceId= CompliancePreferencePage.PREF_ID;
665
			String complianceId= CompliancePreferencePage.PREF_ID;
675
			Map data= new HashMap();
666
			Map data= new HashMap();
676
			data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
667
			data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
677
			PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID, complianceId  }, data).open();
668
			PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID, complianceId , eeID }, data).open();
678
669
679
			handlePossibleJVMChange();
670
			handlePossibleJVMChange();
680
			fDetectGroup.handlePossibleJVMChange();
671
			fDetectGroup.handlePossibleJVMChange();
Lines 702-720 Link Here
702
				}
693
				}
703
			} else if (field == fUseDefaultJRE) {
694
			} else if (field == fUseDefaultJRE) {
704
				if (fUseDefaultJRE.isSelected()) {
695
				if (fUseDefaultJRE.isSelected()) {
705
					JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND, DEFAULT_JRE);
696
					JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND2, DEFAULT_JRE);
706
					fUseProjectJRE.setSelection(false);
697
					fUseProjectJRE.setSelection(false);
707
					fUseEEJRE.setSelection(false);
698
					fUseEEJRE.setSelection(false);
708
				}
699
				}
709
			} else if (field == fUseProjectJRE) {
700
			} else if (field == fUseProjectJRE) {
710
				if (fUseProjectJRE.isSelected()) {
701
				if (fUseProjectJRE.isSelected()) {
711
					JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND, PROJECT_JRE);
702
					JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND2, PROJECT_JRE);
712
					fUseDefaultJRE.setSelection(false);
703
					fUseDefaultJRE.setSelection(false);
713
					fUseEEJRE.setSelection(false);
704
					fUseEEJRE.setSelection(false);
714
				}
705
				}
715
			} else if (field == fUseEEJRE) {
706
			} else if (field == fUseEEJRE) {
716
				if (fUseEEJRE.isSelected()) {
707
				if (fUseEEJRE.isSelected()) {
717
					JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND, EE_JRE);
708
					JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND2, EE_JRE);
718
					fUseDefaultJRE.setSelection(false);
709
					fUseDefaultJRE.setSelection(false);
719
					fUseProjectJRE.setSelection(false);
710
					fUseProjectJRE.setSelection(false);
720
				}
711
				}
Lines 732-741 Link Here
732
723
733
		private int getLastSelectedJREKind() {
724
		private int getLastSelectedJREKind() {
734
			IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
725
			IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
735
			if (settings.get(LAST_SELECTED_JRE_KIND) == null)
726
			if (settings.get(LAST_SELECTED_JRE_KIND2) == null)
736
				return DEFAULT_JRE;
727
				return EE_JRE;
737
728
738
			return settings.getInt(LAST_SELECTED_JRE_KIND);
729
			return settings.getInt(LAST_SELECTED_JRE_KIND2);
739
		}
730
		}
740
731
741
		private String getLastSelectedEE() {
732
		private String getLastSelectedEE() {
Lines 962-972 Link Here
962
		 */
953
		 */
963
		public void widgetDefaultSelected(SelectionEvent e) {
954
		public void widgetDefaultSelected(SelectionEvent e) {
964
			String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
955
			String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
956
			String eeID= BuildPathSupport.EE_PREF_PAGE_ID;
965
			String complianceId= CompliancePreferencePage.PREF_ID;
957
			String complianceId= CompliancePreferencePage.PREF_ID;
966
			Map data= new HashMap();
958
			Map data= new HashMap();
967
			data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
959
			data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
968
			String id= "JRE".equals(e.text) ? jreID : complianceId; //$NON-NLS-1$
960
			String id= "JRE".equals(e.text) ? jreID : complianceId; //$NON-NLS-1$
969
			PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { jreID, complianceId  }, data).open();
961
			PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { jreID, complianceId, eeID  }, data).open();
970
962
971
			fJREGroup.handlePossibleJVMChange();
963
			fJREGroup.handlePossibleJVMChange();
972
			handlePossibleJVMChange();
964
			handlePossibleJVMChange();
Lines 1324-1341 Link Here
1324
	 * @return returns the default class path entries
1316
	 * @return returns the default class path entries
1325
	 */
1317
	 */
1326
	public IClasspathEntry[] getDefaultClasspathEntries() {
1318
	public IClasspathEntry[] getDefaultClasspathEntries() {
1327
		IClasspathEntry[] defaultJRELibrary= PreferenceConstants.getDefaultJRELibrary();
1328
		String compliance= getCompilerCompliance();
1329
		IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER);
1330
		if (compliance == null || defaultJRELibrary.length > 1 || !jreContainerPath.isPrefixOf(defaultJRELibrary[0].getPath())) {
1331
			// use default
1332
			return defaultJRELibrary;
1333
		}
1334
		IPath newPath= fJREGroup.getJREContainerPath();
1319
		IPath newPath= fJREGroup.getJREContainerPath();
1335
		if (newPath != null) {
1320
		if (newPath != null) {
1336
			return new IClasspathEntry[] { JavaCore.newContainerEntry(newPath) };
1321
			return new IClasspathEntry[] { JavaCore.newContainerEntry(newPath) };
1337
		}
1322
		}
1338
		return defaultJRELibrary;
1323
		return PreferenceConstants.getDefaultJRELibrary();
1339
	}
1324
	}
1340
1325
1341
	/**
1326
	/**
(-)ui/org/eclipse/jdt/ui/wizards/JavaCapabilityConfigurationPage.java (-2 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 260-265 Link Here
260
	 * @throws InterruptedException Thrown when the operation has been canceled.
260
	 * @throws InterruptedException Thrown when the operation has been canceled.
261
	 */
261
	 */
262
	public void configureJavaProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
262
	public void configureJavaProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
263
		configureJavaProject(null, monitor);
264
	}
265
	
266
	/**
267
	 * Adds the Java nature to the project (if not set yet) and configures the build classpath.
268
	 *
269
	 * @param newProjectCompliance compliance to set for a new project, can be <code>null</code>
270
	 * @param monitor a progress monitor to report progress or <code>null</code> if
271
	 * progress reporting is not desired
272
	 * @throws CoreException Thrown when the configuring the Java project failed.
273
	 * @throws InterruptedException Thrown when the operation has been canceled.
274
	 * @since 3.5
275
	 */
276
	public void configureJavaProject(String newProjectCompliance, IProgressMonitor monitor) throws CoreException, InterruptedException {
263
		if (monitor == null) {
277
		if (monitor == null) {
264
			monitor= new NullProgressMonitor();
278
			monitor= new NullProgressMonitor();
265
		}
279
		}
Lines 270-276 Link Here
270
		try {
284
		try {
271
			IProject project= getJavaProject().getProject();
285
			IProject project= getJavaProject().getProject();
272
			BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(monitor, 1));
286
			BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(monitor, 1));
273
			getBuildPathsBlock().configureJavaProject(new SubProgressMonitor(monitor, 5));
287
			getBuildPathsBlock().configureJavaProject(newProjectCompliance, new SubProgressMonitor(monitor, 5));
274
		} catch (OperationCanceledException e) {
288
		} catch (OperationCanceledException e) {
275
			throw new InterruptedException();
289
			throw new InterruptedException();
276
		} finally {
290
		} finally {
(-)core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java (-5 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 57-62 Link Here
57
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
57
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
58
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
58
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
59
import org.eclipse.jdt.internal.ui.wizards.buildpaths.ArchiveFileFilter;
59
import org.eclipse.jdt.internal.ui.wizards.buildpaths.ArchiveFileFilter;
60
import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport;
60
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
61
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
61
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElementAttribute;
62
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElementAttribute;
62
import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.OutputFolderValidator;
63
import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.OutputFolderValidator;
Lines 1038-1044 Link Here
1038
			IJavaModelStatus status= JavaConventions.validateClasspath(project, entries, outputLocation);
1039
			IJavaModelStatus status= JavaConventions.validateClasspath(project, entries, outputLocation);
1039
			if (!status.isOK())
1040
			if (!status.isOK())
1040
				throw new JavaModelException(status);
1041
				throw new JavaModelException(status);
1041
1042
			
1043
			BuildPathSupport.setEEComplianceOptions(project, newEntries);
1042
			project.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
1044
			project.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
1043
		} finally {
1045
		} finally {
1044
			monitor.done();
1046
			monitor.done();
Lines 1052-1065 Link Here
1052
		monitor.beginTask("", 2); //$NON-NLS-1$
1054
		monitor.beginTask("", 2); //$NON-NLS-1$
1053
1055
1054
		try {
1056
		try {
1055
			IClasspathEntry[] entries= convert(cpProject.getCPListElements());
1057
			List cpListElements= cpProject.getCPListElements();
1058
			IClasspathEntry[] entries= convert(cpListElements);
1056
			IPath outputLocation= cpProject.getDefaultOutputLocation();
1059
			IPath outputLocation= cpProject.getDefaultOutputLocation();
1057
1060
1058
			IJavaModelStatus status= JavaConventions.validateClasspath(cpProject.getJavaProject(), entries, outputLocation);
1061
			IJavaProject javaProject= cpProject.getJavaProject();
1062
			IJavaModelStatus status= JavaConventions.validateClasspath(javaProject, entries, outputLocation);
1059
			if (!status.isOK())
1063
			if (!status.isOK())
1060
				throw new JavaModelException(status);
1064
				throw new JavaModelException(status);
1061
1065
1062
			cpProject.getJavaProject().setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
1066
			BuildPathSupport.setEEComplianceOptions(javaProject, cpListElements);
1067
			javaProject.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
1063
		} finally {
1068
		} finally {
1064
			monitor.done();
1069
			monitor.done();
1065
		}
1070
		}

Return to bug 176516