Search in sources :

Example 1 with IAConfiguration

use of org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration 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)

Example 2 with IAConfiguration

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

the class CProjectBuildHelpers method setOptionInAutotools.

/**
 * <h1>Set Autotools option and write to disk.</h1>
 *
 * <p> Set an option (as well as flags) in the .autotools configuration and update gui. <br>
 * It is oblivious as to whether the option ID is an option or a flag, it just looks at the ID in the xml. </p>
 *
 * <p> It is designed so that it can be ran from a background thread.
 * It syncs with the GUI thread to avoid concurrency exceptions. </p>
 *
 * <p> *this modifies gui checkbox options* <b>as well as</b> *saving the option to disk*. </p>
 *
 * @param project    the IProject project which will be read to check if it is c or cpp.
 * @param optId      Id of option to set. Take directly out of .autotools. a 'flag' is also an option.
 * @param optVal     string value of the option. e.g "true"  "1234";
 */
public static void setOptionInAutotools(final IProject project, final String optId, final String optVal) {
    // 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());
            // Set option value.
            iaConfig.setOption(optId, optVal);
            // Save option to disk.
            AutotoolsConfigurationManager.getInstance().saveConfigs(project);
        }
    });
}
Also used : IAConfiguration(org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription)

Aggregations

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