Skip to main content

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

Hi Rekha,

You should use IConfiguration.setOption to set the value of the other
option.  It will create the non-isExtensionElement option instance if
necessary.

/**
 * Sets the value of a boolean option for this configuration.
 * 
 * @param parent The holder/parent of the option.
 * @param option The option to change.
 * @param value The value to apply to the option.
 * 
 * @return IOption The modified option.  This can be the same option or
a newly created option.
 * 
 * @throws BuildException
 * 
 * @since 3.0 - The type of parent has changed from ITool to
IHoldsOptions.
 *        Code assuming ITool as type, will continue to work unchanged.
 */
public IOption setOption(IHoldsOptions parent, IOption option, boolean
value) 
	throws BuildException;	

Regards,
Leo

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Rekha Deshmukh
Sent: Thursday, December 22, 2005 7:49 AM
To: cdt-dev@xxxxxxxxxxx
Subject: [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;
  } 
}  
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top