Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Modifying the .cdtbuild file through program

Hi All,

I have two Boolean options i.e. checkboxes (e.g. option1 and option2)
owned by a single category in my new MBS.  
I want to make the options inter-dependent in such a way that if one of
the option say option1 is selected then the other option option2 gets
selected automatically and vice versa.
For start I have written applicability calculator for option1 and in
that I am trying to select/deselect the option2 based on the option1. 

But as the option2 is not present in the .cdtbuild I cannot set the
value of the option2. The setValue throws exception if the
isExtensionElement is true, which is always true at the time of project
creation. The option2 does not get added to .cdtbuild unless until I
click on the option2.
So my applicability calculator throws exception at the start but if I
select/de-select option2 once it works fine afterwards.

Please guide. 
My applicability calculator is as follows: 

Option1ApplicabilityCalculator.java
public class Option1ApplicabilityCalculator implements
IOptionApplicability {
	public boolean isOptionUsedInCommandLine(IBuildObject
configuration,
      IHoldsOptions holder, IOption option) {
    try {
      if(option.getBooleanValue()){
      IOption opt =
holder.getOptionBySuperClassId("org.eclipse.option2");
      opt.setCommand("-myoption");
      }
    } catch (BuildException e) {
      e.printStackTrace();
    }
    return true;
    
  }

  public boolean isOptionVisible(IBuildObject configuration,
      IHoldsOptions holder, IOption option) {
	return true;
  }

  public boolean isOptionEnabled(IBuildObject configuration,
      IHoldsOptions holder, IOption option) {
    try {
      if(option.getBooleanValue()){
      IOption opt =
holder.getOptionBySuperClassId("org.eclipse.option2");
      opt.setValue(true);
      }
    } catch (BuildException e) {
      e.printStackTrace();
    }
    return true;
  } 
}  


Back to the top