Search in sources :

Example 1 with IConfigureOption

use of org.eclipse.cdt.internal.autotools.core.configure.IConfigureOption in project linuxtools by eclipse.

the class CProjectBuildHelpers method isOptionCheckedInAutotoolsPrefStore.

/**
 * <h1>Option enabled check</h1>
 * <p> Check to see if an option is enabled in the .autotools configuration.</p>
 *
 * @param project  the IProject project which will be read to check if it is c or cpp.
 * @param optionId copy paste directly from .autotools. pick the 'ID' field value.
 * @return true if it is
 */
public static boolean isOptionCheckedInAutotoolsPrefStore(final IProject project, final String optionId) {
    // We define a 'final' variable that will be accessible in the runnable object.
    final BooleanWithGetSet userChoiceBool = new BooleanWithGetSet(false);
    // need to run this in the ui thread otherwise get SWT Exceptions
    // based on concurrency issues.
    Display.getDefault().syncExec(() -> {
        // Code copied from private methd: SetAutotoolsStringOptionValue.setOptionValue()
        // Except I added a line to save the configuration to disk as well.
        AutotoolsConfigurationManager.getInstance().syncConfigurations(project);
        ICConfigurationDescription cfgds = CoreModel.getDefault().getProjectDescription(project).getActiveConfiguration();
        if (cfgds != null) {
            IAConfiguration iaConfig = AutotoolsConfigurationManager.getInstance().getConfiguration(project, cfgds.getId());
            // Read option value
            IConfigureOption option = iaConfig.getOption(optionId);
            String optValString = option.getValue();
            boolean optVal = Boolean.parseBoolean(optValString);
            userChoiceBool.setVal(optVal);
        }
    });
    return userChoiceBool.getVal();
}
Also used : IAConfiguration(org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) IConfigureOption(org.eclipse.cdt.internal.autotools.core.configure.IConfigureOption)

Aggregations

ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)1 IAConfiguration (org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration)1 IConfigureOption (org.eclipse.cdt.internal.autotools.core.configure.IConfigureOption)1