Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] RE: IOptionApplicability (Jesper Eskilson)

 Hello Jesper,

	try this, it works,
-----------------
	private static boolean flag;
	
	public boolean isOptionEnabled(IBuildObject configuration,
			IHoldsOptions holder, IOption option) {
		IOption opt;
		opt =
holder.getOptionBySuperClassId("TheEnumeratedOptionID");
		try {
			if
(opt.getSelectedEnum().equalsIgnoreCase("TheEnumeratedOptionValue"))) {
					//where TheEnumeratedOptionValue =
//OptionConstants.LIB_CONFIG_CUSTOM
				flag = true;
			}
			else{
				flag = false;	
			}
			
		} catch (BuildException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return flag;
	}	
--------------------
And add a valuer handler class to the option
Where you set "return true" in the isEnumValueAppropriate(...) method.

Khaled ABDA

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On
Behalf Of cdt-dev-request@xxxxxxxxxxx
Sent: Thursday, September 27, 2007 6:01 PM
To: cdt-dev@xxxxxxxxxxx
Subject: cdt-dev Digest, Vol 31, Issue 58

Send cdt-dev mailing list submissions to
	cdt-dev@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
	https://dev.eclipse.org/mailman/listinfo/cdt-dev
or, via email, send a message with subject or body 'help' to
	cdt-dev-request@xxxxxxxxxxx

You can reach the person managing the list at
	cdt-dev-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of cdt-dev digest..."


Today's Topics:

   1. CDT 4.0.1 Now Available (Doug Schaefer)
   2. IOptionApplicability (Jesper Eskilson)
   3. Re: IOptionApplicability (Wieant Nielander)


----------------------------------------------------------------------

Message: 1
Date: Wed, 26 Sep 2007 17:57:44 -0400
From: Doug Schaefer <DSchaefer@xxxxxxx>
Subject: [cdt-dev] CDT 4.0.1 Now Available
To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
Message-ID:
	<3518719F06577C4F85DA618E3C37AB910C0D3274@xxxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset="us-ascii"

Hey gang,

 

CDT 4.0.1 is now available. It is on our Europa update site along with the
cdt-master zip. Check out the downloads page on our web site:
http://www.eclipse.org/cdt <http://www.eclipse.org/cdt> .

 

Thanks to everyone who has contributed!

Cheers,

Doug Schaefer, QNX Software Systems
Eclipse CDT Project Lead, http://cdtdoug.blogspot.com
<http://cdtdoug.blogspot.com> 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
https://dev.eclipse.org/mailman/listinfo/cdt-dev/attachments/20070926/a98f63
af/attachment.html

------------------------------

Message: 2
Date: Thu, 27 Sep 2007 13:54:55 +0200
From: Jesper Eskilson <jesper@xxxxxxxxxxx>
Subject: [cdt-dev] IOptionApplicability
To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
Message-ID: <46FB9A0F.6020903@xxxxxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1


Hi,

I'm trying to implement an IOptionApplicability class for an option
which should be enabled depending on the state of another (enum) option.

This is the method which tries to determine the state of the enum option:

>     private final boolean usingCustomLibraryConfig(IHoldsOptions holder,
>             IOption option)
>     {
>         IOption o =
holder.getOptionById(OptionConstants.LIB_CONFIG_OPTION);
>         assert o != null;
>         try {
>             String s = o.getSelectedEnum();
> 
>             System.err.println("Selected enum: " + s);
> 
>             if (s.equals(OptionConstants.LIB_CONFIG_CUSTOM)) {
>                 return true;
>             } else {
>                 return false;
>             }
> 
>         } catch (BuildException e) {
>             e.printStackTrace();
>         }
>         return false;
> 
>     }

The problem is that the return value from getSelectedEnum() is always
the default value (which is != LIB_CONFIG_CUSTOM in this case),
regardless of the actual state of the combobox in the UI. So the method
always returns false, and the option is therefore always disabled.

What am I doing wrong?

-- 
/Jesper


------------------------------

Message: 3
Date: Thu, 27 Sep 2007 14:36:30 +0200
From: wieant@xxxxxxxxx (Wieant Nielander)
Subject: Re: [cdt-dev] IOptionApplicability
To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
Message-ID: <20070927123630.GA18854@xxxxxxxxx>
Content-Type: text/plain; charset=us-ascii

> I'm trying to implement an IOptionApplicability class for an option
> which should be enabled depending on the state of another (enum) option.
> 
> This is the method which tries to determine the state of the enum option:
> 
>>     private final boolean usingCustomLibraryConfig(IHoldsOptions holder,
>>             IOption option)
>>     {
>>         IOption o =
holder.getOptionById(OptionConstants.LIB_CONFIG_OPTION);
>>         assert o != null;
>>         try {
>>             String s = o.getSelectedEnum();
>> 
>>             System.err.println("Selected enum: " + s);
>> 
>>             if (s.equals(OptionConstants.LIB_CONFIG_CUSTOM)) {
>>                 return true;
>>             } else {
>>                 return false;
>>             }
>> 
>>         } catch (BuildException e) {
>>             e.printStackTrace();
>>         }
>>         return false;
>> 
>>     }
>
> The problem is that the return value from getSelectedEnum() is always
> the default value (which is != LIB_CONFIG_CUSTOM in this case),
> regardless of the actual state of the combobox in the UI. So the method
> always returns false, and the option is therefore always disabled.

I think the problem is in:
   IOption o = holder.getOptionById(OptionConstants.LIB_CONFIG_OPTION);
this returns the 'original' option as defined in your manifest file,
this by definition will return its default value. Once you change an
option a new instance will be created with a new id, that is the
original id followed by some kind of random number.

As you don't know the random nr part in the id you will have to use
something like the following to get to the actual value:

  String s = null;
  for ( IOption opt : holder.getOptions() ) {
    if ( opt.isExtensionElement() ) {
      // option as loaded from the manifest file
      if ( opt.getId().
              equals(OptionConstants.LIB_CONFIG_CUSTOM)) {
        s = opt.getSelectedEnum();
        break;
      }
    } else {
      // 'changed' option, check its superclass id
      if ( opt.getSuperClass().getId().
              equals(OptionConstants.LIB_CONFIG_CUSTOM)) {
        s = opt.getSelectedEnum();
        break;
      }
    } 
  }

Hope this helps,
  Wieant


------------------------------

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


End of cdt-dev Digest, Vol 31, Issue 58
***************************************



Back to the top