Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
pfiffi78
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Preprocessing in Eclipse Plugin

Hello,

 

I am trying to get preprocessing in the Eclipse plugin to work. I would like to have one code base and be able to compile against the component pack 4.5 and 4.6. In 4.6 you can do something like this:



title.setBackground(BackgroundFactory.createSolidBackground(0x0016286D));

 

where title is a LabelField in this case. BackgroundFactory doesn't exist in 4.5 and hence I would like to do something like this

 

 

//#preprocess
//#ifdef VERSION_4_6_HIGHER
title.setBackground(BackgroundFactory.createSolidBackground(0x0016286D));
//#else
//do nothing for now
//#endif

 

According to my eclipse/configuration/config.ini I have the following line it it:

 

osgi.framework.extensions=net.rim.eide.preprocessing.hook

 

But still, even after a clean build, Eclipse still says it cannot find BackgroundFactory when I try to compile it against the 4.5 component pack. I have not specified VERSION_4_6_HIGHER in my 'preprocessor defines' in my project settings so hence it shouldn't compile the one line and Eclipse shouldn't say it can't find BackgroundFactory.

 

Am I missing anything here? Has anybody made any successful expierence with preprocessor and the Eclipse Plugin?

 

Thanks.

 

Daniel

 

 

 

Please use plain text.
Developer
pfiffi78
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Preprocessing in Eclipse Plugin

Has no one yet made any expierence with using preprocessing in the Eclipse plugin?
Please use plain text.
Developer
skicson
Posts: 56
Registered: ‎07-14-2008
My Device: Not Specified

Re: Preprocessing in Eclipse Plugin

First the

//#preprocess must be the first line in the file.

 

Second, to avoid Eclipse complaints, you could comment out the line like so:

 


 
//#ifndef VERSION_4_6_HIGHER
/*
//#endif

title.setBackground(BackgroundFactory.createSolidBackground(0x0016286D));

//#ifndef VERSION_4_6_HIGHER
*/
//#endif

Please use plain text.
Developer
pfiffi78
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Preprocessing in Eclipse Plugin

Great, That seems to work. Thank you very much for that!

 

I wish all this was documented in the Eclipse plugin's help though!

 

Thank you again for your help! :-)

Please use plain text.
New Developer
mruthven
Posts: 20
Registered: ‎07-21-2008
My Device: Not Specified

Re: Preprocessing in Eclipse Plugin

Not a lot of information added here, I know, but FWIW, I have not had any problems with the preproccesor and have not had to do the block comment thing.  //#preprocess as the first line of the file is all I have needed.
Please use plain text.
Developer
pfiffi78
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Preprocessing in Eclipse Plugin

That's really odd. I have the //#preprocess on the first line too and as soon as I add this:

 

//#ifdef VERSION_4_6_HIGHER
      this.setBackground(net.rim.device.api.ui.decor.BackgroundFactory.createSolidBackground(backgroundColor));
    //#endif

 

Eclipse will complain. Are you using the 'Build automatically' option or do you manual builds?

 

 

Please use plain text.
New Developer
mruthven
Posts: 20
Registered: ‎07-21-2008
My Device: Not Specified

Re: Preprocessing in Eclipse Plugin

Hopefully you got this sorted out, somehow I missed your message.  I use the build automatically option.  I have run into trouble when I've accidentally ended up with spaces between the // and the #, which happens because of my tendency to use the auto-formatting to clean up indents and such when they get wacky.

Please use plain text.
New Developer
DanDroid
Posts: 4
Registered: ‎11-25-2010
My Device: Not Specified

Re: Preprocessing in Eclipse Plugin

[ Edited ]

Thread from the Dead, I know, but I experience similar issues with preprocessor commands (eclipse 3.5/bb plugin1.1), with the proviso that imports behave as expected in the //#ifdef  //endif block -- no commenting out necessary

-- thanks to skicson for suggesting the obvious that I missed :smileywink:

 

It's a simple task, usually, and this workaround is fine, but this kind of says "I don't know the guts of my rig" if you know what I mean...

 

if preprocessor ifdef/endif blocks (in methods, etc) are not commented out eclipse whines...  Are we missing a simple global setting in eclipse/plugin?

 

anyone from RIM out there?  :smileyhappy:  

 

Peace,

Dan

Please use plain text.