Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » What is best way to set a property outside RCP application for use by the RCP ap
What is best way to set a property outside RCP application for use by the RCP ap [message #453297] Tue, 25 July 2006 15:22 Go to next message
Bill Blalock is currently offline Bill BlalockFriend
Messages: 119
Registered: July 2009
Location: Alabama
Senior Member
What is the best way to set a property outside of an RCP application for
use by the RCP application? Eclipse 3.2, Windows XP, Java 1.4.2 is the
environment.

In this case I want to specify a folder for the RCP application to use. I
don't want to hard code it. The RCP user doesn't need to see or change
it. After the RCP is installed (in a shared install environment) the
property value will rarely change.

Can the Preferences class be used in this case? That is, can a
preference/property which will be accessed by the Preference class be set
outside of the RCP application? In an .ini file perhaps?

Is there a way to set it up as an Eclipse preference but set it outside of
Eclipse?

AbstractPreferenceInitializer doesn't seem to directly support this. One
could extend this class, create a Java Property object and read the value
through it. Is there any better facility built into Eclipse?

Using an environment variable would work.

Using System.property doesn't seem advisable.

Does anyone have any suggestions? I would appreciate a code snippet or
explanation of how to read the preference/property.

Thanks all
BillB
Re: What is best way to set a property outside RCP application for use by the RCP ap [message #453337 is a reply to message #453297] Wed, 26 July 2006 14:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dittmar.steiner.web.de

Bill Blalock schrieb:
> What is the best way to set a property outside of an RCP application for
> use by the RCP application? Eclipse 3.2, Windows XP, Java 1.4.2 is the
> environment.
>
> In this case I want to specify a folder for the RCP application to use.
> I don't want to hard code it. The RCP user doesn't need to see or
> change it. After the RCP is installed (in a shared install environment)
> the property value will rarely change.
>
> Can the Preferences class be used in this case? That is, can a
> preference/property which will be accessed by the Preference class be
> set outside of the RCP application? In an .ini file perhaps?
>
> Is there a way to set it up as an Eclipse preference but set it outside
> of Eclipse?
> AbstractPreferenceInitializer doesn't seem to directly support this.
> One could extend this class, create a Java Property object and read the
> value through it. Is there any better facility built into Eclipse?
>
> Using an environment variable would work.
>
> Using System.property doesn't seem advisable.
>
> Does anyone have any suggestions? I would appreciate a code snippet or
> explanation of how to read the preference/property.
>
> Thanks all
> BillB
>
>
>
Hi Bill,

the simplest way is to put the value as a VM argument in the config.ini.
This can be done through the dialog input of "sth.product/Launcher/Launching Arguments/VM Arguments".

Also possible is the use of org.eclipse.core.variables valueVariable. (just ignore the use of a initializer class)
This makes it part of the plugin, maintainable through updates and independent of any launcher.

Or put a configuration file in your plugin's class path and use getClass().getResourceAsStream() (which i personally don't like)

regards
Dittmar


--
Quidquid latine dictum sit, altum sonatur.
- Whatever is said in Latin sounds profound.
Re: What is best way to set a property outside RCP application for use by the RCP ap [message #453366 is a reply to message #453337] Thu, 27 July 2006 16:10 Go to previous messageGo to next message
Bill Blalock is currently offline Bill BlalockFriend
Messages: 119
Registered: July 2009
Location: Alabama
Senior Member
Dittmar Steiner wrote:

> Bill Blalock schrieb:
>> What is the best way to set a property outside of an RCP application for
>> use by the RCP application? Eclipse 3.2, Windows XP, Java 1.4.2 is the
>> environment.
>>
>> In this case I want to specify a folder for the RCP application to use.
>> I don't want to hard code it. The RCP user doesn't need to see or
>> change it. After the RCP is installed (in a shared install environment)
>> the property value will rarely change.
>>
>> Can the Preferences class be used in this case? That is, can a
>> preference/property which will be accessed by the Preference class be
>> set outside of the RCP application? In an .ini file perhaps?
>>
>> Is there a way to set it up as an Eclipse preference but set it outside
>> of Eclipse?
>> AbstractPreferenceInitializer doesn't seem to directly support this.
>> One could extend this class, create a Java Property object and read the
>> value through it. Is there any better facility built into Eclipse?
>>
>> Using an environment variable would work.
>>
>> Using System.property doesn't seem advisable.
>>
>> Does anyone have any suggestions? I would appreciate a code snippet or
>> explanation of how to read the preference/property.
>>
>> Thanks all
>> BillB
>>
>>
>>
> Hi Bill,

> the simplest way is to put the value as a VM argument in the config.ini.
> This can be done through the dialog input of "sth.product/Launcher/Launching
Arguments/VM Arguments".

> Also possible is the use of org.eclipse.core.variables valueVariable. (just
ignore the use of a initializer class)
> This makes it part of the plugin, maintainable through updates and
independent of any launcher.

> Or put a configuration file in your plugin's class path and use
getClass().getResourceAsStream() (which i personally don't like)

> regards
> Dittmar

Thank you Dittmar:

> the simplest way is to put the value as a VM argument in the config.ini

How would the program access the data in this case? A snippet would be
very helpful.

> Also possible is the use of org.eclipse.core.variables valueVariable

Could you explain this or point me to some documentation?

Again, thanks for your time and help.
Re: What is best way to set a property outside RCP application for use by the RCP ap [message #453405 is a reply to message #453366] Fri, 28 July 2006 13:37 Go to previous message
Eclipse UserFriend
Originally posted by: dittmar.steiner.web.de

Bill Blalock schrieb:
> Dittmar Steiner wrote:
>
>> Bill Blalock schrieb:
>>> What is the best way to set a property outside of an RCP application
>>> for use by the RCP application? Eclipse 3.2, Windows XP, Java 1.4.2
>>> is the environment.
>>>
>>> In this case I want to specify a folder for the RCP application to
>>> use. I don't want to hard code it. The RCP user doesn't need to see
>>> or change it. After the RCP is installed (in a shared install
>>> environment) the property value will rarely change.
>>>
>>> Can the Preferences class be used in this case? That is, can a
>>> preference/property which will be accessed by the Preference class be
>>> set outside of the RCP application? In an .ini file perhaps?
>>>
>>> Is there a way to set it up as an Eclipse preference but set it
>>> outside of Eclipse?
>>> AbstractPreferenceInitializer doesn't seem to directly support this.
>>> One could extend this class, create a Java Property object and read
>>> the value through it. Is there any better facility built into Eclipse?
>>>
>>> Using an environment variable would work.
>>>
>>> Using System.property doesn't seem advisable.
>>>
>>> Does anyone have any suggestions? I would appreciate a code snippet
>>> or explanation of how to read the preference/property.
>>>
>>> Thanks all
>>> BillB
>>>
>>>
>>>
>> Hi Bill,
>
>> the simplest way is to put the value as a VM argument in the config.ini.
>> This can be done through the dialog input of
>> "sth.product/Launcher/Launching
> Arguments/VM Arguments".
>
>> Also possible is the use of org.eclipse.core.variables valueVariable.
>> (just
> ignore the use of a initializer class)
>> This makes it part of the plugin, maintainable through updates and
> independent of any launcher.
>
>> Or put a configuration file in your plugin's class path and use
> getClass().getResourceAsStream() (which i personally don't like)
>
>> regards
>> Dittmar
>
> Thank you Dittmar:
>
>> the simplest way is to put the value as a VM argument in the config.ini
>
> How would the program access the data in this case? A snippet would be
> very helpful.
>
>> Also possible is the use of org.eclipse.core.variables valueVariable
>
> Could you explain this or point me to some documentation?
>
> Again, thanks for your time and help.

Hi Bill,

* sorry, it's NOT the config.ini, it's the <yourproduct>.ini
-vmargs
-Dmy.varialble.name=myValue <- don't for get the D!
-D... <- each arg a new line

String val = System.getProperty("myProperty");

Also accessible through <yourproduct>.product "Launcher/Launching Arguments/VM Arguments" dialog. The ini file will be created
then automatically. Does not work for pure plugins.


* Value Variables (my prefered solution, works for products and plugins):
String val = null;
IValueVariable var = VariablesPlugin.getDefault()
.getStringVariableManager().getValueVariable("my.varialble.name ");
if (var != null)
val = var.getValue();

plugin.xml:
<extension
point="org.eclipse.core.variables.valueVariables">
<variable
description="My Property"
initialValue="myValue"
name="my.varialble.name"/>
</extension>

hope this answeres you questions.
Dittmar
Previous Topic:Ecllipse Application Launcher
Next Topic:adding files and values to concerned folder of tree in eclipse rcp
Goto Forum:
  


Current Time: Wed Oct 09 03:06:23 GMT 2024

Powered by FUDForum. Page generated in 0.04571 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top