mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 15:25:49 +02:00
bug 328007: [sd90] Disablement of property pages depending on preference
This commit is contained in:
parent
2b5e3e6a20
commit
5edeb05a5b
6 changed files with 106 additions and 28 deletions
|
@ -502,11 +502,11 @@
|
||||||
|
|
||||||
<and>
|
<and>
|
||||||
` <instanceof value="org.eclipse.core.resources.IFile"/>
|
` <instanceof value="org.eclipse.core.resources.IFile"/>
|
||||||
<test property="org.eclipse.cdt.ui.isSource" value="" />
|
<test property="org.eclipse.cdt.ui.isSource"/>
|
||||||
</and>
|
</and>
|
||||||
<and>
|
<and>
|
||||||
<instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
|
<instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
|
||||||
<test property="org.eclipse.cdt.ui.isSource" value="" />
|
<test property="org.eclipse.cdt.ui.isSource"/>
|
||||||
</and>
|
</and>
|
||||||
|
|
||||||
</or>
|
</or>
|
||||||
|
|
|
@ -534,7 +534,7 @@
|
||||||
<test property="org.eclipse.core.resources.projectNature"
|
<test property="org.eclipse.core.resources.projectNature"
|
||||||
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
|
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
|
||||||
</adapt>
|
</adapt>
|
||||||
<test property="org.eclipse.cdt.ui.pageEnabled" value="export" />
|
<test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.export.page.enable=true"/>
|
||||||
</and>
|
</and>
|
||||||
</enabledWhen>
|
</enabledWhen>
|
||||||
</page>
|
</page>
|
||||||
|
@ -564,7 +564,7 @@
|
||||||
<test property="org.eclipse.core.resources.projectNature"
|
<test property="org.eclipse.core.resources.projectNature"
|
||||||
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
|
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
|
||||||
</adapt>
|
</adapt>
|
||||||
<test property="org.eclipse.cdt.ui.pageEnabled" value="toolEdit" />
|
<test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.toolchain.modification.disable=false"/>
|
||||||
</and>
|
</and>
|
||||||
</enabledWhen>
|
</enabledWhen>
|
||||||
</page>
|
</page>
|
||||||
|
|
|
@ -24,10 +24,13 @@ import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set
|
||||||
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
|
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
|
||||||
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgScannerConfigUtil;
|
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgScannerConfigUtil;
|
||||||
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
|
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
|
||||||
|
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
|
||||||
import org.eclipse.cdt.core.model.util.CDTListComparator;
|
import org.eclipse.cdt.core.model.util.CDTListComparator;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
|
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage;
|
||||||
|
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2Set;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2Set;
|
||||||
|
@ -46,7 +49,9 @@ import org.eclipse.cdt.managedbuilder.core.IInputType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
||||||
|
@ -103,6 +108,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
private Button reportProblemsCheckBox;
|
private Button reportProblemsCheckBox;
|
||||||
private Combo profileComboBox;
|
private Combo profileComboBox;
|
||||||
private Composite profileOptionsComposite;
|
private Composite profileOptionsComposite;
|
||||||
|
private Button clearButton;
|
||||||
|
|
||||||
private ICfgScannerConfigBuilderInfo2Set cbi;
|
private ICfgScannerConfigBuilderInfo2Set cbi;
|
||||||
private Map<InfoContext, IScannerConfigBuilderInfo2> baseInfoMap;
|
private Map<InfoContext, IScannerConfigBuilderInfo2> baseInfoMap;
|
||||||
|
@ -116,6 +122,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
|
|
||||||
private DiscoveryPageWrapper wrapper = null;
|
private DiscoveryPageWrapper wrapper = null;
|
||||||
|
|
||||||
|
private StatusMessageLine fStatusLine;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -184,6 +192,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
profileOptionsComposite.setLayoutData(gd);
|
profileOptionsComposite.setLayoutData(gd);
|
||||||
profileOptionsComposite.setLayout(new TabFolderLayout());
|
profileOptionsComposite.setLayout(new TabFolderLayout());
|
||||||
|
|
||||||
|
fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
|
||||||
|
setEnablement();
|
||||||
|
|
||||||
sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
|
sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +215,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
buildInfo.setSelectedProfileId(id);
|
buildInfo.setSelectedProfileId(id);
|
||||||
handleDiscoveryProfileChanged();
|
handleDiscoveryProfileChanged();
|
||||||
}
|
}
|
||||||
|
showStatusLine();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reportProblemsCheckBox = setupCheck(autoDiscoveryGroup,
|
reportProblemsCheckBox = setupCheck(autoDiscoveryGroup,
|
||||||
|
@ -236,7 +248,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
Label clearLabel = ControlFactory.createLabel(autoDiscoveryGroup, Messages.DiscoveryTab_ClearDisoveredEntries);
|
Label clearLabel = ControlFactory.createLabel(autoDiscoveryGroup, Messages.DiscoveryTab_ClearDisoveredEntries);
|
||||||
|
|
||||||
// "Clear" button
|
// "Clear" button
|
||||||
Button clearButton = ControlFactory.createPushButton(autoDiscoveryGroup, Messages.DiscoveryTab_Clear);
|
clearButton = ControlFactory.createPushButton(autoDiscoveryGroup, Messages.DiscoveryTab_Clear);
|
||||||
GridData gd = (GridData) clearButton.getLayoutData();
|
GridData gd = (GridData) clearButton.getLayoutData();
|
||||||
gd.grabExcessHorizontalSpace = true;
|
gd.grabExcessHorizontalSpace = true;
|
||||||
//Bug 331783 - NLS: "Clear" button label in Makefile Project preferences truncated
|
//Bug 331783 - NLS: "Clear" button label in Makefile Project preferences truncated
|
||||||
|
@ -334,6 +346,37 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
} else {
|
} else {
|
||||||
setVisibility(Messages.DiscoveryTab_6);
|
setVisibility(Messages.DiscoveryTab_6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setEnablement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEnablement() {
|
||||||
|
ICConfigurationDescription cfgDescription = page.getResDesc().getConfiguration();
|
||||||
|
boolean isEnabled = !LanguageSettingsProvidersPage.isLanguageSettingsProvidersEnabled(getProject()) || ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
|
||||||
|
|
||||||
|
scopeComboBox.setEnabled(isEnabled);
|
||||||
|
resTable.setEnabled(isEnabled);
|
||||||
|
boolean isSCDEnabled = autoDiscoveryCheckBox.getSelection();
|
||||||
|
reportProblemsCheckBox.setEnabled(isEnabled && isSCDEnabled);
|
||||||
|
autoDiscoveryCheckBox.setEnabled(isEnabled);
|
||||||
|
autoDiscoveryGroup.setEnabled(isEnabled);
|
||||||
|
clearButton.setEnabled(isEnabled);
|
||||||
|
|
||||||
|
showStatusLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showStatusLine() {
|
||||||
|
ICConfigurationDescription cfgDescription = page.getResDesc().getConfiguration();
|
||||||
|
boolean isEnabled = !LanguageSettingsProvidersPage.isLanguageSettingsProvidersEnabled(getProject()) || ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
|
||||||
|
IStatus status = null;
|
||||||
|
if (isEnabled) {
|
||||||
|
if (autoDiscoveryCheckBox.getSelection()) {
|
||||||
|
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, "This discovery method is deprecated, use 'Preprocessor Include Paths' instead.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, "Managed Build language settings provider is not enabled (see 'Preprocessor Include Paths' page).");
|
||||||
|
}
|
||||||
|
fStatusLine.setErrorStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVisibility(String errMsg) {
|
private void setVisibility(String errMsg) {
|
||||||
|
@ -372,7 +415,13 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
|
||||||
buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$
|
buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$
|
||||||
String selectedProfileId = buildInfo.getSelectedProfileId();
|
String selectedProfileId = buildInfo.getSelectedProfileId();
|
||||||
iContext = (CfgInfoContext) ti.getData("cont"); //$NON-NLS-1$
|
iContext = (CfgInfoContext) ti.getData("cont"); //$NON-NLS-1$
|
||||||
autoDiscoveryCheckBox.setSelection(buildInfo.isAutoDiscoveryEnabled()
|
boolean autodiscoveryEnabled2 = buildInfo.isAutoDiscoveryEnabled();
|
||||||
|
if (autodiscoveryEnabled2) {
|
||||||
|
IConfiguration cfg = iContext.getConfiguration();
|
||||||
|
ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
||||||
|
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isLegacyScannerDiscoveryOn(cfgDescription);
|
||||||
|
}
|
||||||
|
autoDiscoveryCheckBox.setSelection(autodiscoveryEnabled2
|
||||||
&& !selectedProfileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID));
|
&& !selectedProfileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID));
|
||||||
reportProblemsCheckBox.setSelection(buildInfo.isProblemReportingEnabled());
|
reportProblemsCheckBox.setSelection(buildInfo.isProblemReportingEnabled());
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,10 @@ public class ScannerDiscoveryLegacySupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if legacy Scanner Discovery in MBS should be active.
|
* Check if legacy Scanner Discovery in MBS should be active.
|
||||||
|
* @noreference This is internal helper method to support compatibility with previous versions
|
||||||
|
* which is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
private static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) {
|
public static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) {
|
||||||
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||||
List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
|
||||||
for (ILanguageSettingsProvider lsp : lsProviders) {
|
for (ILanguageSettingsProvider lsp : lsProviders) {
|
||||||
|
|
|
@ -3376,7 +3376,10 @@
|
||||||
category="org.eclipse.cdt.ui.newui.Page_head_general">
|
category="org.eclipse.cdt.ui.newui.Page_head_general">
|
||||||
<enabledWhen>
|
<enabledWhen>
|
||||||
<adapt type="org.eclipse.core.resources.IResource">
|
<adapt type="org.eclipse.core.resources.IResource">
|
||||||
|
<and>
|
||||||
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
|
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
|
||||||
|
<test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.providers.tab.disable=false"/>
|
||||||
|
</and>
|
||||||
</adapt>
|
</adapt>
|
||||||
</enabledWhen>
|
</enabledWhen>
|
||||||
</page>
|
</page>
|
||||||
|
@ -3940,10 +3943,10 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.core.expressions.propertyTesters">
|
point="org.eclipse.core.expressions.propertyTesters">
|
||||||
<propertyTester
|
<propertyTester
|
||||||
id="org.eclipse.cdt.Tester3"
|
id="org.eclipse.cdt.ui.preferenceTester"
|
||||||
class="org.eclipse.cdt.ui.newui.PropertyTester"
|
class="org.eclipse.cdt.ui.newui.PropertyTester"
|
||||||
namespace="org.eclipse.cdt.ui"
|
namespace="org.eclipse.cdt.ui"
|
||||||
properties="pageEnabled"
|
properties="checkPreference"
|
||||||
type="java.lang.Object"/>
|
type="java.lang.Object"/>
|
||||||
<propertyTester
|
<propertyTester
|
||||||
id="org.eclipse.cdt.Tester1"
|
id="org.eclipse.cdt.Tester1"
|
||||||
|
|
|
@ -10,39 +10,63 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.newui;
|
package org.eclipse.cdt.ui.newui;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether given object is a source file.
|
* Property tester to test expressions in plugin.xml. Tests following expressions:
|
||||||
|
* 1. Checks whether given object is a source file. Usage:
|
||||||
|
* <test property="org.eclipse.cdt.ui.isSource"/>
|
||||||
|
* 2. Checks value of a preference. Usage:
|
||||||
|
* <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.export.page.enable=true"/>
|
||||||
|
*
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
*/
|
*/
|
||||||
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
|
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
|
||||||
private static final String KEY_SRC = "isSource"; //$NON-NLS-1$
|
private static final String KEY_SRC = "isSource"; //$NON-NLS-1$
|
||||||
private static final String KEY_PAGE = "pageEnabled"; //$NON-NLS-1$
|
private static final String KEY_PREF = "checkPreference"; //$NON-NLS-1$
|
||||||
private static final String VAL_EXP = "export"; //$NON-NLS-1$
|
|
||||||
private static final String VAL_TOOL = "toolEdit"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Object receiver, String property, Object[] args,
|
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
|
||||||
Object expectedValue) {
|
|
||||||
if (KEY_SRC.equals(property)) {
|
if (KEY_SRC.equals(property)) {
|
||||||
if (receiver instanceof ITranslationUnit) {
|
if (receiver instanceof ITranslationUnit) {
|
||||||
return ((ITranslationUnit)receiver).isSourceUnit();
|
return ((ITranslationUnit) receiver).isSourceUnit();
|
||||||
}
|
} else if (receiver instanceof IFile) {
|
||||||
else if (receiver instanceof IFile) {
|
IFile file = (IFile) receiver;
|
||||||
IFile file = (IFile)receiver;
|
|
||||||
return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
|
return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
|
||||||
}
|
}
|
||||||
} else if (KEY_PAGE.equals(property)
|
} else if (KEY_PREF.equals(property) && expectedValue instanceof String) {
|
||||||
&& expectedValue instanceof String) {
|
boolean result = false;
|
||||||
String s = (String) expectedValue;
|
final Pattern pat = Pattern.compile("(.*):(.*)=(.*)"); //$NON-NLS-1$
|
||||||
if (VAL_EXP.equalsIgnoreCase(s))
|
Matcher matcher = pat.matcher((String) expectedValue);
|
||||||
return CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT);
|
if (matcher.matches()) {
|
||||||
if (VAL_TOOL.equalsIgnoreCase(s))
|
String pluginId = matcher.group(1);
|
||||||
return !CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM);
|
String preference = matcher.group(2);
|
||||||
|
String wantedValue = matcher.group(3);
|
||||||
|
|
||||||
|
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(pluginId);
|
||||||
|
if (wantedValue != null) {
|
||||||
|
String actualValue = node.get(preference, ""); //$NON-NLS-1$
|
||||||
|
result = wantedValue.equals(actualValue) || (wantedValue.equals("false") && actualValue.isEmpty()); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
result = Arrays.asList(node.keys()).contains(preference);
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
CUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue