Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » saving properties
saving properties [message #287419] Wed, 29 June 2005 14:58 Go to next message
Eclipse UserFriend
Is there a simple way to store the propoerties of a fileand or a project
so that they are persistent and will be deleted when the matching resource
is deleted. I can use IPrefrenceStore but that seems to be one huge store
per worksheet. I looking for something at the IProject and IFile level (or
Iresource)
Re: saving properties [message #287422 is a reply to message #287419] Wed, 29 June 2005 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Charles Godwin" <charles.godwin@ca.com> wrote in message
news:44731074daf995d85d02fc75e97f61a7$1@www.eclipse.org...
> Is there a simple way to store the propoerties of a fileand or a project
> so that they are persistent and will be deleted when the matching resource
> is deleted. I can use IPrefrenceStore but that seems to be one huge store
> per worksheet. I looking for something at the IProject and IFile level (or
> Iresource)


IEclipsePreferences is what you want to use, at least for projects.

Take a look at
http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform -core-home/documents/user_settings/faq.html
for detailed info on how to use it.

For file properties, I assume the answer is
IResource.setPersistentProperty(), but I have not personally used it. I'd
start by searching for uses of that method within Eclipse, to see if it is
used in the way you expect.
Re: saving properties [message #287424 is a reply to message #287419] Wed, 29 June 2005 15:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chaves-do-not-spam.inf.ufsc.br

IResource.setPersistentProperty() is what you want.
Re: saving properties [message #287427 is a reply to message #287424] Wed, 29 June 2005 15:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

That is good only if you do not need to move between workspaces.
Persistent properties are not transferred. The project properties that
were mentioned in a previous append can be moved between workspaces
because the .settings directory in the project can be moved with the
project.

Rafael Chaves wrote:
> IResource.setPersistentProperty() is what you want.
>

--
Thanks,
Rich Kulp
Re: saving properties [message #287924 is a reply to message #287422] Fri, 08 July 2005 07:29 Go to previous messageGo to next message
Eclipse UserFriend
Walter

Thanks for this link. But... I found the example a little thin. It has
code for all the needed methods #get #put etc. but these methods don't do
anything (if you exclude the //TODO lines) There is no code describing
what to actually do to store the values to a physical (on-disk) resource.
Re: saving properties [message #287957 is a reply to message #287924] Fri, 08 July 2005 19:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Charles Godwin" <charles.godwin@ca.com> wrote in message
news:74e1fe02f7af2f21a28be33bbca2a85a$1@www.eclipse.org...
> Walter
>
> Thanks for this link. But... I found the example a little thin. It has
> code for all the needed methods #get #put etc. but these methods don't do
> anything (if you exclude the //TODO lines) There is no code describing
> what to actually do to store the values to a physical (on-disk) resource.

Are we looking at the same document? When I click on the link in my post,
the document I see does not have any //TODO lines in it. The doc is dated
Jan 19, 2005 (at the top of the page).

But anyway:

When you do the IEclipsePreferences.put(), it writes to the disk for you.
In other words, you do *not* have to do any file i/o yourself; the
infrastructure handles it all for you. The code examples are complete.

For a project-scoped preference, it writes to a file in [project]/.settings.
The name of the file is determined by the "qualifier" you pass in to
context.getNode(). For a workspace-scoped preference, it writes somewhere
under .metadata; I don't know where.
Re: saving properties [message #288118 is a reply to message #287957] Tue, 12 July 2005 11:23 Go to previous messageGo to next message
Eclipse UserFriend
Walter

The article at this link
http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform -core-home/documents/user_settings/faq.html
is dated January and it is comprehensive. I have worked with the
predefined scopes of Default, Instance, configuration and project. They
all work properly and magically.

My problem is I want to add a File level scope which is not predefined. If
you scroll to the end of the article, you'll see this:

How do I extend the preferences and add my own scope?

1. Extend the org.eclipse.core.runtime.preferences extension point.

<extension point="org.eclipse.core.runtime.preferences">
<scope name="myScope" class="com.example.preferences.MyScope"/>
</extension>

2. Have your class implement IScope and IEclipsePreferences.

public class MyScope implements IScope, IEclipsePreferences {
...
}

Here is an example plug-in which creates a new scope.

clicking on the "example" link provides a zip file of an extension
example. The source in this zip file named preferencessrc.zip dated
1/19/2005 contains a file named ServerScope.java with the same date. This
is the file with only //TODO in it.
Re: saving properties [message #288131 is a reply to message #288118] Tue, 12 July 2005 13:09 Go to previous message
Eclipse UserFriend
Originally posted by: bob.objfac.com

The article seems to be missing the Listeners part. Is there an updated
version?

Bob Foster
http://xmlbuddy.com/

Charles Godwin wrote:
> Walter
>
> The article at this link
> http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform -core-home/documents/user_settings/faq.html
>
> is dated January and it is comprehensive. I have worked with the
> predefined scopes of Default, Instance, configuration and project. They
> all work properly and magically.
>
> My problem is I want to add a File level scope which is not predefined.
> If you scroll to the end of the article, you'll see this:
>
> How do I extend the preferences and add my own scope?
>
> 1. Extend the org.eclipse.core.runtime.preferences extension point.
>
> <extension point="org.eclipse.core.runtime.preferences">
> <scope name="myScope" class="com.example.preferences.MyScope"/>
> </extension>
> 2. Have your class implement IScope and IEclipsePreferences.
>
> public class MyScope implements IScope, IEclipsePreferences {
> ...
> }
> Here is an example plug-in which creates a new scope.
>
> clicking on the "example" link provides a zip file of an extension
> example. The source in this zip file named preferencessrc.zip dated
> 1/19/2005 contains a file named ServerScope.java with the same date.
> This is the file with only //TODO in it.
>
Previous Topic:[PDE] PopUp Menu
Next Topic:Installing plug-ins in a place separate from the platform
Goto Forum:
  


Current Time: Sun Nov 09 17:19:32 EST 2025

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

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

Back to the top