Skip to main content



      Home
Home » Newcomers » Newcomers » Access Persistent Property value out side of PropertyPage
Access Persistent Property value out side of PropertyPage [message #138064] Fri, 17 February 2006 07:16 Go to next message
Eclipse UserFriend
Originally posted by: zhengxie.ie.ibm.com

I have used the new plugin wizard creatd a plugin with property dialog ( a
subclass of PropertyPage), in it I use the following code to persist a
property.

public class MyPropertyPage extends PropertyPage {

.....
public boolean performOk() {
// store the value in the outputSqlFile text field
try {
((IResource) getElement()).setPersistentProperty(
new
QualifiedName(Platform.getBundle("com.myPlugin").getSymbolicName(),
OUTPUT_SQL_FILE_PROPERTY),
outputSqlFileText.getText());

} catch (CoreException e) {
return false;
}
return true;
}

I need to get the persistent property value outside of MyPorpertyPage,
because the value needs to be available even the user does not open the
properties dialog. How can I do it?

I have searched eclipse help, it says "Persistent properties are used to
store resource-specific information on disk. The value of a persistent
property is an arbitrary string. Your plug-in decides how to interpret the
string. The strings are intended to be short (under 2KB). "

But how do I access the property persisted on the PropertyPage, from
outside of the PropertyPage class?

Thanks a million.

Jenny
Re: Access Persistent Property value out side of PropertyPage [message #697938 is a reply to message #138064] Mon, 18 July 2011 08:22 Go to previous messageGo to next message
Eclipse UserFriend
Hello,
I have the same problem.
Does anyone have a possible solution to this?

Thanks
Re: Access Persistent Property value out side of PropertyPage [message #697949 is a reply to message #697938] Mon, 18 July 2011 08:49 Go to previous messageGo to next message
Eclipse UserFriend
On 18.07.2011 14:22, forums-noreply@eclipse.org wrote:
> Hello,
> I have the same problem. Does anyone have a possible solution to this?
The properties are stored with the bundle. No need to be inside a
property page do access them.

Dani
>
> Thanks
Re: Access Persistent Property value out side of PropertyPage [message #697954 is a reply to message #697949] Mon, 18 July 2011 09:11 Go to previous messageGo to next message
Eclipse UserFriend
Dani Megert wrote on Mon, 18 July 2011 08:49
On 18.07.2011 14:22, forums-noreply@eclipse.org wrote:
> Hello,
> I have the same problem. Does anyone have a possible solution to this?
The properties are stored with the bundle. No need to be inside a
property page do access them.

Dani
>
> Thanks

Thank you for the answer!
But now I have to ask you how can I access the bundle, because I wasn't able to find anywhere.
Re: Access Persistent Property value out side of PropertyPage [message #697985 is a reply to message #697954] Mon, 18 July 2011 09:21 Go to previous messageGo to next message
Eclipse UserFriend
On 18.07.2011 15:11, forums-noreply@eclipse.org wrote:
> Dani Megert wrote on Mon, 18 July 2011 08:49
>> On 18.07.2011 14:22, forums-noreply@eclipse.org wrote:
>> > Hello,
>> > I have the same problem. Does anyone have a possible solution to this?
>> The properties are stored with the bundle. No need to be inside a
>> property page do access them.
>>
>> Dani
>> >
>> > Thanks
>
> Thank you for the answer!
> But now I have to ask you how can I access the bundle, because I
> wasn't able to find anywhere.
Platform.getBundle("com.myPlugin")

Dani
Re: Access Persistent Property value out side of PropertyPage [message #698025 is a reply to message #697985] Mon, 18 July 2011 12:07 Go to previous messageGo to next message
Eclipse UserFriend
I still have some problem:

Now I set the property in the PropertyPage like this:
((IResource) getElement()).setPersistentProperty(
					new 
					QualifiedName(Platform.getBundle("org.eclipse.emailrecommender").getSymbolicName(), 
					"MAIL_LIST"),
					MailingList.listToString(arrayMailingList));


and I try to access like this:
Bundle b=Platform.getBundle("org.eclipse.emailrecommender");
		BundleContext bc = b.getBundleContext();
		String s=bc.getProperty(Platform.getBundle("org.eclipse.emailrecommender").getSymbolicName());

but I get a NullPointerException at b.getBundleContext();
Re: Access Persistent Property value out side of PropertyPage [message #698328 is a reply to message #698025] Tue, 19 July 2011 05:21 Go to previous messageGo to next message
Eclipse UserFriend
On 18.07.2011 18:07, forums-noreply@eclipse.org wrote:
> I still have some problem:
> Now I set the property in the PropertyPage like this:
>
> ((IResource) getElement()).setPersistentProperty(
> new
> QualifiedName(Platform.getBundle("org.eclipse.emailrecommender").getSymbolicName(),
> "MAIL_LIST"),
> MailingList.listToString(arrayMailingList));
> and I try to access like this:
>
> Bundle b=Platform.getBundle("org.eclipse.emailrecommender");
> BundleContext bc = b.getBundleContext();
> String
> s=bc.getProperty(Platform.getBundle("org.eclipse.emailrecommender").getSymbolicName());
>
> but I get a NullPointerException at b.getBundleContext();
This either means you have a typo in the bundle name or the bundle
cannot be found.

Dani
Re: Access Persistent Property value out side of PropertyPage [message #698330 is a reply to message #698328] Tue, 19 July 2011 05:28 Go to previous message
Eclipse UserFriend
I solved my problem with this:
IProject[] projects=ResourcesPlugin.getWorkspace().getRoot().getProjects();
for(IProject prj :projects){
    String property=prj.getPersistentProperty(PROPERTY_NAME);
}


And I can get all the projects which has my property set!
(It's more or less what I wanted)

Thanks Dani for the help!
Previous Topic:Suggest a best open source GUI design plugin for eclipse
Next Topic:Making Java docs for Eclipse Foundation software work offline in Eclipse IDE
Goto Forum:
  


Current Time: Thu May 08 11:15:28 EDT 2025

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

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

Back to the top