private void updateComplianceEnableState() { boolean enableComplianceControls= true; if (fProject != null) { boolean hasProjectSpecificOptions= hasProjectSpecificOptions(fProject); String complianceFollowsEE= getValue(INTR_COMPLIANCE_FOLLOWS_EE); updateCheckBox(getCheckBox(INTR_COMPLIANCE_FOLLOWS_EE)); boolean enableComplianceFollowsEE= hasProjectSpecificOptions && ! DISABLED.equals(complianceFollowsEE); // is default or user updateControlsEnableState(fComplianceFollowsEEControls, enableComplianceFollowsEE); enableComplianceControls= hasProjectSpecificOptions && ! DEFAULT_CONF.equals(complianceFollowsEE); // is disabled or user updateControlsEnableState(fComplianceControls, enableComplianceControls); } boolean enableComplianceChildren= enableComplianceControls && checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF); updateControlsEnableState(fComplianceChildControls, enableComplianceChildren); }
@Override protected Control createContents(Composite parent) { fPixelConverter= new PixelConverter(parent); setShell(parent.getShell()); Composite complianceComposite= createComplianceTabContent(parent); validateSettings(null, null, null); return complianceComposite; }
@Override protected Control createPreferenceContent(Composite composite) { return fConfigurationBlock.createContents(composite); }
private void updateAssertEnumAsIdentifierEnableState() { if (checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF)) { String compatibility= getValue(PREF_SOURCE_COMPATIBILITY); boolean isLessThan14= VERSION_1_3.equals(compatibility); updateRememberedComplianceOption(PREF_PB_ASSERT_AS_IDENTIFIER, IDX_ASSERT_AS_IDENTIFIER, isLessThan14); boolean isLessThan15= isLessThan14 || VERSION_1_4.equals(compatibility); updateRememberedComplianceOption(PREF_PB_ENUM_AS_IDENTIFIER, IDX_ENUM_AS_IDENTIFIER, isLessThan15); } }
private void updateComplianceReleaseSettings() { String compliance= getValue(PREF_COMPLIANCE); boolean isRelease= checkValue(PREF_RELEASE, JavaCore.ENABLED) && JavaModelUtil.is16OrHigher(compliance); if (isRelease) { setValue(PREF_SOURCE_COMPATIBILITY, compliance); setValue(PREF_CODEGEN_TARGET_PLATFORM, compliance); } }
@Override protected void validateSettings(Key changedKey, String oldValue, String newValue) { if (!areSettingsEnabled()) { return; updateComplianceEnableState(); updateComplianceDefaultSettings(true, null); fComplianceStatus= validateCompliance(); } else if (INTR_COMPLIANCE_FOLLOWS_EE.equals(changedKey)) { setValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); updateComplianceEnableState(); updateComplianceDefaultSettings(true, null); updateControls(); fComplianceStatus= validateCompliance(); validateComplianceStatus(); } else if (PREF_COMPLIANCE.equals(changedKey)) { Object oldDefault= getValue(INTR_DEFAULT_COMPLIANCE); boolean rememberOld= USER_CONF.equals(oldDefault); updateComplianceDefaultSettings(rememberOld, oldValue); fComplianceStatus= validateCompliance(); validateComplianceStatus(); } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey)) { updateAssertEnumAsIdentifierEnableState(); fComplianceStatus= validateCompliance(); } else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey)) { if (VERSION_CLDC_1_1.equals(newValue) && !oldValue.equals(newValue)) { String compliance= getValue(PREF_COMPLIANCE); String source= getValue(PREF_SOURCE_COMPATIBILITY); if (!JavaModelUtil.isVersionLessThan(compliance, VERSION_1_5)) {
boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); boolean isFollowEE= checkValue(INTR_COMPLIANCE_FOLLOWS_EE, DEFAULT_CONF); String complianceLevel= getValue(PREF_COMPLIANCE); boolean isRelease= checkValue(PREF_RELEASE, JavaCore.ENABLED) && JavaModelUtil.is16OrHigher(complianceLevel) && !isDefault; fRememberedUserCompliance[IDX_ASSERT_AS_IDENTIFIER]= getValue(PREF_PB_ASSERT_AS_IDENTIFIER); fRememberedUserCompliance[IDX_ENUM_AS_IDENTIFIER]= getValue(PREF_PB_ENUM_AS_IDENTIFIER); fRememberedUserCompliance[IDX_SOURCE_COMPATIBILITY]= getValue(PREF_SOURCE_COMPATIBILITY); fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM]= getValue(PREF_CODEGEN_TARGET_PLATFORM); fRememberedUserCompliance[IDX_RELEASE]= getValue(PREF_RELEASE); fRememberedUserCompliance[IDX_COMPLIANCE]= oldComplianceLevel; IExecutionEnvironment ee= getEE(); Map<String, String> eeOptions= BuildPathSupport.getEEOptions(ee); if (eeOptions == null) setValue(PREF_COMPLIANCE, eeOptions.get(PREF_COMPLIANCE.getName())); String inlineJSR= eeOptions.get(PREF_CODEGEN_INLINE_JSR_BYTECODE.getName()); if (inlineJSR != null) { setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, inlineJSR); setValue(PREF_RELEASE, DISABLED); fComplierReleaseCheck.setSelection(false); source= getValue(PREF_COMPLIANCE); target= getValue(PREF_COMPLIANCE); assertAsId= getValue(PREF_PB_ASSERT_AS_IDENTIFIER); enumAsId= getValue(PREF_PB_ENUM_AS_IDENTIFIER); } else {
protected void validateSettings(Key changedKey, String oldValue, String newValue) { if (!areSettingsEnabled()) { return; updateComplianceEnableState(); updateComplianceDefaultSettings(true, null); fComplianceStatus= validateCompliance(); } else if (PREF_COMPLIANCE.equals(changedKey)) { Object oldDefault= setValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); updateComplianceEnableState(); updateComplianceDefaultSettings(USER_CONF.equals(oldDefault), oldValue); fComplianceStatus= validateCompliance(); validateJRE50Status(); } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey)) { updateAssertEnumAsIdentifierEnableState(); fComplianceStatus= validateCompliance(); } else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey)) { updateInlineJSREnableState(); fComplianceStatus= validateCompliance(); } else if (PREF_PB_ENUM_AS_IDENTIFIER.equals(changedKey) || PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) { fComplianceStatus= validateCompliance(); } else { return; updateComplianceEnableState(); updateAssertEnumAsIdentifierEnableState(); updateInlineJSREnableState(); fComplianceStatus= validateCompliance();
private void updateInlineJSREnableState() { String target= getValue(PREF_CODEGEN_TARGET_PLATFORM); boolean enabled= JavaModelUtil.isVersionLessThan(target, VERSION_1_5); Button checkBox= getCheckBox(PREF_CODEGEN_INLINE_JSR_BYTECODE); checkBox.setEnabled(enabled); if (!enabled) { String val= getValue(PREF_CODEGEN_INLINE_JSR_BYTECODE); fRememberedUserCompliance[IDX_INLINE_JSR_BYTECODE]= val; if (!ENABLED.equals(val)) { setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, ENABLED); updateCheckBox(checkBox); } } else { String val= fRememberedUserCompliance[IDX_INLINE_JSR_BYTECODE]; if (!ENABLED.equals(val)) { setValue(PREF_CODEGEN_INLINE_JSR_BYTECODE, val); updateCheckBox(checkBox); } } }
private void updateComplianceDefaultSettings(boolean rememberOld, String oldComplianceLevel) { String assertAsId, enumAsId, source, target; boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); String complianceLevel= getValue(PREF_COMPLIANCE); fRememberedUserCompliance[IDX_ASSERT_AS_IDENTIFIER]= getValue(PREF_PB_ASSERT_AS_IDENTIFIER); fRememberedUserCompliance[IDX_ENUM_AS_IDENTIFIER]= getValue(PREF_PB_ENUM_AS_IDENTIFIER); fRememberedUserCompliance[IDX_SOURCE_COMPATIBILITY]= getValue(PREF_SOURCE_COMPATIBILITY); fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM]= getValue(PREF_CODEGEN_TARGET_PLATFORM); fRememberedUserCompliance[IDX_COMPLIANCE]= oldComplianceLevel; target= fRememberedUserCompliance[IDX_CODEGEN_TARGET_PLATFORM]; } else { updateInlineJSREnableState(); updateAssertEnumAsIdentifierEnableState(); return; setValue(PREF_PB_ASSERT_AS_IDENTIFIER, assertAsId); setValue(PREF_PB_ENUM_AS_IDENTIFIER, enumAsId); setValue(PREF_SOURCE_COMPATIBILITY, source); setValue(PREF_CODEGEN_TARGET_PLATFORM, target); updateControls(); updateInlineJSREnableState(); updateAssertEnumAsIdentifierEnableState();
PreferencesMessages.ComplianceConfigurationBlock_version_11, }; if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) { targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14); targetLabels= append(targetLabels, ComplianceConfigurationBlock.VERSION_JSR14); String label= PreferencesMessages.ComplianceConfigurationBlock_compliance_follows_EE_label; int widthHint= fPixelConverter.convertWidthInCharsToPixels(40); addCheckBoxWithLink(group, label, INTR_COMPLIANCE_FOLLOWS_EE, defaultUserValues, 0, widthHint, new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { addComboBox(group, label, PREF_COMPLIANCE, complianceVersions, complianceLabels, 0); fComplierReleaseCheck= addCheckBox(group, label, PREF_RELEASE, new String[] { DISABLED, ENABLED }, 0, false); addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0); addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, targetVersions, targetLabels, indent); addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, sourceVersions, sourceLabels, indent); addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningInfoIgnore, errorWarningInfoIgnoreLabels, indent); addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningInfoIgnore, errorWarningInfoIgnoreLabels, indent); addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0); addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0);
String label= PreferencesMessages.ComplianceConfigurationBlock_compliance_follows_EE_label; int widthHint= fPixelConverter.convertWidthInCharsToPixels(40); addCheckBoxWithLink(group, label, INTR_COMPLIANCE_FOLLOWS_EE, defaultUserValues, 0, widthHint, new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0); addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0); boolean showJsr14= ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)); if (showJsr14) { versions= append(versions, ComplianceConfigurationBlock.VERSION_JSR14); versionsLabels= append(versionsLabels, ComplianceConfigurationBlock.VERSION_JSR14); addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent); addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent); addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningInfoIgnore, errorWarningInfoIgnoreLabels, indent); addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningInfoIgnore, errorWarningInfoIgnoreLabels, indent); addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0); addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0); addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0);
private void updateComplianceEnableSourceTargetState() { boolean enableComplianceControls= true; if (fProject != null) { boolean hasProjectSpecificOptions= hasProjectSpecificOptions(fProject); String complianceFollowsEE= getValue(INTR_COMPLIANCE_FOLLOWS_EE); enableComplianceControls= hasProjectSpecificOptions && !DEFAULT_CONF.equals(complianceFollowsEE); // is disabled or user } boolean enableBasedOnRelease= !fComplierReleaseCheck.getSelection() || !JavaModelUtil.is16OrHigher(getValue(PREF_COMPLIANCE)); boolean enableComplianceChildren= enableComplianceControls && checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF) && enableBasedOnRelease; for (int i= fComplianceChildControls.size() - 1; i >= 0; i--) { Control curr= fComplianceChildControls.get(i); ControlData data= (ControlData) curr.getData(); if (data != null) { if (PREF_SOURCE_COMPATIBILITY.equals(data.getKey()) || PREF_CODEGEN_TARGET_PLATFORM.equals(data.getKey())) { Combo combo= getComboBox(data.getKey()); combo.setEnabled(enableComplianceChildren); } } } }
private void updateReleaseOptionStatus() { if (fComplierReleaseCheck != null && !fComplierReleaseCheck.isDisposed()) { String compliance= getStoredValue(PREF_COMPLIANCE); // get actual value IVMInstall install= null; if (fProject != null) { // project specific settings: only test if a 50 JRE is installed fComplierReleaseCheck.setEnabled(false); fComplierReleaseCheck.setSelection(false); setValue(PREF_RELEASE, DISABLED); } else { if (fProject != null) { fComplierReleaseCheck.setEnabled(checkValue(INTR_COMPLIANCE_FOLLOWS_EE, USER_CONF)); updateComplianceEnableSourceTargetState(); } else { fComplierReleaseCheck.setEnabled(false); fComplierReleaseCheck.setSelection(false); setValue(PREF_RELEASE, DISABLED); setValue(PREF_RELEASE, JavaCore.DISABLED); } else { if (fProject == null) { fComplierReleaseCheck.setEnabled(true); updateComplianceEnableSourceTargetState();
addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0); addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String[] { DEFAULT_CONF, USER_CONF }, 0); addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent); addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent); addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent); addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent); addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0); addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0); addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0); addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0); addCheckBox(group, label, PREF_CODEGEN_INLINE_JSR_BYTECODE, enableDisableValues, 0); gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50); fJRE50InfoText.setLayoutData(gd); validateJRE50Status();
@Override protected void enablePreferenceContent(boolean enable) { if (fConfigurationBlock != null) { fConfigurationBlock.enablePreferenceContent(enable); } }
private void updateComplianceEnableState() { boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF); for (int i= fComplianceControls.size() - 1; i >= 0; i--) { Control curr= (Control) fComplianceControls.get(i); curr.setEnabled(enabled); } }
@Override public void dispose() { if (fConfigurationBlock != null) { fConfigurationBlock.dispose(); } super.dispose(); }
@Override public void createControl(Composite parent) { IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer(); fConfigurationBlock= new ComplianceConfigurationBlock(getNewStatusChangedListener(), getProject(), container); super.createControl(parent); if (isProjectPreferencePage()) { PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE); } else { PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE); } }
@Override protected void validateSettings(Key changedKey, String oldValue, String newValue) { if (!areSettingsEnabled()) { return; updateComplianceEnableState(); updateComplianceDefaultSettings(true, null); fComplianceStatus= validateCompliance(); } else if (INTR_COMPLIANCE_FOLLOWS_EE.equals(changedKey)) { setValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); updateReleaseOptionStatus(); updateComplianceEnableState(); updateComplianceDefaultSettings(true, null); updateControls(); fComplianceStatus= validateCompliance(); validateComplianceStatus(); } else if (PREF_COMPLIANCE.equals(changedKey)) { updateReleaseOptionStatus(); Object oldDefault= getValue(INTR_DEFAULT_COMPLIANCE); boolean rememberOld= USER_CONF.equals(oldDefault); updateComplianceDefaultSettings(rememberOld, oldValue); fComplianceStatus= validateCompliance(); validateComplianceStatus(); } else if (PREF_RELEASE.equals(changedKey)) { setValue(PREF_RELEASE, DISABLED.equals(newValue) ? ENABLED : DISABLED); updateReleaseOptionStatus(); updateComplianceDefaultSettings(true, null); fComplianceStatus= validateCompliance(); validateComplianceStatus();